Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • 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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

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