Ejemplo n.º 1
0
 /**
  * Méthode qui effectue une création ou mise a jour d'un article
  *
  * @param	content	données saisies de l'article
  * @param	&id	retourne le numero de l'article
  * @return	string
  * @author	Stephane F. et Florent MONTHEL
  **/
 public function editArticle($content, &$id)
 {
     # Détermine le numero de fichier si besoin est
     if ($id == '0000' or $id == '') {
         $id = $this->nextIdArticle();
     }
     # Vérification de l'intégrité de l'identifiant
     if (!preg_match('/^[0-9]{4}$/', $id)) {
         return 'Identifiant d\'article invalide !';
     }
     # Génération de notre url d'article
     if (trim($content['url']) == '') {
         $content['url'] = plxUtils::title2url($content['title']);
     } else {
         $content['url'] = plxUtils::title2url($content['url']);
     }
     # URL vide après le passage de la fonction ;)
     if ($content['url'] == '') {
         $content['url'] = 'nouvel-article';
     }
     # Génération du fichier XML
     $xml = "<?xml version='1.0' encoding='" . PLX_CHARSET . "'?>\n";
     $xml .= "<document>\n";
     $xml .= "\t" . '<title><![CDATA[' . trim($content['title']) . ']]></title>' . "\n";
     $xml .= "\t" . '<allow_com>' . $content['allow_com'] . '</allow_com>' . "\n";
     $xml .= "\t" . '<template><![CDATA[' . $content['template'] . ']]></template>' . "\n";
     $xml .= "\t" . '<chapo><![CDATA[' . trim($content['chapo']) . ']]></chapo>' . "\n";
     $xml .= "\t" . '<content><![CDATA[' . trim($content['content']) . ']]></content>' . "\n";
     $xml .= "\t" . '<tags><![CDATA[' . trim($content['tags']) . ']]></tags>' . "\n";
     $xml .= "</document>\n";
     # A t'on besoin de supprimer un fichier ?
     if ($globArt = $this->plxGlob_arts->query('/^' . $id . '.(.*).xml$/', '', 'sort', 0, 1, 'all')) {
         if (file_exists(PLX_ROOT . $this->aConf['racine_articles'] . $globArt['0'])) {
             # Un fichier existe, on le supprime
             @unlink(PLX_ROOT . $this->aConf['racine_articles'] . $globArt['0']);
         }
     }
     # On genère le nom de notre fichier
     $time = $content['year'] . $content['month'] . $content['day'] . substr(str_replace(':', '', $content['time']), 0, 4);
     if (!preg_match('/^[0-9]{12}$/', $time)) {
         $time = @date('YmdHi');
     }
     # Check de la date au cas ou...
     if (empty($content['catId'])) {
         $content['catId'] = array('000');
     }
     # Catégorie non classée
     $filename = PLX_ROOT . $this->aConf['racine_articles'] . $id . '.' . implode(',', $content['catId']) . '.' . trim($content['author']) . '.' . $time . '.' . $content['url'] . '.xml';
     # On va mettre à jour notre fichier
     if (plxUtils::write($xml, $filename)) {
         # mise à jour de la liste des tags
         $this->aTags[$id] = array('tags' => implode(',', array(trim($content['tags']), $this->tagsFrom($content['chapo'] . $content['content']))), 'date' => $time, 'active' => intval(!in_array('draft', $content['catId'])));
         $this->editTags();
         if ($content['artId'] == '0000' or $content['artId'] == '') {
             return plxMsg::Info('Article cr&eacute;&eacute; avec succ&egrave;s');
         } else {
             return plxMsg::Info('Article mis &agrave; jour avec succ&egrave;s');
         }
     } else {
         return plxMsg::Error('Erreur lors de la sauvegarde de l\'article');
     }
 }
Ejemplo n.º 2
0
 /**
  * Méthode qui formate un lien pour la barre des menus
  *
  * @param	name	string 			titre du menu
  * @param	href	string 			lien du menu
  * @param	title	string			contenu de la balise title
  * @param	class	string			contenu de la balise class
  * @param	onclick	string			contenu de la balise onclick
  * @param	extra	string			extra texte à afficher
  * @return			string			balise <a> formatée
  * @author	Stephane F.
  **/
 public static function formatMenu($name, $href, $title = false, $class = false, $onclick = false, $extra = '', $highlight = true)
 {
     $menu = '';
     $basename = explode('?', basename($href));
     $active = ($highlight and $basename[0] == basename($_SERVER['SCRIPT_NAME'])) ? ' active' : '';
     if ($basename[0] == 'plugin.php' and isset($_GET['p']) and $basename[1] != 'p=' . $_GET['p']) {
         $active = '';
     }
     $title = $title ? ' title="' . $title . '"' : '';
     $class = $class ? ' ' . $class : '';
     $onclick = $onclick ? ' onclick="' . $onclick . '"' : '';
     $menu = '<li id="mnu_' . plxUtils::title2url($name) . '" class="menu' . $active . $class . '"><a href="' . $href . '"' . $onclick . $title . '>' . $name . $extra . '</a></li>';
     return $menu;
 }
Ejemplo n.º 3
0
 /**
  * Méthode qui effectue une création ou mise a jour d'un article
  *
  * @param	content		données saisies de l'article
  * @param	&id			retourne le numero de l'article
  * @return	string
  * @author	Stephane F. et Florent MONTHEL
  **/
 public function editArticle($content, &$id)
 {
     # Détermine le numero de fichier si besoin est
     if ($id == '0000' or $id == '') {
         $id = $this->nextIdArticle();
     }
     # Vérification de l'intégrité de l'identifiant
     if (!preg_match('/^_?[0-9]{4}$/', $id)) {
         $id = '';
         return L_ERR_INVALID_ARTICLE_IDENT;
     }
     # Génération de notre url d'article
     if (trim($content['url']) == '') {
         $content['url'] = plxUtils::title2url($content['title']);
     } else {
         $content['url'] = plxUtils::title2url($content['url']);
     }
     # URL vide après le passage de la fonction ;)
     if ($content['url'] == '') {
         $content['url'] = L_DEFAULT_NEW_ARTICLE_URL;
     }
     # Hook plugins
     if (eval($this->plxPlugins->callHook('plxAdminEditArticle'))) {
         return;
     }
     # Génération du fichier XML
     $xml = "<?xml version='1.0' encoding='" . PLX_CHARSET . "'?>\n";
     $xml .= "<document>\n";
     $xml .= "\t" . '<title><![CDATA[' . plxUtils::cdataCheck(trim($content['title'])) . ']]></title>' . "\n";
     $xml .= "\t" . '<allow_com>' . $content['allow_com'] . '</allow_com>' . "\n";
     $xml .= "\t" . '<template><![CDATA[' . basename($content['template']) . ']]></template>' . "\n";
     $xml .= "\t" . '<chapo><![CDATA[' . plxUtils::cdataCheck(trim($content['chapo'])) . ']]></chapo>' . "\n";
     $xml .= "\t" . '<content><![CDATA[' . plxUtils::cdataCheck(trim($content['content'])) . ']]></content>' . "\n";
     $xml .= "\t" . '<tags><![CDATA[' . plxUtils::cdataCheck(trim($content['tags'])) . ']]></tags>' . "\n";
     $meta_description = plxUtils::getValue($content['meta_description']);
     $xml .= "\t" . '<meta_description><![CDATA[' . plxUtils::cdataCheck(trim($meta_description)) . ']]></meta_description>' . "\n";
     $meta_keywords = plxUtils::getValue($content['meta_keywords']);
     $xml .= "\t" . '<meta_keywords><![CDATA[' . plxUtils::cdataCheck(trim($meta_keywords)) . ']]></meta_keywords>' . "\n";
     $title_htmltag = plxUtils::getValue($content['title_htmltag']);
     $xml .= "\t" . '<title_htmltag><![CDATA[' . plxUtils::cdataCheck(trim($title_htmltag)) . ']]></title_htmltag>' . "\n";
     # Hook plugins
     eval($this->plxPlugins->callHook('plxAdminEditArticleXml'));
     $xml .= "</document>\n";
     # Recherche du nom du fichier correspondant à l'id
     $oldArt = $this->plxGlob_arts->query('/^' . $id . '.(.*).xml$/', '', 'sort', 0, 1, 'all');
     # Si demande de modération de l'article
     if (isset($content['moderate'])) {
         $id = '_' . str_replace('_', '', $id);
     }
     # Si demande de publication
     if (isset($content['publish']) or isset($content['draft'])) {
         $id = str_replace('_', '', $id);
     }
     # On genère le nom de notre fichier
     $time = $content['year'] . $content['month'] . $content['day'] . substr(str_replace(':', '', $content['time']), 0, 4);
     if (!preg_match('/^[0-9]{12}$/', $time)) {
         $time = date('YmdHi');
     }
     # Check de la date au cas ou...
     if (empty($content['catId'])) {
         $content['catId'] = array('000');
     }
     # Catégorie non classée
     $filename = PLX_ROOT . $this->aConf['racine_articles'] . $id . '.' . implode(',', $content['catId']) . '.' . trim($content['author']) . '.' . $time . '.' . $content['url'] . '.xml';
     # On va mettre à jour notre fichier
     if (plxUtils::write($xml, $filename)) {
         # suppression ancien fichier si nécessaire
         if ($oldArt) {
             $oldfilename = PLX_ROOT . $this->aConf['racine_articles'] . $oldArt['0'];
             if ($oldfilename != $filename and file_exists($oldfilename)) {
                 unlink($oldfilename);
             }
         }
         # mise à jour de la liste des tags
         $this->aTags[$id] = array('tags' => trim($content['tags']), 'date' => $time, 'active' => intval(!in_array('draft', $content['catId'])));
         $this->editTags();
         if ($content['artId'] == '0000' or $content['artId'] == '') {
             return plxMsg::Info(L_ARTICLE_SAVE_SUCCESSFUL);
         } else {
             return plxMsg::Info(L_ARTICLE_MODIFY_SUCCESSFUL);
         }
     } else {
         return plxMsg::Error(L_ARTICLE_SAVE_ERR);
     }
 }
Ejemplo n.º 4
0
 /**
  * Méthode qui édite le fichier XML des produits selon le tableau $content
  *
  * @param    content    tableau multidimensionnel des produits
  * @param    action    permet de forcer la mise àjour du fichier
  * @return    string
  * @author    David L.
  **/
 public function editProducts($content, $action = false)
 {
     $save = $this->aProds;
     # suppression
     if (!empty($content['selection']) and $content['selection'] == 'delete' and isset($content['idProduct'])) {
         foreach ($content['idProduct'] as $product_id) {
             $filename = PLX_ROOT . 'data/products/' . $product_id . '.' . $this->aProds[$product_id]['url'] . '.php';
             if (is_file($filename)) {
                 unlink($filename);
             }
             # si le produit supprimée est en page d'accueil on met à jour le parametre
             unset($this->aProds[$product_id]);
             $action = true;
         }
     } elseif (!empty($content['update'])) {
         foreach ($content['productNum'] as $product_id) {
             $stat_name = $content[$product_id . '_name'];
             if ($stat_name != '') {
                 $url = isset($content[$product_id . '_url']) ? trim($content[$product_id . '_url']) : '';
                 $stat_url = $url != '' ? plxUtils::title2url($url) : plxUtils::title2url($stat_name);
                 if ($stat_url == '') {
                     $stat_url = L_DEFAULT_NEW_PRODUCT_URL;
                 }
                 # On vérifie si on a besoin de renommer le fichier du produit
                 if (isset($this->aProds[$product_id]) and $this->aProds[$product_id]['url'] != $stat_url) {
                     $oldfilename = PLX_ROOT . 'data/products/' . $product_id . '.' . $this->aProds[$product_id]['url'] . '.php';
                     $newfilename = PLX_ROOT . 'data/products/' . $product_id . '.' . $stat_url . '.php';
                     if (is_file($oldfilename)) {
                         rename($oldfilename, $newfilename);
                     }
                 }
                 $this->aProds[$product_id]['pcat'] = trim($content[$product_id . '_pcat']);
                 $this->aProds[$product_id]['menu'] = trim($content[$product_id . '_menu']);
                 $this->aProds[$product_id]['group'] = isset($this->aProds[$product_id]['group']) ? $this->aProds[$product_id]['group'] : '';
                 $this->aProds[$product_id]['name'] = $stat_name;
                 $this->aProds[$product_id]['url'] = plxUtils::checkSite($url) ? $url : $stat_url;
                 $this->aProds[$product_id]['active'] = $content[$product_id . '_active'];
                 $this->aProds[$product_id]['ordre'] = intval($content[$product_id . '_ordre']);
                 $this->aProds[$product_id]['template'] = isset($this->aProds[$product_id]['template']) ? $this->aProds[$product_id]['template'] : $this->getParam('template');
                 $this->aProds[$product_id]['title_htmltag'] = isset($this->aProds[$product_id]['title_htmltag']) ? $this->aProds[$product_id]['title_htmltag'] : '';
                 $this->aProds[$product_id]['image'] = isset($this->aProds[$product_id]['image']) ? $this->aProds[$product_id]['image'] : '';
                 $this->aProds[$product_id]['noaddcart'] = isset($this->aProds[$product_id]['noaddcart']) ? $this->aProds[$product_id]['noaddcart'] : '';
                 $this->aProds[$product_id]['notice_noaddcart'] = isset($this->aProds[$product_id]['notice_noaddcart']) ? $this->aProds[$product_id]['notice_noaddcart'] : '';
                 $this->aProds[$product_id]['pricettc'] = isset($this->aProds[$product_id]['pricettc']) ? $this->aProds[$product_id]['pricettc'] : '';
                 $this->aProds[$product_id]['poidg'] = isset($this->aProds[$product_id]['poidg']) ? $this->aProds[$product_id]['poidg'] : '';
                 $this->aProds[$product_id]['meta_description'] = isset($this->aProds[$product_id]['meta_description']) ? $this->aProds[$product_id]['meta_description'] : '';
                 $this->aProds[$product_id]['meta_keywords'] = isset($this->aProds[$product_id]['meta_keywords']) ? $this->aProds[$product_id]['meta_keywords'] : '';
                 $action = true;
             }
         }
         # On va trier les clés selon l'ordre choisi
         if (sizeof($this->aProds) > 0) {
             uasort($this->aProds, create_function('$a, $b', 'return $a["ordre"]>$b["ordre"];'));
         }
     }
     # sauvegarde
     if ($action) {
         //var_dump($content); exit;
         $products_name = array();
         $products_url = array();
         # On génére le fichier XML
         $xml = "<?xml version=\"1.0\" encoding=\"" . PLX_CHARSET . "\"?>\n";
         $xml .= "<document>\n";
         if (isset($this->aProds) && is_array($this->aProds)) {
             foreach ($this->aProds as $product_id => $product) {
                 # control de l'unicité du titre de la page
                 if (in_array($product['name'], $products_name)) {
                     return plxMsg::Error(L_ERR_PRODUCT_ALREADY_EXISTS . ' : ' . plxUtils::strCheck($product['name']));
                 } else {
                     $products_name[] = $product['name'];
                 }
                 # control de l'unicité de l'url de la page
                 if (in_array($product['url'], $products_url)) {
                     $this->aProds = $save;
                     return plxMsg::Error(L_ERR_URL_ALREADY_EXISTS . ' : ' . plxUtils::strCheck($product['url']));
                 } else {
                     $products_url[] = $product['url'];
                 }
                 $xml .= "\t<product number=\"" . $product_id . "\" active=\"" . $product['active'] . "\" url=\"" . $product['url'] . "\" template=\"" . basename($product['template']) . "\">";
                 $xml .= "<pcat><![CDATA[" . plxUtils::cdataCheck($product['pcat']) . "]]></pcat>";
                 $xml .= "<menu><![CDATA[" . plxUtils::cdataCheck($product['menu']) . "]]></menu>";
                 $xml .= "<group><![CDATA[" . plxUtils::cdataCheck($product['group']) . "]]></group>";
                 $xml .= "<name><![CDATA[" . plxUtils::cdataCheck($product['name']) . "]]></name>";
                 $xml .= "<image><![CDATA[" . plxUtils::cdataCheck($product['image']) . "]]></image>";
                 $xml .= "<noaddcart><![CDATA[" . plxUtils::cdataCheck($product['noaddcart']) . "]]></noaddcart>";
                 $xml .= "<notice_noaddcart><![CDATA[" . plxUtils::cdataCheck($product['notice_noaddcart']) . "]]></notice_noaddcart>";
                 $xml .= "<pricettc><![CDATA[" . plxUtils::cdataCheck($product['pricettc']) . "]]></pricettc>";
                 $xml .= "<poidg><![CDATA[" . plxUtils::cdataCheck($product['poidg'] == 0 ? "0.0" : $product['poidg']) . "]]></poidg>";
                 $xml .= "<meta_description><![CDATA[" . plxUtils::cdataCheck($product['meta_description']) . "]]></meta_description>";
                 $xml .= "<meta_keywords><![CDATA[" . plxUtils::cdataCheck($product['meta_keywords']) . "]]></meta_keywords>";
                 $xml .= "<title_htmltag><![CDATA[" . plxUtils::cdataCheck($product['title_htmltag']) . "]]></title_htmltag>";
                 # Hook plugins
                 //eval($this->plxPlugins->callHook('plxAdminEditProductsXml'));
                 $xml .= "</product>\n";
             }
         }
         $xml .= "</document>";
         # On écrit le fichier si une action valide a été faite
         if (plxUtils::write($xml, PLX_ROOT . PLX_CONFIG_PATH . 'products.xml')) {
             return plxMsg::Info(L_SAVE_SUCCESSFUL);
         } else {
             $this->aProds = $save;
             return plxMsg::Error(L_SAVE_ERR . ' ' . PLX_ROOT . PLX_CONFIG_PATH . 'products.xml');
         }
     }
 }
Ejemplo n.º 5
0
plxUtils::printInput('tags', $tags, 'text', '25-255', false, false);
?>
							<a title="<?php 
echo L_ARTICLE_TOGGLER_TITLE;
?>
" id="toggler" href="javascript:void(0)" onclick="toggleDiv('tags','toggler','+','-')" style="outline:none; text-decoration: none">+</a>
						</div>
						<div id="tags" style="display:none; margin-top: 1rem">
							<?php 
if ($plxAdmin->aTags) {
    $array = array();
    foreach ($plxAdmin->aTags as $tag) {
        if ($tags = array_map('trim', explode(',', $tag['tags']))) {
            foreach ($tags as $tag) {
                if ($tag != '') {
                    $t = plxUtils::title2url($tag);
                    if (!isset($array[$tag])) {
                        $array[$tag] = array('url' => $t, 'count' => 1);
                    } else {
                        $array[$tag]['count']++;
                    }
                }
            }
        }
    }
    array_multisort($array);
    foreach ($array as $tagname => $tag) {
        echo '<a href="javascript:void(0)" onclick="insTag(\'tags\',\'' . $tagname . '\')" title="' . plxUtils::strCheck($tagname) . ' (' . $tag['count'] . ')">' . plxUtils::strCheck($tagname) . '</a> (' . $tag['count'] . ')&nbsp;&nbsp;';
    }
} else {
    echo L_NO_TAG;
Ejemplo n.º 6
0
    /**
     * Méthode statique qui affiche le formulaire de recherche
     *
     * @return	stdio
     * @author	Stephane F
     **/
    public static function form($title = false)
    {
        $placeholder = '';
        # récupération d'une instance de plxMotor
        $plxMotor = plxMotor::getInstance();
        $plxPlugin = $plxMotor->plxPlugins->getInstance('plxMySearch');
        $searchword = '';
        if (!empty($_POST['searchfield'])) {
            $searchword = plxUtils::strCheck(plxUtils::unSlash($_POST['searchfield']));
        }
        if ($plxPlugin->getParam('placeholder_' . $plxPlugin->default_lang) != '') {
            $placeholder = ' placeholder="' . $plxPlugin->getParam('placeholder_' . $plxPlugin->default_lang) . '"';
        }
        ?>

<div class="searchform">
	<form action="<?php 
        echo $plxMotor->urlRewrite('?' . $plxPlugin->getParam('url'));
        ?>
" method="post">
		<?php 
        if ($title) {
            ?>
		<p class="searchtitle">
			<?php 
            if ($plxPlugin->getParam('checkboxes_' . $plxPlugin->default_lang) == '') {
                $plxPlugin->lang('L_FORM_SEARCHFIELD');
            } else {
                $plxPlugin->lang('L_FORM_SEARCHFIELD_2');
            }
            ?>
&nbsp;:
		</p>
		<?php 
        }
        ?>
		<div class="searchfields">
			<?php 
        if ($plxPlugin->getParam('checkboxes_' . $plxPlugin->default_lang) != '') {
            if ($chk = explode(';', $plxPlugin->getParam('checkboxes_' . $plxPlugin->default_lang))) {
                echo '<ul>';
                foreach ($chk as $k => $v) {
                    $c = plxUtils::title2url(trim($v));
                    $sel = "";
                    if (isset($_POST['searchcheckboxes'])) {
                        foreach ($_POST['searchcheckboxes'] as $s) {
                            if ($s == $c) {
                                $sel = ' checked="checked"';
                            }
                        }
                    }
                    echo '<li><input' . $sel . ' class="searchcheckboxes" type="checkbox" name="searchcheckboxes[]" id="id_searchcheckboxes[]" value="' . $c . '" />&nbsp;' . plxUtils::strCheck($v) . '</li>';
                }
                echo '</ul>';
            }
        }
        ?>
			<input type="text"<?php 
        echo $placeholder;
        ?>
 class="searchfield" name="searchfield" value="<?php 
        echo $searchword;
        ?>
" />
			<input type="submit" class="searchbutton" name="searchbutton" value="<?php 
        echo $plxPlugin->getParam('frmLibButton_' . $plxPlugin->default_lang);
        ?>
" />
			</p>
		</div>
	</form>
</div>

	<?php 
    }
Ejemplo n.º 7
0
# récupération d'une instance de plxMotor
$plxMotor = plxMotor::getInstance();
$plxPlugin = $plxMotor->plxPlugins->getInstance('plxMySearch');
# initialisation des variables locales à la page
$content = '';
$searchword = '';
$format_date = '#num_day/#num_month/#num_year(4)';
$searchresults = false;
if (!empty($_POST['searchfield']) or !empty($_POST['searchcheckboxes'])) {
    # formatage des critères de recherches configurés dans l'admin du plugin
    $array = array();
    $cfg_params = explode(';', $plxPlugin->getParam('checkboxes_' . $plxPlugin->default_lang));
    foreach ($cfg_params as $v) {
        $trim = trim($v);
        if ($trim != '') {
            $array[plxUtils::title2url($trim)] = $trim;
        }
    }
    # valeurs de recherche à partir des cases à cocher
    $searchwords = array();
    if (isset($_POST['searchcheckboxes'])) {
        foreach ($_POST['searchcheckboxes'] as $v) {
            if (isset($array[$v])) {
                $searchwords[] = strtolower($array[$v]);
            }
        }
    }
    # valeur de recherche de la zone de saisie libre
    $searchword = trim($_POST['searchfield']);
    if ($searchword != '') {
        $searchwords[] = plxUtils::unSlash(htmlspecialchars(strtolower($searchword)));
Ejemplo n.º 8
0
 /**
  * Méthode qui affiche la liste de tous les tags.
  *
  * @param	format	format du texte pour chaque tag (variable : #tag_size #tag_status, #tag_count, #tag_item, #tag_url, #tag_name, #nb_art)
  * @param	max		nombre maxi de tags à afficher
  * @param	order	tri des tags (random, alpha, '')
  * @return	stdout
  * @scope	global
  * @author	Stephane F
  **/
 public function tagList($format = '<li><a class="#tag_size #tag_status" href="#tag_url" title="#tag_name">#tag_name</a></li>', $max = '', $order = '')
 {
     # Hook Plugins
     if (eval($this->plxMotor->plxPlugins->callHook('plxShowTagList'))) {
         return;
     }
     $datetime = date('YmdHi');
     $array = array();
     $alphasort = array();
     # On verifie qu'il y a des tags
     if ($this->plxMotor->aTags) {
         # On liste les tags sans créer de doublon
         foreach ($this->plxMotor->aTags as $idart => $tag) {
             if (isset($this->plxMotor->activeArts[$idart]) and $tag['date'] <= $datetime and $tag['active']) {
                 if ($tags = array_map('trim', explode(',', $tag['tags']))) {
                     foreach ($tags as $tag) {
                         if ($tag != '') {
                             $t = plxUtils::title2url($tag);
                             if (!isset($array['_' . $tag])) {
                                 $array['_' . $tag] = array('name' => $tag, 'url' => $t, 'count' => 1);
                             } else {
                                 $array['_' . $tag]['count']++;
                             }
                             if (!in_array($t, $alphasort)) {
                                 $alphasort[] = $t;
                             }
                             # pour le tri alpha
                         }
                     }
                 }
             }
         }
         # limite sur le nombre de tags à afficher
         if ($max != '') {
             $array = array_slice($array, 0, intval($max), true);
         }
         # tri des tags
         switch ($order) {
             case 'alpha':
                 if ($alphasort) {
                     array_multisort($alphasort, SORT_ASC, $array);
                 }
                 break;
             case 'random':
                 $arr_elem = array();
                 $keys = array_keys($array);
                 shuffle($keys);
                 foreach ($keys as $key) {
                     $arr_elem[$key] = $array[$key];
                 }
                 $array = $arr_elem;
                 break;
         }
     }
     # On affiche la liste
     $size = 0;
     foreach ($array as $tagname => $tag) {
         $name = str_replace('#tag_id', 'tag-' . $size++, $format);
         $name = str_replace('#tag_size', 'tag-size-' . ($tag['count'] > 10 ? 'max' : $tag['count']), $name);
         $name = str_replace('#tag_count', $tag['count'], $name);
         $name = str_replace('#tag_item', $tag['url'], $name);
         $name = str_replace('#tag_url', $this->plxMotor->urlRewrite('?tag/' . $tag['url']), $name);
         $name = str_replace('#tag_name', plxUtils::strCheck($tag['name']), $name);
         $name = str_replace('#nb_art', $tag['count'], $name);
         $name = str_replace('#tag_status', ($this->plxMotor->mode == 'tags' and $this->plxMotor->cible == $tag['url']) ? 'active' : 'noactive', $name);
         echo $name;
     }
 }
Ejemplo n.º 9
0
 /**
  * M�thode qui affiche la liste de tous les tags.
  *
  * @param	format	format du texte pour chaque tag (variable : #tag_status, #tag_url, #tag_name, #nb_art)
  * @param	max		nombre maxi de tags � afficher
  * @return	stdout
  * @scope	global
  * @author	Stephane F
  **/
 public function tagList($format = '<li><a class="#tag_status" href="#tag_url" title="#tag_name">#tag_name</a></li>', $max = '5')
 {
     $time = @date('YmdHi');
     $array = array();
     # On verifie qu'il y a des tags
     if ($this->plxMotor->aTags) {
         # On liste les tags sans cr�er de doublon
         foreach ($this->plxMotor->aTags as $tag) {
             if ($tag['date'] <= $time and $tag['active']) {
                 if ($tags = array_map('trim', explode(',', $tag['tags']))) {
                     foreach ($tags as $tag) {
                         if ($tag != '') {
                             if (!isset($array[$tag])) {
                                 $array[$tag] = 1;
                             } else {
                                 $array[$tag]++;
                             }
                         }
                     }
                 }
             }
         }
     }
     natsort($array);
     if (intval($max) > 0) {
         $array = array_slice($array, 0, $max, true);
     }
     # On affiche la liste
     $size = 0;
     foreach ($array as $tagname => $nbtags) {
         $t = plxUtils::title2url($tagname);
         $name = str_replace('#tag_id', 'tag-' . $size++, $format);
         $name = str_replace('#tag_url', $this->plxMotor->urlRewrite('?tag/' . $t), $name);
         $name = str_replace('#tag_name', plxUtils::strCheck($tagname), $name);
         $name = str_replace('#nb_art', $nbtags, $name);
         $name = str_replace('#tag_status', ($this->plxMotor->mode == 'tags' and $this->plxMotor->cible == $t) ? 'active' : 'noactive', $name);
         echo $name;
     }
 }
Ejemplo n.º 10
0
    exit;
}
# Control du token du formulaire
plxToken::validateFormToken($_POST);
if (defined('PLX_MYMULTILINGUE')) {
    $array = explode(',', PLX_MYMULTILINGUE);
    $aLangs = array_intersect($array, array('fr', 'en'));
} else {
    $aLangs = array($plxPlugin->default_lang);
}
if (!empty($_POST)) {
    $plxPlugin->setParam('frmDisplay', $_POST['frmDisplay'], 'numeric');
    $plxPlugin->setParam('mnuDisplay', $_POST['mnuDisplay'], 'numeric');
    $plxPlugin->setParam('mnuPos', $_POST['mnuPos'], 'numeric');
    $plxPlugin->setParam('template', $_POST['template'], 'string');
    $plxPlugin->setParam('url', plxUtils::title2url($_POST['url']), 'string');
    $plxPlugin->setParam('sTitle', $_POST['sTitle'], 'numeric');
    $plxPlugin->setParam('sChapo', $_POST['sChapo'], 'numeric');
    $plxPlugin->setParam('sContent', $_POST['sContent'], 'numeric');
    $plxPlugin->setParam('sTags', $_POST['sTags'], 'numeric');
    $plxPlugin->setParam('savesearch', $_POST['savesearch'], 'numeric');
    foreach ($aLangs as $lang) {
        $plxPlugin->setParam('mnuName_' . $lang, $_POST['mnuName_' . $lang], 'string');
        $plxPlugin->setParam('placeholder_' . $lang, $_POST['placeholder_' . $lang], 'string');
        $plxPlugin->setParam('frmLibButton_' . $lang, $_POST['frmLibButton_' . $lang], 'string');
        $plxPlugin->setParam('checkboxes_' . $lang, $_POST['checkboxes_' . $lang], 'string');
    }
    $plxPlugin->saveParams();
    header('Location: parametres_plugin.php?p=plxMySearch');
    exit;
}