protected function getOptions() { $element = $this->element; $options = array(); $_plugin = $element['addon'] ? $element['addon'] : null; $_plugin_group = $element['addon_group'] ? $element['addon_group'] : 'mediatype'; $param_filter = $element['param_name'] ? $element['param_name'] : null; if ($_plugin && $param_filter) { if ($plugin = TZ_Portfolio_PlusPluginHelper::getPlugin($_plugin_group, $_plugin, false)) { if (!empty($plugin->params)) { $plg_params = new JRegistry(); $plg_params->loadString($plugin->params); if ($image_size = $plg_params->get($param_filter)) { if (!is_array($image_size) && preg_match_all('/(\\{.*?\\})/', $image_size, $match)) { $image_size = $match[1]; } foreach ($image_size as $i => $size) { $_size = json_decode($size); $options[$i] = new stdClass(); $options[$i]->text = $_size->{$element['param_text']}; $options[$i]->value = $_size->{$element['param_value']}; } } } } } return array_merge(parent::getOptions(), $options); }
public function display($tpl = null) { JFactory::getLanguage()->load('com_templates'); $document = JFactory::getDocument(); $this->document->addCustomTag('<link rel="stylesheet" href="' . JUri::base(true) . '/components/com_tz_portfolio_plus/css/admin-layout.min.css" type="text/css"/>'); $this->document->addCustomTag('<link rel="stylesheet" href="' . JUri::base(true) . '/components/com_tz_portfolio_plus/css/spectrum.min.css" type="text/css"/>'); $this->item = $this->get('Item'); $this->tzlayout = $this->get('TZLayout'); $this->form = $this->get('Form'); $this->presets = $this->get('Presets'); if ($includeTypes = TZ_Portfolio_PlusPluginHelper::getContentTypes()) { $this->includeTypes = $includeTypes; } $this->addToolbar(); parent::display($tpl); $this->document->addScript(JUri::base(true) . '/components/com_tz_portfolio_plus/js/libs.min.js'); $this->document->addScript(JUri::base(true) . '/components/com_tz_portfolio_plus/js/jquery-ui.min.js'); $this->document->addScript(JUri::base(true) . '/components/com_tz_portfolio_plus/js/layout-admin.min.js'); $this->document->addScript(JUri::base(true) . '/components/com_tz_portfolio_plus/js/spectrum.min.js'); $this->document->addScriptDeclaration(' jQuery(document).ready(function(){ jQuery.tzLayoutAdmin({ pluginPath : "' . JURI::root(true) . '/administrator/components/com_tz_portfolio_plus/views/template_style/tmpl", fieldName : "jform[attrib]" }); }) Joomla.submitbutton = function(task) { if (task == \'template.cancel\' || document.formvalidator.isValid(document.id(\'template-form\'))) { jQuery.tzLayoutAdmin.tzTemplateSubmit(); Joomla.submitform(task, document.getElementById(\'template-form\')); }else { alert("' . $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED')) . '"); } };'); }
protected function _getFieldTypes() { $data = array(); $core_path = COM_TZ_PORTFOLIO_PLUS_ADDON_PATH . DIRECTORY_SEPARATOR . 'extrafields'; if ($plg_ex = TZ_Portfolio_PlusPluginHelper::getPlugin('extrafields')) { $lang = JFactory::getLanguage(); $field = $this->form->getData(); $field = $field->toObject(); foreach ($plg_ex as $i => $plg) { $folder = $plg->name; $core_f_xml_path = $core_path . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $folder . '.xml'; if (JFile::exists($core_f_xml_path)) { $core_class = 'TZ_Portfolio_PlusExtraField' . $folder; if (!class_exists($core_class)) { JLoader::import('com_tz_portfolio_plus.addons.extrafields.' . $folder . '.' . $folder, JPATH_SITE . DIRECTORY_SEPARATOR . 'components'); } $core_class = new $core_class($field); $data[$i] = new stdClass(); $data[$i]->value = $folder; $core_class->loadLanguage($folder); $key_lang = 'PLG_EXTRAFIELDS_' . strtoupper($folder) . '_TITLE'; if ($lang->hasKey($key_lang)) { $data[$i]->text = JText::_($key_lang); } else { $data[$i]->text = (string) $folder; } } } } return $data; }
public function onAfterRoute() { if (class_exists('TZ_Portfolio_PlusPluginHelper')) { TZ_Portfolio_PlusPluginHelper::importPlugin('mediatype'); TZ_Portfolio_PlusPluginHelper::importPlugin('content'); TZ_Portfolio_PlusPluginHelper::importPlugin('user'); } }
/** * Display the view */ public function display($tpl = null) { if (JFactory::getApplication()->input->getCmd('task') != 'lists') { if ($this->getLayout() == 'pagebreak') { $eName = JFactory::getApplication()->input->get('e_name'); $eName = preg_replace('#[^A-Z0-9\\-\\_\\[\\]]#i', '', $eName); $document = JFactory::getDocument(); $document->setTitle(JText::_('COM_CONTENT_PAGEBREAK_DOC_TITLE')); $this->assignRef('eName', $eName); parent::display($tpl); return; } // Initialiase variables. $this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->state = $this->get('State'); $canDo = TZ_Portfolio_PlusHelper::getActions($this->state->get('filter.category_id')); $this->canDo = $canDo; if ($canDo->get('core.edit')) { $this->extraFields = $this->get('ExtraFields'); } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // $this -> assign('listsGroup',$this -> get('Groups')); // v3.3.2 $this->assign('listsTags', json_encode($this->get('Tags'))); $this->assign('listAttach', $this->get('Attachment')); $this->assign('listEdit', $this->get('FieldsContent')); $this->assign('tagsSuggest', TZ_Portfolio_PlusHelperTags::getTagsSuggestToArticle()); // Load Tabs's title from plugin group tz_portfolio_plus_mediatype $dispatcher = JDispatcher::getInstance(); TZ_Portfolio_PlusPluginHelper::importPlugin('mediatype'); if ($mediaType = $dispatcher->trigger('onAddMediaType')) { $mediaForm = $dispatcher->trigger('onMediaTypeDisplayArticleForm', array($this->item)); if (count($mediaType)) { $plugin = array(); foreach ($mediaType as $i => $type) { $plugin[$i] = new stdClass(); $plugin[$i]->type = $type; $plugin[$i]->html = ''; if ($mediaForm && count($mediaForm) && isset($mediaForm[$i])) { $plugin[$i]->html = $mediaForm[$i]; } $this->pluginsMediaTypeTab[$i] = $plugin[$i]; } } } $this->addToolbar(); } parent::display($tpl); }
public static function options($group = 'mediatype') { $options = array(); $dispatcher = JEventDispatcher::getInstance(); TZ_Portfolio_PlusPluginHelper::importPlugin($group); if ($results = $dispatcher->trigger('onAddMediaType')) { if (count($results)) { foreach ($results as $item) { $options[] = JHtml::_('select.option', $item->value, $item->text); } } } return $options; }
public static function getLayoutPath($type, $name, $client = 'site', $layout = 'default', $viewName = null) { $defaultLayout = $layout; if ($client == 'site' && $viewName && !empty($viewName)) { $_template = TZ_Portfolio_PlusTemplate::getTemplate(true); $template = $_template->template; $params = $_template->params; if (strpos($layout, ':') !== false) { // Get the template and file name from the string $temp = explode(':', $layout); $template = $temp[0] == '_' ? $_template->template : $temp[0]; $layout = $temp[1]; $defaultLayout = $temp[1] ? $temp[1] : 'default'; } self::$layout = $defaultLayout; // Build the template and base path for the layout $tPath = COM_TZ_PORTFOLIO_PLUS_TEMPLATE_PATH . '/' . $template . '/html/' . $params->get('layout', 'default') . '/' . $viewName . '/plg_' . $type . '_' . $name . '/' . $layout . '.php'; $bPath = COM_TZ_PORTFOLIO_PLUS_ADDON_PATH . '/' . $type . '/' . $name . '/views' . '/' . $viewName . '/tmpl' . '/' . $defaultLayout . '.php'; $dPath = COM_TZ_PORTFOLIO_PLUS_ADDON_PATH . '/' . $type . '/' . $name . '/views' . '/' . $viewName . '/tmpl' . '/default.php'; } elseif ($client == 'admin') { $template = JFactory::getApplication()->getTemplate(); if (strpos($layout, ':') !== false) { // Get the template and file name from the string $temp = explode(':', $layout); $template = $temp[0] == '_' ? $template : $temp[0]; $layout = $temp[1]; $defaultLayout = $temp[1] ? $temp[1] : 'default'; } // Build the template and base path for the layout $tPath = JPATH_THEMES . '/' . $template . '/html/plg_' . $type . '_' . $name . '/' . $layout . '.php'; $bPath = COM_TZ_PORTFOLIO_PLUS_ADDON_PATH . '/' . $type . '/' . $name . '/tmpl/' . $defaultLayout . '.php'; $dPath = COM_TZ_PORTFOLIO_PLUS_ADDON_PATH . '/' . $type . '/' . $name . '/tmpl/default.php'; } // If the template has a layout override use it if (file_exists($tPath)) { return $tPath; } elseif (file_exists($bPath)) { return $bPath; } else { return $dPath; } }
public function __construct($field = null, $article = null, $option = array()) { if (!is_object($field)) { return false; } if (count($option)) { if (isset($option['control'])) { $this->formcontrol = $option['control']; } if (isset($option['group'])) { $this->group = $option['group']; } } $this->id = $field->id; $app = JFactory::getApplication(); if ($field->type) { $plugin = TZ_Portfolio_PlusPluginHelper::getPlugin('extrafields', $field->type); $this->plugin_params = new JRegistry($plugin->params); } if (isset($field->params) && !empty($field->params)) { $params = new JRegistry($field->params); if ($app->isSite()) { $this->params = $this->plugin_params->merge($params); } else { $this->params = $params; } } else { if ($app->isSite()) { $this->params = $this->plugin_params; } else { $this->params = new JRegistry(); } } $this->fieldname = $field->type; $this->name = $this->formcontrol . '[' . $this->group . '][' . $this->id . ']'; if ($this->multiple) { $this->name .= '[]'; } $this->field = $field; $this->loadLanguage($field->type); return true; }
protected function getOptions() { $element = $this->element; $options = array(); $_plugin_group = $element['plugin_group'] ? $element['plugin_group'] : 'mediatype'; if ($plugins = TZ_Portfolio_PlusPluginHelper::getPlugin($_plugin_group)) { $lang = JFactory::getLanguage(); foreach ($plugins as $plugin) { $std = new stdClass(); $std->value = $plugin->name; $lang->load('plg_' . $plugin->type . '_' . $plugin->name, COM_TZ_PORTFOLIO_PLUS_ADDON_PATH . DIRECTORY_SEPARATOR . $plugin->type . DIRECTORY_SEPARATOR . $plugin->name); if ($lang->hasKey('PLG_' . $plugin->type . '_' . $plugin->name . '_TITLE')) { $std->text = JText::_('PLG_' . $plugin->type . '_' . $plugin->name . '_TITLE'); } else { $std->text = $plugin->name; } $options[] = $std; } } return array_merge(parent::getOptions(), $options); }
protected function _childrenLayout(&$rows, $children, &$article, &$params, $dispatcher) { foreach ($children->children as $children) { $background = null; $color = null; $margin = null; $padding = null; $childRows = array(); $class = null; $rowName = null; $responsive = null; if (isset($children->name) && $children->name) { $rowName = JApplication::stringURLSafe($children->name); } if (isset($children->{"class"}) && $children->{"class"}) { $class = $children->{"class"}; } if (isset($children->responsive) && $children->responsive) { $class = $children->responsive; } if (isset($children->backgroundcolor) && $children->backgroundcolor && !preg_match('/^rgba\\([0-9]+\\,\\s+?[0-9]+\\,\\s+?[0-9]+\\,\\s+?0\\)$/i', trim($children->backgroundcolor))) { $background = 'background: ' . $children->backgroundcolor . ';'; } if (isset($children->textcolor) && $children->textcolor && !preg_match('/^rgba\\([0-9]+\\,\\s+?[0-9]+\\,\\s+?[0-9]+\\,\\s+?0\\)$/i', trim($children->textcolor))) { $color = 'color: ' . $children->textcolor . ';'; } if (isset($children->margin) && !empty($children->margin)) { $margin = 'margin: ' . $children->margin . ';'; } if (isset($children->padding) && !empty($children->padding)) { $padding = 'padding: ' . $children->padding . ';'; } if ($background || $color) { $this->document->addStyleDeclaration(' #tz-portfolio-template-' . ($rowName ? $rowName : '') . '-inner{ ' . $background . $color . $margin . $padding . ' } '); } if (isset($children->linkcolor) && $children->linkcolor && !preg_match('/^rgba\\([0-9]+\\,\\s+?[0-9]+\\,\\s+?[0-9]+\\,\\s+?0\\)$/i', trim($children->linkcolor))) { $this->document->addStyleDeclaration(' #tz-portfolio-template-' . ($rowName ? $rowName : '') . '-inner a{ color: ' . $children->linkcolor . '; } '); } if (isset($children->linkhovercolor) && $children->linkhovercolor && !preg_match('/^rgba\\([0-9]+\\,\\s+?[0-9]+\\,\\s+?[0-9]+\\,\\s+?0\\)$/i', trim($children->linkhovercolor))) { $this->document->addStyleDeclaration(' #tz-portfolio-template-' . ($rowName ? $rowName : '') . '-inner a:hover{ color: ' . $children->linkhovercolor . '; } '); } foreach ($children->children as $children) { $html = null; if ($children->type && $children->type != 'none') { if (in_array($children->type, $this->core_types)) { $html = $this->loadTemplate($children->type); } else { $plugin = $children->type; $layout = null; if (strpos($children->type, ':') != false) { list($plugin, $layout) = explode(':', $children->type); } if ($plugin_obj = TZ_Portfolio_PlusPluginHelper::getPlugin('content', $plugin)) { $className = 'PlgTZ_Portfolio_PlusContent' . ucfirst($plugin); if (!class_exists($className)) { TZ_Portfolio_PlusPluginHelper::importPlugin('content', $plugin); } if (class_exists($className)) { $registry = new JRegistry($plugin_obj->params); $plgClass = new $className($dispatcher, array('type' => $plugin_obj->type, 'name' => $plugin_obj->name, 'params' => $registry)); if (method_exists($plgClass, 'onContentDisplayArticleView')) { $html = $plgClass->onContentDisplayArticleView('com_tz_portfolio_plus.' . $this->getName(), $this->item, $this->item->params, $this->state->get('list.offset'), $layout); } } if (is_array($html)) { $html = implode("\n", $html); } } } $html = trim($html); } if (!empty($html) || (!empty($children->children) and is_array($children->children))) { if (!empty($children->{"col-lg"}) || !empty($children->{"col-md"}) || !empty($children->{"col-sm"}) || !empty($children->{"col-xs"}) || !empty($children->{"col-lg-offset"}) || !empty($children->{"col-md-offset"}) || !empty($children->{"col-sm-offset"}) || !empty($children->{"col-xs-offset"}) || !empty($children->{"customclass"}) || $children->responsiveclass) { $childRows[] = '<div class="' . (!empty($children->{"col-lg"}) ? 'col-lg-' . $children->{"col-lg"} : '') . (!empty($children->{"col-md"}) ? ' col-md-' . $children->{"col-md"} : '') . (!empty($children->{"col-sm"}) ? ' col-sm-' . $children->{"col-sm"} : '') . (!empty($children->{"col-xs"}) ? ' col-xs-' . $children->{"col-xs"} : '') . (!empty($children->{"col-lg-offset"}) ? ' col-lg-offset-' . $children->{"col-lg-offset"} : '') . (!empty($children->{"col-md-offset"}) ? ' col-md-offset-' . $children->{"col-md-offset"} : '') . (!empty($children->{"col-sm-offset"}) ? ' col-sm-offset-' . $children->{"col-sm-offset"} : '') . (!empty($children->{"col-xs-offset"}) ? ' col-xs-offset-' . $children->{"col-xs-offset"} : '') . (!empty($children->{"customclass"}) ? ' ' . $children->{"customclass"} : '') . ($children->responsiveclass ? ' ' . $children->responsiveclass : '') . '">'; } $childRows[] = $html; if (!empty($children->children) and is_array($children->children)) { $this->_childrenLayout($childRows, $children, $article, $params, $dispatcher); } if (!empty($children->{"col-lg"}) || !empty($children->{"col-md"}) || !empty($children->{"col-sm"}) || !empty($children->{"col-xs"}) || !empty($children->{"col-lg-offset"}) || !empty($children->{"col-md-offset"}) || !empty($children->{"col-sm-offset"}) || !empty($children->{"col-xs-offset"}) || !empty($children->{"customclass"}) || $children->responsiveclass) { $childRows[] = '</div>'; // Close col tag } } } if (count($childRows)) { $rows[] = '<div id="tz-portfolio-template-' . ($rowName ? $rowName : '') . '-inner" class="' . ($class ? $class : '') . ($responsive ? ' ' . $responsive : '') . '">'; $rows[] = '<div class="row">'; $rows = array_merge($rows, $childRows); $rows[] = '</div>'; $rows[] = '</div>'; } } return; }
public function getItems() { if ($items = parent::getItems()) { $user = JFactory::getUser(); $userId = $user->get('id'); $guest = $user->get('guest'); $params = $this->getState('params'); JLoader::import('category', COM_TZ_PORTFOLIO_PLUS_PATH_SITE . DIRECTORY_SEPARATOR . 'helpers'); $_params = null; $threadLink = null; $comments = null; if (count($items) > 0) { $content_ids = JArrayHelper::getColumn($items, 'id'); $mainCategories = TZ_Portfolio_PlusFrontHelperCategories::getCategoriesByArticleId($content_ids, array('main' => true)); $second_categories = TZ_Portfolio_PlusFrontHelperCategories::getCategoriesByArticleId($content_ids, array('main' => false)); $tags = null; if (count($content_ids) && $params->get('show_tags', 1)) { $tags = TZ_Portfolio_PlusFrontHelperTags::getTagsByArticleId($content_ids, array('orderby' => 'm.contentid', 'menuActive' => $params->get('menu_active', 'auto'), 'reverse_contentid' => true)); } $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); TZ_Portfolio_PlusPluginHelper::importPlugin('mediatype'); TZ_Portfolio_PlusPluginHelper::importPlugin('content'); $dispatcher->trigger('onAlwaysLoadDocument', array('com_tz_portfolio_plus.portfolio')); $dispatcher->trigger('onLoadData', array('com_tz_portfolio_plus.portfolio', $items, $params)); // Get the global params $globalParams = JComponentHelper::getParams('com_tz_portfolio_plus', true); foreach ($items as $i => &$item) { $_params = clone $params; $item->params = clone $_params; $articleParams = new JRegistry(); $articleParams->loadString($item->attribs); if ($mainCategories && isset($mainCategories[$item->id])) { $mainCategory = $mainCategories[$item->id]; if ($mainCategory) { $item->catid = $mainCategory->id; $item->category_title = $mainCategory->title; $item->catslug = $mainCategory->id . ':' . $mainCategory->alias; $item->category_link = $mainCategory->link; // Merge main category's params to article $catParams = new JRegistry($mainCategory->params); if ($inheritFrom = $catParams->get('inheritFrom', 0)) { if ($inheritCategory = TZ_Portfolio_PlusFrontHelperCategories::getCategoriesById($inheritFrom)) { $inheritCatParams = new JRegistry($inheritCategory->params); $catParams = clone $inheritCatParams; } } $item->params->merge($catParams); } } else { // Create main category's link $item->category_link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getCategoryRoute($item->catid)); // Merge main category's params to article if ($mainCategory = TZ_Portfolio_PlusFrontHelperCategories::getCategoriesById($item->catid)) { $catParams = new JRegistry($mainCategory->params); if ($inheritFrom = $catParams->get('inheritFrom', 0)) { if ($inheritCategory = TZ_Portfolio_PlusFrontHelperCategories::getCategoriesById($inheritFrom)) { $inheritCatParams = new JRegistry($inheritCategory->params); $catParams = clone $inheritCatParams; } } $item->params->merge($catParams); } } // Merge with article params $item->params->merge($articleParams); // Get all second categories $item->second_categories = null; if (isset($second_categories[$item->id])) { $item->second_categories = $second_categories[$item->id]; } // Get article's tags $item->tags = null; if ($tags && count($tags) && isset($tags[$item->id])) { $item->tags = $tags[$item->id]; } /*** Start New Source ***/ $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; } // Create Article Link $item->link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_Portfolio_PlusHelperRoute::getArticleRoute($item->slug, $item->catid), true, $ssl); // Create author Link $item->author_link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getUserRoute($item->created_by, $params->get('user_menu_active', 'auto'))); // Compute the asset access permissions. // Technically guest could edit an article, but lets not check that to improve performance a little. if (!$guest) { $asset = 'com_tz_portfolio_plus.article.' . $item->id; // Check general edit permission first. if ($user->authorise('core.edit', $asset)) { $item->params->set('access-edit', true); } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) { // Check for a valid user and that they are the owner. if ($userId == $item->created_by) { $item->params->set('access-edit', true); } } } $media = $item->media; if ($item->media && !empty($item->media)) { $registry = new JRegistry($item->media); $obj = $registry->toObject(); $item->media = clone $obj; } $item->mediatypes = array(); // Add feed links if (JFactory::getApplication()->input->getCmd('format', null) != 'feed') { // Old plugins: Ensure that text property is available if (!isset($item->text)) { $item->text = $item->introtext; } // // Process the content plugins. // $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio_plus.portfolio', &$item, &$item->params, $this->getState('list.start'))); $item->introtext = $item->text; $item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio_plus.portfolio', &$item, &$item->params, $this->getState('list.start'))); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio_plus.portfolio', &$item, &$item->params, $this->getState('list.start'))); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio_plus.portfolio', &$item, &$item->params, $this->getState('list.start'))); $item->event->afterDisplayContent = trim(implode("\n", $results)); // Process the tz portfolio's content plugins. $results = $dispatcher->trigger('onContentDisplayVote', array('com_tz_portfolio_plus.portfolio', &$item, &$item->params, $this->getState('list.start'))); $item->event->contentDisplayVote = trim(implode("\n", $results)); $results = $dispatcher->trigger('onBeforeDisplayAdditionInfo', array('com_tz_portfolio_plus.portfolio', &$item, &$item->params, $this->getState('list.start'))); $item->event->beforeDisplayAdditionInfo = trim(implode("\n", $results)); $results = $dispatcher->trigger('onAfterDisplayAdditionInfo', array('com_tz_portfolio_plus.portfolio', &$item, &$item->params, $this->getState('list.start'))); $item->event->afterDisplayAdditionInfo = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentDisplayListView', array('com_tz_portfolio_plus.portfolio', &$item, &$item->params, $this->getState('list.start'))); $item->event->contentDisplayListView = trim(implode("\n", $results)); // Process the tz portfolio's mediatype plugins. $results = $dispatcher->trigger('onContentDisplayMediaType', array('com_tz_portfolio_plus.portfolio', &$item, &$item->params, $this->getState('list.start'))); if ($item) { $item->event->onContentDisplayMediaType = trim(implode("\n", $results)); if ($results = $dispatcher->trigger('onAddMediaType')) { $mediatypes = array(); foreach ($results as $result) { if (isset($result->special) && $result->special) { $mediatypes[] = $result->value; } } $item->mediatypes = $mediatypes; } } else { unset($items[$i]); } } if ($item && strlen(trim($item->introtext)) && ($introLimit = $params->get('tz_article_intro_limit'))) { $item->introtext = '<p>' . JHtml::_('string.truncate', $item->introtext, $introLimit, true, false) . '</p>'; } } return $items; } } return false; }
function display($tpl = null) { $doc = JFactory::getDocument(); $menus = JMenu::getInstance('site'); $active = $menus->getActive(); $state = $this->get('State'); $this->state = $state; $params = $state->params; // Set value again for option tz_portfolio_plus_redirect if ($params->get('tz_portfolio_plus_redirect') == 'default') { $params->set('tz_portfolio_plus_redirect', 'article'); } $items = $this->get('Items'); if ($items) { $user = JFactory::getUser(); $userId = $user->get('id'); $guest = $user->get('guest'); $content_ids = array(); if ($items) { $content_ids = JArrayHelper::getColumn($items, 'id'); } $mainCategories = TZ_Portfolio_PlusFrontHelperCategories::getCategoriesByArticleId($content_ids, array('main' => true)); $second_categories = TZ_Portfolio_PlusFrontHelperCategories::getCategoriesByArticleId($content_ids, array('main' => false)); $tags = null; if (count($content_ids) && $params->get('show_tags', 1)) { $tags = TZ_Portfolio_PlusFrontHelperTags::getTagsByArticleId($content_ids, array('orderby' => 'm.contentid', 'reverse_contentid' => true)); } $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); TZ_Portfolio_PlusPluginHelper::importPlugin('content'); TZ_Portfolio_PlusPluginHelper::importPlugin('mediatype'); $dispatcher->trigger('onAlwaysLoadDocument', array('com_tz_portfolio_plus.users')); $dispatcher->trigger('onLoadData', array('com_tz_portfolio_plus.users', $items, $params)); foreach ($items as $i => &$item) { if ($mainCategories && isset($mainCategories[$item->id])) { $mainCategory = $mainCategories[$item->id]; if ($mainCategory) { $item->catid = $mainCategory->id; $item->category_title = $mainCategory->title; $item->catslug = $mainCategory->id . ':' . $mainCategory->alias; $item->category_link = $mainCategory->link; } } else { // Create main category's link $item->category_link = TZ_Portfolio_PlusHelperRoute::getCategoryRoute($item->catid); } // Get all second categories $item->second_categories = null; if (isset($second_categories[$item->id])) { $item->second_categories = $second_categories[$item->id]; } // Get article's tags $item->tags = null; if ($tags && count($tags) && isset($tags[$item->id])) { $item->tags = $tags[$item->id]; } /*** New source ***/ $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; } // Create article link $item->link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_Portfolio_PlusHelperRoute::getArticleRoute($item->slug, $item->catid), true, $ssl); // Create author link $item->author_link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getUserRoute($item->created_by, $params->get('user_menu_active', 'auto'))); // Compute the asset access permissions. // Technically guest could edit an article, but lets not check that to improve performance a little. if (!$guest) { $asset = 'com_tz_portfolio_plus.article.' . $item->id; // Check general edit permission first. if ($user->authorise('core.edit', $asset)) { $item->params->set('access-edit', true); } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) { // Check for a valid user and that they are the owner. if ($userId == $item->created_by) { $item->params->set('access-edit', true); } } } // Old plugins: Ensure that text property is available if (!isset($item->text)) { $item->text = $item->introtext; } if (version_compare(COM_TZ_PORTFOLIO_PLUS_VERSION, '3.1.7', '<')) { $item->text = null; if ($params->get('show_intro', 1)) { $item->text = $item->introtext; } } $item->event = new stdClass(); //Call trigger in group content $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio_plus.users', &$item, &$params, $state->get('offset'))); $item->introtext = $item->text; $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio_plus.users', &$item, &$params, $state->get('offset'))); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio_plus.users', &$item, &$params, $state->get('offset'))); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio_plus.users', &$item, &$params, $state->get('offset'))); $item->event->afterDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentTZPortfolioVote', array('com_tz_portfolio_plus.users', &$item, &$params, $state->get('offset'))); $item->event->TZPortfolioVote = trim(implode("\n", $results)); // Process the tz portfolio's content plugins. $results = $dispatcher->trigger('onContentDisplayVote', array('com_tz_portfolio_plus.users', &$item, &$params, $state->get('offset'))); $item->event->contentDisplayVote = trim(implode("\n", $results)); $results = $dispatcher->trigger('onBeforeDisplayAdditionInfo', array('com_tz_portfolio_plus.users', &$item, &$params, $state->get('offset'))); $item->event->beforeDisplayAdditionInfo = trim(implode("\n", $results)); $results = $dispatcher->trigger('onAfterDisplayAdditionInfo', array('com_tz_portfolio_plus.users', &$item, &$params, $state->get('offset'))); $item->event->afterDisplayAdditionInfo = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentDisplayListView', array('com_tz_portfolio_plus.users', &$item, &$params, $state->get('offset'))); $item->event->contentDisplayListView = trim(implode("\n", $results)); //Call trigger in group tz_portfolio_plus_mediatype $results = $dispatcher->trigger('onContentDisplayMediaType', array('com_tz_portfolio_plus.users', &$item, &$params, $state->get('offset'))); if ($item) { $item->event->onContentDisplayMediaType = trim(implode("\n", $results)); if ($results = $dispatcher->trigger('onAddMediaType')) { $mediatypes = array(); foreach ($results as $result) { if (isset($result->special) && $result->special) { $mediatypes[] = $result->value; } } $item->mediatypes = $mediatypes; } } else { unset($items[$i]); } } } //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); if ($active) { $params->def('page_heading', $params->get('page_title', $active->title)); } else { $params->def('page_heading', JText::_('JGLOBAL_ARTICLES')); } $this->items = $items; $this->params = $params; $this->assign('mediaParams', $params); $this->assign('pagination', $this->get('Pagination')); if ($author = JFactory::getUser($state->get('users.id'))) { $author_registry = $author->getParameters(); $author_info = new stdClass(); $author_info->id = $author->id; $author_info->url = $author_registry->get('tz_portfolio_plus_user_url'); $author_info->email = $author->email; $author_info->gender = $author_registry->get('tz_portfolio_plus_user_gender'); $author_info->avatar = $author_registry->get('tz_portfolio_plus_user_avatar'); $author_info->social_links = null; if ($social_links = $author_registry->get('tz_portfolio_plus_user_social_link')) { foreach ($social_links as &$social_link) { $social_link = json_decode($social_link); } $author_info->social_links = $social_links; } $author_info->description = $author_registry->get('tz_portfolio_plus_user_description'); $author_info->author = $author->name; $author_info->author_link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getUserRoute($state->get('users.id'), $params->get('user_menu_active', 'auto'))); $this->item_author = $author_info; } $params = $state->params; JModelLegacy::addIncludePath(COM_TZ_PORTFOLIO_PLUS_PATH_SITE . DIRECTORY_SEPARATOR . 'models'); $model = JModelLegacy::getInstance('Portfolio', 'TZ_Portfolio_PlusModel', array('ignore_request' => true)); $model->setState('params', $params); $model->setState('filter.userId', $state->get('users.id')); $this->char = $state->get('filter.char'); $this->availLetter = $model->getAvailableLetter(); if ($params->get('tz_use_lightbox', 0) == 1) { $doc->addCustomTag('<script type="text/javascript" src="components/com_tz_portfolio_plus/js' . '/jquery.fancybox.pack.js"></script>'); $doc->addStyleSheet('components/com_tz_portfolio_plus/css/fancybox.min.css'); $width = null; $height = null; $autosize = null; if ($params->get('tz_lightbox_width')) { if (preg_match('/%|px/', $params->get('tz_lightbox_width'))) { $width = 'width:\'' . $params->get('tz_lightbox_width') . '\','; } else { $width = 'width:' . $params->get('tz_lightbox_width') . ','; } } if ($params->get('tz_lightbox_height')) { if (preg_match('/%|px/', $params->get('tz_lightbox_height'))) { $height = 'height:\'' . $params->get('tz_lightbox_height') . '\','; } else { $height = 'height:' . $params->get('tz_lightbox_height') . ','; } } if ($width || $height) { $autosize = 'fitToView: false,autoSize: false,'; } $scrollHidden = null; if ($params->get('use_custom_scrollbar', 1)) { $scrollHidden = ',scrolling: "no" ,iframe: { scrolling : "no", }'; } $doc->addCustomTag('<script type="text/javascript"> jQuery(\'.fancybox\').fancybox({ type:\'iframe\', openSpeed:' . $params->get('tz_lightbox_speed', 350) . ', openEffect: "' . $params->get('tz_lightbox_transition', 'elastic') . '", ' . $width . $height . $autosize . ' helpers: { title : { type : "inside" }, overlay : { css : {background: "rgba(0,0,0,' . $params->get('tz_lightbox_opacity', 0.75) . ')"} } }' . $scrollHidden . ' }); </script> '); } $doc->addStyleSheet('components/com_tz_portfolio_plus/css/tzportfolioplus.min.css'); $this->_prepareDocument(); // Add feed links if ($params->get('show_feed_link', 1)) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $doc->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $doc->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } parent::display($tpl); }
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); }
protected function loadTemplate($tpl = null) { $layout = TZ_Portfolio_PlusPluginHelper::getLayout(); // Create the template file name based on the layout $file = isset($tpl) ? $layout . '_' . $tpl : $layout; // Clean the file name $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $file); $path = TZ_Portfolio_PlusPluginHelper::getLayoutPath($this->_type, $this->_name, 'admin', $file); ob_start(); require_once $path; $html = ob_get_contents(); ob_end_clean(); return $html; }
public function parse(&$segments) { $vars = array(); $tmp = null; $total = count($segments); for ($i = 0; $i < $total; $i++) { if (strpos($segments[$i], 'addon_') !== false) { $tmp = $i; break; } } // Get addon parse router $addonVars = array(); if ($tmp) { $addonSegments = array_slice($segments, $tmp, $total); $segments = array_slice($segments, 0, $tmp); if (count($addonSegments)) { $addon_id = (int) str_replace('addon_', '', $addonSegments[0]); $addonVars['addon_id'] = $addon_id; $addon = TZ_Portfolio_PlusPluginHelper::getPluginById($addon_id); if ($router = $this->getAddonRouter($addon->name, $addon->type)) { $_addonVars = $router->parse($addonSegments); $addonVars = array_merge($addonVars, $_addonVars); } } } $params = JComponentHelper::getParams('com_tz_portfolio_plus'); if ($params->get('tzSef', 1)) { $vars = $this->sefParse($segments); } else { $vars = $this->notSefParse($segments); } $vars = array_merge($vars, $addonVars); return $vars; }
/** * Method to get a list of articles. * Overridden to add a check for access levels. * * @return mixed An array of data items on success, false on failure. * @since 1.6.1 */ public function getItems() { $items = parent::getItems(); $app = JFactory::getApplication(); // Get fields group $data = array(); if ($app->isSite()) { $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); for ($x = 0, $count = count($items); $x < $count; $x++) { //Check the access level. Remove articles the user shouldn't see if (!in_array($items[$x]->access, $groups)) { unset($items[$x]); } } } if ($items) { $texts = array(); $values = array(); $dispatcher = JEventDispatcher::getInstance(); TZ_Portfolio_PlusPluginHelper::importPlugin('mediatype'); $results = $dispatcher->trigger('onAddMediaType'); if (count($results)) { $texts = JArrayHelper::getColumn($results, 'text'); $values = JArrayHelper::getColumn($results, 'value'); } foreach ($items as &$item) { $categories = TZ_Portfolio_PlusHelperCategories::getCategoriesByArticleId($item->id, 0); $item->categories = $categories; if (isset($item->type) && in_array($item->type, $values)) { $index = array_search($item->type, $values); $item->type = $texts[$index]; } else { $item->type = JText::_('COM_TZ_PORTFOLIO_PLUS_OPTION_NONE_MEDIA'); } } } return $items; }
public static function getList(&$params) { // Get the dbo $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('c.*, c.id as content_id, u.name as user_name, u.id as user_id'); $query->select('CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as slug'); $query->select('CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'); $query->select('CASE WHEN CHAR_LENGTH(c.fulltext) THEN c.fulltext ELSE null END as readmore'); $query->from('#__tz_portfolio_plus_content AS c'); $query->join('INNER', $db->quoteName('#__tz_portfolio_plus_content_category_map') . ' AS m ON m.contentid=c.id'); $query->join('LEFT', $db->quoteName('#__tz_portfolio_plus_categories') . ' AS cc ON cc.id=m.catid'); $query->join('LEFT', $db->quoteName('#__tz_portfolio_plus_tag_content_map') . ' AS x ON x.contentid=c.id'); $query->join('LEFT', $db->quoteName('#__tz_portfolio_plus_tags') . ' AS t ON t.id=x.tagsid'); $query->join('LEFT', $db->quoteName('#__users') . ' AS u ON u.id=c.created_by'); $query->where('c.state= 1'); if ($params->get('category_filter', 2) == 2) { $query->where('(m.main = 0 OR m.main = 1)'); } elseif ($params->get('category_filter', 2) == 1) { $query->where('m.main = 1'); } else { $query->where('m.main = 0'); } $nullDate = $db->Quote($db->getNullDate()); $nowDate = $db->Quote(JFactory::getDate()->toSQL()); $query->where('(c.publish_up = ' . $nullDate . ' OR c.publish_up <= ' . $nowDate . ')'); $query->where('(c.publish_down = ' . $nullDate . ' OR c.publish_down >= ' . $nowDate . ')'); if ($types = $params->get('media_types', array())) { $types = array_filter($types); if (count($types)) { $media_conditions = array(); foreach ($types as $type) { $media_conditions[] = 'c.type=' . $db->quote($type); } if (count($media_conditions)) { $query->where('(' . implode(' OR ', $media_conditions) . ')'); } } } if (!$params->get('show_featured', 1)) { $query->where('c.featured = 0'); } elseif ($params->get('show_featured', 1) == 2) { $query->where('c.featured = 1'); } $catids = $params->get('catid'); if (is_array($catids)) { $catids = array_filter($catids); if (count($catids)) { $query->where('m.catid IN(' . implode(',', $catids) . ')'); } } else { $query->where('m.catid IN(' . $catids . ')'); } switch ($params->get('orderby_sec', 'rdate')) { default: $orderby = 'c.id DESC'; break; case 'rdate': $orderby = 'c.created DESC'; break; case 'date': $orderby = 'c.created ASC'; break; case 'alpha': $orderby = 'c.title ASC'; break; case 'ralpha': $orderby = 'c.title DESC'; break; case 'author': $orderby = 'u.name ASC'; break; case 'rauthor': $orderby = 'u.name DESC'; break; case 'hits': $orderby = 'c.hits DESC'; break; case 'rhits': $orderby = 'c.hits ASC'; break; case 'order': $orderby = 'c.ordering ASC'; break; } if ($params->get('random_article', 0)) { $query->order('RAND()'); } $query->order($orderby); $query->group('c.id'); $db->setQuery($query, 0, $params->get('article_limit', 5)); $items = $db->loadObjectList(); if ($items) { $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); TZ_Portfolio_PlusPluginHelper::importPlugin('content'); TZ_Portfolio_PlusPluginHelper::importPlugin('mediatype'); $dispatcher->trigger('onAlwaysLoadDocument', array('modules.mod_tz_portfolio_plus_articles')); $dispatcher->trigger('onLoadData', array('modules.mod_tz_portfolio_plus_articles', $items, $params)); foreach ($items as $i => &$item) { $item->link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getArticleRoute($item->slug, $item->catslug)); $item->fullLink = JRoute::_(TZ_Portfolio_PlusHelperRoute::getArticleRoute($item->slug, $item->catslug), true, -1); $item->author_link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getUserRoute($item->user_id, $params->get('usermenuitem', 'auto'))); $media = $item->media; if (!empty($media)) { $registry = new Registry($media); $media = $registry->toObject(); $item->media = $media; } $item->mediatypes = array(); // Old plugins: Ensure that text property is available if (!isset($item->text)) { $item->text = $item->introtext; } $item->event = new stdClass(); //Call trigger in group content $results = $dispatcher->trigger('onContentPrepare', array('modules.mod_tz_portfolio_plus_articles', &$item, &$params, 0)); $item->introtext = $item->text; if ($introtext_limit = $params->get('introtext_limit')) { $item->introtext = '<p>' . JHtml::_('string.truncate', $item->introtext, $introtext_limit, true, false) . '</p>'; } // $results = $dispatcher->trigger('onContentAfterTitle', array('modules.mod_tz_portfolio_plus_articles', &$item, &$params, 0)); // $item->event->afterDisplayTitle = trim(implode("\n", $results)); // $results = $dispatcher->trigger('onContentBeforeDisplay', array('modules.mod_tz_portfolio_plus_articles', &$item, &$params, 0, $params->get('layout', 'default'))); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('modules.mod_tz_portfolio_plus_articles', &$item, &$params, 0, $params->get('layout', 'default'))); $item->event->afterDisplayContent = trim(implode("\n", $results)); // Process the tz portfolio's content plugins. $results = $dispatcher->trigger('onBeforeDisplayAdditionInfo', array('modules.mod_tz_portfolio_plus_articles', &$item, &$params, 0, $params->get('layout', 'default'))); $item->event->beforeDisplayAdditionInfo = trim(implode("\n", $results)); $results = $dispatcher->trigger('onAfterDisplayAdditionInfo', array('modules.mod_tz_portfolio_plus_articles', &$item, &$params, 0, $params->get('layout', 'default'))); $item->event->afterDisplayAdditionInfo = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentDisplayListView', array('modules.mod_tz_portfolio_plus_articles', &$item, &$params, 0, $params->get('layout', 'default'))); $item->event->contentDisplayListView = trim(implode("\n", $results)); //Call trigger in group tz_portfolio_plus_mediatype $results = $dispatcher->trigger('onContentDisplayMediaType', array('modules.mod_tz_portfolio_plus_articles', &$item, &$params, 0, $params->get('layout', 'default'))); if (isset($item) && $item) { $item->event->onContentDisplayMediaType = trim(implode("\n", $results)); if ($results = $dispatcher->trigger('onAddMediaType')) { $mediatypes = array(); foreach ($results as $result) { if (isset($result->special) && $result->special) { $mediatypes[] = $result->value; } } $item->mediatypes = $mediatypes; } } else { unset($items[$i]); } } return $items; } return false; }
public function getItems() { if ($items = parent::getItems()) { $language = JFactory::getLanguage(); foreach ($items as &$item) { if (strlen($item->manifest_cache)) { $data = json_decode($item->manifest_cache); if ($data) { foreach ($data as $key => $value) { if ($key == 'type') { // Ignore the type field continue; } $item->{$key} = $value; } } } $plugin = TZ_Portfolio_PlusPluginHelper::getInstance($item->folder, $item->element); $item->data_manager = false; if (method_exists($plugin, 'getDataManager')) { $item->data_manager = $plugin->getDataManager(); } $langPath = COM_TZ_PORTFOLIO_PLUS_ADDON_PATH . DIRECTORY_SEPARATOR . $item->folder . DIRECTORY_SEPARATOR . $item->element; $langKey = 'plg_' . $item->folder . '_' . $item->element; if ($loaded = $language->load($langKey, $langPath)) { $langKey = strtoupper($langKey); if ($language->hasKey($langKey)) { $item->name = JText::_($langKey); } } $item->author_info = @$item->authorEmail . '<br />' . @$item->authorUrl; } return $items; } return false; }
public function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $doc = JFactory::getDocument(); $doc->addStyleSheet('components/com_tz_portfolio_plus/css/tzportfolioplus.min.css'); // Get some data from the models $state = $this->get('State'); $params = $state->params; // Set value again for option tz_portfolio_plus_redirect if ($params->get('tz_portfolio_plus_redirect') == 'default') { $params->set('tz_portfolio_plus_redirect', 'article'); } $items = $this->get('Items'); $parent = $this->get('Parent'); $pagination = $this->get('Pagination'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // Check whether category access level allows access. $user = JFactory::getUser(); $content_ids = array(); if ($items) { $content_ids = JArrayHelper::getColumn($items, 'id'); } $tags = null; if (count($content_ids) && $params->get('show_tags', 1)) { $tags = TZ_Portfolio_PlusFrontHelperTags::getTagsByArticleId($content_ids, array('orderby' => 'm.contentid', 'reverse_contentid' => true)); } $_params = null; $dispatcher = JDispatcher::getInstance(); $mainCategories = TZ_Portfolio_PlusFrontHelperCategories::getCategoriesByArticleId($content_ids, array('main' => true)); $second_categories = TZ_Portfolio_PlusFrontHelperCategories::getCategoriesByArticleId($content_ids, array('main' => false)); JPluginHelper::importPlugin('content'); TZ_Portfolio_PlusPluginHelper::importPlugin('content'); TZ_Portfolio_PlusPluginHelper::importPlugin('mediatype'); $dispatcher->trigger('onAlwaysLoadDocument', array('com_tz_portfolio_plus.date')); $dispatcher->trigger('onLoadData', array('com_tz_portfolio_plus.date', $items, $params)); $mediatypes = array(); if ($results = $dispatcher->trigger('onAddMediaType')) { foreach ($results as $result) { if (isset($result->special) && $result->special) { $mediatypes[] = $result->value; } } } for ($i = 0, $n = count($items); $i < $n; $i++) { $item =& $items[$i]; if ($mainCategories && isset($mainCategories[$item->id])) { $mainCategory = $mainCategories[$item->id]; if ($mainCategory) { $item->catid = $mainCategory->id; $item->category_title = $mainCategory->title; $item->catslug = $mainCategory->id . ':' . $mainCategory->alias; $item->category_link = $mainCategory->link; } } else { // Create main category's link $item->category_link = TZ_Portfolio_PlusHelperRoute::getCategoryRoute($item->catid); } // Get all second categories $item->second_categories = null; if (isset($second_categories[$item->id])) { $item->second_categories = $second_categories[$item->id]; } // Get article's tags $item->tags = null; if ($tags && count($tags) && isset($tags[$item->id])) { $item->tags = $tags[$item->id]; } /*** New source ***/ $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; } // Create article link $item->link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_Portfolio_PlusHelperRoute::getArticleRoute($item->slug, $item->catid), true, $ssl); // Create author link $item->author_link = JRoute::_(TZ_Portfolio_PlusHelperRoute::getUserRoute($item->created_by, $params->get('user_menu_active', 'auto'))); // No link for ROOT category if ($item->parent_alias == 'root') { $item->parent_slug = null; } $item->event = new stdClass(); // Old plugins: Ensure that text property is available if (!isset($item->text)) { $item->text = $item->introtext; } //Call trigger in group content $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio_plus.date', &$item, &$item->params, 0)); $item->introtext = $item->text; $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio_plus.date', &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio_plus.date', &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio_plus.date', &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); // Process the tz portfolio's content plugins. $results = $dispatcher->trigger('onContentDisplayVote', array('com_tz_portfolio_plus.date', &$item, &$item->params, 0)); $item->event->contentDisplayVote = trim(implode("\n", $results)); $results = $dispatcher->trigger('onBeforeDisplayAdditionInfo', array('com_tz_portfolio_plus.date', &$item, &$item->params, 0)); $item->event->beforeDisplayAdditionInfo = trim(implode("\n", $results)); $results = $dispatcher->trigger('onAfterDisplayAdditionInfo', array('com_tz_portfolio_plus.date', &$item, &$item->params, 0)); $item->event->afterDisplayAdditionInfo = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentDisplayListView', array('com_tz_portfolio_plus.date', &$item, &$item->params, 0)); $item->event->contentDisplayListView = trim(implode("\n", $results)); //Call trigger in group tz_portfolio_plus_mediatype if ($item) { $results = $dispatcher->trigger('onContentDisplayMediaType', array('com_tz_portfolio_plus.date', &$item, &$item->params, 0)); if ($item) { $item->event->onContentDisplayMediaType = trim(implode("\n", $results)); if ($results = $dispatcher->trigger('onAddMediaType')) { $mediatypes = array(); foreach ($results as $result) { if (isset($result->special) && $result->special) { $mediatypes[] = $result->value; } } $item->mediatypes = $mediatypes; } } else { unset($items[$i]); } } } //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->state = $state; $this->params = $params; $this->items = $items; $this->pagination = $pagination; $this->assignRef('user', $user); $this->assign('listImage', $this->get('CatImages')); JModelLegacy::addIncludePath(COM_TZ_PORTFOLIO_PLUS_PATH_SITE . DIRECTORY_SEPARATOR . 'models'); $model = JModelLegacy::getInstance('Portfolio', 'TZ_Portfolio_PlusModel', array('ignore_request' => true)); $pParams = clone $params; $pParams->set('tz_catid', $params->get('tz_catid', array())); $model->setState('params', $pParams); $model->setState('filter.year', $state->get('filter.year')); $model->setState('filter.month', $state->get('filter.month')); $this->char = $state->get('filter.char'); $this->availLetter = $model->getAvailableLetter(); $this->assign('mediaParams', $params); if ($params->get('tz_use_lightbox', 0) == 1) { $doc->addCustomTag('<script type="text/javascript" src="components/com_tz_portfolio_plus/js' . '/jquery.fancybox.pack.js"></script>'); $doc->addStyleSheet('components/com_tz_portfolio_plus/css/fancybox.min.css'); $width = null; $height = null; $autosize = null; if ($params->get('tz_lightbox_width')) { if (preg_match('/%|px/', $params->get('tz_lightbox_width'))) { $width = 'width:\'' . $params->get('tz_lightbox_width') . '\','; } else { $width = 'width:' . $params->get('tz_lightbox_width') . ','; } } if ($params->get('tz_lightbox_height')) { if (preg_match('/%|px/', $params->get('tz_lightbox_height'))) { $height = 'height:\'' . $params->get('tz_lightbox_height') . '\','; } else { $height = 'height:' . $params->get('tz_lightbox_height') . ','; } } if ($width || $height) { $autosize = 'fitToView: false,autoSize: false,'; } $scrollHidden = null; if ($params->get('use_custom_scrollbar', 1)) { $scrollHidden = ',scrolling: "no" ,iframe: { scrolling : "no", }'; } $doc->addCustomTag('<script type="text/javascript"> jQuery(\'.fancybox\').fancybox({ type:\'iframe\', openSpeed:' . $params->get('tz_lightbox_speed', 350) . ', openEffect: "' . $params->get('tz_lightbox_transition', 'elastic') . '", ' . $width . $height . $autosize . ' helpers: { title : { type : "inside" }, overlay : { css : {background: "rgba(0,0,0,' . $params->get('tz_lightbox_opacity', 0.75) . ')"} } }' . $scrollHidden . ' }); </script> '); } $doc->addStyleSheet('components/com_tz_portfolio_plus/css/tzportfolioplus.min.css'); // $this->_prepareDocument(); // Add feed links if ($this->params->get('show_feed_link', 1)) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } parent::display($tpl); }
if ($_SERVER['HTTP_HOST'] != $check) { die; } define('DS', DIRECTORY_SEPARATOR); define('JPATH_BASE', __DIR__ . DS . '..' . DS . '..' . DS . '..' . DS . '..' . DS . '..' . DS . '..'); require_once JPATH_BASE . DS . 'includes' . DS . 'defines.php'; require_once JPATH_BASE . DS . 'includes' . DS . 'framework.php'; jimport('joomla.database.database'); jimport('joomla.database.table'); $app = JFactory::getApplication('site'); $app->initialise(); $user = JFactory::getUser(); JLoader::import('com_tz_portfolio_plus.includes.framework', JPATH_ADMINISTRATOR . '/components'); // Register TZ_Portfolio_PlusPluginHelper class tzportfolioplusimport('plugin.helper'); $plugin = TZ_Portfolio_PlusPluginHelper::getPlugin('content', 'vote'); $params = new JRegistry(); $params->loadString($plugin->params); if ($params->get('access') == 1 && !$user->get('id')) { echo 'login'; } else { $user_rating = $app->input->getInt('user_rating'); $cid = $app->input->getInt('cid'); $db = JFactory::getDbo(); if ($user_rating >= 1 && $user_rating <= 5) { $currip = $_SERVER['REMOTE_ADDR']; $query = $db->getQuery(true); $query->select('*'); $query->from('#__tz_portfolio_plus_content_rating'); $query->where('content_id = ' . $cid); $db->setQuery($query);
public function getAddOnItem($pk = null) { $pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id'); $storeId = __METHOD__ . '::' . $pk; if (!isset($this->_cache[$storeId])) { $false = false; // Get a row instance. $table = $this->getTable(); // Attempt to load the row. $return = $table->load($pk); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return $false; } // Convert to the JObject before adding other data. $properties = $table->getProperties(1); $this->_cache[$storeId] = JArrayHelper::toObject($properties, 'JObject'); // Convert the params field to an array. $registry = new Registry(); $registry->loadString($table->params); $this->_cache[$storeId]->params = $registry->toArray(); $dispatcher = JEventDispatcher::getInstance(); $plugin = TZ_Portfolio_PlusPluginHelper::getInstance($table->folder, $table->element, false, $dispatcher); if (method_exists($plugin, 'onAddOnDisplayManager')) { $this->_cache[$storeId]->manager = $plugin->onAddOnDisplayManager(); } } return $this->_cache[$storeId]; }
/** * Auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param JForm $form The form object * @param array $data The data to be merged into the form object * @param string $group The plugin group to be executed * * @return void * * @since 3.0 */ protected function preprocessForm(JForm $form, $data, $group = 'content') { // Association content items $app = JFactory::getApplication(); $assoc = JLanguageAssociations::isEnabled(); if ($assoc) { $languages = JLanguageHelper::getLanguages('lang_code'); $addform = new SimpleXMLElement('<form />'); $fields = $addform->addChild('fields'); $fields->addAttribute('name', 'associations'); $fieldset = $fields->addChild('fieldset'); $fieldset->addAttribute('name', 'item_associations'); $fieldset->addAttribute('description', 'COM_CONTENT_ITEM_ASSOCIATIONS_FIELDSET_DESC'); $add = false; foreach ($languages as $tag => $language) { if (empty($data->language) || $tag != $data->language) { $add = true; $field = $fieldset->addChild('field'); $field->addAttribute('name', $tag); $field->addAttribute('type', 'modal_article'); $field->addAttribute('language', $tag); $field->addAttribute('label', $language->title); $field->addAttribute('translate_label', 'false'); $field->addAttribute('edit', 'true'); $field->addAttribute('clear', 'true'); } } if ($add) { $form->load($addform, false); } } // Insert Mediatype from plugins $dispatcher = JDispatcher::getInstance(); TZ_Portfolio_PlusPluginHelper::importPlugin('mediatype'); if ($mediaType = $dispatcher->trigger('onAddMediaType')) { if (count($mediaType)) { $xml = $form->getXml(); $field_type = $xml->xpath('//field[@name="type"]'); $field_type = $field_type[0]; foreach ($mediaType as $type) { if (is_object($type)) { $field_type->addChild('option', $type->text)->addAttribute('value', $type->value); } elseif (is_array($type)) { $field_type->addChild('option', $type['text'])->addAttribute('value', $type['value']); } } } } parent::preprocessForm($form, $data, $group); }