Most recent edit on 2005-05-12 07:45:17 by JosselinJaffres
Additions:
You could also use the Plugin∞ if you don't have modified the functions below.
Vous pouvez aussi utiliser le Plugin∞ si vous n'avez pas fait de modifications dans les fonctions ci-dessous.
Edited on 2005-04-24 08:29:44 by JosselinJaffres
Additions:
$GLOBALS['_PX_render']['m']->lres = $GLOBALS['_PX_render']['m']->getResources($category, , $type, 'DESC', $GLOBALS['_PX_render']['datestart'], $GLOBALS['_PX_render']['dateend'] );
Deletions:
$GLOBALS['_PX_render']['m']->lres = $GLOBALS['_PX_render']['m']->getResources($category, , $type, , $GLOBALS['_PX_render']['datestart'], $GLOBALS['_PX_render']['dateend'] );
Edited on 2005-04-24 08:23:50 by JosselinJaffres
Additions:
function pxMonthsList($homepage=false,$block='<ul>%s</ul>',$item='<li>%s</li>')
$arry_months = $GLOBALS['_PX_render']['m']->getArrayMonths(/* All the types */, $GLOBALS['_PX_render']['resource']['category_id'], $homepage);
function getArrayMonths($type=, $cat_id=
, $homepage=false)
if ($homepage)
Vous n'avez qu'a insérer cette ligne dans vos gabarits pour voir tous les mois où des ressources ont été publiées pour cette catégorie.
If you want to display the months where resources have been publicated without take in order the category (for the homepage by example), use this.
Si vous voulez afficher les mois où des ressources ont été publiées sans tenir compte de la catégorie courante (pour la page d'accueil par exemple), utilisez ceci.
<?php pxMonthsList(true) ?>
Deletions:
function pxMonthsList($block='<ul>%s</ul>',$item='<li>%s</li>')
$arry_months = $GLOBALS['_PX_render']['m']->getArrayMonths(/* All the types */, $GLOBALS['_PX_render']['resource']['category_id'], false);
function getArrayMonths($type=, $cat_id=
, $addalldates=true)
if (($cat_id
1) || ($cat_id
"/"))
if ($addalldates)
$arry_months[ ('All the dates')] = 'alldate';
Vous n'avez qu'a insérer cette ligne dans vos gabarits pour que cela fonctionne.
Edited on 2005-04-24 08:08:12 by JosselinJaffres
Additions:
Change the function pxGetLastResources for this one.
Changer la fonction pxGetLastResources pour celle ci.
function pxGetLastResources($limit = 5, $type = , $category = ) {
if (!empty($GLOBALS['_PX_render']['datestart'])) {
$GLOBALS['_PX_render']['m']->lres = $GLOBALS['_PX_render']['m']->getResources($category, , $type, , $GLOBALS['_PX_render']['datestart'], $GLOBALS['_PX_render']['dateend'] );
}else{
$GLOBALS['_PX_render']['m']->lres = $GLOBALS['_PX_render']['m']->getResources($category, $limit, $type);
if (!empty($GLOBALS['_PX_render']['datestart'])) {
Deletions:
if (!empty($datestart)) {
Edited on 2005-04-24 05:06:35 by JosselinJaffres
No differences.
Edited on 2005-04-23 19:44:51 by JosselinJaffres
Additions:
I've noticed a bug in the initialization of the renderUser. In the file /manager/class.rendermanager.php you have to change, in the function renderUser(), this line.
Cependant, j'ai pu constater un petit problème lors de l'initialisation du renderUser. Dans le fichier /manager/class.rendermanager.php vous devez donc changer dans la fonction renderUser() cette ligne.
Deletions:
I've noticed a bug in the initialization of the renderUser. In the file /manager/class.rendermanager.php you have to change, in the function "RenderUser()", this line.
Cependant, j'ai pu constater un petit problème lors de l'initialisation du renderUser. Dans le fichier /manager/class.rendermanager.php vous devez donc changer dans la fonction "RenderUser()" cette ligne.
Edited on 2005-04-23 19:44:26 by JosselinJaffres
Additions:
I've noticed a bug in the initialization of the renderUser. In the file /manager/class.rendermanager.php you have to change, in the function "RenderUser()", this line.
Cependant, j'ai pu constater un petit problème lors de l'initialisation du renderUser. Dans le fichier /manager/class.rendermanager.php vous devez donc changer dans la fonction "RenderUser()" cette ligne.
Deletions:
I've noticed a bug in the initialization of the renderUser. In the file /manager/class.rendermanager.php you have to change, in the function RenderUser(), this line.
Cependant, j'ai pu constater un petit problème lors de l'initialisation du renderUser. Dans le fichier /manager/class.rendermanager.php vous devez donc changer dans la fonction RenderUser() cette ligne.
Edited on 2005-04-23 19:43:06 by JosselinJaffres
Additions:
You just have to put this line in your template to make this work.
Vous n'avez qu'a insérer cette ligne dans vos gabarits pour que cela fonctionne.
Now you just have to complete your traduction file with the month's name.
Maintenant, il ne vous reste plus qu'a compléter votre fichier de localisation avec le nom des mois.
I've noticed a bug in the initialization of the renderUser. In the file /manager/class.rendermanager.php you have to change, in the function RenderUser(), this line.
Cependant, j'ai pu constater un petit problème lors de l'initialisation du renderUser. Dans le fichier /manager/class.rendermanager.php vous devez donc changer dans la fonction RenderUser() cette ligne.
$this->lang = ;
For this one.
Par celle ci.
$this->lang = $GLOBALS['_PX_config']['lang'];
Deletions:
Now you just have to put this line in your template to make this work.
Maintenant vous n'avez qu'a insérer cette ligne dans vos gabarits pour que cela fonctionne.
Il ne vous reste plus qu'a compléter votre
Edited on 2005-04-23 19:35:40 by JosselinJaffres
Additions:
Template/Gabarits
Now you just have to put this line in your template to make this work.
Maintenant vous n'avez qu'a insérer cette ligne dans vos gabarits pour que cela fonctionne.
<?php pxMonthsList() ?>
Localisation
Il ne vous reste plus qu'a compléter votre
Edited on 2005-04-23 19:30:33 by JosselinJaffres
No differences.
Edited on 2005-04-23 19:29:18 by JosselinJaffres
Additions:
You will need to edit several files, so it could be a good idea to save your sources first.
Change the function px_getResources for this one.
Changer la fonction px_getResources pour celle ci.
Deletions:
You will need to edit several files, so it could be a good idea to save your data first.
Edited on 2005-04-23 19:28:19 by JosselinJaffres
Additions:
pour celle ci
function px_getResources($category=, $limit = 10, $type = , $order = 'DESC', $datestart=, $dateend=)
global $_PX_website_config, $_PX_config;
if (empty($GLOBALS['_PX_render']['m']->res)) {
$GLOBALS['_PX_render']['m']->res = $GLOBALS['_PX_render']['m']->getResources($category, $limit, $type, $order, $datestart, $dateend);
$GLOBALS['_PX_render']['m']->res->move(($GLOBALS['_PX_render']['resource']['page'] - 1) * $GLOBALS['_PX_render']['m']->
NbResPerPage);
if (!empty($datestart)) {
$GLOBALS['_PX_render']['m']->res->int_row_count = $GLOBALS['_PX_render']['m']->res->int_row_count_total;
} elseif ($GLOBALS['_PX_render']['m']->res->int_row_count > ($GLOBALS['_PX_render']['resource']['page'] * $GLOBALS['_PX_render']['m']->
NbResPerPage)) {
$GLOBALS['_PX_render']['m']->res->int_row_count = $GLOBALS['_PX_render']['resource']['page'] * $GLOBALS['_PX_render']['m']->
NbResPerPage;
Edited on 2005-04-23 19:26:25 by JosselinJaffres
No differences.
Edited on 2005-04-23 19:25:26 by JosselinJaffres
Additions:
In the function pxTemplateInit, change this line
Dans la fonction pxTemplateInit, changer cette ligne
px_getResources($GLOBALS['_PX_render']['resource']['category_id'], , , $order );
for this one
px_getResources($GLOBALS['_PX_render']['resource']['category_id'], , , $order , $GLOBALS['_PX_render']['datestart'], $GLOBALS['_PX_render']['dateend'] );
Edited on 2005-04-23 19:22:10 by JosselinJaffres
Additions:
Change the function parseQuery for this one.
Changer la fonction parseQuery pour celle ci.
function parseQuery($query)
$query = preg_replace( '#^(/)+#', '/', $query);
$category = $resource = $page = $mode =
;
if (preg_match('#^(.*/)(index)([0-9]*)$#i', $query, $match)) {
$category = $match[1];
$page = ($match[3]) ? (int) $match[3] : 1;
$mode = 'cat';
} elseif (preg_match('#^(/([A-Za-z][A-Za-z0-9_-]*/)*)(([0-9]{4}/[0-9]{2})(/|\z))?$#i', $query, $match)) {
$category = $match[1];
$page = 1;
$mode = 'cat';
if (preg_match('#^(/([A-Za-z][A-Za-z0-9_-]*/)*)(([0-9]{4}/[0-9]{2})(/|\z))$#i', $query, $match)) {
$date_ = (int)(substr($match[4],0,4).substr($match[4],5,2));
}
} elseif (preg_match('#^(.*/)([a-z]|[a-z][a-z0-9\_\-]*[a-z])(\d*)$#i', $query, $match)) {
$category = $match[1];
$resource = $match[2];
$page = ($match[3]) ? (int)$match[3] : 1;
$mode = 'art';
} elseif (preg_match('#^(.*/)(\d+)\-([^\.]*)$#i', $query, $match)) {
$category = $match[1];
$resource = $match[2];
$mode = 'news';
} else {
$category = '/';
$mode = 'cat';
$page = 1;
return array('category' => $category, 'resource' => $resource, 'page' => $page, 'mode' => $mode, 'date' => $date_);
Edited on 2005-04-23 19:01:40 by JosselinJaffres
Additions:
/manager/frontinc/class.template.php
Edited on 2005-04-23 19:00:39 by JosselinJaffres
No differences.
Edited on 2005-04-23 18:59:41 by JosselinJaffres
Additions:
Add this 2 lines in the function render(), when initializing variables (line 132).
Ajouter ces 2 lignes dans la fonction render(), au niveau de l'initialisation des variables (ligne 132).
$GLOBALS['_PX_render']['datestart'] = (!empty($this->parsed_query['date'])) ? timestamp(0,0,0,maketime($this->parsed_query['date'])) : ;
$GLOBALS['_PX_render']['dateend'] = (!empty($this->parsed_query['date'])) ? timestamp(0,1,0,maketime($this->parsed_query['date'])) : ;
Edited on 2005-04-23 18:55:54 by JosselinJaffres
Additions:
Change the function getCacheId for this one. (Not very sure it's necessary to work ...)
Changer la fonction getCacheId pour celle ci. (Pas sur que ce soit nécessaire pour que ça marche ...)
Deletions:
Change the function getCacheId for this one.
Changer la fonction getCacheId pour celle ci.
Oldest known version of this page was edited on 2005-04-23 18:55:04 by JosselinJaffres []
Page view:
Archive the resources by month
You will need to edit several files, so it could be a good idea to save your data first.
Archiver les ressources par mois
Vous allez devoir éditer plusieurs fichiers, aussi je vous conseille de faire une sauvegarde de vos sources avant de commencer.
/manager/frontinc/class.rendermanager.php
Add this fonction in the renderManager class.
Ajouter cette fonction dans la classe renderManager.
/**
@param string type of resource
@param int category id
@param bool (true) add the all dates choice (true by default!!!)
@return array($first, $last, array of months + year)
*/
function getArrayMonths
($type=
'',
$cat_id=
'',
$addalldates=
true)
{
$arry_months =
array();
if (($cat_id==
1) ||
($cat_id ==
"/"))
$cat_id =
'';
if ($addalldates)
$arry_months[ __
('All the dates')] =
'alldate';
//getAllDates returns the values in time DESC order
foreach ($this->
getAllDates('m',
$type,
$cat_id) as $k =>
$v) {
$arry_months[makeTime
($k)] =
date("Y-m-01",makeTime
($k));
}
return $arry_months;
}
Change the function getResources for this one.
Changer la fonction getResources pour celle ci.
function getResources
($category=
'',
$limit =
10,
$type =
'',
$order =
'DESC',
$datestart=
'',
$dateend=
'')
{
include_once dirname(__FILE__).
'/../inc/class.resource.php';
$this->
getDB();
return parent::
getResources('', PX_RESOURCE_STATUS_VALIDE,
$category,
$type,
$datestart,
$dateend,
$limit,
$order,
true);
}
/manager/frontinc/functions.php
Add this fonction.
Ajouter cette fonction.
/**
@function pxMonthsList
Cette fonction affiche la liste des mois contenant les archives.
Si on se trouve dans une catégorie, seuls les mois de cette catégorie
seront affichés.
@param string block Chaine de substitution pour pour la liste ('<ul>%s</ul>')
@param string item Chaine de substitution pour un élément ('<li>%s</li>')
*/
function pxMonthsList
($block=
'<ul>%s</ul>',
$item=
'<li>%s</li>')
{
global $_PX_website_config,
$_PX_config,
$_PX_render,
$month,
$year,
$cat_id,
$blog;
$s =
($_PX_website_config['secure']) ?
's' :
'';
$arry_months =
$GLOBALS['_PX_render']['m']->
getArrayMonths(''/* All the types */,
$GLOBALS['_PX_render']['resource']['category_id'],
false);
foreach($arry_months as $ts =>
$d)
{
$titre = dt::
str('%B %Y',
$ts);
$url =
sprintf('http'.
$s.
'://'.
$_PX_website_config['domain'].
$_PX_website_config['rel_url'].
$GLOBALS['_PX_render']['parsed_query']['category'].
'%s/%s',
date('Y',
$ts),
date('m',
$ts));
$lien =
'<a href="'.
$url.
'">%s</a>';
$liClass =
'';
if($year ==
date('Y',
$ts) &&
$month ==
date('m',
$ts)) {
$lien =
'<strong>'.
$lien.
'</strong>';
}
$res .=
sprintf($item,
sprintf($lien,
$titre));
}
if (count($arry_months) >
0) {
printf($block,
$res);
}
}
Change the function getCacheId for this one.
Changer la fonction getCacheId pour celle ci.
function getCacheId
($res,
$website=
array())
{
$websiteid =
(!
empty($website['website_id'])) ?
$website['website_id'] :
$GLOBALS['_PX_website_config']['website_id'];
return md5($websiteid.
'%cat='.
$res['category'].
'%res='.
$res['resource'].
'%p='.
$res['page'].
'%mode='.
$res['mode'].
'%date='.
$res['date']);
}
/manager/inc/lib.date.php
Add this file in /manager/inc/
Rajouter ce fichier dans le répertoire /manager/inc/
<?php
class dt
{
function str
($p,
$ts=
NULL)
{
if ($ts ==
NULL) { $ts =
time();
}
$hash =
'799b4e471dc78154865706469d23d512';
$p =
preg_replace('/(?<!%)%(a|A)/',
'{{'.
$hash.
'__$1%w__}}',
$p);
$p =
preg_replace('/(?<!%)%(b|B)/',
'{{'.
$hash.
'__$1%m__}}',
$p);
$res =
strftime($p,
$ts);
$res =
preg_replace_callback('/{{'.
$hash.
'__(a|A|b|B)([0-9]{1,2})__}}/',
array('dt',
'_callback'),
$res);
return $res;
}
function dt2str
($p,
$dt)
{
return dt::
str($p,
strtotime($dt));
}
function iso8601
($ts)
{
$tz =
date('O',
$ts);
$tz =
substr($tz,
0,-
2).
':'.substr
($tz,-
2);
return date('Y-m-d\\TH:i:s',
$ts).
$tz;
}
function _callback
($args)
{
$b =
array(1=>
'Jan',
2=>
'Feb',
3=>
'Mar',
4=>
'Apr',
5=>
'May',
6=>
'Jun',
7=>
'Jul',
8=>
'Aug',
9=>
'Sep',
10=>
'Oct',
11=>
'Nov',
12=>
'Dec');
$B =
array(1=>
'January',
2=>
'February',
3=>
'March',
4=>
'April',
5=>
'May',
6=>
'June',
7=>
'July',
8=>
'August',
9=>
'September',
10=>
'October',
11=>
'November',
12=>
'December');
$a =
array(1=>
'Mon',
2=>
'Tue',
3=>
'Wed',
4=>
'Thu',
5=>
'Fri',
6=>
'Sat',
0=>
'Sun');
$A =
array(1=>
'Monday',
2=>
'Tuesday',
3=>
'Wednesday',
4=>
'Thursday',
5=>
'Friday',
6=>
'Saturday',
0=>
'Sunday');
return __
($
{$args[1]}[(integer
) $args[2]]);
}
}
?>
/manager/frontinc/prepend.php
Add this line in order to load the previous file.
Ajouter cette ligne afin de charger le fichier précédent.
include_once $_PX_config['manager_path'].'/inc/lib.date.php';