Merge remote-tracking branch 'refs/remotes/joomla-extensions/master' into acl-edit-own

This commit is contained in:
andrepereiradasilva 2016-08-07 02:16:42 +01:00
commit ed336b0466
61 changed files with 1869 additions and 792 deletions

View File

@ -29,19 +29,12 @@ If you find any new bugs, or want to raise any type of support issue, please use
## Release Procedure ## Release Procedure
This is the procedure and checklist for creating a new package. This is the procedure and checklist for creating a new package:
* Update the version number in `build.ini`. * Update the version number in `jorobo.ini`
* Run `phing set-version`. * Modify `jorobo.ini`, add your GitHub token and add ` Release` after `Package`
* Pun `phing` to make the new package for the version. * Run `robo build` to make the new package and auto-upload and release it on GitHub.
* Run `phing tag`. * Go to the releases page on GitHub, review the Changelog and change the status from Pre-Release to Stable.
* Push the commits and tags up to Github.
* Go to the releases page on Github.
* Click on the new tag.
- Click the `Edit Tag` button.
- Fill in the title and description for the release.
- Attach the zip-file for the package to the release. Wait for the file to complete uploading!
- Click the `Publish Release` button.
* Create a new `<update>` tag in the `manifest.xml` file. * Create a new `<update>` tag in the `manifest.xml` file.
- Change the `<version>` tag to the new version. - Change the `<version>` tag to the new version.
- Change the `<downloadurl>` tag to match the URL of the new release. - Change the `<downloadurl>` tag to match the URL of the new release.

18
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,18 @@
#### Steps to reproduce the issue
#### Expected result
#### Actual result
#### System information (as much as possible)
#### Additional comments

5
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,5 @@
Pull Request for Issue # .
#### Summary of Changes
#### Testing Instructions

View File

@ -1,29 +1,34 @@
language: php language: php
php:
- 5.5 env:
- 5.6 global:
addons: - RUN_PHPCS="no"
firefox: "44.0.2"
matrix: matrix:
allow_failures: fast_finish: true
- php: 5.6 include:
- php: 5.5
- php: 5.6
env: RUN_PHPCS="yes"
- php: 7.0
sudo: true
addons:
firefox: "47.0.1"
allow_failures:
- php: 7.0
before_script: before_script:
- sudo apt-get update -qq - sudo apt-get update -qq
- sudo apt-get install -y --force-yes apache2 libapache2-mod-fastcgi php5-curl php5-mysql php5-intl php5-gd > /dev/null - sudo apt-get install -y --force-yes apache2 libapache2-mod-fastcgi > /dev/null
- sudo mkdir $(pwd)/.run - sudo mkdir $(pwd)/.run
- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf - chmod a+x tests/travis-php-fpm.sh
- sudo sed -e "s,listen = 127.0.0.1:9000,listen = /tmp/php5-fpm.sock,g" --in-place ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf - sudo ./tests/travis-php-fpm.sh $USER $(phpenv version-name)
- sudo sed -e "s,;listen.owner = nobody,listen.owner = $USER,g" --in-place ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- sudo sed -e "s,;listen.group = nobody,listen.group = $USER,g" --in-place ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- sudo sed -e "s,;listen.mode = 0660,listen.mode = 0666,g" --in-place ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- sudo sed -e "s,user = nobody,;user = $USER,g" --in-place ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- sudo sed -e "s,group = nobody,;group = $USER,g" --in-place ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- cat ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- sudo a2enmod rewrite actions fastcgi alias - sudo a2enmod rewrite actions fastcgi alias
- echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
- sudo cp -f tests/travis-ci-apache.conf /etc/apache2/sites-available/default - sudo cp -f tests/travis-ci-apache.conf /etc/apache2/sites-available/default
- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default
- sudo sed -e "s?%PHPVERSION%?${TRAVIS_PHP_VERSION:0:1}?g" --in-place /etc/apache2/sites-available/default
- git submodule update --init --recursive - git submodule update --init --recursive
- sudo service apache2 restart - sudo service apache2 restart
# Xvfb # Xvfb
@ -41,5 +46,8 @@ script:
# Build # Build
- mv jorobo.dist.ini jorobo.ini - mv jorobo.dist.ini jorobo.ini
- vendor/bin/robo build - vendor/bin/robo build
# System tests (Codeception)
- mv tests/acceptance.suite.dist.yml tests/acceptance.suite.yml - mv tests/acceptance.suite.dist.yml tests/acceptance.suite.yml
- vendor/bin/robo run:tests --use-htaccess - vendor/bin/robo run:tests --use-htaccess
# Run phpcs on PHP 5.6 against weblinks source
- if [[ $RUN_PHPCS == "yes" ]]; then vendor/bin/phpcs --report=full --extensions=php -p --standard=tests/joomla-cms3/build/phpcs/Joomla ./src; fi

View File

@ -2,6 +2,20 @@
This repo is meant to hold the decoupled com_weblinks component and related code. This repo is meant to hold the decoupled com_weblinks component and related code.
How to test a PR with the [Patch Tester Component](https://github.com/joomla-extensions/patchtester/releases/latest)
============
Easily apply changes from a pull requests against this repo:
Install the last release of [com_weblinks](https://github.com/joomla-extensions/weblinks/releases/latest) into your Joomla.
Install the last release of [com_patchtester](https://github.com/joomla-extensions/patchtester/releases/latest) into your Joomla (weblinks is supported since Version 3.0.0 Alpha 2).
Log into your site's administrator section, go to the Patch Tester Component Options (Components -> Patch Tester -> Options)
Switch the `GitHub Repository` to `Joomla Weblinks Package`
Click `Save & Close` and hit the `Fetch Data` Button to the the lastest pull requests
Click `Apply Patch` to apply the proposed changes from the pull request.
Click `Revert Patch` to revert an applied patch.
You can read more about the Patch Tester extension on the [Joomla! Documentation Wiki](https://docs.joomla.org/Component_Patchtester_for_Testers).
# Building # Building
```bash ```bash

View File

@ -66,9 +66,17 @@ class RoboFile extends \Robo\Tasks
{ {
if ($this->isWindows()) if ($this->isWindows())
{ {
return '.exe'; // check wehter git.exe or git as command should be used,
// as on window both is possible
if(!$this->_exec('git.exe --version')->getMessage())
{
return '';
}
else
{
return '.exe';
}
} }
return ''; return '';
} }

View File

@ -11,12 +11,13 @@
"php": ">=5.3.10" "php": ">=5.3.10"
}, },
"require-dev": { "require-dev": {
"codeception/codeception": "~2.1", "codeception/codeception": "^2.2",
"joomla-projects/joomla-browser": "v3.4.8.3", "joomla-projects/joomla-browser": "v3.6.0",
"codegyre/robo": "~0.5", "codegyre/robo": "~0.5",
"joomla-projects/robo": "dev-master", "joomla-projects/robo": "dev-master",
"joomla-projects/selenium-server-standalone": "v2.52.0", "joomla-projects/selenium-server-standalone": "v2.53.1",
"fzaninotto/faker": "^1.5", "fzaninotto/faker": "^1.5",
"joomla-projects/jorobo": "0.3" "joomla-projects/jorobo": "0.4",
"Behat/Gherkin": "^4.4.1"
} }
} }

697
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -2,3 +2,36 @@ extension = weblinks
version = 3.5.0 version = 3.5.0
source = src source = src
target = package target = package
; Create a pre-release of the extension on GitHub
; Add your personal GitHub access tocken
; and add Release to the target (separated by space) above
[github]
remote = origin
branch = develop
token =
owner = joomla-extensions
repository = weblinks
changelog_source = commits
; Automatic upload of the built extension package to an FTP server
[ftp]
host =
port = 21
user =
password =
ssl = false
target = /
; Adds / replaces copyright headers at the beginning of files in the source folder
[header]
files = php,js
exclude =
text = "
/**
* @package Weblinks
*
* @copyright Copyright (C) 2005 - ##YEAR## Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
"

View File

@ -11,6 +11,6 @@
<downloads> <downloads>
<downloadurl type="full" format="zip">https://github.com/joomla-extensions/weblinks/releases/download/3.5.0/pkg-weblinks-3.5.0.zip</downloadurl> <downloadurl type="full" format="zip">https://github.com/joomla-extensions/weblinks/releases/download/3.5.0/pkg-weblinks-3.5.0.zip</downloadurl>
</downloads> </downloads>
<targetplatform name="joomla" version="3.[456789]" /> <targetplatform name="joomla" version="3.[56789]" />
</update> </update>
</updates> </updates>

View File

@ -5,6 +5,19 @@
description="COM_WEBLINKS_COMPONENT_DESC" description="COM_WEBLINKS_COMPONENT_DESC"
> >
<field
name="captcha"
type="plugins"
label="COM_WEBLINKS_FIELD_CAPTCHA_LABEL"
description="COM_WEBLINKS_FIELD_CAPTCHA_DESC"
default=""
folder="captcha"
filter="cmd"
>
<option value="">JOPTION_USE_DEFAULT</option>
<option value="0">JOPTION_DO_NOT_USE</option>
</field>
<field name="target" type="list" <field name="target" type="list"
default="0" default="0"
description="COM_WEBLINKS_FIELD_TARGET_DESC" description="COM_WEBLINKS_FIELD_TARGET_DESC"

View File

@ -19,14 +19,15 @@ class WeblinksController extends JControllerLegacy
/** /**
* Method to display a view. * Method to display a view.
* *
* @param boolean $cachable If true, the view output will be cached * @param boolean $cacheable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * @param array $urlparams An array of safe url parameters and their variable types,
* for valid values see {@link JFilterInput::clean()}.
* *
* @return JControllerLegacy This object to support chaining. * @return JControllerLegacy This object to support chaining.
* *
* @since 1.5 * @since 1.5
*/ */
public function display($cachable = false, $urlparams = false) public function display($cacheable = false, $urlparams = false)
{ {
require_once JPATH_COMPONENT . '/helpers/weblinks.php'; require_once JPATH_COMPONENT . '/helpers/weblinks.php';

View File

@ -9,6 +9,8 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/** /**
* Weblink controller class. * Weblink controller class.
* *
@ -27,14 +29,13 @@ class WeblinksControllerWeblink extends JControllerForm
*/ */
protected function allowAdd($data = array()) protected function allowAdd($data = array())
{ {
$user = JFactory::getUser(); $categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('filter_category_id'), 'int');
$categoryId = JArrayHelper::getValue($data, 'catid', $this->input->getInt('filter_category_id'), 'int');
$allow = null; $allow = null;
if ($categoryId) if ($categoryId)
{ {
// If the category has been passed in the URL check it. // If the category has been passed in the URL check it.
$allow = $user->authorise('core.create', $this->option . '.category.' . $categoryId); $allow = JFactory::getUser()->authorise('core.create', $this->option . '.category.' . $categoryId);
} }
if ($allow !== null) if ($allow !== null)
@ -112,9 +113,9 @@ class WeblinksControllerWeblink extends JControllerForm
* @param JModelLegacy $model The data model object. * @param JModelLegacy $model The data model object.
* @param array $validData The validated data. * @param array $validData The validated data.
* *
* @return void * @return void
* *
* @since 1.6 * @since 1.6
*/ */
protected function postSaveHook(JModelLegacy $model, $validData = array()) protected function postSaveHook(JModelLegacy $model, $validData = array())
{ {

View File

@ -39,4 +39,57 @@ class WeblinksHelper extends JHelperContent
$vName == 'categories' $vName == 'categories'
); );
} }
/**
* Adds Count Items for WebLinks Category Manager.
*
* @param stdClass[] &$items The weblinks category objects.
*
* @return stdClass[] The weblinks category objects.
*
* @since 3.6.0
*/
public static function countItems(&$items)
{
$db = JFactory::getDbo();
foreach ($items as $item)
{
$item->count_trashed = 0;
$item->count_archived = 0;
$item->count_unpublished = 0;
$item->count_published = 0;
$query = $db->getQuery(true)
->select('state, COUNT(*) AS count')
->from($db->qn('#__weblinks'))
->where($db->qn('catid') . ' = ' . (int) $item->id)
->group('state');
$db->setQuery($query);
$weblinks = $db->loadObjectList();
foreach ($weblinks as $weblink)
{
if ($weblink->state == 1)
{
$item->count_published = $weblink->count;
}
elseif ($weblink->state == 0)
{
$item->count_unpublished = $weblink->count;
}
elseif ($weblink->state == 2)
{
$item->count_archived = $weblink->count;
}
elseif ($weblink->state == -2)
{
$item->count_trashed = $weblink->count;
}
}
}
return $items;
}
} }

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
label="COM_WEBLINKS_FILTER_SEARCH_LABEL"
description="COM_WEBLINKS_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="published"
type="status"
label="JOPTION_FILTER_PUBLISHED"
description="JOPTION_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="category_id"
type="category"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
extension="com_weblinks"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_CATEGORY</option>
</field>
<field
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_ACCESS</option>
</field>
<field
name="language"
type="contentlanguage"
label="JOPTION_FILTER_LANGUAGE"
description="JOPTION_FILTER_LANGUAGE_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
<field
name="tag"
type="tag"
label="JOPTION_FILTER_TAG"
description="JOPTION_FILTER_TAG_DESC"
mode="nested"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_TAG</option>
</field>
<field
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="10"
step="1"
languages="*"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_MAX_LEVELS</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
onchange="this.form.submit();"
default="a.title ASC"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="category_title ASC">JCATEGORY_ASC</option>
<option value="category_title DESC">JCATEGORY_DESC</option>
<option value="access_level ASC">JGRID_HEADING_ACCESS_ASC</option>
<option value="access_level DESC">JGRID_HEADING_ACCESS_DESC</option>
<option value="a.hits ASC">JGLOBAL_HITS_ASC</option>
<option value="a.hits DESC">JGLOBAL_HITS_DESC</option>
<option value="language_title ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="language_title DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>

View File

@ -19,7 +19,7 @@ class WeblinksModelWeblinks extends JModelList
/** /**
* Constructor. * Constructor.
* *
* @param array An optional associative array of configuration settings. * @param array $config An optional associative array of configuration settings.
* *
* @see JControllerLegacy * @see JControllerLegacy
* @since 1.6 * @since 1.6
@ -34,18 +34,23 @@ class WeblinksModelWeblinks extends JModelList
'alias', 'a.alias', 'alias', 'a.alias',
'checked_out', 'a.checked_out', 'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time', 'checked_out_time', 'a.checked_out_time',
'catid', 'a.catid', 'category_title', 'catid', 'a.catid', 'category_id',
'state', 'a.state', 'c.title', 'category_title',
'access', 'a.access', 'access_level', 'state', 'a.state', 'published',
'access', 'a.access',
'ag.title', 'access_level',
'created', 'a.created', 'created', 'a.created',
'created_by', 'a.created_by', 'created_by', 'a.created_by',
'ordering', 'a.ordering', 'ordering', 'a.ordering',
'featured', 'a.featured', 'featured', 'a.featured',
'language', 'a.language', 'language', 'a.language',
'l.title', 'language_title',
'hits', 'a.hits', 'hits', 'a.hits',
'publish_up', 'a.publish_up', 'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down', 'publish_down', 'a.publish_down',
'url', 'a.url', 'url', 'a.url',
'tag',
'level', 'c.level',
); );
} }
@ -55,38 +60,31 @@ class WeblinksModelWeblinks extends JModelList
/** /**
* Method to auto-populate the model state. * Method to auto-populate the model state.
* *
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void * @return void
* *
* @note Calling getState in this method will result in recursion. * @note Calling getState in this method will result in recursion.
* @since 1.6 * @since 1.6
*/ */
protected function populateState($ordering = null, $direction = null) protected function populateState($ordering = 'a.title', $direction = 'asc')
{ {
// Load the filter state. // Load the filter state.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.search', $search); $this->setState('filter.access', $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', '', 'cmd'));
$this->setState('filter.published', $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '', 'string'));
$accessId = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', null, 'int'); $this->setState('filter.category_id', $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id', '', 'cmd'));
$this->setState('filter.access', $accessId); $this->setState('filter.language', $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '', 'string'));
$this->setState('filter.tag', $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', '', 'string'));
$published = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string'); $this->setState('filter.level', $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level', '', 'cmd'));
$this->setState('filter.state', $published);
$categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id', '');
$this->setState('filter.category_id', $categoryId);
$language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
$tag = $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', '');
$this->setState('filter.tag', $tag);
// Load the parameters. // Load the parameters.
$params = JComponentHelper::getParams('com_weblinks'); $params = JComponentHelper::getParams('com_weblinks');
$this->setState('params', $params); $this->setState('params', $params);
// List state information. // List state information.
parent::populateState('a.title', 'asc'); parent::populateState($ordering, $direction);
} }
/** /**
@ -107,9 +105,11 @@ class WeblinksModelWeblinks extends JModelList
// Compile the store id. // Compile the store id.
$id .= ':' . $this->getState('filter.search'); $id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.access'); $id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.state'); $id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.category_id'); $id .= ':' . $this->getState('filter.category_id');
$id .= ':' . $this->getState('filter.language'); $id .= ':' . $this->getState('filter.language');
$id .= ':' . $this->getState('filter.tag');
$id .= ':' . $this->getState('filter.level');
return parent::getStoreId($id); return parent::getStoreId($id);
} }
@ -136,47 +136,48 @@ class WeblinksModelWeblinks extends JModelList
'a.hits, a.state, a.access, a.ordering, a.language, a.publish_up, a.publish_down' 'a.hits, a.state, a.access, a.ordering, a.language, a.publish_up, a.publish_down'
) )
); );
$query->from($db->quoteName('#__weblinks') . ' AS a'); $query->from($db->quoteName('#__weblinks', 'a'));
// Join over the language // Join over the language
$query->select('l.title AS language_title, l.image AS language_image') $query->select($db->quoteName('l.title', 'language_title'))
->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language'); ->select($db->quoteName('l.image', 'language_image'))
->join('LEFT', $db->quoteName('#__languages', 'l') . ' ON ' . $db->qn('l.lang_code') . ' = ' . $db->qn('a.language'));
// Join over the users for the checked out user. // Join over the users for the checked out user.
$query->select('uc.name AS editor') $query->select($db->quoteName('uc.name', 'editor'))
->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); ->join('LEFT', $db->quoteName('#__users', 'uc') . ' ON ' . $db->qn('uc.id') . ' = ' . $db->qn('a.checked_out'));
// Join over the asset groups. // Join over the asset groups.
$query->select('ag.title AS access_level') $query->select($db->quoteName('ag.title', 'access_level'))
->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); ->join('LEFT', $db->quoteName('#__viewlevels', 'ag') . ' ON ' . $db->qn('ag.id') . ' = ' . $db->qn('a.access'));
// Join over the categories. // Join over the categories.
$query->select('c.title AS category_title') $query->select('c.title AS category_title')
->join('LEFT', '#__categories AS c ON c.id = a.catid'); ->join('LEFT', $db->quoteName('#__categories', 'c') . ' ON ' . $db->qn('c.id') . ' = ' . $db->qn('a.catid'));
// Filter by access level. // Filter by access level.
if ($access = $this->getState('filter.access')) if ($access = $this->getState('filter.access'))
{ {
$query->where('a.access = ' . (int) $access); $query->where($db->quoteName('a.access') . ' = ' . (int) $access);
} }
// Implement View Level Access // Implement View Level Access
if (!$user->authorise('core.admin')) if (!$user->authorise('core.admin'))
{ {
$groups = implode(',', $user->getAuthorisedViewLevels()); $groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')'); $query->where($db->quoteName('a.access') . ' IN (' . $groups . ')');
} }
// Filter by published state // Filter by published state
$published = $this->getState('filter.state'); $published = $this->getState('filter.published');
if (is_numeric($published)) if (is_numeric($published))
{ {
$query->where('a.state = ' . (int) $published); $query->where($db->quoteName('a.state') . ' = ' . (int) $published);
} }
elseif ($published === '') elseif ($published === '')
{ {
$query->where('(a.state IN (0, 1))'); $query->where('(' . $db->quoteName('a.state') . ' IN (0, 1))');
} }
// Filter by category. // Filter by category.
@ -184,7 +185,13 @@ class WeblinksModelWeblinks extends JModelList
if (is_numeric($categoryId)) if (is_numeric($categoryId))
{ {
$query->where('a.catid = ' . (int) $categoryId); $query->where($db->quoteName('a.catid') . ' = ' . (int) $categoryId);
}
// Filter on the level.
if ($level = $this->getState('filter.level'))
{
$query->where($db->quoteName('c.level') . ' <= ' . (int) $level);
} }
// Filter by search in title // Filter by search in title
@ -194,19 +201,19 @@ class WeblinksModelWeblinks extends JModelList
{ {
if (stripos($search, 'id:') === 0) if (stripos($search, 'id:') === 0)
{ {
$query->where('a.id = ' . (int) substr($search, 3)); $query->where($db->quoteName('a.id') . ' = ' . (int) substr($search, 3));
} }
else else
{ {
$search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%')); $search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%'));
$query->where('(a.title LIKE ' . $search . ' OR a.alias LIKE ' . $search . ')'); $query->where('(' . $db->quoteName('a.title') . ' LIKE ' . $search . ' OR ' . $db->quoteName('a.alias') . ' LIKE ' . $search . ')');
} }
} }
// Filter on the language. // Filter on the language.
if ($language = $this->getState('filter.language')) if ($language = $this->getState('filter.language'))
{ {
$query->where('a.language = ' . $db->quote($language)); $query->where($db->quoteName('a.language') . ' = ' . $db->quote($language));
} }
$tagId = $this->getState('filter.tag'); $tagId = $this->getState('filter.tag');
@ -223,8 +230,8 @@ class WeblinksModelWeblinks extends JModelList
} }
// Add the list ordering clause. // Add the list ordering clause.
$orderCol = $this->state->get('list.ordering'); $orderCol = $this->state->get('list.ordering', 'a.title');
$orderDirn = $this->state->get('list.direction'); $orderDirn = $this->state->get('list.direction', 'ASC');
if ($orderCol == 'a.ordering' || $orderCol == 'category_title') if ($orderCol == 'a.ordering' || $orderCol == 'category_title')
{ {

View File

@ -151,11 +151,26 @@ class Com_WeblinksInstallerScript
$query->values( $query->values(
$db->quote('Weblink') . ', ' $db->quote('Weblink') . ', '
. $db->quote('com_weblinks.weblink') . ', ' . $db->quote('com_weblinks.weblink') . ', '
. $db->quote('{"special":{"dbtable":"#__weblinks","key":"id","type":"Weblink","prefix":"WeblinksTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}') . ', ' . $db->quote(
'{"special":{"dbtable":"#__weblinks","key":"id","type":"Weblink","prefix":"WeblinksTable","config":"array()"},
"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}') . ', '
. $db->quote('') . ', ' . $db->quote('') . ', '
. $db->quote('{"common":{"core_content_item_id":"id","core_title":"title","core_state":"state","core_alias":"alias","core_created_time":"created","core_modified_time":"modified","core_body":"description", "core_hits":"hits","core_publish_up":"publish_up","core_publish_down":"publish_down","core_access":"access", "core_params":"params", "core_featured":"featured", "core_metadata":"metadata", "core_language":"language", "core_images":"images", "core_urls":"url", "core_version":"version", "core_ordering":"ordering", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"catid", "core_xreference":"xreference", "asset_id":"null"}, "special":{}}') . ', ' . $db->quote(
'{"common":{"core_content_item_id":"id","core_title":"title","core_state":"state","core_alias":"alias",
"core_created_time":"created","core_modified_time":"modified","core_body":"description", "core_hits":"hits",
"core_publish_up":"publish_up","core_publish_down":"publish_down","core_access":"access", "core_params":"params",
"core_featured":"featured", "core_metadata":"metadata", "core_language":"language", "core_images":"images", "core_urls":"url",
"core_version":"version", "core_ordering":"ordering", "core_metakey":"metakey", "core_metadesc":"metadesc",
"core_catid":"catid", "core_xreference":"xreference", "asset_id":"null"}, "special":{}}') . ', '
. $db->quote('WeblinksHelperRoute::getWeblinkRoute') . ', ' . $db->quote('WeblinksHelperRoute::getWeblinkRoute') . ', '
. $db->quote('{"formFile":"administrator\\/components\\/com_weblinks\\/models\\/forms\\/weblink.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","featured","images"], "ignoreChanges":["modified_by", "modified", "checked_out", "checked_out_time", "version", "hits"], "convertToInt":["publish_up", "publish_down", "featured", "ordering"], "displayLookup":[{"sourceColumn":"catid","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"created_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"} ]}') . $db->quote(
'{"formFile":"administrator\\/components\\/com_weblinks\\/models\\/forms\\/weblink.xml",
"hideFields":["asset_id","checked_out","checked_out_time","version","featured","images"], "ignoreChanges":["modified_by",
"modified", "checked_out", "checked_out_time", "version", "hits"], "convertToInt":["publish_up", "publish_down", "featured",
"ordering"], "displayLookup":[{"sourceColumn":"catid","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"},
{"sourceColumn":"created_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},
{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},
{"sourceColumn":"modified_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"} ]}')
); );
$db->setQuery($query); $db->setQuery($query);
@ -172,11 +187,29 @@ class Com_WeblinksInstallerScript
$query->values( $query->values(
$db->quote('Weblinks Category') . ', ' $db->quote('Weblinks Category') . ', '
. $db->quote('com_weblinks.category') . ', ' . $db->quote('com_weblinks.category') . ', '
. $db->quote('{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}') . ', ' . $db->quote('
{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},
"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}') . ', '
. $db->quote('') . ', ' . $db->quote('') . ', '
. $db->quote('{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}') . ', ' . $db->quote('
{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias",
"core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description",
"core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access",
"core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language",
"core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey",
"core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"},
"special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}') . ', '
. $db->quote('WeblinksHelperRoute::getCategoryRoute') . ', ' . $db->quote('WeblinksHelperRoute::getCategoryRoute') . ', '
. $db->quote('{"formFile":"administrator\\/components\\/com_categories\\/models\\/forms\\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}') . $db->quote('
{"formFile":"administrator\\/components\\/com_categories\\/models\\/forms\\/category.xml",
"hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"],
"ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version",
"hits", "path"],"convertToInt":["publish_up", "publish_down"],
"displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id",
"displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id",
"displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id",
"displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id",
"displayColumn":"title"}]}')
); );
$db->setQuery($query); $db->setQuery($query);

View File

@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS `#__weblinks` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`catid` int(11) NOT NULL DEFAULT 0, `catid` int(11) NOT NULL DEFAULT 0,
`title` varchar(250) NOT NULL DEFAULT '', `title` varchar(250) NOT NULL DEFAULT '',
`alias` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `alias` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '',
`url` varchar(250) NOT NULL DEFAULT '', `url` varchar(250) NOT NULL DEFAULT '',
`description` text NOT NULL, `description` text NOT NULL,
`hits` int(11) NOT NULL DEFAULT 0, `hits` int(11) NOT NULL DEFAULT 0,
@ -48,4 +48,4 @@ CREATE TABLE IF NOT EXISTS `#__weblinks` (
KEY `idx_featured_catid` (`featured`,`catid`), KEY `idx_featured_catid` (`featured`,`catid`),
KEY `idx_language` (`language`), KEY `idx_language` (`language`),
KEY `idx_xreference` (`xreference`) KEY `idx_xreference` (`xreference`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

View File

@ -0,0 +1,25 @@
# Conversion to utf8mb4
--
-- Step 1.1: Enlarge columns to avoid data loss on later conversion to utf8mb4
--
ALTER TABLE `#__weblinks` MODIFY `alias` varchar(400) NOT NULL DEFAULT '';
--
-- Step 1.2: Convert table to utf8mb4 chracter set with utf8mb4_unicode_ci collation
--
ALTER TABLE `#__weblinks` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
--
-- Step 1.3: Set collation to utf8mb4_bin for formerly utf8_bin collated columns
--
ALTER TABLE `#__weblinks` MODIFY `alias` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '';
--
-- Step 1.4: Set default character set and collation for all tables
--
ALTER TABLE `#__weblinks` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

View File

@ -45,7 +45,7 @@ class WeblinksTableWeblink extends JTable
/** /**
* Overload the store method for the Weblinks table. * Overload the store method for the Weblinks table.
* *
* @param boolean Toggle whether null values should be updated. * @param boolean $updateNulls Toggle whether null values should be updated.
* *
* @return boolean True on success, false on failure. * @return boolean True on success, false on failure.
* *
@ -122,7 +122,7 @@ class WeblinksTableWeblink extends JTable
return false; return false;
} }
// check for valid name // Check for valid name
if (trim($this->title) == '') if (trim($this->title) == '')
{ {
$this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_TITLE')); $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_TITLE'));

View File

@ -9,20 +9,17 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
$fieldSets = $this->form->getFieldsets('params'); $fieldSets = $this->form->getFieldsets('params'); ?>
foreach ($fieldSets as $name => $fieldSet) : <?php foreach ($fieldSets as $name => $fieldSet) : ?>
?> <div class="tab-pane" id="params-<?php echo $name; ?>">
<div class="tab-pane" id="params-<?php echo $name;?>"> <?php if (isset($fieldSet->description) && trim($fieldSet->description)) : ?>
<?php <?php echo '<p class="alert alert-info">' . $this->escape(JText::_($fieldSet->description)) . '</p>'; ?>
if (isset($fieldSet->description) && trim($fieldSet->description)) : <?php endif; ?>
echo '<p class="alert alert-info">'.$this->escape(JText::_($fieldSet->description)).'</p>'; <?php foreach ($this->form->getFieldset($name) as $field) : ?>
endif; <div class="control-group">
?> <div class="control-label"><?php echo $field->label; ?></div>
<?php foreach ($this->form->getFieldset($name) as $field) : ?> <div class="controls"><?php echo $field->input; ?></div>
<div class="control-group"> </div>
<div class="control-label"><?php echo $field->label; ?></div> <?php endforeach; ?>
<div class="controls"><?php echo $field->input; ?></div>
</div>
<?php endforeach; ?>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -23,40 +23,48 @@ class WeblinksViewWeblink extends JViewLegacy
protected $form; protected $form;
/** /**
* Display the view * Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/ */
public function display($tpl = null) public function display($tpl = null)
{ {
$this->state = $this->get('State'); $this->state = $this->get('State');
$this->item = $this->get('Item'); $this->item = $this->get('Item');
$this->form = $this->get('Form'); $this->form = $this->get('Form');
// Check for errors. // Check for errors.
if (count($errors = $this->get('Errors'))) if (count($errors = $this->get('Errors')))
{ {
JError::raiseError(500, implode("\n", $errors)); JError::raiseError(500, implode("\n", $errors));
return false; return false;
} }
$this->addToolbar(); $this->addToolbar();
parent::display($tpl); parent::display($tpl);
} }
/** /**
* Add the page title and toolbar. * Add the page title and toolbar.
* *
* @return void
*
* @since 1.6 * @since 1.6
*/ */
protected function addToolbar() protected function addToolbar()
{ {
JFactory::getApplication()->input->set('hidemainmenu', true); JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser(); $user = JFactory::getUser();
$isNew = ($this->item->id == 0); $isNew = ($this->item->id == 0);
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
// Since we don't track these assets at the item level, use the category id. // Since we don't track these assets at the item level, use the category id.
$canDo = JHelperContent::getActions('com_weblinks', 'category', $this->item->catid); $canDo = JHelperContent::getActions('com_weblinks', 'category', $this->item->catid);
JToolbarHelper::title($isNew ? JText::_('COM_WEBLINKS_MANAGER_WEBLINK_NEW') : JText::_('COM_WEBLINKS_MANAGER_WEBLINK_EDIT'), 'link weblinks'); JToolbarHelper::title($isNew ? JText::_('COM_WEBLINKS_MANAGER_WEBLINK_NEW') : JText::_('COM_WEBLINKS_MANAGER_WEBLINK_EDIT'), 'link weblinks');

View File

@ -9,7 +9,7 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('bootstrap.tooltip'); JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect'); JHtml::_('behavior.multiselect');
@ -21,69 +21,23 @@ $listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction')); $listDirn = $this->escape($this->state->get('list.direction'));
$canOrder = $user->authorise('core.edit.state', 'com_weblinks.category'); $canOrder = $user->authorise('core.edit.state', 'com_weblinks.category');
$saveOrder = $listOrder == 'a.ordering'; $saveOrder = $listOrder == 'a.ordering';
if ($saveOrder) if ($saveOrder)
{ {
$saveOrderingUrl = 'index.php?option=com_weblinks&task=weblinks.saveOrderAjax&tmpl=component'; $saveOrderingUrl = 'index.php?option=com_weblinks&task=weblinks.saveOrderAjax&tmpl=component';
JHtml::_('sortablelist.sortable', 'weblinkList', 'adminForm', strtolower($listDirn), $saveOrderingUrl); JHtml::_('sortablelist.sortable', 'weblinkList', 'adminForm', strtolower($listDirn), $saveOrderingUrl);
} }
$sortFields = $this->getSortFields();
JFactory::getDocument()->addScriptDeclaration('
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != "' . $listOrder . '")
{
dirn = "asc";
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, "");
};
');
?> ?>
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&view=weblinks'); ?>" method="post" name="adminForm" id="adminForm"> <form action="<?php echo JRoute::_('index.php?option=com_weblinks&view=weblinks'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar)) : ?> <?php if (!empty($this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2"> <div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?> <?php echo $this->sidebar; ?>
</div> </div>
<div id="j-main-container" class="span10"> <div id="j-main-container" class="span10">
<?php else : ?> <?php else : ?>
<div id="j-main-container"> <div id="j-main-container">
<?php endif;?> <?php endif;?>
<div id="filter-bar" class="btn-toolbar"> <?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<div class="filter-search btn-group pull-left">
<label for="filter_search" class="element-invisible"><?php echo JText::_('COM_WEBLINKS_SEARCH_IN_TITLE');?></label>
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_WEBLINKS_SEARCH_IN_TITLE'); ?>" />
</div>
<div class="btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.getElementById('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC');?></label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="directionTable" class="element-invisible"><?php echo JText::_('JFIELD_ORDERING_DESC');?></label>
<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JFIELD_ORDERING_DESC');?></option>
<option value="asc" <?php if ($listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_ASCENDING');?></option>
<option value="desc" <?php if ($listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_DESCENDING');?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="sortTable" class="element-invisible"><?php echo JText::_('JGLOBAL_SORT_BY');?></label>
<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JGLOBAL_SORT_BY');?></option>
<?php echo JHtml::_('select.options', $sortFields, 'value', 'text', $listOrder);?>
</select>
</div>
</div>
<div class="clearfix"> </div> <div class="clearfix"> </div>
<?php if (empty($this->items)) : ?> <?php if (empty($this->items)) : ?>
<div class="alert alert-no-items"> <div class="alert alert-no-items">
@ -94,88 +48,90 @@ JFactory::getDocument()->addScriptDeclaration('
<thead> <thead>
<tr> <tr>
<th width="1%" class="nowrap center hidden-phone"> <th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', '<i class="icon-menu-2"></i>', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> <?php echo JHtml::_('searchtools.sort', '', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?>
</th> </th>
<th width="1%" class="hidden-phone center"> <th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.checkall'); ?> <?php echo JHtml::_('grid.checkall'); ?>
</th> </th>
<th width="1%" style="min-width:55px" class="nowrap center"> <th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th> </th>
<th class="title"> <th class="title">
<?php echo JHtml::_('grid.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap hidden-phone">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th> </th>
<th width="10%" class="nowrap hidden-phone"> <th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_LANGUAGE', 'a.language', $listDirn, $listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'access_level', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap center hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language_title', $listDirn, $listOrder); ?>
</th> </th>
<th width="1%" class="nowrap center hidden-phone"> <th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th> </th>
</tr> </tr>
</thead> </thead>
<tfoot> <tfoot>
<tr> <tr>
<td colspan="10"> <td colspan="8">
<?php echo $this->pagination->getListFooter(); ?> <?php echo $this->pagination->getListFooter(); ?>
</td> </td>
</tr> </tr>
</tfoot> </tfoot>
<tbody> <tbody>
<?php foreach ($this->items as $i => $item) : <?php foreach ($this->items as $i => $item) : ?>
$ordering = ($listOrder == 'a.ordering'); <?php $ordering = ($listOrder == 'a.ordering'); ?>
$item->cat_link = JRoute::_('index.php?option=com_categories&extension=com_weblinks&task=edit&type=other&cid[]='. $item->catid); <?php $item->cat_link = JRoute::_('index.php?option=com_categories&extension=com_weblinks&task=edit&type=other&cid[]=' . $item->catid); ?>
$canCreate = $user->authorise('core.create', 'com_weblinks.category.' . $item->catid); <?php $canCreate = $user->authorise('core.create', 'com_weblinks.category.' . $item->catid); ?>
$canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $item->catid); <?php $canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $item->catid); ?>
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || $item->checked_out == 0; <?php $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || $item->checked_out == 0; ?>
$canChange = $user->authorise('core.edit.state', 'com_weblinks.category.' . $item->catid) && $canCheckin; <?php $canChange = $user->authorise('core.edit.state', 'com_weblinks.category.' . $item->catid) && $canCheckin; ?>
?> <tr class="row<?php echo $i % 2; ?>" sortable-group-id="<?php echo $item->catid; ?>">
<tr class="row<?php echo $i % 2; ?>" sortable-group-id="<?php echo $item->catid?>">
<td class="order nowrap center hidden-phone"> <td class="order nowrap center hidden-phone">
<?php <?php $iconClass = ''; ?>
$iconClass = ''; <?php if (!$canChange) : ?>
if (!$canChange) <?php $iconClass = ' inactive'; ?>
{ <?php elseif (!$saveOrder) : ?>
$iconClass = ' inactive'; <?php $iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); ?>
} <?php endif; ?>
elseif (!$saveOrder)
{
$iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED');
}
?>
<span class="sortable-handler<?php echo $iconClass ?>"> <span class="sortable-handler<?php echo $iconClass ?>">
<i class="icon-menu"></i> <i class="icon-menu"></i>
</span> </span>
<?php if ($canChange && $saveOrder) : ?> <?php if ($canChange && $saveOrder) : ?>
<input type="text" style="display:none" name="order[]" size="5" value="<?php echo $item->ordering;?>" class="width-20 text-area-order " /> <input type="text" style="display:none" name="order[]" size="5" value="<?php echo $item->ordering; ?>" class="width-20 text-area-order " />
<?php endif; ?> <?php endif; ?>
</td> </td>
<td class="center hidden-phone"> <td class="center">
<?php echo JHtml::_('grid.id', $i, $item->id); ?> <?php echo JHtml::_('grid.id', $i, $item->id); ?>
</td> </td>
<td class="center"> <td class="center">
<?php echo JHtml::_('jgrid.published', $item->state, $i, 'weblinks.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?> <div class="btn-group">
<?php echo JHtml::_('jgrid.published', $item->state, $i, 'weblinks.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
<?php // Create dropdown items and render the dropdown list. ?>
<?php if ($canChange) : ?>
<?php JHtml::_('actionsdropdown.' . ((int) $item->state === 2 ? 'un' : '') . 'archive', 'cb' . $i, 'weblinks'); ?>
<?php JHtml::_('actionsdropdown.' . ((int) $item->state === -2 ? 'un' : '') . 'trash', 'cb' . $i, 'weblinks'); ?>
<?php echo JHtml::_('actionsdropdown.render', $this->escape($item->title)); ?>
<?php endif; ?>
</div>
</td> </td>
<td class="nowrap has-context"> <td class="nowrap has-context">
<?php if ($item->checked_out) : ?> <?php if ($item->checked_out) : ?>
<?php echo JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'weblinks.', $canCheckin); ?> <?php echo JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'weblinks.', $canCheckin); ?>
<?php endif; ?> <?php endif; ?>
<?php if ($canEdit) : ?> <?php if ($canEdit) : ?>
<a href="<?php echo JRoute::_('index.php?option=com_weblinks&task=weblink.edit&id='.(int) $item->id); ?>"> <a href="<?php echo JRoute::_('index.php?option=com_weblinks&task=weblink.edit&id=' . (int) $item->id); ?>">
<?php echo $this->escape($item->title); ?></a> <?php echo $this->escape($item->title); ?></a>
<?php else : ?> <?php else : ?>
<?php echo $this->escape($item->title); ?> <?php echo $this->escape($item->title); ?>
<?php endif; ?> <?php endif; ?>
<span class="small"> <span class="small">
<?php echo JText::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias));?> <?php echo JText::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
</span> </span>
<div class="small"> <div class="small">
<?php echo $this->escape($item->category_title); ?> <?php echo JText::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
</div> </div>
</td> </td>
<td class="small hidden-phone"> <td class="small hidden-phone">
@ -185,9 +141,9 @@ JFactory::getDocument()->addScriptDeclaration('
<?php echo $item->hits; ?> <?php echo $item->hits; ?>
</td> </td>
<td class="small nowrap hidden-phone"> <td class="small nowrap hidden-phone">
<?php if ($item->language == '*'):?> <?php if ($item->language == '*') : ?>
<?php echo JText::alt('JALL', 'language'); ?> <?php echo JText::alt('JALL', 'language'); ?>
<?php else:?> <?php else : ?>
<?php echo $item->language_title ? JHtml::_('image', 'mod_languages/' . $item->language_image . '.gif', $item->language_title, array('title' => $item->language_title), true) . '&nbsp;' . $this->escape($item->language_title) : JText::_('JUNDEFINED'); ?> <?php echo $item->language_title ? JHtml::_('image', 'mod_languages/' . $item->language_image . '.gif', $item->language_title, array('title' => $item->language_title), true) . '&nbsp;' . $this->escape($item->language_title) : JText::_('JUNDEFINED'); ?>
<?php endif;?> <?php endif;?>
</td> </td>
@ -205,8 +161,6 @@ JFactory::getDocument()->addScriptDeclaration('
<input type="hidden" name="task" value="" /> <input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?> <?php echo JHtml::_('form.token'); ?>
</div> </div>
</form> </form>

View File

@ -9,7 +9,7 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
$published = $this->state->get('filter.state'); $published = $this->state->get('filter.published');
?> ?>
<div class="modal hide fade" id="collapseModal"> <div class="modal hide fade" id="collapseModal">
<div class="modal-header"> <div class="modal-header">

View File

@ -23,15 +23,19 @@ class WeblinksViewWeblinks extends JViewLegacy
protected $state; protected $state;
/** /**
* Display the view * Display the view.
* *
* @return void * @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/ */
public function display($tpl = null) public function display($tpl = null)
{ {
$this->state = $this->get('State'); $this->state = $this->get('State');
$this->items = $this->get('Items'); $this->items = $this->get('Items');
$this->pagination = $this->get('Pagination'); $this->pagination = $this->get('Pagination');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
WeblinksHelper::addSubmenu('weblinks'); WeblinksHelper::addSubmenu('weblinks');
@ -50,6 +54,8 @@ class WeblinksViewWeblinks extends JViewLegacy
/** /**
* Add the page title and toolbar. * Add the page title and toolbar.
* *
* @return void
*
* @since 1.6 * @since 1.6
*/ */
protected function addToolbar() protected function addToolbar()
@ -84,7 +90,7 @@ class WeblinksViewWeblinks extends JViewLegacy
JToolbarHelper::checkin('weblinks.checkin'); JToolbarHelper::checkin('weblinks.checkin');
} }
if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) if ($state->get('filter.published') == -2 && $canDo->get('core.delete'))
{ {
JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'weblinks.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'weblinks.delete', 'JTOOLBAR_EMPTY_TRASH');
} }
@ -113,39 +119,6 @@ class WeblinksViewWeblinks extends JViewLegacy
} }
JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS'); JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS');
JHtmlSidebar::setAction('index.php?option=com_weblinks&view=weblinks');
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_PUBLISHED'),
'filter_state',
JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.state'), true)
);
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_CATEGORY'),
'filter_category_id',
JHtml::_('select.options', JHtml::_('category.options', 'com_weblinks'), 'value', 'text', $this->state->get('filter.category_id'))
);
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_ACCESS'),
'filter_access',
JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))
);
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_LANGUAGE'),
'filter_language',
JHtml::_('select.options', JHtml::_('contentlanguage.existing', true, true), 'value', 'text', $this->state->get('filter.language'))
);
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_TAG'),
'filter_tag',
JHtml::_('select.options', JHtml::_('tag.options', true, true), 'value', 'text', $this->state->get('filter.tag'))
);
} }
/** /**

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.1" method="upgrade"> <extension type="component" version="3.5" method="upgrade">
<name>com_weblinks</name> <name>com_weblinks</name>
<author>Joomla! Project</author> <author>Joomla! Project</author>
<creationDate>##DATE##</creationDate> <creationDate>##DATE##</creationDate>

View File

@ -3,7 +3,7 @@
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 ; Note : All ini files need to be saved as UTF-8
COM_WEBLINKS="Weblinks" COM_WEBLINKS="Web Links"
COM_WEBLINKS_ACCESS_HEADING="Access" COM_WEBLINKS_ACCESS_HEADING="Access"
COM_WEBLINKS_BATCH_OPTIONS="Batch process the selected links" COM_WEBLINKS_BATCH_OPTIONS="Batch process the selected links"
COM_WEBLINKS_BATCH_TIP="If a category is selected for move/copy, any actions selected will be applied to the copied or moved links. Otherwise, all actions are applied to the selected links." COM_WEBLINKS_BATCH_TIP="If a category is selected for move/copy, any actions selected will be applied to the copied or moved links. Otherwise, all actions are applied to the selected links."
@ -21,6 +21,8 @@ COM_WEBLINKS_ERROR_UNIQUE_ALIAS="Another web link from this category has the sam
COM_WEBLINKS_FIELD_ALIAS_DESC="The alias is for internal use only. Leave this blank and Joomla will fill in a default value from the title. It has to be unique for each web link in the same category." COM_WEBLINKS_FIELD_ALIAS_DESC="The alias is for internal use only. Leave this blank and Joomla will fill in a default value from the title. It has to be unique for each web link in the same category."
COM_WEBLINKS_FIELD_CATEGORY_DESC="Choose a category for this Web link." COM_WEBLINKS_FIELD_CATEGORY_DESC="Choose a category for this Web link."
COM_WEBLINKS_FIELD_CATEGORYCHOOSE_DESC="Please choose a Web Links category to display." COM_WEBLINKS_FIELD_CATEGORYCHOOSE_DESC="Please choose a Web Links category to display."
COM_WEBLINKS_FIELD_CAPTCHA_DESC="Select the captcha plugin that will be used in the web link submit form. You may need to enter required information for your captcha plugin in the Plugin Manager.<br />If 'Use Default' is selected, make sure a captcha plugin is selected in Global Configuration."
COM_WEBLINKS_FIELD_CAPTCHA_LABEL="Allow Captcha on Web Link"
COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC="Show/Hide the number of Web Links in each Category." COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC="Show/Hide the number of Web Links in each Category."
COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL="# Web Links" COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL="# Web Links"
COM_WEBLINKS_FIELD_CONFIG_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded." COM_WEBLINKS_FIELD_CONFIG_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded."
@ -79,6 +81,8 @@ COM_WEBLINKS_FIELD_WIDTH_LABEL="Width"
COM_WEBLINKS_FIELDSET_IMAGES="Images" COM_WEBLINKS_FIELDSET_IMAGES="Images"
COM_WEBLINKS_FIELDSET_OPTIONS="Options" COM_WEBLINKS_FIELDSET_OPTIONS="Options"
COM_WEBLINKS_FILTER_CATEGORY="Filter Category" COM_WEBLINKS_FILTER_CATEGORY="Filter Category"
COM_WEBLINKS_FILTER_SEARCH_DESC="Search in web link title and alias. Prefix with ID: to search for an web link ID."
COM_WEBLINKS_FILTER_SEARCH_LABEL="Search Web Links"
COM_WEBLINKS_FILTER_STATE="Filter State" COM_WEBLINKS_FILTER_STATE="Filter State"
COM_WEBLINKS_FLOAT_DESC="Controls placement of the image." COM_WEBLINKS_FLOAT_DESC="Controls placement of the image."
COM_WEBLINKS_FLOAT_LABEL="Image Float" COM_WEBLINKS_FLOAT_LABEL="Image Float"

View File

@ -3,7 +3,7 @@
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 ; Note : All ini files need to be saved as UTF-8
COM_WEBLINKS="Weblinks" COM_WEBLINKS="Web Links"
COM_WEBLINKS_CATEGORIES="Categories" COM_WEBLINKS_CATEGORIES="Categories"
COM_WEBLINKS_CATEGORIES_VIEW_DEFAULT_DESC="Show all the web link categories within a category." COM_WEBLINKS_CATEGORIES_VIEW_DEFAULT_DESC="Show all the web link categories within a category."
COM_WEBLINKS_CATEGORIES_VIEW_DEFAULT_OPTION="Default" COM_WEBLINKS_CATEGORIES_VIEW_DEFAULT_OPTION="Default"

View File

@ -19,7 +19,7 @@ class WeblinksController extends JControllerLegacy
/** /**
* Method to display a view. * Method to display a view.
* *
* @param boolean $cachable If true, the view output will be cached * @param boolean $cacheable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types, * @param array $urlparams An array of safe url parameters and their variable types,
* for valid values see {@link JFilterInput::clean()}. * for valid values see {@link JFilterInput::clean()}.
* *
@ -27,30 +27,32 @@ class WeblinksController extends JControllerLegacy
* *
* @since 1.5 * @since 1.5
*/ */
public function display($cachable = false, $urlparams = false) public function display($cacheable = false, $urlparams = false)
{ {
$cachable = true; // Huh? Why not just put that in the constructor? // Huh? Why not just put that in the constructor?
$user = JFactory::getUser(); $cacheable = true;
// 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. * Set the default view name and format from the Request.
// Frontend is a bit messier than the backend. * 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'); $id = $this->input->getInt('w_id');
$vName = $this->input->get('view', 'categories'); $vName = $this->input->get('view', 'categories');
$this->input->set('view', $vName); $this->input->set('view', $vName);
if (JFactory::getUser()->id ||($this->input->getMethod() == 'POST' && $vName = 'categories')) if (JFactory::getUser()->id ||($this->input->getMethod() == 'POST' && $vName = 'categories'))
{ {
$cachable = false; $cacheable = false;
} }
$safeurlparams = array( $safeurlparams = array(
'id' => 'INT', 'id' => 'INT',
'limit' => 'UINT', 'limit' => 'UINT',
'limitstart' => 'UINT', 'limitstart' => 'UINT',
'filter_order' => 'CMD', 'filter_order' => 'CMD',
'filter_order_Dir' => 'CMD', 'filter_order_Dir' => 'CMD',
'lang' => 'CMD' 'lang' => 'CMD'
); );
// Check for edit form. // Check for edit form.
@ -60,6 +62,6 @@ class WeblinksController extends JControllerLegacy
return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
} }
return parent::display($cachable, $safeurlparams); return parent::display($cacheable, $safeurlparams);
} }
} }

View File

@ -69,7 +69,7 @@ class WeblinksControllerWeblink extends JControllerForm
*/ */
protected function allowAdd($data = array()) protected function allowAdd($data = array())
{ {
$categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('id'), 'int'); $categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('id'), 'int');
$allow = null; $allow = null;
if ($categoryId) if ($categoryId)
@ -180,8 +180,8 @@ class WeblinksControllerWeblink extends JControllerForm
protected function getRedirectToItemAppend($recordId = null, $urlVar = null) protected function getRedirectToItemAppend($recordId = null, $urlVar = null)
{ {
$append = parent::getRedirectToItemAppend($recordId, $urlVar); $append = parent::getRedirectToItemAppend($recordId, $urlVar);
$itemId = $this->input->getInt('Itemid'); $itemId = $this->input->getInt('Itemid');
$return = $this->getReturnPage(); $return = $this->getReturnPage();
if ($itemId) if ($itemId)
{ {
@ -227,11 +227,21 @@ class WeblinksControllerWeblink extends JControllerForm
*/ */
public function save($key = null, $urlVar = 'w_id') public function save($key = null, $urlVar = 'w_id')
{ {
// Get the application
$app = JFactory::getApplication();
// Get the data from POST
$data = $this->input->post->get('jform', array(), 'array');
// Save the data in the session.
$app->setUserState('com_weblinks.edit.weblink.data', $data);
$result = parent::save($key, $urlVar); $result = parent::save($key, $urlVar);
// If ok, redirect to the return page. // If ok, redirect to the return page.
if ($result) if ($result)
{ {
// Flush the data from the session
$app->setUserState('com_weblinks.edit.weblink.data', null);
$this->setRedirect($this->getReturnPage()); $this->setRedirect($this->getReturnPage());
} }
@ -264,7 +274,7 @@ class WeblinksControllerWeblink extends JControllerForm
} }
// Check whether item access level allows access. // Check whether item access level allows access.
$groups = JFactory::getUser()->getAuthorisedViewLevels(); $groups = JFactory::getUser()->getAuthorisedViewLevels();
if (!in_array($link->access, $groups)) if (!in_array($link->access, $groups))
{ {

View File

@ -10,6 +10,7 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php'); JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php');
JLoader::register('WeblinksHelperRoute', JPATH_SITE . '/components/com_weblinks/helpers/route.php');
JLoader::register('CategoryHelperAssociation', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/association.php'); JLoader::register('CategoryHelperAssociation', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/association.php');
/** /**
@ -31,11 +32,9 @@ abstract class WeblinksHelperAssociation extends CategoryHelperAssociation
*/ */
public static function getAssociations($id = 0, $view = null) public static function getAssociations($id = 0, $view = null)
{ {
jimport('helper.route', JPATH_COMPONENT_SITE);
$jinput = JFactory::getApplication()->input; $jinput = JFactory::getApplication()->input;
$view = is_null($view) ? $jinput->get('view') : $view; $view = is_null($view) ? $jinput->get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id; $id = empty($id) ? $jinput->getInt('id') : $id;
if ($view == 'category' || $view == 'categories') if ($view == 'category' || $view == 'categories')
{ {

View File

@ -63,7 +63,7 @@ class JHtmlIcon
$url = WeblinksHelperRoute::getFormRoute($weblink->id, base64_encode($uri)); $url = WeblinksHelperRoute::getFormRoute($weblink->id, base64_encode($uri));
$icon = $weblink->state ? 'edit.png' : 'edit_unpublished.png'; $icon = $weblink->state ? 'edit.png' : 'edit_unpublished.png';
$text = JHtml::_('image', 'system/'.$icon, JText::_('JGLOBAL_EDIT'), null, true); $text = JHtml::_('image', 'system/' . $icon, JText::_('JGLOBAL_EDIT'), null, true);
if ($weblink->state == 0) if ($weblink->state == 0)
{ {

View File

@ -21,18 +21,20 @@ abstract class WeblinksHelperRoute
protected static $lang_lookup = array(); protected static $lang_lookup = array();
/** /**
* @param integer The route of the weblink * Get the route of the weblink
*
* @param integer $id Web link ID
* @param integer $catid Category ID
* @param string $language Language
* *
* @return string * @return string
*/ */
public static function getWeblinkRoute($id, $catid, $language = 0) public static function getWeblinkRoute($id, $catid, $language = 0)
{ {
$needles = array( $needles = array('weblink' => array((int) $id));
'weblink' => array((int) $id)
);
// Create the link // Create the link
$link = 'index.php?option=com_weblinks&view=weblink&id='. $id; $link = 'index.php?option=com_weblinks&view=weblink&id=' . $id;
if ($catid > 1) if ($catid > 1)
{ {
@ -43,7 +45,7 @@ abstract class WeblinksHelperRoute
{ {
$needles['category'] = array_reverse($category->getPath()); $needles['category'] = array_reverse($category->getPath());
$needles['categories'] = $needles['category']; $needles['categories'] = $needles['category'];
$link .= '&catid='.$catid; $link .= '&catid=' . $catid;
} }
} }
@ -60,13 +62,15 @@ abstract class WeblinksHelperRoute
if ($item = self::_findItem($needles)) if ($item = self::_findItem($needles))
{ {
$link .= '&Itemid='.$item; $link .= '&Itemid=' . $item;
} }
return $link; return $link;
} }
/** /**
* Ge the form route
*
* @param integer $id The id of the weblink. * @param integer $id The id of the weblink.
* @param string $return The return page variable. * @param string $return The return page variable.
* *
@ -77,7 +81,7 @@ abstract class WeblinksHelperRoute
// Create the link. // Create the link.
if ($id) if ($id)
{ {
$link = 'index.php?option=com_weblinks&task=weblink.edit&w_id='. $id; $link = 'index.php?option=com_weblinks&task=weblink.edit&w_id=' . $id;
} }
else else
{ {
@ -86,13 +90,15 @@ abstract class WeblinksHelperRoute
if ($return) if ($return)
{ {
$link .= '&return='.$return; $link .= '&return=' . $return;
} }
return $link; return $link;
} }
/** /**
* Get the Category Route
*
* @param JCategoryNode|string|integer $catid JCategoryNode object or category ID * @param JCategoryNode|string|integer $catid JCategoryNode object or category ID
* @param integer $language Language code * @param integer $language Language code
* *
@ -120,7 +126,7 @@ abstract class WeblinksHelperRoute
$needles = array(); $needles = array();
// Create the link // Create the link
$link = 'index.php?option=com_weblinks&view=category&id='.$id; $link = 'index.php?option=com_weblinks&view=category&id=' . $id;
$catids = array_reverse($category->getPath()); $catids = array_reverse($category->getPath());
$needles['category'] = $catids; $needles['category'] = $catids;
@ -139,7 +145,7 @@ abstract class WeblinksHelperRoute
if ($item = self::_findItem($needles)) if ($item = self::_findItem($needles))
{ {
$link .= '&Itemid='.$item; $link .= '&Itemid=' . $item;
} }
} }
@ -147,7 +153,9 @@ abstract class WeblinksHelperRoute
} }
/** /**
* @return void * Do a language lookup
*
* @return void
*/ */
protected static function buildLanguageLookup() protected static function buildLanguageLookup()
{ {
@ -169,6 +177,13 @@ abstract class WeblinksHelperRoute
} }
} }
/**
* Find items per given $needles
*
* @param array $needles A given array of needles to find
*
* @return void
*/
protected static function _findItem($needles = null) protected static function _findItem($needles = null)
{ {
$app = JFactory::getApplication(); $app = JFactory::getApplication();
@ -180,7 +195,7 @@ abstract class WeblinksHelperRoute
{ {
self::$lookup[$language] = array(); self::$lookup[$language] = array();
$component = JComponentHelper::getComponent('com_weblinks'); $component = JComponentHelper::getComponent('com_weblinks');
$attributes = array('component_id'); $attributes = array('component_id');
$values = array($component->id); $values = array($component->id);
@ -208,9 +223,11 @@ abstract class WeblinksHelperRoute
if (isset($item->query['id'])) if (isset($item->query['id']))
{ {
// here it will become a bit tricky /**
// language != * can override existing entries * Here it will become a bit tricky
// language == * cannot override existing entries * language != * can override existing entries
* language == * cannot override existing entries
*/
if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*') if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*')
{ {
self::$lookup[$language][$view][$item->query['id']] = $item->id; self::$lookup[$language][$view][$item->query['id']] = $item->id;

View File

@ -40,6 +40,11 @@ class WeblinksModelCategories extends JModelList
* *
* Note. Calling getState in this method will result in recursion. * Note. Calling getState in this method will result in recursion.
* *
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6 * @since 1.6
*/ */
protected function populateState($ordering = null, $direction = null) protected function populateState($ordering = null, $direction = null)
@ -54,8 +59,8 @@ class WeblinksModelCategories extends JModelList
$params = $app->getParams(); $params = $app->getParams();
$this->setState('params', $params); $this->setState('params', $params);
$this->setState('filter.published', 1); $this->setState('filter.published', 1);
$this->setState('filter.access', true); $this->setState('filter.access', true);
} }
/** /**
@ -65,25 +70,25 @@ class WeblinksModelCategories extends JModelList
* different modules that might need different sets of data or different * different modules that might need different sets of data or different
* ordering requirements. * ordering requirements.
* *
* @param string $id A prefix for the store id. * @param string $id A prefix for the store id.
* *
* @return string A store id. * @return string A store id.
*/ */
protected function getStoreId($id = '') protected function getStoreId($id = '')
{ {
// Compile the store id. // Compile the store id.
$id .= ':'.$this->getState('filter.extension'); $id .= ':' . $this->getState('filter.extension');
$id .= ':'.$this->getState('filter.published'); $id .= ':' . $this->getState('filter.published');
$id .= ':'.$this->getState('filter.access'); $id .= ':' . $this->getState('filter.access');
$id .= ':'.$this->getState('filter.parentId'); $id .= ':' . $this->getState('filter.parentId');
return parent::getStoreId($id); return parent::getStoreId($id);
} }
/** /**
* redefine the function an add some properties to make the styling more easy * Redefine the function and add some properties to make the styling more easy
* *
* @return mixed An array of data items on success, false on failure. * @return mixed An array of data items on success, false on failure.
*/ */
public function getItems() public function getItems()
{ {
@ -117,12 +122,18 @@ class WeblinksModelCategories extends JModelList
return $this->_items; return $this->_items;
} }
/**
* Get the parent
*
* @return mixed An array of data items on success, false on failure.
*/
public function getParent() public function getParent()
{ {
if (!is_object($this->_parent)) if (!is_object($this->_parent))
{ {
$this->getItems(); $this->getItems();
} }
return $this->_parent; return $this->_parent;
} }
} }

View File

@ -36,7 +36,7 @@ class WeblinksModelCategory extends JModelList
/** /**
* Constructor. * Constructor.
* *
* @param array An optional associative array of configuration settings. * @param array $config An optional associative array of configuration settings.
* *
* @see JControllerLegacy * @see JControllerLegacy
* @since 1.6 * @since 1.6
@ -121,9 +121,20 @@ class WeblinksModelCategory extends JModelList
// Filter by category. // Filter by category.
if ($categoryId = $this->getState('category.id')) if ($categoryId = $this->getState('category.id'))
{ {
$query->where('a.catid = ' . (int) $categoryId) // Group by subcategory
->join('LEFT', '#__categories AS c ON c.id = a.catid') if ($this->getState('category.group', 0))
->where('c.access IN (' . $groups . ')'); {
$query->select('c.title AS category_title')
->where('c.parent_id = ' . (int) $categoryId)
->join('LEFT', '#__categories AS c ON c.id = a.catid')
->where('c.access IN (' . $groups . ')');
}
else
{
$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 // Filter by published category
$cpublished = $this->getState('filter.c.published'); $cpublished = $this->getState('filter.c.published');
@ -141,7 +152,6 @@ class WeblinksModelCategory extends JModelList
->join('LEFT', '#__users AS uam ON uam.id = a.modified_by'); ->join('LEFT', '#__users AS uam ON uam.id = a.modified_by');
// Filter by state // Filter by state
$state = $this->getState('filter.state'); $state = $this->getState('filter.state');
if (is_numeric($state)) if (is_numeric($state))
@ -149,7 +159,7 @@ class WeblinksModelCategory extends JModelList
$query->where('a.state = ' . (int) $state); $query->where('a.state = ' . (int) $state);
} }
// do not show trashed links on the front-end // Do not show trashed links on the front-end
$query->where('a.state != -2'); $query->where('a.state != -2');
// Filter by start and end dates. // Filter by start and end dates.
@ -176,12 +186,20 @@ class WeblinksModelCategory extends JModelList
$search = $db->quote('%' . $db->escape($search, true) . '%'); $search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('(a.title LIKE ' . $search . ')'); $query->where('(a.title LIKE ' . $search . ')');
} }
// If grouping by subcategory, add the subcategory list ordering clause.
if ($this->getState('category.group', 0))
{
$query->order(
$db->escape($this->getState('category.ordering', 'c.lft')) . ' ' .
$db->escape($this->getState('category.direction', 'ASC'))
);
}
// Add the list ordering clause. // Add the list ordering clause.
$query->order( $query->order(
$db->escape( $db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' .
$this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC') $db->escape($this->getState('list.direction', 'ASC'))
)
); );
return $query; return $query;
@ -192,6 +210,11 @@ class WeblinksModelCategory extends JModelList
* *
* Note. Calling getState in this method will result in recursion. * Note. Calling getState in this method will result in recursion.
* *
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6 * @since 1.6
*/ */
protected function populateState($ordering = null, $direction = null) protected function populateState($ordering = null, $direction = null)
@ -234,7 +257,7 @@ class WeblinksModelCategory extends JModelList
if ((!$user->authorise('core.edit.state', 'com_weblinks')) && (!$user->authorise('core.edit', 'com_weblinks'))) 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. // Limit to published for people who can't edit or edit.state.
$this->setState('filter.state', 1); $this->setState('filter.state', 1);
// Filter by start and end dates. // Filter by start and end dates.
@ -301,8 +324,6 @@ class WeblinksModelCategory extends JModelList
/** /**
* Get the parent category * 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. * @return mixed An array of categories or false if an error occurs.
*/ */
public function getParent() public function getParent()
@ -311,40 +332,46 @@ class WeblinksModelCategory extends JModelList
{ {
$this->getCategory(); $this->getCategory();
} }
return $this->_parent; return $this->_parent;
} }
/** /**
* Get the sibling (adjacent) categories. * Get the leftsibling (adjacent) categories.
* *
* @return mixed An array of categories or false if an error occurs. * @return mixed An array of categories or false if an error occurs.
*/ */
function &getLeftSibling() public function &getLeftSibling()
{ {
if (!is_object($this->_item)) if (!is_object($this->_item))
{ {
$this->getCategory(); $this->getCategory();
} }
return $this->_leftsibling; return $this->_leftsibling;
} }
function &getRightSibling() /**
* Get the rightsibling (adjacent) categories.
*
* @return mixed An array of categories or false if an error occurs.
*/
public function &getRightSibling()
{ {
if (!is_object($this->_item)) if (!is_object($this->_item))
{ {
$this->getCategory(); $this->getCategory();
} }
return $this->_rightsibling; return $this->_rightsibling;
} }
/** /**
* Get the child categories. * 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. * @return mixed An array of categories or false if an error occurs.
*/ */
function &getChildren() public function &getChildren()
{ {
if (!is_object($this->_item)) if (!is_object($this->_item))
{ {

View File

@ -43,6 +43,8 @@ class WeblinksModelForm extends WeblinksModelWeblink
* *
* Note. Calling getState in this method will result in recursion. * Note. Calling getState in this method will result in recursion.
* *
* @return void
*
* @since 1.6 * @since 1.6
*/ */
protected function populateState() protected function populateState()

View File

@ -89,6 +89,15 @@
size="45" size="45"
labelclass="control-label" /> labelclass="control-label" />
<field
name="captcha"
type="captcha"
label="COM_WEBLINKS_CAPTCHA_LABEL"
description="COM_WEBLINKS_CAPTCHA_DESC"
validate="captcha"
namespace="weblink"
/>
</fieldset> </fieldset>
<fields name="metadata"> <fields name="metadata">
<fieldset name="jmetadata" <fieldset name="jmetadata"

View File

@ -9,6 +9,8 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables'); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables');
/** /**
@ -30,15 +32,17 @@ class WeblinksModelWeblink extends JModelItem
* *
* Note. Calling getState in this method will result in recursion. * Note. Calling getState in this method will result in recursion.
* *
* @return void
*
* @since 1.6 * @since 1.6
*/ */
protected function populateState() protected function populateState()
{ {
$app = JFactory::getApplication(); $app = JFactory::getApplication();
$params = $app->getParams(); $params = $app->getParams();
// Load the object state. // Load the object state.
$id = $app->input->getInt('id'); $id = $app->input->getInt('id');
$this->setState('weblink.id', $id); $this->setState('weblink.id', $id);
// Load the parameters. // Load the parameters.
@ -48,7 +52,7 @@ class WeblinksModelWeblink extends JModelItem
/** /**
* Method to get an object. * Method to get an object.
* *
* @param integer The id of the object to get. * @param integer $id The id of the object to get.
* *
* @return mixed Object on success, false on failure. * @return mixed Object on success, false on failure.
*/ */
@ -79,8 +83,8 @@ class WeblinksModelWeblink extends JModelItem
} }
// Convert the JTable to a clean JObject. // Convert the JTable to a clean JObject.
$properties = $table->getProperties(1); $properties = $table->getProperties(1);
$this->_item = JArrayHelper::toObject($properties, 'JObject'); $this->_item = ArrayHelper::toObject($properties, 'JObject');
} }
elseif ($error = $table->getError()) elseif ($error = $table->getError())
{ {
@ -94,13 +98,13 @@ class WeblinksModelWeblink extends JModelItem
/** /**
* Returns a reference to the a Table object, always creating it. * Returns a reference to the a Table object, always creating it.
* *
* @param type The table type to instantiate * @param string $type The table type to instantiate
* @param string A prefix for the table class name. Optional. * @param string $prefix A prefix for the table class name. Optional.
* @param array Configuration array for model. Optional. * @param array $config Configuration array for model. Optional.
* *
* @return JTable A database object * @return JTable A database object
* *
* @since 1.6 * @since 1.6
*/ */
public function getTable($type = 'Weblink', $prefix = 'WeblinksTable', $config = array()) public function getTable($type = 'Weblink', $prefix = 'WeblinksTable', $config = array())
{ {
@ -121,8 +125,6 @@ class WeblinksModelWeblink extends JModelItem
$id = $this->getState('weblink.id'); $id = $this->getState('weblink.id');
} }
$weblink = $this->getTable('Weblink', 'WeblinksTable'); return $this->getTable('Weblink', 'WeblinksTable')->hit($id);
return $weblink->hit($id);
} }
} }

View File

@ -259,7 +259,11 @@ class WeblinksRouter extends JComponentRouterBase
/** /**
* Weblinks router functions * Weblinks router functions
* *
* These functions are proxys for the new router interface * @param array &$query An array of URL arguments
*
* @return array The URL arguments to use to assemble the subsequent URL.
*
* Note. These functions are proxies for the new router interface
* for old SEF extensions. * for old SEF extensions.
* *
* @deprecated 4.0 Use Class based routers instead * @deprecated 4.0 Use Class based routers instead
@ -271,6 +275,18 @@ function WeblinksBuildRoute(&$query)
return $router->build($query); return $router->build($query);
} }
/**
* Weblinks router functions
*
* @param array $segments The segments of the URL to parse.
*
* @return array The URL attributes to be used by the application.
*
* Note. These functions are proxies for the new router interface
* for old SEF extensions.
*
* @deprecated 4.0 Use Class based routers instead
*/
function WeblinksParseRoute($segments) function WeblinksParseRoute($segments)
{ {
$router = new WeblinksRouter; $router = new WeblinksRouter;

View File

@ -9,6 +9,6 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers'); JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
$this->subtemplatename = 'items'; $this->subtemplatename = 'items';
echo JLayoutHelper::render('joomla.content.category_default', $this); echo JLayoutHelper::render('joomla.content.category_default', $this);

View File

@ -25,8 +25,8 @@ $canCreate = $user->authorise('core.create', 'com_weblinks');
$canEditState = $user->authorise('core.edit.state', 'com_weblinks'); $canEditState = $user->authorise('core.edit.state', 'com_weblinks');
$n = count($this->items); $n = count($this->items);
$listOrder = $this->escape($this->state->get('list.ordering')); $listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction')); $listDirn = $this->escape($this->state->get('list.direction'));
?> ?>
<?php if (empty($this->items)) : ?> <?php if (empty($this->items)) : ?>
@ -34,9 +34,9 @@ $listDirn = $this->escape($this->state->get('list.direction'));
<?php else : ?> <?php else : ?>
<form action="<?php echo htmlspecialchars(JUri::getInstance()->toString()); ?>" method="post" name="adminForm" id="adminForm"> <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')) :?> <?php if ($this->params->get('filter_field') != 'hide' || $this->params->get('show_pagination_limit')) : ?>
<fieldset class="filters btn-toolbar"> <fieldset class="filters btn-toolbar">
<?php if ($this->params->get('filter_field') != 'hide') :?> <?php if ($this->params->get('filter_field') != 'hide') : ?>
<div class="btn-group"> <div class="btn-group">
<label class="filter-search-lbl element-invisible" for="filter-search"><?php echo JText::_('COM_WEBLINKS_FILTER_LABEL') . '&#160;'; ?></label> <label class="filter-search-lbl element-invisible" for="filter-search"><?php echo JText::_('COM_WEBLINKS_FILTER_LABEL') . '&#160;'; ?></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'); ?>" /> <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'); ?>" />
@ -54,12 +54,11 @@ $listDirn = $this->escape($this->state->get('list.direction'));
</fieldset> </fieldset>
<?php endif; ?> <?php endif; ?>
<ul class="category list-striped list-condensed"> <ul class="category list-striped list-condensed">
<?php foreach ($this->items as $i => $item) : ?> <?php foreach ($this->items as $i => $item) : ?>
<?php if (in_array($item->access, $this->user->getAuthorisedViewLevels())) : ?> <?php if (in_array($item->access, $this->user->getAuthorisedViewLevels())) : ?>
<?php if ($this->items[$i]->state == 0) : ?> <?php if ($this->items[$i]->state == 0) : ?>
<li class="system-unpublished cat-list-row<?php echo $i % 2; ?>"> <li class="system-unpublished cat-list-row<?php echo $i % 2; ?>">
<?php else: ?> <?php else : ?>
<li class="cat-list-row<?php echo $i % 2; ?>" > <li class="cat-list-row<?php echo $i % 2; ?>" >
<?php endif; ?> <?php endif; ?>
<?php if ($this->params->get('show_link_hits', 1)) : ?> <?php if ($this->params->get('show_link_hits', 1)) : ?>
@ -84,48 +83,47 @@ $listDirn = $this->escape($this->state->get('list.direction'));
<?php echo '<img src="' . $this->params->get('link_icons') . '" alt="' . JText::_('COM_WEBLINKS_LINK') . '" />'; ?> <?php echo '<img src="' . $this->params->get('link_icons') . '" alt="' . JText::_('COM_WEBLINKS_LINK') . '" />'; ?>
<?php endif; ?> <?php endif; ?>
<?php endif; ?> <?php endif; ?>
<?php // Compute the correct link ?>
<?php $menuclass = 'category' . $this->pageclass_sfx; ?>
<?php $link = $item->link; ?>
<?php $width = $item->params->get('width'); ?>
<?php $height = $item->params->get('height'); ?>
<?php if ($width == null || $height == null) : ?>
<?php $width = 600; ?>
<?php $height = 500; ?>
<?php endif; ?>
<?php if ($this->items[$i]->state == 0) : ?>
<span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
<?php <?php
// Compute the correct link switch ($item->params->get('target', $this->params->get('target')))
$menuclass = 'category' . $this->pageclass_sfx; {
$link = $item->link; case 1:
$width = $item->params->get('width'); // Open in a new window
$height = $item->params->get('height'); echo '<a href="' . $link . '" target="_blank" class="' . $menuclass . '" rel="nofollow">' .
if ($width == null || $height == null) $this->escape($item->title) . '</a>';
{ break;
$width = 600;
$height = 500;
}
if ($this->items[$i]->state == 0) : ?>
<span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
<?php switch ($item->params->get('target', $this->params->get('target'))) case 2:
{ // Open in a popup window
case 1: $attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' . $this->escape($width) . ',height=' . $this->escape($height) . '';
// Open in a new window echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '" . $attribs . "'); return false;\">" .
echo '<a href="' . $link . '" target="_blank" class="' . $menuclass . '" rel="nofollow">' . $this->escape($item->title) . '</a>';
$this->escape($item->title) . '</a>'; break;
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;
case 2: default:
// Open in a popup window // Open in parent 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 . '" class="' . $menuclass . '" rel="nofollow">' .
echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '" . $attribs . "'); return false;\">" . $this->escape($item->title) . ' </a>';
$this->escape($item->title) . '</a>'; break;
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> </div>
<?php $tagsData = $item->tags->getItemTags('com_weblinks.weblink', $item->id); ?> <?php $tagsData = $item->tags->getItemTags('com_weblinks.weblink', $item->id); ?>
@ -133,38 +131,32 @@ $listDirn = $this->escape($this->state->get('list.direction'));
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?> <?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($tagsData); ?> <?php echo $this->item->tagLayout->render($tagsData); ?>
<?php endif; ?> <?php endif; ?>
<?php if (($this->params->get('show_link_description')) and ($item->description != '')) : ?> <?php if (($this->params->get('show_link_description')) and ($item->description != '')) : ?>
<?php $images = json_decode($item->images); ?> <?php $images = json_decode($item->images); ?>
<?php if (isset($images->image_first) and !empty($images->image_first)) : ?> <?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; ?> <?php $imgfloat = (empty($images->float_first)) ? $this->params->get('float_first') : $images->float_first; ?>
<div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>"> <img <div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>"> <img
<?php if ($images->image_first_caption): <?php if ($images->image_first_caption) : ?>
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_first_caption) .'"'; <?php echo 'class="caption" title="' . htmlspecialchars($images->image_first_caption) . '"'; ?>
endif; ?> <?php endif; ?>
src="<?php echo htmlspecialchars($images->image_first); ?>" alt="<?php echo htmlspecialchars($images->image_first_alt); ?>"/> </div> src="<?php echo htmlspecialchars($images->image_first); ?>" alt="<?php echo htmlspecialchars($images->image_first_alt); ?>"/> </div>
<?php endif; ?> <?php endif; ?>
<?php if (isset($images->image_second) and !empty($images->image_second)) : ?> <?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; ?> <?php $imgfloat = (empty($images->float_second)) ? $this->params->get('float_second') : $images->float_second; ?>
<div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img <div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img
<?php if ($images->image_second_caption): <?php if ($images->image_second_caption) : ?>
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_second_caption) .'"'; <?php echo 'class="caption" title="' . htmlspecialchars($images->image_second_caption) . '"'; ?>
endif; ?> <?php endif; ?>
src="<?php echo htmlspecialchars($images->image_second); ?>" alt="<?php echo htmlspecialchars($images->image_second_alt); ?>"/> </div> src="<?php echo htmlspecialchars($images->image_second); ?>" alt="<?php echo htmlspecialchars($images->image_second_alt); ?>"/> </div>
<?php endif; ?> <?php endif; ?>
<?php echo $item->description; ?> <?php echo $item->description; ?>
<?php endif; ?> <?php endif; ?>
</li> </li>
<?php endif;?> <?php endif;?>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
<?php // Code to add a link to submit a weblink. ?> <?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')) : ?> <?php if ($this->params->get('show_pagination')) : ?>
<div class="pagination"> <div class="pagination">
<?php if ($this->params->def('show_pagination_results', 1)) : ?> <?php if ($this->params->def('show_pagination_results', 1)) : ?>

View File

@ -14,6 +14,18 @@ JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select'); JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.modal', 'a.modal_jform_contenthistory'); JHtml::_('behavior.modal', 'a.modal_jform_contenthistory');
$captchaEnabled = false;
$captchaSet = $this->params->get('captcha', JFactory::getApplication()->get('captcha', '0'));
foreach (JPluginHelper::getPlugin('captcha') as $plugin)
{
if ($captchaSet === $plugin->name)
{
$captchaEnabled = true;
break;
}
}
// Create shortcut to parameters. // Create shortcut to parameters.
$params = $this->state->get('params'); $params = $this->state->get('params');
?> ?>
@ -34,7 +46,32 @@ $params = $this->state->get('params');
<?php echo $this->escape($this->params->get('page_heading')); ?> <?php echo $this->escape($this->params->get('page_heading')); ?>
</h1> </h1>
<?php endif; ?> <?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"> <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">
<?php echo $this->form->renderField('title'); ?>
<?php echo $this->form->renderField('alias'); ?>
<?php echo $this->form->renderField('catid'); ?>
<?php echo $this->form->renderField('url'); ?>
<?php echo $this->form->renderField('tags'); ?>
<?php if ($params->get('save_history', 0)) : ?>
<?php echo $this->form->renderField('version_note'); ?>
<?php endif; ?>
<?php if ($this->user->authorise('core.edit.state', 'com_weblinks.weblink')) : ?>
<?php echo $this->form->renderField('state'); ?>
<?php endif; ?>
<?php echo $this->form->renderField('language'); ?>
<?php echo $this->form->renderField('description'); ?>
<hr class="hr-condensed" />
<?php if ($captchaEnabled) : ?>
<div class="btn-group">
<?php echo $this->form->renderField('captcha'); ?>
</div>
<?php endif; ?>
<div class="btn-toolbar"> <div class="btn-toolbar">
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-primary" onclick="Joomla.submitbutton('weblink.save')"> <button type="button" class="btn btn-primary" onclick="Joomla.submitbutton('weblink.save')">
@ -53,23 +90,6 @@ $params = $this->state->get('params');
<?php endif; ?> <?php endif; ?>
</div> </div>
<hr class="hr-condensed" />
<?php echo $this->form->renderField('title'); ?>
<?php echo $this->form->renderField('alias'); ?>
<?php echo $this->form->renderField('catid'); ?>
<?php echo $this->form->renderField('url'); ?>
<?php echo $this->form->renderField('tags'); ?>
<?php if ($params->get('save_history', 0)) : ?>
<?php echo $this->form->renderField('version_note'); ?>
<?php endif; ?>
<?php if ($this->user->authorise('core.edit.state', 'com_weblinks.weblink')) : ?>
<?php echo $this->form->renderField('state'); ?>
<?php endif; ?>
<?php echo $this->form->renderField('language'); ?>
<?php echo $this->form->renderField('description'); ?>
<input type="hidden" name="return" value="<?php echo $this->return_page;?>" /> <input type="hidden" name="return" value="<?php echo $this->return_page;?>" />
<input type="hidden" name="task" value="" /> <input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?> <?php echo JHtml::_('form.token'); ?>

View File

@ -24,6 +24,13 @@ class WeblinksViewForm extends JViewLegacy
protected $state; protected $state;
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null) public function display($tpl = null)
{ {
$user = JFactory::getUser(); $user = JFactory::getUser();
@ -40,7 +47,7 @@ class WeblinksViewForm extends JViewLegacy
} }
else else
{ {
$authorised = $user->authorise('core.edit', 'com_weblinks.category.'.$this->item->catid); $authorised = $user->authorise('core.edit', 'com_weblinks.category.' . $this->item->catid);
} }
if ($authorised !== true) if ($authorised !== true)
@ -52,6 +59,14 @@ class WeblinksViewForm extends JViewLegacy
if (!empty($this->item)) if (!empty($this->item))
{ {
// Override the base weblink data with any data in the session.
$temp = (array) JFactory::getApplication()->getUserState('com_weblinks.edit.weblink.data', array());
foreach ($temp as $k => $v)
{
$this->item->$k = $v;
}
$this->form->bind($this->item); $this->form->bind($this->item);
} }
@ -66,7 +81,7 @@ class WeblinksViewForm extends JViewLegacy
// Create a shortcut to the parameters. // Create a shortcut to the parameters.
$params = &$this->state->params; $params = &$this->state->params;
//Escape strings for HTML output // Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$this->params = $params; $this->params = $params;
@ -78,12 +93,14 @@ class WeblinksViewForm extends JViewLegacy
/** /**
* Prepares the document * Prepares the document
*
* @return void
*/ */
protected function _prepareDocument() protected function _prepareDocument()
{ {
$app = JFactory::getApplication(); $app = JFactory::getApplication();
$menus = $app->getMenu(); $menus = $app->getMenu();
$title = null; $title = null;
// Because the application sets a default page title, // Because the application sets a default page title,
// we need to get it from the menu item itself // we need to get it from the menu item itself

View File

@ -20,25 +20,33 @@ class WeblinksViewWeblink extends JViewLegacy
protected $item; protected $item;
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null) public function display($tpl = null)
{ {
// Get some data from the models // Get some data from the models
$item = $this->get('Item'); $item = $this->get('Item');
if ($this->getLayout() == 'edit') if ($this->getLayout() == 'edit')
{ {
$this->_displayEdit($tpl); $this->_displayEdit($tpl);
return; return;
} }
if ($item->url) if ($item->url)
{ {
// redirects to url if matching id found // Redirects to url if matching id found
JFactory::getApplication()->redirect($item->url); JFactory::getApplication()->redirect($item->url);
} }
else else
{ {
//TODO create proper error handling // @TODO create proper error handling
JFactory::getApplication()->redirect(JRoute::_('index.php'), JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 'notice'); JFactory::getApplication()->redirect(JRoute::_('index.php'), JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 'notice');
} }
} }

View File

@ -3,6 +3,8 @@
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM ; Note : All ini files need to be saved as UTF-8 - No BOM
COM_WEBLINKS_CAPTCHA_LABEL="Captcha"
COM_WEBLINKS_CAPTCHA_DESC="Please complete the security check."
COM_WEBLINKS_CONTENT_TYPE_WEBLINK="Web Link" COM_WEBLINKS_CONTENT_TYPE_WEBLINK="Web Link"
COM_WEBLINKS_CONTENT_TYPE_CATEGORY="Web Links Category" COM_WEBLINKS_CONTENT_TYPE_CATEGORY="Web Links Category"
COM_WEBLINKS_DEFAULT_PAGE_TITLE="Web Links" COM_WEBLINKS_DEFAULT_PAGE_TITLE="Web Links"

View File

@ -3,8 +3,18 @@
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM ; Note : All ini files need to be saved as UTF-8 - No BOM
MOD_WEBLINKS="Weblinks" MOD_WEBLINKS="Web Links"
MOD_WEBLINKS_FIELD_CATEGORY_DESC="Choose the Web Links category to display." MOD_WEBLINKS_FIELD_CATEGORY_DESC="Choose the Web Links category to display."
MOD_WEBLINKS_FIELD_GROUPBY_DESC="If set to yes, weblinks will be grouped by subcategories."
MOD_WEBLINKS_FIELD_GROUPBY_LABEL="Group By Subcategories"
MOD_WEBLINKS_FIELD_GROUPBYSHOWTITLE_DESC="If set to yes, will show groups titles (valid only if grouping)."
MOD_WEBLINKS_FIELD_GROUPBYSHOWTITLE_LABEL="Show Group Title"
MOD_WEBLINKS_FIELD_GROUPBYORDERING_DESC="Ordering for the subcategories (valid only if grouping)."
MOD_WEBLINKS_FIELD_GROUPBYORDERING_LABEL="Group Ordering"
MOD_WEBLINKS_FIELD_GROUPBYDIRECTION_DESC="Direction for the subcategories (valid only if grouping)."
MOD_WEBLINKS_FIELD_GROUPBYDIRECTION_LABEL="Group Ordering Direction"
MOD_WEBLINKS_FIELD_COLUMNS_DESC="When grouping by subcategories, split into # columns."
MOD_WEBLINKS_FIELD_COLUMNS_LABEL="Columns"
MOD_WEBLINKS_FIELD_COUNT_DESC="Number of Web Links to display." MOD_WEBLINKS_FIELD_COUNT_DESC="Number of Web Links to display."
MOD_WEBLINKS_FIELD_COUNT_LABEL="Count" MOD_WEBLINKS_FIELD_COUNT_LABEL="Count"
MOD_WEBLINKS_FIELD_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded." MOD_WEBLINKS_FIELD_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded."

View File

@ -3,5 +3,5 @@
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 ; Note : All ini files need to be saved as UTF-8
PKG_WEBLINKS="Weblinks Extension Package" PKG_WEBLINKS="Web Links Extension Package"
PKG_WEBLINKS_XML_DESCRIPTION="The Weblinks package includes the weblinks component, module, and search plugins for both of Joomla's search platforms." PKG_WEBLINKS_XML_DESCRIPTION="The Web Links package includes the Web Links component, module, and search plugins for both of Joomla's search platforms."

View File

@ -57,6 +57,9 @@ class ModWeblinksHelper
$catid = (int) $params->get('catid', 0); $catid = (int) $params->get('catid', 0);
$model->setState('category.id', $catid); $model->setState('category.id', $catid);
$model->setState('category.group', $params->get('groupby', 0));
$model->setState('category.ordering', $params->get('groupby_ordering', 'c.lft'));
$model->setState('category.direction', $params->get('groupby_direction', 'ASC'));
// Create query object // Create query object
$db = JFactory::getDbo(); $db = JFactory::getDbo();

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.1" client="site" method="upgrade"> <extension type="module" version="3.5" client="site" method="upgrade">
<name>mod_weblinks</name> <name>mod_weblinks</name>
<author>Joomla! Project</author> <author>Joomla! Project</author>
<creationDate>##DATE##</creationDate> <creationDate>##DATE##</creationDate>
@ -20,141 +20,204 @@
<fields name="params"> <fields name="params">
<fieldset name="basic"> <fieldset name="basic">
<field <field
name="catid" name="catid"
type="category" type="category"
extension="com_weblinks" extension="com_weblinks"
required="true" required="true"
label="JCATEGORY" label="JCATEGORY"
description="MOD_WEBLINKS_FIELD_CATEGORY_DESC" /> description="MOD_WEBLINKS_FIELD_CATEGORY_DESC" />
<field <field
name="count" name="groupby"
type="text" type="radio"
default="5" class="btn-group btn-group-yesno"
label="MOD_WEBLINKS_FIELD_COUNT_LABEL" default="0"
description="MOD_WEBLINKS_FIELD_COUNT_DESC" /> label="MOD_WEBLINKS_FIELD_GROUPBY_LABEL"
<field description="MOD_WEBLINKS_FIELD_GROUPBY_DESC">
name="ordering"
type="list"
default="title"
label="MOD_WEBLINKS_FIELD_ORDERING_LABEL"
description="MOD_WEBLINKS_FIELD_ORDERING_DESC">
<option <option
value="title">JGLOBAL_TITLE</option> value="1">JYES</option>
<option <option
value="order">MOD_WEBLINKS_FIELD_VALUE_ORDER</option> value="0">JNO</option>
<option
value="hits">MOD_WEBLINKS_FIELD_VALUE_HITS</option>
</field> </field>
<field <field
name="direction" name="groupby_showtitle"
type="list" type="radio"
default="asc" class="btn-group btn-group-yesno"
label="MOD_WEBLINKS_FIELD_ORDERDIRECTION_LABEL" default="1"
description="MOD_WEBLINKS_FIELD_ORDERDIRECTION_DESC"> label="MOD_WEBLINKS_FIELD_GROUPBYSHOWTITLE_LABEL"
description="MOD_WEBLINKS_FIELD_GROUPBYSHOWTITLE_DESC">
<option <option
value="asc">MOD_WEBLINKS_FIELD_VALUE_ASCENDING</option> value="1">JYES</option>
<option <option
value="desc">MOD_WEBLINKS_FIELD_VALUE_DESCENDING</option> value="0">JNO</option>
</field> </field>
<field <field
name="target" name="groupby_ordering"
type="list" type="list"
default="3" default="c.lft"
label="MOD_WEBLINKS_FIELD_TARGET_LABEL" label="MOD_WEBLINKS_FIELD_GROUPBYORDERING_LABEL"
description="MOD_WEBLINKS_FIELD_TARGET_DESC"> description="MOD_WEBLINKS_FIELD_GROUPBYORDERING_DESC">
<option <option
value="1">JBROWSERTARGET_NEW</option> value="c.title">JGLOBAL_TITLE</option>
<option <option
value="2">JBROWSERTARGET_POPUP</option> value="c.lft">MOD_WEBLINKS_FIELD_VALUE_ORDER</option>
<option
value="3">JBROWSERTARGET_PARENT</option>
</field> </field>
<field <field
name="follow" name="groupby_direction"
type="list" type="list"
default="0" default="asc"
label="MOD_WEBLINKS_FIELD_FOLLOW_LABEL" label="MOD_WEBLINKS_FIELD_GROUPBYDIRECTION_LABEL"
description="MOD_WEBLINKS_FIELD_FOLLOW_DESC"> description="MOD_WEBLINKS_FIELD_GROUPBYDIRECTION_DESC">
<option <option
value="follow">MOD_WEBLINKS_FIELD_VALUE_FOLLOW</option> value="asc">MOD_WEBLINKS_FIELD_VALUE_ASCENDING</option>
<option <option
value="nofollow">MOD_WEBLINKS_FIELD_VALUE_NOFOLLOW</option> value="desc">MOD_WEBLINKS_FIELD_VALUE_DESCENDING</option>
</field> </field>
<field <field
name="description" name="groupby_columns"
type="radio" type="list"
class="btn-group btn-group-yesno" default="3"
default="0" label="MOD_WEBLINKS_FIELD_COLUMNS_LABEL"
label="MOD_WEBLINKS_FIELD_DESCRIPTION_LABEL" description="MOD_WEBLINKS_FIELD_COLUMNS_DESC">
description="MOD_WEBLINKS_FIELD_DESCRIPTION_DESC">
<option <option
value="1">JSHOW</option> value="1">1</option>
<option
value="2">2</option>
<option <option
value="0">JHIDE</option> value="3">3</option>
<option
value="4">4</option>
<option
value="6">6</option>
</field> </field>
<field <field
name="hits" name="count"
type="radio" type="text"
class="btn-group btn-group-yesno" default="5"
default="0" label="MOD_WEBLINKS_FIELD_COUNT_LABEL"
label="MOD_WEBLINKS_FIELD_HITS_LABEL" description="MOD_WEBLINKS_FIELD_COUNT_DESC" />
description="MOD_WEBLINKS_FIELD_HITS_DESC"> <field
name="ordering"
type="list"
default="title"
label="MOD_WEBLINKS_FIELD_ORDERING_LABEL"
description="MOD_WEBLINKS_FIELD_ORDERING_DESC">
<option <option
value="1">JSHOW</option> value="title">JGLOBAL_TITLE</option>
<option <option
value="0">JHIDE</option> value="order">MOD_WEBLINKS_FIELD_VALUE_ORDER</option>
<option
value="hits">MOD_WEBLINKS_FIELD_VALUE_HITS</option>
</field>
<field
name="direction"
type="list"
default="asc"
label="MOD_WEBLINKS_FIELD_ORDERDIRECTION_LABEL"
description="MOD_WEBLINKS_FIELD_ORDERDIRECTION_DESC">
<option
value="asc">MOD_WEBLINKS_FIELD_VALUE_ASCENDING</option>
<option
value="desc">MOD_WEBLINKS_FIELD_VALUE_DESCENDING</option>
</field>
<field
name="target"
type="list"
default="3"
label="MOD_WEBLINKS_FIELD_TARGET_LABEL"
description="MOD_WEBLINKS_FIELD_TARGET_DESC">
<option
value="1">JBROWSERTARGET_NEW</option>
<option
value="2">JBROWSERTARGET_POPUP</option>
<option
value="3">JBROWSERTARGET_PARENT</option>
</field>
<field
name="follow"
type="list"
default="0"
label="MOD_WEBLINKS_FIELD_FOLLOW_LABEL"
description="MOD_WEBLINKS_FIELD_FOLLOW_DESC">
<option
value="follow">MOD_WEBLINKS_FIELD_VALUE_FOLLOW</option>
<option
value="nofollow">MOD_WEBLINKS_FIELD_VALUE_NOFOLLOW</option>
</field>
<field
name="description"
type="radio"
class="btn-group btn-group-yesno"
default="0"
label="MOD_WEBLINKS_FIELD_DESCRIPTION_LABEL"
description="MOD_WEBLINKS_FIELD_DESCRIPTION_DESC">
<option
value="1">JSHOW</option>
<option
value="0">JHIDE</option>
</field>
<field
name="hits"
type="radio"
class="btn-group btn-group-yesno"
default="0"
label="MOD_WEBLINKS_FIELD_HITS_LABEL"
description="MOD_WEBLINKS_FIELD_HITS_DESC">
<option
value="1">JSHOW</option>
<option
value="0">JHIDE</option>
</field> </field>
<field <field
name="count_clicks" name="count_clicks"
type="list" type="list"
class="chzn-color" class="chzn-color"
default="0" default="0"
label="MOD_WEBLINKS_FIELD_COUNTCLICKS_LABEL" label="MOD_WEBLINKS_FIELD_COUNTCLICKS_LABEL"
description="MOD_WEBLINKS_FIELD_COUNTCLICKS_DESC"> description="MOD_WEBLINKS_FIELD_COUNTCLICKS_DESC">
<option
value="">JGLOBAL_USE_GLOBAL</option>
<option <option
value="">JGLOBAL_USE_GLOBAL</option> value="0">JNO</option>
<option <option
value="0">JNO</option> value="1">JYES</option>
<option
value="1">JYES</option>
</field> </field>
</fieldset> </fieldset>
<fieldset <fieldset
name="advanced"> name="advanced">
<field <field
name="layout" name="layout"
type="modulelayout" type="modulelayout"
label="JFIELD_ALT_LAYOUT_LABEL" label="JFIELD_ALT_LAYOUT_LABEL"
description="JFIELD_ALT_MODULE_LAYOUT_DESC" /> description="JFIELD_ALT_MODULE_LAYOUT_DESC" />
<field <field
name="moduleclass_sfx" name="moduleclass_sfx"
type="textarea" rows="3" type="textarea" rows="3"
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL" label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC" /> description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC" />
<field <field
name="cache" name="cache"
type="list" type="list"
default="1" default="1"
label="COM_MODULES_FIELD_CACHING_LABEL" label="COM_MODULES_FIELD_CACHING_LABEL"
description="COM_MODULES_FIELD_CACHING_DESC"> description="COM_MODULES_FIELD_CACHING_DESC">
<option <option
value="1">JGLOBAL_USE_GLOBAL</option> value="1">JGLOBAL_USE_GLOBAL</option>
<option <option
value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option> value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
</field> </field>
<field <field
name="cache_time" name="cache_time"
type="text" type="text"
default="900" default="900"
label="COM_MODULES_FIELD_CACHE_TIME_LABEL" label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
description="COM_MODULES_FIELD_CACHE_TIME_DESC" /> description="COM_MODULES_FIELD_CACHE_TIME_DESC" />
<field <field
name="cachemode" name="cachemode"
type="hidden" type="hidden"
default="static"> default="static">
<option <option
value="static"></option> value="static"></option>
</field> </field>
</fieldset> </fieldset>
</fields> </fields>

View File

@ -9,47 +9,109 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
?> ?>
<ul class="weblinks<?php echo $moduleclass_sfx; ?>">
<?php
foreach ($list as $item) :
?>
<li>
<?php
$link = $item->link;
switch ($params->get('target', 3)) <?php if ($params->get('groupby', 0)) : ?>
{ <?php $cats = array(); ?>
case 1: <?php $cols = $params->get('groupby_columns', 3); ?>
// Open in a new window <?php foreach ($list as $l) : ?>
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' . <?php $cats[] = array('catid' => $l->catid, 'title' => $l->category_title); ?>
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>'; <?php endforeach; ?>
break; <?php $cats = array_values(array_map('unserialize', array_unique(array_map('serialize', $cats)))); ?>
<?php foreach ($cats as $k => $cat) : ?>
<?php $items = array(); ?>
<?php foreach ($list as $item) : ?>
<?php if ($item->catid == $cat['catid']) : ?>
<?php $items[] = $item; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php if ($cols > 1) : ?>
<?php if ($k % $cols == 0) : ?>
<div class="row row-fluid">
<?php endif; ?>
<div class="span<?php echo (12 / $cols); ?>">
<?php endif; ?>
<?php if ($params->get('groupby_showtitle', 1)) : ?>
<h4><?php echo htmlspecialchars($cat['title'], ENT_COMPAT, 'UTF-8')); ?></h4>
<?php endif; ?>
<ul class="weblinks<?php echo $moduleclass_sfx; ?>">
<?php foreach ($items as $item) : ?>
<li>
<?php $link = $item->link; ?>
<?php
switch ($item->params->get('target', 3))
{
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 2: case 2:
// Open in a popup window // Open in a popup window
echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" . echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>'; htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break; break;
default: default:
// Open in parent window // Open in parent window
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' . echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>'; htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break; break;
} }
?>
<?php if ($params->get('description', 0)) : ?>
<?php echo nl2br($item->description); ?>
<?php endif; ?>
if ($params->get('description', 0)) <?php if ($params->get('hits', 0)) : ?>
{ <?php echo '(' . $item->hits . ' ' . JText::_('MOD_WEBLINKS_HITS') . ')'; ?>
echo nl2br($item->description); <?php endif; ?>
} </li>
<?php endforeach; ?>
</ul>
<?php if ($cols > 1) : ?>
</div>
<?php if(($k + 1) % $cols == 0 || $k == count($cats) - 1) : ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php else : ?>
<ul class="weblinks<?php echo $moduleclass_sfx; ?>">
<?php foreach ($list as $item) : ?>
<li>
<?php $link = $item->link; ?>
<?php
switch ($item->params->get('target', 3))
{
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
if ($params->get('hits', 0)) case 2:
{ // Open in a popup window
echo '(' . $item->hits . ' ' . JText::_('MOD_WEBLINKS_HITS') . ')'; echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" .
} htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
?> break;
</li>
<?php default:
endforeach; // Open in parent window
?> echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
</ul> htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
}
?>
<?php if ($params->get('description', 0)) : ?>
<?php echo nl2br($item->description); ?>
<?php endif; ?>
<?php if ($params->get('hits', 0)) : ?>
<?php echo '(' . $item->hits . ' ' . JText::_('MOD_WEBLINKS_HITS') . ')'; ?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<extension type="package" version="3.0" method="upgrade"> <extension type="package" version="3.5" method="upgrade">
<name>pkg_weblinks</name> <name>pkg_weblinks</name>
<packagename>weblinks</packagename> <packagename>weblinks</packagename>
<creationDate>December 2012</creationDate> <creationDate>December 2012</creationDate>
@ -25,6 +25,6 @@
</languages> </languages>
<updateservers> <updateservers>
<!-- Note: No spaces or linebreaks allowed between the server tags --> <!-- Note: No spaces or linebreaks allowed between the server tags -->
<server type="extension" name="Weblinks Update Site">https://raw.githubusercontent.com/joomla-extensions/weblinks/master/manifest.xml</server> <server type="extension" name="Web Links Update Site">https://raw.githubusercontent.com/joomla-extensions/weblinks/master/manifest.xml</server>
</updateservers> </updateservers>
</extension> </extension>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="finder" method="upgrade"> <extension version="3.5" type="plugin" group="finder" method="upgrade">
<name>plg_finder_weblinks</name> <name>plg_finder_weblinks</name>
<author>Joomla! Project</author> <author>Joomla! Project</author>
<creationDate>##DATE##</creationDate> <creationDate>##DATE##</creationDate>

View File

@ -174,7 +174,7 @@ class PlgSearchWeblinks extends JPlugin
$case_when1 .= ' ELSE '; $case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug'; $case_when1 .= $c_id . ' END as catslug';
$query->select('a.title AS title, \'\' AS created, a.url, a.description AS text, ' . $case_when . "," . $case_when1) $query->select('a.title AS title, a.created AS created, a.url, a.description AS text, ' . $case_when . "," . $case_when1)
->select($query->concatenate(array($db->quote($searchWeblinks), 'c.title'), " / ") . ' AS section') ->select($query->concatenate(array($db->quote($searchWeblinks), 'c.title'), " / ") . ' AS section')
->select('\'1\' AS browsernav') ->select('\'1\' AS browsernav')
->from('#__weblinks AS a') ->from('#__weblinks AS a')

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="search" method="upgrade"> <extension version="3.5" type="plugin" group="search" method="upgrade">
<name>plg_search_weblinks</name> <name>plg_search_weblinks</name>
<author>Joomla! Project</author> <author>Joomla! Project</author>
<creationDate>##DATE##</creationDate> <creationDate>##DATE##</creationDate>

View File

@ -44,4 +44,35 @@ class weblink extends \AcceptanceTester
$I->clickToolbarButton('Save & Close'); $I->clickToolbarButton('Save & Close');
$I->waitForText('Web link successfully saved', '30', ['id' => 'system-message-container']); $I->waitForText('Web link successfully saved', '30', ['id' => 'system-message-container']);
} }
public function administratorDeleteWeblink($title)
{
$I = $this;
$I->amGoingTo('Navigate to Weblinks page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_weblinks');
$I->waitForText('Web Links','30',['css' => 'h1']);
$I->expectTo('see weblinks page');
$I->amGoingTo('Search for the weblink');
$I->searchForItem($title);
$I->waitForText('Web Links','30',['css' => 'h1']);
$I->amGoingTo('Trash the weblink');
$I->checkAllResults();
$I->clickToolbarButton('Trash');
$I->waitForText('Web Links','30',['css' => 'h1']);
$I->waitForText('1 web link successfully trashed', 30, ['id' => 'system-message-container']);
$I->amGoingTo('Delete the weblink');
$I->selectOptionInChosen('- Select Status -', 'Trashed');
$I->amGoingTo('Search the just saved weblink');
$I->searchForItem($title);
$I->waitForText('Web Links','30',['css' => 'h1']);
$I->checkAllResults();
$I->click(['xpath'=> '//div[@id="toolbar-delete"]/button']);
$I->acceptPopup();
$I->waitForText('Web Links','30',['css' => 'h1']);
$I->waitForText('1 web link successfully deleted.', 30, ['id' => 'system-message-container']);
}
} }

View File

@ -32,12 +32,12 @@ class AdministratorCategoriesCest
$I->amGoingTo('Navigate to Categories page in /administrator/'); $I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks'); $I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories', '60', ['css' => 'h1']); $I->waitForText('Web Links: Categories', '60', ['css' => 'h1']);
$I->expectTo('see categories page'); $I->expectTo('see categories page');
$I->amGoingTo('try to save a category with empty title and it should fail'); $I->amGoingTo('try to save a category with empty title and it should fail');
$I->clickToolbarButton('new'); $I->clickToolbarButton('new');
$I->waitForText('Weblinks: New Category', '60', ['css' => 'h1']); $I->waitForText('Web Links: New Category', '60', ['css' => 'h1']);
$I->clickToolbarButton('save'); $I->clickToolbarButton('save');
$I->expectTo('see an error when trying to save a category without title'); $I->expectTo('see an error when trying to save a category without title');
$I->see('Invalid field: Title', ['id' => 'system-message-container']); $I->see('Invalid field: Title', ['id' => 'system-message-container']);
@ -52,13 +52,13 @@ class AdministratorCategoriesCest
$I->amGoingTo('Navigate to Categories page in /administrator/ and create a Category'); $I->amGoingTo('Navigate to Categories page in /administrator/ and create a Category');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks'); $I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories', '60', ['css' => 'h1']); $I->waitForText('Web Links: Categories', '60', ['css' => 'h1']);
$I->expectTo('see categories page'); $I->expectTo('see categories page');
$I->checkForPhpNoticesOrWarnings(); $I->checkForPhpNoticesOrWarnings();
$I->amGoingTo('try to save a category with a filled title'); $I->amGoingTo('try to save a category with a filled title');
$I->clickToolbarButton('New'); $I->clickToolbarButton('New');
$I->waitForText('Weblinks: New Category', '60', ['css' => 'h1']); $I->waitForText('Web Links: New Category', '60', ['css' => 'h1']);
$I->fillField(['id' => 'jform_title'], $this->categoryTitle); $I->fillField(['id' => 'jform_title'], $this->categoryTitle);
$I->clickToolbarButton('Save & Close'); $I->clickToolbarButton('Save & Close');
$I->expectTo('see a success message after saving the category'); $I->expectTo('see a success message after saving the category');
@ -78,9 +78,9 @@ class AdministratorCategoriesCest
$I->amGoingTo('Navigate to Categories page in /administrator/'); $I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks'); $I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->searchForItem($this->categoryTitle); $I->searchForItem($this->categoryTitle);
$I->waitForText('Weblinks: Categories', '60', ['css' => 'h1']); $I->waitForText('Web Links: Categories', '60', ['css' => 'h1']);
$I->checkAllResults(); $I->checkAllResults();
$I->amGoingTo('try to publish a Weblinks Category'); $I->amGoingTo('try to publish a Web Links Category');
$I->clickToolbarButton('publish'); $I->clickToolbarButton('publish');
$I->waitForElement(['id' => 'system-message-container'], '60'); $I->waitForElement(['id' => 'system-message-container'], '60');
$I->expectTo('see a success message after publishing the category'); $I->expectTo('see a success message after publishing the category');
@ -98,10 +98,10 @@ class AdministratorCategoriesCest
$I->doAdministratorLogin(); $I->doAdministratorLogin();
$I->amGoingTo('Navigate to Categories page in /administrator/'); $I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks'); $I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories', '60', ['css' => 'h1']); $I->waitForText('Web Links: Categories', '60', ['css' => 'h1']);
$I->searchForItem($this->categoryTitle); $I->searchForItem($this->categoryTitle);
$I->checkAllResults(); $I->checkAllResults();
$I->amGoingTo('try to unpublish a Weblinks Category'); $I->amGoingTo('try to unpublish a Web Links Category');
$I->clickToolbarButton('unpublish'); $I->clickToolbarButton('unpublish');
$I->waitForElement(['id' => 'system-message-container'], '60'); $I->waitForElement(['id' => 'system-message-container'], '60');
$I->expectTo('See a success message after unpublishing the category'); $I->expectTo('See a success message after unpublishing the category');
@ -119,10 +119,10 @@ class AdministratorCategoriesCest
$I->doAdministratorLogin(); $I->doAdministratorLogin();
$I->amGoingTo('Navigate to Categories page in /administrator/'); $I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks'); $I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories', '60', ['css' => 'h1']); $I->waitForText('Web Links: Categories', '60', ['css' => 'h1']);
$I->searchForItem($this->categoryTitle); $I->searchForItem($this->categoryTitle);
$I->checkAllResults(); $I->checkAllResults();
$I->amGoingTo('try to archive a weblink category'); $I->amGoingTo('try to archive a Web Links category');
$I->clickToolbarButton('archive'); $I->clickToolbarButton('archive');
$I->waitForElement(['id' => 'system-message-container'], '60'); $I->waitForElement(['id' => 'system-message-container'], '60');
$I->expectTo('see a success message after Archiving the category'); $I->expectTo('see a success message after Archiving the category');
@ -140,11 +140,11 @@ class AdministratorCategoriesCest
$I->doAdministratorLogin(); $I->doAdministratorLogin();
$I->amGoingTo('Navigate to Categories page in /administrator/'); $I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks'); $I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories', '60', ['css' => 'h1']); $I->waitForText('Web Links: Categories', '60', ['css' => 'h1']);
$I->setFilter('Select Status', 'Archived'); $I->setFilter('Select Status', 'Archived');
$I->searchForItem($this->categoryTitle); $I->searchForItem($this->categoryTitle);
$I->checkAllResults(); $I->checkAllResults();
$I->amGoingTo('try to delete a Weblinks Category'); $I->amGoingTo('try to delete a Web Links Category');
$I->clickToolbarButton('Trash'); $I->clickToolbarButton('Trash');
$I->waitForElement(['id' => 'system-message-container'], '60'); $I->waitForElement(['id' => 'system-message-container'], '60');
$I->expectTo('see a success message after Trashing the category'); $I->expectTo('see a success message after Trashing the category');
@ -162,11 +162,11 @@ class AdministratorCategoriesCest
$I->doAdministratorLogin(); $I->doAdministratorLogin();
$I->amGoingTo('Navigate to Categories page in /administrator/'); $I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks'); $I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories', '60', ['css' => 'h1']); $I->waitForText('Web Links: Categories', '60', ['css' => 'h1']);
$I->setFilter('Select Status', 'Trashed'); $I->setFilter('Select Status', 'Trashed');
$I->searchForItem($this->categoryTitle); $I->searchForItem($this->categoryTitle);
$I->checkAllResults(); $I->checkAllResults();
$I->amGoingTo('try to delete a Weblinks Category'); $I->amGoingTo('try to delete a Web Links Category');
$I->clickToolbarButton('Empty trash'); $I->clickToolbarButton('Empty trash');
$I->acceptPopup(); $I->acceptPopup();
$I->waitForElement(['id' => 'system-message-container'], '60'); $I->waitForElement(['id' => 'system-message-container'], '60');
@ -184,7 +184,7 @@ class AdministratorCategoriesCest
$I->amGoingTo('Navigate to Categories page in /administrator/ and verify the Tabs'); $I->amGoingTo('Navigate to Categories page in /administrator/ and verify the Tabs');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks'); $I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->clickToolbarButton('New'); $I->clickToolbarButton('New');
$I->waitForText('Weblinks: New Category', '30', ['css' => 'h1']); $I->waitForText('Web Links: New Category', '30', ['css' => 'h1']);
$I->verifyAvailableTabs(['Category', 'Publishing', 'Permissions', 'Options']); $I->verifyAvailableTabs(['Category', 'Options', 'Publishing', 'Permissions']);
} }
} }

View File

@ -0,0 +1,179 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
class AdministratorSmartSearchCest
{
public function __construct()
{
$this->faker = Faker\Factory::create();
$this->title = $this->faker->bothify('SmartSearch ?##?');
$this->url = $this->faker->url;
$this->articletext = 'This is a test';
}
/**
* Before the tests proper, switch the WYSIWYG editor off. This is to make it easier to create test content.
*/
public function administratorDisableEditor(\Step\Acceptance\weblink $I, $scenario)
{
$scenario->skip('Temporarilly skipped, see: https://github.com/joomla-extensions/weblinks/issues/239');
$I->am('Administrator');
$I->wantToTest('Disable the editor before the tests proper');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to the Global Configuration page in /administrator/ and disable the WYSIWYG Editor');
$I->amOnPage('administrator/index.php?option=com_config');
$I->waitForText('Global Configuration', 30, ['class' => 'page-title']);
$I->selectOptionInChosen('Default Editor', 'Editor - None');
$I->clickToolbarButton('Save & Close');
$I->waitForText('Control Panel', 30, ['class'=> 'page-title']);
$I->expectTo('see a success message after saving the configuration');
$I->see('Configuration successfully saved', ['id' => 'system-message-container']);
}
public function administratorEnableContentPlugin(\Step\Acceptance\weblink $I)
{
$I->am('Administrator');
$I->wantToTest('Enabling the Smart Search content plugin. Note that this is not a requirement for Smart Search to index Weblinks');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to the Smart Search page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_finder');
$I->expectTo('see a message saying that the content plugin should be enabled');
$I->waitForElement(['link' => 'Smart Search Content Plugin']);
$I->click(['link' => 'Smart Search Content Plugin']);
$I->waitForText('Plugins: Content - Smart Search', 30, ['class'=> 'page-title']);
$I->selectOptionInChosen('Status', 'Enabled');
$I->clickToolbarButton('save & close');
$I->waitForText('Plugin successfully saved.', 30, ['id' => 'system-message-container']);
$I->see('Plugin successfully saved.', ['id' => 'system-message-container']);
}
/**
* Before the tests proper, the Weblinks Smart Search plugin must be enabled.
*/
public function administratorEnableSmartsearchWeblinksPlugin(\Step\Acceptance\weblink $I, $scenario)
{
$scenario->skip('Temporarilly skipped, see: https://github.com/joomla-extensions/weblinks/issues/239');
$I->am('Administrator');
$I->wantToTest('Enabling the Smart Search Weblinks plugin');
$I->doAdministratorLogin();
$I->amOnPage('administrator/index.php?option=com_plugins');
$I->searchForItem('Smart Search - Web Links');
$I->click(['link' => 'Smart Search - Web Links']);
$I->waitForText('Plugins: Smart Search - Web Links', 30, ['class'=> 'page-title']);
$I->selectOptionInChosen('Status', 'Enabled');
$I->clickToolbarButton('save & close');
$I->waitForText('Plugin successfully saved.', 30, ['id' => 'system-message-container']);
$I->see('Plugin successfully saved.', ['id' => 'system-message-container']);
}
/**
* Purge the index.
*/
public function administratorPurgeIndex(\Step\Acceptance\weblink $I, $scenario)
{
$scenario->skip('Temporarilly skipped, see: https://github.com/joomla-extensions/weblinks/issues/239');
$I->am('Administrator');
$I->wantToTest('Purging the index');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to the Smart Search page in /administrator/ and purge the index');
$I->amOnPage('administrator/index.php?option=com_finder');
$I->waitForText('Smart Search', 30, ['class'=> 'page-title']);
$I->click('Clear Index');
$I->acceptPopup();
$I->waitForText('All items have been successfully deleted', 30, ['class' => 'alert-message']);
$I->see('All items have been successfully deleted', ['class' => 'alert-message']);
}
public function administratorCreateWeblink(\Step\Acceptance\weblink $I, $scenario)
{
$scenario->skip('Temporarilly skipped, see: https://github.com/joomla-extensions/weblinks/issues/239');
$I->doAdministratorLogin();
$I->createWeblink($this->title, $this->url);
}
/**
* Index the current content.
*/
public function administratorRunTheIndexer(\Step\Acceptance\weblink $I, $scenario)
{
$scenario->skip('Temporarilly skipped, see: https://github.com/joomla-extensions/weblinks/issues/239');
$I->am('Administrator');
$I->wantToTest('Smart Search Indexer');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to Smart Search page in /administrator/ and index the content');
$I->amOnPage('administrator/index.php?option=com_finder');
$I->waitForText('Smart Search: Indexed Content', 30, ['class'=> 'page-title']);
$I->click(['xpath' => "//div[@id='toolbar']//button[contains(text()[normalize-space()], 'Index')]"]);
$I->comment('I wait while smart search indexes the links');
$I->wait(2);
$I->waitForText($this->title, 30, '#j-main-container');
}
/**
* After the tests, the Smart Search content plugin must be disabled, ready for the next test.
*/
public function administratorDisableContentPlugin(\Step\Acceptance\weblink $I, $scenario)
{
$scenario->skip('Temporarilly skipped, see: https://github.com/joomla-extensions/weblinks/issues/239');
$I->am('Administrator');
$I->wantToTest('Disabling the Smart Search content plugin, ready for the next test run');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to Plugins page in /administrator/ and disable the Smart Search Content plugin');
$I->amOnPage('administrator/index.php?option=com_plugins&view=plugins');
$I->searchForItem('Content - Smart Search');
$I->waitForText('Plugins', 30, ['class'=> 'page-title']);
$I->waitForElement(['link' => 'Content - Smart Search']);
$I->checkOption(['id' => 'cb0']);
$I->clickToolbarButton('Unpublish'); // Note: The button is called "Disable", but we need to call it "Unpublish" here.
$I->waitForText('Plugin successfully disabled', 30, ['class' => 'alert-message']);
}
/**
* After the tests, the Smart Search content plugin must be disabled, ready for the next test.
*/
public function administratorDisableSmartsearchWeblinksPlugin(\Step\Acceptance\weblink $I, $scenario)
{
$scenario->skip('Temporarilly skipped, see: https://github.com/joomla-extensions/weblinks/issues/239');
$I->am('Administrator');
$I->wantToTest('Disabling the Smart Search content plugin, ready for the next test run');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to Plugins page in /administrator/ and disable the Smart Search Content plugin');
$I->amOnPage('administrator/index.php?option=com_plugins&view=plugins');
$I->searchForItem('Smart Search - Web Links');
$I->waitForText('Plugins', 30, ['class'=> 'page-title']);
$I->waitForElement(['link' => 'Smart Search - Web Links']);
$I->checkOption(['id' => 'cb0']);
$I->clickToolbarButton('Unpublish'); // Note: The button is called "Disable", but we need to call it "Unpublish" here.
$I->waitForText('Plugin successfully disabled', 30, ['class' => 'alert-message']);
}
public function cleanUp(\Step\Acceptance\weblink $I, $scenario)
{
$scenario->skip('Temporarilly skipped, see: https://github.com/joomla-extensions/weblinks/issues/239');
$I->doAdministratorLogin();
$I->administratorDeleteWeblink($this->title);
}
}

View File

@ -99,7 +99,9 @@ class AdministratorWeblinksCest
$I->amOnPage('administrator/index.php?option=com_weblinks'); $I->amOnPage('administrator/index.php?option=com_weblinks');
$I->waitForText('Web Links','30',['css' => 'h1']); $I->waitForText('Web Links','30',['css' => 'h1']);
$I->expectTo('see weblinks page'); $I->expectTo('see weblinks page');
$I->selectOptionInChosen('- Select Status -', 'Trashed'); $I->click('Search Tools');
$I->wait(2);
$I->selectOptionInChosenById('filter_published', 'Trashed');
$I->amGoingTo('Search the just saved weblink'); $I->amGoingTo('Search the just saved weblink');
$I->searchForItem($this->title); $I->searchForItem($this->title);
$I->waitForText('Web Links','30',['css' => 'h1']); $I->waitForText('Web Links','30',['css' => 'h1']);

View File

@ -28,26 +28,26 @@ class FrontendWeblinksCest
public function createWeblinkAndConfirmFrontend(\Step\Acceptance\weblink $I) public function createWeblinkAndConfirmFrontend(\Step\Acceptance\weblink $I)
{ {
$I->am('Administrator'); $I->am('Administrator');
$I->wantToTest('Listing a category of Weblinks in frontend'); $I->wantToTest('Listing a category of Web Links in frontend');
$I->doAdministratorLogin(); $I->doAdministratorLogin();
$I->createWeblink($this->title, $this->url, "No"); $I->createWeblink($this->title, $this->url, "No");
// Menu link // Menu link
$I->createMenuItem($this->menuItem, 'Weblinks', 'List All Web Link Categories', 'Main Menu'); $I->createMenuItem($this->menuItem, 'Web Links', 'List All Web Link Categories', 'Main Menu');
// Go to the frontend // Go to the frontend
$I->comment('I want to check if the menu entry exists in the frontend'); $I->comment('I want to check if the menu entry exists in the frontend');
$I->amOnPage('index.php?option=com_weblinks'); $I->amOnPage('index.php?option=com_weblinks');
$I->expectTo('see weblink categories'); $I->expectTo('see web link categories');
$I->waitForText('Uncategorised','30', ['css' => 'h3']); $I->waitForText('Uncategorised','30', ['css' => 'h3']);
$I->checkForPhpNoticesOrWarnings(); $I->checkForPhpNoticesOrWarnings();
$I->comment('I open the uncategorised Weblink Category'); $I->comment('I open the uncategorised Web link Category');
$I->click(['link' => 'Uncategorised']); $I->click(['link' => 'Uncategorised']);
$I->waitForText('Uncategorised','30', ['css' => 'h2']); $I->waitForText('Uncategorised','30', ['css' => 'h2']);
$I->expectTo('see the weblink we created'); $I->expectTo('see the web link we created');
$I->seeElement(['link' => $this->title]); $I->seeElement(['link' => $this->title]);
$I->seeElement(['xpath' => "//a[@href='$this->url']"]); $I->seeElement(['xpath' => "//a[@href='$this->url']"]);
} }
@ -66,16 +66,16 @@ class FrontendWeblinksCest
// Go to the frontend // Go to the frontend
$I->amOnPage('index.php?option=com_weblinks'); $I->amOnPage('index.php?option=com_weblinks');
$I->expectTo('see weblink categories'); $I->expectTo('see web link categories');
$I->waitForText('Uncategorised','30', ['css' => 'h3']); $I->waitForText('Uncategorised','30', ['css' => 'h3']);
$I->checkForPhpNoticesOrWarnings(); $I->checkForPhpNoticesOrWarnings();
$I->comment('I open the uncategorised Weblink Category'); $I->comment('I open the uncategorised Web Link Category');
$I->waitForElement(['link' => 'Uncategorised'], 60); $I->waitForElement(['link' => 'Uncategorised'], 60);
$I->click(['link' => 'Uncategorised']); $I->click(['link' => 'Uncategorised']);
// Check that hits is 0 // Check that hits is 0
$I->waitForText('Uncategorised','30', ['css' => 'h2']); $I->waitForText('Uncategorised','30', ['css' => 'h2']);
$I->expectTo('see the weblink we created'); $I->expectTo('see the web link we created');
$I->seeElement(['link' => $title]); $I->seeElement(['link' => $title]);
$I->expectTo('see that hits is 0'); $I->expectTo('see that hits is 0');
$I->see('Hits: 0', ['class' => 'list-hits']); $I->see('Hits: 0', ['class' => 'list-hits']);
@ -86,7 +86,7 @@ class FrontendWeblinksCest
$I->amOnPage('index.php?option=com_weblinks'); $I->amOnPage('index.php?option=com_weblinks');
$I->waitForElement(['link' => 'Uncategorised'], 60); $I->waitForElement(['link' => 'Uncategorised'], 60);
$I->click(['link' => 'Uncategorised']); $I->click(['link' => 'Uncategorised']);
$I->comment('I search the weblink: ' . $title); $I->comment('I search the web link: ' . $title);
$I->waitForElement(['id' => 'filter-search'], 60); $I->waitForElement(['id' => 'filter-search'], 60);
$I->fillField(['id' => 'filter-search'], $title); $I->fillField(['id' => 'filter-search'], $title);
$I->pressKey(['id' => 'filter-search'], \Facebook\WebDriver\WebDriverKeys::ENTER); $I->pressKey(['id' => 'filter-search'], \Facebook\WebDriver\WebDriverKeys::ENTER);
@ -111,15 +111,15 @@ class FrontendWeblinksCest
// Go to the frontend // Go to the frontend
$I->amOnPage('index.php?option=com_weblinks'); $I->amOnPage('index.php?option=com_weblinks');
$I->expectTo('see weblink categories'); $I->expectTo('see web link categories');
$I->waitForText('Uncategorised','30', ['css' => 'h3']); $I->waitForText('Uncategorised','30', ['css' => 'h3']);
$I->checkForPhpNoticesOrWarnings(); $I->checkForPhpNoticesOrWarnings();
$I->comment('I open the uncategorised Weblink Category'); $I->comment('I open the uncategorised Web Link Category');
$I->click(['link' => 'Uncategorised']); $I->click(['link' => 'Uncategorised']);
// Check that hits is 0 // Check that hits is 0
$I->waitForText('Uncategorised','30', ['css' => 'h2']); $I->waitForText('Uncategorised','30', ['css' => 'h2']);
$I->expectTo('see the weblink we created'); $I->expectTo('see the web link we created');
$I->seeElement(['link' => $title]); $I->seeElement(['link' => $title]);
$I->expectTo('see that hits is 0'); $I->expectTo('see that hits is 0');
$I->see('Hits: 0', ['class' => 'list-hits']); $I->see('Hits: 0', ['class' => 'list-hits']);
@ -127,10 +127,10 @@ class FrontendWeblinksCest
// Click on the link, go back, and check that hits is 1 // Click on the link, go back, and check that hits is 1
$I->click(['link' => $title]); $I->click(['link' => $title]);
$I->amOnPage('index.php?option=com_weblinks'); $I->amOnPage('index.php?option=com_weblinks');
$I->comment('I open the uncategorised Weblink Category'); $I->comment('I open the uncategorised Web Link Category');
$I->waitForElement(['link' => 'Uncategorised'], 60); $I->waitForElement(['link' => 'Uncategorised'], 60);
$I->click(['link' => 'Uncategorised']); $I->click(['link' => 'Uncategorised']);
$I->comment('I search the weblink: ' . $title); $I->comment('I search the web link: ' . $title);
$I->waitForElement(['id' => 'filter-search'], 60); $I->waitForElement(['id' => 'filter-search'], 60);
$I->fillField(['id' => 'filter-search'], $title); $I->fillField(['id' => 'filter-search'], $title);
$I->pressKey(['id' => 'filter-search'], \Facebook\WebDriver\WebDriverKeys::ENTER); $I->pressKey(['id' => 'filter-search'], \Facebook\WebDriver\WebDriverKeys::ENTER);

View File

@ -16,11 +16,11 @@
# Wire up Apache to use Travis CI's php-fpm. # Wire up Apache to use Travis CI's php-fpm.
<IfModule mod_fastcgi.c> <IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php AddHandler php%PHPVERSION%-fcgi .php
Action php5-fcgi /php5-fcgi Action php%PHPVERSION%-fcgi /php%PHPVERSION%-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi Alias /php%PHPVERSION%-fcgi /usr/lib/cgi-bin/php%PHPVERSION%-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /tmp/php5-fpm.sock -pass-header Authorization FastCgiExternalServer /usr/lib/cgi-bin/php%PHPVERSION%-fcgi -socket /tmp/php%PHPVERSION%-fpm.sock -pass-header Authorization
</IfModule> </IfModule>
ErrorLog ${APACHE_LOG_DIR}/error.log ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost> </VirtualHost>

19
tests/travis-php-fpm.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
owner="$1"
phpversionname="$2"
file="/home/$owner/.phpenv/versions/$phpversionname/etc/php-fpm.conf"
cp /home/$owner/.phpenv/versions/$phpversionname/etc/php-fpm.conf.default /home/$owner/.phpenv/versions/$phpversionname/etc/php-fpm.conf
if [ -f /home/$owner/.phpenv/versions/$phpversionname/etc/php-fpm.d/www.conf.default ]; then
cp /home/$owner/.phpenv/versions/$phpversionname/etc/php-fpm.d/www.conf.default /home/$owner/.phpenv/versions/$phpversionname/etc/php-fpm.d/www.conf
file=/home/$owner/.phpenv/versions/$phpversionname/etc/php-fpm.d/www.conf
fi;
sed -e "s,listen = 127.0.0.1:9000,listen = /tmp/php${phpversionname:0:1}-fpm.sock,g" --in-place $file
sed -e "s,;listen.owner = nobody,listen.owner = $owner,g" --in-place $file
sed -e "s,;listen.group = nobody,listen.group = $owner,g" --in-place $file
sed -e "s,;listen.mode = 0660,listen.mode = 0666,g" --in-place $file
sed -e "s,user = nobody,;user = $owner,g" --in-place $file
sed -e "s,group = nobody,;group = $owner,g" --in-place $file