32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-12-27 18:24:56 +00:00

Fix CS for com_weblinks frontend helpers and global controler file (#230)

* Update route.php

* Update icon.php

* Update controller.php

* Update route.php
This commit is contained in:
zero-24 2016-07-02 13:02:00 +02:00 committed by Chris Davenport
parent 1fd0653eb6
commit 276c32922e
3 changed files with 36 additions and 21 deletions

View File

@ -29,8 +29,8 @@ class WeblinksController extends JControllerLegacy
*/ */
public function display($cacheable = false, $urlparams = false) public function display($cacheable = false, $urlparams = false)
{ {
$cacheable = 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. // 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. // Note we are using w_id to avoid collisions with the router and the return page.

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)
{ {
@ -67,6 +69,8 @@ abstract class WeblinksHelperRoute
} }
/** /**
* 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,6 +153,8 @@ abstract class WeblinksHelperRoute
} }
/** /**
* Do a language lookup
*
* @return void * @return void
*/ */
protected static function buildLanguageLookup() protected static function buildLanguageLookup()
@ -169,6 +177,13 @@ abstract class WeblinksHelperRoute
} }
} }
/**
* Find items per given $needles
*
* @params array $needles
*
* @return void
*/
protected static function _findItem($needles = null) protected static function _findItem($needles = null)
{ {
$app = JFactory::getApplication(); $app = JFactory::getApplication();
@ -208,7 +223,7 @@ abstract class WeblinksHelperRoute
if (isset($item->query['id'])) if (isset($item->query['id']))
{ {
// here it will become a bit tricky // Here it will become a bit tricky
// language != * can override existing entries // language != * can override existing entries
// language == * cannot 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 != '*')