function display($tpl = null) { $mainframe = JFactory::getApplication(); //initialise variables $document = JFactory::getDocument(); $user = JFactory::getUser(); $bar = JToolBar::getInstance('toolbar'); $cparams = JComponentHelper::getParams('com_flexicontent'); //get vars $cid = JRequest::getVar('cid'); //add css to document $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VERSION); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VERSION); // Add JS frameworks //flexicontent_html::loadFramework('select2'); // Add js function to overload the joomla submitform validation JHTML::_('behavior.formvalidation'); // load default validation JS to make sure it is overriden $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VERSION); $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VERSION); //Get data from the model $model = $this->getModel(); $row = $this->get('Tag'); //create the toolbar if ($cid) { JToolBarHelper::title(JText::_('FLEXI_EDIT_TAG'), 'tagedit'); $base = str_replace('administrator/', '', JURI::base()); $autologin = ''; // $cparams->get('autoflogin', 1) ? '&fcu='.$user->username . '&fcp='.$user->password : ''; // Add a preview button $previewlink = $base . JRoute::_(FlexicontentHelperRoute::getTagRoute($row->id)) . $autologin; $bar->appendButton('Custom', '<a class="preview" href="' . $previewlink . '" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-32-preview"></span>' . JText::_('Preview') . '</a>', 'preview'); } else { JToolBarHelper::title(JText::_('FLEXI_NEW_TAG'), 'tagadd'); } if (FLEXI_J16GE) { JToolBarHelper::apply('tags.apply'); JToolBarHelper::save('tags.save'); JToolBarHelper::custom('tags.saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false); JToolBarHelper::cancel('tags.cancel'); } else { JToolBarHelper::apply(); JToolBarHelper::save(); JToolBarHelper::custom('saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false); JToolBarHelper::cancel(); } // fail if checked out not by 'me' if ($row->id) { if ($model->isCheckedOut($user->get('id'))) { JError::raiseWarning('SOME_ERROR_CODE', $row->name . ' ' . JText::_('FLEXI_EDITED_BY_ANOTHER_ADMIN')); $mainframe->redirect('index.php?option=com_flexicontent&view=tags'); } } //clean data JFilterOutput::objectHTMLSafe($row, ENT_QUOTES); //assign data to template $this->assignRef('row', $row); parent::display($tpl); }
public function getLinks($args) { $view = isset($args->view) ? $args->view : ''; if (!($view = 'tags')) { return array(); } $items = array(); require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'route.php'; $db =& JFactory::getDBO(); $query = $db->getQuery(true); $query->clear(); $query->select('t.name, t.id, CASE WHEN CHAR_LENGTH(t.alias) THEN CONCAT_WS(\':\', t.id, t.alias) ELSE t.id END as slug '); $query->from('#__flexicontent_tags AS t '); $query->where('t.published = 1 '); $query->order('t.name ASC'); $db->setQuery($query); $tags = $db->loadObjectList(); foreach ($tags as $tag) { $items[] = array('id' => FlexicontentHelperRoute::getTagRoute($tag->slug), 'name' => $tag->name, 'class' => 'fileflexitag'); } return $items; }
/** * Creates the page's display * * @since 1.0 */ function display($tpl = null) { //initialize variables $app = JFactory::getApplication(); $document = JFactory::getDocument(); $menus = $app->getMenu(); $menu = $menus->getActive(); $uri = JFactory::getURI(); $view = JRequest::getCmd('view'); // Get view's Model $model = $this->getModel(); // Get tag and set tag parameters as VIEW's parameters (tag parameters are merged with component/page(=menu item) and optionally with tag cloud parameters) $tag = $model->getTag(); if (empty($tag)) { // Raise a 404 error, if tag doesn't exist or access isn't permitted, maybe move this into model ?? $tid = JRequest::getInt('id', 0); $msg = JText::sprintf($tid ? 'Tag id was not set (is 0)' : 'Tag #%d not found', $tid); if (FLEXI_J16GE) { throw new Exception($msg, 404); } else { JError::raiseError(404, $msg); } } // Get parameters via model $params = $model->getParams(); // Get various data from the model $items = $this->get('Data'); $total = $this->get('Total'); // Make sure field values were retrieved e.g. we need 'item->categories' for template classes $items = FlexicontentFields::getFields($items, $view, $params); // Calculate CSS classes needed to add special styling markups to the items flexicontent_html::calculateItemMarkups($items, $params); // ******************************** // Load needed JS libs & CSS styles // ******************************** FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); flexicontent_html::loadFramework('jQuery'); flexicontent_html::loadFramework('flexi_tmpl_common'); //add css file if (!$params->get('disablecss', '')) { $document->addStyleSheet($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css'); $document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->'); } //allow css override if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) { $document->addStyleSheet($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css'); } // ********************************************************** // Calculate a (browser window) page title and a page heading // ********************************************************** // Verify menu item points to current FLEXIcontent object if ($menu) { $view_ok = 'tags' == @$menu->query['view']; $tid_ok = $tag->id == (int) @$menu->query['id']; $menu_matches = $view_ok && $tid_ok; //$menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params); // Get active menu item parameters } else { $menu_matches = false; } // MENU ITEM matched, use its page heading (but use menu title if the former is not set) if ($menu_matches) { $default_heading = FLEXI_J16GE ? $menu->title : $menu->name; // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template) $params->def('page_heading', $params->get('page_title', $default_heading)); $params->def('page_title', $params->get('page_heading', $default_heading)); $params->def('show_page_heading', $params->get('show_page_title', 0)); $params->def('show_page_title', $params->get('show_page_heading', 0)); } else { // Clear some menu parameters //$params->set('pageclass_sfx', ''); // CSS class SUFFIX is behavior, so do not clear it ? // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ... // meta_params->get('page_title') is meant for <title> but let's use as ... default page heading $default_heading = JText::_('FLEXI_ITEMS_WITH_TAG') . ": " . $tag->name; // Decide to show page heading (=J1.5 page title), this is always yes $show_default_heading = 1; // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template) $params->set('page_title', $default_heading); $params->set('page_heading', $default_heading); $params->set('show_page_heading', $show_default_heading); $params->set('show_page_title', $show_default_heading); } // Prevent showing the page heading if ... currently no reason if (0) { $params->set('show_page_heading', 0); $params->set('show_page_title', 0); } // ************************************************************ // Create the document title, by from page title and other data // ************************************************************ // Use the page heading as document title, (already calculated above via 'appropriate' logic ...) $doc_title = $params->get('page_title'); // Check and prepend or append site name if (FLEXI_J16GE) { // Not available in J1.5 // Add Site Name to page title if ($app->getCfg('sitename_pagetitles', 0) == 1) { $doc_title = $app->getCfg('sitename') . " - " . $doc_title; } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $doc_title = $doc_title . " - " . $app->getCfg('sitename'); } } // Finally, set document title $document->setTitle($doc_title); // ************************ // Set document's META tags // ************************ // Workaround for Joomla not setting the default value for 'robots', so component must do it $app_params = $app->getParams(); if ($_mp = $app_params->get('robots')) { $document->setMetadata('robots', $_mp); } // Overwrite with menu META data if menu matched if (FLEXI_J16GE) { if ($menu_matches) { if ($_mp = $menu->params->get('menu-meta_description')) { $document->setDescription($_mp); } if ($_mp = $menu->params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $_mp); } if ($_mp = $menu->params->get('robots')) { $document->setMetadata('robots', $_mp); } if ($_mp = $menu->params->get('secure')) { $document->setMetadata('secure', $_mp); } } } // ************************************ // Add rel canonical html head link tag (TODO: improve multi-page handing) // ************************************ $base = $uri->getScheme() . '://' . $uri->getHost(); $start = JRequest::getVar('start', ''); $start = $start ? "&start=" . $start : ""; $ucanonical = $base . JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->id) . $start); if ($params->get('add_canonical')) { $head_obj = $document->addHeadLink($ucanonical, 'canonical', 'rel', ''); $defaultCanonical = flexicontent_html::getDefaultCanonical(); if (FLEXI_J30GE && $defaultCanonical != $ucanonical) { unset($head_obj->_links[$defaultCanonical]); } } //ordering $filter_order = JRequest::getCmd('filter_order', 'i.title'); $filter_order_Dir = JRequest::getCmd('filter_order_Dir', 'ASC'); $filter = JRequest::getString('filter'); $lists = array(); $lists['filter_order'] = $filter_order; $lists['filter_order_Dir'] = $filter_order_Dir; $lists['filter'] = $filter; // Create the pagination object $pageNav = $this->get('pagination'); // Create links, etc $link = JRoute::_(FlexicontentHelperRoute::getTagRoute($tag->slug), false); //$print_link = JRoute::_('index.php?view=tags&id='.$tag->slug.'&pop=1&tmpl=component'); $curr_url = $_SERVER['REQUEST_URI']; $print_link = $curr_url . (strstr($curr_url, '?') ? '&' : '?') . 'pop=1&tmpl=component&print=1'; $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->assignRef('action', $link); // $uri->toString() $this->assignRef('print_link', $print_link); $this->assignRef('tag', $tag); $this->assignRef('items', $items); $this->assignRef('lists', $lists); $this->assignRef('params', $params); $this->assignRef('pageNav', $pageNav); $this->assignRef('pageclass_sfx', $pageclass_sfx); $print_logging_info = $params->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; $start_microtime = microtime(true); } parent::display($tpl); if ($print_logging_info) { @($fc_run_times['template_render'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10); } }
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; } } }
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; } } }
static function getTags(&$params, &$module) { // Initialize $app = JFactory::getApplication(); $cparams = JComponentHelper::getParams('com_flexicontent'); $db = JFactory::getDBO(); $user = JFactory::getUser(); //$now = FLEXI_J16GE ? JFactory::getDate()->toSql() : JFactory::getDate()->toMySQL(); $_nowDate = 'UTC_TIMESTAMP()'; //$db->Quote($now); $nullDate = $db->getNullDate(); $show_noauth = $cparams->get('show_noauth', 0); // Get parameters $minsize = (int) $params->get('min_size', '1'); $maxsize = (int) $params->get('max_size', '10'); $limit = (int) $params->get('count', '25'); $method = (int) $params->get('method', '1'); $scope = $params->get('categories'); $scope = is_array($scope) ? implode(',', $scope) : $scope; $tagitemid = (int) $params->get('force_itemid', 0); $where = !FLEXI_J16GE ? ' WHERE i.sectionid = ' . FLEXI_SECTION : ' WHERE 1 '; $where .= ' AND i.state IN ( 1, -5 )'; $where .= ' AND ( i.publish_up = ' . $db->Quote($nullDate) . ' OR i.publish_up <= ' . $_nowDate . ' )'; $where .= ' AND ( i.publish_down = ' . $db->Quote($nullDate) . ' OR i.publish_down >= ' . $_nowDate . ' )'; $where .= ' AND c.published = 1'; $where .= ' AND tag.published = 1'; // filter by permissions if (!$show_noauth) { $aid_arr = JAccess::getAuthorisedViewLevels($user->id); $aid_list = implode(",", $aid_arr); $where .= ' AND i.access IN (' . $aid_list . ')'; } // category scope if ($method == 2) { // include method $where .= ' AND c.id NOT IN (' . $scope . ')'; } else { if ($method == 3) { // exclude method $where .= ' AND c.id IN (' . $scope . ')'; } } // count Tags $result = array(); $query = 'SELECT COUNT( t.tid ) AS no' . ' FROM #__flexicontent_tags_item_relations AS t' . ' LEFT JOIN #__content AS i ON i.id = t.itemid' . ' LEFT JOIN #__categories AS c ON c.id = i.catid' . ' LEFT JOIN #__flexicontent_tags as tag ON tag.id = t.tid' . $where . ' GROUP BY t.tid' . ' ORDER BY no DESC'; $db->setQuery($query, 0, $limit); $result = FLEXI_J30GE ? $db->loadColumn() : $db->loadResultArray(); //Do we have any tags? if (!$result) { return $result; } $max = (int) $result[0]; $min = (int) $result[sizeof($result) - 1]; $query = 'SELECT tag.id, tag.name, count( rel.tid ) AS no,' . ' CASE WHEN CHAR_LENGTH(tag.alias) THEN CONCAT_WS(\':\', tag.id, tag.alias) ELSE tag.id END as slug' . ' FROM #__flexicontent_tags AS tag' . ' LEFT JOIN #__flexicontent_tags_item_relations AS rel ON rel.tid = tag.id' . ' LEFT JOIN #__content AS i ON i.id = rel.itemid' . ' LEFT JOIN #__categories AS c ON c.id = i.catid' . $where . ' GROUP BY tag.id' . ' HAVING no >= ' . $min . ' ORDER BY tag.name'; $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); $use_catlinks = $cparams->get('tags_using_catview', 0); $i = 0; $lists = array(); foreach ($rows as $row) { $lists[$i] = new stdClass(); $lists[$i]->size = modFlexiTagCloudHelper::sizer($min, $max, $row->no, $minsize, $maxsize); $lists[$i]->name = $row->name; $lists[$i]->screenreader = JText::sprintf('FLEXI_NR_ITEMS_TAGGED', $row->no); $lists[$i]->link = $use_catlinks ? FlexicontentHelperRoute::getCategoryRoute(0, $tagitemid, array('layout' => 'tags', 'tagid' => $row->slug)) : FlexicontentHelperRoute::getTagRoute($row->slug, $tagitemid); $lists[$i]->link = JRoute::_($lists[$i]->link . '&module=' . $module->id); $i++; } return $lists; }
?> <tr class="<?php echo "row{$k}"; ?> "> <td class="center hidden-phone"><?php echo $this->pagination->getRowOffset($i); ?> </td> <td class="center"><?php echo $checked; ?> </td> <td class="center hidden-phone"> <?php $tag_link = str_replace('&', '&', FlexicontentHelperRoute::getTagRoute($row->id)); $tag_link = JRoute::_(JURI::root() . $tag_link, $xhtml = false); // xhtml to false we do it manually above (at least the ampersand) also it has no effect because we prepended the root URL ? $previewlink = $tag_link . $autologin; echo '<a class="preview" href="' . $previewlink . '" target="_blank">' . $image_preview . '</a>'; ?> </td> <td class="title"> <?php // Display an icon with checkin link, if current user has checked out current item if ($row->checked_out) { // Record check-in is allowed if either (a) current user has Global Checkin privilege OR (b) record checked out by current user $canCheckin = $canCheckinRecords || $row->checked_out == $user->id; if ($canCheckin) { //if (FLEXI_J16GE && $row->checked_out == $user->id) echo JHtml::_('jgrid.checkedout', $i, $row->editor, $row->checked_out_time, 'tags.', $canCheckin); $task_str = 'tags.checkin';
/** * Creates the email button * * @param string $print_link * @param array $params * @since 1.0 */ static function mailbutton($view, &$params, $slug = null, $itemslug = null, $item = null) { static $initialize = null; static $uri, $base; if (!$params->get('show_email_icon') || JRequest::getCmd('print')) { return; } if ($initialize === null) { if (file_exists(JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php')) { require_once JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php'; $uri = JURI::getInstance(); $base = $uri->toString(array('scheme', 'host', 'port')); $initialize = true; } else { $initialize = false; } } if ($initialize === false) { return; } //TODO: clean this static stuff (Probs when determining the url directly with subdomains) if ($view == 'category') { $non_sef_link = null; flexicontent_html::createCatLink($slug, $non_sef_link); $link = $base . JRoute::_($non_sef_link); //$link = $base . JRoute::_( 'index.php?view='.$view.'&cid='.$slug, false ); } elseif ($view == FLEXI_ITEMVIEW) { $link = $base . JRoute::_(FlexicontentHelperRoute::getItemRoute($itemslug, $slug, 0, $item)); //$link = $base . JRoute::_( 'index.php?view='.$view.'&cid='.$slug.'&id='.$itemslug, false ); } elseif ($view == 'tags') { $link = $base . JRoute::_(FlexicontentHelperRoute::getTagRoute($itemslug)); //$link = $base . JRoute::_( 'index.php?view='.$view.'&id='.$slug, false ); } else { $link = $base . JRoute::_('index.php?view=' . $view, false); } $mail_to_url = JRoute::_('index.php?option=com_mailto&tmpl=component&link=' . MailToHelper::addLink($link)); $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,left=50,width=\'+(screen.width-100)+\',top=20,height=\'+(screen.height-160)+\',directories=no,location=no'; $status = 'left=50,width=\'+((screen.width-100) > 800 ? 800 : (screen.width-100))+\',top=20,height=\'+((screen.width-160) > 800 ? 800 : (screen.width-160))+\',menubar=yes,resizable=yes'; $onclick = ' window.open(this.href,\'win2\',\'' . $status . '\'); return false; '; // This checks template image directory for image, if none found, default image is returned $show_icons = $params->get('show_icons'); if ($show_icons) { $attribs = ''; $image = JHTML::image(FLEXI_ICONPATH . 'emailButton.png', JText::_('FLEXI_EMAIL'), $attribs); } else { $image = ''; } $overlib = JText::_('FLEXI_EMAIL_TIP'); $text = JText::_('FLEXI_EMAIL'); $button_classes = 'fc_mailbutton'; if ($show_icons == 1) { $caption = ''; $button_classes .= ''; } else { $caption = $text; $button_classes .= FLEXI_J30GE ? ' btn btn-small' : ' fc_button fcsimple fcsmall'; } $button_classes .= FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; $tooltip_title = flexicontent_html::getToolTip($text, $overlib, 0); // emailed link was set above $output = '<a href="' . $mail_to_url . '" class="' . $button_classes . '" title="' . $tooltip_title . '" onclick="' . $onclick . '" >' . $image . $caption . '</a>'; $output = JText::_('FLEXI_ICON_SEP') . $output . JText::_('FLEXI_ICON_SEP'); return $output; }
<?php foreach ($tags as $tag) { $tag_id = $tag->id; // Performance concern, only do routing once per tag 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 = $link_to_view ? '<a class="fc_tags fc_tag_' . $tag->id . ' link_' . $field->name . '" href="' . $tag_link . '">' . $tag->name . '</a>' : '<span class="fc_tags fc_tag_' . $tag->id . ' nolink_' . $field->name . '">' . $tag->name . '</span>'; $field->{$prop}[] = $pretext . $display . $posttext; // Some extra data $field->value[] = $tag->name; }