diff --git a/admin/layouts/greeting/details_left.php b/admin/layouts/greeting/details_left.php
index a929786..f60e5e9 100644
--- a/admin/layouts/greeting/details_left.php
+++ b/admin/layouts/greeting/details_left.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage details_left.php
@@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
-
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();
@@ -30,20 +29,10 @@ $fields = $displayData->get('fields') ?: array(
$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;
- }
- }
-}
+?>
+
+
+ setFieldAttribute($field, 'type', 'hidden'); ?>
+
+ renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
+
diff --git a/admin/layouts/greeting/metadata.php b/admin/layouts/greeting/metadata.php
index 184660e..c23d497 100644
--- a/admin/layouts/greeting/metadata.php
+++ b/admin/layouts/greeting/metadata.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage metadata.php
@@ -19,7 +19,6 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
-
defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();
diff --git a/admin/layouts/greeting/publishing.php b/admin/layouts/greeting/publishing.php
index b7e3b79..426f0de 100644
--- a/admin/layouts/greeting/publishing.php
+++ b/admin/layouts/greeting/publishing.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage publishing.php
@@ -19,10 +19,8 @@
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
-
defined('_JEXEC') or die('Restricted access');
-$app = JFactory::getApplication();
$form = $displayData->getForm();
$fields = $displayData->get('fields') ?: array(
@@ -40,20 +38,10 @@ $fields = $displayData->get('fields') ?: array(
$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;
- }
- }
-}
+?>
+
+
+ setFieldAttribute($field, 'type', 'hidden'); ?>
+
+ renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
+
diff --git a/admin/models/forms/greeting.js b/admin/models/forms/greeting.js
index e416ee8..6eb0135 100644
--- a/admin/models/forms/greeting.js
+++ b/admin/models/forms/greeting.js
@@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage greeting.js
diff --git a/admin/models/greeting.php b/admin/models/greeting.php
index 063c540..a83b33c 100644
--- a/admin/models/greeting.php
+++ b/admin/models/greeting.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage greeting.php
@@ -23,9 +23,6 @@ defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
-// import Joomla modelform library
-jimport('joomla.application.component.modeladmin');
-
/**
* Hello_world Greeting Model
*/
@@ -58,6 +55,9 @@ class Hello_worldModelGreeting extends JModelAdmin
*/
public function getTable($type = 'greeting', $prefix = 'Hello_worldTable', $config = array())
{
+ // add table path for when model gets used from other component
+ $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_hello_world/tables');
+ // get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
@@ -98,22 +98,25 @@ class Hello_worldModelGreeting extends JModelAdmin
}
return $item;
- }
+ }
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
+ * @param array $options Optional array of options for the form creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
- public function getForm($data = array(), $loadData = true)
- {
+ 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_hello_world.greeting', 'greeting', array('control' => 'jform', 'load_data' => $loadData));
+ $form = $this->loadForm('com_hello_world.greeting', 'greeting', $options);
if (empty($form))
{
@@ -179,6 +182,7 @@ class Hello_worldModelGreeting extends JModelAdmin
$form->setFieldAttribute('greeting', 'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('greeting', 'readonly', 'true');
+ // If there is no value continue.
if (!$form->getValue('greeting'))
{
// Disable fields while saving.
@@ -190,17 +194,20 @@ class Hello_worldModelGreeting 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;
}
@@ -251,7 +258,7 @@ class Hello_worldModelGreeting extends JModelAdmin
protected function canEditState($record)
{
$user = JFactory::getUser();
- $recordId = (!empty($record->id)) ? $record->id : 0;
+ $recordId = (!empty($record->id)) ? $record->id : 0;
if ($recordId)
{
@@ -358,7 +365,7 @@ class Hello_worldModelGreeting extends JModelAdmin
}
return $data;
- }
+ }
/**
* Method to get the unique fields of this table.
@@ -516,7 +523,7 @@ class Hello_worldModelGreeting extends JModelAdmin
*
* @return mixed An array of new IDs on success, boolean false on failure.
*
- * @since 12.2
+ * @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
@@ -614,7 +621,7 @@ class Hello_worldModelGreeting extends JModelAdmin
$this->table->id = 0;
// TODO: Deal with ordering?
- // $this->table->ordering = 1;
+ // $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
@@ -648,7 +655,7 @@ class Hello_worldModelGreeting extends JModelAdmin
$this->cleanCache();
return $newIds;
- }
+ }
/**
* Batch move items to a new category
@@ -659,7 +666,7 @@ class Hello_worldModelGreeting extends JModelAdmin
*
* @return boolean True if successful, false otherwise and internal error is set.
*
- * @since 12.2
+ * @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
@@ -780,7 +787,7 @@ class Hello_worldModelGreeting extends JModelAdmin
$metadata = new JRegistry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
- }
+ }
// Set the Params Items to data
if (isset($data['params']) && is_array($data['params']))
@@ -836,13 +843,13 @@ class Hello_worldModelGreeting extends JModelAdmin
}
/**
- * Method to change the title
- *
- * @param string $title The title.
- *
- * @return array Contains the modified title and alias.
- *
- */
+ * Method to change the title
+ *
+ * @param string $title The title.
+ *
+ * @return array Contains the modified title and alias.
+ *
+ */
protected function _generateNewTitle($title)
{
diff --git a/admin/models/greetings.php b/admin/models/greetings.php
index 422781f..caf0505 100644
--- a/admin/models/greetings.php
+++ b/admin/models/greetings.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage greetings.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');
-
/**
* Greetings Model
*/
@@ -91,12 +88,12 @@ class Hello_worldModelGreetings extends JModelList
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
- {
+ {
// check in items
$this->checkInNow();
// load parent items
- $items = parent::getItems();
+ $items = parent::getItems();
// return items
return $items;
@@ -174,10 +171,10 @@ class Hello_worldModelGreetings extends JModelList
}
/**
- * Method to get list export data.
- *
- * @return mixed An array of data items on success, false on failure.
- */
+ * Method to get list export data.
+ *
+ * @return mixed An array of data items on success, false on failure.
+ */
public function getExportData($pks)
{
// setup the query
@@ -262,7 +259,7 @@ class Hello_worldModelGreetings extends JModelList
return $headers;
}
return false;
- }
+ }
/**
* Method to get a store id based on model configuration state.
@@ -285,16 +282,16 @@ class Hello_worldModelGreetings extends JModelList
}
/**
- * Build an SQL query to checkin all items left checked out longer then a set time.
- *
- * @return a bool
- *
- */
+ * Build an SQL query to checkin all items left checked out longer then a set time.
+ *
+ * @return a bool
+ *
+ */
protected function checkInNow()
{
// Get set check in time
$time = JComponentHelper::getParams('com_hello_world')->get('check_in');
-
+
if ($time)
{
diff --git a/admin/models/hello_world.php b/admin/models/hello_world.php
index 25b100e..9e8e50b 100644
--- a/admin/models/hello_world.php
+++ b/admin/models/hello_world.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage hello_world.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');
-
/**
* Hello_world Model
*/
diff --git a/admin/models/import.php b/admin/models/import.php
index 3ac7f07..7a033e4 100644
--- a/admin/models/import.php
+++ b/admin/models/import.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage import.php
diff --git a/admin/sql/install.mysql.utf8.sql b/admin/sql/install.mysql.utf8.sql
index 6b66708..c258eaf 100644
--- a/admin/sql/install.mysql.utf8.sql
+++ b/admin/sql/install.mysql.utf8.sql
@@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `#__hello_world_greeting` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',
`greeting` VARCHAR(255) NOT NULL DEFAULT '',
- `params` text NOT NULL DEFAULT '',
+ `params` text NOT NULL,
`published` TINYINT(3) NOT NULL DEFAULT 1,
`created_by` INT(10) unsigned NOT NULL DEFAULT 0,
`modified_by` INT(10) unsigned NOT NULL DEFAULT 0,
@@ -14,9 +14,9 @@ CREATE TABLE IF NOT EXISTS `#__hello_world_greeting` (
`hits` INT(10) unsigned NOT NULL DEFAULT 0,
`access` INT(10) unsigned NOT NULL DEFAULT 0,
`ordering` INT(11) NOT NULL DEFAULT 0,
- `metakey` TEXT NOT NULL DEFAULT '',
- `metadesc` TEXT NOT NULL DEFAULT '',
- `metadata` TEXT NOT NULL DEFAULT '',
+ `metakey` TEXT NOT NULL,
+ `metadesc` TEXT NOT NULL,
+ `metadata` TEXT NOT NULL,
PRIMARY KEY (`id`),
KEY `idx_access` (`access`),
KEY `idx_checkout` (`checked_out`),
@@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS `#__hello_world_greeting` (
KEY `idx_modifiedby` (`modified_by`),
KEY `idx_state` (`published`),
KEY `idx_greeting` (`greeting`)
-) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
+) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
diff --git a/admin/tables/greeting.php b/admin/tables/greeting.php
index 6c10f1d..2e3868d 100644
--- a/admin/tables/greeting.php
+++ b/admin/tables/greeting.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage greeting.php
@@ -23,9 +23,6 @@ defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
-// import Joomla table library
-jimport('joomla.database.table');
-
/**
* Greetings Table class
*/
@@ -49,7 +46,7 @@ class Hello_worldTableGreeting extends JTable
parent::__construct('#__hello_world_greeting', 'id', $db);
// Adding History Options
- JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_hello_world.greeting'));
+ JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_hello_world.greeting'));
}
public function bind($array, $ignore = '')
@@ -232,7 +229,7 @@ class Hello_worldTableGreeting extends JTable
{
// asset alread set so use saved rules
$assetId = (int) $db->loadResult();
- return JAccess::getAssetRules($assetId);
+ return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed.
}
// try again
elseif ($try)
@@ -321,10 +318,10 @@ class Hello_worldTableGreeting extends JTable
}
/**
- * This view does not actually have an alias
- *
- * @return bool
- */
+ * This view does not actually have an alias
+ *
+ * @return bool
+ */
public function generateAlias()
{
return false;
diff --git a/admin/views/greeting/submitbutton.js b/admin/views/greeting/submitbutton.js
index 0d612f5..90535f4 100644
--- a/admin/views/greeting/submitbutton.js
+++ b/admin/views/greeting/submitbutton.js
@@ -3,7 +3,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage submitbutton.js
@@ -22,19 +22,9 @@ Joomla.submitbutton = function(task)
if (task == ''){
return false;
} else {
- var isValid=true;
var action = task.split('.');
- if (action[1] != 'cancel' && action[1] != 'close'){
- var forms = $$('form.form-validate');
- for (var i=0;i
params; // will be removed just use $this->params instead
?>
diff --git a/admin/views/greeting/view.html.php b/admin/views/greeting/view.html.php
index f7c5d1b..e25f908 100644
--- a/admin/views/greeting/view.html.php
+++ b/admin/views/greeting/view.html.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@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');
-
/**
* Greeting View class
*/
@@ -35,27 +32,37 @@ class Hello_worldViewGreeting extends JViewLegacy
*/
public function display($tpl = null)
{
+ // set params
+ $this->params = JComponentHelper::getParams('com_hello_world');
// Assign the variables
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->script = $this->get('Script');
$this->state = $this->get('State');
// get action permissions
- $this->canDo = Hello_worldHelper::getActions('greeting',$this->item);
+ $this->canDo = Hello_worldHelper::getActions('greeting', $this->item);
// get input
$jinput = JFactory::getApplication()->input;
$this->ref = $jinput->get('ref', 0, 'word');
$this->refid = $jinput->get('refid', 0, 'int');
+ $return = $jinput->get('return', null, 'base64');
+ // set the referral string
$this->referral = '';
- if ($this->refid)
+ 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 +94,7 @@ class Hello_worldViewGreeting extends JViewLegacy
JToolbarHelper::title( JText::_($isNew ? 'COM_HELLO_WORLD_GREETING_NEW' : 'COM_HELLO_WORLD_GREETING_EDIT'), 'pencil-2 article-add');
// Built the actions for new and existing records.
- if ($this->refid || $this->ref)
+ if (Hello_worldHelper::checkString($this->referral))
{
if ($this->canDo->get('core.create') && $isNew)
{
@@ -189,7 +196,7 @@ class Hello_worldViewGreeting extends JViewLegacy
$this->document = JFactory::getDocument();
}
$this->document->setTitle(JText::_($isNew ? 'COM_HELLO_WORLD_GREETING_NEW' : 'COM_HELLO_WORLD_GREETING_EDIT'));
- $this->document->addStyleSheet(JURI::root() . "administrator/components/com_hello_world/assets/css/greeting.css", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
+ $this->document->addStyleSheet(JURI::root() . "administrator/components/com_hello_world/assets/css/greeting.css", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
$this->document->addScript(JURI::root() . $this->script, (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
$this->document->addScript(JURI::root() . "administrator/components/com_hello_world/views/greeting/submitbutton.js", (Hello_worldHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
JText::script('view not acceptable. Error');
diff --git a/admin/views/greetings/tmpl/default.php b/admin/views/greetings/tmpl/default.php
index d63a713..c1993bc 100644
--- a/admin/views/greetings/tmpl/default.php
+++ b/admin/views/greetings/tmpl/default.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage default.php
diff --git a/admin/views/greetings/tmpl/default_batch_body.php b/admin/views/greetings/tmpl/default_batch_body.php
index 562b3d5..bd006ce 100644
--- a/admin/views/greetings/tmpl/default_batch_body.php
+++ b/admin/views/greetings/tmpl/default_batch_body.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage default_batch_body.php
diff --git a/admin/views/greetings/tmpl/default_batch_footer.php b/admin/views/greetings/tmpl/default_batch_footer.php
index c1c2260..8865fbb 100644
--- a/admin/views/greetings/tmpl/default_batch_footer.php
+++ b/admin/views/greetings/tmpl/default_batch_footer.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage default_batch_footer.php
diff --git a/admin/views/greetings/tmpl/default_body.php b/admin/views/greetings/tmpl/default_body.php
index 1d070c0..ac6abd8 100644
--- a/admin/views/greetings/tmpl/default_body.php
+++ b/admin/views/greetings/tmpl/default_body.php
@@ -4,7 +4,7 @@
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
- @build 5th May, 2018
+ @build 12th June, 2019
@created 20th September, 2017
@package Hello World
@subpackage default_body.php
@@ -70,16 +70,16 @@ $edit = "index.php?option=com_hello_world&view=greetings&task=greeting.edit";