update the API return values
This commit is contained in:
parent
1b544be971
commit
9180004ba3
10
README.md
10
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**,
|
||||
|
@ -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**,
|
||||
|
@ -361,16 +361,16 @@ abstract class SermondistributorHelper
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file path or url
|
||||
* 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
|
||||
* @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,12 +432,12 @@ abstract class SermondistributorHelper
|
||||
|
||||
|
||||
/**
|
||||
* Write a file to the server
|
||||
* 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
|
||||
* @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)
|
||||
@ -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('<field/>');
|
||||
// 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('<field name="'.$name.'" type="radio" class="btn-group"><option '.$additional.' value="0">'.$no.'</option><option '.$additional.' value="1">'.$yes.'</option></field>');
|
||||
|
||||
// run
|
||||
$button->setup($element, $value);
|
||||
$button->setup($buttonXML, $buttonAttributes['default']);
|
||||
|
||||
return $button->input;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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.
|
||||
@ -185,6 +179,12 @@ class SermondistributorModelExternal_source extends JModelAdmin
|
||||
$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))
|
||||
{
|
||||
$item->tags = new JHelperTags;
|
||||
@ -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.
|
||||
*
|
||||
|
@ -40,106 +40,6 @@ 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[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
|
||||
href="index.php?option=com_sermondistributor&view=&layout=edit'.$ref.'" >
|
||||
<span class="icon-new icon-white"></span></a>';
|
||||
}
|
||||
// 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[] = '<a id="'.$buttonName.'Edit" class="btn btn-small hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_EDIT_S', $buttonNamee).'" style="display: none; padding: 4px 4px 4px 7px;" href="#" >
|
||||
<span class="icon-edit"></span></a>';
|
||||
// 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 '<div class="input-append">' .$html . implode('',$button).'</div>';
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
|
@ -40,106 +40,6 @@ 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[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
|
||||
href="index.php?option=com_sermondistributor&view=article&layout=edit'.$ref.'" >
|
||||
<span class="icon-new icon-white"></span></a>';
|
||||
}
|
||||
// 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[] = '<a id="'.$buttonName.'Edit" class="btn btn-small hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_EDIT_S', $buttonNamee).'" style="display: none; padding: 4px 4px 4px 7px;" href="#" >
|
||||
<span class="icon-edit"></span></a>';
|
||||
// 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 '<div class="input-append">' .$html . implode('',$button).'</div>';
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
|
@ -40,6 +40,7 @@ class JFormFieldExternalsource extends JFormFieldList
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'externalsource';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,106 +40,6 @@ 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[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
|
||||
href="index.php?option=com_sermondistributor&view=&layout=edit'.$ref.'" >
|
||||
<span class="icon-new icon-white"></span></a>';
|
||||
}
|
||||
// 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[] = '<a id="'.$buttonName.'Edit" class="btn btn-small hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_EDIT_S', $buttonNamee).'" style="display: none; padding: 4px 4px 4px 7px;" href="#" >
|
||||
<span class="icon-edit"></span></a>';
|
||||
// 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 '<div class="input-append">' .$html . implode('',$button).'</div>';
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
|
@ -40,106 +40,6 @@ 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[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
|
||||
href="index.php?option=com_sermondistributor&view=&layout=edit'.$ref.'" >
|
||||
<span class="icon-new icon-white"></span></a>';
|
||||
}
|
||||
// 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[] = '<a id="'.$buttonName.'Edit" class="btn btn-small hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_EDIT_S', $buttonNamee).'" style="display: none; padding: 4px 4px 4px 7px;" href="#" >
|
||||
<span class="icon-edit"></span></a>';
|
||||
// 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 '<div class="input-append">' .$html . implode('',$button).'</div>';
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
|
@ -40,106 +40,6 @@ 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[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
|
||||
href="index.php?option=com_sermondistributor&view=preacher&layout=edit'.$ref.'" >
|
||||
<span class="icon-new icon-white"></span></a>';
|
||||
}
|
||||
// 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[] = '<a id="'.$buttonName.'Edit" class="btn btn-small hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_EDIT_S', $buttonNamee).'" style="display: none; padding: 4px 4px 4px 7px;" href="#" >
|
||||
<span class="icon-edit"></span></a>';
|
||||
// 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 '<div class="input-append">' .$html . implode('',$button).'</div>';
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
|
@ -40,106 +40,6 @@ 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[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
|
||||
href="index.php?option=com_sermondistributor&view=series&layout=edit'.$ref.'" >
|
||||
<span class="icon-new icon-white"></span></a>';
|
||||
}
|
||||
// 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[] = '<a id="'.$buttonName.'Edit" class="btn btn-small hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_EDIT_S', $buttonNamee).'" style="display: none; padding: 4px 4px 4px 7px;" href="#" >
|
||||
<span class="icon-edit"></span></a>';
|
||||
// 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 '<div class="input-append">' .$html . implode('',$button).'</div>';
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
|
@ -40,6 +40,7 @@ class JFormFieldSermon extends JFormFieldList
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'sermon';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,106 +40,6 @@ 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[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
|
||||
href="index.php?option=com_sermondistributor&view=&layout=edit'.$ref.'" >
|
||||
<span class="icon-new icon-white"></span></a>';
|
||||
}
|
||||
// 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[] = '<a id="'.$buttonName.'Edit" class="btn btn-small hasTooltip" title="'.JText::sprintf('COM_SERMONDISTRIBUTOR_EDIT_S', $buttonNamee).'" style="display: none; padding: 4px 4px 4px 7px;" href="#" >
|
||||
<span class="icon-edit"></span></a>';
|
||||
// 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 '<div class="input-append">' .$html . implode('',$button).'</div>';
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
|
@ -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"
|
||||
/>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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);
|
||||
@ -325,26 +325,13 @@ class SermondistributorTableExternal_source extends JTable
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a valid alias from title / date.
|
||||
* Remains public to be able to check for duplicated alias before saving
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
* This view does not actually have an alias
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
@ -325,23 +325,23 @@ class SermondistributorTableHelp_document extends JTable
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a valid alias from title / date.
|
||||
* Remains public to be able to check for duplicated alias before saving
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
* 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 = $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");
|
||||
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
|
||||
return $this->alias;
|
||||
|
@ -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);
|
||||
@ -325,26 +325,13 @@ class SermondistributorTableLocal_listing extends JTable
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a valid alias from title / date.
|
||||
* Remains public to be able to check for duplicated alias before saving
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
* This view does not actually have an alias
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
@ -325,11 +325,11 @@ class SermondistributorTablePreacher extends JTable
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a valid alias from title / date.
|
||||
* Remains public to be able to check for duplicated alias before saving
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
* 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))
|
||||
@ -341,7 +341,7 @@ class SermondistributorTablePreacher extends JTable
|
||||
|
||||
if (trim(str_replace('-', '', $this->alias)) == '')
|
||||
{
|
||||
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
|
||||
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
|
||||
return $this->alias;
|
||||
|
@ -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);
|
||||
@ -325,11 +325,11 @@ class SermondistributorTableSeries extends JTable
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a valid alias from title / date.
|
||||
* Remains public to be able to check for duplicated alias before saving
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
* 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))
|
||||
@ -341,7 +341,7 @@ class SermondistributorTableSeries extends JTable
|
||||
|
||||
if (trim(str_replace('-', '', $this->alias)) == '')
|
||||
{
|
||||
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
|
||||
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
|
||||
return $this->alias;
|
||||
|
@ -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);
|
||||
@ -328,11 +328,11 @@ class SermondistributorTableSermon extends JTable
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a valid alias from title / date.
|
||||
* Remains public to be able to check for duplicated alias before saving
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
* 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))
|
||||
@ -344,7 +344,7 @@ class SermondistributorTableSermon extends JTable
|
||||
|
||||
if (trim(str_replace('-', '', $this->alias)) == '')
|
||||
{
|
||||
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
|
||||
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
|
||||
return $this->alias;
|
||||
|
@ -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);
|
||||
@ -325,26 +325,13 @@ class SermondistributorTableStatistic extends JTable
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a valid alias from title / date.
|
||||
* Remains public to be able to check for duplicated alias before saving
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
* This view does not actually have an alias
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="3.2" method="upgrade">
|
||||
<name>COM_SERMONDISTRIBUTOR</name>
|
||||
<creationDate>19th March, 2018</creationDate>
|
||||
<creationDate>4th May, 2018</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>joomla@vdm.io</authorEmail>
|
||||
<authorUrl>https://www.vdm.io/</authorUrl>
|
||||
|
@ -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()
|
||||
|
@ -361,16 +361,16 @@ abstract class SermondistributorHelper
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file path or url
|
||||
* 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
|
||||
* @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,12 +432,12 @@ abstract class SermondistributorHelper
|
||||
|
||||
|
||||
/**
|
||||
* Write a file to the server
|
||||
* 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
|
||||
* @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)
|
||||
@ -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('<field/>');
|
||||
// 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('<field name="'.$name.'" type="radio" class="btn-group"><option '.$additional.' value="0">'.$no.'</option><option '.$additional.' value="1">'.$yes.'</option></field>');
|
||||
|
||||
// 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)
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user