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

@ -2897,17 +2897,17 @@ class Interpretation extends Fields
{
// for single views
$method .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Initialise variables.";
$method .= PHP_EOL . "\t\t\$this->item\t= \$this->get('Item');";
$method .= PHP_EOL . "\t\t\$this->item = \$this->get('Item');";
}
elseif ($view['settings']->main_get->gettype == 2)
{
// for list views
$method .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Initialise variables.";
$method .= PHP_EOL . "\t\t\$this->items\t= \$this->get('Items');";
$method .= PHP_EOL . "\t\t\$this->items = \$this->get('Items');";
// only add if pagination is requered
if ($view['settings']->main_get->pagination == 1)
{
$method .= PHP_EOL . "\t\t\$this->pagination\t= \$this->get('Pagination');";
$method .= PHP_EOL . "\t\t\$this->pagination = \$this->get('Pagination');";
}
// add id to list view
if (isset($this->customAdminViewListId[$view['settings']->code]))
@ -2927,7 +2927,7 @@ class Interpretation extends Fields
foreach ($view['settings']->custom_get as $custom_get)
{
$custom_get_name = str_replace('get', '', $custom_get->getcustom);
$method .= PHP_EOL . "\t\t\$this->" . ComponentbuilderHelper::safeString($custom_get_name) . "\t= \$this->get('" . $custom_get_name . "');";
$method .= PHP_EOL . "\t\t\$this->" . ComponentbuilderHelper::safeString($custom_get_name) . " = \$this->get('" . $custom_get_name . "');";
}
}
// add custom script
@ -7111,7 +7111,7 @@ class Interpretation extends Fields
}
$this->fileContentDynamic[$viewName_single . '_' . $layoutCodeName]['###LAYOUTITEMSHEADER###'] = $headerscript;
// ###LINKEDVIEWITEMS### <<<DYNAMIC>>>
$this->fileContentDynamic[$viewName_single]['###LINKEDVIEWITEMS###'] .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get Linked view data" . PHP_EOL . "\t\t\$this->" . $codeName . "\t\t= \$this->get('" . $functionName . "');";
$this->fileContentDynamic[$viewName_single]['###LINKEDVIEWITEMS###'] .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get Linked view data" . PHP_EOL . "\t\t\$this->" . $codeName . " = \$this->get('" . $functionName . "');";
// ###LINKEDVIEWTABLESCRIPTS### <<<DYNAMIC>>>
$this->fileContentDynamic[$viewName_single]['###LINKEDVIEWTABLESCRIPTS###'] = $this->setFootableScripts();
if (strpos($parentKey, '-R>') !== false || strpos($parentKey, '-A>') !== false)
@ -10898,47 +10898,47 @@ class Interpretation extends Fields
// check if the item has permissions for edit.
if ($coreLoad && isset($core['core.edit']) && isset($this->permissionBuilder['global'][$core['core.edit']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.edit']]) && in_array($viewName_single, $this->permissionBuilder['global'][$core['core.edit']]))
{
$allow[] = PHP_EOL . "\t\t\$this->canEdit\t\t= \$this->canDo->get('" . $core['core.edit'] . "');";
$allow[] = PHP_EOL . "\t\t\$this->canEdit = \$this->canDo->get('" . $core['core.edit'] . "');";
}
else
{
$allow[] = PHP_EOL . "\t\t\$this->canEdit\t\t= \$this->canDo->get('core.edit');";
$allow[] = PHP_EOL . "\t\t\$this->canEdit = \$this->canDo->get('core.edit');";
}
// check if the item has permissions for edit state.
if ($coreLoad && isset($core['core.edit.state']) && isset($this->permissionBuilder['global'][$core['core.edit.state']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.edit.state']]) && in_array($viewName_single, $this->permissionBuilder['global'][$core['core.edit.state']]))
{
$allow[] = "\t\t\$this->canState\t\t= \$this->canDo->get('" . $core['core.edit.state'] . "');";
$allow[] = "\t\t\$this->canState = \$this->canDo->get('" . $core['core.edit.state'] . "');";
}
else
{
$allow[] = "\t\t\$this->canState\t\t= \$this->canDo->get('core.edit.state');";
$allow[] = "\t\t\$this->canState = \$this->canDo->get('core.edit.state');";
}
// check if the item has permissions for create.
if ($coreLoad && isset($core['core.create']) && isset($this->permissionBuilder['global'][$core['core.create']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.create']]) && in_array($viewName_single, $this->permissionBuilder['global'][$core['core.create']]))
{
$allow[] = "\t\t\$this->canCreate\t= \$this->canDo->get('" . $core['core.create'] . "');";
$allow[] = "\t\t\$this->canCreate = \$this->canDo->get('" . $core['core.create'] . "');";
}
else
{
$allow[] = "\t\t\$this->canCreate\t= \$this->canDo->get('core.create');";
$allow[] = "\t\t\$this->canCreate = \$this->canDo->get('core.create');";
}
// check if the item has permissions for delete.
if ($coreLoad && isset($core['core.delete']) && isset($this->permissionBuilder['global'][$core['core.delete']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.delete']]) && in_array($viewName_single, $this->permissionBuilder['global'][$core['core.delete']]))
{
$allow[] = "\t\t\$this->canDelete\t= \$this->canDo->get('" . $core['core.delete'] . "');";
$allow[] = "\t\t\$this->canDelete = \$this->canDo->get('" . $core['core.delete'] . "');";
}
else
{
$allow[] = "\t\t\$this->canDelete\t= \$this->canDo->get('core.delete');";
$allow[] = "\t\t\$this->canDelete = \$this->canDo->get('core.delete');";
}
// check if the item has permissions for batch.
if ($coreLoad && isset($core['core.batch']) && isset($this->permissionBuilder['global']['global'][$core['core.batch']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global']['global'][$core['core.batch']]) && in_array($viewName_single, $this->permissionBuilder['global']['global'][$core['core.delete']]))
{
$allow[] = "\t\t\$this->canBatch\t= (\$this->canDo->get('" . $core['core.batch'] . "') && \$this->canDo->get('core.batch'));";
$allow[] = "\t\t\$this->canBatch = (\$this->canDo->get('" . $core['core.batch'] . "') && \$this->canDo->get('core.batch'));";
}
else
{
$allow[] = "\t\t\$this->canBatch\t= \$this->canDo->get('core.batch');";
$allow[] = "\t\t\$this->canBatch = \$this->canDo->get('core.batch');";
}
return implode(PHP_EOL, $allow);

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)

View File

@ -187,8 +187,7 @@ abstract class ComponentbuilderEmail
// load the bounce email as sender if set
if (!is_null($bounce_email))
{
{
$mail->Sender = $bounce_email;
}