当前位置: 首页>>代码示例>>PHP>>正文


PHP MUtil_Model_ModelAbstract::has方法代码示例

本文整理汇总了PHP中MUtil_Model_ModelAbstract::has方法的典型用法代码示例。如果您正苦于以下问题:PHP MUtil_Model_ModelAbstract::has方法的具体用法?PHP MUtil_Model_ModelAbstract::has怎么用?PHP MUtil_Model_ModelAbstract::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MUtil_Model_ModelAbstract的用法示例。


在下文中一共展示了MUtil_Model_ModelAbstract::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addShowTableRows

 /**
  * Adds rows from the model to the bridge that creates the browse table.
  *
  * Overrule this function to add different columns to the browse table, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function addShowTableRows(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $items = $model->getItemsOrdered();
     foreach ($items as $name) {
         if ($model->get($name, 'type') === \MUtil_Model::TYPE_CHILD_MODEL) {
             $this->submodel = $model->get($name, 'model');
             $subitems = $this->submodel->getItemsOrdered();
         }
     }
     if (isset($subitems) && is_array($subitems)) {
         $items = array_diff($items, $subitems);
     }
     foreach ($items as $name) {
         if ($label = $model->get($name, 'label')) {
             $bridge->addItem($name, $label);
         }
     }
     /*if ($subitems) {
           $bridge->addItem('gctt', 'moo');
       }*/
     if ($model->has('row_class')) {
         // Make sure deactivated rounds are show as deleted
         foreach ($bridge->getTable()->tbody() as $tr) {
             foreach ($tr as $td) {
                 if ('td' === $td->tagName) {
                     $td->appendAttrib('class', $bridge->row_class);
                 }
             }
         }
     }
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:41,代码来源:CommTemplateShowSnippet.php

示例2: addBrowseTableColumns

 /**
  * Adds columns from the model to the bridge that creates the browse table.
  *
  * Overrule this function to add different columns to the browse table, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_TableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     if ($model->has('row_class')) {
         $bridge->getTable()->tbody()->getFirst(true)->appendAttrib('class', $bridge->row_class);
     }
     if ($editMenuItem = $this->getEditMenuItem()) {
         $bridge->addItemLink($editMenuItem->toActionLinkLower($this->request, $bridge));
     }
     // make sure search results are highlighted
     $this->applyTextMarker();
     if ($this->columns) {
         foreach ($this->columns as $column) {
             call_user_func_array(array($bridge, 'addMultiSort'), $column);
         }
     } elseif ($this->sortableLinks) {
         foreach ($model->getItemsOrdered() as $name) {
             if ($label = $model->get($name, 'label')) {
                 $bridge->addSortable($name, $label);
             }
         }
     } else {
         foreach ($model->getItemsOrdered() as $name) {
             if ($label = $model->get($name, 'label')) {
                 $bridge->add($name, $label);
             }
         }
     }
     if ($deleteMenuItem = $this->findMenuItem($this->request->getControllerName(), 'delete')) {
         $bridge->addItemLink($deleteMenuItem->toActionLinkLower($this->request, $bridge));
     }
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:41,代码来源:TableSnippet.php

示例3: _addIf

 private function _addIf(array $names, \MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     foreach ($names as $name) {
         if ($model->has($name, 'label')) {
             $bridge->addItem($name);
         }
     }
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:8,代码来源:ShowRoundStepSnippet.php

示例4: saveValue

 /**
  * A ModelAbstract->setOnSave() function that tracks the change
  *
  * @see \MUtil_Model_ModelAbstract
  *
  * @param mixed $value The value being saved
  * @param boolean $isNew True when a new item is being saved
  * @param string $name The name of the current field
  * @param array $context Optional, the other values being saved
  * @return string Of the values concatenated
  */
 public function saveValue($value, $isNew = false, $name = null, array $context = array())
 {
     // \MUtil_Echo::track($value, $this->_changedValue);
     // Once the value is set (and e.g. stored in the database) do not overwrite it
     if ($this->_changedValue == $value) {
         return $value;
     }
     $compare = $this->_model->get($name, __CLASS__);
     if (!(is_array($compare) && 2 === count($compare))) {
         // Actually a valid setting, do nothring
         return $value;
     }
     list($trackedField, $oldValueField) = $compare;
     if (!isset($context[$trackedField], $context[$oldValueField])) {
         return $value;
     }
     if (!($context[$trackedField] && $context[$oldValueField])) {
         return $context[$trackedField] || $context[$oldValueField] ? $this->_changedValue : $this->_unchangedValue;
     }
     $storageFormat = $this->_model->get($trackedField, 'storageFormat');
     if (!$storageFormat) {
         return $context[$trackedField] == $context[$oldValueField] ? $this->_unchangedValue : $this->_changedValue;
     }
     if ($context[$oldValueField] instanceof \Zend_Date) {
         $oldValue = $context[$oldValueField];
     } else {
         $oldValue = new \MUtil_Date($context[$oldValueField], $storageFormat);
     }
     if ($context[$trackedField] instanceof \Zend_Date) {
         $currentValue = $context[$trackedField];
     } elseif (\Zend_Date::isDate($context[$trackedField], $storageFormat)) {
         $currentValue = new \MUtil_Date($context[$trackedField], $storageFormat);
     } else {
         if ($this->_model->has($trackedField, 'dateFormat')) {
             $secondFormat = $this->_model->get($trackedField, 'dateFormat');
         } else {
             $secondFormat = \MUtil_Model_Bridge_FormBridge::getFixedOption('date', 'dateFormat');
         }
         if (!\Zend_Date::isDate($context[$trackedField], $secondFormat)) {
             // Cannot compare, do nothing
             return $value;
         }
         $currentValue = new \MUtil_Date($context[$trackedField], $secondFormat);
     }
     // \MUtil_Echo::track($trackedField, $oldValueField, $oldValue->toString(), $currentValue->toString(), $oldValue->getTimestamp() === $currentValue->getTimestamp());
     return $oldValue->getTimestamp() === $currentValue->getTimestamp() ? $this->_unchangedValue : $this->_changedValue;
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:58,代码来源:ChangeTracker.php

示例5: getFieldInfo

 /**
  * If the transformer add's fields, these should be returned here.
  * Called in $model->AddTransformer(), so the transformer MUST
  * know which fields to add by then (optionally using the model
  * for that).
  *
  * @param \MUtil_Model_ModelAbstract $model The parent model
  * @return array Of filedname => set() values
  */
 public function getFieldInfo(\MUtil_Model_ModelAbstract $model)
 {
     $data = array();
     foreach ($this->_subModels as $sub) {
         foreach ($sub->getItemNames() as $name) {
             if (!$model->has($name)) {
                 $data[$name] = $sub->get($name);
                 $data[$name]['no_text_search'] = true;
                 // Remove unsuited data
                 unset($data[$name]['table'], $data[$name]['column_expression']);
                 unset($data[$name]['label']);
                 $data[$name]['elementClass'] = 'None';
                 // Remove the submodel's own transformers to prevent changed/created to show up in the data array instead of only in the nested info
                 unset($data[$name][\MUtil_Model_ModelAbstract::LOAD_TRANSFORMER]);
                 unset($data[$name][\MUtil_Model_ModelAbstract::SAVE_TRANSFORMER]);
             }
         }
     }
     return $data;
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:29,代码来源:NestedTransformer.php

示例6: addBrowseTableColumns

 /**
  * Adds columns from the model to the bridge that creates the browse table.
  *
  * Overrule this function to add different columns to the browse table, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_TableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     if ($model->has('row_class')) {
         $bridge->getTable()->tbody()->getFirst(true)->appendAttrib('class', $bridge->row_class);
     }
     if ($this->showMenu) {
         $showMenuItems = $this->getShowMenuItems();
         foreach ($showMenuItems as $menuItem) {
             $bridge->addItemLink($menuItem->toActionLinkLower($this->request, $bridge));
         }
     }
     // Newline placeholder
     $br = \MUtil_Html::create('br');
     $by = \MUtil_Html::raw($this->_(' / '));
     $sp = \MUtil_Html::raw(' ');
     // make sure search results are highlighted
     $this->applyTextMarker();
     $bridge->addMultiSort('grco_created', $br, 'gr2o_patient_nr', $sp, 'respondent_name', $br, 'grco_address', $br, 'gtr_track_name');
     $bridge->addMultiSort('grco_id_token', $br, 'assigned_by', $br, 'grco_sender', $br, 'gsu_survey_name');
     $bridge->addMultiSort('status', $by, 'filler', $br, 'grco_topic');
     if ($this->showMenu) {
         $items = $this->findMenuItems('track', 'show');
         $links = array();
         $params = array('gto_id_token' => $bridge->gto_id_token, \Gems_Model::ID_TYPE => 'token');
         $title = \MUtil_Html::create('strong', $this->_('+'));
         foreach ($items as $item) {
             if ($item instanceof \Gems_Menu_SubMenuItem) {
                 $bridge->addItemLink($item->toActionLinkLower($this->request, $params, $title));
             }
         }
     }
     $bridge->getTable()->appendAttrib('class', 'compliance');
     $tbody = $bridge->tbody();
     $td = $tbody[0][0];
     $td->appendAttrib('class', \MUtil_Lazy::method($this->util->getTokenData(), 'getStatusClass', $bridge->getLazy('status')));
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:46,代码来源:MailLogBrowseSnippet.php

示例7: checkPicker

 /**
  * Checks and updates the on and off strings when one of the effecteds is a date, time or datetime field
  * 
  * @param string $valueOn
  * @param string $valueOff
  */
 protected function checkPicker(&$valueOn, &$valueOff)
 {
     $effecteds = array_keys($this->getEffecteds());
     foreach ($effecteds as $field) {
         if ($this->model instanceof \MUtil_Model_ModelAbstract && $this->model->has($field)) {
             $modelItemType = $this->model->get($field, 'type');
             $dateFormat = $this->model->get($field, 'dateFormat');
             $timeFormat = $this->model->get($field, 'timeFormat');
             switch ($modelItemType) {
                 case \MUtil_Model::TYPE_DATE:
                 case \MUtil_Model::TYPE_TIME:
                 case \MUtil_Model::TYPE_DATETIME:
                     $picker = 'datepicker';
                     break;
                 default:
                     $picker = '';
                     break;
             }
             if (!empty($picker)) {
                 // If none set, get the locale default dateformat
                 if (!$dateFormat && !$timeFormat && \Zend_Registry::isRegistered('Zend_Locale')) {
                     $dateFormat = \ZendX_JQuery_View_Helper_DatePicker::resolveZendLocaleToDatePickerFormat();
                 }
                 if ($dateFormat) {
                     if ($timeFormat) {
                         $picker = 'datetimepicker';
                     }
                 } elseif ($timeFormat) {
                     $picker = 'timepicker';
                 }
                 $valueOn .= "\$('#{$field}').{$picker}('enable');";
                 $valueOff .= "\$('#{$field}').{$picker}('disable');";
             }
         }
     }
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:42,代码来源:OnOffElementsDependency.php

示例8: addBrowseTableColumns

 /**
  * Adds columns from the model to the bridge that creates the browse table.
  *
  * Overrule this function to add different columns to the browse table, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_TableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     if ($model->has('row_class')) {
         $bridge->getTable()->tbody()->getFirst(true)->appendAttrib('class', $bridge->row_class);
     }
     if ($this->showMenu) {
         $showMenuItems = $this->getShowMenuItems();
         foreach ($showMenuItems as $menuItem) {
             $bridge->addItemLink($menuItem->toActionLinkLower($this->request, $bridge));
         }
     }
     // make sure search results are highlighted
     $this->applyTextMarker();
     parent::addBrowseTableColumns($bridge, $model);
     if ($this->showMenu) {
         $editMenuItems = $this->getEditMenuItems();
         foreach ($editMenuItems as $menuItem) {
             $bridge->addItemLink($menuItem->toActionLinkLower($this->request, $bridge));
         }
     }
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:31,代码来源:ModelTableSnippetAbstract.php

示例9: applyToModel

 /**
  * Use this function for a default application of this dependency to the model
  *
  * @param \MUtil_Model_ModelAbstract $model Try not to store the model as variabe in the dependency (keep it simple)
  */
 public function applyToModel(\MUtil_Model_ModelAbstract $model)
 {
     if ($this->applyOnChange) {
         foreach ($this->getDependsOn() as $name) {
             if ($model->is($name, 'elementClass', 'Checkbox')) {
                 if (!$model->has($name, 'onclick')) {
                     $model->set($name, 'onclick', $this->onChangeJs);
                 }
             } else {
                 if (!$model->has($name, 'onchange')) {
                     $model->set($name, 'onchange', $this->onChangeJs);
                 }
             }
         }
     }
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:21,代码来源:DependencyAbstract.php

示例10: addShowTableRows

 /**
  * Adds rows from the model to the bridge that creates the browse table.
  *
  * Overrule this function to add different columns to the browse table, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function addShowTableRows(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     foreach ($model->getItemsOrdered() as $name) {
         if ($label = $model->get($name, 'label')) {
             $bridge->addItem($name, $label);
         }
     }
     if ($model->has('row_class')) {
         // Make sure deactivated rounds are show as deleted
         foreach ($bridge->getTable()->tbody() as $tr) {
             foreach ($tr as $td) {
                 if ('td' === $td->tagName) {
                     $td->appendAttrib('class', $bridge->row_class);
                 }
             }
         }
     }
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:28,代码来源:ModelVerticalTableSnippetAbstract.php

示例11: addBrowseTableColumns

 /**
  * Adds columns from the model to the bridge that creates the browse table.
  *
  * Overrule this function to add different columns to the browse table, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_TableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $br = \MUtil_Html::create('br');
     if ($this->showSelected) {
         $selectedClass = \MUtil_Lazy::iff(\MUtil_Lazy::comp($bridge->gto_id_token, '==', $this->tokenId), 'selectedColumn', null);
     } else {
         $selectedClass = null;
     }
     $bridge->th($this->_('Status'));
     $td = $bridge->tdh(\MUtil_Lazy::first($bridge->grc_description, $this->_('OK')));
     $td->appendAttrib('class', $selectedClass);
     $bridge->th($this->_('Question'));
     if ($model->has('grr_name') && $model->has('gtf_field_name')) {
         $td = $bridge->tdh(\MUtil_Lazy::iif($bridge->grr_name, array($bridge->grr_name, $br)), \MUtil_Lazy::iif($bridge->gtf_field_name, array($bridge->gtf_field_name, $br)), $bridge->gto_round_description, \MUtil_Lazy::iif($bridge->gto_round_description, $br), \MUtil_Lazy::iif($bridge->gto_completion_time, $bridge->gto_completion_time, $bridge->gto_valid_from));
     } else {
         $td = $bridge->tdh($bridge->gto_round_description, \MUtil_Lazy::iif($bridge->gto_round_description, $br), \MUtil_Lazy::iif($bridge->gto_completion_time, $bridge->gto_completion_time, $bridge->gto_valid_from));
     }
     $td->appendAttrib('class', $selectedClass);
     $td->appendAttrib('class', $bridge->row_class);
     // Apply filter on the answers displayed
     $answerNames = $model->getItemsOrdered();
     if ($this->answerFilter instanceof \Gems_Tracker_Snippets_AnswerNameFilterInterface) {
         $answerNames = $this->answerFilter->filterAnswers($bridge, $model, $answerNames);
     }
     foreach ($answerNames as $name) {
         $label = $model->get($name, 'label');
         if (null !== $label) {
             // Was strlen($label), but this ruled out empty sub-questions
             $bridge->thd($label, array('class' => $model->get($name, 'thClass')));
             $td = $bridge->td($bridge->{$name});
             $td->appendAttrib('class', 'answer');
             $td->appendAttrib('class', $selectedClass);
             $td->appendAttrib('class', $bridge->row_class);
         }
     }
     $bridge->th($this->_('Token'));
     $tokenUpper = $bridge->gto_id_token->strtoupper();
     if ($this->showTakeButton && ($menuItem = $this->menu->find(array('controller' => 'ask', 'action' => 'take', 'allowed' => true)))) {
         $source = new \Gems_Menu_ParameterSource();
         $source->setTokenId($bridge->gto_id_token);
         $source->offsetSet('can_be_taken', $bridge->can_be_taken);
         $link = $menuItem->toActionLink($source);
         if ($link) {
             $link->title = array($this->_('Token'), $tokenUpper);
         }
         $td = $bridge->tdh($bridge->can_be_taken->if($link, $tokenUpper));
     } else {
         $td = $bridge->tdh($tokenUpper);
     }
     $td->appendAttrib('class', $selectedClass);
     $td->appendAttrib('class', $bridge->row_class);
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:62,代码来源:AnswerModelSnippetGeneric.php

示例12: getFieldInfo

 /**
  * If the transformer add's fields, these should be returned here.
  * Called in $model->AddTransformer(), so the transformer MUST
  * know which fields to add by then (optionally using the model
  * for that).
  *
  * @param \MUtil_Model_ModelAbstract $model The parent model
  * @return array Of filedname => set() values
  */
 public function getFieldInfo(\MUtil_Model_ModelAbstract $model)
 {
     $data = array();
     foreach ($this->_subModels as $sub) {
         foreach ($sub->getItemNames() as $name) {
             if (!$model->has($name)) {
                 $data[$name] = $sub->get($name);
                 $data[$name]['no_text_search'] = true;
                 // Remove unsuited data
                 unset($data[$name]['table'], $data[$name]['column_expression']);
             }
         }
     }
     return $data;
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:24,代码来源:SubmodelTransformerAbstract.php

示例13: applyToModel

 /**
  * Applies the fieldmap data to the model
  *
  * @param \MUtil_Model_ModelAbstract $model
  */
 public function applyToModel(\MUtil_Model_ModelAbstract $model)
 {
     $map = $this->_getMap();
     $oldfld = null;
     $parent = null;
     foreach ($map as $name => $field) {
         $tmpres = array();
         $tmpres['thClass'] = \Gems_Tracker_SurveyModel::CLASS_MAIN_QUESTION;
         $tmpres['group'] = $field['gid'];
         $tmpres['type'] = $this->_getType($field);
         $tmpres['survey_question'] = true;
         if ($tmpres['type'] === \MUtil_Model::TYPE_DATE) {
             $tmpres['storageFormat'] = 'yyyy-MM-dd';
             $tmpres['dateFormat'] = 'dd MMMM yyyy';
             // $tmpres['formatFunction']
         }
         if ($tmpres['type'] === \MUtil_Model::TYPE_DATETIME) {
             $tmpres['storageFormat'] = 'yyyy-MM-dd HH:mm:ss';
             $tmpres['dateFormat'] = 'dd MMMM yyyy HH:mm';
             // $tmpres['formatFunction']
         }
         if ($tmpres['type'] === \MUtil_Model::TYPE_TIME) {
             $tmpres['storageFormat'] = 'yyyy-MM-dd HH:mm:ss';
             $tmpres['dateFormat'] = 'HH:mm:ss';
             // $tmpres['formatFunction']
         }
         // \MUtil_Echo::track($field);
         $oldQuestion = isset($oldfld['question']) ? $oldfld['question'] : null;
         if (isset($field['question']) && (!isset($oldfld) || $oldQuestion !== $field['question'])) {
             $tmpres['label'] = \MUtil_Html::raw($this->removeMarkup($field['question']));
         }
         if (isset($field['help']) && $field['help']) {
             $tmpres['description'] = \MUtil_Html::raw($this->removeMarkup($field['help']));
         }
         // Juggle the labels for sub-questions etc..
         if (isset($field['sq_question'])) {
             if (isset($tmpres['label'])) {
                 // Add non answered question for grouping and make it the current parent
                 //$parent = '_' . $name . '_';
                 $parent = $field['title'];
                 $model->set($parent, $tmpres);
                 $model->set($parent, 'type', \MUtil_Model::TYPE_NOVALUE);
             }
             if (isset($field['sq_question1'])) {
                 $tmpres['label'] = \MUtil_Html::raw(sprintf($this->translate->_('%s: %s'), $this->removeMarkup($field['sq_question']), $this->removeMarkup($field['sq_question1'])));
             } else {
                 $tmpres['label'] = \MUtil_Html::raw($this->removeMarkup($field['sq_question']));
             }
             $tmpres['thClass'] = \Gems_Tracker_SurveyModel::CLASS_SUB_QUESTION;
         }
         if ($options = $this->_getMultiOptions($field)) {
             $tmpres['multiOptions'] = $options;
         }
         // Code does not have to be unique. So if a title is used
         // twice we only use it for the first result.
         if (isset($field['code']) && !$model->has($field['code'])) {
             $name = $field['code'];
         }
         // Parent storage
         if (\Gems_Tracker_SurveyModel::CLASS_MAIN_QUESTION === $tmpres['thClass']) {
             $parent = $name;
         } elseif ($parent) {
             // Add the name of the parent item
             $tmpres['parent_question'] = $parent;
         }
         $model->set($name, $tmpres);
         $oldfld = $field;
     }
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:74,代码来源:LimeSurvey1m9FieldMap.php

示例14: addFormElements

 /**
  * Adds elements from the model to the bridge that creates the form.
  *
  * Overrule this function to add different elements to the browse table, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @param array $data The data that will later be loaded into the form
  * @param optional boolean $new Form should be for a new element
  * @return void|array When an array of new values is return, these are used to update the $data array in the calling function
  */
 protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model, array $data, $new = false)
 {
     foreach ($model->getItemsOrdered() as $name) {
         if ($model->has($name, 'label') || $model->has($name, 'elementClass')) {
             $bridge->add($name);
         } else {
             $bridge->addHidden($name);
         }
     }
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:22,代码来源:ModelActionAbstract.php

示例15: getTranslatorTable

 /**
  * Get the descriptions of the translators
  *
  * @param mixed $for A single translator, an array of translators or all translators if null;
  * @return array key -> description
  */
 protected function getTranslatorTable($for = null)
 {
     if (!$this->targetModel) {
         return array();
     }
     if (null === $for) {
         $for = $this->getTranslatorDescriptions();
     } elseif (!is_array($for)) {
         $descriptors = $this->getTranslatorDescriptions();
         if (!isset($descriptors[$for])) {
             throw new \Zend_Exception("Unknown translator {$for} passed to " . __CLASS__ . '->' . __FUNCTION__ . '()');
         }
         $for = array($for => $descriptors[$for]);
     }
     $requiredKey = $this->_('Required');
     $minimal = array($requiredKey => ' ');
     // Array for making sure all fields are there
     $results = array_fill_keys($this->targetModel->getItemsOrdered(), array());
     $transCount = count($for);
     foreach ($for as $transKey => $transName) {
         if (!isset($this->importTranslators[$transKey])) {
             throw new \Zend_Exception("Unknown translator {$for} passed to " . __CLASS__ . '->' . __FUNCTION__ . '()');
         }
         $translator = $this->importTranslators[$transKey];
         if ($translator instanceof \MUtil_Model_ModelTranslatorInterface) {
             $translator->setTargetModel($this->targetModel);
             $translations = $translator->getFieldsTranslations();
             $requireds = $translator->getRequiredFields();
             $minimal[$transName] = ' ';
             foreach ($translations as $source => $target) {
                 // Skip numeric fields
                 if (!is_int($source)) {
                     $required = isset($requireds[$source]);
                     // Add required row
                     $results[$target][$requiredKey][$transName] = $required;
                     if (trim($required)) {
                         $results[$target][$transName] = new \MUtil_Html_HtmlElement('strong', $source);
                     } else {
                         $results[$target][$transName] = $source;
                     }
                 }
             }
         }
     }
     $output = array();
     foreach ($results as $name => $resultRow) {
         if (count($resultRow) > 1) {
             // Always first
             $requireds = count(array_filter($resultRow[$requiredKey]));
             $resultRow[$requiredKey] = $requireds ? $requireds == $transCount ? $this->_('Yes') : $this->_('For bold') : ' ';
             if ($this->targetModel->has($name, 'label')) {
                 $label = $this->targetModel->get($name, 'label');
             } else {
                 $label = $name;
             }
             // $field = $this->_targetModel->get($name, 'type', 'maxlength', 'label', 'required');
             switch ($this->targetModel->get($name, 'type')) {
                 case \MUtil_Model::TYPE_NOVALUE:
                     unset($results[$name]);
                     continue 2;
                 case \MUtil_Model::TYPE_NUMERIC:
                     $maxlength = $this->targetModel->get($name, 'maxlength');
                     if ($maxlength) {
                         $decimals = $this->targetModel->get($name, 'decimals');
                         if ($decimals) {
                             $type = sprintf($this->_('A number of length %d, with a precision of %d digits after the period.'), $maxlength, $decimals);
                         } else {
                             $type = sprintf($this->_('A whole number of length %d.'), $maxlength);
                         }
                     } else {
                         $type = $this->_('A numeric value');
                     }
                     break;
                 case \MUtil_Model::TYPE_DATE:
                     $type = $this->_('Date value using ISO 8601: yyyy-mm-dd');
                     break;
                 case \MUtil_Model::TYPE_DATETIME:
                     $type = $this->_('Datetime value using ISO 8601: yyyy-mm-ddThh:mm::ss[+-hh:mm]');
                     break;
                 case \MUtil_Model::TYPE_TIME:
                     $type = $this->_('Time value using ISO 8601: hh:mm::ss[+-hh:mm]');
                     break;
                 default:
                     $maxlength = $this->targetModel->get($name, 'maxlength');
                     $minlength = $this->targetModel->get($name, 'minlength');
                     if ($maxlength && $minlength) {
                         $type = sprintf($this->plural('Text, between %d and %d character', 'Text, between %d and %d characters', $maxlength), $minlength, $maxlength);
                     } elseif ($maxlength) {
                         $type = sprintf($this->plural('Text, %d character', 'Text, %d characters', $maxlength), $maxlength);
                     } elseif ($minlength) {
                         $type = sprintf($this->plural('Text, at least %d character', 'Text, at least %d characters', $minlength), $minlength);
                     } else {
                         $type = $this->_('Text');
                     }
//.........这里部分代码省略.........
开发者ID:GemsTracker,项目名称:MUtil,代码行数:101,代码来源:ModelImportSnippet.php


注:本文中的MUtil_Model_ModelAbstract::has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。