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

Source for file items.php

Documentation is available at items.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.  * SetHTMLTitle()
  13.  * Aggregate string
  14.  * to the global array $GLOBALS['current_title']
  15.  * @param $str string
  16.  * @return void 
  17.  */
  18. function SetHTMLTitle($str)
  19. {
  20.   if(count($GLOBALS['current_title']== 0array_push($GLOBALS['current_title']SITE_NAME);
  21.   array_push($GLOBALS['current_title']$str);
  22. }
  23.  
  24.  
  25.  
  26. /**
  27.  * HrefMaker()
  28.  * Generated a well-formed string URL for SEO
  29.  * if MOD_REWRITE is set to 1
  30.  * Can be override if the given array contains a key
  31.  * named 'rewrite_override'
  32.  * @param array $array 
  33.  * @return string $url_maked
  34.  ***/
  35. function HrefMaker($array)
  36. {
  37.   $url_maked '';
  38.  
  39.   if (defined("MOD_REWRITE"&& MOD_REWRITE == true && !in_array('rewrite_override'$array)) {
  40.      
  41.     if(in_array('#'$array)) {
  42.       $anchor '#'.$array['#'];
  43.     else {
  44.       $anchor '';
  45.     }
  46.      
  47.     if (array_key_exists('rub'$array)) {
  48.       $url_maked .= $array['rub'];
  49.     }
  50.     if (array_key_exists('filter'$array)) {
  51.       $url_maked .= URI_SEPARATOR '@@'.$array['filter'];
  52.     }
  53.     if (array_key_exists('name'$array)) {
  54.       $url_maked .= URI_SEPARATOR stripText(stripAccents($array['name']))','$array['id'];
  55.     }
  56.     else {
  57.       if (array_key_exists('id'$array)) {
  58.  
  59.         $url_maked .= URI_SEPARATOR $array['id'];
  60.       }
  61.     }
  62.     if (array_key_exists('parentid'$array)) {
  63.       $url_maked .= URI_SEPARATOR $array['parentid'];
  64.     }
  65.     if (array_key_exists('parentparentid'$array)) {
  66.       $url_maked .= URI_SEPARATOR $array['parentparentid'];
  67.     }
  68.     if (array_key_exists('debut'$array)) {
  69.       $url_maked .= URI_SEPARATOR '-' $array['debut''-' ;
  70.     }
  71.     $url_maked .= '.html'.$anchor;
  72.   }
  73.   else
  74.   {
  75.     $url_maked get_permalink($array);
  76.   }
  77.   return $url_maked;
  78. }
  79.  
  80. /**
  81.  * display_permalink()
  82.  * Display permalink
  83.  * @param array $array 
  84.  * @return string 
  85.  */
  86. function formatted_permalink($array$sep ''{
  87.  
  88.   if(defined('MOD_REWRITE'&& MOD_REWRITE == 1{
  89.     return $sep.'<a href="'.get_permalink($array).'" title="'_t('divers','permalink').'" class="permalink"><span>'._t('divers','permalink').'</span></a>';
  90.   else {
  91.     return '';
  92.   }
  93. }
  94.  
  95. /**
  96.  * get_permalink()
  97.  * Get permalink
  98.  * @param array $array 
  99.  * @return string 
  100.  */
  101. function get_permalink($array{
  102.   if(isset($array['name'])) unset($array['name']);
  103.   if(isset($array['#'])) {
  104.     $anchor '#'.$array['#'];
  105.     unset($array['#']);
  106.   else {
  107.     $anchor '';
  108.   }
  109.   if(isset($array['amp_no_conversion'])) {
  110.       $restore_amp true;
  111.       unset($array['amp_no_conversion']);
  112.   }
  113.   if(isset($array['rewrite_override'])) unset($array['rewrite_override']);
  114.   if (function_exists('http_build_query')) $url_string http_build_query($array);
  115.   else {
  116.     $url_string '';
  117.     $sep '';
  118.     while (list($key$valueeach ($array)) {
  119.       if (!empty($value)) {
  120.         $url_string .= $sep $key '=' $value;
  121.         $sep OUTPUT_SEP;
  122.       }
  123.     }
  124.   }
  125.   // if needed we restore '&amp;' to '&'
  126.   if(isset($restore_amp)) {
  127.       $url_string str_replace '&amp;' ,'&' $url_string);
  128.   }
  129.   $url_maked 'index.php?' $url_string.$anchor;
  130.  
  131.   return $url_maked;
  132. }
  133.  
  134. /**
  135. * getItemId()
  136. * Return a class identifier with ID
  137. * if exists
  138. *
  139. @return the string id
  140. ***/
  141. function getItemId()
  142. {
  143.     $class_id ActiveItemKey($GLOBALS['activeitem']).'-';
  144.     if(isset($_REQUEST['id'])) {
  145.       $class_id .= $_REQUEST['id'];
  146.     else {
  147.       $class_id .= '0';
  148.     }
  149.     return $class_id;
  150. }
  151.  
  152. /**
  153.  * DisplayTemplate()
  154.  * Include the required template
  155.  * if no user template is found in /public/
  156.  * includes the /public/dist/ version.
  157.  *
  158.  * @return void 
  159.  ***/
  160. function DisplayTemplate()
  161. {
  162.   $key ActiveItemKey($GLOBALS['activeitem']);
  163.   $current_template $GLOBALS['links'][U_L][$key]['template'];
  164.   distInclude(THEME_PUBLIC_PATH.'tpl_' $current_template '.php'THEME_PUBLIC_DIST);
  165. }
  166.  
  167. /**
  168.  * ActiveItem()
  169.  * Détermine l'item actif et le place en var global
  170.  *
  171.  * @return void 
  172.  */
  173. function ActiveItem()
  174. {
  175.   if (array_key_exists('rub'$_REQUEST)) $GLOBALS['activeitem'$_REQUEST['rub'];
  176.   else $GLOBALS['activeitem'$GLOBALS['links'][U_L]['home']['linkvalue'];
  177. }
  178.  
  179. /**
  180.  * ActiveItemKey()
  181.  * Return the Active item key
  182.  * @param string $item 
  183.  * @return string 
  184.  ***/
  185. function ActiveItemKey($item)
  186. {
  187.   foreach ($GLOBALS['links'][U_Las $key => $value{
  188.     if ($GLOBALS['links'][U_L][$key]['linkvalue'== $item)  return $key;
  189.   }
  190.   return false;
  191. }
  192.  
  193. /**
  194.  * ActiveItemAlias()
  195.  * Return the active item
  196.  * or its alias
  197.  * @param string $item 
  198.  * @return string 
  199.  ***/
  200. function ActiveItemAlias($item)
  201. {
  202.   $key ActiveItemKey($item);
  203.  
  204.   if($key == nullheader("Location: error.php");
  205.   if ($GLOBALS['links'][U_L][$key]['alias'=== falsereturn $key;
  206.   else return $GLOBALS['links'][U_L][$key]['alias'];
  207. }
  208.  
  209. ?>

Documentation generated on Thu, 20 Mar 2014 16:48:11 +0100 by phpDocumentor 1.4.1