added the custom code search and more to gh-53

This commit is contained in:
dev 2017-03-19 00:55:34 +02:00
parent 952d26f1f8
commit cfd9b33b30
No known key found for this signature in database
GPG Key ID: 62214715B438FFEE
21 changed files with 180 additions and 28 deletions

View File

@ -108,7 +108,7 @@ Component Builder is mapped as a component in itself on my local development env
+ *Version*: 2.3.7 + *Version*: 2.3.7
+ *Copyright*: Copyright (C) 2015. All Rights Reserved + *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ *Line count*: **93240** + *Line count*: **93392**
+ *File count*: **602** + *File count*: **602**
+ *Folder count*: **105** + *Folder count*: **105**

View File

@ -108,7 +108,7 @@ Component Builder is mapped as a component in itself on my local development env
+ *Version*: 2.3.7 + *Version*: 2.3.7
+ *Copyright*: Copyright (C) 2015. All Rights Reserved + *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ *Line count*: **93240** + *Line count*: **93392**
+ *File count*: **602** + *File count*: **602**
+ *Folder count*: **105** + *Folder count*: **105**

View File

@ -9,7 +9,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -9,7 +9,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -9,7 +9,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder
@ -56,9 +56,12 @@ class ComponentbuilderModelJoomla_components extends JModelList
parent::__construct($config); parent::__construct($config);
} }
public $smartExport = array(); public $smartExport = array();
protected $templateIds = array();
protected $layoutIds = array(); protected $templateIds = array();
protected $layoutIds = array();
protected $customCodeIds = array();
protected $customCodeM = array();
/** /**
* Method to get list export data. * Method to get list export data.
@ -79,7 +82,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
// Select some fields // Select some fields
$query->select($db->quoteName('a.*')); $query->select($db->quoteName('a.*'));
// From the componentbuilder_joomla_componet table // From the componentbuilder_joomla_component table
$query->from($db->quoteName('#__componentbuilder_joomla_component', 'a')); $query->from($db->quoteName('#__componentbuilder_joomla_component', 'a'));
$query->where('a.id IN (' . implode(',',$pks) . ')'); $query->where('a.id IN (' . implode(',',$pks) . ')');
@ -102,6 +105,8 @@ class ComponentbuilderModelJoomla_components extends JModelList
// check if we have items // check if we have items
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// add custom code
$this->setData($user, $db, 'custom_code', $pks, 'component');
// start loading the components // start loading the components
$this->smartExport['components'] = array(); $this->smartExport['components'] = array();
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)
@ -120,6 +125,8 @@ class ComponentbuilderModelJoomla_components extends JModelList
$this->setData($user, $db, 'custom_admin_view', $item->addcustom_admin_views, 'customadminview'); $this->setData($user, $db, 'custom_admin_view', $item->addcustom_admin_views, 'customadminview');
// add site views // add site views
$this->setData($user, $db, 'site_view', $item->addsite_views, 'siteview'); $this->setData($user, $db, 'site_view', $item->addsite_views, 'siteview');
// set the custom code ID's
$this->setCustomCodeIds($item, 'joomla_component');
// load to global object // load to global object
$this->smartExport['components'][$item->id] = $item; $this->smartExport['components'][$item->id] = $item;
} }
@ -133,6 +140,11 @@ class ComponentbuilderModelJoomla_components extends JModelList
{ {
$this->setData($user, $db, 'layout', array('layout' => $this->layoutIds), 'layout'); $this->setData($user, $db, 'layout', array('layout' => $this->layoutIds), 'layout');
} }
// add custom code
if (ComponentbuilderHelper::checkArray($this->customCodeIds))
{
$this->setData($user, $db, 'custom_code', array('custom_code' => $this->customCodeIds), 'custom_code');
}
// has any data been set // has any data been set
if (ComponentbuilderHelper::checkArray($this->smartExport['components'])) if (ComponentbuilderHelper::checkArray($this->smartExport['components']))
{ {
@ -157,7 +169,11 @@ class ComponentbuilderModelJoomla_components extends JModelList
$values = json_decode($values, true); $values = json_decode($values, true);
} }
// make sure we have an array // make sure we have an array
if (!ComponentbuilderHelper::checkArray($values) || !isset($values[$key]) || !ComponentbuilderHelper::checkArray($values[$key])) if (('custom_code' !== $table && 'component' !== $key) && (!ComponentbuilderHelper::checkArray($values) || !isset($values[$key]) || !ComponentbuilderHelper::checkArray($values[$key])))
{
return false;
}
elseif (!ComponentbuilderHelper::checkArray($values))
{ {
return false; return false;
} }
@ -168,7 +184,14 @@ class ComponentbuilderModelJoomla_components extends JModelList
// From the componentbuilder_ANY table // From the componentbuilder_ANY table
$query->from($db->quoteName('#__componentbuilder_'. $table, 'a')); $query->from($db->quoteName('#__componentbuilder_'. $table, 'a'));
$query->where('a.id IN (' . implode(',',$values[$key]) . ')'); if ('custom_code' === $table && 'component' === $key)
{
$query->where('a.component IN (' . implode(',',$values) . ')');
}
else
{
$query->where('a.id IN (' . implode(',',$values[$key]) . ')');
}
// Implement View Level Access // Implement View Level Access
if (!$user->authorise('core.options', 'com_componentbuilder')) if (!$user->authorise('core.options', 'com_componentbuilder'))
@ -234,6 +257,8 @@ class ComponentbuilderModelJoomla_components extends JModelList
$this->setData($user, $db, 'dynamic_get', array('dynamic_get' => array($item->main_get)), 'dynamic_get'); $this->setData($user, $db, 'dynamic_get', array('dynamic_get' => array($item->main_get)), 'dynamic_get');
$this->setData($user, $db, 'dynamic_get', array('dynamic_get' => $item->custom_get), 'dynamic_get'); $this->setData($user, $db, 'dynamic_get', array('dynamic_get' => $item->custom_get), 'dynamic_get');
} }
// set the custom code ID's
$this->setCustomCodeIds($item, $table);
// load to global object // load to global object
$this->smartExport[$table][$item->id] = $item; $this->smartExport[$table][$item->id] = $item;
} }
@ -290,7 +315,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
} }
// set the layout data // set the layout data
$lay1 = ComponentbuilderHelper::getAllBetween($default, "JLayoutHelper::render('","',"); $lay1 = ComponentbuilderHelper::getAllBetween($default, "JLayoutHelper::render('","',");
$lay2 = ComponentbuilderHelper::getAllBetween($default, 'JLayoutHelper::render("','",');; $lay2 = ComponentbuilderHelper::getAllBetween($default, 'JLayoutHelper::render("','",');
if (ComponentbuilderHelper::checkArray($lay1) && ComponentbuilderHelper::checkArray($lay2)) if (ComponentbuilderHelper::checkArray($lay1) && ComponentbuilderHelper::checkArray($lay2))
{ {
$layouts = array_merge($lay1,$lay2); $layouts = array_merge($lay1,$lay2);
@ -370,6 +395,133 @@ class ComponentbuilderModelJoomla_components extends JModelList
return false; return false;
} }
/**
* Set the ids of the found custom code
*
* @param object $item The item being searched
* @param string $target The target table
*
* @return void
*
*/
protected function setCustomCodeIds($item, $target)
{
if ($keys = $this->getCodeSearchKeys($target))
{
foreach ($keys['search'] as $key)
{
if (!isset($keys['not_base64'][$key]))
{
$value = base64_decode($item->{$key});
}
else
{
$value = $item->{$key};
}
// search the value to see if it has custom code
$codeArray = ComponentbuilderHelper::getAllBetween($value, '[CUSTOMC' . 'ODE=',']');
if (ComponentbuilderHelper::checkArray($codeArray))
{
foreach ($codeArray as $func)
{
// first make sure we have only the function key
if (strpos($func, '+') !== false)
{
$funcArray = explode('+', $func);
$func = $funcArray[0];
}
if (!isset($this->customCodeM[$func]))
{
$this->customCodeM[$func] = $func;
// if numeric add to ids
if (is_numeric($func))
{
$this->customCodeIds[$func] = (int) $func;
}
elseif (ComponentbuilderHelper::checkString($func))
{
if ($funcID = ComponentbuilderHelper::getVar('custom_code', $func, 'function_name', 'id'))
{
$this->customCodeIds[$funcID] = (int) $funcID;
}
}
}
}
}
}
}
}
/**
* Get the keys of the values to search custom code in
*
* @param string $targe The table targeted
*
* @return array The query options
*
*/
protected function getCodeSearchKeys($target)
{
$targets = array();
// #__componentbuilder_joomla_component as a
$targets['joomla_component'] = array();
$targets['joomla_component']['search'] = array('php_preflight_install','php_postflight_install',
'php_preflight_update','php_postflight_update','php_method_uninstall',
'php_helper_admin','php_admin_event','php_helper_both','php_helper_site',
'php_site_event','php_dashboard_methods','dashboard_tab');
$targets['joomla_component']['not_base64'] = array('dashboard_tab' => 'json');
// #__componentbuilder_admin_view as b
$targets['admin_view'] = array();
$targets['admin_view']['search'] = array('javascript_view_file','javascript_view_footer','javascript_views_file',
'javascript_views_footer','php_getitem','php_save','php_postsavehook','php_getitems',
'php_getitems_after_all','php_getlistquery','php_allowedit','php_before_delete',
'php_after_delete','php_before_publish','php_after_publish','php_batchcopy',
'php_batchmove','php_document','php_model','php_controller','php_import_display',
'php_import','php_import_setdata','php_import_save','html_import_view','php_ajaxmethod');
$targets['admin_view']['not_base64'] = array();
// #__componentbuilder_custom_admin_view as c
$targets['custom_admin_view'] = array();
$targets['custom_admin_view']['search'] = array('default','php_view','php_jview','php_jview_display','php_document',
'js_document','css_document','css','php_model','php_controller');
$targets['custom_admin_view']['not_base64'] = array();
// #__componentbuilder_site_view as d
$targets['site_view'] = array();
$targets['site_view']['search'] = array('default','php_view','php_jview','php_jview_display','php_document',
'js_document','css_document','css','php_ajaxmethod','php_model','php_controller');
$targets['site_view']['not_base64'] = array();
// #__componentbuilder_field as e
$targets['field'] = array();
$targets['field']['search'] = array('xml','javascript_view_footer','javascript_views_footer');
$targets['field']['not_base64'] = array('xml' => 'json');
// #__componentbuilder_dynamic_get as f
$targets['dynamic_get'] = array();
$targets['dynamic_get']['search'] = array('php_before_getitem','php_after_getitem','php_before_getitems','php_after_getitems',
'php_getlistquery');
$targets['dynamic_get']['not_base64'] = array();
// #__componentbuilder_template as g
$targets['template'] = array();
$targets['template']['search'] = array('php_view','template');
$targets['template']['not_base64'] = array();
// #__componentbuilder_layout as h
$targets['layout'] = array();
$targets['layout']['search'] = array('php_view','layout');
$targets['layout']['not_base64'] = array();
// return the query string to search
if (isset($targets[$target]))
{
return $targets[$target];
}
return false;
}
/** /**
* Method to auto-populate the model state. * Method to auto-populate the model state.
* *

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -9,7 +9,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder

View File

@ -10,7 +10,7 @@
|_| |_|
/-------------------------------------------------------------------------------------------------------------------------------/ /-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 112 of this MVC @version @update number 122 of this MVC
@build 18th March, 2017 @build 18th March, 2017
@created 6th May, 2015 @created 6th May, 2015
@package Component Builder @package Component Builder