Continued formatting of JCB code

This commit is contained in:
2017-12-15 03:10:10 +02:00
parent 8ac350e62b
commit e44b6bc272
91 changed files with 1516 additions and 1518 deletions

View File

@ -1842,10 +1842,10 @@ abstract class ComponentbuilderHelper
/**
* Load the Component xml manifest.
**/
public static function manifest()
public static function manifest()
{
$manifestUrl = JPATH_ADMINISTRATOR."/components/com_componentbuilder/componentbuilder.xml";
return simplexml_load_file($manifestUrl);
$manifestUrl = JPATH_ADMINISTRATOR."/components/com_componentbuilder/componentbuilder.xml";
return simplexml_load_file($manifestUrl);
}
/**
@ -1860,22 +1860,22 @@ abstract class ComponentbuilderHelper
// get all Contributors (max 20)
$searchArray = range('0','20');
foreach($searchArray as $nr)
{
{
if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3))
{
{
// set link based of selected option
if($params->get("useContributor".$nr) == 1)
{
{
$link_front = '<a href="mailto:'.$params->get("emailContributor".$nr).'" target="_blank">';
$link_back = '</a>';
}
elseif($params->get("useContributor".$nr) == 2)
{
elseif($params->get("useContributor".$nr) == 2)
{
$link_front = '<a href="'.$params->get("linkContributor".$nr).'" target="_blank">';
$link_back = '</a>';
}
else
{
else
{
$link_front = '';
$link_back = '';
}
@ -1963,10 +1963,10 @@ abstract class ComponentbuilderHelper
**/
public static function addSubmenu($submenu)
{
// load user for access menus
$user = JFactory::getUser();
// load the submenus to sidebar
JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_DASHBOARD'), 'index.php?option=com_componentbuilder&view=componentbuilder', $submenu === 'componentbuilder');
// load user for access menus
$user = JFactory::getUser();
// load the submenus to sidebar
JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_DASHBOARD'), 'index.php?option=com_componentbuilder&view=componentbuilder', $submenu === 'componentbuilder');
// Access control (compiler.submenu).
if ($user->authorise('compiler.submenu', 'com_componentbuilder'))
{
@ -2410,9 +2410,9 @@ abstract class ComponentbuilderHelper
public static function jsonToString($value, $sperator = ", ", $table = null)
{
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (self::checkArray($result))
@ -2434,15 +2434,15 @@ abstract class ComponentbuilderHelper
}
return (string) implode($sperator,$result);
}
return (string) json_decode($value);
}
return $value;
}
return (string) json_decode($value);
}
return $value;
}
public static function isPublished($id,$type)
{
if ($type == 'raw')
{
{
$type = 'item';
}
$db = JFactory::getDbo();
@ -2455,7 +2455,7 @@ abstract class ComponentbuilderHelper
$db->execute();
$found = $db->getNumRows();
if($found)
{
{
return true;
}
return false;
@ -2472,33 +2472,33 @@ abstract class ComponentbuilderHelper
$db->execute();
$found = $db->getNumRows();
if($found)
{
{
return $db->loadResult();
}
return $id;
}
/**
/**
* Get the actions permissions
**/
public static function getActions($view,&$record = null,$views = null)
public static function getActions($view,&$record = null,$views = null)
{
jimport('joomla.access.access');
$user = JFactory::getUser();
$result = new JObject;
$view = self::safeString($view);
if (self::checkString($views))
{
if (self::checkString($views))
{
$views = self::safeString($views);
}
}
// get all actions from component
$actions = JAccess::getActions('com_componentbuilder', 'component');
// set acctions only set in component settiongs
$componentActions = array('core.admin','core.manage','core.options','core.export');
// set acctions only set in component settiongs
$componentActions = array('core.admin','core.manage','core.options','core.export');
// loop the actions and set the permissions
foreach ($actions as $action)
{
{
// set to use component default
$fallback= true;
if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name,$componentActions))
@ -2577,17 +2577,17 @@ abstract class ComponentbuilderHelper
}
elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0)
{
// make sure we use the core. action check for the categories
if (strpos($action->name,$view) !== false && strpos($action->name,'core.') === false ) {
$coreCheck = explode('.',$action->name);
$coreCheck[0] = 'core';
$categoryCheck = implode('.',$coreCheck);
}
else
{
$categoryCheck = $action->name;
}
// The record has a category. Check the category permissions.
// make sure we use the core. action check for the categories
if (strpos($action->name,$view) !== false && strpos($action->name,'core.') === false ) {
$coreCheck = explode('.',$action->name);
$coreCheck[0] = 'core';
$categoryCheck = implode('.',$coreCheck);
}
else
{
$categoryCheck = $action->name;
}
// The record has a category. Check the category permissions.
$catpermission = $user->authorise($categoryCheck, 'com_componentbuilder.'.$views.'.category.' . (int) $record->catid);
if (!$catpermission && !is_null($catpermission))
{
@ -2968,8 +2968,8 @@ abstract class ComponentbuilderHelper
$string = self::replaceNumbers($string);
}
// 0nly continue if we have a string
if (self::checkString($string))
{
if (self::checkString($string))
{
// create file name without the extention that is safe
if ($type === 'filename')
{
@ -2992,12 +2992,12 @@ abstract class ComponentbuilderHelper
$string = preg_replace("/[^A-Za-z ]/", '', $string);
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no undersocre)
@ -3018,21 +3018,21 @@ abstract class ComponentbuilderHelper
// return a string with all the uppercase(no undersocre)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
@ -3041,14 +3041,14 @@ abstract class ComponentbuilderHelper
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
// return string
return $string;
}
// not a string
return '';
}
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
{
if (self::checkString($var))
{
@ -3059,11 +3059,11 @@ abstract class ComponentbuilderHelper
return self::shorten($string,$length);
}
return $string;
}
}
else
{
return '';
}
}
}
public static function replaceNumbers($string)