public function display($tpl = null) { // Get application $application = JFactory::getApplication(); // Get input $task = $application->input->get('task', '', 'cmd'); $this->offset = $application->input->get('limitstart', 0, 'int'); $this->limit = $application->input->get('limit', 10, 'int'); // Trigger the corresponding method if (method_exists($this, $task)) { call_user_func(array($this, $task)); } else { throw new Exception(JText::_('K2_NOT_FOUND'), 404); } // Generate the view params depedning on the task prefix. This let's us have one common layout file for listing items $this->generateItemlistParams($task); // Load the comments counters in a single query for all items if ($this->params->get('comments')) { K2Items::countComments($this->items); } // Plugins foreach ($this->items as $item) { $item->events = $item->getEvents('com_k2.itemlist.' . $task, $this->params, $this->offset); } // Pagination jimport('joomla.html.pagination'); $this->pagination = new JPagination($this->total, $this->offset, $this->limit); // Display parent::display($tpl); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $user = JFactory::getUser(); $document = JFactory::getDocument(); $document->addStyleSheet('//ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css'); $document->addStyleSheet(JURI::root(true) . '/media/k2/assets/css/theme.css?v=2.6.8'); $document->addStyleSheet(JURI::root(true) . '/media/k2/assets/css/elfinder.min.css?v=2.6.8'); $type = JRequest::getCmd('type'); $fieldID = JRequest::getCmd('fieldID'); if ($type == 'video') { $mimes = "'video','audio'"; } elseif ($type == 'image') { $mimes = "'image'"; } else { $mimes = ''; } $this->assignRef('mimes', $mimes); $this->assignRef('type', $type); $this->assignRef('fieldID', $fieldID); if ($mainframe->isAdmin()) { $toolbar = JToolBar::getInstance('toolbar'); if (K2_JVERSION != '15') { JToolBarHelper::preferences('com_k2', 550, 875, 'K2_PARAMETERS'); } else { $toolbar->appendButton('Popup', 'config', 'K2_PARAMETERS', 'index.php?option=com_k2&view=settings'); } JToolBarHelper::title(JText::_('K2_MEDIA_MANAGER'), 'k2.png'); $this->loadHelper('html'); K2HelperHTML::subMenu(); } parent::display($tpl); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $user = JFactory::getUser(); $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $limitstart = $mainframe->getUserStateFromRequest($option . $view . '.limitstart', 'limitstart', 0, 'int'); $filter_order = $mainframe->getUserStateFromRequest($option . $view . 'filter_order', 'filter_order', '', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest($option . $view . 'filter_order_Dir', 'filter_order_Dir', '', 'word'); $model = $this->getModel(); $total = $model->getTotalGroups(); if ($limitstart > $total - $limit) { $limitstart = max(0, (int) (ceil($total / $limit) - 1) * $limit); JRequest::setVar('limitstart', $limitstart); } $extraFieldGroups = $model->getGroups(); $this->assignRef('rows', $extraFieldGroups); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); $this->assignRef('page', $pageNav); JToolBarHelper::title(JText::_('K2_EXTRA_FIELD_GROUPS'), 'k2.png'); JToolBarHelper::deleteList('', 'remove', 'K2_DELETE'); JToolBarHelper::editList(); JToolBarHelper::addNew(); if (K2_JVERSION != '15') { JToolBarHelper::preferences('com_k2', 550, 875, 'K2_PARAMETERS'); } else { $toolbar = JToolBar::getInstance('toolbar'); $toolbar->appendButton('Popup', 'config', 'Parameters', 'index.php?option=com_k2&view=settings'); } $this->loadHelper('html'); K2HelperHTML::subMenu(); parent::display($tpl); }
public function display($tpl = null) { // Get application $application = JFactory::getApplication(); // Get input $id = $application->input->get('id', 0, 'int'); // Get item $this->item = K2Items::getInstance($id); // Check access $this->item->checkSiteAccess(); // Merge menu params with category params $effectiveParams = $this->item->category->getEffectiveParams(); $this->params->merge($effectiveParams); // Merge params with item params $this->params->merge($this->item->params); // Get the image depending on params $this->item->image = $this->item->getImage($this->params->get('itemImgSize')); // Trigger plugins. We need to do this there in order to provide the correct context $this->item->events = $this->item->getEvents('com_k2.item', $this->params, 0); // Get related items. We need to do this here since the parameter is related with the view if ($this->params->get('itemRelated')) { $this->item->related = $this->item->getRelated($this->params->get('itemRelatedLimit', 5)); } // Get latest from same author. We need to do this here since the parameter is related with the view if ($this->params->get('itemAuthorLatest')) { $this->item->author->latest = $this->item->getLatestByAuthor($this->params->get('itemAuthorLatestLimit', 5)); } // Set the layout $this->setLayout('item'); // Add the template path $this->addTemplatePath(JPATH_SITE . '/components/com_k2/templates/' . $this->item->category->template); $this->addTemplatePath(JPATH_SITE . '/templates/' . JFactory::getApplication()->getTemplate() . '/html/com_k2/' . $this->item->category->template); // Display parent::display($tpl); }
function report($tpl = null) { JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables'); $row =& JTable::getInstance('K2Comment', 'Table'); $row->load(JRequest::getInt('commentID')); if (!$row->published) { JError::raiseError(404, JText::_('K2_NOT_FOUND')); } $this->assignRef('row', $row); $user = JFactory::getUser(); $this->assignRef('user', $user); $params =& K2HelperUtilities::getParams('com_k2'); if (!$params->get('comments') || !$params->get('commentsReporting') || $params->get('commentsReporting') == '2' && $user->guest) { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); } $this->assignRef('params', $params); if ($params->get('recaptcha') && $user->guest) { $document = JFactory::getDocument(); $document->addScript('http://api.recaptcha.net/js/recaptcha_ajax.js'); $js = ' function showRecaptcha(){ Recaptcha.create("' . $params->get('recaptcha_public_key') . '", "recaptcha", { theme: "' . $params->get('recaptcha_theme', 'clean') . '" }); } $K2(window).load(function() { showRecaptcha(); }); '; $document->addScriptDeclaration($js); } parent::display($tpl); }
function display($tpl = null) { JRequest::setVar('hidemainmenu', 1); $model = $this->getModel(); $extraField = $model->getData(); if (!$extraField->id) { $extraField->published = 1; } $this->assignRef('row', $extraField); $lists = array(); $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $extraField->published); $groups[] = JHTML::_('select.option', 0, JText::_('K2_CREATE_NEW_GROUP')); $extraFieldModel = K2Model::getInstance('ExtraFields', 'K2Model'); $uniqueGroups = $extraFieldModel->getGroups(true); foreach ($uniqueGroups as $group) { $groups[] = JHTML::_('select.option', $group->id, $group->name); } $lists['group'] = JHTML::_('select.genericlist', $groups, 'groups', '', 'value', 'text', $extraField->group); $typeOptions[] = JHTML::_('select.option', 0, JText::_('K2_SELECT_TYPE')); $typeOptions[] = JHTML::_('select.option', 'textfield', JText::_('K2_TEXT_FIELD')); $typeOptions[] = JHTML::_('select.option', 'textarea', JText::_('K2_TEXTAREA')); $typeOptions[] = JHTML::_('select.option', 'select', JText::_('K2_DROPDOWN_SELECTION')); $typeOptions[] = JHTML::_('select.option', 'multipleSelect', JText::_('K2_MULTISELECT_LIST')); $typeOptions[] = JHTML::_('select.option', 'radio', JText::_('K2_RADIO_BUTTONS')); $typeOptions[] = JHTML::_('select.option', 'link', JText::_('K2_LINK')); $typeOptions[] = JHTML::_('select.option', 'csv', JText::_('K2_CSV_DATA')); $typeOptions[] = JHTML::_('select.option', 'labels', JText::_('K2_SEARCHABLE_LABELS')); $typeOptions[] = JHTML::_('select.option', 'date', JText::_('K2_DATE')); $lists['type'] = JHTML::_('select.genericlist', $typeOptions, 'type', '', 'value', 'text', $extraField->type); $this->assignRef('lists', $lists); JRequest::getInt('cid') ? $title = JText::_('K2_EDIT_EXTRA_FIELD') : ($title = JText::_('K2_ADD_EXTRA_FIELD')); JToolBarHelper::title($title, 'k2.png'); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JHTML::_('behavior.calendar'); $document = JFactory::getDocument(); $document->addScriptDeclaration(' var K2Language = [ "' . JText::_('K2_REMOVE', true) . '", "' . JText::_('K2_OPTIONAL', true) . '", "' . JText::_('K2_COMMA_SEPARATED_VALUES', true) . '", "' . JText::_('K2_USE_EDITOR', true) . '", "' . JText::_('K2_ALL_SETTINGS_ABOVE_ARE_OPTIONAL', true) . '", "' . JText::_('K2_ADD_AN_OPTION', true) . '", "' . JText::_('K2_LINK_TEXT', true) . '", "' . JText::_('K2_URL', true) . '", "' . JText::_('K2_OPEN_IN', true) . '", "' . JText::_('K2_SAME_WINDOW', true) . '", "' . JText::_('K2_NEW_WINDOW', true) . '", "' . JText::_('K2_CLASSIC_JAVASCRIPT_POPUP', true) . '", "' . JText::_('K2_LIGHTBOX_POPUP', true) . '", "' . JText::_('K2_RESET_VALUE', true) . '", "' . JText::_('K2_CALENDAR', true) . '", "' . JText::_('K2_PLEASE_SELECT_A_FIELD_TYPE_FROM_THE_LIST_ABOVE', true) . '", ];'); parent::display($tpl); }
function display($tpl = null) { JHTML::_('behavior.tooltip'); jimport('joomla.html.pane'); $model =& $this->getModel(); $params =& $model->getParams(); $this->assignRef('params', $params); $pane =& JPane::getInstance('Tabs'); $this->assignRef('pane', $pane); parent::display($tpl); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $user = JFactory::getUser(); $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $limitstart = $mainframe->getUserStateFromRequest($option . $view . '.limitstart', 'limitstart', 0, 'int'); $filter_order = $mainframe->getUserStateFromRequest($option . $view . 'filter_order', 'filter_order', 'id', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest($option . $view . 'filter_order_Dir', 'filter_order_Dir', 'DESC', 'word'); $filter_state = $mainframe->getUserStateFromRequest($option . $view . 'filter_state', 'filter_state', -1, 'int'); $search = $mainframe->getUserStateFromRequest($option . $view . 'search', 'search', '', 'string'); $search = JString::strtolower($search); $model = $this->getModel(); $total = $model->getTotal(); $task = JRequest::getCmd('task'); if ($limitstart > $total - $limit) { $limitstart = max(0, (int) (ceil($total / $limit) - 1) * $limit); JRequest::setVar('limitstart', $limitstart); } $tags = $model->getData(); foreach ($tags as $key => $tag) { $tag->numOfItems = $model->countTagItems($tag->id); $tag->status = K2_JVERSION == '15' ? JHTML::_('grid.published', $tag, $key) : JHtml::_('jgrid.published', $tag->published, $key, '', $task != 'element'); } $this->assignRef('rows', $tags); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); $this->assignRef('page', $pageNav); $lists = array(); $lists['search'] = $search; $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; $filter_state_options[] = JHTML::_('select.option', -1, JText::_('K2_SELECT_STATE')); $filter_state_options[] = JHTML::_('select.option', 1, JText::_('K2_PUBLISHED')); $filter_state_options[] = JHTML::_('select.option', 0, JText::_('K2_UNPUBLISHED')); $lists['state'] = JHTML::_('select.genericlist', $filter_state_options, 'filter_state', '', 'value', 'text', $filter_state); $this->assignRef('lists', $lists); JToolBarHelper::title(JText::_('K2_TAGS'), 'k2.png'); JToolBarHelper::publishList(); JToolBarHelper::unpublishList(); JToolBarHelper::deleteList('', 'remove', 'K2_DELETE'); JToolBarHelper::editList(); JToolBarHelper::addNew(); if (K2_JVERSION != '15') { JToolBarHelper::preferences('com_k2', 550, 875, 'K2_PARAMETERS'); } else { $toolbar = JToolBar::getInstance('toolbar'); $toolbar->appendButton('Popup', 'config', 'Parameters', 'index.php?option=com_k2&view=settings'); } $this->loadHelper('html'); K2HelperHTML::subMenu(); parent::display($tpl); }
function display($tpl = null) { JRequest::setVar('hidemainmenu', 1); $model = $this->getModel(); $extraFieldsGroup = $model->getExtraFieldsGroup(); JFilterOutput::objectHTMLSafe($extraFieldsGroup); $this->assignRef('row', $extraFieldsGroup); JRequest::getInt('cid') ? $title = JText::_('K2_EDIT_EXTRA_FIELD_GROUP') : ($title = JText::_('K2_ADD_EXTRA_FIELD_GROUP')); JToolBarHelper::title($title, 'k2.png'); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); parent::display($tpl); }
public function display($tpl = null) { // Get application $application = JFactory::getApplication(); // Get input $task = $application->input->get('task', '', 'cmd'); $this->offset = $application->input->get('limitstart', 0, 'int'); $this->limit = $application->input->get('limit', 10, 'int'); // Trigger the corresponding method if (method_exists($this, $task)) { call_user_func(array($this, $task)); } else { throw new Exception(JText::_('K2_NOT_FOUND'), 404); } // Generate the view params depedning on the task prefix. This let's us have one common layout file for listing items $this->generateItemlistParams($task); // Load the comments counters in a single query for all items if ($this->params->get('comments')) { K2Items::countComments($this->items); } // Plugins foreach ($this->items as $item) { $item->events = $item->getEvents('com_k2.itemlist.' . $task, $this->params, $this->offset); } // Add feed link $this->feedLink = JRoute::_('&format=feed&limitstart='); // Add feed links to head if ($this->feedLinkToHead) { $attributes = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $this->document->addHeadLink(JRoute::_('&format=feed&limitstart=&type=rss'), 'alternate', 'rel', $attributes); $attributes = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $this->document->addHeadLink(JRoute::_('&format=feed&limitstart=&type=atom'), 'alternate', 'rel', $attributes); } // Pagination jimport('joomla.html.pagination'); $this->pagination = new JPagination($this->total, $this->offset, $this->limit); // Display try { parent::display($tpl); } catch (Exception $e) { if ($this->_template === false) { $this->setLayout('itemlist'); } parent::display($tpl); } }
function display($tpl = null) { JRequest::setVar('hidemainmenu', 1); $model = $this->getModel(); $user = $model->getData(); if (K2_JVERSION == '15') { JFilterOutput::objectHTMLSafe($user); } else { JFilterOutput::objectHTMLSafe($user, ENT_QUOTES, array('params', 'plugins')); } $joomlaUser = JUser::getInstance(JRequest::getInt('cid')); $user->name = $joomlaUser->name; $user->userID = $joomlaUser->id; $this->assignRef('row', $user); $wysiwyg = JFactory::getEditor(); $editor = $wysiwyg->display('description', $user->description, '480px', '250px', '', '', false); $this->assignRef('editor', $editor); $lists = array(); $genderOptions[] = JHTML::_('select.option', 'm', JText::_('K2_MALE')); $genderOptions[] = JHTML::_('select.option', 'f', JText::_('K2_FEMALE')); $lists['gender'] = JHTML::_('select.radiolist', $genderOptions, 'gender', '', 'value', 'text', $user->gender); $userGroupOptions = $model->getUserGroups(); $lists['userGroup'] = JHTML::_('select.genericlist', $userGroupOptions, 'group', 'class="inputbox"', 'id', 'name', $user->group); $this->assignRef('lists', $lists); $params = JComponentHelper::getParams('com_k2'); $this->assignRef('params', $params); JPluginHelper::importPlugin('k2'); $dispatcher = JDispatcher::getInstance(); $K2Plugins = $dispatcher->trigger('onRenderAdminForm', array(&$user, 'user')); $this->assignRef('K2Plugins', $K2Plugins); JToolBarHelper::title(JText::_('K2_USER'), 'k2.png'); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); $toolbar = JToolBar::getInstance('toolbar'); if (K2_JVERSION != '15') { $buttonUrl = JURI::base() . 'index.php?option=com_users&view=user&task=user.edit&id=' . $user->userID; } else { $buttonUrl = JURI::base() . 'index.php?option=com_users&view=user&task=edit&cid[]=' . $user->userID; } $buttonText = JText::_('K2_EDIT_JOOMLA_USER'); $button = '<a target="_blank" href="' . $buttonUrl . '"><span class="icon-32-edit" title="' . $buttonText . '"></span>' . $buttonText . '</a>'; $toolbar->prependButton('Custom', $button); parent::display($tpl); }
function display($tpl = null) { JHTML::_('behavior.tooltip'); JRequest::setVar('hidemainmenu', 1); $model = $this->getModel(); $userGroup = $model->getData(); if (K2_JVERSION == '15') { JFilterOutput::objectHTMLSafe($userGroup); } else { JFilterOutput::objectHTMLSafe($userGroup, ENT_QUOTES, 'permissions'); } $this->assignRef('row', $userGroup); if (K2_JVERSION == '15') { $form = new JParameter('', JPATH_COMPONENT . DS . 'models' . DS . 'usergroup.xml'); $form->loadINI($userGroup->permissions); $appliedCategories = $form->get('categories'); $inheritance = $form->get('inheritance'); } else { jimport('joomla.form.form'); $form = JForm::getInstance('permissions', JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'usergroup.xml'); $values = array('params' => json_decode($userGroup->permissions)); $form->bind($values); $inheritance = isset($values['params']->inheritance) ? $values['params']->inheritance : 0; $appliedCategories = isset($values['params']->categories) ? $values['params']->categories : ''; } $this->assignRef('form', $form); $this->assignRef('categories', $appliedCategories); $lists = array(); require_once JPATH_ADMINISTRATOR . '/components/com_k2/models/categories.php'; $categoriesModel = K2Model::getInstance('Categories', 'K2Model'); $categories = $categoriesModel->categoriesTree(NULL, true); $categories_options = @array_merge($categories_option, $categories); $lists['categories'] = JHTML::_('select.genericlist', $categories, 'params[categories][]', 'multiple="multiple" size="15"', 'value', 'text', $appliedCategories); $lists['inheritance'] = JHTML::_('select.booleanlist', 'params[inheritance]', NULL, $inheritance); $this->assignRef('lists', $lists); JRequest::getInt('cid') ? $title = JText::_('K2_EDIT_USER_GROUP') : ($title = JText::_('K2_ADD_USER_GROUP')); JToolBarHelper::title($title, 'k2.png'); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); parent::display($tpl); }
function display($tpl = null) { jimport('joomla.filesystem.file'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $db_version = $db->getVersion(); $php_version = phpversion(); $server = $this->get_server_software(); $gd_check = extension_loaded('gd'); $mb_check = extension_loaded('mbstring'); $media_folder_check = is_writable(JPATH_ROOT . DS . 'media' . DS . 'k2'); $attachments_folder_check = is_writable(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'attachments'); $categories_folder_check = is_writable(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'categories'); $galleries_folder_check = is_writable(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'galleries'); $items_folder_check = is_writable(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items'); $users_folder_check = is_writable(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'users'); $videos_folder_check = is_writable(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'videos'); $cache_folder_check = is_writable(JPATH_ROOT . DS . 'cache'); $this->assignRef('server', $server); $this->assignRef('php_version', $php_version); $this->assignRef('db_version', $db_version); $this->assignRef('gd_check', $gd_check); $this->assignRef('mb_check', $mb_check); $this->assignRef('media_folder_check', $media_folder_check); $this->assignRef('attachments_folder_check', $attachments_folder_check); $this->assignRef('categories_folder_check', $categories_folder_check); $this->assignRef('galleries_folder_check', $galleries_folder_check); $this->assignRef('items_folder_check', $items_folder_check); $this->assignRef('users_folder_check', $users_folder_check); $this->assignRef('videos_folder_check', $videos_folder_check); $this->assignRef('cache_folder_check', $cache_folder_check); JToolBarHelper::title(JText::_('K2_INFORMATION'), 'k2.png'); if (K2_JVERSION != '15') { JToolBarHelper::preferences('com_k2', 550, 875, 'K2_PARAMETERS'); } else { $toolbar = JToolBar::getInstance('toolbar'); $toolbar->appendButton('Popup', 'config', 'Parameters', 'index.php?option=com_k2&view=settings'); } $this->loadHelper('html'); K2HelperHTML::subMenu(); parent::display($tpl); }
function display($tpl = null) { JRequest::setVar('hidemainmenu', 1); $model = $this->getModel(); $tag = $model->getData(); JFilterOutput::objectHTMLSafe($tag); if (!$tag->id) { $tag->published = 1; } $this->assignRef('row', $tag); $lists = array(); $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $tag->published); $this->assignRef('lists', $lists); JRequest::getInt('cid') ? $title = JText::_('K2_EDIT_TAG') : ($title = JText::_('K2_ADD_TAG')); JToolBarHelper::title($title, 'k2.png'); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); parent::display($tpl); }
public function display($tpl = null) { // Get source $source = $this->params->get('source'); // Trigger the corresponding method if (method_exists($this, $source)) { call_user_func(array($this, $source)); } else { throw new Exception(JText::_('K2_NOT_FOUND'), 404); } // Plugins foreach ($this->blocks as $block) { foreach ($block->items as $item) { $item->events = $item->getEvents('com_k2.latest', $this->params, 0, $this->params->get('latestItemK2Plugins')); } } // Set the layout $this->setLayout('latest'); // Display parent::display($tpl); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $params = K2HelperUtilities::getParams('com_k2'); $model = $this->getModel('itemlist'); $limitstart = JRequest::getInt('limitstart'); $view = JRequest::getWord('view'); $task = JRequest::getWord('task'); //Add link if (K2HelperPermissions::canAddItem()) { $addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component'); } $this->assignRef('addLink', $addLink); //Get data depending on task switch ($task) { case 'category': //Get category $id = JRequest::getInt('id'); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables'); $category = JTable::getInstance('K2Category', 'Table'); $category->load($id); // State Check if (!$category->published || $category->trash) { JError::raiseError(404, JText::_('K2_CATEGORY_NOT_FOUND')); } //Access check $user = JFactory::getUser(); if (K2_JVERSION != '15') { if (!in_array($category->access, $user->getAuthorisedViewLevels())) { if ($user->guest) { $uri = JFactory::getURI(); $url = 'index.php?option=com_user&view=login&return=' . base64_encode($uri->toString()); $mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST')); } else { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); return; } } $languageFilter = $mainframe->getLanguageFilter(); $languageTag = JFactory::getLanguage()->getTag(); if ($languageFilter && $category->language != $languageTag && $category->language != '*') { return; } } else { if ($category->access > $user->get('aid', 0)) { if ($user->guest) { $uri = JFactory::getURI(); $url = 'index.php?option=com_user&view=login&return=' . base64_encode($uri->toString()); $mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST')); } else { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); return; } } } // Hide the add new item link if user cannot post in the specific category if (!K2HelperPermissions::canAddItem($id)) { unset($this->addLink); } //Merge params $cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params); if ($cparams->get('inheritFrom')) { $masterCategory = JTable::getInstance('K2Category', 'Table'); $masterCategory->load($cparams->get('inheritFrom')); $cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($masterCategory->params); } $params->merge($cparams); //Category link $category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias)))); //Category image $category->image = K2HelperUtilities::getCategoryImage($category->image, $params); //Category plugins $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $category->text = $category->description; if (K2_JVERSION != '15') { $dispatcher->trigger('onContentPrepare', array('com_k2.category', &$category, &$params, $limitstart)); } else { $dispatcher->trigger('onPrepareContent', array(&$category, &$params, $limitstart)); } $category->description = $category->text; //Category K2 plugins $category->event->K2CategoryDisplay = ''; JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2CategoryDisplay', array(&$category, &$params, $limitstart)); $category->event->K2CategoryDisplay = trim(implode("\n", $results)); $category->text = $category->description; $dispatcher->trigger('onK2PrepareContent', array(&$category, &$params, $limitstart)); $category->description = $category->text; $this->assignRef('category', $category); $this->assignRef('user', $user); //Category children $ordering = $params->get('subCatOrdering'); $children = $model->getCategoryFirstChildren($id, $ordering); if (count($children)) { foreach ($children as $child) { if ($params->get('subCatTitleItemCounter')) { $child->numOfItems = $model->countCategoryItems($child->id); } $child->image = K2HelperUtilities::getCategoryImage($child->image, $params); $child->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($child->id . ':' . urlencode($child->alias)))); $subCategories[] = $child; } $this->assignRef('subCategories', $subCategories); } //Set limit $limit = $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items') + $params->get('num_links'); //Set featured flag JRequest::setVar('featured', $params->get('catFeaturedItems')); //Set layout $this->setLayout('category'); //Set title $title = $category->name; // Set ordering if ($params->get('singleCatOrdering')) { $ordering = $params->get('singleCatOrdering'); } else { $ordering = $params->get('catOrdering'); } break; case 'user': //Get user $id = JRequest::getInt('id'); $userObject = JFactory::getUser($id); //Check user status if ($userObject->block) { JError::raiseError(404, JText::_('K2_USER_NOT_FOUND')); } //Get K2 user profile $userObject->profile = $model->getUserProfile(); //User image $userObject->avatar = K2HelperUtilities::getAvatar($userObject->id, $userObject->email, $params->get('userImageWidth')); //User K2 plugins $userObject->event->K2UserDisplay = ''; if (is_object($userObject->profile) && $userObject->profile->id > 0) { $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2UserDisplay', array(&$userObject->profile, &$params, $limitstart)); $userObject->event->K2UserDisplay = trim(implode("\n", $results)); $userObject->profile->url = htmlspecialchars($userObject->profile->url, ENT_QUOTES, 'UTF-8'); } $this->assignRef('user', $userObject); //Set layout $this->setLayout('user'); //Set limit $limit = $params->get('userItemCount'); //Set title $title = $userObject->name; // Set ordering $ordering = $params->get('userOrdering'); break; case 'tag': //Set layout $this->setLayout('tag'); //Set limit $limit = $params->get('tagItemCount'); //set title $title = JText::_('K2_DISPLAYING_ITEMS_BY_TAG') . ' ' . JRequest::getVar('tag'); // Set ordering $ordering = $params->get('tagOrdering'); break; case 'search': //Set layout $this->setLayout('generic'); $tpl = JRequest::getCmd('tpl', null); //Set limit $limit = $params->get('genericItemCount'); //Set title $title = JText::_('K2_SEARCH_RESULTS_FOR') . ' ' . JRequest::getVar('searchword'); break; case 'date': //Set layout $this->setLayout('generic'); //Set limit $limit = $params->get('genericItemCount'); // Set title if (JRequest::getInt('day')) { $date = strtotime(JRequest::getInt('year') . '-' . JRequest::getInt('month') . '-' . JRequest::getInt('day')); $dateFormat = K2_JVERSION == '15' ? '%A, %d %B %Y' : 'l, d F Y'; $title = JText::_('K2_ITEMS_FILTERED_BY_DATE') . ' ' . JHTML::_('date', $date, $dateFormat); } else { $date = strtotime(JRequest::getInt('year') . '-' . JRequest::getInt('month')); $dateFormat = K2_JVERSION == '15' ? '%B %Y' : 'F Y'; $title = JText::_('K2_ITEMS_FILTERED_BY_DATE') . ' ' . JHTML::_('date', $date, $dateFormat); } // Set ordering $ordering = 'rdate'; break; default: //Set layout $this->setLayout('category'); $user = JFactory::getUser(); $this->assignRef('user', $user); //Set limit $limit = $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items') + $params->get('num_links'); //Set featured flag JRequest::setVar('featured', $params->get('catFeaturedItems')); //Set title $title = $params->get('page_title'); // Set ordering $ordering = $params->get('catOrdering'); break; } //Set limit for model JRequest::setVar('limit', $limit); if (!isset($ordering)) { $items = $model->getData(); } else { $items = $model->getData($ordering); } //Pagination jimport('joomla.html.pagination'); $total = $model->getTotal(); $pagination = new JPagination($total, $limitstart, $limit); //Prepare items $user = JFactory::getUser(); $cache = JFactory::getCache('com_k2_extended'); $model = $this->getModel('item'); for ($i = 0; $i < sizeof($items); $i++) { //Item group if ($task == "category" || $task == "") { if ($i < $params->get('num_links') + $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items')) { $items[$i]->itemGroup = 'links'; } if ($i < $params->get('num_secondary_items') + $params->get('num_leading_items') + $params->get('num_primary_items')) { $items[$i]->itemGroup = 'secondary'; } if ($i < $params->get('num_primary_items') + $params->get('num_leading_items')) { $items[$i]->itemGroup = 'primary'; } if ($i < $params->get('num_leading_items')) { $items[$i]->itemGroup = 'leading'; } } //Check if model should use cache for preparing item even if user is logged in if ($user->guest || $task == 'tag' || $task == 'search' || $task == 'date') { $cacheFlag = true; } else { $cacheFlag = true; if (K2HelperPermissions::canEditItem($items[$i]->created_by, $items[$i]->catid)) { $cacheFlag = false; } } //Prepare item if ($cacheFlag) { $hits = $items[$i]->hits; $items[$i]->hits = 0; JTable::getInstance('K2Category', 'Table'); $items[$i] = $cache->call(array($model, 'prepareItem'), $items[$i], $view, $task); $items[$i]->hits = $hits; } else { $items[$i] = $model->prepareItem($items[$i], $view, $task); } //Plugins $items[$i] = $model->execPlugins($items[$i], $view, $task); //Trigger comments counter event $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2CommentsCounter', array(&$items[$i], &$params, $limitstart)); $items[$i]->event->K2CommentsCounter = trim(implode("\n", $results)); } //Pathway $pathway = $mainframe->getPathWay(); $pathway->addItem($title); //Feed link $config = JFactory::getConfig(); $menu = $mainframe->getMenu(); $default = $menu->getDefault(); $active = $menu->getActive(); if ($task == 'tag') { $link = K2HelperRoute::getTagRoute(JRequest::getVar('tag')); } else { $link = ''; } $sef = K2_JVERSION == '30' ? $config->get('sef') : $config->getValue('config.sef'); if (!is_null($active) && $active->id == $default->id && $sef) { $link .= '&Itemid=' . $active->id . '&format=feed&limitstart='; } else { $link .= '&format=feed&limitstart='; } $feed = JRoute::_($link); $this->assignRef('feed', $feed); //Assign data if ($task == "category" || $task == "") { $leading = @array_slice($items, 0, $params->get('num_leading_items')); $primary = @array_slice($items, $params->get('num_leading_items'), $params->get('num_primary_items')); $secondary = @array_slice($items, $params->get('num_leading_items') + $params->get('num_primary_items'), $params->get('num_secondary_items')); $links = @array_slice($items, $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items'), $params->get('num_links')); $this->assignRef('leading', $leading); $this->assignRef('primary', $primary); $this->assignRef('secondary', $secondary); $this->assignRef('links', $links); } else { $this->assignRef('items', $items); } //Set default values to avoid division by zero if ($params->get('num_leading_columns') == 0) { $params->set('num_leading_columns', 1); } if ($params->get('num_primary_columns') == 0) { $params->set('num_primary_columns', 1); } if ($params->get('num_secondary_columns') == 0) { $params->set('num_secondary_columns', 1); } if ($params->get('num_links_columns') == 0) { $params->set('num_links_columns', 1); } $this->assignRef('params', $params); $this->assignRef('pagination', $pagination); //Look for template files in component folders $this->_addPath('template', JPATH_COMPONENT . DS . 'templates'); $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . 'default'); //Look for overrides in template folder (K2 template structure) $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates'); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . 'default'); //Look for overrides in template folder (Joomla! template structure) $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'default'); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2'); //Look for specific K2 theme files if ($params->get('theme')) { $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . $params->get('theme')); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . $params->get('theme')); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . $params->get('theme')); } $db = JFactory::getDBO(); $nullDate = $db->getNullDate(); $this->assignRef('nullDate', $nullDate); // Prevent spammers from using the tag view if ($task == 'tag' && !count($this->items)) { $tag = JRequest::getString('tag'); $db = JFactory::getDBO(); $db->setQuery('SELECT id FROM #__k2_tags WHERE name = ' . $db->quote($tag)); $tagID = $db->loadResult(); if (!$tagID) { JError::raiseError(404, JText::_('K2_NOT_FOUND')); return false; } } parent::display($tpl); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $params = K2HelperUtilities::getParams('com_k2'); $document = JFactory::getDocument(); $user = JFactory::getUser(); $cache = JFactory::getCache('com_k2_extended'); $limit = $params->get('latestItemsLimit'); $limitstart = JRequest::getInt('limitstart'); $model = $this->getModel('itemlist'); $itemModel = $this->getModel('item'); $theme = $params->get('theme'); if ($params->get('source')) { $categoryIDs = $params->get('categoryIDs'); if (is_string($categoryIDs) && !empty($categoryIDs)) { $categoryIDs = array(); $categoryIDs[] = $params->get('categoryIDs'); } $categories = array(); JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'tables'); if (is_array($categoryIDs)) { foreach ($categoryIDs as $categoryID) { $category = JTable::getInstance('K2Category', 'Table'); $category->load($categoryID); $category->event = new stdClass(); $languageCheck = true; if (K2_JVERSION != '15') { $accessCheck = in_array($category->access, $user->getAuthorisedViewLevels()); if ($mainframe->getLanguageFilter()) { $languageTag = JFactory::getLanguage()->getTag(); $languageCheck = in_array($category->language, array($languageTag, '*')); } } else { $accessCheck = $category->access <= $user->get('aid', 0); } if ($category->published && $accessCheck && $languageCheck) { //Merge params $cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params); if ($cparams->get('inheritFrom')) { $masterCategory = JTable::getInstance('K2Category', 'Table'); $masterCategory->load($cparams->get('inheritFrom')); $cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($masterCategory->params); } $params->merge($cparams); //Category image $category->image = K2HelperUtilities::getCategoryImage($category->image, $params); //Category plugins $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $category->text = $category->description; if (K2_JVERSION != '15') { $dispatcher->trigger('onContentPrepare', array('com_k2.category', &$category, &$params, $limitstart)); } else { $dispatcher->trigger('onPrepareContent', array(&$category, &$params, $limitstart)); } $category->description = $category->text; //Category K2 plugins $category->event->K2CategoryDisplay = ''; JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2CategoryDisplay', array(&$category, &$params, $limitstart)); $category->event->K2CategoryDisplay = trim(implode("\n", $results)); $category->text = $category->description; $dispatcher->trigger('onK2PrepareContent', array(&$category, &$params, $limitstart)); $category->description = $category->text; //Category link $link = urldecode(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))); $category->link = JRoute::_($link); $category->feed = JRoute::_($link . '&format=feed'); JRequest::setVar('view', 'itemlist'); JRequest::setVar('task', 'category'); JRequest::setVar('id', $category->id); JRequest::setVar('featured', 1); JRequest::setVar('limit', $limit); JRequest::setVar('clearFlag', true); $category->name = htmlspecialchars($category->name, ENT_QUOTES); if ($limit) { $category->items = $model->getData('rdate'); JRequest::setVar('view', 'latest'); JRequest::setVar('task', ''); for ($i = 0; $i < sizeof($category->items); $i++) { $hits = $category->items[$i]->hits; $category->items[$i]->hits = 0; $category->items[$i] = $cache->call(array($itemModel, 'prepareItem'), $category->items[$i], 'latest', ''); $category->items[$i]->hits = $hits; $category->items[$i] = $itemModel->execPlugins($category->items[$i], 'latest', ''); //Trigger comments counter event $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2CommentsCounter', array(&$category->items[$i], &$params, $limitstart)); $category->items[$i]->event->K2CommentsCounter = trim(implode("\n", $results)); } } else { $category->items = array(); } $categories[] = $category; } } } $source = 'categories'; $this->assignRef('blocks', $categories); } else { $usersIDs = $params->get('userIDs'); if (is_string($usersIDs) && !empty($usersIDs)) { $usersIDs = array(); $usersIDs[] = $params->get('userIDs'); } $users = array(); if (is_array($usersIDs)) { foreach ($usersIDs as $userID) { $userObject = JFactory::getUser($userID); if (!$userObject->block) { $userObject->event = new stdClass(); //User profile $userObject->profile = $model->getUserProfile($userID); //User image $userObject->avatar = K2HelperUtilities::getAvatar($userObject->id, $userObject->email, $params->get('userImageWidth')); //User K2 plugins $userObject->event->K2UserDisplay = ''; if (is_object($userObject->profile) && $userObject->profile->id > 0) { $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2UserDisplay', array(&$userObject->profile, &$params, $limitstart)); $userObject->event->K2UserDisplay = trim(implode("\n", $results)); $userObject->profile->url = htmlspecialchars($userObject->profile->url, ENT_QUOTES, 'UTF-8'); } $link = K2HelperRoute::getUserRoute($userObject->id); $userObject->link = JRoute::_($link); $userObject->feed = JRoute::_($link . '&format=feed'); $userObject->name = htmlspecialchars($userObject->name, ENT_QUOTES); if ($limit) { $userObject->items = $model->getAuthorLatest(0, $limit, $userID); for ($i = 0; $i < sizeof($userObject->items); $i++) { $hits = $userObject->items[$i]->hits; $userObject->items[$i]->hits = 0; $userObject->items[$i] = $cache->call(array($itemModel, 'prepareItem'), $userObject->items[$i], 'latest', ''); $userObject->items[$i]->hits = $hits; //Plugins $userObject->items[$i] = $itemModel->execPlugins($userObject->items[$i], 'latest', ''); //Trigger comments counter event $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2CommentsCounter', array(&$userObject->items[$i], &$params, $limitstart)); $userObject->items[$i]->event->K2CommentsCounter = trim(implode("\n", $results)); } } else { $userObject->items = array(); } $users[] = $userObject; } } } $source = 'users'; $this->assignRef('blocks', $users); } // Set menu metadata for Joomla! 2.5+ if (K2_JVERSION != '15') { if ($params->get('menu-meta_description')) { $document->setDescription($params->get('menu-meta_description')); } if ($params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $params->get('menu-meta_keywords')); } if ($params->get('robots')) { $document->setMetadata('robots', $params->get('robots')); } // Menu page display options if ($params->get('page_heading')) { $params->set('page_title', $params->get('page_heading')); } $params->set('show_page_title', $params->get('show_page_heading')); } // Set Facebook meta data $document = JFactory::getDocument(); $uri = JURI::getInstance(); $document->setMetaData('og:url', $uri->toString()); $document->setMetaData('og:title', htmlspecialchars($document->getTitle(), ENT_QUOTES, 'UTF-8')); $document->setMetaData('og:type', 'website'); $document->setMetaData('og:description', htmlspecialchars(strip_tags($document->getDescription()), ENT_QUOTES, 'UTF-8')); //Look for template files in component folders $this->_addPath('template', JPATH_COMPONENT . DS . 'templates'); $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . 'default'); //Look for overrides in template folder (K2 template structure) $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates'); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . 'default'); //Look for overrides in template folder (Joomla! template structure) $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'default'); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2'); // Look for specific K2 theme files if ($theme) { $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . $theme); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . $theme); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . $theme); } //Assign params $this->assignRef('params', $params); $this->assignRef('source', $source); //Set layout $this->setLayout('latest'); //Display parent::display($tpl); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $params = K2HelperUtilities::getParams('com_k2'); $model = $this->getModel('itemlist'); $limitstart = JRequest::getInt('limitstart'); $view = JRequest::getWord('view'); $task = JRequest::getWord('task'); $db = JFactory::getDBO(); // Add link if (K2HelperPermissions::canAddItem()) { $addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component'); } $this->assignRef('addLink', $addLink); // Get data depending on task switch ($task) { case 'category': // Get category $id = JRequest::getInt('id'); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables'); $category = JTable::getInstance('K2Category', 'Table'); $category->load($id); $category->event = new stdClass(); // State check if (!$category->published || $category->trash) { JError::raiseError(404, JText::_('K2_CATEGORY_NOT_FOUND')); } // Access check $user = JFactory::getUser(); if (K2_JVERSION != '15') { if (!in_array($category->access, $user->getAuthorisedViewLevels())) { if ($user->guest) { $uri = JFactory::getURI(); $url = 'index.php?option=com_users&view=login&return=' . base64_encode($uri->toString()); $mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST')); } else { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); return; } } $languageFilter = $mainframe->getLanguageFilter(); $languageTag = JFactory::getLanguage()->getTag(); if ($languageFilter && $category->language != $languageTag && $category->language != '*') { return; } } else { if ($category->access > $user->get('aid', 0)) { if ($user->guest) { $uri = JFactory::getURI(); $url = 'index.php?option=com_user&view=login&return=' . base64_encode($uri->toString()); $mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST')); } else { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); return; } } } // Hide the add new item link if user cannot post in the specific category if (!K2HelperPermissions::canAddItem($id)) { unset($this->addLink); } // Merge params $cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params); // Get the meta information before merging params since we do not want them to be inherited $category->metaDescription = $cparams->get('catMetaDesc'); $category->metaKeywords = $cparams->get('catMetaKey'); $category->metaRobots = $cparams->get('catMetaRobots'); $category->metaAuthor = $cparams->get('catMetaAuthor'); if ($cparams->get('inheritFrom')) { $masterCategory = JTable::getInstance('K2Category', 'Table'); $masterCategory->load($cparams->get('inheritFrom')); $cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($masterCategory->params); } $params->merge($cparams); // Category link $category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias)))); // Category image $category->image = K2HelperUtilities::getCategoryImage($category->image, $params); // Category plugins $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $category->text = $category->description; if (K2_JVERSION != '15') { $dispatcher->trigger('onContentPrepare', array('com_k2.category', &$category, &$params, $limitstart)); } else { $dispatcher->trigger('onPrepareContent', array(&$category, &$params, $limitstart)); } $category->description = $category->text; // Category K2 plugins $category->event->K2CategoryDisplay = ''; JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2CategoryDisplay', array(&$category, &$params, $limitstart)); $category->event->K2CategoryDisplay = trim(implode("\n", $results)); $category->text = $category->description; $dispatcher->trigger('onK2PrepareContent', array(&$category, &$params, $limitstart)); $category->description = $category->text; $this->assignRef('category', $category); $this->assignRef('user', $user); // Category children $ordering = $params->get('subCatOrdering'); $children = $model->getCategoryFirstChildren($id, $ordering); if (count($children)) { foreach ($children as $child) { if ($params->get('subCatTitleItemCounter')) { $child->numOfItems = $model->countCategoryItems($child->id); } $child->image = K2HelperUtilities::getCategoryImage($child->image, $params); $child->name = htmlspecialchars($child->name, ENT_QUOTES); $child->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($child->id . ':' . urlencode($child->alias)))); $subCategories[] = $child; } $this->assignRef('subCategories', $subCategories); } // Set limit $limit = $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items') + $params->get('num_links'); // Set featured flag JRequest::setVar('featured', $params->get('catFeaturedItems')); // Set layout $this->setLayout('category'); // Set title $title = $category->name; $category->name = htmlspecialchars($category->name, ENT_QUOTES); // Set ordering if ($params->get('singleCatOrdering')) { $ordering = $params->get('singleCatOrdering'); } else { $ordering = $params->get('catOrdering'); } $addHeadFeedLink = $params->get('catFeedLink'); break; case 'user': // Get user $id = JRequest::getInt('id'); $userObject = JFactory::getUser($id); $userObject->event = new stdClass(); // Check user status if ($userObject->block) { JError::raiseError(404, JText::_('K2_USER_NOT_FOUND')); } // Get K2 user profile $userObject->profile = $model->getUserProfile(); // User image $userObject->avatar = K2HelperUtilities::getAvatar($userObject->id, $userObject->email, $params->get('userImageWidth')); // User K2 plugins $userObject->event->K2UserDisplay = ''; if (is_object($userObject->profile) && $userObject->profile->id > 0) { $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2UserDisplay', array(&$userObject->profile, &$params, $limitstart)); $userObject->event->K2UserDisplay = trim(implode("\n", $results)); $userObject->profile->url = htmlspecialchars($userObject->profile->url, ENT_QUOTES, 'UTF-8'); } $this->assignRef('user', $userObject); $date = JFactory::getDate(); $now = K2_JVERSION == '15' ? $date->toMySQL() : $date->toSql(); $this->assignRef('now', $now); // Set layout $this->setLayout('user'); // Set limit $limit = $params->get('userItemCount'); // Set title $title = $userObject->name; $userObject->name = htmlspecialchars($userObject->name, ENT_QUOTES); // Set ordering $ordering = $params->get('userOrdering'); $addHeadFeedLink = $params->get('userFeedLink', 1); break; case 'tag': // Set layout $this->setLayout('tag'); // Set limit $limit = $params->get('tagItemCount'); // Set title $title = JText::_('K2_DISPLAYING_ITEMS_BY_TAG') . ' ' . JRequest::getVar('tag'); // Set ordering $ordering = $params->get('tagOrdering'); $addHeadFeedLink = $params->get('tagFeedLink', 1); break; case 'search': // Set layout $this->setLayout('generic'); // Set limit $limit = $params->get('genericItemCount'); // Set title $title = JText::_('K2_SEARCH_RESULTS_FOR') . ' ' . JRequest::getVar('searchword'); $addHeadFeedLink = $params->get('genericFeedLink', 1); break; case 'date': // Set layout $this->setLayout('generic'); // Set limit $limit = $params->get('genericItemCount'); // Fix wrong timezone if (function_exists('date_default_timezone_get')) { $originalTimezone = date_default_timezone_get(); } if (function_exists('date_default_timezone_set')) { date_default_timezone_set('UTC'); } // Set title if (JRequest::getInt('day')) { $date = strtotime(JRequest::getInt('year') . '-' . JRequest::getInt('month') . '-' . JRequest::getInt('day')); $dateFormat = K2_JVERSION == '15' ? '%A, %d %B %Y' : 'l, d F Y'; $title = JText::_('K2_ITEMS_FILTERED_BY_DATE') . ' ' . JHTML::_('date', $date, $dateFormat); } else { $date = strtotime(JRequest::getInt('year') . '-' . JRequest::getInt('month')); $dateFormat = K2_JVERSION == '15' ? '%B %Y' : 'F Y'; $title = JText::_('K2_ITEMS_FILTERED_BY_DATE') . ' ' . JHTML::_('date', $date, $dateFormat); } // Restore the original timezone if (function_exists('date_default_timezone_set') && isset($originalTimezone)) { date_default_timezone_set($originalTimezone); } // Set ordering $ordering = 'rdate'; $addHeadFeedLink = $params->get('genericFeedLink', 1); break; default: // Set layout $this->setLayout('category'); $user = JFactory::getUser(); $this->assignRef('user', $user); // Set limit $limit = $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items') + $params->get('num_links'); // Set featured flag JRequest::setVar('featured', $params->get('catFeaturedItems')); // Set title $title = $params->get('page_title'); // Set ordering $ordering = $params->get('catOrdering'); $addHeadFeedLink = $params->get('catFeedLink', 1); break; } // Set limit for model if (!$limit) { $limit = 10; } JRequest::setVar('limit', $limit); // Get items if (!isset($ordering)) { $items = $model->getData(); } else { $items = $model->getData($ordering); } // Pagination jimport('joomla.html.pagination'); $total = count($items) ? $model->getTotal() : 0; $pagination = new JPagination($total, $limitstart, $limit); //Prepare items $user = JFactory::getUser(); $cache = JFactory::getCache('com_k2_extended'); $model = $this->getModel('item'); for ($i = 0; $i < sizeof($items); $i++) { //Item group if ($task == "category" || $task == "") { if ($i < $params->get('num_links') + $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items')) { $items[$i]->itemGroup = 'links'; } if ($i < $params->get('num_secondary_items') + $params->get('num_leading_items') + $params->get('num_primary_items')) { $items[$i]->itemGroup = 'secondary'; } if ($i < $params->get('num_primary_items') + $params->get('num_leading_items')) { $items[$i]->itemGroup = 'primary'; } if ($i < $params->get('num_leading_items')) { $items[$i]->itemGroup = 'leading'; } } // Check if the model should use the cache for preparing the item even if the user is logged in if ($user->guest || $task == 'tag' || $task == 'search' || $task == 'date') { $cacheFlag = true; } else { $cacheFlag = true; if (K2HelperPermissions::canEditItem($items[$i]->created_by, $items[$i]->catid)) { $cacheFlag = false; } } // Prepare item if ($cacheFlag) { $hits = $items[$i]->hits; $items[$i]->hits = 0; JTable::getInstance('K2Category', 'Table'); $items[$i] = $cache->call(array($model, 'prepareItem'), $items[$i], $view, $task); $items[$i]->hits = $hits; } else { $items[$i] = $model->prepareItem($items[$i], $view, $task); } // Plugins $items[$i] = $model->execPlugins($items[$i], $view, $task); // Trigger comments counter event $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2CommentsCounter', array(&$items[$i], &$params, $limitstart)); $items[$i]->event->K2CommentsCounter = trim(implode("\n", $results)); } // Set title $document = JFactory::getDocument(); $application = JFactory::getApplication(); $menus = $application->getMenu(); $menu = $menus->getActive(); if (is_object($menu)) { if (is_string($menu->params)) { $menu_params = K2_JVERSION == '15' ? new JParameter($menu->params) : new JRegistry($menu->params); } else { $menu_params = $menu->params; } if (!$menu_params->get('page_title')) { $params->set('page_title', $title); } } else { $params->set('page_title', $title); } // We're adding a new variable here which won't get the appended/prepended site title, // when enabled via Joomla!'s SEO/SEF settings $params->set('page_title_clean', $title); if (K2_JVERSION != '15') { if ($mainframe->getCfg('sitename_pagetitles', 0) == 1) { $tmpTitle = JText::sprintf('JPAGETITLE', $mainframe->getCfg('sitename'), $params->get('page_title')); $params->set('page_title', $tmpTitle); } elseif ($mainframe->getCfg('sitename_pagetitles', 0) == 2) { $tmpTitle = JText::sprintf('JPAGETITLE', $params->get('page_title'), $mainframe->getCfg('sitename')); $params->set('page_title', $tmpTitle); } } $document->setTitle($params->get('page_title')); // Search - Update the Google Search results container (K2 v2.6.6+) if ($task == 'search') { $googleSearchContainerID = trim($params->get('googleSearchContainer', 'k2GoogleSearchContainer')); if ($googleSearchContainerID == 'k2Container') { $googleSearchContainerID = 'k2GoogleSearchContainer'; } $params->set('googleSearchContainer', $googleSearchContainerID); } // Set metadata for category if ($task == 'category') { if ($category->metaDescription) { $document->setDescription($category->metaDescription); } else { $metaDescItem = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $this->category->description); $metaDescItem = strip_tags($metaDescItem); $metaDescItem = K2HelperUtilities::characterLimit($metaDescItem, $params->get('metaDescLimit', 150)); $metaDescItem = htmlspecialchars($metaDescItem, ENT_QUOTES, 'UTF-8'); $document->setDescription($metaDescItem); } if ($category->metaKeywords) { $document->setMetadata('keywords', $category->metaKeywords); } if ($category->metaRobots) { $document->setMetadata('robots', $category->metaRobots); } if ($category->metaAuthor) { $document->setMetadata('author', $category->metaAuthor); } } if (K2_JVERSION != '15') { // Menu metadata options if ($params->get('menu-meta_description')) { $document->setDescription($params->get('menu-meta_description')); } if ($params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $params->get('menu-meta_keywords')); } if ($params->get('robots')) { $document->setMetadata('robots', $params->get('robots')); } // Menu page display options if ($params->get('page_heading')) { $params->set('page_title', $params->get('page_heading')); } $params->set('show_page_title', $params->get('show_page_heading')); } // Pathway $pathway = $mainframe->getPathWay(); if (!isset($menu->query['task'])) { $menu->query['task'] = ''; } if ($menu) { switch ($task) { case 'category': if ($menu->query['task'] != 'category' || $menu->query['id'] != JRequest::getInt('id')) { $pathway->addItem($title, ''); } break; case 'user': if ($menu->query['task'] != 'user' || $menu->query['id'] != JRequest::getInt('id')) { $pathway->addItem($title, ''); } break; case 'tag': if ($menu->query['task'] != 'tag' || $menu->query['tag'] != JRequest::getVar('tag')) { $pathway->addItem($title, ''); } break; case 'search': case 'date': $pathway->addItem($title, ''); break; } } // Feed link $config = JFactory::getConfig(); $menu = $application->getMenu(); $default = $menu->getDefault(); $active = $menu->getActive(); if ($task == 'tag') { $link = K2HelperRoute::getTagRoute(JRequest::getVar('tag')); } else { $link = ''; } $sef = K2_JVERSION == '30' ? $config->get('sef') : $config->getValue('config.sef'); if (!is_null($active) && $active->id == $default->id && $sef) { $link .= '&Itemid=' . $active->id . '&format=feed&limitstart='; } else { $link .= '&format=feed&limitstart='; } $feed = JRoute::_($link); $this->assignRef('feed', $feed); // Add head feed link if ($addHeadFeedLink) { $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } // Assign data if ($task == "category" || $task == "") { $leading = @array_slice($items, 0, $params->get('num_leading_items')); $primary = @array_slice($items, $params->get('num_leading_items'), $params->get('num_primary_items')); $secondary = @array_slice($items, $params->get('num_leading_items') + $params->get('num_primary_items'), $params->get('num_secondary_items')); $links = @array_slice($items, $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items'), $params->get('num_links')); $this->assignRef('leading', $leading); $this->assignRef('primary', $primary); $this->assignRef('secondary', $secondary); $this->assignRef('links', $links); } else { $this->assignRef('items', $items); } // Set default values to avoid division by zero if ($params->get('num_leading_columns') == 0) { $params->set('num_leading_columns', 1); } if ($params->get('num_primary_columns') == 0) { $params->set('num_primary_columns', 1); } if ($params->get('num_secondary_columns') == 0) { $params->set('num_secondary_columns', 1); } if ($params->get('num_links_columns') == 0) { $params->set('num_links_columns', 1); } $this->assignRef('params', $params); $this->assignRef('pagination', $pagination); // Set Facebook meta data $document = JFactory::getDocument(); $uri = JURI::getInstance(); $document->setMetaData('og:url', $uri->toString()); $document->setMetaData('og:title', htmlspecialchars($document->getTitle(), ENT_QUOTES, 'UTF-8')); $document->setMetaData('og:type', 'website'); if ($task == 'category' && $this->category->image && strpos($this->category->image, 'placeholder/category.png') === false) { $image = substr(JURI::root(), 0, -1) . str_replace(JURI::root(true), '', $this->category->image); $document->setMetaData('og:image', $image); $document->setMetaData('image', $image); } $document->setMetaData('og:description', htmlspecialchars(strip_tags($document->getDescription()), ENT_QUOTES, 'UTF-8')); // Look for template files in component folders $this->_addPath('template', JPATH_COMPONENT . DS . 'templates'); $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . 'default'); // Look for overrides in template folder (K2 template structure) $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates'); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . 'default'); // Look for overrides in template folder (Joomla! template structure) $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'default'); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2'); // Look for specific K2 theme files if ($params->get('theme')) { $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . $params->get('theme')); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . $params->get('theme')); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . $params->get('theme')); } $nullDate = $db->getNullDate(); $this->assignRef('nullDate', $nullDate); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2'); $dispatcher->trigger('onK2BeforeViewDisplay'); // Prevent spammers from using the tag view if ($task == 'tag' && !count($this->items)) { $tag = JRequest::getString('tag'); $db = JFactory::getDBO(); $db->setQuery('SELECT id FROM #__k2_tags WHERE name = ' . $db->quote($tag)); $tagID = $db->loadResult(); if (!$tagID) { JError::raiseError(404, JText::_('K2_NOT_FOUND')); return false; } } parent::display($tpl); }
function display($tpl = null) { JRequest::setVar('hidemainmenu', 1); $model = $this->getModel(); $category = $model->getData(); if (K2_JVERSION == '15') { JFilterOutput::objectHTMLSafe($category); } else { JFilterOutput::objectHTMLSafe($category, ENT_QUOTES, array('params', 'plugins')); } if (!$category->id) { $category->published = 1; } $this->assignRef('row', $category); $wysiwyg = JFactory::getEditor(); $editor = $wysiwyg->display('description', $category->description, '100%', '250px', '', '', array('pagebreak', 'readmore')); $this->assignRef('editor', $editor); $document = JFactory::getDocument(); $js = "\n\t\tvar K2SitePath = '" . JURI::root(true) . "/';\n\t\tvar K2BasePath = '" . JURI::base(true) . "/';\n\t\t"; $document->addScriptDeclaration($js); $lists = array(); $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $category->published); $lists['access'] = version_compare(JVERSION, '3.0', 'ge') ? JHTML::_('access.level', 'access', $category->access) : JHTML::_('list.accesslevel', $category); $query = 'SELECT ordering AS value, name AS text FROM #__k2_categories ORDER BY ordering'; $lists['ordering'] = version_compare(JVERSION, '3.0', 'ge') ? NUll : JHTML::_('list.specificordering', $category, $category->id, $query); $categories[] = JHTML::_('select.option', '0', JText::_('K2_NONE_ONSELECTLISTS')); $categoriesModel = K2Model::getInstance('Categories', 'K2Model'); $tree = $categoriesModel->categoriesTree($category, true, false); $categories = array_merge($categories, $tree); $lists['parent'] = JHTML::_('select.genericlist', $categories, 'parent', 'class="inputbox"', 'value', 'text', $category->parent); $extraFieldsModel = K2Model::getInstance('ExtraFields', 'K2Model'); $groups = $extraFieldsModel->getGroups(); $group[] = JHTML::_('select.option', '0', JText::_('K2_NONE_ONSELECTLISTS'), 'id', 'name'); $group = array_merge($group, $groups); $lists['extraFieldsGroup'] = JHTML::_('select.genericlist', $group, 'extraFieldsGroup', 'class="inputbox" size="1" ', 'id', 'name', $category->extraFieldsGroup); if (version_compare(JVERSION, '1.6.0', 'ge')) { $languages = JHTML::_('contentlanguage.existing', true, true); $lists['language'] = JHTML::_('select.genericlist', $languages, 'language', '', 'value', 'text', $category->language); } JPluginHelper::importPlugin('k2'); $dispatcher = JDispatcher::getInstance(); $K2Plugins = $dispatcher->trigger('onRenderAdminForm', array(&$category, 'category')); $this->assignRef('K2Plugins', $K2Plugins); $params = JComponentHelper::getParams('com_k2'); $this->assignRef('params', $params); if (version_compare(JVERSION, '1.6.0', 'ge')) { jimport('joomla.form.form'); $form = JForm::getInstance('categoryForm', JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'category.xml'); $values = array('params' => json_decode($category->params)); $form->bind($values); $inheritFrom = isset($values['params']->inheritFrom) ? $values['params']->inheritFrom : 0; } else { $form = new JParameter('', JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'category.xml'); $form->loadINI($category->params); $inheritFrom = $form->get('inheritFrom'); } $this->assignRef('form', $form); $categories[0] = JHTML::_('select.option', '0', JText::_('K2_NONE_ONSELECTLISTS')); $lists['inheritFrom'] = JHTML::_('select.genericlist', $categories, 'params[inheritFrom]', 'class="inputbox"', 'value', 'text', $inheritFrom); $this->assignRef('lists', $lists); JRequest::getInt('cid') ? $title = JText::_('K2_EDIT_CATEGORY') : ($title = JText::_('K2_ADD_CATEGORY')); JToolBarHelper::title($title, 'k2.png'); JToolBarHelper::save(); JToolBarHelper::custom('saveAndNew', 'save.png', 'save_f2.png', 'K2_SAVE_AND_NEW', false); JToolBarHelper::apply(); JToolBarHelper::cancel(); // ACE ACL integration $definedConstants = get_defined_constants(); if (!empty($definedConstants['ACEACL']) && AceaclApi::authorize('permissions', 'com_aceacl')) { $aceAclFlag = true; } else { $aceAclFlag = false; } $this->assignRef('aceAclFlag', $aceAclFlag); parent::display($tpl); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $user = JFactory::getUser(); $document = JFactory::getDocument(); $params = K2HelperUtilities::getParams('com_k2'); $limitstart = JRequest::getInt('limitstart', 0); $view = JRequest::getWord('view'); $task = JRequest::getWord('task'); $db = JFactory::getDBO(); $jnow = JFactory::getDate(); $now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql(); $nullDate = $db->getNullDate(); $this->setLayout('item'); // Add link if (K2HelperPermissions::canAddItem()) { $addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component'); } $this->assignRef('addLink', $addLink); // Get item $model = $this->getModel(); $item = $model->getData(); $item->event = new stdClass(); // Does the item exists? if (!is_object($item) || !$item->id) { JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND')); } // Prepare item $item = $model->prepareItem($item, $view, $task); // Plugins $item = $model->execPlugins($item, $view, $task); // User K2 plugins $item->event->K2UserDisplay = ''; if (isset($item->author) && is_object($item->author->profile) && isset($item->author->profile->id)) { $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2UserDisplay', array(&$item->author->profile, &$params, $limitstart)); $item->event->K2UserDisplay = trim(implode("\n", $results)); $item->author->profile->url = htmlspecialchars($item->author->profile->url, ENT_QUOTES, 'UTF-8'); } // Access check if ($this->getLayout() == 'form') { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); } if (K2_JVERSION != '15') { if (!in_array($item->access, $user->getAuthorisedViewLevels()) || !in_array($item->category->access, $user->getAuthorisedViewLevels())) { if ($user->guest) { $uri = JFactory::getURI(); $url = 'index.php?option=com_users&view=login&return=' . base64_encode($uri->toString()); $mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice'); $mainframe->redirect(JRoute::_($url, false)); } else { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); return; } } } else { if ($item->access > $user->get('aid', 0) || $item->category->access > $user->get('aid', 0)) { if ($user->guest) { $uri = JFactory::getURI(); $url = 'index.php?option=com_user&view=login&return=' . base64_encode($uri->toString()); $mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice'); $mainframe->redirect(JRoute::_($url, false)); } else { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); return; } } } // Published check if (!$item->published || $item->trash) { JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND')); } if ($item->publish_up != $nullDate && $item->publish_up > $now) { JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND')); } if ($item->publish_down != $nullDate && $item->publish_down < $now) { JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND')); } if (!$item->category->published || $item->category->trash) { JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND')); } // Increase hits counter $model->hit($item->id); // Set default image K2HelperUtilities::setDefaultImage($item, $view); // Comments $item->event->K2CommentsCounter = ''; $item->event->K2CommentsBlock = ''; if ($item->params->get('itemComments')) { // Trigger comments events $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2CommentsCounter', array(&$item, &$params, $limitstart)); $item->event->K2CommentsCounter = trim(implode("\n", $results)); $results = $dispatcher->trigger('onK2CommentsBlock', array(&$item, &$params, $limitstart)); $item->event->K2CommentsBlock = trim(implode("\n", $results)); // Load K2 native comments system only if there are no plugins overriding it if (empty($item->event->K2CommentsCounter) && empty($item->event->K2CommentsBlock)) { $limit = $params->get('commentsLimit'); $comments = $model->getItemComments($item->id, $limitstart, $limit); $pattern = "@\\b(https?://)?(([0-9a-zA-Z_!~*'().&=+\$%-]+:)?[0-9a-zA-Z_!~*'().&=+\$%-]+\\@)?(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\\@&=+\$,%#-]+)*/?)@"; for ($i = 0; $i < sizeof($comments); $i++) { $comments[$i]->commentText = nl2br($comments[$i]->commentText); $comments[$i]->commentText = preg_replace($pattern, '<a target="_blank" rel="nofollow" href="\\0">\\0</a>', $comments[$i]->commentText); $comments[$i]->userImage = K2HelperUtilities::getAvatar($comments[$i]->userID, $comments[$i]->commentEmail, $params->get('commenterImgWidth')); if ($comments[$i]->userID > 0) { $comments[$i]->userLink = K2HelperRoute::getUserRoute($comments[$i]->userID); } else { $comments[$i]->userLink = $comments[$i]->commentURL; } } $item->comments = $comments; jimport('joomla.html.pagination'); $total = $item->numOfComments; $pagination = new JPagination($total, $limitstart, $limit); } } // Author's latest items if ($item->params->get('itemAuthorLatest') && $item->created_by_alias == '') { $model = $this->getModel('itemlist'); $authorLatestItems = $model->getAuthorLatest($item->id, $item->params->get('itemAuthorLatestLimit'), $item->created_by); if (count($authorLatestItems)) { for ($i = 0; $i < sizeof($authorLatestItems); $i++) { $authorLatestItems[$i]->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($authorLatestItems[$i]->id . ':' . urlencode($authorLatestItems[$i]->alias), $authorLatestItems[$i]->catid . ':' . urlencode($authorLatestItems[$i]->categoryalias)))); } $this->assignRef('authorLatestItems', $authorLatestItems); } } // Related items if ($item->params->get('itemRelated') && isset($item->tags) && count($item->tags)) { $model = $this->getModel('itemlist'); $relatedItems = $model->getRelatedItems($item->id, $item->tags, $item->params); if (count($relatedItems)) { for ($i = 0; $i < sizeof($relatedItems); $i++) { $relatedItems[$i]->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($relatedItems[$i]->id . ':' . urlencode($relatedItems[$i]->alias), $relatedItems[$i]->catid . ':' . urlencode($relatedItems[$i]->categoryalias)))); } $this->assignRef('relatedItems', $relatedItems); } } // Navigation (previous and next item) if ($item->params->get('itemNavigation')) { $model = $this->getModel('item'); $nextItem = $model->getNextItem($item->id, $item->catid, $item->ordering); if (!is_null($nextItem)) { $item->nextLink = urldecode(JRoute::_(K2HelperRoute::getItemRoute($nextItem->id . ':' . urlencode($nextItem->alias), $nextItem->catid . ':' . urlencode($item->category->alias)))); $item->nextTitle = $nextItem->title; } $previousItem = $model->getPreviousItem($item->id, $item->catid, $item->ordering); if (!is_null($previousItem)) { $item->previousLink = urldecode(JRoute::_(K2HelperRoute::getItemRoute($previousItem->id . ':' . urlencode($previousItem->alias), $previousItem->catid . ':' . urlencode($item->category->alias)))); $item->previousTitle = $previousItem->title; } } // Absolute URL $uri = JURI::getInstance(); $item->absoluteURL = $uri->toString(); // Email link if (K2_JVERSION != '15') { require_once JPATH_SITE . '/components/com_mailto/helpers/mailto.php'; $template = $mainframe->getTemplate(); $item->emailLink = JRoute::_('index.php?option=com_mailto&tmpl=component&template=' . $template . '&link=' . MailToHelper::addLink($item->absoluteURL)); } else { require_once JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php'; $item->emailLink = JRoute::_('index.php?option=com_mailto&tmpl=component&link=' . MailToHelper::addLink($item->absoluteURL)); } // Twitter link (legacy code) if ($params->get('twitterUsername')) { $item->twitterURL = 'http://twitter.com/intent/tweet?text=' . urlencode($item->title) . '&url=' . urlencode($item->absoluteURL) . '&via=' . $params->get('twitterUsername'); } else { $item->twitterURL = 'http://twitter.com/intent/tweet?text=' . urlencode($item->title) . '&url=' . urlencode($item->absoluteURL); } // Social link $item->socialLink = urlencode($item->absoluteURL); // Look for template files in component folders $this->_addPath('template', JPATH_COMPONENT . DS . 'templates'); $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . 'default'); // Look for overrides in template folder (K2 template structure) $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates'); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . 'default'); // Look for overrides in template folder (Joomla! template structure) $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'default'); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2'); // Look for specific K2 theme files if ($item->params->get('theme')) { $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . $item->params->get('theme')); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . $item->params->get('theme')); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . $item->params->get('theme')); } // Assign data $this->assignRef('item', $item); $this->assignRef('user', $user); $this->assignRef('params', $item->params); $this->assignRef('pagination', $pagination); parent::display($tpl); }
function move() { $mainframe = JFactory::getApplication(); JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables'); $cid = JRequest::getVar('cid'); foreach ($cid as $id) { $row =& JTable::getInstance('K2Category', 'Table'); $row->load($id); $rows[] = $row; } $categoriesModel = K2Model::getInstance('Categories', 'K2Model'); $categories_option[] = JHTML::_('select.option', 0, JText::_('K2_NONE_ONSELECTLISTS')); $categories = $categoriesModel->categoriesTree(NULL, true, false); $categories_options = @array_merge($categories_option, $categories); foreach ($categories_options as $option) { if (in_array($option->value, $cid)) { $option->disable = true; } } $lists['categories'] = JHTML::_('select.genericlist', $categories_options, 'category', 'class="inputbox" size="8"', 'value', 'text'); $this->assignRef('rows', $rows); $this->assignRef('lists', $lists); JToolBarHelper::title(JText::_('K2_MOVE_CATEGORIES'), 'k2.png'); JToolBarHelper::custom('saveMove', 'save.png', 'save_f2.png', 'K2_SAVE', false); JToolBarHelper::cancel(); parent::display(); }
function move() { $mainframe = JFactory::getApplication(); JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables'); $cid = JRequest::getVar('cid'); JArrayHelper::toInteger($cid); foreach ($cid as $id) { $row = JFactory::getUser($id); $rows[] = $row; } $this->assignRef('rows', $rows); $model = $this->getModel('users'); $lists = array(); $userGroups = $model->getUserGroups(); $groups[] = JHTML::_('select.option', '', JText::_('K2_DO_NOT_CHANGE')); foreach ($userGroups as $userGroup) { $groups[] = JHTML::_('select.option', $userGroup->value, JText::_($userGroup->text)); } $fieldName = 'group'; $attributes = 'size="10"'; if (K2_JVERSION != '15') { $attributes .= 'multiple="multiple"'; $fieldName .= '[]'; } $lists['group'] = JHTML::_('select.genericlist', $groups, $fieldName, $attributes, 'value', 'text', ''); $K2userGroups = $model->getUserGroups('k2'); $K2groups[] = JHTML::_('select.option', '0', JText::_('K2_DO_NOT_CHANGE')); foreach ($K2userGroups as $K2userGroup) { $K2groups[] = JHTML::_('select.option', $K2userGroup->id, $K2userGroup->name); } $lists['k2group'] = JHTML::_('select.genericlist', $K2groups, 'k2group', 'size="10"', 'value', 'text', 0); $this->assignRef('lists', $lists); JToolBarHelper::title(JText::_('K2_MOVE_USERS'), 'k2.png'); JToolBarHelper::custom('saveMove', 'save.png', 'save_f2.png', 'K2_SAVE', false); JToolBarHelper::cancel(); parent::display(); }
function move() { $mainframe = JFactory::getApplication(); JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables'); $cid = JRequest::getVar('cid'); foreach ($cid as $id) { $row = JTable::getInstance('K2Item', 'Table'); $row->load($id); $rows[] = $row; } $categoriesModel = K2Model::getInstance('Categories', 'K2Model'); $categories = $categoriesModel->categoriesTree(null, true, false); $lists['categories'] = JHTML::_('select.genericlist', $categories, 'category', 'class="inputbox" size="8"', 'value', 'text'); $this->assignRef('rows', $rows); $this->assignRef('lists', $lists); JToolBarHelper::title(JText::_('K2_MOVE_ITEMS'), 'k2.png'); JToolBarHelper::custom('saveMove', 'save.png', 'save_f2.png', 'K2_SAVE', false); JToolBarHelper::cancel(); parent::display(); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $user = JFactory::getUser(); $document = JFactory::getDocument(); $params = K2HelperUtilities::getParams('com_k2'); $limitstart = JRequest::getInt('limitstart', 0); $view = JRequest::getWord('view'); $task = JRequest::getWord('task'); $db = JFactory::getDBO(); $jnow = JFactory::getDate(); $now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql(); $nullDate = $db->getNullDate(); $this->setLayout('item'); // Add link if (K2HelperPermissions::canAddItem()) { $addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component'); } $this->assignRef('addLink', $addLink); // Get item $model = $this->getModel(); $item = $model->getData(); // Does the item exists? if (!is_object($item) || !$item->id) { JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND')); } // Prepare item $item = $model->prepareItem($item, $view, $task); // Plugins $item = $model->execPlugins($item, $view, $task); // User K2 plugins $item->event->K2UserDisplay = ''; if (isset($item->author) && is_object($item->author->profile) && isset($item->author->profile->id)) { $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2UserDisplay', array(&$item->author->profile, &$params, $limitstart)); $item->event->K2UserDisplay = trim(implode("\n", $results)); $item->author->profile->url = htmlspecialchars($item->author->profile->url, ENT_QUOTES, 'UTF-8'); } // Access check if ($this->getLayout() == 'form') { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); } if (K2_JVERSION != '15') { if (!in_array($item->access, $user->getAuthorisedViewLevels()) || !in_array($item->category->access, $user->getAuthorisedViewLevels())) { if ($user->guest) { $uri = JFactory::getURI(); $url = 'index.php?option=com_users&view=login&return=' . base64_encode($uri->toString()); $mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice'); $mainframe->redirect(JRoute::_($url, false)); } else { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); return; } } } else { if ($item->access > $user->get('aid', 0) || $item->category->access > $user->get('aid', 0)) { if ($user->guest) { $uri = JFactory::getURI(); $url = 'index.php?option=com_user&view=login&return=' . base64_encode($uri->toString()); $mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice'); $mainframe->redirect(JRoute::_($url, false)); } else { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); return; } } } // Published check if (!$item->published || $item->trash) { JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND')); } if ($item->publish_up != $nullDate && $item->publish_up > $now) { JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND')); } if ($item->publish_down != $nullDate && $item->publish_down < $now) { JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND')); } if (!$item->category->published || $item->category->trash) { JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND')); } // Increase hits counter $model->hit($item->id); // Set default image K2HelperUtilities::setDefaultImage($item, $view); // Pass the old parameter to the view in order to avoid layout changes if ($params->get('antispam') == 'recaptcha' || $params->get('antispam') == 'both') { $params->set('recaptcha', true); $item->params->set('recaptcha', true); } else { $params->set('recaptcha', false); $item->params->set('recaptcha', false); } // Comments $item->event->K2CommentsCounter = ''; $item->event->K2CommentsBlock = ''; if ($item->params->get('itemComments')) { // Trigger comments events $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2CommentsCounter', array(&$item, &$params, $limitstart)); $item->event->K2CommentsCounter = trim(implode("\n", $results)); $results = $dispatcher->trigger('onK2CommentsBlock', array(&$item, &$params, $limitstart)); $item->event->K2CommentsBlock = trim(implode("\n", $results)); // Load K2 native comments system only if there are no plugins overriding it if (empty($item->event->K2CommentsCounter) && empty($item->event->K2CommentsBlock)) { // Load reCAPTCHA script if (!JRequest::getInt('print') && ($item->params->get('comments') == '1' || $item->params->get('comments') == '2' && K2HelperPermissions::canAddComment($item->catid))) { if ($params->get('recaptcha') && ($user->guest || $params->get('recaptchaForRegistered', 1))) { $document->addScript('https://www.google.com/recaptcha/api/js/recaptcha_ajax.js'); $js = ' function showRecaptcha(){ Recaptcha.create("' . $item->params->get('recaptcha_public_key') . '", "recaptcha", { theme: "' . $item->params->get('recaptcha_theme', 'clean') . '" }); } $K2(window).load(function() { showRecaptcha(); }); '; $document->addScriptDeclaration($js); } } // Check for inline comment moderation if (!$user->guest && $user->id == $item->created_by && $params->get('inlineCommentsModeration')) { $inlineCommentsModeration = true; $commentsPublished = false; } else { $inlineCommentsModeration = false; $commentsPublished = true; } $this->assignRef('inlineCommentsModeration', $inlineCommentsModeration); // Flag spammer link $reportSpammerFlag = false; if (K2_JVERSION != '15') { if ($user->authorise('core.admin', 'com_k2')) { $reportSpammerFlag = true; $document = JFactory::getDocument(); $document->addScriptDeclaration('var K2Language = ["' . JText::_('K2_REPORT_USER_WARNING', true) . '"];'); } } else { if ($user->gid > 24) { $reportSpammerFlag = true; } } $limit = $params->get('commentsLimit'); $comments = $model->getItemComments($item->id, $limitstart, $limit, $commentsPublished); for ($i = 0; $i < sizeof($comments); $i++) { $comments[$i]->commentText = nl2br($comments[$i]->commentText); // Convert URLs to links properly $comments[$i]->commentText = preg_replace("/([^\\w\\/])(www\\.[a-z0-9\\-]+\\.[a-z0-9\\-]+)/i", "\$1http://\$2", $comments[$i]->commentText); $comments[$i]->commentText = preg_replace("/([\\w]+:\\/\\/[\\w-?&;#~=\\.\\/\\@]+[\\w\\/])/i", "<a target=\"_blank\" rel=\"nofollow\" href=\"\$1\">\$1</A>", $comments[$i]->commentText); $comments[$i]->commentText = preg_replace("/([\\w-?&;#~=\\.\\/]+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?))/i", "<a href=\"mailto:\$1\">\$1</A>", $comments[$i]->commentText); $comments[$i]->userImage = K2HelperUtilities::getAvatar($comments[$i]->userID, $comments[$i]->commentEmail, $params->get('commenterImgWidth')); if ($comments[$i]->userID > 0) { $comments[$i]->userLink = K2HelperRoute::getUserRoute($comments[$i]->userID); } else { $comments[$i]->userLink = $comments[$i]->commentURL; } if ($reportSpammerFlag && $comments[$i]->userID > 0) { $comments[$i]->reportUserLink = JRoute::_('index.php?option=com_k2&view=comments&task=reportSpammer&id=' . $comments[$i]->userID . '&format=raw'); } else { $comments[$i]->reportUserLink = false; } } $item->comments = $comments; if (!isset($item->numOfComments)) { $item->numOfComments = 0; } jimport('joomla.html.pagination'); $total = $item->numOfComments; $pagination = new JPagination($total, $limitstart, $limit); } } // Author's latest items if ($item->params->get('itemAuthorLatest') && $item->created_by_alias == '') { $model = $this->getModel('itemlist'); $authorLatestItems = $model->getAuthorLatest($item->id, $item->params->get('itemAuthorLatestLimit'), $item->created_by); if (count($authorLatestItems)) { for ($i = 0; $i < sizeof($authorLatestItems); $i++) { $authorLatestItems[$i]->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($authorLatestItems[$i]->id . ':' . urlencode($authorLatestItems[$i]->alias), $authorLatestItems[$i]->catid . ':' . urlencode($authorLatestItems[$i]->categoryalias)))); } $this->assignRef('authorLatestItems', $authorLatestItems); } } // Related items if ($item->params->get('itemRelated') && isset($item->tags) && count($item->tags)) { $model = $this->getModel('itemlist'); $relatedItems = $model->getRelatedItems($item->id, $item->tags, $item->params); if (count($relatedItems)) { for ($i = 0; $i < sizeof($relatedItems); $i++) { $relatedItems[$i]->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($relatedItems[$i]->id . ':' . urlencode($relatedItems[$i]->alias), $relatedItems[$i]->catid . ':' . urlencode($relatedItems[$i]->categoryalias)))); } $this->assignRef('relatedItems', $relatedItems); } } // Navigation (previous and next item) if ($item->params->get('itemNavigation')) { $model = $this->getModel('item'); $nextItem = $model->getNextItem($item->id, $item->catid, $item->ordering); if (!is_null($nextItem)) { $item->nextLink = urldecode(JRoute::_(K2HelperRoute::getItemRoute($nextItem->id . ':' . urlencode($nextItem->alias), $nextItem->catid . ':' . urlencode($item->category->alias)))); $item->nextTitle = $nextItem->title; $date = JFactory::getDate($item->modified); $timestamp = '?t=' . $date->toUnix(); if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $nextItem->id) . '_XS.jpg')) { $item->nextImageXSmall = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $nextItem->id) . '_XS.jpg' . $timestamp; } if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $nextItem->id) . '_S.jpg')) { $item->nextImageSmall = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $nextItem->id) . '_S.jpg' . $timestamp; } if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $nextItem->id) . '_M.jpg')) { $item->nextImageMedium = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $nextItem->id) . '_M.jpg' . $timestamp; } if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $nextItem->id) . '_L.jpg')) { $item->nextImageLarge = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $nextItem->id) . '_L.jpg' . $timestamp; } if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $nextItem->id) . '_XL.jpg')) { $item->nextImageXLarge = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $nextItem->id) . '_XL.jpg' . $timestamp; } if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $nextItem->id) . '_Generic.jpg')) { $item->nextImageGeneric = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $nextItem->id) . '_Generic.jpg' . $timestamp; } } $previousItem = $model->getPreviousItem($item->id, $item->catid, $item->ordering); if (!is_null($previousItem)) { $item->previousLink = urldecode(JRoute::_(K2HelperRoute::getItemRoute($previousItem->id . ':' . urlencode($previousItem->alias), $previousItem->catid . ':' . urlencode($item->category->alias)))); $item->previousTitle = $previousItem->title; $date = JFactory::getDate($item->modified); $timestamp = '?t=' . $date->toUnix(); if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $previousItem->id) . '_XS.jpg')) { $item->previousImageXSmall = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $previousItem->id) . '_XS.jpg' . $timestamp; } if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $previousItem->id) . '_S.jpg')) { $item->previousImageSmall = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $previousItem->id) . '_S.jpg' . $timestamp; } if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $previousItem->id) . '_M.jpg')) { $item->previousImageMedium = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $previousItem->id) . '_M.jpg' . $timestamp; } if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $previousItem->id) . '_L.jpg')) { $item->previousImageLarge = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $previousItem->id) . '_L.jpg' . $timestamp; } if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $previousItem->id) . '_XL.jpg')) { $item->previousImageXLarge = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $previousItem->id) . '_XL.jpg' . $timestamp; } if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $previousItem->id) . '_Generic.jpg')) { $item->previousImageGeneric = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $previousItem->id) . '_Generic.jpg' . $timestamp; } } } // Absolute URL $uri = JURI::getInstance(); $item->absoluteURL = $uri->toString(); // Email link if (K2_JVERSION != '15') { require_once JPATH_SITE . '/components/com_mailto/helpers/mailto.php'; $template = $mainframe->getTemplate(); $item->emailLink = JRoute::_('index.php?option=com_mailto&tmpl=component&template=' . $template . '&link=' . MailToHelper::addLink($item->absoluteURL)); } else { require_once JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php'; $item->emailLink = JRoute::_('index.php?option=com_mailto&tmpl=component&link=' . MailToHelper::addLink($item->absoluteURL)); } // Twitter link (legacy code) if ($params->get('twitterUsername')) { $item->twitterURL = 'http://twitter.com/intent/tweet?text=' . urlencode($item->title) . '&url=' . urlencode($item->absoluteURL) . '&via=' . $params->get('twitterUsername'); } else { $item->twitterURL = 'http://twitter.com/intent/tweet?text=' . urlencode($item->title) . '&url=' . urlencode($item->absoluteURL); } // Social link $item->socialLink = urlencode($item->absoluteURL); // Set page title $menus = $mainframe->getMenu(); $menu = $menus->getActive(); if (is_object($menu) && isset($menu->query['view']) && $menu->query['view'] == 'item' && isset($menu->query['id']) && $menu->query['id'] == $item->id) { if (is_string($menu->params)) { $menu_params = K2_JVERSION == '15' ? new JParameter($menu->params) : new JRegistry($menu->params); } else { $menu_params = $menu->params; } if (!$menu_params->get('page_title')) { $params->set('page_title', $item->cleanTitle); } } else { $params->set('page_title', $item->cleanTitle); } if (K2_JVERSION != '15') { if ($mainframe->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $mainframe->getCfg('sitename'), $params->get('page_title')); $params->set('page_title', $title); } elseif ($mainframe->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $params->get('page_title'), $mainframe->getCfg('sitename')); $params->set('page_title', $title); } } $document->setTitle($params->get('page_title')); // Set pathway $menus = $mainframe->getMenu(); $menu = $menus->getActive(); $pathway = $mainframe->getPathWay(); if ($menu) { if (isset($menu->query['view']) && ($menu->query['view'] != 'item' || $menu->query['id'] != $item->id)) { if (!isset($menu->query['task']) || $menu->query['task'] != 'category' || $menu->query['id'] != $item->catid) { $pathway->addItem($item->category->name, $item->category->link); } $pathway->addItem($item->cleanTitle, ''); } } // Set metadata if ($item->metadesc) { $document->setDescription(K2_JVERSION == '15' ? htmlspecialchars($item->metadesc, ENT_QUOTES, 'UTF-8') : $item->metadesc); } else { $metaDescItem = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $item->introtext . ' ' . $item->fulltext); $metaDescItem = strip_tags($metaDescItem); $metaDescItem = K2HelperUtilities::characterLimit($metaDescItem, $params->get('metaDescLimit', 150)); $document->setDescription(K2_JVERSION == '15' ? $metaDescItem : html_entity_decode($metaDescItem)); } if ($item->metakey) { $document->setMetadata('keywords', $item->metakey); } else { if (isset($item->tags) && count($item->tags)) { $tmp = array(); foreach ($item->tags as $tag) { $tmp[] = $tag->name; } $document->setMetadata('keywords', implode(',', $tmp)); } } // Menu metadata for Joomla! 2.5+ (overrides the current metadata if set) if (K2_JVERSION != '15') { if ($params->get('menu-meta_description')) { $document->setDescription($params->get('menu-meta_description')); } if ($params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $params->get('menu-meta_keywords')); } if ($params->get('robots')) { $document->setMetadata('robots', $params->get('robots')); } // Menu page display options if ($params->get('page_heading')) { $params->set('page_title', $params->get('page_heading')); } $params->set('show_page_title', $params->get('show_page_heading')); } if ($mainframe->getCfg('MetaTitle') == '1') { $document->setMetadata('title', $item->cleanTitle); } if ($mainframe->getCfg('MetaAuthor') == '1' && isset($item->author->name)) { $document->setMetadata('author', $item->author->name); } $mdata = class_exists('JParameter') ? new JParameter($item->metadata) : new JRegistry($item->metadata); $mdata = $mdata->toArray(); foreach ($mdata as $k => $v) { if ($k == 'robots' || $k == 'author') { if ($v) { $document->setMetadata($k, $v); } } } // Set Facebook meta data $document = JFactory::getDocument(); $uri = JURI::getInstance(); $document->setMetaData('og:url', $uri->toString()); $document->setMetaData('og:title', K2_JVERSION == '15' ? htmlspecialchars($document->getTitle(), ENT_QUOTES, 'UTF-8') : $document->getTitle()); $document->setMetaData('og:type', 'article'); $facebookImage = 'image' . $params->get('facebookImage', 'Small'); if ($item->{$facebookImage}) { $parts = parse_url($item->{$facebookImage}); if (JFile::exists(JPATH_SITE . $parts['path'])) { $image = substr(JURI::root(), 0, -1) . str_replace(JURI::root(true), '', $item->{$facebookImage}); $document->setMetaData('og:image', $image); $document->setMetaData('image', $image); } } $document->setMetaData('og:description', strip_tags($document->getDescription())); // Look for template files in component folders $this->_addPath('template', JPATH_COMPONENT . DS . 'templates'); $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . 'default'); // Look for overrides in template folder (K2 template structure) $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates'); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . 'default'); // Look for overrides in template folder (Joomla! template structure) $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'default'); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2'); // Look for specific K2 theme files if ($item->params->get('theme')) { $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . $item->params->get('theme')); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . $item->params->get('theme')); $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . $item->params->get('theme')); } // Assign data $this->assignRef('item', $item); $this->assignRef('user', $user); $this->assignRef('params', $item->params); $this->assignRef('pagination', $pagination); parent::display($tpl); }
function display($tpl = null) { JRequest::setVar('hidemainmenu', 1); $model = $this->getModel(); $extraField = $model->getData(); if (!$extraField->id) { $extraField->published = 1; $extraField->alias = ''; $extraField->required = 1; $extraField->showNull = 0; $extraField->displayInFrontEnd = 1; } else { require_once JPATH_COMPONENT . DS . 'lib' . DS . 'JSON.php'; $json = new Services_JSON(); $values = $json->decode($extraField->value); if (isset($values[0]->alias) && !empty($values[0]->alias)) { $extraField->alias = $values[0]->alias; } else { $filter = JFilterInput::getInstance(); $extraField->alias = $filter->clean($extraField->name, 'WORD'); } if (isset($values[0]->required)) { $extraField->required = $values[0]->required; } else { $extraField->required = 0; } if (isset($values[0]->showNull)) { $extraField->showNull = $values[0]->showNull; } else { $extraField->showNull = 0; } if (isset($values[0]->displayInFrontEnd)) { $extraField->displayInFrontEnd = $values[0]->displayInFrontEnd; } else { $extraField->displayInFrontEnd = 0; } } $extraField->name = htmlspecialchars($extraField->name, ENT_QUOTES, 'UTF-8'); $this->assignRef('row', $extraField); $lists = array(); $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $extraField->published); $groups[] = JHTML::_('select.option', 0, JText::_('K2_CREATE_NEW_GROUP')); $extraFieldModel = K2Model::getInstance('ExtraFields', 'K2Model'); $uniqueGroups = $extraFieldModel->getGroups(true); foreach ($uniqueGroups as $group) { $groups[] = JHTML::_('select.option', $group->id, $group->name); } $lists['group'] = JHTML::_('select.genericlist', $groups, 'groups', '', 'value', 'text', $extraField->group); $typeOptions[] = JHTML::_('select.option', 0, JText::_('K2_SELECT_TYPE')); $typeOptions[] = JHTML::_('select.option', 'textfield', JText::_('K2_TEXT_FIELD')); $typeOptions[] = JHTML::_('select.option', 'textarea', JText::_('K2_TEXTAREA')); $typeOptions[] = JHTML::_('select.option', 'select', JText::_('K2_DROPDOWN_SELECTION')); $typeOptions[] = JHTML::_('select.option', 'multipleSelect', JText::_('K2_MULTISELECT_LIST')); $typeOptions[] = JHTML::_('select.option', 'radio', JText::_('K2_RADIO_BUTTONS')); $typeOptions[] = JHTML::_('select.option', 'link', JText::_('K2_LINK')); $typeOptions[] = JHTML::_('select.option', 'csv', JText::_('K2_CSV_DATA')); $typeOptions[] = JHTML::_('select.option', 'labels', JText::_('K2_SEARCHABLE_LABELS')); $typeOptions[] = JHTML::_('select.option', 'date', JText::_('K2_DATE')); $typeOptions[] = JHTML::_('select.option', 'image', JText::_('K2_IMAGE')); $typeOptions[] = JHTML::_('select.option', 'header', JText::_('K2_HEADER')); $lists['type'] = JHTML::_('select.genericlist', $typeOptions, 'type', '', 'value', 'text', $extraField->type); $this->assignRef('lists', $lists); JRequest::getInt('cid') ? $title = JText::_('K2_EDIT_EXTRA_FIELD') : ($title = JText::_('K2_ADD_EXTRA_FIELD')); JToolBarHelper::title($title, 'k2.png'); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JHTML::_('behavior.calendar'); $document = JFactory::getDocument(); $document->addScriptDeclaration(' var K2BasePath = "' . JURI::base(true) . '/"; var K2Language = [ "' . JText::_('K2_REMOVE', true) . '", "' . JText::_('K2_OPTIONAL', true) . '", "' . JText::_('K2_COMMA_SEPARATED_VALUES', true) . '", "' . JText::_('K2_USE_EDITOR', true) . '", "' . JText::_('K2_ALL_SETTINGS_ABOVE_ARE_OPTIONAL', true) . '", "' . JText::_('K2_ADD_AN_OPTION', true) . '", "' . JText::_('K2_LINK_TEXT', true) . '", "' . JText::_('K2_URL', true) . '", "' . JText::_('K2_OPEN_IN', true) . '", "' . JText::_('K2_SAME_WINDOW', true) . '", "' . JText::_('K2_NEW_WINDOW', true) . '", "' . JText::_('K2_CLASSIC_JAVASCRIPT_POPUP', true) . '", "' . JText::_('K2_LIGHTBOX_POPUP', true) . '", "' . JText::_('K2_RESET_VALUE', true) . '", "' . JText::_('K2_CALENDAR', true) . '", "' . JText::_('K2_PLEASE_SELECT_A_FIELD_TYPE_FROM_THE_LIST_ABOVE', true) . '", ];'); JHTML::_('behavior.modal'); parent::display($tpl); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $user = JFactory::getUser(); $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $limitstart = $mainframe->getUserStateFromRequest($option . $view . '.limitstart', 'limitstart', 0, 'int'); $filter_order = $mainframe->getUserStateFromRequest($option . $view . 'filter_order', 'filter_order', 'c.id', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest($option . $view . 'filter_order_Dir', 'filter_order_Dir', 'DESC', 'word'); $filter_state = $mainframe->getUserStateFromRequest($option . $view . 'filter_state', 'filter_state', -1, 'int'); $filter_category = $mainframe->getUserStateFromRequest($option . $view . 'filter_category', 'filter_category', 0, 'int'); $filter_author = $mainframe->getUserStateFromRequest($option . $view . 'filter_author', 'filter_author', 0, 'int'); $search = $mainframe->getUserStateFromRequest($option . $view . 'search', 'search', '', 'string'); $search = JString::strtolower($search); if ($mainframe->isSite()) { $filter_author = $user->id; JRequest::setVar('filter_author', $user->id); } $this->loadHelper('html'); K2Model::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models'); $model = K2Model::getInstance('Comments', 'K2Model'); $params = JComponentHelper::getParams('com_k2'); $total = $model->getTotal(); if ($limitstart > $total - $limit) { $limitstart = max(0, (int) (ceil($total / $limit) - 1) * $limit); JRequest::setVar('limitstart', $limitstart); } $comments = $model->getData(); $reportLink = $mainframe->isAdmin() ? 'index.php?option=com_k2&view=user&task=report&id=' : 'index.php?option=com_k2&view=comments&task=reportSpammer&id='; foreach ($comments as $key => $comment) { $comment->reportUserLink = false; $comment->commenterLastVisitIP = NULL; if ($comment->userID) { $db = JFactory::getDBO(); $db->setQuery("SELECT ip FROM #__k2_users WHERE userID = " . $comment->userID); $comment->commenterLastVisitIP = $db->loadResult(); $commenter = JFactory::getUser($comment->userID); if ($commenter->name) { $comment->userName = $commenter->name; } if ($mainframe->isSite()) { if (K2_JVERSION != '15') { if ($user->authorise('core.admin', 'com_k2')) { $comment->reportUserLink = JRoute::_($reportLink . $comment->userID); } } else { if ($user->gid > 24) { $comment->reportUserLink = JRoute::_($reportLink . $comment->userID); } } } else { $comment->reportUserLink = JRoute::_($reportLink . $comment->userID); } } if ($mainframe->isSite()) { $comment->status = K2HelperHTML::stateToggler($comment, $key); } else { $comment->status = K2_JVERSION == '15' ? JHTML::_('grid.published', $comment, $key) : JHtml::_('jgrid.published', $comment->published, $key); } } $this->assignRef('rows', $comments); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); $this->assignRef('page', $pageNav); $lists = array(); $lists['search'] = $search; $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; $filter_state_options[] = JHTML::_('select.option', -1, JText::_('K2_SELECT_STATE')); $filter_state_options[] = JHTML::_('select.option', 1, JText::_('K2_PUBLISHED')); $filter_state_options[] = JHTML::_('select.option', 0, JText::_('K2_UNPUBLISHED')); $lists['state'] = JHTML::_('select.genericlist', $filter_state_options, 'filter_state', '', 'value', 'text', $filter_state); $categoriesModel = K2Model::getInstance('Categories', 'K2Model'); $categories_option[] = JHTML::_('select.option', 0, JText::_('K2_SELECT_CATEGORY')); $categories = $categoriesModel->categoriesTree(null, true, false); $categories_options = @array_merge($categories_option, $categories); $lists['categories'] = JHTML::_('select.genericlist', $categories_options, 'filter_category', '', 'value', 'text', $filter_category); $lists['authors'] = JHTML::_('list.users', 'filter_author', $filter_author, true, ''); $this->assignRef('lists', $lists); $this->assignRef('mainframe', $mainframe); if (K2_JVERSION != '15') { $dateFormat = JText::_('K2_J16_DATE_FORMAT'); } else { $dateFormat = JText::_('K2_DATE_FORMAT'); } $this->assignRef('dateFormat', $dateFormat); if ($mainframe->isAdmin()) { JToolBarHelper::title(JText::_('K2_COMMENTS'), 'k2.png'); JToolBarHelper::publishList(); JToolBarHelper::unpublishList(); JToolBarHelper::deleteList('', 'remove', 'K2_DELETE'); JToolBarHelper::custom('deleteUnpublished', 'delete', 'delete', 'K2_DELETE_ALL_UNPUBLISHED', false); $toolbar = JToolBar::getInstance('toolbar'); if (K2_JVERSION != '15') { JToolBarHelper::preferences('com_k2', 550, 875, 'K2_PARAMETERS'); } else { $toolbar->appendButton('Popup', 'config', 'Parameters', 'index.php?option=com_k2&view=settings'); } K2HelperHTML::subMenu(); if (K2_JVERSION != '15') { $userEditLink = JURI::base() . 'index.php?option=com_k2&view=user&cid='; } else { $userEditLink = JURI::base() . 'index.php?option=com_k2&view=user&cid='; } $this->assignRef('userEditLink', $userEditLink); } $document = JFactory::getDocument(); $document->addScriptDeclaration('var K2Language = ["' . JText::_('K2_YOU_CANNOT_EDIT_TWO_COMMENTS_AT_THE_SAME_TIME', true) . '", "' . JText::_('K2_THIS_WILL_PERMANENTLY_DELETE_ALL_UNPUBLISHED_COMMENTS_ARE_YOU_SURE', true) . '", "' . JText::_('K2_REPORT_USER_WARNING', true) . '"];'); if ($mainframe->isSite()) { // CSS $document->addStyleSheet(JURI::root(true) . '/media/k2/assets/css/k2.frontend.css?v=2.6.2'); $document->addStyleSheet(JURI::root(true) . '/templates/system/css/general.css'); $document->addStyleSheet(JURI::root(true) . '/templates/system/css/system.css'); if (K2_JVERSION != '15') { $document->addStyleSheet(JURI::root(true) . '/administrator/templates/bluestork/css/template.css'); $document->addStyleSheet(JURI::root(true) . '/media/system/css/system.css'); } else { $document->addStyleSheet(JURI::root(true) . '/administrator/templates/khepri/css/general.css'); } } parent::display($tpl); }
public function display($tpl = null) { // Get application $application = JFactory::getApplication(); // Get input $id = $application->input->get('id', 0, 'int'); // Get item $this->item = K2Items::getInstance($id); // Check access $this->item->checkSiteAccess(); // Merge menu params with category params $effectiveParams = $this->item->category->getEffectiveParams(); $this->params->merge($effectiveParams); // Merge params with item params $this->params->merge($this->item->params); // Get the image depending on params $this->item->image = $this->item->getImage($this->params->get('itemImgSize')); // Trigger plugins. We need to do this there in order to provide the correct context $this->item->events = $this->item->getEvents('com_k2.item', $this->params, 0); // Image modal JHtml::_('behavior.modal', 'a.k2Modal'); // Load head data for comments and inline editing if required if ($this->item->canEdit || $this->params->get('itemComments') && $this->params->get('comments') && empty($this->item->events->K2CommentsCounter) && empty($this->item->events->K2CommentsBlock)) { // Common JHtml::_('behavior.keepalive'); $this->document->addScriptDeclaration('var K2SitePath = "' . JUri::root(true) . '";'); $this->document->addScriptDeclaration('var K2SessionToken = "' . JSession::getFormToken() . '";'); // Comments if ($this->params->get('itemComments') && $this->params->get('comments') && empty($this->item->events->K2CommentsCounter) && empty($this->item->events->K2CommentsBlock)) { // Check if user can comment $this->user->canComment = $this->user->authorise('k2.comment.create', 'com_k2'); // Load comments requirements $this->document->addScript(JURI::root(true) . '/media/k2app/vendor/underscore/underscore-min.js'); $this->document->addScript(JURI::root(true) . '/media/k2app/vendor/backbone/backbone-min.js'); $this->document->addScript(JURI::root(true) . '/media/k2app/vendor/marionette/backbone.marionette.min.js'); $this->document->addScript(JURI::root(true) . '/media/k2app/app/sync.js'); require_once JPATH_SITE . '/components/com_k2/helpers/captcha.php'; K2HelperCaptcha::initialize(); } // Inline editing if ($this->item->canEdit) { $this->document->addScript('//cdn.ckeditor.com/4.4.6/standard/ckeditor.js'); } } // Get related items. We need to do this here since the parameter is related with the view if ($this->params->get('itemRelated')) { $this->item->related = $this->item->getRelated($this->params->get('itemRelatedLimit', 5)); foreach ($this->item->related as $related) { $related->image = $related->getImage($this->params->get('itemRelatedImageSize')); } } // Get latest from same author. We need to do this here since the parameter is related with the view if ($this->params->get('itemAuthorLatest')) { $this->item->author->latest = $this->item->getLatestByAuthor($this->params->get('itemAuthorLatestLimit', 5)); } // Increase hits counter $this->item->hit(); // Set metadata $this->setMetadata($this->item); // Set Facebook meta data if ($this->params->get('facebookMetadata')) { $this->document->setMetaData('og:url', $this->item->url); $this->document->setMetaData('og:title', $this->document->getTitle()); $this->document->setMetaData('og:type', 'article'); $this->document->setMetaData('og:description', $this->document->getDescription()); $facebookImage = $this->item->getImage($this->params->get('facebookMetadataImageSize')); if ($facebookImage) { $this->document->setMetaData('og:image', $facebookImage->url); } } // Set the layout $this->setLayout('item'); // Add the template path $this->addTemplatePath(JPATH_SITE . '/components/com_k2/templates/' . $this->item->category->template); $this->addTemplatePath(JPATH_SITE . '/templates/' . JFactory::getApplication()->getTemplate() . '/html/com_k2/' . $this->item->category->template); // Display parent::display($tpl); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $user = JFactory::getUser(); $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $limitstart = $mainframe->getUserStateFromRequest($option . $view . '.limitstart', 'limitstart', 0, 'int'); $filter_order = $mainframe->getUserStateFromRequest($option . $view . 'filter_order', 'filter_order', 'groupname', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest($option . $view . 'filter_order_Dir', 'filter_order_Dir', 'ASC', 'word'); $filter_state = $mainframe->getUserStateFromRequest($option . $view . 'filter_state', 'filter_state', -1, 'int'); $search = $mainframe->getUserStateFromRequest($option . $view . 'search', 'search', '', 'string'); $search = JString::strtolower($search); $filter_type = $mainframe->getUserStateFromRequest($option . $view . 'filter_type', 'filter_type', '', 'string'); $filter_group = $mainframe->getUserStateFromRequest($option . $view . 'filter_group', 'filter_group', '', 'string'); $model = $this->getModel(); $total = $model->getTotal(); if ($limitstart > $total - $limit) { $limitstart = max(0, (int) (ceil($total / $limit) - 1) * $limit); JRequest::setVar('limitstart', $limitstart); } $extraFields = $model->getData(); require_once JPATH_COMPONENT . DS . 'lib' . DS . 'JSON.php'; $json = new Services_JSON(); foreach ($extraFields as $key => $extraField) { $extraField->status = K2_JVERSION == '15' ? JHTML::_('grid.published', $extraField, $key) : JHtml::_('jgrid.published', $extraField->published, $key); $values = $json->decode($extraField->value); if (isset($values[0]->alias) && !empty($values[0]->alias)) { $extraField->alias = $values[0]->alias; } else { $filter = JFilterInput::getInstance(); $extraField->alias = $filter->clean($extraField->name, 'WORD'); } } $this->assignRef('rows', $extraFields); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); $this->assignRef('page', $pageNav); $lists = array(); $lists['search'] = $search; $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; $filter_state_options[] = JHTML::_('select.option', -1, JText::_('K2_SELECT_STATE')); $filter_state_options[] = JHTML::_('select.option', 1, JText::_('K2_PUBLISHED')); $filter_state_options[] = JHTML::_('select.option', 0, JText::_('K2_UNPUBLISHED')); $lists['state'] = JHTML::_('select.genericlist', $filter_state_options, 'filter_state', '', 'value', 'text', $filter_state); $extraFieldGroups = $model->getGroups(true); $groups[] = JHTML::_('select.option', '0', JText::_('K2_SELECT_GROUP')); foreach ($extraFieldGroups as $extraFieldGroup) { $groups[] = JHTML::_('select.option', $extraFieldGroup->id, $extraFieldGroup->name); } $lists['group'] = JHTML::_('select.genericlist', $groups, 'filter_group', '', 'value', 'text', $filter_group); $typeOptions[] = JHTML::_('select.option', 0, JText::_('K2_SELECT_TYPE')); $typeOptions[] = JHTML::_('select.option', 'textfield', JText::_('K2_TEXT_FIELD')); $typeOptions[] = JHTML::_('select.option', 'textarea', JText::_('K2_TEXTAREA')); $typeOptions[] = JHTML::_('select.option', 'select', JText::_('K2_DROPDOWN_SELECTION')); $typeOptions[] = JHTML::_('select.option', 'multipleSelect', JText::_('K2_MULTISELECT_LIST')); $typeOptions[] = JHTML::_('select.option', 'radio', JText::_('K2_RADIO_BUTTONS')); $typeOptions[] = JHTML::_('select.option', 'link', JText::_('K2_LINK')); $typeOptions[] = JHTML::_('select.option', 'csv', JText::_('K2_CSV_DATA')); $typeOptions[] = JHTML::_('select.option', 'labels', JText::_('K2_SEARCHABLE_LABELS')); $typeOptions[] = JHTML::_('select.option', 'date', JText::_('K2_DATE')); $typeOptions[] = JHTML::_('select.option', 'image', JText::_('K2_IMAGE')); $typeOptions[] = JHTML::_('select.option', 'header', JText::_('K2_HEADER')); $lists['type'] = JHTML::_('select.genericlist', $typeOptions, 'filter_type', '', 'value', 'text', $filter_type); $this->assignRef('lists', $lists); JToolBarHelper::title(JText::_('K2_EXTRA_FIELDS'), 'k2.png'); JToolBarHelper::publishList(); JToolBarHelper::unpublishList(); JToolBarHelper::deleteList('K2_ARE_YOU_SURE_YOU_WANT_TO_DELETE_SELECTED_EXTRA_FIELDS', 'remove', 'K2_DELETE'); JToolBarHelper::editList(); JToolBarHelper::addNew(); if (K2_JVERSION != '15') { JToolBarHelper::preferences('com_k2', 550, 875, 'K2_PARAMETERS'); } else { $toolbar = JToolBar::getInstance('toolbar'); $toolbar->appendButton('Popup', 'config', 'Parameters', 'index.php?option=com_k2&view=settings'); } $this->loadHelper('html'); K2HelperHTML::subMenu(); $ordering = $this->lists['order'] == 'ordering'; $this->assignRef('ordering', $ordering); // Joomla! 3.0 drag-n-drop sorting variables if (K2_JVERSION == '30') { if ($ordering) { JHtml::_('sortablelist.sortable', 'k2ExtraFieldsList', 'adminForm', strtolower($this->lists['order_Dir']), 'index.php?option=com_k2&view=extrafields&task=saveorder&format=raw'); } $document = JFactory::getDocument(); $document->addScriptDeclaration(' Joomla.orderTable = function() { table = document.getElementById("sortTable"); direction = document.getElementById("directionTable"); order = table.options[table.selectedIndex].value; if (order != \'' . $this->lists['order'] . '\') { dirn = \'asc\'; } else { dirn = direction.options[direction.selectedIndex].value; } Joomla.tableOrdering(order, dirn, ""); }'); } parent::display($tpl); }
function display($tpl = null) { JRequest::setVar('hidemainmenu', 1); JHTML::_('behavior.keepalive'); $model = $this->getModel(); $extraField = $model->getData(); if (!$extraField->id) { $extraField->published = 1; $extraField->alias = ''; $extraField->required = 1; $extraField->showNull = 0; $extraField->displayInFrontEnd = 1; } else { require_once JPATH_COMPONENT . DS . 'lib' . DS . 'JSON.php'; $json = new Services_JSON(); $values = $json->decode($extraField->value); if (isset($values[0]->alias) && !empty($values[0]->alias)) { $extraField->alias = $values[0]->alias; } else { $extraField->alias = $extraField->name; } $searches = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'à', 'á', 'â', 'ã', 'ä', 'å', 'Ā', 'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ç', 'ç', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ð', 'ð', 'Ď', 'ď', 'Đ', 'đ', 'È', 'É', 'Ê', 'Ë', 'è', 'é', 'ê', 'ë', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ', 'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ì', 'Í', 'Î', 'Ï', 'ì', 'í', 'î', 'ï', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ', 'Į', 'į', 'İ', 'ı', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'ĸ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ', 'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ñ', 'ñ', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ŋ', 'ŋ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'Ō', 'ō', 'Ŏ', 'ŏ', 'Ő', 'ő', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ', 'Ş', 'ş', 'Š', 'š', 'ſ', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ù', 'Ú', 'Û', 'Ü', 'ù', 'ú', 'û', 'ü', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ', 'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ý', 'ý', 'ÿ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż', 'ż', 'Ž', 'ž', 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω', 'Α', 'Β', 'Γ', 'Δ', 'Ε', 'Ζ', 'Η', 'Θ', 'Ι', 'Κ', 'Λ', 'Μ', 'Ξ', 'Ο', 'Π', 'Ρ', 'Σ', 'Τ', 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', 'ά', 'έ', 'ή', 'ί', 'ό', 'ύ', 'ώ', 'Ά', 'Έ', 'Ή', 'Ί', 'Ό', 'Ύ', 'Ώ', 'ϊ', 'ΐ', 'ϋ', 'ς', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'А', 'Ӑ', 'Ӓ', 'Ә', 'Ӛ', 'Ӕ', 'Б', 'В', 'Г', 'Ґ', 'Ѓ', 'Ғ', 'Ӷ', 'y', 'Д', 'Е', 'Ѐ', 'Ё', 'Ӗ', 'Ҽ', 'Ҿ', 'Є', 'Ж', 'Ӂ', 'Җ', 'Ӝ', 'З', 'Ҙ', 'Ӟ', 'Ӡ', 'Ѕ', 'И', 'Ѝ', 'Ӥ', 'Ӣ', 'І', 'Ї', 'Ӏ', 'Й', 'Ҋ', 'Ј', 'К', 'Қ', 'Ҟ', 'Ҡ', 'Ӄ', 'Ҝ', 'Л', 'Ӆ', 'Љ', 'М', 'Ӎ', 'Н', 'Ӊ', 'Ң', 'Ӈ', 'Ҥ', 'Њ', 'О', 'Ӧ', 'Ө', 'Ӫ', 'Ҩ', 'П', 'Ҧ', 'Р', 'Ҏ', 'С', 'Ҫ', 'Т', 'Ҭ', 'Ћ', 'Ќ', 'У', 'Ў', 'Ӳ', 'Ӱ', 'Ӯ', 'Ү', 'Ұ', 'Ф', 'Х', 'Ҳ', 'Һ', 'Ц', 'Ҵ', 'Ч', 'Ӵ', 'Ҷ', 'Ӌ', 'Ҹ', 'Џ', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ӹ', 'Ь', 'Ҍ', 'Э', 'Ӭ', 'Ю', 'Я', 'а', 'ӑ', 'ӓ', 'ә', 'ӛ', 'ӕ', 'б', 'в', 'г', 'ґ', 'ѓ', 'ғ', 'ӷ', 'y', 'д', 'е', 'ѐ', 'ё', 'ӗ', 'ҽ', 'ҿ', 'є', 'ж', 'ӂ', 'җ', 'ӝ', 'з', 'ҙ', 'ӟ', 'ӡ', 'ѕ', 'и', 'ѝ', 'ӥ', 'ӣ', 'і', 'ї', 'Ӏ', 'й', 'ҋ', 'ј', 'к', 'қ', 'ҟ', 'ҡ', 'ӄ', 'ҝ', 'л', 'ӆ', 'љ', 'м', 'ӎ', 'н', 'ӊ', 'ң', 'ӈ', 'ҥ', 'њ', 'о', 'ӧ', 'ө', 'ӫ', 'ҩ', 'п', 'ҧ', 'р', 'ҏ', 'с', 'ҫ', 'т', 'ҭ', 'ћ', 'ќ', 'у', 'ў', 'ӳ', 'ӱ', 'ӯ', 'ү', 'ұ', 'ф', 'х', 'ҳ', 'һ', 'ц', 'ҵ', 'ч', 'ӵ', 'ҷ', 'ӌ', 'ҹ', 'џ', 'ш', 'щ', 'ъ', 'ы', 'ӹ', 'ь', 'ҍ', 'э', 'ӭ', 'ю', 'я'); $replacements = array('A', 'A', 'A', 'A', 'A', 'A', 'a', 'a', 'a', 'a', 'a', 'a', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'D', 'd', 'E', 'E', 'E', 'E', 'e', 'e', 'e', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'I', 'I', 'I', 'i', 'i', 'i', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'J', 'j', 'K', 'k', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'N', 'n', 'O', 'O', 'O', 'O', 'O', 'O', 'o', 'o', 'o', 'o', 'o', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'U', 'U', 'U', 'u', 'u', 'u', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'y', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 'a', 'b', 'g', 'd', 'e', 'z', 'h', 'th', 'i', 'k', 'l', 'm', 'n', 'x', 'o', 'p', 'r', 's', 't', 'y', 'f', 'ch', 'ps', 'w', 'A', 'B', 'G', 'D', 'E', 'Z', 'H', 'Th', 'I', 'K', 'L', 'M', 'X', 'O', 'P', 'R', 'S', 'T', 'Y', 'F', 'Ch', 'Ps', 'W', 'a', 'e', 'h', 'i', 'o', 'y', 'w', 'A', 'E', 'H', 'I', 'O', 'Y', 'W', 'i', 'i', 'y', 's', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Zero', 'A', 'A', 'A', 'E', 'E', 'E', 'B', 'V', 'G', 'G', 'G', 'G', 'G', 'Y', 'D', 'E', 'E', 'YO', 'E', 'E', 'E', 'YE', 'ZH', 'DZH', 'ZH', 'DZH', 'Z', 'Z', 'DZ', 'DZ', 'DZ', 'I', 'I', 'I', 'I', 'I', 'JI', 'I', 'Y', 'Y', 'J', 'K', 'Q', 'Q', 'K', 'Q', 'K', 'L', 'L', 'L', 'M', 'M', 'N', 'N', 'N', 'N', 'N', 'N', 'O', 'O', 'O', 'O', 'O', 'P', 'PF', 'P', 'P', 'S', 'S', 'T', 'TH', 'T', 'K', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'F', 'H', 'H', 'H', 'TS', 'TS', 'CH', 'CH', 'CH', 'CH', 'CH', 'DZ', 'SH', 'SHT', 'A', 'Y', 'Y', 'Y', 'Y', 'E', 'E', 'YU', 'YA', 'a', 'a', 'a', 'e', 'e', 'e', 'b', 'v', 'g', 'g', 'g', 'g', 'g', 'y', 'd', 'e', 'e', 'yo', 'e', 'e', 'e', 'ye', 'zh', 'dzh', 'zh', 'dzh', 'z', 'z', 'dz', 'dz', 'dz', 'i', 'i', 'i', 'i', 'i', 'ji', 'i', 'y', 'y', 'j', 'k', 'q', 'q', 'k', 'q', 'k', 'l', 'l', 'l', 'm', 'm', 'n', 'n', 'n', 'n', 'n', 'n', 'o', 'o', 'o', 'o', 'o', 'p', 'pf', 'p', 'p', 's', 's', 't', 'th', 't', 'k', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'f', 'h', 'h', 'h', 'ts', 'ts', 'ch', 'ch', 'ch', 'ch', 'ch', 'dz', 'sh', 'sht', 'a', 'y', 'y', 'y', 'y', 'e', 'e', 'yu', 'ya'); $extraField->alias = str_replace($searches, $replacements, $extraField->alias); $filter = JFilterInput::getInstance(); $extraField->alias = $filter->clean($extraField->alias, 'WORD'); if (isset($values[0]->required)) { $extraField->required = $values[0]->required; } else { $extraField->required = 0; } if (isset($values[0]->showNull)) { $extraField->showNull = $values[0]->showNull; } else { $extraField->showNull = 0; } if (isset($values[0]->displayInFrontEnd)) { $extraField->displayInFrontEnd = $values[0]->displayInFrontEnd; } else { $extraField->displayInFrontEnd = 0; } } $extraField->name = htmlspecialchars($extraField->name, ENT_QUOTES, 'UTF-8'); $this->assignRef('row', $extraField); $lists = array(); $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $extraField->published); $groups[] = JHTML::_('select.option', 0, JText::_('K2_CREATE_NEW_GROUP')); $extraFieldModel = K2Model::getInstance('ExtraFields', 'K2Model'); $uniqueGroups = $extraFieldModel->getGroups(true); foreach ($uniqueGroups as $group) { $groups[] = JHTML::_('select.option', $group->id, $group->name); } $lists['group'] = JHTML::_('select.genericlist', $groups, 'groups', '', 'value', 'text', $extraField->group); $typeOptions[] = JHTML::_('select.option', 0, JText::_('K2_SELECT_TYPE')); $typeOptions[] = JHTML::_('select.option', 'textfield', JText::_('K2_TEXT_FIELD')); $typeOptions[] = JHTML::_('select.option', 'textarea', JText::_('K2_TEXTAREA')); $typeOptions[] = JHTML::_('select.option', 'select', JText::_('K2_DROPDOWN_SELECTION')); $typeOptions[] = JHTML::_('select.option', 'multipleSelect', JText::_('K2_MULTISELECT_LIST')); $typeOptions[] = JHTML::_('select.option', 'radio', JText::_('K2_RADIO_BUTTONS')); $typeOptions[] = JHTML::_('select.option', 'link', JText::_('K2_LINK')); $typeOptions[] = JHTML::_('select.option', 'csv', JText::_('K2_CSV_DATA')); $typeOptions[] = JHTML::_('select.option', 'labels', JText::_('K2_SEARCHABLE_LABELS')); $typeOptions[] = JHTML::_('select.option', 'date', JText::_('K2_DATE')); $typeOptions[] = JHTML::_('select.option', 'image', JText::_('K2_IMAGE')); $typeOptions[] = JHTML::_('select.option', 'header', JText::_('K2_HEADER')); $lists['type'] = JHTML::_('select.genericlist', $typeOptions, 'type', '', 'value', 'text', $extraField->type); $this->assignRef('lists', $lists); JRequest::getInt('cid') ? $title = JText::_('K2_EDIT_EXTRA_FIELD') : ($title = JText::_('K2_ADD_EXTRA_FIELD')); JToolBarHelper::title($title, 'k2.png'); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JHTML::_('behavior.calendar'); $document = JFactory::getDocument(); $document->addScriptDeclaration(' var K2BasePath = "' . JURI::base(true) . '/"; var K2Language = [ "' . JText::_('K2_REMOVE', true) . '", "' . JText::_('K2_OPTIONAL', true) . '", "' . JText::_('K2_COMMA_SEPARATED_VALUES', true) . '", "' . JText::_('K2_USE_EDITOR', true) . '", "' . JText::_('K2_ALL_SETTINGS_ABOVE_ARE_OPTIONAL', true) . '", "' . JText::_('K2_ADD_AN_OPTION', true) . '", "' . JText::_('K2_LINK_TEXT', true) . '", "' . JText::_('K2_URL', true) . '", "' . JText::_('K2_OPEN_IN', true) . '", "' . JText::_('K2_SAME_WINDOW', true) . '", "' . JText::_('K2_NEW_WINDOW', true) . '", "' . JText::_('K2_CLASSIC_JAVASCRIPT_POPUP', true) . '", "' . JText::_('K2_LIGHTBOX_POPUP', true) . '", "' . JText::_('K2_RESET_VALUE', true) . '", "' . JText::_('K2_CALENDAR', true) . '", "' . JText::_('K2_PLEASE_SELECT_A_FIELD_TYPE_FROM_THE_LIST_ABOVE', true) . '", "' . JText::_('K2_COLUMNS', true) . '", "' . JText::_('K2_ROWS', true) . '", ];'); JHTML::_('behavior.modal'); parent::display($tpl); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $db = JFactory::getDBO(); $view = JRequest::getCmd('view'); jimport('joomla.filesystem.file'); jimport('joomla.html.pane'); JHTML::_('behavior.keepalive'); JHTML::_('behavior.modal'); JRequest::setVar('hidemainmenu', 1); $document = JFactory::getDocument(); $document->addScript(JURI::root(true) . '/media/k2/assets/js/nicEdit.js?v=2.6.8'); //var K2SitePath = '".JURI::root(true)."/'; $js = "\n\t\t\t\t\tvar K2BasePath = '" . JURI::base(true) . "/';\n\t\t\t\t\tvar K2Language = [\n\t\t\t\t\t\t'" . JText::_('K2_REMOVE', true) . "',\n\t\t\t\t\t\t'" . JText::_('K2_LINK_TITLE_OPTIONAL', true) . "',\n\t\t\t\t\t\t'" . JText::_('K2_LINK_TITLE_ATTRIBUTE_OPTIONAL', true) . "',\n\t\t\t\t\t\t'" . JText::_('K2_ARE_YOU_SURE', true) . "',\n\t\t\t\t\t\t'" . JText::_('K2_YOU_ARE_NOT_ALLOWED_TO_POST_TO_THIS_CATEGORY', true) . "',\n\t\t\t\t\t\t'" . JText::_('K2_OR_SELECT_A_FILE_ON_THE_SERVER', true) . "'\n\t\t\t\t\t]\n\t\t\t\t"; $document->addScriptDeclaration($js); K2Model::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models'); $model = K2Model::getInstance('Item', 'K2Model', array('table_path' => JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables')); $item = $model->getData(); JFilterOutput::objectHTMLSafe($item, ENT_QUOTES, array('video', 'params', 'plugins')); $user = JFactory::getUser(); // Permissions check on frontend if ($mainframe->isSite()) { JLoader::register('K2HelperPermissions', JPATH_COMPONENT . DS . 'helpers' . DS . 'permissions.php'); $task = JRequest::getCmd('task'); if ($task == 'edit' && !K2HelperPermissions::canEditItem($item->created_by, $item->catid)) { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); } if ($task == 'add' && !K2HelperPermissions::canAddItem()) { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); } // Get permissions $K2Permissions = K2Permissions::getInstance(); $this->assignRef('permissions', $K2Permissions->permissions); // Build permissions message $permissionsLabels = array(); if ($this->permissions->get('add')) { $permissionsLabels[] = JText::_('K2_ADD_ITEMS'); } if ($this->permissions->get('editOwn')) { $permissionsLabels[] = JText::_('K2_EDIT_OWN_ITEMS'); } if ($this->permissions->get('editAll')) { $permissionsLabels[] = JText::_('K2_EDIT_ANY_ITEM'); } if ($this->permissions->get('publish')) { $permissionsLabels[] = JText::_('K2_PUBLISH_ITEMS'); } if ($this->permissions->get('editPublished')) { $permissionsLabels[] = JText::_('K2_ALLOW_EDITING_OF_ALREADY_PUBLISHED_ITEMS'); } $permissionsMessage = JText::_('K2_YOU_ARE_ALLOWED_TO') . ' ' . implode(', ', $permissionsLabels); $this->assignRef('permissionsMessage', $permissionsMessage); } if ($item->isCheckedOut($user->get('id'), $item->checked_out)) { $message = JText::_('K2_THE_ITEM') . ': ' . $item->title . ' ' . JText::_('K2_IS_CURRENTLY_BEING_EDITED_BY_ANOTHER_ADMINISTRATOR'); $url = $mainframe->isSite() ? 'index.php?option=com_k2&view=item&id=' . $item->id . '&tmpl=component' : 'index.php?option=com_k2'; $mainframe->enqueueMessage($message); $mainframe->redirect($url); } if ($item->id) { $item->checkout($user->get('id')); } else { $item->published = 1; $item->publish_down = $db->getNullDate(); $item->modified = $db->getNullDate(); $date = JFactory::getDate(); $now = K2_JVERSION == '15' ? $date->toMySQL() : $date->toSql(); $item->created = $now; $item->publish_up = $item->created; } $lists = array(); if (version_compare(JVERSION, '1.6.0', 'ge')) { $dateFormat = 'Y-m-d H:i:s'; } else { $dateFormat = '%Y-%m-%d %H:%M:%S'; } $created = $item->created; $publishUp = $item->publish_up; $publishDown = $item->publish_down; $created = JHTML::_('date', $item->created, $dateFormat); $publishUp = JHTML::_('date', $item->publish_up, $dateFormat); if ((int) $item->publish_down) { $publishDown = JHTML::_('date', $item->publish_down, $dateFormat); } else { $publishDown = ''; } // Set up calendars $lists['createdCalendar'] = JHTML::_('calendar', $created, 'created', 'created'); $lists['publish_up'] = JHTML::_('calendar', $publishUp, 'publish_up', 'publish_up'); $lists['publish_down'] = JHTML::_('calendar', $publishDown, 'publish_down', 'publish_down'); if ($item->id) { $lists['created'] = JHTML::_('date', $item->created, JText::_('DATE_FORMAT_LC2')); } else { $lists['created'] = JText::_('K2_NEW_DOCUMENT'); } if ($item->modified == $db->getNullDate() || !$item->id) { $lists['modified'] = JText::_('K2_NEVER'); } else { $lists['modified'] = JHTML::_('date', $item->modified, JText::_('DATE_FORMAT_LC2')); } $params = JComponentHelper::getParams('com_k2'); $wysiwyg = JFactory::getEditor(); $onSave = ''; if ($params->get("mergeEditors")) { if (JString::strlen($item->fulltext) > 1) { $textValue = $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext; } else { $textValue = $item->introtext; } $text = $wysiwyg->display('text', $textValue, '100%', '400px', '', ''); $this->assignRef('text', $text); if (K2_JVERSION == '30') { $onSave = $wysiwyg->save('text'); } } else { $introtext = $wysiwyg->display('introtext', $item->introtext, '100%', '400px', '', '', array('readmore')); $this->assignRef('introtext', $introtext); $fulltext = $wysiwyg->display('fulltext', $item->fulltext, '100%', '400px', '', '', array('readmore')); $this->assignRef('fulltext', $fulltext); if (K2_JVERSION == '30') { $onSave = $wysiwyg->save('introtext'); $onSave .= $wysiwyg->save('fulltext'); } } $document->addScriptDeclaration("function onK2EditorSave(){ " . $onSave . " }"); $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $item->published); $lists['featured'] = JHTML::_('select.booleanlist', 'featured', 'class="inputbox"', $item->featured); $lists['access'] = version_compare(JVERSION, '3.0', 'ge') ? JHTML::_('access.level', 'access', $item->access) : JHTML::_('list.accesslevel', $item); $query = "SELECT ordering AS value, title AS text FROM #__k2_items WHERE catid={$item->catid}"; $lists['ordering'] = version_compare(JVERSION, '3.0', 'ge') ? NUll : JHTML::_('list.specificordering', $item, $item->id, $query); if (!$item->id) { $item->catid = $mainframe->getUserStateFromRequest('com_k2itemsfilter_category', 'catid', 0, 'int'); } require_once JPATH_ADMINISTRATOR . '/components/com_k2/models/categories.php'; $categoriesModel = K2Model::getInstance('Categories', 'K2Model'); $categories = $categoriesModel->categoriesTree(); $lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox"', 'value', 'text', $item->catid); if (version_compare(JVERSION, '1.6.0', 'ge')) { $languages = JHTML::_('contentlanguage.existing', true, true); $lists['language'] = JHTML::_('select.genericlist', $languages, 'language', '', 'value', 'text', $item->language); } $lists['checkSIG'] = $model->checkSIG(); $lists['checkAllVideos'] = $model->checkAllVideos(); $remoteVideo = false; $providerVideo = false; $embedVideo = false; if (stristr($item->video, 'remote}') !== false) { $remoteVideo = true; $options['startOffset'] = 1; } $providers = $model->getVideoProviders(); if (count($providers)) { foreach ($providers as $provider) { $providersOptions[] = JHTML::_('select.option', $provider, ucfirst($provider)); if (stristr($item->video, "{{$provider}}") !== false) { $providerVideo = true; $options['startOffset'] = 2; } } } if (JString::substr($item->video, 0, 1) !== '{') { $embedVideo = true; $options['startOffset'] = 3; } $lists['uploadedVideo'] = !$remoteVideo && !$providerVideo && !$embedVideo ? true : false; if ($lists['uploadedVideo'] || $item->video == '') { $options['startOffset'] = 0; } $document->addScriptDeclaration("var K2ActiveVideoTab = " . $options['startOffset']); $lists['remoteVideo'] = $remoteVideo ? preg_replace('%\\{[a-z0-9-_]*\\}(.*)\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : ''; $lists['remoteVideoType'] = $remoteVideo ? preg_replace('%\\{([a-z0-9-_]*)\\}.*\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : ''; $lists['providerVideo'] = $providerVideo ? preg_replace('%\\{[a-z0-9-_]*\\}(.*)\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : ''; $lists['providerVideoType'] = $providerVideo ? preg_replace('%\\{([a-z0-9-_]*)\\}.*\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : ''; $lists['embedVideo'] = $embedVideo ? $item->video : ''; if (isset($providersOptions)) { $lists['providers'] = JHTML::_('select.genericlist', $providersOptions, 'videoProvider', '', 'value', 'text', $lists['providerVideoType']); } JPluginHelper::importPlugin('content', 'jw_sigpro'); JPluginHelper::importPlugin('content', 'jw_allvideos'); $dispatcher = JDispatcher::getInstance(); // Detect gallery type if (JString::strpos($item->gallery, 'http://')) { $item->galleryType = 'flickr'; $item->galleryValue = JString::substr($item->gallery, 9); $item->galleryValue = JString::substr($item->galleryValue, 0, -10); } else { $item->galleryType = 'server'; $item->galleryValue = ''; } $params->set('galleries_rootfolder', 'media/k2/galleries'); $item->text = $item->gallery; if (K2_JVERSION == '15') { $dispatcher->trigger('onPrepareContent', array(&$item, &$params, null)); } else { $dispatcher->trigger('onContentPrepare', array('com_k2.' . $view, &$item, &$params, null)); } $item->gallery = $item->text; if (!$embedVideo) { $params->set('vfolder', 'media/k2/videos'); $params->set('afolder', 'media/k2/audio'); if (JString::strpos($item->video, 'remote}')) { preg_match("#}(.*?){/#s", $item->video, $matches); if (JString::substr($matches[1], 0, 7) != 'http://') { $item->video = str_replace($matches[1], JURI::root() . $matches[1], $item->video); } } $item->text = $item->video; if (K2_JVERSION == '15') { $dispatcher->trigger('onPrepareContent', array(&$item, &$params, null)); } else { $dispatcher->trigger('onContentPrepare', array('com_k2.' . $view, &$item, &$params, null)); } $item->video = $item->text; } else { // no nothing } if (isset($item->created_by)) { $author = JUser::getInstance($item->created_by); $item->author = $author->name; } else { $item->author = $user->name; } if (isset($item->modified_by)) { $moderator = JUser::getInstance($item->modified_by); $item->moderator = $moderator->name; } if ($item->id) { $active = $item->created_by; } else { $active = $user->id; } $lists['authors'] = JHTML::_('list.users', 'created_by', $active, false); $categories_option[] = JHTML::_('select.option', 0, JText::_('K2_SELECT_CATEGORY')); $categories = $categoriesModel->categoriesTree(NUll, true, false); if ($mainframe->isSite()) { JLoader::register('K2HelperPermissions', JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'permissions.php'); if (($task == 'add' || $task == 'edit') && !K2HelperPermissions::canAddToAll()) { for ($i = 0; $i < sizeof($categories); $i++) { if (!K2HelperPermissions::canAddItem($categories[$i]->value) && $task == 'add') { $categories[$i]->disable = true; } if (!K2HelperPermissions::canEditItem($item->created_by, $categories[$i]->value) && $task == 'edit') { $categories[$i]->disable = true; } } } } $categories_options = @array_merge($categories_option, $categories); $lists['categories'] = JHTML::_('select.genericlist', $categories_options, 'catid', '', 'value', 'text', $item->catid); JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables'); $category = JTable::getInstance('K2Category', 'Table'); $category->load($item->catid); $extraFieldModel = K2Model::getInstance('ExtraField', 'K2Model'); if ($category->id) { $extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup); } else { $extraFields = NULL; } for ($i = 0; $i < sizeof($extraFields); $i++) { $extraFields[$i]->element = $extraFieldModel->renderExtraField($extraFields[$i], $item->id); } if ($item->id) { $item->attachments = $model->getAttachments($item->id); $rating = $model->getRating(); if (is_null($rating)) { $item->ratingSum = 0; $item->ratingCount = 0; } else { $item->ratingSum = (int) $rating->rating_sum; $item->ratingCount = (int) $rating->rating_count; } } else { $item->attachments = NULL; $item->ratingSum = 0; $item->ratingCount = 0; } if ($user->gid < 24 && $params->get('lockTags')) { $params->set('taggingSystem', 0); } $tags = $model->getAvailableTags($item->id); $lists['tags'] = JHTML::_('select.genericlist', $tags, 'tags', 'multiple="multiple" size="10" ', 'id', 'name'); if (isset($item->id)) { $item->tags = $model->getCurrentTags($item->id); $lists['selectedTags'] = JHTML::_('select.genericlist', $item->tags, 'selectedTags[]', 'multiple="multiple" size="10" ', 'id', 'name'); } else { $lists['selectedTags'] = '<select size="10" multiple="multiple" id="selectedTags" name="selectedTags[]"></select>'; } $lists['metadata'] = class_exists('JParameter') ? new JParameter($item->metadata) : new JRegistry($item->metadata); $date = JFactory::getDate($item->modified); $timestamp = '?t=' . $date->toUnix(); if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) { $item->image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg' . $timestamp; } if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) { $item->thumb = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg' . $timestamp; } JPluginHelper::importPlugin('k2'); $dispatcher = JDispatcher::getInstance(); $K2PluginsItemContent = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'content')); $this->assignRef('K2PluginsItemContent', $K2PluginsItemContent); $K2PluginsItemImage = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'image')); $this->assignRef('K2PluginsItemImage', $K2PluginsItemImage); $K2PluginsItemGallery = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'gallery')); $this->assignRef('K2PluginsItemGallery', $K2PluginsItemGallery); $K2PluginsItemVideo = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'video')); $this->assignRef('K2PluginsItemVideo', $K2PluginsItemVideo); $K2PluginsItemExtraFields = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'extra-fields')); $this->assignRef('K2PluginsItemExtraFields', $K2PluginsItemExtraFields); $K2PluginsItemAttachments = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'attachments')); $this->assignRef('K2PluginsItemAttachments', $K2PluginsItemAttachments); $K2PluginsItemOther = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'other')); $this->assignRef('K2PluginsItemOther', $K2PluginsItemOther); if (version_compare(JVERSION, '1.6.0', 'ge')) { jimport('joomla.form.form'); $form = JForm::getInstance('itemForm', JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'item.xml'); $values = array('params' => json_decode($item->params)); $form->bind($values); } else { $form = new JParameter('', JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'item.xml'); $form->loadINI($item->params); } $this->assignRef('form', $form); $nullDate = $db->getNullDate(); $this->assignRef('nullDate', $nullDate); $this->assignRef('extraFields', $extraFields); $this->assignRef('options', $options); $this->assignRef('row', $item); $this->assignRef('lists', $lists); $this->assignRef('params', $params); $this->assignRef('user', $user); JRequest::getInt('cid') ? $title = JText::_('K2_EDIT_ITEM') : ($title = JText::_('K2_ADD_ITEM')); $this->assignRef('title', $title); $this->assignRef('mainframe', $mainframe); if ($mainframe->isAdmin()) { $this->params->set('showImageTab', true); $this->params->set('showImageGalleryTab', true); $this->params->set('showVideoTab', true); $this->params->set('showExtraFieldsTab', true); $this->params->set('showAttachmentsTab', true); $this->params->set('showK2Plugins', true); JToolBarHelper::title($title, 'k2.png'); JToolBarHelper::save(); $saveNewIcon = version_compare(JVERSION, '2.5.0', 'ge') ? 'save-new.png' : 'save.png'; JToolBarHelper::custom('saveAndNew', $saveNewIcon, 'save_f2.png', 'K2_SAVE_AND_NEW', false); JToolBarHelper::apply(); JToolBarHelper::cancel(); } // ACE ACL integration $definedConstants = get_defined_constants(); if (!empty($definedConstants['ACEACL']) && AceaclApi::authorize('permissions', 'com_aceacl')) { $aceAclFlag = true; } else { $aceAclFlag = false; } $this->assignRef('aceAclFlag', $aceAclFlag); // SIG PRO v3 integration if (JPluginHelper::isEnabled('k2', 'jw_sigpro')) { $sigPro = true; $sigProFolder = $this->row->id ? $this->row->id : uniqid(); $this->assignRef('sigProFolder', $sigProFolder); } else { $sigPro = false; } $this->assignRef('sigPro', $sigPro); parent::display($tpl); }