linea21-utils
[ class tree: linea21-utils ] [ index: linea21-utils ] [ all elements ]

Source for file lib_common.php

Documentation is available at lib_common.php

  1. <?php
  2. /**
  3.  * @package linea21.utils
  4.  * @subpackage lib
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11. /**
  12.  * optimize()
  13.  * callback method
  14.  * to ob_start()
  15.  * @param string $buffer 
  16.  * @return string 
  17.  */
  18. function optimize($buffer{
  19.  
  20.   $title implode(' - '$GLOBALS['current_title']);
  21.  
  22.  
  23.   return str_replace('##TITLE##'$title$buffer);
  24. }
  25.  
  26. /**
  27.  * implode_with_keys()
  28.  * implode avec clefs associées renvoyées
  29.  * sous forme de chaîne de caractères
  30.  * @param string $glue 
  31.  * @param string $array 
  32.  * @return string 
  33.  */
  34. function implode_with_keys($glue$array{
  35.   $output array();
  36.   foreach$array as $key => $item )
  37.   $output[$key "=" $item;
  38.  
  39.   return implode($glue$output);
  40. }
  41.  
  42. /**
  43.  * getHttpParameters()
  44.  * Renvoie les paramètres HTTP
  45.  * sous forme de chaîne de caractères
  46.  * @return string 
  47.  */
  48. function getHttpParameters($prefix '?'{
  49.  
  50.   return $prefix. (string) implode_with_keys('&'$_REQUEST);
  51. }
  52.  
  53. /**
  54.  * strip_input()
  55.  * Remove PHP and HTML code
  56.  * @param string $str 
  57.  * @param string $exceptions 
  58.  * @return string 
  59.  */
  60. function strip_input($str$exceptions false{
  61.  
  62.   if(defined('RICH_TEXT_EDITOR'&& RICH_TEXT_EDITOR != (string) 0{
  63.     return $str;
  64.   }
  65.   else {
  66.     if($exceptions)  {
  67.       return strip_tags($strALLOWABLE_TAGS);
  68.     }
  69.     else {
  70.       return strip_tags($str);
  71.     }
  72.   }
  73.  
  74. }
  75.  
  76. /**
  77.  * IncludeTextResizerJs()
  78.  * Include jQuery text-resizer plugin
  79.  * if no js wysiwyg are enabled
  80.  * @return void 
  81.  */
  82. function IncludeTextResizerJs({
  83.  
  84.   if(defined('RICH_TEXT_EDITOR'&& RICH_TEXT_EDITOR == (string) )
  85.   {
  86.     echo '<script type="text/javascript" src="../lib/js/jquery.textarearesizer.compressed.js"></script>';
  87.     echo '<script type="text/javascript">
  88.               $(document).ready(function() {
  89.                 $(\'textarea.largetextfield:not(.processed)\').TextAreaResizer();
  90.             })
  91.               </script>'.END_LINE;
  92.   }
  93. }
  94.  
  95. /**
  96.  * IncludeRichTextEditor()
  97.  * Include RichTextEditor if enabled
  98.  * @return void 
  99.  */
  100. function IncludeRichTextEditor({
  101.  
  102.   if(defined('RICH_TEXT_EDITOR'&& RICH_TEXT_EDITOR != (string) )  {
  103.     if(strtolower(RICH_TEXT_EDITOR== 'tinymce')
  104.     {
  105.       echo '<script type="text/javascript" src="../lib/js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>'.END_LINE;
  106.       echo '<script type="text/javascript" src="../lib/js/tinymce/jscripts/tiny_mce/config.js"></script>'.END_LINE;
  107.     }
  108.     if(strtolower(RICH_TEXT_EDITOR== 'fck')
  109.     {
  110.        
  111.       echo '<script type="text/javascript" src="../lib/js/fckeditor/fckeditor.js"></script>'.END_LINE;
  112.       echo '<script type="text/javascript">
  113.               $(document).ready(function(){
  114.             
  115.               FCKeditor.BasePath = "../lib/js/fckeditor/";
  116.               FCKeditor.MinWidth = "300px";
  117.             FCKeditor.ReplaceAllTextareas(\'largetextfield\');
  118.     
  119.  
  120.               });
  121.               </script>'.END_LINE;
  122.     }
  123.   }
  124.  
  125. }
  126.  
  127.  
  128. /**
  129.  * IncludeLightboxJs()
  130.  * Include Lightbox jQuery plugin
  131.  * if needed
  132.  * @return void 
  133.  */
  134. function IncludeLightboxJs({
  135.  
  136.   $rub = isset($_REQUEST['rub']$_REQUEST['rub''';
  137.   $todo = isset($_REQUEST['todo']$_REQUEST['todo''';
  138.  
  139.   if(ActiveItemKey($rub)) $rub ActiveItemKey($rub);
  140.   $s $rub '|' $todo;
  141.   $a $GLOBALS['lightbox_includes'];
  142.  
  143.   if(in_array($s$a)) {
  144.  
  145.     echo '<script type="text/javascript" src="../lib/js/jquery.lightbox-0.5.pack.js"></script>'.END_LINE;
  146.     echo '<link type="text/css" rel="stylesheet" href="../gfx/'.THEME_ADMIN.'/css/jquery.lightbox-0.5.css" />'.END_LINE;
  147.     echo '
  148.         <script type="text/javascript">
  149.     $(function() {
  150.         $("a.lightbox").lightBox();
  151.     });
  152.     </script>'END_LINE;
  153.   }
  154. }
  155.  
  156. /**
  157.  * IncludedatePickerJs()
  158.  * Include Lightbox jQuery date Picker
  159.  * if needed
  160.  * @return void 
  161.  */
  162. function IncludedatePickerJs({
  163.  
  164.   $rub = isset($_REQUEST['rub']$_REQUEST['rub''';
  165.   $todo = isset($_REQUEST['todo']$_REQUEST['todo''';
  166.  
  167.   if(ActiveItemKey($rub)) $rub ActiveItemKey($rub);
  168.   $s $rub '|' $todo;
  169.   $a $GLOBALS['datePicker_includes'];
  170.  
  171.   if(in_array($s$a)) {
  172.     echo '<script type="text/javascript" src="../lib/js/jquery.datePicker.js"></script>'.END_LINE;
  173.     echo '<link type="text/css" rel="stylesheet" href="../gfx/'.THEME_ADMIN.'/css/datePicker.css" />'.END_LINE;
  174.     echo '<script type="text/javascript" src="../lib/js/date.js"></script>'.END_LINE;
  175.     if(LANGUAGE != 'en'{
  176.       echo '<script type="text/javascript" src="../lib/js/date_'strtolower(LANGUAGE).'.js"></script>'END_LINE;
  177.     }
  178.   }
  179. }
  180.  
  181. /**
  182.  * SureRemoveDir()
  183.  * Supprime le contenu d'un dossier et le dossier lui-même si précisé.
  184.  *
  185.  * @return integer $ver_num
  186.  */
  187. function SureRemoveDir($dir$DeleteMe{
  188.   if(!$dh @opendir($dir)) return;
  189.   while (($obj readdir($dh))) {
  190.     if($obj=='.' || $obj=='..'continue;
  191.     if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$objtrue);
  192.   }
  193.   if ($DeleteMe){
  194.     closedir($dh);
  195.     @rmdir($dir);
  196.   }
  197. }
  198.  
  199. /**
  200.  * num_phpversion()
  201.  * Retourne un entier comme numéro de version PHP
  202.  *
  203.  * @return integer $ver_num
  204.  */
  205. function num_phpversion({
  206.   $ver explode'.'phpversion() );
  207.   $ver_num $ver[0$ver[1$ver[2];
  208.  
  209.   return $ver_num;
  210. }
  211.  
  212. /**
  213.  * cutText()
  214.  * Découpe un texte à une longeur donnée.
  215.  *
  216.  * @param string $content 
  217.  * @param integer $length 
  218.  * @param integer $abbr 
  219.  * @param string $end 
  220.  * @return 
  221.  */
  222. function cutText($content$length$abbr 0$end '...')
  223. {
  224.   if (strlen($content$length{
  225.     if ($abbr == 1$content_light "<abbr title=\"" $content "\">" substr($content0$length$end "</abbr>\n";
  226.     else $content_light substr($content0$length$end;
  227.   else $content_light $content;
  228.   return $content_light;
  229. }
  230.  
  231. /**
  232.  * cutBody()
  233.  * Renvoie un texte en 2 parties dans un tableau
  234.  *
  235.  * @param string $text 
  236.  * @return array $body
  237.  */
  238. function cutBody($text)
  239. {
  240.   $middle (strlen($text2);
  241.   $end strlen($text);
  242.   $body[0substr($text0$middle);
  243.   $body[1substr($text$middle$end);
  244.   $chaine preg_split("/(\.(<br \/>| ))/"$body[1]2);
  245.  
  246.   $body[0.= $chaine[0".";
  247.   $body[1@trim($chaine[1]);
  248.  
  249.   return $body;
  250. }
  251.  
  252. /**
  253.  * EnlargeImage()
  254.  * Miniatures; agrandissement onclick
  255.  *
  256.  * @param string $uri 
  257.  * @param string $style 
  258.  * @param string $alt_desc 
  259.  * @return string $img_link
  260.  */
  261. function EnlargeImage($uri$style ''$alt_desc '')
  262. {
  263.   list($width$height$type$attrgetimagesize($uri);
  264.   //$img_link = '<a href="' . $uri . '" title="' . $GLOBALS['lang']['divers']['enlarge_photo'] . '" onclick="displayImage(\'' . $uri . '\', \'\', \'' . $width . '\', \'' . $height . '\'); return false;">' . END_LINE;
  265.   $img_link '<a href="' $uri '" title="' $GLOBALS['lang']['divers']['enlarge_photo''" class="lightbox">' END_LINE;
  266.  
  267.   $img_link .= '<img src="' get_min_name($uri'" alt="' $GLOBALS['lang']['divers']['enlarge_photo'' ' $alt_desc '"' $style ' />' END_LINE;
  268.   $img_link .= '</a>' END_LINE;
  269.  
  270.   return $img_link;
  271. }
  272.  
  273. /**
  274.  * formatNavTitle()
  275.  * Formatage des titres ( interface admin )
  276.  *
  277.  * @param string $content 
  278.  * @return string $content
  279.  */
  280. function formatNavTitle($content)
  281. {
  282.   $content formatText($content'2HTML');
  283.   $content cutText($content701);
  284.  
  285.   return $content;
  286. }
  287.  
  288. /**
  289.  * formatTextli()
  290.  * Formatage des listes ( interface admin )
  291.  *
  292.  * @param string $content 
  293.  * @return string $content
  294.  */
  295. function formatTextli($content)
  296. {
  297.   $content formatText($content'2HTML');
  298.   $content cutText($content651);
  299.   return $content;
  300. }
  301.  
  302. /**
  303.  * formatTitleh2()
  304.  * Formatage des titres h2 ( interface admin )
  305.  *
  306.  * @param string $content 
  307.  * @return string $content
  308.  */
  309. function formatTitleh2($content)
  310. {
  311.   $content formatText($content'2HTML');
  312.   return $content;
  313. }
  314.  
  315. /**
  316.  * formatText()
  317.  * Formatage de texte pour affichage
  318.  *
  319.  * @param  $content 
  320.  * @param string $format 
  321.  * @return string $content
  322.  */
  323. function formatText($content$format = -1)
  324. {
  325.   $content stripslashes(trim($content));
  326.   switch ($format{
  327.     case '2HTML':
  328.       $content nl2br($content);
  329.       break;
  330.     case '2FIELD':
  331.       $content htmlentities($contentENT_QUOTES'utf-8');
  332.       break;
  333.     case '2ATT':
  334.       $content htmlentities($contentENT_QUOTES'utf-8');
  335.       break;
  336.     case '2XML':
  337.       $content strip_tags($content);
  338.       break;
  339.     case '2FILE':
  340.       //$content = addslashes(trim($content));
  341.       $content htmlspecialchars($contentENT_QUOTES'utf-8');
  342.       break;
  343.     default:
  344.   }
  345.   return $content;
  346. }
  347.  
  348. /**
  349.  * ReplaceInvalidChars()
  350.  * Remplacement des caractères invalides  par leurs entités HTML
  351.  *
  352.  * @param string $str 
  353.  * @return string $valid_string
  354.  */
  355. function ReplaceInvalidChars($str)
  356. {
  357.   $htmlentities_chars array('å' => '&#338;''ú' => '&#339;',
  358.         'ä' => '&#352;''ö' => '&#353;',
  359.         'ü' => '&#376;''à' => '&#710;',
  360.         'ò' => '&#732;''ñ' => '&#8211;',
  361.         'ó' => '&#8212;''ë' => '&#8216;',
  362.         'í' => '&#8217;''Ç' => '&#8218;',
  363.         'ì' => '&#8220;''î' => '&#8221;',
  364.         'Ñ' => '&#8222;''Ü' => '&#8224;',
  365.         'á' => '&#8225;''Ö' => '&#8230;',
  366.         'â' => '&#8240;''É' => '&#402;',
  367.         'ã' => '&#8249;''õ' => '&#8250;',
  368.         'Ä' => '&#8364;''ô' => '&#8482;',
  369.         'ï' => '&#8226;''ò' => '&#732;',
  370.         'ô' => '&#8482;');
  371.  
  372.   //$valid_string = str_replace(array_keys($htmlentities_chars), array_values($htmlentities_chars), $str);
  373.   //return $valid_string;
  374.   return $str;
  375. }
  376.  
  377. function stripAccents($string{
  378.  
  379.   $search explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u");
  380.   $replace explode(",","c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u");
  381.  
  382.   return str_replace($search$replace$string);
  383.  
  384.  
  385. }
  386.  
  387. function stripText($text{
  388.  
  389.   $text strtolower($text);
  390.  
  391.   // strip all non word chars
  392.   $text preg_replace('/\W/'' '$text);
  393.   // replace all white space sections with a dash
  394.   $text preg_replace('/\ +/''-'$text);
  395.   // trim dashes
  396.   $text preg_replace('/\-$/'''$text);
  397.   $text preg_replace('/^\-/'''$text);
  398.  
  399.   return $text;
  400. }
  401.  
  402. /**
  403.  * toStringSqlDate()
  404.  * Renvoie la date au format SQL
  405.  *
  406.  * @param string $format 
  407.  * @return string $s
  408.  */
  409. function toStringSqlDate($format 'short')
  410. {
  411.   $date_format =   array(
  412.                    'dd-mm-yyyy' => array(
  413.                           'mysql' => array('short'=> '%d-%m-%Y''long'=> 
  414.   array('12' => '%d-%m-%Y  %r''24' => '%d-%m-%Y  %T')),
  415.                         'pgsql' => array('short'=> 'DD-MM-YYYY''long'=> 
  416.   array('12' => 'DD-MM-YYYY HH12:MI:SS''24' => 'DD-MM-YYYY HH24:MI:SS'))),
  417.                     'yyyy-mm-dd' => array(
  418.                           'mysql' => array('short'=> '%Y-%m-%d''long'=> 
  419.   array('12' => '%Y-%m-%d  %r''24' => '%Y-%m-%d  %T')),
  420.                         'pgsql' => array('short'=> 'YYYY-MM-DD''long'=> 
  421.   array('12' => 'YYYY-MM-DD HH12:MI:SS''24' => 'YYYY-MM-DD HH24:MI:SS'))),
  422.  
  423.   );
  424.    
  425.   if($format == 'long'$s $date_format[DATE_FORMAT][SQL][$format][TIME_FORMAT];
  426.   else $s $date_format[DATE_FORMAT][SQL][$format];
  427.  
  428.   return $s;
  429. }
  430.  
  431.  
  432. /**
  433.  * date_compare()
  434.  * Compare 2 dates with a given operator.
  435.  * @param  $date1 
  436.  * @param  $date2 
  437.  * @param  $op 
  438.  * @return boolean 
  439.  */
  440. function date_compare($date1$date2$op{
  441.  
  442.   $date1strtotime(formatDate($date1true));
  443.   $date2strtotime(formatDate($date2true));
  444.  
  445.   switch($op{
  446.     case '>':
  447.       if($date1 $date2return true;
  448.       else return false;
  449.       break;
  450.     case '<':
  451.       if($date1 $date2return true;
  452.       else return false;
  453.     case '>=':
  454.       if($date1 >= $date2return true;
  455.       else return false;
  456.       break;
  457.     case '<=':
  458.       if($date1 <= $date2return true;
  459.       else return false;
  460.     case '==':
  461.       if($date1 == $date2return true;
  462.       else return false;
  463.     default:
  464.       return false;
  465.   }
  466. }
  467.  
  468.  
  469. /**
  470.  * distInclude()
  471.  * Include the required file
  472.  * if no user file is found,
  473.  * includes the dist/ version file.
  474.  *
  475.  * @param string $file 
  476.  * @return void 
  477.  */
  478. function distInclude($file)
  479. {
  480.   if(file_exists($file)) {
  481.     include_once($file);
  482.   else {
  483.     include_once(dirname($file).'/dist/'.basename($file));
  484.   }
  485. }
  486.  
  487. /**
  488.  * formatDate()
  489.  * Renvoie la date aux formats yyyy-mm-dd ou dd-mm-yyyy suivant le cas de départ
  490.  * Si $db == true renvoie toujours la date au format yyyy-mm-dd
  491.  *
  492.  * @param string $date 
  493.  * @param boolean $db 
  494.  * @return string $new_date
  495.  */
  496. function formatDate($date$db false)
  497. {
  498.   @list($part1$part2$part3explode('-'$date);
  499.   if(strlen($part1== 2{
  500.     $new_date $part3 '-' $part2 '-' $part1;
  501.   else {
  502.     $new_date $part1 '-' $part2 '-' $part3;
  503.   }
  504.   if($db == true{
  505.     // always return yyyy-mm-dd format
  506.     if(strlen($part1== 2{
  507.       $new_date $part3 '-' $part2 '-' $part1;
  508.     else {
  509.       $new_date $part1 '-' $part2 '-' $part3;
  510.     }
  511.   }
  512.  
  513.   return $new_date;
  514. }
  515.  
  516. /**
  517.  * isNullDate()
  518.  *
  519.  * @param string $date 
  520.  * @return boolean 
  521.  */
  522. function isNullDate($date)
  523. {
  524.   if($date == '0001-01-01' || $date == '01-01-0001'{
  525.     return true;
  526.   else return false;
  527.  
  528. }
  529.  
  530. /**
  531.  * empty_nc()
  532.  * retourne le contenu ou N.C
  533.  *
  534.  * @param string $content 
  535.  * @return string $content
  536.  */
  537. function empty_nc($content)
  538. {
  539.   $content trim($content);
  540.   if (empty($content|| isNullDate($content)) $content $GLOBALS['lang']['divers']['nc'];
  541.  
  542.   return $content;
  543. }
  544.  
  545. /**
  546.  * empty_none()
  547.  * retourne le contenu ou 'aucun'
  548.  *
  549.  * @param string $content 
  550.  * @return string $content
  551.  */
  552. function empty_none($content)
  553. {
  554.   $content trim($content);
  555.   if (empty($content)) $content $GLOBALS['lang']['divers']['none'];
  556.  
  557.   return $content;
  558. }
  559.  
  560. /**
  561.  * empty_none()
  562.  * retourne le contenu ou 0
  563.  *
  564.  * @param string $content 
  565.  * @return string $content
  566.  */
  567. function empty_numeric($content)
  568. {
  569.   $content trim($content);
  570.   if (empty($content)) $content 0;
  571.  
  572.   return $content;
  573. }
  574.  
  575. /**
  576.  * checkdate_validity()
  577.  * Vérifie la validité d'une date
  578.  *
  579.  * @param string $date 
  580.  * @param string $msg (optionnal)
  581.  * @return boolean true or error message (string)
  582.  */
  583. function checkdate_validity($date$msg'')
  584. {
  585.  
  586.   $date=formatDate($datetrue);
  587.   @list($year$month$dayexplode('-'$date);
  588.  
  589.   if(!preg_match('/^\d{4}-\d\d-\d\d$/'$date)) {
  590.     $msg .= $GLOBALS['lang']['date']['not_valid'];
  591.     return $msg;
  592.   }
  593.  
  594.   if (!@checkdate($month $day $year)) return $msg $GLOBALS['lang']['date']['date_do_not_exist'];
  595.   return true;
  596. }
  597.  
  598. /**
  599.  * display_errors()
  600.  * Affichage d'un message d'erreur utilisateur
  601.  *
  602.  * @param string $msg 
  603.  * @return void (echo)
  604.  */
  605. function display_errors($msg)
  606. {
  607.   $display_it "<div class=\"error\">\n";
  608.   $display_it .= $msg;
  609.   $display_it .= "</div>\n";
  610.   echo $display_it;
  611. }
  612.  
  613. /**
  614.  * system_error()
  615.  * Affichage d'un message d'erreur syst�me
  616.  *
  617.  * @param string $msg 
  618.  * @return void (echo)
  619.  */
  620. function system_error($msg ERROR_SYSTEM)
  621. {
  622.   $display_it "<div class=\"systemerror\">\n";
  623.   $display_it .= $msg;
  624.   $display_it .= "</div>\n";
  625.   echo $display_it;
  626.   exit;
  627. }
  628.  
  629. /**
  630.  * get_temp_name()
  631.  * obtenir le nom temporaire d'un fichier
  632.  *
  633.  * @param string $path 
  634.  * @return string $temp_path
  635.  */
  636. function get_temp_name($path)
  637. {
  638.   $short_path dirname($path);
  639.   $filename basename($path);
  640.   $temp_path $short_path "/temp_" $filename;
  641.   return $temp_path;
  642. }
  643.  
  644. /**
  645.  * get_min_name()
  646.  * obtenir le nom de la miniature d'un fichier
  647.  *
  648.  * @param string $path 
  649.  * @return string $min_path
  650.  */
  651. function get_min_name($path)
  652. {
  653.   $short_path dirname($path);
  654.   $filename basename($path);
  655.   $min_path $short_path "/min_" $filename;
  656.   return $min_path;
  657. }
  658.  
  659. /**
  660.  * ExcedMaxSize()
  661.  * Teste si une image dépasse ou non la taille autorisée (en pixels)
  662.  *
  663.  * @param string $path 
  664.  * @param integer $width_max 
  665.  * @return boolean 
  666.  */
  667. function ExcedMaxSize($path$width_max)
  668. {
  669.   list($width$height$type$attrgetimagesize($path);
  670.   if ($width $width_max || $height $width_maxreturn true;
  671.   else return false;
  672. }
  673.  
  674. /**
  675.  * GetAllPhotoUri()
  676.  * renvoie les paths des photos dans un tableau
  677.  *
  678.  * @param string $path 
  679.  * @param string $opt 
  680.  * @return array $tab
  681.  */
  682. function GetAllPhotoUri($path$opt = -1)
  683. {
  684.   if (empty($path)) return false;
  685.   else {
  686.     $tab explode('|'$path);
  687.     if ($opt == 'min'array_walk($tab'get_min_name');
  688.     return $tab;
  689.   }
  690. }
  691.  
  692. /**
  693.  * cancel_button()
  694.  * génére un bouton de retour
  695.  *
  696.  * @param  $back_uri 
  697.  * @return string 
  698.  */
  699. function cancel_button($back_uri)
  700. {
  701.   return '<input name="annuler" type="button" value="' $GLOBALS['lang']['btn']['annul''" class="button" id="annuler" onclick="window.location=\'' $back_uri '\';" />';
  702. }
  703.  
  704. /**
  705.  * GetDisplayUserRight()
  706.  * renvoie les droits d'un utilisateur
  707.  *
  708.  * @param string $indice 
  709.  * @param string $module 
  710.  * @return string 
  711.  */
  712. function GetDisplayUserRight($indice$module = -1)
  713. {
  714.   $indice strtoupper($indice);
  715.   if ($indice == 'U'return $GLOBALS['lang']['user']['norights'];
  716.   if ($indice == 'A'return $GLOBALS['lang']['user']['adminrights'];
  717.   if ($indice == 'O' && $module == 'dashboard'return $GLOBALS['lang']['user']['managerrights'];
  718.   if ($indice == 'O' && $module == 'workshop'return $GLOBALS['lang']['user']['animatorrights'];
  719.   if ($indice == 'O' && ($module != 'workshop' && $module != 'dashboard')) return $GLOBALS['lang']['user']['redactorrights'];
  720. }
  721.  
  722. /**
  723.  * Display_linkin_page()
  724.  *
  725.  * @param array $table_link 
  726.  * @param integer $total 
  727.  * @param integer $debut 
  728.  * @param integer $pas 
  729.  * @return void 
  730.  ***/
  731. function Display_linkin_page($table_link$total$debut$pas SELECT_LIMIT)
  732. {
  733.   $result ceil($total $pas);
  734.   if ($result <= 1return '&nbsp;';
  735.   else {
  736.     $link '<div class="lienliste">'.END_LINE;
  737.     $link .= '&lt; &lt; ';
  738.     $sep='';
  739.     for($i 0$i $result$i++{
  740.       $current_pos ($pas $i);
  741.       if ($debut == $current_pos$link .= $sep."<span>" ($i 1"</span> \n";
  742.       else {
  743.         $array_pos array ('debut' => $current_pos);
  744.         $new_table_link array_merge ($table_link$array_pos);
  745.         $link .= $sep.'<a href="'HrefMaker($new_table_link'">' ($i 1'</a>'.END_LINE;
  746.       }
  747.       $sep=' | ';
  748.     }
  749.     $link .= ' &gt; &gt;';
  750.     $link .= '</div>'.END_LINE;
  751.     echo $link;
  752.   }
  753. }
  754.  
  755. /**
  756.  * linkin_page()
  757.  * création d'un navigateur de pages numérotées
  758.  *
  759.  * @param string $string_uri 
  760.  * @param integer $total 
  761.  * @param integer $debut 
  762.  * @param integer $pas 
  763.  * @return string $link
  764.  */
  765. function linkin_page($string_uri$total$debut$pas SELECT_LIMIT)
  766. {
  767.   $result ceil($total $pas);
  768.   if ($result <= 1return '&nbsp;';
  769.   else {
  770.     if (strpos($string_uri'?'=== false$string_uri .= '?';
  771.     else $string_uri .= '&amp;';
  772.     $link '<div class="lienliste">';
  773.     for($i 0$i $result$i++{
  774.       $current_pos ($pas $i);
  775.       if ($debut == $current_pos$link .= "<span>" ($i 1"</span> \n";
  776.       else $link .= "<a href=\"" $string_uri "debut=" $current_pos "\">" ($i 1"</a> \n";
  777.     }
  778.     $link .= '</div>';
  779.     return $link;
  780.   }
  781. }
  782.  
  783. /**
  784.  * display_statut()
  785.  * renvoie le statut en pleines lettres
  786.  *
  787.  * @param string $statut 
  788.  * @return string $result
  789.  */
  790. function display_statut($statut)
  791. {
  792.   switch ($statut{
  793.     case 'P':
  794.       $result $GLOBALS['lang']['statut']['public'];
  795.       break;
  796.     case 'D':
  797.       $result $GLOBALS['lang']['statut']['draft'];
  798.       break;
  799.     case 'E':
  800.       $result $GLOBALS['lang']['statut']['E'];
  801.       break;
  802.     case 'AA':
  803.       $result $GLOBALS['lang']['statut']['AA'];
  804.       break;
  805.     case 'PA':
  806.       $result $GLOBALS['lang']['statut']['PA'];
  807.       break;
  808.     case 'C':
  809.       $result $GLOBALS['lang']['statut']['C'];
  810.       break;
  811.     case 'U':
  812.       $result $GLOBALS['lang']['statut']['U'];
  813.       break;
  814.     case 'O':
  815.       $result $GLOBALS['lang']['statut']['O'];
  816.       break;
  817.     case 'A':
  818.       $result $GLOBALS['lang']['statut']['A'];
  819.       break;
  820.     case 'W':
  821.       $result $GLOBALS['lang']['statut']['W'];
  822.       break;
  823.     default:
  824.       $result $GLOBALS['lang']['statut']['public'];
  825.   }
  826.   return $result;
  827. }
  828.  
  829. /**
  830.  * linkin_content()
  831.  * Cherche les liens et emails dans du contenu -> linkage
  832.  *
  833.  * @param string $content 
  834.  * @param string $option 
  835.  * @return string $content
  836.  */
  837. function linkin_content($content$option 'ALL')
  838. {
  839.   if(defined('AUTO_LINK'&& AUTO_LINK == 1)
  840.   {
  841.     if(defined('RICH_TEXT_EDITOR'&& RICH_TEXT_EDITOR == (string) 0{
  842.       if ($option == 'ALL' || $option == 'MAIL'{
  843.         $content eregi_replace("( |<br />)+([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+)"'\\1<a href="mailto:\\2">\\2</a>'$content);
  844.       }
  845.       if ($option == 'ALL' || $option == 'LINK'{
  846.         $content eregi_replace("(http|https|ftp|ftps)://([-a-z0-9#?/&=:,_;@%.{}]*)([a-z0-9=]{2,4})"'<a href="\\1://\\2\\3" class="out">\\1://\\2\\3</a>'$content);
  847.       }
  848.     }
  849.   }
  850.  
  851.   return $content;
  852. }
  853.  
  854. /**
  855.  * QuickBoxNow()
  856.  * Génération de la quickbox
  857.  *
  858.  * @param string $module 
  859.  * @param string $h1 
  860.  * @param string $liste 
  861.  * @param string $suffixclass 
  862.  * @return string $quickbox
  863.  */
  864. function QuickBoxNow($module$h1$liste$suffixclass '')
  865. {
  866.   $quickbox "<div class=\"entete\">\n<div class=\"qb_ico\" id=\"qbico" $suffixclass "\" title=\"" $module "\"></div>\n";
  867.   $quickbox .= "<div class=\"quickbox\" id=\"qbbg" $suffixclass "\">\n";
  868.   $quickbox .= "<h1>" $h1 "</h1>\n";
  869.   $quickbox .= "<ul>";
  870.   $quickbox .= $liste;
  871.   $quickbox .= "</ul>";
  872.   $quickbox .= "</div>";
  873.   $quickbox .= "</div>";
  874.  
  875.   return $quickbox;
  876. }
  877.  
  878. /**
  879.  * ReloadIndex()
  880.  * Chargement de l'index après destruction de sessions
  881.  *
  882.  * @param string $item 
  883.  * @return void 
  884.  */
  885. function ReloadIndex($item)
  886. {
  887.   switch ($item{
  888.     case 'public':
  889.       return header("Location: ../public/logout.php");
  890.       break;
  891.     case 'admin':
  892.       return header("Location: ../admin/logout.php");
  893.       break;
  894.   }
  895. }
  896.  
  897. /**
  898.  * getmicrotime()
  899.  * renvoie le temps en microsecondes
  900.  *
  901.  * @return float 
  902.  */
  903. function getmicrotime()
  904. {
  905.   list($usec$secexplode(" "microtime());
  906.   return ((float)$usec + (float)$sec);
  907. }
  908.  
  909.  
  910.  
  911. /**
  912.  * GenerateXhtmlPage()
  913.  *
  914.  * @param $string 
  915.  * @param integer $time 
  916.  * @param unknown $redirect 
  917.  * @return 
  918.  ***/
  919. function GenerateXhtmlPage($string$time 2$redirect SITE_CITY_URL)
  920. {
  921.  
  922.  
  923.   $page  '<?xml version="1.0" encoding="ISO-8859-1" xml:lang="' LANGUAGE '"?>' END_LINE;
  924.   $page .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' END_LINE;
  925.   $page .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' LANGUAGE '">' END_LINE;
  926.   $page .= '<head>' END_LINE;
  927.   $page .= '<meta http-equiv="content-type" content="text/html;charset=' CHARSET '" />' END_LINE;
  928.   $page .= '<meta http-equiv="content-langage" content="' CHARSET '" />' END_LINE;
  929.   $page .= '<meta http-equiv="refresh" content="' $time ';url=' $redirect '">' END_LINE;
  930.   $page .= '<link rel="icon" type="image/gif" href="../gfx/' .THEME_ADMIN'/images/admin/favicon.gif" />' END_LINE;
  931.   $page .= '<title>'.SITE_CITY_NAME.'</title>' END_LINE;
  932.   $page .= '</head>' END_LINE;
  933.   $page .= '<body>' END_LINE;
  934.   $page .= '<div class="info" style="margin-top:10em">'.$string.END_LINE;
  935.   $page .= '<br />';
  936.   $page .= sprintf$GLOBALS['lang']['divers']['redirect_string']$redirect$time);
  937.   $page .= '</div>'END_LINE;
  938.   $page .= '</body>' END_LINE;
  939.   $page .= '</html>' END_LINE;
  940.  
  941.   return $page;
  942. }
  943.  
  944.  
  945.  
  946. ?>

Documentation generated on Sat, 08 Nov 2008 14:52:57 +0100 by phpDocumentor 1.4.1