diff --git a/README.md b/README.md index cbe526e..7e6da2f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Demo (1.0.5) +# Demo (2.0.0) ![Demo image] (https://raw.githubusercontent.com/namibia/demo-joomla-3-component/master/admin/assets/images/component-300.jpg "The Demo") @@ -9,39 +9,39 @@ Just a basic demo of the most basic implementations of the [Joomla] (http://www. + *Company*: [Vast Development Method] (https://www.vdm.io/) + *Author*: [Llewellyn van der Merwe] (mailto:info@vdm.io) + *Name*: [Demo] (https://www.vdm.io/) -+ *First Build*: 5th August, 2015 -+ *Last Build*: 13th July, 2016 -+ *Version*: 1.0.5 ++ *First Build*: 18th October, 2016 ++ *Last Build*: 8th April, 2017 ++ *Version*: 2.0.0 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html ## Build Time -**47 Hours** or **6 Eight Hour Days** (actual time the author saved - +**43 Hours** or **5 Eight Hour Days** (actual time the author saved - due to [Automated Component Builder] (https://www.vdm.io/joomla-component-builder)) > (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*: **16864** -+ *File count*: **152** -+ *Folder count*: **50** ++ *Line count*: **15283** ++ *File count*: **147** ++ *Folder count*: **54** -**31 Hours** or **4 Eight Hour Days** (the actual time the author spent) +**28 Hours** or **4 Eight Hour Days** (the actual time the author spent) > (with the following break down: -> **debugging @12hours** = codingtime / 4; -> **planning @7hours** = codingtime / 7; -> **mapping @5hours** = codingtime / 10; -> **office @8hours** = codingtime / 6;) +> **debugging @11hours** = codingtime / 4; +> **planning @6hours** = codingtime / 7; +> **mapping @4hours** = codingtime / 10; +> **office @7hours** = codingtime / 6;) -**78 Hours** or **10 Eight Hour Days** +**71 Hours** or **9 Eight Hour Days** (a total of the realistic time frame for this project) > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, > with the normal everyday realities at the office, that includes the component planning, mapping & debugging.) -Project duration: **2 weeks** or **0.4 months** +Project duration: **1.8 weeks** or **0.4 months** > This **component** was build with a Joomla [Automated Component Builder] (https://www.vdm.io/joomla-component-builder). > Developed by [Llewellyn van der Merwe] (mailto:joomla@vdm.io) diff --git a/admin/README.txt b/admin/README.txt new file mode 100644 index 0000000..7e6da2f --- /dev/null +++ b/admin/README.txt @@ -0,0 +1,53 @@ +# Demo (2.0.0) + +![Demo image] (https://raw.githubusercontent.com/namibia/demo-joomla-3-component/master/admin/assets/images/component-300.jpg "The Demo") + +Just a basic demo of the most basic implementations of the [Joomla] (http://www.joomla.org) Component Builder's ability. + +# Build Details + ++ *Company*: [Vast Development Method] (https://www.vdm.io/) ++ *Author*: [Llewellyn van der Merwe] (mailto:info@vdm.io) ++ *Name*: [Demo] (https://www.vdm.io/) ++ *First Build*: 18th October, 2016 ++ *Last Build*: 8th April, 2017 ++ *Version*: 2.0.0 ++ *Copyright*: Copyright (C) 2015. All Rights Reserved ++ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +## Build Time + +**43 Hours** or **5 Eight Hour Days** (actual time the author saved - +due to [Automated Component Builder] (https://www.vdm.io/joomla-component-builder)) + +> (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*: **15283** ++ *File count*: **147** ++ *Folder count*: **54** + +**28 Hours** or **4 Eight Hour Days** (the actual time the author spent) + +> (with the following break down: +> **debugging @11hours** = codingtime / 4; +> **planning @6hours** = codingtime / 7; +> **mapping @4hours** = codingtime / 10; +> **office @7hours** = codingtime / 6;) + +**71 Hours** or **9 Eight Hour Days** +(a total of the realistic time frame for this project) + +> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, +> with the normal everyday realities at the office, that includes the component planning, mapping & debugging.) + +Project duration: **1.8 weeks** or **0.4 months** + +> This **component** was build with a Joomla [Automated Component Builder] (https://www.vdm.io/joomla-component-builder). +> Developed by [Llewellyn van der Merwe] (mailto:joomla@vdm.io) + +## Donations + + If you want to support this project, please consider donating: + * PayPal: pay@vdm.io + * Bitcoin: 3H35PYwikEosvcjxHXGPLS1GufZ4b4iFu3 \ No newline at end of file diff --git a/admin/access.xml b/admin/access.xml index 1128eec..b575d61 100644 --- a/admin/access.xml +++ b/admin/access.xml @@ -15,33 +15,29 @@ - - - - - - - - - - - - + + - + + + - + + + + + @@ -55,18 +51,15 @@ + - - + + + + + + + - -
- - - - - - -
\ No newline at end of file diff --git a/admin/assets/css/admin.css b/admin/assets/css/admin.css index 4b21501..a595c70 100644 --- a/admin/assets/css/admin.css +++ b/admin/assets/css/admin.css @@ -2,9 +2,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage admin.css @author Llewellyn van der Merwe diff --git a/admin/assets/css/dashboard.css b/admin/assets/css/dashboard.css index 496f730..977d77e 100644 --- a/admin/assets/css/dashboard.css +++ b/admin/assets/css/dashboard.css @@ -2,9 +2,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage dashboard.css @author Llewellyn van der Merwe diff --git a/admin/assets/css/look.css b/admin/assets/css/look.css index 8ea861d..8abc8d7 100644 --- a/admin/assets/css/look.css +++ b/admin/assets/css/look.css @@ -2,9 +2,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage look.css @author Llewellyn van der Merwe diff --git a/admin/assets/css/looks.css b/admin/assets/css/looks.css index 658777f..f906814 100644 --- a/admin/assets/css/looks.css +++ b/admin/assets/css/looks.css @@ -2,9 +2,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage looks.css @author Llewellyn van der Merwe diff --git a/admin/assets/images/icons/help_documents.png b/admin/assets/images/icons/help_documents.png deleted file mode 100644 index bdf2b46..0000000 Binary files a/admin/assets/images/icons/help_documents.png and /dev/null differ diff --git a/admin/config.xml b/admin/config.xml index 0585a2e..ada4999 100644 --- a/admin/config.xml +++ b/admin/config.xml @@ -68,6 +68,53 @@ readonly="true" class="readonly" /> + +
+ + + " + " + " + " + + + + " + " + + + + " + " + " +
@@ -83,8 +83,7 @@ class DemoController extends JControllerLegacy if (DemoHelper::checkString($view)) { $views = array( - 'look' => 'looks', - 'help_document' => 'help_documents' + 'look' => 'looks' ); // check if this is a list view if (in_array($view,$views)) diff --git a/admin/controllers/demo.php b/admin/controllers/demo.php index b35cfc1..b25ed11 100644 --- a/admin/controllers/demo.php +++ b/admin/controllers/demo.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage demo.php @author Llewellyn van der Merwe diff --git a/admin/controllers/help.php b/admin/controllers/help.php deleted file mode 100644 index 7478d83..0000000 --- a/admin/controllers/help.php +++ /dev/null @@ -1,124 +0,0 @@ - - @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'); - -// import Joomla controllerform library -jimport('joomla.application.component.controller'); - -/** - * Demo Help Controller - */ -class DemoControllerHelp extends JControllerLegacy -{ - public function __construct($config) - { - parent::__construct($config); - // load the tasks - $this->registerTask('getText', 'help'); - } - - public function help() - { - $user = JFactory::getUser(); - $jinput = JFactory::getApplication()->input; - // Check Token! - $token = JSession::getFormToken(); - $call_token = $jinput->get('token', 0, 'ALNUM'); - if($user->id != 0 && $token == $call_token){ - $task = $this->getTask(); - switch($task){ - case 'getText': - try - { - $idValue = $jinput->get('id', 0, 'INT'); - if($idValue) - { - $result = $this->getHelpDocumentText($idValue); - } - else - { - $result = ''; - } - echo $result; - // stop execution gracefully - jexit(); - } - catch(Exception $e) - { - // stop execution gracefully - jexit(); - } - break; - } - } - else - { - // stop execution gracefully - jexit(); - } - } - - protected function getHelpDocumentText($id) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.title','a.content')); - $query->from('#__demo_help_document AS a'); - $query->where('a.id = '.(int) $id); - $query->where('a.published = 1'); - $db->setQuery($query); - $db->execute(); - if($db->getNumRows()) - { - $text = array(); - $document = $db->loadObject(); - // fix image issue - $images['src="images'] = 'src="'.JURI::root().'images'; - $images["src='images"] = "src='".JURI::root()."images"; - $images['src="/images'] = 'src="'.JURI::root().'images'; - $images["src='/images"] = "src='".JURI::root()."images"; - // set document template - $text[] = ""; - $text[] = ''; - $text[] = ""; - $text[] = ''; - $text[] = "".$document->title.""; - $text[] = ''; - $text[] = ''; - $text[] = ""; - $text[] = '
'; - $text[] = '
'; - $text[] = '
'; - // build the help text - $text[] = '

'.$document->title."

"; - $text[] = str_replace(array_keys($images),array_values($images),$document->content); - // end template - $text[] = '


'; - $text[] = '
'; - $text[] = ""; - $text[] = ""; - - return implode("\n",$text); - } - return false; - } -} diff --git a/admin/controllers/help_documents.php b/admin/controllers/help_documents.php deleted file mode 100644 index d15c775..0000000 --- a/admin/controllers/help_documents.php +++ /dev/null @@ -1,106 +0,0 @@ - - @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'); - -// import Joomla controlleradmin library -jimport('joomla.application.component.controlleradmin'); - -/** - * Help_documents Controller - */ -class DemoControllerHelp_documents extends JControllerAdmin -{ - protected $text_prefix = 'COM_DEMO_HELP_DOCUMENTS'; - /** - * Proxy for getModel. - * @since 2.5 - */ - public function getModel($name = 'Help_document', $prefix = 'DemoModel', $config = array()) - { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('help_document.export', 'com_demo') && $user->authorise('core.export', 'com_demo')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - JArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Help_documents'); - // get the data to export - $data = $model->getExportData($pks); - if (DemoHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - DemoHelper::xls($data,'Help_documents_'.$date->format('jS_F_Y'),'Help documents exported ('.$date->format('jS F, Y').')','help documents'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_DEMO_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_demo&view=help_documents', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('help_document.import', 'com_demo') && $user->authorise('core.import', 'com_demo')) - { - // Get the import model - $model = $this->getModel('Help_documents'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (DemoHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('help_document_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'help_documents'); - $session->set('dataType_VDM_IMPORTINTO', 'help_document'); - // Redirect to import view. - $message = JText::_('COM_DEMO_IMPORT_SELECT_FILE_FOR_HELP_DOCUMENTS'); - $this->setRedirect(JRoute::_('index.php?option=com_demo&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_DEMO_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_demo&view=help_documents', false), $message, 'error'); - return; - } -} diff --git a/admin/controllers/import.php b/admin/controllers/import.php index de26e89..ff05a29 100644 --- a/admin/controllers/import.php +++ b/admin/controllers/import.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage import.php @author Llewellyn van der Merwe diff --git a/admin/controllers/look.php b/admin/controllers/look.php index f812327..36fa449 100644 --- a/admin/controllers/look.php +++ b/admin/controllers/look.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage look.php @author Llewellyn van der Merwe @@ -94,7 +94,7 @@ class DemoControllerLook extends JControllerForm { // The record has been set. Check the record permissions. $permission = $user->authorise('look.edit', 'com_demo.look.' . (int) $recordId); - if (!$permission && !is_null($permission)) + if (!$permission) { if ($user->authorise('look.edit.own', 'com_demo.look.' . $recordId)) { diff --git a/admin/controllers/looks.php b/admin/controllers/looks.php index 5176131..cc04f43 100644 --- a/admin/controllers/looks.php +++ b/admin/controllers/looks.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage looks.php @author Llewellyn van der Merwe @@ -102,5 +102,5 @@ class DemoControllerLooks extends JControllerAdmin $message = JText::_('COM_DEMO_IMPORT_FAILED'); $this->setRedirect(JRoute::_('index.php?option=com_demo&view=looks', false), $message, 'error'); return; - } + } } diff --git a/admin/demo.php b/admin/demo.php index c3c4a46..61e9433 100644 --- a/admin/demo.php +++ b/admin/demo.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage demo.php @author Llewellyn van der Merwe diff --git a/admin/helpers/demo.php b/admin/helpers/demo.php index 3801afa..aa9d3f7 100644 --- a/admin/helpers/demo.php +++ b/admin/helpers/demo.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage demo.php @author Llewellyn van der Merwe @@ -25,7 +25,7 @@ defined('_JEXEC') or die('Restricted access'); * Demo component helper. */ abstract class DemoHelper -{ +{ /** * Load the Component xml manifest. **/ @@ -74,75 +74,11 @@ abstract class DemoHelper } /** - * Load the Component Help URLs. + * Can be used to build help urls. **/ public static function getHelpUrl($view) { - $user = JFactory::getUser(); - $groups = $user->get('groups'); - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.id','a.groups','a.target','a.type','a.article','a.url')); - $query->from('#__demo_help_document AS a'); - $query->where('a.admin_view = '.$db->quote($view)); - $query->where('a.location = 1'); - $query->where('a.published = 1'); - $db->setQuery($query); - $db->execute(); - if($db->getNumRows()) - { - $helps = $db->loadObjectList(); - if (self::checkArray($helps)) - { - foreach ($helps as $nr => $help) - { - if ($help->target == 1) - { - $targetgroups = json_decode($help->groups, true); - if (!array_intersect($targetgroups, $groups)) - { - // if user not in those target groups then remove the item - unset($helps[$nr]); - continue; - } - } - // set the return type - switch ($help->type) - { - // set joomla article - case 1: - return self::loadArticleLink($help->article); - break; - // set help text - case 2: - return self::loadHelpTextLink($help->id); - break; - // set Link - case 3: - return $help->url; - break; - } - } - } - } return false; - } - - /** - * Get the Article Link. - **/ - protected static function loadArticleLink($id) - { - return JURI::root().'index.php?option=com_content&view=article&id='.$id.'&tmpl=component&layout=modal'; - } - - /** - * Get the Help Text Link. - **/ - protected static function loadHelpTextLink($id) - { - $token = JSession::getFormToken(); - return 'index.php?option=com_demo&task=help.getText&id=' . (int) $id . '&token=' . $token; } /** @@ -153,16 +89,114 @@ abstract class DemoHelper // load user for access menus $user = JFactory::getUser(); // load the submenus to sidebar - JHtmlSidebar::addEntry(JText::_('COM_DEMO_SUBMENU_DASHBOARD'), 'index.php?option=com_demo&view=demo', $submenu == 'demo'); + JHtmlSidebar::addEntry(JText::_('COM_DEMO_SUBMENU_DASHBOARD'), 'index.php?option=com_demo&view=demo', $submenu === 'demo'); if ($user->authorise('look.access', 'com_demo') && $user->authorise('look.submenu', 'com_demo')) { - JHtmlSidebar::addEntry(JText::_('COM_DEMO_SUBMENU_LOOKS'), 'index.php?option=com_demo&view=looks', $submenu == 'looks'); - } - if ($user->authorise('help_document.access', 'com_demo') && $user->authorise('help_document.submenu', 'com_demo')) - { - JHtmlSidebar::addEntry(JText::_('COM_DEMO_SUBMENU_HELP_DOCUMENTS'), 'index.php?option=com_demo&view=help_documents', $submenu == 'help_documents'); + JHtmlSidebar::addEntry(JText::_('COM_DEMO_SUBMENU_LOOKS'), 'index.php?option=com_demo&view=looks', $submenu === 'looks'); } - } + } + + /** + * UIKIT Component Classes + **/ + public static $uk_components = array( + 'data-uk-grid' => array( + 'grid' ), + 'uk-accordion' => array( + 'accordion' ), + 'uk-autocomplete' => array( + 'autocomplete' ), + 'data-uk-datepicker' => array( + 'datepicker' ), + 'uk-form-password' => array( + 'form-password' ), + 'uk-form-select' => array( + 'form-select' ), + 'data-uk-htmleditor' => array( + 'htmleditor' ), + 'data-uk-lightbox' => array( + 'lightbox' ), + 'uk-nestable' => array( + 'nestable' ), + 'UIkit.notify' => array( + 'notify' ), + 'data-uk-parallax' => array( + 'parallax' ), + 'uk-search' => array( + 'search' ), + 'uk-slider' => array( + 'slider' ), + 'uk-slideset' => array( + 'slideset' ), + 'uk-slideshow' => array( + 'slideshow', + 'slideshow-fx' ), + 'uk-sortable' => array( + 'sortable' ), + 'data-uk-sticky' => array( + 'sticky' ), + 'data-uk-timepicker' => array( + 'timepicker' ), + 'data-uk-tooltip' => array( + 'tooltip' ), + 'uk-placeholder' => array( + 'placeholder' ), + 'uk-dotnav' => array( + 'dotnav' ), + 'uk-slidenav' => array( + 'slidenav' ), + 'uk-form' => array( + 'form-advanced' ), + 'uk-progress' => array( + 'progress' ), + 'upload-drop' => array( + 'upload', 'form-file' ) + ); + + /** + * Add UIKIT Components + **/ + public static $uikit = false; + + /** + * Get UIKIT Components + **/ + public static function getUikitComp($content,$classes = array()) + { + if (strpos($content,'class="uk-') !== false) + { + // reset + $temp = array(); + foreach (self::$uk_components as $looking => $add) + { + if (strpos($content,$looking) !== false) + { + $temp[] = $looking; + } + } + // make sure uikit is loaded to config + if (strpos($content,'class="uk-') !== false) + { + self::$uikit = true; + } + // sorter + if (self::checkArray($temp)) + { + // merger + if (self::checkArray($classes)) + { + $newTemp = array_merge($temp,$classes); + $temp = array_unique($newTemp); + } + return $temp; + } + } + if (self::checkArray($classes)) + { + return $classes; + } + return false; + } /** * Prepares the xml document @@ -252,7 +286,7 @@ abstract class DemoHelper $objPHPExcel->getActiveSheet()->getColumnDimension($a)->setAutoSize(true); $objPHPExcel->getActiveSheet()->getStyle($a.$i)->applyFromArray($headerStyles); $objPHPExcel->getActiveSheet()->getStyle($a.$i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); - } elseif ($a == 'A'){ + } elseif ($a === 'A'){ $objPHPExcel->getActiveSheet()->getStyle($a.$i)->applyFromArray($sideStyles); } else { $objPHPExcel->getActiveSheet()->getStyle($a.$i)->applyFromArray($normalStyles); @@ -396,13 +430,18 @@ abstract class DemoHelper 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))); - $query->from($db->quoteName('#__'.$main.'_'.$table)); + $query->from($db->quoteName('#_'.$main.'_'.$table)); $query->where($db->quoteName($whereString) . ' '.$operator.' (' . implode(',',$where) . ')'); $db->setQuery($query); $db->execute(); @@ -515,7 +554,7 @@ abstract class DemoHelper { // The record has been set. Check the record permissions. $permission = $user->authorise($action->name, 'com_demo.'.$view.'.' . (int) $record->id); - if (!$permission && !is_null($permission)) + if (!$permission) // TODO removed && !is_null($permission) { if ($action->name == 'core.edit' || $action->name == $view.'.edit') { @@ -850,10 +889,22 @@ abstract class DemoHelper return false; } - public static function checkArray($array) + public static function checkArray($array, $removeEmptyString = false) { if (isset($array) && is_array($array) && count($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 true; } return false; @@ -919,57 +970,86 @@ abstract class DemoHelper return $string; } - public static function safeString($string, $type = 'L', $spacer = '_') + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true) { - // remove all numbers and replace with english text version (works well only up to a thousand) - $string = self::replaceNumbers($string); - + 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)) { - // remove all other characters - $string = trim($string); - $string = preg_replace('/'.$spacer.'+/', ' ', $string); - $string = preg_replace('/\s+/', ' ', $string); - $string = preg_replace("/[^A-Za-z ]/", '', $string); - // return a string with all first letter of each word uppercase(no undersocre) - if ($type == 'W') - { - return ucwords(strtolower($string)); - } - elseif ($type == 'w') - { - return strtolower($string); - } - elseif ($type == 'Ww') - { - return ucfirst(strtolower($string)); - } - elseif ($type == 'WW') - { - return strtoupper($string); - } - elseif ($type == 'U') - { - // replace white space with underscore - $string = preg_replace('/\s+/', $spacer, $string); - // return all upper - return strtoupper($string); - } - elseif ($type == 'F') - { - // replace white space with underscore - $string = preg_replace('/\s+/', $spacer, $string); - // return with first caracter to upper - return ucfirst(strtolower($string)); - } - elseif ($type == 'L') + // 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); + // 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); + $string = preg_replace("/[^A-Za-z ]/", '', $string); + // select final adaptations + if ($type === 'L' || $type === 'strtolower') { // replace white space with underscore $string = preg_replace('/\s+/', $spacer, $string); // default is to return lower return strtolower($string); } - + 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; } diff --git a/admin/helpers/headercheck.php b/admin/helpers/headercheck.php new file mode 100644 index 0000000..e796607 --- /dev/null +++ b/admin/helpers/headercheck.php @@ -0,0 +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 HeaderCheck +{ + 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/html/batch_.php b/admin/helpers/html/batch_.php index 019be86..916a2de 100644 --- a/admin/helpers/html/batch_.php +++ b/admin/helpers/html/batch_.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage batch_.php @author Llewellyn van der Merwe diff --git a/admin/language/en-GB/en-GB.com_demo.ini b/admin/language/en-GB/en-GB.com_demo.ini index b26a7c3..796f586 100644 --- a/admin/language/en-GB/en-GB.com_demo.ini +++ b/admin/language/en-GB/en-GB.com_demo.ini @@ -1,11 +1,13 @@ COM_DEMO="Demo" COM_DEMO_AUTHOR="Author" COM_DEMO_BACK="Back" +COM_DEMO_CONFIG_ALMOST_FLAT_LOAD="Almost Flat" COM_DEMO_CONFIG_AUTHOR="Author Info" COM_DEMO_CONFIG_AUTHOR_EMAIL_DESC="The email address of the author of this component." COM_DEMO_CONFIG_AUTHOR_EMAIL_LABEL="Author Email" COM_DEMO_CONFIG_AUTHOR_NAME_DESC="The name of the author of this component." COM_DEMO_CONFIG_AUTHOR_NAME_LABEL="Author Name" +COM_DEMO_CONFIG_AUTO_LOAD="Auto" COM_DEMO_CONFIG_CHECK_TIMER_DESC="Set the intervals for the auto checkin fuction of tables that checks out the items to an user." COM_DEMO_CONFIG_CHECK_TIMER_LABEL="Check in timer" COM_DEMO_CONFIG_CHECK_TIMER_OPTION_FIVE="Once a week" @@ -14,14 +16,29 @@ COM_DEMO_CONFIG_CHECK_TIMER_OPTION_ONE="Every five hours" COM_DEMO_CONFIG_CHECK_TIMER_OPTION_SIX="Never" COM_DEMO_CONFIG_CHECK_TIMER_OPTION_THREE="Once a day" COM_DEMO_CONFIG_CHECK_TIMER_OPTION_TWO="Every twelve hours" +COM_DEMO_CONFIG_DONT_LOAD="Not" +COM_DEMO_CONFIG_FLAT_LOAD="Flat" +COM_DEMO_CONFIG_FORCE_LOAD="Force" COM_DEMO_CONFIG_GLOBAL_DESC="The Global Parameters" COM_DEMO_CONFIG_GLOBAL_LABEL="Global" +COM_DEMO_CONFIG_GRADIANT_LOAD="Gradient" +COM_DEMO_CONFIG_NO="No" +COM_DEMO_CONFIG_ONLY_EXTRA="Only Extra" +COM_DEMO_CONFIG_UIKIT_DESC="The Parameters for the uikit are set here.
Uikit is a lightweight and modular front-end framework +for developing fast and powerful web interfaces. For more info visit http://getuikit.com/" +COM_DEMO_CONFIG_UIKIT_LABEL="Uikit Settings" +COM_DEMO_CONFIG_UIKIT_LOAD_DESC="Set the uikit loading option." +COM_DEMO_CONFIG_UIKIT_LOAD_LABEL="Loading Options" +COM_DEMO_CONFIG_UIKIT_MIN_DESC="Should the minified version of uikit files be loaded?" +COM_DEMO_CONFIG_UIKIT_MIN_LABEL="Load Minified" +COM_DEMO_CONFIG_UIKIT_STYLE_DESC="Set the css style that should be used." +COM_DEMO_CONFIG_UIKIT_STYLE_LABEL="css Style" +COM_DEMO_CONFIG_YES="Yes" COM_DEMO_CONTRIBUTOR="Contributor" COM_DEMO_CONTRIBUTORS="Contributors" COM_DEMO_CREATE_NEW_S="Create New %s" COM_DEMO_DASH="Dashboard" COM_DEMO_DASHBOARD="Demo Dashboard" -COM_DEMO_DASHBOARD_HELP_DOCUMENTS="Help Documents

" COM_DEMO_DASHBOARD_LOOKS="Looks

" COM_DEMO_DASHBOARD_LOOK_ADD="Add Look

" COM_DEMO_DATE="Date" @@ -35,112 +52,6 @@ COM_DEMO_EDIT_VERSIONS_DESC=" Allows users in this group to edit versions." COM_DEMO_EXPORT_DATA="Export Data" COM_DEMO_EXPORT_DATA_DESC=" Allows users in this group to export data." COM_DEMO_EXPORT_FAILED="Export Failed" -COM_DEMO_HELP_DOCUMENT="Help Document" -COM_DEMO_HELP_DOCUMENTS="Help Documents" -COM_DEMO_HELP_DOCUMENTS_ACCESS="Help Documents Access" -COM_DEMO_HELP_DOCUMENTS_ACCESS_DESC="Allows the users in this group to access access help documents" -COM_DEMO_HELP_DOCUMENTS_BATCH_OPTIONS="Batch process the selected Help Documents" -COM_DEMO_HELP_DOCUMENTS_BATCH_TIP="All changes will be applied to all selected Help Documents" -COM_DEMO_HELP_DOCUMENTS_BATCH_USE="Help Documents Batch Use" -COM_DEMO_HELP_DOCUMENTS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch help documents" -COM_DEMO_HELP_DOCUMENTS_CREATE="Help Documents Create" -COM_DEMO_HELP_DOCUMENTS_CREATE_DESC="Allows the users in this group to create create help documents" -COM_DEMO_HELP_DOCUMENTS_DASHBOARD_LIST="Help Documents Dashboard List" -COM_DEMO_HELP_DOCUMENTS_DASHBOARD_LIST_DESC="Allows the users in this group to update the dashboard list of the help document" -COM_DEMO_HELP_DOCUMENTS_DELETE="Help Documents Delete" -COM_DEMO_HELP_DOCUMENTS_DELETE_DESC="Allows the users in this group to delete delete help documents" -COM_DEMO_HELP_DOCUMENTS_EDIT="Help Documents Edit" -COM_DEMO_HELP_DOCUMENTS_EDIT_DESC="Allows the users in this group to edit the help document" -COM_DEMO_HELP_DOCUMENTS_EDIT_OWN="Help Documents Edit Own" -COM_DEMO_HELP_DOCUMENTS_EDIT_OWN_DESC="Allows the users in this group to edit edit own help documents created by them" -COM_DEMO_HELP_DOCUMENTS_EDIT_STATE="Help Documents Edit State" -COM_DEMO_HELP_DOCUMENTS_EDIT_STATE_DESC="Allows the users in this group to update the state of the help document" -COM_DEMO_HELP_DOCUMENTS_EDIT_VERSION="Help Documents Edit Version" -COM_DEMO_HELP_DOCUMENTS_EDIT_VERSION_DESC="Allows users in this group to edit versions of version help documents" -COM_DEMO_HELP_DOCUMENTS_EXPORT="Help Documents Export" -COM_DEMO_HELP_DOCUMENTS_EXPORT_DESC="Allows the users in this group to export export help documents" -COM_DEMO_HELP_DOCUMENTS_IMPORT="Help Documents Import" -COM_DEMO_HELP_DOCUMENTS_IMPORT_DESC="Allows the users in this group to import import help documents" -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_ARCHIVED="%s Help Documents archived." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_ARCHIVED_1="%s Help Document archived." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_CHECKED_IN_0="No Help Document successfully checked in." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_CHECKED_IN_1="%d Help Document successfully checked in." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_CHECKED_IN_MORE="%d Help Documents successfully checked in." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_DELETED="%s Help Documents deleted." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_DELETED_1="%s Help Document deleted." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_FEATURED="%s Help Documents featured." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_FEATURED_1="%s Help Document featured." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_PUBLISHED="%s Help Documents published." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_PUBLISHED_1="%s Help Document published." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_TRASHED="%s Help Documents trashed." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_TRASHED_1="%s Help Document trashed." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_UNFEATURED="%s Help Documents unfeatured." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_UNFEATURED_1="%s Help Document unfeatured." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_UNPUBLISHED="%s Help Documents unpublished." -COM_DEMO_HELP_DOCUMENTS_N_ITEMS_UNPUBLISHED_1="%s Help Document unpublished." -COM_DEMO_HELP_DOCUMENTS_SUBMENU="Help Documents Submenu" -COM_DEMO_HELP_DOCUMENTS_SUBMENU_DESC="Allows the users in this group to update the submenu of the help document" -COM_DEMO_HELP_DOCUMENT_ADMIN="Admin" -COM_DEMO_HELP_DOCUMENT_ADMIN_VIEW="Admin View" -COM_DEMO_HELP_DOCUMENT_ADMIN_VIEW_DESCRIPTION="Select the view being targeted" -COM_DEMO_HELP_DOCUMENT_ADMIN_VIEW_LABEL="Admin Views" -COM_DEMO_HELP_DOCUMENT_ALIAS="Alias" -COM_DEMO_HELP_DOCUMENT_ALIAS_HINT="Auto-generated from name" -COM_DEMO_HELP_DOCUMENT_ALIAS_LABEL="Alias" -COM_DEMO_HELP_DOCUMENT_ALL="All" -COM_DEMO_HELP_DOCUMENT_ARTICLE="Article" -COM_DEMO_HELP_DOCUMENT_ARTICLE_LABEL="Article" -COM_DEMO_HELP_DOCUMENT_CONTENT="Content" -COM_DEMO_HELP_DOCUMENT_CONTENT_LABEL="Content" -COM_DEMO_HELP_DOCUMENT_CREATED_BY_DESC="The user that created this Help Document." -COM_DEMO_HELP_DOCUMENT_CREATED_BY_LABEL="Created By" -COM_DEMO_HELP_DOCUMENT_CREATED_DATE_DESC="The date this Help Document was created." -COM_DEMO_HELP_DOCUMENT_CREATED_DATE_LABEL="Created Date" -COM_DEMO_HELP_DOCUMENT_DETAILS="Details" -COM_DEMO_HELP_DOCUMENT_EDIT="Editing the Help Document" -COM_DEMO_HELP_DOCUMENT_ERROR_UNIQUE_ALIAS="Another Help Document has the same alias." -COM_DEMO_HELP_DOCUMENT_GROUPS="Groups" -COM_DEMO_HELP_DOCUMENT_GROUPS_DESCRIPTION="Select a group/s" -COM_DEMO_HELP_DOCUMENT_GROUPS_LABEL="Group/s" -COM_DEMO_HELP_DOCUMENT_ID="Id" -COM_DEMO_HELP_DOCUMENT_JOOMLA_ARTICLE="Joomla Article" -COM_DEMO_HELP_DOCUMENT_LOCATION="Location" -COM_DEMO_HELP_DOCUMENT_LOCATION_DESCRIPTION="Select the help target location." -COM_DEMO_HELP_DOCUMENT_LOCATION_LABEL="Location" -COM_DEMO_HELP_DOCUMENT_MODIFIED_BY_DESC="The last user that modified this Help Document." -COM_DEMO_HELP_DOCUMENT_MODIFIED_BY_LABEL="Modified By" -COM_DEMO_HELP_DOCUMENT_MODIFIED_DATE_DESC="The date this Help Document was modified." -COM_DEMO_HELP_DOCUMENT_MODIFIED_DATE_LABEL="Modified Date" -COM_DEMO_HELP_DOCUMENT_NEW="A New Help Document" -COM_DEMO_HELP_DOCUMENT_NOT_REQUIRED="Not Required" -COM_DEMO_HELP_DOCUMENT_ORDERING_LABEL="Ordering" -COM_DEMO_HELP_DOCUMENT_PERMISSION="Permissions" -COM_DEMO_HELP_DOCUMENT_PUBLISHING="Publishing" -COM_DEMO_HELP_DOCUMENT_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Help Document to customise the alias." -COM_DEMO_HELP_DOCUMENT_SELECT_AN_OPTION="Select an option" -COM_DEMO_HELP_DOCUMENT_SITE="Site" -COM_DEMO_HELP_DOCUMENT_SITE_VIEW="Site View" -COM_DEMO_HELP_DOCUMENT_SITE_VIEW_DESCRIPTION="Select the view being targeted" -COM_DEMO_HELP_DOCUMENT_SITE_VIEW_LABEL="Site Views" -COM_DEMO_HELP_DOCUMENT_SOME="Some" -COM_DEMO_HELP_DOCUMENT_STATUS="Status" -COM_DEMO_HELP_DOCUMENT_TARGET="Target" -COM_DEMO_HELP_DOCUMENT_TARGET_DESCRIPTION="Select the target option in relation to groups." -COM_DEMO_HELP_DOCUMENT_TARGET_LABEL="Target Groups" -COM_DEMO_HELP_DOCUMENT_TEXT="Text" -COM_DEMO_HELP_DOCUMENT_TITLE="Title" -COM_DEMO_HELP_DOCUMENT_TITLE_DESCRIPTION="Enter Title Here" -COM_DEMO_HELP_DOCUMENT_TITLE_HINT="Title Here" -COM_DEMO_HELP_DOCUMENT_TITLE_LABEL="Title" -COM_DEMO_HELP_DOCUMENT_TYPE="Type" -COM_DEMO_HELP_DOCUMENT_TYPE_DESCRIPTION="Select the help type." -COM_DEMO_HELP_DOCUMENT_TYPE_LABEL="Type" -COM_DEMO_HELP_DOCUMENT_URL="Url" -COM_DEMO_HELP_DOCUMENT_URL_DESCRIPTION="Enter url" -COM_DEMO_HELP_DOCUMENT_URL_HINT="http://www.example.com" -COM_DEMO_HELP_DOCUMENT_URL_LABEL="URL" -COM_DEMO_HELP_DOCUMENT_VERSION_DESC="A count of the number of times this Help Document has been revised." -COM_DEMO_HELP_DOCUMENT_VERSION_LABEL="Revision" COM_DEMO_HELP_MANAGER="Help" COM_DEMO_IMPORT_CONTINUE="Continue" COM_DEMO_IMPORT_DATA="Import Data" @@ -170,7 +81,6 @@ COM_DEMO_IMPORT_NO_IMPORT_TYPE_FOUND="Import type not found." COM_DEMO_IMPORT_PLEASE_SELECT_COLUMN="-- Please Select Column --" COM_DEMO_IMPORT_SELECT_FILE="Select File" COM_DEMO_IMPORT_SELECT_FILE_DIRECTORY="Set the path to file" -COM_DEMO_IMPORT_SELECT_FILE_FOR_HELP_DOCUMENTS="Select the file to import data to help_documents." COM_DEMO_IMPORT_SELECT_FILE_FOR_LOOKS="Select the file to import data to looks." COM_DEMO_IMPORT_SELECT_FILE_URL="Enter file URL" COM_DEMO_IMPORT_SUCCESS="Great! Import successful." @@ -184,9 +94,13 @@ COM_DEMO_KEEP_ORIGINAL_CATEGORY="- Keep Original Category -" COM_DEMO_KEEP_ORIGINAL_STATE="- Keep Original State -" COM_DEMO_LICENSE="License" COM_DEMO_LOOK="Look" +COM_DEMO_LOOKING_ACCESS_SITE="Looking (Site) Access" +COM_DEMO_LOOKING_ACCESS_SITE_DESC=" Allows the users in this group to access site looking." COM_DEMO_LOOKS="Looks" COM_DEMO_LOOKS_ACCESS="Looks Access" COM_DEMO_LOOKS_ACCESS_DESC="Allows the users in this group to access access looks" +COM_DEMO_LOOKS_ACCESS_SITE="Looks (Site) Access" +COM_DEMO_LOOKS_ACCESS_SITE_DESC=" Allows the users in this group to access site looks." COM_DEMO_LOOKS_BATCH_OPTIONS="Batch process the selected Looks" COM_DEMO_LOOKS_BATCH_TIP="All changes will be applied to all selected Looks" COM_DEMO_LOOKS_BATCH_USE="Looks Batch Use" @@ -200,23 +114,35 @@ COM_DEMO_LOOKS_DASHBOARD_LIST_DESC="Allows the users in this group to update the COM_DEMO_LOOKS_DELETE="Looks Delete" COM_DEMO_LOOKS_DELETE_DESC="Allows the users in this group to delete delete looks" COM_DEMO_LOOKS_EDIT="Looks Edit" -COM_DEMO_LOOKS_EDIT_ACRONYM="Looks Edit Acronym" -COM_DEMO_LOOKS_EDIT_ACRONYM_DESC="Allows the users in this group to update the edit acronym of the look" +COM_DEMO_LOOKS_EDIT_ADD="Looks Edit Add" +COM_DEMO_LOOKS_EDIT_ADD_DESC="Allows the users in this group to update the edit add of the look" +COM_DEMO_LOOKS_EDIT_ALIAS="Looks Edit Alias" +COM_DEMO_LOOKS_EDIT_ALIAS_DESC="Allows the users in this group to update the edit alias of the look" COM_DEMO_LOOKS_EDIT_CREATED_BY="Looks Edit Created By" COM_DEMO_LOOKS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by looks" COM_DEMO_LOOKS_EDIT_CREATED_DATE="Looks Edit Created Date" COM_DEMO_LOOKS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created looks" +COM_DEMO_LOOKS_EDIT_DATEOFBIRTH="Looks Edit Dateofbirth" +COM_DEMO_LOOKS_EDIT_DATEOFBIRTH_DESC="Allows the users in this group to update the edit dateofbirth of the look" COM_DEMO_LOOKS_EDIT_DESC="Allows the users in this group to edit the look" COM_DEMO_LOOKS_EDIT_DESCRIPTION="Looks Edit Description" COM_DEMO_LOOKS_EDIT_DESCRIPTION_DESC="Allows the users in this group to update the edit description of the look" -COM_DEMO_LOOKS_EDIT_MALE="Looks Edit Male" -COM_DEMO_LOOKS_EDIT_MALE_DESC="Allows the users in this group to update the edit male of the look" +COM_DEMO_LOOKS_EDIT_EMAIL="Looks Edit Email" +COM_DEMO_LOOKS_EDIT_EMAIL_DESC="Allows the users in this group to update the edit email of the look" +COM_DEMO_LOOKS_EDIT_IMAGE="Looks Edit Image" +COM_DEMO_LOOKS_EDIT_IMAGE_DESC="Allows the users in this group to update the edit image of the look" +COM_DEMO_LOOKS_EDIT_MOBILE_PHONE="Looks Edit Mobile Phone" +COM_DEMO_LOOKS_EDIT_MOBILE_PHONE_DESC="Allows the users in this group to update the edit mobile phone of the look" +COM_DEMO_LOOKS_EDIT_NAME="Looks Edit Name" +COM_DEMO_LOOKS_EDIT_NAME_DESC="Allows the users in this group to update the edit name of the look" COM_DEMO_LOOKS_EDIT_OWN="Looks Edit Own" COM_DEMO_LOOKS_EDIT_OWN_DESC="Allows the users in this group to edit edit own looks created by them" COM_DEMO_LOOKS_EDIT_STATE="Looks Edit State" COM_DEMO_LOOKS_EDIT_STATE_DESC="Allows the users in this group to update the state of the look" COM_DEMO_LOOKS_EDIT_VERSION="Looks Edit Version" COM_DEMO_LOOKS_EDIT_VERSION_DESC="Allows users in this group to edit versions of version looks" +COM_DEMO_LOOKS_EDIT_WEBSITE="Looks Edit Website" +COM_DEMO_LOOKS_EDIT_WEBSITE_DESC="Allows the users in this group to update the edit website of the look" COM_DEMO_LOOKS_EXPORT="Looks Export" COM_DEMO_LOOKS_EXPORT_DESC="Allows the users in this group to export export looks" COM_DEMO_LOOKS_IMPORT="Looks Import" @@ -240,13 +166,8 @@ COM_DEMO_LOOKS_N_ITEMS_UNPUBLISHED="%s Looks unpublished." COM_DEMO_LOOKS_N_ITEMS_UNPUBLISHED_1="%s Look unpublished." COM_DEMO_LOOKS_SUBMENU="Looks Submenu" COM_DEMO_LOOKS_SUBMENU_DESC="Allows the users in this group to update the submenu of the look" -COM_DEMO_LOOK_ACRONYM="Acronym" -COM_DEMO_LOOK_ACRONYM_DESCRIPTION="Enter an acronym" -COM_DEMO_LOOK_ACRONYM_HINT="Acronym Here" -COM_DEMO_LOOK_ACRONYM_LABEL="Acronym" COM_DEMO_LOOK_ADD="Add" -COM_DEMO_LOOK_ADD_LABEL="Add Custom Stuff" -COM_DEMO_LOOK_AGE_LABEL="Age Group" +COM_DEMO_LOOK_ADD_LABEL="Add More" COM_DEMO_LOOK_ALIAS="Alias" COM_DEMO_LOOK_ALIAS_HINT="Auto-generated from name" COM_DEMO_LOOK_ALIAS_LABEL="Alias" @@ -254,29 +175,32 @@ COM_DEMO_LOOK_CREATED_BY_DESC="The user that created this Look." COM_DEMO_LOOK_CREATED_BY_LABEL="Created By" COM_DEMO_LOOK_CREATED_DATE_DESC="The date this Look was created." COM_DEMO_LOOK_CREATED_DATE_LABEL="Created Date" +COM_DEMO_LOOK_DATEOFBIRTH="Dateofbirth" +COM_DEMO_LOOK_DATEOFBIRTH_DESCRIPTION="Your date of birth" +COM_DEMO_LOOK_DATEOFBIRTH_LABEL="Date of Birth" COM_DEMO_LOOK_DESCRIPTION="Description" COM_DEMO_LOOK_DESCRIPTION_DESCRIPTION="Add Description Here" COM_DEMO_LOOK_DESCRIPTION_HINT="Add Description Here" COM_DEMO_LOOK_DESCRIPTION_LABEL="Description" COM_DEMO_LOOK_DETAILS="Details" COM_DEMO_LOOK_EDIT="Editing the Look" +COM_DEMO_LOOK_EMAIL="Email" +COM_DEMO_LOOK_EMAIL_DESCRIPTION="Enter Email" +COM_DEMO_LOOK_EMAIL_HINT="demo@example.com" +COM_DEMO_LOOK_EMAIL_LABEL="Email" COM_DEMO_LOOK_ERROR_UNIQUE_ALIAS="Another Look has the same alias." -COM_DEMO_LOOK_FEMALE="Female" -COM_DEMO_LOOK_FEMALE_DESCRIPTION="Here you can add females data." -COM_DEMO_LOOK_FEMALE_SELECT="Edit/Add" -COM_DEMO_LOOK_FIFTEENNINETEEN="15-19" -COM_DEMO_LOOK_FIFTYFIFTY_FOUR="50-54" -COM_DEMO_LOOK_FIFTY_FIVEFIFTY_NINE="55-59" -COM_DEMO_LOOK_FORTYFORTY_FOUR="40-44" -COM_DEMO_LOOK_FORTY_FIVEFORTY_NINE="45-49" COM_DEMO_LOOK_ID="Id" -COM_DEMO_LOOK_MALE="Male" -COM_DEMO_LOOK_MALE_DESCRIPTION="Here you can add males data." -COM_DEMO_LOOK_MALE_SELECT="Edit/Add" +COM_DEMO_LOOK_IMAGE="Image" +COM_DEMO_LOOK_IMAGE_LABEL="Image" +COM_DEMO_LOOK_MOBILE_PHONE="Mobile Phone" +COM_DEMO_LOOK_MOBILE_PHONE_DESCRIPTION="Enter Mobile Phone Number" +COM_DEMO_LOOK_MOBILE_PHONE_HINT="Mobile Phone Here" +COM_DEMO_LOOK_MOBILE_PHONE_LABEL="Mobile Phone" COM_DEMO_LOOK_MODIFIED_BY_DESC="The last user that modified this Look." COM_DEMO_LOOK_MODIFIED_BY_LABEL="Modified By" COM_DEMO_LOOK_MODIFIED_DATE_DESC="The date this Look was modified." COM_DEMO_LOOK_MODIFIED_DATE_LABEL="Modified Date" +COM_DEMO_LOOK_MORE="More" COM_DEMO_LOOK_NAME="Name" COM_DEMO_LOOK_NAME_DESCRIPTION="Enter Name Here" COM_DEMO_LOOK_NAME_HINT="Name Here" @@ -284,49 +208,24 @@ COM_DEMO_LOOK_NAME_LABEL="Name" COM_DEMO_LOOK_NEW="A New Look" COM_DEMO_LOOK_NO="No" COM_DEMO_LOOK_NOT_REQUIRED="Not Required" -COM_DEMO_LOOK_NUMBER_HINT="Number Here" -COM_DEMO_LOOK_NUMBER_LABEL="Number" COM_DEMO_LOOK_ORDERING_LABEL="Ordering" COM_DEMO_LOOK_PERMISSION="Permissions" COM_DEMO_LOOK_PUBLISHING="Publishing" -COM_DEMO_LOOK_REPETABLE_NUMBERS="Repetable Numbers" COM_DEMO_LOOK_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Look to customise the alias." -COM_DEMO_LOOK_SELECT_A_YEAR="Select a year" -COM_DEMO_LOOK_SIXTYSIXTY_FOUR="60-64" COM_DEMO_LOOK_STATUS="Status" -COM_DEMO_LOOK_THIRTYTHIRTY_FOUR="30-34" -COM_DEMO_LOOK_THIRTY_FIVETHIRTY_NINE="35-39" -COM_DEMO_LOOK_TWENTYTWENTY_FOUR="20-24" -COM_DEMO_LOOK_TWENTY_FIVETWENTY_NINE="25-29" -COM_DEMO_LOOK_TWO_THOUSAND_AND_EIGHTEEN="2018" -COM_DEMO_LOOK_TWO_THOUSAND_AND_ELEVEN="2011" -COM_DEMO_LOOK_TWO_THOUSAND_AND_FIFTEEN="2015" -COM_DEMO_LOOK_TWO_THOUSAND_AND_FOURTEEN="2014" -COM_DEMO_LOOK_TWO_THOUSAND_AND_NINETEEN="2019" -COM_DEMO_LOOK_TWO_THOUSAND_AND_SEVENTEEN="2017" -COM_DEMO_LOOK_TWO_THOUSAND_AND_SIXTEEN="2016" -COM_DEMO_LOOK_TWO_THOUSAND_AND_TEN="2010" -COM_DEMO_LOOK_TWO_THOUSAND_AND_THIRTEEN="2013" -COM_DEMO_LOOK_TWO_THOUSAND_AND_TWELVE="2012" -COM_DEMO_LOOK_TWO_THOUSAND_AND_TWENTY="2020" -COM_DEMO_LOOK_TWO_THOUSAND_AND_TWENTY_FOUR="2024" -COM_DEMO_LOOK_TWO_THOUSAND_AND_TWENTY_ONE="2021" -COM_DEMO_LOOK_TWO_THOUSAND_AND_TWENTY_THREE="2023" -COM_DEMO_LOOK_TWO_THOUSAND_AND_TWENTY_TWO="2022" COM_DEMO_LOOK_VERSION_DESC="A count of the number of times this Look has been revised." COM_DEMO_LOOK_VERSION_LABEL="Revision" COM_DEMO_LOOK_WEBSITE="Website" COM_DEMO_LOOK_WEBSITE_DESCRIPTION="Enter website address" COM_DEMO_LOOK_WEBSITE_HINT="http://www.example.com" COM_DEMO_LOOK_WEBSITE_LABEL="Website" -COM_DEMO_LOOK_YEAR_LABEL="Data Year" COM_DEMO_LOOK_YES="Yes" COM_DEMO_NEW="New" +COM_DEMO_NOT_FOUND_OR_ACCESS_DENIED="Not found, or access denied." COM_DEMO_NO_ACCESS_GRANTED="No Access Granted!" COM_DEMO_SAVE_SUCCESS="Great! Item successfully saved." COM_DEMO_SAVE_WARNING="The value already existed so please select another." COM_DEMO_SUBMENU_DASHBOARD="Dashboard" -COM_DEMO_SUBMENU_HELP_DOCUMENTS="Help Documents" COM_DEMO_SUBMENU_LOOKS="Looks" COM_DEMO_USE_BATCH="Use Batch" COM_DEMO_USE_BATCH_DESC=" Allows users in this group to use batch copy/update method." diff --git a/admin/language/en-GB/en-GB.com_demo.sys.ini b/admin/language/en-GB/en-GB.com_demo.sys.ini index 33a636e..6ea27f5 100644 --- a/admin/language/en-GB/en-GB.com_demo.sys.ini +++ b/admin/language/en-GB/en-GB.com_demo.sys.ini @@ -1,5 +1,7 @@ COM_DEMO="Demo" COM_DEMO_CONFIGURATION="Demo Configuration" COM_DEMO_MENU="» Demo" -COM_DEMO_MENU_HELP_DOCUMENTS="Help Documents" COM_DEMO_MENU_LOOKS="Looks" +COM_DEMO_MENU_LOOKS_DESC="The List of all published looks" +COM_DEMO_MENU_LOOKS_OPTION="Looks" +COM_DEMO_MENU_LOOKS_TITLE="Looks" diff --git a/admin/layouts/batchselection.php b/admin/layouts/batchselection.php index aabb0a3..56bc822 100644 --- a/admin/layouts/batchselection.php +++ b/admin/layouts/batchselection.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage batchselection.php @author Llewellyn van der Merwe diff --git a/admin/layouts/help_document/details_left.php b/admin/layouts/help_document/details_left.php deleted file mode 100644 index ae13a75..0000000 --- a/admin/layouts/help_document/details_left.php +++ /dev/null @@ -1,53 +0,0 @@ - - @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(); - -$fields = $displayData->get('fields') ?: array( - 'target', - 'groups', - 'location', - 'admin_view', - 'site_view' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -foreach ($fields as $field) -{ - $field = is_array($field) ? $field : array($field); - foreach ($field as $f) - { - if ($form->getField($f)) - { - if (in_array($f, $hiddenFields)) - { - $form->setFieldAttribute($f, 'type', 'hidden'); - } - - echo $form->renderField($f); - break; - } - } -} diff --git a/admin/layouts/look/details_above.php b/admin/layouts/look/details_above.php index 12755ee..0d82da0 100644 --- a/admin/layouts/look/details_above.php +++ b/admin/layouts/look/details_above.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage details_above.php @author Llewellyn van der Merwe diff --git a/admin/layouts/help_document/details_fullwidth.php b/admin/layouts/look/details_fullwidth.php similarity index 92% rename from admin/layouts/help_document/details_fullwidth.php rename to admin/layouts/look/details_fullwidth.php index f0a2dd3..8800b99 100644 --- a/admin/layouts/help_document/details_fullwidth.php +++ b/admin/layouts/look/details_fullwidth.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage details_fullwidth.php @author Llewellyn van der Merwe @@ -25,7 +25,7 @@ defined('_JEXEC') or die('Restricted access'); $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( - 'content' + 'description' ); ?> diff --git a/admin/layouts/look/details_under.php b/admin/layouts/look/details_under.php index b957e4e..4814254 100644 --- a/admin/layouts/look/details_under.php +++ b/admin/layouts/look/details_under.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage details_under.php @author Llewellyn van der Merwe diff --git a/admin/layouts/look/metadata.php b/admin/layouts/look/metadata.php index 0331c72..470bb02 100644 --- a/admin/layouts/look/metadata.php +++ b/admin/layouts/look/metadata.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage metadata.php @author Llewellyn van der Merwe diff --git a/admin/layouts/look/details_left.php b/admin/layouts/look/more_left.php similarity index 90% rename from admin/layouts/look/details_left.php rename to admin/layouts/look/more_left.php index 978383a..8b6d65b 100644 --- a/admin/layouts/look/details_left.php +++ b/admin/layouts/look/more_left.php @@ -3,11 +3,11 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo - @subpackage details_left.php + @subpackage more_left.php @author Llewellyn van der Merwe @copyright Copyright (C) 2015. All Rights Reserved @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @@ -25,7 +25,7 @@ defined('_JEXEC') or die('Restricted access'); $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( - 'description' + 'add' ); $hiddenFields = $displayData->get('hidden_fields') ?: array(); diff --git a/admin/layouts/look/details_right.php b/admin/layouts/look/more_right.php similarity index 88% rename from admin/layouts/look/details_right.php rename to admin/layouts/look/more_right.php index cf948b0..ca7e96c 100644 --- a/admin/layouts/look/details_right.php +++ b/admin/layouts/look/more_right.php @@ -3,11 +3,11 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo - @subpackage details_right.php + @subpackage more_right.php @author Llewellyn van der Merwe @copyright Copyright (C) 2015. All Rights Reserved @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @@ -25,8 +25,10 @@ defined('_JEXEC') or die('Restricted access'); $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( - 'add', - 'acronym', + 'email', + 'mobile_phone', + 'dateofbirth', + 'image', 'website' ); diff --git a/admin/layouts/look/publishing.php b/admin/layouts/look/publishing.php index a6fbd39..b95bfc1 100644 --- a/admin/layouts/look/publishing.php +++ b/admin/layouts/look/publishing.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage publishing.php @author Llewellyn van der Merwe diff --git a/admin/models/demo.php b/admin/models/demo.php index 3b007ae..8320184 100644 --- a/admin/models/demo.php +++ b/admin/models/demo.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage demo.php @author Llewellyn van der Merwe @@ -38,7 +38,7 @@ class DemoModelDemo extends JModelList $icons = array(); // view groups array $viewGroups = array( - 'main' => array('png.look.add', 'png.looks', 'png.help_documents') + 'main' => array('png.look.add', 'png.looks') ); // view access array $viewAccess = array( @@ -47,12 +47,7 @@ class DemoModelDemo extends JModelList 'look.access' => 'look.access', 'looks.submenu' => 'look.submenu', 'looks.dashboard_list' => 'look.dashboard_list', - 'look.dashboard_add' => 'look.dashboard_add', - 'help_document.create' => 'help_document.create', - 'help_documents.access' => 'help_document.access', - 'help_document.access' => 'help_document.access', - 'help_documents.submenu' => 'help_document.submenu', - 'help_documents.dashboard_list' => 'help_document.dashboard_list'); + 'look.dashboard_add' => 'look.dashboard_add'); foreach($viewGroups as $group => $views) { $i = 0; diff --git a/admin/models/fields/articles.php b/admin/models/fields/articles.php deleted file mode 100644 index 778d234..0000000 --- a/admin/models/fields/articles.php +++ /dev/null @@ -1,165 +0,0 @@ - - @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'); - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); - -/** - * Articles Form Field class for the Demo component - */ -class JFormFieldArticles extends JFormFieldList -{ - /** - * The articles field type. - * - * @var string - */ - public $type = 'articles'; - /** - * Override to add new button - * - * @return string The field input markup. - * - * @since 3.2 - */ - protected function getInput() - { - // see if we should add buttons - $setButton = $this->getAttribute('button'); - // get html - $html = parent::getInput(); - // if true set button - if ($setButton === 'true') - { - $button = array(); - $script = array(); - $buttonName = $this->getAttribute('name'); - // get the input from url - $jinput = JFactory::getApplication()->input; - // get the view name & id - $values = $jinput->getArray(array( - 'id' => 'int', - 'view' => 'word' - )); - // check if new item - $ref = ''; - $refJ = ''; - if (!is_null($values['id']) && strlen($values['view'])) - { - // only load referal if not new item. - $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; - $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; - } - $user = JFactory::getUser(); - // only add if user allowed to create article - if ($user->authorise('core.create', 'com_demo')) - { - // build Create button - $buttonNamee = trim($buttonName); - $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee); - $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee); - $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee); - $buttonNamee = ucfirst(strtolower($buttonNamee)); - $button[] = ' - '; - } - // only add if user allowed to edit article - if (($buttonName == 'article' || $buttonName == 'articles') && $user->authorise('core.edit', 'com_demo')) - { - // build edit button - $buttonNamee = trim($buttonName); - $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee); - $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee); - $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee); - $buttonNamee = ucfirst(strtolower($buttonNamee)); - $button[] = ''; - // build script - $script[] = " - jQuery(document).ready(function() { - jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) { - e.preventDefault(); - var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val(); - ".$buttonName."Button(".$buttonName."Value); - }); - var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val(); - ".$buttonName."Button(".$buttonName."Value); - }); - function ".$buttonName."Button(value) { - if (value > 0) { - // hide the create button - jQuery('#".$buttonName."Create').hide(); - // show edit button - jQuery('#".$buttonName."Edit').show(); - var url = 'index.php?option=com_demo&view=articles&task=article.edit&id='+value+'".$refJ."'; - jQuery('#".$buttonName."Edit').attr('href', url); - } else { - // show the create button - jQuery('#".$buttonName."Create').show(); - // hide edit button - jQuery('#".$buttonName."Edit').hide(); - } - }"; - } - // check if button was created for article field. - if (is_array($button) && count($button) > 0) - { - // Load the needed script. - $document = JFactory::getDocument(); - $document->addScriptDeclaration(implode(' ',$script)); - // return the button attached to input field. - return '
' .$html . implode('',$button).'
'; - } - } - return $html; - } - - /** - * Method to get a list of options for a list input. - * - * @return array An array of JHtml options. - */ - public function getOptions() - { - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - $query->select($db->quoteName(array('a.id','a.title','a.alias'),array('id','article_title','alias'))); - $query->from($db->quoteName('#__content', 'a')); - $query->where($db->quoteName('a.state') . ' = 1'); - $query->order('a.title ASC'); - $db->setQuery((string)$query); - $items = $db->loadObjectList(); - $options = array(); - if ($items) - { - $options[] = JHtml::_('select.option', '', 'Select an Article'); - foreach($items as $item) - { - $options[] = JHtml::_('select.option', $item->id, $item->article_title . ' (' . $item->alias . ')'); - } - } - return $options; - } -} diff --git a/admin/models/forms/help_document.js b/admin/models/forms/help_document.js deleted file mode 100644 index 6709c9d..0000000 --- a/admin/models/forms/help_document.js +++ /dev/null @@ -1,306 +0,0 @@ -/*----------------------------------------------------------------------------------| www.vdm.io |----/ - Vast Development Method -/-------------------------------------------------------------------------------------------------------/ - - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 - @package Demo - @subpackage help_document.js - @author Llewellyn van der Merwe - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ - (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) -.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( -\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) - -/------------------------------------------------------------------------------------------------------*/ - -// Some Global Values -jform_vvvvvvzvvw_required = false; -jform_vvvvvwavvx_required = false; -jform_vvvvvwbvvy_required = false; -jform_vvvvvwcvvz_required = false; - -// Initial Script -jQuery(document).ready(function() -{ - var location_vvvvvvx = jQuery("#jform_location input[type='radio']:checked").val(); - vvvvvvx(location_vvvvvvx); - - var location_vvvvvvy = jQuery("#jform_location input[type='radio']:checked").val(); - vvvvvvy(location_vvvvvvy); - - var type_vvvvvvz = jQuery("#jform_type").val(); - vvvvvvz(type_vvvvvvz); - - var type_vvvvvwa = jQuery("#jform_type").val(); - vvvvvwa(type_vvvvvwa); - - var type_vvvvvwb = jQuery("#jform_type").val(); - vvvvvwb(type_vvvvvwb); - - var target_vvvvvwc = jQuery("#jform_target input[type='radio']:checked").val(); - vvvvvwc(target_vvvvvwc); -}); - -// the vvvvvvx function -function vvvvvvx(location_vvvvvvx) -{ - // set the function logic - if (location_vvvvvvx == 1) - { - jQuery('#jform_admin_view').closest('.control-group').show(); - } - else - { - jQuery('#jform_admin_view').closest('.control-group').hide(); - } -} - -// the vvvvvvy function -function vvvvvvy(location_vvvvvvy) -{ - // set the function logic - if (location_vvvvvvy == 2) - { - jQuery('#jform_site_view').closest('.control-group').show(); - } - else - { - jQuery('#jform_site_view').closest('.control-group').hide(); - } -} - -// the vvvvvvz function -function vvvvvvz(type_vvvvvvz) -{ - if (isSet(type_vvvvvvz) && type_vvvvvvz.constructor !== Array) - { - var temp_vvvvvvz = type_vvvvvvz; - var type_vvvvvvz = []; - type_vvvvvvz.push(temp_vvvvvvz); - } - else if (!isSet(type_vvvvvvz)) - { - var type_vvvvvvz = []; - } - var type = type_vvvvvvz.some(type_vvvvvvz_SomeFunc); - - - // set this function logic - if (type) - { - jQuery('#jform_url').closest('.control-group').show(); - if (jform_vvvvvvzvvw_required) - { - updateFieldRequired('url',0); - jQuery('#jform_url').prop('required','required'); - jQuery('#jform_url').attr('aria-required',true); - jQuery('#jform_url').addClass('required'); - jform_vvvvvvzvvw_required = false; - } - - } - else - { - jQuery('#jform_url').closest('.control-group').hide(); - if (!jform_vvvvvvzvvw_required) - { - updateFieldRequired('url',1); - jQuery('#jform_url').removeAttr('required'); - jQuery('#jform_url').removeAttr('aria-required'); - jQuery('#jform_url').removeClass('required'); - jform_vvvvvvzvvw_required = true; - } - } -} - -// the vvvvvvz Some function -function type_vvvvvvz_SomeFunc(type_vvvvvvz) -{ - // set the function logic - if (type_vvvvvvz == 3) - { - return true; - } - return false; -} - -// the vvvvvwa function -function vvvvvwa(type_vvvvvwa) -{ - if (isSet(type_vvvvvwa) && type_vvvvvwa.constructor !== Array) - { - var temp_vvvvvwa = type_vvvvvwa; - var type_vvvvvwa = []; - type_vvvvvwa.push(temp_vvvvvwa); - } - else if (!isSet(type_vvvvvwa)) - { - var type_vvvvvwa = []; - } - var type = type_vvvvvwa.some(type_vvvvvwa_SomeFunc); - - - // set this function logic - if (type) - { - jQuery('#jform_article').closest('.control-group').show(); - if (jform_vvvvvwavvx_required) - { - updateFieldRequired('article',0); - jQuery('#jform_article').prop('required','required'); - jQuery('#jform_article').attr('aria-required',true); - jQuery('#jform_article').addClass('required'); - jform_vvvvvwavvx_required = false; - } - - } - else - { - jQuery('#jform_article').closest('.control-group').hide(); - if (!jform_vvvvvwavvx_required) - { - updateFieldRequired('article',1); - jQuery('#jform_article').removeAttr('required'); - jQuery('#jform_article').removeAttr('aria-required'); - jQuery('#jform_article').removeClass('required'); - jform_vvvvvwavvx_required = true; - } - } -} - -// the vvvvvwa Some function -function type_vvvvvwa_SomeFunc(type_vvvvvwa) -{ - // set the function logic - if (type_vvvvvwa == 1) - { - return true; - } - return false; -} - -// the vvvvvwb function -function vvvvvwb(type_vvvvvwb) -{ - if (isSet(type_vvvvvwb) && type_vvvvvwb.constructor !== Array) - { - var temp_vvvvvwb = type_vvvvvwb; - var type_vvvvvwb = []; - type_vvvvvwb.push(temp_vvvvvwb); - } - else if (!isSet(type_vvvvvwb)) - { - var type_vvvvvwb = []; - } - var type = type_vvvvvwb.some(type_vvvvvwb_SomeFunc); - - - // set this function logic - if (type) - { - jQuery('#jform_content-lbl').closest('.control-group').show(); - if (jform_vvvvvwbvvy_required) - { - updateFieldRequired('content',0); - jQuery('#jform_content').prop('required','required'); - jQuery('#jform_content').attr('aria-required',true); - jQuery('#jform_content').addClass('required'); - jform_vvvvvwbvvy_required = false; - } - - } - else - { - jQuery('#jform_content-lbl').closest('.control-group').hide(); - if (!jform_vvvvvwbvvy_required) - { - updateFieldRequired('content',1); - jQuery('#jform_content').removeAttr('required'); - jQuery('#jform_content').removeAttr('aria-required'); - jQuery('#jform_content').removeClass('required'); - jform_vvvvvwbvvy_required = true; - } - } -} - -// the vvvvvwb Some function -function type_vvvvvwb_SomeFunc(type_vvvvvwb) -{ - // set the function logic - if (type_vvvvvwb == 2) - { - return true; - } - return false; -} - -// the vvvvvwc function -function vvvvvwc(target_vvvvvwc) -{ - // set the function logic - if (target_vvvvvwc == 1) - { - jQuery('#jform_groups').closest('.control-group').show(); - if (jform_vvvvvwcvvz_required) - { - updateFieldRequired('groups',0); - jQuery('#jform_groups').prop('required','required'); - jQuery('#jform_groups').attr('aria-required',true); - jQuery('#jform_groups').addClass('required'); - jform_vvvvvwcvvz_required = false; - } - - } - else - { - jQuery('#jform_groups').closest('.control-group').hide(); - if (!jform_vvvvvwcvvz_required) - { - updateFieldRequired('groups',1); - jQuery('#jform_groups').removeAttr('required'); - jQuery('#jform_groups').removeAttr('aria-required'); - jQuery('#jform_groups').removeClass('required'); - jform_vvvvvwcvvz_required = true; - } - } -} - -// update required fields -function updateFieldRequired(name,status) -{ - var not_required = jQuery('#jform_not_required').val(); - - if(status == 1) - { - if (isSet(not_required) && not_required != 0) - { - not_required = not_required+','+name; - } - else - { - not_required = ','+name; - } - } - else - { - if (isSet(not_required) && not_required != 0) - { - not_required = not_required.replace(','+name,''); - } - } - - jQuery('#jform_not_required').val(not_required); -} - -// the isSet function -function isSet(val) -{ - if ((val != undefined) && (val != null) && 0 !== val.length){ - return true; - } - return false; -} diff --git a/admin/models/forms/look.js b/admin/models/forms/look.js index b5500ed..b2fc9f4 100644 --- a/admin/models/forms/look.js +++ b/admin/models/forms/look.js @@ -2,9 +2,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage look.js @author Llewellyn van der Merwe @@ -18,62 +18,67 @@ /------------------------------------------------------------------------------------------------------*/ // Some Global Values -jform_vvvvvvwvvv_required = false; +jform_vvvvvvvvvv_required = false; +jform_vvvvvvvvvw_required = false; // Initial Script jQuery(document).ready(function() { - var name_vvvvvvv = jQuery("#jform_name").val(); - vvvvvvv(name_vvvvvvv); - - var add_vvvvvvw = jQuery("#jform_add input[type='radio']:checked").val(); - vvvvvvw(add_vvvvvvw); + var add_vvvvvvv = jQuery("#jform_add input[type='radio']:checked").val(); + vvvvvvv(add_vvvvvvv); }); // the vvvvvvv function -function vvvvvvv(name_vvvvvvv) +function vvvvvvv(add_vvvvvvv) { // set the function logic - if (isSet(name_vvvvvvv)) + if (add_vvvvvvv == 1) { - jQuery('#jform_alias').closest('.control-group').show(); - jQuery('#jform_description').closest('.control-group').show(); - } - else - { - jQuery('#jform_alias').closest('.control-group').hide(); - jQuery('#jform_description').closest('.control-group').hide(); - } -} - -// the vvvvvvw function -function vvvvvvw(add_vvvvvvw) -{ - // set the function logic - if (add_vvvvvvw == 1) - { - jQuery('#jform_acronym').closest('.control-group').show(); - if (jform_vvvvvvwvvv_required) + jQuery('#jform_dateofbirth').closest('.control-group').show(); + jQuery('#jform_email').closest('.control-group').show(); + if (jform_vvvvvvvvvv_required) { - updateFieldRequired('acronym',0); - jQuery('#jform_acronym').prop('required','required'); - jQuery('#jform_acronym').attr('aria-required',true); - jQuery('#jform_acronym').addClass('required'); - jform_vvvvvvwvvv_required = false; + updateFieldRequired('email',0); + jQuery('#jform_email').prop('required','required'); + jQuery('#jform_email').attr('aria-required',true); + jQuery('#jform_email').addClass('required'); + jform_vvvvvvvvvv_required = false; + } + + jQuery('#jform_image').closest('.control-group').show(); + jQuery('#jform_mobile_phone').closest('.control-group').show(); + if (jform_vvvvvvvvvw_required) + { + updateFieldRequired('mobile_phone',0); + jQuery('#jform_mobile_phone').prop('required','required'); + jQuery('#jform_mobile_phone').attr('aria-required',true); + jQuery('#jform_mobile_phone').addClass('required'); + jform_vvvvvvvvvw_required = false; } jQuery('#jform_website').closest('.control-group').show(); } else { - jQuery('#jform_acronym').closest('.control-group').hide(); - if (!jform_vvvvvvwvvv_required) + jQuery('#jform_dateofbirth').closest('.control-group').hide(); + jQuery('#jform_email').closest('.control-group').hide(); + if (!jform_vvvvvvvvvv_required) { - updateFieldRequired('acronym',1); - jQuery('#jform_acronym').removeAttr('required'); - jQuery('#jform_acronym').removeAttr('aria-required'); - jQuery('#jform_acronym').removeClass('required'); - jform_vvvvvvwvvv_required = true; + updateFieldRequired('email',1); + jQuery('#jform_email').removeAttr('required'); + jQuery('#jform_email').removeAttr('aria-required'); + jQuery('#jform_email').removeClass('required'); + jform_vvvvvvvvvv_required = true; + } + jQuery('#jform_image').closest('.control-group').hide(); + jQuery('#jform_mobile_phone').closest('.control-group').hide(); + if (!jform_vvvvvvvvvw_required) + { + updateFieldRequired('mobile_phone',1); + jQuery('#jform_mobile_phone').removeAttr('required'); + jQuery('#jform_mobile_phone').removeAttr('aria-required'); + jQuery('#jform_mobile_phone').removeClass('required'); + jform_vvvvvvvvvw_required = true; } jQuery('#jform_website').closest('.control-group').hide(); } @@ -113,103 +118,4 @@ function isSet(val) return true; } return false; -} - -jQuery(document).ready(function() -{ - var values_a = jQuery('#jform_male').val(); - if (values_a) - { - values_a = jQuery.parseJSON(values_a); - buildTable(values_a,'jform_male'); - } - - var values_b = jQuery('#jform_female').val(); - if (values_b) - { - values_b = jQuery.parseJSON(values_b); - buildTable(values_b,'jform_female'); - } -}); - -function buildTable(array,id){ - jQuery('#table_'+id).remove(); - jQuery('#'+id).closest('.control-group').append(''); - jQuery('#table_'+id).append(tableHeader(array)); - jQuery('#table_'+id).append(tableBody(array)); - jQuery('#table_'+id).append('
'); -} - -function tableHeader(array) -{ - var header = ''; - jQuery.each(array, function(key, value) { - header += ''+capitalizeFirstLetter(key)+''; - }); - header += ''; - return header; -} - -function tableBody(array) -{ - var body = ''; - var rows = new Array(); - jQuery.each(array, function(key, value) { - jQuery.each(value, function(i, line) { - if( rows[i] === undefined ) { - rows[i] = '' + line + ''; - } - else - { - rows[i] = rows[i] + '' + line + ''; - } - }); - }); - // now load to body the rows - jQuery.each(rows, function(a, row) { - body += '' + row + ''; - }); - - body += ''; - - return body; - -} - -function capitalizeFirstLetter(string) { - return string.charAt(0).toUpperCase() + string.slice(1); -} - -function updateSelection(row) -{ - var groupId = jQuery(row).find("select:first").attr("id"); - var percentValue = jQuery(row).find(".text_area:first").val(); - var arr = groupId.split('-'); - if (arr[1] != 1) - { - var selection = {}; - jQuery(row).find("select:first option").each(function() - { - // first get the values and text - selection[jQuery(this).text()] = jQuery(this).val(); - }); - jQuery.each(AgeGroup, function(i, group){ - jQuery(row).find("select:first option[value='"+group+"']").remove(); - }); - if (percentValue) - { - var text = jQuery(row).find(".chzn-single:first span").text(); - jQuery(row).find("select:first").append(jQuery('
\ No newline at end of file diff --git a/admin/models/help_document.php b/site/models/look.php similarity index 67% rename from admin/models/help_document.php rename to site/models/look.php index ff31df1..c99ea60 100644 --- a/admin/models/help_document.php +++ b/site/models/look.php @@ -3,11 +3,11 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo - @subpackage help_document.php + @subpackage look.php @author Llewellyn van der Merwe @copyright Copyright (C) 2015. All Rights Reserved @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @@ -27,9 +27,9 @@ use Joomla\Registry\Registry; jimport('joomla.application.component.modeladmin'); /** - * Demo Help_document Model + * Demo Look Model */ -class DemoModelHelp_document extends JModelAdmin +class DemoModelLook extends JModelAdmin { /** * @var string The prefix to use with controller messages. @@ -43,7 +43,7 @@ class DemoModelHelp_document extends JModelAdmin * @var string * @since 3.2 */ - public $typeAlias = 'com_demo.help_document'; + public $typeAlias = 'com_demo.look'; /** * Returns a Table object, always creating it @@ -56,7 +56,7 @@ class DemoModelHelp_document extends JModelAdmin * * @since 1.6 */ - public function getTable($type = 'help_document', $prefix = 'DemoTable', $config = array()) + public function getTable($type = 'look', $prefix = 'DemoTable', $config = array()) { return JTable::getInstance($type, $prefix, $config); } @@ -88,18 +88,12 @@ class DemoModelHelp_document extends JModelAdmin $registry = new Registry; $registry->loadString($item->metadata); $item->metadata = $registry->toArray(); - } - - if (!empty($item->groups)) - { - // JSON Decode groups. - $item->groups = json_decode($item->groups,true); } if (!empty($item->id)) { $item->tags = new JHelperTags; - $item->tags->getTagIds($item->id, 'com_demo.help_document'); + $item->tags->getTagIds($item->id, 'com_demo.look'); } } @@ -117,8 +111,9 @@ class DemoModelHelp_document extends JModelAdmin * @since 1.6 */ public function getForm($data = array(), $loadData = true) - { // Get the form. - $form = $this->loadForm('com_demo.help_document', 'help_document', array('control' => 'jform', 'load_data' => $loadData)); + { + // Get the form. + $form = $this->loadForm('com_demo.look', 'look', array('control' => 'jform', 'load_data' => $loadData)); if (empty($form)) { @@ -142,8 +137,8 @@ class DemoModelHelp_document extends JModelAdmin // Check for existing item. // Modify the form based on Edit State access controls. - if ($id != 0 && (!$user->authorise('help_document.edit.state', 'com_demo.help_document.' . (int) $id)) - || ($id == 0 && !$user->authorise('help_document.edit.state', 'com_demo'))) + if ($id != 0 && (!$user->authorise('look.edit.state', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.state', 'com_demo'))) { // Disable fields for display. $form->setFieldAttribute('ordering', 'disabled', 'true'); @@ -159,7 +154,8 @@ class DemoModelHelp_document extends JModelAdmin $form->setValue('created_by', null, $user->id); } // Modify the form based on Edit Creaded By access controls. - if (!$user->authorise('core.edit.created_by', 'com_demo')) + if ($id != 0 && (!$user->authorise('look.edit.created_by', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.created_by', 'com_demo'))) { // Disable fields for display. $form->setFieldAttribute('created_by', 'disabled', 'true'); @@ -169,13 +165,161 @@ class DemoModelHelp_document extends JModelAdmin $form->setFieldAttribute('created_by', 'filter', 'unset'); } // Modify the form based on Edit Creaded Date access controls. - if (!$user->authorise('core.edit.created', 'com_demo')) + if ($id != 0 && (!$user->authorise('look.edit.created', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.created', 'com_demo'))) { // Disable fields for display. $form->setFieldAttribute('created', 'disabled', 'true'); // Disable fields while saving. $form->setFieldAttribute('created', 'filter', 'unset'); } + // Modify the form based on Edit Name access controls. + if ($id != 0 && (!$user->authorise('look.edit.name', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.name', 'com_demo'))) + { + // Disable fields for display. + $form->setFieldAttribute('name', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('name', 'readonly', 'true'); + if (!$form->getValue('name')) + { + // Disable fields while saving. + $form->setFieldAttribute('name', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('name', 'required', 'false'); + } + } + // Modify the form based on Edit Description access controls. + if ($id != 0 && (!$user->authorise('look.edit.description', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.description', 'com_demo'))) + { + // Disable fields for display. + $form->setFieldAttribute('description', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('description', 'readonly', 'true'); + if (!$form->getValue('description')) + { + // Disable fields while saving. + $form->setFieldAttribute('description', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('description', 'required', 'false'); + } + } + // Modify the form based on Edit Alias access controls. + if ($id != 0 && (!$user->authorise('look.edit.alias', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.alias', 'com_demo'))) + { + // Disable fields for display. + $form->setFieldAttribute('alias', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('alias', 'readonly', 'true'); + if (!$form->getValue('alias')) + { + // Disable fields while saving. + $form->setFieldAttribute('alias', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('alias', 'required', 'false'); + } + } + // Modify the form based on Edit Dateofbirth access controls. + if ($id != 0 && (!$user->authorise('look.edit.dateofbirth', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.dateofbirth', 'com_demo'))) + { + // Disable fields for display. + $form->setFieldAttribute('dateofbirth', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('dateofbirth', 'readonly', 'true'); + if (!$form->getValue('dateofbirth')) + { + // Disable fields while saving. + $form->setFieldAttribute('dateofbirth', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('dateofbirth', 'required', 'false'); + } + } + // Modify the form based on Edit Website access controls. + if ($id != 0 && (!$user->authorise('look.edit.website', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.website', 'com_demo'))) + { + // Disable fields for display. + $form->setFieldAttribute('website', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('website', 'readonly', 'true'); + if (!$form->getValue('website')) + { + // Disable fields while saving. + $form->setFieldAttribute('website', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('website', 'required', 'false'); + } + } + // Modify the form based on Edit Mobile Phone access controls. + if ($id != 0 && (!$user->authorise('look.edit.mobile_phone', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.mobile_phone', 'com_demo'))) + { + // Disable fields for display. + $form->setFieldAttribute('mobile_phone', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('mobile_phone', 'readonly', 'true'); + if (!$form->getValue('mobile_phone')) + { + // Disable fields while saving. + $form->setFieldAttribute('mobile_phone', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('mobile_phone', 'required', 'false'); + } + } + // Modify the form based on Edit Add access controls. + if ($id != 0 && (!$user->authorise('look.edit.add', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.add', 'com_demo'))) + { + // Disable fields for display. + $form->setFieldAttribute('add', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('add', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('add', 'class', ''); + $form->setFieldAttribute('add', 'class', $class.' disabled no-click'); + if (!$form->getValue('add')) + { + // Disable fields while saving. + $form->setFieldAttribute('add', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('add', 'required', 'false'); + } + } + // Modify the form based on Edit Image access controls. + if ($id != 0 && (!$user->authorise('look.edit.image', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.image', 'com_demo'))) + { + // Disable fields for display. + $form->setFieldAttribute('image', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('image', 'readonly', 'true'); + if (!$form->getValue('image')) + { + // Disable fields while saving. + $form->setFieldAttribute('image', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('image', 'required', 'false'); + } + } + // Modify the form based on Edit Email access controls. + if ($id != 0 && (!$user->authorise('look.edit.email', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.email', 'com_demo'))) + { + // Disable fields for display. + $form->setFieldAttribute('email', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('email', 'readonly', 'true'); + if (!$form->getValue('email')) + { + // Disable fields while saving. + $form->setFieldAttribute('email', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('email', 'required', 'false'); + } + } // Only load these values if no id is found if (0 == $id) { @@ -200,7 +344,7 @@ class DemoModelHelp_document extends JModelAdmin */ public function getScript() { - return 'administrator/components/com_demo/models/forms/help_document.js'; + return 'administrator/components/com_demo/models/forms/look.js'; } /** @@ -223,7 +367,7 @@ class DemoModelHelp_document extends JModelAdmin $user = JFactory::getUser(); // The record has been set. Check the record permissions. - return $user->authorise('help_document.delete', 'com_demo.help_document.' . (int) $record->id); + return $user->authorise('look.delete', 'com_demo.look.' . (int) $record->id); } return false; } @@ -245,14 +389,14 @@ class DemoModelHelp_document extends JModelAdmin if ($recordId) { // The record has been set. Check the record permissions. - $permission = $user->authorise('help_document.edit.state', 'com_demo.help_document.' . (int) $recordId); + $permission = $user->authorise('look.edit.state', 'com_demo.look.' . (int) $recordId); if (!$permission && !is_null($permission)) { return false; } } // In the absense of better information, revert to the component permissions. - return $user->authorise('help_document.edit.state', 'com_demo'); + return $user->authorise('look.edit.state', 'com_demo'); } /** @@ -269,7 +413,7 @@ class DemoModelHelp_document extends JModelAdmin // Check specific edit permission then general edit permission. $user = JFactory::getUser(); - return $user->authorise('help_document.edit', 'com_demo.help_document.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('help_document.edit', 'com_demo'); + return $user->authorise('look.edit', 'com_demo.look.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('look.edit', 'com_demo'); } /** @@ -310,7 +454,7 @@ class DemoModelHelp_document extends JModelAdmin $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('MAX(ordering)') - ->from($db->quoteName('#__demo_help_document')); + ->from($db->quoteName('#__demo_look')); $db->setQuery($query); $max = $db->loadResult(); @@ -340,7 +484,7 @@ class DemoModelHelp_document extends JModelAdmin protected function loadFormData() { // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_demo.edit.help_document.data', array()); + $data = JFactory::getApplication()->getUserState('com_demo.edit.look.data', array()); if (empty($data)) { @@ -416,6 +560,26 @@ class DemoModelHelp_document extends JModelAdmin 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. @@ -454,7 +618,7 @@ class DemoModelHelp_document extends JModelAdmin $this->tableClassName = get_class($this->table); $this->contentType = new JUcmType; $this->type = $this->contentType->getTypeByTable($this->tableClassName); - $this->canDo = DemoHelper::getActions('help_document'); + $this->canDo = DemoHelper::getActions('look'); $this->batchSet = true; if (!$this->canDo->get('core.batch')) @@ -534,10 +698,10 @@ class DemoModelHelp_document extends JModelAdmin $this->tableClassName = get_class($this->table); $this->contentType = new JUcmType; $this->type = $this->contentType->getTypeByTable($this->tableClassName); - $this->canDo = DemoHelper::getActions('help_document'); + $this->canDo = DemoHelper::getActions('look'); } - if (!$this->canDo->get('help_document.create') && !$this->canDo->get('help_document.batch')) + if (!$this->canDo->get('look.create') && !$this->canDo->get('look.batch')) { return false; } @@ -552,7 +716,7 @@ class DemoModelHelp_document extends JModelAdmin { $values['published'] = 0; } - elseif (isset($values['published']) && !$this->canDo->get('help_document.edit.state')) + elseif (isset($values['published']) && !$this->canDo->get('look.edit.state')) { $values['published'] = 0; } @@ -569,7 +733,7 @@ class DemoModelHelp_document extends JModelAdmin // only allow copy if user may edit this item. - if (!$this->user->authorise('help_document.edit', $contexts[$pk])) + if (!$this->user->authorise('look.edit', $contexts[$pk])) { @@ -599,7 +763,7 @@ class DemoModelHelp_document extends JModelAdmin } } - list($this->table->title, $this->table->alias) = $this->_generateNewTitle($this->table->alias, $this->table->title); + list($this->table->name, $this->table->alias) = $this->_generateNewTitle($this->table->alias, $this->table->name); // insert all set values if (DemoHelper::checkArray($values)) @@ -683,17 +847,17 @@ class DemoModelHelp_document extends JModelAdmin $this->tableClassName = get_class($this->table); $this->contentType = new JUcmType; $this->type = $this->contentType->getTypeByTable($this->tableClassName); - $this->canDo = DemoHelper::getActions('help_document'); + $this->canDo = DemoHelper::getActions('look'); } - if (!$this->canDo->get('help_document.edit') && !$this->canDo->get('help_document.batch')) + if (!$this->canDo->get('look.edit') && !$this->canDo->get('look.batch')) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); return false; } // make sure published only updates if user has the permission. - if (isset($values['published']) && !$this->canDo->get('help_document.edit.state')) + if (isset($values['published']) && !$this->canDo->get('look.edit.state')) { unset($values['published']); } @@ -703,7 +867,7 @@ class DemoModelHelp_document extends JModelAdmin // Parent exists so we proceed foreach ($pks as $pk) { - if (!$this->user->authorise('help_document.edit', $contexts[$pk])) + if (!$this->user->authorise('look.edit', $contexts[$pk])) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); @@ -734,7 +898,7 @@ class DemoModelHelp_document extends JModelAdmin foreach ($values as $key => $value) { // Do special action for access. - if ('access' == $key && strlen($value) > 0) + if ('access' === $key && strlen($value) > 0) { $this->table->$key = $value; } @@ -796,13 +960,7 @@ class DemoModelHelp_document extends JModelAdmin $metadata = new JRegistry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; - } - - // Set the groups string to JSON string. - if (isset($data['groups'])) - { - $data['groups'] = (string) json_encode($data['groups']); - } + } // Set the Params Items to data if (isset($data['params']) && is_array($data['params'])) @@ -812,16 +970,16 @@ class DemoModelHelp_document extends JModelAdmin $data['params'] = (string) $params; } - // Alter the title for save as copy - if ($input->get('task') == 'save2copy') + // Alter the name for save as copy + if ($input->get('task') === 'save2copy') { $origTable = clone $this->getTable(); $origTable->load($input->getInt('id')); - if ($data['title'] == $origTable->title) + if ($data['name'] == $origTable->name) { - list($title, $alias) = $this->_generateNewTitle($data['alias'], $data['title']); - $data['title'] = $title; + list($name, $alias) = $this->_generateNewTitle($data['alias'], $data['name']); + $data['name'] = $name; $data['alias'] = $alias; } else @@ -842,21 +1000,21 @@ class DemoModelHelp_document extends JModelAdmin { if (JFactory::getConfig()->get('unicodeslugs') == 1) { - $data['alias'] = JFilterOutput::stringURLUnicodeSlug($data['title']); + $data['alias'] = JFilterOutput::stringURLUnicodeSlug($data['name']); } else { - $data['alias'] = JFilterOutput::stringURLSafe($data['title']); + $data['alias'] = JFilterOutput::stringURLSafe($data['name']); } - $table = JTable::getInstance('help_document', 'demoTable'); + $table = JTable::getInstance('look', 'demoTable'); if ($table->load(array('alias' => $data['alias'])) && ($table->id != $data['id'] || $data['id'] == 0)) { - $msg = JText::_('COM_DEMO_HELP_DOCUMENT_SAVE_WARNING'); + $msg = JText::_('COM_DEMO_LOOK_SAVE_WARNING'); } - list($title, $alias) = $this->_generateNewTitle($data['alias'], $data['title']); + list($name, $alias) = $this->_generateNewTitle($data['alias'], $data['name']); $data['alias'] = $alias; if (isset($msg)) @@ -867,7 +1025,7 @@ class DemoModelHelp_document extends JModelAdmin } // Alter the uniqe field for save as copy - if ($input->get('task') == 'save2copy') + if ($input->get('task') === 'save2copy') { // Automatic handling of other uniqe fields $uniqeFields = $this->getUniqeFields(); diff --git a/site/models/looking.php b/site/models/looking.php new file mode 100644 index 0000000..d0d81af --- /dev/null +++ b/site/models/looking.php @@ -0,0 +1,185 @@ + + @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'); + +// import Joomla modelitem library +jimport('joomla.application.component.modelitem'); + +/** + * Demo Looking Model + */ +class DemoModelLooking extends JModelItem +{ + /** + * Model context string. + * + * @var string + */ + protected $_context = 'com_demo.looking'; + + /** + * 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('looking.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.looking.access', 'com_demo')) + { + $app = JFactory::getApplication(); + $app->enqueueMessage(JText::_('COM_DEMO_NOT_AUTHORISED_TO_VIEW_LOOKING'), 'error'); + // redirect away to the default view if no access allowed. + $app->redirect(JRoute::_('index.php?option=com_demo&view=looks')); + 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('looking.id'); + + if ($this->_item === null) + { + $this->_item = array(); + } + + if (!isset($this->_item[$pk])) + { + try + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Get from #__demo_look as a + $query->select($db->quoteName( + array('a.id','a.name','a.alias','a.description','a.add','a.email','a.mobile_phone','a.dateofbirth','a.image','a.website','a.published','a.hits'), + array('id','name','alias','description','add','email','mobile_phone','dateofbirth','image','website','published','hits'))); + $query->from($db->quoteName('#__demo_look', 'a')); + $query->where('a.id = ' . (int) $pk); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + // Load the results as a stdClass object. + $data = $db->loadObject(); + + if (empty($data)) + { + $app = JFactory::getApplication(); + // If no data is found redirect to default page and show warning. + $app->enqueueMessage(JText::_('COM_DEMO_NOT_FOUND_OR_ACCESS_DENIED'), 'warning'); + $app->redirect(JRoute::_('index.php?option=com_demo&view=looks')); + return false; + } + // Make sure the content prepare plugins fire on description. + $data->description = JHtml::_('content.prepare',$data->description); + // Checking if description has uikit components that must be loaded. + $this->uikitComp = DemoHelper::getUikitComp($data->description,$this->uikitComp); + + // 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::raiseWaring(404, $e->getMessage()); + } + else + { + $this->setError($e); + $this->_item[$pk] = false; + } + } + } + + return $this->_item[$pk]; + } + + + /** + * Get the uikit needed components + * + * @return mixed An array of objects on success. + * + */ + public function getUikitComp() + { + if (isset($this->uikitComp) && DemoHelper::checkArray($this->uikitComp)) + { + return $this->uikitComp; + } + return false; + } +} diff --git a/site/models/looks.php b/site/models/looks.php new file mode 100644 index 0000000..c4ecda4 --- /dev/null +++ b/site/models/looks.php @@ -0,0 +1,159 @@ + + @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'); + +// import the Joomla modellist library +jimport('joomla.application.component.modellist'); + +/** + * Demo Model for Looks + */ +class DemoModelLooks 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; + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Get from #__demo_look as a + $query->select($db->quoteName( + array('a.id','a.name','a.alias','a.description','a.add','a.email','a.mobile_phone','a.dateofbirth','a.image','a.website','a.not_required','a.published','a.hits','a.ordering'), + array('id','name','alias','description','add','email','mobile_phone','dateofbirth','image','website','not_required','published','hits','ordering'))); + $query->from($db->quoteName('#__demo_look', 'a')); + $query->where('a.published = 1'); + $query->order('a.name ASC'); + + // 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() + { + $user = JFactory::getUser(); + // check if this user has permission to access item + if (!$user->authorise('site.looks.access', 'com_demo')) + { + $app = JFactory::getApplication(); + $app->enqueueMessage(JText::_('COM_DEMO_NOT_AUTHORISED_TO_VIEW_LOOKS'), 'error'); + // 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 + $globalParams = JComponentHelper::getParams('com_demo', true); + + // Convert the parameter fields into objects. + if (DemoHelper::checkArray($items)) + { + foreach ($items as $nr => &$item) + { + // Always create a slug for sef URL's + $item->slug = (isset($item->alias) && isset($item->id)) ? $item->id.':'.$item->alias : $item->id; + // Make sure the content prepare plugins fire on description. + $item->description = JHtml::_('content.prepare',$item->description); + // Checking if description has uikit components that must be loaded. + $this->uikitComp = DemoHelper::getUikitComp($item->description,$this->uikitComp); + } + } + + + // do a quick build of all edit links links + if (isset($items) && $items) + { + foreach ($items as $nr => &$item) + { + $canDo = DemoHelper::getActions('look',$item,'looks'); + if ($canDo->get('look.edit')) + { + $item->editLink = '

'; + $item->editLink .= JText::_('COM_DEMO_EDIT_LOOK'); + $item->editLink .= ''; + } + else + { + $item->editLink = ''; + } + } + } + + // return items + return $items; + } + + + /** + * Get the uikit needed components + * + * @return mixed An array of objects on success. + * + */ + public function getUikitComp() + { + if (isset($this->uikitComp) && DemoHelper::checkArray($this->uikitComp)) + { + return $this->uikitComp; + } + return false; + } +} diff --git a/site/router.php b/site/router.php index eeccac5..1143218 100644 --- a/site/router.php +++ b/site/router.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage router.php @author Llewellyn van der Merwe @@ -77,11 +77,11 @@ class DemoRouter extends JComponentRouterBase return $segments; } - if (isset($view) && isset($query['id']) && 0) + if (isset($view) && isset($query['id']) && ($view === 'look' || $view === 'looks' || $view === 'looking')) { if ($mId != (int) $query['id'] || $mView != $view) { - if (0) + if (($view === 'look' || $view === 'looks' || $view === 'looking')) { $segments[] = $view; $id = explode(':', $query['id']); @@ -119,29 +119,60 @@ class DemoRouter extends JComponentRouterBase * @since 3.3 */ public function parse(&$segments) - { - //var_dump($segments); - //$app = JFactory::getApplication(); - //$menu = $app->getMenu(); - //$item = $menu->getActive(); - + { $count = count($segments); $vars = array(); - - //var_dump($item->query['view']); + //Handle View and Identifier switch($segments[0]) - { + { + case 'look': + $vars['view'] = 'look'; + if (is_numeric($segments[$count-1])) + { + $vars['id'] = (int) $segments[$count-1]; + } + break; + case 'looks': + $vars['view'] = 'looks'; + if (is_numeric($segments[$count-1])) + { + $vars['id'] = (int) $segments[$count-1]; + } + elseif ($segments[$count-1]) + { + $id = $this->getVar('look', $segments[$count-1], 'alias', 'id'); + if($id) + { + $vars['id'] = $id; + } + } + break; + case 'looking': + $vars['view'] = 'looking'; + if (is_numeric($segments[$count-1])) + { + $vars['id'] = (int) $segments[$count-1]; + } + elseif ($segments[$count-1]) + { + $id = $this->getVar('look', $segments[$count-1], 'alias', 'id'); + if($id) + { + $vars['id'] = $id; + } + } + break; } return $vars; } - protected function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'demo') + protected function getVar($table, $where = null, $whereString = null, $what = null, $category = false, $operator = '=', $main = 'demo') { - if(!$where) + if(!$where || !$what || !$whereString) { - $where = JFactory::getUser()->id; + return false; } // Get a db connection. $db = JFactory::getDbo(); @@ -149,21 +180,44 @@ class DemoRouter extends JComponentRouterBase $query = $db->getQuery(true); $query->select($db->quoteName(array($what))); - if ('categories' == $table || 'category' == $table) + if ('categories' == $table || 'category' == $table || $category) { - $query->from($db->quoteName('#__categories')); + $getTable = '#__categories'; + $query->from($db->quoteName($getTable)); } else { - $query->from($db->quoteName('#__'.$main.'_'.$table)); + // 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)) { - $query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where); + return false; } - elseif (is_string($where)) + elseif ($this->checkString($where)) { - $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$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 { @@ -177,6 +231,15 @@ class DemoRouter extends JComponentRouterBase } return false; } + + protected function checkString($string) + { + if (isset($string) && is_string($string) && strlen($string) > 0) + { + return true; + } + return false; + } } function DemoBuildRoute(&$query) diff --git a/admin/views/help_document/submitbutton.js b/site/views/look/submitbutton.js similarity index 86% rename from admin/views/help_document/submitbutton.js rename to site/views/look/submitbutton.js index abfbc98..3215921 100644 --- a/admin/views/help_document/submitbutton.js +++ b/site/views/look/submitbutton.js @@ -2,9 +2,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage submitbutton.js @author Llewellyn van der Merwe @@ -37,7 +37,7 @@ Joomla.submitbutton = function(task) Joomla.submitform(task); return true; } else { - alert(Joomla.JText._('help_document, some values are not acceptable.','Some values are unacceptable')); + alert(Joomla.JText._('look, some values are not acceptable.','Some values are unacceptable')); return false; } } diff --git a/site/views/look/tmpl/edit.php b/site/views/look/tmpl/edit.php new file mode 100644 index 0000000..b48e3d6 --- /dev/null +++ b/site/views/look/tmpl/edit.php @@ -0,0 +1,122 @@ + + @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::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +JHtml::_('behavior.tabstate'); +JHtml::_('behavior.calendar'); +$componentParams = JComponentHelper::getParams('com_demo'); +?> +toolbar->render(); ?> +
+ +
+ + 'details')); ?> + + +
+
+
+
+ +
+
+ + + +
+
+ +
+
+ +
+
+ + + canDo->get('look.delete') || $this->canDo->get('look.edit.created_by') || $this->canDo->get('look.edit.state') || $this->canDo->get('look.edit.created')) : ?> + +
+
+ +
+
+ +
+
+ + + + canDo->get('core.admin')) : ?> + +
+
+
+
+ form->getFieldset('accesscontrol') as $field): ?> +
+ label; echo $field->input;?> +
+
+ +
+
+
+
+ + + + + +
+ + +
+
+ +
+ +
+ + diff --git a/site/views/look/tmpl/index.html b/site/views/look/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/look/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/help_document/view.html.php b/site/views/look/view.html.php similarity index 62% rename from admin/views/help_document/view.html.php rename to site/views/look/view.html.php index 88e3969..5913b36 100644 --- a/admin/views/help_document/view.html.php +++ b/site/views/look/view.html.php @@ -3,9 +3,9 @@ Vast Development Method /-------------------------------------------------------------------------------------------------------/ - @version 1.0.5 - @build 13th July, 2016 - @created 5th August, 2015 + @version 2.0.0 + @build 8th April, 2017 + @created 18th October, 2016 @package Demo @subpackage view.html.php @author Llewellyn van der Merwe @@ -25,9 +25,9 @@ defined('_JEXEC') or die('Restricted access'); jimport('joomla.application.component.view'); /** - * Help_document View class + * Look View class */ -class DemoViewHelp_document extends JViewLegacy +class DemoViewLook extends JViewLegacy { /** * display method of View @@ -48,7 +48,7 @@ class DemoViewHelp_document extends JViewLegacy $this->script = $this->get('Script'); $this->state = $this->get('State'); // get action permissions - $this->canDo = DemoHelper::getActions('help_document',$this->item); + $this->canDo = DemoHelper::getActions('look',$this->item); // get input $jinput = JFactory::getApplication()->input; $this->ref = $jinput->get('ref', 0, 'word'); @@ -81,34 +81,36 @@ class DemoViewHelp_document extends JViewLegacy */ protected function addToolBar() { + // adding the joomla edit toolbar to the front + JLoader::register('JToolbarHelper', JPATH_ADMINISTRATOR.'/includes/toolbar.php'); JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $userId = $user->id; $isNew = $this->item->id == 0; - JToolbarHelper::title( JText::_($isNew ? 'COM_DEMO_HELP_DOCUMENT_NEW' : 'COM_DEMO_HELP_DOCUMENT_EDIT'), 'pencil-2 article-add'); + JToolbarHelper::title( JText::_($isNew ? 'COM_DEMO_LOOK_NEW' : 'COM_DEMO_LOOK_EDIT'), 'pencil-2 article-add'); // Built the actions for new and existing records. if ($this->refid || $this->ref) { - if ($this->canDo->get('help_document.create') && $isNew) + if ($this->canDo->get('look.create') && $isNew) { // We can create the record. - JToolBarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); + JToolBarHelper::save('look.save', 'JTOOLBAR_SAVE'); } - elseif ($this->canDo->get('help_document.edit')) + elseif ($this->canDo->get('look.edit')) { // We can save the record. - JToolBarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); + JToolBarHelper::save('look.save', 'JTOOLBAR_SAVE'); } if ($isNew) { // Do not creat but cancel. - JToolBarHelper::cancel('help_document.cancel', 'JTOOLBAR_CANCEL'); + JToolBarHelper::cancel('look.cancel', 'JTOOLBAR_CANCEL'); } else { // We can close it. - JToolBarHelper::cancel('help_document.cancel', 'JTOOLBAR_CLOSE'); + JToolBarHelper::cancel('look.cancel', 'JTOOLBAR_CLOSE'); } } else @@ -116,47 +118,49 @@ class DemoViewHelp_document extends JViewLegacy if ($isNew) { // For new records, check the create permission. - if ($this->canDo->get('help_document.create')) + if ($this->canDo->get('look.create')) { - JToolBarHelper::apply('help_document.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('help_document.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + JToolBarHelper::apply('look.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('look.save', 'JTOOLBAR_SAVE'); + JToolBarHelper::custom('look.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); }; - JToolBarHelper::cancel('help_document.cancel', 'JTOOLBAR_CANCEL'); + JToolBarHelper::cancel('look.cancel', 'JTOOLBAR_CANCEL'); } else { - if ($this->canDo->get('help_document.edit')) + if ($this->canDo->get('look.edit')) { // We can save the new record - JToolBarHelper::apply('help_document.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); + JToolBarHelper::apply('look.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('look.save', 'JTOOLBAR_SAVE'); // We can save this record, but check the create permission to see // if we can return to make a new one. - if ($this->canDo->get('help_document.create')) + if ($this->canDo->get('look.create')) { - JToolBarHelper::custom('help_document.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + JToolBarHelper::custom('look.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); } } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('help_document.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('help_document.edit') && $canVersion) + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('look.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('look.edit') && $canVersion) { - JToolbarHelper::versions('com_demo.help_document', $this->item->id); + JToolbarHelper::versions('com_demo.look', $this->item->id); } - if ($this->canDo->get('help_document.create')) + if ($this->canDo->get('look.create')) { - JToolBarHelper::custom('help_document.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + JToolBarHelper::custom('look.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); } - JToolBarHelper::cancel('help_document.cancel', 'JTOOLBAR_CLOSE'); + JToolBarHelper::cancel('look.cancel', 'JTOOLBAR_CLOSE'); } } JToolbarHelper::divider(); // set help url for this view if found - $help_url = DemoHelper::getHelpUrl('help_document'); + $help_url = DemoHelper::getHelpUrl('look'); if (DemoHelper::checkString($help_url)) { JToolbarHelper::help('COM_DEMO_HELP_MANAGER', false, $help_url); } + // now initiate the toolbar + $this->toolbar = JToolbar::getInstance(); } /** @@ -186,10 +190,15 @@ class DemoViewHelp_document extends JViewLegacy { $isNew = ($this->item->id < 1); $document = JFactory::getDocument(); - $document->setTitle(JText::_($isNew ? 'COM_DEMO_HELP_DOCUMENT_NEW' : 'COM_DEMO_HELP_DOCUMENT_EDIT')); - $document->addStyleSheet(JURI::root() . "administrator/components/com_demo/assets/css/help_document.css"); - $document->addScript(JURI::root() . $this->script); - $document->addScript(JURI::root() . "administrator/components/com_demo/views/help_document/submitbutton.js"); + $document->setTitle(JText::_($isNew ? 'COM_DEMO_LOOK_NEW' : 'COM_DEMO_LOOK_EDIT')); + // we need this to fix the form display + $document->addStyleSheet(JURI::root()."administrator/templates/isis/css/template.css"); + $document->addScript(JURI::root()."administrator/templates/isis/js/template.js"); + // the default style of this view + $document->addStyleSheet(JURI::root()."components/com_demo/assets/css/look.css"); + // default javascript of this view + $document->addScript(JURI::root().$this->script); + $document->addScript(JURI::root(). "components/com_demo/views/look/submitbutton.js"); JText::script('view not acceptable. Error'); } } diff --git a/site/views/looking/index.html b/site/views/looking/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/looking/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/views/looking/tmpl/default.php b/site/views/looking/tmpl/default.php new file mode 100644 index 0000000..0fc8287 --- /dev/null +++ b/site/views/looking/tmpl/default.php @@ -0,0 +1,62 @@ + + @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(); ?>
+
+
+ +

escape($this->item->name); ?>

+
: item->hits; ?>
+
+
+ item->description; ?> + item->add): ?> +
+ + + +
+
+item->add): ?> + +
+
+ +
+ item->dateofbirth)): ?> +
escape($this->item->dateofbirth)); ?>
+ + item->email)): ?> +
escape($this->item->email); ?>
+ + item->mobile_phone)): ?> +
escape($this->item->mobile_phone); ?>
+ + item->website)): ?> +
escape($this->item->website); ?>
+ +
+
+
+ diff --git a/site/views/looking/tmpl/index.html b/site/views/looking/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/looking/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/views/looking/view.html.php b/site/views/looking/view.html.php new file mode 100644 index 0000000..ce622a5 --- /dev/null +++ b/site/views/looking/view.html.php @@ -0,0 +1,232 @@ + + @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'); + +// import Joomla view library +jimport('joomla.application.component.view'); + +/** + * Demo View class for the Looking + */ +class DemoViewLooking 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'); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + JError::raiseError(500, implode(PHP_EOL, $errors)); + return false; + } + // add a hit to the look + if ($this->hit($this->item->id)) + { + $this->item->hits++; + } + + // Set the toolbar + $this->addToolBar(); + + // set the document + $this->_prepareDocument(); + + parent::display($tpl); + } + + /** + * Increment the hit counter for the preacher. + * + * @param integer $pk Primary key of the preacher to increment. + * + * @return boolean True if successful; + */ + public function hit($pk = 0) + { + if ($pk) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('hits') . ' = '.$db->quoteName('hits').' + 1' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('id') . ' = ' . $pk + ); + + $query->update($db->quoteName('#__demo_look'))->set($fields)->where($conditions); + + $db->setQuery($query); + return $db->execute(); + } + return false; + } + + /** + * Prepares the document + */ + protected function _prepareDocument() + { + + // always make sure jquery is loaded. + JHtml::_('jquery.framework'); + // Load the header checker class. + require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' ); + // Initialize the header checker. + $HeaderCheck = new HeaderCheck; + + // Load uikit options. + $uikit = $this->params->get('uikit_load'); + // Set script size. + $size = $this->params->get('uikit_min'); + // Set css style. + $style = $this->params->get('uikit_style'); + + // The uikit css. + if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + $this->document->addStyleSheet(JURI::root(true) .'/media/com_demo/uikit/css/uikit'.$style.$size.'.css'); + } + // The uikit js. + if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + $this->document->addScript(JURI::root(true) .'/media/com_demo/uikit/js/uikit'.$size.'.js'); + } + + // Load the needed uikit components in this view. + $uikitComp = $this->get('UikitComp'); + if ($uikit != 2 && isset($uikitComp) && DemoHelper::checkArray($uikitComp)) + { + // load just in case. + jimport('joomla.filesystem.file'); + // loading... + foreach ($uikitComp as $class) + { + foreach (DemoHelper::$uk_components[$class] as $name) + { + // check if the CSS file exists. + if (JFile::exists(JPATH_ROOT.'/media/com_demo/uikit/css/components/'.$name.$style.$size.'.css')) + { + // load the css. + $this->document->addStyleSheet(JURI::root(true) .'/media/com_demo/uikit/css/components/'.$name.$style.$size.'.css'); + } + // check if the JavaScript file exists. + if (JFile::exists(JPATH_ROOT.'/media/com_demo/uikit/js/components/'.$name.$size.'.js')) + { + // load the js. + $this->document->addScript(JURI::root(true) .'/media/com_demo/uikit/js/components/'.$name.$size.'.js', 'text/javascript', true); + } + } + } + } + // load the meta description + if (isset($this->item->metadesc) && $this->item->metadesc) + { + $this->document->setDescription($this->item->metadesc); + } + elseif ($this->params->get('menu-meta_description')) + { + $this->document->setDescription($this->params->get('menu-meta_description')); + } + // load the key words if set + if (isset($this->item->metakey) && $this->item->metakey) + { + $this->document->setMetadata('keywords', $this->item->metakey); + } + elseif ($this->params->get('menu-meta_keywords')) + { + $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); + } + // check the robot params + if (isset($this->item->robots) && $this->item->robots) + { + $this->document->setMetadata('robots', $this->item->robots); + } + elseif ($this->params->get('robots')) + { + $this->document->setMetadata('robots', $this->params->get('robots')); + } + // check if autor is to be set + if (isset($this->item->created_by) && $this->params->get('MetaAuthor') == '1') + { + $this->document->setMetaData('author', $this->item->created_by); + } + // check if metadata is available + if (isset($this->item->metadata) && $this->item->metadata) + { + $mdata = json_decode($this->item->metadata,true); + foreach ($mdata as $k => $v) + { + if ($v) + { + $this->document->setMetadata($k, $v); + } + } + } + // add the document default css file + $this->document->addStyleSheet(JURI::root(true) .'/components/com_demo/assets/css/looking.css'); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + // adding the joomla toolbar to the front + JLoader::register('JToolbarHelper', JPATH_ADMINISTRATOR.'/includes/toolbar.php'); + + // set help url for this view if found + $help_url = DemoHelper::getHelpUrl('looking'); + if (DemoHelper::checkString($help_url)) + { + JToolbarHelper::help('COM_DEMO_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 DemoHelper::htmlEscape($var, $this->_charset, $sorten, $length); + } +} diff --git a/site/views/looks/index.html b/site/views/looks/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/looks/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/views/looks/tmpl/default.php b/site/views/looks/tmpl/default.php new file mode 100644 index 0000000..a248971 --- /dev/null +++ b/site/views/looks/tmpl/default.php @@ -0,0 +1,52 @@ + + @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'); + +?> + + + + + + + + + + items as $item): ?> + + + + + + +
name; ?>escape($item->description, true, 120); ?>editLink; ?>
+ +items) && demoHelper::checkArray($this->items) && count($this->items) > 4): ?> +
+ +
+ diff --git a/site/views/looks/tmpl/default.xml b/site/views/looks/tmpl/default.xml new file mode 100644 index 0000000..4f13ea6 --- /dev/null +++ b/site/views/looks/tmpl/default.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/site/views/looks/tmpl/index.html b/site/views/looks/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/looks/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/views/looks/view.html.php b/site/views/looks/view.html.php new file mode 100644 index 0000000..5a07a98 --- /dev/null +++ b/site/views/looks/view.html.php @@ -0,0 +1,167 @@ + + @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'); + +// import Joomla view library +jimport('joomla.application.component.view'); + +/** + * Demo View class for the Looks + */ +class DemoViewLooks 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'); + $this->pagination = $this->get('Pagination'); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + JError::raiseError(500, implode(PHP_EOL, $errors)); + return false; + } + + // Set the toolbar + $this->addToolBar(); + + // set the document + $this->_prepareDocument(); + + parent::display($tpl); + } + + /** + * Prepares the document + */ + protected function _prepareDocument() + { + + // always make sure jquery is loaded. + JHtml::_('jquery.framework'); + // Load the header checker class. + require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' ); + // Initialize the header checker. + $HeaderCheck = new HeaderCheck; + + // Load uikit options. + $uikit = $this->params->get('uikit_load'); + // Set script size. + $size = $this->params->get('uikit_min'); + // Set css style. + $style = $this->params->get('uikit_style'); + + // The uikit css. + if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + $this->document->addStyleSheet(JURI::root(true) .'/media/com_demo/uikit/css/uikit'.$style.$size.'.css'); + } + // The uikit js. + if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + $this->document->addScript(JURI::root(true) .'/media/com_demo/uikit/js/uikit'.$size.'.js'); + } + + // Load the needed uikit components in this view. + $uikitComp = $this->get('UikitComp'); + if ($uikit != 2 && isset($uikitComp) && DemoHelper::checkArray($uikitComp)) + { + // load just in case. + jimport('joomla.filesystem.file'); + // loading... + foreach ($uikitComp as $class) + { + foreach (DemoHelper::$uk_components[$class] as $name) + { + // check if the CSS file exists. + if (JFile::exists(JPATH_ROOT.'/media/com_demo/uikit/css/components/'.$name.$style.$size.'.css')) + { + // load the css. + $this->document->addStyleSheet(JURI::root(true) .'/media/com_demo/uikit/css/components/'.$name.$style.$size.'.css'); + } + // check if the JavaScript file exists. + if (JFile::exists(JPATH_ROOT.'/media/com_demo/uikit/js/components/'.$name.$size.'.js')) + { + // load the js. + $this->document->addScript(JURI::root(true) .'/media/com_demo/uikit/js/components/'.$name.$size.'.js', 'text/javascript', true); + } + } + } + } + // load the meta description + if ($this->params->get('menu-meta_description')) + { + $this->document->setDescription($this->params->get('menu-meta_description')); + } + // load the key words if set + if ($this->params->get('menu-meta_keywords')) + { + $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); + } + // check the robot params + 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_demo/assets/css/looks.css'); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + // adding the joomla toolbar to the front + JLoader::register('JToolbarHelper', JPATH_ADMINISTRATOR.'/includes/toolbar.php'); + + // set help url for this view if found + $help_url = DemoHelper::getHelpUrl('looks'); + if (DemoHelper::checkString($help_url)) + { + JToolbarHelper::help('COM_DEMO_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 DemoHelper::htmlEscape($var, $this->_charset, $sorten, $length); + } +}