Update with all the latest changes to JCB. Fixed the permissions issue by adding the created_by to the query. vdm-io/Joomla-Component-Builder#335

This commit is contained in:
Llewellyn van der Merwe 2018-09-13 04:21:17 +02:00
parent 508dd34a81
commit 1f8a137949
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
85 changed files with 935 additions and 636 deletions

View File

@ -10,20 +10,20 @@ Just a basic demo of the most basic implementations of the [Joomla](http://www.j
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Demo](https://www.vdm.io/)
+ *First Build*: 18th October, 2016
+ *Last Build*: 5th May, 2018
+ *Last Build*: 13th September, 2018
+ *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
**41 Hours** or **5 Eight Hour Days** (actual time the author saved -
**42 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*: **14621**
+ *Line count*: **14920**
+ *File count*: **147**
+ *Folder count*: **54**
@ -35,7 +35,7 @@ due to [Automated Component Builder](https://www.vdm.io/joomla-component-builder
> **mapping @4hours** = codingtime / 10;
> **office @7hours** = codingtime / 6;)
**68 Hours** or **9 Eight Hour Days**
**69 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**,

View File

@ -10,20 +10,20 @@ Just a basic demo of the most basic implementations of the [Joomla](http://www.j
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Demo](https://www.vdm.io/)
+ *First Build*: 18th October, 2016
+ *Last Build*: 5th May, 2018
+ *Last Build*: 13th September, 2018
+ *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
**41 Hours** or **5 Eight Hour Days** (actual time the author saved -
**42 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*: **14621**
+ *Line count*: **14920**
+ *File count*: **147**
+ *Folder count*: **54**
@ -35,7 +35,7 @@ due to [Automated Component Builder](https://www.vdm.io/joomla-component-builder
> **mapping @4hours** = codingtime / 10;
> **office @7hours** = codingtime / 6;)
**68 Hours** or **9 Eight Hour Days**
**69 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**,

View File

@ -13,6 +13,7 @@
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_ACCESS_EDITSTATE_DESC" />
<action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC" />
<action name="core.edit.value" title="JACTION_EDITVALUE" description="JACTION_EDITVALUE_COMPONENT_DESC" />
<action name="core.edit.created_by" title="COM_DEMO_EDIT_CREATED_BY" description="COM_DEMO_EDIT_CREATED_BY_DESC" />
<action name="core.edit.created" title="COM_DEMO_EDIT_CREATED_DATE" description="COM_DEMO_EDIT_CREATED_DATE_DESC" />
<action name="site.looking.access" title="COM_DEMO_LOOKING_ACCESS_SITE" description="COM_DEMO_LOOKING_ACCESS_SITE_DESC" />
@ -44,4 +45,18 @@
<action name="look.access" title="COM_DEMO_LOOKS_ACCESS" description="COM_DEMO_LOOKS_ACCESS_DESC" />
<action name="look.version" title="COM_DEMO_LOOKS_EDIT_VERSION" description="COM_DEMO_LOOKS_EDIT_VERSION_DESC" />
</section>
<section name="fieldgroup">
<action name="core.create" title="JACTION_CREATE" description="COM_FIELDS_GROUP_PERMISSION_CREATE_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="COM_FIELDS_GROUP_PERMISSION_DELETE_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="COM_FIELDS_GROUP_PERMISSION_EDIT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_FIELDS_GROUP_PERMISSION_EDITSTATE_DESC" />
<action name="core.edit.own" title="JACTION_EDITOWN" description="COM_FIELDS_GROUP_PERMISSION_EDITOWN_DESC" />
<action name="core.edit.value" title="JACTION_EDITVALUE" description="COM_FIELDS_GROUP_PERMISSION_EDITVALUE_DESC" />
</section>
<section name="field">
<action name="core.delete" title="JACTION_DELETE" description="COM_FIELDS_FIELD_PERMISSION_DELETE_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="COM_FIELDS_FIELD_PERMISSION_EDIT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_FIELDS_FIELD_PERMISSION_EDITSTATE_DESC" />
<action name="core.edit.value" title="JACTION_EDITVALUE" description="COM_FIELDS_FIELD_PERMISSION_EDITVALUE_DESC" />
</section>
</access>

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage admin.css

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage dashboard.css

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage look.css

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage looks.css

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage admin.js

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage controller.php
@ -21,9 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controller library
jimport('joomla.application.component.controller');
/**
* General Controller of Demo component
*/

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage demo.php
@ -21,9 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controlleradmin library
jimport('joomla.application.component.controlleradmin');
/**
* Demo Controller
*/

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage import.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage look.php
@ -21,9 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controllerform library
jimport('joomla.application.component.controllerform');
/**
* Look Controller
*/
@ -38,6 +35,13 @@ class DemoControllerLook extends JControllerForm
*/
protected $task;
/**
* Class constructor.
*
* @param array $config A named array of configuration variables.
*
* @since 1.6
*/
public function __construct($config = array())
{
$this->view_list = 'Looks'; // safeguard for setting the return view listing to the main view.
@ -55,14 +59,17 @@ class DemoControllerLook extends JControllerForm
*/
protected function allowAdd($data = array())
{
// Get user object.
$user = JFactory::getUser();
// Access check.
$access = JFactory::getUser()->authorise('look.access', 'com_demo');
$access = $user->authorise('look.access', 'com_demo');
if (!$access)
{
return false;
}
// In the absense of better information, revert to the component permissions.
return JFactory::getUser()->authorise('look.create', $this->option);
return $user->authorise('look.create', $this->option);
}
/**
@ -136,42 +143,25 @@ class DemoControllerLook extends JControllerForm
*
* @return string The arguments to append to the redirect URL.
*
* @since 12.2
* @since 1.6
*/
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
{
$tmpl = $this->input->get('tmpl');
$layout = $this->input->get('layout', 'edit', 'string');
// get the referral options (old method use return instead see parent)
$ref = $this->input->get('ref', 0, 'string');
$refid = $this->input->get('refid', 0, 'int');
// Setup redirect info.
// get redirect info.
$append = parent::getRedirectToItemAppend($recordId, $urlVar);
$append = '';
if ($refid)
// set the referral options
if ($refid && $ref)
{
$append .= '&ref='.(string)$ref.'&refid='.(int)$refid;
$append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append;
}
elseif ($ref)
{
$append .= '&ref='.(string)$ref;
}
if ($tmpl)
{
$append .= '&tmpl=' . $tmpl;
}
if ($layout)
{
$append .= '&layout=' . $layout;
}
if ($recordId)
{
$append .= '&' . $urlVar . '=' . $recordId;
$append = '&ref='. (string)$ref . $append;
}
return $append;
@ -210,17 +200,29 @@ class DemoControllerLook extends JControllerForm
*/
public function cancel($key = null)
{
// get the referal details
// get the referral options
$this->ref = $this->input->get('ref', 0, 'word');
$this->refid = $this->input->get('refid', 0, 'int');
// Check if there is a return value
$return = $this->input->get('return', null, 'base64');
$cancel = parent::cancel($key);
if ($cancel)
if (!is_null($return) && JUri::isInternal(base64_decode($return)))
{
if ($this->refid)
$redirect = base64_decode($return);
// Redirect to the return value.
$this->setRedirect(
JRoute::_(
$redirect, false
)
);
}
elseif ($this->refid && $this->ref)
{
$redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid;
$redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid;
// Redirect to the item screen.
$this->setRedirect(
@ -240,16 +242,6 @@ class DemoControllerLook extends JControllerForm
)
);
}
}
else
{
// Redirect to the items screen.
$this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option . '&view=' . $this->view_list, false
)
);
}
return $cancel;
}
@ -265,11 +257,15 @@ class DemoControllerLook extends JControllerForm
*/
public function save($key = null, $urlVar = null)
{
// get the referal details
// get the referral options
$this->ref = $this->input->get('ref', 0, 'word');
$this->refid = $this->input->get('refid', 0, 'int');
if ($this->ref || $this->refid)
// Check if there is a return value
$return = $this->input->get('return', null, 'base64');
$canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return)));
if ($this->ref || $this->refid || $canReturn)
{
// to make sure the item is checkedin on redirect
$this->task = 'save';
@ -277,9 +273,22 @@ class DemoControllerLook extends JControllerForm
$saved = parent::save($key, $urlVar);
if ($this->refid && $saved)
// This is not needed since parent save already does this
// Due to the ref and refid implementation we need to add this
if ($canReturn)
{
$redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid;
$redirect = base64_decode($return);
// Redirect to the return value.
$this->setRedirect(
JRoute::_(
$redirect, false
)
);
}
elseif ($this->refid && $this->ref)
{
$redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid;
// Redirect to the item screen.
$this->setRedirect(
@ -288,9 +297,9 @@ class DemoControllerLook extends JControllerForm
)
);
}
elseif ($this->ref && $saved)
elseif ($this->ref)
{
$redirect = '&view='.(string)$this->ref;
$redirect = '&view=' . (string)$this->ref;
// Redirect to the list screen.
$this->setRedirect(

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage looks.php
@ -21,24 +21,33 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controlleradmin library
jimport('joomla.application.component.controlleradmin');
/**
* Looks Controller
*/
class DemoControllerLooks extends JControllerAdmin
{
protected $text_prefix = 'COM_DEMO_LOOKS';
/**
* Proxy for getModel.
* @since 2.5
* The prefix to use with controller messages.
*
* @var string
* @since 1.6
*/
public function getModel($name = 'Look', $prefix = 'DemoModel', $config = array())
{
$model = parent::getModel($name, $prefix, array('ignore_request' => true));
protected $text_prefix = 'COM_DEMO_LOOKS';
return $model;
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JModelLegacy The model.
*
* @since 1.6
*/
public function getModel($name = 'Look', $prefix = 'DemoModel', $config = array('ignore_request' => true))
{
return parent::getModel($name, $prefix, $config);
}
public function exportData()

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage demo.php
@ -20,29 +20,22 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tabstate');
// Access check.
if (!JFactory::getUser()->authorise('core.manage', 'com_demo'))
{
return JError::raiseWaring(404, JText::_('JERROR_ALERTNOAUTHOR'));
throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
};
// Load cms libraries
JLoader::registerPrefix('J', JPATH_PLATFORM . '/cms');
// Load joomla libraries without overwrite
JLoader::registerPrefix('J', JPATH_PLATFORM . '/joomla',false);
// Add CSS file for all pages
$document = JFactory::getDocument();
$document->addStyleSheet('components/com_demo/assets/css/admin.css');
$document->addScript('components/com_demo/assets/js/admin.js');
// require helper files
JLoader::register('DemoHelper', dirname(__FILE__) . '/helpers/demo.php');
JLoader::register('JHtmlBatch_', dirname(__FILE__) . '/helpers/html/batch_.php');
// import joomla controller library
jimport('joomla.application.component.controller');
JLoader::register('DemoHelper', __DIR__ . '/helpers/demo.php');
JLoader::register('JHtmlBatch_', __DIR__ . '/helpers/html/batch_.php');
// Get an instance of the controller prefixed by Demo
$controller = JControllerLegacy::getInstance('Demo');

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage demo.php
@ -112,6 +112,11 @@ abstract class DemoHelper
{
JHtmlSidebar::addEntry(JText::_('COM_DEMO_SUBMENU_LOOKS'), 'index.php?option=com_demo&view=looks', $submenu === 'looks');
}
if (JComponentHelper::isEnabled('com_fields'))
{
JHtmlSidebar::addEntry(JText::_('COM_DEMO_SUBMENU_LOOKS_FIELDS'), 'index.php?option=com_fields&context=com_demo.look', $submenu === 'fields.fields');
JHtmlSidebar::addEntry(JText::_('COM_DEMO_SUBMENU_LOOKS_FIELDS_GROUPS'), 'index.php?option=com_fields&view=groups&context=com_demo.look', $submenu === 'fields.groups');
}
}
/**
@ -532,16 +537,16 @@ abstract class DemoHelper
{
if ($external)
{
if ($name = self::getVar(null, $val, $id, $name, '=', $table))
if ($_name = self::getVar(null, $val, $id, $name, '=', $table))
{
$names[] = $name;
$names[] = $_name;
}
}
else
{
if ($name = self::getVar($table, $val, $id, $name))
if ($_name = self::getVar($table, $val, $id, $name))
{
$names[] = $name;
$names[] = $_name;
}
}
}
@ -931,7 +936,7 @@ abstract class DemoHelper
}
}
// check if there are any view values remaining
if (count($_result))
if (count((array)$_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@ -1037,6 +1042,46 @@ abstract class DemoHelper
}
}
/**
* get the field object
*
* @param array $attributes The array of attributes
* @param string $default The default of the field
* @param array $options The options to apply to the XML element
*
* @return object
*
*/
public static function getFieldObject(&$attributes, $default = '', $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes) && isset($attributes['type']))
{
// make sure the form helper class is loaded
if (!method_exists('JFormHelper', 'loadFieldType'))
{
jimport('joomla.form.form');
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'],true);
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
self::xmlAddAttributes($XML, $attributes);
// check if we have options
if (self::checkArray($options))
{
// load the options
self::xmlAddOptions($XML, $options);
}
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* Render Bool Button
*
@ -1055,8 +1100,6 @@ abstract class DemoHelper
$args = func_get_args();
// check if there is additional button class
$additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time
// start the xml
$buttonXML = new SimpleXMLElement('<field/>');
// button attributes
$buttonAttributes = array(
'type' => 'radio',
@ -1065,22 +1108,12 @@ abstract class DemoHelper
'class' => 'btn-group',
'filter' => 'INT',
'default' => isset($args[2]) ? (int) $args[2] : 0);
// load the haskey attributes
self::xmlAddAttributes($buttonXML, $buttonAttributes);
// set the button options
$buttonOptions = array(
'1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES',
'0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO');
// load the button options
self::xmlAddOptions($buttonXML, $buttonOptions);
// get the radio element
$button = JFormHelper::loadFieldType('radio');
// run
$button->setup($buttonXML, $buttonAttributes['default']);
return $button->input;
// return the input
return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input;
}
/**
@ -1125,7 +1158,7 @@ abstract class DemoHelper
**/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && count($array) > 0)
if (isset($array) && is_array($array) && count((array)$array) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
@ -1228,7 +1261,7 @@ abstract class DemoHelper
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
$words_count = count($words);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
@ -1263,7 +1296,7 @@ abstract class DemoHelper
*
* @returns string on success
**/
public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true)
public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
@ -1292,7 +1325,16 @@ abstract class DemoHelper
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
$string = preg_replace('/\s+/', ' ', $string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
$string = preg_replace("/[^A-Za-z ]/", '', $string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '', $string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage headercheck.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage batch_.php

View File

@ -111,9 +111,9 @@ COM_DEMO_LOOKS_BATCH_USE_DESC="Allows users in this group to use batch copy/upda
COM_DEMO_LOOKS_CREATE="Looks Create"
COM_DEMO_LOOKS_CREATE_DESC="Allows the users in this group to create create looks"
COM_DEMO_LOOKS_DASHBOARD_ADD="Looks Dashboard Add"
COM_DEMO_LOOKS_DASHBOARD_ADD_DESC="Allows the users in this group to update the dashboard add of the look"
COM_DEMO_LOOKS_DASHBOARD_ADD_DESC="Allows the users in this group to dashboard add of look"
COM_DEMO_LOOKS_DASHBOARD_LIST="Looks Dashboard List"
COM_DEMO_LOOKS_DASHBOARD_LIST_DESC="Allows the users in this group to update the dashboard list of the look"
COM_DEMO_LOOKS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of look"
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"
@ -150,7 +150,7 @@ COM_DEMO_LOOKS_N_ITEMS_UNFEATURED_1="%s Look unfeatured."
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_LOOKS_SUBMENU_DESC="Allows the users in this group to submenu of look"
COM_DEMO_LOOK_ADD="Add"
COM_DEMO_LOOK_ADD_LABEL="Add More"
COM_DEMO_LOOK_ALIAS="Alias"
@ -217,6 +217,8 @@ 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_LOOKS="Looks"
COM_DEMO_SUBMENU_LOOKS_FIELDS="Looks Fields"
COM_DEMO_SUBMENU_LOOKS_FIELDS_GROUPS="Looks Field Groups"
COM_DEMO_TRASHED="Trashed"
COM_DEMO_USE_BATCH="Use Batch"
COM_DEMO_USE_BATCH_DESC=" Allows users in this group to use batch copy/update method."

View File

@ -21,9 +21,9 @@ COM_DEMO_LOOKS_BATCH_USE_DESC="Allows users in this group to use batch copy/upda
COM_DEMO_LOOKS_CREATE="Looks Create"
COM_DEMO_LOOKS_CREATE_DESC="Allows the users in this group to create create looks"
COM_DEMO_LOOKS_DASHBOARD_ADD="Looks Dashboard Add"
COM_DEMO_LOOKS_DASHBOARD_ADD_DESC="Allows the users in this group to update the dashboard add of the look"
COM_DEMO_LOOKS_DASHBOARD_ADD_DESC="Allows the users in this group to dashboard add of look"
COM_DEMO_LOOKS_DASHBOARD_LIST="Looks Dashboard List"
COM_DEMO_LOOKS_DASHBOARD_LIST_DESC="Allows the users in this group to update the dashboard list of the look"
COM_DEMO_LOOKS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of look"
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"
@ -43,7 +43,7 @@ COM_DEMO_LOOKS_EXPORT_DESC="Allows the users in this group to export export look
COM_DEMO_LOOKS_IMPORT="Looks Import"
COM_DEMO_LOOKS_IMPORT_DESC="Allows the users in this group to import import looks"
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_LOOKS_SUBMENU_DESC="Allows the users in this group to submenu of look"
COM_DEMO_MENU="&#187; Demo"
COM_DEMO_MENU_LOOKS="Looks"
COM_DEMO_MENU_LOOKS_DESC="The List of all published looks"

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage batchselection.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage details_above.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage details_fullwidth.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage details_under.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage metadata.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage more_left.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage more_right.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage publishing.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$app = JFactory::getApplication();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage demo.php
@ -21,10 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the Joomla modellist library
jimport('joomla.application.component.modellist');
jimport('joomla.application.component.helper');
/**
* Demo Model
*/

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage look.js
@ -20,6 +20,7 @@
// Some Global Values
jform_vvvvvvvvvv_required = false;
jform_vvvvvvvvvw_required = false;
jform_vvvvvvvvvx_required = false;
// Initial Script
jQuery(document).ready(function()
@ -35,50 +36,70 @@ function vvvvvvv(add_vvvvvvv)
if (add_vvvvvvv == 1)
{
jQuery('#jform_dateofbirth').closest('.control-group').show();
jQuery('#jform_email').closest('.control-group').show();
// add required attribute to dateofbirth field
if (jform_vvvvvvvvvv_required)
{
updateFieldRequired('dateofbirth',0);
jQuery('#jform_dateofbirth').prop('required','required');
jQuery('#jform_dateofbirth').attr('aria-required',true);
jQuery('#jform_dateofbirth').addClass('required');
jform_vvvvvvvvvv_required = false;
}
jQuery('#jform_email').closest('.control-group').show();
// add required attribute to email field
if (jform_vvvvvvvvvw_required)
{
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;
jform_vvvvvvvvvw_required = false;
}
jQuery('#jform_image').closest('.control-group').show();
jQuery('#jform_mobile_phone').closest('.control-group').show();
if (jform_vvvvvvvvvw_required)
// add required attribute to mobile_phone field
if (jform_vvvvvvvvvx_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;
jform_vvvvvvvvvx_required = false;
}
jQuery('#jform_website').closest('.control-group').show();
}
else
{
jQuery('#jform_dateofbirth').closest('.control-group').hide();
jQuery('#jform_email').closest('.control-group').hide();
// remove required attribute from dateofbirth field
if (!jform_vvvvvvvvvv_required)
{
updateFieldRequired('dateofbirth',1);
jQuery('#jform_dateofbirth').removeAttr('required');
jQuery('#jform_dateofbirth').removeAttr('aria-required');
jQuery('#jform_dateofbirth').removeClass('required');
jform_vvvvvvvvvv_required = true;
}
jQuery('#jform_email').closest('.control-group').hide();
// remove required attribute from email field
if (!jform_vvvvvvvvvw_required)
{
updateFieldRequired('email',1);
jQuery('#jform_email').removeAttr('required');
jQuery('#jform_email').removeAttr('aria-required');
jQuery('#jform_email').removeClass('required');
jform_vvvvvvvvvv_required = true;
jform_vvvvvvvvvw_required = true;
}
jQuery('#jform_image').closest('.control-group').hide();
jQuery('#jform_mobile_phone').closest('.control-group').hide();
if (!jform_vvvvvvvvvw_required)
// remove required attribute from mobile_phone field
if (!jform_vvvvvvvvvx_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;
jform_vvvvvvvvvx_required = true;
}
jQuery('#jform_website').closest('.control-group').hide();
}

View File

@ -142,6 +142,7 @@
class="text_area"
filter="url"
validated="url"
scheme="http,https"
message="COM_DEMO_LOOK_WEBSITE_MESSAGE"
hint="COM_DEMO_LOOK_WEBSITE_HINT"
/>
@ -160,6 +161,11 @@
default="1970-01-01"
description="COM_DEMO_LOOK_DATEOFBIRTH_DESCRIPTION"
format="%Y-%m-%d"
filter="STRING"
required="true"
todaybutton="false"
minyear="-120"
maxyear="-1"
/>
<!-- Mobile_phone Field. Type: Tel. (joomla) -->
<field

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage import.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage look.php
@ -23,9 +23,6 @@ defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
// import Joomla modelform library
jimport('joomla.application.component.modeladmin');
/**
* Demo Look Model
*/
@ -58,6 +55,9 @@ class DemoModelLook extends JModelAdmin
*/
public function getTable($type = 'look', $prefix = 'DemoTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_demo/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
@ -105,15 +105,18 @@ class DemoModelLook extends JModelAdmin
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @param array $options Optional array of options for the form creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// Get the form.
$form = $this->loadForm('com_demo.look', 'look', array('control' => 'jform', 'load_data' => $loadData));
$form = $this->loadForm('com_demo.look', 'look', $options);
if (empty($form))
{
@ -176,17 +179,20 @@ class DemoModelLook extends JModelAdmin
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected field name
$redirectedField = $jinput->get('ref', null, 'STRING');
// Set redirected field value
$redirectedValue = $jinput->get('refid', 0, 'INT');
// Set redirected view name
$redirectedView = $jinput->get('ref', null, 'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView, 'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId, 'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage looks.php
@ -21,9 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the Joomla modellist library
jimport('joomla.application.component.modellist');
/**
* Looks Model
*/
@ -105,11 +102,9 @@ class DemoModelLooks extends JModelList
// set values to display correctly.
if (DemoHelper::checkArray($items))
{
// get user object.
$user = JFactory::getUser();
foreach ($items as $nr => &$item)
{
$access = ($user->authorise('look.access', 'com_demo.look.' . (int) $item->id) && $user->authorise('look.access', 'com_demo'));
$access = (JFactory::getUser()->authorise('look.access', 'com_demo.look.' . (int) $item->id) && JFactory::getUser()->authorise('look.access', 'com_demo'));
if (!$access)
{
unset($items[$nr]);
@ -238,11 +233,9 @@ class DemoModelLooks extends JModelList
// set values to display correctly.
if (DemoHelper::checkArray($items))
{
// get user object.
$user = JFactory::getUser();
foreach ($items as $nr => &$item)
{
$access = ($user->authorise('look.access', 'com_demo.look.' . (int) $item->id) && $user->authorise('look.access', 'com_demo'));
$access = (JFactory::getUser()->authorise('look.access', 'com_demo.look.' . (int) $item->id) && JFactory::getUser()->authorise('look.access', 'com_demo'));
if (!$access)
{
unset($items[$nr]);

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage look.php
@ -23,9 +23,6 @@ defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
// import Joomla table library
jimport('joomla.database.table');
/**
* Looks Table class
*/

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default_main.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default_vdm.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage view.html.php
@ -21,9 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
/**
* Demo View class
*/

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage view.html.php
@ -21,9 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
/**
* Demo Import View
*/

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage submitbutton.js

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage edit.php
@ -51,7 +51,7 @@ $componentParams = JComponentHelper::getParams('com_demo');
});
</script>
<div id="demo_loader" style="display: none;">
<form action="<?php echo JRoute::_('index.php?option=com_demo&layout=edit&id='.(int) $this->item->id.$this->referral); ?>" method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
<form action="<?php echo JRoute::_('index.php?option=com_demo&layout=edit&id='. (int) $this->item->id . $this->referral); ?>" method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
<?php echo JLayoutHelper::render('look.details_above', $this); ?>
<div class="form-horizontal">
@ -79,6 +79,10 @@ $componentParams = JComponentHelper::getParams('com_demo');
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php $this->ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?>
<?php $this->tab_name = 'lookTab'; ?>
<?php echo JLayoutHelper::render('joomla.edit.params', $this); ?>
<?php if ($this->canDo->get('look.delete') || $this->canDo->get('look.edit.created_by') || $this->canDo->get('look.edit.state') || $this->canDo->get('look.edit.created')) : ?>
<?php echo JHtml::_('bootstrap.addTab', 'lookTab', 'publishing', JText::_('COM_DEMO_LOOK_PUBLISHING', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage view.html.php
@ -21,9 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
/**
* Look View class
*/
@ -46,16 +43,24 @@ class DemoViewLook extends JViewLegacy
$jinput = JFactory::getApplication()->input;
$this->ref = $jinput->get('ref', 0, 'word');
$this->refid = $jinput->get('refid', 0, 'int');
$return = $jinput->get('return', null, 'base64');
// set the referral string
$this->referral = '';
if ($this->refid)
if ($this->refid && $this->ref)
{
// return to the item that refered to this item
$this->referral = '&ref='.(string)$this->ref.'&refid='.(int)$this->refid;
// return to the item that referred to this item
$this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid;
}
elseif($this->ref)
{
// return to the list view that refered to this item
$this->referral = '&ref='.(string)$this->ref;
// return to the list view that referred to this item
$this->referral = '&ref=' . (string)$this->ref;
}
// check return value
if (!is_null($return))
{
// add the return value
$this->referral .= '&return=' . (string)$return;
}
// Set the toolbar
@ -87,7 +92,7 @@ class DemoViewLook extends JViewLegacy
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 (DemoHelper::checkString($this->referral))
{
if ($this->canDo->get('look.create') && $isNew)
{

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default_batch_body.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default_batch_footer.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default_body.php
@ -70,16 +70,16 @@ $edit = "index.php?option=com_demo&view=looks&task=look.edit";
<?php endif; ?>
</td>
<td class="nowrap">
<?php if ($canDo->get('look.edit')): ?>
<div class="name">
<?php if ($canDo->get('look.edit')): ?>
<a href="<?php echo $edit; ?>&id=<?php echo $item->id; ?>"><?php echo $this->escape($item->name); ?></a>
<?php if ($item->checked_out): ?>
<?php echo JHtml::_('jgrid.checkedout', $i, $userChkOut->name, $item->checked_out_time, 'looks.', $canCheckin); ?>
<?php endif; ?>
</div>
<?php else: ?>
<div class="name"><?php echo $this->escape($item->name); ?></div>
<?php echo $this->escape($item->name); ?>
<?php endif; ?>
</div>
</td>
<td class="hidden-phone">
<?php echo $this->escape($item->description); ?>

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default_foot.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default_head.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default_toolbar.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage view.html.php
@ -21,9 +21,6 @@
// 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
*/

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_DEMO</name>
<creationDate>5th May, 2018</creationDate>
<creationDate>13th September, 2018</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://www.vdm.io/</authorUrl>

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage script.php
@ -22,8 +22,6 @@
defined('_JEXEC') or die('Restricted access');
JHTML::_('behavior.modal');
jimport('joomla.installer.installer');
jimport('joomla.installer.helper');
/**
* Script File of Demo Component
@ -53,6 +51,168 @@ class com_demoInstallerScript
// Get The Database object
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select ids from fields
$query->select($db->quoteName('id'));
$query->from($db->quoteName('#__fields'));
// Where look context is found
$query->where( $db->quoteName('context') . ' = '. $db->quote('com_demo.look') );
$db->setQuery($query);
// Execute query to see if context is found
$db->execute();
$look_found = $db->getNumRows();
// Now check if there were any rows
if ($look_found)
{
// Since there are load the needed look field ids
$look_field_ids = $db->loadColumn();
// Remove look from the field table
$look_condition = array( $db->quoteName('context') . ' = '. $db->quote('com_demo.look') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__fields'));
$query->where($look_condition);
$db->setQuery($query);
// Execute the query to remove look items
$look_done = $db->execute();
if ($look_done)
{
// If succesfully remove look add queued success message.
$app->enqueueMessage(JText::_('The fields with type (com_demo.look) context was removed from the <b>#__fields</b> table'));
}
// Also Remove look field values
$look_condition = array( $db->quoteName('field_id') . ' IN ('. implode(',', $look_field_ids) .')');
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__fields_values'));
$query->where($look_condition);
$db->setQuery($query);
// Execute the query to remove look field values
$look_done = $db->execute();
if ($look_done)
{
// If succesfully remove look add queued success message.
$app->enqueueMessage(JText::_('The fields values for look was removed from the <b>#__fields_values</b> table'));
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select ids from field groups
$query->select($db->quoteName('id'));
$query->from($db->quoteName('#__fields_groups'));
// Where look context is found
$query->where( $db->quoteName('context') . ' = '. $db->quote('com_demo.look') );
$db->setQuery($query);
// Execute query to see if context is found
$db->execute();
$look_found = $db->getNumRows();
// Now check if there were any rows
if ($look_found)
{
// Remove look from the field groups table
$look_condition = array( $db->quoteName('context') . ' = '. $db->quote('com_demo.look') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__fields_groups'));
$query->where($look_condition);
$db->setQuery($query);
// Execute the query to remove look items
$look_done = $db->execute();
if ($look_done)
{
// If succesfully remove look add queued success message.
$app->enqueueMessage(JText::_('The field groups with type (com_demo.look) context was removed from the <b>#__fields_groups</b> table'));
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where look alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.look') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$look_found = $db->getNumRows();
// Now check if there were any rows
if ($look_found)
{
// Since there are load the needed look type ids
$look_ids = $db->loadColumn();
// Remove look from the content type table
$look_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.look') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($look_condition);
$db->setQuery($query);
// Execute the query to remove look items
$look_done = $db->execute();
if ($look_done)
{
// If succesfully remove look add queued success message.
$app->enqueueMessage(JText::_('The (com_demo.look) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove look items from the contentitem tag map table
$look_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.look') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($look_condition);
$db->setQuery($query);
// Execute the query to remove look items
$look_done = $db->execute();
if ($look_done)
{
// If succesfully remove look add queued success message.
$app->enqueueMessage(JText::_('The (com_demo.look) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove look items from the ucm content table
$look_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_demo.look') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($look_condition);
$db->setQuery($query);
// Execute the query to remove look items
$look_done = $db->execute();
if ($look_done)
{
// If succesfully remove look add queued success message.
$app->enqueueMessage(JText::_('The (com_demo.look) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the look items are cleared from DB
foreach ($look_ids as $look_id)
{
// Remove look items from the ucm base table
$look_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $look_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($look_condition);
$db->setQuery($query);
// Execute the query to remove look items
$db->execute();
// Remove look items from the ucm history table
$look_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $look_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($look_condition);
$db->setQuery($query);
// Execute the query to remove look items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
@ -78,7 +238,7 @@ class com_demoInstallerScript
$db->setQuery($query);
// Execute the query to remove Look items
$look_done = $db->execute();
if ($look_done);
if ($look_done)
{
// If succesfully remove Look add queued success message.
$app->enqueueMessage(JText::_('The (com_demo.look) type alias was removed from the <b>#__content_type</b> table'));
@ -93,7 +253,7 @@ class com_demoInstallerScript
$db->setQuery($query);
// Execute the query to remove Look items
$look_done = $db->execute();
if ($look_done);
if ($look_done)
{
// If succesfully remove Look add queued success message.
$app->enqueueMessage(JText::_('The (com_demo.look) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
@ -108,7 +268,7 @@ class com_demoInstallerScript
$db->setQuery($query);
// Execute the query to remove Look items
$look_done = $db->execute();
if ($look_done);
if ($look_done)
{
// If succesfully remove Look add queued success message.
$app->enqueueMessage(JText::_('The (com_demo.look) type alias was removed from the <b>#__ucm_content</b> table'));
@ -152,7 +312,7 @@ class com_demoInstallerScript
$query->where($demo_condition);
$db->setQuery($query);
$look_done = $db->execute();
if ($look_done);
if ($look_done)
{
// If succesfully remove demo add queued success message.
$app->enqueueMessage(JText::_('All related items was removed from the <b>#__assets</b> table'));

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage look.css

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage looking.css

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage looks.css

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage site.css

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage site.js

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage controller.php
@ -21,9 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controller library
jimport('joomla.application.component.controller');
/**
* Demo Component Controller
*/

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage look.php
@ -21,9 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controllerform library
jimport('joomla.application.component.controllerform');
/**
* Look Controller
*/
@ -38,6 +35,13 @@ class DemoControllerLook extends JControllerForm
*/
protected $task;
/**
* Class constructor.
*
* @param array $config A named array of configuration variables.
*
* @since 1.6
*/
public function __construct($config = array())
{
$this->view_list = 'looks'; // safeguard for setting the return view listing to the default site view.
@ -55,14 +59,17 @@ class DemoControllerLook extends JControllerForm
*/
protected function allowAdd($data = array())
{
// Get user object.
$user = JFactory::getUser();
// Access check.
$access = JFactory::getUser()->authorise('look.access', 'com_demo');
$access = $user->authorise('look.access', 'com_demo');
if (!$access)
{
return false;
}
// In the absense of better information, revert to the component permissions.
return JFactory::getUser()->authorise('look.create', $this->option);
return $user->authorise('look.create', $this->option);
}
/**
@ -136,42 +143,25 @@ class DemoControllerLook extends JControllerForm
*
* @return string The arguments to append to the redirect URL.
*
* @since 12.2
* @since 1.6
*/
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
{
$tmpl = $this->input->get('tmpl');
$layout = $this->input->get('layout', 'edit', 'string');
// get the referral options (old method use return instead see parent)
$ref = $this->input->get('ref', 0, 'string');
$refid = $this->input->get('refid', 0, 'int');
// Setup redirect info.
// get redirect info.
$append = parent::getRedirectToItemAppend($recordId, $urlVar);
$append = '';
if ($refid)
// set the referral options
if ($refid && $ref)
{
$append .= '&ref='.(string)$ref.'&refid='.(int)$refid;
$append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append;
}
elseif ($ref)
{
$append .= '&ref='.(string)$ref;
}
if ($tmpl)
{
$append .= '&tmpl=' . $tmpl;
}
if ($layout)
{
$append .= '&layout=' . $layout;
}
if ($recordId)
{
$append .= '&' . $urlVar . '=' . $recordId;
$append = '&ref='. (string)$ref . $append;
}
return $append;
@ -210,17 +200,29 @@ class DemoControllerLook extends JControllerForm
*/
public function cancel($key = null)
{
// get the referal details
// get the referral options
$this->ref = $this->input->get('ref', 0, 'word');
$this->refid = $this->input->get('refid', 0, 'int');
// Check if there is a return value
$return = $this->input->get('return', null, 'base64');
$cancel = parent::cancel($key);
if ($cancel)
if (!is_null($return) && JUri::isInternal(base64_decode($return)))
{
if ($this->refid)
$redirect = base64_decode($return);
// Redirect to the return value.
$this->setRedirect(
JRoute::_(
$redirect, false
)
);
}
elseif ($this->refid && $this->ref)
{
$redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid;
$redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid;
// Redirect to the item screen.
$this->setRedirect(
@ -231,7 +233,7 @@ class DemoControllerLook extends JControllerForm
}
elseif ($this->ref)
{
$redirect = '&view='.(string)$this->ref;
$redirect = '&view=' . (string)$this->ref;
// Redirect to the list screen.
$this->setRedirect(
@ -240,16 +242,6 @@ class DemoControllerLook extends JControllerForm
)
);
}
}
else
{
// Redirect to the items screen.
$this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option . '&view=' . $this->view_list, false
)
);
}
return $cancel;
}
@ -265,11 +257,15 @@ class DemoControllerLook extends JControllerForm
*/
public function save($key = null, $urlVar = null)
{
// get the referal details
// get the referral options
$this->ref = $this->input->get('ref', 0, 'word');
$this->refid = $this->input->get('refid', 0, 'int');
if ($this->ref || $this->refid)
// Check if there is a return value
$return = $this->input->get('return', null, 'base64');
$canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return)));
if ($this->ref || $this->refid || $canReturn)
{
// to make sure the item is checkedin on redirect
$this->task = 'save';
@ -277,9 +273,22 @@ class DemoControllerLook extends JControllerForm
$saved = parent::save($key, $urlVar);
if ($this->refid && $saved)
// This is not needed since parent save already does this
// Due to the ref and refid implementation we need to add this
if ($canReturn)
{
$redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid;
$redirect = base64_decode($return);
// Redirect to the return value.
$this->setRedirect(
JRoute::_(
$redirect, false
)
);
}
elseif ($this->refid && $this->ref)
{
$redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid;
// Redirect to the item screen.
$this->setRedirect(
@ -288,9 +297,9 @@ class DemoControllerLook extends JControllerForm
)
);
}
elseif ($this->ref && $saved)
elseif ($this->ref)
{
$redirect = '&view='.(string)$this->ref;
$redirect = '&view=' . (string)$this->ref;
// Redirect to the list screen.
$this->setRedirect(

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage demo.php
@ -20,6 +20,7 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tabstate');
// Set the component css/js
$document = JFactory::getDocument();
@ -27,18 +28,14 @@ $document->addStyleSheet('components/com_demo/assets/css/site.css');
$document->addScript('components/com_demo/assets/js/site.js');
// Require helper files
JLoader::register('DemoHelper', dirname(__FILE__) . '/helpers/demo.php');
JLoader::register('DemoHelperRoute', dirname(__FILE__) . '/helpers/route.php');
// import joomla controller library
jimport('joomla.application.component.controller');
JLoader::register('DemoHelper', __DIR__ . '/helpers/demo.php');
JLoader::register('DemoHelperRoute', __DIR__ . '/helpers/route.php');
// Get an instance of the controller prefixed by Demo
$controller = JControllerLegacy::getInstance('Demo');
// Perform the request task
$jinput = JFactory::getApplication()->input;
$controller->execute($jinput->get('task', null, 'CMD'));
$controller->execute(JFactory::getApplication()->input->get('task'));
// Redirect if set by the controller
$controller->redirect();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage category.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage demo.php
@ -97,16 +97,16 @@ abstract class DemoHelper
{
if ($external)
{
if ($name = self::getVar(null, $val, $id, $name, '=', $table))
if ($_name = self::getVar(null, $val, $id, $name, '=', $table))
{
$names[] = $name;
$names[] = $_name;
}
}
else
{
if ($name = self::getVar($table, $val, $id, $name))
if ($_name = self::getVar($table, $val, $id, $name))
{
$names[] = $name;
$names[] = $_name;
}
}
}
@ -340,7 +340,7 @@ abstract class DemoHelper
}
}
// check if there are any view values remaining
if (count($_result))
if (count((array)$_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@ -446,6 +446,46 @@ abstract class DemoHelper
}
}
/**
* get the field object
*
* @param array $attributes The array of attributes
* @param string $default The default of the field
* @param array $options The options to apply to the XML element
*
* @return object
*
*/
public static function getFieldObject($attributes, $default = '', $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes) && isset($attributes['type']))
{
// make sure the form helper class is loaded
if (!method_exists('JFormHelper', 'loadFieldType'))
{
jimport('joomla.form.form');
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'],true);
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
self::xmlAddAttributes($XML, $attributes);
// check if we have options
if (self::checkArray($options))
{
// load the options
self::xmlAddOptions($XML, $options);
}
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* Render Bool Button
*
@ -464,8 +504,6 @@ abstract class DemoHelper
$args = func_get_args();
// check if there is additional button class
$additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time
// start the xml
$buttonXML = new SimpleXMLElement('<field/>');
// button attributes
$buttonAttributes = array(
'type' => 'radio',
@ -474,22 +512,12 @@ abstract class DemoHelper
'class' => 'btn-group',
'filter' => 'INT',
'default' => isset($args[2]) ? (int) $args[2] : 0);
// load the haskey attributes
self::xmlAddAttributes($buttonXML, $buttonAttributes);
// set the button options
$buttonOptions = array(
'1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES',
'0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO');
// load the button options
self::xmlAddOptions($buttonXML, $buttonOptions);
// get the radio element
$button = JFormHelper::loadFieldType('radio');
// run
$button->setup($buttonXML, $buttonAttributes['default']);
return $button->input;
// return the input
return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input;
}
/**
@ -982,7 +1010,7 @@ abstract class DemoHelper
**/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && count($array) > 0)
if (isset($array) && is_array($array) && count((array)$array) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
@ -1085,7 +1113,7 @@ abstract class DemoHelper
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
$words_count = count($words);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
@ -1120,7 +1148,7 @@ abstract class DemoHelper
*
* @returns string on success
**/
public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true)
public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
@ -1149,7 +1177,16 @@ abstract class DemoHelper
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
$string = preg_replace('/\s+/', ' ', $string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
$string = preg_replace("/[^A-Za-z ]/", '', $string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '', $string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage headercheck.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage route.php
@ -21,10 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// Component Helper
jimport('joomla.application.component.helper');
jimport('joomla.application.categories');
/**
* Demo Route Helper
**/

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage details_above.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage details_fullwidth.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage details_under.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage metadata.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage more_left.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage more_right.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage publishing.php
@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$app = JFactory::getApplication();

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage look.js
@ -20,6 +20,7 @@
// Some Global Values
jform_vvvvvvvvvv_required = false;
jform_vvvvvvvvvw_required = false;
jform_vvvvvvvvvx_required = false;
// Initial Script
jQuery(document).ready(function()
@ -35,50 +36,70 @@ function vvvvvvv(add_vvvvvvv)
if (add_vvvvvvv == 1)
{
jQuery('#jform_dateofbirth').closest('.control-group').show();
jQuery('#jform_email').closest('.control-group').show();
// add required attribute to dateofbirth field
if (jform_vvvvvvvvvv_required)
{
updateFieldRequired('dateofbirth',0);
jQuery('#jform_dateofbirth').prop('required','required');
jQuery('#jform_dateofbirth').attr('aria-required',true);
jQuery('#jform_dateofbirth').addClass('required');
jform_vvvvvvvvvv_required = false;
}
jQuery('#jform_email').closest('.control-group').show();
// add required attribute to email field
if (jform_vvvvvvvvvw_required)
{
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;
jform_vvvvvvvvvw_required = false;
}
jQuery('#jform_image').closest('.control-group').show();
jQuery('#jform_mobile_phone').closest('.control-group').show();
if (jform_vvvvvvvvvw_required)
// add required attribute to mobile_phone field
if (jform_vvvvvvvvvx_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;
jform_vvvvvvvvvx_required = false;
}
jQuery('#jform_website').closest('.control-group').show();
}
else
{
jQuery('#jform_dateofbirth').closest('.control-group').hide();
jQuery('#jform_email').closest('.control-group').hide();
// remove required attribute from dateofbirth field
if (!jform_vvvvvvvvvv_required)
{
updateFieldRequired('dateofbirth',1);
jQuery('#jform_dateofbirth').removeAttr('required');
jQuery('#jform_dateofbirth').removeAttr('aria-required');
jQuery('#jform_dateofbirth').removeClass('required');
jform_vvvvvvvvvv_required = true;
}
jQuery('#jform_email').closest('.control-group').hide();
// remove required attribute from email field
if (!jform_vvvvvvvvvw_required)
{
updateFieldRequired('email',1);
jQuery('#jform_email').removeAttr('required');
jQuery('#jform_email').removeAttr('aria-required');
jQuery('#jform_email').removeClass('required');
jform_vvvvvvvvvv_required = true;
jform_vvvvvvvvvw_required = true;
}
jQuery('#jform_image').closest('.control-group').hide();
jQuery('#jform_mobile_phone').closest('.control-group').hide();
if (!jform_vvvvvvvvvw_required)
// remove required attribute from mobile_phone field
if (!jform_vvvvvvvvvx_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;
jform_vvvvvvvvvx_required = true;
}
jQuery('#jform_website').closest('.control-group').hide();
}

View File

@ -142,6 +142,7 @@
class="text_area"
filter="url"
validated="url"
scheme="http,https"
message="COM_DEMO_LOOK_WEBSITE_MESSAGE"
hint="COM_DEMO_LOOK_WEBSITE_HINT"
/>
@ -160,6 +161,11 @@
default="1970-01-01"
description="COM_DEMO_LOOK_DATEOFBIRTH_DESCRIPTION"
format="%Y-%m-%d"
filter="STRING"
required="true"
todaybutton="false"
minyear="-120"
maxyear="-1"
/>
<!-- Mobile_phone Field. Type: Tel. (joomla) -->
<field

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage look.php
@ -23,9 +23,6 @@ defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
// import Joomla modelform library
jimport('joomla.application.component.modeladmin');
/**
* Demo Look Model
*/
@ -58,6 +55,9 @@ class DemoModelLook extends JModelAdmin
*/
public function getTable($type = 'look', $prefix = 'DemoTable', $config = array())
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_demo/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
@ -105,15 +105,18 @@ class DemoModelLook extends JModelAdmin
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @param array $options Optional array of options for the form creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// Get the form.
$form = $this->loadForm('com_demo.look', 'look', array('control' => 'jform', 'load_data' => $loadData));
$form = $this->loadForm('com_demo.look', 'look', $options);
if (empty($form))
{
@ -176,17 +179,20 @@ class DemoModelLook extends JModelAdmin
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected field name
$redirectedField = $jinput->get('ref', null, 'STRING');
// Set redirected field value
$redirectedValue = $jinput->get('refid', 0, 'INT');
// Set redirected view name
$redirectedView = $jinput->get('ref', null, 'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView, 'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId, 'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
return $form;
}

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage looking.php
@ -21,9 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla modelitem library
jimport('joomla.application.component.modelitem');
/**
* Demo Looking Model
*/
@ -123,8 +120,8 @@ class DemoModelLooking extends JModelItem
// 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')));
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','a.created_by'),
array('id','name','alias','description','add','email','mobile_phone','dateofbirth','image','website','published','hits','created_by')));
$query->from($db->quoteName('#__demo_look', 'a'));
$query->where('a.id = ' . (int) $pk);
@ -144,11 +141,13 @@ class DemoModelLooking extends JModelItem
// Load the JEvent Dispatcher
JPluginHelper::importPlugin('content');
$this->_dispatcher = JEventDispatcher::getInstance();
// Check if item has params, or pass whole item.
$params = (isset($data->params) && DemoHelper::checkJson($data->params)) ? json_decode($data->params) : $data;
// Make sure the content prepare plugins fire on description
$_description = new stdClass();
$_description->text =& $data->description; // value must be in text
// Since all values are now in text (Joomla Limitation), we also add the field name (description) to context
$this->_dispatcher->trigger("onContentPrepare", array('com_demo.looking.description', &$_description, &$this->params, 0));
$this->_dispatcher->trigger("onContentPrepare", array('com_demo.looking.description', &$_description, &$params, 0));
// Checking if description has uikit components that must be loaded.
$this->uikitComp = DemoHelper::getUikitComp($data->description,$this->uikitComp);
@ -173,7 +172,6 @@ class DemoModelLooking extends JModelItem
return $this->_item[$pk];
}
/**
* Get the uikit needed components
*

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage looks.php
@ -21,9 +21,6 @@
// 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
*/
@ -68,8 +65,8 @@ class DemoModelLooks extends JModelList
// 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')));
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','a.created_by'),
array('id','name','alias','description','add','email','mobile_phone','dateofbirth','image','website','not_required','published','hits','ordering','created_by')));
$query->from($db->quoteName('#__demo_look', 'a'));
// Get where a.published is 1
$query->where('a.published = 1');
@ -112,11 +109,13 @@ class DemoModelLooks extends JModelList
{
// Always create a slug for sef URL's
$item->slug = (isset($item->alias) && isset($item->id)) ? $item->id.':'.$item->alias : $item->id;
// Check if item has params, or pass whole item.
$params = (isset($item->params) && DemoHelper::checkJson($item->params)) ? json_decode($item->params) : $item;
// Make sure the content prepare plugins fire on description
$_description = new stdClass();
$_description->text =& $item->description; // value must be in text
// Since all values are now in text (Joomla Limitation), we also add the field name (description) to context
$this->_dispatcher->trigger("onContentPrepare", array('com_demo.looks.description', &$_description, &$this->params, 0));
$this->_dispatcher->trigger("onContentPrepare", array('com_demo.looks.description', &$_description, &$params, 0));
// Checking if description has uikit components that must be loaded.
$this->uikitComp = DemoHelper::getUikitComp($item->description,$this->uikitComp);
}
@ -148,7 +147,6 @@ class DemoModelLooks extends JModelList
return $items;
}
/**
* Get the uikit needed components
*

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage router.php

View File

@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage submitbutton.js

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage edit.php
@ -31,7 +31,7 @@ JHtml::_('behavior.calendar');
$componentParams = JComponentHelper::getParams('com_demo');
?>
<?php echo $this->toolbar->render(); ?>
<form action="<?php echo JRoute::_('index.php?option=com_demo&layout=edit&id='.(int) $this->item->id.$this->referral); ?>" method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
<form action="<?php echo JRoute::_('index.php?option=com_demo&layout=edit&id='. (int) $this->item->id . $this->referral); ?>" method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
<?php echo JLayoutHelper::render('look.details_above', $this); ?>
<div class="form-horizontal">
@ -59,6 +59,10 @@ $componentParams = JComponentHelper::getParams('com_demo');
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php $this->ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?>
<?php $this->tab_name = 'lookTab'; ?>
<?php echo JLayoutHelper::render('joomla.edit.params', $this); ?>
<?php if ($this->canDo->get('look.delete') || $this->canDo->get('look.edit.created_by') || $this->canDo->get('look.edit.state') || $this->canDo->get('look.edit.created')) : ?>
<?php echo JHtml::_('bootstrap.addTab', 'lookTab', 'publishing', JText::_('COM_DEMO_LOOK_PUBLISHING', true)); ?>
<div class="row-fluid form-horizontal-desktop">

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage view.html.php
@ -21,9 +21,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
/**
* Look View class
*/
@ -46,16 +43,24 @@ class DemoViewLook extends JViewLegacy
$jinput = JFactory::getApplication()->input;
$this->ref = $jinput->get('ref', 0, 'word');
$this->refid = $jinput->get('refid', 0, 'int');
$return = $jinput->get('return', null, 'base64');
// set the referral string
$this->referral = '';
if ($this->refid)
if ($this->refid && $this->ref)
{
// return to the item that refered to this item
$this->referral = '&ref='.(string)$this->ref.'&refid='.(int)$this->refid;
// return to the item that referred to this item
$this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid;
}
elseif($this->ref)
{
// return to the list view that refered to this item
$this->referral = '&ref='.(string)$this->ref;
// return to the list view that referred to this item
$this->referral = '&ref=' . (string)$this->ref;
}
// check return value
if (!is_null($return))
{
// add the return value
$this->referral .= '&return=' . (string)$return;
}
// Set the toolbar
@ -89,7 +94,7 @@ class DemoViewLook extends JViewLegacy
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 (DemoHelper::checkString($this->referral))
{
if ($this->canDo->get('look.create') && $isNew)
{

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default.php

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage view.html.php
@ -21,9 +21,6 @@
// 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
*/

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage default.php
@ -22,7 +22,8 @@
defined('_JEXEC') or die('Restricted access');
?>
<table class="uk-table uk-table-hover">
<form action="<?php echo JRoute::_('index.php?option=com_demo'); ?>" method="post" name="adminForm" id="adminForm">
<table class="uk-table uk-table-hover">
<caption><?php echo JText::_('COM_DEMO_LIST_OF_ALL_LOOKS'); ?></caption>
<thead>
<tr>
@ -41,12 +42,13 @@ defined('_JEXEC') or die('Restricted access');
</table>
<?php if (isset($this->items) && isset($this->pagination) && isset($this->pagination->pagesTotal) && $this->pagination->pagesTotal > 1): ?>
<form name="adminForm" method="post">
<div class="pagination">
<?php if ($this->params->def('show_pagination_results', 1)) : ?>
<p class="counter pull-right"> <?php echo $this->pagination->getPagesCounter(); ?> <?php echo $this->pagination->getLimitBox(); ?></p>
<?php endif; ?>
<?php echo $this->pagination->getPagesLinks(); ?>
</div>
</form>
<?php endif; ?>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</form>

View File

@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 2.0.0
@build 5th May, 2018
@build 13th September, 2018
@created 18th October, 2016
@package Demo
@subpackage view.html.php
@ -21,9 +21,6 @@
// 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
*/