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


PHP FlexicontentFields::renderField方法代码示例

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


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

示例1: array

 /**
  * Method to get the fields in their positions
  * 
  * @access private
  * @return object
  * @since 1.5
  */
 static function &renderPositions(&$items, $view = FLEXI_ITEMVIEW, $params = null, $use_tmpl = true, &$_rendered = array())
 {
     if (!$items) {
         return;
     }
     if (!$params) {
         return $items;
     }
     if ($view == 'category') {
         $layout = 'clayout';
     }
     if ($view == FLEXI_ITEMVIEW) {
         $layout = 'ilayout';
     }
     // field's source code, can use this JRequest variable, to detect who rendered the fields (e.g. they can detect rendering from 'module')
     JRequest::setVar("flexi_callview", $view);
     if ($use_tmpl && ($view == 'category' || $view == FLEXI_ITEMVIEW)) {
         $fbypos = flexicontent_tmpl::getFieldsByPositions($params->get($layout, 'default'), $view);
     } else {
         // $view == 'module', or other
         // Create a fake template position, for fields defined via parameters
         $fbypos[0] = new stdClass();
         $fbypos[0]->fields = explode(',', $params->get('fields'));
         $fbypos[0]->methods = explode(',', $params->get('methods'));
         $fbypos[0]->position = $view;
     }
     $always_create_fields_display = $params->get('always_create_fields_display', 0);
     // Render some fields by default, this is done for compatibility reasons, but avoid rendering these fields again (2nd time),
     // since some of them may also be in template positions. NOTE: this is not needed since renderField() should detect this case
     if ($always_create_fields_display != 3) {
         // value 3 means never create for any view (blog template incompatible)
         $item = reset($items);
         // get the first item ... so that we can get the name of CORE fields out of it
         // 'description' item field is implicitly used by category layout of some templates (blog), render it
         $custom_values = null;
         if ($view == 'category') {
             if (isset($item->fields['text']) && !isset($_rendered['ALL']['text'])) {
                 $_field_name_ = 'text';
                 FlexicontentFields::renderField($items, $_field_name_, $custom_values, $method = 'display', $view);
             }
             $_rendered['ALL']['text'] = 1;
         } else {
             if ($view == FLEXI_ITEMVIEW) {
                 foreach ($item->fields as $field) {
                     if ($field->iscore && !isset($_rendered['ALL'][$field->name])) {
                         $_field_name_ = $field->name;
                         FlexicontentFields::renderField($items, $_field_name_, $custom_values, $method = 'display', $view);
                     }
                 }
                 $_rendered['ALL']['core'] = 1;
             }
         }
     }
     // *** RENDER fields on DEMAND, (if present in template positions)
     foreach ($fbypos as $pos) {
         // RENDER fields if they are present in a template position (or in a dummy template position ... e.g. when called by module)
         foreach ($pos->fields as $c => $f) {
             // CORE/CUSTOM: Render field (if already rendered above, the function will return result immediately)
             $method = isset($pos->methods[$c]) && $pos->methods[$c] ? $pos->methods[$c] : 'display';
             // Render ANY CORE field with single call for all items, CORE fields are assigned to ALL types,
             // try to get field out of first item, if it does not exist, then field is a CUSTOM field
             $item = reset($items);
             $field = @$item->fields[$f];
             if ($field && $field->iscore) {
                 // Check if already rendered
                 if (!isset($_rendered['ALL']['core']) && !isset($_rendered['ALL'][$f])) {
                     // No custom values for CORE fields, values are decided inside the CORE field
                     $values = null;
                     FlexicontentFields::renderField($items, $f, $values, $method, $view);
                 }
                 $_rendered['ALL'][$f] = 1;
             } else {
                 foreach ($items as $item) {
                     // Check that field with given name: $f exists for current item (AKA, that it is assigned to the item's type)
                     if (!isset($item->fields[$f])) {
                         continue;
                     }
                     // Check if already rendered
                     if (isset($_rendered['ALL'][$f]) || isset($_rendered[$item->id][$f])) {
                         continue;
                     }
                     // Get field and field values, currently, custom field values can be passed only for CUSTOM fields, OR versioned CORE/CUSTOM fields too ...
                     $field = $item->fields[$f];
                     $values = isset($item->fieldvalues[$field->id]) ? $item->fieldvalues[$field->id] : array();
                     // Render the field's display
                     $field = FlexicontentFields::renderField($item, $field, $values, $method, $view);
                     $_rendered[$item->id][$f] = 1;
                 }
             }
             foreach ($items as $item) {
                 // Check that field with given name: $f exists for current item (AKA, that it is assigned to the item's type)
                 if (!isset($item->fields[$f])) {
                     continue;
//.........这里部分代码省略.........
开发者ID:jakesyl,项目名称:flexicontent,代码行数:101,代码来源:flexicontent.fields.php

示例2: renderFields

    function renderFields($context, &$row, &$params, $page = 0)
    {
        JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'tables');
        require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'defineconstants.php';
        require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.fields.php';
        require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php';
        require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'permission.php';
        require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'models' . DS . FLEXI_ITEMVIEW . '.php';
        $app = JFactory::getApplication();
        $user = JFactory::getUser();
        $aid = JAccess::getAuthorisedViewLevels($user->id);
        $itemmodel = new FlexicontentModelItem();
        $item = $itemmodel->getItem($row->id, $check_view_access = false);
        $view = 'com_content.article' ? FLEXI_ITEMVIEW : 'category';
        $items = FlexicontentFields::getFields($item, $view, $_item_params = null, $aid = null, $use_tmpl = false);
        // $_item_params == null means only retrieve fields
        // Only Render custom fields
        $displayed_fields = array();
        foreach ($item->fields as $field) {
            if ($field->iscore) {
                continue;
            }
            $displayed_fields[$field->name] = $field;
            $values = isset($item->fieldvalues[$field->id]) ? $item->fieldvalues[$field->id] : array();
            FlexicontentFields::renderField($item, $field, $values, $method = 'display', $view);
        }
        if (!count($displayed_fields)) {
            return null;
        }
        // Render the list of groups
        $field_html = array();
        foreach ($displayed_fields as $field_name => $field) {
            $_values = null;
            if (!isset($field->display)) {
                continue;
            }
            $field_html[] = '
				<div class="fc-field-box">
					' . ($field->parameters->get('display_label') ? '
					<span class="flexi label">' . $field->label . '</span>' : '') . '
					<div class="flexi value">' . $field->display . '</div>
				</div>
				';
        }
        $_display = '<div class="fc-custom-fields-box">' . implode('', $field_html) . '</div>';
        return $_display;
    }
开发者ID:khetsothea,项目名称:flexicontent-cck,代码行数:47,代码来源:flexisystem.php

示例3: foreach

    ?>
			</td>

    <?php 
    foreach ($this->extra_fields as $_field) {
        ?>

			<td>
		    <?php 
        // Clear display HTML just in case
        $field = clone $_field;
        // quickly make a shallow copy of the fields object to avoid assignments of various member variables being persistent
        // Field value for current item
        $field_value = isset($row->fieldvalues[$field->id]) ? $row->fieldvalues[$field->id] : false;
        // Create field's display HTML, via calling FlexicontentFields::renderField() for the given method name
        FlexicontentFields::renderField($row, $field, $field_value, $method = $field->methodname);
        // Output the field's display HTML
        echo @$field->{$field->methodname};
        ?>
			</td>
		<?php 
    }
    ?>

		<?php 
    if ($this->CanOrder) {
        ?>
			<td class="order">
				<?php 
        $row_stategrp_prev = @$stategrps[@$this->rows[$i - 1]->state];
        $row_stategrp = @$stategrps[$this->rows[$i]->state];
开发者ID:nettdotkomm,项目名称:flexicontent-cck,代码行数:31,代码来源:default.php

示例4: _createDisplayHTML

 private function _createDisplayHTML(&$field, &$item, &$grouped_fields, $custom_html, $max_count, $pretext, $posttext)
 {
     // ********************************
     // Parse and identify custom fields
     // ********************************
     //return array('"<b>Custom HTML</b>" display for fieldgroup field, is not implemented yet, please use default HTML');
     if (!$custom_html) {
         return "Empty custom HTML variable for group field: " . $field->label;
     }
     $result = preg_match_all("/\\{\\{([a-zA-Z_0-9]+)(##)?([a-zA-Z_0-9]+)?\\}\\}/", $custom_html, $field_matches);
     $gf_reps = $result ? $field_matches[0] : array();
     $gf_names = $result ? $field_matches[1] : array();
     $gf_methods = $result ? $field_matches[3] : array();
     //foreach ($gf_names as $i => $gf_name)
     //	$parsed_fields[] = $gf_names[$i] . ($gf_methods[$i] ? "->". $gf_methods[$i] : "");
     //echo "$custom_html :: Fields for Related Items List: ". implode(", ", $parsed_fields ? $parsed_fields : array() ) ."<br/>\n";
     // ***********************************************************************
     // Parse and identify language strings and then make language replacements
     // ***********************************************************************
     $result = preg_match_all("/\\%\\%([^%]+)\\%\\%/", $custom_html, $translate_matches);
     $translate_strings = $result ? $translate_matches[1] : array('FLEXI_READ_MORE_ABOUT');
     foreach ($translate_strings as $translate_string) {
         $custom_html = str_replace('%%' . $translate_string . '%%', JText::_($translate_string), $custom_html);
     }
     // **************************************************************
     // Render HTML of grouped fields mentioned inside the custom HTML
     // **************************************************************
     $_rendered_fields = array();
     $found_names = array_flip($gf_names);
     //print_r($gf_names);
     if (count($gf_names)) {
         $view = JRequest::getVar('flexi_callview', JRequest::getVar('view', FLEXI_ITEMVIEW));
         $gf_props = array();
         foreach ($grouped_fields as $grouped_field) {
             if (!isset($found_names[$grouped_field->name])) {
                 continue;
             }
             $pos = $found_names[$grouped_field->name];
             $_rendered_fields[$pos] = $grouped_field;
             // Check if display method is 'label' aka nothing to render
             if ($gf_methods[$pos] == 'label') {
                 continue;
             }
             // Check if display method of the field has been created already
             $method = $gf_methods[$pos] ? $gf_methods[$pos] : 'display';
             if (isset($grouped_field->{$method}) && is_array($grouped_field->{$method})) {
                 continue;
             }
             // Render the display method for the given field
             $_values = $grouped_field->value;
             $grouped_field->ingroup = 1;
             // render as array
             //echo 'Rendering: '. $grouped_field->name . ', method: ' . $method . '<br/>';
             //FLEXIUtilities::call_FC_Field_Func($grouped_field->field_type, 'onDisplayFieldValue', array(&$grouped_field, $item, $_values, $method));
             unset($grouped_field->{$method});
             // Unset display variable to make sure display HTML it is created, because we reuse the field
             FlexicontentFields::renderField($item, $grouped_field, $_values, $method, $view);
             // Includes content plugins triggering
             unset($grouped_field->ingroup);
         }
     }
     // *******************************************************************
     // Render the value list of the fieldgroup, using custom HTML for each
     // value-set of the fieldgroup, and performing the field replacements
     // *******************************************************************
     $custom_display = array();
     for ($n = 0; $n < $max_count; $n++) {
         $rendered_html = $custom_html;
         foreach ($_rendered_fields as $pos => $_rendered_field) {
             $pos = $found_names[$_rendered_field->name];
             $method = $gf_methods[$pos] ? $gf_methods[$pos] : 'display';
             //echo 'Replacing: '. $_rendered_field->name . ', method: ' . $method . ', index: ' .$n. '<br/>';
             $rendered_html = str_replace($gf_reps[$pos], @$_rendered_field->{$method}[$n], $rendered_html);
             //unset($_rendered_field->{$method});  // Unset display of fields in case they need to be rendered again
         }
         $custom_display[$n] = $pretext . $rendered_html . $posttext;
     }
     return $custom_display;
 }
开发者ID:noxidsoft,项目名称:flexicontent-cck,代码行数:79,代码来源:fieldgroup.php

示例5: _createDisplayHTML

 private function _createDisplayHTML(&$field, &$item, &$grouped_fields, $custom_html, $max_count, $pretext, $posttext)
 {
     // ********************************
     // Parse and identify custom fields
     // ********************************
     //return array('"<b>Custom HTML</b>" display for fieldgroup field, is not implemented yet, please use default HTML');
     if (!$custom_html) {
         return "Empty custom HTML variable for group field: " . $field->label;
     }
     $result = preg_match_all("/\\{\\{([a-zA-Z_0-9]+)(##)?([a-zA-Z_0-9]+)?\\}\\}/", $custom_html, $field_matches);
     $gf_reps = $result ? $field_matches[0] : array();
     $gf_names = $result ? $field_matches[1] : array();
     $gf_methods = $result ? $field_matches[3] : array();
     //foreach ($gf_names as $i => $gf_name)
     //	$parsed_fields[] = $gf_names[$i] . ($gf_methods[$i] ? "->". $gf_methods[$i] : "");
     //echo "$custom_html :: Fields for Related Items List: ". implode(", ", $parsed_fields ? $parsed_fields : array() ) ."<br/>\n";
     $_name_to_field = array();
     foreach ($grouped_fields as $i => $grouped_field) {
         $_name_to_field[$grouped_field->name] =& $grouped_fields[$i];
     }
     //print_r(array_keys($_name_to_field)); echo "<br/>";
     // ***********************************************************************
     // Parse and identify language strings and then make language replacements
     // ***********************************************************************
     $result = preg_match_all("/\\%\\%([^%]+)\\%\\%/", $custom_html, $translate_matches);
     $translate_strings = $result ? $translate_matches[1] : array('FLEXI_READ_MORE_ABOUT');
     foreach ($translate_strings as $translate_string) {
         $custom_html = str_replace('%%' . $translate_string . '%%', JText::_($translate_string), $custom_html);
     }
     // **************************************************************
     // Render HTML of grouped fields mentioned inside the custom HTML
     // **************************************************************
     $_rendered_fields = array();
     if (count($gf_names)) {
         $view = JRequest::getVar('flexi_callview', JRequest::getVar('view', FLEXI_ITEMVIEW));
         $gf_props = array();
         foreach ($gf_names as $pos => $grp_field_name) {
             // Check that field exists and is assigned the fieldgroup field
             $grouped_field = $_name_to_field[$grp_field_name];
             if (!isset($_name_to_field[$grp_field_name])) {
                 continue;
             }
             $_rendered_fields[$pos] = $grouped_field;
             // Check if display method is 'label' aka nothing to render
             if ($gf_methods[$pos] == 'label') {
                 continue;
             }
             // Optional use custom display method
             $method = $gf_methods[$pos] ? $gf_methods[$pos] : 'display';
             // SAME field with SAME method, may have been used more than ONCE, inside the custom HTML parameter
             // Check if field has been rendered already
             if (isset($grouped_field->{$method}) && is_array($grouped_field->{$method})) {
                 continue;
             }
             // Render the display method for the given field
             $_values = $grouped_field->value;
             $grouped_field->ingroup = 1;
             // render as array
             //echo 'Rendering: '. $grouped_field->name . ', method: ' . $method . '<br/>';
             //FLEXIUtilities::call_FC_Field_Func($grouped_field->field_type, 'onDisplayFieldValue', array(&$grouped_field, $item, $_values, $method));
             FlexicontentFields::renderField($item, $grouped_field, $_values, $method, $view);
             // Includes content plugins triggering
             //print_r($grouped_field->$method);
             $grouped_field->_method = $method;
             // This is used to decide if field does not have value and hide label (if configured to hide on empty values)
             unset($grouped_field->ingroup);
         }
     }
     // *******************************************************************
     // Render the value list of the fieldgroup, using custom HTML for each
     // value-set of the fieldgroup, and performing the field replacements
     // *******************************************************************
     // Get labels to hide on empty values
     $hide_lbl_ifnoval = $this->getHideLabelsOnEmpty($field);
     $custom_display = array();
     //echo "<br/>max_count: ".$max_count."<br/>";
     for ($n = 0; $n < $max_count; $n++) {
         $rendered_html = $custom_html;
         foreach ($_rendered_fields as $pos => $_rendered_field) {
             $method = $gf_methods[$pos] ? $gf_methods[$pos] : 'display';
             //echo 'Replacing: '. $_rendered_field->name . ', method: ' . $method . ', index: ' .$n. '<br/>';
             if ($method != 'label') {
                 $_html = isset($_rendered_field->{$method}[$n]) ? $_rendered_field->{$method}[$n] : '';
             } else {
                 $_method = isset($_rendered_field->_method) ? $_rendered_field->_method : 'display';
                 if ((!isset($_rendered_field->{$_method}[$n]) || !strlen($_rendered_field->{$_method}[$n])) && isset($hide_lbl_ifnoval[$_rendered_field->id])) {
                     $_html = '';
                     // Skip (hide) label for field without value (is such behaviour was configured)
                 } else {
                     $_html = $_rendered_field->label;
                 }
             }
             $rendered_html = str_replace($gf_reps[$pos], $_html, $rendered_html);
         }
         $custom_display[$n] = $pretext . $rendered_html . $posttext;
     }
     // IMPORTANT FIELD IS REUSED, !! unset display methods since it maybe rendered again for different item
     foreach ($_rendered_fields as $pos => $_rendered_field) {
         unset($_rendered_field->{$method});
     }
//.........这里部分代码省略.........
开发者ID:khetsothea,项目名称:flexicontent-cck,代码行数:101,代码来源:fieldgroup.php


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