0byt3m1n1-V2
Path:
/
home
/
a
/
c
/
a
/
academiac
/
www
/
[
Home
]
File: weblinks.php.tar
home/academiac/www/plugins/search/weblinks/weblinks.php 0000644 00000012376 15137265173 0017325 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // no direct access defined('_JEXEC') or die; require_once JPATH_SITE.'/components/com_weblinks/helpers/route.php'; /** * Weblinks Search plugin * * @package Joomla.Plugin * @subpackage Search.weblinks * @since 1.6 */ class plgSearchWeblinks extends JPlugin { /** * Constructor * * @access protected * @param object $subject The object to observe * @param array $config An array that holds the plugin configuration * @since 1.5 */ public function __construct(& $subject, $config) { parent::__construct($subject, $config); $this->loadLanguage(); } /** * @return array An array of search areas */ function onContentSearchAreas() { static $areas = array( 'weblinks' => 'PLG_SEARCH_WEBLINKS_WEBLINKS' ); return $areas; } /** * Weblink Search method * * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category * @param mixed An array if the search it to be restricted to areas, null if search all */ function onContentSearch($text, $phrase='', $ordering='', $areas=null) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $searchText = $text; if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $sContent = $this->params->get('search_content', 1); $sArchived = $this->params->get('search_archived', 1); $limit = $this->params->def('search_limit', 50); $state = array(); if ($sContent) { $state[]=1; } if ($sArchived) { $state[]=2; } $text = trim($text); if ($text == '') { return array(); } $section = JText::_('PLG_SEARCH_WEBLINKS'); $wheres = array(); switch ($phrase) { case 'exact': $text = $db->Quote('%'.$db->escape($text, true).'%', false); $wheres2 = array(); $wheres2[] = 'a.url LIKE '.$text; $wheres2[] = 'a.description LIKE '.$text; $wheres2[] = 'a.title LIKE '.$text; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%'.$db->escape($word, true).'%', false); $wheres2 = array(); $wheres2[] = 'a.url LIKE '.$word; $wheres2[] = 'a.description LIKE '.$word; $wheres2[] = 'a.title LIKE '.$word; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } switch ($ordering) { case 'oldest': $order = 'a.created ASC'; break; case 'popular': $order = 'a.hits DESC'; break; case 'alpha': $order = 'a.title ASC'; break; case 'category': $order = 'c.title ASC, a.title ASC'; break; case 'newest': default: $order = 'a.created DESC'; } $return = array(); if (!empty($state)) { $query = $db->getQuery(true); //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id.' END as slug'; $case_when1 = ' CASE WHEN '; $case_when1 .= $query->charLength('c.alias'); $case_when1 .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when1 .= ' ELSE '; $case_when1 .= $c_id.' END as catslug'; $query->select('a.title AS title, a.description AS text, a.created AS created, a.url, ' .$case_when.','.$case_when1.', ' .$query->concatenate(array($db->Quote($section), "c.title"), " / ").' AS section, \'1\' AS browsernav'); $query->from('#__weblinks AS a'); $query->innerJoin('#__categories AS c ON c.id = a.catid'); $query->where('('.$where.')' . ' AND a.state in ('.implode(',', $state).') AND c.published=1 AND c.access IN ('.$groups.')'); $query->order($order); // Filter by language if ($app->isSite() && $app->getLanguageFilter()) { $tag = JFactory::getLanguage()->getTag(); $query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); $query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); $return = array(); if ($rows) { foreach($rows as $key => $row) { $rows[$key]->href = WeblinksHelperRoute::getWeblinkRoute($row->slug, $row->catslug); } foreach($rows as $key => $weblink) { if (searchHelper::checkNoHTML($weblink, $searchText, array('url', 'text', 'title'))) { $return[] = $weblink; } } } } return $return; } } home/academiac/www/administrator/components/com_weblinks/weblinks.php 0000644 00000001055 15137413710 0022262 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_weblinks * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; // Access check. if (!JFactory::getUser()->authorise('core.manage', 'com_weblinks')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } $controller = JControllerLegacy::getInstance('Weblinks'); $controller->execute(JRequest::getCmd('task')); $controller->redirect(); home/academiac/www/administrator/components/com_weblinks/helpers/weblinks.php 0000644 00000003153 15137414035 0023726 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; /** * Weblinks helper. * * @package Joomla.Administrator * @subpackage com_weblinks * @since 1.6 */ class WeblinksHelper { /** * Configure the Linkbar. * * @param string The name of the active view. * @since 1.6 */ public static function addSubmenu($vName = 'weblinks') { JSubMenuHelper::addEntry( JText::_('COM_WEBLINKS_SUBMENU_WEBLINKS'), 'index.php?option=com_weblinks&view=weblinks', $vName == 'weblinks' ); JSubMenuHelper::addEntry( JText::_('COM_WEBLINKS_SUBMENU_CATEGORIES'), 'index.php?option=com_categories&extension=com_weblinks', $vName == 'categories' ); if ($vName=='categories') { JToolBarHelper::title( JText::sprintf('COM_CATEGORIES_CATEGORIES_TITLE', JText::_('com_weblinks')), 'weblinks-categories'); } } /** * Gets a list of the actions that can be performed. * * @param int The category ID. * @return JObject * @since 1.6 */ public static function getActions($categoryId = 0) { $user = JFactory::getUser(); $result = new JObject; if (empty($categoryId)) { $assetName = 'com_weblinks'; $level = 'component'; } else { $assetName = 'com_weblinks.category.'.(int) $categoryId; $level = 'category'; } $actions = JAccess::getActions('com_weblinks', $level); foreach ($actions as $action) { $result->set($action->name, $user->authorise($action->name, $assetName)); } return $result; } } home/academiac/www/administrator/components/com_weblinks/controllers/weblinks.php 0000644 00000001306 15137414162 0024631 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access. defined('_JEXEC') or die; jimport('joomla.application.component.controlleradmin'); /** * Weblinks list controller class. * * @package Joomla.Administrator * @subpackage com_weblinks * @since 1.6 */ class WeblinksControllerWeblinks extends JControllerAdmin { /** * Proxy for getModel. * @since 1.6 */ public function getModel($name = 'Weblink', $prefix = 'WeblinksModel', $config = array('ignore_request' => true)) { $model = parent::getModel($name, $prefix, $config); return $model; } } home/academiac/www/administrator/components/com_weblinks/models/weblinks.php 0000644 00000014006 15137414365 0023554 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); /** * Methods supporting a list of weblink records. * * @package Joomla.Administrator * @subpackage com_weblinks * @since 1.6 */ class WeblinksModelWeblinks extends JModelList { /** * Constructor. * * @param array An optional associative array of configuration settings. * @see JController * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'id', 'a.id', 'title', 'a.title', 'alias', 'a.alias', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time', 'catid', 'a.catid', 'category_title', 'state', 'a.state', 'access', 'a.access', 'access_level', 'created', 'a.created', 'created_by', 'a.created_by', 'ordering', 'a.ordering', 'featured', 'a.featured', 'language', 'a.language', 'hits', 'a.hits', 'publish_up', 'a.publish_up', 'publish_down', 'a.publish_down', 'url', 'a.url', ); } parent::__construct($config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication('administrator'); // Load the filter state. $search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); $this->setState('filter.search', $search); $accessId = $this->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int'); $this->setState('filter.access', $accessId); $published = $this->getUserStateFromRequest($this->context.'.filter.state', 'filter_published', '', 'string'); $this->setState('filter.state', $published); $categoryId = $this->getUserStateFromRequest($this->context.'.filter.category_id', 'filter_category_id', ''); $this->setState('filter.category_id', $categoryId); $language = $this->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', ''); $this->setState('filter.language', $language); // Load the parameters. $params = JComponentHelper::getParams('com_weblinks'); $this->setState('params', $params); // List state information. parent::populateState('a.title', 'asc'); } /** * 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. * @since 1.6 */ protected function getStoreId($id = '') { // Compile the store id. $id.= ':' . $this->getState('filter.search'); $id.= ':' . $this->getState('filter.access'); $id.= ':' . $this->getState('filter.state'); $id.= ':' . $this->getState('filter.category_id'); $id.= ':' . $this->getState('filter.language'); return parent::getStoreId($id); } /** * Build an SQL query to load the list data. * * @return JDatabaseQuery * @since 1.6 */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); $user = JFactory::getUser(); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid,' . 'a.hits,' . 'a.state, a.access, a.ordering,'. 'a.language, a.publish_up, a.publish_down' ) ); $query->from($db->quoteName('#__weblinks').' AS a'); // Join over the language $query->select('l.title AS language_title'); $query->join('LEFT', $db->quoteName('#__languages').' AS l ON l.lang_code = a.language'); // Join over the users for the checked out user. $query->select('uc.name AS editor'); $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); // Join over the asset groups. $query->select('ag.title AS access_level'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); // Join over the categories. $query->select('c.title AS category_title'); $query->join('LEFT', '#__categories AS c ON c.id = a.catid'); // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where('a.access = '.(int) $access); } // Implement View Level Access if (!$user->authorise('core.admin')) { $groups = implode(',', $user->getAuthorisedViewLevels()); $query->where('a.access IN ('.$groups.')'); } // Filter by published state $published = $this->getState('filter.state'); if (is_numeric($published)) { $query->where('a.state = '.(int) $published); } elseif ($published === '') { $query->where('(a.state IN (0, 1))'); } // Filter by category. $categoryId = $this->getState('filter.category_id'); if (is_numeric($categoryId)) { $query->where('a.catid = '.(int) $categoryId); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = '.(int) substr($search, 3)); } else { $search = $db->Quote('%'.$db->escape($search, true).'%'); $query->where('(a.title LIKE '.$search.' OR a.alias LIKE '.$search.')'); } } // Filter on the language. if ($language = $this->getState('filter.language')) { $query->where('a.language = ' . $db->quote($language)); } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); if ($orderCol == 'a.ordering' || $orderCol == 'category_title') { $orderCol = 'c.title '.$orderDirn.', a.ordering'; } $query->order($db->escape($orderCol.' '.$orderDirn)); //echo nl2br(str_replace('#__','jos_',$query)); return $query; } } home/academiac/www/plugins/finder/weblinks/weblinks.php 0000644 00000025074 15137441322 0017316 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage Finder.Weblinks * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_BASE') or die; jimport('joomla.application.component.helper'); // Load the base adapter. require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php'; /** * Finder adapter for Joomla Web Links. * * @package Joomla.Plugin * @subpackage Finder.Weblinks * @since 2.5 */ class plgFinderWeblinks extends FinderIndexerAdapter { /** * The plugin identifier. * * @var string * @since 2.5 */ protected $context = 'Weblinks'; /** * The extension name. * * @var string * @since 2.5 */ protected $extension = 'com_weblinks'; /** * The sublayout to use when rendering the results. * * @var string * @since 2.5 */ protected $layout = 'weblink'; /** * The type of content that the adapter indexes. * * @var string * @since 2.5 */ protected $type_title = 'Web Link'; /** * The table name. * * @var string * @since 2.5 */ protected $table = '#__weblinks'; /** * Constructor * * @param object &$subject The object to observe * @param array $config An array that holds the plugin configuration * * @since 2.5 */ public function __construct(&$subject, $config) { parent::__construct($subject, $config); $this->loadLanguage(); } /** * Method to update the item link information when the item category is * changed. This is fired when the item category is published or unpublished * from the list view. * * @param string $extension The extension whose category has been updated. * @param array $pks A list of primary key ids of the content that has changed state. * @param integer $value The value of the state that the content has been changed to. * * @return void * * @since 2.5 */ public function onFinderCategoryChangeState($extension, $pks, $value) { // Make sure we're handling com_weblinks categories if ($extension == 'com_weblinks') { $this->categoryStateChange($pks, $value); } } /** * Method to remove the link information for items that have been deleted. * * @param string $context The context of the action being performed. * @param JTable $table A JTable object containing the record to be deleted * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderAfterDelete($context, $table) { if ($context == 'com_weblinks.weblink') { $id = $table->id; } elseif ($context == 'com_finder.index') { $id = $table->link_id; } else { return true; } // Remove the items. return $this->remove($id); } /** * Method to determine if the access level of an item changed. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content has just been created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle web links here. We need to handle front end and back end editing. if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form' ) { // Check if the access levels are different if (!$isNew && $this->old_access != $row->access) { // Process the change. $this->itemAccessChange($row); } // Reindex the item $this->reindex($row->id); } // Check for access changes in the category if ($context == 'com_categories.category') { // Check if the access levels are different if (!$isNew && $this->old_cataccess != $row->access) { $this->categoryAccessChange($row); } } return true; } /** * Method to reindex the link information for an item that has been saved. * This event is fired before the data is actually saved so we are going * to queue the item to be indexed later. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content is just about to be created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle web links here if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form') { // Query the database for the old access level if the item isn't new if (!$isNew) { $this->checkItemAccess($row); } } // Check for access levels from the category if ($context == 'com_categories.category') { // Query the database for the old access level if the item isn't new if (!$isNew) { $this->checkCategoryAccess($row); } } return true; } /** * Method to update the link information for items that have been changed * from outside the edit screen. This is fired when the item is published, * unpublished, archived, or unarchived from the list view. * * @param string $context The context for the content passed to the plugin. * @param array $pks A list of primary key ids of the content that has changed state. * @param integer $value The value of the state that the content has been changed to. * * @return void * * @since 2.5 */ public function onFinderChangeState($context, $pks, $value) { // We only want to handle web links here if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form') { $this->itemStateChange($pks, $value); } // Handle when the plugin is disabled if ($context == 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } } /** * Method to index an item. The item must be a FinderIndexerResult object. * * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. * @param string $format The item format * * @return void * * @since 2.5 * @throws Exception on database error. */ protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled if (JComponentHelper::isEnabled($this->extension) == false) { return; } // Initialize the item parameters. $registry = new JRegistry; $registry->loadString($item->params); $item->params = $registry; $registry = new JRegistry; $registry->loadString($item->metadata); $item->metadata = $registry; // Build the necessary route and path information. $item->url = $this->getURL($item->id, $this->extension, $this->layout); $item->route = WeblinksHelperRoute::getWeblinkRoute($item->slug, $item->catslug); $item->path = FinderIndexerHelper::getContentPath($item->route); /* * Add the meta-data processing instructions based on the newsfeeds * configuration parameters. */ // Add the meta-author. $item->metaauthor = $item->metadata->get('author'); // Handle the link to the meta-data. $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Web Link'); // Add the category taxonomy data. $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. FinderIndexer::index($item); } /** * Method to setup the indexer to be run. * * @return boolean True on success. * * @since 2.5 */ protected function setup() { // Load dependent classes. require_once JPATH_SITE . '/includes/application.php'; require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php'; return true; } /** * Method to get the SQL query used to retrieve the list of content items. * * @param mixed $sql A JDatabaseQuery object or null. * * @return JDatabaseQuery A database object. * * @since 2.5 */ protected function getListQuery($sql = null) { $db = JFactory::getDbo(); // Check if we can use the supplied SQL query. $sql = $sql instanceof JDatabaseQuery ? $sql : $db->getQuery(true); $sql->select('a.id, a.catid, a.title, a.alias, a.url AS link, a.description AS summary'); $sql->select('a.metakey, a.metadesc, a.metadata, a.language, a.access, a.ordering'); $sql->select('a.created_by_alias, a.modified, a.modified_by'); $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); $sql->select('a.state AS state, a.ordering, a.access, a.approved, a.created AS start_date, a.params'); $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); // Handle the alias CASE WHEN portion of the query $case_when_item_alias = ' CASE WHEN '; $case_when_item_alias .= $sql->charLength('a.alias'); $case_when_item_alias .= ' THEN '; $a_id = $sql->castAsChar('a.id'); $case_when_item_alias .= $sql->concatenate(array($a_id, 'a.alias'), ':'); $case_when_item_alias .= ' ELSE '; $case_when_item_alias .= $a_id.' END as slug'; $sql->select($case_when_item_alias); $case_when_category_alias = ' CASE WHEN '; $case_when_category_alias .= $sql->charLength('c.alias'); $case_when_category_alias .= ' THEN '; $c_id = $sql->castAsChar('c.id'); $case_when_category_alias .= $sql->concatenate(array($c_id, 'c.alias'), ':'); $case_when_category_alias .= ' ELSE '; $case_when_category_alias .= $c_id.' END as catslug'; $sql->select($case_when_category_alias); $sql->from('#__weblinks AS a'); $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); $sql->where('a.approved = 1'); return $sql; } /** * Method to get the query clause for getting items to update by time. * * @param string $time The modified timestamp. * * @return JDatabaseQuery A database object. * * @since 2.5 */ protected function getUpdateQueryByTime($time) { // Build an SQL query based on the modified time. $sql = $this->db->getQuery(true); $sql->where('a.date >= ' . $this->db->quote($time)); return $sql; } } home/academiac/www/components/com_weblinks/weblinks.php 0000644 00000000671 15137551646 0017420 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_weblinks * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; require_once JPATH_COMPONENT.'/helpers/route.php'; $controller = JControllerLegacy::getInstance('Weblinks'); $controller->execute(JRequest::getCmd('task')); $controller->redirect();
©
2018.