diff --git a/README.md b/README.md
index e3dadfb7..7316f993 100644
--- a/README.md
+++ b/README.md
@@ -23,24 +23,24 @@ The best way to see all your options is to install this component on you Joomla
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Sermon Distributor](https://www.vdm.io/)
+ *First Build*: 22nd October, 2015
-+ *Last Build*: 19th March, 2018
++ *Last Build*: 4th May, 2018
+ *Version*: 2.0.x
+ *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 :hourglass:
-**188 Hours** or **24 Eight Hour Days** (actual time the author saved -
+**186 Hours** or **23 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*: **67247**
++ *Line count*: **66759**
+ *File count*: **445**
+ *Folder count*: **93**
-**123 Hours** or **15 Eight Hour Days** (the actual time the author spent)
+**123 Hours** or **16 Eight Hour Days** (the actual time the author spent)
> (with the following break down:
> **debugging @47hours** = codingtime / 4;
@@ -48,7 +48,7 @@ due to [Automated Component Builder](https://www.vdm.io/joomla-component-builder
> **mapping @19hours** = codingtime / 10;
> **office @31hours** = codingtime / 6;)
-**311 Hours** or **39 Eight Hour Days**
+**309 Hours** or **39 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**,
diff --git a/admin/README.txt b/admin/README.txt
index e3dadfb7..7316f993 100644
--- a/admin/README.txt
+++ b/admin/README.txt
@@ -23,24 +23,24 @@ The best way to see all your options is to install this component on you Joomla
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Sermon Distributor](https://www.vdm.io/)
+ *First Build*: 22nd October, 2015
-+ *Last Build*: 19th March, 2018
++ *Last Build*: 4th May, 2018
+ *Version*: 2.0.x
+ *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 :hourglass:
-**188 Hours** or **24 Eight Hour Days** (actual time the author saved -
+**186 Hours** or **23 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*: **67247**
++ *Line count*: **66759**
+ *File count*: **445**
+ *Folder count*: **93**
-**123 Hours** or **15 Eight Hour Days** (the actual time the author spent)
+**123 Hours** or **16 Eight Hour Days** (the actual time the author spent)
> (with the following break down:
> **debugging @47hours** = codingtime / 4;
@@ -48,7 +48,7 @@ due to [Automated Component Builder](https://www.vdm.io/joomla-component-builder
> **mapping @19hours** = codingtime / 10;
> **office @31hours** = codingtime / 6;)
-**311 Hours** or **39 Eight Hour Days**
+**309 Hours** or **39 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**,
diff --git a/admin/helpers/sermondistributor.php b/admin/helpers/sermondistributor.php
index a53bbf9e..d447296d 100644
--- a/admin/helpers/sermondistributor.php
+++ b/admin/helpers/sermondistributor.php
@@ -50,7 +50,7 @@ abstract class SermondistributorHelper
* The external source links auto
**/
protected static $links_externalsource_auto;
-
+
/**
* The external source links manual
**/
@@ -60,7 +60,7 @@ abstract class SermondistributorHelper
* The external source selection auto
**/
protected static $select_externalsource_auto;
-
+
/**
* The external source selection manual
**/
@@ -361,17 +361,17 @@ abstract class SermondistributorHelper
}
/**
- * Get the file path or url
- *
- * @param string $type The (url/path) type to return
- * @param string $target The Params Target name (if set)
- * @param string $fileType The kind of filename to generate (if not set no file name is generated)
- * @param string $key The key to adjust the filename (if not set ignored)
- * @param string $default The default path if not set in Params (fallback path)
- * @param bool $createIfNotSet The switch to create the folder if not found
+ * Get the file path or url
+ *
+ * @param string $type The (url/path) type to return
+ * @param string $target The Params Target name (if set)
+ * @param string $fileType The kind of filename to generate (if not set no file name is generated)
+ * @param string $key The key to adjust the filename (if not set ignored)
+ * @param string $default The default path if not set in Params (fallback path)
+ * @param bool $createIfNotSet The switch to create the folder if not found
+ *
+ * @return string On success the path or url is returned based on the type requested
*
- * @return string On success the path or url is returned based on the type requested
- *
*/
public static function getFilePath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = JPATH_SITE . '/images/', $createIfNotSet = true)
{
@@ -432,13 +432,13 @@ abstract class SermondistributorHelper
/**
- * Write a file to the server
- *
- * @param string $path The path and file name where to safe the data
- * @param string $data The data to safe
+ * Write a file to the server
+ *
+ * @param string $path The path and file name where to safe the data
+ * @param string $data The data to safe
+ *
+ * @return bool true On success
*
- * @return bool true On success
- *
*/
public static function writeFile($path, $data)
{
@@ -549,7 +549,7 @@ abstract class SermondistributorHelper
}
return false;
}
-
+
public static function getExternalSourceLink($type, $return = 7, $get = false, $target = 'links')
{
// make sure all defaults are set
@@ -1692,7 +1692,7 @@ abstract class SermondistributorHelper
}
return 'application/octet-stream';
}
-
+
protected static function getDownloadFileName(&$sermon, $file, $type)
{
// first get file name and file type
@@ -1898,7 +1898,7 @@ abstract class SermondistributorHelper
}
return false;
}
-
+
public static function getUpdateError($id, $fileKey = null)
{
// get update error from file
@@ -1922,7 +1922,7 @@ abstract class SermondistributorHelper
}
return JText::_('COM_SERMONDISTRIBUTOR_UNKNOWN_ERROR_HAS_OCCURRED');
}
-
+
protected static function setUpdateError($id, $errorArray)
{
if (self::checkArray($errorArray) && $id > 0)
@@ -2025,6 +2025,23 @@ abstract class SermondistributorHelper
*/
protected static $curlErrorLoaded = false;
+ /**
+ * check if a worker has more work
+ *
+ * @param string $function The function to target to perform the task
+ *
+ * @return bool
+ *
+ */
+ public static function hasWork(&$function)
+ {
+ if (isset(self::$worker[$function]) && self::checkArray(self::$worker[$function]))
+ {
+ return count( (array) self::$worker[$function]);
+ }
+ return false;
+ }
+
/**
* Set a worker url
*
@@ -2327,8 +2344,8 @@ abstract class SermondistributorHelper
{
self::$locker[$key] = new FOFEncryptAes($key, 128);
}
- // convert array to string
- if (self::checkArray($string))
+ // convert array or object to string
+ if (self::checkArray($string) || self::checkObject($string))
{
$string = serialize($string);
}
@@ -3059,6 +3076,19 @@ abstract class SermondistributorHelper
return false;
}
+ /**
+ * Get a Variable
+ *
+ * @param string $table The table from which to get the variable
+ * @param string $where The value where
+ * @param string $whereString The target/field string where/name
+ * @param string $what The return field
+ * @param string $operator The operator between $whereString/field and $where/value
+ * @param string $main The component in which the table is found
+ *
+ * @return mix string/int/float
+ *
+ */
public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'sermondistributor')
{
if(!$where)
@@ -3099,6 +3129,20 @@ abstract class SermondistributorHelper
return false;
}
+ /**
+ * Get array of variables
+ *
+ * @param string $table The table from which to get the variables
+ * @param string $where The value where
+ * @param string $whereString The target/field string where/name
+ * @param string $what The return field
+ * @param string $operator The operator between $whereString/field and $where/value
+ * @param string $main The component in which the table is found
+ * @param bool $unique The switch to return a unique array
+ *
+ * @return array
+ *
+ */
public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'sermondistributor', $unique = true)
{
if(!$where)
@@ -3147,8 +3191,15 @@ abstract class SermondistributorHelper
return false;
}
- public static function jsonToString($value, $sperator = ", ", $table = null)
+ public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
{
+ // do some table foot work
+ $external = false;
+ if (strpos($table, '#__') !== false)
+ {
+ $external = true;
+ $table = str_replace('#__', '', $table);
+ }
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
@@ -3161,9 +3212,19 @@ abstract class SermondistributorHelper
$names = array();
foreach ($result as $val)
{
- if ($name = self::getVar($table, $val, 'id', 'name'))
+ if ($external)
{
- $names[] = $name;
+ if ($name = self::getVar(null, $val, $id, $name, '=', $table))
+ {
+ $names[] = $name;
+ }
+ }
+ else
+ {
+ if ($name = self::getVar($table, $val, $id, $name))
+ {
+ $names[] = $name;
+ }
}
}
if (self::checkArray($names))
@@ -3567,28 +3628,141 @@ abstract class SermondistributorHelper
return JAccess::getAssetRules(0);
}
+ /**
+ * xmlAppend
+ *
+ * @param SimpleXMLElement $xml The XML element reference in which to inject a comment
+ * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement
+ *
+ * @return null
+ *
+ */
+ public static function xmlAppend(&$xml, $node)
+ {
+ if (!$node)
+ {
+ // element was not returned
+ return;
+ }
+ switch (get_class($node))
+ {
+ case 'stdClass':
+ if (property_exists($node, 'comment'))
+ {
+ self::xmlComment($xml, $node->comment);
+ }
+ if (property_exists($node, 'fieldXML'))
+ {
+ self::xmlAppend($xml, $node->fieldXML);
+ }
+ break;
+ case 'SimpleXMLElement':
+ $domXML = dom_import_simplexml($xml);
+ $domNode = dom_import_simplexml($node);
+ $domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
+ $xml = simplexml_import_dom($domXML);
+ break;
+ }
+ }
+
+ /**
+ * xmlComment
+ *
+ * @param SimpleXMLElement $xml The XML element reference in which to inject a comment
+ * @param string $comment The comment to inject
+ *
+ * @return null
+ *
+ */
+ public static function xmlComment(&$xml, $comment)
+ {
+ $domXML = dom_import_simplexml($xml);
+ $domComment = new DOMComment($comment);
+ $nodeTarget = $domXML->ownerDocument->importNode($domComment, true);
+ $domXML->appendChild($nodeTarget);
+ $xml = simplexml_import_dom($domXML);
+ }
+
+ /**
+ * xmlAddAttributes
+ *
+ * @param SimpleXMLElement $xml The XML element reference in which to inject a comment
+ * @param array $attributes The attributes to apply to the XML element
+ *
+ * @return null
+ *
+ */
+ public static function xmlAddAttributes(&$xml, $attributes = array())
+ {
+ foreach ($attributes as $key => $value)
+ {
+ $xml->addAttribute($key, $value);
+ }
+ }
+
+ /**
+ * xmlAddOptions
+ *
+ * @param SimpleXMLElement $xml The XML element reference in which to inject a comment
+ * @param array $options The options to apply to the XML element
+ *
+ * @return void
+ *
+ */
+ public static function xmlAddOptions(&$xml, $options = array())
+ {
+ foreach ($options as $key => $value)
+ {
+ $addOption = $xml->addChild('option');
+ $addOption->addAttribute('value', $key);
+ $addOption[] = $value;
+ }
+ }
+
+ /**
+ * Render Bool Button
+ *
+ * @param array $args All the args for the button
+ * 0) name
+ * 1) additional (options class) // not used at this time
+ * 2) default
+ * 3) yes (name)
+ * 4) no (name)
+ *
+ * @return string The input html of the button
+ *
+ */
public static function renderBoolButton()
{
$args = func_get_args();
+ // check if there is additional button class
+ $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time
+ // start the xml
+ $buttonXML = new SimpleXMLElement('');
+ // button attributes
+ $buttonAttributes = array(
+ 'type' => 'radio',
+ 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button',
+ 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway
+ 'class' => 'btn-group',
+ 'filter' => 'INT',
+ 'default' => isset($args[2]) ? (int) $args[2] : 0);
+ // 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');
- // setup the properties
- $name = self::htmlEscape($args[0]);
- $additional = isset($args[1]) ? (string) $args[1] : '';
- $value = $args[2];
- $yes = isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES';
- $no = isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO';
-
- // prepare the xml
- $element = new SimpleXMLElement('');
-
// run
- $button->setup($element, $value);
+ $button->setup($buttonXML, $buttonAttributes['default']);
return $button->input;
-
}
/**
diff --git a/admin/language/en-GB/en-GB.com_sermondistributor.ini b/admin/language/en-GB/en-GB.com_sermondistributor.ini
index 6d50a5fd..f905c256 100644
--- a/admin/language/en-GB/en-GB.com_sermondistributor.ini
+++ b/admin/language/en-GB/en-GB.com_sermondistributor.ini
@@ -1512,4 +1512,4 @@ COM_SERMONDISTRIBUTOR_VIEW_MORE_RELEASES_ON_GITHUB="View more releases on Github
COM_SERMONDISTRIBUTOR_VIEW_UPDATE_STATUS="View Update Status"
COM_SERMONDISTRIBUTOR_WEBSITE="Website"
COM_SERMONDISTRIBUTOR_YOU_DO_NOT_HAVE_PERMISSION_TO_CLEAR_LOCAL_LISTING="You do not have permission to clear local listing."
-COM_SERMONDISTRIBUTOR_YOU_DO_NOT_HAVE_PERMISSION_TO_RESET_UPDATE_STATUS="You do not have permission to reset update status."
+COM_SERMONDISTRIBUTOR_YOU_DO_NOT_HAVE_PERMISSION_TO_RESET_UPDATE_STATUS="You do not have permission to reset update status."
\ No newline at end of file
diff --git a/admin/language/en-GB/en-GB.com_sermondistributor.sys.ini b/admin/language/en-GB/en-GB.com_sermondistributor.sys.ini
index 338222f3..ce6d1ee1 100644
--- a/admin/language/en-GB/en-GB.com_sermondistributor.sys.ini
+++ b/admin/language/en-GB/en-GB.com_sermondistributor.sys.ini
@@ -271,4 +271,4 @@ COM_SERMONDISTRIBUTOR_STATISTICS_IMPORT_DESC="Allows the users in this group to
COM_SERMONDISTRIBUTOR_STATISTICS_SUBMENU="Statistics Submenu"
COM_SERMONDISTRIBUTOR_STATISTICS_SUBMENU_DESC="Allows the users in this group to update the submenu of the statistic"
COM_SERMONDISTRIBUTOR_USE_BATCH="Use Batch"
-COM_SERMONDISTRIBUTOR_USE_BATCH_DESC=" Allows users in this group to use batch copy/update method."
+COM_SERMONDISTRIBUTOR_USE_BATCH_DESC=" Allows users in this group to use batch copy/update method."
\ No newline at end of file
diff --git a/admin/models/external_source.php b/admin/models/external_source.php
index 6355a56a..2876eb81 100644
--- a/admin/models/external_source.php
+++ b/admin/models/external_source.php
@@ -168,12 +168,6 @@ class SermondistributorModelExternal_source extends JModelAdmin
$item->metadata = $registry->toArray();
}
- if (!empty($item->filetypes))
- {
- // JSON Decode filetypes.
- $item->filetypes = json_decode($item->filetypes);
- }
-
// Get the basic encryption.
$basickey = SermondistributorHelper::getCryptKey('basic');
// Get the encryption object.
@@ -183,6 +177,12 @@ class SermondistributorModelExternal_source extends JModelAdmin
{
// basic decrypt data oauthtoken.
$item->oauthtoken = rtrim($basic->decryptString($item->oauthtoken), "\0");
+ }
+
+ if (!empty($item->filetypes))
+ {
+ // JSON Decode filetypes.
+ $item->filetypes = json_decode($item->filetypes);
}
if (!empty($item->id))
@@ -971,9 +971,9 @@ class SermondistributorModelExternal_source extends JModelAdmin
}
/**
- * Method to change the title & alias.
+ * Method to change the title
*
- * @param string $title The title.
+ * @param string $title The title.
*
* @return array Contains the modified title and alias.
*
diff --git a/admin/models/fields/adminviewfolderlist.php b/admin/models/fields/adminviewfolderlist.php
index 4c12eb26..cc27afaa 100644
--- a/admin/models/fields/adminviewfolderlist.php
+++ b/admin/models/fields/adminviewfolderlist.php
@@ -39,107 +39,7 @@ class JFormFieldAdminviewfolderlist extends JFormFieldList
*
* @var string
*/
- public $type = 'adminviewfolderlist';
- /**
- * Override to add new button
- *
- * @return string The field input markup.
- *
- * @since 3.2
- */
- protected function getInput()
- {
- // see if we should add buttons
- $setButton = $this->getAttribute('button');
- // get html
- $html = parent::getInput();
- // if true set button
- if ($setButton === 'true')
- {
- $button = array();
- $script = array();
- $buttonName = $this->getAttribute('name');
- // get the input from url
- $app = JFactory::getApplication();
- $jinput = $app->input;
- // get the view name & id
- $values = $jinput->getArray(array(
- 'id' => 'int',
- 'view' => 'word'
- ));
- // check if new item
- $ref = '';
- $refJ = '';
- if (!is_null($values['id']) && strlen($values['view']))
- {
- // only load referal if not new item.
- $ref = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- }
- $user = JFactory::getUser();
- // only add if user allowed to create
- if ($user->authorise('core.create', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build Create button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- }
- // only add if user allowed to edit
- if (($buttonName === '' || $buttonName === '') && $user->authorise('core.edit', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build edit button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- // build script
- $script[] = "
- jQuery(document).ready(function() {
- jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) {
- e.preventDefault();
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- function ".$buttonName."Button(value) {
- if (value > 0) {
- // hide the create button
- jQuery('#".$buttonName."Create').hide();
- // show edit button
- jQuery('#".$buttonName."Edit').show();
- var url = 'index.php?option=com_sermondistributor&view=&task=.edit&id='+value+'".$refJ."';
- jQuery('#".$buttonName."Edit').attr('href', url);
- } else {
- // show the create button
- jQuery('#".$buttonName."Create').show();
- // hide edit button
- jQuery('#".$buttonName."Edit').hide();
- }
- }";
- }
- // check if button was created for field.
- if (is_array($button) && count($button) > 0)
- {
- // Load the needed script.
- $document = JFactory::getDocument();
- $document->addScriptDeclaration(implode(' ',$script));
- // return the button attached to input field.
- return '
' .$html . implode('',$button).'
';
- }
- }
- return $html;
- }
+ public $type = 'adminviewfolderlist';
/**
* Method to get a list of options for a list input.
diff --git a/admin/models/fields/articles.php b/admin/models/fields/articles.php
index bd9e2e10..1886d26a 100644
--- a/admin/models/fields/articles.php
+++ b/admin/models/fields/articles.php
@@ -39,107 +39,7 @@ class JFormFieldArticles extends JFormFieldList
*
* @var string
*/
- public $type = 'articles';
- /**
- * Override to add new button
- *
- * @return string The field input markup.
- *
- * @since 3.2
- */
- protected function getInput()
- {
- // see if we should add buttons
- $setButton = $this->getAttribute('button');
- // get html
- $html = parent::getInput();
- // if true set button
- if ($setButton === 'true')
- {
- $button = array();
- $script = array();
- $buttonName = $this->getAttribute('name');
- // get the input from url
- $app = JFactory::getApplication();
- $jinput = $app->input;
- // get the view name & id
- $values = $jinput->getArray(array(
- 'id' => 'int',
- 'view' => 'word'
- ));
- // check if new item
- $ref = '';
- $refJ = '';
- if (!is_null($values['id']) && strlen($values['view']))
- {
- // only load referal if not new item.
- $ref = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- }
- $user = JFactory::getUser();
- // only add if user allowed to create article
- if ($user->authorise('core.create', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build Create button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- }
- // only add if user allowed to edit article
- if (($buttonName === 'article' || $buttonName === 'articles') && $user->authorise('core.edit', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build edit button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- // build script
- $script[] = "
- jQuery(document).ready(function() {
- jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) {
- e.preventDefault();
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- function ".$buttonName."Button(value) {
- if (value > 0) {
- // hide the create button
- jQuery('#".$buttonName."Create').hide();
- // show edit button
- jQuery('#".$buttonName."Edit').show();
- var url = 'index.php?option=com_sermondistributor&view=articles&task=article.edit&id='+value+'".$refJ."';
- jQuery('#".$buttonName."Edit').attr('href', url);
- } else {
- // show the create button
- jQuery('#".$buttonName."Create').show();
- // hide edit button
- jQuery('#".$buttonName."Edit').hide();
- }
- }";
- }
- // check if button was created for article field.
- if (is_array($button) && count($button) > 0)
- {
- // Load the needed script.
- $document = JFactory::getDocument();
- $document->addScriptDeclaration(implode(' ',$script));
- // return the button attached to input field.
- return '
' .$html . implode('',$button).'
';
- }
- }
- return $html;
- }
+ public $type = 'articles';
/**
* Method to get a list of options for a list input.
diff --git a/admin/models/fields/externalsource.php b/admin/models/fields/externalsource.php
index a5f08eeb..f45acc63 100644
--- a/admin/models/fields/externalsource.php
+++ b/admin/models/fields/externalsource.php
@@ -39,7 +39,8 @@ class JFormFieldExternalsource extends JFormFieldList
*
* @var string
*/
- public $type = 'externalsource';
+ public $type = 'externalsource';
+
/**
* Override to add new button
*
diff --git a/admin/models/fields/externalsourcefiles.php b/admin/models/fields/externalsourcefiles.php
index e554a02d..bc9cede5 100644
--- a/admin/models/fields/externalsourcefiles.php
+++ b/admin/models/fields/externalsourcefiles.php
@@ -39,107 +39,7 @@ class JFormFieldExternalsourcefiles extends JFormFieldList
*
* @var string
*/
- public $type = 'externalsourcefiles';
- /**
- * Override to add new button
- *
- * @return string The field input markup.
- *
- * @since 3.2
- */
- protected function getInput()
- {
- // see if we should add buttons
- $setButton = $this->getAttribute('button');
- // get html
- $html = parent::getInput();
- // if true set button
- if ($setButton === 'true')
- {
- $button = array();
- $script = array();
- $buttonName = $this->getAttribute('name');
- // get the input from url
- $app = JFactory::getApplication();
- $jinput = $app->input;
- // get the view name & id
- $values = $jinput->getArray(array(
- 'id' => 'int',
- 'view' => 'word'
- ));
- // check if new item
- $ref = '';
- $refJ = '';
- if (!is_null($values['id']) && strlen($values['view']))
- {
- // only load referal if not new item.
- $ref = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- }
- $user = JFactory::getUser();
- // only add if user allowed to create
- if ($user->authorise('core.create', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build Create button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- }
- // only add if user allowed to edit
- if (($buttonName === '' || $buttonName === '') && $user->authorise('core.edit', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build edit button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- // build script
- $script[] = "
- jQuery(document).ready(function() {
- jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) {
- e.preventDefault();
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- function ".$buttonName."Button(value) {
- if (value > 0) {
- // hide the create button
- jQuery('#".$buttonName."Create').hide();
- // show edit button
- jQuery('#".$buttonName."Edit').show();
- var url = 'index.php?option=com_sermondistributor&view=&task=.edit&id='+value+'".$refJ."';
- jQuery('#".$buttonName."Edit').attr('href', url);
- } else {
- // show the create button
- jQuery('#".$buttonName."Create').show();
- // hide edit button
- jQuery('#".$buttonName."Edit').hide();
- }
- }";
- }
- // check if button was created for field.
- if (is_array($button) && count($button) > 0)
- {
- // Load the needed script.
- $document = JFactory::getDocument();
- $document->addScriptDeclaration(implode(' ',$script));
- // return the button attached to input field.
- return '
' .$html . implode('',$button).'
';
- }
- }
- return $html;
- }
+ public $type = 'externalsourcefiles';
/**
* Method to get a list of options for a list input.
diff --git a/admin/models/fields/localfiles.php b/admin/models/fields/localfiles.php
index 6a83cc7f..e245f98f 100644
--- a/admin/models/fields/localfiles.php
+++ b/admin/models/fields/localfiles.php
@@ -39,107 +39,7 @@ class JFormFieldLocalfiles extends JFormFieldList
*
* @var string
*/
- public $type = 'localfiles';
- /**
- * Override to add new button
- *
- * @return string The field input markup.
- *
- * @since 3.2
- */
- protected function getInput()
- {
- // see if we should add buttons
- $setButton = $this->getAttribute('button');
- // get html
- $html = parent::getInput();
- // if true set button
- if ($setButton === 'true')
- {
- $button = array();
- $script = array();
- $buttonName = $this->getAttribute('name');
- // get the input from url
- $app = JFactory::getApplication();
- $jinput = $app->input;
- // get the view name & id
- $values = $jinput->getArray(array(
- 'id' => 'int',
- 'view' => 'word'
- ));
- // check if new item
- $ref = '';
- $refJ = '';
- if (!is_null($values['id']) && strlen($values['view']))
- {
- // only load referal if not new item.
- $ref = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- }
- $user = JFactory::getUser();
- // only add if user allowed to create
- if ($user->authorise('core.create', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build Create button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- }
- // only add if user allowed to edit
- if (($buttonName === '' || $buttonName === '') && $user->authorise('core.edit', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build edit button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- // build script
- $script[] = "
- jQuery(document).ready(function() {
- jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) {
- e.preventDefault();
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- function ".$buttonName."Button(value) {
- if (value > 0) {
- // hide the create button
- jQuery('#".$buttonName."Create').hide();
- // show edit button
- jQuery('#".$buttonName."Edit').show();
- var url = 'index.php?option=com_sermondistributor&view=&task=.edit&id='+value+'".$refJ."';
- jQuery('#".$buttonName."Edit').attr('href', url);
- } else {
- // show the create button
- jQuery('#".$buttonName."Create').show();
- // hide edit button
- jQuery('#".$buttonName."Edit').hide();
- }
- }";
- }
- // check if button was created for field.
- if (is_array($button) && count($button) > 0)
- {
- // Load the needed script.
- $document = JFactory::getDocument();
- $document->addScriptDeclaration(implode(' ',$script));
- // return the button attached to input field.
- return '
' .$html . implode('',$button).'
';
- }
- }
- return $html;
- }
+ public $type = 'localfiles';
/**
* Method to get a list of options for a list input.
diff --git a/admin/models/fields/preachers.php b/admin/models/fields/preachers.php
index 8b535e8e..03da1bf5 100644
--- a/admin/models/fields/preachers.php
+++ b/admin/models/fields/preachers.php
@@ -39,107 +39,7 @@ class JFormFieldPreachers extends JFormFieldList
*
* @var string
*/
- public $type = 'preachers';
- /**
- * Override to add new button
- *
- * @return string The field input markup.
- *
- * @since 3.2
- */
- protected function getInput()
- {
- // see if we should add buttons
- $setButton = $this->getAttribute('button');
- // get html
- $html = parent::getInput();
- // if true set button
- if ($setButton === 'true')
- {
- $button = array();
- $script = array();
- $buttonName = $this->getAttribute('name');
- // get the input from url
- $app = JFactory::getApplication();
- $jinput = $app->input;
- // get the view name & id
- $values = $jinput->getArray(array(
- 'id' => 'int',
- 'view' => 'word'
- ));
- // check if new item
- $ref = '';
- $refJ = '';
- if (!is_null($values['id']) && strlen($values['view']))
- {
- // only load referal if not new item.
- $ref = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- }
- $user = JFactory::getUser();
- // only add if user allowed to create preacher
- if ($user->authorise('preacher.create', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build Create button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- }
- // only add if user allowed to edit preacher
- if (($buttonName === 'preacher' || $buttonName === 'preachers') && $user->authorise('preacher.edit', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build edit button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- // build script
- $script[] = "
- jQuery(document).ready(function() {
- jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) {
- e.preventDefault();
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- function ".$buttonName."Button(value) {
- if (value > 0) {
- // hide the create button
- jQuery('#".$buttonName."Create').hide();
- // show edit button
- jQuery('#".$buttonName."Edit').show();
- var url = 'index.php?option=com_sermondistributor&view=preachers&task=preacher.edit&id='+value+'".$refJ."';
- jQuery('#".$buttonName."Edit').attr('href', url);
- } else {
- // show the create button
- jQuery('#".$buttonName."Create').show();
- // hide edit button
- jQuery('#".$buttonName."Edit').hide();
- }
- }";
- }
- // check if button was created for preacher field.
- if (is_array($button) && count($button) > 0)
- {
- // Load the needed script.
- $document = JFactory::getDocument();
- $document->addScriptDeclaration(implode(' ',$script));
- // return the button attached to input field.
- return '
' .$html . implode('',$button).'
';
- }
- }
- return $html;
- }
+ public $type = 'preachers';
/**
* Method to get a list of options for a list input.
diff --git a/admin/models/fields/series.php b/admin/models/fields/series.php
index 0a6cbe55..8618cc7f 100644
--- a/admin/models/fields/series.php
+++ b/admin/models/fields/series.php
@@ -39,107 +39,7 @@ class JFormFieldSeries extends JFormFieldList
*
* @var string
*/
- public $type = 'series';
- /**
- * Override to add new button
- *
- * @return string The field input markup.
- *
- * @since 3.2
- */
- protected function getInput()
- {
- // see if we should add buttons
- $setButton = $this->getAttribute('button');
- // get html
- $html = parent::getInput();
- // if true set button
- if ($setButton === 'true')
- {
- $button = array();
- $script = array();
- $buttonName = $this->getAttribute('name');
- // get the input from url
- $app = JFactory::getApplication();
- $jinput = $app->input;
- // get the view name & id
- $values = $jinput->getArray(array(
- 'id' => 'int',
- 'view' => 'word'
- ));
- // check if new item
- $ref = '';
- $refJ = '';
- if (!is_null($values['id']) && strlen($values['view']))
- {
- // only load referal if not new item.
- $ref = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- }
- $user = JFactory::getUser();
- // only add if user allowed to create series
- if ($user->authorise('series.create', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build Create button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- }
- // only add if user allowed to edit series
- if (($buttonName === 'series' || $buttonName === 'all_series') && $user->authorise('series.edit', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build edit button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- // build script
- $script[] = "
- jQuery(document).ready(function() {
- jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) {
- e.preventDefault();
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- function ".$buttonName."Button(value) {
- if (value > 0) {
- // hide the create button
- jQuery('#".$buttonName."Create').hide();
- // show edit button
- jQuery('#".$buttonName."Edit').show();
- var url = 'index.php?option=com_sermondistributor&view=all_series&task=series.edit&id='+value+'".$refJ."';
- jQuery('#".$buttonName."Edit').attr('href', url);
- } else {
- // show the create button
- jQuery('#".$buttonName."Create').show();
- // hide edit button
- jQuery('#".$buttonName."Edit').hide();
- }
- }";
- }
- // check if button was created for series field.
- if (is_array($button) && count($button) > 0)
- {
- // Load the needed script.
- $document = JFactory::getDocument();
- $document->addScriptDeclaration(implode(' ',$script));
- // return the button attached to input field.
- return '
' .$html . implode('',$button).'
';
- }
- }
- return $html;
- }
+ public $type = 'series';
/**
* Method to get a list of options for a list input.
diff --git a/admin/models/fields/sermon.php b/admin/models/fields/sermon.php
index 6520e76e..65799f48 100644
--- a/admin/models/fields/sermon.php
+++ b/admin/models/fields/sermon.php
@@ -39,7 +39,8 @@ class JFormFieldSermon extends JFormFieldList
*
* @var string
*/
- public $type = 'sermon';
+ public $type = 'sermon';
+
/**
* Override to add new button
*
diff --git a/admin/models/fields/siteviewfolderlist.php b/admin/models/fields/siteviewfolderlist.php
index e86a9838..22492b65 100644
--- a/admin/models/fields/siteviewfolderlist.php
+++ b/admin/models/fields/siteviewfolderlist.php
@@ -39,107 +39,7 @@ class JFormFieldSiteviewfolderlist extends JFormFieldList
*
* @var string
*/
- public $type = 'siteviewfolderlist';
- /**
- * Override to add new button
- *
- * @return string The field input markup.
- *
- * @since 3.2
- */
- protected function getInput()
- {
- // see if we should add buttons
- $setButton = $this->getAttribute('button');
- // get html
- $html = parent::getInput();
- // if true set button
- if ($setButton === 'true')
- {
- $button = array();
- $script = array();
- $buttonName = $this->getAttribute('name');
- // get the input from url
- $app = JFactory::getApplication();
- $jinput = $app->input;
- // get the view name & id
- $values = $jinput->getArray(array(
- 'id' => 'int',
- 'view' => 'word'
- ));
- // check if new item
- $ref = '';
- $refJ = '';
- if (!is_null($values['id']) && strlen($values['view']))
- {
- // only load referal if not new item.
- $ref = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
- }
- $user = JFactory::getUser();
- // only add if user allowed to create
- if ($user->authorise('core.create', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build Create button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- }
- // only add if user allowed to edit
- if (($buttonName === '' || $buttonName === '') && $user->authorise('core.edit', 'com_sermondistributor') && $app->isAdmin()) // TODO for now only in admin area.
- {
- // build edit button
- $buttonNamee = trim($buttonName);
- $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
- $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
- $buttonNamee = ucfirst(strtolower($buttonNamee));
- $button[] = '
- ';
- // build script
- $script[] = "
- jQuery(document).ready(function() {
- jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) {
- e.preventDefault();
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
- ".$buttonName."Button(".$buttonName."Value);
- });
- function ".$buttonName."Button(value) {
- if (value > 0) {
- // hide the create button
- jQuery('#".$buttonName."Create').hide();
- // show edit button
- jQuery('#".$buttonName."Edit').show();
- var url = 'index.php?option=com_sermondistributor&view=&task=.edit&id='+value+'".$refJ."';
- jQuery('#".$buttonName."Edit').attr('href', url);
- } else {
- // show the create button
- jQuery('#".$buttonName."Create').show();
- // hide edit button
- jQuery('#".$buttonName."Edit').hide();
- }
- }";
- }
- // check if button was created for field.
- if (is_array($button) && count($button) > 0)
- {
- // Load the needed script.
- $document = JFactory::getDocument();
- $document->addScriptDeclaration(implode(' ',$script));
- // return the button attached to input field.
- return '
' .$html . implode('',$button).'
';
- }
- }
- return $html;
- }
+ public $type = 'siteviewfolderlist';
/**
* Method to get a list of options for a list input.
diff --git a/admin/models/forms/help_document.xml b/admin/models/forms/help_document.xml
index 22c0f960..157d057b 100644
--- a/admin/models/forms/help_document.xml
+++ b/admin/models/forms/help_document.xml
@@ -222,6 +222,7 @@
required="true"
filter="url"
validated="url"
+ scheme="http,https"
message="COM_SERMONDISTRIBUTOR_HELP_DOCUMENT_URL_MESSAGE"
hint="COM_SERMONDISTRIBUTOR_HELP_DOCUMENT_URL_HINT"
/>
diff --git a/admin/models/help_document.php b/admin/models/help_document.php
index dc5e6664..091dd929 100644
--- a/admin/models/help_document.php
+++ b/admin/models/help_document.php
@@ -848,7 +848,7 @@ class SermondistributorModelHelp_document extends JModelAdmin
// Automatic handling of alias for empty fields
if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (int) $input->get('id') == 0)
{
- if ($data['alias'] == null)
+ if ($data['alias'] == null || empty($data['alias']))
{
if (JFactory::getConfig()->get('unicodeslugs') == 1)
{
@@ -866,8 +866,7 @@ class SermondistributorModelHelp_document extends JModelAdmin
$msg = JText::_('COM_SERMONDISTRIBUTOR_HELP_DOCUMENT_SAVE_WARNING');
}
- list($title, $alias) = $this->_generateNewTitle($data['alias'], $data['title']);
- $data['alias'] = $alias;
+ $data['alias'] = $this->_generateNewTitle($data['alias']);
if (isset($msg))
{
@@ -922,26 +921,49 @@ class SermondistributorModelHelp_document extends JModelAdmin
}
/**
- * Method to change the title & alias.
+ * Method to change the title/s & alias.
*
- * @param string $alias The alias.
- * @param string $title The title.
+ * @param string $alias The alias.
+ * @param string/array $title The title.
*
- * @return array Contains the modified title and alias.
+ * @return array/string Contains the modified title/s and/or alias.
*
*/
- protected function _generateNewTitle($alias, $title)
+ protected function _generateNewTitle($alias, $title = null)
{
- // Alter the title & alias
+ // Alter the title/s & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias)))
{
- $title = JString::increment($title);
+ // Check if this is an array of titles
+ if (SermondistributorHelper::checkArray($title))
+ {
+ foreach($title as $nr => &$_title)
+ {
+ $_title = JString::increment($_title);
+ }
+ }
+ // Make sure we have a title
+ elseif ($title)
+ {
+ $title = JString::increment($title);
+ }
$alias = JString::increment($alias, 'dash');
}
-
- return array($title, $alias);
+ // Check if this is an array of titles
+ if (SermondistributorHelper::checkArray($title))
+ {
+ $title[] = $alias;
+ return $title;
+ }
+ // Make sure we have a title
+ elseif ($title)
+ {
+ return array($title, $alias);
+ }
+ // We only had an alias
+ return $alias;
}
}
diff --git a/admin/models/local_listing.php b/admin/models/local_listing.php
index 76d7bf18..e9ad5f81 100644
--- a/admin/models/local_listing.php
+++ b/admin/models/local_listing.php
@@ -977,9 +977,9 @@ class SermondistributorModelLocal_listing extends JModelAdmin
}
/**
- * Method to change the title & alias.
+ * Method to change the title
*
- * @param string $title The title.
+ * @param string $title The title.
*
* @return array Contains the modified title and alias.
*
diff --git a/admin/models/preacher.php b/admin/models/preacher.php
index 0ac8affe..aa7274e1 100644
--- a/admin/models/preacher.php
+++ b/admin/models/preacher.php
@@ -945,7 +945,7 @@ class SermondistributorModelPreacher extends JModelAdmin
// Automatic handling of alias for empty fields
if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (int) $input->get('id') == 0)
{
- if ($data['alias'] == null)
+ if ($data['alias'] == null || empty($data['alias']))
{
if (JFactory::getConfig()->get('unicodeslugs') == 1)
{
@@ -963,8 +963,7 @@ class SermondistributorModelPreacher extends JModelAdmin
$msg = JText::_('COM_SERMONDISTRIBUTOR_PREACHER_SAVE_WARNING');
}
- list($name, $alias) = $this->_generateNewTitle($data['alias'], $data['name']);
- $data['alias'] = $alias;
+ $data['alias'] = $this->_generateNewTitle($data['alias']);
if (isset($msg))
{
@@ -1019,26 +1018,49 @@ class SermondistributorModelPreacher extends JModelAdmin
}
/**
- * Method to change the title & alias.
+ * Method to change the title/s & alias.
*
- * @param string $alias The alias.
- * @param string $title The title.
+ * @param string $alias The alias.
+ * @param string/array $title The title.
*
- * @return array Contains the modified title and alias.
+ * @return array/string Contains the modified title/s and/or alias.
*
*/
- protected function _generateNewTitle($alias, $title)
+ protected function _generateNewTitle($alias, $title = null)
{
- // Alter the title & alias
+ // Alter the title/s & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias)))
{
- $title = JString::increment($title);
+ // Check if this is an array of titles
+ if (SermondistributorHelper::checkArray($title))
+ {
+ foreach($title as $nr => &$_title)
+ {
+ $_title = JString::increment($_title);
+ }
+ }
+ // Make sure we have a title
+ elseif ($title)
+ {
+ $title = JString::increment($title);
+ }
$alias = JString::increment($alias, 'dash');
}
-
- return array($title, $alias);
+ // Check if this is an array of titles
+ if (SermondistributorHelper::checkArray($title))
+ {
+ $title[] = $alias;
+ return $title;
+ }
+ // Make sure we have a title
+ elseif ($title)
+ {
+ return array($title, $alias);
+ }
+ // We only had an alias
+ return $alias;
}
}
diff --git a/admin/models/series.php b/admin/models/series.php
index fe584843..6d837333 100644
--- a/admin/models/series.php
+++ b/admin/models/series.php
@@ -945,7 +945,7 @@ class SermondistributorModelSeries extends JModelAdmin
// Automatic handling of alias for empty fields
if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (int) $input->get('id') == 0)
{
- if ($data['alias'] == null)
+ if ($data['alias'] == null || empty($data['alias']))
{
if (JFactory::getConfig()->get('unicodeslugs') == 1)
{
@@ -963,8 +963,7 @@ class SermondistributorModelSeries extends JModelAdmin
$msg = JText::_('COM_SERMONDISTRIBUTOR_SERIES_SAVE_WARNING');
}
- list($name, $alias) = $this->_generateNewTitle($data['alias'], $data['name']);
- $data['alias'] = $alias;
+ $data['alias'] = $this->_generateNewTitle($data['alias']);
if (isset($msg))
{
@@ -1019,26 +1018,49 @@ class SermondistributorModelSeries extends JModelAdmin
}
/**
- * Method to change the title & alias.
+ * Method to change the title/s & alias.
*
- * @param string $alias The alias.
- * @param string $title The title.
+ * @param string $alias The alias.
+ * @param string/array $title The title.
*
- * @return array Contains the modified title and alias.
+ * @return array/string Contains the modified title/s and/or alias.
*
*/
- protected function _generateNewTitle($alias, $title)
+ protected function _generateNewTitle($alias, $title = null)
{
- // Alter the title & alias
+ // Alter the title/s & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias)))
{
- $title = JString::increment($title);
+ // Check if this is an array of titles
+ if (SermondistributorHelper::checkArray($title))
+ {
+ foreach($title as $nr => &$_title)
+ {
+ $_title = JString::increment($_title);
+ }
+ }
+ // Make sure we have a title
+ elseif ($title)
+ {
+ $title = JString::increment($title);
+ }
$alias = JString::increment($alias, 'dash');
}
-
- return array($title, $alias);
+ // Check if this is an array of titles
+ if (SermondistributorHelper::checkArray($title))
+ {
+ $title[] = $alias;
+ return $title;
+ }
+ // Make sure we have a title
+ elseif ($title)
+ {
+ return array($title, $alias);
+ }
+ // We only had an alias
+ return $alias;
}
}
diff --git a/admin/models/sermon.php b/admin/models/sermon.php
index 67336816..0a0a095e 100644
--- a/admin/models/sermon.php
+++ b/admin/models/sermon.php
@@ -995,7 +995,7 @@ class SermondistributorModelSermon extends JModelAdmin
// Automatic handling of alias for empty fields
if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (int) $input->get('id') == 0)
{
- if ($data['alias'] == null)
+ if ($data['alias'] == null || empty($data['alias']))
{
if (JFactory::getConfig()->get('unicodeslugs') == 1)
{
@@ -1069,26 +1069,49 @@ class SermondistributorModelSermon extends JModelAdmin
}
/**
- * Method to change the title & alias.
+ * Method to change the title/s & alias.
*
- * @param string $alias The alias.
- * @param string $title The title.
+ * @param string $alias The alias.
+ * @param string/array $title The title.
*
- * @return array Contains the modified title and alias.
+ * @return array/string Contains the modified title/s and/or alias.
*
*/
- protected function _generateNewTitle($alias, $title)
+ protected function _generateNewTitle($alias, $title = null)
{
- // Alter the title & alias
+ // Alter the title/s & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias)))
{
- $title = JString::increment($title);
+ // Check if this is an array of titles
+ if (SermondistributorHelper::checkArray($title))
+ {
+ foreach($title as $nr => &$_title)
+ {
+ $_title = JString::increment($_title);
+ }
+ }
+ // Make sure we have a title
+ elseif ($title)
+ {
+ $title = JString::increment($title);
+ }
$alias = JString::increment($alias, 'dash');
}
-
- return array($title, $alias);
+ // Check if this is an array of titles
+ if (SermondistributorHelper::checkArray($title))
+ {
+ $title[] = $alias;
+ return $title;
+ }
+ // Make sure we have a title
+ elseif ($title)
+ {
+ return array($title, $alias);
+ }
+ // We only had an alias
+ return $alias;
}
}
diff --git a/admin/models/statistic.php b/admin/models/statistic.php
index bfec6b3b..9a0428bd 100644
--- a/admin/models/statistic.php
+++ b/admin/models/statistic.php
@@ -827,9 +827,9 @@ class SermondistributorModelStatistic extends JModelAdmin
}
/**
- * Method to change the title & alias.
+ * Method to change the title
*
- * @param string $title The title.
+ * @param string $title The title.
*
* @return array Contains the modified title and alias.
*
diff --git a/admin/tables/external_source.php b/admin/tables/external_source.php
index b64f2d01..f344d266 100644
--- a/admin/tables/external_source.php
+++ b/admin/tables/external_source.php
@@ -264,7 +264,7 @@ class SermondistributorTableExternal_source extends JTable
}
}
// check if there are any view values remaining
- if (count($_result))
+ if (count( (array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@@ -322,29 +322,16 @@ class SermondistributorTableExternal_source extends JTable
$asset->loadByName('com_sermondistributor');
return $asset->id;
- }
-
- /**
- * Generate a valid alias from title / date.
- * Remains public to be able to check for duplicated alias before saving
- *
- * @return string
- */
- public function generateAlias()
- {
- if (empty($this->alias))
- {
- $this->alias = $this->name;
- }
-
- $this->alias = JApplication::stringURLSafe($this->alias);
-
- if (trim(str_replace('-', '', $this->alias)) == '')
- {
- $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
- }
-
- return $this->alias;
+ }
+
+ /**
+ * This view does not actually have an alias
+ *
+ * @return bool
+ */
+ public function generateAlias()
+ {
+ return false;
}
}
diff --git a/admin/tables/help_document.php b/admin/tables/help_document.php
index ff485219..53829e38 100644
--- a/admin/tables/help_document.php
+++ b/admin/tables/help_document.php
@@ -264,7 +264,7 @@ class SermondistributorTableHelp_document extends JTable
}
}
// check if there are any view values remaining
- if (count($_result))
+ if (count( (array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@@ -322,29 +322,29 @@ class SermondistributorTableHelp_document extends JTable
$asset->loadByName('com_sermondistributor');
return $asset->id;
- }
-
- /**
- * Generate a valid alias from title / date.
- * Remains public to be able to check for duplicated alias before saving
- *
- * @return string
- */
- public function generateAlias()
- {
- if (empty($this->alias))
- {
- $this->alias = $this->name;
- }
-
- $this->alias = JApplication::stringURLSafe($this->alias);
-
- if (trim(str_replace('-', '', $this->alias)) == '')
- {
- $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
- }
-
- return $this->alias;
+ }
+
+ /**
+ * Generate a valid alias from title / date.
+ * Remains public to be able to check for duplicated alias before saving
+ *
+ * @return string
+ */
+ public function generateAlias()
+ {
+ if (empty($this->alias))
+ {
+ $this->alias = $this->title;
+ }
+
+ $this->alias = JApplication::stringURLSafe($this->alias);
+
+ if (trim(str_replace('-', '', $this->alias)) == '')
+ {
+ $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
+ }
+
+ return $this->alias;
}
}
diff --git a/admin/tables/local_listing.php b/admin/tables/local_listing.php
index 01eaa6bd..4d190f31 100644
--- a/admin/tables/local_listing.php
+++ b/admin/tables/local_listing.php
@@ -264,7 +264,7 @@ class SermondistributorTableLocal_listing extends JTable
}
}
// check if there are any view values remaining
- if (count($_result))
+ if (count( (array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@@ -322,29 +322,16 @@ class SermondistributorTableLocal_listing extends JTable
$asset->loadByName('com_sermondistributor');
return $asset->id;
- }
-
- /**
- * Generate a valid alias from title / date.
- * Remains public to be able to check for duplicated alias before saving
- *
- * @return string
- */
- public function generateAlias()
- {
- if (empty($this->alias))
- {
- $this->alias = $this->name;
- }
-
- $this->alias = JApplication::stringURLSafe($this->alias);
-
- if (trim(str_replace('-', '', $this->alias)) == '')
- {
- $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
- }
-
- return $this->alias;
+ }
+
+ /**
+ * This view does not actually have an alias
+ *
+ * @return bool
+ */
+ public function generateAlias()
+ {
+ return false;
}
}
diff --git a/admin/tables/preacher.php b/admin/tables/preacher.php
index ce554fdc..dfb980ba 100644
--- a/admin/tables/preacher.php
+++ b/admin/tables/preacher.php
@@ -264,7 +264,7 @@ class SermondistributorTablePreacher extends JTable
}
}
// check if there are any view values remaining
- if (count($_result))
+ if (count( (array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@@ -322,29 +322,29 @@ class SermondistributorTablePreacher extends JTable
$asset->loadByName('com_sermondistributor');
return $asset->id;
- }
-
- /**
- * Generate a valid alias from title / date.
- * Remains public to be able to check for duplicated alias before saving
- *
- * @return string
- */
- public function generateAlias()
- {
- if (empty($this->alias))
- {
- $this->alias = $this->name;
- }
-
- $this->alias = JApplication::stringURLSafe($this->alias);
-
- if (trim(str_replace('-', '', $this->alias)) == '')
- {
- $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
- }
-
- return $this->alias;
+ }
+
+ /**
+ * Generate a valid alias from title / date.
+ * Remains public to be able to check for duplicated alias before saving
+ *
+ * @return string
+ */
+ public function generateAlias()
+ {
+ if (empty($this->alias))
+ {
+ $this->alias = $this->name;
+ }
+
+ $this->alias = JApplication::stringURLSafe($this->alias);
+
+ if (trim(str_replace('-', '', $this->alias)) == '')
+ {
+ $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
+ }
+
+ return $this->alias;
}
}
diff --git a/admin/tables/series.php b/admin/tables/series.php
index c7cd2e5f..329796f0 100644
--- a/admin/tables/series.php
+++ b/admin/tables/series.php
@@ -264,7 +264,7 @@ class SermondistributorTableSeries extends JTable
}
}
// check if there are any view values remaining
- if (count($_result))
+ if (count( (array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@@ -322,29 +322,29 @@ class SermondistributorTableSeries extends JTable
$asset->loadByName('com_sermondistributor');
return $asset->id;
- }
-
- /**
- * Generate a valid alias from title / date.
- * Remains public to be able to check for duplicated alias before saving
- *
- * @return string
- */
- public function generateAlias()
- {
- if (empty($this->alias))
- {
- $this->alias = $this->name;
- }
-
- $this->alias = JApplication::stringURLSafe($this->alias);
-
- if (trim(str_replace('-', '', $this->alias)) == '')
- {
- $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
- }
-
- return $this->alias;
+ }
+
+ /**
+ * Generate a valid alias from title / date.
+ * Remains public to be able to check for duplicated alias before saving
+ *
+ * @return string
+ */
+ public function generateAlias()
+ {
+ if (empty($this->alias))
+ {
+ $this->alias = $this->name;
+ }
+
+ $this->alias = JApplication::stringURLSafe($this->alias);
+
+ if (trim(str_replace('-', '', $this->alias)) == '')
+ {
+ $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
+ }
+
+ return $this->alias;
}
}
diff --git a/admin/tables/sermon.php b/admin/tables/sermon.php
index ec6a4283..3de833ad 100644
--- a/admin/tables/sermon.php
+++ b/admin/tables/sermon.php
@@ -267,7 +267,7 @@ class SermondistributorTableSermon extends JTable
}
}
// check if there are any view values remaining
- if (count($_result))
+ if (count( (array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@@ -325,29 +325,29 @@ class SermondistributorTableSermon extends JTable
$asset->loadByName('com_sermondistributor');
return $asset->id;
- }
-
- /**
- * Generate a valid alias from title / date.
- * Remains public to be able to check for duplicated alias before saving
- *
- * @return string
- */
- public function generateAlias()
- {
- if (empty($this->alias))
- {
- $this->alias = $this->name;
- }
-
- $this->alias = JApplication::stringURLSafe($this->alias);
-
- if (trim(str_replace('-', '', $this->alias)) == '')
- {
- $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
- }
-
- return $this->alias;
+ }
+
+ /**
+ * Generate a valid alias from title / date.
+ * Remains public to be able to check for duplicated alias before saving
+ *
+ * @return string
+ */
+ public function generateAlias()
+ {
+ if (empty($this->alias))
+ {
+ $this->alias = $this->name;
+ }
+
+ $this->alias = JApplication::stringURLSafe($this->alias);
+
+ if (trim(str_replace('-', '', $this->alias)) == '')
+ {
+ $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
+ }
+
+ return $this->alias;
}
}
diff --git a/admin/tables/statistic.php b/admin/tables/statistic.php
index b1f49b3c..57fe35bf 100644
--- a/admin/tables/statistic.php
+++ b/admin/tables/statistic.php
@@ -264,7 +264,7 @@ class SermondistributorTableStatistic extends JTable
}
}
// check if there are any view values remaining
- if (count($_result))
+ if (count( (array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@@ -322,29 +322,16 @@ class SermondistributorTableStatistic extends JTable
$asset->loadByName('com_sermondistributor');
return $asset->id;
- }
-
- /**
- * Generate a valid alias from title / date.
- * Remains public to be able to check for duplicated alias before saving
- *
- * @return string
- */
- public function generateAlias()
- {
- if (empty($this->alias))
- {
- $this->alias = $this->name;
- }
-
- $this->alias = JApplication::stringURLSafe($this->alias);
-
- if (trim(str_replace('-', '', $this->alias)) == '')
- {
- $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
- }
-
- return $this->alias;
+ }
+
+ /**
+ * This view does not actually have an alias
+ *
+ * @return bool
+ */
+ public function generateAlias()
+ {
+ return false;
}
}
diff --git a/sermondistributor.xml b/sermondistributor.xml
index 0bd00dd6..e7936c84 100644
--- a/sermondistributor.xml
+++ b/sermondistributor.xml
@@ -1,7 +1,7 @@
COM_SERMONDISTRIBUTOR
- 19th March, 2018
+ 4th May, 2018Llewellyn van der Merwejoomla@vdm.iohttps://www.vdm.io/
diff --git a/site/controllers/api.php b/site/controllers/api.php
index 146b8b69..d2fd8a33 100644
--- a/site/controllers/api.php
+++ b/site/controllers/api.php
@@ -125,7 +125,19 @@ class SermondistributorControllerApi extends JControllerForm
$model->setExternalUpdate();
} while (SermondistributorHelper::$updateWatch == 1); // only do one round
// run the workers
- SermondistributorHelper::runWorker('theQueue', 2);
+ if (SermondistributorHelper::runWorker('theQueue', 2))
+ {
+ // not success
+ echo 1;
+ // clear session
+ JFactory::getApplication()->getSession()->destroy();
+ jexit();
+ }
+ // not success
+ echo 0;
+ // clear session
+ JFactory::getApplication()->getSession()->destroy();
+ jexit();
}
protected function getApiUser()
diff --git a/site/helpers/sermondistributor.php b/site/helpers/sermondistributor.php
index 323f0a0c..80c652df 100644
--- a/site/helpers/sermondistributor.php
+++ b/site/helpers/sermondistributor.php
@@ -50,7 +50,7 @@ abstract class SermondistributorHelper
* The external source links auto
**/
protected static $links_externalsource_auto;
-
+
/**
* The external source links manual
**/
@@ -60,7 +60,7 @@ abstract class SermondistributorHelper
* The external source selection auto
**/
protected static $select_externalsource_auto;
-
+
/**
* The external source selection manual
**/
@@ -361,17 +361,17 @@ abstract class SermondistributorHelper
}
/**
- * Get the file path or url
- *
- * @param string $type The (url/path) type to return
- * @param string $target The Params Target name (if set)
- * @param string $fileType The kind of filename to generate (if not set no file name is generated)
- * @param string $key The key to adjust the filename (if not set ignored)
- * @param string $default The default path if not set in Params (fallback path)
- * @param bool $createIfNotSet The switch to create the folder if not found
+ * Get the file path or url
+ *
+ * @param string $type The (url/path) type to return
+ * @param string $target The Params Target name (if set)
+ * @param string $fileType The kind of filename to generate (if not set no file name is generated)
+ * @param string $key The key to adjust the filename (if not set ignored)
+ * @param string $default The default path if not set in Params (fallback path)
+ * @param bool $createIfNotSet The switch to create the folder if not found
+ *
+ * @return string On success the path or url is returned based on the type requested
*
- * @return string On success the path or url is returned based on the type requested
- *
*/
public static function getFilePath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = JPATH_SITE . '/images/', $createIfNotSet = true)
{
@@ -432,13 +432,13 @@ abstract class SermondistributorHelper
/**
- * Write a file to the server
- *
- * @param string $path The path and file name where to safe the data
- * @param string $data The data to safe
+ * Write a file to the server
+ *
+ * @param string $path The path and file name where to safe the data
+ * @param string $data The data to safe
+ *
+ * @return bool true On success
*
- * @return bool true On success
- *
*/
public static function writeFile($path, $data)
{
@@ -549,7 +549,7 @@ abstract class SermondistributorHelper
}
return false;
}
-
+
public static function getExternalSourceLink($type, $return = 7, $get = false, $target = 'links')
{
// make sure all defaults are set
@@ -1692,7 +1692,7 @@ abstract class SermondistributorHelper
}
return 'application/octet-stream';
}
-
+
protected static function getDownloadFileName(&$sermon, $file, $type)
{
// first get file name and file type
@@ -1898,7 +1898,7 @@ abstract class SermondistributorHelper
}
return false;
}
-
+
public static function getUpdateError($id, $fileKey = null)
{
// get update error from file
@@ -1922,7 +1922,7 @@ abstract class SermondistributorHelper
}
return JText::_('COM_SERMONDISTRIBUTOR_UNKNOWN_ERROR_HAS_OCCURRED');
}
-
+
protected static function setUpdateError($id, $errorArray)
{
if (self::checkArray($errorArray) && $id > 0)
@@ -2025,6 +2025,23 @@ abstract class SermondistributorHelper
*/
protected static $curlErrorLoaded = false;
+ /**
+ * check if a worker has more work
+ *
+ * @param string $function The function to target to perform the task
+ *
+ * @return bool
+ *
+ */
+ public static function hasWork(&$function)
+ {
+ if (isset(self::$worker[$function]) && self::checkArray(self::$worker[$function]))
+ {
+ return count( (array) self::$worker[$function]);
+ }
+ return false;
+ }
+
/**
* Set a worker url
*
@@ -2327,8 +2344,8 @@ abstract class SermondistributorHelper
{
self::$locker[$key] = new FOFEncryptAes($key, 128);
}
- // convert array to string
- if (self::checkArray($string))
+ // convert array or object to string
+ if (self::checkArray($string) || self::checkObject($string))
{
$string = serialize($string);
}
@@ -2598,8 +2615,15 @@ abstract class SermondistributorHelper
return $open;
}
- public static function jsonToString($value, $sperator = ", ", $table = null)
+ public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
{
+ // do some table foot work
+ $external = false;
+ if (strpos($table, '#__') !== false)
+ {
+ $external = true;
+ $table = str_replace('#__', '', $table);
+ }
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
@@ -2612,9 +2636,19 @@ abstract class SermondistributorHelper
$names = array();
foreach ($result as $val)
{
- if ($name = self::getVar($table, $val, 'id', 'name'))
+ if ($external)
{
- $names[] = $name;
+ if ($name = self::getVar(null, $val, $id, $name, '=', $table))
+ {
+ $names[] = $name;
+ }
+ }
+ else
+ {
+ if ($name = self::getVar($table, $val, $id, $name))
+ {
+ $names[] = $name;
+ }
}
}
if (self::checkArray($names))
@@ -2926,28 +2960,141 @@ abstract class SermondistributorHelper
return JAccess::getAssetRules(0);
}
+ /**
+ * xmlAppend
+ *
+ * @param SimpleXMLElement $xml The XML element reference in which to inject a comment
+ * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement
+ *
+ * @return null
+ *
+ */
+ public static function xmlAppend(&$xml, $node)
+ {
+ if (!$node)
+ {
+ // element was not returned
+ return;
+ }
+ switch (get_class($node))
+ {
+ case 'stdClass':
+ if (property_exists($node, 'comment'))
+ {
+ self::xmlComment($xml, $node->comment);
+ }
+ if (property_exists($node, 'fieldXML'))
+ {
+ self::xmlAppend($xml, $node->fieldXML);
+ }
+ break;
+ case 'SimpleXMLElement':
+ $domXML = dom_import_simplexml($xml);
+ $domNode = dom_import_simplexml($node);
+ $domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
+ $xml = simplexml_import_dom($domXML);
+ break;
+ }
+ }
+
+ /**
+ * xmlComment
+ *
+ * @param SimpleXMLElement $xml The XML element reference in which to inject a comment
+ * @param string $comment The comment to inject
+ *
+ * @return null
+ *
+ */
+ public static function xmlComment(&$xml, $comment)
+ {
+ $domXML = dom_import_simplexml($xml);
+ $domComment = new DOMComment($comment);
+ $nodeTarget = $domXML->ownerDocument->importNode($domComment, true);
+ $domXML->appendChild($nodeTarget);
+ $xml = simplexml_import_dom($domXML);
+ }
+
+ /**
+ * xmlAddAttributes
+ *
+ * @param SimpleXMLElement $xml The XML element reference in which to inject a comment
+ * @param array $attributes The attributes to apply to the XML element
+ *
+ * @return null
+ *
+ */
+ public static function xmlAddAttributes(&$xml, $attributes = array())
+ {
+ foreach ($attributes as $key => $value)
+ {
+ $xml->addAttribute($key, $value);
+ }
+ }
+
+ /**
+ * xmlAddOptions
+ *
+ * @param SimpleXMLElement $xml The XML element reference in which to inject a comment
+ * @param array $options The options to apply to the XML element
+ *
+ * @return void
+ *
+ */
+ public static function xmlAddOptions(&$xml, $options = array())
+ {
+ foreach ($options as $key => $value)
+ {
+ $addOption = $xml->addChild('option');
+ $addOption->addAttribute('value', $key);
+ $addOption[] = $value;
+ }
+ }
+
+ /**
+ * Render Bool Button
+ *
+ * @param array $args All the args for the button
+ * 0) name
+ * 1) additional (options class) // not used at this time
+ * 2) default
+ * 3) yes (name)
+ * 4) no (name)
+ *
+ * @return string The input html of the button
+ *
+ */
public static function renderBoolButton()
{
$args = func_get_args();
+ // check if there is additional button class
+ $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time
+ // start the xml
+ $buttonXML = new SimpleXMLElement('');
+ // button attributes
+ $buttonAttributes = array(
+ 'type' => 'radio',
+ 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button',
+ 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway
+ 'class' => 'btn-group',
+ 'filter' => 'INT',
+ 'default' => isset($args[2]) ? (int) $args[2] : 0);
+ // 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');
- // setup the properties
- $name = self::htmlEscape($args[0]);
- $additional = isset($args[1]) ? (string) $args[1] : '';
- $value = $args[2];
- $yes = isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES';
- $no = isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO';
-
- // prepare the xml
- $element = new SimpleXMLElement('');
-
// run
- $button->setup($element, $value);
+ $button->setup($buttonXML, $buttonAttributes['default']);
return $button->input;
-
}
/**
@@ -3052,6 +3199,19 @@ abstract class SermondistributorHelper
return false;
}
+ /**
+ * Get a variable
+ *
+ * @param string $table The table from which to get the variable
+ * @param string $where The value where
+ * @param string $whereString The target/field string where/name
+ * @param string $what The return field
+ * @param string $operator The operator between $whereString/field and $where/value
+ * @param string $main The component in which the table is found
+ *
+ * @return mix string/int/float
+ *
+ */
public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'sermondistributor')
{
if(!$where)
@@ -3092,6 +3252,20 @@ abstract class SermondistributorHelper
return false;
}
+ /**
+ * Get array of variables
+ *
+ * @param string $table The table from which to get the variables
+ * @param string $where The value where
+ * @param string $whereString The target/field string where/name
+ * @param string $what The return field
+ * @param string $operator The operator between $whereString/field and $where/value
+ * @param string $main The component in which the table is found
+ * @param bool $unique The switch to return a unique array
+ *
+ * @return array
+ *
+ */
public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'sermondistributor', $unique = true)
{
if(!$where)
diff --git a/site/language/en-GB/en-GB.com_sermondistributor.ini b/site/language/en-GB/en-GB.com_sermondistributor.ini
index 82a8f1ac..10abeedf 100644
--- a/site/language/en-GB/en-GB.com_sermondistributor.ini
+++ b/site/language/en-GB/en-GB.com_sermondistributor.ini
@@ -105,4 +105,4 @@ JTOOLBAR_CLOSE="Close"
JTOOLBAR_HELP="Help"
JTOOLBAR_SAVE="Save & Close"
JTOOLBAR_SAVE_AND_NEW="Save & New"
-JTOOLBAR_SAVE_AS_COPY="Save as Copy"
+JTOOLBAR_SAVE_AS_COPY="Save as Copy"
\ No newline at end of file
diff --git a/site/language/en-GB/en-GB.com_sermondistributor.sys.ini b/site/language/en-GB/en-GB.com_sermondistributor.sys.ini
index bb217a49..8bf2d4bf 100644
--- a/site/language/en-GB/en-GB.com_sermondistributor.sys.ini
+++ b/site/language/en-GB/en-GB.com_sermondistributor.sys.ini
@@ -1,3 +1,3 @@
COM_SERMONDISTRIBUTOR="Sermon Distributor"
COM_SERMONDISTRIBUTOR_NOT_FOUND_OR_ACCESS_DENIED="Not found or access denied!"
-COM_SERMONDISTRIBUTOR_NO_ACCESS_GRANTED="No Access Granted!"
+COM_SERMONDISTRIBUTOR_NO_ACCESS_GRANTED="No Access Granted!"
\ No newline at end of file
diff --git a/site/views/api/view.html.php b/site/views/api/view.html.php
index 05a5c9ef..8a83f5b4 100644
--- a/site/views/api/view.html.php
+++ b/site/views/api/view.html.php
@@ -44,6 +44,8 @@ class SermondistributorViewApi extends JViewLegacy
$this->user = JFactory::getUser();
// Initialise variables.
$this->items = $this->get('Items');
+ // do not load the display
+ jexit('Access Denied!');
// Set the toolbar
$this->addToolBar();