File manager - Edit - /home/opticamezl/www/newok/com_weblinks.zip
Back
PK 9�\��oF F com_weblinks.xmlnu &1i� <?xml version="1.0" encoding="iso-8859-1"?> <extension type="plugin" group="osmap" version="1.6" method="upgrade"> <name>OSMap - WebLinks Plugin</name> <author>Alledia</author> <creationDate>March 10 2016</creationDate> <copyright>Copyright (C) 2016 Open Source Training, LLC. All rights reserved. / Forked from XMap - Guillermo Vargas - guille@vargas.co.cr</copyright> <license>GNU General Public License version 2 or later; see LICENSE.txt</license> <authorEmail>support@alledia.com</authorEmail> <authorUrl>http://www.alledia.com</authorUrl> <version>3.3.0</version> <description>OSMAP_WL_PLUGIN_DESCRIPTION</description> <files> <filename plugin="com_weblinks">com_weblinks.php</filename> </files> <languages folder="language"> <!-- these files will be installed in the administrator/language folder. --> <language tag="en-GB">en-GB.plg_osmap_com_weblinks.ini</language> </languages> <config> <fields name="params"> <fieldset name="basic"> <field name="include_links" type="list" default="1" label="OSMAP_WL_SETTING_SHOW_LINKS_LABEL" description="OSMAP_WL_SETTING_SHOW_LINKS_DESC"> <option value="0">OSMAP_OPTION_NEVER</option> <option value="1">OSMAP_OPTION_ALWAYS</option> <option value="2">OSMAP_OPTION_XML_ONLY</option> <option value="3">OSMAP_OPTION_HTML_ONLY</option> </field> <field name="max_links" type="text" default="" label="OSMAP_WL_SETTING_MAX_LINKS_LABEL" description="OSMAP_WL_SETTING_MAX_LINKS_DESC" /> </fieldset> <fieldset name="xml"> <field name="cat_priority" type="list" default="-1" label="OSMAP_WL_CATEGORY_PRIORITY_LABEL" description="OSMAP_WL_CATEGORY_PRIORITY_DESC"> <option value="-1">OSMAP_OPTION_USE_PARENT_MENU</option> <option value="0.0">0.0</option> <option value="0.1">0.1</option> <option value="0.2">0.2</option> <option value="0.3">0.3</option> <option value="0.4">0.4</option> <option value="0.5">0.5</option> <option value="0.6">0.6</option> <option value="0.7">0.7</option> <option value="0.8">0.8</option> <option value="0.9">0.9</option> <option value="1">1</option> </field> <field name="cat_changefreq" type="list" default="-1" label="OSMAP_WL_CATEGORY_CHANGEFREQ_LABEL" description="OSMAP_WL_CATEGORY_CHANGEFREQ_DESC"> <option value="-1">OSMAP_OPTION_USE_PARENT_MENU</option> <option value="always">OSMAP_OPTION_ALWAYS</option> <option value="hourly">OSMAP_OPTION_HOURLY</option> <option value="daily">OSMAP_OPTION_DAILY</option> <option value="weekly">OSMAP_OPTION_WEEKLY</option> <option value="monthly">OSMAP_OPTION_MONTHLY</option> <option value="yearly">OSMAP_OPTION_YEARLY</option> <option value="never">OSMAP_OPTION_NEVER</option> </field> <field name="link_priority" type="list" default="-1" label="OSMAP_WL_LINK_PRIORITY_LABEL" description="OSMAP_WL_LINK_PRIORITY_DESC"> <option value="-1">OSMAP_OPTION_USE_PARENT_MENU</option> <option value="0.0">0.0</option> <option value="0.2">0.2</option> <option value="0.3">0.3</option> <option value="0.4">0.4</option> <option value="0.5">0.5</option> <option value="0.6">0.6</option> <option value="0.7">0.7</option> <option value="0.8">0.8</option> <option value="0.9">0.9</option> <option value="1">1</option> </field> <field name="link_changefreq" type="list" default="-1" label="OSMAP_WL_LINK_CHANGEFREQ_LABEL" description="OSMAP_WL_LINK_CHANGEFREQ_DESC"> <option value="-1">OSMAP_OPTION_USE_PARENT_MENU</option> <option value="always">OSMAP_OPTION_ALWAYS</option> <option value="hourly">OSMAP_OPTION_HOURLY</option> <option value="daily">OSMAP_OPTION_DAILY</option> <option value="weekly">OSMAP_OPTION_WEEKLY</option> <option value="monthly">OSMAP_OPTION_MONTHLY</option> <option value="yearly">OSMAP_OPTION_YEARLY</option> <option value="never">OSMAP_OPTION_NEVER</option> </field> </fieldset> </fields> </config> </extension> PK 9�\�ܻ�J J com_weblinks.phpnu &1i� <?php /** * @package OSMap * @copyright 2007-2014 XMap - Joomla! Vargas. All rights reserved. * @copyright 2016 Open Source Training, LLC. All rights reserved.. * @author Guillermo Vargas <guille@vargas.co.cr> * @author Alledia <support@alledia.com> * @license GNU General Public License version 2 or later; see LICENSE.txt * * This file is part of OSMap. * * OSMap is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * any later version. * * OSMap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OSMap. If not, see <http://www.gnu.org/licenses/>. */ defined('_JEXEC') or die('Restricted access'); class osmap_com_weblinks { private static $views = array('categories', 'category'); private static $enabled = null; private static $instance = null; public function __construct() { if (static::isEnabled()) { JLoader::register('WeblinksHelperRoute', JPATH_SITE . '/components/com_weblinks/helpers/route.php'); } } public static function getInstance() { if (empty(static::$instance)) { $instance = new self; static::$instance = $instance; } return static::$instance; } public function getTree($osmap, $parent, &$params) { $uri = new JUri($parent->link); if (!static::isEnabled() || !in_array($uri->getVar('view'), static::$views)) { return; } $params['groups'] = implode(',', JFactory::getUser()->getAuthorisedViewLevels()); $params['language_filter'] = JFactory::getApplication()->getLanguageFilter(); $params['include_links'] = JArrayHelper::getValue($params, 'include_links', 1); $params['include_links'] = ($params['include_links'] == 1 || ($params['include_links'] == 2 && $osmap->view == 'xml') || ($params['include_links'] == 3 && $osmap->view == 'html')); $params['show_unauth'] = JArrayHelper::getValue($params, 'show_unauth', 0); $params['show_unauth'] = ($params['show_unauth'] == 1 || ($params['show_unauth'] == 2 && $osmap->view == 'xml') || ($params['show_unauth'] == 3 && $osmap->view == 'html')); $params['category_priority'] = JArrayHelper::getValue($params, 'category_priority', $parent->priority); $params['category_changefreq'] = JArrayHelper::getValue($params, 'category_changefreq', $parent->changefreq); if ($params['category_priority'] == -1) { $params['category_priority'] = $parent->priority; } if ($params['category_changefreq'] == -1) { $params['category_changefreq'] = $parent->changefreq; } $params['link_priority'] = JArrayHelper::getValue($params, 'link_priority', $parent->priority); $params['link_changefreq'] = JArrayHelper::getValue($params, 'link_changefreq', $parent->changefreq); if ($params['link_priority'] == -1) { $params['link_priority'] = $parent->priority; } if ($params['link_changefreq'] == -1) { $params['link_changefreq'] = $parent->changefreq; } switch ($uri->getVar('view')) { case 'categories': static::getCategoryTree($osmap, $parent, $params, $uri->getVar('id')); break; case 'category': static::getlinks($osmap, $parent, $params, $uri->getVar('id')); break; } } private static function getCategoryTree(&$osmap, &$parent, &$params, $parent_id) { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select(array('c.id', 'c.alias', 'c.title', 'c.parent_id, params, metadata')) ->from('#__categories AS c') ->where('c.parent_id = ' . $db->quote($parent_id ? $parent_id : 1)) ->where('c.extension = ' . $db->quote('com_weblinks')) ->where('c.published = 1') ->order('c.lft'); if (!$params['show_unauth']) { $query->where('c.access IN(' . $params['groups'] . ')'); } if ($params['language_filter']) { $query->where('c.language IN(' . $db->quote(JFactory::getLanguage()->getTag()) . ', ' . $db->quote('*') . ')'); } $db->setQuery($query); $rows = $db->loadObjectList(); if (empty($rows)) { return; } $osmap->changeLevel(1); foreach ($rows as $row) { if (OSMAP_LICENSE === 'pro') { $content = new Alledia\OSMap\Pro\Joomla\Item($row); if (!$content->isVisibleForRobots()) { continue; } } $node = new stdclass; $node->id = $parent->id; $node->name = $row->title; $node->uid = $parent->uid . '_cid_' . $row->id; $node->browserNav = $parent->browserNav; $node->priority = $params['category_priority']; $node->changefreq = $params['category_changefreq']; $node->pid = $row->parent_id; $node->link = WeblinksHelperRoute::getCategoryRoute($row->id); if ($osmap->printNode($node) !== false) { static::getlinks($osmap, $parent, $params, $row->id); } } $osmap->changeLevel(-1); } private static function getlinks(&$osmap, &$parent, &$params, $catid) { static::getCategoryTree($osmap, $parent, $params, $catid); if (!$params['include_links']) { return; } $db = JFactory::getDbo(); $now = JFactory::getDate('now', 'UTC')->toSql(); $query = $db->getQuery(true) ->select(array('w.id', 'w.alias', 'w.title', 'params', 'metadata')) ->from('#__weblinks AS w') ->where('w.catid = ' . $db->Quote($catid)) ->where('w.state = 1') ->where('(w.publish_up = ' . $db->quote($db->getNullDate()) . ' OR w.publish_up <= ' . $db->quote($now) . ')') ->where('(w.publish_down = ' . $db->quote($db->getNullDate()) . ' OR w.publish_down >= ' . $db->quote($now) . ')') ->order('w.ordering'); if (!$params['show_unauth']) { $query->where('w.access IN(' . $params['groups'] . ')'); } if ($params['language_filter']) { $query->where('w.language IN(' . $db->quote(JFactory::getLanguage()->getTag()) . ', ' . $db->quote('*') . ')'); } $db->setQuery($query); $rows = $db->loadObjectList(); if (empty($rows)) { return; } $osmap->changeLevel(1); foreach ($rows as $row) { if (OSMAP_LICENSE === 'pro') { $content = new Alledia\OSMap\Pro\Joomla\Item($row); if (!$content->isVisibleForRobots()) { continue; } } $node = new stdclass; $node->id = $parent->id; $node->name = $row->title; $node->uid = $parent->uid . '_' . $row->id; $node->browserNav = $parent->browserNav; $node->priority = $params['link_priority']; $node->changefreq = $params['link_changefreq']; $node->link = WeblinksHelperRoute::getWeblinkRoute($row->id . ':' . $row->alias, $catid); $osmap->printNode($node); } $osmap->changeLevel(-1); } protected static function isEnabled() { if (null === static::$enabled) { $db = JFactory::getDbo(); $db->setQuery('Select enabled From #__extensions Where name=' . $db->quote('com_weblinks')); static::$enabled = (bool)$db->loadResult(); } return static::$enabled; } } PK ��\����' ' src/Model/FormModel.phpnu �[��� <?php /** * @package Joomla.Site * @subpackage com_weblinks * * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Weblinks\Site\Model; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; use Joomla\CMS\Uri\Uri; use Joomla\Component\Weblinks\Administrator\Model\WeblinkModel; /** * Weblinks model. * * @since 1.6 */ class FormModel extends WeblinkModel { /** * Model typeAlias string. Used for version history. * * @var string * @since 3.2 */ public $typeAlias = 'com_weblinks.weblink'; /** * Get the return URL. * * @return string The return URL. * * @since 1.6 */ public function getReturnPage() { return base64_encode($this->getState('return_page', '')); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * * @since 1.6 */ protected function populateState() { $app = Factory::getApplication(); // Load state from the request. $pk = $app->getInput()->getInt('w_id'); $this->setState('weblink.id', $pk); // Add compatibility variable for default naming conventions. $this->setState('form.id', $pk); $categoryId = $app->getInput()->getInt('catid'); $this->setState('weblink.catid', $categoryId); $return = $app->getInput()->get('return', '', 'base64'); if ($return && !Uri::isInternal(base64_decode($return))) { $return = ''; } $this->setState('return_page', base64_decode($return)); // Load the parameters. $params = $app->getParams(); $this->setState('params', $params); $this->setState('layout', $app->getInput()->getString('layout')); } /** * Abstract method for getting the form from the model. * * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * * @return mixed A JForm object on success, false on failure * * @since __DEPLOY_VERSION__ */ public function getForm($data = [], $loadData = true) { $form = $this->loadForm('com_weblinks.form', 'weblink', ['control' => 'jform', 'load_data' => $loadData]); // Disable the buttons and just allow editor none for not authenticated users if ($this->getCurrentUser()->guest) { $form->setFieldAttribute('description', 'editor', 'none'); $form->setFieldAttribute('description', 'buttons', 'no'); } return $form; } /** * Method to get a table object, load it if necessary. * * @param string $name The table name. Optional. * @param string $prefix The class prefix. Optional. * @param array $options Configuration array for model. Optional. * * @return Table A Table object * * @since 4.0.0 * @throws \Exception */ public function getTable($name = 'Weblink', $prefix = 'Administrator', $options = []) { return parent::getTable($name, $prefix, $options); } } PK ��\h6�2 �2 src/Model/CategoryModel.phpnu �[��� <?php /** * @package Joomla.Site * @subpackage com_weblinks * * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Weblinks\Site\Model; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects use Joomla\CMS\Categories\Categories; use Joomla\CMS\Categories\CategoryNode; use Joomla\CMS\Factory; use Joomla\CMS\Helper\TagsHelper; use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Table\Category; use Joomla\Database\ParameterType; use Joomla\Registry\Registry; /** * Weblinks Component Weblink Model * * @since 1.5 */ class CategoryModel extends ListModel { /** * Category item data * * @var CategoryNode|null */ protected $_item = null; /** * Category left of this one * * @var CategoryNode|null */ protected $_leftsibling = null; /** * Category right right of this one * * @var CategoryNode|null */ protected $_rightsibling = null; /** * Array of child-categories * * @var CategoryNode[]|null */ protected $_children = null; /** * Parent category of the current one * * @var CategoryNode|null */ protected $_parent = null; /** * Constructor. * * @param array $config An optional associative array of configuration settings. * * @see JControllerLegacy * @since 1.6 */ public function __construct($config = []) { if (empty($config['filter_fields'])) { $config['filter_fields'] = [ 'id', 'a.id', 'title', 'a.title', 'hits', 'a.hits', 'ordering', 'a.ordering', ]; } parent::__construct($config); } /** * Method to get a list of items. * * @return mixed An array of objects on success, false on failure. */ public function getItems() { // Invoke the parent getItems method to get the main list $items = parent::getItems(); $taggedItems = []; // Convert the params field into an object, saving original in _params foreach ($items as $item) { if (!isset($this->_params)) { $item->params = new Registry($item->params); } // Some contexts may not use tags data at all, so we allow callers to disable loading tag data if ($this->getState('load_tags', true)) { $item->tags = new TagsHelper(); $taggedItems[$item->id] = $item; } } // Load tags of all items. if ($taggedItems) { $tagsHelper = new TagsHelper(); $itemIds = array_keys($taggedItems); foreach ($tagsHelper->getMultipleItemTags('com_weblinks.weblink', $itemIds) as $id => $tags) { $taggedItems[$id]->tags->itemTags = $tags; } } return $items; } /** * Method to get a JDatabaseQuery object for retrieving the data set from a database. * * @return \JDatabaseQuery A JDatabaseQuery object to retrieve the data set. * * @since 1.6 */ protected function getListQuery() { $viewLevels = $this->getCurrentUser()->getAuthorisedViewLevels(); // Create a new query object. $db = $this->getDatabase(); $query = $db->getQuery(true); // Select required fields from the categories. $query->select($this->getState('list.select', 'a.*')) ->from($db->quoteName('#__weblinks') . ' AS a') ->whereIn($db->quoteName('a.access'), $viewLevels); // Filter by category. if ($categoryId = $this->getState('category.id')) { // Group by subcategory if ($this->getState('category.group', 0)) { $query->select('c.title AS category_title') ->where('c.parent_id = :parent_id') ->bind(':parent_id', $categoryId, ParameterType::INTEGER) ->join('LEFT', '#__categories AS c ON c.id = a.catid') ->whereIn($db->quoteName('c.access'), $viewLevels); } else { $query->where('a.catid = :catid') ->bind(':catid', $categoryId, ParameterType::INTEGER) ->join('LEFT', '#__categories AS c ON c.id = a.catid') ->whereIn($db->quoteName('c.access'), $viewLevels); } // Filter by published category $cpublished = $this->getState('filter.c.published'); if (is_numeric($cpublished)) { $query->where('c.published = :published') ->bind(':published', $cpublished, ParameterType::INTEGER); } } // Join over the users for the author and modified_by names. $query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author") ->select("ua.email AS author_email") ->join('LEFT', '#__users AS ua ON ua.id = a.created_by') ->join('LEFT', '#__users AS uam ON uam.id = a.modified_by'); // Filter by state $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where('a.state = :state') ->bind(':state', $state, ParameterType::INTEGER); } // Do not show trashed links on the front-end $query->where('a.state != -2'); // Filter by start and end dates. if ($this->getState('filter.publish_date')) { $nowDate = Factory::getDate()->toSql(); $query->where('(' . $db->quoteName('a.publish_up') . ' IS NULL OR ' . $db->quoteName('a.publish_up') . ' <= :publish_up)') ->where('(' . $db->quoteName('a.publish_down') . ' IS NULL OR ' . $db->quoteName('a.publish_down') . ' >= :publish_down)') ->bind(':publish_up', $nowDate) ->bind(':publish_down', $nowDate); } // Filter by language if ($this->getState('filter.language')) { $query->whereIn($db->quoteName('a.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING); } // Filter by search in title $search = $this->getState('list.filter'); if (!empty($search)) { $search = '%' . trim($search) . '%'; $query->where('(a.title LIKE :search)') ->bind(':search', $search); } // If grouping by subcategory, add the subcategory list ordering clause. if ($this->getState('category.group', 0)) { $query->order( $db->escape($this->getState('category.ordering', 'c.lft')) . ' ' . $db->escape($this->getState('category.direction', 'ASC')) ); } // Add the list ordering clause. $query->order( $db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')) ); return $query; } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = Factory::getApplication(); $params = $app->getParams(); $this->setState('params', $params); // List state information $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit'), 'uint'); $this->setState('list.limit', $limit); $limitstart = $app->getInput()->get('limitstart', 0, 'uint'); $this->setState('list.start', $limitstart); // Optional filter text $this->setState('list.filter', $app->getInput()->getString('filter-search')); $orderCol = $app->getInput()->get('filter_order', 'ordering'); if (!\in_array($orderCol, $this->filter_fields)) { $orderCol = 'ordering'; } $this->setState('list.ordering', $orderCol); $listOrder = $app->getInput()->get('filter_order_Dir', 'ASC'); if (!\in_array(strtoupper($listOrder), ['ASC', 'DESC', ''])) { $listOrder = 'ASC'; } $this->setState('list.direction', $listOrder); $id = $app->getInput()->get('id', 0, 'int'); $this->setState('category.id', $id); $user = $this->getCurrentUser(); if (!$user->authorise('core.edit.state', 'com_weblinks') && !$user->authorise('core.edit', 'com_weblinks')) { // Limit to published for people who can't edit or edit.state. $this->setState('filter.state', 1); // Filter by start and end dates. $this->setState('filter.publish_date', true); } $this->setState('filter.language', Multilanguage::isEnabled()); } /** * Method to get category data for the current category * * @return object * * @since 1.5 */ public function getCategory() { if (!\is_object($this->_item)) { $params = $this->getState('params', new Registry()); $options = []; $options['countItems'] = $params->get('show_cat_num_links_cat', 1) || $params->get('show_empty_categories', 0); $categories = Categories::getInstance('Weblinks', $options); $this->_item = $categories->get($this->getState('category.id', 'root')); if (\is_object($this->_item)) { $this->_children = $this->_item->getChildren(); $this->_parent = false; if ($this->_item->getParent()) { $this->_parent = $this->_item->getParent(); } $this->_rightsibling = $this->_item->getSibling(); $this->_leftsibling = $this->_item->getSibling(false); } else { $this->_children = false; $this->_parent = false; } } return $this->_item; } /** * Get the parent category * * @return mixed An array of categories or false if an error occurs. */ public function getParent() { if (!\is_object($this->_item)) { $this->getCategory(); } return $this->_parent; } /** * Get the leftsibling (adjacent) categories. * * @return mixed An array of categories or false if an error occurs. */ public function &getLeftSibling() { if (!\is_object($this->_item)) { $this->getCategory(); } return $this->_leftsibling; } /** * Get the rightsibling (adjacent) categories. * * @return mixed An array of categories or false if an error occurs. */ public function &getRightSibling() { if (!\is_object($this->_item)) { $this->getCategory(); } return $this->_rightsibling; } /** * Get the child categories. * * @return mixed An array of categories or false if an error occurs. */ public function &getChildren() { if (!\is_object($this->_item)) { $this->getCategory(); } return $this->_children; } /** * Increment the hit counter for the category. * * @param integer $pk Optional primary key of the category to increment. * * @return boolean True if successful; false otherwise and internal error set. * * @since 3.2 */ public function hit($pk = 0) { $hitcount = Factory::getApplication()->getInput()->getInt('hitcount', 1); if ($hitcount) { $pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id'); $table = new Category($this->getDatabase()); $table->load($pk); $table->hit($pk); } return true; } } PK ��\�* 7 7 src/Model/CategoriesModel.phpnu �[��� <?php /** * @package Joomla.Site * @subpackage com_weblinks * * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Weblinks\Site\Model; use Joomla\CMS\Categories\Categories; use Joomla\CMS\Categories\CategoryNode; use Joomla\CMS\Factory; use Joomla\CMS\MVC\Model\ListModel; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * This models supports retrieving lists of article categories. * * @since 1.6 */ class CategoriesModel extends ListModel { /** * Context string for the model type. This is used to handle uniqueness * when dealing with the getStoreId() method and caching data structures. * * @var string */ protected $context = 'com_weblinks.categories'; /** * The category context (allows other extensions to derived from this model). * * @var string */ protected $_extension = 'com_weblinks'; /** * Parent category * * @var CategoryNode|null */ private $_parent = null; /** * Categories data * * @var false|array */ private $_items = null; /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = Factory::getApplication(); $this->setState('filter.extension', $this->_extension); // Get the parent id if defined. $parentId = $app->getInput()->getInt('id'); $this->setState('filter.parentId', $parentId); $params = $app->getParams(); $this->setState('params', $params); $this->setState('filter.published', 1); $this->setState('filter.access', true); } /** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id A prefix for the store id. * * @return string A store id. */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->getState('filter.extension'); $id .= ':' . $this->getState('filter.published'); $id .= ':' . $this->getState('filter.access'); $id .= ':' . $this->getState('filter.parentId'); return parent::getStoreId($id); } /** * Redefine the function and add some properties to make the styling more easy * * @return mixed An array of data items on success, false on failure. */ public function getItems() { if ($this->_items === null) { $params = $this->getState('params', new Registry()); $options = []; $options['access'] = $this->getState('filter.access'); $options['published'] = $this->getState('filter.published'); $options['countItems'] = $params->get('show_cat_num_links', 1) || !$params->get('show_empty_categories_cat', 0); $categories = Categories::getInstance('Weblinks', $options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if (\is_object($this->_parent)) { $this->_items = $this->_parent->getChildren(); } else { $this->_items = false; } } return $this->_items; } /** * Get the parent * * @return mixed An array of data items on success, false on failure. */ public function getParent() { if (!\is_object($this->_parent)) { $this->getItems(); } return $this->_parent; } } PK ��\l��� � src/Model/WeblinkModel.phpnu �[��� <?php /** * @package Joomla.Site * @subpackage com_weblinks * * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Weblinks\Site\Model; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects use Joomla\CMS\Factory; use Joomla\CMS\Helper\TagsHelper; use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Model\ItemModel; use Joomla\CMS\Table\Table; use Joomla\Database\ParameterType; use Joomla\Registry\Registry; /** * Weblinks Component Model for a Weblink record * * @since 1.5 */ class WeblinkModel extends ItemModel { /** * Store loaded weblink items * * @var array * @since 1.6 */ protected $_item = null; /** * Model context string. * * @var string */ protected $_context = 'com_weblinks.weblink'; /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * * @since 1.6 */ protected function populateState() { $app = Factory::getApplication(); // Load the object state. $pk = $app->getInput()->getInt('id'); $this->setState('weblink.id', $pk); // Load the parameters. $params = $app->getParams(); $this->setState('params', $params); $user = $this->getCurrentUser(); if (!$user->authorise('core.edit.state', 'com_weblinks') && !$user->authorise('core.edit', 'com_weblinks')) { $this->setState('filter.published', 1); $this->setState('filter.archived', 2); } $this->setState('filter.language', Multilanguage::isEnabled()); } /** * Method to get an object. * * @param integer $pk The id of the object to get. * * @return mixed Object on success, false on failure. */ public function getItem($pk = null) { $user = $this->getCurrentUser(); $pk = (!empty($pk)) ? $pk : (int) $this->getState('weblink.id'); if ($this->_item === null) { $this->_item = []; } if (!isset($this->_item[$pk])) { try { $db = $this->getDatabase(); $query = $db->getQuery(true) ->select($this->getState('item.select', 'a.*')) ->from('#__weblinks AS a') ->where($db->quoteName('a.id') . ' = :id') ->bind(':id', $pk, ParameterType::INTEGER); // Join on category table. $query->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access') ->innerJoin('#__categories AS c on c.id = a.catid') ->where('c.published > 0'); // Join on user table. $query->select('u.name AS author') ->join('LEFT', '#__users AS u on u.id = a.created_by'); // Filter by language if ($this->getState('filter.language')) { $query->whereIn($db->quoteName('a.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING); } // Join over the categories to get parent category titles $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias') ->join('LEFT', '#__categories as parent ON parent.id = c.parent_id'); if (!$user->authorise('core.edit.state', 'com_weblinks') && !$user->authorise('core.edit', 'com_weblinks')) { // Filter by start and end dates. $nowDate = Factory::getDate()->toSql(); $query->where('(' . $db->quoteName('a.publish_up') . ' IS NULL OR ' . $db->quoteName('a.publish_up') . ' <= :publish_up)') ->where('(' . $db->quoteName('a.publish_down') . ' IS NULL OR ' . $db->quoteName('a.publish_down') . ' >= :publish_down)') ->bind(':publish_up', $nowDate) ->bind(':publish_down', $nowDate); } // Filter by published state. $published = $this->getState('filter.published'); $archived = $this->getState('filter.archived'); if (is_numeric($published)) { $query->whereIn($db->quoteName('a.state'), [$published, $archived]); } $db->setQuery($query); $data = $db->loadObject(); if (empty($data)) { throw new \Exception(Text::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 404); } // Check for published state if filter set. if ((is_numeric($published) || is_numeric($archived)) && (($data->state != $published) && ($data->state != $archived))) { throw new \Exception(Text::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 404); } // Convert parameter fields to objects. $data->params = new Registry($data->params); $data->metadata = new Registry($data->metadata); // Some contexts may not use tags data at all, so we allow callers to disable loading tag data if ($this->getState('load_tags', true)) { $data->tags = new TagsHelper(); $data->tags->getItemTags('com_weblinks.weblink', $data->id); } // Compute access permissions. if ($this->getState('filter.access')) { // If the access filter has been set, we already know this user can view. $data->params->set('access-view', true); } else { // If no access filter is set, the layout takes some responsibility for display of limited information. $groups = $user->getAuthorisedViewLevels(); $data->params->set('access-view', \in_array($data->access, $groups) && \in_array($data->category_access, $groups)); } $this->_item[$pk] = $data; } catch (\Exception $e) { $this->setError($e); $this->_item[$pk] = false; } } return $this->_item[$pk]; } /** * Returns a reference to the a Table object, always creating it. * * @param string $type The table type to instantiate * @param string $prefix A prefix for the table class name. Optional. * @param array $config Configuration array for model. Optional. * * @return Table A database object * * @since 1.6 */ public function getTable($type = 'Weblink', $prefix = 'Administrator', $config = []) { return parent::getTable($type, $prefix, $config); } /** * Method to increment the hit counter for the weblink * * @param integer $pk Optional ID of the weblink. * * @return boolean True on success */ public function hit($pk = null) { if (empty($pk)) { $pk = $this->getState('weblink.id'); } return $this->getTable('Weblink')->hit($pk); } } PK ��\]uo�u u src/Service/Category.phpnu �[��� <?php /** * @package Joomla.Site * @subpackage com_weblinks * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Weblinks\Site\Service; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects use Joomla\CMS\Categories\Categories; /** * Weblinks Component Category Tree * * @since 1.6 */ class Category extends Categories { /** * Class constructor * * @param array $options Array of options * * @since 1.7.0 */ public function __construct($options = []) { $options['table'] = '#__weblinks'; $options['extension'] = 'com_weblinks'; parent::__construct($options); } } PK ��\�G�"