Overview

Namespaces

  • Cron
  • None

Classes

  • _HtmlGrid_TableOut
  • _TransactionModel_RawSaveOperation
  • AccessControlComponent
  • AccessControlHelper
  • ActionListHelper
  • ActiveDirectoryUtils
  • AddCurrentPidToSchedulingShellCallLogs
  • AnonymousFunctionOperation
  • ArrayUtil
  • AssociationIntegrityBehavior
  • AtomicOperation
  • AuthenticationComponent
  • AuthenticationController
  • AuthenticationUser
  • AutocompleteDatasourceComponent
  • BaseModelComponent
  • Basics
  • CakeLayersHelper
  • CheckAndRunShell
  • ClassSearcher
  • CommandLineUtil
  • CommonValidationBehavior
  • ConfigurableShellCallsSchedulingTask
  • ConfigurationKey
  • ConfigurationKeys
  • ConfigurationKeysController
  • Context
  • ContextComponent
  • ContextHelper
  • Contexts
  • ControllerInspector
  • ControllerMenuHelper
  • CreateJournalingTables
  • CreateTableConfigurationKeys
  • CreateTableSchedulingConfigurableShellCalls
  • CreateTableSchedulingShellCallLogs
  • CreateTableSettedConfigurationKeys
  • CreateTableUserResetPasswordRequests
  • CreateTableUsers
  • CronSchedulingInstaller
  • CronValidationBehavior
  • CssBox
  • CssController
  • CssProperties
  • CssShell
  • CsvUtil
  • CustomDataModel
  • DatasourceDumperManager
  • DateTimeInput
  • DependencyShell
  • DetailHelper
  • DumperShell
  • ExtendedFieldsAccessControl
  • ExtendedFieldSet
  • ExtendedFieldSetHelper
  • ExtendedFieldsParser
  • ExtendedFormHelper
  • ExtendedHasManyAppModel
  • ExtendedOperationsBehavior
  • FieldDefinition
  • FieldRowDefinition
  • FieldSetDefinition
  • FieldSetLayoutHelper
  • FileOperations
  • FileOperations_Rename
  • FileOperations_SymLink
  • FileOperations_Touch
  • FileOperations_Unlink
  • FileSystem
  • FixConfigurationKeysPrimaryKey
  • FixSettedConfigurationKeysPrimaryKey
  • HasManyUtilsBehavior
  • HtmlDocument
  • HtmlGrid
  • HtmlGrid_Cell
  • HttpClient
  • HttpResponse
  • ImapClient
  • ImapMailBox
  • ImapParserShell
  • IncludePath
  • InputMasked
  • InputSearchable
  • InputsOnSubmit
  • InstallShell
  • JenkinsBuildShell
  • Journal
  • JournalDetail
  • JournalizedBehavior
  • JsonResponseComponent
  • LayoutsHelper
  • Ldap
  • LdapUtils
  • ListFieldSet
  • ListFieldSetHelper
  • ListsHelper
  • MailParser
  • Make
  • MenuHelper
  • MigrationAllPluginsShell
  • ModelOperations
  • ModelOperations_Delete
  • ModelOperations_Save
  • ModelTraverser
  • MysqlDumper
  • OpenLdapUtils
  • PaginatorUtilComponent
  • PaginatorUtilComponentFilter
  • PaginatorUtilHelper
  • Plugin
  • PluginManager
  • Reflections
  • RenameEnabledToActiveFromUsersTable
  • RunShellCallShell
  • ScaffoldUtilComponent
  • ScaffoldUtilHelper
  • Scheduling
  • SchedulingConfigurableShellCall
  • SchedulingConfigurableShellCallsController
  • SchedulingShellCallLog
  • SchedulingShellCallLogsController
  • SettedConfigurationKey
  • StuffreposPluginsRename
  • TimeZoneBehavior
  • TransactionModel
  • TransactionOperation
  • Translator
  • TranslatorShell
  • User
  • UserAuthenticationComponent
  • UserChangePassword
  • UserResetPassword
  • UserResetPasswordRequest
  • UserResetPasswordRequestSubmission
  • UsersController
  • ViewUtilHelper

Interfaces

  • AccessControlFilter
  • CommitableOperation
  • DatasourceDumper
  • MakeListener
  • SchedulingInstaller
  • TasksObject
  • UndoableOperation

Exceptions

  • LdapObjectNotWritableException
  • ModelTraverserException
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: App::uses('AppHelper', 'View/Helper');
  4: 
  5: class MenuHelper extends AppHelper {
  6: 
  7:     public $helpers = array(
  8:         'AccessControl.AccessControl',
  9:         'ExtendedScaffold.ScaffoldUtil',
 10:     );
 11: 
 12:     public function __construct(\View $View, $settings = array()) {
 13:         parent::__construct($View, $settings + array(
 14:             'defaultCss' => true,
 15:             'subMenuSymbol' => '&darr;',
 16:         ));
 17: 
 18:         if ($this->settings['defaultCss']) {
 19:             $this->ScaffoldUtil->addCssLink('Widgets.MenuHelper.css');
 20:         }
 21:     }
 22: 
 23:     public function dropdown($entries, $mainEntriesEqualsWidth = false) {
 24:         return $mainEntriesEqualsWidth ?
 25:             $this->_dropDownMainEntriesEqualsWidth($entries) :
 26:             $this->_dropDownCommon($entries);
 27:     }
 28: 
 29:     private function _dropDownCommon($entries) {
 30:         $buffer = "<ul class='MenuHelper'>";
 31: 
 32:         foreach ($this->_userMenu($entries) as $name => $entry) {
 33:             if (is_array($entry)) {
 34:                 $buffer .= $this->_submenu($name, $entry, null);
 35:             } else {
 36:                 $buffer .= $this->_link($name, $entry, null);
 37:             }
 38:         }
 39: 
 40:         $buffer .= "</ul>";
 41:         return $buffer;
 42:     }
 43: 
 44:     private function _dropDownMainEntriesEqualsWidth($entries) {
 45:         $buffer = "<ul class='MenuHelper'>";
 46:         $totalWidth = 100;
 47:         $count = count($entries);
 48: 
 49:         foreach ($this->_userMenu($entries) as $name => $entry) {
 50:             $width = floor($totalWidth / $count) - 1;
 51:             if (is_array($entry)) {
 52:                 $buffer .= $this->_submenu($name, $entry, $width);
 53:             } else {
 54:                 $buffer .= $this->_link($name, $entry, $width);
 55:             }
 56:         }
 57: 
 58:         $buffer .= "</ul>";
 59:         return $buffer;
 60:     }
 61: 
 62:     private function _listItem($content, $width) {
 63:         $b = '<li';
 64:         if ($width) {
 65:             $b .= " style='width: $width%'";
 66:         }
 67:         $b .= '>' . $content . '</li>';
 68:         return $b;
 69:     }
 70: 
 71:     private function _link($label, $uri, $width = null) {
 72:         return $this->_listItem($this->AccessControl->link($label, $uri), $width);
 73:     }
 74: 
 75:     private function _submenu($label, $entries, $width = null) {
 76:         $buffer = "<a href='#'>$label {$this->settings['subMenuSymbol']}</a>";
 77:         $buffer .= "<ul class='sub_menu'>";
 78:         foreach ($entries as $name => $entry) {
 79:             if (is_array($entry)) {
 80:                 $buffer .= $this->_submenu($name, $entry);
 81:             } else {
 82:                 $buffer .= $this->_link($name, $entry);
 83:             }
 84:         }
 85:         $buffer .= "</ul>";
 86: 
 87:         return $this->_listItem($buffer, $width);
 88:     }
 89: 
 90:     private function _userMenu($entries) {
 91:         $userEntries = array();
 92:         foreach ($entries as $name => $value) {
 93:             if (is_array($value)) {
 94:                 $subUserEntries = $this->_userMenu($value);
 95:                 if (!empty($subUserEntries)) {
 96:                     $userEntries[$name] = $subUserEntries;
 97:                 }
 98:             } else {
 99:                 if ($this->AccessControl->hasAccessByUrl($value)) {
100:                     $userEntries[$name] = $value;
101:                 }
102:             }
103:         }
104: 
105:         return $userEntries;
106:     }
107: 
108: }
109: 
110: ?>
API documentation generated by ApiGen 2.8.0