Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • ArticleForumRightBottom
  • cApiClickableAction
  • cApiClickableQuestionAction
  • cGuiBackendHelpbox
  • cGuiFoldingRow
  • cGuiList
  • cGuiMenu
  • cGuiNavigation
  • cGuiNotification
  • cGuiObjectPager
  • cGuiPage
  • cGuiScrollList
  • cGuiTableForm
  • cGuiTree
  • cPager
  • cTemplate
  • cTree
  • cTreeItem
  • NoteLink
  • NoteList
  • NoteListItem
  • NoteView
  • TODOBackendList
  • TODOLink
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the navigation GUI class.
  4:  *
  5:  * @package          Core
  6:  * @subpackage       GUI
  7:  * @version          SVN Revision $Rev:$
  8:  *
  9:  * @author           Jan Lengowski
 10:  * @copyright        four for business AG <www.4fb.de>
 11:  * @license          http://www.contenido.org/license/LIZENZ.txt
 12:  * @link             http://www.4fb.de
 13:  * @link             http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: cInclude('includes', 'functions.api.string.php');
 19: cInclude('includes', 'functions.api.images.php');
 20: 
 21: /**
 22:  * Backend navigaton class. Renders the header navigation document containing the navigtion structure.
 23:  *
 24:  * @package    Core
 25:  * @subpackage GUI
 26:  */
 27: class cGuiNavigation {
 28: 
 29:     /**
 30:      * Array storing all data
 31:      * @var  array
 32:      */
 33:     public $data = array();
 34: 
 35:     /**
 36:      * Constructor. Loads the XML language file using cXmlReader.
 37:      *
 38:      * @throws cException if XML language files could not be loaded
 39:      */
 40:     public function __construct() {
 41:         global $cfg;
 42: 
 43:         $this->xml = new cXmlReader();
 44:         $this->plugxml = new cXmlReader();
 45: 
 46:         // Load language file
 47:         if ($this->xml->load($cfg['path']['xml'] . "navigation.xml") == false) {
 48:             throw new cException('Unable to load any XML language file');
 49:         }
 50:     }
 51: 
 52:     /**
 53:      * Extracts caption from the XML language file including plugins extended multilang version.
 54:      *
 55:      * @param  string  $location  The location of navigation item caption. Feasible values are
 56:      *                            - "{xmlFilePath};{XPath}": Path to XML File and the XPath value
 57:      *                                                       separated by semicolon. This type is used
 58:      *                                                       to extract caption from a plugin XML file.
 59:      *                            - "{XPath}": XPath value to extract caption from CONTENIDO XML file
 60:      * @throws cException if XML language files could not be loaded
 61:      * @return  string  The found caption
 62:      */
 63:     public function getName($location) {
 64:         global $cfg, $belang;
 65: 
 66:         // If a ";" is found entry is from a plugin -> explode location, first is xml file path,
 67:         // second is xpath location in xml file
 68:         if (strstr($location, ';')) {
 69:             $locs = explode(';', $location);
 70:             $file = trim($locs[0]);
 71:             $xpath = trim($locs[1]);
 72: 
 73:             $filepath = explode('/', $file);
 74:             $counter = count($filepath) - 1;
 75: 
 76:             if ($filepath[$counter] == '') {
 77:                 unset($filepath[$counter]);
 78:                 $counter--;
 79:             }
 80: 
 81:             if (strstr($filepath[$counter], '.xml')) {
 82:                 $filename = $filepath[$counter];
 83:                 unset($filepath[$counter]);
 84:                 $counter--;
 85:             }
 86: 
 87:             $filepath[($counter + 1)] = '';
 88: 
 89:             $filepath = implode('/', $filepath);
 90: 
 91:             if ($this->plugxml->load($cfg['path']['plugins'] . $filepath . $cfg['lang'][$belang]) == false) {
 92:                 if (!isset($filename)) {
 93:                     $filename = 'lang_en_US.xml';
 94:                 }
 95:                 if ($this->plugxml->load($cfg['path']['plugins'] . $filepath . $filename) == false) {
 96:                     throw new cException("Unable to load $filepath XML language file");
 97:                 }
 98:             }
 99:             $caption = $this->plugxml->getXpathValue('/language/' . $xpath);
100:         } else {
101:             $caption = $this->xml->getXpathValue('/language/' . $location);
102:         }
103: 
104:         return i18n($caption);
105:     }
106: 
107:     /**
108:      * Reads and fills the navigation structure data
109:      */
110:     public function _buildHeaderData() {
111:         global $cfg, $perm;
112: 
113:         $db = cRegistry::getDb();
114:         $db2 = cRegistry::getDb();
115: 
116:         // Load main items
117:         $sql = "SELECT idnavm, location FROM " . $cfg['tab']['nav_main'] . " ORDER BY idnavm";
118: 
119:         $db->query($sql);
120: 
121:         // Loop result and build array
122:         while ($db->nextRecord()) {
123: 
124:             // Extract names from the XML document.
125:             $main = $this->getName($db->f('location'));
126: 
127:             // Build data array
128:             $this->data[$db->f('idnavm')] = array($main);
129: 
130:             $sql = "SELECT
131:                         a.location AS location, b.name AS area, b.relevant
132:                     FROM
133:                         " . $cfg['tab']['nav_sub'] . " AS a, " . $cfg['tab']['area'] . " AS b
134:                     WHERE
135:                         a.idnavm = " . $db->f('idnavm') . " AND
136:                         a.level  = 0 AND
137:                         b.idarea = a.idarea AND
138:                         a.online = 1 AND
139:                         b.online = 1
140:                     ORDER BY
141:                         a.idnavs";
142: 
143:             $db2->query($sql);
144: 
145:             while ($db2->nextRecord()) {
146:                 $area = $db2->f('area');
147:                 if ($perm->have_perm_area_action($area) || $db2->f('relevant') == 0) {
148:                     // if this menu entry is a plugin and plugins are disabled, ignore it
149:                     if (strpos($db2->f('location'), ';') !== false && $cfg['debug']['disable_plugins']) {
150:                         continue;
151:                     }
152:                     // Extract names from the XML document.
153:                     $name = $this->getName($db2->f('location'));
154:                     $this->data[$db->f('idnavm')][] = array($name, $area);
155:                 }
156:             }
157:         }
158: 
159:         // debugging information
160:         cDebug::out(print_r($this->data, true));
161:     }
162: 
163:     /**
164:      * Function to build the CONTENIDO header document for backend
165:      *
166:      * @param  int  $lang  The language to use for header doc creation
167:      */
168:     public function buildHeader($lang) {
169:         global $cfg, $sess, $client, $auth, $cfgClient;
170: 
171:         $this->_buildHeaderData();
172: 
173:         $main = new cTemplate();
174:         $sub = new cTemplate();
175: 
176:         $cnt = 0;
177:         $t_sub = '';
178:         $numSubMenus = 0;
179: 
180:         $properties = new cApiPropertyCollection();
181:         $clientImage = $properties->getValue('idclient', $client, 'backend', 'clientimage', false);
182: 
183:         $sJsEvents = '';
184:         foreach ($this->data as $id => $item) {
185:             $sub->reset();
186:             $genSubMenu = false;
187: 
188:             foreach ($item as $key => $value) {
189:                 if (is_array($value)) {
190:                     $sub->set('s', 'SUBID', 'sub_' . $id);
191: 
192:                     // create sub menu link
193:                     $link = new cHTMLLink();
194:                     $link->disableAutomaticParameterAppend();
195:                     $link->setClass('sub');
196:                     $link->setID('sub_' . $value[1]);
197:                     $link->setLink($sess->url('frameset.php?area=' . $value[1]));
198:                     $link->setTargetFrame('content');
199:                     $link->setContent(i18n($value[0]));
200: 
201:                     if ($cfg['help'] == true) {
202:                         $sJsEvents .= "\n\t" . '$("#sub_' . $value[1] . '").click(function() { $("#help").attr("data", "' . $value[0] . '"); })';
203:                     }
204:                     $sub->set('d', 'CAPTION', $link->render());
205: 
206:                     $sub->next();
207:                     $genSubMenu = true;
208:                 }
209:             }
210: 
211:             if ($genSubMenu == true) {
212:                 $link = new cHTMLLink();
213:                 $link->setClass('main');
214:                 $link->setID('main_' . $id);
215:                 $link->setLink('javascript://');
216:                 $link->setAttribute('ident', 'sub_' . $id);
217:                 $link->setContent(i18n($item[0]));
218: 
219:                 $main->set('d', 'CAPTION', $link->render());
220:                 $main->next();
221: 
222:                 $numSubMenus++;
223:             } else {
224:                 // first entry in array is a main menu item
225:             }
226: 
227:             // generate a sub menu item.
228:             $t_sub .= $sub->generate($cfg['path']['templates'] . $cfg['templates']['submenu'], true);
229:             $cnt++;
230:         }
231: 
232:         if ($numSubMenus == 0) {
233:             $main->set('d', 'CAPTION', '&nbsp;');
234:             $main->next();
235:         }
236: 
237:         $main->set('s', 'SUBMENUS', $t_sub);
238: 
239:         $backendUrl = cRegistry::getBackendUrl();
240: 
241:         // my CONTENIDO link
242:         $link = new cHTMLLink();
243:         $link->setClass('main');
244:         $link->setTargetFrame('content');
245:         $link->setLink($sess->url("frameset.php?area=mycontenido&frame=4"));
246:         $link->setContent('<img class="vAlignMiddle" src="' . $backendUrl . $cfg['path']['images'] . 'my_contenido.gif" border="0" alt="My CONTENIDO" id="imgMyContenido" title="' . i18n("My CONTENIDO") . '">');
247:         $main->set('s', 'MYCONTENIDO', $link->render());
248: 
249:         // info link
250:         $link = new cHTMLLink();
251:         $link->setClass('main');
252:         $link->setTargetFrame('content');
253:         $link->setLink($sess->url('frameset.php?area=info&frame=4'));
254:         $link->setContent('<img class="vAlignMiddle" src="' . $backendUrl . $cfg['path']['images'] . 'info.gif" border="0" alt="Info" title="Info" id="imgInfo">');
255:         $main->set('s', 'INFO', $link->render());
256: 
257:         $main->set('s', 'LOGOUT', $sess->url('logout.php'));
258: 
259:         if ($cfg['help'] == true) {
260:             // help link
261:             $link = new cHTMLLink();
262:             $link->setID('help');
263:             $link->setClass('main');
264:             $link->setLink('javascript://');
265:             $link->setEvent('click', 'callHelp($(\'#help\').attr(\'data\'));');
266:             $link->setContent('<img class="vAlignMiddle" src="' . $backendUrl . $cfg['path']['images'] . 'but_help.gif" border="0" alt="Hilfe" title="Hilfe">');
267:             $main->set('s', 'HELP', $link->render());
268:         } else {
269:             $main->set('s', 'HELP', '');
270:         }
271: 
272:         $oUser = new cApiUser($auth->auth["uid"]);
273:         $clientCollection = new cApiClientCollection();
274: 
275:         if (getEffectiveSetting('system', 'clickmenu') == 'true') {
276:             // set click menu
277:             $main->set('s', 'HEADER_MENU_OBJ', 'HeaderClickMenu');
278:             $main->set('s', 'HEADER_MENU_OPTIONS', '{menuId: "main_0", subMenuId: "sub_0"}');
279:         } else {
280:             // set delay menu
281:             $mouseOver = getEffectiveSetting('system', 'delaymenu_mouseover', 300);
282:             $mouseOot = getEffectiveSetting('system', 'delaymenu_mouseout', 1000);
283:             $main->set('s', 'HEADER_MENU_OBJ', 'HeaderDelayMenu');
284:             $main->set('s', 'HEADER_MENU_OPTIONS', '{menuId: "main_0", subMenuId: "sub_0", mouseOverDelay: ' . $mouseOver . ', mouseOutDelay: ' . $mouseOot . '}');
285:         }
286: 
287:         $main->set('s', 'ACTION', $sess->url('index.php'));
288:         $main->set('s', 'LANG', $this->_renderLanguageSelect());
289: 
290:         $sClientName = $clientCollection->getClientName($client);
291:         if (strlen($sClientName) > 25) {
292:             $sClientName = cApiStrTrimHard($sClientName, 25);
293:         }
294: 
295:         $client = cSecurity::toInteger($client);
296:         if ($client == 0) {
297:             $sClientNameTemplate = '<b>' . i18n("Client") . ':</b> %s';
298:             $main->set('s', 'CHOSENCLIENT', sprintf($sClientNameTemplate, $sClientName));
299:         } else {
300:             $sClientNameTemplate = '<b>' . i18n("Client") . ':</b> <a href="%s" target="_blank">%s</a>';
301: 
302:             $sClientName = '<span id="chosenclient">' . $clientCollection->getClientName($client) . ' (' . $client . ')</span>';
303:             $sClientUrl = cRegistry::getFrontendUrl();
304:             $frontendPath = cRegistry::getFrontendPath();
305: 
306:             if ($clientImage !== false && $clientImage != "" && cFileHandler::exists($frontendPath . $clientImage)) {
307:                 $sClientImageTemplate = '<img src="%s" alt="%s" title="%s" />';
308: 
309:                 $sThumbnailPath = cApiImgScale($frontendPath . $clientImage, 80, 25, 0, 1);
310:                 $sClientImageTag = sprintf($sClientImageTemplate, $sThumbnailPath, $sClientName, $sClientName);
311: 
312:                 $main->set('s', 'CHOSENCLIENT', sprintf($sClientNameTemplate, $sClientUrl, $sClientImageTag));
313:             } else {
314:                 $html = sprintf($sClientNameTemplate, $sClientUrl, $sClientName);
315:                 $html .= $this->_renderClientSelect();
316:                 $main->set('s', 'CHOSENCLIENT', $html);
317:             }
318:         }
319: 
320:         $main->set('s', 'CHOSENUSER', "<b>" . i18n("User") . ":</b> " . $oUser->getEffectiveName());
321:         $main->set('s', 'SID', $sess->id);
322:         $main->set('s', 'MAINLOGINLINK', $sess->url("frameset.php?area=mycontenido&frame=4"));
323: 
324:         // additional footer javascript
325:         $footerJs = '';
326:         if ($sJsEvents !== '') {
327:             $footerJs = '$(document).ready(function() {' . $sJsEvents . '});';
328:         }
329:         $main->set('s', 'FOOTER_JS', $footerJs);
330: 
331:         $main->generate($cfg['path']['templates'] . $cfg['templates']['header']);
332:     }
333: 
334:     /**
335:      * Renders the language select box
336:      *
337:      * @return  string
338:      */
339:     public function _renderLanguageSelect() {
340:         global $cfg, $client, $lang;
341: 
342:         $tpl = new cTemplate();
343: 
344:         $tpl->set('s', 'NAME', 'changelang');
345:         $tpl->set('s', 'CLASS', 'vAlignMiddle text_medium');
346:         $tpl->set('s', 'ID', 'cLanguageSelect');
347:         $tpl->set('s', 'OPTIONS', 'onchange="changeContenidoLanguage(this.value)"');
348: 
349:         $availableLanguages = new cApiLanguageCollection();
350: 
351:         if (getEffectiveSetting('system', 'languageorder', 'name') == 'name') {
352:             $availableLanguages->select('', '', 'name ASC');
353:         } else {
354:             $availableLanguages->select('', '', 'idlang ASC');
355:         }
356: 
357:         if ($availableLanguages->count() > 0) {
358:             while (($myLang = $availableLanguages->nextAccessible()) !== false) {
359:                 $key = $myLang->get('idlang');
360:                 $value = $myLang->get('name');
361: 
362:                 $clientsLang = new cApiClientLanguage();
363:                 $clientsLang->loadBy('idlang', cSecurity::toInteger($key));
364:                 if ($clientsLang->isLoaded()) {
365:                     if ($clientsLang->get('idclient') == $client) {
366:                         if ($key == $lang) {
367:                             $tpl->set('d', 'SELECTED', 'selected');
368:                         } else {
369:                             $tpl->set('d', 'SELECTED', '');
370:                         }
371: 
372:                         if (strlen($value) > 20) {
373:                             $value = cApiStrTrimHard($value, 20);
374:                         }
375: 
376:                         $tpl->set('d', 'VALUE', $key);
377:                         $tpl->set('d', 'CAPTION', $value . ' (' . $key . ')');
378:                         $tpl->next();
379:                     }
380:                 }
381:             }
382:         } else {
383:             $tpl->set('d', 'VALUE', 0);
384:             $tpl->set('d', 'CAPTION', i18n('-- No Language available --'));
385:             $tpl->next();
386:         }
387: 
388:         return $tpl->generate($cfg['path']['templates'] . $cfg['templates']['generic_select'], true);
389:     }
390: 
391:     /**
392:      * Renders a select box where the client can be selected as well as an edit button.
393:      *
394:      * @return string rendered HTML
395:      */
396:     protected function _renderClientSelect() {
397:         $cfg = cRegistry::getConfig();
398:         $client = cRegistry::getClientId();
399:         // get all accessible clients
400:         $clientCollection = new cApiClientCollection();
401:         $clients = $clientCollection->getAccessibleClients();
402:         if (count($clients) === 1) {
403:             return '';
404:         }
405: 
406:         $tpl = new cTemplate();
407:         $tpl->set('s', 'NAME', 'changeclient');
408:         $tpl->set('s', 'CLASS', 'vAlignMiddle text_medium nodisplay');
409:         $tpl->set('s', 'ID', 'cClientSelect');
410:         $tpl->set('s', 'OPTIONS', 'onchange="changeContenidoClient(this.value)"');
411: 
412:         // add all accessible clients to the select
413:         foreach ($clients as $idclient => $clientInfo) {
414:             $name = $clientInfo['name'];
415:             if ($idclient == $client) {
416:                 $tpl->set('d', 'SELECTED', 'selected');
417:             } else {
418:                 $tpl->set('d', 'SELECTED', '');
419:             }
420: 
421:             if (strlen($name) > 20) {
422:                 $name = cApiStrTrimHard($name, 20);
423:             }
424: 
425:             $tpl->set('d', 'VALUE', $idclient);
426:             $tpl->set('d', 'CAPTION', $name . ' (' . $idclient . ')');
427:             $tpl->next();
428:         }
429: 
430:         $html = $tpl->generate($cfg['path']['templates'] . $cfg['templates']['generic_select'], true);
431:         $editButton = new cHTMLImage(cRegistry::getBackendUrl() . $cfg['path']['images'] . 'but_edithead.gif');
432:         $editButton->setID('changeclient');
433:         $editButton->setClass("vAlignMiddle");
434:         $editButton->appendStyleDefinition('cursor', 'pointer');
435: 
436:         return $html . $editButton->render();
437:     }
438: 
439: }
440: 
CMS CONTENIDO 4.9.1 API documentation generated by ApiGen 2.8.0