本文整理汇总了PHP中FlexicontentFields::doQueryReplacements方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentFields::doQueryReplacements方法的具体用法?PHP FlexicontentFields::doQueryReplacements怎么用?PHP FlexicontentFields::doQueryReplacements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentFields
的用法示例。
在下文中一共展示了FlexicontentFields::doQueryReplacements方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createItemsListHTML
//.........这里部分代码省略.........
$result = preg_match_all("/\\%\\%([^%]+)\\%\\%/", $relitem_html, $translate_matches);
$translate_strings = $result ? $translate_matches[1] : array('FLEXI_READ_MORE_ABOUT');
foreach ($translate_strings as $translate_string) {
$relitem_html = str_replace('%%' . $translate_string . '%%', JText::_($translate_string), $relitem_html);
}
foreach ($item_list as $result) {
// Check if related item is published and skip if not published
if ($result->state != 1 && $result->state != -5) {
continue;
}
$itemslug = $result->id . ":" . $result->alias;
$catslug = "";
// Check if removed from category or inside a noRoute category or inside a non-published category
// and use main category slug or other routable & published category slug
$catid_arr = explode(",", $result->catidlist);
$catalias_arr = explode(",", $result->cataliaslist);
for ($i = 0; $i < count($catid_arr); $i++) {
$itemcataliases[$catid_arr[$i]] = $catalias_arr[$i];
}
$rel_itemid = $result->id;
$rel_catid = !empty($result->rel_catid) ? $result->rel_catid : $result->catid;
if (isset($itemcataliases[$rel_catid]) && !in_array($rel_catid, $globalnoroute) && $globalcats[$rel_catid]->published) {
$catslug = $rel_catid . ":" . $itemcataliases[$rel_catid];
} else {
if (!in_array($result->catid, $globalnoroute) && $globalcats[$result->catid]->published) {
$catslug = $globalcats[$result->catid]->slug;
} else {
foreach ($catid_arr as $catid) {
if (!in_array($catid, $globalnoroute) && $globalcats[$catid]->published) {
$catslug = $globalcats[$catid]->slug;
break;
}
}
}
}
$result->slug = $itemslug;
$result->categoryslug = $catslug;
}
// Perform field's display replacements
if ($i_slave = $parentfield ? $parentitem->id . "_" . $parentfield->id : '') {
$fc_run_times['render_subfields'][$i_slave] = 0;
}
foreach ($custom_field_names as $i => $custom_field_name) {
if (isset($disallowed_fieldnames[$custom_field_name])) {
continue;
}
if ($custom_field_methods[$i] == 'label') {
continue;
}
if ($i_slave) {
$start_microtime = microtime(true);
}
$display_var = $custom_field_methods[$i] ? $custom_field_methods[$i] : 'display';
FlexicontentFields::getFieldDisplay($item_list, $custom_field_name, $custom_field_values = null, $display_var);
if ($i_slave) {
$fc_run_times['render_subfields'][$i_slave] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
}
}
$tooltip_class = FLEXI_J30GE ? 'hasTooltip' : 'hasTip';
$display = array();
foreach ($item_list as $result) {
$url_read_more = JText::_(isset($_item_data->url_read_more) ? $_item_data->url_read_more : 'FLEXI_READ_MORE_ABOUT', 1);
$url_class = isset($_item_data->url_class) ? $_item_data->url_class : 'relateditem';
// Check if related item is published and skip if not published
if ($result->state != 1 && $result->state != -5) {
continue;
}
// a. Replace some custom made strings
$item_url = JRoute::_(FlexicontentHelperRoute::getItemRoute($result->slug, $result->categoryslug, 0, $result));
$item_title_escaped = htmlspecialchars($result->title, ENT_COMPAT, 'UTF-8');
$tooltip_title = flexicontent_html::getToolTip($url_read_more, $item_title_escaped, $translate = 0, $escape = 0);
$item_tooltip = ' class="' . $tooltip_class . ' ' . $url_class . '" title="' . $tooltip_title . '" ';
$display_text = $displayway ? $result->title : $result->id;
$display_text = !$addlink ? $display_text : '<a href="' . $item_url . '"' . ($addtooltip ? $item_tooltip : '') . ' >' . $display_text . '</a>';
$curr_relitem_html = $relitem_html;
$curr_relitem_html = str_replace('__item_url__', $item_url, $curr_relitem_html);
$curr_relitem_html = str_replace('__item_title_escaped__', $item_title_escaped, $curr_relitem_html);
$curr_relitem_html = str_replace('__item_tooltip__', $item_tooltip, $curr_relitem_html);
$curr_relitem_html = str_replace('__display_text__', $display_text, $curr_relitem_html);
// b. Replace item properties, e.g. {item->id}, (item->title}, etc
$null_field = null;
FlexicontentFields::doQueryReplacements($curr_relitem_html, $null_field, $result);
// c. Replace HTML display of various item fields
$err_mssg = 'Cannot replace field: "%s" because it is of not allowed field type: "%s", which can cause loop or other problem';
foreach ($custom_field_names as $i => $custom_field_name) {
$_field = @$result->fields[$custom_field_name];
$custom_field_display = '';
if ($is_disallowed_field = isset($disallowed_fieldnames[$custom_field_name])) {
$custom_field_display .= sprintf($err_mssg, $custom_field_name, @$_field->field_type);
} else {
$display_var = $custom_field_methods[$i] ? $custom_field_methods[$i] : 'display';
$custom_field_display .= @$_field->{$display_var};
}
$curr_relitem_html = str_replace($custom_field_reps[$i], $custom_field_display, $curr_relitem_html);
}
$display[] = trim($pretext . $curr_relitem_html . $posttext);
}
$display = $opentag . implode($separatorf, $display) . $closetag;
return $display;
}