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']) == 0) array_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['rewrite_override'])) unset($array['rewrite_override']);
  110.   if (function_exists('http_build_query')) $url_string = http_build_query($array);
  111.   else {
  112.     $url_string = '';
  113.     $sep = '';
  114.     while (list($key, $value) = each ($array)) {
  115.       if (!empty($value)) {
  116.         $url_string .= $sep . $key . '=' . $value;
  117.         $sep = OUTPUT_SEP;
  118.       }
  119.     }
  120.   }
  121.   $url_maked = 'index.php?' . $url_string.$anchor;
  122.  
  123.   return $url_maked;
  124. }
  125.  
  126. /**
  127. * getItemId()
  128. * Return a class identifier with ID
  129. * if exists
  130. *
  131. * @return the string id
  132. ***/
  133. function getItemId()
  134. {
  135.     $class_id = ActiveItemKey($GLOBALS['activeitem']).'-';
  136.     if(isset($_REQUEST['id'])) {
  137.       $class_id .= $_REQUEST['id'];
  138.     } else {
  139.       $class_id .= '0';
  140.     }
  141.     return $class_id;
  142. }
  143.  
  144. /**
  145.  * DisplayTemplate()
  146.  * Include the required template
  147.  * if no user template is found in /public/
  148.  * includes the /public/dist/ version.
  149.  *
  150.  * @return void 
  151.  ***/
  152. function DisplayTemplate()
  153. {
  154.   $key = ActiveItemKey($GLOBALS['activeitem']);
  155.   $current_template = $GLOBALS['links'][U_L][$key]['template'];
  156.   distInclude(THEME_PUBLIC_PATH.'tpl_' . $current_template . '.php', THEME_PUBLIC_DIST);
  157. }
  158.  
  159. /**
  160.  * ActiveItem()
  161.  * Détermine l'item actif et le place en var global
  162.  *
  163.  * @return void 
  164.  */
  165. function ActiveItem()
  166. {
  167.   if (array_key_exists('rub', $_REQUEST)) $GLOBALS['activeitem'] = $_REQUEST['rub'];
  168.   else $GLOBALS['activeitem'] = $GLOBALS['links'][U_L]['home']['linkvalue'];
  169. }
  170.  
  171. /**
  172.  * ActiveItemKey()
  173.  * Return the Active item key
  174.  * @param string $item 
  175.  * @return string 
  176.  ***/
  177. function ActiveItemKey($item)
  178. {
  179.   foreach ($GLOBALS['links'][U_L] as $key => $value) {
  180.     if ($GLOBALS['links'][U_L][$key]['linkvalue'] == $item)  return $key;
  181.   }
  182.   return false;
  183. }
  184.  
  185. /**
  186.  * ActiveItemAlias()
  187.  * Return the active item
  188.  * or its alias
  189.  * @param string $item 
  190.  * @return string 
  191.  ***/
  192. function ActiveItemAlias($item)
  193. {
  194.   $key = ActiveItemKey($item);
  195.  
  196.   if($key == null) header("Location: error.php");
  197.   if ($GLOBALS['links'][U_L][$key]['alias'] === false) return $key;
  198.   else return $GLOBALS['links'][U_L][$key]['alias'];
  199. }
  200.  
  201. ?>

Documentation generated on Thu, 03 May 2012 15:05:15 +0200 by phpDocumentor 1.4.1