You've already forked joomla_test
first commit
This commit is contained in:
65
components/com_weblinks/controller.php
Normal file
65
components/com_weblinks/controller.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Weblinks Component Controller
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.5
|
||||
*/
|
||||
class WeblinksController extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* Method to display a view.
|
||||
*
|
||||
* @param boolean If true, the view output will be cached
|
||||
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
|
||||
*
|
||||
* @return JController This object to support chaining.
|
||||
* @since 1.5
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = false)
|
||||
{
|
||||
$cachable = true; // Huh? Why not just put that in the constructor?
|
||||
$user = JFactory::getUser();
|
||||
|
||||
// Set the default view name and format from the Request.
|
||||
// Note we are using w_id to avoid collisions with the router and the return page.
|
||||
// Frontend is a bit messier than the backend.
|
||||
$id = $this->input->getInt('w_id');
|
||||
$vName = $this->input->get('view', 'categories');
|
||||
$this->input->set('view', $vName);
|
||||
|
||||
if ($user->get('id') ||($this->input->getMethod() == 'POST' && $vName = 'categories'))
|
||||
{
|
||||
$cachable = false;
|
||||
}
|
||||
|
||||
$safeurlparams = array(
|
||||
'id' => 'INT',
|
||||
'limit' => 'UINT',
|
||||
'limitstart' => 'UINT',
|
||||
'filter_order' => 'CMD',
|
||||
'filter_order_Dir' => 'CMD',
|
||||
'lang' => 'CMD'
|
||||
);
|
||||
|
||||
// Check for edit form.
|
||||
if ($vName == 'form' && !$this->checkEditId('com_weblinks.edit.weblink', $id))
|
||||
{
|
||||
// Somehow the person just went to the form - we don't allow that.
|
||||
return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
|
||||
}
|
||||
|
||||
return parent::display($cachable, $safeurlparams);
|
||||
}
|
||||
}
|
1
components/com_weblinks/controllers/index.html
Normal file
1
components/com_weblinks/controllers/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
305
components/com_weblinks/controllers/weblink.php
Normal file
305
components/com_weblinks/controllers/weblink.php
Normal file
@ -0,0 +1,305 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.5
|
||||
*/
|
||||
class WeblinksControllerWeblink extends JControllerForm
|
||||
{
|
||||
/**
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $view_item = 'form';
|
||||
|
||||
/**
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $view_list = 'categories';
|
||||
|
||||
/**
|
||||
* Method to add a new record.
|
||||
*
|
||||
* @return boolean True if the article can be added, false if not.
|
||||
* @since 1.6
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
|
||||
if (!parent::add())
|
||||
{
|
||||
// Redirect to the return page.
|
||||
$this->setRedirect($this->getReturnPage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can add a new record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
* @return boolean
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowAdd($data = array())
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$categoryId = JArrayHelper::getValue($data, 'catid', $this->input->getInt('id'), 'int');
|
||||
$allow = null;
|
||||
|
||||
if ($categoryId)
|
||||
{
|
||||
// If the category has been passed in the URL check it.
|
||||
$allow = $user->authorise('core.create', $this->option.'.category.'.$categoryId);
|
||||
}
|
||||
|
||||
if ($allow === null)
|
||||
{
|
||||
// In the absense of better information, revert to the component permissions.
|
||||
return parent::allowAdd($data);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $allow;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if you can add a new record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
* @param string $key The name of the key for the primary key.
|
||||
*
|
||||
* @return boolean
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowEdit($data = array(), $key = 'id')
|
||||
{
|
||||
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
|
||||
$categoryId = 0;
|
||||
|
||||
if ($recordId)
|
||||
{
|
||||
$categoryId = (int) $this->getModel()->getItem($recordId)->catid;
|
||||
}
|
||||
|
||||
if ($categoryId)
|
||||
{
|
||||
// The category has been set. Check the category permissions.
|
||||
return JFactory::getUser()->authorise('core.edit', $this->option.'.category.'.$categoryId);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Since there is no asset tracking, revert to the component permissions.
|
||||
return parent::allowEdit($data, $key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to cancel an edit.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
*
|
||||
* @return Boolean True if access level checks pass, false otherwise.
|
||||
* @since 1.6
|
||||
*/
|
||||
public function cancel($key = 'w_id')
|
||||
{
|
||||
parent::cancel($key);
|
||||
|
||||
// Redirect to the return page.
|
||||
$this->setRedirect($this->getReturnPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to edit an existing record.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
|
||||
*
|
||||
* @return Boolean True if access level check and checkout passes, false otherwise.
|
||||
* @since 1.6
|
||||
*/
|
||||
public function edit($key = null, $urlVar = 'w_id')
|
||||
{
|
||||
$result = parent::edit($key, $urlVar);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a model object, loading it if required.
|
||||
*
|
||||
* @param string $name The model name. Optional.
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return object The model.
|
||||
* @since 1.5
|
||||
*/
|
||||
public function getModel($name = 'form', $prefix = '', $config = array('ignore_request' => true))
|
||||
{
|
||||
$model = parent::getModel($name, $prefix, $config);
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL arguments to append to an item redirect.
|
||||
*
|
||||
* @param integer $recordId The primary key id for the item.
|
||||
* @param string $urlVar The name of the URL variable for the id.
|
||||
*
|
||||
* @return string The arguments to append to the redirect URL.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getRedirectToItemAppend($recordId = null, $urlVar = null)
|
||||
{
|
||||
$append = parent::getRedirectToItemAppend($recordId, $urlVar);
|
||||
$itemId = $this->input->getInt('Itemid');
|
||||
$return = $this->getReturnPage();
|
||||
|
||||
if ($itemId)
|
||||
{
|
||||
$append .= '&Itemid='.$itemId;
|
||||
}
|
||||
|
||||
if ($return)
|
||||
{
|
||||
$append .= '&return='.base64_encode($return);
|
||||
}
|
||||
|
||||
return $append;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the return URL.
|
||||
*
|
||||
* If a "return" variable has been passed in the request
|
||||
*
|
||||
* @return string The return URL.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getReturnPage()
|
||||
{
|
||||
$return = $this->input->get('return', null, 'base64');
|
||||
|
||||
if (empty($return) || !JUri::isInternal(base64_decode($return)))
|
||||
{
|
||||
return JUri::base();
|
||||
}
|
||||
else
|
||||
{
|
||||
return base64_decode($return);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that allows child controller access to model data after the data has been saved.
|
||||
*
|
||||
* @param JModelLegacy $model The data model object.
|
||||
* @param array $validData The validated data.
|
||||
*
|
||||
* @return void
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function postSaveHook(JModelLegacy $model, $validData = array())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save a record.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
|
||||
*
|
||||
* @return Boolean True if successful, false otherwise.
|
||||
* @since 1.6
|
||||
*/
|
||||
public function save($key = null, $urlVar = 'w_id')
|
||||
{
|
||||
$result = parent::save($key, $urlVar);
|
||||
|
||||
// If ok, redirect to the return page.
|
||||
if ($result)
|
||||
{
|
||||
$this->setRedirect($this->getReturnPage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Go to a weblink
|
||||
*
|
||||
* @return void
|
||||
* @since 1.6
|
||||
*/
|
||||
public function go()
|
||||
{
|
||||
// Get the ID from the request
|
||||
$id = $this->input->getInt('id');
|
||||
|
||||
// Get the model, requiring published items
|
||||
$modelLink = $this->getModel('Weblink', '', array('ignore_request' => true));
|
||||
$modelLink->setState('filter.published', 1);
|
||||
|
||||
// Get the item
|
||||
$link = $modelLink->getItem($id);
|
||||
|
||||
// Make sure the item was found.
|
||||
if (empty($link))
|
||||
{
|
||||
return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'));
|
||||
}
|
||||
|
||||
// Check whether item access level allows access.
|
||||
$user = JFactory::getUser();
|
||||
$groups = $user->getAuthorisedViewLevels();
|
||||
|
||||
if (!in_array($link->access, $groups))
|
||||
{
|
||||
return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
|
||||
}
|
||||
|
||||
// Check whether category access level allows access.
|
||||
$modelCat = $this->getModel('Category', 'WeblinksModel', array('ignore_request' => true));
|
||||
$modelCat->setState('filter.published', 1);
|
||||
|
||||
// Get the category
|
||||
$category = $modelCat->getCategory($link->catid);
|
||||
|
||||
// Make sure the category was found.
|
||||
if (empty($category))
|
||||
{
|
||||
return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'));
|
||||
}
|
||||
|
||||
// Check whether item access level allows access.
|
||||
if (!in_array($category->access, $groups))
|
||||
{
|
||||
return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
|
||||
}
|
||||
|
||||
// Redirect to the URL
|
||||
// TODO: Probably should check for a valid http link
|
||||
if ($link->url)
|
||||
{
|
||||
$modelLink->hit($id);
|
||||
JFactory::getApplication()->redirect($link->url);
|
||||
}
|
||||
else
|
||||
{
|
||||
return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_URL_INVALID'));
|
||||
}
|
||||
}
|
||||
}
|
52
components/com_weblinks/helpers/association.php
Normal file
52
components/com_weblinks/helpers/association.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php');
|
||||
JLoader::register('CategoryHelperAssociation', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/association.php');
|
||||
|
||||
/**
|
||||
* Weblinks Component Association Helper
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 3.0
|
||||
*/
|
||||
abstract class WeblinksHelperAssociation extends CategoryHelperAssociation
|
||||
{
|
||||
/**
|
||||
* Method to get the associations for a given item
|
||||
*
|
||||
* @param integer $id Id of the item
|
||||
* @param string $view Name of the view
|
||||
*
|
||||
* @return array Array of associations for the item
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
|
||||
public static function getAssociations($id = 0, $view = null)
|
||||
{
|
||||
jimport('helper.route', JPATH_COMPONENT_SITE);
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$jinput = $app->input;
|
||||
$view = is_null($view) ? $jinput->get('view') : $view;
|
||||
$id = empty($id) ? $jinput->getInt('id') : $id;
|
||||
|
||||
if ($view == 'category' || $view == 'categories')
|
||||
{
|
||||
return self::getCategoryAssociations($id, 'com_weblinks');
|
||||
}
|
||||
|
||||
return array();
|
||||
|
||||
}
|
||||
}
|
28
components/com_weblinks/helpers/category.php
Normal file
28
components/com_weblinks/helpers/category.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Weblinks Component Category Tree
|
||||
*
|
||||
* @static
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.6
|
||||
*/
|
||||
class WeblinksCategories extends JCategories
|
||||
{
|
||||
public function __construct($options = array())
|
||||
{
|
||||
$options['table'] = '#__weblinks';
|
||||
$options['extension'] = 'com_weblinks';
|
||||
parent::__construct($options);
|
||||
}
|
||||
}
|
77
components/com_weblinks/helpers/icon.php
Normal file
77
components/com_weblinks/helpers/icon.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Weblink Component HTML Helper
|
||||
*
|
||||
* @static
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.5
|
||||
*/
|
||||
class JHtmlIcon
|
||||
{
|
||||
public static function create($weblink, $params)
|
||||
{
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
|
||||
$uri = JUri::getInstance();
|
||||
$url = JRoute::_(WeblinksHelperRoute::getFormRoute(0, base64_encode($uri)));
|
||||
$text = JHtml::_('image', 'system/new.png', JText::_('JNEW'), null, true);
|
||||
$button = JHtml::_('link', $url, $text);
|
||||
$output = '<span class="hasTooltip" title="' . JHtml::tooltipText('COM_WEBLINKS_FORM_CREATE_WEBLINK') . '">' . $button . '</span>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function edit($weblink, $params, $attribs = array())
|
||||
{
|
||||
$uri = JUri::getInstance();
|
||||
|
||||
if ($params && $params->get('popup'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ($weblink->state < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
|
||||
$url = WeblinksHelperRoute::getFormRoute($weblink->id, base64_encode($uri));
|
||||
$icon = $weblink->state ? 'edit.png' : 'edit_unpublished.png';
|
||||
$text = JHtml::_('image', 'system/'.$icon, JText::_('JGLOBAL_EDIT'), null, true);
|
||||
|
||||
if ($weblink->state == 0)
|
||||
{
|
||||
$overlib = JText::_('JUNPUBLISHED');
|
||||
}
|
||||
else
|
||||
{
|
||||
$overlib = JText::_('JPUBLISHED');
|
||||
}
|
||||
|
||||
$date = JHtml::_('date', $weblink->created);
|
||||
$author = $weblink->created_by_alias ? $weblink->created_by_alias : $weblink->author;
|
||||
|
||||
$overlib .= '<br />';
|
||||
$overlib .= $date;
|
||||
$overlib .= '<br />';
|
||||
$overlib .= htmlspecialchars($author, ENT_COMPAT, 'UTF-8');
|
||||
|
||||
$button = JHtml::_('link', JRoute::_($url), $text);
|
||||
|
||||
$output = '<span class="hasTooltip" title="' . JHtml::tooltipText('COM_WEBLINKS_EDIT') . ' :: ' . $overlib . '">' . $button . '</span>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
1
components/com_weblinks/helpers/index.html
Normal file
1
components/com_weblinks/helpers/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
256
components/com_weblinks/helpers/route.php
Normal file
256
components/com_weblinks/helpers/route.php
Normal file
@ -0,0 +1,256 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Weblinks Component Route Helper
|
||||
*
|
||||
* @static
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.5
|
||||
*/
|
||||
abstract class WeblinksHelperRoute
|
||||
{
|
||||
protected static $lookup;
|
||||
|
||||
/**
|
||||
* @param integer The route of the weblink
|
||||
*/
|
||||
public static function getWeblinkRoute($id, $catid, $language = 0)
|
||||
{
|
||||
$needles = array(
|
||||
'weblink' => array((int) $id)
|
||||
);
|
||||
|
||||
//Create the link
|
||||
$link = 'index.php?option=com_weblinks&view=weblink&id='. $id;
|
||||
|
||||
if ($catid > 1)
|
||||
{
|
||||
$categories = JCategories::getInstance('Weblinks');
|
||||
$category = $categories->get($catid);
|
||||
|
||||
if ($category)
|
||||
{
|
||||
$needles['category'] = array_reverse($category->getPath());
|
||||
$needles['categories'] = $needles['category'];
|
||||
$link .= '&catid='.$catid;
|
||||
}
|
||||
}
|
||||
|
||||
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.sef AS sef')
|
||||
->select('a.lang_code AS lang_code')
|
||||
->from('#__languages AS a');
|
||||
|
||||
$db->setQuery($query);
|
||||
$langs = $db->loadObjectList();
|
||||
foreach ($langs as $lang)
|
||||
{
|
||||
if ($language == $lang->lang_code)
|
||||
{
|
||||
$link .= '&lang='.$lang->sef;
|
||||
$needles['language'] = $language;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($item = self::_findItem($needles))
|
||||
{
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
elseif ($item = self::_findItem())
|
||||
{
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $id The id of the weblink.
|
||||
* @param string $return The return page variable.
|
||||
*/
|
||||
public static function getFormRoute($id, $return = null)
|
||||
{
|
||||
// Create the link.
|
||||
if ($id)
|
||||
{
|
||||
$link = 'index.php?option=com_weblinks&task=weblink.edit&w_id='. $id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$link = 'index.php?option=com_weblinks&task=weblink.add&w_id=0';
|
||||
}
|
||||
|
||||
if ($return)
|
||||
{
|
||||
$link .= '&return='.$return;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
public static function getCategoryRoute($catid, $language = 0)
|
||||
{
|
||||
if ($catid instanceof JCategoryNode)
|
||||
{
|
||||
$id = $catid->id;
|
||||
$category = $catid;
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = (int) $catid;
|
||||
$category = JCategories::getInstance('Weblinks')->get($id);
|
||||
}
|
||||
|
||||
if ($id < 1)
|
||||
{
|
||||
$link = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
//Create the link
|
||||
$link = 'index.php?option=com_weblinks&view=category&id='.$id;
|
||||
$needles = array(
|
||||
'category' => array($id)
|
||||
);
|
||||
|
||||
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.sef AS sef')
|
||||
->select('a.lang_code AS lang_code')
|
||||
->from('#__languages AS a');
|
||||
|
||||
$db->setQuery($query);
|
||||
$langs = $db->loadObjectList();
|
||||
foreach ($langs as $lang)
|
||||
{
|
||||
if ($language == $lang->lang_code)
|
||||
{
|
||||
$link .= '&lang='.$lang->sef;
|
||||
$needles['language'] = $language;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($item = self::_findItem($needles))
|
||||
{
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($category)
|
||||
{
|
||||
$catids = array_reverse($category->getPath());
|
||||
$needles = array(
|
||||
'category' => $catids,
|
||||
'categories' => $catids
|
||||
);
|
||||
if ($item = self::_findItem($needles))
|
||||
{
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
elseif ($item = self::_findItem())
|
||||
{
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
protected static function _findItem($needles = null)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$menus = $app->getMenu('site');
|
||||
$language = isset($needles['language']) ? $needles['language'] : '*';
|
||||
|
||||
// Prepare the reverse lookup array.
|
||||
if (!isset(self::$lookup[$language]))
|
||||
{
|
||||
self::$lookup[$language] = array();
|
||||
|
||||
$component = JComponentHelper::getComponent('com_weblinks');
|
||||
|
||||
$attributes = array('component_id');
|
||||
$values = array($component->id);
|
||||
|
||||
if ($language != '*')
|
||||
{
|
||||
$attributes[] = 'language';
|
||||
$values[] = array($needles['language'], '*');
|
||||
}
|
||||
|
||||
$items = $menus->getItems($attributes, $values);
|
||||
|
||||
if ($items)
|
||||
{
|
||||
foreach ($items as $item)
|
||||
{
|
||||
if (isset($item->query) && isset($item->query['view']))
|
||||
{
|
||||
$view = $item->query['view'];
|
||||
if (!isset(self::$lookup[$language][$view]))
|
||||
{
|
||||
self::$lookup[$language][$view] = array();
|
||||
}
|
||||
if (isset($item->query['id']))
|
||||
{
|
||||
|
||||
// here it will become a bit tricky
|
||||
// language != * can override existing entries
|
||||
// language == * cannot override existing entries
|
||||
if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*')
|
||||
{
|
||||
self::$lookup[$language][$view][$item->query['id']] = $item->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($needles)
|
||||
{
|
||||
foreach ($needles as $view => $ids)
|
||||
{
|
||||
if (isset(self::$lookup[$language][$view]))
|
||||
{
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
if (isset(self::$lookup[$language][$view][(int) $id]))
|
||||
{
|
||||
return self::$lookup[$language][$view][(int) $id];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$active = $menus->getActive();
|
||||
if ($active && ($active->language == '*' || !JLanguageMultilang::isEnabled()))
|
||||
{
|
||||
return $active->id;
|
||||
}
|
||||
|
||||
// if not found, return language specific home link
|
||||
$default = $menus->getDefault($language);
|
||||
return !empty($default->id) ? $default->id : null;
|
||||
}
|
||||
}
|
1
components/com_weblinks/index.html
Normal file
1
components/com_weblinks/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
3
components/com_weblinks/metadata.xml
Normal file
3
components/com_weblinks/metadata.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
</metadata>
|
124
components/com_weblinks/models/categories.php
Normal file
124
components/com_weblinks/models/categories.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* This models supports retrieving lists of article categories.
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.6
|
||||
*/
|
||||
class WeblinksModelCategories extends JModelList
|
||||
{
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $_context = 'com_weblinks.categories';
|
||||
|
||||
/**
|
||||
* The category context (allows other extensions to derived from this model).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_extension = 'com_weblinks';
|
||||
|
||||
private $_parent = null;
|
||||
|
||||
private $_items = null;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$this->setState('filter.extension', $this->_extension);
|
||||
|
||||
// Get the parent id if defined.
|
||||
$parentId = $app->input->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 an 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 (!count($this->_items))
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$menu = $app->getMenu();
|
||||
$active = $menu->getActive();
|
||||
$params = new JRegistry;
|
||||
if ($active)
|
||||
{
|
||||
$params->loadString($active->params);
|
||||
}
|
||||
$options = array();
|
||||
$options['countItems'] = $params->get('show_cat_num_links', 1) || !$params->get('show_empty_categories_cat', 0);
|
||||
$categories = JCategories::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;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
if (!is_object($this->_parent))
|
||||
{
|
||||
$this->getItems();
|
||||
}
|
||||
return $this->_parent;
|
||||
}
|
||||
}
|
339
components/com_weblinks/models/category.php
Normal file
339
components/com_weblinks/models/category.php
Normal file
@ -0,0 +1,339 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Weblinks Component Weblink Model
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.5
|
||||
*/
|
||||
class WeblinksModelCategory extends JModelList
|
||||
{
|
||||
/**
|
||||
* Category items data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_item = null;
|
||||
|
||||
protected $_articles = null;
|
||||
|
||||
protected $_siblings = null;
|
||||
|
||||
protected $_children = null;
|
||||
|
||||
protected $_parent = null;
|
||||
|
||||
/**
|
||||
* 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',
|
||||
'hits', 'a.hits',
|
||||
'ordering', 'a.ordering',
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* The category that applies.
|
||||
*
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
protected $_category = null;
|
||||
|
||||
/**
|
||||
* The list of other weblink categories.
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $_categories = null;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
// Convert the params field into an object, saving original in _params
|
||||
foreach ($items as $item)
|
||||
{
|
||||
if (!isset($this->_params))
|
||||
{
|
||||
$params = new JRegistry;
|
||||
$params->loadString($item->params);
|
||||
$item->params = $params;
|
||||
}
|
||||
// Get the tags
|
||||
$item->tags = new JHelperTags;
|
||||
$item->tags->getItemTags('com_weblinks.weblink', $item->id);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build an SQL query to load the list data.
|
||||
*
|
||||
* @return string An SQL query
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
|
||||
// Create a new query object.
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select required fields from the categories.
|
||||
$query->select($this->getState('list.select', 'a.*'))
|
||||
->from($db->quoteName('#__weblinks') . ' AS a')
|
||||
->where('a.access IN (' . $groups . ')');
|
||||
|
||||
// Filter by category.
|
||||
if ($categoryId = $this->getState('category.id'))
|
||||
{
|
||||
$query->where('a.catid = ' . (int) $categoryId)
|
||||
->join('LEFT', '#__categories AS c ON c.id = a.catid')
|
||||
->where('c.access IN (' . $groups . ')');
|
||||
|
||||
//Filter by published category
|
||||
$cpublished = $this->getState('filter.c.published');
|
||||
if (is_numeric($cpublished))
|
||||
{
|
||||
$query->where('c.published = ' . (int) $cpublished);
|
||||
}
|
||||
}
|
||||
|
||||
// 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 = ' . (int) $state);
|
||||
}
|
||||
// do not show trashed links on the front-end
|
||||
$query->where('a.state != -2');
|
||||
|
||||
// Filter by start and end dates.
|
||||
$nullDate = $db->quote($db->getNullDate());
|
||||
$date = JFactory::getDate();
|
||||
$nowDate = $db->quote($date->toSql());
|
||||
|
||||
if ($this->getState('filter.publish_date'))
|
||||
{
|
||||
$query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
|
||||
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
|
||||
}
|
||||
|
||||
// Filter by language
|
||||
if ($this->getState('filter.language'))
|
||||
{
|
||||
$query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
|
||||
}
|
||||
|
||||
// Filter by search in title
|
||||
$search = $this->getState('list.filter');
|
||||
if (!empty($search))
|
||||
{
|
||||
$search = $db->quote('%' . $db->escape($search, true) . '%');
|
||||
$query->where('(a.title LIKE ' . $search . ')');
|
||||
}
|
||||
|
||||
// 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.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$params = JComponentHelper::getParams('com_weblinks');
|
||||
|
||||
// List state information
|
||||
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'uint');
|
||||
$this->setState('list.limit', $limit);
|
||||
|
||||
$limitstart = $app->input->get('limitstart', 0, 'uint');
|
||||
$this->setState('list.start', $limitstart);
|
||||
|
||||
// Optional filter text
|
||||
$this->setState('list.filter', $app->input->getString('filter-search'));
|
||||
|
||||
$orderCol = $app->input->get('filter_order', 'ordering');
|
||||
if (!in_array($orderCol, $this->filter_fields))
|
||||
{
|
||||
$orderCol = 'ordering';
|
||||
}
|
||||
$this->setState('list.ordering', $orderCol);
|
||||
|
||||
$listOrder = $app->input->get('filter_order_Dir', 'ASC');
|
||||
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
|
||||
{
|
||||
$listOrder = 'ASC';
|
||||
}
|
||||
$this->setState('list.direction', $listOrder);
|
||||
|
||||
$id = $app->input->get('id', 0, 'int');
|
||||
$this->setState('category.id', $id);
|
||||
|
||||
$user = JFactory::getUser();
|
||||
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', JLanguageMultilang::isEnabled());
|
||||
|
||||
// Load the parameters.
|
||||
$this->setState('params', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get category data for the current category
|
||||
*
|
||||
* @param integer An optional ID
|
||||
*
|
||||
* @return object
|
||||
* @since 1.5
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
if (!is_object($this->_item))
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$menu = $app->getMenu();
|
||||
$active = $menu->getActive();
|
||||
$params = new JRegistry;
|
||||
|
||||
if ($active)
|
||||
{
|
||||
$params->loadString($active->params);
|
||||
}
|
||||
|
||||
$options = array();
|
||||
$options['countItems'] = $params->get('show_cat_num_links_cat', 1) || $params->get('show_empty_categories', 0);
|
||||
$categories = JCategories::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
|
||||
*
|
||||
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
|
||||
*
|
||||
* @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 sibling (adjacent) categories.
|
||||
*
|
||||
* @return mixed An array of categories or false if an error occurs.
|
||||
*/
|
||||
function &getLeftSibling()
|
||||
{
|
||||
if (!is_object($this->_item))
|
||||
{
|
||||
$this->getCategory();
|
||||
}
|
||||
return $this->_leftsibling;
|
||||
}
|
||||
|
||||
function &getRightSibling()
|
||||
{
|
||||
if (!is_object($this->_item))
|
||||
{
|
||||
$this->getCategory();
|
||||
}
|
||||
return $this->_rightsibling;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the child categories.
|
||||
*
|
||||
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
|
||||
*
|
||||
* @return mixed An array of categories or false if an error occurs.
|
||||
*/
|
||||
function &getChildren()
|
||||
{
|
||||
if (!is_object($this->_item))
|
||||
{
|
||||
$this->getCategory();
|
||||
}
|
||||
return $this->_children;
|
||||
}
|
||||
}
|
69
components/com_weblinks/models/form.php
Normal file
69
components/com_weblinks/models/form.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 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_ADMINISTRATOR.'/models/weblink.php';
|
||||
|
||||
/**
|
||||
* Weblinks model.
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.6
|
||||
*/
|
||||
class WeblinksModelForm extends WeblinksModelWeblink
|
||||
{
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
// Load state from the request.
|
||||
$pk = $app->input->getInt('w_id');
|
||||
$this->setState('weblink.id', $pk);
|
||||
// Add compatibility variable for default naming conventions.
|
||||
$this->setState('form.id', $pk);
|
||||
|
||||
$categoryId = $app->input->getInt('catid');
|
||||
$this->setState('weblink.catid', $categoryId);
|
||||
|
||||
$return = $app->input->get('return', null, 'base64');
|
||||
|
||||
if (!JUri::isInternal(base64_decode($return)))
|
||||
{
|
||||
$return = null;
|
||||
}
|
||||
|
||||
$this->setState('return_page', base64_decode($return));
|
||||
|
||||
// Load the parameters.
|
||||
$params = $app->getParams();
|
||||
$this->setState('params', $params);
|
||||
|
||||
$this->setState('layout', $app->input->get('layout'));
|
||||
}
|
||||
}
|
1
components/com_weblinks/models/forms/index.html
Normal file
1
components/com_weblinks/models/forms/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
124
components/com_weblinks/models/forms/weblink.xml
Normal file
124
components/com_weblinks/models/forms/weblink.xml
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fieldset addfieldpath="/administrator/components/com_categories/models/fields">
|
||||
<field name="id" type="hidden"
|
||||
label="WEBLINK_ID_LABEL"
|
||||
readonly="true"
|
||||
required="true"
|
||||
size="10"
|
||||
default="0"
|
||||
/>
|
||||
|
||||
<field name="title" type="text"
|
||||
description="COM_WEBLINKS_FIELD_TITLE_DESC"
|
||||
label="JGLOBAL_TITLE"
|
||||
required="true"
|
||||
size="30"
|
||||
/>
|
||||
|
||||
<field name="alias" type="text"
|
||||
description="COM_WEBLINKS_FIELD_ALIAS_DESC"
|
||||
label="JFIELD_ALIAS_LABEL"
|
||||
size="45"
|
||||
/>
|
||||
|
||||
<field name="description" type="editor"
|
||||
buttons="true"
|
||||
hide="pagebreak,readmore"
|
||||
description="COM_WEBLINKS_FIELD_DESCRIPTION_DESC"
|
||||
filter="safehtml"
|
||||
label="JGLOBAL_DESCRIPTION"
|
||||
asset_id="com_weblinks"
|
||||
/>
|
||||
|
||||
<field name="state" type="list"
|
||||
default="1"
|
||||
description="JFIELD_PUBLISHED_DESC"
|
||||
label="JSTATUS"
|
||||
size="1"
|
||||
>
|
||||
<option value="1">JPUBLISHED</option>
|
||||
<option value="0">JUNPUBLISHED</option>
|
||||
</field>
|
||||
|
||||
<field name="catid" type="categoryedit"
|
||||
description="COM_WEBLINKS_FIELD_CATEGORY_DESC"
|
||||
extension="com_weblinks"
|
||||
label="JCATEGORY"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field name="url" type="url"
|
||||
description="COM_WEBLINKS_FIELD_URL_DESC"
|
||||
label="COM_WEBLINKS_FIELD_URL_LABEL"
|
||||
required="true"
|
||||
size="45"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
label="JFIELD_LANGUAGE_LABEL"
|
||||
description="JFIELD_LANGUAGE_DESC"
|
||||
class="inputbox">
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
|
||||
<field name="tags"
|
||||
type="tag"
|
||||
label="JTAG"
|
||||
description="JTAG_DESC"
|
||||
class="inputbox span12 small"
|
||||
multiple="true"
|
||||
>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
<fields name="metadata">
|
||||
<fieldset name="jmetadata"
|
||||
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
|
||||
|
||||
<field name="robots"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
label="JFIELD_METADATA_ROBOTS_LABEL"
|
||||
description="JFIELD_METADATA_ROBOTS_DESC"
|
||||
labelclass="control-label"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="index, follow">JGLOBAL_INDEX_FOLLOW</option>
|
||||
<option value="noindex, follow">JGLOBAL_NOINDEX_FOLLOW</option>
|
||||
<option value="index, nofollow">JGLOBAL_INDEX_NOFOLLOW</option>
|
||||
<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>
|
||||
</field>
|
||||
|
||||
<field name="author"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
label="JAUTHOR"
|
||||
description="JFIELD_METADATA_AUTHOR_DESC"
|
||||
size="20"
|
||||
labelclass="control-label"
|
||||
/>
|
||||
|
||||
<field name="rights"
|
||||
type="hidden"
|
||||
label="JFIELD_META_RIGHTS_LABEL"
|
||||
filter="unset"
|
||||
description="JFIELD_META_RIGHTS_DESC"
|
||||
required="false"
|
||||
labelclass="control-label"
|
||||
/>
|
||||
|
||||
<field name="xreference"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
label="COM_CONTENT_FIELD_XREFERENCE_LABEL"
|
||||
description="COM_CONTENT_FIELD_XREFERENCE_DESC"
|
||||
class="inputbox"
|
||||
size="20"
|
||||
labelclass="control-label" />
|
||||
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
1
components/com_weblinks/models/index.html
Normal file
1
components/com_weblinks/models/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
128
components/com_weblinks/models/weblink.php
Normal file
128
components/com_weblinks/models/weblink.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables');
|
||||
|
||||
/**
|
||||
* Weblinks Component Model for a Weblink record
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.5
|
||||
*/
|
||||
class WeblinksModelWeblink extends JModelItem
|
||||
{
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = 'com_weblinks.weblink';
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$params = $app->getParams();
|
||||
|
||||
// Load the object state.
|
||||
$id = $app->input->getInt('id');
|
||||
$this->setState('weblink.id', $id);
|
||||
|
||||
// Load the parameters.
|
||||
$this->setState('params', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an object.
|
||||
*
|
||||
* @param integer The id of the object to get.
|
||||
*
|
||||
* @return mixed Object on success, false on failure.
|
||||
*/
|
||||
public function getItem($id = null)
|
||||
{
|
||||
if ($this->_item === null)
|
||||
{
|
||||
$this->_item = false;
|
||||
|
||||
if (empty($id))
|
||||
{
|
||||
$id = $this->getState('weblink.id');
|
||||
}
|
||||
|
||||
// Get a level row instance.
|
||||
$table = JTable::getInstance('Weblink', 'WeblinksTable');
|
||||
|
||||
// Attempt to load the row.
|
||||
if ($table->load($id))
|
||||
{
|
||||
// Check published state.
|
||||
if ($published = $this->getState('filter.published'))
|
||||
{
|
||||
if ($table->state != $published)
|
||||
{
|
||||
return $this->_item;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert the JTable to a clean JObject.
|
||||
$properties = $table->getProperties(1);
|
||||
$this->_item = JArrayHelper::toObject($properties, 'JObject');
|
||||
}
|
||||
elseif ($error = $table->getError())
|
||||
{
|
||||
$this->setError($error);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the a Table object, always creating it.
|
||||
*
|
||||
* @param type The table type to instantiate
|
||||
* @param string A prefix for the table class name. Optional.
|
||||
* @param array Configuration array for model. Optional.
|
||||
* @return JTable A database object
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getTable($type = 'Weblink', $prefix = 'WeblinksTable', $config = array())
|
||||
{
|
||||
return JTable::getInstance($type, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to increment the hit counter for the weblink
|
||||
*
|
||||
* @param integer $id Optional ID of the weblink.
|
||||
*
|
||||
* @return boolean True on success
|
||||
*/
|
||||
public function hit($id = null)
|
||||
{
|
||||
if (empty($id))
|
||||
{
|
||||
$id = $this->getState('weblink.id');
|
||||
}
|
||||
|
||||
$weblink = $this->getTable('Weblink', 'WeblinksTable');
|
||||
return $weblink->hit($id);
|
||||
}
|
||||
}
|
229
components/com_weblinks/router.php
Normal file
229
components/com_weblinks/router.php
Normal file
@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Build the route for the com_weblinks component
|
||||
*
|
||||
* @return array An array of URL arguments
|
||||
*
|
||||
* @return array The URL arguments to use to assemble the subsequent URL.
|
||||
*/
|
||||
function WeblinksBuildRoute(&$query)
|
||||
{
|
||||
$segments = array();
|
||||
|
||||
// get a menu item based on Itemid or currently active
|
||||
$app = JFactory::getApplication();
|
||||
$menu = $app->getMenu();
|
||||
$params = JComponentHelper::getParams('com_weblinks');
|
||||
$advanced = $params->get('sef_advanced_link', 0);
|
||||
|
||||
// we need a menu item. Either the one specified in the query, or the current active one if none specified
|
||||
if (empty($query['Itemid']))
|
||||
{
|
||||
$menuItem = $menu->getActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
$menuItem = $menu->getItem($query['Itemid']);
|
||||
}
|
||||
|
||||
$mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
|
||||
$mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];
|
||||
|
||||
if (isset($query['view']))
|
||||
{
|
||||
$view = $query['view'];
|
||||
|
||||
if (empty($query['Itemid']) || empty($menuItem) || $menuItem->component != 'com_weblinks')
|
||||
{
|
||||
$segments[] = $query['view'];
|
||||
}
|
||||
|
||||
// We need to keep the view for forms since they never have their own menu item
|
||||
if ($view != 'form')
|
||||
{
|
||||
unset($query['view']);
|
||||
}
|
||||
}
|
||||
|
||||
// are we dealing with an weblink that is attached to a menu item?
|
||||
if (isset($query['view']) && ($mView == $query['view']) and (isset($query['id'])) and ($mId == (int) $query['id']))
|
||||
{
|
||||
unset($query['view']);
|
||||
unset($query['catid']);
|
||||
unset($query['id']);
|
||||
|
||||
return $segments;
|
||||
}
|
||||
|
||||
if (isset($view) and ($view == 'category' or $view == 'weblink'))
|
||||
{
|
||||
if ($mId != (int) $query['id'] || $mView != $view)
|
||||
{
|
||||
if ($view == 'weblink' && isset($query['catid']))
|
||||
{
|
||||
$catid = $query['catid'];
|
||||
}
|
||||
elseif (isset($query['id']))
|
||||
{
|
||||
$catid = $query['id'];
|
||||
}
|
||||
|
||||
$menuCatid = $mId;
|
||||
$categories = JCategories::getInstance('Weblinks');
|
||||
$category = $categories->get($catid);
|
||||
|
||||
if ($category)
|
||||
{
|
||||
//TODO Throw error that the category either not exists or is unpublished
|
||||
$path = $category->getPath();
|
||||
$path = array_reverse($path);
|
||||
|
||||
$array = array();
|
||||
foreach ($path as $id)
|
||||
{
|
||||
if ((int) $id == (int) $menuCatid)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if ($advanced)
|
||||
{
|
||||
list($tmp, $id) = explode(':', $id, 2);
|
||||
}
|
||||
|
||||
$array[] = $id;
|
||||
}
|
||||
$segments = array_merge($segments, array_reverse($array));
|
||||
}
|
||||
|
||||
if ($view == 'weblink')
|
||||
{
|
||||
if ($advanced)
|
||||
{
|
||||
list($tmp, $id) = explode(':', $query['id'], 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $query['id'];
|
||||
}
|
||||
|
||||
$segments[] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
unset($query['id']);
|
||||
unset($query['catid']);
|
||||
}
|
||||
|
||||
if (isset($query['layout']))
|
||||
{
|
||||
if (!empty($query['Itemid']) && isset($menuItem->query['layout']))
|
||||
{
|
||||
if ($query['layout'] == $menuItem->query['layout'])
|
||||
{
|
||||
unset($query['layout']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($query['layout'] == 'default')
|
||||
{
|
||||
unset($query['layout']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $segments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the segments of a URL.
|
||||
*
|
||||
* @return array The segments of the URL to parse.
|
||||
*
|
||||
* @return array The URL attributes to be used by the application.
|
||||
*/
|
||||
function WeblinksParseRoute($segments)
|
||||
{
|
||||
$vars = array();
|
||||
|
||||
//Get the active menu item.
|
||||
$app = JFactory::getApplication();
|
||||
$menu = $app->getMenu();
|
||||
$item = $menu->getActive();
|
||||
$params = JComponentHelper::getParams('com_weblinks');
|
||||
$advanced = $params->get('sef_advanced_link', 0);
|
||||
|
||||
// Count route segments
|
||||
$count = count($segments);
|
||||
|
||||
// Standard routing for weblinks.
|
||||
if (!isset($item))
|
||||
{
|
||||
$vars['view'] = $segments[0];
|
||||
$vars['id'] = $segments[$count - 1];
|
||||
return $vars;
|
||||
}
|
||||
|
||||
// From the categories view, we can only jump to a category.
|
||||
$id = (isset($item->query['id']) && $item->query['id'] > 1) ? $item->query['id'] : 'root';
|
||||
|
||||
$category = JCategories::getInstance('Weblinks')->get($id);
|
||||
|
||||
$categories = $category->getChildren();
|
||||
$found = 0;
|
||||
|
||||
foreach ($segments as $segment)
|
||||
{
|
||||
foreach ($categories as $category)
|
||||
{
|
||||
if (($category->slug == $segment) || ($advanced && $category->alias == str_replace(':', '-', $segment)))
|
||||
{
|
||||
$vars['id'] = $category->id;
|
||||
$vars['view'] = 'category';
|
||||
$categories = $category->getChildren();
|
||||
$found = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($found == 0)
|
||||
{
|
||||
if ($advanced)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('id'))
|
||||
->from('#__weblinks')
|
||||
->where($db->quoteName('catid') . ' = ' . (int) $vars['catid'])
|
||||
->where($db->quoteName('alias') . ' = ' . $db->quote($db->quote(str_replace(':', '-', $segment))));
|
||||
$db->setQuery($query);
|
||||
$id = $db->loadResult();
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $segment;
|
||||
}
|
||||
|
||||
$vars['id'] = $id;
|
||||
$vars['view'] = 'weblink';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$found = 0;
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
1
components/com_weblinks/views/categories/index.html
Normal file
1
components/com_weblinks/views/categories/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
17
components/com_weblinks/views/categories/tmpl/default.php
Normal file
17
components/com_weblinks/views/categories/tmpl/default.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
|
||||
JHtml::_('behavior.caption');
|
||||
echo JLayoutHelper::render('joomla.content.categories_default', $this);
|
||||
echo $this->loadTemplate('items');
|
||||
?>
|
||||
</div>
|
243
components/com_weblinks/views/categories/tmpl/default.xml
Normal file
243
components/com_weblinks/views/categories/tmpl/default.xml
Normal file
@ -0,0 +1,243 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<layout title="com_weblinks_categories_view_default_title" option="com_weblinks_categories_view_default_option">
|
||||
<help
|
||||
key="JHELP_MENUS_MENU_ITEM_WEBLINK_CATEGORIES"
|
||||
/>
|
||||
<message>
|
||||
<![CDATA[com_weblinks_categories_view_default_desc]]>
|
||||
</message>
|
||||
</layout>
|
||||
|
||||
<!-- Add fields to the request variables for the layout. -->
|
||||
<fields name="request">
|
||||
<fieldset name="request"
|
||||
>
|
||||
<field name="id" type="category"
|
||||
description="JGLOBAL_FIELD_CATEGORIES_CHOOSE_CATEGORY_DESC"
|
||||
extension="com_weblinks"
|
||||
label="JGLOBAL_FIELD_CATEGORIES_CHOOSE_CATEGORY_LABEL"
|
||||
show_root="true"
|
||||
required="true"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
|
||||
<!-- Add fields to the parameters object for the layout. -->
|
||||
<fields name="params">
|
||||
<fieldset name="basic" label="JGLOBAL_CATEGORIES_OPTIONS">
|
||||
|
||||
<field name="show_base_description" type="list"
|
||||
label="JGLOBAL_FIELD_SHOW_BASE_DESCRIPTION_LABEL"
|
||||
description="JGLOBAL_FIELD_SHOW_BASE_DESCRIPTION_DESC"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="categories_description" type="textarea"
|
||||
description="JGLOBAL_FIELD_CATEGORIES_DESC_DESC"
|
||||
label="JGLOBAL_FIELD_CATEGORIES_DESC_LABEL"
|
||||
cols="25"
|
||||
rows="5"
|
||||
/>
|
||||
|
||||
<field name="maxLevelcat" type="list"
|
||||
default="-1"
|
||||
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
|
||||
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="-1">JALL</option>
|
||||
<option value="1">J1</option>
|
||||
<option value="2">J2</option>
|
||||
<option value="3">J3</option>
|
||||
<option value="4">J4</option>
|
||||
<option value="5">J5</option>
|
||||
|
||||
</field>
|
||||
|
||||
<field name="show_empty_categories_cat" type="list"
|
||||
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
|
||||
description="COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_subcat_desc_cat" type="list"
|
||||
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
|
||||
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_cat_num_links_cat" type="list"
|
||||
description="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC"
|
||||
label="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="category" label="JGLOBAL_CATEGORY_OPTIONS">
|
||||
<field name="spacer1" type="spacer" class="text"
|
||||
label="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
|
||||
/>
|
||||
|
||||
<field name="show_category_title" type="list"
|
||||
label="JGLOBAL_SHOW_CATEGORY_TITLE"
|
||||
description="JGLOBAL_SHOW_CATEGORY_TITLE_DESC"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_description" type="list"
|
||||
description="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_DESC"
|
||||
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_description_image" type="list"
|
||||
description="JGLOBAL_SHOW_CATEGORY_IMAGE_DESC"
|
||||
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="maxLevel" type="list"
|
||||
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
|
||||
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JNONE</option>
|
||||
<option value="-1">JALL</option>
|
||||
<option value="1">J1</option>
|
||||
<option value="2">J2</option>
|
||||
<option value="3">J3</option>
|
||||
<option value="4">J4</option>
|
||||
<option value="5">J5</option>
|
||||
|
||||
</field>
|
||||
|
||||
<field name="show_empty_categories" type="list"
|
||||
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
|
||||
description="COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_subcat_desc" type="list"
|
||||
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
|
||||
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_cat_num_links" type="list"
|
||||
description="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC"
|
||||
label="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="advanced" label="JGLOBAL_LIST_LAYOUT_OPTIONS">
|
||||
<field name="spacer2" type="spacer" class="text"
|
||||
label="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
|
||||
/>
|
||||
<field
|
||||
name="filter_field"
|
||||
type="list"
|
||||
default=""
|
||||
description="JGLOBAL_FILTER_FIELD_DESC"
|
||||
label="JGLOBAL_FILTER_FIELD_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="hide">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_pagination_limit" type="list"
|
||||
label="JGLOBAL_DISPLAY_SELECT_LABEL"
|
||||
description="JGLOBAL_DISPLAY_SELECT_DESC">
|
||||
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_headings" type="list"
|
||||
description="JGLOBAL_SHOW_HEADINGS_DESC"
|
||||
label="JGLOBAL_SHOW_HEADINGS_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_link_description" type="list"
|
||||
|
||||
description="COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_DESC"
|
||||
label="COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_link_hits" type="list"
|
||||
|
||||
description="COM_WEBLINKS_FIELD_CONFIG_HITS_DESC"
|
||||
label="JGLOBAL_HITS"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
|
||||
</field>
|
||||
|
||||
<field name="show_pagination" type="list"
|
||||
description="JGLOBAL_PAGINATION_DESC"
|
||||
label="JGLOBAL_PAGINATION_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="2">JGLOBAL_AUTO</option>
|
||||
</field>
|
||||
|
||||
<field name="show_pagination_results" type="list"
|
||||
|
||||
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
|
||||
description="JGLOBAL_PAGINATION_RESULTS_DESC">
|
||||
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
</fields>
|
||||
</metadata>
|
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
|
||||
$class = ' class="first"';
|
||||
|
||||
if (count($this->items[$this->parent->id]) > 0 && $this->maxLevelcat != 0) :
|
||||
?>
|
||||
<?php foreach($this->items[$this->parent->id] as $id => $item) : ?>
|
||||
<?php
|
||||
if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) :
|
||||
if (!isset($this->items[$this->parent->id][$id + 1]))
|
||||
{
|
||||
$class = ' class="last"';
|
||||
}
|
||||
?>
|
||||
<div <?php echo $class; ?> >
|
||||
<?php $class = ''; ?>
|
||||
<h3 class="page-header item-title">
|
||||
<a href="<?php echo JRoute::_(WeblinksHelperRoute::getCategoryRoute($item->id));?>">
|
||||
<?php echo $this->escape($item->title); ?></a>
|
||||
<?php if ($this->params->get('show_cat_num_articles_cat') == 1) :?>
|
||||
<span class="badge badge-info tip hasTooltip" title="<?php echo JHtml::tooltipText('COM_WEBLINKS_NUM_ITEMS'); ?>">
|
||||
<?php echo $item->numitems; ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<?php if (count($item->getChildren()) > 0) : ?>
|
||||
<a href="#category-<?php echo $item->id;?>" data-toggle="collapse" data-toggle="button" class="btn btn-mini pull-right"><span class="icon-plus"></span></a>
|
||||
<?php endif;?>
|
||||
</h3>
|
||||
<?php if ($this->params->get('show_subcat_desc_cat') == 1) :?>
|
||||
<?php if ($item->description) : ?>
|
||||
<div class="category-desc">
|
||||
<?php echo JHtml::_('content.prepare', $item->description, '', 'com_weblinks.categories'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (count($item->getChildren()) > 0) :?>
|
||||
<div class="collapse fade" id="category-<?php echo $item->id;?>">
|
||||
<?php
|
||||
$this->items[$item->id] = $item->getChildren();
|
||||
$this->parent = $item;
|
||||
$this->maxLevelcat--;
|
||||
echo $this->loadTemplate('items');
|
||||
$this->parent = $item->getParent();
|
||||
$this->maxLevelcat++;
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
1
components/com_weblinks/views/categories/tmpl/index.html
Normal file
1
components/com_weblinks/views/categories/tmpl/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
122
components/com_weblinks/views/categories/view.html.php
Normal file
122
components/com_weblinks/views/categories/view.html.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Content categories view.
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.5
|
||||
*/
|
||||
class WeblinksViewCategories extends JViewLegacy
|
||||
{
|
||||
protected $state = null;
|
||||
|
||||
protected $item = null;
|
||||
|
||||
protected $items = null;
|
||||
|
||||
/**
|
||||
* Display the view
|
||||
*
|
||||
* @return mixed False on error, null otherwise.
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$state = $this->get('State');
|
||||
$items = $this->get('Items');
|
||||
$parent = $this->get('Parent');
|
||||
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
JError::raiseWarning(500, implode("\n", $errors));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($items === false)
|
||||
{
|
||||
return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
|
||||
}
|
||||
|
||||
if ($parent == false)
|
||||
{
|
||||
return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
|
||||
}
|
||||
|
||||
$params = &$state->params;
|
||||
|
||||
$items = array($parent->id => $items);
|
||||
|
||||
//Escape strings for HTML output
|
||||
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
|
||||
|
||||
$this->maxLevelcat = $params->get('maxLevelcat', -1);
|
||||
$this->params = &$params;
|
||||
$this->parent = &$parent;
|
||||
$this->items = &$items;
|
||||
|
||||
$this->_prepareDocument();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document
|
||||
*/
|
||||
protected function _prepareDocument()
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$menus = $app->getMenu();
|
||||
$title = null;
|
||||
|
||||
// Because the application sets a default page title,
|
||||
// we need to get it from the menu item itself
|
||||
$menu = $menus->getActive();
|
||||
if ($menu)
|
||||
{
|
||||
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->params->def('page_heading', JText::_('COM_WEBLINKS_DEFAULT_PAGE_TITLE'));
|
||||
}
|
||||
$title = $this->params->get('page_title', '');
|
||||
if (empty($title))
|
||||
{
|
||||
$title = $app->getCfg('sitename');
|
||||
}
|
||||
elseif ($app->getCfg('sitename_pagetitles', 0) == 1)
|
||||
{
|
||||
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
|
||||
}
|
||||
elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
|
||||
{
|
||||
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
|
||||
}
|
||||
$this->document->setTitle($title);
|
||||
|
||||
if ($this->params->get('menu-meta_description'))
|
||||
{
|
||||
$this->document->setDescription($this->params->get('menu-meta_description'));
|
||||
}
|
||||
|
||||
if ($this->params->get('menu-meta_keywords'))
|
||||
{
|
||||
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
|
||||
}
|
||||
|
||||
if ($this->params->get('robots'))
|
||||
{
|
||||
$this->document->setMetadata('robots', $this->params->get('robots'));
|
||||
}
|
||||
}
|
||||
}
|
1
components/com_weblinks/views/category/index.html
Normal file
1
components/com_weblinks/views/category/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
6
components/com_weblinks/views/category/metadata.xml
Normal file
6
components/com_weblinks/views/category/metadata.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<view title="Category">
|
||||
<message><![CDATA[TYPECATEGORYDESC]]></message>
|
||||
</view>
|
||||
</metadata>
|
14
components/com_weblinks/views/category/tmpl/default.php
Normal file
14
components/com_weblinks/views/category/tmpl/default.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
|
||||
$this->subtemplatename = 'items';
|
||||
echo JLayoutHelper::render('joomla.content.category_default', $this);
|
195
components/com_weblinks/views/category/tmpl/default.xml
Normal file
195
components/com_weblinks/views/category/tmpl/default.xml
Normal file
@ -0,0 +1,195 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<layout title="com_weblinks_category_view_default_title" option="com_weblinks_category_view_default_option">
|
||||
<help
|
||||
key="JHELP_MENUS_MENU_ITEM_WEBLINK_CATEGORY"
|
||||
/>
|
||||
<message>
|
||||
<![CDATA[com_weblinks_category_view_default_desc]]>
|
||||
</message>
|
||||
</layout>
|
||||
|
||||
<!-- Add fields to the request variables for the layout. -->
|
||||
<fields name="request">
|
||||
<fieldset name="request">
|
||||
|
||||
<field name="id" type="category"
|
||||
default="0"
|
||||
description="COM_WEBLINKS_FIELD_SELECT_CATEGORY_DESC"
|
||||
extension="com_weblinks"
|
||||
label="COM_WEBLINKS_FIELD_SELECT_CATEGORY_LABEL"
|
||||
required="true"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
|
||||
<!-- Add fields to the parameters object for the layout. -->
|
||||
<fields name="params">
|
||||
<fieldset name="basic" label="JGLOBAL_CATEGORY_OPTIONS">
|
||||
<field name="spacer1" type="spacer" class="text"
|
||||
label="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
|
||||
/>
|
||||
|
||||
<field name="show_category_title" type="list"
|
||||
label="JGLOBAL_SHOW_CATEGORY_TITLE"
|
||||
description="JGLOBAL_SHOW_CATEGORY_TITLE_DESC"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_description" type="list"
|
||||
description="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_DESC"
|
||||
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_description_image" type="list"
|
||||
description="JGLOBAL_SHOW_CATEGORY_IMAGE_DESC"
|
||||
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="maxLevel" type="list"
|
||||
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
|
||||
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JNONE</option>
|
||||
<option value="-1">JALL</option>
|
||||
<option value="1">J1</option>
|
||||
<option value="2">J2</option>
|
||||
<option value="3">J3</option>
|
||||
<option value="4">J4</option>
|
||||
<option value="5">J5</option>
|
||||
|
||||
</field>
|
||||
|
||||
<field name="show_empty_categories" type="list"
|
||||
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
|
||||
description="COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_subcat_desc" type="list"
|
||||
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
|
||||
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_cat_num_links" type="list"
|
||||
description="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC"
|
||||
label="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="advanced" label="JGLOBAL_LIST_LAYOUT_OPTIONS">
|
||||
<field name="spacer2" type="spacer" class="text"
|
||||
label="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="filter_field"
|
||||
type="list"
|
||||
default=""
|
||||
description="JGLOBAL_FILTER_FIELD_DESC"
|
||||
label="JGLOBAL_FILTER_FIELD_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="hide">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_pagination_limit" type="list"
|
||||
label="JGLOBAL_DISPLAY_SELECT_LABEL"
|
||||
description="JGLOBAL_DISPLAY_SELECT_DESC">
|
||||
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_headings" type="list"
|
||||
description="JGLOBAL_SHOW_HEADINGS_DESC"
|
||||
label="JGLOBAL_SHOW_HEADINGS_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_link_description" type="list"
|
||||
|
||||
description="COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_DESC"
|
||||
label="COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="show_link_hits" type="list"
|
||||
|
||||
description="COM_WEBLINKS_FIELD_CONFIG_HITS_DESC"
|
||||
label="JGLOBAL_HITS"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
|
||||
</field>
|
||||
|
||||
<field name="show_pagination" type="list"
|
||||
description="JGLOBAL_PAGINATION_DESC"
|
||||
label="JGLOBAL_PAGINATION_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="2">JGLOBAL_AUTO</option>
|
||||
</field>
|
||||
|
||||
<field name="show_pagination_results" type="list"
|
||||
|
||||
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
|
||||
description="JGLOBAL_PAGINATION_RESULTS_DESC">
|
||||
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="integration"
|
||||
>
|
||||
|
||||
<field name="show_feed_link" type="list"
|
||||
description="JGLOBAL_SHOW_FEED_LINK_DESC"
|
||||
label="JGLOBAL_SHOW_FEED_LINK_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
</fields>
|
||||
</metadata>
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
$class = ' class="first"';
|
||||
if (count($this->children[$this->category->id]) > 0 && $this->maxLevel != 0) :
|
||||
?>
|
||||
<ul>
|
||||
<?php foreach ($this->children[$this->category->id] as $id => $child) : ?>
|
||||
<?php
|
||||
if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) :
|
||||
if (!isset($this->children[$this->category->id][$id + 1]))
|
||||
{
|
||||
$class = ' class="last"';
|
||||
}
|
||||
?>
|
||||
<li<?php echo $class; ?>>
|
||||
<?php $class = ''; ?>
|
||||
<span class="item-title"><a href="<?php echo JRoute::_(WeblinksHelperRoute::getCategoryRoute($child->id));?>">
|
||||
<?php echo $this->escape($child->title); ?></a>
|
||||
</span>
|
||||
|
||||
<?php if ($this->params->get('show_subcat_desc') == 1) :?>
|
||||
<?php if ($child->description) : ?>
|
||||
<div class="category-desc">
|
||||
<?php echo JHtml::_('content.prepare', $child->description, '', 'com_weblinks.category'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_cat_num_links') == 1) :?>
|
||||
<dl class="weblink-count"><dt>
|
||||
<?php echo JText::_('COM_WEBLINKS_NUM'); ?></dt>
|
||||
<dd><?php echo $child->numitems; ?></dd>
|
||||
</dl>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (count($child->getChildren()) > 0 ) :
|
||||
$this->children[$child->id] = $child->getChildren();
|
||||
$this->category = $child;
|
||||
$this->maxLevel--;
|
||||
echo $this->loadTemplate('children');
|
||||
$this->category = $child->getParent();
|
||||
$this->maxLevel++;
|
||||
endif; ?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif;
|
177
components/com_weblinks/views/category/tmpl/default_items.php
Normal file
177
components/com_weblinks/views/category/tmpl/default_items.php
Normal file
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||
|
||||
JHtml::_('behavior.framework');
|
||||
|
||||
// Create a shortcut for params.
|
||||
$params = &$this->item->params;
|
||||
// Get the user object.
|
||||
$user = JFactory::getUser();
|
||||
// Check if user is allowed to add/edit based on weblinks permissinos.
|
||||
$canEdit = $user->authorise('core.edit', 'com_weblinks.category.'.$this->category->id);
|
||||
$canCreate = $user->authorise('core.create', 'com_weblinks');
|
||||
$canEditState = $user->authorise('core.edit.state', 'com_weblinks');
|
||||
|
||||
$n = count($this->items);
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
?>
|
||||
|
||||
<?php if (empty($this->items)) : ?>
|
||||
<p> <?php echo JText::_('COM_WEBLINKS_NO_WEBLINKS'); ?></p>
|
||||
<?php else : ?>
|
||||
|
||||
<form action="<?php echo htmlspecialchars(JUri::getInstance()->toString()); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<?php if ($this->params->get('filter_field') != 'hide' || $this->params->get('show_pagination_limit')) :?>
|
||||
<fieldset class="filters btn-toolbar">
|
||||
<?php if ($this->params->get('filter_field') != 'hide') :?>
|
||||
<div class="btn-group">
|
||||
<label class="filter-search-lbl element-invisible" for="filter-search"><span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span><?php echo JText::_('COM_WEBLINKS_FILTER_LABEL').' '; ?></label>
|
||||
<input type="text" name="filter-search" id="filter-search" value="<?php echo $this->escape($this->state->get('list.filter')); ?>" class="inputbox" onchange="document.adminForm.submit();" title="<?php echo JText::_('COM_WEBLINKS_FILTER_SEARCH_DESC'); ?>" placeholder="<?php echo JText::_('COM_WEBLINKS_FILTER_SEARCH_DESC'); ?>" />
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->params->get('show_pagination_limit')) : ?>
|
||||
<div class="btn-group pull-right">
|
||||
<label for="limit" class="element-invisible">
|
||||
<?php echo JText::_('JGLOBAL_DISPLAY_NUM'); ?>
|
||||
</label>
|
||||
<?php echo $this->pagination->getLimitBox(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
<ul class="category list-striped list-condensed">
|
||||
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<?php if (in_array($item->access, $this->user->getAuthorisedViewLevels())) : ?>
|
||||
<?php if ($this->items[$i]->state == 0) : ?>
|
||||
<li class="system-unpublished cat-list-row<?php echo $i % 2; ?>">
|
||||
<?php else: ?>
|
||||
<li class="cat-list-row<?php echo $i % 2; ?>" >
|
||||
<?php endif; ?>
|
||||
<?php if ($this->params->get('show_link_hits', 1)) : ?>
|
||||
<span class="list-hits badge badge-info pull-right">
|
||||
<?php echo JText::sprintf('JGLOBAL_HITS_COUNT', $item->hits); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canEdit) : ?>
|
||||
<span class="list-edit pull-left width-50">
|
||||
<?php echo JHtml::_('icon.edit', $item, $params); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="list-title">
|
||||
<?php if ($this->params->get('icons', 1) == 0) : ?>
|
||||
<?php echo JText::_('COM_WEBLINKS_LINK'); ?>
|
||||
<?php elseif ($this->params->get('icons', 1) == 1) : ?>
|
||||
<?php if (!$this->params->get('link_icons')) : ?>
|
||||
<?php echo JHtml::_('image', 'system/weblink.png', JText::_('COM_WEBLINKS_LINK'), null, true); ?>
|
||||
<?php else: ?>
|
||||
<?php echo '<img src="'.$this->params->get('link_icons').'" alt="'.JText::_('COM_WEBLINKS_LINK').'" />'; ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
// Compute the correct link
|
||||
$menuclass = 'category'.$this->pageclass_sfx;
|
||||
$link = $item->link;
|
||||
$width = $item->params->get('width');
|
||||
$height = $item->params->get('height');
|
||||
if ($width == null || $height == null)
|
||||
{
|
||||
$width = 600;
|
||||
$height = 500;
|
||||
}
|
||||
if ($this->items[$i]->state == 0) : ?>
|
||||
<span class="label label-warning">Unpublished</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php switch ($item->params->get('target', $this->params->get('target')))
|
||||
{
|
||||
case 1:
|
||||
// open in a new window
|
||||
echo '<a href="'. $link .'" target="_blank" class="'. $menuclass .'" rel="nofollow">'.
|
||||
$this->escape($item->title) .'</a>';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// open in a popup window
|
||||
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='.$this->escape($width).',height='.$this->escape($height).'';
|
||||
echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '".$attribs."'); return false;\">".
|
||||
$this->escape($item->title).'</a>';
|
||||
break;
|
||||
case 3:
|
||||
// open in a modal window
|
||||
JHtml::_('behavior.modal', 'a.modal');
|
||||
echo '<a class="modal" href="'.$link.'" rel="{handler: \'iframe\', size: {x:'.$this->escape($width).', y:'.$this->escape($height).'}}">'.
|
||||
$this->escape($item->title). ' </a>';
|
||||
break;
|
||||
|
||||
default:
|
||||
// open in parent window
|
||||
echo '<a href="'. $link . '" class="'. $menuclass .'" rel="nofollow">'.
|
||||
$this->escape($item->title) . ' </a>';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php $tagsData = $item->tags->getItemTags('com_weblinks.weblink', $item->id); ?>
|
||||
<?php if ($this->params->get('show_tags', 1)) : ?>
|
||||
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
|
||||
<?php echo $this->item->tagLayout->render($tagsData); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (($this->params->get('show_link_description')) and ($item->description != '')) : ?>
|
||||
<?php $images = json_decode($item->images); ?>
|
||||
<?php if (isset($images->image_first) and !empty($images->image_first)) : ?>
|
||||
<?php $imgfloat = (empty($images->float_first)) ? $this->params->get('float_first') : $images->float_first; ?>
|
||||
<div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>"> <img
|
||||
<?php if ($images->image_first_caption):
|
||||
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_first_caption) .'"';
|
||||
endif; ?>
|
||||
src="<?php echo htmlspecialchars($images->image_first); ?>" alt="<?php echo htmlspecialchars($images->image_first_alt); ?>"/> </div>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($images->image_second) and !empty($images->image_second)) : ?>
|
||||
<?php $imgfloat = (empty($images->float_second)) ? $this->params->get('float_second') : $images->float_second; ?>
|
||||
<div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img
|
||||
<?php if ($images->image_second_caption):
|
||||
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_second_caption) .'"';
|
||||
endif; ?>
|
||||
src="<?php echo htmlspecialchars($images->image_second); ?>" alt="<?php echo htmlspecialchars($images->image_second_alt); ?>"/> </div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo $item->description; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</li>
|
||||
<?php endif;?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<?php // Code to add a link to submit a weblink. ?>
|
||||
<?php /* if ($canCreate) : // TODO This is not working due to some problem in the router, I think. Ref issue #23685 ?>
|
||||
<?php echo JHtml::_('icon.create', $item, $item->params); ?>
|
||||
<?php endif; */ ?>
|
||||
<?php if ($this->params->get('show_pagination')) : ?>
|
||||
<div class="pagination">
|
||||
<?php if ($this->params->def('show_pagination_results', 1)) : ?>
|
||||
<p class="counter">
|
||||
<?php echo $this->pagination->getPagesCounter(); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<?php echo $this->pagination->getPagesLinks(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
<?php endif; ?>
|
1
components/com_weblinks/views/category/tmpl/index.html
Normal file
1
components/com_weblinks/views/category/tmpl/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
79
components/com_weblinks/views/category/view.feed.php
Normal file
79
components/com_weblinks/views/category/view.feed.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* HTML View class for the WebLinks component
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.0
|
||||
*/
|
||||
class WeblinksViewCategory extends JViewLegacy
|
||||
{
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$document = JFactory::getDocument();
|
||||
|
||||
$document->link = JRoute::_(WeblinksHelperRoute::getCategoryRoute($app->input->getInt('id')));
|
||||
|
||||
$app->input->set('limit', $app->getCfg('feed_limit'));
|
||||
$siteEmail = $app->getCfg('mailfrom');
|
||||
$fromName = $app->getCfg('fromname');
|
||||
$feedEmail = $app->getCfg('feed_email', 'author');
|
||||
$document->editor = $fromName;
|
||||
if ($feedEmail != "none")
|
||||
{
|
||||
$document->editorEmail = $siteEmail;
|
||||
}
|
||||
|
||||
// Get some data from the model
|
||||
$items = $this->get('Items');
|
||||
$category = $this->get('Category');
|
||||
|
||||
foreach ($items as $item)
|
||||
{
|
||||
// strip html from feed item title
|
||||
$title = $this->escape($item->title);
|
||||
$title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
|
||||
|
||||
// url link to article
|
||||
$link = JRoute::_(WeblinksHelperRoute::getWeblinkRoute($item->id, $item->catid));
|
||||
|
||||
// strip html from feed item description text
|
||||
$description = $item->description;
|
||||
$author = $item->created_by_alias ? $item->created_by_alias : $item->author;
|
||||
$date = ($item->date ? date('r', strtotime($item->date)) : '');
|
||||
|
||||
// load individual item creator class
|
||||
$feeditem = new JFeedItem;
|
||||
$feeditem->title = $title;
|
||||
$feeditem->link = $link;
|
||||
$feeditem->description = $description;
|
||||
$feeditem->date = $date;
|
||||
$feeditem->category = $category->title;
|
||||
$feeditem->author = $author;
|
||||
|
||||
// We don't have the author email so we have to use site in both cases.
|
||||
if ($feedEmail == 'site')
|
||||
{
|
||||
$feeditem->authorEmail = $siteEmail;
|
||||
}
|
||||
elseif ($feedEmail === 'author')
|
||||
{
|
||||
$feeditem->authorEmail = $item->author_email;
|
||||
}
|
||||
|
||||
// loads item info into rss array
|
||||
$document->addItem($feeditem);
|
||||
}
|
||||
}
|
||||
}
|
245
components/com_weblinks/views/category/view.html.php
Normal file
245
components/com_weblinks/views/category/view.html.php
Normal file
@ -0,0 +1,245 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* HTML View class for the WebLinks component
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.5
|
||||
*/
|
||||
class WeblinksViewCategory extends JViewLegacy
|
||||
{
|
||||
protected $state;
|
||||
|
||||
protected $items;
|
||||
|
||||
protected $category;
|
||||
|
||||
protected $children;
|
||||
|
||||
protected $pagination;
|
||||
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$params = $app->getParams();
|
||||
|
||||
// Get some data from the models
|
||||
$state = $this->get('State');
|
||||
$items = $this->get('Items');
|
||||
$category = $this->get('Category');
|
||||
$children = $this->get('Children');
|
||||
$parent = $this->get('Parent');
|
||||
$pagination = $this->get('Pagination');
|
||||
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
JError::raiseError(500, implode("\n", $errors));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($category == false)
|
||||
{
|
||||
return JError::raiseWarning(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
|
||||
}
|
||||
|
||||
if ($parent == false)
|
||||
{
|
||||
return JError::raiseWarning(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
|
||||
}
|
||||
|
||||
// Check whether category access level allows access.
|
||||
// TODO: SHould already be computed in $category->params->get('access-view')
|
||||
$user = JFactory::getUser();
|
||||
$groups = $user->getAuthorisedViewLevels();
|
||||
if (!in_array($category->access, $groups))
|
||||
{
|
||||
return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
|
||||
}
|
||||
|
||||
// Prepare the data.
|
||||
// Compute the weblink slug & link url.
|
||||
for ($i = 0, $n = count($items); $i < $n; $i++)
|
||||
{
|
||||
$item = &$items[$i];
|
||||
$item->slug = $item->alias ? ($item->id.':'.$item->alias) : $item->id;
|
||||
|
||||
if ($item->params->get('count_clicks', $params->get('count_clicks')) == 1)
|
||||
{
|
||||
$item->link = JRoute::_('index.php?option=com_weblinks&task=weblink.go&id='. $item->id);
|
||||
}
|
||||
else {
|
||||
$item->link = $item->url;
|
||||
}
|
||||
|
||||
$temp = new JRegistry;
|
||||
$temp->loadString($item->params);
|
||||
$item->params = clone($params);
|
||||
$item->params->merge($temp);
|
||||
}
|
||||
|
||||
// Setup the category parameters.
|
||||
$cparams = $category->getParams();
|
||||
$category->params = clone($params);
|
||||
$category->params->merge($cparams);
|
||||
|
||||
$children = array($category->id => $children);
|
||||
$maxLevel = $params->get('maxLevel', -1);
|
||||
|
||||
$this->maxLevel = &$maxLevel;
|
||||
$this->state = &$state;
|
||||
$this->items = &$items;
|
||||
$this->category = &$category;
|
||||
$this->children = &$children;
|
||||
$this->params = &$params;
|
||||
$this->parent = &$parent;
|
||||
$this->pagination = &$pagination;
|
||||
$this->user = &$user;
|
||||
//Escape strings for HTML output
|
||||
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
|
||||
|
||||
// Check for layout override only if this is not the active menu item
|
||||
// If it is the active menu item, then the view and category id will match
|
||||
$active = $app->getMenu()->getActive();
|
||||
if ((!$active) || ((strpos($active->link, 'view=category') === false) || (strpos($active->link, '&id=' . (string) $this->category->id) === false)))
|
||||
{
|
||||
if ($layout = $category->params->get('category_layout'))
|
||||
{
|
||||
$this->setLayout($layout);
|
||||
}
|
||||
}
|
||||
elseif (isset($active->query['layout']))
|
||||
{
|
||||
// We need to set the layout in case this is an alternative menu item (with an alternative layout)
|
||||
$this->setLayout($active->query['layout']);
|
||||
}
|
||||
|
||||
$this->category->tags = new JHelperTags;
|
||||
$this->category->tags->getItemTags('com_weblinks.category', $this->category->id);
|
||||
|
||||
$this->_prepareDocument();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document
|
||||
*/
|
||||
protected function _prepareDocument()
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$menus = $app->getMenu();
|
||||
$pathway = $app->getPathway();
|
||||
$title = null;
|
||||
|
||||
// Because the application sets a default page title,
|
||||
// we need to get it from the menu item itself
|
||||
$menu = $menus->getActive();
|
||||
|
||||
if ($menu)
|
||||
{
|
||||
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->params->def('page_heading', JText::_('COM_WEBLINKS_DEFAULT_PAGE_TITLE'));
|
||||
}
|
||||
|
||||
$id = (int) @$menu->query['id'];
|
||||
|
||||
if ($menu && ($menu->query['option'] != 'com_weblinks' || $id != $this->category->id))
|
||||
{
|
||||
$this->params->set('page_subheading', $this->category->title);
|
||||
$path = array(array('title' => $this->category->title, 'link' => ''));
|
||||
$category = $this->category->getParent();
|
||||
|
||||
while (($menu->query['option'] != 'com_weblinks' || $id != $category->id) && $category->id > 1)
|
||||
{
|
||||
$path[] = array('title' => $category->title, 'link' => WeblinksHelperRoute::getCategoryRoute($category->id));
|
||||
$category = $category->getParent();
|
||||
}
|
||||
|
||||
$path = array_reverse($path);
|
||||
|
||||
foreach ($path as $item)
|
||||
{
|
||||
$pathway->addItem($item['title'], $item['link']);
|
||||
}
|
||||
}
|
||||
|
||||
$title = $this->params->get('page_title', '');
|
||||
|
||||
if (empty($title))
|
||||
{
|
||||
$title = $app->getCfg('sitename');
|
||||
}
|
||||
elseif ($app->getCfg('sitename_pagetitles', 0) == 1)
|
||||
{
|
||||
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
|
||||
}
|
||||
elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
|
||||
{
|
||||
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
|
||||
}
|
||||
|
||||
$this->document->setTitle($title);
|
||||
|
||||
if ($this->category->metadesc)
|
||||
{
|
||||
$this->document->setDescription($this->category->metadesc);
|
||||
}
|
||||
elseif (!$this->category->metadesc && $this->params->get('menu-meta_description'))
|
||||
{
|
||||
$this->document->setDescription($this->params->get('menu-meta_description'));
|
||||
}
|
||||
|
||||
if ($this->category->metakey)
|
||||
{
|
||||
$this->document->setMetadata('keywords', $this->category->metakey);
|
||||
}
|
||||
elseif (!$this->category->metakey && $this->params->get('menu-meta_keywords'))
|
||||
{
|
||||
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
|
||||
}
|
||||
|
||||
if ($this->params->get('robots'))
|
||||
{
|
||||
$this->document->setMetadata('robots', $this->params->get('robots'));
|
||||
}
|
||||
|
||||
if ($app->getCfg('MetaAuthor') == '1')
|
||||
{
|
||||
$this->document->setMetaData('author', $this->category->getMetadata()->get('author'));
|
||||
}
|
||||
|
||||
$mdata = $this->category->getMetadata()->toArray();
|
||||
|
||||
foreach ($mdata as $k => $v)
|
||||
{
|
||||
if ($v)
|
||||
{
|
||||
$this->document->setMetadata($k, $v);
|
||||
}
|
||||
}
|
||||
|
||||
// Add alternative feed link
|
||||
if ($this->params->get('show_feed_link', 1) == 1)
|
||||
{
|
||||
$link = '&format=feed&limitstart=';
|
||||
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
|
||||
$this->document->addHeadLink(JRoute::_($link.'&type=rss'), 'alternate', 'rel', $attribs);
|
||||
$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
|
||||
$this->document->addHeadLink(JRoute::_($link.'&type=atom'), 'alternate', 'rel', $attribs);
|
||||
}
|
||||
}
|
||||
}
|
1
components/com_weblinks/views/form/index.html
Normal file
1
components/com_weblinks/views/form/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
7
components/com_weblinks/views/form/metadata.xml
Normal file
7
components/com_weblinks/views/form/metadata.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<view
|
||||
title="Form">
|
||||
<message><![CDATA[TYPEARTICLAYDESC]]></message>
|
||||
</view>
|
||||
</metadata>
|
123
components/com_weblinks/views/form/tmpl/edit.php
Normal file
123
components/com_weblinks/views/form/tmpl/edit.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JHtml::_('behavior.keepalive');
|
||||
JHtml::_('behavior.formvalidation');
|
||||
JHtml::_('formbehavior.chosen', 'select');
|
||||
|
||||
// Create shortcut to parameters.
|
||||
$params = $this->state->get('params');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
Joomla.submitbutton = function(task)
|
||||
{
|
||||
if (task == 'weblink.cancel' || document.formvalidator.isValid(document.id('adminForm')))
|
||||
{
|
||||
<?php echo $this->form->getField('description')->save(); ?>
|
||||
Joomla.submitform(task);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div class="edit<?php echo $this->pageclass_sfx; ?>">
|
||||
<?php if ($this->params->get('show_page_heading')) : ?>
|
||||
<h1>
|
||||
<?php echo $this->escape($this->params->get('page_heading')); ?>
|
||||
</h1>
|
||||
<?php endif; ?>
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&view=form&w_id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="adminForm" class="form-validate form-vertical">
|
||||
<div class="btn-toolbar">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-primary" onclick="Joomla.submitbutton('weblink.save')">
|
||||
<span class="icon-ok"></span> <?php echo JText::_('JSAVE') ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn" onclick="Joomla.submitbutton('weblink.cancel')">
|
||||
<span class="icon-cancel"></span> <?php echo JText::_('JCANCEL') ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="hr-condensed" />
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('title'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('title'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('alias'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('alias'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('catid'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('catid'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('url'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('url'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('tags'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('tags'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($this->user->authorise('core.edit.state', 'com_weblinks.weblink')) : ?>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('state'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('state'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('language'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('language'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $this->form->getLabel('description'); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $this->form->getInput('description'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="return" value="<?php echo $this->return_page;?>" />
|
||||
<input type="hidden" name="task" value="" />
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</form>
|
||||
</div>
|
12
components/com_weblinks/views/form/tmpl/edit.xml
Normal file
12
components/com_weblinks/views/form/tmpl/edit.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<layout
|
||||
title="com_weblinks_form_view_default_title" option="com_weblinks_form_view_default_option">
|
||||
<help
|
||||
key="JHELP_MENUS_MENU_ITEM_WEBLINK_SUBMIT"
|
||||
/>
|
||||
<message>
|
||||
<![CDATA[com_weblinks_form_view_default_desc]]>
|
||||
</message>
|
||||
</layout>
|
||||
</metadata>
|
1
components/com_weblinks/views/form/tmpl/index.html
Normal file
1
components/com_weblinks/views/form/tmpl/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
137
components/com_weblinks/views/form/view.html.php
Normal file
137
components/com_weblinks/views/form/view.html.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* HTML Article View class for the Weblinks component
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.5
|
||||
*/
|
||||
class WeblinksViewForm extends JViewLegacy
|
||||
{
|
||||
protected $form;
|
||||
|
||||
protected $item;
|
||||
|
||||
protected $return_page;
|
||||
|
||||
protected $state;
|
||||
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
|
||||
// Get model data.
|
||||
$this->state = $this->get('State');
|
||||
$this->item = $this->get('Item');
|
||||
$this->form = $this->get('Form');
|
||||
$this->return_page = $this->get('ReturnPage');
|
||||
|
||||
if (empty($this->item->id))
|
||||
{
|
||||
$authorised = ($user->authorise('core.create', 'com_weblinks') || (count($user->getAuthorisedCategories('com_weblinks', 'core.create'))));
|
||||
}
|
||||
else
|
||||
{
|
||||
$authorised = $user->authorise('core.edit', 'com_weblinks.category.'.$this->item->catid);
|
||||
|
||||
}
|
||||
|
||||
if ($authorised !== true)
|
||||
{
|
||||
JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($this->item))
|
||||
{
|
||||
$this->form->bind($this->item);
|
||||
}
|
||||
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
JError::raiseWarning(500, implode("\n", $errors));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a shortcut to the parameters.
|
||||
$params = &$this->state->params;
|
||||
|
||||
//Escape strings for HTML output
|
||||
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
|
||||
|
||||
$this->params = $params;
|
||||
$this->user = $user;
|
||||
|
||||
$this->_prepareDocument();
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document
|
||||
*/
|
||||
protected function _prepareDocument()
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$menus = $app->getMenu();
|
||||
$title = null;
|
||||
|
||||
// Because the application sets a default page title,
|
||||
// we need to get it from the menu item itself
|
||||
$menu = $menus->getActive();
|
||||
|
||||
if (empty($this->item->id))
|
||||
{
|
||||
$head = JText::_('COM_WEBLINKS_FORM_SUBMIT_WEBLINK');
|
||||
}
|
||||
else
|
||||
{
|
||||
$head = JText::_('COM_WEBLINKS_FORM_EDIT_WEBLINK');
|
||||
}
|
||||
|
||||
if ($menu)
|
||||
{
|
||||
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->params->def('page_heading', $head);
|
||||
}
|
||||
|
||||
$title = $this->params->def('page_title', $head);
|
||||
if ($app->getCfg('sitename_pagetitles', 0) == 1)
|
||||
{
|
||||
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
|
||||
}
|
||||
elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
|
||||
{
|
||||
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
|
||||
}
|
||||
$this->document->setTitle($title);
|
||||
|
||||
if ($this->params->get('menu-meta_description'))
|
||||
{
|
||||
$this->document->setDescription($this->params->get('menu-meta_description'));
|
||||
}
|
||||
|
||||
if ($this->params->get('menu-meta_keywords'))
|
||||
{
|
||||
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
|
||||
}
|
||||
|
||||
if ($this->params->get('robots'))
|
||||
{
|
||||
$this->document->setMetadata('robots', $this->params->get('robots'));
|
||||
}
|
||||
}
|
||||
}
|
1
components/com_weblinks/views/index.html
Normal file
1
components/com_weblinks/views/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
components/com_weblinks/views/weblink/index.html
Normal file
1
components/com_weblinks/views/weblink/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
components/com_weblinks/views/weblink/tmpl/index.html
Normal file
1
components/com_weblinks/views/weblink/tmpl/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
47
components/com_weblinks/views/weblink/view.html.php
Normal file
47
components/com_weblinks/views/weblink/view.html.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* HTML View class for the WebLinks component
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
* @since 1.5
|
||||
*/
|
||||
class WeblinksViewWeblink extends JViewLegacy
|
||||
{
|
||||
protected $state;
|
||||
|
||||
protected $item;
|
||||
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// Get some data from the models
|
||||
$item = $this->get('Item');
|
||||
|
||||
if ($this->getLayout() == 'edit')
|
||||
{
|
||||
$this->_displayEdit($tpl);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($item->url)
|
||||
{
|
||||
// redirects to url if matching id found
|
||||
JFactory::getApplication()->redirect($item->url);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO create proper error handling
|
||||
JFactory::getApplication()->redirect(JRoute::_('index.php'), JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 'notice');
|
||||
}
|
||||
}
|
||||
}
|
16
components/com_weblinks/weblinks.php
Normal file
16
components/com_weblinks/weblinks.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 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(JFactory::getApplication()->input->get('task'));
|
||||
$controller->redirect();
|
Reference in New Issue
Block a user