Cheetah
ChBaseMenuSimple.php
Go to the documentation of this file.
1 <?php
2 
8  ch_import('ChWsbMenuSimple');
9 
14  {
18  function __construct()
19  {
20  parent::__construct();
21  }
22 
23  /*
24  * Generate navigation menu source
25  */
26  function getCode()
27  {
28  if(empty($this->aItems))
29  $this->load();
30 
31  if(isset($GLOBALS['ch_profiler']))
32  $GLOBALS['ch_profiler']->beginMenu(ucfirst($this->sName) . ' Menu');
33 
34  $sResult = $this->getItems();
35 
36  if(isset($GLOBALS['ch_profiler']))
37  $GLOBALS['ch_profiler']->endMenu(ucfirst($this->sName) . ' Menu');
38 
39  return $sResult;
40  }
41 
42  function getItems()
43  {
44  $aTmplVars = array();
45  foreach($this->aItems as $aItem) {
46  if(!$this->checkToShow($aItem))
47  continue;
48 
49  list( $aItem['Link'] ) = explode( '|', $aItem['Link'] );
50 
51  $aItem['Caption'] = _t($this->replaceMetas($aItem['Caption']));
52  $aItem['Link'] = $this->replaceMetas($aItem['Link']);
53  $aItem['Script'] = $this->replaceMetas($aItem['Script']);
54 
55  $aTmplVars[] = array(
56  'caption' => $aItem['Caption'],
57  'caption_attr' => ch_html_attribute($aItem['Caption']),
58  'icon' => $aItem['Icon'],
59  'link' => $aItem['Script'] ? 'javascript:void(0)' : $this->oPermalinks->permalink($aItem['Link']),
60  'script' => $aItem['Script'] ? 'onclick="' . $aItem['Script'] . '"' : null,
61  'target' => $aItem['Target'] ? 'target="_blank"' : null
62  );
63  }
64 
65  return $GLOBALS['oSysTemplate']->parseHtmlByName('extra_' . $this->sName . '_menu.html', array('ch_repeat:items' => $aTmplVars));
66  }
67 
68  function getItemsArray($iLimit=1)
69  {
70  if(empty($this->aItems))
71  $this->load();
72 
73  if(isset($GLOBALS['ch_profiler']))
74  $GLOBALS['ch_profiler']->beginMenu(ucfirst($this->sName) . ' Menu');
75 
76  $iCount = 0;
77  $aTmplVars = array();
78  foreach ($this->aItems as $aItem) {
79  if (!$this->checkToShow($aItem))
80  continue;
81 
82  $iCount++;
83  if ($iCount > $iLimit)
84  break;
85 
86  list($aItem['Link']) = explode('|', $aItem['Link']);
87 
88  $aItem['Caption'] = _t($this->replaceMetas($aItem['Caption']));
89  $aItem['Link'] = $this->replaceMetas($aItem['Link']);
90  $aItem['Script'] = $this->replaceMetas($aItem['Script']);
91 
92  $aTmplVars[] = array(
93  'name' => $aItem['Name'],
94  'caption' => $aItem['Caption'],
95  'caption_attr' => ch_html_attribute($aItem['Caption']),
96  'icon' => $aItem['Icon'],
97  'link' => $aItem['Script'] ? 'javascript:void(0)' : $this->oPermalinks->permalink($aItem['Link']),
98  'script' => $aItem['Script'] ? 'onclick="' . $aItem['Script'] . '"' : null,
99  'target' => $aItem['Target'] ? 'target="_blank"' : null
100  );
101  }
102 
103  if(isset($GLOBALS['ch_profiler']))
104  $GLOBALS['ch_profiler']->endMenu(ucfirst($this->sName) . ' Menu');
105 
106  return $aTmplVars;
107  }
108  }
ChBaseMenuSimple
Definition: ChBaseMenuSimple.php:14
$sResult
$sResult
Definition: advanced_settings.php:26
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChBaseMenuSimple\getCode
getCode()
Definition: ChBaseMenuSimple.php:26
php
ChBaseMenuSimple\__construct
__construct()
Definition: ChBaseMenuSimple.php:18
ch_html_attribute
ch_html_attribute($mixedInput)
Definition: utils.inc.php:1324
ChBaseMenuSimple\getItemsArray
getItemsArray($iLimit=1)
Definition: ChBaseMenuSimple.php:68
ChBaseMenuSimple\getItems
getItems()
Definition: ChBaseMenuSimple.php:42
ChWsbMenuSimple
Definition: ChWsbMenuSimple.php:22
ChWsbMenuSimple\checkToShow
checkToShow( $aItem)
Definition: ChWsbMenuSimple.php:112
ChWsbMenuSimple\load
load()
Definition: ChWsbMenuSimple.php:57
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChWsbMenuSimple\replaceMetas
replaceMetas($sData)
Definition: ChWsbMenuSimple.php:125
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10