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('ArrayUtil', 'Base.Lib');
  4: App::uses('AppHelper', 'View/Helper');
  5: 
  6: /**
  7:  * Cria listas de links.
  8:  * 
  9:  * Action:
 10:  * - post
 11:  * - caption
 12:  * - linkOptions
 13:  * - url
 14:  */
 15: class ActionListHelper extends AppHelper {
 16: 
 17:     const LAYOUT_LIST = 'list';
 18:     const LAYOUT_TABLE = 'table';
 19: 
 20:     public $helpers = array(
 21:         'AccessControl.AccessControl',
 22:     );
 23: 
 24:     /**
 25:      * @var array
 26:      */
 27:     public $settings = array(
 28:         'listLayoutBeforeAll' => '',
 29:         'listLayoutAfterAll' => '',
 30:         'listLayoutBeforeEach' => '',
 31:         'listLayoutAfterEach' => '',
 32:         'tableLayoutBeforeAll' => '',
 33:         'tableLayoutAfterAll' => '',
 34:         'tableLayoutBeforeEach' => '',
 35:         'tableLayoutAfterEach' => '',
 36:         'layout' => self::LAYOUT_LIST
 37:     );
 38: 
 39:     /**
 40:      * Cria lista de links.
 41:      * @param array $actions
 42:      * @return string
 43:      * @throws Exception
 44:      */
 45:     public function actionList($actions, $options = array()) {
 46:         $options = array_merge($this->settings, $options);
 47:         switch ($options['layout']) {
 48:             case self::LAYOUT_LIST:
 49:                 return $this->_outputActionsList($this->_parseActions($actions), $options);
 50: 
 51:             case self::LAYOUT_TABLE:
 52:                 return $this->_outputActionsTable($this->_parseActions($actions), $options);
 53: 
 54:             default:
 55:                 throw new Exception("Layout not mapped: \"{$options['layout']}\".");
 56:         }
 57:     }
 58: 
 59:     private function _parseActions($actions) {
 60:         return array_map(function($value) {
 61:             return array_merge(
 62:                     array('post' => false, 'caption' => '?', 'linkOptions' => array())
 63:                     , $value
 64:             );
 65:         }, $actions);
 66:     }
 67: 
 68:     /**
 69:      * 
 70:      * @param array $actions
 71:      * @param array $options
 72:      * @return string
 73:      */
 74:     private function _outputActionsList($actions, $options) {
 75:         $buffer = $options['listLayoutBeforeAll'];
 76:         foreach ($actions as $action) {
 77:             $buffer .= $options['listLayoutBeforeEach'] . $this->_buildActionLink($action) . $options['listLayoutAfterEach'];
 78:         }
 79:         $buffer .= $options['listLayoutAfterAll'];
 80:         return $buffer;
 81:     }
 82: 
 83:     /**
 84:      * 
 85:      * @param array $actions
 86:      * @return string
 87:      */
 88:     private function _outputActionsTable($actions, $options) {
 89:         if (count($actions) >= 4) {
 90:             $rows = floor(count($actions) / sqrt(count($actions)));
 91:         } else {
 92:             $rows = 1;
 93:         }
 94: 
 95:         $columns = ceil(count($actions) / $rows);
 96:         $cellWidth = ($columns == 0 ? '100%' : floor(100 / $columns) . '%');
 97: 
 98:         $b = $options['tableLayoutBeforeAll'];
 99:         $b .= '<table class="actionListHelperTableLayout">';
100: 
101:         for ($row = 0; $row < $rows; $row++) {
102:             $b .= '<tr>';
103:             for ($column = 0; $column < $columns; $column++) {
104:                 $index = $row * $columns + $column;
105:                 $b .= "<td style='width: $cellWidth'>";
106:                 if (!empty($actions[$index])) {
107:                     $b .= $options['tableLayoutBeforeEach'];
108:                     $b .= $this->_buildActionLink($actions[$index]);
109:                     $b .= $options['tableLayoutAfterEach'];
110:                 } else {
111:                     $b .= '&nbsp;';
112:                 }
113: 
114:                 $b .= '</td>';
115:             }
116:             $b .= '</tr>';
117:         }
118: 
119:         $b .= '</table>';
120:         $b .= $options['tableLayoutAfterAll'];
121:         return $b;
122:     }
123: 
124:     /**
125:      * 
126:      * @param array $action
127:      * @return string
128:      */
129:     private function _buildActionLink($action) {
130:         $linkOptions = empty($action['linkOptions']) ? array() : $action['linkOptions'];
131:         $linkOptions['method'] = $action['post'] ? 'post' : 'get';
132:         $question = isset($action['question']) ? __d('widgets',$action['question']) : false;
133:         return $this->AccessControl->link(
134:                         $action['caption']
135:                         , $action['url']
136:                         , $linkOptions
137:                         , $question
138:         );
139:     }
140: 
141: }
142: 
API documentation generated by ApiGen 2.8.0