diff --git a/README.md b/README.md index 85a5fef93..2caa2635a 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ Component Builder is mapped as a component in itself on my local development env + *Version*: 2.3.7 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *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** + *Folder count*: **105** diff --git a/admin/README.txt b/admin/README.txt index 85a5fef93..2caa2635a 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -108,7 +108,7 @@ Component Builder is mapped as a component in itself on my local development env + *Version*: 2.3.7 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *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** + *Folder count*: **105** diff --git a/admin/assets/css/joomla_component.css b/admin/assets/css/joomla_component.css index ff824f488..fde344d56 100644 --- a/admin/assets/css/joomla_component.css +++ b/admin/assets/css/joomla_component.css @@ -9,7 +9,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/assets/css/joomla_components.css b/admin/assets/css/joomla_components.css index 30f9e684b..c656b3078 100644 --- a/admin/assets/css/joomla_components.css +++ b/admin/assets/css/joomla_components.css @@ -9,7 +9,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/controllers/joomla_component.php b/admin/controllers/joomla_component.php index 64325a639..98b8f5397 100644 --- a/admin/controllers/joomla_component.php +++ b/admin/controllers/joomla_component.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/controllers/joomla_components.php b/admin/controllers/joomla_components.php index 2b213d156..0caa84406 100644 --- a/admin/controllers/joomla_components.php +++ b/admin/controllers/joomla_components.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/models/forms/joomla_component.js b/admin/models/forms/joomla_component.js index 83ee45d3a..db9355e96 100644 --- a/admin/models/forms/joomla_component.js +++ b/admin/models/forms/joomla_component.js @@ -9,7 +9,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/models/joomla_component.php b/admin/models/joomla_component.php index aba943a8a..f0cbe3adb 100644 --- a/admin/models/joomla_component.php +++ b/admin/models/joomla_component.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/models/joomla_components.php b/admin/models/joomla_components.php index f881dd54c..ee55a84b4 100644 --- a/admin/models/joomla_components.php +++ b/admin/models/joomla_components.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder @@ -56,9 +56,12 @@ class ComponentbuilderModelJoomla_components extends JModelList parent::__construct($config); } - public $smartExport = array(); - protected $templateIds = array(); - protected $layoutIds = array(); + public $smartExport = array(); + + protected $templateIds = array(); + protected $layoutIds = array(); + protected $customCodeIds = array(); + protected $customCodeM = array(); /** * Method to get list export data. @@ -79,7 +82,7 @@ class ComponentbuilderModelJoomla_components extends JModelList // Select some fields $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->where('a.id IN (' . implode(',',$pks) . ')'); @@ -102,6 +105,8 @@ class ComponentbuilderModelJoomla_components extends JModelList // check if we have items if (ComponentbuilderHelper::checkArray($items)) { + // add custom code + $this->setData($user, $db, 'custom_code', $pks, 'component'); // start loading the components $this->smartExport['components'] = array(); 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'); // add site views $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 $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'); } + // 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 if (ComponentbuilderHelper::checkArray($this->smartExport['components'])) { @@ -157,7 +169,11 @@ class ComponentbuilderModelJoomla_components extends JModelList $values = json_decode($values, true); } // 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; } @@ -168,7 +184,14 @@ class ComponentbuilderModelJoomla_components extends JModelList // From the componentbuilder_ANY table $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 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' => $item->custom_get), 'dynamic_get'); } + // set the custom code ID's + $this->setCustomCodeIds($item, $table); // load to global object $this->smartExport[$table][$item->id] = $item; } @@ -290,7 +315,7 @@ class ComponentbuilderModelJoomla_components extends JModelList } // set the layout data $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)) { $layouts = array_merge($lay1,$lay2); @@ -369,6 +394,133 @@ class ComponentbuilderModelJoomla_components extends JModelList } 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. diff --git a/admin/tables/joomla_component.php b/admin/tables/joomla_component.php index 0597e05de..0465bc0f0 100644 --- a/admin/tables/joomla_component.php +++ b/admin/tables/joomla_component.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/views/joomla_component/submitbutton.js b/admin/views/joomla_component/submitbutton.js index 6d423a162..c7587f7ea 100644 --- a/admin/views/joomla_component/submitbutton.js +++ b/admin/views/joomla_component/submitbutton.js @@ -9,7 +9,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/views/joomla_component/tmpl/edit.php b/admin/views/joomla_component/tmpl/edit.php index 041724ed1..7c1829e38 100644 --- a/admin/views/joomla_component/tmpl/edit.php +++ b/admin/views/joomla_component/tmpl/edit.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/views/joomla_component/view.html.php b/admin/views/joomla_component/view.html.php index e1307fa43..a55e97a4c 100644 --- a/admin/views/joomla_component/view.html.php +++ b/admin/views/joomla_component/view.html.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/views/joomla_components/tmpl/default.php b/admin/views/joomla_components/tmpl/default.php index c795d647b..fdc42797f 100644 --- a/admin/views/joomla_components/tmpl/default.php +++ b/admin/views/joomla_components/tmpl/default.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/views/joomla_components/tmpl/default_batch_body.php b/admin/views/joomla_components/tmpl/default_batch_body.php index 112b91f54..5c30147e2 100644 --- a/admin/views/joomla_components/tmpl/default_batch_body.php +++ b/admin/views/joomla_components/tmpl/default_batch_body.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/views/joomla_components/tmpl/default_batch_footer.php b/admin/views/joomla_components/tmpl/default_batch_footer.php index 24b04be1f..9faba4a82 100644 --- a/admin/views/joomla_components/tmpl/default_batch_footer.php +++ b/admin/views/joomla_components/tmpl/default_batch_footer.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/views/joomla_components/tmpl/default_body.php b/admin/views/joomla_components/tmpl/default_body.php index 198ac25ac..14cbe9129 100644 --- a/admin/views/joomla_components/tmpl/default_body.php +++ b/admin/views/joomla_components/tmpl/default_body.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/views/joomla_components/tmpl/default_foot.php b/admin/views/joomla_components/tmpl/default_foot.php index d24f6857a..20d6f5514 100644 --- a/admin/views/joomla_components/tmpl/default_foot.php +++ b/admin/views/joomla_components/tmpl/default_foot.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/views/joomla_components/tmpl/default_head.php b/admin/views/joomla_components/tmpl/default_head.php index c59badd20..a77ae1d76 100644 --- a/admin/views/joomla_components/tmpl/default_head.php +++ b/admin/views/joomla_components/tmpl/default_head.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/views/joomla_components/tmpl/default_toolbar.php b/admin/views/joomla_components/tmpl/default_toolbar.php index 9acd49e49..b8df711df 100644 --- a/admin/views/joomla_components/tmpl/default_toolbar.php +++ b/admin/views/joomla_components/tmpl/default_toolbar.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder diff --git a/admin/views/joomla_components/view.html.php b/admin/views/joomla_components/view.html.php index 79903d48b..1c523783b 100644 --- a/admin/views/joomla_components/view.html.php +++ b/admin/views/joomla_components/view.html.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 112 of this MVC + @version @update number 122 of this MVC @build 18th March, 2017 @created 6th May, 2015 @package Component Builder