diff --git a/README.md b/README.md index 5ddf818..1a1caaf 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ + *Author*: [Llewellyn](mailto:joomla@vdm.io) + *Name*: [Hello World](https://www.vdm.io) + *First Build*: 20th September, 2017 -+ *Last Build*: 4th January, 2021 ++ *Last Build*: 3rd March, 2022 + *Version*: 1.0.1 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @@ -21,7 +21,7 @@ due to [Automated Component Builder](http://joomlacomponentbuilder.com)) > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, > never making one mistake or taking any coffee break.) -+ *Line count*: **14632** ++ *Line count*: **14630** + *File count*: **139** + *Folder count*: **55** diff --git a/admin/README.txt b/admin/README.txt index 5ddf818..1a1caaf 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -8,7 +8,7 @@ + *Author*: [Llewellyn](mailto:joomla@vdm.io) + *Name*: [Hello World](https://www.vdm.io) + *First Build*: 20th September, 2017 -+ *Last Build*: 4th January, 2021 ++ *Last Build*: 3rd March, 2022 + *Version*: 1.0.1 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @@ -21,7 +21,7 @@ due to [Automated Component Builder](http://joomlacomponentbuilder.com)) > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, > never making one mistake or taking any coffee break.) -+ *Line count*: **14632** ++ *Line count*: **14630** + *File count*: **139** + *Folder count*: **55** diff --git a/admin/access.xml b/admin/access.xml index cb65edb..4ce6a7b 100644 --- a/admin/access.xml +++ b/admin/access.xml @@ -1,5 +1,5 @@ - - + +
@@ -43,5 +43,5 @@ -
+
\ No newline at end of file diff --git a/admin/assets/css/admin.css b/admin/assets/css/admin.css index fb7bd30..409f44c 100644 --- a/admin/assets/css/admin.css +++ b/admin/assets/css/admin.css @@ -1,24 +1,24 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage admin.css - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -/* CSS Document */ -.no-click { - pointer-events: none; -} - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage admin.css + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ +.no-click { + pointer-events: none; +} + diff --git a/admin/assets/css/dashboard.css b/admin/assets/css/dashboard.css index 04cf2c6..54c78f8 100644 --- a/admin/assets/css/dashboard.css +++ b/admin/assets/css/dashboard.css @@ -1,172 +1,172 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage dashboard.css - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -/* CSS Document */ - -.dashboard-container { - margin-left: 10px; - margin-top: 10px; - width: 100%; -} -.dashboard-container [class*="span"] { - display: block; - float: none; - margin-left: 0; - width: auto; -} -.dashboard-container:before, .dashboard-container:after { - content: ""; - display: table; -} -.dashboard-container:after { - clear: both; -} -.dashboard-container [class*="span"] { - box-sizing: border-box; - display: block; - float: left; - min-height: 145px; - min-width: 96px; - width: 100%; -} -.dashboard-container [class*="span"]:first-child { - margin-left: 0; -} -.dashboard-wraper { - background: none repeat scroll 0 0 hsl(0, 0%, 93%); - border-radius: 5px; - float: left; - margin: 1%; - padding: 3px; - width: 17%; - min-height: 194px; - min-width: 96px; -} -.dashboard-content a { - background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - border: 1px solid hsl(0, 0%, 85%); - border-radius: 4px; - box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; - color: hsl(0, 0%, 20%); - display: block; - min-height: 89px; - padding: 10px; - text-align: center; - text-decoration: none; -} -.dashboard-content a:hover { - background: linear-gradient(to bottom, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 100%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - color: hsl(200, 100%, 30%); - text-decoration: none; -} -.dashboard-title { - display: block; - padding-top: 5px; -} -.dashboard-info { - background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - border: 1px solid hsl(0, 0%, 85%); - border-radius: 4px; - box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; - color: hsl(0, 0%, 20%); - display: block; - font-size: 12px; - padding: 10px; - text-align: center; -} -.dashboard-info span { - display: block; - text-align: center; -} -.dashboard-info img { - margin: 0 auto; -} -.dashboard-table { - border-top: 1px solid hsl(0, 0%, 87%); - margin-top: 5px; - width: 100%; -} -.dashboard-info h5 { - font-size: 11px; - font-weight: bold; -} -.dashboard-block { - background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - border: 1px solid hsl(0, 0%, 76%); - border-radius: 3px; - box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset; - margin-bottom: 20px; -} -.dashboard-block .dashboard-block-head { - background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - border-bottom: 1px solid hsl(0, 0%, 76%); - border-radius: 3px 3px 0 0; - box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset, 0 0 3px hsl(0, 0%, 87%); - height: 40px; - position: relative; -} -.dashboard-block .dashboard-block-head h5 { - font-size: 12px; - margin: 0; - padding-left: 10px; - padding-top: 11px; - text-transform: uppercase; -} -.dashboard-block .dashboard-block-content { - background: none repeat scroll 0 0 hsl(0, 0%, 93%); - border-radius: 0 0 3px 3px; -} -.dashboard-block .dashboard-block-box { - background: none repeat scroll 0 0 hsl(0, 0%, 100%); - border-top: 1px solid hsl(0, 0%, 82%); - box-shadow: 0 0 5px hsl(0, 0%, 87%) inset; -} -.dashboard-block .dashboard-block-content .dashboard-block-box { - margin-top: 0 !important; -} -.dashboard-block .dashboard-block-content .dashboard-block-box .dashboard-block-table { - margin-bottom: 0 !important; -} -.dashboard-block-table { - background-color: hsla(0, 0%, 0%, 0); - border-collapse: collapse; - border-spacing: 0; - margin-bottom: 20px; - max-width: 100%; - width: 100%; -} -.dashboard-block-table th, .dashboard-block-table td { - border-top: 1px solid hsl(0, 0%, 87%); - line-height: 20px; - padding: 5px; - text-align: left; - vertical-align: middle; -} -.dashboard-badge { - background-color: hsl(0, 0%, 60%); - border-radius: 9px; - color: hsl(0, 0%, 100%); - font-size: 11.844px; - font-weight: bold; - line-height: 14px; - padding: 1px 9px 2px; - text-shadow: 0 -1px 0 hsla(0, 0%, 0%, 0.25); - vertical-align: baseline; - white-space: nowrap; +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage dashboard.css + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + +.dashboard-container { + margin-left: 10px; + margin-top: 10px; + width: 100%; +} +.dashboard-container [class*="span"] { + display: block; + float: none; + margin-left: 0; + width: auto; +} +.dashboard-container:before, .dashboard-container:after { + content: ""; + display: table; +} +.dashboard-container:after { + clear: both; +} +.dashboard-container [class*="span"] { + box-sizing: border-box; + display: block; + float: left; + min-height: 145px; + min-width: 96px; + width: 100%; +} +.dashboard-container [class*="span"]:first-child { + margin-left: 0; +} +.dashboard-wraper { + background: none repeat scroll 0 0 hsl(0, 0%, 93%); + border-radius: 5px; + float: left; + margin: 1%; + padding: 3px; + width: 17%; + min-height: 194px; + min-width: 96px; +} +.dashboard-content a { + background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 85%); + border-radius: 4px; + box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; + color: hsl(0, 0%, 20%); + display: block; + min-height: 89px; + padding: 10px; + text-align: center; + text-decoration: none; +} +.dashboard-content a:hover { + background: linear-gradient(to bottom, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 100%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + color: hsl(200, 100%, 30%); + text-decoration: none; +} +.dashboard-title { + display: block; + padding-top: 5px; +} +.dashboard-info { + background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 85%); + border-radius: 4px; + box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; + color: hsl(0, 0%, 20%); + display: block; + font-size: 12px; + padding: 10px; + text-align: center; +} +.dashboard-info span { + display: block; + text-align: center; +} +.dashboard-info img { + margin: 0 auto; +} +.dashboard-table { + border-top: 1px solid hsl(0, 0%, 87%); + margin-top: 5px; + width: 100%; +} +.dashboard-info h5 { + font-size: 11px; + font-weight: bold; +} +.dashboard-block { + background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 76%); + border-radius: 3px; + box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset; + margin-bottom: 20px; +} +.dashboard-block .dashboard-block-head { + background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border-bottom: 1px solid hsl(0, 0%, 76%); + border-radius: 3px 3px 0 0; + box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset, 0 0 3px hsl(0, 0%, 87%); + height: 40px; + position: relative; +} +.dashboard-block .dashboard-block-head h5 { + font-size: 12px; + margin: 0; + padding-left: 10px; + padding-top: 11px; + text-transform: uppercase; +} +.dashboard-block .dashboard-block-content { + background: none repeat scroll 0 0 hsl(0, 0%, 93%); + border-radius: 0 0 3px 3px; +} +.dashboard-block .dashboard-block-box { + background: none repeat scroll 0 0 hsl(0, 0%, 100%); + border-top: 1px solid hsl(0, 0%, 82%); + box-shadow: 0 0 5px hsl(0, 0%, 87%) inset; +} +.dashboard-block .dashboard-block-content .dashboard-block-box { + margin-top: 0 !important; +} +.dashboard-block .dashboard-block-content .dashboard-block-box .dashboard-block-table { + margin-bottom: 0 !important; +} +.dashboard-block-table { + background-color: hsla(0, 0%, 0%, 0); + border-collapse: collapse; + border-spacing: 0; + margin-bottom: 20px; + max-width: 100%; + width: 100%; +} +.dashboard-block-table th, .dashboard-block-table td { + border-top: 1px solid hsl(0, 0%, 87%); + line-height: 20px; + padding: 5px; + text-align: left; + vertical-align: middle; +} +.dashboard-badge { + background-color: hsl(0, 0%, 60%); + border-radius: 9px; + color: hsl(0, 0%, 100%); + font-size: 11.844px; + font-weight: bold; + line-height: 14px; + padding: 1px 9px 2px; + text-shadow: 0 -1px 0 hsla(0, 0%, 0%, 0.25); + vertical-align: baseline; + white-space: nowrap; } \ No newline at end of file diff --git a/admin/assets/css/greeting.css b/admin/assets/css/greeting.css index fba7b34..05bd8e8 100644 --- a/admin/assets/css/greeting.css +++ b/admin/assets/css/greeting.css @@ -1,22 +1,22 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage greeting.css - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -/* CSS Document */ - - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greeting.css + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/greetings.css b/admin/assets/css/greetings.css index e873ad8..71a85ef 100644 --- a/admin/assets/css/greetings.css +++ b/admin/assets/css/greetings.css @@ -1,22 +1,22 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage greetings.css - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -/* CSS Document */ - - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greetings.css + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/js/admin.js b/admin/assets/js/admin.js index 6c1456d..39fec1c 100644 --- a/admin/assets/js/admin.js +++ b/admin/assets/js/admin.js @@ -1,20 +1,20 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage admin.js - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage admin.js + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + /------------------------------------------------------------------------------------------------------*/ /* JS Document */ diff --git a/admin/config.xml b/admin/config.xml index 484c8bd..1496b10 100644 --- a/admin/config.xml +++ b/admin/config.xml @@ -1,5 +1,5 @@ - - + +
COM_HELLO_WORLD_CONFIG_GRADIANT_LOAD" -
-
- -
+ +
+ +
\ No newline at end of file diff --git a/admin/controller.php b/admin/controller.php index e6c5b15..bc1fd43 100644 --- a/admin/controller.php +++ b/admin/controller.php @@ -1,121 +1,121 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * General Controller of Hello_world component - */ -class Hello_worldController extends JControllerLegacy -{ - /** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * Recognized key values include 'name', 'default_task', 'model_path', and - * 'view_path' (this list is not meant to be comprehensive). - * - * @since 3.0 - */ - public function __construct($config = array()) - { - // set the default view - $config['default_view'] = 'hello_world'; - - parent::__construct($config); - } - - /** - * display task - * - * @return void - */ - function display($cachable = false, $urlparams = false) - { - // set default view if not set - $view = $this->input->getCmd('view', 'hello_world'); - $data = $this->getViewRelation($view); - $layout = $this->input->get('layout', null, 'WORD'); - $id = $this->input->getInt('id'); - - // Check for edit form. - if(Hello_worldHelper::checkArray($data)) - { - if ($data['edit'] && $layout == 'edit' && !$this->checkEditId('com_hello_world.edit.'.$data['view'], $id)) - { - // Somehow the person just went to the form - we don't allow that. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); - $this->setMessage($this->getError(), 'error'); - // check if item was opend from other then its own list view - $ref = $this->input->getCmd('ref', 0); - $refid = $this->input->getInt('refid', 0); - // set redirect - if ($refid > 0 && Hello_worldHelper::checkString($ref)) - { - // redirect to item of ref - $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); - } - elseif (Hello_worldHelper::checkString($ref)) - { - - // redirect to ref - $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view='.(string)$ref, false)); - } - else - { - // normal redirect back to the list view - $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view='.$data['views'], false)); - } - - return false; - } - } - - return parent::display($cachable, $urlparams); - } - - protected function getViewRelation($view) - { - // check the we have a value - if (Hello_worldHelper::checkString($view)) - { - // the view relationships +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage controller.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * General Controller of Hello_world component + */ +class Hello_worldController extends JControllerLegacy +{ + /** + * Constructor. + * + * @param array $config An optional associative array of configuration settings. + * Recognized key values include 'name', 'default_task', 'model_path', and + * 'view_path' (this list is not meant to be comprehensive). + * + * @since 3.0 + */ + public function __construct($config = array()) + { + // set the default view + $config['default_view'] = 'hello_world'; + + parent::__construct($config); + } + + /** + * display task + * + * @return void + */ + function display($cachable = false, $urlparams = false) + { + // set default view if not set + $view = $this->input->getCmd('view', 'hello_world'); + $data = $this->getViewRelation($view); + $layout = $this->input->get('layout', null, 'WORD'); + $id = $this->input->getInt('id'); + + // Check for edit form. + if(Hello_worldHelper::checkArray($data)) + { + if ($data['edit'] && $layout == 'edit' && !$this->checkEditId('com_hello_world.edit.'.$data['view'], $id)) + { + // Somehow the person just went to the form - we don't allow that. + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); + $this->setMessage($this->getError(), 'error'); + // check if item was opend from other then its own list view + $ref = $this->input->getCmd('ref', 0); + $refid = $this->input->getInt('refid', 0); + // set redirect + if ($refid > 0 && Hello_worldHelper::checkString($ref)) + { + // redirect to item of ref + $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); + } + elseif (Hello_worldHelper::checkString($ref)) + { + + // redirect to ref + $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view='.(string)$ref, false)); + } + else + { + // normal redirect back to the list view + $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view='.$data['views'], false)); + } + + return false; + } + } + + return parent::display($cachable, $urlparams); + } + + protected function getViewRelation($view) + { + // check the we have a value + if (Hello_worldHelper::checkString($view)) + { + // the view relationships $views = array( - 'greeting' => 'greetings' - ); - // check if this is a list view - if (in_array($view, $views)) - { - // this is a list view - return array('edit' => false, 'view' => array_search($view,$views), 'views' => $view); - } - // check if it is an edit view - elseif (array_key_exists($view, $views)) - { - // this is a edit view - return array('edit' => true, 'view' => $view, 'views' => $views[$view]); - } - } - return false; - } -} + 'greeting' => 'greetings' + ); + // check if this is a list view + if (in_array($view, $views)) + { + // this is a list view + return array('edit' => false, 'view' => array_search($view,$views), 'views' => $view); + } + // check if it is an edit view + elseif (array_key_exists($view, $views)) + { + // this is a edit view + return array('edit' => true, 'view' => $view, 'views' => $views[$view]); + } + } + return false; + } +} diff --git a/admin/controllers/greeting.php b/admin/controllers/greeting.php index e202cb1..c7c8d25 100644 --- a/admin/controllers/greeting.php +++ b/admin/controllers/greeting.php @@ -1,65 +1,65 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Greeting Controller - */ -class Hello_worldControllerGreeting extends JControllerForm -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Greetings'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greeting.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Greeting Controller + */ +class Hello_worldControllerGreeting extends JControllerForm +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Greetings'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) { // Get user object. $user = JFactory::getUser(); @@ -71,20 +71,20 @@ class Hello_worldControllerGreeting extends JControllerForm } // In the absense of better information, revert to the component permissions. - return parent::allowAdd($data); - } - - /** - * 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 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') + return parent::allowAdd($data); + } + + /** + * 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 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') { // get user object. $user = JFactory::getUser(); @@ -127,199 +127,199 @@ class Hello_worldControllerGreeting extends JControllerForm } } // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Greeting', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view=greetings' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) + return parent::allowEdit($data, $key); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - return; - } - -} + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Greeting', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view=greetings' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/greetings.php b/admin/controllers/greetings.php index ad1b8f8..db04dd2 100644 --- a/admin/controllers/greetings.php +++ b/admin/controllers/greetings.php @@ -1,55 +1,55 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Greetings Controller - */ -class Hello_worldControllerGreetings extends JControllerAdmin -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_HELLO_WORLD_GREETINGS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Greeting', $prefix = 'Hello_worldModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greetings.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Greetings Controller + */ +class Hello_worldControllerGreetings extends JControllerAdmin +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_HELLO_WORLD_GREETINGS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Greeting', $prefix = 'Hello_worldModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); } public function exportData() @@ -113,5 +113,5 @@ class Hello_worldControllerGreetings extends JControllerAdmin $message = JText::_('COM_HELLO_WORLD_IMPORT_FAILED'); $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view=greetings', false), $message, 'error'); return; - } -} + } +} diff --git a/admin/controllers/hello_world.php b/admin/controllers/hello_world.php index 4301083..3746be1 100644 --- a/admin/controllers/hello_world.php +++ b/admin/controllers/hello_world.php @@ -1,30 +1,32 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Hello_world Controller - */ -class Hello_worldControllerHello_world extends JControllerAdmin -{ - -} +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage hello_world.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + + + +/** + * Hello_world Controller + */ +class Hello_worldControllerHello_world extends JControllerAdmin +{ + +} diff --git a/admin/controllers/import.php b/admin/controllers/import.php index 71d3bb8..4f5fe89 100644 --- a/admin/controllers/import.php +++ b/admin/controllers/import.php @@ -1,64 +1,64 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Hello_world Import Controller - */ -class Hello_worldControllerImport extends JControllerLegacy -{ - /** - * Import an spreadsheet. - * - * @return void - */ - public function import() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - $model = $this->getModel('import'); - if ($model->import()) - { - $cache = JFactory::getCache('mod_menu'); - $cache->clean(); - // TODO: Reset the users acl here as well to kill off any missing bits - } - - $app = JFactory::getApplication(); - $redirect_url = $app->getUserState('com_hello_world.redirect_url'); - if (empty($redirect_url)) - { - $redirect_url = JRoute::_('index.php?option=com_hello_world&view=import', false); - } - else - { - // wipe out the user state when we're going to redirect - $app->setUserState('com_hello_world.redirect_url', ''); - $app->setUserState('com_hello_world.message', ''); - $app->setUserState('com_hello_world.extension_message', ''); - } - $this->setRedirect($redirect_url); - } -} +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage import.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Hello_world Import Controller + */ +class Hello_worldControllerImport extends JControllerLegacy +{ + /** + * Import an spreadsheet. + * + * @return void + */ + public function import() + { + // Check for request forgeries + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + $model = $this->getModel('import'); + if ($model->import()) + { + $cache = JFactory::getCache('mod_menu'); + $cache->clean(); + // TODO: Reset the users acl here as well to kill off any missing bits + } + + $app = JFactory::getApplication(); + $redirect_url = $app->getUserState('com_hello_world.redirect_url'); + if (empty($redirect_url)) + { + $redirect_url = JRoute::_('index.php?option=com_hello_world&view=import', false); + } + else + { + // wipe out the user state when we're going to redirect + $app->setUserState('com_hello_world.redirect_url', ''); + $app->setUserState('com_hello_world.message', ''); + $app->setUserState('com_hello_world.extension_message', ''); + } + $this->setRedirect($redirect_url); + } +} diff --git a/admin/hello_world.php b/admin/hello_world.php index 2a3c6cd..da79c27 100644 --- a/admin/hello_world.php +++ b/admin/hello_world.php @@ -1,48 +1,48 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.tabstate'); - -// Access check. -if (!JFactory::getUser()->authorise('core.manage', 'com_hello_world')) -{ - throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); -}; - -// Add CSS file for all pages -$document = JFactory::getDocument(); -$document->addStyleSheet('components/com_hello_world/assets/css/admin.css'); -$document->addScript('components/com_hello_world/assets/js/admin.js'); - -// require helper files -JLoader::register('Hello_worldHelper', __DIR__ . '/helpers/hello_world.php'); -JLoader::register('JHtmlBatch_', __DIR__ . '/helpers/html/batch_.php'); - -// Get an instance of the controller prefixed by Hello_world -$controller = JControllerLegacy::getInstance('Hello_world'); - -// Perform the Request task -$controller->execute(JFactory::getApplication()->input->get('task')); - -// Redirect if set by the controller -$controller->redirect(); +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage hello_world.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + + + +// Access check. +if (!JFactory::getUser()->authorise('core.manage', 'com_hello_world')) +{ + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); +}; + +// Add CSS file for all pages +$document = JFactory::getDocument(); +$document->addStyleSheet('components/com_hello_world/assets/css/admin.css'); +$document->addScript('components/com_hello_world/assets/js/admin.js'); + +// require helper files +JLoader::register('Hello_worldHelper', __DIR__ . '/helpers/hello_world.php'); +JLoader::register('JHtmlBatch_', __DIR__ . '/helpers/html/batch_.php'); + +// Get an instance of the controller prefixed by Hello_world +$controller = JControllerLegacy::getInstance('Hello_world'); + +// Perform the Request task +$controller->execute(JFactory::getApplication()->input->get('task')); + +// Redirect if set by the controller +$controller->redirect(); diff --git a/admin/helpers/headercheck.php b/admin/helpers/headercheck.php index f352a15..5cab117 100644 --- a/admin/helpers/headercheck.php +++ b/admin/helpers/headercheck.php @@ -1,80 +1,80 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -class hello_worldHeaderCheck -{ - function js_loaded($script_name) - { - // UIkit check point - if (strpos($script_name,'uikit') !== false) - { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - - if (strpos($getTemplateName,'yoo') !== false) - { - return true; - } - } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); - foreach (array_keys($head_data['scripts']) as $script) - { - if (stristr($script, $script_name)) - { - return true; - } - } - - return false; - } - - function css_loaded($script_name) - { - // UIkit check point - if (strpos($script_name,'uikit') !== false) - { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - - if (strpos($getTemplateName,'yoo') !== false) - { - return true; - } - } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); - - foreach (array_keys($head_data['styleSheets']) as $script) - { - if (stristr($script, $script_name)) - { - return true; - } - } - - return false; - } +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage headercheck.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +class hello_worldHeaderCheck +{ + function js_loaded($script_name) + { + // UIkit check point + if (strpos($script_name,'uikit') !== false) + { + $app = JFactory::getApplication(); + $getTemplateName = $app->getTemplate('template')->template; + + if (strpos($getTemplateName,'yoo') !== false) + { + return true; + } + } + + $document = JFactory::getDocument(); + $head_data = $document->getHeadData(); + foreach (array_keys($head_data['scripts']) as $script) + { + if (stristr($script, $script_name)) + { + return true; + } + } + + return false; + } + + function css_loaded($script_name) + { + // UIkit check point + if (strpos($script_name,'uikit') !== false) + { + $app = JFactory::getApplication(); + $getTemplateName = $app->getTemplate('template')->template; + + if (strpos($getTemplateName,'yoo') !== false) + { + return true; + } + } + + $document = JFactory::getDocument(); + $head_data = $document->getHeadData(); + + foreach (array_keys($head_data['styleSheets']) as $script) + { + if (stristr($script, $script_name)) + { + return true; + } + } + + return false; + } } \ No newline at end of file diff --git a/admin/helpers/hello_world.php b/admin/helpers/hello_world.php index 60ef45b..05d43c7 100644 --- a/admin/helpers/hello_world.php +++ b/admin/helpers/hello_world.php @@ -1,51 +1,53 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage hello_world.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + use Joomla\CMS\Language\Language; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Spreadsheet; -use PhpOffice\PhpSpreadsheet\Writer\Xlsx; - -/** - * Hello_world component helper. - */ -abstract class Hello_worldHelper -{ - /** - * Composer Switch - * - * @var array - */ - protected static $composer = array(); - - /** - * The Main Active Language - * - * @var string - */ +use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; + +/** + * Hello_world component helper. + */ +abstract class Hello_worldHelper +{ + /** + * Composer Switch + * + * @var array + */ + protected static $composer = array(); + + /** + * The Main Active Language + * + * @var string + */ public static $langTag; @@ -146,7 +148,7 @@ abstract class Hello_worldHelper */ public static function removeFolder($dir, $ignore = false) { - if (JFolder::exists($dir)) + if (Folder::exists($dir)) { $it = new RecursiveDirectoryIterator($dir); $it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); @@ -176,7 +178,7 @@ abstract class Hello_worldHelper { continue; } - JFolder::delete($file_dir); + Folder::delete($file_dir); } else { @@ -195,103 +197,103 @@ abstract class Hello_worldHelper { continue; } - JFile::delete($file_dir); + File::delete($file_dir); } } // delete the root folder if not ignore found if (!self::checkArray($ignore)) { - return JFolder::delete($dir); + return Folder::delete($dir); } return true; } return false; } - - - /** - * Load the Composer Vendors - */ - public static function composerAutoload($target) - { - // insure we load the composer vendor only once - if (!isset(self::$composer[$target])) - { - // get the function name - $functionName = self::safeString('compose' . $target); - // check if method exist - if (method_exists(__CLASS__, $functionName)) - { - return self::{$functionName}(); - } - return false; - } - return self::$composer[$target]; - } - - /** - * Load the Component xml manifest. - */ - public static function manifest() - { - $manifestUrl = JPATH_ADMINISTRATOR."/components/com_hello_world/hello_world.xml"; - return simplexml_load_file($manifestUrl); - } - - /** - * Joomla version object - */ - protected static $JVersion; - - /** - * set/get Joomla version - */ - public static function jVersion() - { - // check if set - if (!self::checkObject(self::$JVersion)) - { - self::$JVersion = new JVersion(); - } - return self::$JVersion; - } - - /** - * Load the Contributors details. - */ - public static function getContributors() - { - // get params - $params = JComponentHelper::getParams('com_hello_world'); - // start contributors array - $contributors = array(); - // get all Contributors (max 20) - $searchArray = range('0','20'); - foreach($searchArray as $nr) - { - if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3)) - { - // set link based of selected option - if($params->get("useContributor".$nr) == 1) - { - $link_front = ''; - $link_back = ''; - } - elseif($params->get("useContributor".$nr) == 2) - { - $link_front = ''; - $link_back = ''; - } - else - { - $link_front = ''; - $link_back = ''; - } - $contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr)); - $contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back; - } - } - return $contributors; + + + /** + * Load the Composer Vendors + */ + public static function composerAutoload($target) + { + // insure we load the composer vendor only once + if (!isset(self::$composer[$target])) + { + // get the function name + $functionName = self::safeString('compose' . $target); + // check if method exist + if (method_exists(__CLASS__, $functionName)) + { + return self::{$functionName}(); + } + return false; + } + return self::$composer[$target]; + } + + /** + * Load the Component xml manifest. + */ + public static function manifest() + { + $manifestUrl = JPATH_ADMINISTRATOR."/components/com_hello_world/hello_world.xml"; + return simplexml_load_file($manifestUrl); + } + + /** + * Joomla version object + */ + protected static $JVersion; + + /** + * set/get Joomla version + */ + public static function jVersion() + { + // check if set + if (!self::checkObject(self::$JVersion)) + { + self::$JVersion = new JVersion(); + } + return self::$JVersion; + } + + /** + * Load the Contributors details. + */ + public static function getContributors() + { + // get params + $params = JComponentHelper::getParams('com_hello_world'); + // start contributors array + $contributors = array(); + // get all Contributors (max 20) + $searchArray = range('0','20'); + foreach($searchArray as $nr) + { + if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3)) + { + // set link based of selected option + if($params->get("useContributor".$nr) == 1) + { + $link_front = ''; + $link_back = ''; + } + elseif($params->get("useContributor".$nr) == 2) + { + $link_front = ''; + $link_back = ''; + } + else + { + $link_front = ''; + $link_back = ''; + } + $contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr)); + $contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back; + } + } + return $contributors; } /** @@ -300,16 +302,16 @@ abstract class Hello_worldHelper public static function getHelpUrl($view) { return false; - } - - /** - * Configure the Linkbar. - */ - public static function addSubmenu($submenu) - { - // load user for access menus - $user = JFactory::getUser(); - // load the submenus to sidebar + } + + /** + * Configure the Linkbar. + */ + public static function addSubmenu($submenu) + { + // load user for access menus + $user = JFactory::getUser(); + // load the submenus to sidebar JHtmlSidebar::addEntry(JText::_('COM_HELLO_WORLD_SUBMENU_DASHBOARD'), 'index.php?option=com_hello_world&view=hello_world', $submenu === 'hello_world'); if ($user->authorise('greeting.access', 'com_hello_world') && $user->authorise('greeting.submenu', 'com_hello_world')) { @@ -319,7 +321,7 @@ abstract class Hello_worldHelper { JHtmlSidebar::addEntry(JText::_('COM_HELLO_WORLD_SUBMENU_GREETINGS_FIELDS'), 'index.php?option=com_fields&context=com_hello_world.greeting', $submenu === 'fields.fields'); JHtmlSidebar::addEntry(JText::_('COM_HELLO_WORLD_SUBMENU_GREETINGS_FIELDS_GROUPS'), 'index.php?option=com_fields&view=groups&context=com_hello_world.greeting', $submenu === 'fields.groups'); - } + } } /** @@ -427,7 +429,7 @@ abstract class Hello_worldHelper /** * Prepares the xml document */ - public static function xls($rows, $fileName = null, $title = null, $subjectTab = null, $creator = 'Joomla Component Builder', $description = null, $category = null,$keywords = null, $modified = null) + public static function xls($rows, $fileName = null, $title = null, $subjectTab = null, $creator = 'VDM', $description = null, $category = null,$keywords = null, $modified = null) { // set the user $user = JFactory::getUser(); @@ -461,7 +463,7 @@ abstract class Hello_worldHelper // Set document properties $spreadsheet->getProperties() ->setCreator($creator) - ->setCompany('Joomla Component Builder') + ->setCompany('VDM') ->setLastModifiedBy($modified) ->setTitle($title) ->setSubject($subjectTab); @@ -641,1210 +643,1210 @@ abstract class Hello_worldHelper self::$composer['phpspreadsheet'] = true; return true; - } - - /** - * Get a Variable - * - * @param string $table The table from which to get the variable - * @param string $where The value where - * @param string $whereString The target/field string where/name - * @param string $what The return field - * @param string $operator The operator between $whereString/field and $where/value - * @param string $main The component in which the table is found - * - * @return mix string/int/float - * - */ - public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'hello_world') - { - if(!$where) - { - $where = JFactory::getUser()->id; - } - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array($what))); - if (empty($table)) - { - $query->from($db->quoteName('#__'.$main)); - } - else - { - $query->from($db->quoteName('#__'.$main.'_'.$table)); - } - if (is_numeric($where)) - { - $query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where); - } - elseif (is_string($where)) - { - $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where)); - } - else - { - return false; - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - return $db->loadResult(); - } - return false; - } - - /** - * Get array of variables - * - * @param string $table The table from which to get the variables - * @param string $where The value where - * @param string $whereString The target/field string where/name - * @param string $what The return field - * @param string $operator The operator between $whereString/field and $where/value - * @param string $main The component in which the table is found - * @param bool $unique The switch to return a unique array - * - * @return array - * - */ - public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'hello_world', $unique = true) - { - if(!$where) - { - $where = JFactory::getUser()->id; - } - - if (!self::checkArray($where) && $where > 0) - { - $where = array($where); - } - - if (self::checkArray($where)) - { - // prep main <-- why? well if $main='' is empty then $table can be categories or users - if (self::checkString($main)) - { - $main = '_'.ltrim($main, '_'); - } - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - - $query->select($db->quoteName(array($what))); - if (empty($table)) - { - $query->from($db->quoteName('#__'.$main)); - } - else - { - $query->from($db->quoteName('#_'.$main.'_'.$table)); - } - // add strings to array search - if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) - { - $query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")'); - } - else - { - $query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')'); - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - if ($unique) - { - return array_unique($db->loadColumn()); - } - return $db->loadColumn(); - } - } - return false; - } - - public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name') - { - // do some table foot work - $external = false; - if (strpos($table, '#__') !== false) - { - $external = true; - $table = str_replace('#__', '', $table); - } - // check if string is JSON - $result = json_decode($value, true); - if (json_last_error() === JSON_ERROR_NONE) - { - // is JSON - if (self::checkArray($result)) - { - if (self::checkString($table)) - { - $names = array(); - foreach ($result as $val) - { - if ($external) - { - if ($_name = self::getVar(null, $val, $id, $name, '=', $table)) - { - $names[] = $_name; - } - } - else - { - if ($_name = self::getVar($table, $val, $id, $name)) - { - $names[] = $_name; - } - } - } - if (self::checkArray($names)) - { - return (string) implode($sperator,$names); - } - } - return (string) implode($sperator,$result); - } - return (string) json_decode($value); - } - return $value; - } - - public static function isPublished($id,$type) - { - if ($type == 'raw') - { - $type = 'item'; - } - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.published')); - $query->from('#__hello_world_'.$type.' AS a'); - $query->where('a.id = '. (int) $id); - $query->where('a.published = 1'); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return true; - } - return false; - } - - public static function getGroupName($id) - { - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - $query->select(array('a.title')); - $query->from('#__usergroups AS a'); - $query->where('a.id = '. (int) $id); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return $db->loadResult(); - } - return $id; - } - - /** - * Get the action permissions - * - * @param string $view The related view name - * @param int $record The item to act upon - * @param string $views The related list view name - * @param mixed $target Only get this permission (like edit, create, delete) - * @param string $component The target component - * @param object $user The user whose permissions we are loading - * - * @return object The JObject of permission/authorised actions - * - */ - public static function getActions($view, &$record = null, $views = null, $target = null, $component = 'hello_world', $user = 'null') - { - // load the user if not given - if (!self::checkObject($user)) - { - // get the user object - $user = JFactory::getUser(); - } - // load the JObject - $result = new JObject; - // make view name safe (just incase) - $view = self::safeString($view); - if (self::checkString($views)) - { - $views = self::safeString($views); - } - // get all actions from component - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', - "/access/section[@name='component']/" - ); - // if non found then return empty JObject - if (empty($actions)) - { - return $result; - } - // get created by if not found - if (self::checkObject($record) && !isset($record->created_by) && isset($record->id)) - { - $record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component); - } - // set actions only set in component settings - $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); - // check if we have a target - $checkTarget = false; - if ($target) - { - // convert to an array - if (self::checkString($target)) - { - $target = array($target); - } - // check if we are good to go - if (self::checkArray($target)) - { - $checkTarget = true; - } - } - // loop the actions and set the permissions - foreach ($actions as $action) - { - // check target action filter - if ($checkTarget && self::filterActions($view, $action->name, $target)) - { - continue; - } - // set to use component default - $fallback = true; - // reset permission per/action - $permission = false; - $catpermission = false; - // set area - $area = 'comp'; - // check if the record has an ID and the action is item related (not a component action) - if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && - (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) - { - // we are in item - $area = 'item'; - // The record has been set. Check the record permissions. - $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); - // if no permission found, check edit own - if (!$permission) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // the correct target - $coreCheck = (array) explode('.', $action->name); - // check that we have both local and global access - if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && - $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0) - { - // we are in item - $area = 'category'; - // set the core check - $coreCheck = explode('.', $action->name); - $core = $coreCheck[0]; - // make sure we use the core. action check for the categories - if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) - { - $coreCheck[0] = 'core'; - $categoryCheck = implode('.', $coreCheck); - } - else - { - $categoryCheck = $action->name; - } - // The record has a category. Check the category permissions. - $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); - if (!$catpermission && !is_null($catpermission)) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // check that we have both local and global access - if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && - $user->authorise($core . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - } - } - // if allowed then fallback on component global settings - if ($fallback) - { - // if item/category blocks access then don't fall back on global - if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) - { - // do not allow - $result->set($action->name, false); - } - // Finally remember the global settings have the final say. (even if item allow) - // The local item permissions can block, but it can't open and override of global permissions. - // Since items are created by users and global permissions is set by system admin. - else - { - $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); - } - } - } - return $result; - } - - /** - * Filter the action permissions - * - * @param string $action The action to check - * @param array $targets The array of target actions - * - * @return boolean true if action should be filtered out - * - */ - protected static function filterActions(&$view, &$action, &$targets) - { - foreach ($targets as $target) - { - if (strpos($action, $view . '.' . $target) !== false || - strpos($action, 'core.' . $target) !== false) - { - return false; - break; - } - } - return true; - } - - /** - * Get any component's model - */ - public static function getModel($name, $path = JPATH_COMPONENT_ADMINISTRATOR, $Component = 'Hello_world', $config = array()) - { - // fix the name - $name = self::safeString($name); - // full path to models - $fullPathModels = $path . '/models'; - // load the model file - JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); - // make sure the table path is loaded - if (!isset($config['table_path']) || !self::checkString($config['table_path'])) - { - // This is the JCB default path to tables in Joomla 3.x - $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; - } - // get instance - $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); - // if model not found (strange) - if ($model == false) - { - jimport('joomla.filesystem.file'); - // get file path - $filePath = $path . '/' . $name . '.php'; - $fullPathModel = $fullPathModels . '/' . $name . '.php'; - // check if it exists - if (JFile::exists($filePath)) - { - // get the file - require_once $filePath; - } - elseif (JFile::exists($fullPathModel)) - { - // get the file - require_once $fullPathModel; - } - // build class names - $modelClass = $Component . 'Model' . $name; - if (class_exists($modelClass)) - { - // initialize the model - return new $modelClass($config); - } - } - return $model; - } - - /** - * Add to asset Table - */ - public static function setAsset($id, $table, $inherit = true) - { - $parent = JTable::getInstance('Asset'); - $parent->loadByName('com_hello_world'); - - $parentId = $parent->id; - $name = 'com_hello_world.'.$table.'.'.$id; - $title = ''; - - $asset = JTable::getInstance('Asset'); - $asset->loadByName($name); - - // Check for an error. - $error = $asset->getError(); - - if ($error) - { - return false; - } - else - { - // Specify how a new or moved node asset is inserted into the tree. - if ($asset->parent_id != $parentId) - { - $asset->setLocation($parentId, 'last-child'); - } - - // Prepare the asset to be stored. - $asset->parent_id = $parentId; - $asset->name = $name; - $asset->title = $title; - // get the default asset rules - $rules = self::getDefaultAssetRules('com_hello_world', $table, $inherit); - if ($rules instanceof JAccessRules) - { - $asset->rules = (string) $rules; - } - - if (!$asset->check() || !$asset->store()) - { - JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); - return false; - } - else - { - // Create an asset_id or heal one that is corrupted. - $object = new stdClass(); - - // Must be a valid primary key value. - $object->id = $id; - $object->asset_id = (int) $asset->id; - - // Update their asset_id to link to the asset table. - return JFactory::getDbo()->updateObject('#__hello_world_'.$table, $object, 'id'); - } - } - return false; - } - - /** - * Gets the default asset Rules for a component/view. - */ - protected static function getDefaultAssetRules($component, $view, $inherit = true) - { - // if new or inherited - $assetId = 0; - // Only get the actual item rules if not inheriting - if (!$inherit) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - // check that there is a value - if ($db->getNumRows()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - } - } - // get asset rules - $result = JAccess::getAssetRules($assetId); - if ($result instanceof JAccessRules) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($view !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - elseif ($inherit) - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count((array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules($_result); - // return filtered rules - return $rules; - } - } - return $result; - } - - /** - * xmlAppend - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement - * - * @return null - * - */ - public static function xmlAppend(&$xml, $node) - { - if (!$node) - { - // element was not returned - return; - } - switch (get_class($node)) - { - case 'stdClass': - if (property_exists($node, 'comment')) - { - self::xmlComment($xml, $node->comment); - } - if (property_exists($node, 'fieldXML')) - { - self::xmlAppend($xml, $node->fieldXML); - } - break; - case 'SimpleXMLElement': - $domXML = dom_import_simplexml($xml); - $domNode = dom_import_simplexml($node); - $domXML->appendChild($domXML->ownerDocument->importNode($domNode, true)); - $xml = simplexml_import_dom($domXML); - break; - } - } - - /** - * xmlComment - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param string $comment The comment to inject - * - * @return null - * - */ - public static function xmlComment(&$xml, $comment) - { - $domXML = dom_import_simplexml($xml); - $domComment = new DOMComment($comment); - $nodeTarget = $domXML->ownerDocument->importNode($domComment, true); - $domXML->appendChild($nodeTarget); - $xml = simplexml_import_dom($domXML); - } - - /** - * xmlAddAttributes - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $attributes The attributes to apply to the XML element - * - * @return null - * - */ - public static function xmlAddAttributes(&$xml, $attributes = array()) - { - foreach ($attributes as $key => $value) - { - $xml->addAttribute($key, $value); - } - } - - /** - * xmlAddOptions - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $options The options to apply to the XML element - * - * @return void - * - */ - public static function xmlAddOptions(&$xml, $options = array()) - { - foreach ($options as $key => $value) - { - $addOption = $xml->addChild('option'); - $addOption->addAttribute('value', $key); - $addOption[] = $value; - } - } - - /** - * get the field object - * - * @param array $attributes The array of attributes - * @param string $default The default of the field - * @param array $options The options to apply to the XML element - * - * @return object - * - */ - public static function getFieldObject(&$attributes, $default = '', $options = null) - { - // make sure we have attributes and a type value - if (self::checkArray($attributes) && isset($attributes['type'])) - { - // make sure the form helper class is loaded - if (!method_exists('JFormHelper', 'loadFieldType')) - { - jimport('joomla.form.form'); - } - // get field type - $field = JFormHelper::loadFieldType($attributes['type'], true); - // get field xml - $XML = self::getFieldXML($attributes, $options); - // setup the field - $field->setup($XML, $default); - // return the field object - return $field; - } - return false; - } - - /** - * get the field xml - * - * @param array $attributes The array of attributes - * @param array $options The options to apply to the XML element - * - * @return object - * - */ - public static function getFieldXML(&$attributes, $options = null) - { - // make sure we have attributes and a type value - if (self::checkArray($attributes)) - { - // start field xml - $XML = new SimpleXMLElement(''); - // load the attributes - self::xmlAddAttributes($XML, $attributes); - // check if we have options - if (self::checkArray($options)) - { - // load the options - self::xmlAddOptions($XML, $options); - } - // return the field xml - return $XML; - } - return false; - } - - /** - * Render Bool Button - * - * @param array $args All the args for the button - * 0) name - * 1) additional (options class) // not used at this time - * 2) default - * 3) yes (name) - * 4) no (name) - * - * @return string The input html of the button - * - */ - public static function renderBoolButton() - { - $args = func_get_args(); - // check if there is additional button class - $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time - // button attributes - $buttonAttributes = array( - 'type' => 'radio', - 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button', - 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway - 'class' => 'btn-group', - 'filter' => 'INT', - 'default' => isset($args[2]) ? (int) $args[2] : 0); - // set the button options - $buttonOptions = array( - '1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES', - '0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'); - // return the input - return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; - } - - /** - * Check if have an json string - * - * @input string The json string to check - * - * @returns bool true on success - */ - public static function checkJson($string) - { - if (self::checkString($string)) - { - json_decode($string); - return (json_last_error() === JSON_ERROR_NONE); - } - return false; - } - - /** - * Check if have an object with a length - * - * @input object The object to check - * - * @returns bool true on success - */ - public static function checkObject($object) - { - if (isset($object) && is_object($object)) - { - return count((array)$object) > 0; - } - return false; - } - - /** - * Check if have an array with a length - * - * @input array The array to check - * - * @returns bool/int number of items in array on success - */ - public static function checkArray($array, $removeEmptyString = false) - { - if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) - { - // also make sure the empty strings are removed - if ($removeEmptyString) - { - foreach ($array as $key => $string) - { - if (empty($string)) - { - unset($array[$key]); - } - } - return self::checkArray($array, false); - } - return $nr; - } - return false; - } - - /** - * Check if have a string with a length - * - * @input string The string to check - * - * @returns bool true on success - */ - public static function checkString($string) - { - if (isset($string) && is_string($string) && strlen($string) > 0) - { - return true; - } - return false; - } - - /** - * Check if we are connected - * Thanks https://stackoverflow.com/a/4860432/1429677 - * - * @returns bool true on success - */ - public static function isConnected() - { - // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? - $connected = @fsockopen("www.example.com", 80); - // website, port (try 80 or 443) - if ($connected) - { - //action when connected - $is_conn = true; - fclose($connected); - } - else - { - //action in connection failure - $is_conn = false; - } - return $is_conn; - } - - /** - * Merge an array of array's - * - * @input array The arrays you would like to merge - * - * @returns array on success - */ - public static function mergeArrays($arrays) - { - if(self::checkArray($arrays)) - { - $arrayBuket = array(); - foreach ($arrays as $array) - { - if (self::checkArray($array)) - { - $arrayBuket = array_merge($arrayBuket, $array); - } - } - return $arrayBuket; - } - return false; - } - - // typo sorry! - public static function sorten($string, $length = 40, $addTip = true) - { - return self::shorten($string, $length, $addTip); - } - - /** - * Shorten a string - * - * @input string The you would like to shorten - * - * @returns string on success - */ - public static function shorten($string, $length = 40, $addTip = true) - { - if (self::checkString($string)) - { - $initial = strlen($string); - $words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); - $words_count = count((array)$words); - - $word_length = 0; - $last_word = 0; - for (; $last_word < $words_count; ++$last_word) - { - $word_length += strlen($words[$last_word]); - if ($word_length > $length) - { - break; - } - } - - $newString = implode(array_slice($words, 0, $last_word)); - $final = strlen($newString); - if ($initial != $final && $addTip) - { - $title = self::shorten($string, 400 , false); - return ''.trim($newString).'...'; - } - elseif ($initial != $final && !$addTip) - { - return trim($newString).'...'; - } - } - return $string; - } - - /** - * Making strings safe (various ways) - * - * @input string The you would like to make safe - * - * @returns string on success - */ - public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) - { - if ($replaceNumbers === true) - { - // remove all numbers and replace with english text version (works well only up to millions) - $string = self::replaceNumbers($string); - } - // 0nly continue if we have a string - if (self::checkString($string)) - { - // create file name without the extention that is safe - if ($type === 'filename') - { - // make sure VDM is not in the string - $string = str_replace('VDM', 'vDm', $string); - // Remove anything which isn't a word, whitespace, number - // or any of the following caracters -_() - // If you don't need to handle multi-byte characters - // you can use preg_replace rather than mb_ereg_replace - // Thanks @Łukasz Rysiak! - // $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string); - $string = preg_replace("([^\w\s\d\-_\(\)])", '', $string); - // http://stackoverflow.com/a/2021729/1429677 - return preg_replace('/\s+/', ' ', $string); - } - // remove all other characters - $string = trim($string); - $string = preg_replace('/'.$spacer.'+/', ' ', $string); - $string = preg_replace('/\s+/', ' ', $string); - // Transliterate string - $string = self::transliterate($string); - // remove all and keep only characters - if ($keepOnlyCharacters) - { - $string = preg_replace("/[^A-Za-z ]/", '', $string); - } - // keep both numbers and characters - else - { - $string = preg_replace("/[^A-Za-z0-9 ]/", '', $string); - } - // select final adaptations - if ($type === 'L' || $type === 'strtolower') - { - // replace white space with underscore - $string = preg_replace('/\s+/', $spacer, $string); - // default is to return lower - return strtolower($string); - } - elseif ($type === 'W') - { - // return a string with all first letter of each word uppercase(no undersocre) - return ucwords(strtolower($string)); - } - elseif ($type === 'w' || $type === 'word') - { - // return a string with all lowercase(no undersocre) - return strtolower($string); - } - elseif ($type === 'Ww' || $type === 'Word') - { - // return a string with first letter of the first word uppercase and all the rest lowercase(no undersocre) - return ucfirst(strtolower($string)); - } - elseif ($type === 'WW' || $type === 'WORD') - { - // return a string with all the uppercase(no undersocre) - return strtoupper($string); - } - elseif ($type === 'U' || $type === 'strtoupper') - { - // replace white space with underscore - $string = preg_replace('/\s+/', $spacer, $string); - // return all upper - return strtoupper($string); - } - elseif ($type === 'F' || $type === 'ucfirst') - { - // replace white space with underscore - $string = preg_replace('/\s+/', $spacer, $string); - // return with first caracter to upper - return ucfirst(strtolower($string)); - } - elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase') - { - // convert all words to first letter uppercase - $string = ucwords(strtolower($string)); - // remove white space - $string = preg_replace('/\s+/', '', $string); - // now return first letter lowercase - return lcfirst($string); - } - // return string - return $string; - } - // not a string - return ''; - } - - public static function transliterate($string) - { - // set tag only once - if (!self::checkString(self::$langTag)) - { - // get global value - self::$langTag = JComponentHelper::getParams('com_hello_world')->get('language', 'en-GB'); - } - // Transliterate on the language requested - $lang = Language::getInstance(self::$langTag); - return $lang->transliterate($string); - } - - public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40) - { - if (self::checkString($var)) - { - $filter = new JFilterInput(); - $string = $filter->clean(html_entity_decode(htmlentities($var, ENT_COMPAT, $charset)), 'HTML'); - if ($shorten) - { - return self::shorten($string,$length); - } - return $string; - } - else - { - return ''; - } - } - - public static function replaceNumbers($string) - { - // set numbers array - $numbers = array(); - // first get all numbers - preg_match_all('!\d+!', $string, $numbers); - // check if we have any numbers - if (isset($numbers[0]) && self::checkArray($numbers[0])) - { - foreach ($numbers[0] as $number) - { - $searchReplace[$number] = self::numberToString((int)$number); - } - // now replace numbers in string - $string = str_replace(array_keys($searchReplace), array_values($searchReplace),$string); - // check if we missed any, strange if we did. - return self::replaceNumbers($string); - } - // return the string with no numbers remaining. - return $string; - } - - /** - * Convert an integer into an English word string - * Thanks to Tom Nicholson - * - * @input an int - * @returns a string - */ - public static function numberToString($x) - { - $nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven", - "eight", "nine", "ten", "eleven", "twelve", "thirteen", - "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", - "nineteen", "twenty", 30 => "thirty", 40 => "forty", - 50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty", - 90 => "ninety" ); - - if(!is_numeric($x)) - { - $w = $x; - } - elseif(fmod($x, 1) != 0) - { - $w = $x; - } - else - { - if($x < 0) - { - $w = 'minus '; - $x = -$x; - } - else - { - $w = ''; - // ... now $x is a non-negative integer. - } - - if($x < 21) // 0 to 20 - { - $w .= $nwords[$x]; - } - elseif($x < 100) // 21 to 99 - { - $w .= $nwords[10 * floor($x/10)]; - $r = fmod($x, 10); - if($r > 0) - { - $w .= ' '. $nwords[$r]; - } - } - elseif($x < 1000) // 100 to 999 - { - $w .= $nwords[floor($x/100)] .' hundred'; - $r = fmod($x, 100); - if($r > 0) - { - $w .= ' and '. self::numberToString($r); - } - } - elseif($x < 1000000) // 1000 to 999999 - { - $w .= self::numberToString(floor($x/1000)) .' thousand'; - $r = fmod($x, 1000); - if($r > 0) - { - $w .= ' '; - if($r < 100) - { - $w .= 'and '; - } - $w .= self::numberToString($r); - } - } - else // millions - { - $w .= self::numberToString(floor($x/1000000)) .' million'; - $r = fmod($x, 1000000); - if($r > 0) - { - $w .= ' '; - if($r < 100) - { - $w .= 'and '; - } - $w .= self::numberToString($r); - } - } - } - return $w; - } - - /** - * Random Key - * - * @returns a string - */ - public static function randomkey($size) - { - $bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ"; - $key = array(); - $bagsize = strlen($bag) - 1; - for ($i = 0; $i < $size; $i++) - { - $get = rand(0, $bagsize); - $key[] = $bag[$get]; - } - return implode($key); - } -} + } + + /** + * Get a Variable + * + * @param string $table The table from which to get the variable + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * + * @return mix string/int/float + * + */ + public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'hello_world') + { + if(!$where) + { + $where = JFactory::getUser()->id; + } + // Get a db connection. + $db = JFactory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array($what))); + if (empty($table)) + { + $query->from($db->quoteName('#__'.$main)); + } + else + { + $query->from($db->quoteName('#__'.$main.'_'.$table)); + } + if (is_numeric($where)) + { + $query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where); + } + elseif (is_string($where)) + { + $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where)); + } + else + { + return false; + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + return $db->loadResult(); + } + return false; + } + + /** + * Get array of variables + * + * @param string $table The table from which to get the variables + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * @param bool $unique The switch to return a unique array + * + * @return array + * + */ + public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'hello_world', $unique = true) + { + if(!$where) + { + $where = JFactory::getUser()->id; + } + + if (!self::checkArray($where) && $where > 0) + { + $where = array($where); + } + + if (self::checkArray($where)) + { + // prep main <-- why? well if $main='' is empty then $table can be categories or users + if (self::checkString($main)) + { + $main = '_'.ltrim($main, '_'); + } + // Get a db connection. + $db = JFactory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + + $query->select($db->quoteName(array($what))); + if (empty($table)) + { + $query->from($db->quoteName('#__'.$main)); + } + else + { + $query->from($db->quoteName('#_'.$main.'_'.$table)); + } + // add strings to array search + if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) + { + $query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")'); + } + else + { + $query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')'); + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + if ($unique) + { + return array_unique($db->loadColumn()); + } + return $db->loadColumn(); + } + } + return false; + } + + public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name') + { + // do some table foot work + $external = false; + if (strpos($table, '#__') !== false) + { + $external = true; + $table = str_replace('#__', '', $table); + } + // check if string is JSON + $result = json_decode($value, true); + if (json_last_error() === JSON_ERROR_NONE) + { + // is JSON + if (self::checkArray($result)) + { + if (self::checkString($table)) + { + $names = array(); + foreach ($result as $val) + { + if ($external) + { + if ($_name = self::getVar(null, $val, $id, $name, '=', $table)) + { + $names[] = $_name; + } + } + else + { + if ($_name = self::getVar($table, $val, $id, $name)) + { + $names[] = $_name; + } + } + } + if (self::checkArray($names)) + { + return (string) implode($sperator,$names); + } + } + return (string) implode($sperator,$result); + } + return (string) json_decode($value); + } + return $value; + } + + public static function isPublished($id,$type) + { + if ($type == 'raw') + { + $type = 'item'; + } + $db = JFactory::getDbo(); + $query = $db->getQuery(true); + $query->select(array('a.published')); + $query->from('#__hello_world_'.$type.' AS a'); + $query->where('a.id = '. (int) $id); + $query->where('a.published = 1'); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return true; + } + return false; + } + + public static function getGroupName($id) + { + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select(array('a.title')); + $query->from('#__usergroups AS a'); + $query->where('a.id = '. (int) $id); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return $db->loadResult(); + } + return $id; + } + + /** + * Get the action permissions + * + * @param string $view The related view name + * @param int $record The item to act upon + * @param string $views The related list view name + * @param mixed $target Only get this permission (like edit, create, delete) + * @param string $component The target component + * @param object $user The user whose permissions we are loading + * + * @return object The JObject of permission/authorised actions + * + */ + public static function getActions($view, &$record = null, $views = null, $target = null, $component = 'hello_world', $user = 'null') + { + // load the user if not given + if (!self::checkObject($user)) + { + // get the user object + $user = JFactory::getUser(); + } + // load the JObject + $result = new JObject; + // make view name safe (just incase) + $view = self::safeString($view); + if (self::checkString($views)) + { + $views = self::safeString($views); + } + // get all actions from component + $actions = JAccess::getActionsFromFile( + JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', + "/access/section[@name='component']/" + ); + // if non found then return empty JObject + if (empty($actions)) + { + return $result; + } + // get created by if not found + if (self::checkObject($record) && !isset($record->created_by) && isset($record->id)) + { + $record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component); + } + // set actions only set in component settings + $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); + // check if we have a target + $checkTarget = false; + if ($target) + { + // convert to an array + if (self::checkString($target)) + { + $target = array($target); + } + // check if we are good to go + if (self::checkArray($target)) + { + $checkTarget = true; + } + } + // loop the actions and set the permissions + foreach ($actions as $action) + { + // check target action filter + if ($checkTarget && self::filterActions($view, $action->name, $target)) + { + continue; + } + // set to use component default + $fallback = true; + // reset permission per/action + $permission = false; + $catpermission = false; + // set area + $area = 'comp'; + // check if the record has an ID and the action is item related (not a component action) + if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && + (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) + { + // we are in item + $area = 'item'; + // The record has been set. Check the record permissions. + $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); + // if no permission found, check edit own + if (!$permission) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // the correct target + $coreCheck = (array) explode('.', $action->name); + // check that we have both local and global access + if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && + $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0) + { + // we are in item + $area = 'category'; + // set the core check + $coreCheck = explode('.', $action->name); + $core = $coreCheck[0]; + // make sure we use the core. action check for the categories + if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) + { + $coreCheck[0] = 'core'; + $categoryCheck = implode('.', $coreCheck); + } + else + { + $categoryCheck = $action->name; + } + // The record has a category. Check the category permissions. + $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); + if (!$catpermission && !is_null($catpermission)) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // check that we have both local and global access + if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && + $user->authorise($core . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + } + } + // if allowed then fallback on component global settings + if ($fallback) + { + // if item/category blocks access then don't fall back on global + if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) + { + // do not allow + $result->set($action->name, false); + } + // Finally remember the global settings have the final say. (even if item allow) + // The local item permissions can block, but it can't open and override of global permissions. + // Since items are created by users and global permissions is set by system admin. + else + { + $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); + } + } + } + return $result; + } + + /** + * Filter the action permissions + * + * @param string $action The action to check + * @param array $targets The array of target actions + * + * @return boolean true if action should be filtered out + * + */ + protected static function filterActions(&$view, &$action, &$targets) + { + foreach ($targets as $target) + { + if (strpos($action, $view . '.' . $target) !== false || + strpos($action, 'core.' . $target) !== false) + { + return false; + break; + } + } + return true; + } + + /** + * Get any component's model + */ + public static function getModel($name, $path = JPATH_COMPONENT_ADMINISTRATOR, $Component = 'Hello_world', $config = array()) + { + // fix the name + $name = self::safeString($name); + // full path to models + $fullPathModels = $path . '/models'; + // load the model file + JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); + // make sure the table path is loaded + if (!isset($config['table_path']) || !self::checkString($config['table_path'])) + { + // This is the JCB default path to tables in Joomla 3.x + $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; + } + // get instance + $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); + // if model not found (strange) + if ($model == false) + { + jimport('joomla.filesystem.file'); + // get file path + $filePath = $path . '/' . $name . '.php'; + $fullPathModel = $fullPathModels . '/' . $name . '.php'; + // check if it exists + if (File::exists($filePath)) + { + // get the file + require_once $filePath; + } + elseif (File::exists($fullPathModel)) + { + // get the file + require_once $fullPathModel; + } + // build class names + $modelClass = $Component . 'Model' . $name; + if (class_exists($modelClass)) + { + // initialize the model + return new $modelClass($config); + } + } + return $model; + } + + /** + * Add to asset Table + */ + public static function setAsset($id, $table, $inherit = true) + { + $parent = JTable::getInstance('Asset'); + $parent->loadByName('com_hello_world'); + + $parentId = $parent->id; + $name = 'com_hello_world.'.$table.'.'.$id; + $title = ''; + + $asset = JTable::getInstance('Asset'); + $asset->loadByName($name); + + // Check for an error. + $error = $asset->getError(); + + if ($error) + { + return false; + } + else + { + // Specify how a new or moved node asset is inserted into the tree. + if ($asset->parent_id != $parentId) + { + $asset->setLocation($parentId, 'last-child'); + } + + // Prepare the asset to be stored. + $asset->parent_id = $parentId; + $asset->name = $name; + $asset->title = $title; + // get the default asset rules + $rules = self::getDefaultAssetRules('com_hello_world', $table, $inherit); + if ($rules instanceof JAccessRules) + { + $asset->rules = (string) $rules; + } + + if (!$asset->check() || !$asset->store()) + { + JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); + return false; + } + else + { + // Create an asset_id or heal one that is corrupted. + $object = new stdClass(); + + // Must be a valid primary key value. + $object->id = $id; + $object->asset_id = (int) $asset->id; + + // Update their asset_id to link to the asset table. + return JFactory::getDbo()->updateObject('#__hello_world_'.$table, $object, 'id'); + } + } + return false; + } + + /** + * Gets the default asset Rules for a component/view. + */ + protected static function getDefaultAssetRules($component, $view, $inherit = true) + { + // if new or inherited + $assetId = 0; + // Only get the actual item rules if not inheriting + if (!$inherit) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + // check that there is a value + if ($db->getNumRows()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + } + } + // get asset rules + $result = JAccess::getAssetRules($assetId); + if ($result instanceof JAccessRules) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($view !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + elseif ($inherit) + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count((array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules($_result); + // return filtered rules + return $rules; + } + } + return $result; + } + + /** + * xmlAppend + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement + * + * @return null + * + */ + public static function xmlAppend(&$xml, $node) + { + if (!$node) + { + // element was not returned + return; + } + switch (get_class($node)) + { + case 'stdClass': + if (property_exists($node, 'comment')) + { + self::xmlComment($xml, $node->comment); + } + if (property_exists($node, 'fieldXML')) + { + self::xmlAppend($xml, $node->fieldXML); + } + break; + case 'SimpleXMLElement': + $domXML = dom_import_simplexml($xml); + $domNode = dom_import_simplexml($node); + $domXML->appendChild($domXML->ownerDocument->importNode($domNode, true)); + $xml = simplexml_import_dom($domXML); + break; + } + } + + /** + * xmlComment + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param string $comment The comment to inject + * + * @return null + * + */ + public static function xmlComment(&$xml, $comment) + { + $domXML = dom_import_simplexml($xml); + $domComment = new DOMComment($comment); + $nodeTarget = $domXML->ownerDocument->importNode($domComment, true); + $domXML->appendChild($nodeTarget); + $xml = simplexml_import_dom($domXML); + } + + /** + * xmlAddAttributes + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $attributes The attributes to apply to the XML element + * + * @return null + * + */ + public static function xmlAddAttributes(&$xml, $attributes = array()) + { + foreach ($attributes as $key => $value) + { + $xml->addAttribute($key, $value); + } + } + + /** + * xmlAddOptions + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $options The options to apply to the XML element + * + * @return void + * + */ + public static function xmlAddOptions(&$xml, $options = array()) + { + foreach ($options as $key => $value) + { + $addOption = $xml->addChild('option'); + $addOption->addAttribute('value', $key); + $addOption[] = $value; + } + } + + /** + * get the field object + * + * @param array $attributes The array of attributes + * @param string $default The default of the field + * @param array $options The options to apply to the XML element + * + * @return object + * + */ + public static function getFieldObject(&$attributes, $default = '', $options = null) + { + // make sure we have attributes and a type value + if (self::checkArray($attributes) && isset($attributes['type'])) + { + // make sure the form helper class is loaded + if (!method_exists('JFormHelper', 'loadFieldType')) + { + jimport('joomla.form.form'); + } + // get field type + $field = JFormHelper::loadFieldType($attributes['type'], true); + // get field xml + $XML = self::getFieldXML($attributes, $options); + // setup the field + $field->setup($XML, $default); + // return the field object + return $field; + } + return false; + } + + /** + * get the field xml + * + * @param array $attributes The array of attributes + * @param array $options The options to apply to the XML element + * + * @return object + * + */ + public static function getFieldXML(&$attributes, $options = null) + { + // make sure we have attributes and a type value + if (self::checkArray($attributes)) + { + // start field xml + $XML = new SimpleXMLElement(''); + // load the attributes + self::xmlAddAttributes($XML, $attributes); + // check if we have options + if (self::checkArray($options)) + { + // load the options + self::xmlAddOptions($XML, $options); + } + // return the field xml + return $XML; + } + return false; + } + + /** + * Render Bool Button + * + * @param array $args All the args for the button + * 0) name + * 1) additional (options class) // not used at this time + * 2) default + * 3) yes (name) + * 4) no (name) + * + * @return string The input html of the button + * + */ + public static function renderBoolButton() + { + $args = func_get_args(); + // check if there is additional button class + $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time + // button attributes + $buttonAttributes = array( + 'type' => 'radio', + 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button', + 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway + 'class' => 'btn-group', + 'filter' => 'INT', + 'default' => isset($args[2]) ? (int) $args[2] : 0); + // set the button options + $buttonOptions = array( + '1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES', + '0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'); + // return the input + return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; + } + + /** + * Check if have an json string + * + * @input string The json string to check + * + * @returns bool true on success + */ + public static function checkJson($string) + { + if (self::checkString($string)) + { + json_decode($string); + return (json_last_error() === JSON_ERROR_NONE); + } + return false; + } + + /** + * Check if have an object with a length + * + * @input object The object to check + * + * @returns bool true on success + */ + public static function checkObject($object) + { + if (isset($object) && is_object($object)) + { + return count((array)$object) > 0; + } + return false; + } + + /** + * Check if have an array with a length + * + * @input array The array to check + * + * @returns bool/int number of items in array on success + */ + public static function checkArray($array, $removeEmptyString = false) + { + if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) + { + // also make sure the empty strings are removed + if ($removeEmptyString) + { + foreach ($array as $key => $string) + { + if (empty($string)) + { + unset($array[$key]); + } + } + return self::checkArray($array, false); + } + return $nr; + } + return false; + } + + /** + * Check if have a string with a length + * + * @input string The string to check + * + * @returns bool true on success + */ + public static function checkString($string) + { + if (isset($string) && is_string($string) && strlen($string) > 0) + { + return true; + } + return false; + } + + /** + * Check if we are connected + * Thanks https://stackoverflow.com/a/4860432/1429677 + * + * @returns bool true on success + */ + public static function isConnected() + { + // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? + $connected = @fsockopen("www.example.com", 80); + // website, port (try 80 or 443) + if ($connected) + { + //action when connected + $is_conn = true; + fclose($connected); + } + else + { + //action in connection failure + $is_conn = false; + } + return $is_conn; + } + + /** + * Merge an array of array's + * + * @input array The arrays you would like to merge + * + * @returns array on success + */ + public static function mergeArrays($arrays) + { + if(self::checkArray($arrays)) + { + $arrayBuket = array(); + foreach ($arrays as $array) + { + if (self::checkArray($array)) + { + $arrayBuket = array_merge($arrayBuket, $array); + } + } + return $arrayBuket; + } + return false; + } + + // typo sorry! + public static function sorten($string, $length = 40, $addTip = true) + { + return self::shorten($string, $length, $addTip); + } + + /** + * Shorten a string + * + * @input string The you would like to shorten + * + * @returns string on success + */ + public static function shorten($string, $length = 40, $addTip = true) + { + if (self::checkString($string)) + { + $initial = strlen($string); + $words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); + $words_count = count((array)$words); + + $word_length = 0; + $last_word = 0; + for (; $last_word < $words_count; ++$last_word) + { + $word_length += strlen($words[$last_word]); + if ($word_length > $length) + { + break; + } + } + + $newString = implode(array_slice($words, 0, $last_word)); + $final = strlen($newString); + if ($initial != $final && $addTip) + { + $title = self::shorten($string, 400 , false); + return ''.trim($newString).'...'; + } + elseif ($initial != $final && !$addTip) + { + return trim($newString).'...'; + } + } + return $string; + } + + /** + * Making strings safe (various ways) + * + * @input string The you would like to make safe + * + * @returns string on success + */ + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) + { + if ($replaceNumbers === true) + { + // remove all numbers and replace with english text version (works well only up to millions) + $string = self::replaceNumbers($string); + } + // 0nly continue if we have a string + if (self::checkString($string)) + { + // create file name without the extention that is safe + if ($type === 'filename') + { + // make sure VDM is not in the string + $string = str_replace('VDM', 'vDm', $string); + // Remove anything which isn't a word, whitespace, number + // or any of the following caracters -_() + // If you don't need to handle multi-byte characters + // you can use preg_replace rather than mb_ereg_replace + // Thanks @Łukasz Rysiak! + // $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string); + $string = preg_replace("([^\w\s\d\-_\(\)])", '', $string); + // http://stackoverflow.com/a/2021729/1429677 + return preg_replace('/\s+/', ' ', $string); + } + // remove all other characters + $string = trim($string); + $string = preg_replace('/'.$spacer.'+/', ' ', $string); + $string = preg_replace('/\s+/', ' ', $string); + // Transliterate string + $string = self::transliterate($string); + // remove all and keep only characters + if ($keepOnlyCharacters) + { + $string = preg_replace("/[^A-Za-z ]/", '', $string); + } + // keep both numbers and characters + else + { + $string = preg_replace("/[^A-Za-z0-9 ]/", '', $string); + } + // select final adaptations + if ($type === 'L' || $type === 'strtolower') + { + // replace white space with underscore + $string = preg_replace('/\s+/', $spacer, $string); + // default is to return lower + return strtolower($string); + } + elseif ($type === 'W') + { + // return a string with all first letter of each word uppercase(no undersocre) + return ucwords(strtolower($string)); + } + elseif ($type === 'w' || $type === 'word') + { + // return a string with all lowercase(no undersocre) + return strtolower($string); + } + elseif ($type === 'Ww' || $type === 'Word') + { + // return a string with first letter of the first word uppercase and all the rest lowercase(no undersocre) + return ucfirst(strtolower($string)); + } + elseif ($type === 'WW' || $type === 'WORD') + { + // return a string with all the uppercase(no undersocre) + return strtoupper($string); + } + elseif ($type === 'U' || $type === 'strtoupper') + { + // replace white space with underscore + $string = preg_replace('/\s+/', $spacer, $string); + // return all upper + return strtoupper($string); + } + elseif ($type === 'F' || $type === 'ucfirst') + { + // replace white space with underscore + $string = preg_replace('/\s+/', $spacer, $string); + // return with first caracter to upper + return ucfirst(strtolower($string)); + } + elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase') + { + // convert all words to first letter uppercase + $string = ucwords(strtolower($string)); + // remove white space + $string = preg_replace('/\s+/', '', $string); + // now return first letter lowercase + return lcfirst($string); + } + // return string + return $string; + } + // not a string + return ''; + } + + public static function transliterate($string) + { + // set tag only once + if (!self::checkString(self::$langTag)) + { + // get global value + self::$langTag = JComponentHelper::getParams('com_hello_world')->get('language', 'en-GB'); + } + // Transliterate on the language requested + $lang = Language::getInstance(self::$langTag); + return $lang->transliterate($string); + } + + public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40) + { + if (self::checkString($var)) + { + $filter = new JFilterInput(); + $string = $filter->clean(html_entity_decode(htmlentities($var, ENT_COMPAT, $charset)), 'HTML'); + if ($shorten) + { + return self::shorten($string,$length); + } + return $string; + } + else + { + return ''; + } + } + + public static function replaceNumbers($string) + { + // set numbers array + $numbers = array(); + // first get all numbers + preg_match_all('!\d+!', $string, $numbers); + // check if we have any numbers + if (isset($numbers[0]) && self::checkArray($numbers[0])) + { + foreach ($numbers[0] as $number) + { + $searchReplace[$number] = self::numberToString((int)$number); + } + // now replace numbers in string + $string = str_replace(array_keys($searchReplace), array_values($searchReplace),$string); + // check if we missed any, strange if we did. + return self::replaceNumbers($string); + } + // return the string with no numbers remaining. + return $string; + } + + /** + * Convert an integer into an English word string + * Thanks to Tom Nicholson + * + * @input an int + * @returns a string + */ + public static function numberToString($x) + { + $nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven", + "eight", "nine", "ten", "eleven", "twelve", "thirteen", + "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", + "nineteen", "twenty", 30 => "thirty", 40 => "forty", + 50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty", + 90 => "ninety" ); + + if(!is_numeric($x)) + { + $w = $x; + } + elseif(fmod($x, 1) != 0) + { + $w = $x; + } + else + { + if($x < 0) + { + $w = 'minus '; + $x = -$x; + } + else + { + $w = ''; + // ... now $x is a non-negative integer. + } + + if($x < 21) // 0 to 20 + { + $w .= $nwords[$x]; + } + elseif($x < 100) // 21 to 99 + { + $w .= $nwords[10 * floor($x/10)]; + $r = fmod($x, 10); + if($r > 0) + { + $w .= ' '. $nwords[$r]; + } + } + elseif($x < 1000) // 100 to 999 + { + $w .= $nwords[floor($x/100)] .' hundred'; + $r = fmod($x, 100); + if($r > 0) + { + $w .= ' and '. self::numberToString($r); + } + } + elseif($x < 1000000) // 1000 to 999999 + { + $w .= self::numberToString(floor($x/1000)) .' thousand'; + $r = fmod($x, 1000); + if($r > 0) + { + $w .= ' '; + if($r < 100) + { + $w .= 'and '; + } + $w .= self::numberToString($r); + } + } + else // millions + { + $w .= self::numberToString(floor($x/1000000)) .' million'; + $r = fmod($x, 1000000); + if($r > 0) + { + $w .= ' '; + if($r < 100) + { + $w .= 'and '; + } + $w .= self::numberToString($r); + } + } + } + return $w; + } + + /** + * Random Key + * + * @returns a string + */ + public static function randomkey($size) + { + $bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ"; + $key = array(); + $bagsize = strlen($bag) - 1; + for ($i = 0; $i < $size; $i++) + { + $get = rand(0, $bagsize); + $key[] = $bag[$get]; + } + return implode($key); + } +} diff --git a/admin/helpers/html/batch_.php b/admin/helpers/html/batch_.php index 4b6b213..8e55b7e 100644 --- a/admin/helpers/html/batch_.php +++ b/admin/helpers/html/batch_.php @@ -1,87 +1,87 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('JPATH_PLATFORM') or die; - -/** - * Utility class to render a list view batch selection options - * - * @since 3.0 - */ -abstract class JHtmlBatch_ -{ - /** - * ListSelection - * - * @var array - * @since 3.0 - */ - protected static $ListSelection = array(); - - /** - * Render the batch selection options. - * - * @return string The necessary HTML to display the batch selection options - * - * @since 3.0 - */ - public static function render() - { - // Collect display data - $data = new stdClass; - $data->ListSelection = static::getListSelection(); - - // Create a layout object and ask it to render the batch selection options - $layout = new JLayoutFile('batchselection'); - $batchHtml = $layout->render($data); - - return $batchHtml; - } - - /** - * Method to add a list selection to the batch modal - * - * @param string $label Label for the menu item. - * @param string $name Name for the filter. Also used as id. - * @param string $options Options for the select field. - * @param bool $noDefault Don't the label as the empty option - * - * @return void - * - * @since 3.0 - */ - public static function addListSelection($label, $name, $options, $noDefault = false) - { - array_push(static::$ListSelection, array('label' => $label, 'name' => $name, 'options' => $options, 'noDefault' => $noDefault)); - } - - /** - * Returns an array of all ListSelection - * - * @return array - * - * @since 3.0 - */ - public static function getListSelection() - { - return static::$ListSelection; - } -} +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage batch_.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('JPATH_PLATFORM') or die; + +/** + * Utility class to render a list view batch selection options + * + * @since 3.0 + */ +abstract class JHtmlBatch_ +{ + /** + * ListSelection + * + * @var array + * @since 3.0 + */ + protected static $ListSelection = array(); + + /** + * Render the batch selection options. + * + * @return string The necessary HTML to display the batch selection options + * + * @since 3.0 + */ + public static function render() + { + // Collect display data + $data = new stdClass; + $data->ListSelection = static::getListSelection(); + + // Create a layout object and ask it to render the batch selection options + $layout = new JLayoutFile('batchselection'); + $batchHtml = $layout->render($data); + + return $batchHtml; + } + + /** + * Method to add a list selection to the batch modal + * + * @param string $label Label for the menu item. + * @param string $name Name for the filter. Also used as id. + * @param string $options Options for the select field. + * @param bool $noDefault Don't the label as the empty option + * + * @return void + * + * @since 3.0 + */ + public static function addListSelection($label, $name, $options, $noDefault = false) + { + array_push(static::$ListSelection, array('label' => $label, 'name' => $name, 'options' => $options, 'noDefault' => $noDefault)); + } + + /** + * Returns an array of all ListSelection + * + * @return array + * + * @since 3.0 + */ + public static function getListSelection() + { + return static::$ListSelection; + } +} diff --git a/admin/language/en-GB/en-GB.com_hello_world.ini b/admin/language/en-GB/en-GB.com_hello_world.ini index 55a4181..efffd30 100644 --- a/admin/language/en-GB/en-GB.com_hello_world.ini +++ b/admin/language/en-GB/en-GB.com_hello_world.ini @@ -114,7 +114,6 @@ COM_HELLO_WORLD_GREETING_CREATED_DATE_LABEL="Created Date" COM_HELLO_WORLD_GREETING_DETAILS="Details" COM_HELLO_WORLD_GREETING_EDIT="Editing the Greeting" COM_HELLO_WORLD_GREETING_ERROR_UNIQUE_ALIAS="Another Greeting has the same alias." -COM_HELLO_WORLD_GREETING_GREETING="Greeting" COM_HELLO_WORLD_GREETING_GREETING_DESCRIPTION="Enter a greeting" COM_HELLO_WORLD_GREETING_GREETING_HINT="Greeting here!" COM_HELLO_WORLD_GREETING_GREETING_LABEL="Greeting" diff --git a/admin/layouts/batchselection.php b/admin/layouts/batchselection.php index 08575b9..95ff167 100644 --- a/admin/layouts/batchselection.php +++ b/admin/layouts/batchselection.php @@ -1,57 +1,57 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('JPATH_BASE') or die; - -JHtmlBehavior::core(); -$divWrapper = range(1,120,2); -$counter = 0; -?> -ListSelection) : ?> -
- ListSelection as $ListSelection) : ?> -
-
- - -
-
- -
-
- - - -
-
-
- - -
-
+/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage batchselection.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('JPATH_BASE') or die; + +JHtmlBehavior::core(); +$divWrapper = range(1,120,2); +$counter = 0; +?> +ListSelection) : ?> +
+ ListSelection as $ListSelection) : ?> +
+
+ + +
+
+ +
+
+ + + +
+
+
+ + +
+
\ No newline at end of file diff --git a/admin/layouts/greeting/details_left.php b/admin/layouts/greeting/details_left.php index 49f2333..1033f06 100644 --- a/admin/layouts/greeting/details_left.php +++ b/admin/layouts/greeting/details_left.php @@ -1,51 +1,51 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( - 'greeting' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage details_left.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'greeting' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/greeting/metadata.php b/admin/layouts/greeting/metadata.php index 1af483a..cf7d1ee 100644 --- a/admin/layouts/greeting/metadata.php +++ b/admin/layouts/greeting/metadata.php @@ -1,50 +1,50 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$form = $displayData->getForm(); - -// JLayout for standard handling of metadata fields in the administrator content edit screens. -$fieldSets = $form->getFieldsets('metadata'); -?> - - $fieldSet) : ?> - description) && trim($fieldSet->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(); - } - } ?> - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage metadata.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$form = $displayData->getForm(); + +// JLayout for standard handling of metadata fields in the administrator content edit screens. +$fieldSets = $form->getFieldsets('metadata'); +?> + + $fieldSet) : ?> + description) && trim($fieldSet->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/greeting/publishing.php b/admin/layouts/greeting/publishing.php index e3d12cf..382da4d 100644 --- a/admin/layouts/greeting/publishing.php +++ b/admin/layouts/greeting/publishing.php @@ -1,40 +1,40 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage publishing.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( 'title', 'created', 'created_by', @@ -45,17 +45,17 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'access', 'version', 'hits', - 'id' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/trashhelper.php b/admin/layouts/trashhelper.php index 24056ba..d6cfe58 100644 --- a/admin/layouts/trashhelper.php +++ b/admin/layouts/trashhelper.php @@ -1,28 +1,28 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage trashhelper.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file defined('JPATH_BASE') or die('Restricted access'); - - + + ?> state->get('filter.published') == -2 && ($displayData->canState && $displayData->canDelete)) : ?> - + + + diff --git a/admin/views/greeting/view.html.php b/admin/views/greeting/view.html.php index cce7791..a8af7ed 100644 --- a/admin/views/greeting/view.html.php +++ b/admin/views/greeting/view.html.php @@ -1,92 +1,92 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Greeting View class - */ -class Hello_worldViewGreeting extends JViewLegacy -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_hello_world'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = Hello_worldHelper::getActions('greeting', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage view.html.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Greeting View class + */ +class Hello_worldViewGreeting extends JViewLegacy +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_hello_world'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = Hello_worldHelper::getActions('greeting', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $userId = $user->id; @@ -158,47 +158,47 @@ class Hello_worldViewGreeting extends JViewLegacy } JToolbarHelper::divider(); // set help url for this view if found - $help_url = Hello_worldHelper::getHelpUrl('greeting'); - if (Hello_worldHelper::checkString($help_url)) + $this->help_url = Hello_worldHelper::getHelpUrl('greeting'); + if (Hello_worldHelper::checkString($this->help_url)) { - JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return Hello_worldHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return Hello_worldHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_HELLO_WORLD_GREETING_NEW' : 'COM_HELLO_WORLD_GREETING_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_hello_world/assets/css/greeting.css", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_hello_world/views/greeting/submitbutton.js", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} + JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return Hello_worldHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return Hello_worldHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_HELLO_WORLD_GREETING_NEW' : 'COM_HELLO_WORLD_GREETING_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_hello_world/assets/css/greeting.css", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_hello_world/views/greeting/submitbutton.js", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/greetings/tmpl/default.php b/admin/views/greetings/tmpl/default.php index 7dbd55d..5acc35c 100644 --- a/admin/views/greetings/tmpl/default.php +++ b/admin/views/greetings/tmpl/default.php @@ -1,37 +1,36 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.tooltip'); +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage default.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + JHtml::_('behavior.multiselect'); JHtml::_('dropdown.init'); JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_HELLO_WORLD_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_hello_world&task=greetings.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'greetingList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_hello_world&task=greetings.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'greetingList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?>
sidebar)): ?>
@@ -74,4 +73,4 @@ if ($this->saveOrder) - + diff --git a/admin/views/greetings/tmpl/default_batch_body.php b/admin/views/greetings/tmpl/default_batch_body.php index bed8564..52b8493 100644 --- a/admin/views/greetings/tmpl/default_batch_body.php +++ b/admin/views/greetings/tmpl/default_batch_body.php @@ -1,27 +1,27 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

+/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage default_batch_body.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/greetings/tmpl/default_batch_footer.php b/admin/views/greetings/tmpl/default_batch_footer.php index d23075e..84d1965 100644 --- a/admin/views/greetings/tmpl/default_batch_footer.php +++ b/admin/views/greetings/tmpl/default_batch_footer.php @@ -1,32 +1,32 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - + + \ No newline at end of file diff --git a/admin/views/greetings/tmpl/default_body.php b/admin/views/greetings/tmpl/default_body.php index 6bc2aea..493bdd7 100644 --- a/admin/views/greetings/tmpl/default_body.php +++ b/admin/views/greetings/tmpl/default_body.php @@ -1,29 +1,29 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_hello_world&view=greetings&task=greeting.edit"; - -?> +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage default_body.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_hello_world&view=greetings&task=greeting.edit"; + +?> items as $i => $item): ?> user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; diff --git a/admin/views/greetings/tmpl/default_foot.php b/admin/views/greetings/tmpl/default_foot.php index e18f179..303a515 100644 --- a/admin/views/greetings/tmpl/default_foot.php +++ b/admin/views/greetings/tmpl/default_foot.php @@ -1,27 +1,27 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage default_foot.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> \ No newline at end of file diff --git a/admin/views/greetings/tmpl/default_head.php b/admin/views/greetings/tmpl/default_head.php index 3eb4b0c..8d655dd 100644 --- a/admin/views/greetings/tmpl/default_head.php +++ b/admin/views/greetings/tmpl/default_head.php @@ -1,27 +1,27 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage default_head.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> canEdit&& $this->canState): ?> diff --git a/admin/views/greetings/tmpl/default_toolbar.php b/admin/views/greetings/tmpl/default_toolbar.php index 8613219..ddee64b 100644 --- a/admin/views/greetings/tmpl/default_toolbar.php +++ b/admin/views/greetings/tmpl/default_toolbar.php @@ -1,54 +1,54 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
- -
- - -
-
- - pagination->getLimitBox(); ?> -
-
- - -
-
- - -
-
+/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage default_toolbar.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
\ No newline at end of file diff --git a/admin/views/greetings/view.html.php b/admin/views/greetings/view.html.php index 68abbeb..9f20988 100644 --- a/admin/views/greetings/view.html.php +++ b/admin/views/greetings/view.html.php @@ -1,47 +1,47 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Hello_world View class for the Greetings - */ -class Hello_worldViewGreetings extends JViewLegacy -{ - /** - * Greetings view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - Hello_worldHelper::addSubmenu('greetings'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage view.html.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Hello_world View class for the Greetings + */ +class Hello_worldViewGreetings extends JViewLegacy +{ + /** + * Greetings view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + Hello_worldHelper::addSubmenu('greetings'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); $this->user = JFactory::getUser(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); @@ -49,122 +49,122 @@ class Hello_worldViewGreetings extends JViewLegacy $this->activeFilters = $this->get('ActiveFilters'); // Add the list ordering clause. $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions $this->canDo = Hello_worldHelper::getActions('greeting'); $this->canEdit = $this->canDo->get('core.edit'); $this->canState = $this->canDo->get('core.edit.state'); $this->canCreate = $this->canDo->get('core.create'); $this->canDelete = $this->canDo->get('core.delete'); - $this->canBatch = $this->canDo->get('core.batch'); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_HELLO_WORLD_GREETINGS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_hello_world&view=greetings'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('greeting.add'); - } - - // Only load if there are items - if (Hello_worldHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('greeting.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('greetings.publish'); - JToolBarHelper::unpublishList('greetings.unpublish'); - JToolBarHelper::archiveList('greetings.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('greetings.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'greetings.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('greetings.trash'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_HELLO_WORLD_GREETINGS'), 'joomla'); + JHtmlSidebar::setAction('index.php?option=com_hello_world&view=greetings'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('greeting.add'); + } + + // Only load if there are items + if (Hello_worldHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('greeting.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('greetings.publish'); + JToolBarHelper::unpublishList('greetings.unpublish'); + JToolBarHelper::archiveList('greetings.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('greetings.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'greetings.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('greetings.trash'); } if ($this->canDo->get('core.export') && $this->canDo->get('greeting.export')) { JToolBarHelper::custom('greetings.exportData', 'download', '', 'COM_HELLO_WORLD_EXPORT_DATA', true); - } + } } if ($this->canDo->get('core.import') && $this->canDo->get('greeting.import')) { JToolBarHelper::custom('greetings.importData', 'upload', '', 'COM_HELLO_WORLD_IMPORT_DATA', false); - } - - // set help url for this view if found - $help_url = Hello_worldHelper::getHelpUrl('greetings'); - if (Hello_worldHelper::checkString($help_url)) - { - JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_hello_world'); + } + + // set help url for this view if found + $this->help_url = Hello_worldHelper::getHelpUrl('greetings'); + if (Hello_worldHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_hello_world'); } // Only load published batch if state and batch is allowed @@ -185,54 +185,54 @@ class Hello_worldViewGreetings extends JViewLegacy 'batch[access]', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_HELLO_WORLD_GREETINGS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_hello_world/assets/css/greetings.css", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return Hello_worldHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return Hello_worldHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_HELLO_WORLD_GREETINGS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_hello_world/assets/css/greetings.css", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return Hello_worldHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return Hello_worldHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { return array( 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), 'a.published' => JText::_('JSTATUS'), 'a.greeting' => JText::_('COM_HELLO_WORLD_GREETING_GREETING_LABEL'), 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} + ); + } +} diff --git a/admin/views/hello_world/tmpl/default.php b/admin/views/hello_world/tmpl/default.php index 2d00c09..70b2c90 100644 --- a/admin/views/hello_world/tmpl/default.php +++ b/admin/views/hello_world/tmpl/default.php @@ -1,28 +1,28 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.tooltip'); - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage default.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + + + ?>
diff --git a/admin/views/hello_world/tmpl/default_main.php b/admin/views/hello_world/tmpl/default_main.php index 6c4df46..8c88a97 100644 --- a/admin/views/hello_world/tmpl/default_main.php +++ b/admin/views/hello_world/tmpl/default_main.php @@ -1,39 +1,39 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -icons['main']) && is_array($this->icons['main'])) :?> - icons['main'] as $icon): ?> - - -
- -

+/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage default_main.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +icons['main']) && is_array($this->icons['main'])) :?> + icons['main'] as $icon): ?> + + +
+ +

\ No newline at end of file diff --git a/admin/views/hello_world/tmpl/default_vdm.php b/admin/views/hello_world/tmpl/default_vdm.php index f13499d..8f95b85 100644 --- a/admin/views/hello_world/tmpl/default_vdm.php +++ b/admin/views/hello_world/tmpl/default_vdm.php @@ -1,47 +1,47 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -<?php echo JText::_('COM_HELLO_WORLD'); ?> - -
-contributors)): ?> - contributors) > 1): ?> -

- -

- -
    - contributors as $contributor): ?> -
  • :
  • - -
-
+/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage default_vdm.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +<?php echo JText::_('COM_HELLO_WORLD'); ?> + +
+contributors)): ?> + contributors) > 1): ?> +

+ +

+ +
    + contributors as $contributor): ?> +
  • :
  • + +
+
\ No newline at end of file diff --git a/admin/views/hello_world/view.html.php b/admin/views/hello_world/view.html.php index 179ec92..df63bc6 100644 --- a/admin/views/hello_world/view.html.php +++ b/admin/views/hello_world/view.html.php @@ -1,97 +1,99 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Hello_world View class - */ -class Hello_worldViewHello_world extends JViewLegacy -{ - /** - * View display method - * @return void - */ - function display($tpl = null) - { - // Assign data to the view - $this->icons = $this->get('Icons'); - $this->contributors = Hello_worldHelper::getContributors(); - - // get the manifest details of the component - $this->manifest = Hello_worldHelper::manifest(); - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - $canDo = Hello_worldHelper::getActions('hello_world'); - JToolBarHelper::title(JText::_('COM_HELLO_WORLD_DASHBOARD'), 'grid-2'); - - // set help url for this view if found - $help_url = Hello_worldHelper::getHelpUrl('hello_world'); - if (Hello_worldHelper::checkString($help_url)) - { - JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $help_url); - } - - if ($canDo->get('core.admin') || $canDo->get('core.options')) - { - JToolBarHelper::preferences('com_hello_world'); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $document = JFactory::getDocument(); - - // add dashboard style sheets - $document->addStyleSheet(JURI::root() . "administrator/components/com_hello_world/assets/css/dashboard.css"); - - // set page title - $document->setTitle(JText::_('COM_HELLO_WORLD_DASHBOARD')); - - // add manifest to page JavaScript - $document->addScriptDeclaration("var manifest = jQuery.parseJSON('" . json_encode($this->manifest) . "');", "text/javascript"); - } -} +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage view.html.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + + + +/** + * Hello_world View class + */ +class Hello_worldViewHello_world extends JViewLegacy +{ + /** + * View display method + * @return void + */ + function display($tpl = null) + { + // Assign data to the view + $this->icons = $this->get('Icons'); + $this->contributors = Hello_worldHelper::getContributors(); + + // get the manifest details of the component + $this->manifest = Hello_worldHelper::manifest(); + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + $canDo = Hello_worldHelper::getActions('hello_world'); + JToolBarHelper::title(JText::_('COM_HELLO_WORLD_DASHBOARD'), 'grid-2'); + + // set help url for this view if found + $this->help_url = Hello_worldHelper::getHelpUrl('hello_world'); + if (Hello_worldHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $this->help_url); + } + + if ($canDo->get('core.admin') || $canDo->get('core.options')) + { + JToolBarHelper::preferences('com_hello_world'); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $document = JFactory::getDocument(); + + // add dashboard style sheets + $document->addStyleSheet(JURI::root() . "administrator/components/com_hello_world/assets/css/dashboard.css"); + + // set page title + $document->setTitle(JText::_('COM_HELLO_WORLD_DASHBOARD')); + + // add manifest to page JavaScript + $document->addScriptDeclaration("var manifest = jQuery.parseJSON('" . json_encode($this->manifest) . "');", "text/javascript"); + } +} diff --git a/admin/views/import/tmpl/default.php b/admin/views/import/tmpl/default.php index 2d322b5..69be733 100644 --- a/admin/views/import/tmpl/default.php +++ b/admin/views/import/tmpl/default.php @@ -1,226 +1,226 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('jquery.framework'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('script', 'system/core.js', false, true); -JHtml::_('behavior.keepalive'); -?> - - -
-
- - sidebar)) : ?> -
- sidebar; ?> -
-
- -
- - - hasPackage && Hello_worldHelper::checkArray($this->headerList) && Hello_worldHelper::checkArray($this->headers)) : ?> -
- -
- -
- -
-
- headerList as $name => $title): ?> -
- -
- -
-
- -
- -
-
- - - 'upload')); ?> - - -
- -
- -
- -
-
-
-     (.csv .xls .ods) -
-
- - - -
- -
- -
- -
-
-
-     (.csv .xls .ods) -
-
- - - -
- -
- -
- -
-
-
-     (.csv .xls .ods) -
-
- - - - - - - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage default.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('jquery.framework'); +JHtml::_('bootstrap.tooltip'); +JHtml::_('script', 'system/core.js', false, true); +JHtml::_('behavior.keepalive'); +?> + + +
+
+ + sidebar)) : ?> +
+ sidebar; ?> +
+
+ +
+ + + hasPackage && Hello_worldHelper::checkArray($this->headerList) && Hello_worldHelper::checkArray($this->headers)) : ?> +
+ +
+ +
+ +
+
+ headerList as $name => $title): ?> +
+ +
+ +
+
+ +
+ +
+
+ + + 'upload')); ?> + + +
+ +
+ +
+ +
+
+
+     (.csv .xls .ods) +
+
+ + + +
+ +
+ +
+ +
+
+
+     (.csv .xls .ods) +
+
+ + + +
+ +
+ +
+ +
+
+
+     (.csv .xls .ods) +
+
+ + + + + + +
\ No newline at end of file diff --git a/admin/views/import/view.html.php b/admin/views/import/view.html.php index d972358..97c659a 100644 --- a/admin/views/import/view.html.php +++ b/admin/views/import/view.html.php @@ -1,102 +1,102 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Hello_world Import View - */ -class Hello_worldViewImport extends JViewLegacy -{ - protected $headerList; - protected $hasPackage = false; - protected $headers; - protected $hasHeader = 0; - protected $dataType; - - public function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - Hello_worldHelper::addSubmenu('import'); - } - - $paths = new stdClass; - $paths->first = ''; - $state = $this->get('state'); - - $this->paths = &$paths; - $this->state = &$state; - // get global action permissions - $this->canDo = Hello_worldHelper::getActions('import'); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - } - - // get the session object - $session = JFactory::getSession(); - // check if it has package - $this->hasPackage = $session->get('hasPackage', false); - $this->dataType = $session->get('dataType', false); - if($this->hasPackage && $this->dataType) - { - $this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true); - $this->headers = Hello_worldHelper::getFileHeaders($this->dataType); - // clear the data type - $session->clear('dataType'); - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_HELLO_WORLD_IMPORT_TITLE'), 'upload'); - JHtmlSidebar::setAction('index.php?option=com_hello_world&view=import'); - - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_hello_world'); - } - - // set help url for this view if found - $help_url = Hello_worldHelper::getHelpUrl('import'); - if (Hello_worldHelper::checkString($help_url)) - { - JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $help_url); - } - } -} +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage view.html.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Hello_world Import View + */ +class Hello_worldViewImport extends JViewLegacy +{ + protected $headerList; + protected $hasPackage = false; + protected $headers; + protected $hasHeader = 0; + protected $dataType; + + public function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + Hello_worldHelper::addSubmenu('import'); + } + + $paths = new stdClass; + $paths->first = ''; + $state = $this->get('state'); + + $this->paths = &$paths; + $this->state = &$state; + // get global action permissions + $this->canDo = Hello_worldHelper::getActions('import'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + } + + // get the session object + $session = JFactory::getSession(); + // check if it has package + $this->hasPackage = $session->get('hasPackage', false); + $this->dataType = $session->get('dataType', false); + if($this->hasPackage && $this->dataType) + { + $this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true); + $this->headers = Hello_worldHelper::getFileHeaders($this->dataType); + // clear the data type + $session->clear('dataType'); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_HELLO_WORLD_IMPORT_TITLE'), 'upload'); + JHtmlSidebar::setAction('index.php?option=com_hello_world&view=import'); + + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_hello_world'); + } + + // set help url for this view if found + $this->help_url = Hello_worldHelper::getHelpUrl('import'); + if (Hello_worldHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $this->help_url); + } + } +} diff --git a/hello_world.xml b/hello_world.xml index 0d76581..019ac7f 100644 --- a/hello_world.xml +++ b/hello_world.xml @@ -1,102 +1,102 @@ - - - COM_HELLO_WORLD - 4th January, 2021 - Llewellyn - joomla@vdm.io - https://www.vdm.io - Copyright (C) 2015. All Rights Reserved - GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - 1.0.1 - Hello World (v.1.0.1) -
-

-

Created by Llewellyn
Development started 20th September, 2017

- ]]>
- - - - - sql/install.mysql.utf8.sql - - - - - - - sql/uninstall.mysql.utf8.sql - - - - - script.php - - - index.html - js - css + + + COM_HELLO_WORLD + 3rd March, 2022 + Llewellyn + joomla@vdm.io + https://www.vdm.io + Copyright (C) 2015. All Rights Reserved + GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + 1.0.1 + Hello World (v.1.0.1) +
+

+

Created by Llewellyn
Development started 20th September, 2017

+ ]]>
+ + + + + sql/install.mysql.utf8.sql + + + + + + + sql/uninstall.mysql.utf8.sql + + + + + script.php + + + index.html + js + css images uikit-v2 - footable-v3 - - - - - - sql/updates/mysql/ - - - - - controller.php - index.html - router.php + footable-v3 +
+ + + + + sql/updates/mysql/ + + + + + controller.php + index.html + router.php hello_world.php - router.php - assets - helpers - controllers - models - views - layouts - - - + router.php + assets + helpers + controllers + models + views + layouts + + + language/en-GB/en-GB.com_hello_world.ini - language/en-GB/en-GB.com_hello_world.sys.ini - - - - COM_HELLO_WORLD_MENU - + language/en-GB/en-GB.com_hello_world.sys.ini + + + + COM_HELLO_WORLD_MENU + - COM_HELLO_WORLD_MENU_GREETINGS - - - access.xml - config.xml - controller.php - index.html + COM_HELLO_WORLD_MENU_GREETINGS + + + access.xml + config.xml + controller.php + index.html hello_world.php - README.txt - assets - controllers - helpers - models - sql - tables - views - layouts - - - + README.txt + assets + controllers + helpers + models + sql + tables + views + layouts + + + language/en-GB/en-GB.com_hello_world.ini - language/en-GB/en-GB.com_hello_world.sys.ini - - + language/en-GB/en-GB.com_hello_world.sys.ini + + https://raw.githubusercontent.com/Llewellynvdm/Joomla-Hello-World-Component/master/helloworld_updateserver.xml - +
\ No newline at end of file diff --git a/admin/models/forms/greeting.js b/media/js/greeting.js similarity index 95% rename from admin/models/forms/greeting.js rename to media/js/greeting.js index 020e5df..a88eabf 100644 --- a/admin/models/forms/greeting.js +++ b/media/js/greeting.js @@ -1,20 +1,20 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage greeting.js - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greeting.js + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + + diff --git a/script.php b/script.php index 2390360..7b36001 100644 --- a/script.php +++ b/script.php @@ -1,55 +1,58 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHTML::_('behavior.modal'); - -/** - * Script File of Hello_world Component - */ -class com_hello_worldInstallerScript -{ - /** - * Constructor - * - * @param JAdapterInstance $parent The object responsible for running this script - */ - public function __construct(JAdapterInstance $parent) {} - - /** - * Called on installation - * - * @param JAdapterInstance $parent The object responsible for running this script - * - * @return boolean True on success - */ - public function install(JAdapterInstance $parent) {} - - /** - * Called on uninstallation - * - * @param JAdapterInstance $parent The object responsible for running this script - */ - public function uninstall(JAdapterInstance $parent) +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage script.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Installer\Adapter\ComponentAdapter; +JHTML::_('bootstrap.renderModal'); + +/** + * Script File of Hello_world Component + */ +class com_hello_worldInstallerScript +{ + /** + * Constructor + * + * @param JAdapterInstance $parent The object responsible for running this script + */ + public function __construct(ComponentAdapter $parent) {} + + /** + * Called on installation + * + * @param ComponentAdapter $parent The object responsible for running this script + * + * @return boolean True on success + */ + public function install(ComponentAdapter $parent) {} + + /** + * Called on uninstallation + * + * @param ComponentAdapter $parent The object responsible for running this script + */ + public function uninstall(ComponentAdapter $parent) { // Get Application object $app = JFactory::getApplication(); @@ -373,83 +376,83 @@ class com_hello_worldInstallerScript { // If successfully removed Hello_world Greeting add queued success message. $app->enqueueMessage(JText::_('The com_hello_world.greeting type alias was removed from the #__action_log_config table')); - } - // little notice as after service, in case of bad experience with component. - echo '

Did something go wrong? Are you disappointed?

-

Please let me know at joomla@vdm.io. -
We at VDM are committed to building extensions that performs proficiently! You can help us, really! -
Send me your thoughts on improvements that is needed, trust me, I will be very grateful! -
Visit us at https://www.vdm.io today!

'; - } - - /** - * Called on update - * - * @param JAdapterInstance $parent The object responsible for running this script - * - * @return boolean True on success - */ - public function update(JAdapterInstance $parent){} - - /** - * Called before any type of action - * - * @param string $type Which action is happening (install|uninstall|discover_install|update) - * @param JAdapterInstance $parent The object responsible for running this script - * - * @return boolean True on success - */ - public function preflight($type, JAdapterInstance $parent) - { - // get application - $app = JFactory::getApplication(); - // is redundant or so it seems ...hmmm let me know if it works again - if ($type === 'uninstall') - { - return true; - } - // the default for both install and update - $jversion = new JVersion(); - if (!$jversion->isCompatible('3.8.0')) - { - $app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error'); - return false; - } - // do any updates needed - if ($type === 'update') - { - } - // do any install needed - if ($type === 'install') - { - } - // check if the PHPExcel stuff is still around - if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_hello_world/helpers/PHPExcel.php')) - { - // We need to remove this old PHPExcel folder - $this->removeFolder(JPATH_ADMINISTRATOR . '/components/com_hello_world/helpers/PHPExcel'); - // We need to remove this old PHPExcel file - JFile::delete(JPATH_ADMINISTRATOR . '/components/com_hello_world/helpers/PHPExcel.php'); - } - return true; - } - - /** - * Called after any type of action - * - * @param string $type Which action is happening (install|uninstall|discover_install|update) - * @param JAdapterInstance $parent The object responsible for running this script - * - * @return boolean True on success - */ - public function postflight($type, JAdapterInstance $parent) - { - // get application + } + // little notice as after service, in case of bad experience with component. + echo '

Did something go wrong? Are you disappointed?

+

Please let me know at joomla@vdm.io. +
We at VDM are committed to building extensions that performs proficiently! You can help us, really! +
Send me your thoughts on improvements that is needed, trust me, I will be very grateful! +
Visit us at https://www.vdm.io today!

'; + } + + /** + * Called on update + * + * @param ComponentAdapter $parent The object responsible for running this script + * + * @return boolean True on success + */ + public function update(ComponentAdapter $parent){} + + /** + * Called before any type of action + * + * @param string $type Which action is happening (install|uninstall|discover_install|update) + * @param ComponentAdapter $parent The object responsible for running this script + * + * @return boolean True on success + */ + public function preflight($type, ComponentAdapter $parent) + { + // get application + $app = JFactory::getApplication(); + // is redundant or so it seems ...hmmm let me know if it works again + if ($type === 'uninstall') + { + return true; + } + // the default for both install and update + $jversion = new JVersion(); + if (!$jversion->isCompatible('3.8.0')) + { + $app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error'); + return false; + } + // do any updates needed + if ($type === 'update') + { + } + // do any install needed + if ($type === 'install') + { + } + // check if the PHPExcel stuff is still around + if (File::exists(JPATH_ADMINISTRATOR . '/components/com_hello_world/helpers/PHPExcel.php')) + { + // We need to remove this old PHPExcel folder + $this->removeFolder(JPATH_ADMINISTRATOR . '/components/com_hello_world/helpers/PHPExcel'); + // We need to remove this old PHPExcel file + File::delete(JPATH_ADMINISTRATOR . '/components/com_hello_world/helpers/PHPExcel.php'); + } + return true; + } + + /** + * Called after any type of action + * + * @param string $type Which action is happening (install|uninstall|discover_install|update) + * @param ComponentAdapter $parent The object responsible for running this script + * + * @return boolean True on success + */ + public function postflight($type, ComponentAdapter $parent) + { + // get application $app = JFactory::getApplication(); // We check if we have dynamic folders to copy - $this->setDynamicF0ld3rs($app, $parent); - // set the default component settings - if ($type === 'install') + $this->setDynamicF0ld3rs($app, $parent); + // set the default component settings + if ($type === 'install') { // Get The Database object @@ -482,7 +485,7 @@ class com_hello_worldInstallerScript $db->setQuery($query); $allDone = $db->execute(); - // Install the global extenstion params. + // Install the global extension params. $query = $db->getQuery(true); // Field to update. $fields = array( @@ -527,10 +530,10 @@ class com_hello_worldInstallerScript $greeting_action_log_config->text_prefix = 'COM_HELLO_WORLD'; // Set the object into the action log config table. - $greeting_Inserted = $db->insertObject('#__action_log_config', $greeting_action_log_config); - } - // do any updates needed - if ($type === 'update') + $greeting_Inserted = $db->insertObject('#__action_log_config', $greeting_action_log_config); + } + // do any updates needed + if ($type === 'update') { // Get The Database object @@ -626,110 +629,110 @@ class com_hello_worldInstallerScript else { $greeting_action_log_config_Inserted = $db->insertObject('#__action_log_config', $greeting_action_log_config); - } - } - return true; - } - - /** - * Remove folders with files - * - * @param string $dir The path to folder to remove - * @param boolean $ignore The folders and files to ignore and not remove - * - * @return boolean True in all is removed - * - */ - protected function removeFolder($dir, $ignore = false) - { - if (JFolder::exists($dir)) - { - $it = new RecursiveDirectoryIterator($dir); - $it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); - // remove ending / - $dir = rtrim($dir, '/'); - // now loop the files & folders - foreach ($it as $file) - { - if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue; - // set file dir - $file_dir = $file->getPathname(); - // check if this is a dir or a file - if ($file->isDir()) - { - $keeper = false; - if ($this->checkArray($ignore)) - { - foreach ($ignore as $keep) - { - if (strpos($file_dir, $dir.'/'.$keep) !== false) - { - $keeper = true; - } - } - } - if ($keeper) - { - continue; - } - JFolder::delete($file_dir); - } - else - { - $keeper = false; - if ($this->checkArray($ignore)) - { - foreach ($ignore as $keep) - { - if (strpos($file_dir, $dir.'/'.$keep) !== false) - { - $keeper = true; - } - } - } - if ($keeper) - { - continue; - } - JFile::delete($file_dir); - } - } - // delete the root folder if not ignore found - if (!$this->checkArray($ignore)) - { - return JFolder::delete($dir); - } - return true; - } - return false; - } - - /** - * Check if have an array with a length - * - * @input array The array to check - * - * @returns bool/int number of items in array on success - */ - protected function checkArray($array, $removeEmptyString = false) - { - if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) - { - // also make sure the empty strings are removed - if ($removeEmptyString) - { - foreach ($array as $key => $string) - { - if (empty($string)) - { - unset($array[$key]); - } - } - return $this->checkArray($array, false); - } - return $nr; - } - return false; + } + } + return true; + } + + /** + * Remove folders with files + * + * @param string $dir The path to folder to remove + * @param boolean $ignore The folders and files to ignore and not remove + * + * @return boolean True in all is removed + * + */ + protected function removeFolder($dir, $ignore = false) + { + if (Folder::exists($dir)) + { + $it = new RecursiveDirectoryIterator($dir); + $it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); + // remove ending / + $dir = rtrim($dir, '/'); + // now loop the files & folders + foreach ($it as $file) + { + if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue; + // set file dir + $file_dir = $file->getPathname(); + // check if this is a dir or a file + if ($file->isDir()) + { + $keeper = false; + if ($this->checkArray($ignore)) + { + foreach ($ignore as $keep) + { + if (strpos($file_dir, $dir.'/'.$keep) !== false) + { + $keeper = true; + } + } + } + if ($keeper) + { + continue; + } + Folder::delete($file_dir); + } + else + { + $keeper = false; + if ($this->checkArray($ignore)) + { + foreach ($ignore as $keep) + { + if (strpos($file_dir, $dir.'/'.$keep) !== false) + { + $keeper = true; + } + } + } + if ($keeper) + { + continue; + } + File::delete($file_dir); + } + } + // delete the root folder if not ignore found + if (!$this->checkArray($ignore)) + { + return Folder::delete($dir); + } + return true; + } + return false; + } + + /** + * Check if have an array with a length + * + * @input array The array to check + * + * @returns bool/int number of items in array on success + */ + protected function checkArray($array, $removeEmptyString = false) + { + if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) + { + // also make sure the empty strings are removed + if ($removeEmptyString) + { + foreach ($array as $key => $string) + { + if (empty($string)) + { + unset($array[$key]); + } + } + return $this->checkArray($array, false); + } + return $nr; + } + return false; } /** @@ -743,7 +746,7 @@ class com_hello_worldInstallerScript $installer = $parent->getParent(); $installPath = $installer->getPath('source'); // get all the folders - $folders = JFolder::folders($installPath); + $folders = Folder::folders($installPath); // check if we have folders we may want to copy $doNotCopy = array('media','admin','site'); // Joomla already deals with these if (count((array) $folders) > 1) @@ -758,12 +761,12 @@ class com_hello_worldInstallerScript // set the destination path $dest = JPATH_ROOT.'/'.$folder; // now try to copy the folder - if (!JFolder::copy($src, $dest, '', true)) + if (!Folder::copy($src, $dest, '', true)) { $app->enqueueMessage('Could not copy '.$folder.' folder into place, please make sure destination is writable!', 'error'); } } } } - } -} + } +} diff --git a/site/assets/css/greet.css b/site/assets/css/greet.css index 5bf90e5..01ae2d7 100644 --- a/site/assets/css/greet.css +++ b/site/assets/css/greet.css @@ -1,22 +1,22 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage greet.css - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -/* CSS Document */ - - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greet.css + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/site/assets/css/greeting.css b/site/assets/css/greeting.css index fba7b34..05bd8e8 100644 --- a/site/assets/css/greeting.css +++ b/site/assets/css/greeting.css @@ -1,22 +1,22 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage greeting.css - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -/* CSS Document */ - - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greeting.css + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/site/assets/css/greetings.css b/site/assets/css/greetings.css index e873ad8..71a85ef 100644 --- a/site/assets/css/greetings.css +++ b/site/assets/css/greetings.css @@ -1,22 +1,22 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage greetings.css - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -/* CSS Document */ - - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greetings.css + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/site/assets/css/site.css b/site/assets/css/site.css index 58619a1..3e5c25e 100644 --- a/site/assets/css/site.css +++ b/site/assets/css/site.css @@ -1,24 +1,24 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage site.css - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -/* CSS Document */ -.no-click { - pointer-events: none; -} - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage site.css + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ +.no-click { + pointer-events: none; +} + diff --git a/site/assets/js/site.js b/site/assets/js/site.js index cfac371..d2f4b1d 100644 --- a/site/assets/js/site.js +++ b/site/assets/js/site.js @@ -1,20 +1,20 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage site.js - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage site.js + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + /------------------------------------------------------------------------------------------------------*/ /* JS Document */ diff --git a/site/controller.php b/site/controller.php index 7afa38a..b63fa96 100644 --- a/site/controller.php +++ b/site/controller.php @@ -1,131 +1,131 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Hello_world Component Controller - */ -class Hello_worldController extends JControllerLegacy -{ - /** - * Method to display a view. - * - * @param boolean $cachable If true, the view output will be cached. - * @param boolean $urlparams An array of safe URL parameters and their variable types, for valid values see {@link JFilterInput::clean()}. - * - * @return JController This object to support chaining. - * - */ - function display($cachable = false, $urlparams = false) - { - // set default view if not set - $view = $this->input->getCmd('view', 'greetings'); - $this->input->set('view', $view); - $isEdit = $this->checkEditView($view); - $layout = $this->input->get('layout', null, 'WORD'); - $id = $this->input->getInt('id'); - // $cachable = true; (TODO) working on a fix [gh-238](https://github.com/vdm-io/Joomla-Component-Builder/issues/238) - - // insure that the view is not cashable if edit view or if user is logged in - $user = JFactory::getUser(); - if ($user->get('id') || $isEdit) - { - $cachable = false; - } - - // Check for edit form. - if($isEdit) - { - if ($layout == 'edit' && !$this->checkEditId('com_hello_world.edit.'.$view, $id)) - { - // Somehow the person just went to the form - we don't allow that. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); - $this->setMessage($this->getError(), 'error'); - // check if item was opend from other then its own list view - $ref = $this->input->getCmd('ref', 0); - $refid = $this->input->getInt('refid', 0); - // set redirect - if ($refid > 0 && Hello_worldHelper::checkString($ref)) - { - // redirect to item of ref - $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); - } - elseif (Hello_worldHelper::checkString($ref)) - { - // redirect to ref - $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view='.(string)$ref, false)); - } - else - { - // normal redirect back to the list default site view - $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view=greetings', false)); - } - return false; - } - } - - // we may need to make this more dynamic in the future. (TODO) - $safeurlparams = array( - 'catid' => 'INT', - 'id' => 'INT', - 'cid' => 'ARRAY', - 'year' => 'INT', - 'month' => 'INT', - 'limit' => 'UINT', - 'limitstart' => 'UINT', - 'showall' => 'INT', - 'return' => 'BASE64', - 'filter' => 'STRING', - 'filter_order' => 'CMD', - 'filter_order_Dir' => 'CMD', - 'filter-search' => 'STRING', - 'print' => 'BOOLEAN', - 'lang' => 'CMD', - 'Itemid' => 'INT'); - - // should these not merge? - if (Hello_worldHelper::checkArray($urlparams)) - { - $safeurlparams = Hello_worldHelper::mergeArrays(array($urlparams, $safeurlparams)); - } - - return parent::display($cachable, $safeurlparams); - } - - protected function checkEditView($view) - { - if (Hello_worldHelper::checkString($view)) - { +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage controller.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Hello_world Component Controller + */ +class Hello_worldController extends JControllerLegacy +{ + /** + * Method to display a view. + * + * @param boolean $cachable If true, the view output will be cached. + * @param boolean $urlparams An array of safe URL parameters and their variable types, for valid values see {@link JFilterInput::clean()}. + * + * @return JController This object to support chaining. + * + */ + function display($cachable = false, $urlparams = false) + { + // set default view if not set + $view = $this->input->getCmd('view', 'greetings'); + $this->input->set('view', $view); + $isEdit = $this->checkEditView($view); + $layout = $this->input->get('layout', null, 'WORD'); + $id = $this->input->getInt('id'); + // $cachable = true; (TODO) working on a fix [gh-238](https://github.com/vdm-io/Joomla-Component-Builder/issues/238) + + // insure that the view is not cashable if edit view or if user is logged in + $user = JFactory::getUser(); + if ($user->get('id') || $isEdit) + { + $cachable = false; + } + + // Check for edit form. + if($isEdit) + { + if ($layout == 'edit' && !$this->checkEditId('com_hello_world.edit.'.$view, $id)) + { + // Somehow the person just went to the form - we don't allow that. + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); + $this->setMessage($this->getError(), 'error'); + // check if item was opend from other then its own list view + $ref = $this->input->getCmd('ref', 0); + $refid = $this->input->getInt('refid', 0); + // set redirect + if ($refid > 0 && Hello_worldHelper::checkString($ref)) + { + // redirect to item of ref + $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); + } + elseif (Hello_worldHelper::checkString($ref)) + { + // redirect to ref + $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view='.(string)$ref, false)); + } + else + { + // normal redirect back to the list default site view + $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view=greetings', false)); + } + return false; + } + } + + // we may need to make this more dynamic in the future. (TODO) + $safeurlparams = array( + 'catid' => 'INT', + 'id' => 'INT', + 'cid' => 'ARRAY', + 'year' => 'INT', + 'month' => 'INT', + 'limit' => 'UINT', + 'limitstart' => 'UINT', + 'showall' => 'INT', + 'return' => 'BASE64', + 'filter' => 'STRING', + 'filter_order' => 'CMD', + 'filter_order_Dir' => 'CMD', + 'filter-search' => 'STRING', + 'print' => 'BOOLEAN', + 'lang' => 'CMD', + 'Itemid' => 'INT'); + + // should these not merge? + if (Hello_worldHelper::checkArray($urlparams)) + { + $safeurlparams = Hello_worldHelper::mergeArrays(array($urlparams, $safeurlparams)); + } + + return parent::display($cachable, $safeurlparams); + } + + protected function checkEditView($view) + { + if (Hello_worldHelper::checkString($view)) + { $views = array( - 'greeting' - ); - // check if this is a edit view - if (in_array($view,$views)) - { - return true; - } - } - return false; - } -} + 'greeting' + ); + // check if this is a edit view + if (in_array($view,$views)) + { + return true; + } + } + return false; + } +} diff --git a/site/controllers/greeting.php b/site/controllers/greeting.php index ded5a70..5fa737f 100644 --- a/site/controllers/greeting.php +++ b/site/controllers/greeting.php @@ -1,65 +1,65 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Greeting Controller - */ -class Hello_worldControllerGreeting extends JControllerForm -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'greetings'; // safeguard for setting the return view listing to the default site view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greeting.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Greeting Controller + */ +class Hello_worldControllerGreeting extends JControllerForm +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'greetings'; // safeguard for setting the return view listing to the default site view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) { // Get user object. $user = JFactory::getUser(); @@ -71,20 +71,20 @@ class Hello_worldControllerGreeting extends JControllerForm } // In the absense of better information, revert to the component permissions. - return parent::allowAdd($data); - } - - /** - * 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 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') + return parent::allowAdd($data); + } + + /** + * 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 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') { // get user object. $user = JFactory::getUser(); @@ -127,199 +127,199 @@ class Hello_worldControllerGreeting extends JControllerForm } } // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Greeting', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view=greetings' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) + return parent::allowEdit($data, $key); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - return; - } - -} + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Greeting', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_hello_world&view=greetings' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/site/hello_world.php b/site/hello_world.php index c7e94e5..db22bc5 100644 --- a/site/hello_world.php +++ b/site/hello_world.php @@ -1,42 +1,42 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.tabstate'); - -// Set the component css/js -$document = JFactory::getDocument(); -$document->addStyleSheet('components/com_hello_world/assets/css/site.css'); -$document->addScript('components/com_hello_world/assets/js/site.js'); - -// Require helper files -JLoader::register('Hello_worldHelper', __DIR__ . '/helpers/hello_world.php'); -JLoader::register('Hello_worldHelperRoute', __DIR__ . '/helpers/route.php'); - -// Get an instance of the controller prefixed by Hello_world -$controller = JControllerLegacy::getInstance('Hello_world'); - -// Perform the request task -$controller->execute(JFactory::getApplication()->input->get('task')); - -// Redirect if set by the controller -$controller->redirect(); +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage hello_world.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + + + +// Set the component css/js +$document = JFactory::getDocument(); +$document->addStyleSheet('components/com_hello_world/assets/css/site.css'); +$document->addScript('components/com_hello_world/assets/js/site.js'); + +// Require helper files +JLoader::register('Hello_worldHelper', __DIR__ . '/helpers/hello_world.php'); +JLoader::register('Hello_worldHelperRoute', __DIR__ . '/helpers/route.php'); + +// Get an instance of the controller prefixed by Hello_world +$controller = JControllerLegacy::getInstance('Hello_world'); + +// Perform the request task +$controller->execute(JFactory::getApplication()->input->get('task')); + +// Redirect if set by the controller +$controller->redirect(); diff --git a/site/helpers/category.php b/site/helpers/category.php index 998be1e..e8a96ad 100644 --- a/site/helpers/category.php +++ b/site/helpers/category.php @@ -1,21 +1,21 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage category.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + /------------------------------------------------------------------------------------------------------*/ // No direct access to this file diff --git a/site/helpers/headercheck.php b/site/helpers/headercheck.php index f352a15..5cab117 100644 --- a/site/helpers/headercheck.php +++ b/site/helpers/headercheck.php @@ -1,80 +1,80 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -class hello_worldHeaderCheck -{ - function js_loaded($script_name) - { - // UIkit check point - if (strpos($script_name,'uikit') !== false) - { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - - if (strpos($getTemplateName,'yoo') !== false) - { - return true; - } - } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); - foreach (array_keys($head_data['scripts']) as $script) - { - if (stristr($script, $script_name)) - { - return true; - } - } - - return false; - } - - function css_loaded($script_name) - { - // UIkit check point - if (strpos($script_name,'uikit') !== false) - { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - - if (strpos($getTemplateName,'yoo') !== false) - { - return true; - } - } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); - - foreach (array_keys($head_data['styleSheets']) as $script) - { - if (stristr($script, $script_name)) - { - return true; - } - } - - return false; - } +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage headercheck.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +class hello_worldHeaderCheck +{ + function js_loaded($script_name) + { + // UIkit check point + if (strpos($script_name,'uikit') !== false) + { + $app = JFactory::getApplication(); + $getTemplateName = $app->getTemplate('template')->template; + + if (strpos($getTemplateName,'yoo') !== false) + { + return true; + } + } + + $document = JFactory::getDocument(); + $head_data = $document->getHeadData(); + foreach (array_keys($head_data['scripts']) as $script) + { + if (stristr($script, $script_name)) + { + return true; + } + } + + return false; + } + + function css_loaded($script_name) + { + // UIkit check point + if (strpos($script_name,'uikit') !== false) + { + $app = JFactory::getApplication(); + $getTemplateName = $app->getTemplate('template')->template; + + if (strpos($getTemplateName,'yoo') !== false) + { + return true; + } + } + + $document = JFactory::getDocument(); + $head_data = $document->getHeadData(); + + foreach (array_keys($head_data['styleSheets']) as $script) + { + if (stristr($script, $script_name)) + { + return true; + } + } + + return false; + } } \ No newline at end of file diff --git a/site/helpers/hello_world.php b/site/helpers/hello_world.php index 3aa9155..1e13c22 100644 --- a/site/helpers/hello_world.php +++ b/site/helpers/hello_world.php @@ -1,48 +1,50 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage hello_world.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + use Joomla\CMS\Language\Language; use Joomla\Registry\Registry; use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Hello_world component helper - */ -abstract class Hello_worldHelper -{ - /** - * Composer Switch - * - * @var array - */ - protected static $composer = array(); - - /** - * The Main Active Language - * - * @var string - */ +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; + +/** + * Hello_world component helper + */ +abstract class Hello_worldHelper +{ + /** + * Composer Switch + * + * @var array + */ + protected static $composer = array(); + + /** + * The Main Active Language + * + * @var string + */ public static $langTag; @@ -143,7 +145,7 @@ abstract class Hello_worldHelper */ public static function removeFolder($dir, $ignore = false) { - if (JFolder::exists($dir)) + if (Folder::exists($dir)) { $it = new RecursiveDirectoryIterator($dir); $it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); @@ -173,7 +175,7 @@ abstract class Hello_worldHelper { continue; } - JFolder::delete($file_dir); + Folder::delete($file_dir); } else { @@ -192,154 +194,154 @@ abstract class Hello_worldHelper { continue; } - JFile::delete($file_dir); + File::delete($file_dir); } } // delete the root folder if not ignore found if (!self::checkArray($ignore)) { - return JFolder::delete($dir); + return Folder::delete($dir); } return true; } return false; } - - - /** - * Load the Composer Vendors - */ - public static function composerAutoload($target) - { - // insure we load the composer vendor only once - if (!isset(self::$composer[$target])) - { - // get the function name - $functionName = self::safeString('compose' . $target); - // check if method exist - if (method_exists(__CLASS__, $functionName)) - { - return self::{$functionName}(); - } - return false; - } - return self::$composer[$target]; - } - - /** - * Convert it into a string - */ - public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name') - { - // do some table foot work - $external = false; - if (strpos($table, '#__') !== false) - { - $external = true; - $table = str_replace('#__', '', $table); - } - // check if string is JSON - $result = json_decode($value, true); - if (json_last_error() === JSON_ERROR_NONE) - { - // is JSON - if (self::checkArray($result)) - { - if (self::checkString($table)) - { - $names = array(); - foreach ($result as $val) - { - if ($external) - { - if ($_name = self::getVar(null, $val, $id, $name, '=', $table)) - { - $names[] = $_name; - } - } - else - { - if ($_name = self::getVar($table, $val, $id, $name)) - { - $names[] = $_name; - } - } - } - if (self::checkArray($names)) - { - return (string) implode($sperator,$names); - } - } - return (string) implode($sperator,$result); - } - return (string) json_decode($value); - } - return $value; - } - - /** - * Load the Component xml manifest. - */ - public static function manifest() - { - $manifestUrl = JPATH_ADMINISTRATOR."/components/com_hello_world/hello_world.xml"; - return simplexml_load_file($manifestUrl); - } - - /** - * Joomla version object - */ - protected static $JVersion; - - /** - * set/get Joomla version - */ - public static function jVersion() - { - // check if set - if (!self::checkObject(self::$JVersion)) - { - self::$JVersion = new JVersion(); - } - return self::$JVersion; - } - - /** - * Load the Contributors details. - */ - public static function getContributors() - { - // get params - $params = JComponentHelper::getParams('com_hello_world'); - // start contributors array - $contributors = array(); - // get all Contributors (max 20) - $searchArray = range('0','20'); - foreach($searchArray as $nr) - { - if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 2 || $params->get("showContributor".$nr) == 3)) - { - // set link based of selected option - if($params->get("useContributor".$nr) == 1) - { - $link_front = ''; - $link_back = ''; - } - elseif($params->get("useContributor".$nr) == 2) - { - $link_front = ''; - $link_back = ''; - } - else - { - $link_front = ''; - $link_back = ''; - } - $contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr)); - $contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back; - } - } - return $contributors; + + + /** + * Load the Composer Vendors + */ + public static function composerAutoload($target) + { + // insure we load the composer vendor only once + if (!isset(self::$composer[$target])) + { + // get the function name + $functionName = self::safeString('compose' . $target); + // check if method exist + if (method_exists(__CLASS__, $functionName)) + { + return self::{$functionName}(); + } + return false; + } + return self::$composer[$target]; + } + + /** + * Convert it into a string + */ + public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name') + { + // do some table foot work + $external = false; + if (strpos($table, '#__') !== false) + { + $external = true; + $table = str_replace('#__', '', $table); + } + // check if string is JSON + $result = json_decode($value, true); + if (json_last_error() === JSON_ERROR_NONE) + { + // is JSON + if (self::checkArray($result)) + { + if (self::checkString($table)) + { + $names = array(); + foreach ($result as $val) + { + if ($external) + { + if ($_name = self::getVar(null, $val, $id, $name, '=', $table)) + { + $names[] = $_name; + } + } + else + { + if ($_name = self::getVar($table, $val, $id, $name)) + { + $names[] = $_name; + } + } + } + if (self::checkArray($names)) + { + return (string) implode($sperator,$names); + } + } + return (string) implode($sperator,$result); + } + return (string) json_decode($value); + } + return $value; + } + + /** + * Load the Component xml manifest. + */ + public static function manifest() + { + $manifestUrl = JPATH_ADMINISTRATOR."/components/com_hello_world/hello_world.xml"; + return simplexml_load_file($manifestUrl); + } + + /** + * Joomla version object + */ + protected static $JVersion; + + /** + * set/get Joomla version + */ + public static function jVersion() + { + // check if set + if (!self::checkObject(self::$JVersion)) + { + self::$JVersion = new JVersion(); + } + return self::$JVersion; + } + + /** + * Load the Contributors details. + */ + public static function getContributors() + { + // get params + $params = JComponentHelper::getParams('com_hello_world'); + // start contributors array + $contributors = array(); + // get all Contributors (max 20) + $searchArray = range('0','20'); + foreach($searchArray as $nr) + { + if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 2 || $params->get("showContributor".$nr) == 3)) + { + // set link based of selected option + if($params->get("useContributor".$nr) == 1) + { + $link_front = ''; + $link_back = ''; + } + elseif($params->get("useContributor".$nr) == 2) + { + $link_front = ''; + $link_back = ''; + } + else + { + $link_front = ''; + $link_back = ''; + } + $contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr)); + $contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back; + } + } + return $contributors; } /** @@ -348,362 +350,362 @@ abstract class Hello_worldHelper public static function getHelpUrl($view) { return false; - } - - /** - * Get any component's model - */ - public static function getModel($name, $path = JPATH_COMPONENT_SITE, $Component = 'Hello_world', $config = array()) - { - // fix the name - $name = self::safeString($name); - // full path to models - $fullPathModels = $path . '/models'; - // load the model file - JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); - // make sure the table path is loaded - if (!isset($config['table_path']) || !self::checkString($config['table_path'])) - { - // This is the JCB default path to tables in Joomla 3.x - $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; - } - // get instance - $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); - // if model not found (strange) - if ($model == false) - { - jimport('joomla.filesystem.file'); - // get file path - $filePath = $path . '/' . $name . '.php'; - $fullPathModel = $fullPathModels . '/' . $name . '.php'; - // check if it exists - if (JFile::exists($filePath)) - { - // get the file - require_once $filePath; - } - elseif (JFile::exists($fullPathModel)) - { - // get the file - require_once $fullPathModel; - } - // build class names - $modelClass = $Component . 'Model' . $name; - if (class_exists($modelClass)) - { - // initialize the model - return new $modelClass($config); - } - } - return $model; - } - - /** - * Add to asset Table - */ - public static function setAsset($id, $table, $inherit = true) - { - $parent = JTable::getInstance('Asset'); - $parent->loadByName('com_hello_world'); - - $parentId = $parent->id; - $name = 'com_hello_world.'.$table.'.'.$id; - $title = ''; - - $asset = JTable::getInstance('Asset'); - $asset->loadByName($name); - - // Check for an error. - $error = $asset->getError(); - - if ($error) - { - return false; - } - else - { - // Specify how a new or moved node asset is inserted into the tree. - if ($asset->parent_id != $parentId) - { - $asset->setLocation($parentId, 'last-child'); - } - - // Prepare the asset to be stored. - $asset->parent_id = $parentId; - $asset->name = $name; - $asset->title = $title; - // get the default asset rules - $rules = self::getDefaultAssetRules('com_hello_world', $table, $inherit); - if ($rules instanceof JAccessRules) - { - $asset->rules = (string) $rules; - } - - if (!$asset->check() || !$asset->store()) - { - JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); - return false; - } - else - { - // Create an asset_id or heal one that is corrupted. - $object = new stdClass(); - - // Must be a valid primary key value. - $object->id = $id; - $object->asset_id = (int) $asset->id; - - // Update their asset_id to link to the asset table. - return JFactory::getDbo()->updateObject('#__hello_world_'.$table, $object, 'id'); - } - } - return false; - } - - /** - * Gets the default asset Rules for a component/view. - */ - protected static function getDefaultAssetRules($component, $view, $inherit = true) - { - // if new or inherited - $assetId = 0; - // Only get the actual item rules if not inheriting - if (!$inherit) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - // check that there is a value - if ($db->getNumRows()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - } - } - // get asset rules - $result = JAccess::getAssetRules($assetId); - if ($result instanceof JAccessRules) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($view !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - elseif ($inherit) - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count((array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules($_result); - // return filtered rules - return $rules; - } - } - return $result; - } - - /** - * xmlAppend - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement - * - * @return null - * - */ - public static function xmlAppend(&$xml, $node) - { - if (!$node) - { - // element was not returned - return; - } - switch (get_class($node)) - { - case 'stdClass': - if (property_exists($node, 'comment')) - { - self::xmlComment($xml, $node->comment); - } - if (property_exists($node, 'fieldXML')) - { - self::xmlAppend($xml, $node->fieldXML); - } - break; - case 'SimpleXMLElement': - $domXML = dom_import_simplexml($xml); - $domNode = dom_import_simplexml($node); - $domXML->appendChild($domXML->ownerDocument->importNode($domNode, true)); - $xml = simplexml_import_dom($domXML); - break; - } - } - - /** - * xmlComment - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param string $comment The comment to inject - * - * @return null - * - */ - public static function xmlComment(&$xml, $comment) - { - $domXML = dom_import_simplexml($xml); - $domComment = new DOMComment($comment); - $nodeTarget = $domXML->ownerDocument->importNode($domComment, true); - $domXML->appendChild($nodeTarget); - $xml = simplexml_import_dom($domXML); - } - - /** - * xmlAddAttributes - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $attributes The attributes to apply to the XML element - * - * @return null - * - */ - public static function xmlAddAttributes(&$xml, $attributes = array()) - { - foreach ($attributes as $key => $value) - { - $xml->addAttribute($key, $value); - } - } - - /** - * xmlAddOptions - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $options The options to apply to the XML element - * - * @return void - * - */ - public static function xmlAddOptions(&$xml, $options = array()) - { - foreach ($options as $key => $value) - { - $addOption = $xml->addChild('option'); - $addOption->addAttribute('value', $key); - $addOption[] = $value; - } - } - - /** - * get the field object - * - * @param array $attributes The array of attributes - * @param string $default The default of the field - * @param array $options The options to apply to the XML element - * - * @return object - * - */ - public static function getFieldObject(&$attributes, $default = '', $options = null) - { - // make sure we have attributes and a type value - if (self::checkArray($attributes) && isset($attributes['type'])) - { - // make sure the form helper class is loaded - if (!method_exists('JFormHelper', 'loadFieldType')) - { - jimport('joomla.form.form'); - } - // get field type - $field = JFormHelper::loadFieldType($attributes['type'], true); - // get field xml - $XML = self::getFieldXML($attributes, $options); - // setup the field - $field->setup($XML, $default); - // return the field object - return $field; - } - return false; - } - - /** - * get the field xml - * - * @param array $attributes The array of attributes - * @param array $options The options to apply to the XML element - * - * @return object - * - */ - public static function getFieldXML(&$attributes, $options = null) - { - // make sure we have attributes and a type value - if (self::checkArray($attributes)) - { - // start field xml - $XML = new SimpleXMLElement(''); - // load the attributes - self::xmlAddAttributes($XML, $attributes); - // check if we have options - if (self::checkArray($options)) - { - // load the options - self::xmlAddOptions($XML, $options); - } - // return the field xml - return $XML; - } - return false; - } - - /** - * Render Bool Button - * - * @param array $args All the args for the button - * 0) name - * 1) additional (options class) // not used at this time - * 2) default - * 3) yes (name) - * 4) no (name) - * - * @return string The input html of the button - * - */ - public static function renderBoolButton() - { - $args = func_get_args(); - // check if there is additional button class - $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time - // button attributes - $buttonAttributes = array( - 'type' => 'radio', - 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button', - 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway - 'class' => 'btn-group', - 'filter' => 'INT', - 'default' => isset($args[2]) ? (int) $args[2] : 0); - // set the button options - $buttonOptions = array( - '1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES', - '0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'); - // return the input - return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; + } + + /** + * Get any component's model + */ + public static function getModel($name, $path = JPATH_COMPONENT_SITE, $Component = 'Hello_world', $config = array()) + { + // fix the name + $name = self::safeString($name); + // full path to models + $fullPathModels = $path . '/models'; + // load the model file + JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); + // make sure the table path is loaded + if (!isset($config['table_path']) || !self::checkString($config['table_path'])) + { + // This is the JCB default path to tables in Joomla 3.x + $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; + } + // get instance + $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); + // if model not found (strange) + if ($model == false) + { + jimport('joomla.filesystem.file'); + // get file path + $filePath = $path . '/' . $name . '.php'; + $fullPathModel = $fullPathModels . '/' . $name . '.php'; + // check if it exists + if (File::exists($filePath)) + { + // get the file + require_once $filePath; + } + elseif (File::exists($fullPathModel)) + { + // get the file + require_once $fullPathModel; + } + // build class names + $modelClass = $Component . 'Model' . $name; + if (class_exists($modelClass)) + { + // initialize the model + return new $modelClass($config); + } + } + return $model; + } + + /** + * Add to asset Table + */ + public static function setAsset($id, $table, $inherit = true) + { + $parent = JTable::getInstance('Asset'); + $parent->loadByName('com_hello_world'); + + $parentId = $parent->id; + $name = 'com_hello_world.'.$table.'.'.$id; + $title = ''; + + $asset = JTable::getInstance('Asset'); + $asset->loadByName($name); + + // Check for an error. + $error = $asset->getError(); + + if ($error) + { + return false; + } + else + { + // Specify how a new or moved node asset is inserted into the tree. + if ($asset->parent_id != $parentId) + { + $asset->setLocation($parentId, 'last-child'); + } + + // Prepare the asset to be stored. + $asset->parent_id = $parentId; + $asset->name = $name; + $asset->title = $title; + // get the default asset rules + $rules = self::getDefaultAssetRules('com_hello_world', $table, $inherit); + if ($rules instanceof JAccessRules) + { + $asset->rules = (string) $rules; + } + + if (!$asset->check() || !$asset->store()) + { + JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); + return false; + } + else + { + // Create an asset_id or heal one that is corrupted. + $object = new stdClass(); + + // Must be a valid primary key value. + $object->id = $id; + $object->asset_id = (int) $asset->id; + + // Update their asset_id to link to the asset table. + return JFactory::getDbo()->updateObject('#__hello_world_'.$table, $object, 'id'); + } + } + return false; + } + + /** + * Gets the default asset Rules for a component/view. + */ + protected static function getDefaultAssetRules($component, $view, $inherit = true) + { + // if new or inherited + $assetId = 0; + // Only get the actual item rules if not inheriting + if (!$inherit) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + // check that there is a value + if ($db->getNumRows()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + } + } + // get asset rules + $result = JAccess::getAssetRules($assetId); + if ($result instanceof JAccessRules) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($view !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + elseif ($inherit) + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count((array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules($_result); + // return filtered rules + return $rules; + } + } + return $result; + } + + /** + * xmlAppend + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement + * + * @return null + * + */ + public static function xmlAppend(&$xml, $node) + { + if (!$node) + { + // element was not returned + return; + } + switch (get_class($node)) + { + case 'stdClass': + if (property_exists($node, 'comment')) + { + self::xmlComment($xml, $node->comment); + } + if (property_exists($node, 'fieldXML')) + { + self::xmlAppend($xml, $node->fieldXML); + } + break; + case 'SimpleXMLElement': + $domXML = dom_import_simplexml($xml); + $domNode = dom_import_simplexml($node); + $domXML->appendChild($domXML->ownerDocument->importNode($domNode, true)); + $xml = simplexml_import_dom($domXML); + break; + } + } + + /** + * xmlComment + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param string $comment The comment to inject + * + * @return null + * + */ + public static function xmlComment(&$xml, $comment) + { + $domXML = dom_import_simplexml($xml); + $domComment = new DOMComment($comment); + $nodeTarget = $domXML->ownerDocument->importNode($domComment, true); + $domXML->appendChild($nodeTarget); + $xml = simplexml_import_dom($domXML); + } + + /** + * xmlAddAttributes + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $attributes The attributes to apply to the XML element + * + * @return null + * + */ + public static function xmlAddAttributes(&$xml, $attributes = array()) + { + foreach ($attributes as $key => $value) + { + $xml->addAttribute($key, $value); + } + } + + /** + * xmlAddOptions + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $options The options to apply to the XML element + * + * @return void + * + */ + public static function xmlAddOptions(&$xml, $options = array()) + { + foreach ($options as $key => $value) + { + $addOption = $xml->addChild('option'); + $addOption->addAttribute('value', $key); + $addOption[] = $value; + } + } + + /** + * get the field object + * + * @param array $attributes The array of attributes + * @param string $default The default of the field + * @param array $options The options to apply to the XML element + * + * @return object + * + */ + public static function getFieldObject(&$attributes, $default = '', $options = null) + { + // make sure we have attributes and a type value + if (self::checkArray($attributes) && isset($attributes['type'])) + { + // make sure the form helper class is loaded + if (!method_exists('JFormHelper', 'loadFieldType')) + { + jimport('joomla.form.form'); + } + // get field type + $field = JFormHelper::loadFieldType($attributes['type'], true); + // get field xml + $XML = self::getFieldXML($attributes, $options); + // setup the field + $field->setup($XML, $default); + // return the field object + return $field; + } + return false; + } + + /** + * get the field xml + * + * @param array $attributes The array of attributes + * @param array $options The options to apply to the XML element + * + * @return object + * + */ + public static function getFieldXML(&$attributes, $options = null) + { + // make sure we have attributes and a type value + if (self::checkArray($attributes)) + { + // start field xml + $XML = new SimpleXMLElement(''); + // load the attributes + self::xmlAddAttributes($XML, $attributes); + // check if we have options + if (self::checkArray($options)) + { + // load the options + self::xmlAddOptions($XML, $options); + } + // return the field xml + return $XML; + } + return false; + } + + /** + * Render Bool Button + * + * @param array $args All the args for the button + * 0) name + * 1) additional (options class) // not used at this time + * 2) default + * 3) yes (name) + * 4) no (name) + * + * @return string The input html of the button + * + */ + public static function renderBoolButton() + { + $args = func_get_args(); + // check if there is additional button class + $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time + // button attributes + $buttonAttributes = array( + 'type' => 'radio', + 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button', + 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway + 'class' => 'btn-group', + 'filter' => 'INT', + 'default' => isset($args[2]) ? (int) $args[2] : 0); + // set the button options + $buttonOptions = array( + '1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES', + '0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'); + // return the input + return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; } /** @@ -806,806 +808,806 @@ abstract class Hello_worldHelper return $classes; } return false; - } - - /** - * Get a variable - * - * @param string $table The table from which to get the variable - * @param string $where The value where - * @param string $whereString The target/field string where/name - * @param string $what The return field - * @param string $operator The operator between $whereString/field and $where/value - * @param string $main The component in which the table is found - * - * @return mix string/int/float - * - */ - public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'hello_world') - { - if(!$where) - { - $where = JFactory::getUser()->id; - } - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array($what))); - if (empty($table)) - { - $query->from($db->quoteName('#__'.$main)); - } - else - { - $query->from($db->quoteName('#__'.$main.'_'.$table)); - } - if (is_numeric($where)) - { - $query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where); - } - elseif (is_string($where)) - { - $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where)); - } - else - { - return false; - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - return $db->loadResult(); - } - return false; - } - - /** - * Get array of variables - * - * @param string $table The table from which to get the variables - * @param string $where The value where - * @param string $whereString The target/field string where/name - * @param string $what The return field - * @param string $operator The operator between $whereString/field and $where/value - * @param string $main The component in which the table is found - * @param bool $unique The switch to return a unique array - * - * @return array - * - */ - public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'hello_world', $unique = true) - { - if(!$where) - { - $where = JFactory::getUser()->id; - } - - if (!self::checkArray($where) && $where > 0) - { - $where = array($where); - } - - if (self::checkArray($where)) - { - // prep main <-- why? well if $main='' is empty then $table can be categories or users - if (self::checkString($main)) - { - $main = '_'.ltrim($main, '_'); - } - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - - $query->select($db->quoteName(array($what))); - if (empty($table)) - { - $query->from($db->quoteName('#__'.$main)); - } - else - { - $query->from($db->quoteName('#_'.$main.'_'.$table)); - } - // add strings to array search - if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) - { - $query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")'); - } - else - { - $query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')'); - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - if ($unique) - { - return array_unique($db->loadColumn()); - } - return $db->loadColumn(); - } - } - return false; - } - - public static function isPublished($id,$type) - { - if ($type == 'raw') - { - $type = 'item'; - } - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.published')); - $query->from('#__hello_world_'.$type.' AS a'); - $query->where('a.id = '. (int) $id); - $query->where('a.published = 1'); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return true; - } - return false; - } - - public static function getGroupName($id) - { - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - $query->select(array('a.title')); - $query->from('#__usergroups AS a'); - $query->where('a.id = '. (int) $id); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return $db->loadResult(); - } - return $id; - } - - /** - * Get the action permissions - * - * @param string $view The related view name - * @param int $record The item to act upon - * @param string $views The related list view name - * @param mixed $target Only get this permission (like edit, create, delete) - * @param string $component The target component - * @param object $user The user whose permissions we are loading - * - * @return object The JObject of permission/authorised actions - * - */ - public static function getActions($view, &$record = null, $views = null, $target = null, $component = 'hello_world', $user = 'null') - { - // load the user if not given - if (!self::checkObject($user)) - { - // get the user object - $user = JFactory::getUser(); - } - // load the JObject - $result = new JObject; - // make view name safe (just incase) - $view = self::safeString($view); - if (self::checkString($views)) - { - $views = self::safeString($views); - } - // get all actions from component - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', - "/access/section[@name='component']/" - ); - // if non found then return empty JObject - if (empty($actions)) - { - return $result; - } - // get created by if not found - if (self::checkObject($record) && !isset($record->created_by) && isset($record->id)) - { - $record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component); - } - // set actions only set in component settings - $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); - // check if we have a target - $checkTarget = false; - if ($target) - { - // convert to an array - if (self::checkString($target)) - { - $target = array($target); - } - // check if we are good to go - if (self::checkArray($target)) - { - $checkTarget = true; - } - } - // loop the actions and set the permissions - foreach ($actions as $action) - { - // check target action filter - if ($checkTarget && self::filterActions($view, $action->name, $target)) - { - continue; - } - // set to use component default - $fallback = true; - // reset permission per/action - $permission = false; - $catpermission = false; - // set area - $area = 'comp'; - // check if the record has an ID and the action is item related (not a component action) - if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && - (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) - { - // we are in item - $area = 'item'; - // The record has been set. Check the record permissions. - $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); - // if no permission found, check edit own - if (!$permission) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // the correct target - $coreCheck = (array) explode('.', $action->name); - // check that we have both local and global access - if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && - $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0) - { - // we are in item - $area = 'category'; - // set the core check - $coreCheck = explode('.', $action->name); - $core = $coreCheck[0]; - // make sure we use the core. action check for the categories - if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) - { - $coreCheck[0] = 'core'; - $categoryCheck = implode('.', $coreCheck); - } - else - { - $categoryCheck = $action->name; - } - // The record has a category. Check the category permissions. - $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); - if (!$catpermission && !is_null($catpermission)) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // check that we have both local and global access - if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && - $user->authorise($core . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - } - } - // if allowed then fallback on component global settings - if ($fallback) - { - // if item/category blocks access then don't fall back on global - if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) - { - // do not allow - $result->set($action->name, false); - } - // Finally remember the global settings have the final say. (even if item allow) - // The local item permissions can block, but it can't open and override of global permissions. - // Since items are created by users and global permissions is set by system admin. - else - { - $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); - } - } - } - return $result; - } - - /** - * Filter the action permissions - * - * @param string $action The action to check - * @param array $targets The array of target actions - * - * @return boolean true if action should be filtered out - * - */ - protected static function filterActions(&$view, &$action, &$targets) - { - foreach ($targets as $target) - { - if (strpos($action, $view . '.' . $target) !== false || - strpos($action, 'core.' . $target) !== false) - { - return false; - break; - } - } - return true; - } - - /** - * Check if have an json string - * - * @input string The json string to check - * - * @returns bool true on success - */ - public static function checkJson($string) - { - if (self::checkString($string)) - { - json_decode($string); - return (json_last_error() === JSON_ERROR_NONE); - } - return false; - } - - /** - * Check if have an object with a length - * - * @input object The object to check - * - * @returns bool true on success - */ - public static function checkObject($object) - { - if (isset($object) && is_object($object)) - { - return count((array)$object) > 0; - } - return false; - } - - /** - * Check if have an array with a length - * - * @input array The array to check - * - * @returns bool/int number of items in array on success - */ - public static function checkArray($array, $removeEmptyString = false) - { - if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) - { - // also make sure the empty strings are removed - if ($removeEmptyString) - { - foreach ($array as $key => $string) - { - if (empty($string)) - { - unset($array[$key]); - } - } - return self::checkArray($array, false); - } - return $nr; - } - return false; - } - - /** - * Check if have a string with a length - * - * @input string The string to check - * - * @returns bool true on success - */ - public static function checkString($string) - { - if (isset($string) && is_string($string) && strlen($string) > 0) - { - return true; - } - return false; - } - - /** - * Check if we are connected - * Thanks https://stackoverflow.com/a/4860432/1429677 - * - * @returns bool true on success - */ - public static function isConnected() - { - // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? - $connected = @fsockopen("www.example.com", 80); - // website, port (try 80 or 443) - if ($connected) - { - //action when connected - $is_conn = true; - fclose($connected); - } - else - { - //action in connection failure - $is_conn = false; - } - return $is_conn; - } - - /** - * Merge an array of array's - * - * @input array The arrays you would like to merge - * - * @returns array on success - */ - public static function mergeArrays($arrays) - { - if(self::checkArray($arrays)) - { - $arrayBuket = array(); - foreach ($arrays as $array) - { - if (self::checkArray($array)) - { - $arrayBuket = array_merge($arrayBuket, $array); - } - } - return $arrayBuket; - } - return false; - } - - // typo sorry! - public static function sorten($string, $length = 40, $addTip = true) - { - return self::shorten($string, $length, $addTip); - } - - /** - * Shorten a string - * - * @input string The you would like to shorten - * - * @returns string on success - */ - public static function shorten($string, $length = 40, $addTip = true) - { - if (self::checkString($string)) - { - $initial = strlen($string); - $words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); - $words_count = count((array)$words); - - $word_length = 0; - $last_word = 0; - for (; $last_word < $words_count; ++$last_word) - { - $word_length += strlen($words[$last_word]); - if ($word_length > $length) - { - break; - } - } - - $newString = implode(array_slice($words, 0, $last_word)); - $final = strlen($newString); - if ($initial != $final && $addTip) - { - $title = self::shorten($string, 400 , false); - return ''.trim($newString).'...'; - } - elseif ($initial != $final && !$addTip) - { - return trim($newString).'...'; - } - } - return $string; - } - - /** - * Making strings safe (various ways) - * - * @input string The you would like to make safe - * - * @returns string on success - */ - public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) - { - if ($replaceNumbers === true) - { - // remove all numbers and replace with english text version (works well only up to millions) - $string = self::replaceNumbers($string); - } - // 0nly continue if we have a string - if (self::checkString($string)) - { - // create file name without the extention that is safe - if ($type === 'filename') - { - // make sure VDM is not in the string - $string = str_replace('VDM', 'vDm', $string); - // Remove anything which isn't a word, whitespace, number - // or any of the following caracters -_() - // If you don't need to handle multi-byte characters - // you can use preg_replace rather than mb_ereg_replace - // Thanks @Łukasz Rysiak! - // $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string); - $string = preg_replace("([^\w\s\d\-_\(\)])", '', $string); - // http://stackoverflow.com/a/2021729/1429677 - return preg_replace('/\s+/', ' ', $string); - } - // remove all other characters - $string = trim($string); - $string = preg_replace('/'.$spacer.'+/', ' ', $string); - $string = preg_replace('/\s+/', ' ', $string); - // Transliterate string - $string = self::transliterate($string); - // remove all and keep only characters - if ($keepOnlyCharacters) - { - $string = preg_replace("/[^A-Za-z ]/", '', $string); - } - // keep both numbers and characters - else - { - $string = preg_replace("/[^A-Za-z0-9 ]/", '', $string); - } - // select final adaptations - if ($type === 'L' || $type === 'strtolower') - { - // replace white space with underscore - $string = preg_replace('/\s+/', $spacer, $string); - // default is to return lower - return strtolower($string); - } - elseif ($type === 'W') - { - // return a string with all first letter of each word uppercase(no undersocre) - return ucwords(strtolower($string)); - } - elseif ($type === 'w' || $type === 'word') - { - // return a string with all lowercase(no undersocre) - return strtolower($string); - } - elseif ($type === 'Ww' || $type === 'Word') - { - // return a string with first letter of the first word uppercase and all the rest lowercase(no undersocre) - return ucfirst(strtolower($string)); - } - elseif ($type === 'WW' || $type === 'WORD') - { - // return a string with all the uppercase(no undersocre) - return strtoupper($string); - } - elseif ($type === 'U' || $type === 'strtoupper') - { - // replace white space with underscore - $string = preg_replace('/\s+/', $spacer, $string); - // return all upper - return strtoupper($string); - } - elseif ($type === 'F' || $type === 'ucfirst') - { - // replace white space with underscore - $string = preg_replace('/\s+/', $spacer, $string); - // return with first caracter to upper - return ucfirst(strtolower($string)); - } - elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase') - { - // convert all words to first letter uppercase - $string = ucwords(strtolower($string)); - // remove white space - $string = preg_replace('/\s+/', '', $string); - // now return first letter lowercase - return lcfirst($string); - } - // return string - return $string; - } - // not a string - return ''; - } - - public static function transliterate($string) - { - // set tag only once - if (!self::checkString(self::$langTag)) - { - // get global value - self::$langTag = JComponentHelper::getParams('com_hello_world')->get('language', 'en-GB'); - } - // Transliterate on the language requested - $lang = Language::getInstance(self::$langTag); - return $lang->transliterate($string); - } - - public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40) - { - if (self::checkString($var)) - { - $filter = new JFilterInput(); - $string = $filter->clean(html_entity_decode(htmlentities($var, ENT_COMPAT, $charset)), 'HTML'); - if ($shorten) - { - return self::shorten($string,$length); - } - return $string; - } - else - { - return ''; - } - } - - public static function replaceNumbers($string) - { - // set numbers array - $numbers = array(); - // first get all numbers - preg_match_all('!\d+!', $string, $numbers); - // check if we have any numbers - if (isset($numbers[0]) && self::checkArray($numbers[0])) - { - foreach ($numbers[0] as $number) - { - $searchReplace[$number] = self::numberToString((int)$number); - } - // now replace numbers in string - $string = str_replace(array_keys($searchReplace), array_values($searchReplace),$string); - // check if we missed any, strange if we did. - return self::replaceNumbers($string); - } - // return the string with no numbers remaining. - return $string; - } - - /** - * Convert an integer into an English word string - * Thanks to Tom Nicholson - * - * @input an int - * @returns a string - */ - public static function numberToString($x) - { - $nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven", - "eight", "nine", "ten", "eleven", "twelve", "thirteen", - "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", - "nineteen", "twenty", 30 => "thirty", 40 => "forty", - 50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty", - 90 => "ninety" ); - - if(!is_numeric($x)) - { - $w = $x; - } - elseif(fmod($x, 1) != 0) - { - $w = $x; - } - else - { - if($x < 0) - { - $w = 'minus '; - $x = -$x; - } - else - { - $w = ''; - // ... now $x is a non-negative integer. - } - - if($x < 21) // 0 to 20 - { - $w .= $nwords[$x]; - } - elseif($x < 100) // 21 to 99 - { - $w .= $nwords[10 * floor($x/10)]; - $r = fmod($x, 10); - if($r > 0) - { - $w .= ' '. $nwords[$r]; - } - } - elseif($x < 1000) // 100 to 999 - { - $w .= $nwords[floor($x/100)] .' hundred'; - $r = fmod($x, 100); - if($r > 0) - { - $w .= ' and '. self::numberToString($r); - } - } - elseif($x < 1000000) // 1000 to 999999 - { - $w .= self::numberToString(floor($x/1000)) .' thousand'; - $r = fmod($x, 1000); - if($r > 0) - { - $w .= ' '; - if($r < 100) - { - $w .= 'and '; - } - $w .= self::numberToString($r); - } - } - else // millions - { - $w .= self::numberToString(floor($x/1000000)) .' million'; - $r = fmod($x, 1000000); - if($r > 0) - { - $w .= ' '; - if($r < 100) - { - $w .= 'and '; - } - $w .= self::numberToString($r); - } - } - } - return $w; - } - - /** - * Random Key - * - * @returns a string - */ - public static function randomkey($size) - { - $bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ"; - $key = array(); - $bagsize = strlen($bag) - 1; - for ($i = 0; $i < $size; $i++) - { - $get = rand(0, $bagsize); - $key[] = $bag[$get]; - } - return implode($key); - } -} + } + + /** + * Get a variable + * + * @param string $table The table from which to get the variable + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * + * @return mix string/int/float + * + */ + public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'hello_world') + { + if(!$where) + { + $where = JFactory::getUser()->id; + } + // Get a db connection. + $db = JFactory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array($what))); + if (empty($table)) + { + $query->from($db->quoteName('#__'.$main)); + } + else + { + $query->from($db->quoteName('#__'.$main.'_'.$table)); + } + if (is_numeric($where)) + { + $query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where); + } + elseif (is_string($where)) + { + $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where)); + } + else + { + return false; + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + return $db->loadResult(); + } + return false; + } + + /** + * Get array of variables + * + * @param string $table The table from which to get the variables + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * @param bool $unique The switch to return a unique array + * + * @return array + * + */ + public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'hello_world', $unique = true) + { + if(!$where) + { + $where = JFactory::getUser()->id; + } + + if (!self::checkArray($where) && $where > 0) + { + $where = array($where); + } + + if (self::checkArray($where)) + { + // prep main <-- why? well if $main='' is empty then $table can be categories or users + if (self::checkString($main)) + { + $main = '_'.ltrim($main, '_'); + } + // Get a db connection. + $db = JFactory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + + $query->select($db->quoteName(array($what))); + if (empty($table)) + { + $query->from($db->quoteName('#__'.$main)); + } + else + { + $query->from($db->quoteName('#_'.$main.'_'.$table)); + } + // add strings to array search + if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) + { + $query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")'); + } + else + { + $query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')'); + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + if ($unique) + { + return array_unique($db->loadColumn()); + } + return $db->loadColumn(); + } + } + return false; + } + + public static function isPublished($id,$type) + { + if ($type == 'raw') + { + $type = 'item'; + } + $db = JFactory::getDbo(); + $query = $db->getQuery(true); + $query->select(array('a.published')); + $query->from('#__hello_world_'.$type.' AS a'); + $query->where('a.id = '. (int) $id); + $query->where('a.published = 1'); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return true; + } + return false; + } + + public static function getGroupName($id) + { + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select(array('a.title')); + $query->from('#__usergroups AS a'); + $query->where('a.id = '. (int) $id); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return $db->loadResult(); + } + return $id; + } + + /** + * Get the action permissions + * + * @param string $view The related view name + * @param int $record The item to act upon + * @param string $views The related list view name + * @param mixed $target Only get this permission (like edit, create, delete) + * @param string $component The target component + * @param object $user The user whose permissions we are loading + * + * @return object The JObject of permission/authorised actions + * + */ + public static function getActions($view, &$record = null, $views = null, $target = null, $component = 'hello_world', $user = 'null') + { + // load the user if not given + if (!self::checkObject($user)) + { + // get the user object + $user = JFactory::getUser(); + } + // load the JObject + $result = new JObject; + // make view name safe (just incase) + $view = self::safeString($view); + if (self::checkString($views)) + { + $views = self::safeString($views); + } + // get all actions from component + $actions = JAccess::getActionsFromFile( + JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', + "/access/section[@name='component']/" + ); + // if non found then return empty JObject + if (empty($actions)) + { + return $result; + } + // get created by if not found + if (self::checkObject($record) && !isset($record->created_by) && isset($record->id)) + { + $record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component); + } + // set actions only set in component settings + $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); + // check if we have a target + $checkTarget = false; + if ($target) + { + // convert to an array + if (self::checkString($target)) + { + $target = array($target); + } + // check if we are good to go + if (self::checkArray($target)) + { + $checkTarget = true; + } + } + // loop the actions and set the permissions + foreach ($actions as $action) + { + // check target action filter + if ($checkTarget && self::filterActions($view, $action->name, $target)) + { + continue; + } + // set to use component default + $fallback = true; + // reset permission per/action + $permission = false; + $catpermission = false; + // set area + $area = 'comp'; + // check if the record has an ID and the action is item related (not a component action) + if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && + (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) + { + // we are in item + $area = 'item'; + // The record has been set. Check the record permissions. + $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); + // if no permission found, check edit own + if (!$permission) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // the correct target + $coreCheck = (array) explode('.', $action->name); + // check that we have both local and global access + if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && + $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0) + { + // we are in item + $area = 'category'; + // set the core check + $coreCheck = explode('.', $action->name); + $core = $coreCheck[0]; + // make sure we use the core. action check for the categories + if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) + { + $coreCheck[0] = 'core'; + $categoryCheck = implode('.', $coreCheck); + } + else + { + $categoryCheck = $action->name; + } + // The record has a category. Check the category permissions. + $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); + if (!$catpermission && !is_null($catpermission)) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // check that we have both local and global access + if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && + $user->authorise($core . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + } + } + // if allowed then fallback on component global settings + if ($fallback) + { + // if item/category blocks access then don't fall back on global + if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) + { + // do not allow + $result->set($action->name, false); + } + // Finally remember the global settings have the final say. (even if item allow) + // The local item permissions can block, but it can't open and override of global permissions. + // Since items are created by users and global permissions is set by system admin. + else + { + $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); + } + } + } + return $result; + } + + /** + * Filter the action permissions + * + * @param string $action The action to check + * @param array $targets The array of target actions + * + * @return boolean true if action should be filtered out + * + */ + protected static function filterActions(&$view, &$action, &$targets) + { + foreach ($targets as $target) + { + if (strpos($action, $view . '.' . $target) !== false || + strpos($action, 'core.' . $target) !== false) + { + return false; + break; + } + } + return true; + } + + /** + * Check if have an json string + * + * @input string The json string to check + * + * @returns bool true on success + */ + public static function checkJson($string) + { + if (self::checkString($string)) + { + json_decode($string); + return (json_last_error() === JSON_ERROR_NONE); + } + return false; + } + + /** + * Check if have an object with a length + * + * @input object The object to check + * + * @returns bool true on success + */ + public static function checkObject($object) + { + if (isset($object) && is_object($object)) + { + return count((array)$object) > 0; + } + return false; + } + + /** + * Check if have an array with a length + * + * @input array The array to check + * + * @returns bool/int number of items in array on success + */ + public static function checkArray($array, $removeEmptyString = false) + { + if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) + { + // also make sure the empty strings are removed + if ($removeEmptyString) + { + foreach ($array as $key => $string) + { + if (empty($string)) + { + unset($array[$key]); + } + } + return self::checkArray($array, false); + } + return $nr; + } + return false; + } + + /** + * Check if have a string with a length + * + * @input string The string to check + * + * @returns bool true on success + */ + public static function checkString($string) + { + if (isset($string) && is_string($string) && strlen($string) > 0) + { + return true; + } + return false; + } + + /** + * Check if we are connected + * Thanks https://stackoverflow.com/a/4860432/1429677 + * + * @returns bool true on success + */ + public static function isConnected() + { + // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? + $connected = @fsockopen("www.example.com", 80); + // website, port (try 80 or 443) + if ($connected) + { + //action when connected + $is_conn = true; + fclose($connected); + } + else + { + //action in connection failure + $is_conn = false; + } + return $is_conn; + } + + /** + * Merge an array of array's + * + * @input array The arrays you would like to merge + * + * @returns array on success + */ + public static function mergeArrays($arrays) + { + if(self::checkArray($arrays)) + { + $arrayBuket = array(); + foreach ($arrays as $array) + { + if (self::checkArray($array)) + { + $arrayBuket = array_merge($arrayBuket, $array); + } + } + return $arrayBuket; + } + return false; + } + + // typo sorry! + public static function sorten($string, $length = 40, $addTip = true) + { + return self::shorten($string, $length, $addTip); + } + + /** + * Shorten a string + * + * @input string The you would like to shorten + * + * @returns string on success + */ + public static function shorten($string, $length = 40, $addTip = true) + { + if (self::checkString($string)) + { + $initial = strlen($string); + $words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); + $words_count = count((array)$words); + + $word_length = 0; + $last_word = 0; + for (; $last_word < $words_count; ++$last_word) + { + $word_length += strlen($words[$last_word]); + if ($word_length > $length) + { + break; + } + } + + $newString = implode(array_slice($words, 0, $last_word)); + $final = strlen($newString); + if ($initial != $final && $addTip) + { + $title = self::shorten($string, 400 , false); + return ''.trim($newString).'...'; + } + elseif ($initial != $final && !$addTip) + { + return trim($newString).'...'; + } + } + return $string; + } + + /** + * Making strings safe (various ways) + * + * @input string The you would like to make safe + * + * @returns string on success + */ + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) + { + if ($replaceNumbers === true) + { + // remove all numbers and replace with english text version (works well only up to millions) + $string = self::replaceNumbers($string); + } + // 0nly continue if we have a string + if (self::checkString($string)) + { + // create file name without the extention that is safe + if ($type === 'filename') + { + // make sure VDM is not in the string + $string = str_replace('VDM', 'vDm', $string); + // Remove anything which isn't a word, whitespace, number + // or any of the following caracters -_() + // If you don't need to handle multi-byte characters + // you can use preg_replace rather than mb_ereg_replace + // Thanks @Łukasz Rysiak! + // $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string); + $string = preg_replace("([^\w\s\d\-_\(\)])", '', $string); + // http://stackoverflow.com/a/2021729/1429677 + return preg_replace('/\s+/', ' ', $string); + } + // remove all other characters + $string = trim($string); + $string = preg_replace('/'.$spacer.'+/', ' ', $string); + $string = preg_replace('/\s+/', ' ', $string); + // Transliterate string + $string = self::transliterate($string); + // remove all and keep only characters + if ($keepOnlyCharacters) + { + $string = preg_replace("/[^A-Za-z ]/", '', $string); + } + // keep both numbers and characters + else + { + $string = preg_replace("/[^A-Za-z0-9 ]/", '', $string); + } + // select final adaptations + if ($type === 'L' || $type === 'strtolower') + { + // replace white space with underscore + $string = preg_replace('/\s+/', $spacer, $string); + // default is to return lower + return strtolower($string); + } + elseif ($type === 'W') + { + // return a string with all first letter of each word uppercase(no undersocre) + return ucwords(strtolower($string)); + } + elseif ($type === 'w' || $type === 'word') + { + // return a string with all lowercase(no undersocre) + return strtolower($string); + } + elseif ($type === 'Ww' || $type === 'Word') + { + // return a string with first letter of the first word uppercase and all the rest lowercase(no undersocre) + return ucfirst(strtolower($string)); + } + elseif ($type === 'WW' || $type === 'WORD') + { + // return a string with all the uppercase(no undersocre) + return strtoupper($string); + } + elseif ($type === 'U' || $type === 'strtoupper') + { + // replace white space with underscore + $string = preg_replace('/\s+/', $spacer, $string); + // return all upper + return strtoupper($string); + } + elseif ($type === 'F' || $type === 'ucfirst') + { + // replace white space with underscore + $string = preg_replace('/\s+/', $spacer, $string); + // return with first caracter to upper + return ucfirst(strtolower($string)); + } + elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase') + { + // convert all words to first letter uppercase + $string = ucwords(strtolower($string)); + // remove white space + $string = preg_replace('/\s+/', '', $string); + // now return first letter lowercase + return lcfirst($string); + } + // return string + return $string; + } + // not a string + return ''; + } + + public static function transliterate($string) + { + // set tag only once + if (!self::checkString(self::$langTag)) + { + // get global value + self::$langTag = JComponentHelper::getParams('com_hello_world')->get('language', 'en-GB'); + } + // Transliterate on the language requested + $lang = Language::getInstance(self::$langTag); + return $lang->transliterate($string); + } + + public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40) + { + if (self::checkString($var)) + { + $filter = new JFilterInput(); + $string = $filter->clean(html_entity_decode(htmlentities($var, ENT_COMPAT, $charset)), 'HTML'); + if ($shorten) + { + return self::shorten($string,$length); + } + return $string; + } + else + { + return ''; + } + } + + public static function replaceNumbers($string) + { + // set numbers array + $numbers = array(); + // first get all numbers + preg_match_all('!\d+!', $string, $numbers); + // check if we have any numbers + if (isset($numbers[0]) && self::checkArray($numbers[0])) + { + foreach ($numbers[0] as $number) + { + $searchReplace[$number] = self::numberToString((int)$number); + } + // now replace numbers in string + $string = str_replace(array_keys($searchReplace), array_values($searchReplace),$string); + // check if we missed any, strange if we did. + return self::replaceNumbers($string); + } + // return the string with no numbers remaining. + return $string; + } + + /** + * Convert an integer into an English word string + * Thanks to Tom Nicholson + * + * @input an int + * @returns a string + */ + public static function numberToString($x) + { + $nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven", + "eight", "nine", "ten", "eleven", "twelve", "thirteen", + "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", + "nineteen", "twenty", 30 => "thirty", 40 => "forty", + 50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty", + 90 => "ninety" ); + + if(!is_numeric($x)) + { + $w = $x; + } + elseif(fmod($x, 1) != 0) + { + $w = $x; + } + else + { + if($x < 0) + { + $w = 'minus '; + $x = -$x; + } + else + { + $w = ''; + // ... now $x is a non-negative integer. + } + + if($x < 21) // 0 to 20 + { + $w .= $nwords[$x]; + } + elseif($x < 100) // 21 to 99 + { + $w .= $nwords[10 * floor($x/10)]; + $r = fmod($x, 10); + if($r > 0) + { + $w .= ' '. $nwords[$r]; + } + } + elseif($x < 1000) // 100 to 999 + { + $w .= $nwords[floor($x/100)] .' hundred'; + $r = fmod($x, 100); + if($r > 0) + { + $w .= ' and '. self::numberToString($r); + } + } + elseif($x < 1000000) // 1000 to 999999 + { + $w .= self::numberToString(floor($x/1000)) .' thousand'; + $r = fmod($x, 1000); + if($r > 0) + { + $w .= ' '; + if($r < 100) + { + $w .= 'and '; + } + $w .= self::numberToString($r); + } + } + else // millions + { + $w .= self::numberToString(floor($x/1000000)) .' million'; + $r = fmod($x, 1000000); + if($r > 0) + { + $w .= ' '; + if($r < 100) + { + $w .= 'and '; + } + $w .= self::numberToString($r); + } + } + } + return $w; + } + + /** + * Random Key + * + * @returns a string + */ + public static function randomkey($size) + { + $bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ"; + $key = array(); + $bagsize = strlen($bag) - 1; + for ($i = 0; $i < $size; $i++) + { + $get = rand(0, $bagsize); + $key[] = $bag[$get]; + } + return implode($key); + } +} diff --git a/site/helpers/route.php b/site/helpers/route.php index 09ae8e6..fc4a0be 100644 --- a/site/helpers/route.php +++ b/site/helpers/route.php @@ -1,31 +1,31 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Hello_world Route Helper - **/ -abstract class Hello_worldHelperRoute -{ +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage route.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Hello_world Route Helper + **/ +abstract class Hello_worldHelperRoute +{ protected static $lookup; /** @@ -112,196 +112,196 @@ abstract class Hello_worldHelperRoute } return $link; - } - - /** - * Get the URL route for hello_world category from a category ID and language - * - * @param mixed $catid The id of the items's category either an integer id or a instance of JCategoryNode - * @param mixed $language The id of the language being used. - * - * @return string The link to the contact - * - * @since 1.5 - */ - public static function getCategoryRoute_keep_for_later($catid, $language = 0) - { - if ($catid instanceof JCategoryNode) - { - $id = $catid->id; - $category = $catid; - } - else - { - throw new Exception('First parameter must be JCategoryNode'); - } - - $views = array(); - $view = $views[$category->extension]; - - if ($id < 1 || !($category instanceof JCategoryNode)) - { - $link = ''; - } - else - { - //Create the link - $link = 'index.php?option=com_hello_world&view='.$view.'&category='.$category->slug; - - $needles = array( - $view => array($id), - 'category' => array($id) - ); - - if ($language && $language != "*" && JLanguageMultilang::isEnabled()) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select('a.sef AS sef') - ->select('a.lang_code AS lang_code') - ->from('#__languages AS a'); - - $db->setQuery($query); - $langs = $db->loadObjectList(); - foreach ($langs as $lang) - { - if ($language == $lang->lang_code) - { - $link .= '&lang='.$lang->sef; - $needles['language'] = $language; - } - } - } - - if ($item = self::_findItem($needles,'category')) - { - - $link .= '&Itemid='.$item; - } - else - { - if ($category) - { - $catids = array_reverse($category->getPath()); - $needles = array( - 'category' => $catids - ); - if ($item = self::_findItem($needles,'category')) - { - $link .= '&Itemid='.$item; - } - elseif ($item = self::_findItem(null, 'category')) - { - $link .= '&Itemid='.$item; - } - } - } - } - return $link; - } - - protected static function _findItem($needles = null,$type = null) - { - $app = JFactory::getApplication(); - $menus = $app->getMenu('site'); - $language = isset($needles['language']) ? $needles['language'] : '*'; - - // Prepare the reverse lookup array. - if (!isset(self::$lookup[$language])) - { - self::$lookup[$language] = array(); - - $component = JComponentHelper::getComponent('com_hello_world'); - - $attributes = array('component_id'); - $values = array($component->id); - - if ($language != '*') - { - $attributes[] = 'language'; - $values[] = array($needles['language'], '*'); - } - - $items = $menus->getItems($attributes, $values); - - foreach ($items as $item) - { - if (isset($item->query) && isset($item->query['view'])) - { - $view = $item->query['view']; - - if (!isset(self::$lookup[$language][$view])) - { - self::$lookup[$language][$view] = array(); - } - - if (isset($item->query['id'])) - { - /** - * Here it will become a bit tricky - * language != * can override existing entries - * language == * cannot override existing entries - */ - if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*') - { - self::$lookup[$language][$view][$item->query['id']] = $item->id; - } - } - else - { - self::$lookup[$language][$view][0] = $item->id; - } - } - } - } - - if ($needles) - { - foreach ($needles as $view => $ids) - { - if (isset(self::$lookup[$language][$view])) - { - if (Hello_worldHelper::checkArray($ids)) - { - foreach ($ids as $id) - { - if (isset(self::$lookup[$language][$view][(int) $id])) - { - return self::$lookup[$language][$view][(int) $id]; - } - } - } - elseif (isset(self::$lookup[$language][$view][0])) - { - return self::$lookup[$language][$view][0]; - } - } - } - } - - if ($type) - { - // Check if the global menu item has been set. - $params = JComponentHelper::getParams('com_hello_world'); - if ($item = $params->get($type.'_menu', 0)) - { - return $item; - } - } - - // Check if the active menuitem matches the requested language - $active = $menus->getActive(); - - if ($active - && $active->component == 'com_hello_world' - && ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled())) - { - return $active->id; - } - - // If not found, return language specific home link - $default = $menus->getDefault($language); - - return !empty($default->id) ? $default->id : null; - } -} + } + + /** + * Get the URL route for hello_world category from a category ID and language + * + * @param mixed $catid The id of the items's category either an integer id or a instance of JCategoryNode + * @param mixed $language The id of the language being used. + * + * @return string The link to the contact + * + * @since 1.5 + */ + public static function getCategoryRoute_keep_for_later($catid, $language = 0) + { + if ($catid instanceof JCategoryNode) + { + $id = $catid->id; + $category = $catid; + } + else + { + throw new Exception('First parameter must be JCategoryNode'); + } + + $views = array(); + $view = $views[$category->extension]; + + if ($id < 1 || !($category instanceof JCategoryNode)) + { + $link = ''; + } + else + { + //Create the link + $link = 'index.php?option=com_hello_world&view='.$view.'&category='.$category->slug; + + $needles = array( + $view => array($id), + 'category' => array($id) + ); + + if ($language && $language != "*" && JLanguageMultilang::isEnabled()) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('a.sef AS sef') + ->select('a.lang_code AS lang_code') + ->from('#__languages AS a'); + + $db->setQuery($query); + $langs = $db->loadObjectList(); + foreach ($langs as $lang) + { + if ($language == $lang->lang_code) + { + $link .= '&lang='.$lang->sef; + $needles['language'] = $language; + } + } + } + + if ($item = self::_findItem($needles,'category')) + { + + $link .= '&Itemid='.$item; + } + else + { + if ($category) + { + $catids = array_reverse($category->getPath()); + $needles = array( + 'category' => $catids + ); + if ($item = self::_findItem($needles,'category')) + { + $link .= '&Itemid='.$item; + } + elseif ($item = self::_findItem(null, 'category')) + { + $link .= '&Itemid='.$item; + } + } + } + } + return $link; + } + + protected static function _findItem($needles = null,$type = null) + { + $app = JFactory::getApplication(); + $menus = $app->getMenu('site'); + $language = isset($needles['language']) ? $needles['language'] : '*'; + + // Prepare the reverse lookup array. + if (!isset(self::$lookup[$language])) + { + self::$lookup[$language] = array(); + + $component = JComponentHelper::getComponent('com_hello_world'); + + $attributes = array('component_id'); + $values = array($component->id); + + if ($language != '*') + { + $attributes[] = 'language'; + $values[] = array($needles['language'], '*'); + } + + $items = $menus->getItems($attributes, $values); + + foreach ($items as $item) + { + if (isset($item->query) && isset($item->query['view'])) + { + $view = $item->query['view']; + + if (!isset(self::$lookup[$language][$view])) + { + self::$lookup[$language][$view] = array(); + } + + if (isset($item->query['id'])) + { + /** + * Here it will become a bit tricky + * language != * can override existing entries + * language == * cannot override existing entries + */ + if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*') + { + self::$lookup[$language][$view][$item->query['id']] = $item->id; + } + } + else + { + self::$lookup[$language][$view][0] = $item->id; + } + } + } + } + + if ($needles) + { + foreach ($needles as $view => $ids) + { + if (isset(self::$lookup[$language][$view])) + { + if (Hello_worldHelper::checkArray($ids)) + { + foreach ($ids as $id) + { + if (isset(self::$lookup[$language][$view][(int) $id])) + { + return self::$lookup[$language][$view][(int) $id]; + } + } + } + elseif (isset(self::$lookup[$language][$view][0])) + { + return self::$lookup[$language][$view][0]; + } + } + } + } + + if ($type) + { + // Check if the global menu item has been set. + $params = JComponentHelper::getParams('com_hello_world'); + if ($item = $params->get($type.'_menu', 0)) + { + return $item; + } + } + + // Check if the active menuitem matches the requested language + $active = $menus->getActive(); + + if ($active + && $active->component == 'com_hello_world' + && ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled())) + { + return $active->id; + } + + // If not found, return language specific home link + $default = $menus->getDefault($language); + + return !empty($default->id) ? $default->id : null; + } +} diff --git a/site/language/en-GB/en-GB.com_hello_world.ini b/site/language/en-GB/en-GB.com_hello_world.ini index b09bf2d..241997d 100644 --- a/site/language/en-GB/en-GB.com_hello_world.ini +++ b/site/language/en-GB/en-GB.com_hello_world.ini @@ -37,7 +37,6 @@ COM_HELLO_WORLD_GREETING_CREATED_DATE_LABEL="Created Date" COM_HELLO_WORLD_GREETING_DETAILS="Details" COM_HELLO_WORLD_GREETING_EDIT="Editing the Greeting" COM_HELLO_WORLD_GREETING_ERROR_UNIQUE_ALIAS="Another Greeting has the same alias." -COM_HELLO_WORLD_GREETING_GREETING="Greeting" COM_HELLO_WORLD_GREETING_GREETING_DESCRIPTION="Enter a greeting" COM_HELLO_WORLD_GREETING_GREETING_HINT="Greeting here!" COM_HELLO_WORLD_GREETING_GREETING_LABEL="Greeting" diff --git a/site/layouts/greeting/details_left.php b/site/layouts/greeting/details_left.php index 49f2333..1033f06 100644 --- a/site/layouts/greeting/details_left.php +++ b/site/layouts/greeting/details_left.php @@ -1,51 +1,51 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( - 'greeting' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage details_left.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'greeting' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/site/layouts/greeting/metadata.php b/site/layouts/greeting/metadata.php index 1af483a..cf7d1ee 100644 --- a/site/layouts/greeting/metadata.php +++ b/site/layouts/greeting/metadata.php @@ -1,50 +1,50 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$form = $displayData->getForm(); - -// JLayout for standard handling of metadata fields in the administrator content edit screens. -$fieldSets = $form->getFieldsets('metadata'); -?> - - $fieldSet) : ?> - description) && trim($fieldSet->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(); - } - } ?> - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage metadata.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$form = $displayData->getForm(); + +// JLayout for standard handling of metadata fields in the administrator content edit screens. +$fieldSets = $form->getFieldsets('metadata'); +?> + + $fieldSet) : ?> + description) && trim($fieldSet->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/site/layouts/greeting/publishing.php b/site/layouts/greeting/publishing.php index e3d12cf..382da4d 100644 --- a/site/layouts/greeting/publishing.php +++ b/site/layouts/greeting/publishing.php @@ -1,40 +1,40 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage publishing.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( 'title', 'created', 'created_by', @@ -45,17 +45,17 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'access', 'version', 'hits', - 'id' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/site/models/forms/greeting.js b/site/models/forms/greeting.js index 020e5df..a88eabf 100644 --- a/site/models/forms/greeting.js +++ b/site/models/forms/greeting.js @@ -1,20 +1,20 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage greeting.js - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greeting.js + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + + diff --git a/site/models/forms/greeting.xml b/site/models/forms/greeting.xml index f71faac..a3c8a77 100644 --- a/site/models/forms/greeting.xml +++ b/site/models/forms/greeting.xml @@ -1,8 +1,8 @@ - -
+ +
@@ -154,8 +154,8 @@ cols="30" rows="2" />
- - + +
@@ -176,5 +176,5 @@ component="com_hello_world" section="greeting" /> -
+
\ No newline at end of file diff --git a/site/models/greet.php b/site/models/greet.php index b15f93c..ecd733e 100644 --- a/site/models/greet.php +++ b/site/models/greet.php @@ -1,91 +1,91 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Hello_world Greet Model - */ -class Hello_worldModelGreet extends JModelItem -{ - /** - * Model context string. - * - * @var string - */ - protected $_context = 'com_hello_world.greet'; - - /** - * Model user data. - * - * @var strings - */ - protected $user; - protected $userId; - protected $guest; - protected $groups; - protected $levels; - protected $app; - protected $input; - protected $uikitComp; - - /** - * @var object item - */ - protected $item; - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @since 1.6 - * - * @return void - */ - protected function populateState() - { - $this->app = JFactory::getApplication(); - $this->input = $this->app->input; - // Get the itme main id - $id = $this->input->getInt('id', null); - $this->setState('greet.id', $id); - - // Load the parameters. - $params = $this->app->getParams(); - $this->setState('params', $params); - parent::populateState(); - } - - /** - * Method to get article data. - * - * @param integer $pk The id of the article. - * - * @return mixed Menu item data object on success, false on failure. - */ - public function getItem($pk = null) - { +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greet.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Hello_world Greet Model + */ +class Hello_worldModelGreet extends JModelItem +{ + /** + * Model context string. + * + * @var string + */ + protected $_context = 'com_hello_world.greet'; + + /** + * Model user data. + * + * @var strings + */ + protected $user; + protected $userId; + protected $guest; + protected $groups; + protected $levels; + protected $app; + protected $input; + protected $uikitComp; + + /** + * @var object item + */ + protected $item; + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @since 1.6 + * + * @return void + */ + protected function populateState() + { + $this->app = JFactory::getApplication(); + $this->input = $this->app->input; + // Get the itme main id + $id = $this->input->getInt('id', null); + $this->setState('greet.id', $id); + + // Load the parameters. + $params = $this->app->getParams(); + $this->setState('params', $params); + parent::populateState(); + } + + /** + * Method to get article data. + * + * @param integer $pk The id of the article. + * + * @return mixed Menu item data object on success, false on failure. + */ + public function getItem($pk = null) + { $this->user = JFactory::getUser(); // check if this user has permission to access item if (!$this->user->authorise('site.greet.access', 'com_hello_world')) @@ -95,24 +95,24 @@ class Hello_worldModelGreet extends JModelItem // redirect away to the home page if no access allowed. $app->redirect(JURI::root()); return false; - } - $this->userId = $this->user->get('id'); - $this->guest = $this->user->get('guest'); - $this->groups = $this->user->get('groups'); - $this->authorisedGroups = $this->user->getAuthorisedGroups(); - $this->levels = $this->user->getAuthorisedViewLevels(); - $this->initSet = true; - - $pk = (!empty($pk)) ? $pk : (int) $this->getState('greet.id'); - - if ($this->_item === null) - { - $this->_item = array(); - } - - if (!isset($this->_item[$pk])) - { - try + } + $this->userId = $this->user->get('id'); + $this->guest = $this->user->get('guest'); + $this->groups = $this->user->get('groups'); + $this->authorisedGroups = $this->user->getAuthorisedGroups(); + $this->levels = $this->user->getAuthorisedViewLevels(); + $this->initSet = true; + + $pk = (!empty($pk)) ? $pk : (int) $this->getState('greet.id'); + + if ($this->_item === null) + { + $this->_item = array(); + } + + if (!isset($this->_item[$pk])) + { + try { // Get a db connection. $db = JFactory::getDbo(); @@ -142,24 +142,24 @@ class Hello_worldModelGreet extends JModelItem } // set data object to item. - $this->_item[$pk] = $data; - } - catch (Exception $e) - { - if ($e->getCode() == 404) - { - // Need to go thru the error handler to allow Redirect to work. - JError::raiseWarning(404, $e->getMessage()); - } - else - { - $this->setError($e); - $this->_item[$pk] = false; - } - } - } - - return $this->_item[$pk]; + $this->_item[$pk] = $data; + } + catch (Exception $e) + { + if ($e->getCode() == 404) + { + // Need to go thru the error handler to allow Redirect to work. + JError::raiseWarning(404, $e->getMessage()); + } + else + { + $this->setError($e); + $this->_item[$pk] = false; + } + } + } + + return $this->_item[$pk]; } /** @@ -175,5 +175,5 @@ class Hello_worldModelGreet extends JModelItem return $this->uikitComp; } return false; - } -} + } +} diff --git a/site/models/greeting.php b/site/models/greeting.php index ca3ca4d..374528f 100644 --- a/site/models/greeting.php +++ b/site/models/greeting.php @@ -1,134 +1,128 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greeting.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + use Joomla\Registry\Registry; use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Hello_world Greeting Model - */ -class Hello_worldModelGreeting extends JModelAdmin -{ - /** - * The tab layout fields array. - * - * @var array - */ +use Joomla\Utilities\ArrayHelper; + +/** + * Hello_world Greeting Model + */ +class Hello_worldModelGreeting extends JModelAdmin +{ + /** + * The tab layout fields array. + * + * @var array + */ protected $tabLayoutFields = array( 'details' => array( 'left' => array( 'greeting' ) ) - ); - - /** - * @var string The prefix to use with controller messages. - * @since 1.6 - */ - protected $text_prefix = 'COM_HELLO_WORLD'; - - /** - * The type alias for this content type. - * - * @var string - * @since 3.2 - */ - public $typeAlias = 'com_hello_world.greeting'; - - /** - * 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 = 'greeting', $prefix = 'Hello_worldTable', $config = array()) - { - // add table path for when model gets used from other component - $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_hello_world/tables'); - // get instance of the table - 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) && !is_array($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->id)) - { - $item->tags = new JHelperTags; - $item->tags->getTagIds($item->id, 'com_hello_world.greeting'); - } - } - - 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. - * @param array $options Optional array of options for the form creation. - * - * @return mixed A JForm object on success, false on failure - * - * @since 1.6 - */ - public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) - { - // set load data option + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_HELLO_WORLD'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_hello_world.greeting'; + + /** + * 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 = 'greeting', $prefix = 'Hello_worldTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_hello_world/tables'); + // get instance of the table + 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) && !is_array($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(); + } + } + + 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. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option $options['load_data'] = $loadData; // check if xpath was set in options $xpath = false; @@ -221,29 +215,29 @@ class Hello_worldModelGreeting extends JModelAdmin $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_hello_world/models/forms/greeting.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) + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_hello_world/js/greeting.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)) { @@ -256,19 +250,19 @@ class Hello_worldModelGreeting extends JModelAdmin // The record has been set. Check the record permissions. return $user->authorise('core.delete', 'com_hello_world.greeting.' . (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) + 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; @@ -283,103 +277,103 @@ class Hello_worldModelGreeting extends JModelAdmin } } // 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') + 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_hello_world.greeting.'. ((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('#__hello_world_greeting')); - $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_hello_world.edit.greeting.data', array()); - - if (empty($data)) - { - $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_hello_world.greeting', $data); - } - - return $data; + return JFactory::getUser()->authorise('core.edit', 'com_hello_world.greeting.'. ((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('#__hello_world_greeting')); + $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_hello_world.edit.greeting.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_hello_world.greeting', $data); + } + + return $data; } /** @@ -392,141 +386,141 @@ class Hello_worldModelGreeting extends JModelAdmin protected function getUniqueFields() { 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); - ArrayHelper::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 = Hello_worldHelper::getActions('greeting'); - $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 = ArrayHelper::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; + } + + /** + * 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); + ArrayHelper::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 = Hello_worldHelper::getActions('greeting'); + $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 = ArrayHelper::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; } /** @@ -778,38 +772,38 @@ class Hello_worldModelGreeting extends JModelAdmin $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 Params Items to data - if (isset($data['params']) && is_array($data['params'])) - { - $params = new JRegistry; - $params->loadArray($data['params']); - $data['params'] = (string) $params; + } + + /** + * 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 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 unique field for save as copy @@ -824,37 +818,37 @@ class Hello_worldModelGreeting extends JModelAdmin $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); } } - } - - if (parent::save($data)) - { - return true; - } - return false; - } - - /** - * Method to generate a unique value. - * - * @param string $field name. - * @param string $value data. - * - * @return string New value. - * - * @since 3.0 - */ - protected function generateUnique($field,$value) - { - - // set field value unique - $table = $this->getTable(); - - while ($table->load(array($field => $value))) - { - $value = StringHelper::increment($value); - } - - return $value; + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; } /** @@ -877,5 +871,5 @@ class Hello_worldModelGreeting extends JModelAdmin } return $title; - } -} + } +} diff --git a/site/models/greetings.php b/site/models/greetings.php index 07e4f8d..4e00128 100644 --- a/site/models/greetings.php +++ b/site/models/greetings.php @@ -1,63 +1,63 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Hello_world Model for Greetings - */ -class Hello_worldModelGreetings extends JModelList -{ - /** - * Model user data. - * - * @var strings - */ - protected $user; - protected $userId; - protected $guest; - protected $groups; - protected $levels; - protected $app; - protected $input; - protected $uikitComp; - - /** - * Method to build an SQL query to load the list data. - * - * @return string An SQL query - */ - protected function getListQuery() - { - // Get the current user for authorisation checks - $this->user = JFactory::getUser(); - $this->userId = $this->user->get('id'); - $this->guest = $this->user->get('guest'); - $this->groups = $this->user->get('groups'); - $this->authorisedGroups = $this->user->getAuthorisedGroups(); - $this->levels = $this->user->getAuthorisedViewLevels(); - $this->app = JFactory::getApplication(); - $this->input = $this->app->input; +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage greetings.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Hello_world Model for Greetings + */ +class Hello_worldModelGreetings extends JModelList +{ + /** + * Model user data. + * + * @var strings + */ + protected $user; + protected $userId; + protected $guest; + protected $groups; + protected $levels; + protected $app; + protected $input; + protected $uikitComp; + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the current user for authorisation checks + $this->user = JFactory::getUser(); + $this->userId = $this->user->get('id'); + $this->guest = $this->user->get('guest'); + $this->groups = $this->user->get('groups'); + $this->authorisedGroups = $this->user->getAuthorisedGroups(); + $this->levels = $this->user->getAuthorisedViewLevels(); + $this->app = JFactory::getApplication(); + $this->input = $this->app->input; $this->initSet = true; // Make sure all records load, since no pagination allowed. $this->setState('list.limit', 0); @@ -76,16 +76,16 @@ class Hello_worldModelGreetings extends JModelList $query->where('a.published = 1'); // return the query object - return $query; - } - - /** - * Method to get an array of data items. - * - * @return mixed An array of data items on success, false on failure. - */ - public function getItems() - { + return $query; + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { $user = JFactory::getUser(); // check if this user has permission to access item if (!$user->authorise('site.greetings.access', 'com_hello_world')) @@ -95,11 +95,11 @@ class Hello_worldModelGreetings extends JModelList // redirect away to the home page if no access allowed. $app->redirect(JURI::root()); return false; - } - // load parent items - $items = parent::getItems(); - - // Get the global params + } + // load parent items + $items = parent::getItems(); + + // Get the global params $globalParams = JComponentHelper::getParams('com_hello_world', true); // Insure all item fields are adapted where needed. @@ -110,10 +110,10 @@ class Hello_worldModelGreetings extends JModelList // Always create a slug for sef URL's $item->slug = (isset($item->alias) && isset($item->id)) ? $item->id.':'.$item->alias : $item->id; } - } - - // return items - return $items; + } + + // return items + return $items; } /** @@ -129,5 +129,5 @@ class Hello_worldModelGreetings extends JModelList return $this->uikitComp; } return false; - } -} + } +} diff --git a/site/router.php b/site/router.php index 27a6512..17ac361 100644 --- a/site/router.php +++ b/site/router.php @@ -1,130 +1,130 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Routing class from com_hello_world - * - * @since 3.3 - */ -class Hello_worldRouter extends JComponentRouterBase -{ - /** - * Build the route for the com_hello_world component - * - * @param array &$query An array of URL arguments - * - * @return array The URL arguments to use to assemble the subsequent URL. - * - * @since 3.3 - */ - public function build(&$query) - { - $segments = array(); - - // Get a menu item based on Itemid or currently active - $params = JComponentHelper::getParams('com_hello_world'); - - if (empty($query['Itemid'])) - { - $menuItem = $this->menu->getActive(); - } - else - { - $menuItem = $this->menu->getItem($query['Itemid']); - } - - $mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view']; - $mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id']; - - if (isset($query['view'])) - { - $view = $query['view']; - - if (empty($query['Itemid'])) - { - $segments[] = $query['view']; - } - - unset($query['view']); - } - - // Are we dealing with a item that is attached to a menu item? - if (isset($view) && ($mView == $view) and (isset($query['id'])) and ($mId == (int) $query['id'])) - { - unset($query['view']); - unset($query['catid']); - unset($query['id']); - return $segments; - } - - if (isset($view) && isset($query['id']) && ($view === 'greeting' || $view === 'greet' || $view === 'greetings')) - { - if ($mId != (int) $query['id'] || $mView != $view) - { - if (($view === 'greeting' || $view === 'greet' || $view === 'greetings')) - { - $segments[] = $view; - $id = explode(':', $query['id']); - if (count($id) == 2) - { - $segments[] = $id[1]; - } - else - { - $segments[] = $id[0]; - } - } - } - unset($query['id']); - } - - $total = count($segments); - - for ($i = 0; $i < $total; $i++) - { - $segments[$i] = str_replace(':', '-', $segments[$i]); - } - - return $segments; - - } - - /** - * Parse the segments of a URL. - * - * @param array &$segments The segments of the URL to parse. - * - * @return array The URL attributes to be used by the application. - * - * @since 3.3 - */ - public function parse(&$segments) - { - $count = count($segments); - $vars = array(); - - //Handle View and Identifier - switch($segments[0]) +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage router.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Routing class from com_hello_world + * + * @since 3.3 + */ +class Hello_worldRouter extends JComponentRouterBase +{ + /** + * Build the route for the com_hello_world component + * + * @param array &$query An array of URL arguments + * + * @return array The URL arguments to use to assemble the subsequent URL. + * + * @since 3.3 + */ + public function build(&$query) + { + $segments = array(); + + // Get a menu item based on Itemid or currently active + $params = JComponentHelper::getParams('com_hello_world'); + + if (empty($query['Itemid'])) + { + $menuItem = $this->menu->getActive(); + } + else + { + $menuItem = $this->menu->getItem($query['Itemid']); + } + + $mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view']; + $mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id']; + + if (isset($query['view'])) + { + $view = $query['view']; + + if (empty($query['Itemid']) && !(isset($view) && isset($query['id']) && ($view === 'greeting' || $view === 'greet' || $view === 'greetings'))) + { + $segments[] = $query['view']; + } + + unset($query['view']); + } + + // Are we dealing with a item that is attached to a menu item? + if (isset($view) && ($mView == $view) and (isset($query['id'])) and ($mId == (int) $query['id'])) + { + unset($query['view']); + unset($query['catid']); + unset($query['id']); + return $segments; + } + + if (isset($view) && isset($query['id']) && ($view === 'greeting' || $view === 'greet' || $view === 'greetings')) + { + if ($mId != (int) $query['id'] || $mView != $view) + { + if (($view === 'greeting' || $view === 'greet' || $view === 'greetings')) + { + $segments[] = $view; + $id = explode(':', $query['id']); + if (count($id) == 2) + { + $segments[] = $id[1]; + } + else + { + $segments[] = $id[0]; + } + } + } + unset($query['id']); + } + + $total = count($segments); + + for ($i = 0; $i < $total; $i++) + { + $segments[$i] = str_replace(':', '-', $segments[$i]); + } + + return $segments; + + } + + /** + * Parse the segments of a URL. + * + * @param array &$segments The segments of the URL to parse. + * + * @return array The URL attributes to be used by the application. + * + * @since 3.3 + */ + public function parse(&$segments) + { + $count = count($segments); + $vars = array(); + + // Handle View and Identifier + switch($segments[0]) { case 'greeting': $vars['view'] = 'greeting'; @@ -162,98 +162,98 @@ class Hello_worldRouter extends JComponentRouterBase $vars['id'] = $id; } } - break; - } - - return $vars; - } - - protected function getVar($table, $where = null, $whereString = null, $what = null, $category = false, $operator = '=', $main = 'hello_world') - { - if(!$where || !$what || !$whereString) - { - return false; - } - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - - $query->select($db->quoteName(array($what))); - if ('categories' == $table || 'category' == $table || $category) - { - $getTable = '#__categories'; - $query->from($db->quoteName($getTable)); - // we need this to target the components categories (TODO will keep an eye on this) - $query->where($db->quoteName('extension') . ' LIKE '. $db->quote((string)'com_' . $main . '%')); - } - else - { - // we must check if the table exist (TODO not ideal) - $tables = $db->getTableList(); - $app = JFactory::getApplication(); - $prefix = $app->get('dbprefix'); - $check = $prefix.$main.'_'.$table; - if (in_array($check, $tables)) - { - $getTable = '#__'.$main.'_'.$table; - $query->from($db->quoteName($getTable)); - } - else - { - return false; - } - } - if (is_numeric($where)) - { - return false; - } - elseif ($this->checkString($where)) - { - // we must first check if this table has the column - $columns = $db->getTableColumns($getTable); - if (isset($columns[$whereString])) - { - $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where)); - } - else - { - return false; - } - } - else - { - return false; - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - return $db->loadResult(); - } - return false; - } - - protected function checkString($string) - { - if (isset($string) && is_string($string) && strlen($string) > 0) - { - return true; - } - return false; - } -} - -function Hello_worldBuildRoute(&$query) -{ - $router = new Hello_worldRouter; - - return $router->build($query); -} - -function Hello_worldParseRoute($segments) -{ - $router = new Hello_worldRouter; - - return $router->parse($segments); + break; + } + + return $vars; + } + + protected function getVar($table, $where = null, $whereString = null, $what = null, $category = false, $operator = '=', $main = 'hello_world') + { + if(!$where || !$what || !$whereString) + { + return false; + } + // Get a db connection. + $db = JFactory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + + $query->select($db->quoteName(array($what))); + if ('categories' == $table || 'category' == $table || $category) + { + $getTable = '#__categories'; + $query->from($db->quoteName($getTable)); + // we need this to target the components categories (TODO will keep an eye on this) + $query->where($db->quoteName('extension') . ' LIKE '. $db->quote((string)'com_' . $main . '%')); + } + else + { + // we must check if the table exist (TODO not ideal) + $tables = $db->getTableList(); + $app = JFactory::getApplication(); + $prefix = $app->get('dbprefix'); + $check = $prefix.$main.'_'.$table; + if (in_array($check, $tables)) + { + $getTable = '#__'.$main.'_'.$table; + $query->from($db->quoteName($getTable)); + } + else + { + return false; + } + } + if (is_numeric($where)) + { + return false; + } + elseif ($this->checkString($where)) + { + // we must first check if this table has the column + $columns = $db->getTableColumns($getTable); + if (isset($columns[$whereString])) + { + $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where)); + } + else + { + return false; + } + } + else + { + return false; + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + return $db->loadResult(); + } + return false; + } + + protected function checkString($string) + { + if (isset($string) && is_string($string) && strlen($string) > 0) + { + return true; + } + return false; + } +} + +function Hello_worldBuildRoute(&$query) +{ + $router = new Hello_worldRouter; + + return $router->build($query); +} + +function Hello_worldParseRoute($segments) +{ + $router = new Hello_worldRouter; + + return $router->parse($segments); } \ No newline at end of file diff --git a/site/views/greet/tmpl/default.php b/site/views/greet/tmpl/default.php index cdd63ab..668b03a 100644 --- a/site/views/greet/tmpl/default.php +++ b/site/views/greet/tmpl/default.php @@ -1,27 +1,27 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - - -?> +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage default.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + + +?> toolbar->render(); ?> -

item->greeting; ?>

+

item->greeting; ?>

diff --git a/site/views/greet/view.html.php b/site/views/greet/view.html.php index fc8c06f..95d5864 100644 --- a/site/views/greet/view.html.php +++ b/site/views/greet/view.html.php @@ -1,39 +1,39 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Hello_world View class for the Greet - */ -class Hello_worldViewGreet extends JViewLegacy -{ - // Overwriting JView display method - function display($tpl = null) - { - // get combined params of both component and menu - $this->app = JFactory::getApplication(); - $this->params = $this->app->getParams(); - $this->menu = $this->app->getMenu()->getActive(); - // get the user object +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage view.html.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Hello_world View class for the Greet + */ +class Hello_worldViewGreet extends JViewLegacy +{ + // Overwriting JView display method + function display($tpl = null) + { + // get combined params of both component and menu + $this->app = JFactory::getApplication(); + $this->params = $this->app->getParams(); + $this->menu = $this->app->getMenu()->getActive(); + // get the user object $this->user = JFactory::getUser(); // Initialise variables. $this->item = $this->get('Item'); @@ -50,13 +50,13 @@ class Hello_worldViewGreet extends JViewLegacy throw new Exception(implode(PHP_EOL, $errors), 500); } - parent::display($tpl); - } - - /** - * Prepares the document - */ - protected function _prepareDocument() + parent::display($tpl); + } + + /** + * Prepares the document + */ + protected function _prepareDocument() { // always make sure jquery is loaded. @@ -126,37 +126,37 @@ class Hello_worldViewGreet extends JViewLegacy $this->document->setMetadata($k, $v); } } - } - // add the document default css file - $this->document->addStyleSheet(JURI::root(true) .'/components/com_hello_world/assets/css/greet.css', (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - - // set help url for this view if found - $help_url = Hello_worldHelper::getHelpUrl('greet'); - if (Hello_worldHelper::checkString($help_url)) - { - JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $help_url); - } - // now initiate the toolbar - $this->toolbar = JToolbar::getInstance(); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var, $sorten = false, $length = 40) - { - // use the helper htmlEscape method instead. - return Hello_worldHelper::htmlEscape($var, $this->_charset, $sorten, $length); - } -} + } + // add the document default css file + $this->document->addStyleSheet(JURI::root(true) .'/components/com_hello_world/assets/css/greet.css', (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + + // set help url for this view if found + $this->help_url = Hello_worldHelper::getHelpUrl('greet'); + if (Hello_worldHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $this->help_url); + } + // now initiate the toolbar + $this->toolbar = JToolbar::getInstance(); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var, $sorten = false, $length = 40) + { + // use the helper htmlEscape method instead. + return Hello_worldHelper::htmlEscape($var, $this->_charset, $sorten, $length); + } +} diff --git a/site/views/greeting/submitbutton.js b/site/views/greeting/submitbutton.js index c2b2f5d..618a933 100644 --- a/site/views/greeting/submitbutton.js +++ b/site/views/greeting/submitbutton.js @@ -1,34 +1,34 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - VDM -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.1 - @build 4th January, 2021 - @created 20th September, 2017 - @package Hello World - @subpackage submitbutton.js - @author Llewellyn - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('greeting, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage submitbutton.js + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('greeting, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } } \ No newline at end of file diff --git a/site/views/greeting/tmpl/edit.php b/site/views/greeting/tmpl/edit.php index 5198c29..d847015 100644 --- a/site/views/greeting/tmpl/edit.php +++ b/site/views/greeting/tmpl/edit.php @@ -1,37 +1,34 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage edit.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.tooltip'); -JHtml::_('behavior.formvalidation'); +JHtml::_('behavior.formvalidator'); JHtml::_('formbehavior.chosen', 'select'); JHtml::_('behavior.keepalive'); -JHtml::_('behavior.tabstate'); -JHtml::_('behavior.calendar'); -?> -
-toolbar->render(); ?> -
+?> +
+toolbar->render(); ?> +
@@ -87,6 +84,6 @@ JHtml::_('behavior.calendar');
-
-
-
+
+ +
diff --git a/site/views/greeting/view.html.php b/site/views/greeting/view.html.php index d90d52e..7009168 100644 --- a/site/views/greeting/view.html.php +++ b/site/views/greeting/view.html.php @@ -1,91 +1,91 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Greeting View class - */ -class Hello_worldViewGreeting extends JViewLegacy -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_hello_world'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = Hello_worldHelper::getActions('greeting', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage view.html.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Greeting View class + */ +class Hello_worldViewGreeting extends JViewLegacy +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_hello_world'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = Hello_worldHelper::getActions('greeting', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() {JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $userId = $user->id; @@ -157,61 +157,61 @@ class Hello_worldViewGreeting extends JViewLegacy } JToolbarHelper::divider(); // set help url for this view if found - $help_url = Hello_worldHelper::getHelpUrl('greeting'); - if (Hello_worldHelper::checkString($help_url)) + $this->help_url = Hello_worldHelper::getHelpUrl('greeting'); + if (Hello_worldHelper::checkString($this->help_url)) { - JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $help_url); - } - // now initiate the toolbar - $this->toolbar = JToolbar::getInstance(); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return Hello_worldHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return Hello_worldHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_HELLO_WORLD_GREETING_NEW' : 'COM_HELLO_WORLD_GREETING_EDIT')); - // only add the ISIS template css & js if needed (default is 1 = true) - // you can override this in the global component options - // just add a (radio yes/no field) with a name called add_isis_template - // to your components config area - if ($this->params->get('add_isis_template', 1)) - { - // we need this to fix the form display (TODO) - $this->document->addStyleSheet(JURI::root() . "administrator/templates/isis/css/template.css", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . "administrator/templates/isis/js/template.js", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - } - // the default style of this view - $this->document->addStyleSheet(JURI::root()."components/com_hello_world/assets/css/greeting.css", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // default javascript of this view - $this->document->addScript(JURI::root(). $this->script, (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root(). "components/com_hello_world/views/greeting/submitbutton.js", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} + JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $this->help_url); + } + // now initiate the toolbar + $this->toolbar = JToolbar::getInstance(); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return Hello_worldHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return Hello_worldHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_HELLO_WORLD_GREETING_NEW' : 'COM_HELLO_WORLD_GREETING_EDIT')); + // only add the ISIS template css & js if needed (default is 1 = true) + // you can override this in the global component options + // just add a (radio yes/no field) with a name called add_isis_template + // to your components config area + if ($this->params->get('add_isis_template', 1)) + { + // we need this to fix the form display (TODO) + $this->document->addStyleSheet(JURI::root() . "administrator/templates/isis/css/template.css", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . "administrator/templates/isis/js/template.js", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + } + // the default style of this view + $this->document->addStyleSheet(JURI::root()."components/com_hello_world/assets/css/greeting.css", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + // default javascript of this view + $this->document->addScript(JURI::root(). $this->script, (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root(). "components/com_hello_world/views/greeting/submitbutton.js", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/site/views/greetings/tmpl/default.php b/site/views/greetings/tmpl/default.php index 9ef2300..185ff1f 100644 --- a/site/views/greetings/tmpl/default.php +++ b/site/views/greetings/tmpl/default.php @@ -1,33 +1,33 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage default.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); -$edit = "index.php?option=com_hello_world&view=greetings&task=greeting.edit"; -?> + +$edit = "index.php?option=com_hello_world&view=greetings&task=greeting.edit"; +?> toolbar->render(); ?> + diff --git a/site/views/greetings/view.html.php b/site/views/greetings/view.html.php index 91851fa..a977a68 100644 --- a/site/views/greetings/view.html.php +++ b/site/views/greetings/view.html.php @@ -1,39 +1,39 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Hello_world View class for the Greetings - */ -class Hello_worldViewGreetings extends JViewLegacy -{ - // Overwriting JView display method - function display($tpl = null) - { - // get combined params of both component and menu - $this->app = JFactory::getApplication(); - $this->params = $this->app->getParams(); - $this->menu = $this->app->getMenu()->getActive(); - // get the user object +/*----------------------------------------------------------------------------------| www.vdm.io |----/ + VDM +/-------------------------------------------------------------------------------------------------------/ + + @version 1.0.1 + @build 3rd March, 2022 + @created 20th September, 2017 + @package Hello World + @subpackage view.html.php + @author Llewellyn + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ + (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) +.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( +\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Hello_world View class for the Greetings + */ +class Hello_worldViewGreetings extends JViewLegacy +{ + // Overwriting JView display method + function display($tpl = null) + { + // get combined params of both component and menu + $this->app = JFactory::getApplication(); + $this->params = $this->app->getParams(); + $this->menu = $this->app->getMenu()->getActive(); + // get the user object $this->user = JFactory::getUser(); // Initialise variables. $this->items = $this->get('Items'); @@ -50,13 +50,13 @@ class Hello_worldViewGreetings extends JViewLegacy throw new Exception(implode(PHP_EOL, $errors), 500); } - parent::display($tpl); - } - - /** - * Prepares the document - */ - protected function _prepareDocument() + parent::display($tpl); + } + + /** + * Prepares the document + */ + protected function _prepareDocument() { // always make sure jquery is loaded. @@ -97,37 +97,37 @@ class Hello_worldViewGreetings extends JViewLegacy if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); - } - // add the document default css file - $this->document->addStyleSheet(JURI::root(true) .'/components/com_hello_world/assets/css/greetings.css', (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - - // set help url for this view if found - $help_url = Hello_worldHelper::getHelpUrl('greetings'); - if (Hello_worldHelper::checkString($help_url)) - { - JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $help_url); - } - // now initiate the toolbar - $this->toolbar = JToolbar::getInstance(); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var, $sorten = false, $length = 40) - { - // use the helper htmlEscape method instead. - return Hello_worldHelper::htmlEscape($var, $this->_charset, $sorten, $length); - } -} + } + // add the document default css file + $this->document->addStyleSheet(JURI::root(true) .'/components/com_hello_world/assets/css/greetings.css', (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + + // set help url for this view if found + $this->help_url = Hello_worldHelper::getHelpUrl('greetings'); + if (Hello_worldHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_HELLO_WORLD_HELP_MANAGER', false, $this->help_url); + } + // now initiate the toolbar + $this->toolbar = JToolbar::getInstance(); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var, $sorten = false, $length = 40) + { + // use the helper htmlEscape method instead. + return Hello_worldHelper::htmlEscape($var, $this->_charset, $sorten, $length); + } +}