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: App::uses('ExtendedFieldsAccessControl', 'ExtendedScaffold.Lib');
  5: 
  6: class DetailHelper extends AppHelper {
  7: 
  8:     public $helpers = array(        
  9:         'AccessControl.AccessControl',
 10:         'Base.CakeLayers',
 11:         'ExtendedScaffold.Lists',
 12:         'ExtendedScaffold.ViewUtil',
 13:         'ExtendedScaffold.ExtendedFieldSet',
 14:         'ExtendedScaffold.ListFieldSet',
 15:     );
 16: 
 17:     /**
 18:      *
 19:      * @var array
 20:      */
 21:     public $settings = array(
 22:         'listSettings' => array(),
 23:     );
 24: 
 25:     /**
 26:      *
 27:      * @param array $fields 
 28:      * @return string
 29:      */
 30:     public function commonViewFieldList($fields) {
 31:         $b = "\n<table class='viewFieldList'>\n";
 32:         foreach ($fields as $label => $value) {
 33:             $b .= "\t" . (is_array($value) ? $this->viewField($value) : $this->viewField($label, $value)) . "\n";
 34:         }
 35:         $b .= "\n</table>\n";
 36:         return $b;
 37:     }
 38: 
 39:     /**
 40:      * Cria uma lista com entradas "Rótulo:Valor" para valores vindos de um
 41:      * Scaffold de Visão.
 42:      * @param type $instance
 43:      * @param type $fields
 44:      * @param type $associations 
 45:      */
 46:     public function scaffoldViewFieldList($instance, $fields, $options = array()) {
 47:         if (empty($options['modelClass'])) {
 48:             $modelClass = $this->CakeLayers->getControllerDefaultModelClass();
 49:         } else {
 50:             $modelClass = $options['modelClass'];
 51:         }
 52: 
 53:         if (empty($options['associations'])) {
 54:             $associations = $this->CakeLayers->getModelAssociations($modelClass);
 55:         } else {
 56:             $associations = $options['associations'];
 57:         }
 58: 
 59:         if (ExtendedFieldsParser::isExtendedFieldsDefinition($fields)) {
 60:             return $this->_scaffoldExtendedFieldList(
 61:                             $instance
 62:                             , ExtendedFieldsAccessControl::parseFieldsets($fields, true)
 63:                             , $associations
 64:                             , $modelClass
 65:             );
 66:         } else {
 67:             return $this->_scaffoldCommonFieldList($instance, $fields, $associations, $modelClass);
 68:         }
 69:     }
 70: 
 71:     /**
 72:      *
 73:      * @param mixed $label Uma string com o rótulo a ser usado ou um array com 
 74:      * as seguintes opções: fieldName, value, label, type
 75:      * @param mixed $value
 76:      * @param mixed $valueType
 77:      * @return string 
 78:      */
 79:     public function viewField($label, $value = null,
 80:             $valueType = ViewUtilHelper::VALUE_TYPE_UNKNOWN) {
 81:         $class = null;
 82:         if ($this->viewFieldCount++ % 2 == 0) {
 83:             $class = ' class="altrow"';
 84:         }
 85: 
 86:         $field = $this->_extractFieldData($label, $value, $valueType);
 87: 
 88:         switch ($field['type']) {
 89:             case ViewUtilHelper::VALUE_TYPE_BOOLEAN:
 90:                 $value = $this->ViewUtil->yesNo($field['value']);
 91:                 break;
 92:             case ViewUtilHelper::VALUE_TYPE_UNKNOWN:
 93:             default:
 94:                 $value = $this->ViewUtil->autoFormat($field['value']);
 95:         }
 96: 
 97:         $buffer = "<tr{$class}>";
 98:         $buffer .= "\t\t<th>" . __d('extended_scaffold', Inflector::humanize($field['label']), true) . "</th>\n";
 99:         $buffer .= "\t\t<td>\n\t\t\t" . $value . "\n&nbsp;\t\t</td>\n";
100:         $buffer .= "</tr>";
101: 
102:         return $buffer;
103:     }
104: 
105:     private function _scaffoldCommonFieldList($instance, $fields, $associations,
106:             $modelClass) {
107:         $i = 0;
108:         $viewFields = array();
109:         foreach ($fields as $_field) {
110: 
111:             $isKey = false;
112: 
113:             if (!empty($associations['belongsTo'])) {
114:                 foreach ($associations['belongsTo'] as $_alias => $_details) {
115:                     if ($_field === $_details['foreignKey']) {
116:                         $isKey = true;
117:                         $viewFields[] = array(
118:                             'label' => __d('extended_scaffold', Inflector::humanize($_alias), true),
119:                             'value' => $this->AccessControl->linkOrText(
120:                                     ModelTraverser::value($this->_getCurrentController()->{$modelClass}, $instance, "$_alias.{$_details['displayField']}")
121:                                     , array(
122:                                 'controller' => $_details['controller']
123:                                 , 'action' => 'view'
124:                                 , ModelTraverser::value($this->_getCurrentController()->{$modelClass}, $instance, "$_alias.{$_details['primaryKey']}")
125:                                     )
126:                             )
127:                             , 'fieldName' => $_field
128:                         );
129: 
130:                         break;
131:                     }
132:                 }
133:             }
134:             if ($isKey !== true) {
135:                 $viewFields[] = array(
136:                     'label' => __d('extended_scaffold', Inflector::humanize($_field), true),
137:                     'value' => ModelTraverser::value($this->_getCurrentController()->{$modelClass}, $instance, $_field),
138:                     'fieldName' => $_field,
139:                 );
140:             }
141:         }
142: 
143:         return $this->commonViewFieldList($viewFields);
144:     }
145: 
146:     private function _scaffoldExtendedFieldList($instance, $fieldsets,
147:             $associations, $modelClass) {
148:         $b = '';
149: 
150:         foreach ($fieldsets as $fieldset) {
151:             $fieldSetResult = $this->_scaffoldExtendedViewFieldListFieldset($fieldset, compact('instance', 'associations', 'modelClass'));
152:             if ($fieldSetResult) {
153:                 $b .= $fieldSetResult;
154:             }
155:         }
156: 
157:         return $b;
158:     }
159: 
160:     private function _scaffoldExtendedViewFieldListFieldset(\FieldSetDefinition $fieldset, 
161:             $scaffoldVars) {
162:         return $fieldset->getListAssociation() ?
163:                 $this->ListFieldSet->fieldSet($fieldset, $scaffoldVars, $this->settings['listSettings']) :
164:                 $this->ExtendedFieldSet->fieldSet($fieldset, $scaffoldVars);
165:     }
166: 
167:     private function _getCurrentController() {
168:         return $this->CakeLayers->getController();
169:     }
170: 
171:     private function _extractFieldData($label, $value, $type) {
172:         $fieldName = null;
173:         if (is_array($label)) {
174:             $labelArray = $label;
175:             foreach (array('label', 'fieldName', 'value', 'type') as $option) {
176:                 if (!empty($labelArray[$option])) {
177:                     ${$option} = $labelArray[$option];
178:                 }
179:             }
180:         }
181: 
182:         if (empty($type)) {
183:             $type = ViewUtilHelper::VALUE_TYPE_UNKNOWN;
184:         }
185: 
186:         if ($type == ViewUtilHelper::VALUE_TYPE_UNKNOWN && !empty($fieldName)) {
187:             if (($fieldInfo = $this->_getFieldInfo($fieldName))) {
188:                 if ($fieldInfo['type'] == 'boolean') {
189:                     $type = ViewUtilHelper::VALUE_TYPE_BOOLEAN;
190:                 }
191:             }
192:         }
193: 
194:         return compact('label', 'fieldName', 'value', 'type');
195:     }
196: 
197:     private function _getFieldInfo($fieldName) {
198:         $schema = $this->_getCurrentController()->{$this->_getCurrentController()->modelClass}->schema();
199: 
200:         if (!empty($schema[$fieldName])) {
201:             return $schema[$fieldName];
202:         } else {
203:             return false;
204:         }
205:     }
206: 
207: }
208: 
API documentation generated by ApiGen 2.8.0