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


PHP Attribute::renderDataType方法代码示例

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


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

示例1: htmlFormElementForAttributeSearch

 /**
  *
  */
 public function htmlFormElementForAttributeSearch($po_request, $pm_element_code_or_id, $pa_options = null)
 {
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     if (!($t_element = $this->_getElementInstance($pm_element_code_or_id))) {
         return false;
     }
     $vb_is_sub_element = (bool) $t_element->get('parent_id');
     $t_parent = $vb_is_sub_element ? $this->_getElementInstance($t_element->get('parent_id')) : null;
     while ($vb_is_sub_element && $t_parent->get('datatype') == 0 && $t_parent->get('parent_id') > 0) {
         $t_parent = $this->_getElementInstance($t_parent->get('parent_id'));
     }
     $vs_element_code = $t_element->get('element_code');
     // get all elements of this element set
     $va_element_set = $vb_is_sub_element ? $t_parent->getElementsInSet() : $t_element->getElementsInSet();
     if ($vb_is_sub_element) {
         foreach ($va_element_set as $vn_i => $va_element) {
             if ($va_element['element_code'] !== $vs_element_code) {
                 unset($va_element_set[$vn_i]);
             }
         }
     }
     $t_attr = new ca_attributes();
     $t_attr->purify($this->purify());
     $va_element_codes = array();
     $va_elements_by_container = array();
     if (sizeof($va_element_set) > 1) {
         $vs_format = isset($pa_options['multivalueFormat']) ? $pa_options['multivalueFormat'] : null;
     } else {
         $vs_format = isset($pa_options['format']) ? $pa_options['format'] : null;
     }
     $pa_options['format'] = $vs_format;
     foreach ($va_element_set as $va_element) {
         $va_override_options = array();
         if ($va_element['datatype'] == 0) {
             // containers are not active form elements
             continue;
         }
         $va_label = $this->getAttributeLabelAndDescription($va_element['element_id']);
         $vs_subelement_code = $this->tableName() . '.' . ($vb_is_sub_element ? $t_parent->get('element_code') . '.' : '') . ($vs_element_code !== $va_element['element_code'] ? "{$vs_element_code}." : "") . $va_element['element_code'];
         $vs_value = isset($pa_options['values']) && isset($pa_options['values'][$vs_subelement_code]) ? $pa_options['values'][$vs_subelement_code] : '';
         $va_element_opts = array_merge(array('label' => $va_label['name'], 'description' => $va_label['description'], 't_subject' => $this, 'request' => $po_request, 'class' => $pa_options['class'], 'nullOption' => '-', 'value' => $vs_value, 'forSearch' => true, 'render' => isset($va_element['settings']['render']) && $va_element['settings']['render'] == 'lookup' ? $va_element['settings']['render'] : isset($pa_options['render']) ? $pa_options['render'] : 'select'), array_merge($pa_options, $va_override_options));
         if (caGetOption('forSimpleForm', $pa_options, false)) {
             unset($va_element_opts['nullOption']);
         }
         // We don't want to pass the entire set of values to ca_attributes::attributeHtmlFormElement() since it'll treat it as a simple list
         // of values for an individual element and the 'values' array is actually set to values for *all* elements in the form
         unset($va_element_opts['values']);
         $va_element_opts['values'] = '';
         // ... replace name of form element
         $vs_fld_name = $vs_subelement_code;
         //str_replace('.', '_', $vs_subelement_code);
         if (caGetOption('asArrayElement', $pa_options, false)) {
             $vs_fld_name .= "[]";
         }
         if ($vs_force_value = caGetOption('force', $pa_options, false)) {
             $vs_form_element = caHTMLHiddenInput($vs_fld_name, array('value' => $vs_force_value));
         } else {
             $vs_form_element = ca_attributes::attributeHtmlFormElement($va_element, $va_element_opts);
             //
             // prep element for use as search element
             //
             // ... replace value
             $vs_form_element = str_replace('{{' . $va_element['element_id'] . '}}', $vs_value, $vs_form_element);
             // escape any special characters in jQuery selectors
             $vs_form_element = str_replace("jQuery('#{fieldNamePrefix}" . $va_element['element_id'] . "_{n}')", "jQuery('#" . str_replace(array("[", "]", "."), array("\\\\[", "\\\\]", "\\\\."), $vs_fld_name) . "')", $vs_form_element);
             $vs_form_element = str_replace('{fieldNamePrefix}' . $va_element['element_id'] . '_{n}', $vs_fld_name, $vs_form_element);
             $vs_form_element = str_replace('{n}', '', $vs_form_element);
             $vs_form_element = str_replace('{' . $va_element['element_id'] . '}', '', $vs_form_element);
         }
         $va_elements_by_container[$va_element['parent_id'] ? $va_element['parent_id'] : $va_element['element_id']][] = $vs_form_element;
         // If the elements datatype returns true from renderDataType, then force render the element
         if (Attribute::renderDataType($va_element)) {
             return array_pop($va_elements_by_container[$va_element['element_id']]);
         }
         $va_element_ids[] = $va_element['element_id'];
     }
     $vs_view_path = isset($pa_options['viewPath']) && $pa_options['viewPath'] ? $pa_options['viewPath'] : $po_request->getViewsDirectoryPath();
     $o_view = new View($po_request, "{$vs_view_path}/bundles/");
     $o_view->setVar('request', $po_request);
     $o_view->setVar('elements', $va_elements_by_container);
     $o_view->setVar('element_ids', $va_element_ids);
     $o_view->setVar('element_set_label', $this->getAttributeLabel($t_element->get('element_id')));
     return $o_view->render(caGetOption('view', $pa_options, 'ca_search_form_attributes.php'));
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:89,代码来源:BaseModelWithAttributes.php

示例2: htmlFormElementForAttributeSearch

 /**
  *
  */
 public function htmlFormElementForAttributeSearch($po_request, $pm_element_code_or_id, $pa_options = null)
 {
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     if (!($t_element = $this->_getElementInstance($pm_element_code_or_id))) {
         return false;
     }
     if ($t_element->get('parent_id')) {
         $this->postError(1930, _t('Element is not the root of the element set'), 'BaseModelWithAttributes->htmlFormElementForAttributeSearch()');
         return false;
     }
     // get all elements of this element set
     $va_element_set = $t_element->getElementsInSet();
     $t_attr = new ca_attributes();
     $t_attr->purify($this->purify());
     $va_element_codes = array();
     $va_elements_by_container = array();
     if (sizeof($va_element_set) > 1) {
         $vs_format = isset($pa_options['multivalueFormat']) ? $pa_options['multivalueFormat'] : null;
     } else {
         $vs_format = isset($pa_options['format']) ? $pa_options['format'] : null;
     }
     $pa_options['format'] = $vs_format;
     if (sizeof($va_element_set) > 1 && isset($pa_options['width']) && $pa_options['width'] > 0) {
         if (($pa_options['width'] = ceil($pa_options['width'] / sizeof($va_element_set))) < 20) {
             $pa_options['width'] = 20;
         }
     }
     foreach ($va_element_set as $va_element) {
         $va_override_options = array();
         if ($va_element['datatype'] == 0) {
             // containers are not active form elements
             continue;
         }
         $va_label = $this->getAttributeLabelAndDescription($va_element['element_id']);
         $vs_element = $this->tableName() . '.' . $va_element['element_code'];
         $vs_value = isset($pa_options['values']) && isset($pa_options['values'][$vs_element]) ? $pa_options['values'][$vs_element] : '';
         $va_element_opts = array_merge(array('label' => $va_label['name'], 'description' => $va_label['description'], 't_subject' => $this, 'request' => $po_request, 'nullOption' => '-', 'value' => $vs_value, 'forSearch' => true), array_merge($pa_options, $va_override_options));
         // We don't want to pass the entire set of values to ca_attributes::attributeHtmlFormElement() since it'll treat it as a simple list
         // of values for an individual element and the 'values' array is actually set to values for *all* elements in the form
         unset($va_element_opts['values']);
         $vs_form_element = ca_attributes::attributeHtmlFormElement($va_element, $va_element_opts);
         //
         // prep element for use as search element
         //
         // ... replace value
         $vs_form_element = str_replace('{{' . $va_element['element_id'] . '}}', $vs_value, $vs_form_element);
         // ... replace name of form element
         $vs_form_element = str_replace('{fieldNamePrefix}' . $va_element['element_id'] . '_{n}', str_replace('.', '_', $this->tableName() . '.' . $va_element['element_code']), $vs_form_element);
         $va_elements_by_container[$va_element['parent_id'] ? $va_element['parent_id'] : $va_element['element_id']][] = $vs_form_element;
         //if the elements datatype returns true from renderDataType, then force render the element
         if (Attribute::renderDataType($va_element)) {
             return array_pop($va_elements_by_container[$va_element['element_id']]);
         }
         $va_element_ids[] = $va_element['element_id'];
     }
     $vs_view_path = isset($pa_options['viewPath']) && $pa_options['viewPath'] ? $pa_options['viewPath'] : $po_request->getViewsDirectoryPath();
     $o_view = new View($po_request, "{$vs_view_path}/bundles/");
     $o_view->setVar('request', $po_request);
     $o_view->setVar('elements', $va_elements_by_container);
     $o_view->setVar('element_ids', $va_element_ids);
     $o_view->setVar('element_set_label', $this->getAttributeLabel($t_element->get('element_id')));
     return $o_view->render('ca_search_form_attributes.php');
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:68,代码来源:BaseModelWithAttributes.php


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