Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Codestyle in Plugins; Closes #3646

  • Loading branch information...
commit 6f9e9172aea5d7f66e614c2a0cb6e83df1339008 1 parent 1410dea
@SniperSister SniperSister authored Bakual committed
View
3  plugins/editors/codemirror/codemirror.php
@@ -117,7 +117,8 @@ public function onGetInsertMethod()
*
* @return string HTML Output
*/
- public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array())
+ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true,
+ $id = null, $asset = null, $author = null, $params = array())
{
if (empty($id))
{
View
6 plugins/editors/none/none.php
@@ -133,7 +133,8 @@ public function onGetInsertMethod($id)
*
* @return string
*/
- public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array())
+ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true,
+ $id = null, $asset = null, $author = null, $params = array())
{
if (empty($id))
{
@@ -152,7 +153,8 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons
}
$buttons = $this->_displayButtons($id, $buttons, $asset, $author);
- $editor = "<textarea name=\"$name\" id=\"$id\" cols=\"$col\" rows=\"$row\" style=\"width: $width; height: $height;\">$content</textarea>" . $buttons;
+ $editor = "<textarea name=\"$name\" id=\"$id\" cols=\"$col\" rows=\"$row\" style=\"width: $width; height: $height;\">$content</textarea>"
+ . $buttons;
return $editor;
}
View
3  plugins/editors/tinymce/tinymce.php
@@ -450,7 +450,8 @@ public function onInit()
preg_match_all('/\".*\"/', $match, $values);
$result = trim($values["0"]["0"], '"');
$final_result = explode(',', $result);
- $templates .= "{title: '" . trim($final_result['0'], ' " ') . "', description: '" . trim($final_result['2'], ' " ') . "', url: '" . JUri::root() . trim($final_result['1'], ' " ') . "'},";
+ $templates .= "{title: '" . trim($final_result['0'], ' " ') . "', description: '"
+ . trim($final_result['2'], ' " ') . "', url: '" . JUri::root() . trim($final_result['1'], ' " ') . "'},";
}
$templates .= "],";
View
4 plugins/search/categories/categories.php
@@ -159,8 +159,8 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu
$query->select('a.title, a.description AS text, \'\' AS created, \'2\' AS browsernav, a.id AS catid, ' . $case_when)
->from('#__categories AS a')
->where(
- '(a.title LIKE ' . $text . ' OR a.description LIKE ' . $text . ') AND a.published IN (' . implode(',', $state) . ') AND a.extension = ' . $db->quote('com_content')
- . 'AND a.access IN (' . $groups . ')'
+ '(a.title LIKE ' . $text . ' OR a.description LIKE ' . $text . ') AND a.published IN (' . implode(',', $state) . ') AND a.extension = '
+ . $db->quote('com_content') . 'AND a.access IN (' . $groups . ')'
)
->group('a.id, a.title, a.description, a.alias')
->order($order);
View
6 plugins/system/cache/cache.php
@@ -30,7 +30,7 @@ class PlgSystemCache extends JPlugin
*
* @since 1.5
*/
- function __construct(& $subject, $config)
+ public function __construct(& $subject, $config)
{
parent::__construct($subject, $config);
@@ -52,7 +52,7 @@ function __construct(& $subject, $config)
*
* @since 1.5
*/
- function onAfterInitialise()
+ public function onAfterInitialise()
{
global $_PROFILER;
@@ -99,7 +99,7 @@ function onAfterInitialise()
*
* @since 1.5
*/
- function onAfterRender()
+ public function onAfterRender()
{
$app = JFactory::getApplication();
View
19 plugins/system/debug/debug.php
@@ -888,7 +888,8 @@ protected function displayQueries()
$queryTime = ($timings[$id * 2 + 1] - $timings[$id * 2]) * 1000;
// Timing. Formats the output for the query time with EXPLAIN query results as tooltip.
- $htmlTiming = '<div style="margin: 0px 0 5px;"><span class="dbg-query-time">' . JText::sprintf('PLG_DEBUG_QUERY_TIME', sprintf('<span class="label ' . $info[$id]->class . '">%.2f&nbsp;ms</span>', $timing[$id]['0']));
+ $htmlTiming = '<div style="margin: 0px 0 5px;"><span class="dbg-query-time">'
+ . JText::sprintf('PLG_DEBUG_QUERY_TIME', sprintf('<span class="label ' . $info[$id]->class . '">%.2f&nbsp;ms</span>', $timing[$id]['0']));
if ($timing[$id]['1'])
{
@@ -945,7 +946,8 @@ protected function displayQueries()
}
$htmlResultsReturned = '<span class="label ' . $labelClass . '">' . (int) $resultsReturned . '</span>';
- $htmlTiming .= ' ' . '<span class="dbg-query-rowsnumber">' . JText::sprintf('PLG_DEBUG_ROWS_RETURNED_BY_QUERY', $htmlResultsReturned) . '</span>';
+ $htmlTiming .= ' ' . '<span class="dbg-query-rowsnumber">'
+ . JText::sprintf('PLG_DEBUG_ROWS_RETURNED_BY_QUERY', $htmlResultsReturned) . '</span>';
}
}
@@ -985,7 +987,8 @@ protected function displayQueries()
if (!$this->linkFormat)
{
- $htmlCallStack .= '<div>[<a href="http://xdebug.org/docs/all_settings#file_link_format" target="_blank">' . JText::_('PLG_DEBUG_LINK_FORMAT') . '</a>]</div>';
+ $htmlCallStack .= '<div>[<a href="http://xdebug.org/docs/all_settings#file_link_format" target="_blank">'
+ . JText::_('PLG_DEBUG_LINK_FORMAT') . '</a>]</div>';
}
}
@@ -1181,7 +1184,8 @@ protected function renderBars(&$bars, $class = '', $id = null)
$tip = JHtml::tooltipText($bar->tip, '', 0);
}
- $html[] = '<a class="bar dbg-bar ' . $barClass . '" title="' . $tip . '" style="width: ' . $bar->width . '%;" href="#dbg-' . $class . '-' . ($i + 1) . '"></a>';
+ $html[] = '<a class="bar dbg-bar ' . $barClass . '" title="' . $tip . '" style="width: '
+ . $bar->width . '%;" href="#dbg-' . $class . '-' . ($i + 1) . '"></a>';
}
return '<div class="progress dbg-bars dbg-bars-' . $class . '">' . implode('', $html) . '</div>';
@@ -1267,7 +1271,8 @@ protected function tableToHtml($table, &$hasWarnings)
if ($td === 'NULL')
{
// Displays query parts which don't use a key with warning.
- $html[] = '<td><strong>' . '<span class="dbg-warning hasTooltip" title="' . JHtml::tooltipText('PLG_DEBUG_WARNING_NO_INDEX_DESC') . '">' . JText::_('PLG_DEBUG_WARNING_NO_INDEX') . '</span>' . '</strong>';
+ $html[] = '<td><strong>' . '<span class="dbg-warning hasTooltip" title="' . JHtml::tooltipText('PLG_DEBUG_WARNING_NO_INDEX_DESC') . '">'
+ . JText::_('PLG_DEBUG_WARNING_NO_INDEX') . '</span>' . '</strong>';
$hasWarnings = true;
}
else
@@ -1283,7 +1288,9 @@ protected function tableToHtml($table, &$hasWarnings)
$htmlTd = preg_replace('/([^;]) /', '\1&nbsp;', $htmlTd);
// Displays warnings for "Using filesort".
- $htmlTdWithWarnings = str_replace('Using&nbsp;filesort', '<span class="dbg-warning hasTooltip" title="' . JHtml::tooltipText('PLG_DEBUG_WARNING_USING_FILESORT_DESC') . '">' . JText::_('PLG_DEBUG_WARNING_USING_FILESORT') . '</span>', $htmlTd);
+ $htmlTdWithWarnings = str_replace('Using&nbsp;filesort', '<span class="dbg-warning hasTooltip" title="'
+ . JHtml::tooltipText('PLG_DEBUG_WARNING_USING_FILESORT_DESC') . '">' . JText::_('PLG_DEBUG_WARNING_USING_FILESORT') . '</span>', $htmlTd
+ );
if ($htmlTdWithWarnings !== $htmlTd)
{
View
14 plugins/system/languagefilter/languagefilter.php
@@ -38,7 +38,7 @@ class PlgSystemLanguageFilter extends JPlugin
protected static $cookie;
- private static $_user_lang_code;
+ private static $user_lang_code;
/**
* Constructor.
@@ -409,11 +409,11 @@ public function onUserBeforeSave($user, $isnew, $new)
{
$registry = new JRegistry;
$registry->loadString($user['params']);
- self::$_user_lang_code = $registry->get('language');
+ self::$user_lang_code = $registry->get('language');
- if (empty(self::$_user_lang_code))
+ if (empty(self::$user_lang_code))
{
- self::$_user_lang_code = self::$default_lang;
+ self::$user_lang_code = self::$default_lang;
}
}
}
@@ -447,7 +447,7 @@ public function onUserAfterSave($user, $isnew, $success, $msg)
$app = JFactory::getApplication();
- if ($lang_code == self::$_user_lang_code || !isset(self::$lang_codes[$lang_code]))
+ if ($lang_code == self::$user_lang_code || !isset(self::$lang_codes[$lang_code]))
{
if ($app->isSite())
{
@@ -458,7 +458,9 @@ public function onUserAfterSave($user, $isnew, $success, $msg)
{
if ($app->isSite())
{
- $app->setUserState('com_users.edit.profile.redirect', 'index.php?Itemid=' . $app->getMenu()->getDefault($lang_code)->id . '&lang=' . self::$lang_codes[$lang_code]->sef);
+ $app->setUserState('com_users.edit.profile.redirect', 'index.php?Itemid='
+ . $app->getMenu()->getDefault($lang_code)->id . '&lang=' . self::$lang_codes[$lang_code]->sef
+ );
self::$tag = $lang_code;
// Create a cookie.
View
3  plugins/user/profile/fields/tos.php
@@ -79,7 +79,8 @@ protected function getLabel()
}
$tosarticle = $this->element['article'] ? (int) $this->element['article'] : 1;
- $link = '<a class="modal" title="" href="index.php?option=com_content&amp;view=article&amp;layout=modal&amp;id=' . $tosarticle . '&amp;tmpl=component" rel="{handler: \'iframe\', size: {x:800, y:500}}">' . $text . '</a>';
+ $link = '<a class="modal" title="" href="index.php?option=com_content&amp;view=article&amp;layout=modal&amp;id='
+ . $tosarticle . '&amp;tmpl=component" rel="{handler: \'iframe\', size: {x:800, y:500}}">' . $text . '</a>';
// Add the label text and closing tag.
$label .= '>' . $link . '<span class="star">&#160;*</span></label>';
View
70 plugins/user/profile/profile.php
@@ -24,7 +24,7 @@ class PlgUserProfile extends JPlugin
* @var string
* @since 3.1
*/
- private $_date = '';
+ private $date = '';
/**
* Load the language file on instantiation.
@@ -37,8 +37,8 @@ class PlgUserProfile extends JPlugin
/**
* Constructor
*
- * @param object $subject The object to observe
- * @param array $config An array that holds the plugin configuration
+ * @param object &$subject The object to observe
+ * @param array $config An array that holds the plugin configuration
*
* @since 1.5
*/
@@ -49,8 +49,10 @@ public function __construct(& $subject, $config)
}
/**
- * @param string $context The context for the data
- * @param integer $data The user id
+ * Runs on content preparation
+ *
+ * @param string $context The context for the data
+ * @param integer $data The user id
*
* @return boolean
*
@@ -85,6 +87,7 @@ public function onContentPrepareData($context, $data)
catch (RuntimeException $e)
{
$this->_subject->setError($e->getMessage());
+
return false;
}
@@ -95,6 +98,7 @@ public function onContentPrepareData($context, $data)
{
$k = str_replace('profile.', '', $v[0]);
$data->profile[$k] = json_decode($v[1], true);
+
if ($data->profile[$k] === null)
{
$data->profile[$k] = $v[1];
@@ -106,10 +110,12 @@ public function onContentPrepareData($context, $data)
{
JHtml::register('users.url', array(__CLASS__, 'url'));
}
+
if (!JHtml::isRegistered('users.calendar'))
{
JHtml::register('users.calendar', array(__CLASS__, 'calendar'));
}
+
if (!JHtml::isRegistered('users.tos'))
{
JHtml::register('users.tos', array(__CLASS__, 'tos'));
@@ -119,6 +125,13 @@ public function onContentPrepareData($context, $data)
return true;
}
+ /**
+ * returns a anchor tag generated from a given value
+ *
+ * @param string $value url to use
+ *
+ * @return mixed|string
+ */
public static function url($value)
{
if (empty($value))
@@ -141,6 +154,13 @@ public static function url($value)
}
}
+ /**
+ * returns html markup showing a date picker
+ *
+ * @param string $value valid date string
+ *
+ * @return mixed
+ */
public static function calendar($value)
{
if (empty($value))
@@ -153,6 +173,13 @@ public static function calendar($value)
}
}
+ /**
+ * return the translated strings yes or no depending on the value
+ *
+ * @param boolean $value input value
+ *
+ * @return string
+ */
public static function tos($value)
{
if ($value)
@@ -166,10 +193,13 @@ public static function tos($value)
}
/**
- * @param JForm $form The form to be altered.
- * @param array $data The associated data for the form.
+ * adds additional fields to the user editing form
+ *
+ * @param JForm $form The form to be altered.
+ * @param array $data The associated data for the form.
*
* @return boolean
+ *
* @since 1.6
*/
public function onContentPrepareForm($form, $data)
@@ -177,11 +207,13 @@ public function onContentPrepareForm($form, $data)
if (!($form instanceof JForm))
{
$this->_subject->setError('JERROR_NOT_A_FORM');
+
return false;
}
// Check we are manipulating a valid form.
$name = $form->getName();
+
if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration')))
{
return true;
@@ -206,8 +238,9 @@ public function onContentPrepareForm($form, $data)
'tos',
);
- //Change fields description when displayed in front-end or back-end profile editing
+ // Change fields description when displayed in front-end or back-end profile editing
$app = JFactory::getApplication();
+
if ($app->isSite() || $name == 'com_users.user' || $name == 'com_admin.profile')
{
$form->setFieldAttribute('address1', 'description', 'PLG_USER_PROFILE_FILL_FIELD_DESC_SITE', 'profile');
@@ -246,8 +279,7 @@ public function onContentPrepareForm($form, $data)
{
// Remove the field if it is disabled in registration and profile
if ($this->params->get('register-require_' . $field, 1) == 0
- && $this->params->get('profile-require_' . $field, 1) == 0
- )
+ && $this->params->get('profile-require_' . $field, 1) == 0)
{
$form->removeField($field, 'profile');
}
@@ -321,7 +353,7 @@ public function onUserBeforeSave($user, $isnew, $data)
$data['profile']['website'] = JStringPunycode::urlToPunycode($data['profile']['website']);
$date = new JDate($data['profile']['dob']);
- $this->_date = $date->format('Y-m-d');
+ $this->date = $date->format('Y-m-d');
}
catch (Exception $e)
{
@@ -333,6 +365,16 @@ public function onUserBeforeSave($user, $isnew, $data)
return true;
}
+ /**
+ * saves user profile data
+ *
+ * @param array $data entered user data
+ * @param boolean $isNew true if this is a new user
+ * @param boolean $result true if saving the user worked
+ * @param string $error error message
+ *
+ * @return bool
+ */
public function onUserAfterSave($data, $isNew, $result, $error)
{
$userId = JArrayHelper::getValue($data, 'id', 0, 'int');
@@ -342,7 +384,7 @@ public function onUserAfterSave($data, $isNew, $result, $error)
try
{
// Sanitize the date
- $data['profile']['dob'] = $this->_date;
+ $data['profile']['dob'] = $this->date;
$db = JFactory::getDbo();
$query = $db->getQuery(true)
@@ -357,7 +399,7 @@ public function onUserAfterSave($data, $isNew, $result, $error)
foreach ($data['profile'] as $k => $v)
{
- $tuples[] = '(' . $userId . ', ' . $db->quote('profile.' . $k) . ', ' . $db->quote(json_encode($v)) . ', ' . $order++ . ')';
+ $tuples[] = '(' . $userId . ', ' . $db->quote('profile.' . $k) . ', ' . $db->quote(json_encode($v)) . ', ' . ($order++) . ')';
}
$db->setQuery('INSERT INTO #__user_profiles VALUES ' . implode(', ', $tuples));
@@ -366,6 +408,7 @@ public function onUserAfterSave($data, $isNew, $result, $error)
catch (RuntimeException $e)
{
$this->_subject->setError($e->getMessage());
+
return false;
}
}
@@ -408,6 +451,7 @@ public function onUserAfterDelete($user, $success, $msg)
catch (Exception $e)
{
$this->_subject->setError($e->getMessage());
+
return false;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.