if ($fieldname == 'catid') { echo $field_values . ' : '; echo isset($this->categories[$field_values]) ? $this->categories[$field_values]->title : 'Invalid, no Category with ID: ' . $field_values; } else { if ($fieldname == 'cid') { $seccats = array(); foreach ($field_values as $seccatid) { $seccats[] = isset($this->categories[$seccatid]) ? $this->categories[$seccatid]->title : 'Invalid, no Category with ID: ' . $seccatid; } echo !empty($seccats) ? implode(", ", $seccats) : '-'; } else { if ($fieldname == 'language') { echo $this->languages->{$field_values}->name; } else { if ($fieldname == 'state') { echo flexicontent_html::stateicon($field_values, $this->cparams); } else { if (!is_array($field_values)) { $is_missing = !empty($this->conf['filenames_missing'][$fieldname]) && is_string($field_values) && isset($this->conf['filenames_missing'][$fieldname][$field_values]); echo $is_missing ? '<span class="fcimport_missingfile hasTip" title="File is missing::not found in path ' . @$this->conf['thefields'][$fieldname]->folderpath . '">' : ''; echo mb_strlen($field_values, 'UTF-8') > 40 ? mb_substr(strip_tags($field_values), 0, 40, 'UTF-8') . ' ... ' : $field_values; echo $is_missing ? '</span>' : ''; } else { echo '<ul class="fcimport_field_value_list">'; foreach ($field_values as $field_value) { echo '<li>'; if (!is_array($field_value)) { $is_missing = !empty($this->conf['filenames_missing'][$fieldname]) && is_string($field_value) && isset($this->conf['filenames_missing'][$fieldname][$field_value]); echo $is_missing ? '<span class="fcimport_missingfile hasTip" title="File is missing::not found in path ' . @$this->conf['thefields'][$fieldname]->folderpath . '">' : ''; echo mb_strlen($field_value, 'UTF-8') > 40 ? mb_substr(strip_tags($field_value), 0, 40, 'UTF-8') . ' ... ' : $field_value; echo $is_missing ? '</span>' : '';
function onDisplayCoreFieldValue(&$_field, &$_item, &$params, $_tags = null, $_categories = null, $_favourites = null, $_favoured = null, $_vote = null, $values = null, $prop = 'display') { $view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW)); static $cat_links = array(); static $tag_links = array(); static $cparams = null; if ($cparams === null) { $cparams = JComponentHelper::getParams('com_flexicontent'); } if (!is_array($_item)) { $items = array(&$_item); } else { $items =& $_item; } // Prefix - Suffix - Separator parameters // these parameters should be common so we will retrieve them from the first item instead of inside the loop $item = reset($items); if (is_object($_field)) { $field = $_field; } else { $field = $item->fields[$_field]; } $remove_space = $field->parameters->get('remove_space', 0); $_pretext = $field->parameters->get('pretext', ''); $_posttext = $field->parameters->get('posttext', ''); $separatorf = $field->parameters->get('separatorf', 3); $_opentag = $field->parameters->get('opentag', ''); $_closetag = $field->parameters->get('closetag', ''); $pretext_cacheable = $posttext_cacheable = $opentag_cacheable = $closetag_cacheable = false; switch ($separatorf) { case 0: $separatorf = ' '; break; case 1: $separatorf = '<br />'; break; case 2: $separatorf = ' | '; break; case 3: $separatorf = ', '; break; case 4: $separatorf = $closetag . $opentag; break; case 5: $separatorf = ''; break; default: $separatorf = ' '; break; } foreach ($items as $item) { //if (!is_object($_field)) echo $item->id." - ".$_field ."<br/>"; if (is_object($_field)) { $field = $_field; } else { $field = $item->fields[$_field]; } if ($field->iscore != 1) { continue; } $field->item_id = $item->id; // Replace item properties or values of other fields if (!$pretext_cacheable) { $pretext = FlexicontentFields::replaceFieldValue($field, $item, $_pretext, 'pretext', $pretext_cacheable); if ($pretext && !$remove_space) { $pretext = $pretext . ' '; } } if (!$posttext_cacheable) { $posttext = FlexicontentFields::replaceFieldValue($field, $item, $_posttext, 'posttext', $posttext_cacheable); if ($posttext && !$remove_space) { $posttext = ' ' . $posttext; } } if (!$opentag_cacheable) { $opentag = FlexicontentFields::replaceFieldValue($field, $item, $_opentag, 'opentag', $opentag_cacheable); } // used by some fields if (!$closetag_cacheable) { $closetag = FlexicontentFields::replaceFieldValue($field, $item, $_closetag, 'closetag', $closetag_cacheable); } // used by some fields $field->value = array(); switch ($field->field_type) { case 'created': // created $field->value = array($item->created); // Get date format $customdate = $field->parameters->get('custom_date', 'Y-m-d'); $dateformat = $field->parameters->get('date_format', ''); $dateformat = $dateformat ? JText::_($dateformat) : ($field->parameters->get('lang_filter_format', 0) ? JText::_($customdate) : $customdate); // Add prefix / suffix $field->{$prop} = $pretext . JHTML::_('date', $item->created, $dateformat) . $posttext; // Add microdata property $itemprop = $field->parameters->get('microdata_itemprop', 'dateCreated'); if ($itemprop) { $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>'; } break; case 'createdby': // created by $field->value[] = $item->created_by; $field->{$prop} = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->cuname : $item->creator) . $posttext; break; case 'modified': // modified $field->value = array($item->modified); // Get date format $customdate = $field->parameters->get('custom_date', 'Y-m-d'); $dateformat = $field->parameters->get('date_format', ''); $dateformat = $dateformat ? JText::_($dateformat) : ($field->parameters->get('lang_filter_format', 0) ? JText::_($customdate) : $customdate); // Add prefix / suffix $field->{$prop} = $pretext . JHTML::_('date', $item->modified, $dateformat) . $posttext; // Add microdata property $itemprop = $field->parameters->get('microdata_itemprop', 'dateModified'); if ($itemprop) { $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>'; } break; case 'modifiedby': // modified by $field->value[] = $item->modified_by; $field->{$prop} = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->muname : $item->modifier) . $posttext; break; case 'title': // title $field->value[] = $item->title; $field->{$prop} = $pretext . $item->title . $posttext; // Get ogp configuration $useogp = $field->parameters->get('useogp', 1); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); if ($useogp && $field->{$prop}) { if (in_array($view, $ogpinview)) { $content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:title" content="' . $content_val . '" />'); } } // Add microdata property (currently no parameter in XML for this field) $itemprop = $field->parameters->get('microdata_itemprop', 'name'); if ($itemprop) { $field->{$prop} = '<div style="display:inline" itemprop="' . $itemprop . '" >' . $field->{$prop} . '</div>'; } break; case 'hits': // hits $field->value[] = $item->hits; $field->{$prop} = $pretext . $item->hits . $posttext; break; case 'type': // document type $field->value[] = $item->type_id; $field->{$prop} = $pretext . JText::_($item->typename) . $posttext; break; case 'version': // version $field->value[] = $item->version; $field->{$prop} = $pretext . $item->version . $posttext; break; case 'state': // state $field->value[] = $item->state; $field->{$prop} = $pretext . flexicontent_html::stateicon($item->state, $field->parameters) . $posttext; break; case 'voting': // voting button if ($_vote === false) { $vote =& $item->vote; } else { $vote =& $_vote; } $field->value[] = 'button'; // dummy value to force display $field->{$prop} = $pretext . flexicontent_html::ItemVote($field, 'all', $vote) . $posttext; break; case 'favourites': // favourites button if ($_favourites === false) { $favourites =& $item->favs; } else { $favourites =& $_favourites; } if ($_favoured === false) { $favoured =& $item->fav; } else { $favoured =& $_favoured; } $field->value[] = 'button'; // dummy value to force display $favs = flexicontent_html::favoured_userlist($field, $item, $favourites); $field->{$prop} = $pretext . ' <div class="fav-block"> ' . flexicontent_html::favicon($field, $favoured, $item) . ' <div id="fcfav-reponse_item_' . $item->id . '" class="fcfav-reponse-tip"> <div class="fc-mssg-inline fc-info fc-iblock fc-nobgimage ' . ($favoured ? 'fcfavs-is-subscriber' : 'fcfavs-isnot-subscriber') . '"> ' . JText::_($favoured ? 'FLEXI_FAVS_YOU_HAVE_SUBSCRIBED' : 'FLEXI_FAVS_CLICK_TO_SUBSCRIBE') . ' </div> ' . $favs . ' </div> </div> ' . $posttext; break; case 'categories': // assigned categories $field->{$prop} = ''; if ($_categories === false) { $categories =& $item->cats; } else { $categories =& $_categories; } if ($categories) { // Get categories that should be excluded from linking global $globalnoroute; if (!is_array($globalnoroute)) { $globalnoroute = array(); } // Create list of category links, excluding the "noroute" categories $field->{$prop} = array(); foreach ($categories as $category) { $cat_id = $category->id; if (in_array($cat_id, @$globalnoroute)) { continue; } if (!isset($cat_links[$cat_id])) { $cat_links[$cat_id] = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug)); } $cat_link =& $cat_links[$cat_id]; $display = '<a class="fc_categories fc_category_' . $cat_id . ' link_' . $field->name . '" href="' . $cat_link . '">' . $category->title . '</a>'; $field->{$prop}[] = $pretext . $display . $posttext; $field->value[] = $category->title; } $field->{$prop} = implode($separatorf, $field->{$prop}); $field->{$prop} = $opentag . $field->{$prop} . $closetag; } break; case 'tags': // assigned tags $use_catlinks = $cparams->get('tags_using_catview', 0); $field->{$prop} = ''; if ($_tags === false) { $tags =& $item->tags; } else { $tags =& $_tags; } if ($tags) { // Create list of tag links $field->{$prop} = array(); foreach ($tags as $tag) { $tag_id = $tag->id; if (!isset($tag_links[$tag_id])) { $tag_links[$tag_id] = $use_catlinks ? JRoute::_(FlexicontentHelperRoute::getCategoryRoute(0, 0, array('layout' => 'tags', 'tagid' => $tag->slug))) : JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->slug)); } $tag_link =& $tag_links[$tag_id]; $display = '<a class="fc_tags fc_tag_' . $tag->id . ' link_' . $field->name . '" href="' . $tag_link . '">' . $tag->name . '</a>'; $field->{$prop}[] = $pretext . $display . $posttext; $field->value[] = $tag->name; } $field->{$prop} = implode($separatorf, $field->{$prop}); $field->{$prop} = $opentag . $field->{$prop} . $closetag; } break; case 'maintext': // main text // Special display variables if ($prop != 'display') { switch ($prop) { case 'display_if': $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext; break; case 'display_i': $field->{$prop} = $item->introtext; break; case 'display_f': $field->{$prop} = $item->fulltext; break; } } else { if (!$item->fulltext) { $field->{$prop} = $item->introtext; } else { if ($view != FLEXI_ITEMVIEW) { if ($item->parameters->get('force_full', 0)) { $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext; } else { $field->{$prop} = $item->introtext; } } else { if ($item->parameters->get('show_intro', 1)) { $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext; } else { $field->{$prop} = $item->fulltext; } } } } // Get ogp configuration $useogp = $field->parameters->get('useogp', 1); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); if ($useogp && $field->{$prop}) { if (in_array($view, $ogpinview)) { if ($item->metadesc) { JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $item->metadesc . '" />'); } else { $content_val = flexicontent_html::striptagsandcut($field->{$prop}, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $content_val . '" />'); } } } break; } } }
/** * Creates the state selector button * * @param int $id * @param array $params * @since 1.0 */ static function statebutton($item, &$params = null, $addToggler = true) { // Check for empty params too if ($params && !$params->get('show_state_icon', 1) || JRequest::getCmd('print')) { return; } $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $nullDate = $db->getNullDate(); $app = JFactory::getApplication(); // Determine general archive privilege static $has_archive = null; if ($has_archive === null) { $permission = FlexicontentHelperPerm::getPerm(); $has_archive = $permission->CanArchives; } // Determine edit state, delete privileges of the current user on the given item $asset = 'com_content.article.' . $item->id; $has_edit_state = $user->authorise('core.edit.state', $asset) || $user->authorise('core.edit.state.own', $asset) && $item->created_by == $user->get('id'); $has_delete = $user->authorise('core.delete', $asset) || $user->authorise('core.delete.own', $asset) && $item->created_by == $user->get('id'); // Display state toggler if it can do any of state change $canChangeState = $has_edit_state || $has_delete || $has_archive; static $js_and_css_added = false; if (!$js_and_css_added && $canChangeState && $addToggler) { // File exists both in frontend & backend (and is different), so we will use 'base' method and not 'root' $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/stateselector.js', FLEXI_VERSION); $js = ' function fc_setitemstate(state, id) { var handler = new fc_statehandler({task: "' . ($app->isAdmin() ? 'items.setitemstate' : 'setitemstate') . '"}); handler.setstate( state, id ); }'; $document->addScriptDeclaration($js); $js_and_css_added = true; } static $state_names = null; static $state_descrs = null; static $state_imgs = null; static $tooltip_class = null; static $state_tips = null; static $button_classes = null; static $icon_sep = null; if (!$state_names) { $state_names = array(1 => JText::_('FLEXI_PUBLISHED'), -5 => JText::_('FLEXI_IN_PROGRESS'), 0 => JText::_('FLEXI_UNPUBLISHED'), -3 => JText::_('FLEXI_PENDING'), -4 => JText::_('FLEXI_TO_WRITE'), 2 => JText::_('FLEXI_ARCHIVED'), -2 => JText::_('FLEXI_TRASHED'), '' => JText::_('FLEXI_UNKNOWN')); $state_descrs = array(1 => JText::_('FLEXI_PUBLISH_THIS_ITEM'), -5 => JText::_('FLEXI_SET_STATE_AS_IN_PROGRESS'), 0 => JText::_('FLEXI_UNPUBLISH_THIS_ITEM'), -3 => JText::_('FLEXI_SET_STATE_AS_PENDING'), -4 => JText::_('FLEXI_SET_STATE_AS_TO_WRITE'), 2 => JText::_('FLEXI_ARCHIVE_THIS_ITEM'), -2 => JText::_('FLEXI_TRASH_THIS_ITEM'), '' => 'FLEXI_UNKNOWN'); $state_imgs = array(1 => 'tick.png', -5 => 'publish_g.png', 0 => 'publish_x.png', -3 => 'publish_r.png', -4 => 'publish_y.png', 2 => 'archive.png', -2 => 'trash.png', '' => 'unknown.png'); $tooltip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; $state_tips = array(); $title_header = ''; //JText::_( 'FLEXI_ACTION' ); foreach ($state_names as $state_id => $i) { $state_tips[$state_id] = flexicontent_html::getToolTip($title_header, $state_names[$state_id], 0); } $button_classes = 'fc_statebutton'; $button_classes .= FLEXI_J30GE ? ' btn btn-small' : ' fc_button fcsimple fcsmall'; $button_classes .= FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; $icon_sep = JText::_('FLEXI_ICON_SEP'); } // Create state icon $state = $item->state; $state_text = ''; $tmpparams = new JRegistry(); $tmpparams->set('stateicon_popup', 'none'); $stateicon = flexicontent_html::stateicon($state, $tmpparams, $state_text); $tz_string = JFactory::getApplication()->getCfg('offset'); $tz = new DateTimeZone($tz_string); $tz_offset = $tz->getOffset(new JDate()) / 3600; // Calculate common variables used to produce output $publish_up = JFactory::getDate($item->publish_up); $publish_down = JFactory::getDate($item->publish_down); $publish_up->setTimezone($tz); $publish_down->setTimezone($tz); $img_path = JURI::root(true) . "/components/com_flexicontent/assets/images/"; // Create publish information $publish_info = ''; if (isset($item->publish_up)) { if ($item->publish_up == $nullDate) { $publish_info .= JText::_('FLEXI_START_ALWAYS'); } else { $publish_info .= JText::_('FLEXI_START') . ": " . JHTML::_('date', $publish_up->toSql(), 'Y-m-d H:i:s'); } } if (isset($item->publish_down)) { if ($item->publish_down == $nullDate) { $publish_info .= ($publish_info ? '<br/>' : '') . JText::_('FLEXI_FINISH_NO_EXPIRY'); } else { $publish_info .= ($publish_info ? '<br/>' : '') . JText::_('FLEXI_FINISH') . ": " . JHTML::_('date', $publish_down->toSql(), 'Y-m-d H:i:s'); } } $publish_info = $state_text . '<br/>' . $publish_info; // Create the state selector button and return it if ($canChangeState && $addToggler) { // Only add user's permitted states on the current item if ($has_edit_state) { $state_ids = array(1, -5, 0, -3, -4); } if ($has_archive) { $state_ids[] = 2; } if ($has_delete) { $state_ids[] = -2; } $box_css = ''; //$app->isSite() ? 'width:182px; left:-100px;' : ''; $publish_info .= '<br/><br/>' . JText::_('FLEXI_CLICK_TO_CHANGE_STATE'); $allowed_states = array(); foreach ($state_ids as $i => $state_id) { $allowed_states[] = ' <li> <a href="javascript:void(0);" onclick="fc_setitemstate(\'' . $state_id . '\', \'' . $item->id . '\')" class="btn setstate_btn ' . $tooltip_class . '" title="' . $state_tips[$state_id] . '"> <img src="' . $img_path . $state_imgs[$state_id] . '" width="16" height="16" style="border-width:0;" alt="' . $state_names[$state_id] . '" /> </a> </li>'; } $tooltip_title = flexicontent_html::getToolTip(JText::_('FLEXI_PUBLISH_INFORMATION'), $publish_info, 0); $output = ' <ul class="statetoggler"> <li class="topLevel"> <a href="javascript:void(0);" onclick="fc_toggleStateSelector(this)" id="row' . $item->id . '" class="stateopener ' . $button_classes . '" title="' . $tooltip_title . '"> ' . $stateicon . ' </a> <div class="options" style="' . $box_css . '" onclick="fc_toggleStateSelector(this)"> <ul> ' . implode('', $allowed_states) . ' </ul> </div> </li> </ul>'; } else { if ($app->isAdmin()) { if ($canChangeState) { $publish_info .= '<br/><br/>' . JText::_('FLEXI_STATE_CHANGER_DISABLED'); } $tooltip_title = flexicontent_html::getToolTip(JText::_('FLEXI_PUBLISH_INFORMATION'), $publish_info, 0); $output = ' <div id="row' . $item->id . '"> <span class="' . $tooltip_class . '" title="' . $tooltip_title . '"> ' . $stateicon . ' </span> </div>'; $output = $icon_sep . $output . $icon_sep; } else { $output = ''; // frontend with no permissions to edit / delete / archive } } return $output; }
function onDisplayCoreFieldValue(&$_field, &$_item, &$params, $_tags = null, $_categories = null, $_favourites = null, $_favoured = null, $_vote = null, $values = null, $prop = 'display') { // this function is a mess and need complete refactoring // execute the code only if the field type match the plugin type $view = JRequest::setVar('view', JRequest::getVar('view', FLEXI_ITEMVIEW)); static $cat_links = array(); static $tag_links = array(); if (!is_array($_item)) { $items = array(&$_item); } else { $items =& $_item; } // Prefix - Suffix - Separator parameters // these parameters should be common so we will retrieve them from the first item instead of inside the loop $item = reset($items); if (is_object($_field)) { $field = $_field; } else { $field = $item->fields[$_field]; } $remove_space = $field->parameters->get('remove_space', 0); $_pretext = $field->parameters->get('pretext', ''); $_posttext = $field->parameters->get('posttext', ''); $separatorf = $field->parameters->get('separatorf', 3); $_opentag = $field->parameters->get('opentag', ''); $_closetag = $field->parameters->get('closetag', ''); $pretext_cacheable = $posttext_cacheable = $opentag_cacheable = $closetag_cacheable = false; foreach ($items as $item) { //if (!is_object($_field)) echo $item->id." - ".$_field ."<br/>"; if (is_object($_field)) { $field = $_field; } else { $field = $item->fields[$_field]; } if ($field->iscore != 1) { continue; } $field->item_id = $item->id; // Replace item properties or values of other fields if (!$pretext_cacheable) { $pretext = FlexicontentFields::replaceFieldValue($field, $item, $_pretext, 'pretext', $pretext_cacheable); if ($pretext && !$remove_space) { $pretext = $pretext . ' '; } } if (!$posttext_cacheable) { $posttext = FlexicontentFields::replaceFieldValue($field, $item, $_posttext, 'posttext', $posttext_cacheable); if ($posttext && !$remove_space) { $posttext = ' ' . $posttext; } } if (!$opentag_cacheable) { $opentag = FlexicontentFields::replaceFieldValue($field, $item, $_opentag, 'opentag', $opentag_cacheable); } // used by some fields if (!$closetag_cacheable) { $closetag = FlexicontentFields::replaceFieldValue($field, $item, $_closetag, 'closetag', $closetag_cacheable); } // used by some fields switch ($separatorf) { case 0: $separatorf = ' '; break; case 1: $separatorf = '<br />'; break; case 2: $separatorf = ' | '; break; case 3: $separatorf = ', '; break; case 4: $separatorf = $closetag . $opentag; break; case 5: $separatorf = ''; break; default: $separatorf = ' '; break; } $field->value = array(); switch ($field->field_type) { case 'created': // created $field->value[] = $item->created; $dateformat = $field->parameters->get('date_format', ''); $customdate = $field->parameters->get('custom_date', ''); $dateformat = $dateformat ? $dateformat : $customdate; $field->display = $pretext . JHTML::_('date', $item->created, JText::_($dateformat)) . $posttext; break; case 'createdby': // created by $field->value[] = $item->created_by; $field->display = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->cuname : $item->creator) . $posttext; break; case 'modified': // modified $field->value[] = $item->modified; $dateformat = $field->parameters->get('date_format', ''); $customdate = $field->parameters->get('custom_date', ''); $dateformat = $dateformat ? $dateformat : $customdate; $field->display = $pretext . JHTML::_('date', $item->modified, JText::_($dateformat)) . $posttext; break; case 'modifiedby': // modified by $field->value[] = $item->modified_by; $field->display = $pretext . ($field->parameters->get('name_username', 1) == 2 ? $item->muname : $item->modifier) . $posttext; break; case 'title': // title $field->value[] = $item->title; $field->display = $pretext . $item->title . $posttext; // Get ogp configuration $useogp = $field->parameters->get('useogp', 1); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); if ($useogp && $field->{$prop}) { if (in_array($view, $ogpinview)) { $content_val = flexicontent_html::striptagsandcut($field->display, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:title" content="' . $content_val . '" />'); } } break; case 'hits': // hits $field->value[] = $item->hits; $field->display = $pretext . $item->hits . $posttext; break; case 'type': // document type $field->value[] = $item->type_id; $field->display = $pretext . JText::_($item->typename) . $posttext; break; case 'version': // version $field->value[] = $item->version; $field->display = $pretext . $item->version . $posttext; break; case 'state': // state $field->value[] = $item->state; $field->display = $pretext . flexicontent_html::stateicon($item->state, $field->parameters) . $posttext; break; case 'voting': // voting button if ($_vote === false) { $vote =& $item->vote; } else { $vote =& $_vote; } $field->value[] = 'button'; // dummy value to force display $field->display = $pretext . flexicontent_html::ItemVote($field, 'all', $vote) . $posttext; break; case 'favourites': // favourites button if ($_favourites === false) { $favourites =& $item->favs; } else { $favourites =& $_favourites; } if ($_favoured === false) { $favoured =& $item->fav; } else { $favoured =& $_favoured; } $field->value[] = 'button'; // dummy value to force display $favs = flexicontent_html::favoured_userlist($field, $item, $favourites); $field->display = $pretext . ' <span class="fav-block"> ' . flexicontent_html::favicon($field, $favoured, $item) . ' <span id="fcfav-reponse_' . $field->item_id . '" class="fcfav-reponse"> <small>' . $favs . '</small> </span> </span> ' . $posttext; break; case 'categories': // assigned categories $field->display = ''; if ($_categories === false) { $categories =& $item->cats; } else { $categories =& $_categories; } if ($categories) { // Get categories that should be excluded from linking global $globalnoroute; if (!is_array($globalnoroute)) { $globalnoroute = array(); } // Create list of category links, excluding the "noroute" categories $field->display = array(); foreach ($categories as $category) { $cat_id = $category->id; if (in_array($cat_id, @$globalnoroute)) { continue; } if (!isset($cat_links[$cat_id])) { $cat_links[$cat_id] = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug)); } $cat_link = $cat_links[$cat_id]; $display = '<a class="fc_categories fc_category_' . $cat_id . ' link_' . $field->name . '" href="' . $cat_link . '">' . $category->title . '</a>'; $field->display[] = $pretext . $display . $posttext; $field->value[] = $category->title; } $field->display = implode($separatorf, $field->display); $field->display = $opentag . $field->display . $closetag; } break; case 'tags': // assigned tags $field->display = ''; if ($_tags === false) { $tags =& $item->tags; } else { $tags =& $_tags; } if ($tags) { // Create list of tag links $field->display = array(); foreach ($tags as $tag) { $tag_id = $tag->id; if (!isset($tag_links[$tag_id])) { $tag_links[$tag_id] = JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->slug)); } $tag_link = $tag_links[$tag_id]; $display = '<a class="fc_tags fc_tag_' . $tag->id . ' link_' . $field->name . '" href="' . $tag_link . '">' . $tag->name . '</a>'; $field->display[] = $pretext . $display . $posttext; $field->value[] = $tag->name; } $field->display = implode($separatorf, $field->display); $field->display = $opentag . $field->display . $closetag; } break; case 'maintext': // main text // Special display variables if ($prop != 'display') { switch ($prop) { case 'display_if': $field->{$prop} = $item->introtext . chr(13) . chr(13) . $item->fulltext; break; case 'display_i': $field->{$prop} = $item->introtext; break; case 'display_f': $field->{$prop} = $item->fulltext; break; } } else { if (!$item->fulltext) { $field->display = $item->introtext; } else { if ($view != FLEXI_ITEMVIEW) { if ($item->parameters->get('force_full', 0)) { $field->display = $item->introtext . chr(13) . chr(13) . $item->fulltext; } else { $field->display = $item->introtext; } } else { if ($item->parameters->get('show_intro', 1)) { $field->display = $item->introtext . chr(13) . chr(13) . $item->fulltext; } else { $field->display = $item->fulltext; } } } } // Get ogp configuration $useogp = $field->parameters->get('useogp', 1); $ogpinview = $field->parameters->get('ogpinview', array()); $ogpinview = FLEXIUtilities::paramToArray($ogpinview); $ogpmaxlen = $field->parameters->get('ogpmaxlen', 300); if ($useogp && $field->{$prop}) { if (in_array($view, $ogpinview)) { if ($item->metadesc) { JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $item->metadesc . '" />'); } else { $content_val = flexicontent_html::striptagsandcut($field->display, $ogpmaxlen); JFactory::getDocument()->addCustomTag('<meta property="og:description" content="' . $content_val . '" />'); } } } break; } } }
/** * Creates the state selector button * * @param int $id * @param array $params * @since 1.0 */ static function statebutton( $item, &$params=null, $addToggler=true ) { // Check for empty params too if ( $params && !$params->get('show_state_icon', 1) || JRequest::getCmd('print') ) return; $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $nullDate = $db->getNullDate(); $app = JFactory::getApplication(); // Determine general archive privilege static $has_archive = null; if ($has_archive === null) { $permission = FlexicontentHelperPerm::getPerm(); $has_archive = $permission->CanArchives; } // Determine edit state, delete privileges of the current user on the given item if (FLEXI_J16GE) { $asset = 'com_content.article.' . $item->id; $has_edit_state = $user->authorise('core.edit.state', $asset) || ($user->authorise('core.edit.state.own', $asset) && $item->created_by == $user->get('id')); $has_delete = $user->authorise('core.delete', $asset) || ($user->authorise('core.delete.own', $asset) && $item->created_by == $user->get('id')); } else if ($user->gid >= 25) { $has_edit_state = true; $has_delete = true; } else if (FLEXI_ACCESS) { $rights = FAccess::checkAllItemAccess('com_content', 'users', $user->gmid, $item->id, $item->catid); $has_edit_state = in_array('publish', $rights) || (in_array('publishown', $rights) && $item->created_by == $user->get('id')) ; $has_delete = in_array('delete', $rights) || (in_array('deleteown', $rights) && $item->created_by == $user->get('id')) ; } else { $has_edit_state = $user->authorize('com_content', 'publish', 'content', 'all'); $has_delete = $user->gid >= 23; // is at least manager } // Display state toggler if it can do any of state change $canChangeState = $has_edit_state || $has_delete || $has_archive; static $js_and_css_added = false; if (!$js_and_css_added && $canChangeState && $addToggler ) { // File exists both in frontend & backend (and is different), so we will use 'base' method and not 'root' $document->addScript( JURI::base(true).'/components/com_flexicontent/assets/js/stateselector.js' ); $js =' if(MooTools.version>="1.2.4") { window.addEvent("domready", function() {stateselector.init()}); }else{ window.onDomReady(stateselector.init.bind(stateselector)); } function dostate(state, id) { var change = new processstate(); change.dostate( state, id ); }'; $document->addScriptDeclaration($js); $js_and_css_added = true; } static $state_names = null; static $state_descrs = null; static $state_imgs = null; if ( !$state_names ) { $state_names = array(1=>JText::_('FLEXI_PUBLISHED'), -5=>JText::_('FLEXI_IN_PROGRESS'), 0=>JText::_('FLEXI_UNPUBLISHED'), -3=>JText::_('FLEXI_PENDING'), -4=>JText::_('FLEXI_TO_WRITE'), (FLEXI_J16GE ? 2:-1)=>JText::_('FLEXI_ARCHIVED'), -2=>JText::_('FLEXI_TRASHED'), ''=>'FLEXI_UNKNOWN'); $state_descrs = array(1=>JText::_('FLEXI_PUBLISH_THIS_ITEM'), -5=>JText::_('FLEXI_SET_ITEM_IN_PROGRESS'), 0=>JText::_('FLEXI_UNPUBLISH_THIS_ITEM'), -3=>JText::_('FLEXI_SET_ITEM_PENDING'), -4=>JText::_('FLEXI_SET_ITEM_TO_WRITE'), (FLEXI_J16GE ? 2:-1)=>JText::_('FLEXI_ARCHIVE_THIS_ITEM'), -2=>JText::_('FLEXI_TRASH_THIS_ITEM'), ''=>'FLEXI_UNKNOWN'); $state_imgs = array(1=>'tick.png', -5=>'publish_g.png', 0=>'publish_x.png', -3=>'publish_r.png', -4=>'publish_y.png', (FLEXI_J16GE ? 2:-1)=>'archive.png', -2=>'trash.png', ''=>'unknown.png'); } // Create state icon $state = $item->state; $state_text =''; $tmpparams = FLEXI_J16GE ? new JRegistry() : new JParameter(""); $tmpparams->set('stateicon_popup', 'none'); $stateicon = flexicontent_html::stateicon( $state, $tmpparams, $state_text ); $tz_string = JFactory::getApplication()->getCfg('offset'); if (FLEXI_J16GE) { $tz = new DateTimeZone( $tz_string ); $tz_offset = $tz->getOffset(new JDate()) / 3600; } else { $tz_offset = $tz_string; } // Calculate common variables used to produce output $publish_up = JFactory::getDate($item->publish_up); $publish_down = JFactory::getDate($item->publish_down); if (FLEXI_J16GE) { $publish_up->setTimezone($tz); $publish_down->setTimezone($tz); } else { $publish_up->setOffset($tz_offset); $publish_down->setOffset($tz_offset); } $img_path = JURI::root(true)."/components/com_flexicontent/assets/images/"; // Create publish information $publish_info = ''; if (isset($item->publish_up)) { if ($item->publish_up == $nullDate) { $publish_info .= JText::_( 'FLEXI_START_ALWAYS' ); } else { $publish_info .= JText::_( 'FLEXI_START' ) .": ". JHTML::_('date', FLEXI_J16GE ? $publish_up->toSql() : $publish_up->toMySQL(), FLEXI_J16GE ? 'Y-m-d H:i:s' : '%Y-%m-%d %H:%M:%S'); } } if (isset($item->publish_down)) { if ($item->publish_down == $nullDate) { $publish_info .= "<br />". JText::_( 'FLEXI_FINISH_NO_EXPIRY' ); } else { $publish_info .= "<br />". JText::_( 'FLEXI_FINISH' ) .": ". JHTML::_('date', FLEXI_J16GE ? $publish_down->toSql() : $publish_down->toMySQL(), FLEXI_J16GE ? 'Y-m-d H:i:s' : '%Y-%m-%d %H:%M:%S'); } } $publish_info = $state_text.'<br /><br />'.$publish_info; // Create the state selector button and return it if ( $canChangeState && $addToggler ) { $separators_at = array(-5,-4); // Only add user's permitted states on the current item if ($has_edit_state) $state_ids = array(1, -5, 0, -3, -4); if ($has_archive) $state_ids[] = FLEXI_J16GE ? 2:-1; if ($has_delete) $state_ids[] = -2; $box_css = ''; //$app->isSite() ? 'width:182px; left:-100px;' : ''; $publish_info .= '<br><br>'.JText::_('FLEXI_CLICK_TO_CHANGE_STATE'); $tooltip_class = 'fc_statebutton'; $tooltip_class .= FLEXI_J30GE ? ' btn btn-small' : ' fc_button fcsimple fcsmall'; $tooltip_class .= FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; $tooltip_title = flexicontent_html::getToolTip(JText::_( 'FLEXI_PUBLISH_INFORMATION' ), $publish_info, 0); $output =' <ul class="statetoggler"> <li class="topLevel"> <a href="javascript:void(0);" style="outline:none;" id="row'.$item->id.'" class="opener '.$tooltip_class.'" title="'.$tooltip_title.'"> '.$stateicon.' </a> <div class="options" style="'.$box_css.'"> <ul>'; $tooltip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; $title_header = JText::_( 'FLEXI_ACTION' ); foreach ($state_ids as $i => $state_id) { $tooltip_title = flexicontent_html::getToolTip($title_header, $state_descrs[$state_id], 0); $spacer = in_array($state_id,$separators_at) ? '' : ''; $output .=' <li> <a href="javascript:void(0);" onclick="dostate(\''.$state_id.'\', \''.$item->id.'\')" class="closer '.$tooltip_class.'" title="'.$tooltip_title.'"> <img src="'.$img_path.$state_imgs[$state_id].'" width="16" height="16" border="0" alt="'.$state_names[$state_id].'" /> </a> </li>'; } $output .=' </ul> </div> </li> </ul>'; } else if ($app->isAdmin()) { if ($canChangeState) $publish_info .= '<br><br>'.JText::_('FLEXI_STATE_CHANGER_DISABLED'); $tooltip_class = FLEXI_J30GE ? '' : ''; $tooltip_class .= FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; $tooltip_title = flexicontent_html::getToolTip(JText::_( 'FLEXI_PUBLISH_INFORMATION' ), $publish_info, 0); $output = ' <div id="row'.$item->id.'"> <span class="'.$tooltip_class.'" title="'.$tooltip_title.'"> '.$stateicon.' </span> </div>'; $output = JText::_( 'FLEXI_ICON_SEP' ) .$output. JText::_( 'FLEXI_ICON_SEP' ); } else { $output = ''; // frontend with no permissions to edit / delete / archive } return $output; }