';
+ . '
';
}
/**
* Load the JavaScript behavior.
*
- * @param string $group The pane identifier.
- * @param array $params Array of options.
+ * @param string $group The pane identifier.
+ * @param array $params Array of options.
*
* @return void
*
@@ -91,22 +91,22 @@ protected static function loadBehavior($group, $params = array())
$display = (isset($params['startOffset']) && isset($params['startTransition']) && $params['startTransition'])
? (int) $params['startOffset'] : null;
- $show = (isset($params['startOffset']) && !(isset($params['startTransition']) && $params['startTransition']))
+ $show = (isset($params['startOffset']) && !(isset($params['startTransition']) && $params['startTransition']))
? (int) $params['startOffset'] : null;
- $opt['onActive'] = "\\function(toggler, i) {toggler.addClass('pane-toggler-down');" .
+ $opt['onActive'] = "\\function(toggler, i) {toggler.addClass('pane-toggler-down');" .
"toggler.removeClass('pane-toggler');i.addClass('pane-down');i.removeClass('pane-hide');Cookie.write('jpanesliders_"
. $group . "',$$('div#" . $group . ".pane-sliders > .panel > h3').indexOf(toggler));}";
$opt['onBackground'] = "\\function(toggler, i) {toggler.addClass('pane-toggler');" .
"toggler.removeClass('pane-toggler-down');i.addClass('pane-hide');i.removeClass('pane-down');if($$('div#"
. $group . ".pane-sliders > .panel > h3').length==$$('div#" . $group
. ".pane-sliders > .panel > h3.pane-toggler').length) Cookie.write('jpanesliders_" . $group . "',-1);}";
- $opt['duration'] = (isset($params['duration'])) ? (int) $params['duration'] : 300;
- $opt['display'] = (isset($params['useCookie']) && $params['useCookie']) ? $input->cookie->get('jpanesliders_' . $group, $display, 'integer')
+ $opt['duration'] = (isset($params['duration'])) ? (int) $params['duration'] : 300;
+ $opt['display'] = (isset($params['useCookie']) && $params['useCookie']) ? $input->cookie->get('jpanesliders_' . $group, $display, 'integer')
: $display;
- $opt['show'] = (isset($params['useCookie']) && $params['useCookie']) ? $input->cookie->get('jpanesliders_' . $group, $show, 'integer') : $show;
- $opt['opacity'] = (isset($params['opacityTransition']) && ($params['opacityTransition'])) ? 'true' : 'false';
- $opt['alwaysHide'] = (isset($params['allowAllClose']) && (!$params['allowAllClose'])) ? 'false' : 'true';
+ $opt['show'] = (isset($params['useCookie']) && $params['useCookie']) ? $input->cookie->get('jpanesliders_' . $group, $show, 'integer') : $show;
+ $opt['opacity'] = (isset($params['opacityTransition']) && ($params['opacityTransition'])) ? 'true' : 'false';
+ $opt['alwaysHide'] = (isset($params['allowAllClose']) && (!$params['allowAllClose'])) ? 'false' : 'true';
$options = JHtml::getJSObject($opt);
diff --git a/libraries/cms/html/sortablelist.php b/libraries/cms/html/sortablelist.php
index 0f3b0ba095c1a..66e879c1db8a9 100644
--- a/libraries/cms/html/sortablelist.php
+++ b/libraries/cms/html/sortablelist.php
@@ -27,12 +27,12 @@ abstract class JHtmlSortablelist
/**
* Method to load the Sortable script and make table sortable
*
- * @param string $tableId DOM id of the table
- * @param string $formId DOM id of the form
- * @param string $sortDir Sort direction
- * @param string $saveOrderingUrl Save ordering url, ajax-load after an item dropped
- * @param boolean $proceedSaveOrderButton Set whether a save order button is displayed
- * @param boolean $nestedList Set whether the list is a nested list
+ * @param string $tableId DOM id of the table
+ * @param string $formId DOM id of the form
+ * @param string $sortDir Sort direction
+ * @param string $saveOrderingUrl Save ordering url, ajax-load after an item dropped
+ * @param boolean $proceedSaveOrderButton Set whether a save order button is displayed
+ * @param boolean $nestedList Set whether the list is a nested list
*
* @return void
*
@@ -69,6 +69,7 @@ public static function sortable($tableId, $formId, $sortDir = 'asc', $saveOrderi
// Set static array
static::$loaded[__METHOD__] = true;
+
return;
}
@@ -102,6 +103,7 @@ public static function _proceedSaveOrderButton()
});
})(jQuery);"
);
+
return;
}
}
diff --git a/libraries/cms/html/string.php b/libraries/cms/html/string.php
index 36f7a9b01f845..24ce7fa30e704 100644
--- a/libraries/cms/html/string.php
+++ b/libraries/cms/html/string.php
@@ -24,10 +24,10 @@ abstract class JHtmlString
* word, it will find the first space that is within the limit and
* truncate at that point. This method is UTF-8 safe.
*
- * @param string $text The text to truncate.
- * @param integer $length The maximum length of the text.
- * @param boolean $noSplit Don't split a word if that is where the cutoff occurs (default: true).
- * @param boolean $allowHtml Allow HTML tags in the output, and close any open tags (default: true).
+ * @param string $text The text to truncate.
+ * @param integer $length The maximum length of the text.
+ * @param boolean $noSplit Don't split a word if that is where the cutoff occurs (default: true).
+ * @param boolean $allowHtml Allow HTML tags in the output, and close any open tags (default: true).
*
* @return string The truncated text.
*
@@ -73,7 +73,7 @@ public static function truncate($text, $length = 0, $noSplit = true, $allowHtml
{
// Find the position of the last space within the allowed length.
$offset = JString::strrpos($tmp, ' ');
- $tmp = JString::substr($tmp, 0, $offset + 1);
+ $tmp = JString::substr($tmp, 0, $offset + 1);
// If there are no spaces and the string is longer than the maximum
// we need to just use the ellipsis. In that case we are done.
@@ -141,24 +141,24 @@ public static function truncate($text, $length = 0, $noSplit = true, $allowHtml
}
/**
- * Method to extend the truncate method to more complex situations
- *
- * The goal is to get the proper length plain text string with as much of
- * the html intact as possible with all tags properly closed.
- *
- * @param string $html The content of the introtext to be truncated
- * @param integer $maxLength The maximum number of characters to render
- * @param boolean $noSplit Don't split a word if that is where the cutoff occurs (default: true).
- *
- * @return string The truncated string. If the string is truncated an ellipsis
- * (...) will be appended.
- *
- * @note If a maximum length of 3 or less is selected and the text has more than
- * that number of characters an ellipsis will be displayed.
- * This method will not create valid HTML from malformed HTML.
- *
- * @since 3.1
- */
+ * Method to extend the truncate method to more complex situations
+ *
+ * The goal is to get the proper length plain text string with as much of
+ * the html intact as possible with all tags properly closed.
+ *
+ * @param string $html The content of the introtext to be truncated
+ * @param integer $maxLength The maximum number of characters to render
+ * @param boolean $noSplit Don't split a word if that is where the cutoff occurs (default: true).
+ *
+ * @return string The truncated string. If the string is truncated an ellipsis
+ * (...) will be appended.
+ *
+ * @note If a maximum length of 3 or less is selected and the text has more than
+ * that number of characters an ellipsis will be displayed.
+ * This method will not create valid HTML from malformed HTML.
+ *
+ * @since 3.1
+ */
public static function truncateComplex($html, $maxLength = 0, $noSplit = true)
{
// Start with some basic rules.
@@ -180,7 +180,7 @@ public static function truncateComplex($html, $maxLength = 0, $noSplit = true)
if ($maxLength == 1 && substr($html, 0, 1) == '<')
{
$endTagPos = strlen(strstr($html, '>', true));
- $tag = substr($html, 1, $endTagPos);
+ $tag = substr($html, 1, $endTagPos);
$l = $endTagPos + 1;
@@ -201,14 +201,14 @@ public static function truncateComplex($html, $maxLength = 0, $noSplit = true)
// It's all HTML, just return it.
if (strlen($ptString) == 0)
{
- return $html;
+ return $html;
}
// If the plain text is shorter than the max length the variable will not end in ...
// In that case we use the whole string.
if (substr($ptString, -3) != '...')
{
- return $html;
+ return $html;
}
// Regular truncate gives us the ellipsis but we want to go back for text and tags.
@@ -267,9 +267,9 @@ public static function truncateComplex($html, $maxLength = 0, $noSplit = true)
*
* Note that this method does not scan for HTML tags so will potentially break them.
*
- * @param string $text The text to abridge.
- * @param integer $length The maximum length of the text (default is 50).
- * @param integer $intro The maximum length of the intro text (default is 30).
+ * @param string $text The text to abridge.
+ * @param integer $length The maximum length of the text (default is 50).
+ * @param integer $intro The maximum length of the intro text (default is 30).
*
* @return string The abridged text.
*
diff --git a/libraries/cms/html/tabs.php b/libraries/cms/html/tabs.php
index 6d46fa915c2f4..d233cb3f85e4a 100644
--- a/libraries/cms/html/tabs.php
+++ b/libraries/cms/html/tabs.php
@@ -21,8 +21,8 @@ abstract class JHtmlTabs
/**
* Creates a panes and creates the JavaScript object for it.
*
- * @param string $group The pane identifier.
- * @param array $params An array of option.
+ * @param string $group The pane identifier.
+ * @param array $params An array of option.
*
* @return string
*
@@ -50,8 +50,8 @@ public static function end()
/**
* Begins the display of a new panel.
*
- * @param string $text Text to display.
- * @param string $id Identifier of the panel.
+ * @param string $text Text to display.
+ * @param string $id Identifier of the panel.
*
* @return string HTML to start a new panel
*
@@ -65,8 +65,8 @@ public static function panel($text, $id)
/**
* Load the JavaScript behavior.
*
- * @param string $group The pane identifier.
- * @param array $params Array of options.
+ * @param string $group The pane identifier.
+ * @param array $params Array of options.
*
* @return void
*
diff --git a/libraries/cms/html/tag.php b/libraries/cms/html/tag.php
index 8c4b2177d33c3..9354cc7814afb 100644
--- a/libraries/cms/html/tag.php
+++ b/libraries/cms/html/tag.php
@@ -29,7 +29,7 @@ abstract class JHtmlTag
/**
* Returns an array of tags.
*
- * @param array $config An array of configuration options. By default, only
+ * @param array $config An array of configuration options. By default, only
* published and unpublished categories are returned.
*
* @return array
@@ -43,8 +43,8 @@ public static function options($config = array('filter.published' => array(0, 1)
if (!isset(static::$items[$hash]))
{
$config = (array) $config;
- $db = JFactory::getDbo();
- $query = $db->getQuery(true)
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true)
->select('a.id, a.title, a.level')
->from('#__tags AS a')
->where('a.parent_id > 0');
@@ -90,8 +90,8 @@ public static function options($config = array('filter.published' => array(0, 1)
foreach ($items as &$item)
{
- $repeat = ($item->level - 1 >= 0) ? $item->level - 1 : 0;
- $item->title = str_repeat('- ', $repeat) . $item->title;
+ $repeat = ($item->level - 1 >= 0) ? $item->level - 1 : 0;
+ $item->title = str_repeat('- ', $repeat) . $item->title;
static::$items[$hash][] = JHtml::_('select.option', $item->id, $item->title);
}
}
@@ -102,7 +102,7 @@ public static function options($config = array('filter.published' => array(0, 1)
/**
* Returns an array of tags.
*
- * @param array $config An array of configuration options. By default, only published and unpublished tags are returned.
+ * @param array $config An array of configuration options. By default, only published and unpublished tags are returned.
*
* @return array Tag data
*
@@ -110,10 +110,10 @@ public static function options($config = array('filter.published' => array(0, 1)
*/
public static function tags($config = array('filter.published' => array(0, 1)))
{
- $hash = md5(serialize($config));
+ $hash = md5(serialize($config));
$config = (array) $config;
- $db = JFactory::getDbo();
- $query = $db->getQuery(true)
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true)
->select('a.id, a.title, a.level, a.parent_id')
->from('#__tags AS a')
->where('a.parent_id > 0');
@@ -142,24 +142,25 @@ public static function tags($config = array('filter.published' => array(0, 1)))
foreach ($items as &$item)
{
- $repeat = ($item->level - 1 >= 0) ? $item->level - 1 : 0;
- $item->title = str_repeat('- ', $repeat) . $item->title;
+ $repeat = ($item->level - 1 >= 0) ? $item->level - 1 : 0;
+ $item->title = str_repeat('- ', $repeat) . $item->title;
static::$items[$hash][] = JHtml::_('select.option', $item->id, $item->title);
}
+
return static::$items[$hash];
}
/**
* This is just a proxy for the formbehavior.ajaxchosen method
*
- * @param string $selector DOM id of the tag field
- * @param boolean $allowCustom Flag to allow custom values
+ * @param string $selector DOM id of the tag field
+ * @param boolean $allowCustom Flag to allow custom values
*
* @return void
*
* @since 3.1
*/
- public static function ajaxfield($selector='#jform_tags', $allowCustom = true)
+ public static function ajaxfield($selector = '#jform_tags', $allowCustom = true)
{
// Tags field ajax
$chosenAjaxSettings = new JRegistry(
diff --git a/libraries/cms/html/tel.php b/libraries/cms/html/tel.php
index 5bca63690878e..0779cedd7d257 100644
--- a/libraries/cms/html/tel.php
+++ b/libraries/cms/html/tel.php
@@ -24,9 +24,9 @@ abstract class JHtmlTel
* By default, the ITU-T format will automatically be used.
* However, one of the allowed unit types may also be used instead.
*
- * @param integer $number The integers in a phone number with dot separated country code
+ * @param integer $number The integers in a phone number with dot separated country code
* ccc.nnnnnnn where ccc represents country code and nnn represents the local number.
- * @param string $displayplan The numbering plan used to display the numbers.
+ * @param string $displayplan The numbering plan used to display the numbers.
*
* @return string The formatted telephone number.
*
@@ -35,9 +35,9 @@ abstract class JHtmlTel
*/
public static function tel($number, $displayplan)
{
- $number = explode('.', $number);
+ $number = explode('.', $number);
$countrycode = $number[0];
- $number = $number[1];
+ $number = $number[1];
if ($displayplan == 'ITU-T' || $displayplan == 'International' || $displayplan == 'int' || $displayplan == 'missdn' || $displayplan == null)
{
@@ -65,7 +65,7 @@ public static function tel($number, $displayplan)
}
elseif ($displayplan == 'ARPA' || $displayplan == 'ENUM')
{
- $number = implode(str_split(strrev($number), 1), '.');
+ $number = implode(str_split(strrev($number), 1), '.');
$display[0] = '+';
$display[1] = $number;
$display[2] = '.';
diff --git a/libraries/cms/html/user.php b/libraries/cms/html/user.php
index 77c90c75c096b..dd0c02d9062fb 100644
--- a/libraries/cms/html/user.php
+++ b/libraries/cms/html/user.php
@@ -21,7 +21,7 @@ abstract class JHtmlUser
/**
* Displays a list of user groups.
*
- * @param boolean $includeSuperAdmin true to include super admin groups, false to exclude them
+ * @param boolean $includeSuperAdmin true to include super admin groups, false to exclude them
*
* @return array An array containing a list of user groups.
*
@@ -29,7 +29,7 @@ abstract class JHtmlUser
*/
public static function groups($includeSuperAdmin = false)
{
- $db = JFactory::getDbo();
+ $db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level')
->from($db->quoteName('#__usergroups') . ' AS a')
@@ -42,7 +42,7 @@ public static function groups($includeSuperAdmin = false)
for ($i = 0, $n = count($options); $i < $n; $i++)
{
$options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
- $groups[] = JHtml::_('select.option', $options[$i]->value, $options[$i]->text);
+ $groups[] = JHtml::_('select.option', $options[$i]->value, $options[$i]->text);
}
// Exclude super admin groups if requested
diff --git a/libraries/cms/installer/adapter/component.php b/libraries/cms/installer/adapter/component.php
index 00ad2137c0d74..b030a39940b41 100644
--- a/libraries/cms/installer/adapter/component.php
+++ b/libraries/cms/installer/adapter/component.php
@@ -88,7 +88,7 @@ class JInstallerAdapterComponent extends JAdapterInstance
/**
* Custom loadLanguage method
*
- * @param string $path The path language files are on.
+ * @param string $path The path language files are on.
*
* @return void
*
@@ -102,14 +102,14 @@ public function loadLanguage($path = null)
{
$this->parent
->setPath(
- 'source',
- ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) .
- '/components/' . $this->parent->extension->element
- );
+ 'source',
+ ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) .
+ '/components/' . $this->parent->extension->element
+ );
}
$this->manifest = $this->parent->getManifest();
- $name = strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd'));
+ $name = strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd'));
if (substr($name, 0, 4) == 'com_')
{
@@ -120,7 +120,7 @@ public function loadLanguage($path = null)
$extension = 'com_' . $name;
}
- $lang = JFactory::getLanguage();
+ $lang = JFactory::getLanguage();
$source = $path ? $path : ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/components/' . $extension;
if ($this->manifest->administration->files)
@@ -146,8 +146,8 @@ public function loadLanguage($path = null)
}
}
$lang->load($extension . '.sys', $source, null, false, false) || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, false)
- || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
- || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false);
+ || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
+ || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false);
}
/**
@@ -228,7 +228,8 @@ public function install()
// Upgrade manually set or update function available or update tag detected
if ($this->parent->isUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update'))
- || $updateElement)
+ || $updateElement
+ )
{
// Transfer control to the update function
return $this->update();
@@ -253,6 +254,7 @@ public function install()
JLog::WARNING, 'jerror'
);
}
+
return false;
}
}
@@ -393,7 +395,7 @@ public function install()
// If there is a manifest script, let's copy it.
if ($this->get('manifest_script'))
{
- $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
+ $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
$path['dest'] = $this->parent->getPath('extension_administrator') . '/' . $this->get('manifest_script');
if (!file_exists($path['dest']) || $this->parent->isOverwrite())
@@ -490,7 +492,7 @@ public function install()
// Clobber any possible pending updates
$update = JTable::getInstance('update');
- $uid = $update->find(array('element' => $this->get('element'), 'type' => 'component', 'client_id' => 1, 'folder' => ''));
+ $uid = $update->find(array('element' => $this->get('element'), 'type' => 'component', 'client_id' => 1, 'folder' => ''));
if ($uid)
{
@@ -522,11 +524,11 @@ public function install()
}
// Register the component container just under root in the assets table.
- $asset = JTable::getInstance('Asset');
- $asset->name = $row->element;
+ $asset = JTable::getInstance('Asset');
+ $asset->name = $row->element;
$asset->parent_id = 1;
- $asset->rules = '{}';
- $asset->title = $row->name;
+ $asset->rules = '{}';
+ $asset->title = $row->name;
$asset->setLocation(1, 'last-child');
if (!$asset->store())
@@ -643,12 +645,12 @@ public function update()
if ($old_manifest)
{
$this->oldAdminFiles = $old_manifest->administration->files;
- $this->oldFiles = $old_manifest->files;
+ $this->oldFiles = $old_manifest->files;
}
else
{
$this->oldAdminFiles = null;
- $this->oldFiles = null;
+ $this->oldFiles = null;
}
/**
@@ -806,7 +808,7 @@ public function update()
// If there is a manifest script, let's copy it.
if ($this->get('manifest_script'))
{
- $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
+ $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
$path['dest'] = $this->parent->getPath('extension_administrator') . '/' . $this->get('manifest_script');
if (!file_exists($path['dest']) || $this->parent->isOverwrite())
@@ -890,7 +892,7 @@ public function update()
// Clobber any possible pending updates
$update = JTable::getInstance('update');
- $uid = $update->find(array('element' => $this->get('element'), 'type' => 'component', 'client_id' => 1, 'folder' => ''));
+ $uid = $update->find(array('element' => $this->get('element'), 'type' => 'component', 'client_id' => 1, 'folder' => ''));
if ($uid)
{
@@ -906,17 +908,17 @@ public function update()
{
// Set the defaults
// There is no folder for components
- $row->folder = '';
- $row->enabled = 1;
+ $row->folder = '';
+ $row->enabled = 1;
$row->protected = 0;
- $row->access = 1;
+ $row->access = 1;
$row->client_id = 1;
- $row->params = $this->parent->getParams();
+ $row->params = $this->parent->getParams();
}
- $row->name = $this->get('name');
- $row->type = 'component';
- $row->element = $this->get('element');
+ $row->name = $this->get('name');
+ $row->type = 'component';
+ $row->element = $this->get('element');
$row->manifest_cache = $this->parent->generateManifestCache();
if (!$row->store())
@@ -960,7 +962,7 @@ public function update()
/**
* Custom uninstall method for components
*
- * @param integer $id The unique extension id of the component to uninstall
+ * @param integer $id The unique extension id of the component to uninstall
*
* @return mixed Return value for uninstall method in component uninstall file
*
@@ -968,8 +970,8 @@ public function update()
*/
public function uninstall($id)
{
- $db = $this->parent->getDbo();
- $row = null;
+ $db = $this->parent->getDbo();
+ $row = null;
$retval = true;
// First order of business will be to load the component object table from the database.
@@ -1154,7 +1156,7 @@ public function uninstall($id)
// Clobber any possible pending updates
$update = JTable::getInstance('update');
- $uid = $update->find(array('element' => $row->element, 'type' => 'component', 'client_id' => 1, 'folder' => ''));
+ $uid = $update->find(array('element' => $row->element, 'type' => 'component', 'client_id' => 1, 'folder' => ''));
if ($uid)
{
@@ -1208,8 +1210,8 @@ public function uninstall($id)
*/
protected function _buildAdminMenus()
{
- $db = $this->parent->getDbo();
- $table = JTable::getInstance('menu');
+ $db = $this->parent->getDbo();
+ $table = JTable::getInstance('menu');
$option = $this->get('element');
// If a component exists with this option in the table then we don't need to add menus
@@ -1262,18 +1264,18 @@ protected function _buildAdminMenus()
if ($menuElement)
{
- $data = array();
- $data['menutype'] = 'main';
- $data['client_id'] = 1;
- $data['title'] = (string) trim($menuElement);
- $data['alias'] = (string) $menuElement;
- $data['link'] = 'index.php?option=' . $option;
- $data['type'] = 'component';
- $data['published'] = 0;
- $data['parent_id'] = 1;
+ $data = array();
+ $data['menutype'] = 'main';
+ $data['client_id'] = 1;
+ $data['title'] = (string) trim($menuElement);
+ $data['alias'] = (string) $menuElement;
+ $data['link'] = 'index.php?option=' . $option;
+ $data['type'] = 'component';
+ $data['published'] = 0;
+ $data['parent_id'] = 1;
$data['component_id'] = $component_id;
- $data['img'] = ((string) $menuElement->attributes()->img) ? (string) $menuElement->attributes()->img : 'class:component';
- $data['home'] = 0;
+ $data['img'] = ((string) $menuElement->attributes()->img) ? (string) $menuElement->attributes()->img : 'class:component';
+ $data['home'] = 0;
try
{
@@ -1341,18 +1343,18 @@ protected function _buildAdminMenus()
// No menu element was specified, Let's make a generic menu item
else
{
- $data = array();
- $data['menutype'] = 'main';
- $data['client_id'] = 1;
- $data['title'] = $option;
- $data['alias'] = $option;
- $data['link'] = 'index.php?option=' . $option;
- $data['type'] = 'component';
- $data['published'] = 0;
- $data['parent_id'] = 1;
+ $data = array();
+ $data['menutype'] = 'main';
+ $data['client_id'] = 1;
+ $data['title'] = $option;
+ $data['alias'] = $option;
+ $data['link'] = 'index.php?option=' . $option;
+ $data['type'] = 'component';
+ $data['published'] = 0;
+ $data['parent_id'] = 1;
$data['component_id'] = $component_id;
- $data['img'] = 'class:component';
- $data['home'] = 0;
+ $data['img'] = 'class:component';
+ $data['home'] = 0;
try
{
@@ -1393,17 +1395,17 @@ protected function _buildAdminMenus()
foreach ($this->manifest->administration->submenu->menu as $child)
{
- $data = array();
- $data['menutype'] = 'main';
- $data['client_id'] = 1;
- $data['title'] = (string) trim($child);
- $data['alias'] = (string) $child;
- $data['type'] = 'component';
- $data['published'] = 0;
- $data['parent_id'] = $parent_id;
+ $data = array();
+ $data['menutype'] = 'main';
+ $data['client_id'] = 1;
+ $data['title'] = (string) trim($child);
+ $data['alias'] = (string) $child;
+ $data['type'] = 'component';
+ $data['published'] = 0;
+ $data['parent_id'] = $parent_id;
$data['component_id'] = $component_id;
- $data['img'] = ((string) $child->attributes()->img) ? (string) $child->attributes()->img : 'class:component';
- $data['home'] = 0;
+ $data['img'] = ((string) $child->attributes()->img) ? (string) $child->attributes()->img : 'class:component';
+ $data['home'] = 0;
// Set the sub menu link
if ((string) $child->attributes()->link)
@@ -1444,7 +1446,7 @@ protected function _buildAdminMenus()
$request[] = 'sub=' . $child->attributes()->sub;
}
- $qstring = (count($request)) ? '&' . implode('&', $request) : '';
+ $qstring = (count($request)) ? '&' . implode('&', $request) : '';
$data['link'] = 'index.php?option=' . $option . $qstring;
}
@@ -1478,7 +1480,7 @@ protected function _buildAdminMenus()
/**
* Method to remove admin menu references to a component
*
- * @param object &$row Component table object.
+ * @param object &$row Component table object.
*
* @return boolean True if successful.
*
@@ -1486,9 +1488,9 @@ protected function _buildAdminMenus()
*/
protected function _removeAdminMenus(&$row)
{
- $db = $this->parent->getDbo();
+ $db = $this->parent->getDbo();
$table = JTable::getInstance('menu');
- $id = $row->extension_id;
+ $id = $row->extension_id;
// Get the ids of the menu items
$query = $db->getQuery(true)
@@ -1518,6 +1520,7 @@ protected function _removeAdminMenus(&$row)
$table->rebuild();
}
+
return true;
}
@@ -1525,7 +1528,7 @@ protected function _removeAdminMenus(&$row)
* Custom rollback method
* - Roll back the component menu item
*
- * @param array $step Installation step to rollback.
+ * @param array $step Installation step to rollback.
*
* @return boolean True on success
*
@@ -1545,8 +1548,8 @@ protected function _rollback_menu($step)
*/
public function discover()
{
- $results = array();
- $site_components = JFolder::folders(JPATH_SITE . '/components');
+ $results = array();
+ $site_components = JFolder::folders(JPATH_SITE . '/components');
$admin_components = JFolder::folders(JPATH_ADMINISTRATOR . '/components');
foreach ($site_components as $component)
@@ -1556,7 +1559,7 @@ public function discover()
$manifest_details = JInstaller::parseXMLInstallFile(
JPATH_SITE . '/components/' . $component . '/' . str_replace('com_', '', $component) . '.xml'
);
- $extension = JTable::getInstance('extension');
+ $extension = JTable::getInstance('extension');
$extension->set('type', 'component');
$extension->set('client_id', 0);
$extension->set('element', $component);
@@ -1576,7 +1579,7 @@ public function discover()
$manifest_details = JInstaller::parseXMLInstallFile(
JPATH_ADMINISTRATOR . '/components/' . $component . '/' . str_replace('com_', '', $component) . '.xml'
);
- $extension = JTable::getInstance('extension');
+ $extension = JTable::getInstance('extension');
$extension->set('type', 'component');
$extension->set('client_id', 1);
$extension->set('element', $component);
@@ -1588,6 +1591,7 @@ public function discover()
$results[] = $extension;
}
}
+
return $results;
}
@@ -1601,20 +1605,20 @@ public function discover()
public function discover_install()
{
// Need to find to find where the XML file is since we don't store this normally
- $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
- $short_element = str_replace('com_', '', $this->parent->extension->element);
- $manifestPath = $client->path . '/components/' . $this->parent->extension->element . '/' . $short_element . '.xml';
+ $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
+ $short_element = str_replace('com_', '', $this->parent->extension->element);
+ $manifestPath = $client->path . '/components/' . $this->parent->extension->element . '/' . $short_element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
$this->parent->setPath('source', $client->path . '/components/' . $this->parent->extension->element);
$this->parent->setPath('extension_root', $this->parent->getPath('source'));
- $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
+ $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->state = 0;
- $this->parent->extension->name = $manifest_details['name'];
- $this->parent->extension->enabled = 1;
- $this->parent->extension->params = $this->parent->getParams();
+ $this->parent->extension->state = 0;
+ $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->enabled = 1;
+ $this->parent->extension->params = $this->parent->getParams();
try
{
@@ -1820,7 +1824,7 @@ public function discover_install()
// Clobber any possible pending updates
$update = JTable::getInstance('update');
- $uid = $update->find(array('element' => $this->get('element'), 'type' => 'component', 'client_id' => 1, 'folder' => ''));
+ $uid = $update->find(array('element' => $this->get('element'), 'type' => 'component', 'client_id' => 1, 'folder' => ''));
if ($uid)
{
@@ -1858,15 +1862,15 @@ public function discover_install()
public function refreshManifestCache()
{
// Need to find to find where the XML file is since we don't store this normally
- $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
- $short_element = str_replace('com_', '', $this->parent->extension->element);
- $manifestPath = $client->path . '/components/' . $this->parent->extension->element . '/' . $short_element . '.xml';
+ $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
+ $short_element = str_replace('com_', '', $this->parent->extension->element);
+ $manifestPath = $client->path . '/components/' . $this->parent->extension->element . '/' . $short_element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
- $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
+ $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->name = $manifest_details['name'];
try
{
diff --git a/libraries/cms/installer/adapter/file.php b/libraries/cms/installer/adapter/file.php
index 2ae816a62d9fb..84117cb2b6e2e 100644
--- a/libraries/cms/installer/adapter/file.php
+++ b/libraries/cms/installer/adapter/file.php
@@ -40,7 +40,7 @@ class JInstallerAdapterFile extends JAdapterInstance
/**
* Custom loadLanguage method
*
- * @param string $path The path on which to find language files.
+ * @param string $path The path on which to find language files.
*
* @return void
*
@@ -49,13 +49,13 @@ class JInstallerAdapterFile extends JAdapterInstance
public function loadLanguage($path)
{
$this->manifest = $this->parent->getManifest();
- $extension = 'files_' . str_replace('files_', '', strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd')));
- $lang = JFactory::getLanguage();
- $source = $path;
+ $extension = 'files_' . str_replace('files_', '', strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd')));
+ $lang = JFactory::getLanguage();
+ $source = $path;
$lang->load($extension . '.sys', $source, null, false, false)
- || $lang->load($extension . '.sys', JPATH_SITE, null, false, false)
- || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
- || $lang->load($extension . '.sys', JPATH_SITE, $lang->getDefault(), false, false);
+ || $lang->load($extension . '.sys', JPATH_SITE, null, false, false)
+ || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
+ || $lang->load($extension . '.sys', JPATH_SITE, $lang->getDefault(), false, false);
}
/**
@@ -82,7 +82,7 @@ public function install()
// Set element
$manifestPath = JPath::clean($this->parent->getPath('manifest'));
- $element = preg_replace('/\.xml/', '', basename($manifestPath));
+ $element = preg_replace('/\.xml/', '', basename($manifestPath));
$this->set('element', $element);
// Get the component description
@@ -133,7 +133,7 @@ public function install()
// If there is an manifest class file, lets load it; we'll copy it later (don't have dest yet)
$this->scriptElement = $this->manifest->scriptfile;
- $manifestScript = (string) $this->manifest->scriptfile;
+ $manifestScript = (string) $this->manifest->scriptfile;
if ($manifestScript)
{
@@ -254,7 +254,7 @@ public function install()
return false;
}
- $id = $db->loadResult();
+ $id = $db->loadResult();
$row = JTable::getInstance('extension');
if ($id)
@@ -365,8 +365,8 @@ public function install()
ob_end_clean();
// Lastly, we will copy the manifest file to its appropriate place.
- $manifest = array();
- $manifest['src'] = $this->parent->getPath('manifest');
+ $manifest = array();
+ $manifest['src'] = $this->parent->getPath('manifest');
$manifest['dest'] = JPATH_MANIFESTS . '/files/' . basename($this->parent->getPath('manifest'));
if (!$this->parent->copyFiles(array($manifest), true))
@@ -386,7 +386,7 @@ public function install()
JFolder::create($this->parent->getPath('extension_root'));
}
- $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
+ $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
$path['dest'] = $this->parent->getPath('extension_root') . '/' . $this->get('manifest_script');
if (!file_exists($path['dest']) || $this->parent->isOverwrite())
@@ -402,7 +402,7 @@ public function install()
}
// Clobber any possible pending updates
$update = JTable::getInstance('update');
- $uid = $update->find(
+ $uid = $update->find(
array('element' => $this->get('element'), 'type' => 'file', 'client_id' => (int) '', 'folder' => '')
);
@@ -453,7 +453,7 @@ public function update()
/**
* Custom uninstall method
*
- * @param string $id The id of the file to uninstall
+ * @param string $id The id of the file to uninstall
*
* @return boolean True on success
*
@@ -477,7 +477,7 @@ public function uninstall($id)
return false;
}
- $retval = true;
+ $retval = true;
$manifestFile = JPATH_MANIFESTS . '/files/' . $row->element . '.xml';
// Because files may not have their own folders we cannot use the standard method of finding an installation manifest
@@ -508,7 +508,7 @@ public function uninstall($id)
// If there is an manifest class file, let's load it
$this->scriptElement = $this->manifest->scriptfile;
- $manifestScript = (string) $this->manifest->scriptfile;
+ $manifestScript = (string) $this->manifest->scriptfile;
if ($manifestScript)
{
@@ -647,7 +647,7 @@ public function uninstall($id)
/**
* Function used to check if extension is already installed
*
- * @param string $extension The element name of the extension to install
+ * @param string $extension The element name of the extension to install
*
* @return boolean True if extension exists
*
@@ -698,11 +698,11 @@ protected function populateFilesAndFolderList()
{
// Initialise variable
$this->folderList = array();
- $this->fileList = array();
+ $this->fileList = array();
// Set root folder names
$packagePath = $this->parent->getPath('source');
- $jRootPath = JPath::clean(JPATH_ROOT);
+ $jRootPath = JPath::clean(JPATH_ROOT);
// Loop through all elements and get list of files and folders
foreach ($this->manifest->fileset->files as $eFiles)
@@ -753,7 +753,7 @@ protected function populateFilesAndFolderList()
// Loop through all filenames elements
foreach ($eFiles->children() as $eFileName)
{
- $path['src'] = $sourceFolder . '/' . $eFileName;
+ $path['src'] = $sourceFolder . '/' . $eFileName;
$path['dest'] = $targetFolder . '/' . $eFileName;
$path['type'] = 'file';
@@ -773,7 +773,7 @@ protected function populateFilesAndFolderList()
foreach ($files as $file)
{
- $path['src'] = $sourceFolder . '/' . $file;
+ $path['src'] = $sourceFolder . '/' . $file;
$path['dest'] = $targetFolder . '/' . $file;
array_push($this->fileList, $path);
@@ -793,13 +793,13 @@ protected function populateFilesAndFolderList()
public function refreshManifestCache()
{
// Need to find to find where the XML file is since we don't store this normally
- $manifestPath = JPATH_MANIFESTS . '/files/' . $this->parent->extension->element . '.xml';
+ $manifestPath = JPATH_MANIFESTS . '/files/' . $this->parent->extension->element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
- $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
+ $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->name = $manifest_details['name'];
try
{
diff --git a/libraries/cms/installer/adapter/language.php b/libraries/cms/installer/adapter/language.php
index b47514083c2ef..00c048f7034c6 100644
--- a/libraries/cms/installer/adapter/language.php
+++ b/libraries/cms/installer/adapter/language.php
@@ -48,9 +48,9 @@ public function install()
{
$this->parent
->setPath(
- 'source',
- ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/language/' . $this->parent->extension->element
- );
+ 'source',
+ ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/language/' . $this->parent->extension->element
+ );
}
$this->manifest = $this->parent->getManifest();
@@ -68,17 +68,17 @@ public function install()
}
$basePath = $client->path;
$clientId = $client->id;
- $element = $this->manifest->files;
+ $element = $this->manifest->files;
return $this->_install($cname, $basePath, $clientId, $element);
}
else
{
// No client attribute was found so we assume the site as the client
- $cname = 'site';
+ $cname = 'site';
$basePath = JPATH_SITE;
$clientId = 0;
- $element = $this->manifest->files;
+ $element = $this->manifest->files;
return $this->_install($cname, $basePath, $clientId, $element);
}
@@ -87,10 +87,10 @@ public function install()
/**
* Install function that is designed to handle individual clients
*
- * @param string $cname Cname @todo: not used
- * @param string $basePath The base name.
- * @param integer $clientId The client id.
- * @param object &$element The XML element.
+ * @param string $cname Cname @todo: not used
+ * @param string $basePath The base name.
+ * @param integer $clientId The client id.
+ * @param object &$element The XML element.
*
* @return boolean
*
@@ -145,11 +145,11 @@ protected function _install($cname, $basePath, $clientId, &$element)
{
$this->parent
->abort(
- JText::sprintf(
- 'JLIB_INSTALLER_ABORT',
- JText::sprintf('JLIB_INSTALLER_ERROR_CREATE_FOLDER_FAILED', $this->parent->getPath('extension_site'))
- )
- );
+ JText::sprintf(
+ 'JLIB_INSTALLER_ABORT',
+ JText::sprintf('JLIB_INSTALLER_ERROR_CREATE_FOLDER_FAILED', $this->parent->getPath('extension_site'))
+ )
+ );
return false;
}
@@ -185,6 +185,7 @@ protected function _install($cname, $basePath, $clientId, &$element)
JLog::WARNING, 'jerror'
);
}
+
return false;
}
}
@@ -261,7 +262,7 @@ protected function _install($cname, $basePath, $clientId, &$element)
// Clobber any possible pending updates
$update = JTable::getInstance('update');
- $uid = $update->find(array('element' => $this->get('tag'), 'type' => 'language', 'client_id' => '', 'folder' => ''));
+ $uid = $update->find(array('element' => $this->get('tag'), 'type' => 'language', 'client_id' => '', 'folder' => ''));
if ($uid)
{
@@ -369,7 +370,7 @@ public function update()
// Clobber any possible pending updates
$update = JTable::getInstance('update');
- $uid = $update->find(array('element' => $this->get('tag'), 'type' => 'language', 'client_id' => $clientId));
+ $uid = $update->find(array('element' => $this->get('tag'), 'type' => 'language', 'client_id' => $clientId));
if ($uid)
{
@@ -415,7 +416,7 @@ public function update()
/**
* Custom uninstall method
*
- * @param string $eid The tag of the language to uninstall
+ * @param string $eid The tag of the language to uninstall
*
* @return mixed Return value for uninstall method in component uninstall file
*
@@ -493,7 +494,7 @@ public function uninstall($eid)
$extension->delete();
// Setting the language of users which have this language as the default language
- $db = JFactory::getDbo();
+ $db = JFactory::getDbo();
$query = $db->getQuery(true)
->from('#__users')
->select('*');
@@ -547,8 +548,8 @@ public function uninstall($eid)
*/
public function discover()
{
- $results = array();
- $site_languages = JFolder::folders(JPATH_SITE . '/language');
+ $results = array();
+ $site_languages = JFolder::folders(JPATH_SITE . '/language');
$admin_languages = JFolder::folders(JPATH_ADMINISTRATOR . '/language');
foreach ($site_languages as $language)
@@ -556,7 +557,7 @@ public function discover()
if (file_exists(JPATH_SITE . '/language/' . $language . '/' . $language . '.xml'))
{
$manifest_details = JInstaller::parseXMLInstallFile(JPATH_SITE . '/language/' . $language . '/' . $language . '.xml');
- $extension = JTable::getInstance('extension');
+ $extension = JTable::getInstance('extension');
$extension->set('type', 'language');
$extension->set('client_id', 0);
$extension->set('element', $language);
@@ -573,7 +574,7 @@ public function discover()
if (file_exists(JPATH_ADMINISTRATOR . '/language/' . $language . '/' . $language . '.xml'))
{
$manifest_details = JInstaller::parseXMLInstallFile(JPATH_ADMINISTRATOR . '/language/' . $language . '/' . $language . '.xml');
- $extension = JTable::getInstance('extension');
+ $extension = JTable::getInstance('extension');
$extension->set('type', 'language');
$extension->set('client_id', 1);
$extension->set('element', $language);
@@ -585,6 +586,7 @@ public function discover()
$results[] = $extension;
}
}
+
return $results;
}
@@ -599,18 +601,18 @@ public function discover()
public function discover_install()
{
// Need to find to find where the XML file is since we don't store this normally
- $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
- $short_element = $this->parent->extension->element;
- $manifestPath = $client->path . '/language/' . $short_element . '/' . $short_element . '.xml';
+ $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
+ $short_element = $this->parent->extension->element;
+ $manifestPath = $client->path . '/language/' . $short_element . '/' . $short_element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
$this->parent->setPath('source', $client->path . '/language/' . $short_element);
$this->parent->setPath('extension_root', $this->parent->getPath('source'));
- $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
+ $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->state = 0;
- $this->parent->extension->name = $manifest_details['name'];
- $this->parent->extension->enabled = 1;
+ $this->parent->extension->state = 0;
+ $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->enabled = 1;
// @todo remove code: $this->parent->extension->params = $this->parent->getParams();
try
@@ -623,6 +625,7 @@ public function discover_install()
return false;
}
+
return $this->parent->extension->get('extension_id');
}
@@ -635,13 +638,13 @@ public function discover_install()
*/
public function refreshManifestCache()
{
- $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
- $manifestPath = $client->path . '/language/' . $this->parent->extension->element . '/' . $this->parent->extension->element . '.xml';
+ $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
+ $manifestPath = $client->path . '/language/' . $this->parent->extension->element . '/' . $this->parent->extension->element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
- $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
+ $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->name = $manifest_details['name'];
if ($this->parent->extension->store())
{
diff --git a/libraries/cms/installer/adapter/library.php b/libraries/cms/installer/adapter/library.php
index 398bf5a85acb1..3cf4a4a83c83c 100644
--- a/libraries/cms/installer/adapter/library.php
+++ b/libraries/cms/installer/adapter/library.php
@@ -24,7 +24,7 @@ class JInstallerAdapterLibrary extends JAdapterInstance
/**
* Custom loadLanguage method
*
- * @param string $path The path where to find language files.
+ * @param string $path The path where to find language files.
*
* @return void
*
@@ -39,14 +39,14 @@ public function loadLanguage($path = null)
$this->parent->setPath('source', JPATH_PLATFORM . '/' . $this->parent->extension->element);
}
$this->manifest = $this->parent->getManifest();
- $extension = 'lib_' . strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd'));
- $name = strtolower((string) $this->manifest->libraryname);
- $lang = JFactory::getLanguage();
- $source = $path ? $path : JPATH_PLATFORM . "/$name";
+ $extension = 'lib_' . strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd'));
+ $name = strtolower((string) $this->manifest->libraryname);
+ $lang = JFactory::getLanguage();
+ $source = $path ? $path : JPATH_PLATFORM . "/$name";
$lang->load($extension . '.sys', $source, null, false, false)
- || $lang->load($extension . '.sys', JPATH_SITE, null, false, false)
- || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
- || $lang->load($extension . '.sys', JPATH_SITE, $lang->getDefault(), false, false);
+ || $lang->load($extension . '.sys', JPATH_SITE, null, false, false)
+ || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
+ || $lang->load($extension . '.sys', JPATH_SITE, $lang->getDefault(), false, false);
}
/**
@@ -68,12 +68,12 @@ public function install()
*/
// Set the extension's name
- $name = JFilterInput::getInstance()->clean((string) $this->manifest->name, 'string');
+ $name = JFilterInput::getInstance()->clean((string) $this->manifest->name, 'string');
$element = str_replace('.xml', '', basename($this->parent->getPath('manifest')));
$this->set('name', $name);
$this->set('element', $element);
- $db = $this->parent->getDbo();
+ $db = $this->parent->getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('extension_id'))
->from($db->quoteName('#__extensions'))
@@ -171,21 +171,21 @@ public function install()
$this->parent->parseMedia($this->manifest->media);
// Extension Registration
- $row = JTable::getInstance('extension');
- $row->name = $this->get('name');
- $row->type = 'library';
+ $row = JTable::getInstance('extension');
+ $row->name = $this->get('name');
+ $row->type = 'library';
$row->element = $this->get('element');
// There is no folder for libraries
- $row->folder = '';
- $row->enabled = 1;
+ $row->folder = '';
+ $row->enabled = 1;
$row->protected = 0;
- $row->access = 1;
+ $row->access = 1;
$row->client_id = 0;
- $row->params = $this->parent->getParams();
+ $row->params = $this->parent->getParams();
// Custom data
- $row->custom_data = '';
+ $row->custom_data = '';
$row->manifest_cache = $this->parent->generateManifestCache();
if (!$row->store())
@@ -203,8 +203,8 @@ public function install()
*/
// Lastly, we will copy the manifest file to its appropriate place.
- $manifest = array();
- $manifest['src'] = $this->parent->getPath('manifest');
+ $manifest = array();
+ $manifest['src'] = $this->parent->getPath('manifest');
$manifest['dest'] = JPATH_MANIFESTS . '/libraries/' . basename($this->parent->getPath('manifest'));
if (!$this->parent->copyFiles(array($manifest), true))
@@ -214,6 +214,7 @@ public function install()
return false;
}
+
return $row->get('extension_id');
}
@@ -237,16 +238,16 @@ public function update()
*/
// Set the extensions name
- $name = (string) $this->manifest->name;
- $name = JFilterInput::getInstance()->clean($name, 'string');
+ $name = (string) $this->manifest->name;
+ $name = JFilterInput::getInstance()->clean($name, 'string');
$element = str_replace('.xml', '', basename($this->parent->getPath('manifest')));
$this->set('name', $name);
$this->set('element', $element);
// We don't want to compromise this instance!
$installer = new JInstaller;
- $db = $this->parent->getDbo();
- $query = $db->getQuery(true)
+ $db = $this->parent->getDbo();
+ $query = $db->getQuery(true)
->select($db->quoteName('extension_id'))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('type') . ' = ' . $db->quote('library'))
@@ -259,6 +260,7 @@ public function update()
// Already installed, which would make sense
$installer->uninstall('library', $result);
}
+
// Now create the new files
return $this->install();
}
@@ -266,7 +268,7 @@ public function update()
/**
* Custom uninstall method
*
- * @param string $id The id of the library to uninstall.
+ * @param string $id The id of the library to uninstall.
*
* @return boolean True on success
*
@@ -371,14 +373,14 @@ public function uninstall($id)
*/
public function discover()
{
- $results = array();
+ $results = array();
$file_list = JFolder::files(JPATH_MANIFESTS . '/libraries', '\.xml$');
foreach ($file_list as $file)
{
$manifest_details = JInstaller::parseXMLInstallFile(JPATH_MANIFESTS . '/libraries/' . $file);
- $file = JFile::stripExt($file);
- $extension = JTable::getInstance('extension');
+ $file = JFile::stripExt($file);
+ $extension = JTable::getInstance('extension');
$extension->set('type', 'library');
$extension->set('client_id', 0);
$extension->set('element', $file);
@@ -389,6 +391,7 @@ public function discover()
$extension->set('params', '{}');
$results[] = $extension;
}
+
return $results;
}
@@ -412,15 +415,15 @@ public function discover_install()
* time they can be adequately removed.
*/
- $manifestPath = JPATH_MANIFESTS . '/libraries/' . $this->parent->extension->element . '.xml';
+ $manifestPath = JPATH_MANIFESTS . '/libraries/' . $this->parent->extension->element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
- $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
+ $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->state = 0;
- $this->parent->extension->name = $manifest_details['name'];
- $this->parent->extension->enabled = 1;
- $this->parent->extension->params = $this->parent->getParams();
+ $this->parent->extension->state = 0;
+ $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->enabled = 1;
+ $this->parent->extension->params = $this->parent->getParams();
if ($this->parent->extension->store())
{
@@ -444,13 +447,13 @@ public function discover_install()
public function refreshManifestCache()
{
// Need to find to find where the XML file is since we don't store this normally
- $manifestPath = JPATH_MANIFESTS . '/libraries/' . $this->parent->extension->element . '.xml';
+ $manifestPath = JPATH_MANIFESTS . '/libraries/' . $this->parent->extension->element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
- $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
+ $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->name = $manifest_details['name'];
try
{
diff --git a/libraries/cms/installer/adapter/module.php b/libraries/cms/installer/adapter/module.php
index 8aa80aac10808..aed8decac8638 100644
--- a/libraries/cms/installer/adapter/module.php
+++ b/libraries/cms/installer/adapter/module.php
@@ -73,7 +73,7 @@ class JInstallerAdapterModule extends JAdapterInstance
/**
* Custom loadLanguage method
*
- * @param string $path The path where we find language files
+ * @param string $path The path where we find language files
*
* @return void
*
@@ -87,16 +87,16 @@ public function loadLanguage($path = null)
{
$this->parent
->setPath(
- 'source',
- ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/modules/' . $this->parent->extension->element
- );
+ 'source',
+ ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/modules/' . $this->parent->extension->element
+ );
}
$this->manifest = $this->parent->getManifest();
if ($this->manifest->files)
{
- $element = $this->manifest->files;
+ $element = $this->manifest->files;
$extension = '';
if (count($element->children()))
@@ -113,7 +113,7 @@ public function loadLanguage($path = null)
if ($extension)
{
- $lang = JFactory::getLanguage();
+ $lang = JFactory::getLanguage();
$source = $path ? $path : ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/modules/' . $extension;
$folder = (string) $element->attributes()->folder;
@@ -124,9 +124,9 @@ public function loadLanguage($path = null)
$client = (string) $this->manifest->attributes()->client;
$lang->load($extension . '.sys', $source, null, false, false)
- || $lang->load($extension . '.sys', constant('JPATH_' . strtoupper($client)), null, false, false)
- || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
- || $lang->load($extension . '.sys', constant('JPATH_' . strtoupper($client)), $lang->getDefault(), false, false);
+ || $lang->load($extension . '.sys', constant('JPATH_' . strtoupper($client)), null, false, false)
+ || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
+ || $lang->load($extension . '.sys', constant('JPATH_' . strtoupper($client)), $lang->getDefault(), false, false);
}
}
}
@@ -269,7 +269,8 @@ public function install()
// Upgrade manually set or update function available or update tag detected
if ($this->parent->isUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update'))
- || $updateElement)
+ || $updateElement
+ )
{
// Force this one
$this->parent->setOverwrite(true);
@@ -287,11 +288,11 @@ public function install()
// We didn't have overwrite set, find an update function or find an update tag so lets call it safe
$this->parent
->abort(
- JText::sprintf(
- 'JLIB_INSTALLER_ABORT_MOD_INSTALL_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route),
- $this->parent->getPath('extension_root')
- )
- );
+ JText::sprintf(
+ 'JLIB_INSTALLER_ABORT_MOD_INSTALL_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route),
+ $this->parent->getPath('extension_root')
+ )
+ );
return false;
}
@@ -305,7 +306,7 @@ public function install()
// If there is an manifest class file, let's load it; we'll copy it later (don't have destination yet)
$this->scriptElement = $this->manifest->scriptfile;
- $manifestScript = (string) $this->manifest->scriptfile;
+ $manifestScript = (string) $this->manifest->scriptfile;
if ($manifestScript)
{
@@ -364,11 +365,11 @@ public function install()
{
$this->parent
->abort(
- JText::sprintf(
- 'JLIB_INSTALLER_ABORT_MOD_INSTALL_CREATE_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route),
- $this->parent->getPath('extension_root')
- )
- );
+ JText::sprintf(
+ 'JLIB_INSTALLER_ABORT_MOD_INSTALL_CREATE_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route),
+ $this->parent->getPath('extension_root')
+ )
+ );
return false;
}
@@ -397,7 +398,7 @@ public function install()
// If there is a manifest script, let's copy it.
if ($this->get('manifest_script'))
{
- $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
+ $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
$path['dest'] = $this->parent->getPath('extension_root') . '/' . $this->get('manifest_script');
if (!file_exists($path['dest']) || $this->parent->isOverwrite())
@@ -477,7 +478,7 @@ public function install()
$this->parent->pushStep(array('type' => 'extension', 'extension_id' => $row->extension_id));
// Create unpublished module in jos_modules
- $name = preg_replace('#[\*?]#', '', JText::_($this->get('name')));
+ $name = preg_replace('#[\*?]#', '', JText::_($this->get('name')));
$module = JTable::getInstance('module');
$module->set('title', $name);
$module->set('content', '');
@@ -501,8 +502,8 @@ public function install()
// Install failed, rollback changes
$this->parent
->abort(
- JText::sprintf('JLIB_INSTALLER_ABORT_MOD_INSTALL_SQL_ERROR', JText::_('JLIB_INSTALLER_' . $this->route), $db->stderr(true))
- );
+ JText::sprintf('JLIB_INSTALLER_ABORT_MOD_INSTALL_SQL_ERROR', JText::_('JLIB_INSTALLER_' . $this->route), $db->stderr(true))
+ );
return false;
}
@@ -615,16 +616,16 @@ public function update()
*/
public function discover()
{
- $results = array();
- $site_list = JFolder::folders(JPATH_SITE . '/modules');
+ $results = array();
+ $site_list = JFolder::folders(JPATH_SITE . '/modules');
$admin_list = JFolder::folders(JPATH_ADMINISTRATOR . '/modules');
- $site_info = JApplicationHelper::getClientInfo('site', true);
+ $site_info = JApplicationHelper::getClientInfo('site', true);
$admin_info = JApplicationHelper::getClientInfo('administrator', true);
foreach ($site_list as $module)
{
$manifest_details = JInstaller::parseXMLInstallFile(JPATH_SITE . "/modules/$module/$module.xml");
- $extension = JTable::getInstance('extension');
+ $extension = JTable::getInstance('extension');
$extension->set('type', 'module');
$extension->set('client_id', $site_info->id);
$extension->set('element', $module);
@@ -639,7 +640,7 @@ public function discover()
foreach ($admin_list as $module)
{
$manifest_details = JInstaller::parseXMLInstallFile(JPATH_ADMINISTRATOR . "/modules/$module/$module.xml");
- $extension = JTable::getInstance('extension');
+ $extension = JTable::getInstance('extension');
$extension->set('type', 'module');
$extension->set('client_id', $admin_info->id);
$extension->set('element', $module);
@@ -665,10 +666,10 @@ public function discover_install()
{
// Modules are like templates, and are one of the easiest
// If its not in the extensions table we just add it
- $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
- $manifestPath = $client->path . '/modules/' . $this->parent->extension->element . '/' . $this->parent->extension->element . '.xml';
+ $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
+ $manifestPath = $client->path . '/modules/' . $this->parent->extension->element . '/' . $this->parent->extension->element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
- $description = (string) $this->parent->manifest->description;
+ $description = (string) $this->parent->manifest->description;
if ($description)
{
@@ -684,10 +685,10 @@ public function discover_install()
// TODO: Re-evaluate this; should we run installation triggers? postflight perhaps?
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->state = 0;
- $this->parent->extension->name = $manifest_details['name'];
- $this->parent->extension->enabled = 1;
- $this->parent->extension->params = $this->parent->getParams();
+ $this->parent->extension->state = 0;
+ $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->enabled = 1;
+ $this->parent->extension->params = $this->parent->getParams();
if ($this->parent->extension->store())
{
@@ -710,13 +711,13 @@ public function discover_install()
*/
public function refreshManifestCache()
{
- $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
- $manifestPath = $client->path . '/modules/' . $this->parent->extension->element . '/' . $this->parent->extension->element . '.xml';
+ $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
+ $manifestPath = $client->path . '/modules/' . $this->parent->extension->element . '/' . $this->parent->extension->element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
- $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
+ $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->name = $manifest_details['name'];
if ($this->parent->extension->store())
{
@@ -733,7 +734,7 @@ public function refreshManifestCache()
/**
* Custom uninstall method
*
- * @param integer $id The id of the module to uninstall
+ * @param integer $id The id of the module to uninstall
*
* @return boolean True on success
*
@@ -741,9 +742,9 @@ public function refreshManifestCache()
*/
public function uninstall($id)
{
- $row = null;
+ $row = null;
$retval = true;
- $db = $this->parent->getDbo();
+ $db = $this->parent->getDbo();
// First order of business will be to load the module object table from the database.
// This should give us the necessary information to proceed.
@@ -767,7 +768,7 @@ public function uninstall($id)
// Get the extension root path
$element = $row->element;
- $client = JApplicationHelper::getClientInfo($row->client_id);
+ $client = JApplicationHelper::getClientInfo($row->client_id);
if ($client === false)
{
@@ -789,7 +790,7 @@ public function uninstall($id)
// If there is an manifest class file, let's load it
$this->scriptElement = $this->manifest->scriptfile;
- $manifestScript = (string) $this->manifest->scriptfile;
+ $manifestScript = (string) $this->manifest->scriptfile;
if ($manifestScript)
{
@@ -945,7 +946,7 @@ public function uninstall($id)
* Custom rollback method
* - Roll back the menu item
*
- * @param array $arg Installation step to rollback
+ * @param array $arg Installation step to rollback
*
* @return boolean True on success
*
@@ -974,7 +975,7 @@ protected function _rollback_menu($arg)
* Custom rollback method
* - Roll back the module item
*
- * @param array $arg Installation step to rollback
+ * @param array $arg Installation step to rollback
*
* @return boolean True on success
*
diff --git a/libraries/cms/installer/adapter/package.php b/libraries/cms/installer/adapter/package.php
index 3a64e3c63e37a..93cbc665b3900 100644
--- a/libraries/cms/installer/adapter/package.php
+++ b/libraries/cms/installer/adapter/package.php
@@ -40,7 +40,7 @@ class JInstallerAdapterPackage extends JAdapterInstance
/**
* Load language from a path
*
- * @param string $path The path of the language.
+ * @param string $path The path of the language.
*
* @return void
*
@@ -49,13 +49,13 @@ class JInstallerAdapterPackage extends JAdapterInstance
public function loadLanguage($path)
{
$this->manifest = $this->parent->getManifest();
- $extension = 'pkg_' . strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->packagename, 'cmd'));
- $lang = JFactory::getLanguage();
- $source = $path;
+ $extension = 'pkg_' . strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->packagename, 'cmd'));
+ $lang = JFactory::getLanguage();
+ $source = $path;
$lang->load($extension . '.sys', $source, null, false, false)
- || $lang->load($extension . '.sys', JPATH_SITE, null, false, false)
- || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
- || $lang->load($extension . '.sys', JPATH_SITE, $lang->getDefault(), false, false);
+ || $lang->load($extension . '.sys', JPATH_SITE, null, false, false)
+ || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
+ || $lang->load($extension . '.sys', JPATH_SITE, $lang->getDefault(), false, false);
}
/**
@@ -78,8 +78,8 @@ public function install()
// Set the extensions name
$filter = JFilterInput::getInstance();
- $name = (string) $this->manifest->packagename;
- $name = $filter->clean($name, 'cmd');
+ $name = (string) $this->manifest->packagename;
+ $name = $filter->clean($name, 'cmd');
$this->set('name', $name);
$element = 'pkg_' . $filter->clean($this->manifest->packagename, 'cmd');
@@ -138,7 +138,7 @@ public function install()
// If there is an manifest class file, lets load it; we'll copy it later (don't have dest yet)
$this->scriptElement = $this->manifest->scriptfile;
- $manifestScript = (string) $this->manifest->scriptfile;
+ $manifestScript = (string) $this->manifest->scriptfile;
if ($manifestScript)
{
@@ -209,8 +209,8 @@ public function install()
if (is_dir($file))
{
// If it's actually a directory then fill it up
- $package = array();
- $package['dir'] = $file;
+ $package = array();
+ $package['dir'] = $file;
$package['type'] = JInstallerHelper::detectType($file);
}
else
@@ -218,7 +218,7 @@ public function install()
// If it's an archive
$package = JInstallerHelper::unpack($file);
}
- $tmpInstaller = new JInstaller;
+ $tmpInstaller = new JInstaller;
$installResult = $tmpInstaller->{$this->route}($package['dir']);
if (!$installResult)
@@ -235,7 +235,7 @@ public function install()
else
{
$results[$i] = array(
- 'name' => $tmpInstaller->manifest->name,
+ 'name' => $tmpInstaller->manifest->name,
'result' => $installResult
);
}
@@ -267,20 +267,20 @@ public function install()
}
else
{
- $row->name = $this->get('name');
- $row->type = 'package';
+ $row->name = $this->get('name');
+ $row->type = 'package';
$row->element = $this->get('element');
// There is no folder for modules
- $row->folder = '';
- $row->enabled = 1;
+ $row->folder = '';
+ $row->enabled = 1;
$row->protected = 0;
- $row->access = 1;
+ $row->access = 1;
$row->client_id = 0;
// Custom data
$row->custom_data = '';
- $row->params = $this->parent->getParams();
+ $row->params = $this->parent->getParams();
}
// Update the manifest cache for the entry
$row->manifest_cache = $this->parent->generateManifestCache();
@@ -319,8 +319,8 @@ public function install()
ob_end_clean();
// Lastly, we will copy the manifest file to its appropriate place.
- $manifest = array();
- $manifest['src'] = $this->parent->getPath('manifest');
+ $manifest = array();
+ $manifest['src'] = $this->parent->getPath('manifest');
$manifest['dest'] = JPATH_MANIFESTS . '/packages/' . basename($this->parent->getPath('manifest'));
if (!$this->parent->copyFiles(array($manifest), true))
@@ -342,7 +342,7 @@ public function install()
JFolder::create($this->parent->getPath('extension_root'));
}
- $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
+ $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
$path['dest'] = $this->parent->getPath('extension_root') . '/' . $this->get('manifest_script');
if (!file_exists($path['dest']) || $this->parent->isOverwrite())
@@ -374,6 +374,7 @@ public function install()
{
$this->parent->set('extension_message', $msg);
}
+
return $row->extension_id;
}
@@ -396,7 +397,7 @@ public function update()
/**
* Custom uninstall method
*
- * @param integer $id The id of the package to uninstall.
+ * @param integer $id The id of the package to uninstall.
*
* @return boolean True on success
*
@@ -404,7 +405,7 @@ public function update()
*/
public function uninstall($id)
{
- $row = null;
+ $row = null;
$retval = true;
$row = JTable::getInstance('extension');
@@ -418,7 +419,7 @@ public function uninstall($id)
}
$manifestFile = JPATH_MANIFESTS . '/packages/' . $row->get('element') . '.xml';
- $manifest = new JInstallerManifestPackage($manifestFile);
+ $manifest = new JInstallerManifestPackage($manifestFile);
// Set the package root path
$this->parent->setPath('extension_root', JPATH_MANIFESTS . '/packages/' . $manifest->packagename);
@@ -453,7 +454,7 @@ public function uninstall($id)
// If there is an manifest class file, let's load it
$this->scriptElement = $manifest->scriptfile;
- $manifestScript = (string) $manifest->scriptfile;
+ $manifestScript = (string) $manifest->scriptfile;
if ($manifestScript)
{
@@ -500,8 +501,8 @@ public function uninstall($id)
foreach ($manifest->filelist as $extension)
{
$tmpInstaller = new JInstaller;
- $id = $this->_getExtensionID($extension->type, $extension->id, $extension->client, $extension->group);
- $client = JApplicationHelper::getClientInfo($extension->client, true);
+ $id = $this->_getExtensionID($extension->type, $extension->id, $extension->client, $extension->group);
+ $client = JApplicationHelper::getClientInfo($extension->client, true);
if ($id)
{
@@ -544,10 +545,10 @@ public function uninstall($id)
/**
* Gets the extension id.
*
- * @param string $type The extension type.
- * @param string $id The name of the extension (the element field).
- * @param integer $client The application id (0: Joomla CMS site; 1: Joomla CMS administrator).
- * @param string $group The extension group (mainly for plugins).
+ * @param string $type The extension type.
+ * @param string $id The name of the extension (the element field).
+ * @param integer $client The application id (0: Joomla CMS site; 1: Joomla CMS administrator).
+ * @param string $group The extension group (mainly for plugins).
*
* @return integer
*
@@ -604,13 +605,13 @@ protected function _getExtensionID($type, $id, $client, $group)
public function refreshManifestCache()
{
// Need to find to find where the XML file is since we don't store this normally
- $manifestPath = JPATH_MANIFESTS . '/packages/' . $this->parent->extension->element . '.xml';
+ $manifestPath = JPATH_MANIFESTS . '/packages/' . $this->parent->extension->element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
- $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
+ $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->name = $manifest_details['name'];
try
{
diff --git a/libraries/cms/installer/adapter/plugin.php b/libraries/cms/installer/adapter/plugin.php
index 0d660d06aaa3b..032c22d3049fb 100644
--- a/libraries/cms/installer/adapter/plugin.php
+++ b/libraries/cms/installer/adapter/plugin.php
@@ -73,7 +73,7 @@ class JInstallerAdapterPlugin extends JAdapterInstance
/**
* Custom loadLanguage method
*
- * @param string $path The path where to find language files.
+ * @param string $path The path where to find language files.
*
* @return void
*
@@ -88,12 +88,12 @@ public function loadLanguage($path = null)
$this->parent->setPath('source', JPATH_PLUGINS . '/' . $this->parent->extension->folder . '/' . $this->parent->extension->element);
}
$this->manifest = $this->parent->getManifest();
- $element = $this->manifest->files;
+ $element = $this->manifest->files;
if ($element)
{
$group = strtolower((string) $this->manifest->attributes()->group);
- $name = '';
+ $name = '';
if (count($element->children()))
{
@@ -109,18 +109,18 @@ public function loadLanguage($path = null)
if ($name)
{
$extension = "plg_${group}_${name}";
- $lang = JFactory::getLanguage();
- $source = $path ? $path : JPATH_PLUGINS . "/$group/$name";
- $folder = (string) $element->attributes()->folder;
+ $lang = JFactory::getLanguage();
+ $source = $path ? $path : JPATH_PLUGINS . "/$group/$name";
+ $folder = (string) $element->attributes()->folder;
if ($folder && file_exists("$path/$folder"))
{
$source = "$path/$folder";
}
$lang->load($extension . '.sys', $source, null, false, false)
- || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, false)
- || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
- || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false);
+ || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, false)
+ || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
+ || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false);
}
}
}
@@ -227,7 +227,8 @@ public function install()
// Upgrade manually set or update function available or update tag detected
if ($this->parent->isUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update'))
- || $updateElement)
+ || $updateElement
+ )
{
// Force this one
$this->parent->setOverwrite(true);
@@ -245,11 +246,11 @@ public function install()
// We didn't have overwrite set, find an update function or find an update tag so lets call it safe
$this->parent
->abort(
- JText::sprintf(
- 'JLIB_INSTALLER_ABORT_PLG_INSTALL_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route),
- $this->parent->getPath('extension_root')
- )
- );
+ JText::sprintf(
+ 'JLIB_INSTALLER_ABORT_PLG_INSTALL_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route),
+ $this->parent->getPath('extension_root')
+ )
+ );
return false;
}
@@ -264,7 +265,7 @@ public function install()
// If there is an manifest class file, let's load it; we'll copy it later (don't have destination yet).
if ((string) $xml->scriptfile)
{
- $manifestScript = (string) $xml->scriptfile;
+ $manifestScript = (string) $xml->scriptfile;
$manifestScriptFile = $this->parent->getPath('source') . '/' . $manifestScript;
if (is_file($manifestScriptFile))
@@ -322,11 +323,11 @@ public function install()
{
$this->parent
->abort(
- JText::sprintf(
- 'JLIB_INSTALLER_ABORT_PLG_INSTALL_CREATE_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route),
- $this->parent->getPath('extension_root')
- )
- );
+ JText::sprintf(
+ 'JLIB_INSTALLER_ABORT_PLG_INSTALL_CREATE_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route),
+ $this->parent->getPath('extension_root')
+ )
+ );
return false;
}
@@ -346,7 +347,7 @@ public function install()
if ($tmpInstaller->findManifest())
{
- $old_manifest = $tmpInstaller->getManifest();
+ $old_manifest = $tmpInstaller->getManifest();
$this->oldFiles = $old_manifest->files;
}
}
@@ -378,7 +379,7 @@ public function install()
// If there is a manifest script, lets copy it.
if ($this->get('manifest_script'))
{
- $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
+ $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
$path['dest'] = $this->parent->getPath('extension_root') . '/' . $this->get('manifest_script');
if (!file_exists($path['dest']))
@@ -410,16 +411,16 @@ public function install()
// Install failed, roll back changes
$this->parent
->abort(
- JText::sprintf(
- 'JLIB_INSTALLER_ABORT_PLG_INSTALL_ALLREADY_EXISTS', JText::_('JLIB_INSTALLER_' . $this->route),
- $this->get('name')
- )
- );
+ JText::sprintf(
+ 'JLIB_INSTALLER_ABORT_PLG_INSTALL_ALLREADY_EXISTS', JText::_('JLIB_INSTALLER_' . $this->route),
+ $this->get('name')
+ )
+ );
return false;
}
$row->load($id);
- $row->name = $this->get('name');
+ $row->name = $this->get('name');
$row->manifest_cache = $this->parent->generateManifestCache();
// Update the manifest cache and name
@@ -428,22 +429,22 @@ public function install()
else
{
// Store in the extensions table (1.6)
- $row->name = $this->get('name');
- $row->type = 'plugin';
- $row->ordering = 0;
- $row->element = $element;
- $row->folder = $group;
- $row->enabled = 0;
+ $row->name = $this->get('name');
+ $row->type = 'plugin';
+ $row->ordering = 0;
+ $row->element = $element;
+ $row->folder = $group;
+ $row->enabled = 0;
$row->protected = 0;
- $row->access = 1;
+ $row->access = 1;
$row->client_id = 0;
- $row->params = $this->parent->getParams();
+ $row->params = $this->parent->getParams();
// Custom data
$row->custom_data = '';
// System data
- $row->system_data = '';
+ $row->system_data = '';
$row->manifest_cache = $this->parent->generateManifestCache();
// Editor plugins are published by default
@@ -457,8 +458,8 @@ public function install()
// Install failed, roll back changes
$this->parent
->abort(
- JText::sprintf('JLIB_INSTALLER_ABORT_PLG_INSTALL_ROLLBACK', JText::_('JLIB_INSTALLER_' . $this->route), $db->stderr(true))
- );
+ JText::sprintf('JLIB_INSTALLER_ABORT_PLG_INSTALL_ROLLBACK', JText::_('JLIB_INSTALLER_' . $this->route), $db->stderr(true))
+ );
return false;
}
@@ -479,8 +480,8 @@ public function install()
// Install failed, rollback changes
$this->parent
->abort(
- JText::sprintf('JLIB_INSTALLER_ABORT_PLG_INSTALL_SQL_ERROR', JText::_('JLIB_INSTALLER_' . $this->route), $db->stderr(true))
- );
+ JText::sprintf('JLIB_INSTALLER_ABORT_PLG_INSTALL_SQL_ERROR', JText::_('JLIB_INSTALLER_' . $this->route), $db->stderr(true))
+ );
return false;
}
@@ -585,7 +586,7 @@ public function update()
/**
* Custom uninstall method
*
- * @param integer $id The id of the plugin to uninstall
+ * @param integer $id The id of the plugin to uninstall
*
* @return boolean True on success
*
@@ -595,9 +596,9 @@ public function uninstall($id)
{
$this->route = 'uninstall';
- $row = null;
+ $row = null;
$retval = true;
- $db = $this->parent->getDbo();
+ $db = $this->parent->getDbo();
// First order of business will be to load the plugin object table from the database.
// This should give us the necessary information to proceed.
@@ -754,7 +755,7 @@ public function uninstall($id)
*/
public function discover()
{
- $results = array();
+ $results = array();
$folder_list = JFolder::folders(JPATH_SITE . '/plugins');
foreach ($folder_list as $folder)
@@ -764,7 +765,7 @@ public function discover()
foreach ($file_list as $file)
{
$manifest_details = JInstaller::parseXMLInstallFile(JPATH_SITE . '/plugins/' . $folder . '/' . $file);
- $file = JFile::stripExt($file);
+ $file = JFile::stripExt($file);
// Ignore example plugins
if ($file == 'example')
@@ -794,7 +795,7 @@ public function discover()
$manifest_details = JInstaller::parseXMLInstallFile(
JPATH_SITE . '/plugins/' . $folder . '/' . $plugin_folder . '/' . $file
);
- $file = JFile::stripExt($file);
+ $file = JFile::stripExt($file);
if ($file == 'example')
{
@@ -815,6 +816,7 @@ public function discover()
}
}
}
+
return $results;
}
@@ -844,7 +846,7 @@ public function discover_install()
$manifestPath = $client->path . '/plugins/' . $this->parent->extension->folder . '/' . $this->parent->extension->element . '.xml';
}
$this->parent->manifest = $this->parent->isManifest($manifestPath);
- $description = (string) $this->parent->manifest->description;
+ $description = (string) $this->parent->manifest->description;
if ($description)
{
@@ -855,12 +857,12 @@ public function discover_install()
$this->parent->set('message', '');
}
$this->parent->setPath('manifest', $manifestPath);
- $manifest_details = JInstaller::parseXMLInstallFile($manifestPath);
+ $manifest_details = JInstaller::parseXMLInstallFile($manifestPath);
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->state = 0;
- $this->parent->extension->name = $manifest_details['name'];
- $this->parent->extension->enabled = ('editors' == $this->parent->extension->folder) ? 1 : 0;
- $this->parent->extension->params = $this->parent->getParams();
+ $this->parent->extension->state = 0;
+ $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->enabled = ('editors' == $this->parent->extension->folder) ? 1 : 0;
+ $this->parent->extension->params = $this->parent->getParams();
if ($this->parent->extension->store())
{
@@ -888,12 +890,12 @@ public function refreshManifestCache()
* Similar to modules and templates, rather easy
* If it's not in the extensions table we just add it
*/
- $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
- $manifestPath = $client->path . '/plugins/' . $this->parent->extension->folder . '/' . $this->parent->extension->element . '/'
+ $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
+ $manifestPath = $client->path . '/plugins/' . $this->parent->extension->folder . '/' . $this->parent->extension->element . '/'
. $this->parent->extension->element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
- $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
+ $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
$this->parent->extension->name = $manifest_details['name'];
diff --git a/libraries/cms/installer/adapter/template.php b/libraries/cms/installer/adapter/template.php
index a3970a2682a4f..01b489c2b3547 100644
--- a/libraries/cms/installer/adapter/template.php
+++ b/libraries/cms/installer/adapter/template.php
@@ -57,7 +57,7 @@ class JInstallerAdapterTemplate extends JAdapterInstance
/**
* Custom loadLanguage method
*
- * @param string $path The path where to find language files.
+ * @param string $path The path where to find language files.
*
* @return JInstallerTemplate
*
@@ -71,14 +71,14 @@ public function loadLanguage($path = null)
{
$this->parent
->setPath(
- 'source',
- ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/templates/' . $this->parent->extension->element
- );
+ 'source',
+ ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/templates/' . $this->parent->extension->element
+ );
}
$this->manifest = $this->parent->getManifest();
- $name = strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd'));
- $client = (string) $this->manifest->attributes()->client;
+ $name = strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd'));
+ $client = (string) $this->manifest->attributes()->client;
// Load administrator language if not set.
if (!$client)
@@ -87,12 +87,12 @@ public function loadLanguage($path = null)
}
$extension = "tpl_$name";
- $lang = JFactory::getLanguage();
- $source = $path ? $path : ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/templates/' . $name;
+ $lang = JFactory::getLanguage();
+ $source = $path ? $path : ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/templates/' . $name;
$lang->load($extension . '.sys', $source, null, false, false)
- || $lang->load($extension . '.sys', constant('JPATH_' . strtoupper($client)), null, false, false)
- || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
- || $lang->load($extension . '.sys', constant('JPATH_' . strtoupper($client)), $lang->getDefault(), false, false);
+ || $lang->load($extension . '.sys', constant('JPATH_' . strtoupper($client)), null, false, false)
+ || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
+ || $lang->load($extension . '.sys', constant('JPATH_' . strtoupper($client)), $lang->getDefault(), false, false);
}
/**
@@ -108,7 +108,7 @@ public function install()
$db = $this->parent->getDbo();
$lang = JFactory::getLanguage();
- $xml = $this->parent->getManifest();
+ $xml = $this->parent->getManifest();
// Get the client application target
if ($cname = (string) $xml->attributes()->client)
@@ -186,11 +186,11 @@ public function install()
// If we didn't have overwrite set, find an update function or find an update tag so let's call it safe
$this->parent
->abort(
- JText::sprintf(
- 'JLIB_INSTALLER_ABORT_TPL_INSTALL_ANOTHER_TEMPLATE_USING_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route),
- $this->parent->getPath('extension_root')
- )
- );
+ JText::sprintf(
+ 'JLIB_INSTALLER_ABORT_TPL_INSTALL_ANOTHER_TEMPLATE_USING_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route),
+ $this->parent->getPath('extension_root')
+ )
+ );
return false;
}
@@ -286,23 +286,23 @@ public function install()
}
else
{
- $row->type = 'template';
+ $row->type = 'template';
$row->element = $this->get('element');
// There is no folder for templates
- $row->folder = '';
- $row->enabled = 1;
+ $row->folder = '';
+ $row->enabled = 1;
$row->protected = 0;
- $row->access = 1;
+ $row->access = 1;
$row->client_id = $clientId;
- $row->params = $this->parent->getParams();
+ $row->params = $this->parent->getParams();
// Custom data
$row->custom_data = '';
}
// Name might change in an update
- $row->name = $this->get('name');
+ $row->name = $this->get('name');
$row->manifest_cache = $this->parent->generateManifestCache();
if (!$row->store())
@@ -327,7 +327,7 @@ public function install()
$values = array(
$db->quote($row->element), $clientId, $db->quote(0),
$db->quote(JText::sprintf('JLIB_INSTALLER_DEFAULT_STYLE', JText::_($this->get('name')))),
- $db->quote($row->params) );
+ $db->quote($row->params));
$lang->setDebug($debug);
@@ -363,7 +363,7 @@ public function update()
/**
* Custom uninstall method
*
- * @param integer $id The extension ID
+ * @param integer $id The extension ID
*
* @return boolean True on success
*
@@ -391,7 +391,7 @@ public function uninstall($id)
return false;
}
- $name = $row->element;
+ $name = $row->element;
$clientId = $row->client_id;
// For a template the id will be the template name which represents the subfolder of the templates folder that the template resides in.
@@ -403,7 +403,7 @@ public function uninstall($id)
}
// Deny remove default template
- $db = $this->parent->getDbo();
+ $db = $this->parent->getDbo();
$query = "SELECT COUNT(*) FROM #__template_styles WHERE home = '1' AND template = " . $db->quote($name);
$db->setQuery($query);
@@ -486,10 +486,10 @@ public function uninstall($id)
*/
public function discover()
{
- $results = array();
- $site_list = JFolder::folders(JPATH_SITE . '/templates');
+ $results = array();
+ $site_list = JFolder::folders(JPATH_SITE . '/templates');
$admin_list = JFolder::folders(JPATH_ADMINISTRATOR . '/templates');
- $site_info = JApplicationHelper::getClientInfo('site', true);
+ $site_info = JApplicationHelper::getClientInfo('site', true);
$admin_info = JApplicationHelper::getClientInfo('administrator', true);
foreach ($site_list as $template)
@@ -500,7 +500,7 @@ public function discover()
continue;
}
$manifest_details = JInstaller::parseXMLInstallFile(JPATH_SITE . "/templates/$template/templateDetails.xml");
- $extension = JTable::getInstance('extension');
+ $extension = JTable::getInstance('extension');
$extension->set('type', 'template');
$extension->set('client_id', $site_info->id);
$extension->set('element', $template);
@@ -521,7 +521,7 @@ public function discover()
}
$manifest_details = JInstaller::parseXMLInstallFile(JPATH_ADMINISTRATOR . "/templates/$template/templateDetails.xml");
- $extension = JTable::getInstance('extension');
+ $extension = JTable::getInstance('extension');
$extension->set('type', 'template');
$extension->set('client_id', $admin_info->id);
$extension->set('element', $template);
@@ -548,10 +548,10 @@ public function discover_install()
{
// Templates are one of the easiest
// If its not in the extensions table we just add it
- $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
- $manifestPath = $client->path . '/templates/' . $this->parent->extension->element . '/templateDetails.xml';
+ $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
+ $manifestPath = $client->path . '/templates/' . $this->parent->extension->element . '/templateDetails.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
- $description = (string) $this->parent->manifest->description;
+ $description = (string) $this->parent->manifest->description;
if ($description)
{
@@ -563,11 +563,11 @@ public function discover_install()
}
$this->parent->setPath('manifest', $manifestPath);
- $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
+ $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->state = 0;
- $this->parent->extension->name = $manifest_details['name'];
- $this->parent->extension->enabled = 1;
+ $this->parent->extension->state = 0;
+ $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->enabled = 1;
$data = new JObject;
@@ -583,23 +583,23 @@ public function discover_install()
$db = $this->parent->getDbo();
// Insert record in #__template_styles
- $lang = JFactory::getLanguage();
- $debug = $lang->setDebug(false);
+ $lang = JFactory::getLanguage();
+ $debug = $lang->setDebug(false);
$columns = array($db->quoteName('template'),
$db->quoteName('client_id'),
$db->quoteName('home'),
$db->quoteName('title'),
$db->quoteName('params')
);
- $query = $db->getQuery(true)
+ $query = $db->getQuery(true)
->insert($db->quoteName('#__template_styles'))
->columns($columns)
->values(
$db->quote($this->parent->extension->element)
- . ',' . $db->quote($this->parent->extension->client_id)
- . ',' . $db->quote(0)
- . ',' . $db->quote(JText::sprintf('JLIB_INSTALLER_DEFAULT_STYLE', $this->parent->extension->name))
- . ',' . $db->quote($this->parent->extension->params)
+ . ',' . $db->quote($this->parent->extension->client_id)
+ . ',' . $db->quote(0)
+ . ',' . $db->quote(JText::sprintf('JLIB_INSTALLER_DEFAULT_STYLE', $this->parent->extension->name))
+ . ',' . $db->quote($this->parent->extension->params)
);
$lang->setDebug($debug);
$db->setQuery($query);
@@ -625,14 +625,14 @@ public function discover_install()
public function refreshManifestCache()
{
// Need to find to find where the XML file is since we don't store this normally.
- $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
- $manifestPath = $client->path . '/templates/' . $this->parent->extension->element . '/templateDetails.xml';
+ $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
+ $manifestPath = $client->path . '/templates/' . $this->parent->extension->element . '/templateDetails.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
- $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
+ $manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
- $this->parent->extension->name = $manifest_details['name'];
+ $this->parent->extension->name = $manifest_details['name'];
try
{
diff --git a/libraries/cms/installer/extension.php b/libraries/cms/installer/extension.php
index 0becc9bb2734b..f3bfc23148afb 100644
--- a/libraries/cms/installer/extension.php
+++ b/libraries/cms/installer/extension.php
@@ -86,7 +86,7 @@ class JInstallerExtension extends JObject
/**
* Constructor
*
- * @param SimpleXMLElement $element A SimpleXMLElement from which to load data from
+ * @param SimpleXMLElement $element A SimpleXMLElement from which to load data from
*
* @since 3.1
*/
@@ -95,7 +95,7 @@ public function __construct(SimpleXMLElement $element = null)
if ($element)
{
$this->type = (string) $element->attributes()->type;
- $this->id = (string) $element->attributes()->id;
+ $this->id = (string) $element->attributes()->id;
switch ($this->type)
{
@@ -106,7 +106,7 @@ public function __construct(SimpleXMLElement $element = null)
case 'module':
case 'template':
case 'language':
- $this->client = (string) $element->attributes()->client;
+ $this->client = (string) $element->attributes()->client;
$tmp_client_id = JApplicationHelper::getClientInfo($this->client, 1);
if ($tmp_client_id == null)
@@ -156,7 +156,7 @@ class JExtension extends JInstallerExtension
/**
* Constructor
*
- * @param SimpleXMLElement $element A SimpleXMLElement from which to load data from
+ * @param SimpleXMLElement $element A SimpleXMLElement from which to load data from
*
* @since 3.1
*/
diff --git a/libraries/cms/installer/helper.php b/libraries/cms/installer/helper.php
index a0f2daf02973e..8e6e1ec11d13f 100644
--- a/libraries/cms/installer/helper.php
+++ b/libraries/cms/installer/helper.php
@@ -25,8 +25,8 @@ abstract class JInstallerHelper
/**
* Downloads a package
*
- * @param string $url URL of file to download
- * @param string $target Download target filename [optional]
+ * @param string $url URL of file to download
+ * @param string $target Download target filename [optional]
*
* @return mixed Path to downloaded package or boolean false on failure
*
@@ -44,7 +44,7 @@ public static function downloadPackage($url, $target = false)
$version = new JVersion;
ini_set('user_agent', $version->getUserAgent('Installer'));
- $http = JHttpFactory::getHttp();
+ $http = JHttpFactory::getHttp();
$response = $http->get($url);
if (302 == $response->code && isset($response->headers['Location']))
@@ -61,7 +61,7 @@ public static function downloadPackage($url, $target = false)
if (isset($response->headers['Content-Disposition']))
{
$contentfilename = explode("\"", $response->headers['Content-Disposition']);
- $target = $contentfilename[1];
+ $target = $contentfilename[1];
}
// Set the target path if not given
@@ -91,7 +91,7 @@ public static function downloadPackage($url, $target = false)
* Unpacks a file and verifies it as a Joomla element package
* Supports .gz .tar .tar.gz and .zip
*
- * @param string $p_filename The uploaded package filename or install directory
+ * @param string $p_filename The uploaded package filename or install directory
*
* @return mixed Array on success or boolean false on failure
*
@@ -106,7 +106,7 @@ public static function unpack($p_filename)
$tmpdir = uniqid('install_');
// Clean the paths to use for archive extraction
- $extractdir = JPath::clean(dirname($p_filename) . '/' . $tmpdir);
+ $extractdir = JPath::clean(dirname($p_filename) . '/' . $tmpdir);
$archivename = JPath::clean($archivename);
// Do the unpacking of the archive
@@ -123,7 +123,7 @@ public static function unpack($p_filename)
* Let's set the extraction directory and package file in the result array so we can
* cleanup everything properly later on.
*/
- $retval['extractdir'] = $extractdir;
+ $retval['extractdir'] = $extractdir;
$retval['packagefile'] = $archivename;
/*
@@ -168,7 +168,7 @@ public static function unpack($p_filename)
/**
* Method to detect the extension type from a package directory
*
- * @param string $p_dir Path to package directory
+ * @param string $p_dir Path to package directory
*
* @return mixed Extension type string or boolean false on fail
*
@@ -220,7 +220,7 @@ public static function detectType($p_dir)
/**
* Gets a file name out of a url
*
- * @param string $url URL to get name from
+ * @param string $url URL to get name from
*
* @return mixed String filename or boolean false if failed
*
@@ -234,14 +234,15 @@ public static function getFilenameFromURL($url)
return $parts[count($parts) - 1];
}
+
return false;
}
/**
* Clean up temporary uploaded package and unpacked extension
*
- * @param string $package Path to the uploaded package file
- * @param string $resultdir Path to the unpacked extension
+ * @param string $package Path to the uploaded package file
+ * @param string $resultdir Path to the unpacked extension
*
* @return boolean True on success
*
@@ -273,11 +274,11 @@ public static function cleanupInstall($package, $resultdir)
* Splits contents of a sql file into array of discreet queries.
* Queries need to be delimited with end of statement marker ';'
*
- * @param string $query The SQL statement.
+ * @param string $query The SQL statement.
*
* @return array Array of queries
*
- * @since 3.1
+ * @since 3.1
* @deprecated 13.3 Use JDatabaseDriver::splitSql() directly
* @codeCoverageIgnore
*/
diff --git a/libraries/cms/installer/installer.php b/libraries/cms/installer/installer.php
index 3ffdb218e43d3..e914d70a3c2ad 100644
--- a/libraries/cms/installer/installer.php
+++ b/libraries/cms/installer/installer.php
@@ -139,6 +139,7 @@ public static function getInstance()
{
self::$instance = new JInstaller;
}
+
return self::$instance;
}
@@ -157,7 +158,7 @@ public function isOverwrite()
/**
* Set the allow overwrite switch
*
- * @param boolean $state Overwrite switch state
+ * @param boolean $state Overwrite switch state
*
* @return boolean True it state is set, false if it is not
*
@@ -194,7 +195,7 @@ public function getRedirectURL()
/**
* Set the redirect location
*
- * @param string $newurl New redirect location
+ * @param string $newurl New redirect location
*
* @return void
*
@@ -220,7 +221,7 @@ public function isUpgrade()
/**
* Set the upgrade switch
*
- * @param boolean $state Upgrade switch state
+ * @param boolean $state Upgrade switch state
*
* @return boolean True if upgrade, false otherwise
*
@@ -262,8 +263,8 @@ public function getManifest()
/**
* Get an installer path by name
*
- * @param string $name Path name
- * @param string $default Default value
+ * @param string $name Path name
+ * @param string $default Default value
*
* @return string Path
*
@@ -277,8 +278,8 @@ public function getPath($name, $default = null)
/**
* Sets an installer path by name
*
- * @param string $name Path name
- * @param string $value Path
+ * @param string $name Path name
+ * @param string $value Path
*
* @return void
*
@@ -292,7 +293,7 @@ public function setPath($name, $value)
/**
* Pushes a step onto the installer stack for rolling back steps
*
- * @param array $step Installer step
+ * @param array $step Installer step
*
* @return void
*
@@ -306,8 +307,8 @@ public function pushStep($step)
/**
* Installation abort method
*
- * @param string $msg Abort message from the installer
- * @param string $type Package type if defined
+ * @param string $msg Abort message from the installer
+ * @param string $type Package type if defined
*
* @return boolean True if successful
*
@@ -317,7 +318,7 @@ public function pushStep($step)
public function abort($msg = null, $type = null)
{
$retval = true;
- $step = array_pop($this->stepStack);
+ $step = array_pop($this->stepStack);
// Raise abort warning
if ($msg)
@@ -347,7 +348,7 @@ public function abort($msg = null, $type = null)
case 'extension':
// Get database connector object
- $db = $this->getDBO();
+ $db = $this->getDBO();
$query = $db->getQuery(true);
// Remove the entry from the #__extensions table
@@ -388,7 +389,7 @@ public function abort($msg = null, $type = null)
$step = array_pop($this->stepStack);
}
- $conf = JFactory::getConfig();
+ $conf = JFactory::getConfig();
$debug = $conf->get('debug');
if ($debug)
@@ -404,7 +405,7 @@ public function abort($msg = null, $type = null)
/**
* Package installation method
*
- * @param string $path Path to package source folder
+ * @param string $path Path to package source folder
*
* @return boolean True if successful
*
@@ -473,7 +474,7 @@ public function install($path = null)
/**
* Discovered package installation method
*
- * @param integer $eid Extension ID
+ * @param integer $eid Extension ID
*
* @return boolean True if successful
*
@@ -524,9 +525,9 @@ public function discover_install($eid = null)
$dispatcher->trigger(
'onExtensionBeforeInstall',
array(
- 'method' => 'discover_install',
- 'type' => $this->extension->get('type'),
- 'manifest' => null,
+ 'method' => 'discover_install',
+ 'type' => $this->extension->get('type'),
+ 'manifest' => null,
'extension' => $this->extension->get('extension_id')
)
);
@@ -602,7 +603,7 @@ public function discover()
/**
* Package update method
*
- * @param string $path Path to package source folder
+ * @param string $path Path to package source folder
*
* @return boolean True if successful
*
@@ -617,12 +618,14 @@ public function update($path = null)
else
{
$this->abort(JText::_('JLIB_INSTALLER_ABORT_NOUPDATEPATH'));
+
return false;
}
if (!$this->setupInstall())
{
$this->abort(JText::_('JLIB_INSTALLER_ABORT_DETECTMANIFEST'));
+
return false;
}
@@ -666,9 +669,9 @@ public function update($path = null)
/**
* Package uninstallation method
*
- * @param string $type Package type
- * @param mixed $identifier Package identifier for adapter
- * @param integer $cid Application ID; deprecated in 1.6
+ * @param string $type Package type
+ * @param mixed $identifier Package identifier for adapter
+ * @param integer $cid Application ID; deprecated in 1.6
*
* @return boolean True if successful
*
@@ -711,7 +714,7 @@ public function uninstall($type, $identifier, $cid = 0)
/**
* Refreshes the manifest cache stored in #__extensions
*
- * @param integer $eid Extension ID
+ * @param integer $eid Extension ID
*
* @return mixed void on success, false on error @todo missing return value ?
*
@@ -816,7 +819,7 @@ public function setupInstall()
* Backward compatible method to parse through a queries element of the
* installation manifest file and take appropriate action.
*
- * @param SimpleXMLElement $element The XML node to process
+ * @param SimpleXMLElement $element The XML node to process
*
* @return mixed Number of queries processed or False on error
*
@@ -861,7 +864,7 @@ public function parseQueries(SimpleXMLElement $element)
/**
* Method to extract the name of a discreet installation sql file from the installation manifest file.
*
- * @param object $element The XML node to process
+ * @param object $element The XML node to process
*
* @return mixed Number of queries processed or False on error
*
@@ -875,8 +878,8 @@ public function parseSQLFiles($element)
return 0;
}
- $queries = array();
- $db = & $this->_db;
+ $queries = array();
+ $db = & $this->_db;
$dbDriver = strtolower($db->name);
if ($dbDriver == 'mysqli')
@@ -888,7 +891,7 @@ public function parseSQLFiles($element)
foreach ($element->children() as $file)
{
$fCharset = (strtolower($file->attributes()->charset) == 'utf8') ? 'utf8' : '';
- $fDriver = strtolower($file->attributes()->driver);
+ $fDriver = strtolower($file->attributes()->driver);
if ($fDriver == 'mysqli')
{
@@ -952,8 +955,8 @@ public function parseSQLFiles($element)
/**
* Set the schema version for an extension by looking at its latest update
*
- * @param SimpleXMLElement $schema Schema Tag
- * @param integer $eid Extension ID
+ * @param SimpleXMLElement $schema Schema Tag
+ * @param integer $eid Extension ID
*
* @return void
*
@@ -963,7 +966,7 @@ public function setSchemaVersion(SimpleXMLElement $schema, $eid)
{
if ($eid && $schema)
{
- $db = JFactory::getDbo();
+ $db = JFactory::getDbo();
$schemapaths = $schema->children();
if (!$schemapaths)
@@ -1021,8 +1024,8 @@ public function setSchemaVersion(SimpleXMLElement $schema, $eid)
/**
* Method to process the updates for an item
*
- * @param SimpleXMLElement $schema The XML node to process
- * @param integer $eid Extension Identifier
+ * @param SimpleXMLElement $schema The XML node to process
+ * @param integer $eid Extension Identifier
*
* @return boolean Result of the operations
*
@@ -1035,7 +1038,7 @@ public function parseSchemaUpdates(SimpleXMLElement $schema, $eid)
// Ensure we have an XML element and a valid extension id
if ($eid && $schema)
{
- $db = JFactory::getDbo();
+ $db = JFactory::getDbo();
$schemapaths = $schema->children();
if (count($schemapaths))
@@ -1152,10 +1155,10 @@ public function parseSchemaUpdates(SimpleXMLElement $schema, $eid)
* Method to parse through a files element of the installation manifest and take appropriate
* action.
*
- * @param SimpleXMLElement $element The XML node to process
- * @param integer $cid Application ID of application to install to
- * @param array $oldFiles List of old files (SimpleXMLElement's)
- * @param array $oldMD5 List of old MD5 sums (indexed by filename with value as MD5)
+ * @param SimpleXMLElement $element The XML node to process
+ * @param integer $cid Application ID of application to install to
+ * @param array $oldFiles List of old files (SimpleXMLElement's)
+ * @param array $oldMD5 List of old MD5 sums (indexed by filename with value as MD5)
*
* @return boolean True on success
*
@@ -1180,12 +1183,12 @@ public function parseFiles(SimpleXMLElement $element, $cid = 0, $oldFiles = null
*/
if ($client)
{
- $pathname = 'extension_' . $client->name;
+ $pathname = 'extension_' . $client->name;
$destination = $this->getPath($pathname);
}
else
{
- $pathname = 'extension_root';
+ $pathname = 'extension_root';
$destination = $this->getPath($pathname);
}
@@ -1236,16 +1239,16 @@ public function parseFiles(SimpleXMLElement $element, $cid = 0, $oldFiles = null
// Copy the MD5SUMS file if it exists
if (file_exists($source . '/MD5SUMS'))
{
- $path['src'] = $source . '/MD5SUMS';
+ $path['src'] = $source . '/MD5SUMS';
$path['dest'] = $destination . '/MD5SUMS';
$path['type'] = 'file';
- $copyfiles[] = $path;
+ $copyfiles[] = $path;
}
// Process each file in the $files array (children of $tagName).
foreach ($element->children() as $file)
{
- $path['src'] = $source . '/' . $file;
+ $path['src'] = $source . '/' . $file;
$path['dest'] = $destination . '/' . $file;
// Is this path a file or folder?
@@ -1280,8 +1283,8 @@ public function parseFiles(SimpleXMLElement $element, $cid = 0, $oldFiles = null
* Method to parse through a languages element of the installation manifest and take appropriate
* action.
*
- * @param SimpleXMLElement $element The XML node to process
- * @param integer $cid Application ID of application to install to
+ * @param SimpleXMLElement $element The XML node to process
+ * @param integer $cid Application ID of application to install to
*
* @return boolean True on success
*
@@ -1346,7 +1349,7 @@ public function parseLanguages(SimpleXMLElement $element, $cid = 0)
if ((string) $file->attributes()->client != '')
{
// Override the client
- $langclient = JApplicationHelper::getClientInfo((string) $file->attributes()->client, true);
+ $langclient = JApplicationHelper::getClientInfo((string) $file->attributes()->client, true);
$path['dest'] = $langclient->path . '/language/' . $file->attributes()->tag . '/' . basename((string) $file);
}
else
@@ -1363,7 +1366,7 @@ public function parseLanguages(SimpleXMLElement $element, $cid = 0)
}
else
{
- $path['src'] = $source . '/' . $file;
+ $path['src'] = $source . '/' . $file;
$path['dest'] = $destination . '/' . $file;
}
@@ -1396,8 +1399,8 @@ public function parseLanguages(SimpleXMLElement $element, $cid = 0)
* Method to parse through a media element of the installation manifest and take appropriate
* action.
*
- * @param SimpleXMLElement $element The XML node to process
- * @param integer $cid Application ID of application to install to
+ * @param SimpleXMLElement $element The XML node to process
+ * @param integer $cid Application ID of application to install to
*
* @return boolean True on success
*
@@ -1416,7 +1419,7 @@ public function parseMedia(SimpleXMLElement $element, $cid = 0)
// Here we set the folder we are going to copy the files to.
// Default 'media' Files are copied to the JPATH_BASE/media folder
- $folder = ((string) $element->attributes()->destination) ? '/' . $element->attributes()->destination : null;
+ $folder = ((string) $element->attributes()->destination) ? '/' . $element->attributes()->destination : null;
$destination = JPath::clean(JPATH_ROOT . '/media' . $folder);
// Here we set the folder we are going to copy the files from.
@@ -1442,7 +1445,7 @@ public function parseMedia(SimpleXMLElement $element, $cid = 0)
// Process each file in the $files array (children of $tagName).
foreach ($element->children() as $file)
{
- $path['src'] = $source . '/' . $file;
+ $path['src'] = $source . '/' . $file;
$path['dest'] = $destination . '/' . $file;
// Is this path a file or folder?
@@ -1531,8 +1534,8 @@ public function getParams()
*
* Copy files from source directory to the target directory
*
- * @param array $files Array with filenames
- * @param boolean $overwrite True if existing files can be replaced
+ * @param array $files Array with filenames
+ * @param boolean $overwrite True if existing files can be replaced
*
* @return boolean True on success
*
@@ -1562,8 +1565,8 @@ public function copyFiles($files, $overwrite = null)
{
// Get the source and destination paths
$filesource = JPath::clean($file['src']);
- $filedest = JPath::clean($file['dest']);
- $filetype = array_key_exists('type', $file) ? $file['type'] : 'file';
+ $filedest = JPath::clean($file['dest']);
+ $filetype = array_key_exists('type', $file) ? $file['type'] : 'file';
if (!file_exists($filesource))
{
@@ -1640,8 +1643,8 @@ public function copyFiles($files, $overwrite = null)
* Method to parse through a files element of the installation manifest and remove
* the files that were installed
*
- * @param object $element The XML node to process
- * @param integer $cid Application ID of application to remove from
+ * @param object $element The XML node to process
+ * @param integer $cid Application ID of application to remove from
*
* @return boolean True on success
*
@@ -1724,12 +1727,12 @@ public function removeFiles($element, $cid = 0)
if ($client)
{
$pathname = 'extension_' . $client->name;
- $source = $this->getPath($pathname);
+ $source = $this->getPath($pathname);
}
else
{
$pathname = 'extension_root';
- $source = $this->getPath($pathname);
+ $source = $this->getPath($pathname);
}
break;
@@ -1754,7 +1757,7 @@ public function removeFiles($element, $cid = 0)
else
{
$target_client = JApplicationHelper::getClientInfo((string) $file->attributes()->client, true);
- $path = $target_client->path . '/language/' . $file->attributes()->tag . '/' . basename((string) $file);
+ $path = $target_client->path . '/language/' . $file->attributes()->tag . '/' . basename((string) $file);
}
// If the language folder is not present, then the core pack hasn't been installed... ignore
@@ -1797,7 +1800,7 @@ public function removeFiles($element, $cid = 0)
/**
* Copies the installation manifest file to the extension folder in the given client
*
- * @param integer $cid Where to copy the installfile [optional: defaults to 1 (admin)]
+ * @param integer $cid Where to copy the installfile [optional: defaults to 1 (admin)]
*
* @return boolean True on success, False on error
*
@@ -1812,12 +1815,12 @@ public function copyManifest($cid = 1)
if ($client)
{
- $pathname = 'extension_' . $client->name;
+ $pathname = 'extension_' . $client->name;
$path['dest'] = $this->getPath($pathname) . '/' . basename($this->getPath('manifest'));
}
else
{
- $pathname = 'extension_root';
+ $pathname = 'extension_root';
$path['dest'] = $this->getPath($pathname) . '/' . basename($this->getPath('manifest'));
}
@@ -1837,7 +1840,7 @@ public function findManifest()
$parentXmlfiles = JFolder::files($this->getPath('source'), '.xml$', false, true);
// Search for children manifests (lower priority)
- $allXmlFiles = JFolder::files($this->getPath('source'), '.xml$', 1, true);
+ $allXmlFiles = JFolder::files($this->getPath('source'), '.xml$', 1, true);
// Create an unique array of files ordered by priority
$xmlfiles = array_unique(array_merge($parentXmlfiles, $allXmlFiles));
@@ -1856,7 +1859,7 @@ public function findManifest()
// If the root method attribute is set to upgrade, allow file overwrite
if ((string) $manifest->attributes()->method == 'upgrade')
{
- $this->upgrade = true;
+ $this->upgrade = true;
$this->overwrite = true;
}
@@ -1894,7 +1897,7 @@ public function findManifest()
/**
* Is the XML file a valid Joomla installation manifest file.
*
- * @param string $file An xmlfile path to check
+ * @param string $file An xmlfile path to check
*
* @return mixed A SimpleXMLElement, or null if the file failed to parse
*
@@ -1935,10 +1938,10 @@ public function generateManifestCache()
/**
* Cleans up discovered extensions if they're being installed some other way
*
- * @param string $type The type of extension (component, etc)
- * @param string $element Unique element identifier (e.g. com_content)
- * @param string $folder The folder of the extension (plugins; e.g. system)
- * @param integer $client The client application (administrator or site)
+ * @param string $type The type of extension (component, etc)
+ * @param string $element Unique element identifier (e.g. com_content)
+ * @param string $folder The folder of the extension (plugins; e.g. system)
+ * @param integer $client The client application (administrator or site)
*
* @return object Result of query
*
@@ -1946,7 +1949,7 @@ public function generateManifestCache()
*/
public function cleanDiscoveredExtension($type, $element, $folder = '', $client = 0)
{
- $db = JFactory::getDbo();
+ $db = JFactory::getDbo();
$query = $db->getQuery(true)
->delete($db->quoteName('#__extensions'))
->where('type = ' . $db->quote($type))
@@ -1962,8 +1965,8 @@ public function cleanDiscoveredExtension($type, $element, $folder = '', $client
/**
* Compares two "files" entries to find deleted files/folders
*
- * @param array $old_files An array of SimpleXMLElement objects that are the old files
- * @param array $new_files An array of SimpleXMLElement objects that are the new files
+ * @param array $old_files An array of SimpleXMLElement objects that are the old files
+ * @param array $new_files An array of SimpleXMLElement objects that are the new files
*
* @return array An array with the delete files and folders in findDeletedFiles[files] and findDeletedFiles[folders] respectively
*
@@ -2067,7 +2070,7 @@ public function findDeletedFiles($old_files, $new_files)
/**
* Loads an MD5SUMS file into an associative array
*
- * @param string $filename Filename to load
+ * @param string $filename Filename to load
*
* @return array Associative array with filenames as the index and the MD5 as the value
*
@@ -2081,7 +2084,7 @@ public function loadMD5Sum($filename)
return false;
}
- $data = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
+ $data = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$retval = array();
foreach ($data as $row)
@@ -2104,7 +2107,7 @@ public function loadMD5Sum($filename)
*
* XML Root tag should be 'install' except for languages which use meta file.
*
- * @param string $path Full path to XML file.
+ * @param string $path Full path to XML file.
*
* @return array XML metadata.
*
@@ -2139,14 +2142,14 @@ public static function parseXMLInstallFile($path)
$data['type'] = $xml->getName() == 'metafile' ? 'language' : (string) $xml->attributes()->type;
$data['creationDate'] = ((string) $xml->creationDate) ? (string) $xml->creationDate : JText::_('Unknown');
- $data['author'] = ((string) $xml->author) ? (string) $xml->author : JText::_('Unknown');
+ $data['author'] = ((string) $xml->author) ? (string) $xml->author : JText::_('Unknown');
- $data['copyright'] = (string) $xml->copyright;
+ $data['copyright'] = (string) $xml->copyright;
$data['authorEmail'] = (string) $xml->authorEmail;
- $data['authorUrl'] = (string) $xml->authorUrl;
- $data['version'] = (string) $xml->version;
+ $data['authorUrl'] = (string) $xml->authorUrl;
+ $data['version'] = (string) $xml->version;
$data['description'] = (string) $xml->description;
- $data['group'] = (string) $xml->group;
+ $data['group'] = (string) $xml->group;
return $data;
}
diff --git a/libraries/cms/installer/manifest.php b/libraries/cms/installer/manifest.php
index 71468c9fc418c..748ddc2387d08 100644
--- a/libraries/cms/installer/manifest.php
+++ b/libraries/cms/installer/manifest.php
@@ -87,7 +87,7 @@ abstract class JInstallerManifest
/**
* Constructor
*
- * @param string $xmlpath Path to XML manifest file.
+ * @param string $xmlpath Path to XML manifest file.
*
* @since 3.1
*/
@@ -102,7 +102,7 @@ public function __construct($xmlpath = '')
/**
* Load a manifest from a file
*
- * @param string $xmlfile Path to file to load
+ * @param string $xmlfile Path to file to load
*
* @return boolean
*
@@ -131,7 +131,7 @@ public function loadManifestFromXML($xmlfile)
/**
* Apply manifest data from a SimpleXMLElement to the object.
*
- * @param SimpleXMLElement $xml Data to load
+ * @param SimpleXMLElement $xml Data to load
*
* @return void
*
diff --git a/libraries/cms/installer/manifest/library.php b/libraries/cms/installer/manifest/library.php
index f8d43f33c7fdb..aa9996115a196 100644
--- a/libraries/cms/installer/manifest/library.php
+++ b/libraries/cms/installer/manifest/library.php
@@ -77,7 +77,7 @@ class JInstallerManifestLibrary extends JInstallerManifest
/**
* Apply manifest data from a SimpleXMLElement to the object.
*
- * @param SimpleXMLElement $xml Data to load
+ * @param SimpleXMLElement $xml Data to load
*
* @return void
*
diff --git a/libraries/cms/installer/manifest/package.php b/libraries/cms/installer/manifest/package.php
index 918d9c4d91507..822181b690762 100644
--- a/libraries/cms/installer/manifest/package.php
+++ b/libraries/cms/installer/manifest/package.php
@@ -45,7 +45,7 @@ class JInstallerManifestPackage extends JInstallerManifest
/**
* Apply manifest data from a SimpleXMLElement to the object.
*
- * @param SimpleXMLElement $xml Data to load
+ * @param SimpleXMLElement $xml Data to load
*
* @return void
*
diff --git a/libraries/cms/language/associations.php b/libraries/cms/language/associations.php
index ca3f74b51b896..0bff7f094efe1 100644
--- a/libraries/cms/language/associations.php
+++ b/libraries/cms/language/associations.php
@@ -21,13 +21,13 @@ class JLanguageAssociations
/**
* Get the associations.
*
- * @param string $extension The name of the component.
- * @param string $tablename The name of the table.
- * @param string $context The context
- * @param integer $id The primary key value.
- * @param string $pk The name of the primary key in the given $table.
- * @param string $aliasField If the table has an alias field set it here. Null to not use it
- * @param string $catField If the table has a catid field set it here. Null to not use it
+ * @param string $extension The name of the component.
+ * @param string $tablename The name of the table.
+ * @param string $context The context
+ * @param integer $id The primary key value.
+ * @param string $pk The name of the primary key in the given $table.
+ * @param string $aliasField If the table has an alias field set it here. Null to not use it
+ * @param string $catField If the table has a catid field set it here. Null to not use it
*
* @return array The associated items
*
@@ -36,8 +36,8 @@ class JLanguageAssociations
public static function getAssociations($extension, $tablename, $context, $id, $pk = 'id', $aliasField = 'alias', $catField = 'catid')
{
$associations = array();
- $db = JFactory::getDbo();
- $query = $db->getQuery(true)
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true)
->select($db->quoteName('c2.language'))
->from($db->quoteName($tablename, 'c'))
->join('INNER', $db->quoteName('#__associations', 'a') . ' ON a.id = c.id AND a.context=' . $db->quote($context))
diff --git a/libraries/cms/language/multilang.php b/libraries/cms/language/multilang.php
index fc32c81e8d08c..d1740c089d641 100644
--- a/libraries/cms/language/multilang.php
+++ b/libraries/cms/language/multilang.php
@@ -41,6 +41,7 @@ public static function isEnabled()
if ($app->isSite())
{
$enabled = $app->getLanguageFilter();
+
return $enabled;
}
@@ -48,7 +49,7 @@ public static function isEnabled()
if (!$tested)
{
// Determine status of language filter plug-in.
- $db = JFactory::getDbo();
+ $db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('enabled')
->from($db->quoteName('#__extensions'))
@@ -58,7 +59,7 @@ public static function isEnabled()
$db->setQuery($query);
$enabled = $db->loadResult();
- $tested = true;
+ $tested = true;
}
return $enabled;
diff --git a/libraries/cms/layout/base.php b/libraries/cms/layout/base.php
index e0f89381de116..04659e119b51a 100644
--- a/libraries/cms/layout/base.php
+++ b/libraries/cms/layout/base.php
@@ -22,7 +22,7 @@ class JLayoutBase implements JLayout
/**
* Method to escape output.
*
- * @param string $output The output to escape.
+ * @param string $output The output to escape.
*
* @return string The escaped output.
*
@@ -36,7 +36,7 @@ public function escape($output)
/**
* Method to render the layout.
*
- * @param object $displayData Object which properties are used inside the layout file to build displayed output
+ * @param object $displayData Object which properties are used inside the layout file to build displayed output
*
* @return string The necessary HTML to display the layout
*
diff --git a/libraries/cms/layout/file.php b/libraries/cms/layout/file.php
index 6262371429e06..6aa2a88eb01e9 100644
--- a/libraries/cms/layout/file.php
+++ b/libraries/cms/layout/file.php
@@ -41,8 +41,8 @@ class JLayoutFile extends JLayoutBase
/**
* Method to instantiate the file-based layout.
*
- * @param string $layoutId Dot separated path to the layout file, relative to base path
- * @param string $basePath Base path to use when loading layout files
+ * @param string $layoutId Dot separated path to the layout file, relative to base path
+ * @param string $basePath Base path to use when loading layout files
*
* @since 3.0
*/
@@ -55,7 +55,7 @@ public function __construct($layoutId, $basePath = null)
/**
* Method to render the layout.
*
- * @param object $displayData Object which properties are used inside the layout file to build displayed output
+ * @param object $displayData Object which properties are used inside the layout file to build displayed output
*
* @return string The necessary HTML to display the layout
*
@@ -93,7 +93,7 @@ protected function getPath()
if (is_null($this->fullPath) && !empty($this->layoutId))
{
- $rawPath = str_replace('.', '/', $this->layoutId) . '.php';
+ $rawPath = str_replace('.', '/', $this->layoutId) . '.php';
$fileName = basename($rawPath);
$filePath = dirname($rawPath);
diff --git a/libraries/cms/layout/helper.php b/libraries/cms/layout/helper.php
index 4515733d2ea59..81662b9fe433f 100644
--- a/libraries/cms/layout/helper.php
+++ b/libraries/cms/layout/helper.php
@@ -31,9 +31,9 @@ class JLayoutHelper
/**
* Method to render the layout.
*
- * @param string $layoutFile Dot separated path to the layout file, relative to base path
- * @param object $displayData Object which properties are used inside the layout file to build displayed output
- * @param string $basePath Base path to use when loading layout files
+ * @param string $layoutFile Dot separated path to the layout file, relative to base path
+ * @param object $displayData Object which properties are used inside the layout file to build displayed output
+ * @param string $basePath Base path to use when loading layout files
*
* @return string
*
@@ -44,8 +44,8 @@ public static function render($layoutFile, $displayData = null, $basePath = '')
$basePath = empty($basePath) ? self::$defaultBasePath : $basePath;
// Make sure we send null to JLayoutFile if no path set
- $basePath = empty($basePath) ? null : $basePath;
- $layout = new JLayoutFile($layoutFile, $basePath);
+ $basePath = empty($basePath) ? null : $basePath;
+ $layout = new JLayoutFile($layoutFile, $basePath);
$renderedLayout = $layout->render($displayData);
return $renderedLayout;
diff --git a/libraries/cms/layout/layout.php b/libraries/cms/layout/layout.php
index 66601d97dc0df..0ab15d3c667db 100644
--- a/libraries/cms/layout/layout.php
+++ b/libraries/cms/layout/layout.php
@@ -22,7 +22,7 @@ interface JLayout
/**
* Method to escape output.
*
- * @param string $output The output to escape.
+ * @param string $output The output to escape.
*
* @return string The escaped output.
*
@@ -33,7 +33,7 @@ public function escape($output);
/**
* Method to render the layout.
*
- * @param object $displayData Object which properties are used inside the layout file to build displayed output
+ * @param object $displayData Object which properties are used inside the layout file to build displayed output
*
* @return string The rendered layout.
*
diff --git a/libraries/cms/menu/menu.php b/libraries/cms/menu/menu.php
index 65c3257f9c115..ccb4a5fa62be6 100644
--- a/libraries/cms/menu/menu.php
+++ b/libraries/cms/menu/menu.php
@@ -22,7 +22,7 @@ class JMenu
* Array to hold the menu items
*
* @var array
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Will convert to $items
*/
protected $_items = array();
@@ -31,7 +31,7 @@ class JMenu
* Identifier of the default menu item
*
* @var integer
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Will convert to $default
*/
protected $_default = array();
@@ -40,7 +40,7 @@ class JMenu
* Identifier of the active menu item
*
* @var integer
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Will convert to $active
*/
protected $_active = 0;
@@ -54,7 +54,7 @@ class JMenu
/**
* Class constructor
*
- * @param array $options An array of configuration options.
+ * @param array $options An array of configuration options.
*
* @since 1.5
*/
@@ -80,8 +80,8 @@ public function __construct($options = array())
/**
* Returns a JMenu object
*
- * @param string $client The name of the client
- * @param array $options An associative array of options
+ * @param string $client The name of the client
+ * @param array $options An associative array of options
*
* @return JMenu A menu object.
*
@@ -129,7 +129,7 @@ public static function getInstance($client, $options = array())
/**
* Get menu item by id
*
- * @param integer $id The item id
+ * @param integer $id The item id
*
* @return mixed The item object, or null if not found
*
@@ -141,7 +141,7 @@ public function getItem($id)
if (isset($this->_items[$id]))
{
- $result = &$this->_items[$id];
+ $result = & $this->_items[$id];
}
return $result;
@@ -150,8 +150,8 @@ public function getItem($id)
/**
* Set the default item by id and language code.
*
- * @param integer $id The menu item id.
- * @param string $language The language cod (since 1.6).
+ * @param integer $id The menu item id.
+ * @param string $language The language cod (since 1.6).
*
* @return boolean True, if successful
*
@@ -172,7 +172,7 @@ public function setDefault($id, $language = '')
/**
* Get the default item by language code.
*
- * @param string $language The language code, default value of * means all.
+ * @param string $language The language code, default value of * means all.
*
* @return object The item object
*
@@ -197,7 +197,7 @@ public function getDefault($language = '*')
/**
* Set the default item by id
*
- * @param integer $id The item id
+ * @param integer $id The item id
*
* @return mixed If successful the active item, otherwise null
*
@@ -208,7 +208,7 @@ public function setActive($id)
if (isset($this->_items[$id]))
{
$this->_active = $id;
- $result = &$this->_items[$id];
+ $result = & $this->_items[$id];
return $result;
}
@@ -227,7 +227,7 @@ public function getActive()
{
if ($this->_active)
{
- $item = &$this->_items[$this->_active];
+ $item = & $this->_items[$this->_active];
return $item;
}
@@ -238,10 +238,10 @@ public function getActive()
/**
* Gets menu items by attribute
*
- * @param mixed $attributes The field name(s).
- * @param mixed $values The value(s) of the field. If an array, need to match field names
+ * @param mixed $attributes The field name(s).
+ * @param mixed $values The value(s) of the field. If an array, need to match field names
* each attribute may have multiple values to lookup for.
- * @param boolean $firstonly If true, only returns the first item found
+ * @param boolean $firstonly If true, only returns the first item found
*
* @return array
*
@@ -249,9 +249,9 @@ public function getActive()
*/
public function getItems($attributes, $values, $firstonly = false)
{
- $items = array();
+ $items = array();
$attributes = (array) $attributes;
- $values = (array) $values;
+ $values = (array) $values;
foreach ($this->_items as $item)
{
@@ -299,7 +299,7 @@ public function getItems($attributes, $values, $firstonly = false)
/**
* Gets the parameter object for a certain menu item
*
- * @param integer $id The item id
+ * @param integer $id The item id
*
* @return JRegistry A JRegistry object
*
@@ -333,7 +333,7 @@ public function getMenu()
* Method to check JMenu object authorization against an access control
* object and optionally an access extension object
*
- * @param integer $id The menu id
+ * @param integer $id The menu id
*
* @return boolean True if authorised
*
diff --git a/libraries/cms/menu/site.php b/libraries/cms/menu/site.php
index 498838ba4afc4..2c4c4421c0833 100644
--- a/libraries/cms/menu/site.php
+++ b/libraries/cms/menu/site.php
@@ -49,6 +49,7 @@ public function load()
catch (RuntimeException $e)
{
JError::raiseWarning(500, JText::sprintf('JERROR_LOADING_MENUS', $e->getMessage()));
+
return false;
}
@@ -59,12 +60,12 @@ public function load()
if (isset($this->_items[$item->parent_id]))
{
- $parent_tree = $this->_items[$item->parent_id]->tree;
+ $parent_tree = $this->_items[$item->parent_id]->tree;
}
// Create tree.
$parent_tree[] = $item->id;
- $item->tree = $parent_tree;
+ $item->tree = $parent_tree;
// Create the query array.
$url = str_replace('index.php?', '', $item->link);
@@ -77,9 +78,9 @@ public function load()
/**
* Gets menu items by attribute
*
- * @param string $attributes The field name
- * @param string $values The value of the field
- * @param boolean $firstonly If true, only returns the first item found
+ * @param string $attributes The field name
+ * @param string $values The value of the field
+ * @param boolean $firstonly If true, only returns the first item found
*
* @return array
*
@@ -98,8 +99,8 @@ public function getItems($attributes, $values, $firstonly = false)
{
if (JLanguageMultilang::isEnabled())
{
- $attributes[] = 'language';
- $values[] = array(JFactory::getLanguage()->getTag(), '*');
+ $attributes[] = 'language';
+ $values[] = array(JFactory::getLanguage()->getTag(), '*');
}
}
elseif ($values[$key] === null)
@@ -112,7 +113,7 @@ public function getItems($attributes, $values, $firstonly = false)
if (($key = array_search('access', $attributes)) === false)
{
$attributes[] = 'access';
- $values[] = JFactory::getUser()->getAuthorisedViewLevels();
+ $values[] = JFactory::getUser()->getAuthorisedViewLevels();
}
elseif ($values[$key] === null)
{
@@ -123,7 +124,7 @@ public function getItems($attributes, $values, $firstonly = false)
// Reset arrays or we get a notice if some values were unset
$attributes = array_values($attributes);
- $values = array_values($values);
+ $values = array_values($values);
return parent::getItems($attributes, $values, $firstonly);
}
@@ -131,7 +132,7 @@ public function getItems($attributes, $values, $firstonly = false)
/**
* Get menu item by id
*
- * @param string $language The language code.
+ * @param string $language The language code.
*
* @return object The item object
*
diff --git a/libraries/cms/model/administrator.php b/libraries/cms/model/administrator.php
new file mode 100644
index 0000000000000..e80317d3a12e7
--- /dev/null
+++ b/libraries/cms/model/administrator.php
@@ -0,0 +1,661 @@
+getForm($data, false);
+
+ $validData = $this->validate($form, $data);
+
+ $table = $this->getTable();
+
+ if ((!empty($validData['tags']) && $validData['tags'][0] != ''))
+ {
+ $table->newTags = $validData['tags'];
+ }
+
+ //prepare the table for store
+ $table->bind($validData);
+ $table->check();
+
+ // Get dispatcher and include the content plugins for the on save events.
+ JPluginHelper::importPlugin('content');
+ $dispatcher = $this->getDispatcher();
+ $context = $this->getContext();
+
+ $result = $dispatcher->trigger('onContentBeforeSave', array($context, $table, true));
+
+ if (in_array(false, $result, true))
+ {
+ throw new ErrorException($table->getError());
+ }
+
+ // Store the data.
+ if (!$table->store())
+ {
+ throw new ErrorException($table->getError());
+ }
+
+ // Clean the cache.
+ $this->cleanCache();
+
+ // Trigger the onContentAfterSave event.
+ $dispatcher->trigger('onContentAfterSave', array($context, $table, true));
+
+ $pkName = $table->getKeyName();
+
+ if (isset($table->$pkName))
+ {
+ $context = $this->getContext();
+ $this->setState($context . '.id', $table->$pkName);
+ }
+
+ return true;
+ }
+
+ /**
+ * method for getting the form from the model.
+ *
+ * @param array $data Data for the form.
+ * @param boolean $loadData True if the form is to load its own data (default case), false if not.
+ *
+ * @return mixed A JForm object on success, false on failure
+ *
+ * @since 12.2
+ */
+ public function getForm($data = array(), $loadData = false)
+ {
+ $config = $this->config;
+ $form = $this->loadForm($config['option'] . '.' . $config['subject'], $config['subject'], array('control' => 'jform', 'load_data' => $loadData));
+
+ if (empty($form))
+ {
+ return false;
+ }
+
+ if (!empty($data) && $loadData == false)
+ {
+ $form->bind($data);
+ }
+
+ return $form;
+ }
+
+ /**
+ * Method to get a form object.
+ *
+ * @param string $name The name of the form.
+ * @param string $source The form source. Can be XML string if file flag is set to false.
+ * @param array $config Optional array of options for the form creation.
+ * @param boolean $clear Optional argument to force load a new form.
+ * @param bool|string $xpath An optional xpath to search for the fields.
+ *
+ * @return mixed JForm object on success, False on error.
+ *
+ * @see JForm
+ * @since 12.2
+ */
+ protected function loadForm($name, $source = null, $config = array(), $clear = false, $xpath = false)
+ {
+ // Handle the optional arguments.
+ $config['control'] = JArrayHelper::getValue($config, 'control', false);
+
+ // Create a signature hash.
+ $hash = md5($source . serialize($config));
+
+ // Check if we can use a previously loaded form.
+ if (isset($this->forms[$hash]) && !$clear)
+ {
+ return $this->forms[$hash];
+ }
+
+ // Get the form.
+ JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
+ JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
+ JForm::addFormPath(JPATH_COMPONENT . '/model/forms');
+ JForm::addFieldPath(JPATH_COMPONENT . '/model/fields');
+
+ $form = JForm::getInstance($name, $source, $config, false, $xpath);
+
+ if (isset($config['load_data']) && $config['load_data'])
+ {
+ // Get the data for the form.
+ $data = $this->loadFormData();
+ }
+ else
+ {
+ $data = array();
+ }
+
+ // Allow for additional modification of the form, and events to be triggered.
+ // We pass the data because plugins may require it.
+ $this->preprocessForm($form, $data);
+
+ // Load the data into the form after the plugins have operated.
+ $form->bind($data);
+
+
+ // Store the form for later.
+ $this->forms[$hash] = $form;
+
+ return $form;
+ }
+
+ /**
+ * Method to get the data that should be injected in the form.
+ *
+ * @param string $context user state variables context prefix
+ * @return array The default data is an empty array.
+ *
+ * @since 12.2
+ */
+ protected function loadFormData($context = null)
+ {
+ if(is_null($context))
+ {
+ $context = $this->getContext();
+ }
+
+ $data = JFactory::getApplication()->getUserState($context . '.jform.data', array());
+
+ if (empty($data))
+ {
+ $data = $this->getItem();
+ }
+
+ return $data;
+ }
+
+ /**
+ * Method to allow derived classes to preprocess the form.
+ *
+ * @param JForm $form A JForm object.
+ * @param mixed $data The data expected for the form.
+ * @param string $group The name of the plugin group to import (defaults to "content").
+ *
+ * @return void
+ *
+ * @see JFormField
+ * @since 12.2
+ * @throws Exception if there is an error in the form event.
+ */
+ protected function preprocessForm($form, $data, $group = 'content')
+ {
+ // Import the appropriate plugin group.
+ JPluginHelper::importPlugin($group);
+
+ $dispatcher = $this->getDispatcher();
+
+ // Trigger the form preparation event.
+ $results = $dispatcher->trigger('onContentPrepareForm', array($form, $data));
+
+ // Check for errors encountered while preparing the form.
+ if (count($results) && in_array(false, $results, true))
+ {
+ // Get the last error.
+ $error = $dispatcher->getError();
+
+ if (!($error instanceof Exception))
+ {
+ throw new Exception($error);
+ }
+ }
+ }
+
+ /**
+ * Method to validate the form data.
+ *
+ * @param JForm $form The form to validate against.
+ * @param array $data The data to validate.
+ * @param string $group The name of the field group to validate.
+ *
+ * @throws ErrorException
+ * @return mixed Array of filtered data if valid
+ *
+ * @see JFormRule
+ * @see JFilterInput
+ * @since 12.2
+ */
+ public function validate($form, $data, $group = null)
+ {
+ // Filter and validate the form data.
+ $data = $form->filter($data);
+
+ try
+ {
+ $return = $form->validate($data, $group);
+ }
+ catch (Exception $e)
+ {
+ throw new ErrorException($e->getMessage());
+ }
+
+ // Check the validation results.
+ if ($return === false)
+ {
+ $msg = '';
+ $i = 0;
+
+ // Get the validation messages from the form.
+ foreach ($form->getErrors() as $e)
+ {
+ if ($i != 0)
+ {
+ $msg .= '
';
+ }
+
+ $msg .= $e->getMessage();
+ $i++;
+ }
+
+ throw new ErrorException($msg);
+ }
+
+ // Tags B/C break at 3.1.2
+ if (isset($data['metadata']['tags']) && !isset($data['tags']))
+ {
+ $data['tags'] = $data['metadata']['tags'];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Method to validate data and update into db
+ *
+ * @param array $data
+ *
+ * @throws ErrorException
+ * @return boolean
+ */
+ public function update($data)
+ {
+
+ $form = $this->getForm($data, false);
+ $validData = $this->validate($form, $data);
+
+ $table = $this->getTable();
+
+ if ((!empty($validData['tags']) && $validData['tags'][0] != ''))
+ {
+ $table->newTags = $validData['tags'];
+ }
+
+ //prepare the table for store
+ $pk = $data[$table->getKeyName()];
+ $table->load($pk);
+ $table->bind($validData);
+ $table->check();
+
+ // Get dispatcher and include the content plugins for the on save events.
+ JPluginHelper::importPlugin('content');
+ $dispatcher = $this->getDispatcher();
+ $config = $this->config;
+
+ $result = $dispatcher->trigger('onContentBeforeSave', array($config['option'] . '.' . $config['subject'], $table, false));
+
+ if (in_array(false, $result, true))
+ {
+ throw new ErrorException($table->getError());
+ }
+
+ // Store the data.
+ if (!$table->store())
+ {
+ throw new ErrorException($table->getError());
+ }
+
+ // Clean the cache.
+ $this->cleanCache();
+
+ // Trigger the onContentAfterSave event.
+ $dispatcher->trigger('onContentAfterSave', array($config['option'] . '.' . $config['subject'], $table, false));
+
+ $pkName = $table->getKeyName();
+
+ if (isset($table->$pkName))
+ {
+ $this->setState($config['subject'] . '.id', $table->$pkName);
+ }
+
+ return true;
+ }
+
+ /**
+ * Method to delete one or more records.
+ *
+ * @param array $cid array of record primary keys.
+ *
+ * @throws ErrorException
+ * @internal param array $pks
+ *
+ * @return boolean True if successful, false if an error occurs.
+ *
+ * @since 12.2
+ */
+ public function delete($cid)
+ {
+ // Include the content plugins for the on delete events.
+ JPluginHelper::importPlugin('content');
+ $dispatcher = $this->getDispatcher();
+
+ $config = $this->config;
+ $pks = (array) $cid;
+
+ foreach ($pks AS $pk)
+ {
+ $context = $config['option'] . '.' . $config['subject'];
+
+ $activeRecord = $this->getActiveRecord($pk);
+
+ if ($this->allowAction('core.delete', $config['option'], $activeRecord))
+ {
+ // Trigger the onContentBeforeDelete event.
+ $result = $dispatcher->trigger('onContentBeforeDelete', array($context, $activeRecord));
+
+ if (in_array(false, $result, true))
+ {
+ throw new ErrorException($activeRecord->getError());
+ }
+
+ $activeRecord->delete($pk);
+
+ // Trigger the onContentAfterDelete event.
+ $dispatcher->trigger('onContentAfterDelete', array($context, $activeRecord));
+ }
+ else
+ {
+ throw new ErrorException('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED');
+
+ }
+ }
+
+ // Clear the component's cache
+ $this->cleanCache();
+
+ return true;
+ }
+
+ /**
+ * Method to update one or more record states
+ *
+ * @param mixed $cid primary key or array of primary keys.
+ * @param string $type type of state change.
+ *
+ * @see JCmsModelAdministrator::getStateTypes
+ * @throws ErrorException
+ * @return boolean
+ */
+ public function updateRecordState($cid, $type)
+ {
+ $stateChangeTypes = $this->getStateTypes();
+
+ if (!array_key_exists($type, $stateChangeTypes))
+ {
+ throw new ErrorException('JLIB_APPLICATION_ERROR_UNRECOGNIZED_STATE_CHANGE');
+ }
+
+ $newState = $stateChangeTypes[$type];
+
+ $user = JFactory::getUser();
+ $config = $this->config;
+ $pks = (array) $cid;
+
+ foreach ($pks AS $i => $pk)
+ {
+ $activeRecord = $this->getActiveRecord($pk);
+
+ if ($this->allowAction('core.edit.state', $config['option'], $activeRecord))
+ {
+ $activeRecord->updateRecordState($pk, $newState, $user->id);
+ }
+ else
+ {
+ //remove items we cannot edit.
+ unset($cid[$i]);
+ }
+ }
+
+ // Include the content plugins for the change of state event.
+ JPluginHelper::importPlugin('content');
+ $dispatcher = $this->getDispatcher();
+
+ $context = $this->getContext();
+
+ //trigger 'onContentChangeState'
+ $result = $dispatcher->trigger('onContentChangeState', array($context, $cid, $newState));
+
+ if (!in_array(false, $result, true))
+ {
+ // Clear the component's cache
+ $this->cleanCache();
+ }
+
+ return true;
+ }
+
+ /**
+ * Method to get an associative array of state types.
+ * Default array has these values 'publish' => 1, 'unpublish' => 0,'archive' => 2,'trash' => -2,'report' => -3
+ * This allows extensions to add additional states to their records by overloading this function.
+ * @return array $stateChangeTypes
+ */
+ protected function getStateTypes()
+ {
+ $stateChangeTypes = array();
+ $stateChangeTypes['publish'] = 1;
+ $stateChangeTypes['unpublish'] = 0;
+ $stateChangeTypes['archive'] = 2;
+ $stateChangeTypes['trash'] = -2;
+ $stateChangeTypes['report'] = -3;
+
+ return $stateChangeTypes;
+ }
+
+ /**
+ * Method to reorder one or more records
+ *
+ * @param array $cid
+ * @param string $direction up or down
+ *
+ * @throws ErrorException
+ * @return boolean
+ */
+ public function reorder($cid, $direction)
+ {
+ $direction = strtoupper($direction);
+
+ if ($direction == 'UP')
+ {
+ $delta = -1;
+ }
+ elseif ($direction == 'DOWN')
+ {
+ $delta = 1;
+ }
+ else
+ {
+ $delta = null;
+ }
+
+ $config = $this->config;
+ $pks = (array) $cid;
+
+ foreach ($pks AS $pk)
+ {
+ $activeRecord = $this->getActiveRecord($pk);
+
+ if ($this->allowAction('core.edit.state', $config['option'], $activeRecord))
+ {
+ $where = $activeRecord->getReorderConditions($activeRecord);
+ $activeRecord->moveOrder($pk, $delta, $where);
+ }
+ else
+ {
+ throw new ErrorException('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED');
+ }
+ }
+
+ // Clear the component's cache
+ $this->cleanCache();
+
+ return true;
+ }
+
+ /**
+ * Saves the manually set order of records.
+ *
+ * @param array $cid An array of primary key ids.
+ * @param integer $order +1 or -1
+ *
+ * @throws ErrorException
+ * @return mixed
+ *
+ * @since 12.2
+ */
+ public function saveorder($cid = null, $order = null)
+ {
+ if (empty($cid))
+ {
+ throw new ErrorException(JText::_('JLIB_APPLICATION_ERROR_NO_ITEMS_SELECTED'));
+ }
+
+
+ /*
+ * This is something that needs to be worked out once changes to JTable are completed
+ * Commented out because I haven't really studied the implementation, so this code might not be correct.
+ * $table = $this->getTable();
+ * $tableClassName = get_class($table);
+ * $contentType = new JUcmType;
+ * $type = $contentType->getTypeByTable($tableClassName);
+ * $typeAlias = $type->type_alias;
+ * $tagsObserver = $table->getObserverOfClass('JTableObserverTags');
+ */
+
+ $conditions = array();
+ $config = $this->config;
+ $pks = (array) $cid;
+ // Update ordering values
+ foreach ($pks as $i => $pk)
+ {
+ $activeRecord = $this->getActiveRecord($pk);
+ // Access checks.
+ if ($this->allowAction('core.edit.state', $config['option'], $activeRecord))
+ {
+ $activeRecord->ordering = $order[$i];
+
+ // Store the data.
+ if (!$activeRecord->store())
+ {
+ throw new ErrorException($activeRecord->getError());
+ }
+
+ // Remember to reorder within position and client_id
+ $condition = $activeRecord->getReorderConditions($activeRecord);
+ $found = false;
+
+ foreach ($conditions as $cond)
+ {
+ if ($cond[1] == $condition)
+ {
+ $found = true;
+ break;
+ }
+ }
+
+ if (!$found)
+ {
+ $key = $activeRecord->getKeyName();
+ $conditions[] = array($activeRecord->$key, $condition);
+ }
+ }
+ }
+
+ // Execute reorder for each condition.
+ foreach ($conditions as $cond)
+ {
+ $table = $this->getTable();
+ $table->load($cond[0]);
+ $table->reorder($cond[1]);
+ }
+
+ // Clear the component's cache
+ $this->cleanCache();
+
+ return true;
+ }
+
+ /**
+ * Method to import one or more files.
+ *
+ * This method is intended to be overridden by child classes.
+ *
+ * @param array $data post data from the input
+ * @param array $files files data from the input
+ *
+ * @throws ErrorException
+ */
+ public function import($data, $files)
+ {
+ throw new ErrorException(JText::_('JLIB_APPLICATION_ERROR_IMPORT_NOT_SUPPORTED'));
+ }
+
+ /**
+ * Method to allow derived classes to preprocess the data.
+ *
+ * @param string $context The context identifier.
+ * @param mixed &$data The data to be processed. It gets altered directly.
+ *
+ * @throws Exception
+ * @return void
+ *
+ * @since 3.1
+ */
+ protected function preprocessData($context, &$data)
+ {
+ // Get the dispatcher and load the users plugins.
+ $dispatcher = $this->getDispatcher();
+ JPluginHelper::importPlugin('content');
+
+ // Trigger the data preparation event.
+ $results = $dispatcher->trigger('onContentPrepareData', array($context, $data));
+
+ // Check for errors encountered while preparing the data.
+ if (count($results) > 0 && in_array(false, $results, true))
+ {
+ // Get the last error.
+ $error = $dispatcher->getError();
+
+ if (!($error instanceof Exception))
+ {
+ throw new Exception($error);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/libraries/cms/model/cms.php b/libraries/cms/model/cms.php
new file mode 100644
index 0000000000000..cf6aae71efc72
--- /dev/null
+++ b/libraries/cms/model/cms.php
@@ -0,0 +1,243 @@
+config = $config;
+
+ if (array_key_exists('state', $config) && ($config['state'] instanceof JObject))
+ {
+ $this->state = $config['state'];
+ }
+ else
+ {
+ $this->state = new JObject();
+ }
+
+ if (!empty($config['ignore_request']))
+ {
+ $this->ignoreRequest = true;
+ }
+ }
+
+ /**
+ * Method to get model state variables
+ *
+ * @param string $property Optional parameter name
+ * @param mixed $default Optional default value
+ *
+ * @return object The property where specified, the state object where omitted
+ *
+ * @since 12.2
+ */
+ public function getState($property = null, $default = null)
+ {
+ if (!$this->ignoreRequest && !$this->stateIsSet)
+ {
+ // Protected method to auto-populate the model state.
+ $this->populateState();
+
+ // Set the model state set flag to true.
+ $this->stateIsSet = true;
+ }
+
+ if ($property === null)
+ {
+ $returnProperty = $this->state;
+ }
+ else
+ {
+ $returnProperty = $this->state->get($property, $default);
+ }
+
+ return $returnProperty;
+ }
+
+ /**
+ * Method to set model state variables
+ *
+ * @param string $property The name of the property.
+ * @param mixed $value The value of the property to set or null.
+ *
+ * @return mixed The previous value of the property or null if not set.
+ *
+ * @since 12.2
+ */
+ public function setState($property, $value = null)
+ {
+ return $this->state->set($property, $value);
+ }
+
+ /**
+ * Method to auto-populate the model state.
+ *
+ * This method should only be called once per instantiation and is designed
+ * to be called on the first call to the getState() method unless the model
+ * configuration flag to ignore the request is set.
+ *
+ * @param string $ordering column to order by. I.E. 'a.title'
+ * @param string $direction 'ASC' or 'DESC'
+ *
+ * @return void
+ *
+ * @note Calling getState in this method will result in recursion.
+ * @since 12.2
+ */
+ protected function populateState($ordering = null, $direction = null)
+ {
+ if (!$this->stateIsSet)
+ {
+ //do something
+ }
+ }
+
+ /**
+ * Method to authorise the current user for an action.
+ * This method is intended to be overridden to allow for customized access rights
+ *
+ * @param string $action ACL action string. I.E. 'core.create'
+ * @param string $assetName asset name to check against.
+ * @param object $activeRecord active record data to check against
+ *
+ * @return bool
+ * @see JUser::authorise
+ */
+ public function allowAction($action, $assetName = null, $activeRecord = null)
+ {
+ if (is_null($assetName))
+ {
+ $config = $this->config;
+ $assetName = $config['option'];
+ }
+
+ $user = JFactory::getUser();
+
+ return $user->authorise($action, $assetName);
+ }
+
+ /**
+ * Method to get the model context.
+ * $context = $config['option'].'.'.$config['subject'];
+ * @return string
+ */
+ public function getContext()
+ {
+ $config = $this->config;
+ $context = $config['option'] . '.' . $config['subject'];
+
+ return $context;
+ }
+
+ /**
+ * Clean the cache
+ *
+ * @param string $group The cache group
+ * @param integer $client_id The ID of the client
+ *
+ * @return void
+ *
+ * @since 12.2
+ */
+ protected function cleanCache($group = null, $client_id = 0)
+ {
+ $localConfig = $this->config;
+ $dispatcher = $this->getDispatcher();
+
+ $options = array();
+
+ if ($group)
+ {
+ $options['defaultgroup'] = $group;
+ }
+ else
+ {
+ $options['defaultgroup'] = $localConfig['option'];
+ }
+
+ if ($client_id)
+ {
+ $options['cachebase'] = JPATH_ADMINISTRATOR . '/cache';
+ }
+ else
+ {
+ $globalConfig = JFactory::getConfig();
+ $options['cachbase'] = $globalConfig->get('cache_path', JPATH_SITE . '/cache');
+ }
+
+ $cache = JCache::getInstance('callback', $options);
+ $cache->clean();
+
+ // Trigger the onContentCleanCache event.
+ $dispatcher->trigger('onContentCleanCache', $options);
+ }
+
+ /**
+ * Method to get a dispatcher
+ * @return JEventDispatcher
+ */
+ public function getDispatcher()
+ {
+ $version = new JVersion();
+ if ($version->isCompatible('3.0'))
+ {
+ // Get the dispatcher.
+ $dispatcher = JEventDispatcher::getInstance();
+ }
+ else
+ {
+ // Get the dispatcher.
+ $dispatcher = JDispatcher::getInstance();
+ }
+
+ return $dispatcher;
+ }
+
+ /**
+ * Method to check the session token
+ */
+ protected function validateSession()
+ {
+ JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
+ }
+}
diff --git a/libraries/cms/model/collection.php b/libraries/cms/model/collection.php
new file mode 100644
index 0000000000000..71988ec9c0095
--- /dev/null
+++ b/libraries/cms/model/collection.php
@@ -0,0 +1,484 @@
+addFilterField($name, $dataKeyName, $sortable, $searchable);
+ }
+ }
+ }
+ }
+
+ /**
+ * Method to add field to filterField and/or to searchFields arrays
+ *
+ * @param string $name name of the filter I.E. "title"
+ * @param string $dataKeyName name of the database key I.E. "a.title"
+ * @param bool $sortable true to add to the filterFields array
+ * @param bool $searchable true to add to the searchFields array
+ *
+ * @return JModelList $this to allow for chaining
+ */
+ public function addFilterField($name, $dataKeyName, $sortable = true, $searchable = false)
+ {
+ $filterField = array('name' => $name, 'dataKeyName' => $dataKeyName);
+
+ if ($sortable)
+ {
+ $this->filterFields[$dataKeyName] = $filterField;
+ }
+
+ if ($searchable)
+ {
+ $this->searchFields[$dataKeyName] = $filterField;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Method to get an array of data items.
+ *
+ * @return mixed An array of data items on success, false on failure.
+ *
+ * @since 12.2
+ */
+ public function getItems()
+ {
+ $db = $this->getDbo();
+ // Load the list items.
+ $query = $this->getListQuery();
+
+ $start = $this->getStart();
+ $limit = $this->getState('list.limit', 0);
+
+ $db->setQuery($query, $start, (int) $limit);
+
+ $items = $db->loadObjectList();
+
+ return $items;
+ }
+
+ /**
+ * Method to get a JDatabaseQuery object for retrieving the data set from a database.
+ *
+ * If you send a $query object to this function it will append active filters before returning.
+ *
+ * If you don't send a $query it will return a $query object with:
+ *
+ * $query->select('a.*');
+ * $query->from($tableName.' AS a');
+ *
+ * before appending the active filters.
+ *
+ * @param JDatabaseQuery $query
+ *
+ * @return JDatabaseQuery A JDatabaseQuery object to retrieve the data set.
+ *
+ * @since 12.2
+ */
+ protected function getListQuery(JDatabaseQuery $query = null)
+ {
+ $db = $this->getDbo();
+
+ if (is_null($query))
+ {
+ $query = $db->getQuery(true);
+
+ $table = $this->getTable();
+ $tableName = $table->getTableName();
+
+ $query->select('a.*');
+ $query->from($tableName . ' AS a');
+ }
+
+ if (array_key_exists('a.state', $this->filterFields))
+ {
+ $state = $this->getState('filter.state');
+
+ if (is_numeric($state))
+ {
+ $query->where('a.state = ' . (int) $state);
+ }
+ else if ($state === '')
+ {
+ $query->where('(a.state IN (0, 1))');
+ }
+ }
+
+ $activeFilters = $this->getActiveFilters();
+ foreach ($activeFilters AS $dataKeyName => $value)
+ {
+ $query->where($dataKeyName . ' = ' . $db->quote($value));
+ }
+
+ $search = $this->buildSearch();
+
+ if ($search != '' && JString::strlen($search) != 0)
+ {
+ $query->where($search);
+ }
+
+ $orderCol = $this->state->get('list.ordering');
+ $orderDirn = $this->state->get('list.direction');
+
+ if ($orderCol && $orderDirn)
+ {
+ $query->order($db->escape($orderCol . ' ' . $orderDirn));
+ }
+
+ return $query;
+ }
+
+ /**
+ * Function to get the active filters
+ *
+ * @return array Associative array in the format: array('filter_published' => 0)
+ *
+ * @since 3.2
+ */
+ public function getActiveFilters()
+ {
+ $activeFilters = array();
+
+ if (count($this->filterFields) != 0)
+ {
+ foreach ($this->filterFields as $filterField)
+ {
+ $filterName = 'filter.' . $filterField['name'];
+
+ $stateHasFilter = property_exists($this->state, $filterName);
+ if ($stateHasFilter)
+ {
+ $validState = (!empty($this->state->$filterName) || is_numeric($this->state->$filterName));
+ $isPublishFilter = ($filterName == 'filter.state');
+
+ if ($validState && !$isPublishFilter)
+ {
+ $activeFilters[$filterField['dataKeyName']] = $this->state->get($filterName);
+ }
+ }
+ }
+ }
+
+ return $activeFilters;
+ }
+
+ protected function buildSearch()
+ {
+ $db = JFactory::getDbo();
+ $search = $this->getState('filter.search');
+ $where = null;
+
+ if (!empty($search))
+ {
+ if (isset($this->searchFields))
+ {
+
+ $searchInList = (array) $this->searchFields;
+
+ $isExact = (JString::strrpos($search, '"'));
+
+ if ($isExact)
+ {
+ $search = JString::substr($search, 1, -1);
+ $where = '( ';
+ foreach ((array) $searchInList as $search_field)
+ {
+ $cleanSearch = $db->Quote($db->escape($search, true));
+ $where .= ' ' . $search_field['dataKeyName'] . ' = ' . $cleanSearch . ' OR';
+ }
+ $where = substr($where, 0, -3);
+ $where .= ')';
+ }
+ else
+ {
+ $search = $db->Quote('%' . $db->escape($search, true) . '%');
+
+ $where = '( ';
+ foreach ((array) $searchInList as $search_field)
+ {
+ $where .= ' ' . $search_field['dataKeyName'] . ' LIKE ' . $search . ' OR ';
+ }
+ $where = substr($where, 0, -3);
+ $where .= ')';
+ }
+ }
+ }
+ return $where; //no search found
+ }
+
+ /**
+ * Method to get the starting number of items for the data set.
+ *
+ * @return integer The starting number of items available in the data set.
+ *
+ * @since 12.2
+ */
+ public function getStart()
+ {
+
+ $start = $this->getState('list.start');
+ $limit = $this->getState('list.limit');
+ $total = $this->getTotal();
+
+ if ($start > $total - $limit)
+ {
+ $start = max(0, (int) (ceil($total / $limit) - 1) * $limit);
+ }
+
+ return $start;
+ }
+
+ /**
+ * Method to get the total number of items for the data set.
+ *
+ * @return integer The total number of items available in the data set.
+ *
+ * @since 12.2
+ */
+ public function getTotal()
+ {
+ // Get a storage key.
+ $total = $this->getState('list.total', null);
+
+ if ($total == null)
+ {
+ // Load the total.
+ $query = $this->getListQuery();
+
+ $total = (int) $this->_getListCount($query);
+ $this->setState('list.total', $total);
+ }
+
+ return $total;
+ }
+
+ /**
+ * Returns a record count for the query.
+ *
+ * @param JDatabaseQuery $query The query.
+ *
+ * @return integer Number of rows for query.
+ *
+ * @since 12.2
+ */
+ protected function _getListCount(JDatabaseQuery $query)
+ {
+ $db = $this->getDbo();
+
+ //if this is a select and there are no GROUP BY or HAVING clause
+ //Use COUNT(*) method to improve performance.
+
+ $isSelect = ($query->type == 'select');
+ $hasGroupClause = ($query->group === null);
+ $hasHaveClause = ($query->having === null);
+
+ if ($isSelect && !$hasGroupClause && !$hasHaveClause)
+ {
+ $query = clone $query;
+ $query->clear('select')->clear('order')->select('COUNT(*)');
+
+ $db->setQuery($query);
+
+ return (int) $db->loadResult();
+ }
+
+ // Else use brute-force and count all returned results.
+ $db->setQuery($query);
+ $db->execute();
+
+ return (int) $db->getNumRows();
+ }
+
+ /**
+ * Method to get a JPagination object for the data set.
+ *
+ * @return JPagination A JPagination object for the data set.
+ *
+ * @since 12.2
+ */
+ public function getPagination()
+ {
+ // Create the pagination object.
+ jimport('joomla.html.pagination');
+ $limit = (int) $this->getState('list.limit') - (int) $this->getState('list.links');
+ $page = new JPagination($this->getTotal(), $this->getStart(), $limit);
+
+ return $page;
+ }
+
+ /**
+ * Gets the value of a user state variable and sets it in the session
+ *
+ * This is the same as the method in JApplication except that this also can optionally
+ * force you back to the first page when a filter has changed
+ *
+ * @param string $key The key of the user state variable.
+ * @param string $request The name of the variable passed in a request.
+ * @param string $default The default value for the variable if not found. Optional.
+ * @param string $type Filter for the variable, for valid values see {@link JFilterInput::clean()}. Optional.
+ * @param boolean $resetPage If true, the limitstart in request is set to zero
+ *
+ * @return mixed The request user state.
+ *
+ * @since 12.2
+ */
+ public function getUserStateFromRequest($key, $request, $default = null, $type = 'none', $resetPage = true)
+ {
+ $app = JFactory::getApplication();
+ $input = $app->input;
+
+ $old_state = $app->getUserState($key);
+ if (!is_null($old_state))
+ {
+ $cur_state = $old_state;
+ }
+ else
+ {
+ $cur_state = $default;
+ }
+
+ $new_state = $input->get($request, null, $type);
+
+ $hasChanged = ($cur_state != $new_state);
+
+ if ($hasChanged && $resetPage)
+ {
+ $input->set('limitstart', 0);
+ $input->set('list.total', null);
+
+ }
+
+ // Save the new value only if it is set in this request.
+ if ($new_state !== null)
+ {
+ $app->setUserState($key, $new_state);
+ }
+ else
+ {
+ $new_state = $cur_state;
+ }
+
+ return $new_state;
+ }
+
+ /**
+ * @see JModelCms::populateState()
+ */
+ protected function populateState($ordering = null, $direction = null)
+ {
+ $context = $this->getContext();
+
+ if (!$this->stateIsSet)
+ {
+ $app = JFactory::getApplication();
+
+ $filters = $app->getUserStateFromRequest($context . '.filter', 'filter', array(), 'array');
+
+ foreach ($filters AS $name => $value)
+ {
+ $this->setState('filter.' . $name, $value);
+ }
+
+ $limit = $app->getUserStateFromRequest($context . 'list.limit', 'limit', $app->getCfg('list_limit'), 'uint');
+ $this->setState('list.limit', $limit);
+
+ // Check if the ordering field is in the white list, otherwise use the incoming value.
+ $orderColName = $app->getUserStateFromRequest($context . '.ordercol', 'filter_order', $ordering);
+
+ if (!array_key_exists($orderColName, $this->filterFields))
+ {
+ $orderColName = $ordering;
+ $app->setUserState($context . '.ordercol', $orderColName);
+ }
+
+ $this->setState('list.ordering', $orderColName);
+
+ // Check if the ordering direction is valid, otherwise use the incoming value.
+ $orderDir = $app->getUserStateFromRequest($context . '.orderdirn', 'filter_order_Dir', $direction);
+
+ if (!in_array(strtoupper($orderDir), array('ASC', 'DESC')))
+ {
+ $orderDir = $direction;
+ $app->setUserState($context . '.orderdirn', $orderDir);
+ }
+
+ $this->setState('list.direction', strtoupper($orderDir));
+
+ $limitStartValue = $app->getUserStateFromRequest($context . '.limitstart', 'limitstart', 0, 'int');
+
+ if ($limit != 0)
+ {
+ $limitStart = (floor($limitStartValue / $limit) * $limit);
+ }
+ else
+ {
+ $limitStart = 0;
+ }
+
+ $this->setState('list.start', $limitStart);
+
+ parent::populateState($ordering, $direction);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/libraries/cms/model/data.php b/libraries/cms/model/data.php
new file mode 100644
index 0000000000000..4596871254188
--- /dev/null
+++ b/libraries/cms/model/data.php
@@ -0,0 +1,223 @@
+getTable($tablePrefix, $tableName, $config);
+
+ return $table->getKeyName();
+ }
+
+ /**
+ * Method to get a table object, load it if necessary.
+ *
+ * @param string $prefix The class prefix. Optional.
+ * @param string $name The table name. Optional.
+ * @param array $config Configuration array for model. Optional.
+ *
+ * @return JTable A JTable object
+ *
+ * @since 12.2
+ * @throws ErrorException
+ */
+ public function getTable($prefix = null, $name = null, $config = array())
+ {
+ if (count($config) == 0)
+ {
+ $config = $this->config;
+ }
+ else
+ {
+ //merge sent config to
+ //make sure both subject and options
+ //are always set.
+ //Will not overwrite existing keys
+ $config += $this->config;
+ }
+
+ if (empty($name))
+ {
+ $name = ucfirst($config['subject']);
+ }
+
+ if (empty($prefix))
+ {
+ $prefix = ucfirst(substr($config['option'], 4));
+ }
+
+ if (!$table = $this->createTable( $prefix, $name, $config))
+ {
+ throw new ErrorException(JText::sprintf('JLIB_APPLICATION_ERROR_TABLE_NAME_NOT_SUPPORTED', $prefix . 'Table' . $name), 0);
+ }
+ return $table;
+
+ }
+
+ /**
+ * Method to load and return a model object.
+ *
+ * @param string $prefix The class prefix. Optional.
+ * @param string $name The name of the view
+ * @param array $config Configuration settings to pass to JTable::getInstance
+ *
+ * @return mixed A JTable object or boolean false if failed
+ *
+ * @since 12.2
+ * @see JTable::getInstance()
+ */
+ protected function createTable($prefix, $name, $config = array())
+ {
+ // Clean the model name
+ $prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
+ $name = preg_replace('/[^A-Z0-9_]/i', '', $name);
+
+ // Make sure we are returning a DBO object
+ if (!array_key_exists('dbo', $config))
+ {
+ $config['dbo'] = $this->getDbo();
+ }
+
+ $className = $prefix . 'Table' . $name;
+
+ return new $className($config);
+ }
+
+ /**
+ * Method to lock a record for editing
+ *
+ * @param int $pk primary key of record
+ *
+ * @throws InvalidArgumentException
+ * @throws ErrorException
+ * @return boolean
+ * @see JCmsModelData::checkin
+ */
+ public function checkout($pk)
+ {
+ $activeRecord = $this->getActiveRecord($pk);
+ $user = JFactory::getUser();
+
+ $activeRecord->checkout($user->id, $pk);
+
+ return true;
+ }
+
+ /**
+ * Method to unlock a record
+ *
+ * @param int $pk primary key
+ *
+ * @throws InvalidArgumentException
+ * @throws ErrorException
+ * @return boolean
+ * @see JCmsModelData::checkout
+ */
+ public function checkin($pk)
+ {
+ // Get an instance of the row to checkout.
+ $activeRecord = $this->getActiveRecord($pk);
+
+ $activeRecord->checkin($pk);
+
+ return true;
+ }
+
+ /**
+ * Method to get a loaded active record.
+ *
+ * @param int $pk primary key
+ *
+ * @throws ErrorException
+ * @return JTable
+ */
+ protected function getActiveRecord($pk)
+ {
+ // Get an instance of the row to checkout.
+ $table = $this->getTable();
+
+ if (!$table->load($pk))
+ {
+ throw new ErrorException($table->getError());
+ }
+
+ return $table;
+ }
+
+ /**
+ * Method to check if a table is lockable
+ *
+ * @param JTable $table
+ *
+ * @return boolean
+ */
+ protected function isLockable($table)
+ {
+ $hasCheckedOut = (property_exists($table, 'checked_out'));
+ $hasCheckedOutTime = (property_exists($table, 'checked_out_time'));
+ // If there is no checked_out or checked_out_time field, just return true.
+
+ if ($hasCheckedOut && $hasCheckedOutTime)
+ {
+ return true; // is lockable
+ }
+
+ return false; // is not lockable
+ }
+
+
+ /**
+ * Method to check if a record is locked
+ *
+ * @param JTable $activeRecord
+ *
+ * @return boolean
+ */
+ protected function isLocked($activeRecord)
+ {
+ if ($this->isLockable($activeRecord))
+ {
+ $isCheckedOut = ($activeRecord->checked_out > 0);
+
+ $user = JFactory::getUser();
+ $isCurrentEditor = ($activeRecord->checked_out == $user->get('id'));
+ $canOverride = ($user->authorise('core.admin', 'com_checkin'));
+
+ if ($isCheckedOut && !$isCurrentEditor && !$canOverride)
+ {
+ return true; // record is locked
+ }
+ }
+ return false; // record is not locked
+ }
+}
diff --git a/libraries/cms/model/index.html b/libraries/cms/model/index.html
new file mode 100644
index 0000000000000..2efb97f319a35
--- /dev/null
+++ b/libraries/cms/model/index.html
@@ -0,0 +1 @@
+
diff --git a/libraries/cms/model/record.php b/libraries/cms/model/record.php
new file mode 100644
index 0000000000000..2491653c83888
--- /dev/null
+++ b/libraries/cms/model/record.php
@@ -0,0 +1,47 @@
+getContext();
+ $pk = (int) $this->getState($context . '.id');
+ }
+
+ $activeRecord = $this->getActiveRecord($pk);
+
+ // Convert to the JObject before adding other data.
+ $properties = $activeRecord->getProperties(1);
+ $item = JArrayHelper::toObject($properties, 'JObject');
+
+ if (property_exists($item, 'params'))
+ {
+ $registry = new JRegistry;
+ $registry->loadString($item->params);
+ $item->params = $registry->toArray();
+ }
+
+ return $item;
+ }
+
+}
\ No newline at end of file
diff --git a/libraries/cms/model/ucm.php b/libraries/cms/model/ucm.php
new file mode 100644
index 0000000000000..3f1c0c5175925
--- /dev/null
+++ b/libraries/cms/model/ucm.php
@@ -0,0 +1,59 @@
+load($version_id))
+ {
+ throw new ErrorException($historyTable->getError());
+ }
+
+ $rowArray = JArrayHelper::fromObject(json_decode($historyTable->version_data));
+
+ $typeId = JTable::getInstance('Contenttype')->getTypeId($this->typeAlias);
+
+ if ($historyTable->ucm_type_id != $typeId)
+ {
+ $key = $table->getKeyName();
+
+ if (isset($rowArray[$key]))
+ {
+ $table->checkIn($rowArray[$key]);
+ }
+
+ throw new ErrorException(JText::_('JLIB_APPLICATION_ERROR_HISTORY_ID_MISMATCH'));
+ }
+ }
+
+ $this->setState('save_date', $historyTable->save_date);
+ $this->setState('version_note', $historyTable->version_note);
+
+ return $table->bind($rowArray);
+ }
+}
\ No newline at end of file
diff --git a/libraries/cms/pagination/object.php b/libraries/cms/pagination/object.php
index 2ff4afcd8d0f8..1d6db77d86e3d 100644
--- a/libraries/cms/pagination/object.php
+++ b/libraries/cms/pagination/object.php
@@ -51,11 +51,11 @@ class JPaginationObject
/**
* Class constructor.
*
- * @param string $text The link text.
- * @param integer $prefix The prefix used for request variables.
- * @param integer $base The number of rows as a base offset.
- * @param string $link The link URL.
- * @param boolean $active Flag whether the object is the 'active' page
+ * @param string $text The link text.
+ * @param integer $prefix The prefix used for request variables.
+ * @param integer $base The number of rows as a base offset.
+ * @param string $link The link URL.
+ * @param boolean $active Flag whether the object is the 'active' page
*
* @since 1.5
*/
diff --git a/libraries/cms/pagination/pagination.php b/libraries/cms/pagination/pagination.php
index 248bce2dac840..49edf4fc878d1 100644
--- a/libraries/cms/pagination/pagination.php
+++ b/libraries/cms/pagination/pagination.php
@@ -84,20 +84,20 @@ class JPagination
/**
* Constructor.
*
- * @param integer $total The total number of items.
- * @param integer $limitstart The offset of the item to start at.
- * @param integer $limit The number of items to display per page.
- * @param string $prefix The prefix used for request variables.
+ * @param integer $total The total number of items.
+ * @param integer $limitstart The offset of the item to start at.
+ * @param integer $limit The number of items to display per page.
+ * @param string $prefix The prefix used for request variables.
*
* @since 1.5
*/
public function __construct($total, $limitstart, $limit, $prefix = '')
{
// Value/type checking.
- $this->total = (int) $total;
+ $this->total = (int) $total;
$this->limitstart = (int) max($limitstart, 0);
- $this->limit = (int) max($limit, 0);
- $this->prefix = $prefix;
+ $this->limit = (int) max($limit, 0);
+ $this->prefix = $prefix;
if ($this->limit > $this->total)
{
@@ -106,7 +106,7 @@ public function __construct($total, $limitstart, $limit, $prefix = '')
if (!$this->limit)
{
- $this->limit = $total;
+ $this->limit = $total;
$this->limitstart = 0;
}
@@ -122,12 +122,12 @@ public function __construct($total, $limitstart, $limit, $prefix = '')
// Set the total pages and current page values.
if ($this->limit > 0)
{
- $this->pagesTotal = ceil($this->total / $this->limit);
+ $this->pagesTotal = ceil($this->total / $this->limit);
$this->pagesCurrent = ceil(($this->limitstart + 1) / $this->limit);
}
// Set the pagination iteration loop values.
- $displayedPages = 10;
+ $displayedPages = 10;
$this->pagesStart = $this->pagesCurrent - ($displayedPages / 2);
if ($this->pagesStart < 1)
@@ -164,8 +164,8 @@ public function __construct($total, $limitstart, $limit, $prefix = '')
* Method to set an additional URL parameter to be added to all pagination class generated
* links.
*
- * @param string $key The name of the URL parameter for which to set a value.
- * @param mixed $value The value to set for the URL parameter.
+ * @param string $key The name of the URL parameter for which to set a value.
+ * @param mixed $value The value to set for the URL parameter.
*
* @return mixed The old value for the parameter.
*
@@ -193,7 +193,7 @@ public function setAdditionalUrlParam($key, $value)
* Method to get an additional URL parameter (if it exists) to be added to
* all pagination class generated links.
*
- * @param string $key The name of the URL parameter for which to get the value.
+ * @param string $key The name of the URL parameter for which to get the value.
*
* @return mixed The value if it exists or null if it does not.
*
@@ -209,7 +209,7 @@ public function getAdditionalUrlParam($key)
/**
* Return the rationalised offset for a row with a given index.
*
- * @param integer $index The row index
+ * @param integer $index The row index
*
* @return integer Rationalised offset for a row with a given index.
*
@@ -267,7 +267,7 @@ public function getPagesCounter()
*/
public function getResultsCounter()
{
- $html = null;
+ $html = null;
$fromResult = $this->limitstart + 1;
// If the limit is reached before the end of the list.
@@ -308,7 +308,7 @@ public function getPagesLinks()
// Build the page navigation list.
$data = $this->_buildDataObject();
- $list = array();
+ $list = array();
$list['prefix'] = $this->prefix;
$itemOverride = false;
@@ -335,34 +335,34 @@ public function getPagesLinks()
if ($data->all->base !== null)
{
$list['all']['active'] = true;
- $list['all']['data'] = ($itemOverride) ? pagination_item_active($data->all) : $this->_item_active($data->all);
+ $list['all']['data'] = ($itemOverride) ? pagination_item_active($data->all) : $this->_item_active($data->all);
}
else
{
$list['all']['active'] = false;
- $list['all']['data'] = ($itemOverride) ? pagination_item_inactive($data->all) : $this->_item_inactive($data->all);
+ $list['all']['data'] = ($itemOverride) ? pagination_item_inactive($data->all) : $this->_item_inactive($data->all);
}
if ($data->start->base !== null)
{
$list['start']['active'] = true;
- $list['start']['data'] = ($itemOverride) ? pagination_item_active($data->start) : $this->_item_active($data->start);
+ $list['start']['data'] = ($itemOverride) ? pagination_item_active($data->start) : $this->_item_active($data->start);
}
else
{
$list['start']['active'] = false;
- $list['start']['data'] = ($itemOverride) ? pagination_item_inactive($data->start) : $this->_item_inactive($data->start);
+ $list['start']['data'] = ($itemOverride) ? pagination_item_inactive($data->start) : $this->_item_inactive($data->start);
}
if ($data->previous->base !== null)
{
$list['previous']['active'] = true;
- $list['previous']['data'] = ($itemOverride) ? pagination_item_active($data->previous) : $this->_item_active($data->previous);
+ $list['previous']['data'] = ($itemOverride) ? pagination_item_active($data->previous) : $this->_item_active($data->previous);
}
else
{
$list['previous']['active'] = false;
- $list['previous']['data'] = ($itemOverride) ? pagination_item_inactive($data->previous) : $this->_item_inactive($data->previous);
+ $list['previous']['data'] = ($itemOverride) ? pagination_item_inactive($data->previous) : $this->_item_inactive($data->previous);
}
// Make sure it exists
@@ -373,35 +373,35 @@ public function getPagesLinks()
if ($page->base !== null)
{
$list['pages'][$i]['active'] = true;
- $list['pages'][$i]['data'] = ($itemOverride) ? pagination_item_active($page) : $this->_item_active($page);
+ $list['pages'][$i]['data'] = ($itemOverride) ? pagination_item_active($page) : $this->_item_active($page);
}
else
{
$list['pages'][$i]['active'] = false;
- $list['pages'][$i]['data'] = ($itemOverride) ? pagination_item_inactive($page) : $this->_item_inactive($page);
+ $list['pages'][$i]['data'] = ($itemOverride) ? pagination_item_inactive($page) : $this->_item_inactive($page);
}
}
if ($data->next->base !== null)
{
$list['next']['active'] = true;
- $list['next']['data'] = ($itemOverride) ? pagination_item_active($data->next) : $this->_item_active($data->next);
+ $list['next']['data'] = ($itemOverride) ? pagination_item_active($data->next) : $this->_item_active($data->next);
}
else
{
$list['next']['active'] = false;
- $list['next']['data'] = ($itemOverride) ? pagination_item_inactive($data->next) : $this->_item_inactive($data->next);
+ $list['next']['data'] = ($itemOverride) ? pagination_item_inactive($data->next) : $this->_item_inactive($data->next);
}
if ($data->end->base !== null)
{
$list['end']['active'] = true;
- $list['end']['data'] = ($itemOverride) ? pagination_item_active($data->end) : $this->_item_active($data->end);
+ $list['end']['data'] = ($itemOverride) ? pagination_item_active($data->end) : $this->_item_active($data->end);
}
else
{
$list['end']['active'] = false;
- $list['end']['data'] = ($itemOverride) ? pagination_item_inactive($data->end) : $this->_item_inactive($data->end);
+ $list['end']['data'] = ($itemOverride) ? pagination_item_inactive($data->end) : $this->_item_inactive($data->end);
}
if ($this->total > $this->limit)
@@ -425,14 +425,14 @@ public function getListFooter()
{
$app = JFactory::getApplication();
- $list = array();
- $list['prefix'] = $this->prefix;
- $list['limit'] = $this->limit;
- $list['limitstart'] = $this->limitstart;
- $list['total'] = $this->total;
- $list['limitfield'] = $this->getLimitBox();
+ $list = array();
+ $list['prefix'] = $this->prefix;
+ $list['limit'] = $this->limit;
+ $list['limitstart'] = $this->limitstart;
+ $list['total'] = $this->total;
+ $list['limitfield'] = $this->getLimitBox();
$list['pagescounter'] = $this->getPagesCounter();
- $list['pageslinks'] = $this->getPagesLinks();
+ $list['pageslinks'] = $this->getPagesLinks();
$chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/pagination.php';
@@ -458,7 +458,7 @@ public function getListFooter()
*/
public function getLimitBox()
{
- $app = JFactory::getApplication();
+ $app = JFactory::getApplication();
$limits = array();
// Make the option list.
@@ -505,12 +505,12 @@ public function getLimitBox()
/**
* Return the icon to move an item UP.
*
- * @param integer $i The row index.
- * @param boolean $condition True to show the icon.
- * @param string $task The task to fire.
- * @param string $alt The image alternative text string.
- * @param boolean $enabled An optional setting for access control on the action.
- * @param string $checkbox An optional prefix for checkboxes.
+ * @param integer $i The row index.
+ * @param boolean $condition True to show the icon.
+ * @param string $task The task to fire.
+ * @param string $alt The image alternative text string.
+ * @param boolean $enabled An optional setting for access control on the action.
+ * @param string $checkbox An optional prefix for checkboxes.
*
* @return string Either the icon to move an item up or a space.
*
@@ -531,13 +531,13 @@ public function orderUpIcon($i, $condition = true, $task = 'orderup', $alt = 'JL
/**
* Return the icon to move an item DOWN.
*
- * @param integer $i The row index.
- * @param integer $n The number of items in the list.
- * @param boolean $condition True to show the icon.
- * @param string $task The task to fire.
- * @param string $alt The image alternative text string.
- * @param boolean $enabled An optional setting for access control on the action.
- * @param string $checkbox An optional prefix for checkboxes.
+ * @param integer $i The row index.
+ * @param integer $n The number of items in the list.
+ * @param boolean $condition True to show the icon.
+ * @param string $task The task to fire.
+ * @param string $alt The image alternative text string.
+ * @param boolean $enabled An optional setting for access control on the action.
+ * @param string $checkbox An optional prefix for checkboxes.
*
* @return string Either the icon to move an item down or a space.
*
@@ -558,7 +558,7 @@ public function orderDownIcon($i, $n, $condition = true, $task = 'orderdown', $a
/**
* Create the HTML for a list footer
*
- * @param array $list Pagination list data structure.
+ * @param array $list Pagination list data structure.
*
* @return string HTML for a list footer
*
@@ -581,7 +581,7 @@ protected function _list_footer($list)
/**
* Create the html for a list footer
*
- * @param array $list Pagination list data structure.
+ * @param array $list Pagination list data structure.
*
* @return string HTML for a list start, previous, next,end
*
@@ -609,7 +609,7 @@ protected function _list_render($list)
/**
* Method to create an active pagination link to the item
*
- * @param JPaginationObject $item The object with which to make an active link.
+ * @param JPaginationObject $item The object with which to make an active link.
*
* @return string HTML link
*
@@ -643,7 +643,7 @@ protected function _item_active(JPaginationObject $item)
/**
* Method to create an inactive pagination string
*
- * @param JPaginationObject $item The item to be processed
+ * @param JPaginationObject $item The item to be processed
*
* @return string
*
@@ -694,7 +694,7 @@ protected function _buildDataObject()
}
// Set the start and previous data objects.
- $data->start = new JPaginationObject(JText::_('JLIB_HTML_START'), $this->prefix);
+ $data->start = new JPaginationObject(JText::_('JLIB_HTML_START'), $this->prefix);
$data->previous = new JPaginationObject(JText::_('JPREV'), $this->prefix);
if ($this->pagesCurrent > 1)
@@ -704,29 +704,29 @@ protected function _buildDataObject()
// Set the empty for removal from route
// @todo remove code: $page = $page == 0 ? '' : $page;
- $data->start->base = '0';
- $data->start->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=0');
+ $data->start->base = '0';
+ $data->start->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=0');
$data->previous->base = $page;
$data->previous->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $page);
}
// Set the next and end data objects.
$data->next = new JPaginationObject(JText::_('JNEXT'), $this->prefix);
- $data->end = new JPaginationObject(JText::_('JLIB_HTML_END'), $this->prefix);
+ $data->end = new JPaginationObject(JText::_('JLIB_HTML_END'), $this->prefix);
if ($this->pagesCurrent < $this->pagesTotal)
{
$next = $this->pagesCurrent * $this->limit;
- $end = ($this->pagesTotal - 1) * $this->limit;
+ $end = ($this->pagesTotal - 1) * $this->limit;
$data->next->base = $next;
$data->next->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $next);
- $data->end->base = $end;
- $data->end->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $end);
+ $data->end->base = $end;
+ $data->end->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $end);
}
$data->pages = array();
- $stop = $this->pagesStop;
+ $stop = $this->pagesStop;
for ($i = $this->pagesStart; $i <= $stop; $i++)
{
@@ -751,12 +751,12 @@ protected function _buildDataObject()
/**
* Modifies a property of the object, creating it if it does not already exist.
*
- * @param string $property The name of the property.
- * @param mixed $value The value of the property to set.
+ * @param string $property The name of the property.
+ * @param mixed $value The value of the property to set.
*
* @return void
*
- * @since 3.0
+ * @since 3.0
* @deprecated 4.0 Access the properties directly.
*/
public function set($property, $value = null)
@@ -765,8 +765,8 @@ public function set($property, $value = null)
if (strpos($property, '.'))
{
- $prop = explode('.', $property);
- $prop[1] = ucfirst($prop[1]);
+ $prop = explode('.', $property);
+ $prop[1] = ucfirst($prop[1]);
$property = implode($prop);
}
@@ -776,12 +776,12 @@ public function set($property, $value = null)
/**
* Returns a property of the object or the default value if the property is not set.
*
- * @param string $property The name of the property.
- * @param mixed $default The default value.
+ * @param string $property The name of the property.
+ * @param mixed $default The default value.
*
* @return mixed The value of the property.
*
- * @since 3.0
+ * @since 3.0
* @deprecated 4.0 Access the properties directly.
*/
public function get($property, $default = null)
@@ -790,8 +790,8 @@ public function get($property, $default = null)
if (strpos($property, '.'))
{
- $prop = explode('.', $property);
- $prop[1] = ucfirst($prop[1]);
+ $prop = explode('.', $property);
+ $prop[1] = ucfirst($prop[1]);
$property = implode($prop);
}
diff --git a/libraries/cms/pathway/pathway.php b/libraries/cms/pathway/pathway.php
index 43fe11dd48305..30c7cfd1aac9b 100644
--- a/libraries/cms/pathway/pathway.php
+++ b/libraries/cms/pathway/pathway.php
@@ -22,14 +22,14 @@ class JPathway
{
/**
* @var array Array to hold the pathway item objects
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Will convert to $pathway
*/
protected $_pathway = array();
/**
* @var integer Integer number of items in the pathway
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Will convert to $count
*/
protected $_count = 0;
@@ -43,7 +43,7 @@ class JPathway
/**
* Class constructor
*
- * @param array $options The class options.
+ * @param array $options The class options.
*
* @since 1.5
*/
@@ -54,8 +54,8 @@ public function __construct($options = array())
/**
* Returns a JPathway object
*
- * @param string $client The name of the client
- * @param array $options An associative array of options
+ * @param string $client The name of the client
+ * @param array $options An associative array of options
*
* @return JPathway A JPathway object.
*
@@ -118,7 +118,7 @@ public function getPathway()
/**
* Set the JPathway items array.
*
- * @param array $pathway An array of pathway objects.
+ * @param array $pathway An array of pathway objects.
*
* @return array The previous pathway data.
*
@@ -158,8 +158,8 @@ public function getPathwayNames()
/**
* Create and add an item to the pathway.
*
- * @param string $name The name of the item.
- * @param string $link The link to the item.
+ * @param string $name The name of the item.
+ * @param string $link The link to the item.
*
* @return boolean True on success
*
@@ -181,8 +181,8 @@ public function addItem($name, $link = '')
/**
* Set item name.
*
- * @param integer $id The id of the item on which to set the name.
- * @param string $name The name to set.
+ * @param integer $id The id of the item on which to set the name.
+ * @param string $name The name to set.
*
* @return boolean True on success
*
@@ -195,7 +195,7 @@ public function setItemName($id, $name)
if (isset($this->_pathway[$id]))
{
$this->_pathway[$id]->name = $name;
- $ret = true;
+ $ret = true;
}
return $ret;
@@ -204,12 +204,12 @@ public function setItemName($id, $name)
/**
* Create and return a new pathway object.
*
- * @param string $name Name of the item
- * @param string $link Link to the item
+ * @param string $name Name of the item
+ * @param string $link Link to the item
*
* @return JPathway Pathway item object
*
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Use makeItem() instead
*/
protected function _makeItem($name, $link)
@@ -220,8 +220,8 @@ protected function _makeItem($name, $link)
/**
* Create and return a new pathway object.
*
- * @param string $name Name of the item
- * @param string $link Link to the item
+ * @param string $name Name of the item
+ * @param string $link Link to the item
*
* @return JPathway Pathway item object
*
@@ -229,7 +229,7 @@ protected function _makeItem($name, $link)
*/
protected function makeItem($name, $link)
{
- $item = new stdClass;
+ $item = new stdClass;
$item->name = html_entity_decode($name, ENT_COMPAT, 'UTF-8');
$item->link = $link;
diff --git a/libraries/cms/pathway/site.php b/libraries/cms/pathway/site.php
index 3cd91407f886f..5c853b5dff6ca 100644
--- a/libraries/cms/pathway/site.php
+++ b/libraries/cms/pathway/site.php
@@ -21,7 +21,7 @@ class JPathwaySite extends JPathway
/**
* Class constructor.
*
- * @param array $options The class options.
+ * @param array $options The class options.
*
* @since 1.5
*/
@@ -41,7 +41,7 @@ public function __construct($options = array())
{
foreach ($item->tree as $menupath)
{
- $url = '';
+ $url = '';
$link = $menu->getItem($menupath);
switch ($link->type)
diff --git a/libraries/cms/response/json.php b/libraries/cms/response/json.php
index 5f7abcdac37a4..901d3b24f0ff8 100644
--- a/libraries/cms/response/json.php
+++ b/libraries/cms/response/json.php
@@ -56,10 +56,10 @@ class JResponseJson
/**
* Constructor
*
- * @param mixed $response The Response data
- * @param string $message The main response message
- * @param boolean $error True, if the success flag shall be set to false, defaults to false
- * @param boolean $ignoreMessages True, if the message queue shouldn't be included, defaults to false
+ * @param mixed $response The Response data
+ * @param string $message The main response message
+ * @param boolean $error True, if the success flag shall be set to false, defaults to false
+ * @param boolean $ignoreMessages True, if the message queue shouldn't be included, defaults to false
*
* @since 3.1
*/
@@ -97,14 +97,14 @@ public function __construct($response = null, $message = null, $error = false, $
if ($response instanceof Exception)
{
// Prepare the error response
- $this->success = false;
- $this->message = $response->getMessage();
+ $this->success = false;
+ $this->message = $response->getMessage();
}
else
{
// Prepare the response data
- $this->success = !$error;
- $this->data = $response;
+ $this->success = !$error;
+ $this->data = $response;
}
}
diff --git a/libraries/cms/router/administrator.php b/libraries/cms/router/administrator.php
index 093e791f5d8c9..ee01ce2581311 100644
--- a/libraries/cms/router/administrator.php
+++ b/libraries/cms/router/administrator.php
@@ -21,7 +21,7 @@ class JRouterAdministrator extends JRouter
/**
* Function to convert a route to an internal URI.
*
- * @param JUri &$uri The uri.
+ * @param JUri &$uri The uri.
*
* @return array
*
@@ -35,7 +35,7 @@ public function parse(&$uri)
/**
* Function to convert an internal URI to a route
*
- * @param string $url The internal URL
+ * @param string $url The internal URL
*
* @return string The absolute search engine friendly URL
*
diff --git a/libraries/cms/router/router.php b/libraries/cms/router/router.php
index 3cb2359a753d5..5f145dc9b84aa 100644
--- a/libraries/cms/router/router.php
+++ b/libraries/cms/router/router.php
@@ -36,7 +36,7 @@ class JRouter
* The rewrite mode
*
* @var integer
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Will convert to $mode
*/
protected $_mode = null;
@@ -53,7 +53,7 @@ class JRouter
* An array of variables
*
* @var array
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Will convert to $vars
*/
protected $_vars = array();
@@ -73,7 +73,7 @@ class JRouter
* An array of rules
*
* @var array
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Will convert to $rules
*/
protected $_rules = array(
@@ -92,7 +92,7 @@ class JRouter
/**
* Class constructor
*
- * @param array $options Array of options
+ * @param array $options Array of options
*
* @since 1.5
*/
@@ -112,8 +112,8 @@ public function __construct($options = array())
* Returns the global JRouter object, only creating it if it
* doesn't already exist.
*
- * @param string $client The name of the client
- * @param array $options An associative array of options
+ * @param string $client The name of the client
+ * @param array $options An associative array of options
*
* @return JRouter A JRouter object.
*
@@ -161,7 +161,7 @@ public static function getInstance($client, $options = array())
/**
* Function to convert a route to an internal URI
*
- * @param JUri &$uri The uri.
+ * @param JUri &$uri The uri.
*
* @return array
*
@@ -190,7 +190,7 @@ public function parse(&$uri)
/**
* Function to convert an internal URI to a route
*
- * @param string $url The internal URL
+ * @param string $url The internal URL
*
* @return string The absolute search engine friendly URL
*
@@ -234,7 +234,7 @@ public function getMode()
/**
* Set the router mode
*
- * @param integer $mode The routing mode.
+ * @param integer $mode The routing mode.
*
* @return void
*
@@ -248,9 +248,9 @@ public function setMode($mode)
/**
* Set a router variable, creating it if it doesn't exist
*
- * @param string $key The name of the variable
- * @param mixed $value The value of the variable
- * @param boolean $create If True, the variable will be created if it doesn't exist yet
+ * @param string $key The name of the variable
+ * @param mixed $value The value of the variable
+ * @param boolean $create If True, the variable will be created if it doesn't exist yet
*
* @return void
*
@@ -267,8 +267,8 @@ public function setVar($key, $value, $create = true)
/**
* Set the router variable array
*
- * @param array $vars An associative array with variables
- * @param boolean $merge If True, the array will be merged instead of overwritten
+ * @param array $vars An associative array with variables
+ * @param boolean $merge If True, the array will be merged instead of overwritten
*
* @return void
*
@@ -289,7 +289,7 @@ public function setVars($vars = array(), $merge = true)
/**
* Get a router variable
*
- * @param string $key The name of the variable
+ * @param string $key The name of the variable
*
* @return mixed Value of the variable
*
@@ -322,7 +322,7 @@ public function getVars()
/**
* Attach a build rule
*
- * @param callback $callback The function to be called
+ * @param callback $callback The function to be called
*
* @return void
*
@@ -336,7 +336,7 @@ public function attachBuildRule($callback)
/**
* Attach a parse rule
*
- * @param callback $callback The function to be called.
+ * @param callback $callback The function to be called.
*
* @return void
*
@@ -350,11 +350,11 @@ public function attachParseRule($callback)
/**
* Function to convert a raw route to an internal URI
*
- * @param JUri &$uri The raw route
+ * @param JUri &$uri The raw route
*
* @return boolean
*
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Use parseRawRoute() instead
*/
protected function _parseRawRoute(&$uri)
@@ -365,7 +365,7 @@ protected function _parseRawRoute(&$uri)
/**
* Function to convert a raw route to an internal URI
*
- * @param JUri &$uri The raw route
+ * @param JUri &$uri The raw route
*
* @return boolean
*
@@ -379,11 +379,11 @@ protected function parseRawRoute(&$uri)
/**
* Function to convert a sef route to an internal URI
*
- * @param JUri &$uri The sef URI
+ * @param JUri &$uri The sef URI
*
* @return string Internal URI
*
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Use parseSefRoute() instead
*/
protected function _parseSefRoute(&$uri)
@@ -394,7 +394,7 @@ protected function _parseSefRoute(&$uri)
/**
* Function to convert a sef route to an internal URI
*
- * @param JUri &$uri The sef URI
+ * @param JUri &$uri The sef URI
*
* @return string Internal URI
*
@@ -408,11 +408,11 @@ protected function parseSefRoute(&$uri)
/**
* Function to build a raw route
*
- * @param JUri &$uri The internal URL
+ * @param JUri &$uri The internal URL
*
* @return string Raw Route
*
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Use buildRawRoute() instead
*/
protected function _buildRawRoute(&$uri)
@@ -423,7 +423,7 @@ protected function _buildRawRoute(&$uri)
/**
* Function to build a raw route
*
- * @param JUri &$uri The internal URL
+ * @param JUri &$uri The internal URL
*
* @return string Raw Route
*
@@ -436,11 +436,11 @@ protected function buildRawRoute(&$uri)
/**
* Function to build a sef route
*
- * @param JUri &$uri The uri
+ * @param JUri &$uri The uri
*
* @return string The SEF route
*
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Use buildSefRoute() instead
*/
protected function _buildSefRoute(&$uri)
@@ -451,7 +451,7 @@ protected function _buildSefRoute(&$uri)
/**
* Function to build a sef route
*
- * @param JUri &$uri The uri
+ * @param JUri &$uri The uri
*
* @return string The SEF route
*
@@ -464,11 +464,11 @@ protected function buildSefRoute(&$uri)
/**
* Process the parsed router variables based on custom defined rules
*
- * @param JUri &$uri The URI to parse
+ * @param JUri &$uri The URI to parse
*
* @return array The array of processed URI variables
*
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Use processParseRules() instead
*/
protected function _processParseRules(&$uri)
@@ -479,7 +479,7 @@ protected function _processParseRules(&$uri)
/**
* Process the parsed router variables based on custom defined rules
*
- * @param JUri &$uri The URI to parse
+ * @param JUri &$uri The URI to parse
*
* @return array The array of processed URI variables
*
@@ -500,11 +500,11 @@ protected function processParseRules(&$uri)
/**
* Process the build uri query data based on custom defined rules
*
- * @param JUri &$uri The URI
+ * @param JUri &$uri The URI
*
* @return void
*
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Use processBuildRules() instead
*/
protected function _processBuildRules(&$uri)
@@ -515,7 +515,7 @@ protected function _processBuildRules(&$uri)
/**
* Process the build uri query data based on custom defined rules
*
- * @param JUri &$uri The URI
+ * @param JUri &$uri The URI
*
* @return void
*
@@ -532,11 +532,11 @@ protected function processBuildRules(&$uri)
/**
* Create a uri based on a full or partial url string
*
- * @param string $url The URI
+ * @param string $url The URI
*
* @return JUri
*
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Use createURI() instead
*/
protected function _createURI($url)
@@ -547,7 +547,7 @@ protected function _createURI($url)
/**
* Create a uri based on a full or partial url string
*
- * @param string $url The URI
+ * @param string $url The URI
*
* @return JUri
*
@@ -587,11 +587,11 @@ protected function createURI($url)
/**
* Encode route segments
*
- * @param array $segments An array of route segments
+ * @param array $segments An array of route segments
*
* @return array Array of encoded route segments
*
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Use encodeSegments() instead
*/
protected function _encodeSegments($segments)
@@ -602,7 +602,7 @@ protected function _encodeSegments($segments)
/**
* Encode route segments
*
- * @param array $segments An array of route segments
+ * @param array $segments An array of route segments
*
* @return array Array of encoded route segments
*
@@ -623,11 +623,11 @@ protected function encodeSegments($segments)
/**
* Decode route segments
*
- * @param array $segments An array of route segments
+ * @param array $segments An array of route segments
*
* @return array Array of decoded route segments
*
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Use decodeSegments() instead
*/
protected function _decodeSegments($segments)
@@ -638,7 +638,7 @@ protected function _decodeSegments($segments)
/**
* Decode route segments
*
- * @param array $segments An array of route segments
+ * @param array $segments An array of route segments
*
* @return array Array of decoded route segments
*
diff --git a/libraries/cms/router/site.php b/libraries/cms/router/site.php
index 9e94e93170727..d26f4511c5d4b 100644
--- a/libraries/cms/router/site.php
+++ b/libraries/cms/router/site.php
@@ -21,7 +21,7 @@ class JRouterSite extends JRouter
/**
* Function to convert a route to an internal URI
*
- * @param JUri &$uri The uri.
+ * @param JUri &$uri The uri.
*
* @return array
*
@@ -52,7 +52,7 @@ public function parse(&$uri)
if (preg_match("#.*?\.php#u", $path, $matches))
{
// Get the current entry point path relative to the site path.
- $scriptPath = realpath($_SERVER['SCRIPT_FILENAME'] ? $_SERVER['SCRIPT_FILENAME'] : str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']));
+ $scriptPath = realpath($_SERVER['SCRIPT_FILENAME'] ? $_SERVER['SCRIPT_FILENAME'] : str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']));
$relativeScriptPath = str_replace('\\', '/', str_replace(JPATH_SITE, '', $scriptPath));
// If a php file has been found in the request path, check to see if it is a valid file.
@@ -87,7 +87,7 @@ public function parse(&$uri)
/**
* Function to convert an internal URI to a route
*
- * @param string $url The internal URL
+ * @param string $url The internal URL
*
* @return string The absolute search engine friendly URL
*
@@ -137,7 +137,7 @@ public function build($url)
/**
* Function to convert a raw route to an internal URI
*
- * @param JUri &$uri The raw route
+ * @param JUri &$uri The raw route
*
* @return array
*
@@ -179,7 +179,7 @@ protected function parseRawRoute(&$uri)
$this->setVar('Itemid', $app->input->getInt('Itemid', null));
// Only an Itemid OR if filter language plugin set? Get the full information from the itemid
- if (count($this->getVars()) == 1 || ($app->getLanguageFilter() && count($this->getVars()) == 2 ))
+ if (count($this->getVars()) == 1 || ($app->getLanguageFilter() && count($this->getVars()) == 2))
{
$item = $menu->getItem($this->getVar('Itemid'));
@@ -198,7 +198,7 @@ protected function parseRawRoute(&$uri)
/**
* Function to convert a sef route to an internal URI
*
- * @param JUri &$uri The sef URI
+ * @param JUri &$uri The sef URI
*
* @return string Internal URI
*
@@ -259,7 +259,7 @@ protected function parseSefRoute(&$uri)
{
$vars['option'] = 'com_' . $segments[1];
$vars['Itemid'] = null;
- $route = implode('/', array_slice($segments, 2));
+ $route = implode('/', array_slice($segments, 2));
}
else
{
@@ -281,7 +281,8 @@ protected function parseSefRoute(&$uri)
$length = strlen($item->route);
if ($length > 0 && JString::strpos($route_lowercase . '/', $item->route . '/') === 0
&& $item->type != 'menulink' && (!$app->getLanguageFilter() || $item->language == '*'
- || $item->language == $lang_tag))
+ || $item->language == $lang_tag)
+ )
{
// We have exact item for this language
if ($item->language == $lang_tag)
@@ -363,7 +364,7 @@ protected function parseSefRoute(&$uri)
require_once $path;
$function = substr($component, 4) . 'ParseRoute';
$function = str_replace(array("-", "."), "", $function);
- $vars = $function($segments);
+ $vars = $function($segments);
$this->setVars($vars);
}
@@ -383,11 +384,11 @@ protected function parseSefRoute(&$uri)
/**
* Function to build a sef route
*
- * @param JUri &$uri The internal URL
+ * @param JUri &$uri The internal URL
*
* @return void
*
- * @since 1.5
+ * @since 1.5
* @deprecated 4.0 Use buildSefRoute() instead
*/
protected function _buildSefRoute(&$uri)
@@ -398,7 +399,7 @@ protected function _buildSefRoute(&$uri)
/**
* Function to build a sef route
*
- * @param JUri &$uri The uri
+ * @param JUri &$uri The uri
*
* @return void
*
@@ -511,7 +512,7 @@ protected function buildSefRoute(&$uri)
/**
* Process the parsed router variables based on custom defined rules
*
- * @param JUri &$uri The URI to parse
+ * @param JUri &$uri The URI to parse
*
* @return array The array of processed URI variables
*
@@ -538,7 +539,7 @@ protected function processParseRules(&$uri)
/**
* Process the build uri query data based on custom defined rules
*
- * @param JUri &$uri The URI
+ * @param JUri &$uri The URI
*
* @return void
*
@@ -554,7 +555,7 @@ protected function processBuildRules(&$uri)
// Get the active menu item
$itemid = $uri->getVar('Itemid');
- $item = $menu->getItem($itemid);
+ $item = $menu->getItem($itemid);
if ($item)
{
@@ -585,7 +586,7 @@ protected function processBuildRules(&$uri)
/**
* Create a uri based on a full or partial url string
*
- * @param string $url The URI
+ * @param string $url The URI
*
* @return JUri
*
@@ -607,7 +608,7 @@ protected function createURI($url)
{
if ($option = $uri->getVar('option'))
{
- $item = $menu->getItem($this->getVar('Itemid'));
+ $item = $menu->getItem($this->getVar('Itemid'));
if (isset($item) && $item->component == $option)
{
diff --git a/libraries/cms/schema/changeitem.php b/libraries/cms/schema/changeitem.php
index beaf2102999ba..78dbe1100aeae 100644
--- a/libraries/cms/schema/changeitem.php
+++ b/libraries/cms/schema/changeitem.php
@@ -112,26 +112,26 @@ abstract class JSchemaChangeitem
/**
* Constructor: builds check query and message from $updateQuery
*
- * @param JDatabaseDriver $db Database connector object
- * @param string $file Full path name of the sql file
- * @param string $query Text of the sql query (one line of the file)
+ * @param JDatabaseDriver $db Database connector object
+ * @param string $file Full path name of the sql file
+ * @param string $query Text of the sql query (one line of the file)
*
* @since 2.5
*/
public function __construct($db, $file, $query)
{
$this->updateQuery = $query;
- $this->file = $file;
- $this->db = $db;
+ $this->file = $file;
+ $this->db = $db;
$this->buildCheckQuery();
}
/**
* Returns a reference to the JSchemaChangeitem object.
*
- * @param JDatabaseDriver $db Database connector object
- * @param string $file Full path name of the sql file
- * @param string $query Text of the sql query (one line of the file)
+ * @param JDatabaseDriver $db Database connector object
+ * @param string $file Full path name of the sql file
+ * @param string $query Text of the sql query (one line of the file)
*
* @return JSchemaChangeitem instance based on the database driver
*
@@ -213,6 +213,7 @@ public function check()
$this->checkStatus = -2;
}
}
+
return $this->checkStatus;
}
diff --git a/libraries/cms/schema/changeitem/mysql.php b/libraries/cms/schema/changeitem/mysql.php
index 5194ba5661bdf..8ca9e23024fe3 100644
--- a/libraries/cms/schema/changeitem/mysql.php
+++ b/libraries/cms/schema/changeitem/mysql.php
@@ -39,16 +39,16 @@ protected function buildCheckQuery()
{
// Initialize fields in case we can't create a check query
$this->checkStatus = -1; // change status to skipped
- $result = null;
+ $result = null;
// Remove any newlines
$this->updateQuery = str_replace("\n", '', $this->updateQuery);
// Fix up extra spaces around () and in general
- $find = array('#((\s*)\(\s*([^)\s]+)\s*)(\))#', '#(\s)(\s*)#');
- $replace = array('($3)', '$1');
+ $find = array('#((\s*)\(\s*([^)\s]+)\s*)(\))#', '#(\s)(\s*)#');
+ $replace = array('($3)', '$1');
$updateQuery = preg_replace($find, $replace, $this->updateQuery);
- $wordArray = explode(' ', $updateQuery);
+ $wordArray = explode(' ', $updateQuery);
// First, make sure we have an array of at least 6 elements
// if not, we can't make a check query for this one
@@ -65,8 +65,8 @@ protected function buildCheckQuery()
$alterCommand = strtoupper($wordArray[3] . ' ' . $wordArray[4]);
if ($alterCommand == 'ADD COLUMN')
{
- $result = 'SHOW COLUMNS IN ' . $wordArray[2] . ' WHERE field = ' . $this->fixQuote($wordArray[5]);
- $this->queryType = 'ADD_COLUMN';
+ $result = 'SHOW COLUMNS IN ' . $wordArray[2] . ' WHERE field = ' . $this->fixQuote($wordArray[5]);
+ $this->queryType = 'ADD_COLUMN';
$this->msgElements = array($this->fixQuote($wordArray[2]), $this->fixQuote($wordArray[5]));
}
elseif ($alterCommand == 'ADD INDEX' || $alterCommand == 'ADD UNIQUE')
@@ -79,25 +79,25 @@ protected function buildCheckQuery()
{
$index = $this->fixQuote($wordArray[5]);
}
- $result = 'SHOW INDEXES IN ' . $wordArray[2] . ' WHERE Key_name = ' . $index;
- $this->queryType = 'ADD_INDEX';
+ $result = 'SHOW INDEXES IN ' . $wordArray[2] . ' WHERE Key_name = ' . $index;
+ $this->queryType = 'ADD_INDEX';
$this->msgElements = array($this->fixQuote($wordArray[2]), $index);
}
elseif ($alterCommand == 'DROP INDEX')
{
- $index = $this->fixQuote($wordArray[5]);
- $result = 'SHOW INDEXES IN ' . $wordArray[2] . ' WHERE Key_name = ' . $index;
- $this->queryType = 'DROP_INDEX';
+ $index = $this->fixQuote($wordArray[5]);
+ $result = 'SHOW INDEXES IN ' . $wordArray[2] . ' WHERE Key_name = ' . $index;
+ $this->queryType = 'DROP_INDEX';
$this->checkQueryExpected = 0;
- $this->msgElements = array($this->fixQuote($wordArray[2]), $index);
+ $this->msgElements = array($this->fixQuote($wordArray[2]), $index);
}
elseif ($alterCommand == 'DROP COLUMN')
{
- $index = $this->fixQuote($wordArray[5]);
- $result = 'SHOW COLUMNS IN ' . $wordArray[2] . ' WHERE Field = ' . $index;
- $this->queryType = 'DROP_COLUMN';
+ $index = $this->fixQuote($wordArray[5]);
+ $result = 'SHOW COLUMNS IN ' . $wordArray[2] . ' WHERE Field = ' . $index;
+ $this->queryType = 'DROP_COLUMN';
$this->checkQueryExpected = 0;
- $this->msgElements = array($this->fixQuote($wordArray[2]), $index);
+ $this->msgElements = array($this->fixQuote($wordArray[2]), $index);
}
elseif (strtoupper($wordArray[3]) == 'MODIFY')
{
@@ -107,16 +107,16 @@ protected function buildCheckQuery()
{
$type = $this->fixQuote($this->fixInteger($wordArray[5], $wordArray[6]));
}
- $result = 'SHOW COLUMNS IN ' . $wordArray[2] . ' WHERE field = ' . $this->fixQuote($wordArray[4]) . ' AND type = ' . $type;
- $this->queryType = 'CHANGE_COLUMN_TYPE';
+ $result = 'SHOW COLUMNS IN ' . $wordArray[2] . ' WHERE field = ' . $this->fixQuote($wordArray[4]) . ' AND type = ' . $type;
+ $this->queryType = 'CHANGE_COLUMN_TYPE';
$this->msgElements = array($this->fixQuote($wordArray[2]), $this->fixQuote($wordArray[4]), $type);
}
elseif (strtoupper($wordArray[3]) == 'CHANGE')
{
// Kludge to fix problem with "integer unsigned"
- $type = $this->fixQuote($this->fixInteger($wordArray[6], $wordArray[7]));
- $result = 'SHOW COLUMNS IN ' . $wordArray[2] . ' WHERE field = ' . $this->fixQuote($wordArray[4]) . ' AND type = ' . $type;
- $this->queryType = 'CHANGE_COLUMN_TYPE';
+ $type = $this->fixQuote($this->fixInteger($wordArray[6], $wordArray[7]));
+ $result = 'SHOW COLUMNS IN ' . $wordArray[2] . ' WHERE field = ' . $this->fixQuote($wordArray[4]) . ' AND type = ' . $type;
+ $this->queryType = 'CHANGE_COLUMN_TYPE';
$this->msgElements = array($this->fixQuote($wordArray[2]), $this->fixQuote($wordArray[4]), $type);
}
}
@@ -131,8 +131,8 @@ protected function buildCheckQuery()
{
$table = $wordArray[2];
}
- $result = 'SHOW TABLES LIKE ' . $this->fixQuote($table);
- $this->queryType = 'CREATE_TABLE';
+ $result = 'SHOW TABLES LIKE ' . $this->fixQuote($table);
+ $this->queryType = 'CREATE_TABLE';
$this->msgElements = array($this->fixQuote($table));
}
@@ -154,8 +154,8 @@ protected function buildCheckQuery()
* If you change a column to "integer unsigned" it shows
* as "int(10) unsigned" in the check query.
*
- * @param string $type1 the column type
- * @param string $type2 the column attributes
+ * @param string $type1 the column type
+ * @param string $type2 the column attributes
*
* @return string The original or changed column type.
*
@@ -168,6 +168,7 @@ private function fixInteger($type1, $type2)
{
$result = 'int(10) unsigned';
}
+
return $result;
}
@@ -176,7 +177,7 @@ private function fixInteger($type1, $type2)
* Replaces name quote character with normal quote for literal.
* Drops trailing semi-colon. Injects the database prefix.
*
- * @param string $string The input string to be cleaned up.
+ * @param string $string The input string to be cleaned up.
*
* @return string The modified string.
*
@@ -187,6 +188,7 @@ private function fixQuote($string)
$string = str_replace('`', '', $string);
$string = str_replace(';', '', $string);
$string = str_replace('#__', $this->db->getPrefix(), $string);
+
return $this->db->quote($string);
}
}
diff --git a/libraries/cms/schema/changeitem/postgresql.php b/libraries/cms/schema/changeitem/postgresql.php
index dc9721e68707f..98e2c5c4bf682 100644
--- a/libraries/cms/schema/changeitem/postgresql.php
+++ b/libraries/cms/schema/changeitem/postgresql.php
@@ -39,16 +39,16 @@ protected function buildCheckQuery()
{
// Initialize fields in case we can't create a check query
$this->checkStatus = -1; // change status to skipped
- $result = null;
+ $result = null;
// Remove any newlines
$this->updateQuery = str_replace("\n", '', $this->updateQuery);
// Fix up extra spaces around () and in general
- $find = array('#((\s*)\(\s*([^)\s]+)\s*)(\))#', '#(\s)(\s*)#');
- $replace = array('($3)', '$1');
+ $find = array('#((\s*)\(\s*([^)\s]+)\s*)(\))#', '#(\s)(\s*)#');
+ $replace = array('($3)', '$1');
$updateQuery = preg_replace($find, $replace, $this->updateQuery);
- $wordArray = explode(' ', $updateQuery);
+ $wordArray = explode(' ', $updateQuery);
// First, make sure we have an array of at least 6 elements
// if not, we can't make a check query for this one
@@ -66,9 +66,9 @@ protected function buildCheckQuery()
if ($alterCommand === 'ADD COLUMN')
{
$result = 'SELECT column_name FROM information_schema.columns WHERE table_name='
- . $this->fixQuote($wordArray[2]) . ' AND column_name=' . $this->fixQuote($wordArray[5]);
+ . $this->fixQuote($wordArray[2]) . ' AND column_name=' . $this->fixQuote($wordArray[5]);
- $this->queryType = 'ADD_COLUMN';
+ $this->queryType = 'ADD_COLUMN';
$this->msgElements = array($this->fixQuote($wordArray[2]), $this->fixQuote($wordArray[5]));
}
elseif ($alterCommand === 'ALTER COLUMN')
@@ -95,7 +95,7 @@ protected function buildCheckQuery()
. $this->fixQuote($wordArray[2]) . ' AND column_name=' . $this->fixQuote($wordArray[5])
. ' AND data_type=' . $this->fixQuote($type);
- $this->queryType = 'CHANGE_COLUMN_TYPE';
+ $this->queryType = 'CHANGE_COLUMN_TYPE';
$this->msgElements = array($this->fixQuote($wordArray[2]), $this->fixQuote($wordArray[5]), $type);
}
elseif (strtoupper($wordArray[7] . ' ' . $wordArray[8]) == 'NOT NULL')
@@ -114,9 +114,9 @@ protected function buildCheckQuery()
. $this->fixQuote($wordArray[2]) . ' AND column_name=' . $this->fixQuote($wordArray[5])
. ' AND is_nullable=' . $isNullable;
- $this->queryType = 'CHANGE_COLUMN_TYPE';
+ $this->queryType = 'CHANGE_COLUMN_TYPE';
$this->checkQueryExpected = 1;
- $this->msgElements = array($this->fixQuote($wordArray[2]), $this->fixQuote($wordArray[5]), $isNullable);
+ $this->msgElements = array($this->fixQuote($wordArray[2]), $this->fixQuote($wordArray[5]), $isNullable);
}
elseif (strtoupper($wordArray[7]) === 'DEFAULT')
{
@@ -133,9 +133,9 @@ protected function buildCheckQuery()
. $this->fixQuote($wordArray[2]) . ' AND column_name=' . $this->fixQuote($wordArray[5])
. ' AND column_default ' . $isNullDef;
- $this->queryType = 'CHANGE_COLUMN_TYPE';
+ $this->queryType = 'CHANGE_COLUMN_TYPE';
$this->checkQueryExpected = 1;
- $this->msgElements = array($this->fixQuote($wordArray[2]), $this->fixQuote($wordArray[5]), $isNullDef);
+ $this->msgElements = array($this->fixQuote($wordArray[2]), $this->fixQuote($wordArray[5]), $isNullDef);
}
}
}
@@ -150,28 +150,28 @@ protected function buildCheckQuery()
$idx = $this->fixQuote($wordArray[2]);
}
- $result = 'SELECT * FROM pg_indexes WHERE indexname=' . $idx;
- $this->queryType = 'DROP_INDEX';
+ $result = 'SELECT * FROM pg_indexes WHERE indexname=' . $idx;
+ $this->queryType = 'DROP_INDEX';
$this->checkQueryExpected = 0;
- $this->msgElements = array($this->fixQuote($idx));
+ $this->msgElements = array($this->fixQuote($idx));
}
elseif ($command == 'CREATE INDEX' || (strtoupper($command . $wordArray[2]) == 'CREATE UNIQUE INDEX'))
{
if ($wordArray[1] === 'UNIQUE')
{
- $idx = $this->fixQuote($wordArray[3]);
+ $idx = $this->fixQuote($wordArray[3]);
$table = $this->fixQuote($wordArray[5]);
}
else
{
- $idx = $this->fixQuote($wordArray[2]);
+ $idx = $this->fixQuote($wordArray[2]);
$table = $this->fixQuote($wordArray[4]);
}
- $result = 'SELECT * FROM pg_indexes WHERE indexname=' . $idx . ' AND tablename=' . $table;
- $this->queryType = 'ADD_INDEX';
+ $result = 'SELECT * FROM pg_indexes WHERE indexname=' . $idx . ' AND tablename=' . $table;
+ $this->queryType = 'ADD_INDEX';
$this->checkQueryExpected = 1;
- $this->msgElements = array($table, $idx);
+ $this->msgElements = array($table, $idx);
}
if ($command == 'CREATE TABLE')
@@ -184,10 +184,10 @@ protected function buildCheckQuery()
{
$table = $this->fixQuote($wordArray[2]);
}
- $result = 'SELECT table_name FROM information_schema.tables WHERE table_name=' . $table;
- $this->queryType = 'CREATE_TABLE';
+ $result = 'SELECT table_name FROM information_schema.tables WHERE table_name=' . $table;
+ $this->queryType = 'CREATE_TABLE';
$this->checkQueryExpected = 1;
- $this->msgElements = array($table);
+ $this->msgElements = array($table);
}
// Set fields based on results
@@ -208,8 +208,8 @@ protected function buildCheckQuery()
* If you change a column to "integer unsigned" it shows
* as "int(10) unsigned" in the check query.
*
- * @param string $type1 the column type
- * @param string $type2 the column attributes
+ * @param string $type1 the column type
+ * @param string $type2 the column attributes
*
* @return string The original or changed column type.
*
@@ -222,6 +222,7 @@ private function fixInteger($type1, $type2)
{
$result = 'unsigned int(10)';
}
+
return $result;
}
@@ -230,7 +231,7 @@ private function fixInteger($type1, $type2)
* Replaces name quote character with normal quote for literal.
* Drops trailing semi-colon. Injects the database prefix.
*
- * @param string $string The input string to be cleaned up.
+ * @param string $string The input string to be cleaned up.
*
* @return string The modified string.
*
@@ -241,6 +242,7 @@ private function fixQuote($string)
$string = str_replace('"', '', $string);
$string = str_replace(';', '', $string);
$string = str_replace('#__', $this->db->getPrefix(), $string);
+
return $this->db->quote($string);
}
}
diff --git a/libraries/cms/schema/changeitem/sqlsrv.php b/libraries/cms/schema/changeitem/sqlsrv.php
index 1bd71f7444003..d20726ad2e4ff 100644
--- a/libraries/cms/schema/changeitem/sqlsrv.php
+++ b/libraries/cms/schema/changeitem/sqlsrv.php
@@ -39,16 +39,16 @@ protected function buildCheckQuery()
{
// Initialize fields in case we can't create a check query
$this->checkStatus = -1; // change status to skipped
- $result = null;
+ $result = null;
// Remove any newlines
$this->updateQuery = str_replace("\n", '', $this->updateQuery);
// Fix up extra spaces around () and in general
- $find = array('#((\s*)\(\s*([^)\s]+)\s*)(\))#', '#(\s)(\s*)#');
- $replace = array('($3)', '$1');
+ $find = array('#((\s*)\(\s*([^)\s]+)\s*)(\))#', '#(\s)(\s*)#');
+ $replace = array('($3)', '$1');
$updateQuery = preg_replace($find, $replace, $this->updateQuery);
- $wordArray = explode(' ', $updateQuery);
+ $wordArray = explode(' ', $updateQuery);
// First, make sure we have an array of at least 6 elements
// if not, we can't make a check query for this one
@@ -65,30 +65,30 @@ protected function buildCheckQuery()
$alterCommand = strtoupper($wordArray[3] . ' ' . $wordArray[4]);
if ($alterCommand == 'ADD')
{
- $result = 'SELECT * FROM INFORMATION_SCHEMA.Columns ' . $wordArray[2] . ' WHERE COLUMN_NAME = ' . $this->fixQuote($wordArray[5]);
- $this->queryType = 'ADD';
+ $result = 'SELECT * FROM INFORMATION_SCHEMA.Columns ' . $wordArray[2] . ' WHERE COLUMN_NAME = ' . $this->fixQuote($wordArray[5]);
+ $this->queryType = 'ADD';
$this->msgElements = array($this->fixQuote($wordArray[2]), $this->fixQuote($wordArray[5]));
}
elseif ($alterCommand == 'CREATE INDEX')
{
- $index = $this->fixQuote(substr($wordArray[5], 0, strpos($wordArray[5], '(')));
- $result = 'SELECT * FROM SYS.INDEXES ' . $wordArray[2] . ' WHERE name = ' . $index;
- $this->queryType = 'CREATE INDEX';
+ $index = $this->fixQuote(substr($wordArray[5], 0, strpos($wordArray[5], '(')));
+ $result = 'SELECT * FROM SYS.INDEXES ' . $wordArray[2] . ' WHERE name = ' . $index;
+ $this->queryType = 'CREATE INDEX';
$this->msgElements = array($this->fixQuote($wordArray[2]), $index);
}
elseif (strtoupper($wordArray[3]) == 'MODIFY' || strtoupper($wordArray[3]) == 'CHANGE')
{
- $result = 'SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = ' . $this->fixQuote($wordArray[2]);
- $this->queryType = 'ALTER COLUMN COLUMN_NAME =' . $this->fixQuote($wordArray[4]);
+ $result = 'SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = ' . $this->fixQuote($wordArray[2]);
+ $this->queryType = 'ALTER COLUMN COLUMN_NAME =' . $this->fixQuote($wordArray[4]);
$this->msgElements = array($this->fixQuote($wordArray[2]), $this->fixQuote($wordArray[4]));
}
}
if ($command == 'CREATE TABLE')
{
- $table = $wordArray[5];
- $result = 'SELECT * FROM sys.TABLES WHERE NAME = ' . $this->fixQuote($table);
- $this->queryType = 'CREATE_TABLE';
+ $table = $wordArray[5];
+ $result = 'SELECT * FROM sys.TABLES WHERE NAME = ' . $this->fixQuote($table);
+ $this->queryType = 'CREATE_TABLE';
$this->msgElements = array($this->fixQuote($table));
}
@@ -110,8 +110,8 @@ protected function buildCheckQuery()
* If you change a column to "integer unsigned" it shows
* as "int(10) unsigned" in the check query.
*
- * @param string $type1 the column type
- * @param string $type2 the column attributes
+ * @param string $type1 the column type
+ * @param string $type2 the column attributes
*
* @return string The original or changed column type.
*
@@ -124,6 +124,7 @@ private function fixInteger($type1, $type2)
{
$result = 'int';
}
+
return $result;
}
@@ -132,7 +133,7 @@ private function fixInteger($type1, $type2)
* Replaces name quote character with normal quote for literal.
* Drops trailing semi-colon. Injects the database prefix.
*
- * @param string $string The input string to be cleaned up.
+ * @param string $string The input string to be cleaned up.
*
* @return string The modified string.
*
@@ -143,6 +144,7 @@ private function fixQuote($string)
$string = str_replace('`', '', $string);
$string = str_replace(';', '', $string);
$string = str_replace('#__', $this->db->getPrefix(), $string);
+
return $this->db->quote($string);
}
}
diff --git a/libraries/cms/schema/changeset.php b/libraries/cms/schema/changeset.php
index e5ea804c4f113..f2ece0dac5897 100644
--- a/libraries/cms/schema/changeset.php
+++ b/libraries/cms/schema/changeset.php
@@ -50,16 +50,16 @@ class JSchemaChangeset
* Constructor: builds array of $changeItems by processing the .sql files in a folder.
* The folder for the Joomla core updates is administrator/components/com_admin/sql/updates/.
*
- * @param JDatabaseDriver $db The current database object
- * @param string $folder The full path to the folder containing the update queries
+ * @param JDatabaseDriver $db The current database object
+ * @param string $folder The full path to the folder containing the update queries
*
* @since 2.5
*/
public function __construct($db, $folder = null)
{
- $this->db = $db;
- $this->folder = $folder;
- $updateFiles = $this->getUpdateFiles();
+ $this->db = $db;
+ $this->folder = $folder;
+ $updateFiles = $this->getUpdateFiles();
$updateQueries = $this->getUpdateQueries($updateFiles);
foreach ($updateQueries as $obj)
{
@@ -70,8 +70,8 @@ public function __construct($db, $folder = null)
/**
* Returns a reference to the JSchemaChangeset object, only creating it if it doesn't already exist.
*
- * @param JDatabaseDriver $db The current database object
- * @param string $folder The full path to the folder containing the update queries
+ * @param JDatabaseDriver $db The current database object
+ * @param string $folder The full path to the folder containing the update queries
*
* @return JSchemaChangeset
*
@@ -109,6 +109,7 @@ public function check()
$errors[] = $item;
}
}
+
return $errors;
}
@@ -129,12 +130,12 @@ public function fix()
}
/**
- * Returns an array of results for this set
- *
- * @return array associative array of changeitems grouped by unchecked, ok, error, and skipped
- *
- * @since 2.5
- */
+ * Returns an array of results for this set
+ *
+ * @return array associative array of changeitems grouped by unchecked, ok, error, and skipped
+ *
+ * @since 2.5
+ */
public function getStatus()
{
$result = array('unchecked' => array(), 'ok' => array(), 'error' => array(), 'skipped' => array());
@@ -156,6 +157,7 @@ public function getStatus()
break;
}
}
+
return $result;
}
@@ -172,7 +174,8 @@ public function getStatus()
public function getSchema()
{
$updateFiles = $this->getUpdateFiles();
- $result = new SplFileInfo(array_pop($updateFiles));
+ $result = new SplFileInfo(array_pop($updateFiles));
+
return $result->getBasename('.sql');
}
@@ -211,7 +214,7 @@ private function getUpdateFiles()
/**
* Get array of SQL queries
*
- * @param array $sqlfiles Array of .sql update filenames.
+ * @param array $sqlfiles Array of .sql update filenames.
*
* @return array Array of stdClass objects where:
* file=filename,
@@ -233,20 +236,21 @@ private function getUpdateQueries(array $sqlfiles)
{
if ($trimmedQuery = $this->trimQuery($query))
{
- $fileQueries = new stdClass;
- $fileQueries->file = $file;
+ $fileQueries = new stdClass;
+ $fileQueries->file = $file;
$fileQueries->updateQuery = $trimmedQuery;
- $result[] = $fileQueries;
+ $result[] = $fileQueries;
}
}
}
+
return $result;
}
/**
* Trim comment and blank lines out of a query string
*
- * @param string $query query string to be trimmed
+ * @param string $query query string to be trimmed
*
* @return string String with leading comment lines removed
*
diff --git a/libraries/cms/search/helper.php b/libraries/cms/search/helper.php
index ddd5e414059fd..e1b447a6564cb 100644
--- a/libraries/cms/search/helper.php
+++ b/libraries/cms/search/helper.php
@@ -21,8 +21,8 @@ class JSearchHelper
/**
* Method to log search terms to the database
*
- * @param string $term The term being searched
- * @param string $component The component being used for the search
+ * @param string $term The term being searched
+ * @param string $component The component being used for the search
*
* @return void
*
@@ -31,8 +31,8 @@ class JSearchHelper
public static function logSearch($term, $component)
{
// Initialise our variables
- $db = JFactory::getDbo();
- $query = $db->getQuery(true);
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true);
$enable_log_searches = JComponentHelper::getParams($component)->get('enabled');
// Sanitise the term for the database
diff --git a/libraries/cms/table/cms.php b/libraries/cms/table/cms.php
new file mode 100644
index 0000000000000..efabdb5476df2
--- /dev/null
+++ b/libraries/cms/table/cms.php
@@ -0,0 +1,704 @@
+buildTableName($config);
+ }
+
+ if (!isset($config['table']['key']))
+ {
+ $config['table']['key'] = $config['subject'] . '_id';
+ }
+
+ if (!isset($config['dbo']))
+ {
+ $config['dbo'] = JFactory::getDbo();
+ }
+
+ $table = $config['table']['name'];
+ $key = $config['table']['key'];
+ $db = $config['dbo'];
+
+ $this->_config = $config;
+
+ parent::__construct($table, $key, $db);
+
+ //fix for 2.5 BC
+ if (count($this->_tbl_keys) == 0)
+ {
+ // Set the key to be an array.
+ if (is_string($key))
+ {
+ $key = array($key);
+ }
+ elseif (is_object($key))
+ {
+ $key = (array) $key;
+ }
+
+ $this->_tbl_keys = $key;
+ }
+
+ $this->_config = $config;
+ }
+
+ /**
+ * Method to build a default table class name
+ * Format: '#__'.substr($config['option'], 4).'_'.$config['subject']
+ * Also applies strtolower
+ *
+ * @param $config
+ *
+ * @return string
+ */
+ protected function buildTableName($config)
+ {
+ $prefix = '#__' . substr($config['option'], 4);
+ $postfix = '_' . $config['subject'];
+
+ $tableName = strtolower($prefix . $postfix);
+
+ return $tableName;
+ }
+
+ /**
+ * Method to update the record state
+ *
+ * @param array $pk array of one or more primary keys
+ * @param integer $newState The new publishing state.
+ * @param integer $userId The user id of the user performing the operation.
+ *
+ * @internal param mixed $pks An optional array of primary key values to update.
+ * @return boolean
+ */
+ public function updateRecordState($pk, $newState, $userId = 0)
+ {
+ $pks = $this->getValidPk($pk);
+
+ $userId = (int) $userId;
+ $newState = (int) $newState;
+
+ foreach ($pks AS $pk)
+ {
+
+ $this->load($pk);
+
+ // Update the publishing state for rows with the given primary keys.
+ $query = $this->_db->getQuery(true)
+ ->update($this->_tbl)
+ ->set('state = ' . $newState);
+
+ $checkin = false;
+ if ($this->isLockable($this))
+ {
+ if (!$this->isLocked($this))
+ {
+ $this->checkout($userId, $pk);
+ $checkin = true;
+ }
+
+ $query->where('(checked_out = 0 OR checked_out = ' . $userId . ')');
+ }
+
+ // Build the WHERE clause for the primary keys.
+ $this->appendPrimaryKeys($query, $pk);
+
+ $this->_db->setQuery($query);
+ $this->_db->execute();
+
+ //Check in what we checked out
+ if ($checkin)
+ {
+ $this->checkin($pk);
+ }
+ }
+
+ //if no exceptions were thrown
+ //we are good to go.
+ return true;
+ }
+
+ /**
+ * Method to check out a record
+ *
+ * @param int $userId
+ * @param null $pk
+ *
+ * @return bool
+ * @throws ErrorException
+ */
+ public function checkout($userId, $pk = null)
+ {
+ $pk = $this->getValidPk($pk);
+
+ if (!$this->isLockable($this))
+ {
+ return true;
+ }
+
+ if ($this->isLocked($this))
+ {
+ throw new ErrorException(JText::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'));
+ }
+
+ // Get the current time in the database format.
+ $time = JFactory::getDate()->toSql();
+
+ // Check the row out by primary key.
+ $query = $this->_db->getQuery(true)
+ ->update($this->_tbl)
+ ->set($this->_db->quoteName('checked_out') . ' = ' . (int) $userId)
+ ->set($this->_db->quoteName('checked_out_time') . ' = ' . $this->_db->quote($time));
+ $this->appendPrimaryKeys($query, $pk);
+ $this->_db->setQuery($query);
+ $this->_db->execute();
+
+ // Set table values in the object.
+ $this->checked_out = (int) $userId;
+ $this->checked_out_time = $time;
+
+ return true;
+ }
+
+ /**
+ * Method to check in a record
+ *
+ * @param null $pk
+ *
+ * @return bool
+ * @throws ErrorException
+ */
+ public function checkin($pk = null)
+ {
+ $pk = $this->getValidPk($pk);
+
+ if (!$this->isLockable($this))
+ {
+ return true;
+ }
+
+ if ($this->isLocked($this))
+ {
+ throw new ErrorException(JText::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'));
+ }
+
+ // Check the row in by primary key.
+ $query = $this->_db->getQuery(true)
+ ->update($this->_tbl)
+ ->set($this->_db->quoteName('checked_out') . ' = 0')
+ ->set($this->_db->quoteName('checked_out_time') . ' = ' . $this->_db->quote($this->_db->getNullDate()));
+ $this->appendPrimaryKeys($query, $pk);
+
+ $this->_db->setQuery($query);
+
+
+ // Check for a database error.
+ $this->_db->execute();
+
+ // Set table values in the object.
+ $this->checked_out = 0;
+ $this->checked_out_time = '';
+
+ return true;
+ }
+
+ /**
+ * Method to delete one or more records
+ *
+ * @param array $pk primary keys
+ *
+ * @return bool
+ * @throws ErrorException
+ */
+ public function delete($pk = null)
+ {
+ $pk = $this->getValidPk($pk);
+
+ if ($this->isCompatible('3.0'))
+ {
+ // Implement JObservableInterface: Pre-processing by observers
+ $this->_observers->update('onBeforeDelete', array($pk));
+ }
+
+ // If tracking assets, remove the asset first.
+ if ($this->_trackAssets)
+ {
+ // Get the asset name
+ $name = $this->_getAssetName();
+ $asset = self::getInstance('Asset');
+
+ if ($asset->loadByName($name))
+ {
+ if (!$asset->delete())
+ {
+ throw new ErrorException($asset->getError());
+ }
+ }
+ }
+
+ // Delete the row by primary key.
+ $query = $this->_db->getQuery(true)
+ ->delete($this->_tbl);
+ $this->appendPrimaryKeys($query, $pk);
+
+ $this->_db->setQuery($query);
+
+ // Check for a database error.
+ $this->_db->execute();
+
+ if ($this->isCompatible('3.0'))
+ {
+ // Implement JObservableInterface: Post-processing by observers
+ $this->_observers->update('onAfterDelete', array($pk));
+ }
+
+ return true;
+ }
+
+ /**
+ * Method to sanitize the primary key
+ *
+ * @param array $pk
+ *
+ * @return array|null
+ * @throws UnexpectedValueException
+ */
+ public function getValidPk($pk = null)
+ {
+ if (is_null($pk))
+ {
+ $pk = array();
+
+ foreach ($this->_tbl_keys AS $key)
+ {
+ $pk[$key] = $this->$key;
+ }
+ }
+ elseif (!is_array($pk))
+ {
+ $pk = array($this->_tbl_key => $pk);
+ }
+
+ foreach ($this->_tbl_keys AS $key)
+ {
+ $pk[$key] = is_null($pk[$key]) ? $this->$key : $pk[$key];
+
+ if ($pk[$key] === null)
+ {
+ throw new UnexpectedValueException(JText::_('JLIB_APPLICATION_ERROR_NULL_PRIMARY_KEYS_NOT_ALLOWED'));
+ }
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Method to append the primary keys for this table to a query.
+ *
+ * @param JDatabaseQuery $query A query object to append.
+ * @param mixed $pk Optional primary key parameter.
+ *
+ * @return void
+ *
+ * @since 12.3
+ */
+ public function appendPrimaryKeys($query, $pk = null)
+ {
+ if (is_null($pk))
+ {
+ foreach ($this->_tbl_keys as $k)
+ {
+ $query->where($this->_db->quoteName($k) . ' = ' . $this->_db->quote($this->$k));
+ }
+ }
+ else
+ {
+ if (!is_object($pk) && !is_array($pk))
+ {
+ $pk = array($this->_tbl_key => $pk);
+ }
+
+ $pk = (object) $pk;
+
+ foreach ($this->_tbl_keys AS $k)
+ {
+ $query->where($this->_db->quoteName($k) . ' = ' . $this->_db->quote($pk->$k));
+ }
+ }
+ }
+
+ /**
+ * Method to check if a table has lockable rows.
+ * A table that has both the "checked_out" and "checked_out_time" fields has lockable rows
+ *
+ * @param JTable $table
+ *
+ * @return boolean
+ */
+ protected function isLockable(JTable $table)
+ {
+ $hasCheckedOut = (property_exists($table, 'checked_out'));
+ $hasCheckedOutTime = (property_exists($table, 'checked_out_time'));
+ // If there is no checked_out or checked_out_time field, just return true.
+
+ if ($hasCheckedOut && $hasCheckedOutTime)
+ {
+ return true; // is lockable
+ }
+
+ return false; // is not lockable
+ }
+
+ /**
+ * Method ot check if a table row is locked.
+ * A row is locked if it is lockable and has a checked_out value greater than 0
+ *
+ * @param JTableCms $activeRecord
+ *
+ * @return boolean
+ */
+ protected function isLocked($activeRecord)
+ {
+ $user = JFactory::getUser();
+ if ($this->isLockable($activeRecord))
+ {
+ $isCheckedOut = ($activeRecord->checked_out > 0);
+ $isCurrentEditor = ($activeRecord->checked_out == $user->get('id'));
+ $canOverride = ($user->authorise('core.admin', 'com_checkin'));
+
+ if ($isCheckedOut && !$isCurrentEditor && !$canOverride)
+ {
+ return true; // record is locked
+ }
+ }
+
+ return false; // record is not locked
+ }
+
+ /**
+ * @param array $pk array of one or more primary keys
+ * @param int $userId current user id
+ * @param int $delta Either 1 or -1 depending on movement direction
+ * @param string $where SQL WHERE clause
+ *
+ * @return bool
+ * @throws ErrorException
+ * @see JModelAdministrator::reorder
+ */
+ public function moveOrder($pk, $userId, $delta, $where = null)
+ {
+ // if no ordering not supported then just return true
+ if (!$this->supportsOrdering($this))
+ {
+ return true;
+ }
+
+ // If the change is none, do nothing.
+ if (empty($delta))
+ {
+ return true;
+ }
+
+ $checkin = false;
+ if ($this->isLockable($this))
+ {
+ if ($this->isLocked($this))
+ {
+ throw new ErrorException(JText::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'));
+ }
+ $this->checkout($userId);
+ $checkin = true;
+ }
+
+ $row = null;
+ $query = $this->_db->getQuery(true);
+
+ // Select the primary key and ordering values from the table.
+ $query->select(implode(',', $this->_tbl_keys) . ', ordering')
+ ->from($this->_tbl);
+
+ // If the movement delta is negative move the row up.
+ if ($delta < 0)
+ {
+ $query->where('ordering < ' . (int) $this->ordering)
+ ->order('ordering DESC');
+ }
+ // If the movement delta is positive move the row down.
+ elseif ($delta > 0)
+ {
+ $query->where('ordering > ' . (int) $this->ordering)
+ ->order('ordering ASC');
+ }
+
+ // Add the custom WHERE clause if set.
+ if ($where)
+ {
+ $query->where($where);
+ }
+
+ // Select the first row with the criteria.
+ $this->_db->setQuery($query, 0, 1);
+ $row = $this->_db->loadObject();
+
+ // If a row is found, move the item.
+ if (!empty($row))
+ {
+ // Update the ordering field for this instance to the row's ordering value.
+ $query->clear()
+ ->update($this->_tbl)
+ ->set('ordering = ' . (int) $row->ordering);
+ $this->appendPrimaryKeys($query);
+ $this->_db->setQuery($query);
+ $this->_db->execute();
+
+ // Update the ordering field for the row to this instance's ordering value.
+ $query->clear()
+ ->update($this->_tbl)
+ ->set('ordering = ' . (int) $this->ordering);
+ $this->appendPrimaryKeys($query, $row);
+ $this->_db->setQuery($query);
+ $this->_db->execute();
+
+ // Update the instance value.
+ $this->ordering = $row->ordering;
+ }
+ else
+ {
+ // Update the ordering field for this instance.
+ $query->clear()
+ ->update($this->_tbl)
+ ->set('ordering = ' . (int) $this->ordering);
+ $this->appendPrimaryKeys($query);
+ $this->_db->setQuery($query);
+ $this->_db->execute();
+ }
+
+ if ($checkin)
+ {
+ $this->checkin($pk);
+ }
+
+ return true;
+ }
+
+ /**
+ * Method to check if the current table supports the ordering field
+ *
+ * @param JTable $table
+ *
+ * @return bool
+ */
+ protected function supportsOrdering(JTable $table)
+ {
+ if (property_exists($table, 'ordering'))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Method to get an SQL WHERE clause to order by
+ * This method is intended to be overridden by children classes if needed
+ *
+ * @param JTable $activeRecord
+ *
+ * @see JModelCms::reorder
+ * @return string
+ */
+ public function getReorderConditions($activeRecord)
+ {
+ return '';
+ }
+
+ /**
+ * @see JTable::check()
+ */
+ public function check()
+ {
+ $key = $this->getKeyName();
+ if (property_exists($this, 'ordering') && $this->$key == 0)
+ {
+ $this->ordering = self::getNextOrder();
+ }
+
+ return parent::check();
+ }
+
+ /**
+ * @see JTable::bind()
+ */
+ public function bind($src, $ignore = array())
+ {
+ $array = $src;
+
+ if (isset($array['params']) && is_array($array['params']))
+ {
+ $registry = new JRegistry();
+ $registry->loadArray($array['params']);
+ $array['params'] = (string) $registry;
+ }
+
+ if (isset($array['metadata']) && is_array($array['metadata']))
+ {
+ $registry = new JRegistry();
+ $registry->loadArray($array['metadata']);
+ $array['metadata'] = (string) $registry;
+ }
+
+ if (isset($array['rules']) && is_array($array['rules']))
+ {
+ $rules = new JAccessRules($array['rules']);
+ $this->setRules($rules);
+ }
+
+ return parent::bind($array, $ignore);
+ }
+
+ /**
+ * Method to load a row from the database by primary key and bind the fields
+ * to the JTable instance properties.
+ *
+ * @param mixed $keys An optional primary key value to load the row by, or an array of fields to match. If not
+ * set the instance property value is used.
+ * @param boolean $reset True to reset the default values before loading the new row.
+ *
+ * @return boolean True if successful. False if row not found.
+ *
+ * @link http://docs.joomla.org/JTable/load
+ * @since 11.1
+ * @throws InvalidArgumentException
+ * @throws RuntimeException
+ * @throws UnexpectedValueException
+ */
+ public function load($keys = null, $reset = true)
+ {
+ if ($this->isCompatible('3.0'))
+ {
+ // Implement JObservableInterface: Pre-processing by observers
+ $this->_observers->update('onBeforeLoad', array($keys, $reset));
+ }
+
+ if (empty($keys))
+ {
+ $empty = true;
+ $keys = array();
+
+ // If empty, use the value of the current key
+ foreach ($this->_tbl_keys as $key)
+ {
+ $empty = $empty && empty($this->$key);
+ $keys[$key] = $this->$key;
+ }
+
+ // If empty primary key there's is no need to load anything
+ if ($empty)
+ {
+ return true;
+ }
+ }
+ elseif (!is_array($keys))
+ {
+ // Load by primary key.
+ $keyCount = count($this->_tbl_keys);
+
+ if ($keyCount)
+ {
+ if ($keyCount > 1)
+ {
+ throw new InvalidArgumentException('Table has multiple primary keys specified, only one primary key value provided.');
+ }
+ $keys = array($this->getKeyName() => $keys);
+ }
+ else
+ {
+ throw new RuntimeException('No table keys defined.');
+ }
+ }
+
+ if ($reset)
+ {
+ $this->reset();
+ }
+
+ // Initialise the query.
+ $query = $this->_db->getQuery(true)
+ ->select('*')
+ ->from($this->_tbl);
+ $fields = array_keys($this->getProperties());
+
+ foreach ($keys as $field => $value)
+ {
+ // Check that $field is in the table.
+ if (!in_array($field, $fields))
+ {
+ throw new UnexpectedValueException(sprintf('Missing field in database: %s %s.', get_class($this), $field));
+ }
+ // Add the search tuple to the query.
+ $query->where($this->_db->quoteName($field) . ' = ' . $this->_db->quote($value));
+ }
+
+ $this->_db->setQuery($query);
+
+ $row = $this->_db->loadAssoc();
+
+ // Check that we have a result.
+ if (empty($row))
+ {
+ $result = false;
+ }
+ else
+ {
+ // Bind the object with the row and return.
+ $result = $this->bind($row);
+ }
+
+ if ($this->isCompatible('3.0'))
+ {
+ // Implement JObservableInterface: Post-processing by observers
+ $this->_observers->update('onAfterLoad', array(&$result, $row));
+ }
+
+ return $result;
+ }
+
+ /**
+ * Check if the version compatible
+ *
+ * @param string $minimum The minimum version of the Joomla which is compatible.
+ *
+ * @see JVersion::isCompatible
+ * @return boolean
+ */
+ protected function isCompatible($minimum)
+ {
+ $version = new JVersion();
+ if ($version->isCompatible($minimum))
+ {
+ return true;
+ }
+
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/libraries/cms/table/contenthistory.php b/libraries/cms/table/contenthistory.php
index de6a9f26b77f0..4b8b94ce5dfb2 100644
--- a/libraries/cms/table/contenthistory.php
+++ b/libraries/cms/table/contenthistory.php
@@ -30,7 +30,7 @@ class JTableContenthistory extends JTable
/**
* Constructor
*
- * @param JDatabaseDriver $db A database connector object
+ * @param JDatabaseDriver $db A database connector object
*
* @since 3.1
*/
@@ -43,7 +43,7 @@ public function __construct($db)
/**
* Overrides JTable::store to set modified hash, user id, and save date.
*
- * @param boolean $updateNulls True to update fields even if they are null.
+ * @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success.
*
@@ -68,7 +68,7 @@ public function store($updateNulls = false)
* Utility method to get the hash after removing selected values. This lets us detect changes other than
* modified date (which will change on every save).
*
- * @param mixed $jsonData Either an object or a string with json-encoded data
+ * @param mixed $jsonData Either an object or a string with json-encoded data
*
* @return string SHA1 hash on sucess. Empty string on failure.
*
@@ -127,7 +127,7 @@ public function getSha1($jsonData)
*/
public function getHashMatch()
{
- $db = $this->_db;
+ $db = $this->_db;
$query = $db->getQuery(true);
$query->select('*')
->from($db->quoteName('#__ucm_history'))
@@ -142,7 +142,7 @@ public function getHashMatch()
/**
* Utility method to remove the oldest versions of an item, saving only the most recent versions.
*
- * @param integer $maxVersions The maximum number of versions to save. All others will be deleted.
+ * @param integer $maxVersions The maximum number of versions to save. All others will be deleted.
*
* @return boolean true on sucess, false on failure.
*
@@ -153,7 +153,7 @@ public function deleteOldVersions($maxVersions)
$result = true;
// Get the list of version_id values we want to save
- $db = $this->_db;
+ $db = $this->_db;
$query = $db->getQuery(true);
$query->select($db->quoteName('version_id'))
->from($db->quoteName('#__ucm_history'))
diff --git a/libraries/cms/table/contenttype.php b/libraries/cms/table/contenttype.php
index 22acbf4f38146..217d5fc035f5d 100644
--- a/libraries/cms/table/contenttype.php
+++ b/libraries/cms/table/contenttype.php
@@ -21,7 +21,7 @@ class JTableContenttype extends JTable
/**
* Constructor
*
- * @param JDatabaseDriver $db A database connector object
+ * @param JDatabaseDriver $db A database connector object
*
* @since 3.1
*/
@@ -59,7 +59,7 @@ public function check()
/**
* Overridden JTable::store.
*
- * @param boolean $updateNulls True to update fields even if they are null.
+ * @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success.
*
@@ -83,7 +83,7 @@ public function store($updateNulls = false)
/**
* Method to expand the field mapping
*
- * @param boolean $assoc True to return an associative array.
+ * @param boolean $assoc True to return an associative array.
*
* @return mixed Array or object with field mappings. Defaults to object.
*
@@ -97,7 +97,7 @@ public function fieldmapExpand($assoc = true)
/**
* Method to get the id given the type alias
*
- * @param string $typeAlias Content type alias (for example, 'com_content.article').
+ * @param string $typeAlias Content type alias (for example, 'com_content.article').
*
* @return mixed type_id for this alias if successful, otherwise null.
*
@@ -105,7 +105,7 @@ public function fieldmapExpand($assoc = true)
*/
public function getTypeId($typeAlias)
{
- $db = $this->_db;
+ $db = $this->_db;
$query = $db->getQuery(true);
$query->select($db->quoteName('type_id'))
->from($db->quoteName('#__content_types'))
@@ -124,7 +124,7 @@ public function getTypeId($typeAlias)
*/
public function getContentTable()
{
- $result = false;
+ $result = false;
$tableInfo = json_decode($this->table);
if (is_object($tableInfo) && isset($tableInfo->special))
diff --git a/libraries/cms/table/corecontent.php b/libraries/cms/table/corecontent.php
index 96d4a597f3b09..739dc27640bd0 100644
--- a/libraries/cms/table/corecontent.php
+++ b/libraries/cms/table/corecontent.php
@@ -21,7 +21,7 @@ class JTableCorecontent extends JTable
/**
* Constructor
*
- * @param JDatabaseDriver $db A database connector object
+ * @param JDatabaseDriver $db A database connector object
*
* @since 3.1
*/
@@ -33,8 +33,8 @@ public function __construct($db)
/**
* Overloaded bind function
*
- * @param array $array Named array
- * @param mixed $ignore An optional array or space separated list of properties
+ * @param array $array Named array
+ * @param mixed $ignore An optional array or space separated list of properties
* to ignore while binding.
*
* @return mixed Null if operation was satisfactory, otherwise returns an error string
@@ -95,6 +95,7 @@ public function check()
if (trim($this->core_title) == '')
{
$this->setError(JText::_('LIB_CMS_WARNING_PROVIDE_VALID_NAME'));
+
return false;
}
@@ -114,8 +115,8 @@ public function check()
if ($this->core_publish_down > $this->_db->getNullDate() && $this->core_publish_down < $this->core_publish_up)
{
// Swap the dates.
- $temp = $this->core_publish_up;
- $this->core_publish_up = $this->core_publish_down;
+ $temp = $this->core_publish_up;
+ $this->core_publish_up = $this->core_publish_down;
$this->core_publish_down = $temp;
}
@@ -154,7 +155,7 @@ public function check()
/**
* Override JTable delete method to include deleting corresponding row from #__ucm_base.
*
- * @param integer $pk primary key value to delete. Must be set or throws an exception.
+ * @param integer $pk primary key value to delete. Must be set or throws an exception.
*
* @return boolean True on success.
*
@@ -164,13 +165,14 @@ public function check()
public function delete($pk = null)
{
$baseTable = JTable::getInstance('Ucm');
+
return parent::delete($pk) && $baseTable->delete($pk);
}
/**
* Method to delete a row from the #__ucm_content table by content_item_id.
*
- * @param integer $contentItemId value of the core_content_item_id to delete. Corresponds to the primary key of the content table.
+ * @param integer $contentItemId value of the core_content_item_id to delete. Corresponds to the primary key of the content table.
*
* @return boolean True on success.
*
@@ -184,7 +186,7 @@ public function deleteByContentId($contentItemId = null)
throw new UnexpectedValueException('Null content item key not allowed.');
}
- $db = $this->getDbo();
+ $db = $this->getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('core_content_id'))
->from($db->quoteName('#__ucm_content'))
@@ -203,7 +205,7 @@ public function deleteByContentId($contentItemId = null)
/**
* Overrides JTable::store to set modified data and user id.
*
- * @param boolean $updateNulls True to update fields even if they are null.
+ * @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success.
*
@@ -217,9 +219,9 @@ public function store($updateNulls = false)
if ($this->core_content_id)
{
// Existing item
- $this->core_modified_time = $date->toSql();
+ $this->core_modified_time = $date->toSql();
$this->core_modified_user_id = $user->get('id');
- $isNew = false;
+ $isNew = false;
}
else
{
@@ -253,8 +255,8 @@ public function store($updateNulls = false)
/**
* Insert or update row in ucm_base table
*
- * @param boolean $updateNulls True to update fields even if they are null.
- * @param boolean $isNew if true, need to insert. Otherwise update.
+ * @param boolean $updateNulls True to update fields even if they are null.
+ * @param boolean $isNew if true, need to insert. Otherwise update.
*
* @return boolean True on success.
*
@@ -263,8 +265,8 @@ public function store($updateNulls = false)
protected function storeUcmBase($updateNulls = false, $isNew = false)
{
// Store the ucm_base row
- $db = $this->getDbo();
- $query = $db->getQuery(true);
+ $db = $this->getDbo();
+ $query = $db->getQuery(true);
$languageId = JHelperContent::getLanguageId($this->core_language);
if ($isNew)
@@ -276,7 +278,7 @@ protected function storeUcmBase($updateNulls = false, $isNew = false)
. $db->quote($this->core_content_item_id) . ', '
. $db->quote($this->core_type_id) . ', '
. $db->quote($languageId)
- );
+ );
}
else
{
@@ -297,9 +299,9 @@ protected function storeUcmBase($updateNulls = false, $isNew = false)
* table. The method respects checked out rows by other users and will attempt
* to checkin rows that it can after adjustments are made.
*
- * @param mixed $pks An optional array of primary key values to update. If not set the instance property value is used.
- * @param integer $state The publishing state. eg. [0 = unpublished, 1 = published]
- * @param integer $userId The user id of the user performing the operation.
+ * @param mixed $pks An optional array of primary key values to update. If not set the instance property value is used.
+ * @param integer $state The publishing state. eg. [0 = unpublished, 1 = published]
+ * @param integer $userId The user id of the user performing the operation.
*
* @return boolean True on success.
*
@@ -312,7 +314,7 @@ public function publish($pks = null, $state = 1, $userId = 0)
// Sanitize input.
JArrayHelper::toInteger($pks);
$userId = (int) $userId;
- $state = (int) $state;
+ $state = (int) $state;
// If there are no primary keys set check to see if the instance key is set.
if (empty($pks))
@@ -325,6 +327,7 @@ public function publish($pks = null, $state = 1, $userId = 0)
else
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
+
return false;
}
}
@@ -355,6 +358,7 @@ public function publish($pks = null, $state = 1, $userId = 0)
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
+
return false;
}
diff --git a/libraries/cms/table/ucm.php b/libraries/cms/table/ucm.php
index e4d857fed3776..3a71347edb74b 100644
--- a/libraries/cms/table/ucm.php
+++ b/libraries/cms/table/ucm.php
@@ -21,7 +21,7 @@ class JTableUcm extends JTable
/**
* Constructor
*
- * @param JDatabaseDriver $db A database connector object
+ * @param JDatabaseDriver $db A database connector object
*
* @since 3.1
*/
diff --git a/libraries/cms/toolbar/button.php b/libraries/cms/toolbar/button.php
index 16a674211a2e6..44661cf35a71e 100644
--- a/libraries/cms/toolbar/button.php
+++ b/libraries/cms/toolbar/button.php
@@ -39,7 +39,7 @@ abstract class JToolbarButton
/**
* Constructor
*
- * @param object $parent The parent
+ * @param object $parent The parent
*/
public function __construct($parent = null)
{
@@ -61,7 +61,7 @@ public function getName()
/**
* Get the HTML to render the button
*
- * @param array &$definition Parameters to be passed
+ * @param array &$definition Parameters to be passed
*
* @return string
*
@@ -72,7 +72,7 @@ public function render(&$definition)
/*
* Initialise some variables
*/
- $id = call_user_func_array(array(&$this, 'fetchId'), $definition);
+ $id = call_user_func_array(array(&$this, 'fetchId'), $definition);
$action = call_user_func_array(array(&$this, 'fetchButton'), $definition);
// Build id attribute
@@ -82,8 +82,8 @@ public function render(&$definition)
}
// Build the HTML Button
- $options = array();
- $options['id'] = $id;
+ $options = array();
+ $options['id'] = $id;
$options['action'] = $action;
$layout = new JLayoutFile('joomla.toolbar.base');
@@ -96,7 +96,7 @@ public function render(&$definition)
*
* Can be redefined in the final class
*
- * @param string $identifier Icon identification string
+ * @param string $identifier Icon identification string
*
* @return string CSS class name
*
@@ -136,7 +136,7 @@ abstract class JButton extends JToolbarButton
/**
* Constructor
*
- * @param object $parent The parent
+ * @param object $parent The parent
*
* @deprecated 4.0 Use JToolbarButton instead.
*/
diff --git a/libraries/cms/toolbar/button/confirm.php b/libraries/cms/toolbar/button/confirm.php
index 55b0f9cb68fe8..cf74c53ea9454 100644
--- a/libraries/cms/toolbar/button/confirm.php
+++ b/libraries/cms/toolbar/button/confirm.php
@@ -28,13 +28,13 @@ class JToolbarButtonConfirm extends JToolbarButton
/**
* Fetch the HTML for the button
*
- * @param string $type Unused string.
- * @param string $msg Message to render
- * @param string $name Name to be used as apart of the id
- * @param string $text Button text
- * @param string $task The task associated with the button
- * @param boolean $list True to allow use of lists
- * @param boolean $hideMenu True to hide the menu on click
+ * @param string $type Unused string.
+ * @param string $msg Message to render
+ * @param string $name Name to be used as apart of the id
+ * @param string $text Button text
+ * @param string $task The task associated with the button
+ * @param boolean $list True to allow use of lists
+ * @param boolean $hideMenu True to hide the menu on click
*
* @return string HTML string for the button
*
@@ -43,10 +43,10 @@ class JToolbarButtonConfirm extends JToolbarButton
public function fetchButton($type = 'Confirm', $msg = '', $name = '', $text = '', $task = '', $list = true, $hideMenu = false)
{
// Store all data to the options array for use with JLayout
- $options = array();
- $options['text'] = JText::_($text);
- $options['msg'] = JText::_($msg, true);
- $options['class'] = $this->fetchIconClass($name);
+ $options = array();
+ $options['text'] = JText::_($text);
+ $options['msg'] = JText::_($msg, true);
+ $options['class'] = $this->fetchIconClass($name);
$options['doTask'] = $this->_getCommand($options['msg'], $name, $task, $list);
// Instantiate a new JLayoutFile instance and render the layout
@@ -58,12 +58,12 @@ public function fetchButton($type = 'Confirm', $msg = '', $name = '', $text = ''
/**
* Get the button CSS Id
*
- * @param string $type Button type
- * @param string $name Name to be used as apart of the id
- * @param string $text Button text
- * @param string $task The task associated with the button
- * @param boolean $list True to allow use of lists
- * @param boolean $hideMenu True to hide the menu on click
+ * @param string $type Button type
+ * @param string $name Name to be used as apart of the id
+ * @param string $text Button text
+ * @param string $task The task associated with the button
+ * @param boolean $list True to allow use of lists
+ * @param boolean $hideMenu True to hide the menu on click
*
* @return string Button CSS Id
*
@@ -77,10 +77,10 @@ public function fetchId($type = 'Confirm', $name = '', $text = '', $task = '', $
/**
* Get the JavaScript command for the button
*
- * @param object $msg The message to display.
- * @param string $name Not used.
- * @param string $task The task used by the application
- * @param boolean $list True is requires a list confirmation.
+ * @param object $msg The message to display.
+ * @param string $name Not used.
+ * @param string $task The task used by the application
+ * @param boolean $list True is requires a list confirmation.
*
* @return string JavaScript command string
*
diff --git a/libraries/cms/toolbar/button/custom.php b/libraries/cms/toolbar/button/custom.php
index 049dfd6585d1a..1f5c5dcea73d3 100644
--- a/libraries/cms/toolbar/button/custom.php
+++ b/libraries/cms/toolbar/button/custom.php
@@ -28,9 +28,9 @@ class JToolbarButtonCustom extends JToolbarButton
/**
* Fetch the HTML for the button
*
- * @param string $type Button type, unused string.
- * @param string $html HTML strng for the button
- * @param string $id CSS id for the button
+ * @param string $type Button type, unused string.
+ * @param string $html HTML strng for the button
+ * @param string $id CSS id for the button
*
* @return string HTML string for the button
*
@@ -44,9 +44,9 @@ public function fetchButton($type = 'Custom', $html = '', $id = 'custom')
/**
* Get the button CSS Id
*
- * @param string $type Not used.
- * @param string $html Not used.
- * @param string $id The id prefix for the button.
+ * @param string $type Not used.
+ * @param string $html Not used.
+ * @param string $id The id prefix for the button.
*
* @return string Button CSS Id
*
diff --git a/libraries/cms/toolbar/button/help.php b/libraries/cms/toolbar/button/help.php
index dde84d16cfe8d..44fe2cb67ca5e 100644
--- a/libraries/cms/toolbar/button/help.php
+++ b/libraries/cms/toolbar/button/help.php
@@ -19,18 +19,18 @@
class JToolbarButtonHelp extends JToolbarButton
{
/**
- * @var string Button type
+ * @var string Button type
*/
protected $_name = 'Help';
/**
* Fetches the button HTML code.
*
- * @param string $type Unused string.
- * @param string $ref The name of the help screen (its key reference).
- * @param boolean $com Use the help file in the component directory.
- * @param string $override Use this URL instead of any other.
- * @param string $component Name of component to get Help (null for current component)
+ * @param string $type Unused string.
+ * @param string $ref The name of the help screen (its key reference).
+ * @param boolean $com Use the help file in the component directory.
+ * @param string $override Use this URL instead of any other.
+ * @param string $component Name of component to get Help (null for current component)
*
* @return string
*
@@ -39,7 +39,7 @@ class JToolbarButtonHelp extends JToolbarButton
public function fetchButton($type = 'Help', $ref = '', $com = false, $override = null, $component = null)
{
// Store all data to the options array for use with JLayout
- $options = array();
+ $options = array();
$options['text'] = JText::_('JTOOLBAR_HELP');
$options['doTask'] = $this->_getCommand($ref, $com, $override, $component);
@@ -54,7 +54,7 @@ public function fetchButton($type = 'Help', $ref = '', $com = false, $override =
*
* Redefined from JButton class
*
- * @return string Button CSS Id
+ * @return string Button CSS Id
*
* @since 3.0
*/
@@ -66,10 +66,10 @@ public function fetchId()
/**
* Get the JavaScript command for the button
*
- * @param string $ref The name of the help screen (its key reference).
- * @param boolean $com Use the help file in the component directory.
- * @param string $override Use this URL instead of any other.
- * @param string $component Name of component to get Help (null for current component)
+ * @param string $ref The name of the help screen (its key reference).
+ * @param boolean $com Use the help file in the component directory.
+ * @param string $override Use this URL instead of any other.
+ * @param string $component Name of component to get Help (null for current component)
*
* @return string JavaScript command string
*
diff --git a/libraries/cms/toolbar/button/link.php b/libraries/cms/toolbar/button/link.php
index f3e046cf94902..a6cc36eaaff1d 100644
--- a/libraries/cms/toolbar/button/link.php
+++ b/libraries/cms/toolbar/button/link.php
@@ -27,10 +27,10 @@ class JToolbarButtonLink extends JToolbarButton
/**
* Fetch the HTML for the button
*
- * @param string $type Unused string.
- * @param string $name Name to be used as apart of the id
- * @param string $text Button text
- * @param string $url The link url
+ * @param string $type Unused string.
+ * @param string $name Name to be used as apart of the id
+ * @param string $text Button text
+ * @param string $url The link url
*
* @return string HTML string for the button
*
@@ -39,9 +39,9 @@ class JToolbarButtonLink extends JToolbarButton
public function fetchButton($type = 'Link', $name = 'back', $text = '', $url = null)
{
// Store all data to the options array for use with JLayout
- $options = array();
- $options['text'] = JText::_($text);
- $options['class'] = $this->fetchIconClass($name);
+ $options = array();
+ $options['text'] = JText::_($text);
+ $options['class'] = $this->fetchIconClass($name);
$options['doTask'] = $this->_getCommand($url);
// Instantiate a new JLayoutFile instance and render the layout
@@ -53,8 +53,8 @@ public function fetchButton($type = 'Link', $name = 'back', $text = '', $url = n
/**
* Get the button CSS Id
*
- * @param string $type The button type.
- * @param string $name The name of the button.
+ * @param string $type The button type.
+ * @param string $name The name of the button.
*
* @return string Button CSS Id
*
@@ -68,7 +68,7 @@ public function fetchId($type = 'Link', $name = '')
/**
* Get the JavaScript command for the button
*
- * @param object $url Button definition
+ * @param object $url Button definition
*
* @return string JavaScript command string
*
diff --git a/libraries/cms/toolbar/button/popup.php b/libraries/cms/toolbar/button/popup.php
index a1f417a71901e..eb4a9203574a7 100644
--- a/libraries/cms/toolbar/button/popup.php
+++ b/libraries/cms/toolbar/button/popup.php
@@ -28,23 +28,23 @@ class JToolbarButtonPopup extends JToolbarButton
/**
* Fetch the HTML for the button
*
- * @param string $type Unused string, formerly button type.
- * @param string $name Modal name, used to generate element ID
- * @param string $text The link text
- * @param string $url URL for popup
- * @param integer $width Width of popup
- * @param integer $height Height of popup
- * @param integer $top Top attribute. [@deprecated Unused, will be removed in 4.0]
- * @param integer $left Left attribute. [@deprecated Unused, will be removed in 4.0]
- * @param string $onClose JavaScript for the onClose event.
- * @param string $title The title text
+ * @param string $type Unused string, formerly button type.
+ * @param string $name Modal name, used to generate element ID
+ * @param string $text The link text
+ * @param string $url URL for popup
+ * @param integer $width Width of popup
+ * @param integer $height Height of popup
+ * @param integer $top Top attribute. [@deprecated Unused, will be removed in 4.0]
+ * @param integer $left Left attribute. [@deprecated Unused, will be removed in 4.0]
+ * @param string $onClose JavaScript for the onClose event.
+ * @param string $title The title text
*
* @return string HTML string for the button
*
* @since 3.0
*/
public function fetchButton($type = 'Modal', $name = '', $text = '', $url = '', $width = 640, $height = 480, $top = 0, $left = 0,
- $onClose = '', $title = '')
+ $onClose = '', $title = '')
{
// If no $title is set, use the $text element
if (strlen($title) == 0)
@@ -53,29 +53,29 @@ public function fetchButton($type = 'Modal', $name = '', $text = '', $url = '',
}
// Store all data to the options array for use with JLayout
- $options = array();
- $options['name'] = trim(JText::_($name), '*?');
- $options['text'] = JText::_($text);
- $options['title'] = JText::_($title);
- $options['class'] = $this->fetchIconClass($name);
+ $options = array();
+ $options['name'] = trim(JText::_($name), '*?');
+ $options['text'] = JText::_($text);
+ $options['title'] = JText::_($title);
+ $options['class'] = $this->fetchIconClass($name);
$options['doTask'] = $this->_getCommand($url);
// Instantiate a new JLayoutFile instance and render the layout
$layout = new JLayoutFile('joomla.toolbar.popup');
- $html = array();
+ $html = array();
$html[] = $layout->render($options);
// Place modal div and scripts in a new div
$html[] = '';
// Build the options array for the modal
- $params = array();
+ $params = array();
$params['title'] = $options['title'];
$params['url'] = $options['doTask'];
$params['height'] = $height;
$params['width'] = $width;
- $html[] = JHtml::_('bootstrap.renderModal', 'modal-' . $name, $params);
+ $html[] = JHtml::_('bootstrap.renderModal', 'modal-' . $name, $params);
// If an $onClose event is passed, add it to the modal JS object
if (strlen($onClose) >= 1)
@@ -91,10 +91,10 @@ public function fetchButton($type = 'Modal', $name = '', $text = '', $url = '',
/**
* Get the button id
*
- * @param string $type Button type
- * @param string $name Button name
+ * @param string $type Button type
+ * @param string $name Button name
*
- * @return string Button CSS Id
+ * @return string Button CSS Id
*
* @since 3.0
*/
@@ -106,7 +106,7 @@ public function fetchId($type, $name)
/**
* Get the JavaScript command for the button
*
- * @param string $url URL for popup
+ * @param string $url URL for popup
*
* @return string JavaScript command string
*
diff --git a/libraries/cms/toolbar/button/separator.php b/libraries/cms/toolbar/button/separator.php
index 6fbd403280361..80c63cdea7dc0 100644
--- a/libraries/cms/toolbar/button/separator.php
+++ b/libraries/cms/toolbar/button/separator.php
@@ -28,7 +28,7 @@ class JToolbarButtonSeparator extends JToolbarButton
/**
* Get the HTML for a separator in the toolbar
*
- * @param array &$definition Class name and custom width
+ * @param array &$definition Class name and custom width
*
* @return string The HTML for the separator
*
diff --git a/libraries/cms/toolbar/button/slider.php b/libraries/cms/toolbar/button/slider.php
index 61a2981e54610..41b1496ddbd1b 100644
--- a/libraries/cms/toolbar/button/slider.php
+++ b/libraries/cms/toolbar/button/slider.php
@@ -28,13 +28,13 @@ class JToolbarButtonSlider extends JToolbarButton
/**
* Fetch the HTML for the button
*
- * @param string $type Unused string, formerly button type.
- * @param string $name Button name
- * @param string $text The link text
- * @param string $url URL for popup
- * @param integer $width Width of popup
- * @param integer $height Height of popup
- * @param string $onClose JavaScript for the onClose event.
+ * @param string $type Unused string, formerly button type.
+ * @param string $name Button name
+ * @param string $text The link text
+ * @param string $url URL for popup
+ * @param integer $width Width of popup
+ * @param integer $height Height of popup
+ * @param string $onClose JavaScript for the onClose event.
*
* @return string HTML string for the button
*
@@ -45,13 +45,13 @@ public function fetchButton($type = 'Slider', $name = '', $text = '', $url = '',
JHtml::_('script', 'jui/cms.js', false, true);
// Store all data to the options array for use with JLayout
- $options = array();
- $options['text'] = JText::_($text);
- $options['name'] = $name;
- $options['class'] = $this->fetchIconClass($name);
+ $options = array();
+ $options['text'] = JText::_($text);
+ $options['name'] = $name;
+ $options['class'] = $this->fetchIconClass($name);
$options['onClose'] = '';
- $doTask = $this->_getCommand($url);
+ $doTask = $this->_getCommand($url);
$options['doTask'] = 'Joomla.setcollapse(\'' . $doTask . '\', \'' . $name . '\', \'' . $height . '\');';
if ($onClose)
@@ -68,10 +68,10 @@ public function fetchButton($type = 'Slider', $name = '', $text = '', $url = '',
/**
* Get the button id
*
- * @param string $type Button type
- * @param string $name Button name
+ * @param string $type Button type
+ * @param string $name Button name
*
- * @return string Button CSS Id
+ * @return string Button CSS Id
*
* @since 3.0
*/
@@ -83,7 +83,7 @@ public function fetchId($type, $name)
/**
* Get the JavaScript command for the button
*
- * @param string $url URL for popup
+ * @param string $url URL for popup
*
* @return string JavaScript command string
*
diff --git a/libraries/cms/toolbar/button/standard.php b/libraries/cms/toolbar/button/standard.php
index 6e7c194ce52ef..9a8003ab42bfd 100644
--- a/libraries/cms/toolbar/button/standard.php
+++ b/libraries/cms/toolbar/button/standard.php
@@ -28,11 +28,11 @@ class JToolbarButtonStandard extends JToolbarButton
/**
* Fetch the HTML for the button
*
- * @param string $type Unused string.
- * @param string $name The name of the button icon class.
- * @param string $text Button text.
- * @param string $task Task associated with the button.
- * @param boolean $list True to allow lists
+ * @param string $type Unused string.
+ * @param string $name The name of the button icon class.
+ * @param string $text Button text.
+ * @param string $task Task associated with the button.
+ * @param boolean $list True to allow lists
*
* @return string HTML string for the button
*
@@ -41,9 +41,9 @@ class JToolbarButtonStandard extends JToolbarButton
public function fetchButton($type = 'Standard', $name = '', $text = '', $task = '', $list = true)
{
// Store all data to the options array for use with JLayout
- $options = array();
- $options['text'] = JText::_($text);
- $options['class'] = $this->fetchIconClass($name);
+ $options = array();
+ $options['text'] = JText::_($text);
+ $options['class'] = $this->fetchIconClass($name);
$options['doTask'] = $this->_getCommand($options['text'], $task, $list);
if ($name == 'apply' || $name == 'new')
@@ -65,12 +65,12 @@ public function fetchButton($type = 'Standard', $name = '', $text = '', $task =
/**
* Get the button CSS Id
*
- * @param string $type Unused string.
- * @param string $name Name to be used as apart of the id
- * @param string $text Button text
- * @param string $task The task associated with the button
- * @param boolean $list True to allow use of lists
- * @param boolean $hideMenu True to hide the menu on click
+ * @param string $type Unused string.
+ * @param string $name Name to be used as apart of the id
+ * @param string $text Button text
+ * @param string $task The task associated with the button
+ * @param boolean $list True to allow use of lists
+ * @param boolean $hideMenu True to hide the menu on click
*
* @return string Button CSS Id
*
@@ -84,9 +84,9 @@ public function fetchId($type = 'Standard', $name = '', $text = '', $task = '',
/**
* Get the JavaScript command for the button
*
- * @param string $name The task name as seen by the user
- * @param string $task The task used by the application
- * @param boolean $list True is requires a list confirmation.
+ * @param string $name The task name as seen by the user
+ * @param string $task The task used by the application
+ * @param boolean $list True is requires a list confirmation.
*
* @return string JavaScript command string
*
diff --git a/libraries/cms/toolbar/toolbar.php b/libraries/cms/toolbar/toolbar.php
index 6b9dc2164fe92..31b81bdb9be30 100644
--- a/libraries/cms/toolbar/toolbar.php
+++ b/libraries/cms/toolbar/toolbar.php
@@ -57,7 +57,7 @@ class JToolbar
/**
* Constructor
*
- * @param string $name The toolbar name.
+ * @param string $name The toolbar name.
*
* @since 1.5
*/
@@ -74,7 +74,7 @@ public function __construct($name = 'toolbar')
* Returns the global JToolbar object, only creating it if it
* doesn't already exist.
*
- * @param string $name The name of the toolbar.
+ * @param string $name The name of the toolbar.
*
* @return JToolbar The JToolbar object.
*
@@ -102,6 +102,7 @@ public function appendButton()
// Push button onto the end of the toolbar array.
$btn = func_get_args();
array_push($this->_bar, $btn);
+
return true;
}
@@ -141,6 +142,7 @@ public function prependButton()
// Insert button into the front of the toolbar array.
$btn = func_get_args();
array_unshift($this->_bar, $btn);
+
return true;
}
@@ -177,7 +179,7 @@ public function render()
/**
* Render a button.
*
- * @param object &$node A toolbar node.
+ * @param object &$node A toolbar node.
*
* @return string
*
@@ -195,14 +197,15 @@ public function renderButton(&$node)
{
return JText::sprintf('JLIB_HTML_BUTTON_NOT_DEFINED', $type);
}
+
return $button->render($node);
}
/**
* Loads a button type.
*
- * @param string $type Button Type
- * @param boolean $new False by default
+ * @param string $type Button Type
+ * @param boolean $new False by default
*
* @return boolean
*
@@ -219,6 +222,7 @@ public function loadButtonType($type, $new = false)
if (!class_exists('JToolbarButton'))
{
JLog::add(JText::_('JLIB_HTML_BUTTON_BASE_CLASS'), JLog::WARNING, 'jerror');
+
return false;
}
@@ -249,6 +253,7 @@ public function loadButtonType($type, $new = false)
else
{
JLog::add(JText::sprintf('JLIB_HTML_BUTTON_NO_LOAD', $buttonClass, $buttonFile), JLog::WARNING, 'jerror');
+
return false;
}
}
@@ -273,7 +278,7 @@ public function loadButtonType($type, $new = false)
* added them. If the parameter type cannot be found in the custom folders,
* it will look in libraries/joomla/html/toolbar/button.
*
- * @param mixed $path Directory or directories to search.
+ * @param mixed $path Directory or directories to search.
*
* @return void
*
diff --git a/libraries/cms/ucm/base.php b/libraries/cms/ucm/base.php
index 91ce874a84787..63c724f73191e 100644
--- a/libraries/cms/ucm/base.php
+++ b/libraries/cms/ucm/base.php
@@ -37,15 +37,15 @@ class JUcmBase implements JUcm
/**
* Instantiate the UcmBase.
*
- * @param string $alias The alias string
- * @param JUcmType $type The type object
+ * @param string $alias The alias string
+ * @param JUcmType $type The type object
*
* @since 3.1
*/
public function __construct($alias = null, JUcmType $type = null)
{
// Setup dependencies.
- $input = JFactory::getApplication()->input;
+ $input = JFactory::getApplication()->input;
$this->alias = isset($alias) ? $alias : $input->get('option') . '.' . $input->get('view');
$this->type = isset($type) ? $type : $this->getType();
@@ -54,9 +54,9 @@ public function __construct($alias = null, JUcmType $type = null)
/**
* Store data to the appropriate table
*
- * @param array $data Data to be stored
- * @param JTable $table JTable Object
- * @param string $primaryKey The primary key name
+ * @param array $data Data to be stored
+ * @param JTable $table JTable Object
+ * @param string $primaryKey The primary key name
*
* @return boolean True on success
*
@@ -70,8 +70,8 @@ protected function store($data, JTable $table = null, $primaryKey = null)
$table = JTable::getInstance('Ucm');
}
- $ucmId = isset($data['ucm_id']) ? $data['ucm_id'] : null;
- $primaryKey = $primaryKey ? $primaryKey : $ucmId;
+ $ucmId = isset($data['ucm_id']) ? $data['ucm_id'] : null;
+ $primaryKey = $primaryKey ? $primaryKey : $ucmId;
if (isset($primaryKey))
{
@@ -116,8 +116,8 @@ public function getType()
/**
* Method to map the base ucm fields
*
- * @param array $original Data array
- * @param JUcmType $type UCM Content Type
+ * @param array $original Data array
+ * @param JUcmType $type UCM Content Type
*
* @return array Data array of UCM mappings
*
@@ -128,8 +128,8 @@ public function mapBase($original, JUcmType $type = null)
$type = $type ? $type : $this->type;
$data = array(
- 'ucm_type_id' => $type->id,
- 'ucm_item_id' => $original[$type->primary_key],
+ 'ucm_type_id' => $type->id,
+ 'ucm_item_id' => $original[$type->primary_key],
'ucm_language_id' => JHelperContent::getLanguageId($original['language'])
);
diff --git a/libraries/cms/ucm/content.php b/libraries/cms/ucm/content.php
index 483b6791b7caf..7ee8250924f32 100644
--- a/libraries/cms/ucm/content.php
+++ b/libraries/cms/ucm/content.php
@@ -53,16 +53,16 @@ class JUcmContent extends JUcmBase
/**
* Instantiate JUcmContent.
*
- * @param JTable $table The table object
- * @param sring $alias The type alias
- * @param JUcmType $type The type object
+ * @param JTable $table The table object
+ * @param sring $alias The type alias
+ * @param JUcmType $type The type object
*
* @since 3.1
*/
public function __construct(JTable $table = null, $alias = null, JUcmType $type = null)
{
// Setup dependencies.
- $input = JFactory::getApplication()->input;
+ $input = JFactory::getApplication()->input;
$this->alias = isset($alias) ? $alias : $input->get('option') . '.' . $input->get('view');
$this->type = isset($type) ? $type : $this->getType();
@@ -81,8 +81,8 @@ public function __construct(JTable $table = null, $alias = null, JUcmType $type
/**
* Method to save the data
*
- * @param array $original The original data to be saved
- * @param JUcmType $type The UCM Type object
+ * @param array $original The original data to be saved
+ * @param JUcmType $type The UCM Type object
*
* @return boolean true
*
@@ -109,8 +109,8 @@ public function save($original = null, JUcmType $type = null)
/**
* Delete content from the Core Content table
*
- * @param mixed $pk The string/array of id's to delete
- * @param JUcmType $type The content type object
+ * @param mixed $pk The string/array of id's to delete
+ * @param JUcmType $type The content type object
*
* @return boolean True if success
*
@@ -140,8 +140,8 @@ public function delete($pk, JUcmType $type = null)
/**
* Map the original content to the Core Content fields
*
- * @param array $original The original data array
- * @param JUcmType $type Type object for this data
+ * @param array $original The original data array
+ * @param JUcmType $type Type object for this data
*
* @return object $ucmData The mapped UCM data
*
@@ -194,9 +194,9 @@ public function mapData($original, JUcmType $type = null)
/**
* Store data to the appropriate table
*
- * @param array $data Data to be stored
- * @param JTable $table JTable Object
- * @param boolean $primaryKey Flag that is true for data that are using #__ucm_content as their primary table
+ * @param array $data Data to be stored
+ * @param JTable $table JTable Object
+ * @param boolean $primaryKey Flag that is true for data that are using #__ucm_content as their primary table
*
* @return Boolean true on success
*
@@ -212,7 +212,7 @@ protected function store($data, JTable $table = null, $primaryKey = null)
if (!$primaryKey)
{
// Store the core UCM mappings
- $baseData = array();
+ $baseData = array();
$baseData['ucm_type_id'] = $typeId;
$baseData['ucm_item_id'] = $data['core_content_item_id'];
$baseData['ucm_language_id'] = JHelperContent::getLanguageId($data['core_language']);
@@ -229,8 +229,8 @@ protected function store($data, JTable $table = null, $primaryKey = null)
/**
* Get the value of the primary key from #__ucm_base
*
- * @param string $typeId The ID for the type
- * @param integer $contentItemId Value of the primary key in the legacy or secondary table
+ * @param string $typeId The ID for the type
+ * @param integer $contentItemId Value of the primary key in the legacy or secondary table
*
* @return integer The integer of the primary key
*
@@ -238,7 +238,7 @@ protected function store($data, JTable $table = null, $primaryKey = null)
*/
public function getPrimaryKey($typeId, $contentItemId)
{
- $db = JFactory::getDbo();
+ $db = JFactory::getDbo();
$queryccid = $db->getQuery(true);
$queryccid->select($db->quoteName('ucm_id'))
->from($db->quoteName('#__ucm_base'))
diff --git a/libraries/cms/ucm/type.php b/libraries/cms/ucm/type.php
index 83b90683ba92b..030d060b7f13a 100644
--- a/libraries/cms/ucm/type.php
+++ b/libraries/cms/ucm/type.php
@@ -27,27 +27,27 @@ class JUcmType implements JUcm
public $type;
/**
- * The Database object
- *
- * @var JDatabaseDriver
- * @since 3.1
- */
+ * The Database object
+ *
+ * @var JDatabaseDriver
+ * @since 3.1
+ */
protected $db;
/**
- * The alias for the content type
- *
- * @var string
- * @since 3.1
- */
+ * The alias for the content type
+ *
+ * @var string
+ * @since 3.1
+ */
protected $alias;
/**
* Class constructor
*
- * @param string $alias The alias for the item
- * @param JDatabaseDriver $database The database object
- * @param JApplicationBase $application The application object
+ * @param string $alias The alias for the item
+ * @param JDatabaseDriver $database The database object
+ * @param JApplicationBase $application The application object
*
* @since 3.1
*/
@@ -62,14 +62,14 @@ public function __construct($alias = null, JDatabaseDriver $database = null, JAp
}
/**
- * Get the Content Type
- *
- * @param integer $pk The primary key of the alias type
- *
- * @return object The UCM Type data
- *
- * @since 3.1
- */
+ * Get the Content Type
+ *
+ * @param integer $pk The primary key of the alias type
+ *
+ * @return object The UCM Type data
+ *
+ * @since 3.1
+ */
public function getType($pk = null)
{
if (!$pk)
@@ -77,7 +77,7 @@ public function getType($pk = null)
$pk = $this->getTypeId();
}
- $query = $this->db->getQuery(true);
+ $query = $this->db->getQuery(true);
$query->select('ct.*');
$query->from($this->db->quoteName('#__content_types', 'ct'));
@@ -92,7 +92,7 @@ public function getType($pk = null)
/**
* Retrieves the UCM type ID
*
- * @param string $alias The string of the type alias
+ * @param string $alias The string of the type alias
*
* @return mixed The ID of the requested type or false if type is not found
*
diff --git a/libraries/cms/version/version.php b/libraries/cms/version/version.php
index 19aef415a1467..4ef7af4a35163 100644
--- a/libraries/cms/version/version.php
+++ b/libraries/cms/version/version.php
@@ -54,7 +54,7 @@ final class JVersion
/**
* Compares two a "PHP standardized" version number against the current Joomla version.
*
- * @param string $minimum The minimum version of the Joomla which is compatible.
+ * @param string $minimum The minimum version of the Joomla which is compatible.
*
* @return bool True if the version is compatible.
*
@@ -100,16 +100,16 @@ public function getShortVersion()
public function getLongVersion()
{
return $this->PRODUCT . ' ' . $this->RELEASE . '.' . $this->DEV_LEVEL . ' '
- . $this->DEV_STATUS . ' [ ' . $this->CODENAME . ' ] ' . $this->RELDATE . ' '
- . $this->RELTIME . ' ' . $this->RELTZ;
+ . $this->DEV_STATUS . ' [ ' . $this->CODENAME . ' ] ' . $this->RELDATE . ' '
+ . $this->RELTIME . ' ' . $this->RELTZ;
}
/**
* Returns the user agent.
*
- * @param string $component Name of the component.
- * @param bool $mask Mask as Mozilla/5.0 or not.
- * @param bool $add_version Add version afterwards to component.
+ * @param string $component Name of the component.
+ * @param bool $mask Mask as Mozilla/5.0 or not.
+ * @param bool $add_version Add version afterwards to component.
*
* @return string User Agent.
*
diff --git a/libraries/cms/view/administrator.php b/libraries/cms/view/administrator.php
new file mode 100644
index 0000000000000..8a9e652752a8f
--- /dev/null
+++ b/libraries/cms/view/administrator.php
@@ -0,0 +1,47 @@
+config;
+ }
+
+ $pageHeader = strtoupper($config['option'].'_header_'.$config['subject'].'_'.$config['layout']);
+ $icon = substr($config['option'], 4).'.png';
+
+ JToolBarHelper::title(JText::_($pageHeader), $icon);
+ }
+
+ /**
+ * Method to add filters to the sidebar
+ */
+ protected function addFilters()
+ {
+
+ }
+
+ /**
+ * Method to get a list of sortable filter fields
+ * @return array
+ */
+ protected function getSortFields()
+ {
+ return array();
+ }
+}
\ No newline at end of file
diff --git a/libraries/cms/view/cms.php b/libraries/cms/view/cms.php
new file mode 100644
index 0000000000000..ecfb29a69f716
--- /dev/null
+++ b/libraries/cms/view/cms.php
@@ -0,0 +1,284 @@
+config = $config;
+
+ $this->setPaths($config);
+
+ // Set the layout
+ if (array_key_exists('layout', $config))
+ {
+ $this->layout = $config['layout'];
+ }
+
+ }
+
+ /**
+ * Method to set the template paths.
+ * You can set your own by adding an array of paths to $config['templates']
+ * @param array $config
+ */
+ protected function setPaths($config = array())
+ {
+ $class = get_class($this);
+ $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE;
+ $directoryArray = preg_split('/(?=[A-Z])/', $class, null, $flags);
+ $type = $directoryArray[(count($directoryArray) - 1)];
+ $component = $this->clean(array_shift($directoryArray));
+
+ $path_to_file = '/';
+ foreach ($directoryArray as $dir)
+ {
+ if ($dir != $type)
+ {
+ $path_to_file .= strtolower($dir) . '/';
+ }
+ }
+
+
+ $app = JFactory::getApplication();
+ $template_path = JPATH_THEMES . '/' . $app->getTemplate() . '/html/';
+ $template_path .= 'com_' . strtolower($component) . substr($path_to_file, 0, -1);
+ $this->paths['template'][] = $template_path;
+
+ $this->paths['template'][] = JPATH_COMPONENT . $path_to_file . 'tmpl';
+
+ //add paths from the config
+ if(array_key_exists('templates', $config))
+ {
+ foreach((array) $config['templates'] AS $tmpl_path)
+ {
+ $this->paths['template'][] = $tmpl_path;
+ }
+ }
+ }
+
+ /**
+ * Method to render a template script and return the output.
+ *
+ * @param string $tpl The name of the template file to parse. Automatically searches through the template paths.
+ *
+ * @return mixed $output A string
+ * @see JViewCms::loadTemplate()
+ */
+ public function render($tpl = null)
+ {
+ $output = $this->loadTemplate($tpl);
+
+ return $output;
+ }
+
+ /**
+ * Method to render a layout template file
+ *
+ * @param string $tpl
+ *
+ * @return string
+ * @throws ErrorException
+ */
+ public function loadTemplate($tpl = null)
+ {
+ $template = JFactory::getApplication()->getTemplate();
+ $this->loadTplLanguageFiles($template);
+
+ $layout = $this->layout;
+
+ if (isset($tpl))
+ {
+ $file = $layout . '_' . $tpl;
+
+ $defaultFile = 'default_' . $tpl;
+
+ $tpl = $this->clean($tpl);
+ }
+ else
+ {
+ $file = $layout;
+ $defaultFile = 'default';
+ }
+
+ // Clean the file name
+ $file = $this->clean($file) . '.php';
+ $defaultFile = $this->clean($defaultFile) . '.php';
+
+ jimport('joomla.filesystem.path');
+ $templateLocation = JPath::find($this->paths['template'], $file);
+
+ // if we couldn't find the layout_file, look for default_file
+ if ($templateLocation == false)
+ {
+ $templateLocation = JPath::find($this->paths['template'], $defaultFile);
+ }
+
+ if ($templateLocation == false) // panic
+ {
+ throw new ErrorException(JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file), 500);
+ }
+
+ // Unset so as not to introduce into template scope
+ unset($tpl);
+ unset($file);
+
+ // Never allow a 'this' property
+ if (isset($this->this))
+ {
+ unset($this->this);
+ }
+
+ // Start capturing output into a buffer
+ ob_start();
+
+ // Include the requested template filename in the local scope
+ // (this will execute the view logic).
+ include $templateLocation;
+
+ // Done with the requested template; get the buffer and
+ // clear it.
+ $output = ob_get_contents();
+ ob_end_clean();
+
+ return $output;
+ }
+
+ /**
+ * Method to clean illegal characters from path variables
+ *
+ * @param mixed $subject
+ * @param string $pattern regular expression used to clean a string default is '/[^A-Z0-9_\.-]/i'
+ * @param mixed $replacement default is ''
+ *
+ * @return mixed
+ */
+ protected function clean($subject, $pattern = '/[^A-Z0-9_\.-]/i', $replacement = '')
+ {
+ $subject = preg_replace($pattern, $replacement, $subject);
+
+ return $subject;
+ }
+
+ /**
+ * Method to load the language files for the template
+ *
+ * @param string $template name
+ */
+ protected function loadTplLanguageFiles($template)
+ {
+ // Load the language file for the template
+ $lang = JFactory::getLanguage();
+
+ if (!$lang->load('tpl_' . $template, JPATH_BASE, null, false, true))
+ {
+ $lang->load('tpl_' . $template, JPATH_THEMES . "/$template", null, false, true);
+ }
+ }
+
+ /**
+ * Method to escape variables
+ *
+ * @param mixed $var to escape
+ * @param bool $htmlSpecialChars true for htmlspecialchars or false for htmlentities
+ * @param bool $doubleEncode When doubleEncode is false PHP will not encode existing html entities, the default is to convert everything.
+ *
+ * @return string
+ */
+ public function escape($var, $htmlSpecialChars = true, $doubleEncode = true)
+ {
+ if ($htmlSpecialChars)
+ {
+ $escaped = htmlspecialchars($var, ENT_COMPAT, 'UTF-8', $doubleEncode);
+ }
+ else
+ {
+ $escaped = htmlentities($var, ENT_COMPAT, 'UTF-8', $doubleEncode);
+ }
+
+ return $escaped;
+ }
+
+ /**
+ * Method to get the model object
+ *
+ * @param string $name The name of the model (optional)
+ *
+ * @return JModelCms
+ *
+ */
+ public function getModel($name = null)
+ {
+ if ($name === null)
+ {
+ $name = $this->defaultModel;
+ }
+
+ return $this->models[$name];
+ }
+
+
+ /**
+ * Method to add a model to the view. We support a multiple model single
+ * view system by which models are referenced by class name.
+ *
+ * @param string $name
+ * @param JModelCms $model The model to add to the view.
+ * @param boolean $default Is this the default model?
+ *
+ * @return JModelCms The input parameters $model.
+ */
+ public function setModel($name, $model, $default = false)
+ {
+ $this->models[$name] = $model;
+
+ if ($default)
+ {
+ $this->defaultModel = $name;
+ }
+
+ return $model;
+ }
+}
\ No newline at end of file
diff --git a/libraries/cms/view/index.html b/libraries/cms/view/index.html
new file mode 100644
index 0000000000000..2efb97f319a35
--- /dev/null
+++ b/libraries/cms/view/index.html
@@ -0,0 +1 @@
+