The scripts that are automatic added to the input fields below is identical to the default import scripts used. Adapt them to your own custom needs.
" COM_COMPONENTBUILDER_ADMIN_VIEW_NOTE_ADVANCED_IMPORT_LABEL="Advanced notice." COM_COMPONENTBUILDER_ADMIN_VIEW_NOTE_BEGINNER_IMPORT_DESCRIPTION="Please do not change this area unless you would like to add special import to this view that goes beyond the default import concept that Component Builder already does automatic if this view is set to have import & export in the component area where this view is linked to the component.
" COM_COMPONENTBUILDER_ADMIN_VIEW_NOTE_BEGINNER_IMPORT_LABEL="Beginners notice." -COM_COMPONENTBUILDER_ADMIN_VIEW_NOTE_ON_CONDITIONS_DESCRIPTION="Here you can add conditional field settings" -COM_COMPONENTBUILDER_ADMIN_VIEW_NOTE_ON_CONDITIONS_LABEL="Condition Implementation" +COM_COMPONENTBUILDER_ADMIN_VIEW_NOTE_CREATE_EDIT_BUTTONS_DESCRIPTION="" +COM_COMPONENTBUILDER_ADMIN_VIEW_NOTE_CREATE_EDIT_DISPLAY_DESCRIPTION="escape(JText::_($fieldSet->description)); ?>
+ + + renderField('metadesc'); + echo $form->renderField('metakey'); + } + + foreach ($form->getFieldset($name) as $field) + { + if ($field->name != 'jform[metadata][tags][]') + { + echo $field->renderField(); + } + } ?> + diff --git a/admin/layouts/joomla_component/mysql_fullwidth.php b/admin/layouts/joomla_component/mysql_fullwidth.php index b583cf211..33e3b0c57 100644 --- a/admin/layouts/joomla_component/mysql_fullwidth.php +++ b/admin/layouts/joomla_component/mysql_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/joomla_component/php_fullwidth.php b/admin/layouts/joomla_component/php_fullwidth.php index 3a527eeb0..50884943e 100644 --- a/admin/layouts/joomla_component/php_fullwidth.php +++ b/admin/layouts/joomla_component/php_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/joomla_component/publishing.php b/admin/layouts/joomla_component/publishing.php index 124f89ba1..d5c295540 100644 --- a/admin/layouts/joomla_component/publishing.php +++ b/admin/layouts/joomla_component/publishing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder @@ -34,7 +34,13 @@ $fields = $displayData->get('fields') ?: array( 'created', 'created_by', 'modified', - 'modified_by' + 'modified_by', + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' ); $hiddenFields = $displayData->get('hidden_fields') ?: array(); diff --git a/admin/layouts/joomla_component/readme_left.php b/admin/layouts/joomla_component/readme_left.php index ffa7e2432..a4bed1ca4 100644 --- a/admin/layouts/joomla_component/readme_left.php +++ b/admin/layouts/joomla_component/readme_left.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/joomla_component/readme_right.php b/admin/layouts/joomla_component/readme_right.php index cce9880fe..7c5b9c3bc 100644 --- a/admin/layouts/joomla_component/readme_right.php +++ b/admin/layouts/joomla_component/readme_right.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/joomla_component/settings_left.php b/admin/layouts/joomla_component/settings_left.php index d1017c034..0e1305dab 100644 --- a/admin/layouts/joomla_component/settings_left.php +++ b/admin/layouts/joomla_component/settings_left.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/joomla_component/settings_right.php b/admin/layouts/joomla_component/settings_right.php index 33461e68f..b97449d7c 100644 --- a/admin/layouts/joomla_component/settings_right.php +++ b/admin/layouts/joomla_component/settings_right.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/joomla_component/site_views_fullwidth.php b/admin/layouts/joomla_component/site_views_fullwidth.php index b5409ec3d..ae8b3114b 100644 --- a/admin/layouts/joomla_component/site_views_fullwidth.php +++ b/admin/layouts/joomla_component/site_views_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/joomla_component/translation_fullwidth.php b/admin/layouts/joomla_component/translation_fullwidth.php index d88364bbe..96a982f3f 100644 --- a/admin/layouts/joomla_component/translation_fullwidth.php +++ b/admin/layouts/joomla_component/translation_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/language/details_left.php b/admin/layouts/language/details_left.php index c7c1f0cce..9401a56e4 100644 --- a/admin/layouts/language/details_left.php +++ b/admin/layouts/language/details_left.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/language/details_right.php b/admin/layouts/language/details_right.php index 2d2b05d7e..62441e6d3 100644 --- a/admin/layouts/language/details_right.php +++ b/admin/layouts/language/details_right.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/language/publishing.php b/admin/layouts/language/publishing.php index 124f89ba1..fb681cf40 100644 --- a/admin/layouts/language/publishing.php +++ b/admin/layouts/language/publishing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/language/publlshing.php b/admin/layouts/language/publlshing.php index 7b4a2be8e..ad942d2f1 100644 --- a/admin/layouts/language/publlshing.php +++ b/admin/layouts/language/publlshing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder @@ -33,7 +33,6 @@ $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( 'published', 'ordering', - 'access', 'version', 'hits', 'id' diff --git a/admin/layouts/language_translation/details_above.php b/admin/layouts/language_translation/details_above.php index 115f6aef7..b5b4aef34 100644 --- a/admin/layouts/language_translation/details_above.php +++ b/admin/layouts/language_translation/details_above.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/language_translation/details_fullwidth.php b/admin/layouts/language_translation/details_fullwidth.php index 647bedfb1..eb1d0117a 100644 --- a/admin/layouts/language_translation/details_fullwidth.php +++ b/admin/layouts/language_translation/details_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/language_translation/publishing.php b/admin/layouts/language_translation/publishing.php index 124f89ba1..fb681cf40 100644 --- a/admin/layouts/language_translation/publishing.php +++ b/admin/layouts/language_translation/publishing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/language_translation/publlshing.php b/admin/layouts/language_translation/publlshing.php index 7b4a2be8e..ad942d2f1 100644 --- a/admin/layouts/language_translation/publlshing.php +++ b/admin/layouts/language_translation/publlshing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder @@ -33,7 +33,6 @@ $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( 'published', 'ordering', - 'access', 'version', 'hits', 'id' diff --git a/admin/layouts/layout/custom_script_fullwidth.php b/admin/layouts/layout/custom_script_fullwidth.php index 9037e7b79..32ecee070 100644 --- a/admin/layouts/layout/custom_script_fullwidth.php +++ b/admin/layouts/layout/custom_script_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/layout/details_fullwidth.php b/admin/layouts/layout/details_fullwidth.php index 112ffc15a..54b2f1ee2 100644 --- a/admin/layouts/layout/details_fullwidth.php +++ b/admin/layouts/layout/details_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/layout/details_left.php b/admin/layouts/layout/details_left.php index fc2b93218..6df1fb844 100644 --- a/admin/layouts/layout/details_left.php +++ b/admin/layouts/layout/details_left.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/layout/details_right.php b/admin/layouts/layout/details_right.php index e211859a8..9b2e232c3 100644 --- a/admin/layouts/layout/details_right.php +++ b/admin/layouts/layout/details_right.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/layout/details_rightside.php b/admin/layouts/layout/details_rightside.php index 0b1ec7323..d462afb5f 100644 --- a/admin/layouts/layout/details_rightside.php +++ b/admin/layouts/layout/details_rightside.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/layout/details_under.php b/admin/layouts/layout/details_under.php index 752bff74f..21469c10a 100644 --- a/admin/layouts/layout/details_under.php +++ b/admin/layouts/layout/details_under.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/layout/publishing.php b/admin/layouts/layout/publishing.php index 124f89ba1..fb681cf40 100644 --- a/admin/layouts/layout/publishing.php +++ b/admin/layouts/layout/publishing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/layout/publlshing.php b/admin/layouts/layout/publlshing.php index 7b4a2be8e..ad942d2f1 100644 --- a/admin/layouts/layout/publlshing.php +++ b/admin/layouts/layout/publlshing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder @@ -33,7 +33,6 @@ $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( 'published', 'ordering', - 'access', 'version', 'hits', 'id' diff --git a/admin/layouts/site_view/custom_buttons_fullwidth.php b/admin/layouts/site_view/custom_buttons_fullwidth.php index 983e181e6..969ef17a5 100644 --- a/admin/layouts/site_view/custom_buttons_fullwidth.php +++ b/admin/layouts/site_view/custom_buttons_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/custom_buttons_left.php b/admin/layouts/site_view/custom_buttons_left.php index 55086c164..04b569c28 100644 --- a/admin/layouts/site_view/custom_buttons_left.php +++ b/admin/layouts/site_view/custom_buttons_left.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/custom_buttons_right.php b/admin/layouts/site_view/custom_buttons_right.php index 83f244633..208628d3f 100644 --- a/admin/layouts/site_view/custom_buttons_right.php +++ b/admin/layouts/site_view/custom_buttons_right.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/details_above.php b/admin/layouts/site_view/details_above.php index cf5d9da9e..f23dac70d 100644 --- a/admin/layouts/site_view/details_above.php +++ b/admin/layouts/site_view/details_above.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/details_fullwidth.php b/admin/layouts/site_view/details_fullwidth.php index 424473003..cf0e1f4c9 100644 --- a/admin/layouts/site_view/details_fullwidth.php +++ b/admin/layouts/site_view/details_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/details_left.php b/admin/layouts/site_view/details_left.php index 6b747dfa0..e97d5302c 100644 --- a/admin/layouts/site_view/details_left.php +++ b/admin/layouts/site_view/details_left.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/details_right.php b/admin/layouts/site_view/details_right.php index e211859a8..9b2e232c3 100644 --- a/admin/layouts/site_view/details_right.php +++ b/admin/layouts/site_view/details_right.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/details_rightside.php b/admin/layouts/site_view/details_rightside.php index 6d3dee0c3..199ef5937 100644 --- a/admin/layouts/site_view/details_rightside.php +++ b/admin/layouts/site_view/details_rightside.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/details_under.php b/admin/layouts/site_view/details_under.php index 752bff74f..21469c10a 100644 --- a/admin/layouts/site_view/details_under.php +++ b/admin/layouts/site_view/details_under.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/javascript_css_fullwidth.php b/admin/layouts/site_view/javascript_css_fullwidth.php index 5a9fdf03e..055a6e300 100644 --- a/admin/layouts/site_view/javascript_css_fullwidth.php +++ b/admin/layouts/site_view/javascript_css_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/linked_components_fullwidth.php b/admin/layouts/site_view/linked_components_fullwidth.php index 791b66d23..cfb7fcb47 100644 --- a/admin/layouts/site_view/linked_components_fullwidth.php +++ b/admin/layouts/site_view/linked_components_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/php_fullwidth.php b/admin/layouts/site_view/php_fullwidth.php index 12356d149..754c7f23e 100644 --- a/admin/layouts/site_view/php_fullwidth.php +++ b/admin/layouts/site_view/php_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/publishing.php b/admin/layouts/site_view/publishing.php index 124f89ba1..fb681cf40 100644 --- a/admin/layouts/site_view/publishing.php +++ b/admin/layouts/site_view/publishing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/site_view/publlshing.php b/admin/layouts/site_view/publlshing.php index 7b4a2be8e..ad942d2f1 100644 --- a/admin/layouts/site_view/publlshing.php +++ b/admin/layouts/site_view/publlshing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder @@ -33,7 +33,6 @@ $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( 'published', 'ordering', - 'access', 'version', 'hits', 'id' diff --git a/admin/layouts/snippet/details_above.php b/admin/layouts/snippet/details_above.php index 627d9bbf6..35bc05647 100644 --- a/admin/layouts/snippet/details_above.php +++ b/admin/layouts/snippet/details_above.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/snippet/details_left.php b/admin/layouts/snippet/details_left.php index fa2029108..f1ba0a275 100644 --- a/admin/layouts/snippet/details_left.php +++ b/admin/layouts/snippet/details_left.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/snippet/details_right.php b/admin/layouts/snippet/details_right.php index 44fa2ea43..72b9af6c0 100644 --- a/admin/layouts/snippet/details_right.php +++ b/admin/layouts/snippet/details_right.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/snippet/publishing.php b/admin/layouts/snippet/publishing.php index 124f89ba1..fb681cf40 100644 --- a/admin/layouts/snippet/publishing.php +++ b/admin/layouts/snippet/publishing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/snippet/publlshing.php b/admin/layouts/snippet/publlshing.php index 7b4a2be8e..ad942d2f1 100644 --- a/admin/layouts/snippet/publlshing.php +++ b/admin/layouts/snippet/publlshing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder @@ -33,7 +33,6 @@ $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( 'published', 'ordering', - 'access', 'version', 'hits', 'id' diff --git a/admin/layouts/template/custom_script_fullwidth.php b/admin/layouts/template/custom_script_fullwidth.php index 9037e7b79..32ecee070 100644 --- a/admin/layouts/template/custom_script_fullwidth.php +++ b/admin/layouts/template/custom_script_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/template/details_fullwidth.php b/admin/layouts/template/details_fullwidth.php index 69a7693af..f874474c4 100644 --- a/admin/layouts/template/details_fullwidth.php +++ b/admin/layouts/template/details_fullwidth.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/template/details_left.php b/admin/layouts/template/details_left.php index fc2b93218..6df1fb844 100644 --- a/admin/layouts/template/details_left.php +++ b/admin/layouts/template/details_left.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/template/details_right.php b/admin/layouts/template/details_right.php index e211859a8..9b2e232c3 100644 --- a/admin/layouts/template/details_right.php +++ b/admin/layouts/template/details_right.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/template/details_rightside.php b/admin/layouts/template/details_rightside.php index 0b1ec7323..d462afb5f 100644 --- a/admin/layouts/template/details_rightside.php +++ b/admin/layouts/template/details_rightside.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/template/details_under.php b/admin/layouts/template/details_under.php index 752bff74f..21469c10a 100644 --- a/admin/layouts/template/details_under.php +++ b/admin/layouts/template/details_under.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/template/publishing.php b/admin/layouts/template/publishing.php index 124f89ba1..fb681cf40 100644 --- a/admin/layouts/template/publishing.php +++ b/admin/layouts/template/publishing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder diff --git a/admin/layouts/template/publlshing.php b/admin/layouts/template/publlshing.php index 7b4a2be8e..ad942d2f1 100644 --- a/admin/layouts/template/publlshing.php +++ b/admin/layouts/template/publlshing.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder @@ -33,7 +33,6 @@ $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( 'published', 'ordering', - 'access', 'version', 'hits', 'id' diff --git a/admin/models/admin_fields.php b/admin/models/admin_fields.php new file mode 100644 index 000000000..2c8aa3729 --- /dev/null +++ b/admin/models/admin_fields.php @@ -0,0 +1,879 @@ + + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + + Builds Complex Joomla Components + +/-----------------------------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Registry\Registry; + +// import Joomla modelform library +jimport('joomla.application.component.modeladmin'); + +/** + * Componentbuilder Admin_fields Model + */ +class ComponentbuilderModelAdmin_fields extends JModelAdmin +{ + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.admin_fields'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'admin_fields', $prefix = 'ComponentbuilderTable', $config = array()) + { + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addfields)) + { + // Convert the addfields field to an array. + $addfields = new Registry; + $addfields->loadString($item->addfields); + $item->addfields = $addfields->toArray(); + } + + if (!empty($item->id)) + { + $item->tags = new JHelperTags; + $item->tags->getTagIds($item->id, 'com_componentbuilder.admin_fields'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true) + { + // Get the form. + $form = $this->loadForm('com_componentbuilder.admin_fields', 'admin_fields', array('control' => 'jform', 'load_data' => $loadData)); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('core.edit.state', 'com_componentbuilder.admin_fields.' . (int) $id)) + || ($id == 0 && !$user->authorise('core.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected field name + $redirectedField = $jinput->get('ref', null, 'STRING'); + // Set redirected field value + $redirectedValue = $jinput->get('refid', 0, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'administrator/components/com_componentbuilder/models/forms/admin_fields.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('core.delete', 'com_componentbuilder.admin_fields.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit.state', 'com_componentbuilder.admin_fields.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return parent::canEditState($record); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + + return JFactory::getUser()->authorise('core.edit', 'com_componentbuilder.admin_fields.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_admin_fields')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_componentbuilder.edit.admin_fields.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqeFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + JArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = JArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields'); + } + + if (!$this->canDo->get('core.create') || !$this->canDo->get('core.batch')) + { + return false; + } + + // get list of uniqe fields + $uniqeFields = $this->getUniqeFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + + if (!$this->user->authorise('core.edit', $contexts[$pk])) + + { + + // Not fatal error + + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + + continue; + + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + $this->table->admin_view = $this->generateUniqe('admin_view',$this->table->admin_view); + + // insert all set values + if (ComponentbuilderHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all uniqe fields + if (ComponentbuilderHelper::checkArray($uniqeFields)) + { + foreach ($uniqeFields as $uniqeField) + { + $this->table->$uniqeField = $this->generateUniqe($uniqeField,$this->table->$uniqeField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields'); + } + + if (!$this->canDo->get('core.edit') && !$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (ComponentbuilderHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the addfields items to data. + if (isset($data['addfields']) && is_array($data['addfields'])) + { + $addfields = new JRegistry; + $addfields->loadArray($data['addfields']); + $data['addfields'] = (string) $addfields; + } + elseif (!isset($data['addfields'])) + { + // Set the empty addfields to data + $data['addfields'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the uniqe field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other uniqe fields + $uniqeFields = $this->getUniqeFields(); + if (ComponentbuilderHelper::checkArray($uniqeFields)) + { + foreach ($uniqeFields as $uniqeField) + { + $data[$uniqeField] = $this->generateUniqe($uniqeField,$data[$uniqeField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a uniqe value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUniqe($field,$value) + { + + // set field value uniqe + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = JString::increment($value); + } + + return $value; + } + + /** + * Method to change the title & alias. + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(array('title' => $title))) + { + $title = JString::increment($title); + } + + return $title; + } +} diff --git a/admin/models/admin_fields_conditions.php b/admin/models/admin_fields_conditions.php new file mode 100644 index 000000000..87be74748 --- /dev/null +++ b/admin/models/admin_fields_conditions.php @@ -0,0 +1,879 @@ + + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + + Builds Complex Joomla Components + +/-----------------------------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Registry\Registry; + +// import Joomla modelform library +jimport('joomla.application.component.modeladmin'); + +/** + * Componentbuilder Admin_fields_conditions Model + */ +class ComponentbuilderModelAdmin_fields_conditions extends JModelAdmin +{ + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.admin_fields_conditions'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'admin_fields_conditions', $prefix = 'ComponentbuilderTable', $config = array()) + { + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addconditions)) + { + // Convert the addconditions field to an array. + $addconditions = new Registry; + $addconditions->loadString($item->addconditions); + $item->addconditions = $addconditions->toArray(); + } + + if (!empty($item->id)) + { + $item->tags = new JHelperTags; + $item->tags->getTagIds($item->id, 'com_componentbuilder.admin_fields_conditions'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true) + { + // Get the form. + $form = $this->loadForm('com_componentbuilder.admin_fields_conditions', 'admin_fields_conditions', array('control' => 'jform', 'load_data' => $loadData)); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('core.edit.state', 'com_componentbuilder.admin_fields_conditions.' . (int) $id)) + || ($id == 0 && !$user->authorise('core.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected field name + $redirectedField = $jinput->get('ref', null, 'STRING'); + // Set redirected field value + $redirectedValue = $jinput->get('refid', 0, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'administrator/components/com_componentbuilder/models/forms/admin_fields_conditions.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('core.delete', 'com_componentbuilder.admin_fields_conditions.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit.state', 'com_componentbuilder.admin_fields_conditions.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return parent::canEditState($record); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + + return JFactory::getUser()->authorise('core.edit', 'com_componentbuilder.admin_fields_conditions.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_admin_fields_conditions')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_componentbuilder.edit.admin_fields_conditions.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqeFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + JArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_conditions'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = JArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_conditions'); + } + + if (!$this->canDo->get('core.create') || !$this->canDo->get('core.batch')) + { + return false; + } + + // get list of uniqe fields + $uniqeFields = $this->getUniqeFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + + if (!$this->user->authorise('core.edit', $contexts[$pk])) + + { + + // Not fatal error + + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + + continue; + + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + $this->table->admin_view = $this->generateUniqe('admin_view',$this->table->admin_view); + + // insert all set values + if (ComponentbuilderHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all uniqe fields + if (ComponentbuilderHelper::checkArray($uniqeFields)) + { + foreach ($uniqeFields as $uniqeField) + { + $this->table->$uniqeField = $this->generateUniqe($uniqeField,$this->table->$uniqeField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_conditions'); + } + + if (!$this->canDo->get('core.edit') && !$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (ComponentbuilderHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the addconditions items to data. + if (isset($data['addconditions']) && is_array($data['addconditions'])) + { + $addconditions = new JRegistry; + $addconditions->loadArray($data['addconditions']); + $data['addconditions'] = (string) $addconditions; + } + elseif (!isset($data['addconditions'])) + { + // Set the empty addconditions to data + $data['addconditions'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the uniqe field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other uniqe fields + $uniqeFields = $this->getUniqeFields(); + if (ComponentbuilderHelper::checkArray($uniqeFields)) + { + foreach ($uniqeFields as $uniqeField) + { + $data[$uniqeField] = $this->generateUniqe($uniqeField,$data[$uniqeField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a uniqe value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUniqe($field,$value) + { + + // set field value uniqe + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = JString::increment($value); + } + + return $value; + } + + /** + * Method to change the title & alias. + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(array('title' => $title))) + { + $title = JString::increment($title); + } + + return $title; + } +} diff --git a/admin/models/admin_view.php b/admin/models/admin_view.php index 82277ad41..3be57afe9 100644 --- a/admin/models/admin_view.php +++ b/admin/models/admin_view.php @@ -10,8 +10,8 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 126 of this MVC - @build 11th October, 2017 + @version @update number 136 of this MVC + @build 12th October, 2017 @created 30th April, 2015 @package Component Builder @subpackage admin_view.php @@ -64,6 +64,11 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin public function getTable($type = 'admin_view', $prefix = 'ComponentbuilderTable', $config = array()) { return JTable::getInstance($type, $prefix, $config); + } + + public function getVDM() + { + return $this->vastDevMod; } /** @@ -119,22 +124,6 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin $item->addlinked_views = $addlinked_views->toArray(); } - if (!empty($item->addfields)) - { - // Convert the addfields field to an array. - $addfields = new Registry; - $addfields->loadString($item->addfields); - $item->addfields = $addfields->toArray(); - } - - if (!empty($item->addconditions)) - { - // Convert the addconditions field to an array. - $addconditions = new Registry; - $addconditions->loadString($item->addconditions); - $item->addconditions = $addconditions->toArray(); - } - if (!empty($item->custom_button)) { // Convert the custom_button field to an array. @@ -261,10 +250,10 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin $item->php_import_display = base64_decode($item->php_import_display); } - if (!empty($item->php_getitem)) + if (!empty($item->css_view)) { - // base64 Decode php_getitem. - $item->php_getitem = base64_decode($item->php_getitem); + // base64 Decode css_view. + $item->css_view = base64_decode($item->css_view); } if (!empty($item->php_import_save)) @@ -273,12 +262,6 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin $item->php_import_save = base64_decode($item->php_import_save); } - if (!empty($item->css_view)) - { - // base64 Decode css_view. - $item->css_view = base64_decode($item->css_view); - } - if (!empty($item->css_views)) { // base64 Decode css_views. @@ -351,11 +334,38 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin $item->php_import_setdata = base64_decode($item->php_import_setdata); } + if (!empty($item->php_getitem)) + { + // base64 Decode php_getitem. + $item->php_getitem = base64_decode($item->php_getitem); + } + if (!empty($item->php_import_ext)) { // base64 Decode php_import_ext. $item->php_import_ext = base64_decode($item->php_import_ext); + } + + + if (empty($item->id)) + { + $id = 0; } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('admin_view__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'admin_view__'.$id); + ComponentbuilderHelper::set('admin_view__'.$id, $this->vastDevMod); + } if (!empty($item->id)) { @@ -1192,32 +1202,6 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin $data['addlinked_views'] = ''; } - // Set the addfields items to data. - if (isset($data['addfields']) && is_array($data['addfields'])) - { - $addfields = new JRegistry; - $addfields->loadArray($data['addfields']); - $data['addfields'] = (string) $addfields; - } - elseif (!isset($data['addfields'])) - { - // Set the empty addfields to data - $data['addfields'] = ''; - } - - // Set the addconditions items to data. - if (isset($data['addconditions']) && is_array($data['addconditions'])) - { - $addconditions = new JRegistry; - $addconditions->loadArray($data['addconditions']); - $data['addconditions'] = (string) $addconditions; - } - elseif (!isset($data['addconditions'])) - { - // Set the empty addconditions to data - $data['addconditions'] = ''; - } - // Set the custom_button items to data. if (isset($data['custom_button']) && is_array($data['custom_button'])) { @@ -1359,10 +1343,10 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin $data['php_import_display'] = base64_encode($data['php_import_display']); } - // Set the php_getitem string to base64 string. - if (isset($data['php_getitem'])) + // Set the css_view string to base64 string. + if (isset($data['css_view'])) { - $data['php_getitem'] = base64_encode($data['php_getitem']); + $data['css_view'] = base64_encode($data['css_view']); } // Set the php_import_save string to base64 string. @@ -1371,12 +1355,6 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin $data['php_import_save'] = base64_encode($data['php_import_save']); } - // Set the css_view string to base64 string. - if (isset($data['css_view'])) - { - $data['css_view'] = base64_encode($data['css_view']); - } - // Set the css_views string to base64 string. if (isset($data['css_views'])) { @@ -1449,6 +1427,12 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin $data['php_import_setdata'] = base64_encode($data['php_import_setdata']); } + // Set the php_getitem string to base64 string. + if (isset($data['php_getitem'])) + { + $data['php_getitem'] = base64_encode($data['php_getitem']); + } + // Set the php_import_ext string to base64 string. if (isset($data['php_import_ext'])) { diff --git a/admin/models/admin_views.php b/admin/models/admin_views.php index d5a7380bb..7f62d32cd 100644 --- a/admin/models/admin_views.php +++ b/admin/models/admin_views.php @@ -10,8 +10,8 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version @update number 126 of this MVC - @build 11th October, 2017 + @version @update number 136 of this MVC + @build 12th October, 2017 @created 30th April, 2015 @package Component Builder @subpackage admin_views.php @@ -148,21 +148,6 @@ class ComponentbuilderModelAdmin_views extends JModelList { $query->where('(a.published = 0 OR a.published = 1)'); } - - // Join over the asset groups. - $query->select('ag.title AS access_level'); - $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); - // Filter by access level. - if ($access = $this->getState('filter.access')) - { - $query->where('a.access = ' . (int) $access); - } - // Implement View Level Access - if (!$user->authorise('core.options', 'com_componentbuilder')) - { - $groups = implode(',', $user->getAuthorisedViewLevels()); - $query->where('a.access IN (' . $groups . ')'); - } // Filter by search. $search = $this->getState('filter.search'); if (!empty($search)) @@ -214,12 +199,6 @@ class ComponentbuilderModelAdmin_views extends JModelList // From the componentbuilder_admin_view table $query->from($db->quoteName('#__componentbuilder_admin_view', 'a')); $query->where('a.id IN (' . implode(',',$pks) . ')'); - // Implement View Level Access - if (!$user->authorise('core.options', 'com_componentbuilder')) - { - $groups = implode(',', $user->getAuthorisedViewLevels()); - $query->where('a.access IN (' . $groups . ')'); - } // Order the results by ordering $query->order('a.ordering ASC'); @@ -270,12 +249,10 @@ class ComponentbuilderModelAdmin_views extends JModelList $item->sql = base64_decode($item->sql); // decode php_import_display $item->php_import_display = base64_decode($item->php_import_display); - // decode php_getitem - $item->php_getitem = base64_decode($item->php_getitem); - // decode php_import_save - $item->php_import_save = base64_decode($item->php_import_save); // decode css_view $item->css_view = base64_decode($item->css_view); + // decode php_import_save + $item->php_import_save = base64_decode($item->php_import_save); // decode css_views $item->css_views = base64_decode($item->css_views); // decode javascript_view_file @@ -300,6 +277,8 @@ class ComponentbuilderModelAdmin_views extends JModelList $item->html_import_view = base64_decode($item->html_import_view); // decode php_import_setdata $item->php_import_setdata = base64_decode($item->php_import_setdata); + // decode php_getitem + $item->php_getitem = base64_decode($item->php_getitem); // decode php_import_ext $item->php_import_ext = base64_decode($item->php_import_ext); // unset the values we don't want exported. diff --git a/admin/models/admins_fields.php b/admin/models/admins_fields.php new file mode 100644 index 000000000..b375ff59e --- /dev/null +++ b/admin/models/admins_fields.php @@ -0,0 +1,224 @@ + + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + + Builds Complex Joomla Components + +/-----------------------------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the Joomla modellist library +jimport('joomla.application.component.modellist'); + +/** + * Admins_fields Model + */ +class ComponentbuilderModelAdmins_fields extends JModelList +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * @return void + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + $this->setState('filter.access', $access); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_admin_fields', 'a')); + + // From the componentbuilder_admin_view table. + $query->select($db->quoteName('g.system_name','admin_view_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_admin_view', 'g') . ' ON (' . $db->quoteName('a.admin_view') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'asc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // reset query + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_admin_fields')); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date + $date = JFactory::getDate()->modify($time)->toSql(); + // reset query + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table + $query->update($db->quoteName('#__componentbuilder_admin_fields'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/admins_fields_conditions.php b/admin/models/admins_fields_conditions.php new file mode 100644 index 000000000..36979f431 --- /dev/null +++ b/admin/models/admins_fields_conditions.php @@ -0,0 +1,224 @@ + + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + + Builds Complex Joomla Components + +/-----------------------------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the Joomla modellist library +jimport('joomla.application.component.modellist'); + +/** + * Admins_fields_conditions Model + */ +class ComponentbuilderModelAdmins_fields_conditions extends JModelList +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * @return void + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + $this->setState('filter.access', $access); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_admin_fields_conditions', 'a')); + + // From the componentbuilder_admin_view table. + $query->select($db->quoteName('g.system_name','admin_view_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_admin_view', 'g') . ' ON (' . $db->quoteName('a.admin_view') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'asc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // reset query + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_admin_fields_conditions')); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date + $date = JFactory::getDate()->modify($time)->toSql(); + // reset query + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table + $query->update($db->quoteName('#__componentbuilder_admin_fields_conditions'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/ajax.php b/admin/models/ajax.php index 10f0319ec..1783571a6 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -10,7 +10,7 @@ |_| /-------------------------------------------------------------------------------------------------------------------------------/ - @version 2.5.6 + @version 2.5.8 @build 12th October, 2017 @created 30th April, 2015 @package Component Builder @@ -177,6 +177,131 @@ class ComponentbuilderModelAjax extends JModelList } // Used in admin_view + + protected $viewid = array(); + + protected function getViewID($call = 'table') + { + if (!isset($this->viewid[$call])) + { + // get the vdm key + $jinput = JFactory::getApplication()->input; + $vdm = $jinput->get('vdm', null, 'WORD'); + if ($vdm) + { + if ($view = ComponentbuilderHelper::get($vdm)) + { + $current = (array) explode('__', $view); + if (ComponentbuilderHelper::checkString($current[0]) && isset($current[1]) && is_numeric($current[1])) + { + // get the view name & id + $this->viewid[$call] = array( + 'a_id' => (int) $current[1], + 'a_view' => $current[0] + ); + } + } + } + } + if (isset($this->viewid[$call])) + { + return $this->viewid[$call]; + } + return false; + } + + protected $buttonArray = array( + 'admin_fields' => 'admins_fields', + 'admin_fields_conditions' => 'admins_fields_conditions', + 'language' => true); + + public function getButton($type) + { + if (isset($this->buttonArray[$type])) + { + $user = JFactory::getUser(); + // only add if user allowed to create + if ($user->authorise($type.'.create', 'com_componentbuilder')) + { + // get the view name & id + $values = $this->getViewID(); + // check if new item + $ref = ''; + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view'])) + { + // only load referal if not new item. + $ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id']; + } + // build the button + $button = '