示例#1
0
 function display($tpl = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $doc->addStyleSheet('components/com_tz_portfolio_plus/css/tzportfolioplus.min.css');
     $tmpl = $app->input->getString('tmpl');
     if ($tmpl) {
         JHtml::_('bootstrap.framework');
         JHtml::_('jquery.framework');
     }
     $user = JFactory::getUser();
     $dispatcher = JDispatcher::getInstance();
     $this->state = $this->get('State');
     $params = $this->state->get('params');
     $this->item = $this->get('Item');
     $offset = $this->state->get('list.offset');
     $related = $this->get('ItemRelated');
     // Merge article params. If this is single-article view, menu params override article params
     // Otherwise, article params override menu item params
     $this->params = $this->state->get('params');
     $active = $app->getMenu()->getActive();
     $temp = clone $this->params;
     $tempR = clone $this->params;
     JPluginHelper::importPlugin('content');
     TZ_Portfolio_PlusPluginHelper::importPlugin('mediatype');
     TZ_Portfolio_PlusPluginHelper::importPlugin('content');
     if ($this->item->id && $params->get('show_tags', 1)) {
         $this->listTags = TZ_Portfolio_PlusFrontHelperTags::getTagsByArticleId($this->item->id, array('orderby' => 'm.contentid', 'menuActive' => $params->get('menu_active', 'auto')));
     }
     $mediatypes = array();
     if ($results = $dispatcher->trigger('onAddMediaType')) {
         foreach ($results as $result) {
             if (isset($result->special) && $result->special) {
                 $mediatypes[] = $result->value;
             }
         }
     }
     if ($tmpl) {
         $tmpl = '&tmpl=' . $tmpl;
     }
     if ($params->get('tz_use_lightbox', 0) && !$tmpl) {
         $tmpl = '&tmpl=component';
     }
     $this->print = $app->input->getBool('print');
     $this->user = $user;
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // Create a shortcut for $item.
     $item =& $this->item;
     // Get second categories
     $second_categories = TZ_Portfolio_PlusFrontHelperCategories::getCategoriesByArticleId($item->id, array('main' => false, 'reverse_contentid' => false));
     $item->second_categories = $second_categories;
     // Add router helpers.
     $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
     $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
     $item->parent_slug = $item->category_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
     // TODO: Change based on shownoauth
     $item->readmore_link = null;
     // Check to see which parameters should take priority
     if ($active) {
         $currentLink = $active->link;
         // If the current view is the active item and an article view for this article, then the menu item params take priority
         if (strpos($currentLink, 'view=article') && strpos($currentLink, '&id=' . (string) $item->id)) {
             // $item->params are the article params, $temp are the menu item params
             // Merge so that the menu item params take priority
             $item->params->merge($temp);
             // Load layout from active query (in case it is an alternative menu item)
             if (isset($active->query['layout'])) {
                 $this->setLayout($active->query['layout']);
             }
         } else {
             // Current view is not a single article, so the article params take priority here
             // Merge the menu item params with the article params so that the article params take priority
             $temp->merge($item->params);
             $item->params = $temp;
             // Check for alternative layouts (since we are not in a single-article menu item)
             // Single-article menu item layout takes priority over alt layout for an article
             if ($layout = $item->params->get('article_layout')) {
                 $this->setLayout($layout);
             }
         }
     } else {
         // Merge so that article params take priority
         $temp->merge($item->params);
         $item->params = $temp;
         // Check for alternative layouts (since we are not in a single-article menu item)
         // Single-article menu item layout takes priority over alt layout for an article
         if ($layout = $item->params->get('article_layout')) {
             $this->setLayout($layout);
         }
     }
     $item->params->set('show_cat_icons', $item->params->get('show_icons'));
     // Create "link" and "fullLink" for article object
     $tmpl = null;
     if ($item->params->get('tz_use_lightbox', 0)) {
         $tmpl = '&tmpl=component';
     }
     $config = JFactory::getConfig();
     $ssl = -1;
     if ($config->get('force_ssl')) {
         $ssl = 1;
     }
     $item->link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getArticleRoute($item->slug, $item->catid) . $tmpl, true, $ssl);
     $item->fullLink = JRoute::_(TZ_Portfolio_PlusHelperRoute::getArticleRoute($item->slug, $item->catid), true, $ssl);
     $item->parent_link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getCategoryRoute($item->parent_slug));
     $item->category_link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getCategoryRoute($item->catslug));
     $item->author_link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getUserRoute($item->created_by, $params->get('user_menu_active', 'auto')));
     $url = JURI::getInstance()->toString();
     $this->assign('linkCurrent', $url);
     // Check the view access to the article (the model has already computed the values).
     if ($item->params->get('access-view') != true && ($item->params->get('show_noauth') != true && $user->get('guest'))) {
         JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
         return;
     }
     //
     // Process the content plugins.
     //
     $dispatcher->trigger('onAlwaysLoadDocument', array('com_tz_portfolio_plus.portfolio'));
     $dispatcher->trigger('onLoadData', array('com_tz_portfolio_plus.portfolio', $this->item, $params));
     if ($item->params->get('show_intro', 1)) {
         $item->text = $item->introtext . ' ' . $item->fulltext;
     } elseif ($item->fulltext) {
         $item->text = $item->fulltext;
     } else {
         $item->text = $item->introtext;
     }
     if ($item->params->get('show_intro', 1)) {
         $text = $item->introtext . ' ' . $item->fulltext;
     } elseif ($item->fulltext) {
         $text = $item->fulltext;
     } else {
         $text = $item->introtext;
     }
     if ($item->introtext && !empty($item->introtext)) {
         $item->text = $item->introtext;
         $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio_plus.article', &$item, &$this->params, $offset));
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio_plus.article', &$item, &$this->params, $offset));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio_plus.article', &$item, &$this->params, $offset));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio_plus.article', &$item, &$this->params, $offset));
         $item->introtext = $item->text;
     }
     if ($item->fulltext && !empty($item->fulltext)) {
         $item->text = $item->fulltext;
         $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio_plus.article', &$item, &$this->params, $offset));
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio_plus.article', &$item, &$this->params, $offset));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio_plus.article', &$item, &$this->params, $offset));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio_plus.article', &$item, &$this->params, $offset));
         $item->fulltext = $item->text;
     }
     $item->text = $text;
     $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio_plus.article', &$item, &$this->params, $offset));
     $item->event = new stdClass();
     $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio_plus.article', &$item, &$this->params, $offset));
     $item->event->afterDisplayTitle = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio_plus.article', &$item, &$this->params, $offset));
     $item->event->beforeDisplayContent = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio_plus.article', &$item, &$this->params, $offset));
     $item->event->afterDisplayContent = trim(implode("\n", $results));
     // Trigger portfolio's plugin
     $results = $dispatcher->trigger('onContentDisplayCommentCount', array('com_tz_portfolio_plus.article', &$item, &$item->params, $offset));
     $item->event->contentDisplayCommentCountCount = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentDisplayVote', array('com_tz_portfolio_plus.article', &$item, &$item->params, $offset));
     $item->event->contentDisplayVote = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onBeforeDisplayAdditionInfo', array('com_tz_portfolio_plus.article', &$item, &$item->params, $offset));
     $item->event->beforeDisplayAdditionInfo = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onAfterDisplayAdditionInfo', array('com_tz_portfolio_plus.article', &$item, &$item->params, $offset));
     $item->event->afterDisplayAdditionInfo = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentDisplayMediaType', array('com_tz_portfolio_plus.article', &$item, &$item->params, $offset));
     $item->event->onContentDisplayMediaType = trim(implode("\n", $results));
     if ($template = TZ_Portfolio_PlusTemplate::getTemplate(true)) {
         $tplparams = $template->params;
         if (!$tplparams->get('use_single_layout_builder', 1)) {
             $results = $dispatcher->trigger('onContentDisplayArticleView', array('com_tz_portfolio_plus.article', &$item, &$item->params, $offset));
             $item->event->contentDisplayArticleView = trim(implode("\n", $results));
         }
     }
     // Increment the hit counter of the article.
     if (!$this->params->get('intro_only') && $offset == 0) {
         $model = $this->getModel();
         $model->hit();
     }
     foreach ($related as $i => &$itemR) {
         $itemR->link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getArticleRoute($itemR->slug, $itemR->catid) . $tmpl);
         $media = $itemR->media;
         $registry = new JRegistry();
         $registry->loadString($media);
         $media = $registry->toObject();
         $itemR->media = $media;
         $itemR->event = new stdClass();
         $results = $dispatcher->trigger('onContentDisplayMediaType', array('com_tz_portfolio_plus.article', &$itemR, &$item->params, $offset, 'related'));
         if ($itemR) {
             $itemR->event->onContentDisplayMediaType = trim(implode("\n", $results));
             $itemR->mediatypes = $mediatypes;
         } else {
             unset($related[$i]);
         }
     }
     $this->itemsRelated = $related;
     // Get article's extrafields
     JLoader::import('extrafields', COM_TZ_PORTFOLIO_PLUS_SITE_HELPERS_PATH);
     $extraFields = TZ_Portfolio_PlusFrontHelperExtraFields::getExtraFields($this->item, $params);
     $this->item->extrafields = $extraFields;
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($this->item->params->get('pageclass_sfx'));
     $this->_prepareDocument();
     $this->generateLayout($item, $params, $dispatcher);
     parent::display($tpl);
 }
示例#2
0
 public function onSaveArticleFieldValue($value)
 {
     if (!$this->article_id) {
         return false;
     }
     $_value = $this->prepareFieldValue($value);
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $result = true;
     $table_name = '#__tz_portfolio_plus_field_content_map';
     $query->select('m.*');
     $query->from($table_name . ' AS m');
     $query->where('m.fieldsid = ' . $this->id);
     $query->where('m.contentid = ' . $this->article_id);
     $db->setQuery($query);
     $countData = $db->loadResult();
     if ($countData > 0) {
         if ($groupid = TZ_Portfolio_PlusFrontHelperExtraFields::getFieldGroupsByArticleId($this->article_id)) {
             $groupid = JArrayHelper::getColumn($groupid, 'id');
             if (count($groupid)) {
                 $query->join('INNER', '#__tz_portfolio_plus_field_fieldgroup_map AS fm ON fm.fieldsid = m.fieldsid');
                 $query->where('fm.groupid IN(' . implode(',', $groupid) . ')');
             }
         }
         $db->setQuery($query);
         $countGData = $db->loadResult();
         $query->clear();
         if ($_value !== "" && !is_null($_value) && $countGData > 0) {
             $query->update($table_name);
             $query->set('value = ' . $db->quote($_value));
             $query->where('fieldsid = ' . $this->id);
             $query->where('contentid = ' . $this->article_id);
             $db->setQuery($query);
             $result = $db->execute();
         } else {
             $query->delete($table_name);
             $query->where('fieldsid = ' . $this->id);
             $query->where('contentid = ' . $this->article_id);
             $db->setQuery($query);
             $result = $db->execute();
         }
     } else {
         if ($_value !== "" && !is_null($_value)) {
             $query->clear();
             $query->insert($table_name);
             $query->columns('fieldsid, contentid, value, ordering');
             $query->values($this->id . ',' . $this->article_id . ',' . $db->quote($_value) . ', 0');
             $db->setQuery($query);
             $result = $db->execute();
         }
     }
     return $result;
 }
示例#3
0
 public function save($data)
 {
     $groupid = $data['groupid'];
     unset($data['groupid']);
     $table = $this->getTable();
     if ($data['id'] && $table->load($data['id'])) {
         $fieldClass = TZ_Portfolio_PlusFrontHelperExtraFields::getExtraField($data['id']);
         $data = $fieldClass->onSave($data);
     }
     if (parent::save($data)) {
         $pk = !empty($data['id']) ? $data['id'] : (int) $this->getState($this->getName() . '.id');
         // Insert field's groups
         TZ_Portfolio_PlusHelperExtraFields::insertFieldGroups($pk, $groupid);
         return true;
     }
     return false;
 }
示例#4
0
 public function getExtraFields()
 {
     $app = JFactory::getApplication();
     $articleId = $app->input->getInt('id', 0);
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     if ($fieldGroups = TZ_Portfolio_PlusFrontHelperExtraFields::getFieldGroupsByArticleId($articleId)) {
         $fieldsCache = array();
         foreach ($fieldGroups as $i => $fieldGroup) {
             $fieldGroup->fields = array();
             $query->clear();
             $query->select("field.*, m.groupid");
             $query->from("#__tz_portfolio_plus_fields AS field");
             $query->join('LEFT', '#__tz_portfolio_plus_field_fieldgroup_map AS m ON field.id = m.fieldsid');
             $query->join('INNER', '#__tz_portfolio_plus_extensions AS e ON e.element = field.type')->where('e.type = ' . $db->quote('tz_portfolio_plus-plugin'))->where('e.folder = ' . $db->quote('extrafields'))->where('e.published = 1');
             $query->where("field.published = 1");
             $query->where("m.groupid = " . $fieldGroup->id);
             $query->order("field.ordering ASC");
             $db->setQuery($query);
             $_fields = $db->loadObjectList();
             if ($_fields) {
                 foreach ($_fields as $field) {
                     if (!in_array($field->id, $fieldsCache)) {
                         $fieldObj = TZ_Portfolio_PlusFrontHelperExtraFields::getExtraField($field, $articleId);
                         $fieldGroup->fields[] = $fieldObj;
                         $fieldsCache[] = $field->id;
                     }
                 }
             }
             if (!count($fieldGroup->fields)) {
                 unset($fieldGroups[$i]);
             }
         }
         return $fieldGroups;
     }
     return false;
 }