diff --git a/libraries/cms/captcha/captcha.php b/libraries/cms/captcha/captcha.php index eb57b63225d7e..5d67d2b11fb56 100644 --- a/libraries/cms/captcha/captcha.php +++ b/libraries/cms/captcha/captcha.php @@ -46,7 +46,7 @@ class JCaptcha extends JObject /** * Captcha Plugin object * - * @var JPlugin + * @var JPlugin * @since 2.5 */ private $_captcha; @@ -62,15 +62,15 @@ class JCaptcha extends JObject /** * Array of instances of this class. * - * @var array + * @var array */ private static $_instances = array(); /** * Class constructor. * - * @param string $captcha The editor to use. - * @param array $options Associative array of options. + * @param string $captcha The editor to use. + * @param array $options Associative array of options. * * @since 2.5 */ @@ -84,8 +84,8 @@ public function __construct($captcha, $options) * Returns the global Captcha object, only creating it * if it doesn't already exist. * - * @param string $captcha The plugin to use. - * @param array $options Associative array of options. + * @param string $captcha The plugin to use. + * @param array $options Associative array of options. * * @return JCaptcha Instance of this class. * @@ -104,6 +104,7 @@ public static function getInstance($captcha, array $options = array()) catch (RuntimeException $e) { JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error'); + return null; } } @@ -114,11 +115,11 @@ public static function getInstance($captcha, array $options = array()) /** * Fire the onInit event to initialise the captcha plug-in. * - * @param string $id The id of the field. + * @param string $id The id of the field. * * @return boolean True on success * - * @since 2.5 + * @since 2.5 */ public function initialise($id) { @@ -132,6 +133,7 @@ public function initialise($id) catch (Exception $e) { JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error'); + return false; } @@ -141,9 +143,9 @@ public function initialise($id) /** * Get the HTML for the captcha. * - * @param string $name The control name. - * @param string $id The id for the control. - * @param string $class Value for the HTML class attribute + * @param string $name The control name. + * @param string $id The id for the control. + * @param string $class Value for the HTML class attribute * * @return mixed The return value of the function "onDisplay" of the selected Plugin. * @@ -174,11 +176,11 @@ public function display($name, $id, $class = '') /** * Checks if the answer is correct. * - * @param string $code The answer. + * @param string $code The answer. * * @return mixed The return value of the function "onCheckAnswer" of the selected Plugin. * - * @since 2.5 + * @since 2.5 */ public function checkAnswer($code) { @@ -197,11 +199,11 @@ public function checkAnswer($code) /** * Load the Captcha plug-in. * - * @param array $options Associative array of options. + * @param array $options Associative array of options. * * @return void * - * @since 2.5 + * @since 2.5 * @throws RuntimeException */ private function _load(array $options = array()) @@ -224,11 +226,11 @@ private function _load(array $options = array()) { throw new RuntimeException(JText::sprintf('JLIB_CAPTCHA_ERROR_PLUGIN_NOT_FOUND', $name)); } - $params = new JRegistry($plugin->params); + $params = new JRegistry($plugin->params); $plugin->params = $params; // Build captcha plugin classname - $name = 'plgCaptcha' . $this->_name; + $name = 'plgCaptcha' . $this->_name; $this->_captcha = new $name($this, (array) $plugin, $options); } @@ -247,7 +249,7 @@ public function getState() /** * Attach an observer object * - * @param object $observer An observer object to attach + * @param object $observer An observer object to attach * * @return void * @@ -294,7 +296,7 @@ public function attach($observer) } $this->_observers[] = $observer; - $methods = array_diff(get_class_methods($observer), get_class_methods('JPlugin')); + $methods = array_diff(get_class_methods($observer), get_class_methods('JPlugin')); } $key = key($this->_observers); @@ -315,7 +317,7 @@ public function attach($observer) /** * Detach an observer object * - * @param object $observer An observer object to detach. + * @param object $observer An observer object to detach. * * @return boolean True if the observer object was detached. * diff --git a/libraries/cms/controller/add.php b/libraries/cms/controller/add.php new file mode 100644 index 0000000000000..23b23ac899aaa --- /dev/null +++ b/libraries/cms/controller/add.php @@ -0,0 +1,47 @@ +set('layout', 'edit'); + + parent::__construct($input, $app, $config); + } + + /** + * @see JControllerDisplay::execute() + */ + public function execute() + { + $model = $this->getModel(); + if (!$model->allowAction('core.create')) + { + $msg = $this->translate('JLIB_APPLICATION_ERROR_CREATE_RECORD_NOT_PERMITTED'); + $this->abort($msg, 'error'); + + return false; + } + + return parent::execute(); + } + +} \ No newline at end of file diff --git a/libraries/cms/controller/cancel.php b/libraries/cms/controller/cancel.php new file mode 100644 index 0000000000000..6c596ceb6851b --- /dev/null +++ b/libraries/cms/controller/cancel.php @@ -0,0 +1,50 @@ +config; + $url = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + + $model = $this->getModel(); + $keyName = $model->getKeyName(); + + $input = $this->input; + $pk = $input->getInt($keyName, 0); + + if ($pk != 0) + { + try + { + $model->checkin($pk); + } + catch (Exception $e) + { + $msg = $e->getMessage(); + $this->setRedirect($url, $msg, 'warning'); + + return false; + } + } + + $this->setRedirect($url); + + return true; + } + + +} \ No newline at end of file diff --git a/libraries/cms/controller/checkin.php b/libraries/cms/controller/checkin.php new file mode 100644 index 0000000000000..1e43d585b0982 --- /dev/null +++ b/libraries/cms/controller/checkin.php @@ -0,0 +1,59 @@ +validateSession(); + + $model = $this->getModel(); + + if (!$model->allowAction('core.manage')) + { + $msg = $this->translate('JLIB_APPLICATION_ERROR_CHECKIN_NOT_ALLOWED'); + $this->abort($msg, 'error'); + + return false; + } + + $input = $this->input; + $cid = $input->post->get('cid', array(), 'array'); + // Make sure the item ids are integers + $cid = $this->cleanCid($cid); + + try + { + foreach ($cid AS $pk) + { + $model->checkin($pk); + } + } + catch (Exception $e) + { + $msg = $e->getMessage(); + $this->abort($msg, 'warning'); + + return false; + } + + $config = $this->config; + $url = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + $msg = $this->translate('JLIB_APPLICATION_MSG_CHECKIN_SUCCEEDED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } +} \ No newline at end of file diff --git a/libraries/cms/controller/cms.php b/libraries/cms/controller/cms.php new file mode 100644 index 0000000000000..37d9b42b934cf --- /dev/null +++ b/libraries/cms/controller/cms.php @@ -0,0 +1,342 @@ +get('option'); + } + + $this->config = $config; + } + + /** + * Method to check the session token + * @return void + */ + protected function validateSession() + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + } + + /** + * Method to refresh the session token to prevent the back button + * @return void + */ + protected function refreshToken() + { + $session = JFactory::getSession(); + $session->getToken(true); + } + + /** + * Method to translate a string using JText::_() method + * + * @param string $string + * + * @return string translation result + */ + protected function translate($string) + { + return JText::_($string); + } + + /** + * Method to get the option prefix from the input + * + * @param string $option component option string 'com_{componentName}' + * + * @return string ucfirst(substr($this->config['option'], 4)); + */ + protected function getPrefix($option = null) + { + if (is_null($option)) + { + $option = $this->config['option']; + } + $prefix = ucfirst(substr($option, 4)); + + return $prefix; + } + + /** + * Method to get a model, creating it if it does not already exist. + * Uses the prefix and $name to create the class name. Format $prefix.'Model'.$name + * If null default values are taken from $config array + * + * @param string $prefix + * @param string $name + * @param array $config + * + * @return JModelCms + * @throws ErrorException + */ + public function getModel($prefix = null, $name = null, $config = array()) + { + $config = $this->normalizeConfig($config); + + if (is_null($prefix)) + { + $prefix = $this->getPrefix(); + } + + if (is_null($name)) + { + $name = $config['subject']; + } + + $prefix = ucfirst($prefix); + $name = ucfirst($name); + + if (isset($this->models[$prefix][$name])) + { + return $this->models[$prefix][$name]; + } + + $class = $prefix . 'Model' . $name; + + if (!class_exists($class)) + { + throw new ErrorException(JText::sprintf('JLIB_APPLICATION_ERROR_MODELCLASS_NOT_FOUND', $class)); + } + + $this->models[$prefix][$name] = new $class($config); + + return $this->models[$prefix][$name]; + } + + /** + * Method to insure all config variables are are included. + * Intended to be used in getModel, getView and other factory methods + * that can be passed a config array. + * + * @param array $config to normalize + * + * @return array normalized config array + */ + protected function normalizeConfig($config) + { + //Safe merge. will not overwrite existing keys + $config += $this->config; + + return $config; + } + + /** + * Redirects the browser or returns false if no redirect is set. + * @return boolean False if no redirect exists. + * + * @since 12.2 + */ + public function redirect() + { + if ($this->hasRedirect()) + { + $app = $this->app; + + // Enqueue the redirect message + $app->enqueueMessage($this->message, $this->messageType); + + // Execute the redirect + $app->redirect($this->redirect); + } + + return false; + } + + /** + * Method to check if the controller has a redirect + * @return boolean + */ + public function hasRedirect() + { + if (!empty($this->redirect)) + { + return true; + } + + return false; + } + + /** + * Method to set the default abort redirect + * + * @param string $msg translated abort message + * @param string $type type of message I.E. 'error' or 'warning + */ + protected function abort($msg, $type) + { + $config = $this->config; + $abortUrl = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + $this->setRedirect($abortUrl, $msg, $type, true); + } + + /** + * Set a URL for browser redirection. + * + * @param string $url URL to redirect to. + * @param string $msg Message to display on redirect. Optional. + * @param string $type Message type. Optional, defaults to 'message'. + * @param bool $useJRoute should we phrase the url with JRoute? + * + * @return $this Object to support chaining. + * + * @since 12.2 + */ + public function setRedirect($url, $msg = null, $type = 'message', $useJRoute = true) + { + if ($useJRoute) + { + $this->redirect = JRoute::_($url, false); + } + else + { + $this->redirect = $url; + } + + if ($msg !== null) + { + $this->message = $msg; + } + + $this->messageType = $type; + + return $this; + } + + /** + * Method to cast all values in a cid array to integer values + * + * @param array $cid + * + * @return array $cleanCid + */ + protected function cleanCid($cid) + { + $cleanCid = array(); + foreach ((array) $cid AS $id) + { + $cleanCid[] = (int) $id; + } + + return $cleanCid; + } + + /** + * Method to execute a task controller internally without rebuilding the stack. + * This is intended to be used for task chaining + * + * @param JInput $input + * @param JApplication $app + * @param array $config + * + * @throws InvalidArgumentException + * @return boolean + */ + protected function executeInline(JInput $input, $app = null, $config = array()) + { + if(is_null($app)) + { + $app = $this->app; + } + + $config = $this->normalizeConfig($config); + + $prefix = $this->getPrefix($config['option']); + + $dispatchControllerName = $prefix.'Controller'; + if(!class_exists($dispatchControllerName)) + { + $format = $input->getWord('format', 'html'); + throw new InvalidArgumentException(JText::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER', $dispatchControllerName, $format)); + } + + + /** @var $dispatchController JControllerDispatcher */ + $dispatchController = new $dispatchControllerName($input, $app, $config); + $dispatchController->mergeModels($this->models); + + return $dispatchController->execute(); + } + + /** + * Method to merge an array of models to $this->models array + * @param array $models Associative array of models that follow the $models[prefix][$name] format + * @param bool $overwrite True to overwrite existing models with $models value + * @return void + */ + public function mergeModels($models = array(), $overwrite = false) + { + if($overwrite) + { + $models += $this->models; + $this->models = $models; + } + else + { + $this->models += $models; + } + } +} \ No newline at end of file diff --git a/libraries/cms/controller/create/base.php b/libraries/cms/controller/create/base.php new file mode 100644 index 0000000000000..405bbb486789f --- /dev/null +++ b/libraries/cms/controller/create/base.php @@ -0,0 +1,62 @@ +validateSession(); + + $config = $this->config; + $url = 'index.php?option=' . $config['option'] . '&task=add.' . $config['subject']; + + $prefix = $this->getPrefix(); + $model = $this->getModel($prefix, $config['subject'], $config); + + if (!$model->allowAction('core.create')) + { + $msg = $this->translate('JLIB_APPLICATION_ERROR_CREATE_RECORD_NOT_PERMITTED'); + $this->setRedirect($url, $msg, 'error'); + + return false; + } + + try + { + $input = $this->input; + $data = $input->post->get('jform', array(), 'array'); + $keyName = $model->getKeyName(); + $data[$keyName] = 0; + + $this->commit($model, $data); + } + catch (Exception $e) + { + $this->setUserState($model); + $msg = $e->getMessage(); + $this->setRedirect($url, $msg, 'error'); + + return false; + } + + return true; + + } + + /** + * @see JControllerSave::commit + */ + protected function commit($model, $data) + { + $model->create($data); + } +} diff --git a/libraries/cms/controller/create/close.php b/libraries/cms/controller/create/close.php new file mode 100644 index 0000000000000..23d9df3af25e4 --- /dev/null +++ b/libraries/cms/controller/create/close.php @@ -0,0 +1,27 @@ +translate('JLIB_APPLICATION_MSG_SAVE_COMPLETED'); + $this->abort($msg, 'error'); + + return true; + } + + return false; + } + +} \ No newline at end of file diff --git a/libraries/cms/controller/create/edit.php b/libraries/cms/controller/create/edit.php new file mode 100644 index 0000000000000..5080c8620757f --- /dev/null +++ b/libraries/cms/controller/create/edit.php @@ -0,0 +1,37 @@ +config; + $model = $this->getModel(); + + $context = $model->getContext(); + $keyName = $model->getKeyName(); + $keyValue = $model->getState($context . '.id'); + + $url = 'index.php?option=' . $config['option'] . '&task=edit.' . $config['subject']; + $url .= '&' . $keyName . '=' . $keyValue; + + $msg = $this->translate('JLIB_APPLICATION_MSG_SAVE_COMPLETED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + return false; + } + +} diff --git a/libraries/cms/controller/create/index.html b/libraries/cms/controller/create/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/libraries/cms/controller/create/index.html @@ -0,0 +1 @@ + diff --git a/libraries/cms/controller/create/new.php b/libraries/cms/controller/create/new.php new file mode 100644 index 0000000000000..cbeaa3a80fb20 --- /dev/null +++ b/libraries/cms/controller/create/new.php @@ -0,0 +1,29 @@ +config; + $url = 'index.php?option=' . $config['option'] . '&task=add.' . $config['subject']; + $msg = $this->translate('JLIB_APPLICATION_MSG_SAVE_COMPLETED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + return false; + } + +} diff --git a/libraries/cms/controller/delete.php b/libraries/cms/controller/delete.php new file mode 100644 index 0000000000000..0040649445736 --- /dev/null +++ b/libraries/cms/controller/delete.php @@ -0,0 +1,69 @@ +validateSession(); + + $model = $this->getModel(); + + If (!$model->allowAction('core.delete')) + { + $msg = $this->translate('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'); + $this->abort($msg, 'error'); + + return false; + } + + $input = $this->input; + + $cid = $input->post->get('cid', array(), 'array'); + $totalCids = count($cid); + + if (!is_array($cid) || $totalCids < 1) + { + $msg = $this->translate('JLIB_APPLICATION_ERROR_NO_ITEM_SELECTED'); + $this->abort($msg, 'error'); + + return false; + } + + + // Make sure the item ids are integers + $cid = $this->cleanCid($cid); + + try + { + $model->delete($cid); + } + catch (Exception $e) + { + $msg = $e->getMessage(); + $this->abort($msg, 'error'); + + return false; + } + + $config = $this->config; + $url = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + $msg = $this->translate('JLIB_APPLICATION_MSG_ITEMS_DELETED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } +} \ No newline at end of file diff --git a/libraries/cms/controller/dispatcher.php b/libraries/cms/controller/dispatcher.php new file mode 100644 index 0000000000000..9206589faa704 --- /dev/null +++ b/libraries/cms/controller/dispatcher.php @@ -0,0 +1,140 @@ +controller + * format: {Option}.'Controller'.{Task} + * Also sets the subject using the task + * if the task isn't in controller.subject format, it defaults to task.view + * if no task is set, it defaults to display.view + * if both the task and the view are not set, it defaults to display.$config['default_view'] + * + * @param JInput $input + * @param JApplicationWeb $app + * @param array $config + * + * @throws InvalidArgumentException + */ + public function __construct(JInput $input, $app = null, $config = array()) + { + if(!array_key_exists('task',$config) || !array_key_exists('subject', $config)) + { + $command = $this->getCommand($input, $config); + list($controllerName, $subject) = explode('.', $command); + + $config['task'] = $controllerName; + $config['subject'] = $subject; + } + + parent::__construct($input, $app, $config); + + $optionPrefix = $this->getPrefix(); + + $class = $optionPrefix . 'Controller' . ucfirst($controllerName); + + if (!class_exists($class)) // get the fallback + { + $class = $this->getFallbackClassName($controllerName); + + if (!class_exists($class)) // PANIC! + { + $format = $input->getWord('format', 'html'); + throw new InvalidArgumentException(JText::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER', $controllerName, $format)); + } + } + + $input->set('task', $controllerName); + + $this->controller = new $class($input, $app, $config); + } + + /** + * Method to get the task command from the input + * + * @param JInput $input + * @param array $config + * + * @return string dot delimited task command + */ + protected function getCommand($input, $config) + { + $command = $input->get('task', 'display', 'cmd'); + + if (!strpos($command, '.')) + { + if (!array_key_exists('default_view', $config)) + { + $config['default_view'] = 'default'; + } + + $command .= '.' . $input->get('view', $config['default_view']); + } + return $command; + } + + /** + * Method to get a the default task controller. + * "JController'.ucfirst($task); + * + * @param String $task + * + * @return string + */ + protected function getFallbackClassName($task) + { + $class_name = 'JController' . ucfirst($task); + + return $class_name; + } + + /** + * proxy for $this->controller->execute() + * @see JControllerCms::execute() + */ + public function execute() + { + if ($this->controller->execute()) + { + return true; + } + + return false; + } + + /** + * proxy for $this->controller->redirect() + * @see JControllerCms::redirect() + */ + public function redirect() + { + return $this->controller->redirect(); + } + + /** + * proxy for $this->controller->mergeModels() + * @param array $models Associative array of models that follow the $models[prefix][$name] format + * @param bool $overwrite True to overwrite existing models with $models value + * @return void + */ + public function mergeModels($models = array(), $overwrite = false) + { + $this->controller->mergeModels($models, $overwrite); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/display.php b/libraries/cms/controller/display.php new file mode 100644 index 0000000000000..dd58885cac903 --- /dev/null +++ b/libraries/cms/controller/display.php @@ -0,0 +1,143 @@ +get('view', $config['subject']); + $layout = $input->get('layout', 'default', 'string'); + + $document = JFactory::getDocument(); + $viewType = $document->getType(); + + $config['viewName'] = $viewName; + $config['layout'] = $layout; + $config['viewType'] = $viewType; + + + parent::__construct($input, $app, $config); + + $task = $input->get('task', 'display', 'cmd'); + + //check to make sure the user isn't accessing a form + //without using the task controller + if ($layout == 'edit' && $task == 'display') + { + $msg = $this->translate('JLIB_APPLICATION_ERROR_DIRECT_ACCESS_DENIED'); + $this->abort($msg, 'error'); + $this->redirect(); + } + } + + /** + * @see JController::execute() + */ + public function execute() + { + $config = $this->config; + $viewName = $config['viewName']; + + $document = JFactory::getDocument(); + $viewType = $document->getType(); + $prefix = $this->getPrefix(); + + if (empty($this->view)) + { + $view = $this->getView($prefix, $viewName, $viewType, $config); + + $subject = $this->config['subject']; + + // Get OR Create the model + if ($model = $this->getModel($prefix, $subject, $config)) + { + // Push the model into the view (as default) + $view->setModel($subject,$model, true); + } + + $this->view = $view; + } + + $output = $this->view->render(); + + if (!($output instanceof Exception)) + { + // wrap the output in an object to allow it to be modified by plugins + $outputObj = new stdClass(); + $outputObj->output = $output; + + JPluginHelper::importPlugin('content'); + + $defaultModel = $this->view->getModel(); + $dispatcher = $defaultModel->getDispatcher(); + $dispatcher->trigger('onContentPrepareToEcho', array($outputObj)); + + echo $outputObj->output; + + return true; // finished executing + } + + return false; // problem displaying the view + } + + /** + * Method to get a view, initiating it if it does not already exist. + * This method assumes auto-loading + * format is $prefix.'View'.$name.$type + * $type is used for the file name which is a deviation from the traditional + * Joomla naming convention. + * + * @param string $prefix option prefix exp. com_content + * @param string $name name of the view folder exp. articles + * @param string $type name of the file exp. html = html.php + * @param array $config settings + * + * @throws ErrorException + * @return JViewBase + */ + protected function getView($prefix, $name, $type, $config = array()) + { + $class = ucfirst($prefix) . 'View' . ucfirst($name) . ucfirst($type); + + if ($this->view instanceof $class) + { + return $this->view; + } + + if (!class_exists($class)) + { + $path = 'com_' . strtolower($prefix) . '/view'; + $path .= '/' . strtolower($name) . '/'; + throw new ErrorException(JText::sprintf('JLIB_APPLICATION_ERROR_VIEW_CLASS_NOT_FOUND', $class, $path), 500); + } + + $config = $this->normalizeConfig($config); + + $this->view = new $class($config); + + return $this->view; + } +} \ No newline at end of file diff --git a/libraries/cms/controller/edit.php b/libraries/cms/controller/edit.php new file mode 100644 index 0000000000000..0fb24cf933d5f --- /dev/null +++ b/libraries/cms/controller/edit.php @@ -0,0 +1,75 @@ +set('layout', 'edit'); + + parent::__construct($input, $app, $config); + } + + /** + * @see JControllerDisplay::execute() + */ + public function execute() + { + $model = $this->getModel(); + + if (!$model->allowAction('core.edit')) + { + $msg = $this->translate('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'); + $this->abort($msg, 'error'); + + return false; + } + + $input = $this->input; + $cid = $input->post->get('cid', array(), 'array'); + + if (count($cid)) + { + $pk = (int) $cid[0]; + } + else + { + $keyName = $model->getKeyName(); + $pk = $input->getInt($keyName, 0); + } + + $context = $model->getContext(); + $model->setState($context . '.id', $pk); + + try + { + $model->checkout($pk); + } + catch (Exception $e) + { + $msg = $e->getMessage(); + $this->abort($msg, 'error'); + + return false; + } + + return parent::execute(); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/export/base.php b/libraries/cms/controller/export/base.php new file mode 100644 index 0000000000000..59a7d07104516 --- /dev/null +++ b/libraries/cms/controller/export/base.php @@ -0,0 +1,59 @@ +validateSession(); + + $model = $this->getModel(); + + if (!$model->allowAction('core.export')) + { + $msg = $this->translate('JLIB_APPLICATION_ERROR_EXPORT_NOT_PERMITTED'); + $this->abort($msg, 'error'); + + return false; + } + + try + { + $config = $this->config; + $input = $this->input; + $this->export($model, $input, $config); + } + catch (Exception $e) + { + $msg = $e->getMessage(); + $this->abort($msg, 'error'); + + return false; + } + + // We assume the export file was sent to the browser + //So close the application + JFactory::getApplication()->close(); + } + + /** + * Method to export data from the model + * + * @param JModelCms $model + * @param JInput $input + * @param array $config + * + * @return boolean True if the file was sent successfully. + */ + abstract function export($model, $input, $config); +} \ No newline at end of file diff --git a/libraries/cms/controller/export/csv.php b/libraries/cms/controller/export/csv.php new file mode 100644 index 0000000000000..6a7651c9deef0 --- /dev/null +++ b/libraries/cms/controller/export/csv.php @@ -0,0 +1,32 @@ +exportCsv($handle, $input); + + fclose($handle); + } + + return true; + } +} \ No newline at end of file diff --git a/libraries/cms/controller/export/index.html b/libraries/cms/controller/export/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/libraries/cms/controller/export/index.html @@ -0,0 +1 @@ + diff --git a/libraries/cms/controller/import.php b/libraries/cms/controller/import.php new file mode 100644 index 0000000000000..73a4a9a8c8d65 --- /dev/null +++ b/libraries/cms/controller/import.php @@ -0,0 +1,65 @@ +validateSession(); + + $model = $this->getModel(); + + if (!$model->allowAction('core.import')) + { + $msg = $this->translate('JLIB_APPLICATION_ERROR_IMPORT_NOT_PERMITTED'); + $this->abort($msg, 'error'); + + return false; + } + + try + { + $input = $this->input; + $data = $input->post->get('jform', array(), 'array'); + $files = $input->files->get('jform'); + + $this->import($model, $data, $files); + } + catch (Exception $e) + { + $msg = $e->getMessage(); + $this->abort($msg, 'error'); + + return false; + } + + $config = $this->config; + $url = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + $msg = $this->translate('JLIB_APPLICATION_MESSAGE_IMPORT_COMPLETED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + /** + * Method to execute model import function + * + * @param JModelCms $model + * @param array $data JForm data + * @param array $files JForm files + */ + protected function import($model, $data, $files) + { + $model->import($data, $files); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/index.html b/libraries/cms/controller/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/libraries/cms/controller/index.html @@ -0,0 +1 @@ + diff --git a/libraries/cms/controller/save.php b/libraries/cms/controller/save.php new file mode 100644 index 0000000000000..13ce76f712fb4 --- /dev/null +++ b/libraries/cms/controller/save.php @@ -0,0 +1,44 @@ +getContext(); + $key = $context . '.jform.data'; + + $input = $this->input; + $data = $input->get('jform', array(), 'array'); + + $app = $this->app; + $app->setUserState($key, $data); + } +} diff --git a/libraries/cms/controller/state/ajax/base.php b/libraries/cms/controller/state/ajax/base.php new file mode 100644 index 0000000000000..4f6bf8e1af714 --- /dev/null +++ b/libraries/cms/controller/state/ajax/base.php @@ -0,0 +1,43 @@ +getMessage(); + $this->abort($msg, 'warning'); + + return false; + } + + echo '1'; + + // Close the application + JFactory::getApplication()->close(); + } + + /** + * Overridden to allow AJAX without token + * @return void + */ + protected function validateSession() + { + return; + } +} \ No newline at end of file diff --git a/libraries/cms/controller/state/ajax/index.html b/libraries/cms/controller/state/ajax/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/libraries/cms/controller/state/ajax/index.html @@ -0,0 +1 @@ + diff --git a/libraries/cms/controller/state/ajax/publish.php b/libraries/cms/controller/state/ajax/publish.php new file mode 100644 index 0000000000000..fc7e41e862ad4 --- /dev/null +++ b/libraries/cms/controller/state/ajax/publish.php @@ -0,0 +1,24 @@ +updateRecordState($cid, 'publish'); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/state/ajax/saveorder.php b/libraries/cms/controller/state/ajax/saveorder.php new file mode 100644 index 0000000000000..00a73884294bb --- /dev/null +++ b/libraries/cms/controller/state/ajax/saveorder.php @@ -0,0 +1,25 @@ +input->get('order', array(), 'array'); + $model->saveorder($cid, $order); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/state/ajax/unpublish.php b/libraries/cms/controller/state/ajax/unpublish.php new file mode 100644 index 0000000000000..d9644bd3d8d4a --- /dev/null +++ b/libraries/cms/controller/state/ajax/unpublish.php @@ -0,0 +1,24 @@ +updateRecordState($cid, 'unpublish'); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/state/archive.php b/libraries/cms/controller/state/archive.php new file mode 100644 index 0000000000000..f8e764684ad3e --- /dev/null +++ b/libraries/cms/controller/state/archive.php @@ -0,0 +1,47 @@ +getMessage(); + $this->abort($msg, 'error'); + + return false; + } + + $config = $this->config; + $url = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + $msg = $this->translate('JLIB_APPLICATION_MSG_ITEMS_ARCHIVED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + + /** + * @param JModelAdministrator $model + * @param array $cid + * + * @see JControllerStateBase::execute() + */ + protected function updateRecordState($model, $cid) + { + $model->updateRecordState($cid, 'archive'); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/state/base.php b/libraries/cms/controller/state/base.php new file mode 100644 index 0000000000000..bec8bda113073 --- /dev/null +++ b/libraries/cms/controller/state/base.php @@ -0,0 +1,46 @@ +validateSession(); + + $input = $this->input; + + $model = $this->getModel(); + + if (!$model->allowAction('core.edit.state')) + { + throw new ErrorException($this->translate('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); + } + + $cid = $input->get('cid', array(), 'array'); + // Make sure the item ids are integers + $cid = $this->cleanCid($cid); + + $this->updateRecordState($model, $cid); + + return true; + } + + /** + * Method to update one or more record states + * + * @param JModelAdministrator $model + * @param array $cid + */ + abstract protected function updateRecordState($model, $cid); + + +} \ No newline at end of file diff --git a/libraries/cms/controller/state/index.html b/libraries/cms/controller/state/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/libraries/cms/controller/state/index.html @@ -0,0 +1 @@ + diff --git a/libraries/cms/controller/state/orderdown.php b/libraries/cms/controller/state/orderdown.php new file mode 100644 index 0000000000000..aca637f4f4a7a --- /dev/null +++ b/libraries/cms/controller/state/orderdown.php @@ -0,0 +1,24 @@ +reorder($cid, 'down'); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/state/orderup.php b/libraries/cms/controller/state/orderup.php new file mode 100644 index 0000000000000..4ff73b452660a --- /dev/null +++ b/libraries/cms/controller/state/orderup.php @@ -0,0 +1,46 @@ +getMessage(); + $this->abort($msg, 'warning'); + + return false; + } + + $config = $this->config; + $url = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + $msg = $this->translate('JLIB_APPLICATION_SUCCESS_ITEM_REORDERED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + /** + * @param JModelAdministrator $model + * @param array $cid + * + * @see JControllerStateBase::execute() + */ + protected function updateRecordState($model, $cid) + { + $model->reorder($cid, 'up'); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/state/publish.php b/libraries/cms/controller/state/publish.php new file mode 100644 index 0000000000000..26368fa9bae54 --- /dev/null +++ b/libraries/cms/controller/state/publish.php @@ -0,0 +1,46 @@ +getMessage(); + $this->abort($msg, 'warning'); + + return false; + } + + $config = $this->config; + $url = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + $msg = $this->translate('JLIB_APPLICATION_MSG_ITEMS_PUBLISHED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + /** + * @param JModelAdministrator $model + * @param array $cid + * + * @see JControllerStateBase::execute() + */ + protected function updateRecordState($model, $cid) + { + $model->updateRecordState($cid, 'publish'); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/state/report.php b/libraries/cms/controller/state/report.php new file mode 100644 index 0000000000000..217de0187d090 --- /dev/null +++ b/libraries/cms/controller/state/report.php @@ -0,0 +1,46 @@ +getMessage(); + $this->abort($msg, 'warning'); + + return false; + } + + $config = $this->config; + $url = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + $msg = $this->translate('JLIB_APPLICATION_MSG_ITEMS_REPORTED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + /** + * @param JModelAdministrator $model + * @param array $cid + * + * @see JControllerStateBase::execute() + */ + protected function updateRecordState($model, $cid) + { + $model->updateRecordState($cid, 'report'); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/state/saveorder.php b/libraries/cms/controller/state/saveorder.php new file mode 100644 index 0000000000000..9ce14c0a28c13 --- /dev/null +++ b/libraries/cms/controller/state/saveorder.php @@ -0,0 +1,47 @@ +getMessage(); + $this->abort($msg, 'warning'); + + return false; + } + + $config = $this->config; + $url = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + $msg = $this->translate('JLIB_APPLICATION_SUCCESS_ORDERING_SAVED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + /** + * @param JModelAdministrator $model + * @param array $cid + * + * @see JControllerStateBase::execute() + */ + protected function updateRecordState($model, $cid) + { + $order = $this->input->get('order', array(), 'array'); + $model->saveorder($cid, $order); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/state/trash.php b/libraries/cms/controller/state/trash.php new file mode 100644 index 0000000000000..1e0b4a8577e7b --- /dev/null +++ b/libraries/cms/controller/state/trash.php @@ -0,0 +1,46 @@ +getMessage(); + $this->abort($msg, 'warning'); + + return false; + } + + $config = $this->config; + $url = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + $msg = $this->translate('JLIB_APPLICATION_MSG_ITEMS_TRASHED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + /** + * @param JModelAdministrator $model + * @param array $cid + * + * @see JControllerStateBase::execute() + */ + protected function updateRecordState($model, $cid) + { + $model->updateRecordState($cid, 'trash'); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/state/unpublish.php b/libraries/cms/controller/state/unpublish.php new file mode 100644 index 0000000000000..95531dc4491e9 --- /dev/null +++ b/libraries/cms/controller/state/unpublish.php @@ -0,0 +1,46 @@ +getMessage(); + $this->abort($msg, 'warning'); + + return false; + } + + $config = $this->config; + $url = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + $msg = $this->translate('JLIB_APPLICATION_MSG_ITEMS_UNPUBLISHED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + /** + * @param JModelAdministrator $model + * @param array $cid + * + * @see JControllerStateBase::execute() + */ + protected function updateRecordState($model, $cid) + { + $model->updateRecordState($cid, 'unpublish'); + } +} \ No newline at end of file diff --git a/libraries/cms/controller/update/base.php b/libraries/cms/controller/update/base.php new file mode 100644 index 0000000000000..55ff144290366 --- /dev/null +++ b/libraries/cms/controller/update/base.php @@ -0,0 +1,83 @@ +validateSession(); + + $config = $this->config; + $input = $this->input; + + $model = $this->getModel(); + $keyName = $model->getKeyName(); + $keyValue = $input->getInt($keyName); + + $url = 'index.php?option=' . $config['option'] . '&task=edit.' . $config['subject']; + $url .= '&' . $keyName . '=' . $keyValue; + + if (!$model->allowAction('core.edit')) + { + $msg = $this->translate('JLIB_APPLICATION_ERROR_EDIT_RECORD_NOT_PERMITTED'); + $this->setRedirect($url, $msg, 'error'); + + return false; + } + + try + { + $input = $this->input; + $data = $input->post->get('jform', array(), 'array'); + $this->commit($model, $data); + } + catch (Exception $e) + { + $this->setUserState($model); + $msg = $e->getMessage(); + $this->setRedirect($url, $msg, 'error'); + + return false; + } + + return true; + } + + /** + * @see JControllerSave::commit() + */ + protected function commit($model, $data) + { + $model->update($data); + } + + /** + * Method to checkin a record + * @return boolean + */ + protected function checkin() + { + $config = $this->config; + + $prefix = $this->getPrefix(); + $model = $this->getModel($prefix, $config['subject'], $config); + $keyName = $model->getKeyName(); + + $input = $this->input; + $keyValue = $input->getInt($keyName); + + $model->checkin($keyValue); + + return true; + } +} diff --git a/libraries/cms/controller/update/close.php b/libraries/cms/controller/update/close.php new file mode 100644 index 0000000000000..37e488b4556b2 --- /dev/null +++ b/libraries/cms/controller/update/close.php @@ -0,0 +1,39 @@ +checkin(); + } + catch (Exception $e) + { + $msg = $e->getMessage(); + $this->abort($msg, 'warning'); + } + + $config = $this->config; + $url = 'index.php?option=' . $config['option'] . '&task=display.' . $config['subject']; + $msg = $this->translate('JLIB_APPLICATION_MSG_SAVE_COMPLETED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + return false; + } + +} diff --git a/libraries/cms/controller/update/copy.php b/libraries/cms/controller/update/copy.php new file mode 100644 index 0000000000000..0f52cbcb90420 --- /dev/null +++ b/libraries/cms/controller/update/copy.php @@ -0,0 +1,65 @@ +config; + $model = $this->getModel(); + + $context = $model->getContext(); + $keyName = $model->getKeyName(); + $keyValue = $model->getState($context . '.id'); + + $url = 'index.php?option=' . $config['option'] . '&task=edit.' . $config['subject']; + $url .= '&' . $keyName . '=' . $keyValue; + + try + { + $this->checkin(); + } + catch (Exception $e) + { + $msg = $e->getMessage(); + $this->setRedirect($url, $msg, 'warning', true, false); + } + + $msg = $this->translate('JLIB_APPLICATION_MSG_COPY_COMPLETED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + return false; + } + + /** + * (non-PHPdoc) + * @see JControllerUpdateBase::commit() + */ + protected function commit($model, $data) + { + if (!$model->allowAction('core.create')) + { + throw new ErrorException($this->translate('JLIB_APPLICATION_ERROR_CREATE_RECORD_NOT_PERMITTED')); + } + else + { + $keyName = $model->getKeyName(); + $data[$keyName] = 0; + + $model->create($data); + } + } +} \ No newline at end of file diff --git a/libraries/cms/controller/update/edit.php b/libraries/cms/controller/update/edit.php new file mode 100644 index 0000000000000..132399647d833 --- /dev/null +++ b/libraries/cms/controller/update/edit.php @@ -0,0 +1,37 @@ +config; + $input = $this->input; + + $model = $this->getModel(); + $keyName = $model->getKeyName(); + $keyValue = $input->getInt($keyName); + + $url = 'index.php?option=' . $config['option'] . '&task=edit.' . $config['subject']; + $url .= '&' . $keyName . '=' . $keyValue; + + $msg = $this->translate('JLIB_APPLICATION_MSG_SAVE_COMPLETED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + return false; + } + +} \ No newline at end of file diff --git a/libraries/cms/controller/update/index.html b/libraries/cms/controller/update/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/libraries/cms/controller/update/index.html @@ -0,0 +1 @@ + diff --git a/libraries/cms/controller/update/new.php b/libraries/cms/controller/update/new.php new file mode 100644 index 0000000000000..32a38adbd1f5a --- /dev/null +++ b/libraries/cms/controller/update/new.php @@ -0,0 +1,40 @@ +config; + $url = 'index.php?option=' . $config['option'] . '&task=add.' . $config['subject']; + + try + { + $this->checkin(); + } + catch (Exception $e) + { + $msg = $e->getMessage(); + $this->setRedirect($url, $msg, 'warning', true, false); + } + + $msg = $this->translate('JLIB_APPLICATION_MSG_SAVE_COMPLETED'); + $this->setRedirect($url, $msg, 'message'); + + return true; + } + + return false; + } + +} diff --git a/libraries/cms/editor/editor.php b/libraries/cms/editor/editor.php index ddfe6d4cdd4f9..41b752f993f21 100644 --- a/libraries/cms/editor/editor.php +++ b/libraries/cms/editor/editor.php @@ -83,7 +83,7 @@ class JEditor extends JObject /** * Constructor * - * @param string $editor The editor name + * @param string $editor The editor name */ public function __construct($editor = 'none') { @@ -94,7 +94,7 @@ public function __construct($editor = 'none') * Returns the global Editor object, only creating it * if it doesn't already exist. * - * @param string $editor The editor to use. + * @param string $editor The editor to use. * * @return JEditor The Editor object. * @@ -127,7 +127,7 @@ public function getState() /** * Attach an observer object * - * @param object $observer An observer object to attach + * @param object $observer An observer object to attach * * @return void * @@ -174,7 +174,7 @@ public function attach($observer) } $this->_observers[] = $observer; - $methods = array_diff(get_class_methods($observer), get_class_methods('JPlugin')); + $methods = array_diff(get_class_methods($observer), get_class_methods('JPlugin')); } $key = key($this->_observers); @@ -195,7 +195,7 @@ public function attach($observer) /** * Detach an observer object * - * @param object $observer An observer object to detach. + * @param object $observer An observer object to detach. * * @return boolean True if the observer object was detached. * @@ -243,7 +243,7 @@ public function initialise() $args['event'] = 'onInit'; - $return = ''; + $return = ''; $results[] = $this->_editor->update($args); foreach ($results as $result) @@ -262,17 +262,17 @@ public function initialise() /** * Display the editor area. * - * @param string $name The control name. - * @param string $html The contents of the text area. - * @param string $width The width of the text area (px or %). - * @param string $height The height of the text area (px or %). - * @param integer $col The number of columns for the textarea. - * @param integer $row The number of rows for the textarea. - * @param boolean $buttons True and the editor buttons will be displayed. - * @param string $id An optional ID for the textarea (note: since 1.6). If not supplied the name is used. - * @param string $asset The object asset - * @param object $author The author. - * @param array $params Associative array of editor parameters. + * @param string $name The control name. + * @param string $html The contents of the text area. + * @param string $width The width of the text area (px or %). + * @param string $height The height of the text area (px or %). + * @param integer $col The number of columns for the textarea. + * @param integer $row The number of rows for the textarea. + * @param boolean $buttons True and the editor buttons will be displayed. + * @param string $id An optional ID for the textarea (note: since 1.6). If not supplied the name is used. + * @param string $asset The object asset + * @param object $author The author. + * @param array $params Associative array of editor parameters. * * @return string * @@ -280,7 +280,7 @@ public function initialise() */ public function display($name, $html, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array()) { - $this->asset = $asset; + $this->asset = $asset; $this->author = $author; $this->_loadEditor($params); @@ -292,20 +292,20 @@ public function display($name, $html, $width, $height, $col, $row, $buttons = tr // Backwards compatibility. Width and height should be passed without a semicolon from now on. // If editor plugins need a unit like "px" for CSS styling, they need to take care of that - $width = str_replace(';', '', $width); + $width = str_replace(';', '', $width); $height = str_replace(';', '', $height); $return = null; - $args['name'] = $name; + $args['name'] = $name; $args['content'] = $html; - $args['width'] = $width; - $args['height'] = $height; - $args['col'] = $col; - $args['row'] = $row; + $args['width'] = $width; + $args['height'] = $height; + $args['col'] = $col; + $args['row'] = $row; $args['buttons'] = $buttons; - $args['id'] = $id ? $id : $name; - $args['event'] = 'onDisplay'; + $args['id'] = $id ? $id : $name; + $args['event'] = 'onDisplay'; $results[] = $this->_editor->update($args); @@ -316,13 +316,14 @@ public function display($name, $html, $width, $height, $col, $row, $buttons = tr $return .= $result; } } + return $return; } /** * Save the editor content * - * @param string $editor The name of the editor control + * @param string $editor The name of the editor control * * @return string * @@ -338,10 +339,10 @@ public function save($editor) return; } - $args[] = $editor; + $args[] = $editor; $args['event'] = 'onSave'; - $return = ''; + $return = ''; $results[] = $this->_editor->update($args); foreach ($results as $result) @@ -358,7 +359,7 @@ public function save($editor) /** * Get the editor contents * - * @param string $editor The name of the editor control + * @param string $editor The name of the editor control * * @return string * @@ -368,10 +369,10 @@ public function getContent($editor) { $this->_loadEditor(); - $args['name'] = $editor; + $args['name'] = $editor; $args['event'] = 'onGetContent'; - $return = ''; + $return = ''; $results[] = $this->_editor->update($args); foreach ($results as $result) @@ -388,8 +389,8 @@ public function getContent($editor) /** * Set the editor contents * - * @param string $editor The name of the editor control - * @param string $html The contents of the text area + * @param string $editor The name of the editor control + * @param string $html The contents of the text area * * @return string * @@ -399,11 +400,11 @@ public function setContent($editor, $html) { $this->_loadEditor(); - $args['name'] = $editor; - $args['html'] = $html; + $args['name'] = $editor; + $args['html'] = $html; $args['event'] = 'onSetContent'; - $return = ''; + $return = ''; $results[] = $this->_editor->update($args); foreach ($results as $result) @@ -420,8 +421,8 @@ public function setContent($editor, $html) /** * Get the editor extended buttons (usually from plugins) * - * @param string $editor The name of the editor. - * @param mixed $buttons Can be boolean or array, if boolean defines if the buttons are + * @param string $editor The name of the editor. + * @param mixed $buttons Can be boolean or array, if boolean defines if the buttons are * displayed, if array defines a list of buttons not to show. * * @return array @@ -468,7 +469,7 @@ public function getButtons($editor, $buttons = true) /** * Load the editor * - * @param array $config Associative array of editor config paramaters + * @param array $config Associative array of editor config paramaters * * @return mixed * @@ -492,6 +493,7 @@ protected function _loadEditor($config = array()) if (!is_file($path)) { JLog::add(JText::_('JLIB_HTML_EDITOR_CANNOT_LOAD'), JLog::WARNING, 'jerror'); + return false; } } diff --git a/libraries/cms/error/page.php b/libraries/cms/error/page.php index ec8b4ac680868..2b40da8c1a886 100644 --- a/libraries/cms/error/page.php +++ b/libraries/cms/error/page.php @@ -21,7 +21,7 @@ class JErrorPage /** * Render the error page based on an exception. * - * @param Exception $error The exception for which to render the error page. + * @param Exception $error The exception for which to render the error page. * * @return void * @@ -56,9 +56,9 @@ public static function render(Exception $error) $document->setTitle(JText::_('Error') . ': ' . $error->getCode()); $data = $document->render( false, - array('template' => $template, - 'directory' => JPATH_THEMES, - 'debug' => $config->get('debug')) + array('template' => $template, + 'directory' => JPATH_THEMES, + 'debug' => $config->get('debug')) ); // Failsafe to get the error displayed. diff --git a/libraries/cms/form/field/captcha.php b/libraries/cms/form/field/captcha.php index 890f4b130bc17..8f33afdd87d53 100644 --- a/libraries/cms/form/field/captcha.php +++ b/libraries/cms/form/field/captcha.php @@ -21,16 +21,16 @@ class JFormFieldCaptcha extends JFormField /** * The field type. * - * @var string + * @var string */ protected $type = 'Captcha'; /** * Method to attach a JForm object to the field. * - * @param SimpleXMLElement $element The SimpleXMLElement object representing the tag for the form field object. - * @param mixed $value The form field value to validate. - * @param string $group The field name group control value. This acts as as an array container for the field. + * @param SimpleXMLElement $element The SimpleXMLElement object representing the tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * @@ -54,7 +54,7 @@ public function setup(SimpleXMLElement $element, $value, $group = null) // Force field to be required. There's no reason to have a captcha if it is not required. // Obs: Don't put required="required" in the xml file, you just need to have validate="captcha" $this->required = true; - $class = $this->element['class']; + $class = $this->element['class']; if (strpos($class, 'required') === false) { $this->element['class'] = $class . ' required'; diff --git a/libraries/cms/form/field/chromestyle.php b/libraries/cms/form/field/chromestyle.php index 970c1c715081d..dbba86e3e7cc7 100644 --- a/libraries/cms/form/field/chromestyle.php +++ b/libraries/cms/form/field/chromestyle.php @@ -41,7 +41,7 @@ protected function getGroups() $groups = array(); // Add Module Style Field - $tmp = '---' . JText::_('JLIB_FORM_VALUE_FROM_TEMPLATE') . '---'; + $tmp = '---' . JText::_('JLIB_FORM_VALUE_FROM_TEMPLATE') . '---'; $groups[$tmp][] = JHtml::_('select.option', '0', JText::_('JLIB_FORM_VALUE_INHERITED')); $templateStyles = $this->getTemplateModuleStyles(); @@ -49,12 +49,12 @@ protected function getGroups() // Create one new option object for each available style, grouped by templates foreach ($templateStyles as $template => $styles) { - $template = ucfirst($template); + $template = ucfirst($template); $groups[$template] = array(); foreach ($styles as $style) { - $tmp = JHtml::_('select.option', $template . '-' . $style, $style); + $tmp = JHtml::_('select.option', $template . '-' . $style, $style); $groups[$template][] = $tmp; } } @@ -110,7 +110,7 @@ protected function getTemplateModuleStyles() */ protected function getSystemTemplate() { - $template = new stdClass; + $template = new stdClass; $template->element = 'system'; $template->name = 'system'; $template->enabled = 1; diff --git a/libraries/cms/form/field/contenthistory.php b/libraries/cms/form/field/contenthistory.php index b649b41f9f859..c7d9cc42ce476 100644 --- a/libraries/cms/form/field/contenthistory.php +++ b/libraries/cms/form/field/contenthistory.php @@ -37,9 +37,9 @@ protected function getInput() { $typeId = JTable::getInstance('Contenttype')->getTypeId($this->element['data-typeAlias']); $itemId = $this->form->getValue('id'); - $label = JText::_('JTOOLBAR_VERSIONS'); - $html = array(); - $link = 'index.php?option=com_contenthistory&view=history&layout=modal&tmpl=component&field=' + $label = JText::_('JTOOLBAR_VERSIONS'); + $html = array(); + $link = 'index.php?option=com_contenthistory&view=history&layout=modal&tmpl=component&field=' . $this->id . '&item_id=' . $itemId . '&type_id=' . $typeId . '&type_alias=' . $this->element['data-typeAlias'] . '&' . JSession::getFormToken() . '=1'; @@ -52,6 +52,7 @@ protected function getInput() $html[] = $label; $html[] = ''; $html[] = ''; + return implode("\n", $html); } } diff --git a/libraries/cms/form/field/contenttype.php b/libraries/cms/form/field/contenttype.php index 9975025b8fb80..b2ddce5b0be36 100644 --- a/libraries/cms/form/field/contenttype.php +++ b/libraries/cms/form/field/contenttype.php @@ -64,8 +64,8 @@ protected function getInput() */ protected function getOptions() { - $db = JFactory::getDbo(); - $query = $db->getQuery(true) + $db = JFactory::getDbo(); + $query = $db->getQuery(true) ->select('a.type_id AS value, a.type_title AS text') ->from('#__content_types AS a') diff --git a/libraries/cms/form/field/editor.php b/libraries/cms/form/field/editor.php index 20dee558c7789..f2877ac2875e5 100644 --- a/libraries/cms/form/field/editor.php +++ b/libraries/cms/form/field/editor.php @@ -76,10 +76,10 @@ protected function getInput() return $editor ->display( - $this->name, htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'), $width, $height, $cols, $rows, - $buttons ? (is_array($buttons) ? array_merge($buttons, $hide) : $hide) : false, $this->id, $asset, - $this->form->getValue($authorField) - ); + $this->name, htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'), $width, $height, $cols, $rows, + $buttons ? (is_array($buttons) ? array_merge($buttons, $hide) : $hide) : false, $this->id, $asset, + $this->form->getValue($authorField) + ); } /** @@ -133,7 +133,7 @@ protected function getEditor() // Create the JEditor instance based on the given editor. if (is_null($editor)) { - $conf = JFactory::getConfig(); + $conf = JFactory::getConfig(); $editor = $conf->get('editor'); } $this->editor = JEditor::getInstance($editor); diff --git a/libraries/cms/form/field/headertag.php b/libraries/cms/form/field/headertag.php index 700cb81708715..a663cad8b1d5a 100644 --- a/libraries/cms/form/field/headertag.php +++ b/libraries/cms/form/field/headertag.php @@ -38,12 +38,12 @@ class JFormFieldHeadertag extends JFormFieldList protected function getOptions() { $options = array(); - $tags = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'); + $tags = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'); // Create one new option object for each tag foreach ($tags as $tag) { - $tmp = JHtml::_('select.option', $tag, $tag); + $tmp = JHtml::_('select.option', $tag, $tag); $options[] = $tmp; } diff --git a/libraries/cms/form/field/helpsite.php b/libraries/cms/form/field/helpsite.php index cfcc80f7a00d4..b07cd68db03ee 100644 --- a/libraries/cms/form/field/helpsite.php +++ b/libraries/cms/form/field/helpsite.php @@ -58,7 +58,7 @@ protected function getInput() 'var helpsite_base = "' . addslashes(JUri::root()) . '";' ); - $html = parent::getInput(); + $html = parent::getInput(); $button = ''; return $html . $button; diff --git a/libraries/cms/form/field/media.php b/libraries/cms/form/field/media.php index fc38abe50f206..341ca86d7a0ba 100644 --- a/libraries/cms/form/field/media.php +++ b/libraries/cms/form/field/media.php @@ -45,9 +45,9 @@ class JFormFieldMedia extends JFormField */ protected function getInput() { - $assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id'; + $assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id'; $authorField = $this->element['created_by_field'] ? (string) $this->element['created_by_field'] : 'created_by'; - $asset = $this->form->getValue($assetField) ? $this->form->getValue($assetField) : (string) $this->element['asset_id']; + $asset = $this->form->getValue($assetField) ? $this->form->getValue($assetField) : (string) $this->element['asset_id']; if ($asset == '') { $asset = JFactory::getApplication()->input->get('option'); @@ -60,7 +60,7 @@ protected function getInput() JHtml::_('behavior.modal'); // Build the script. - $script = array(); + $script = array(); $script[] = ' function jInsertFieldValue(value, id) {'; $script[] = ' var old_value = document.id(id).value;'; $script[] = ' if (old_value != value) {'; @@ -122,8 +122,8 @@ protected function getInput() $html[] = '
'; // The Preview. - $preview = (string) $this->element['preview']; - $showPreview = true; + $preview = (string) $this->element['preview']; + $showPreview = true; $showAsTooltip = false; switch ($preview) { @@ -141,7 +141,7 @@ protected function getInput() case 'tooltip': default: $showAsTooltip = true; - $options = array( + $options = array( 'onShow' => 'jMediaRefreshPreviewTip', ); JHtml::_('behavior.tooltip', '.hasTipPreview', $options); @@ -159,33 +159,33 @@ protected function getInput() $src = ''; } - $width = isset($this->element['preview_width']) ? (int) $this->element['preview_width'] : 300; + $width = isset($this->element['preview_width']) ? (int) $this->element['preview_width'] : 300; $height = isset($this->element['preview_height']) ? (int) $this->element['preview_height'] : 200; - $style = ''; + $style = ''; $style .= ($width > 0) ? 'max-width:' . $width . 'px;' : ''; $style .= ($height > 0) ? 'max-height:' . $height . 'px;' : ''; - $imgattr = array( - 'id' => $this->id . '_preview', + $imgattr = array( + 'id' => $this->id . '_preview', 'class' => 'media-preview', 'style' => $style, ); - $img = JHtml::image($src, JText::_('JLIB_FORM_MEDIA_PREVIEW_ALT'), $imgattr); - $previewImg = ''; + $img = JHtml::image($src, JText::_('JLIB_FORM_MEDIA_PREVIEW_ALT'), $imgattr); + $previewImg = ''; $previewImgEmpty = ''; if ($showAsTooltip) { - $html[] = '
'; + $html[] = '
'; $tooltip = $previewImgEmpty . $previewImg; $options = array( 'title' => JText::_('JLIB_FORM_MEDIA_PREVIEW_SELECTED_IMAGE'), - 'text' => '', + 'text' => '', 'class' => 'hasTipPreview' ); - $html[] = JHtml::tooltip($tooltip, $options); - $html[] = '
'; + $html[] = JHtml::tooltip($tooltip, $options); + $html[] = '
'; } else { @@ -223,9 +223,9 @@ protected function getInput() $html[] = ''; $html[] = JText::_('JLIB_FORM_BUTTON_SELECT') . 'getQuery(true) + $db = JFactory::getDbo(); + $query = $db->getQuery(true) ->select('position, ordering, title') ->from('#__modules') ->where('client_id = ' . (int) $clientId) @@ -71,6 +71,7 @@ protected function getInput() catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); + return false; } @@ -82,7 +83,7 @@ protected function getInput() $orders2[$orders[$i]->position] = 0; } $orders2[$orders[$i]->position]++; - $ord = $orders2[$orders[$i]->position]; + $ord = $orders2[$orders[$i]->position]; $title = JText::sprintf('COM_MODULES_OPTION_ORDER_POSITION', $ord, addslashes($orders[$i]->title)); $html[] = 'orders[' . $i . '] = new Array("' . $orders[$i]->position . '","' . $ord . '","' . $title . '");'; diff --git a/libraries/cms/form/field/moduleposition.php b/libraries/cms/form/field/moduleposition.php index 1ad463bc46377..39bcfb56336a7 100644 --- a/libraries/cms/form/field/moduleposition.php +++ b/libraries/cms/form/field/moduleposition.php @@ -23,7 +23,7 @@ class JFormFieldModulePosition extends JFormFieldText /** * The form field type. * - * @var string + * @var string * @since 1.6 */ protected $type = 'ModulePosition'; @@ -31,7 +31,7 @@ class JFormFieldModulePosition extends JFormFieldText /** * Method to get the field input markup. * - * @return string The field input markup. + * @return string The field input markup. * * @since 1.6 */ @@ -44,7 +44,7 @@ protected function getInput() $clientName = $this->element['client']; if (isset($clientName)) { - $client = JApplicationHelper::getClientInfo($clientName, true); + $client = JApplicationHelper::getClientInfo($clientName, true); $clientId = $client->id; } } @@ -60,7 +60,7 @@ protected function getInput() JHtml::_('behavior.modal', 'a.modal'); // Build the script. - $script = array(); + $script = array(); $script[] = ' function jSelectPosition_' . $this->id . '(name) {'; $script[] = ' document.id("' . $this->id . '").value = name;'; $script[] = ' SqueezeBox.close();'; diff --git a/libraries/cms/form/field/moduletag.php b/libraries/cms/form/field/moduletag.php index 86f1bd0eae6c1..00cd6725c5a29 100644 --- a/libraries/cms/form/field/moduletag.php +++ b/libraries/cms/form/field/moduletag.php @@ -38,12 +38,12 @@ class JFormFieldModuletag extends JFormFieldList protected function getOptions() { $options = array(); - $tags = array('div', 'section', 'aside', 'nav', 'address', 'article'); + $tags = array('div', 'section', 'aside', 'nav', 'address', 'article'); // Create one new option object for each tag foreach ($tags as $tag) { - $tmp = JHtml::_('select.option', $tag, $tag); + $tmp = JHtml::_('select.option', $tag, $tag); $options[] = $tmp; } diff --git a/libraries/cms/form/field/ordering.php b/libraries/cms/form/field/ordering.php index 542338fe477f5..7b9705fe61803 100644 --- a/libraries/cms/form/field/ordering.php +++ b/libraries/cms/form/field/ordering.php @@ -21,7 +21,7 @@ class JFormFieldOrdering extends JFormField /** * The form field type. * - * @var string + * @var string * @since 3.2 */ protected $type = 'Ordering'; @@ -29,7 +29,7 @@ class JFormFieldOrdering extends JFormField /** * Method to get the field input markup. * - * @return string The field input markup. + * @return string The field input markup. * * @since 3.2 */ @@ -72,10 +72,10 @@ protected function getInput() */ protected function getQuery() { - $categoryId = (int) $this->form->getValue('catid'); - $table = (string) $this->element['table']; + $categoryId = (int) $this->form->getValue('catid'); + $table = (string) $this->element['table']; - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select(array($db->quoteName('ordering', 'value'), $db->quoteName('name', 'text'))) ->from($db->quoteName($table)) diff --git a/libraries/cms/form/field/tag.php b/libraries/cms/form/field/tag.php index d8a10152c8e99..eeef6bdd9d2b7 100644 --- a/libraries/cms/form/field/tag.php +++ b/libraries/cms/form/field/tag.php @@ -112,10 +112,10 @@ protected function getInput() */ protected function getOptions() { - $published = $this->element['published']? $this->element['published'] : array(0,1); + $published = $this->element['published'] ? $this->element['published'] : array(0, 1); - $db = JFactory::getDbo(); - $query = $db->getQuery(true) + $db = JFactory::getDbo(); + $query = $db->getQuery(true) ->select('a.id AS value, a.path, a.title AS text, a.level, a.published') ->from('#__tags AS a') ->join('LEFT', $db->quoteName('#__tags') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt'); @@ -182,7 +182,7 @@ protected function getOptions() /** * Add "-" before nested tags, depending on level * - * @param array &$options Array of tags + * @param array &$options Array of tags * * @return array The field option objects. * @@ -194,7 +194,7 @@ protected function prepareOptionsNested(&$options) { foreach ($options as &$option) { - $repeat = (isset($option->level) && $option->level - 1 >= 0) ? $option->level - 1 : 0; + $repeat = (isset($option->level) && $option->level - 1 >= 0) ? $option->level - 1 : 0; $option->text = str_repeat('- ', $repeat) . $option->text; } } @@ -215,7 +215,8 @@ public function isNested() { // If mode="nested" || ( mode not set & config = nested ) if ((isset($this->element['mode']) && $this->element['mode'] == 'nested') - || (!isset($this->element['mode']) && $this->comParams->get('tag_field_ajax_mode', 1) == 0)) + || (!isset($this->element['mode']) && $this->comParams->get('tag_field_ajax_mode', 1) == 0) + ) { $this->isNested = true; } diff --git a/libraries/cms/form/field/templatestyle.php b/libraries/cms/form/field/templatestyle.php index 7d0977a20bc34..f0aaaee2832e7 100644 --- a/libraries/cms/form/field/templatestyle.php +++ b/libraries/cms/form/field/templatestyle.php @@ -42,17 +42,17 @@ class JFormFieldTemplatestyle extends JFormFieldGroupedList protected function getGroups() { $groups = array(); - $lang = JFactory::getLanguage(); + $lang = JFactory::getLanguage(); // Get the client and client_id. $clientName = $this->element['client'] ? (string) $this->element['client'] : 'site'; - $client = JApplicationHelper::getClientInfo($clientName, true); + $client = JApplicationHelper::getClientInfo($clientName, true); // Get the template. $template = (string) $this->element['template']; // Get the database object and a new query object. - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true); // Build the query. @@ -80,9 +80,9 @@ protected function getGroups() { $template = $style->template; $lang->load('tpl_' . $template . '.sys', $client->path, null, false, false) - || $lang->load('tpl_' . $template . '.sys', $client->path . '/templates/' . $template, null, false, false) - || $lang->load('tpl_' . $template . '.sys', $client->path, $lang->getDefault(), false, false) - || $lang->load('tpl_' . $template . '.sys', $client->path . '/templates/' . $template, $lang->getDefault(), false, false); + || $lang->load('tpl_' . $template . '.sys', $client->path . '/templates/' . $template, null, false, false) + || $lang->load('tpl_' . $template . '.sys', $client->path, $lang->getDefault(), false, false) + || $lang->load('tpl_' . $template . '.sys', $client->path . '/templates/' . $template, $lang->getDefault(), false, false); $name = JText::_($style->name); // Initialize the group if necessary. diff --git a/libraries/cms/form/field/user.php b/libraries/cms/form/field/user.php index 7513a10f55e8e..0880e69d0b24d 100644 --- a/libraries/cms/form/field/user.php +++ b/libraries/cms/form/field/user.php @@ -35,10 +35,10 @@ class JFormFieldUser extends JFormField */ protected function getInput() { - $html = array(); - $groups = $this->getGroups(); + $html = array(); + $groups = $this->getGroups(); $excluded = $this->getExcluded(); - $link = 'index.php?option=com_users&view=users&layout=modal&tmpl=component&field=' . $this->id + $link = 'index.php?option=com_users&view=users&layout=modal&tmpl=component&field=' . $this->id . (isset($groups) ? ('&groups=' . base64_encode(json_encode($groups))) : '') . (isset($excluded) ? ('&excluded=' . base64_encode(json_encode($excluded))) : ''); @@ -54,7 +54,7 @@ protected function getInput() JHtml::_('behavior.modal', 'a.modal_' . $this->id); // Build the script. - $script = array(); + $script = array(); $script[] = ' function jSelectUser_' . $this->id . '(id, title) {'; $script[] = ' var old_id = document.getElementById("' . $this->id . '_id").value;'; $script[] = ' if (old_id != id) {'; diff --git a/libraries/cms/form/rule/captcha.php b/libraries/cms/form/rule/captcha.php index 0267aaaadc299..82207f42ae626 100644 --- a/libraries/cms/form/rule/captcha.php +++ b/libraries/cms/form/rule/captcha.php @@ -21,13 +21,13 @@ class JFormRuleCaptcha extends JFormRule /** * Method to test if the Captcha is correct. * - * @param SimpleXMLElement $element The SimpleXMLElement object representing the tag for the form field object. - * @param mixed $value The form field value to validate. - * @param string $group The field name group control value. This acts as as an array container for the field. + * @param SimpleXMLElement $element The SimpleXMLElement object representing the tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". - * @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form. - * @param JForm $form The form object for which the field is being tested. + * @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form. + * @param JForm $form The form object for which the field is being tested. * * @return boolean True if the value is valid, false otherwise. * @@ -35,8 +35,8 @@ class JFormRuleCaptcha extends JFormRule */ public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null) { - $plugin = $element['plugin'] ?: JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha', 0)); - $namespace = $element['namespace'] ?: $form->getName(); + $plugin = $element['plugin'] ? : JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha', 0)); + $namespace = $element['namespace'] ? : $form->getName(); // Use 0 for none if ($plugin === 0 || $plugin === '0') diff --git a/libraries/cms/form/rule/notequals.php b/libraries/cms/form/rule/notequals.php index 35141b46afea4..fb439a449829e 100644 --- a/libraries/cms/form/rule/notequals.php +++ b/libraries/cms/form/rule/notequals.php @@ -23,13 +23,13 @@ class JFormRuleNotequals extends JFormRule * XML needs a validate attribute of equals and a field attribute * that is equal to the field to test against. * - * @param SimpleXMLElement $element The SimpleXMLElement object representing the tag for the form field object. - * @param mixed $value The form field value to validate. - * @param string $group The field name group control value. This acts as as an array container for the field. + * @param SimpleXMLElement $element The SimpleXMLElement object representing the tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". - * @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form. - * @param JForm $form The form object for which the field is being tested. + * @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form. + * @param JForm $form The form object for which the field is being tested. * * @return boolean True if the value is valid, false otherwise. * diff --git a/libraries/cms/form/rule/password.php b/libraries/cms/form/rule/password.php index 025382420cdb6..4f104fbb2de4e 100644 --- a/libraries/cms/form/rule/password.php +++ b/libraries/cms/form/rule/password.php @@ -23,13 +23,13 @@ class JFormRulePassword extends JFormRule * XML needs a validate attribute of equals and a field attribute * that is equal to the field to test against. * - * @param SimpleXMLElement $element The SimpleXMLElement object representing the tag for the form field object. - * @param mixed $value The form field value to validate. - * @param string $group The field name group control value. This acts as as an array container for the field. + * @param SimpleXMLElement $element The SimpleXMLElement object representing the tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". - * @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form. - * @param JForm $form The form object for which the field is being tested. + * @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form. + * @param JForm $form The form object for which the field is being tested. * * @return boolean True if the value is valid, false otherwise. * @@ -39,11 +39,11 @@ class JFormRulePassword extends JFormRule */ public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null) { - $meter = isset($this->element['strengthmeter']) ? ' meter="0"' : '1'; - $threshold = isset($this->element['threshold']) ? (int) $this->element['threshold'] : 66; - $minimumLength = isset($this->element['minimum_length']) ? (int) $this->element['minimum_length'] : 4; - $minimumIntegers = isset($this->element['minimum_integers']) ? (int) $this->element['minimum_integers'] : 0; - $minimumSymbols = isset($this->element['minimum_symbols']) ? (int) $this->element['minimum_symbols'] : 0; + $meter = isset($this->element['strengthmeter']) ? ' meter="0"' : '1'; + $threshold = isset($this->element['threshold']) ? (int) $this->element['threshold'] : 66; + $minimumLength = isset($this->element['minimum_length']) ? (int) $this->element['minimum_length'] : 4; + $minimumIntegers = isset($this->element['minimum_integers']) ? (int) $this->element['minimum_integers'] : 0; + $minimumSymbols = isset($this->element['minimum_symbols']) ? (int) $this->element['minimum_symbols'] : 0; $minimumUppercase = isset($this->element['minimum_uppercase']) ? (int) $this->element['minimum_uppercase'] : 0; // If we have parameters from com_users, use those instead. @@ -52,12 +52,12 @@ public function test(SimpleXMLElement $element, $value, $group = null, JRegistry if (!empty($params)) { - $minimumLengthp = $params->get('minimum_length'); - $minimumIntegersp = $params->get('minimum_integers'); - $minimumSymbolsp = $params->get('minimum_symbols'); + $minimumLengthp = $params->get('minimum_length'); + $minimumIntegersp = $params->get('minimum_integers'); + $minimumSymbolsp = $params->get('minimum_symbols'); $minimumUppercasep = $params->get('minimum_uppercase'); - $meterp = $params->get('meter'); - $thresholdp = $params->get('threshold'); + $meterp = $params->get('meter'); + $thresholdp = $params->get('threshold'); empty($minimumLengthp) ? : $minimumLength = (int) $minimumLengthp; empty($minimumIntegersp) ? : $minimumIntegers = (int) $minimumIntegersp; @@ -83,7 +83,7 @@ public function test(SimpleXMLElement $element, $value, $group = null, JRegistry JFactory::getApplication()->enqueueMessage( JText::_('COM_USERS_MSG_PASSWORD_TOO_LONG'), 'warning' - ); + ); } // We don't allow white space inside passwords @@ -97,7 +97,7 @@ public function test(SimpleXMLElement $element, $value, $group = null, JRegistry JFactory::getApplication()->enqueueMessage( JText::_('COM_USERS_MSG_SPACES_IN_PASSWORD'), 'warning' - ); + ); $validPassword = false; } @@ -144,7 +144,7 @@ public function test(SimpleXMLElement $element, $value, $group = null, JRegistry JFactory::getApplication()->enqueueMessage( JText::plural('COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N', $minimumUppercase), 'warning' - ); + ); $validPassword = false; } @@ -158,7 +158,7 @@ public function test(SimpleXMLElement $element, $value, $group = null, JRegistry JFactory::getApplication()->enqueueMessage( JText::plural('COM_USERS_MSG_PASSWORD_TOO_SHORT_N', $minimumLength), 'warning' - ); + ); $validPassword = false; } diff --git a/libraries/cms/help/help.php b/libraries/cms/help/help.php index 3f42f99ff1ee4..b9310cff4631a 100644 --- a/libraries/cms/help/help.php +++ b/libraries/cms/help/help.php @@ -21,10 +21,10 @@ class JHelp /** * Create a URL for a given help key reference * - * @param string $ref The name of the help screen (its key reference) - * @param boolean $useComponent Use the help file in the component directory - * @param string $override Use this URL instead of any other - * @param string $component Name of component (or null for current component) + * @param string $ref The name of the help screen (its key reference) + * @param boolean $useComponent Use the help file in the component directory + * @param string $override Use this URL instead of any other + * @param string $component Name of component (or null for current component) * * @return string * @@ -33,7 +33,7 @@ class JHelp public static function createURL($ref, $useComponent = false, $override = null, $component = null) { $local = false; - $app = JFactory::getApplication(); + $app = JFactory::getApplication(); if (is_null($component)) { @@ -51,7 +51,7 @@ public static function createURL($ref, $useComponent = false, $override = null, { // Get the user help URL. $user = JFactory::getUser(); - $url = $user->getParam('helpsite'); + $url = $user->getParam('helpsite'); // If user hasn't specified a help URL, then get the global one. if ($url == '') @@ -64,12 +64,12 @@ public static function createURL($ref, $useComponent = false, $override = null, { // Look for help URL in component parameters. $params = JComponentHelper::getParams($component); - $url = $params->get('helpURL'); + $url = $params->get('helpURL'); if ($url == '') { $local = true; - $url = 'components/{component}/help/{language}/{keyref}'; + $url = 'components/{component}/help/{language}/{keyref}'; } } @@ -77,7 +77,7 @@ public static function createURL($ref, $useComponent = false, $override = null, if (!$url) { $local = true; - $url = 'help/{language}/{keyref}'; + $url = 'help/{language}/{keyref}'; } } @@ -93,12 +93,12 @@ public static function createURL($ref, $useComponent = false, $override = null, /* * Replace substitution codes in the URL. */ - $lang = JFactory::getLanguage(); + $lang = JFactory::getLanguage(); $version = new JVersion; - $jver = explode('.', $version->getShortVersion()); - $jlang = explode('-', $lang->getTag()); + $jver = explode('.', $version->getShortVersion()); + $jlang = explode('-', $lang->getTag()); - $debug = $lang->setDebug(false); + $debug = $lang->setDebug(false); $keyref = JText::_($ref); $lang->setDebug($debug); @@ -167,7 +167,7 @@ public static function createURL($ref, $useComponent = false, $override = null, /** * Builds a list of the help sites which can be used in a select option. * - * @param string $pathToXml Path to an XML file. + * @param string $pathToXml Path to an XML file. * * @return array An array of arrays (text, value, selected). * @@ -176,7 +176,7 @@ public static function createURL($ref, $useComponent = false, $override = null, public static function createSiteList($pathToXml) { $list = array(); - $xml = false; + $xml = false; if (!empty($pathToXml)) { @@ -185,9 +185,9 @@ public static function createSiteList($pathToXml) if (!$xml) { - $option['text'] = 'English (GB) help.joomla.org'; + $option['text'] = 'English (GB) help.joomla.org'; $option['value'] = 'http://help.joomla.org'; - $list[] = $option; + $list[] = $option; } else { @@ -195,7 +195,7 @@ public static function createSiteList($pathToXml) foreach ($xml->sites->site as $site) { - $option['text'] = (string) $site; + $option['text'] = (string) $site; $option['value'] = (string) $site->attributes()->url; $list[] = $option; diff --git a/libraries/cms/helper/content.php b/libraries/cms/helper/content.php index 2eebae77dc1ff..fc67734c4f197 100644 --- a/libraries/cms/helper/content.php +++ b/libraries/cms/helper/content.php @@ -21,7 +21,7 @@ class JHelperContent /** * Configure the Linkbar. Must be implemented by each extension. * - * @param string $vName The name of the active view. + * @param string $vName The name of the active view. * * @return void * @@ -34,9 +34,9 @@ public static function addSubmenu($vName) /** * Gets a list of the actions that can be performed. * - * @param integer $categoryId The category ID. - * @param integer $id The item ID. - * @param string $assetName The asset name + * @param integer $categoryId The category ID. + * @param integer $id The item ID. + * @param string $assetName The asset name * * @return JObject * @@ -45,8 +45,8 @@ public static function addSubmenu($vName) public static function getActions($categoryId = 0, $id = 0, $assetName = '') { // Reverted a change for version 2.5.6 - $user = JFactory::getUser(); - $result = new JObject; + $user = JFactory::getUser(); + $result = new JObject; $actions = array( 'core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.own', 'core.edit.state', 'core.delete' @@ -63,7 +63,7 @@ public static function getActions($categoryId = 0, $id = 0, $assetName = '') /** * Gets the current language * - * @param boolean $detectBrowser Flag indicating whether to use the browser language as a fallback. + * @param boolean $detectBrowser Flag indicating whether to use the browser language as a fallback. * * @return string The language string * @@ -71,7 +71,7 @@ public static function getActions($categoryId = 0, $id = 0, $assetName = '') */ public static function getCurrentLanguage($detectBrowser = true) { - $app = JFactory::getApplication(); + $app = JFactory::getApplication(); $langCode = $app->input->cookie->getString(JApplication::getHash('language')); // No cookie - let's try to detect browser language or use site default @@ -91,14 +91,14 @@ public static function getCurrentLanguage($detectBrowser = true) } /** - * Gets the associated language ID - * - * @param string $langCode The language code to look up - * - * @return integer The language ID - * - * @since 3.1 - */ + * Gets the associated language ID + * + * @param string $langCode The language code to look up + * + * @return integer The language ID + * + * @since 3.1 + */ public static function getLanguageId($langCode) { $db = JFactory::getDbo(); @@ -116,7 +116,7 @@ public static function getLanguageId($langCode) /** * Gets a row of data from a table * - * @param JTable $table JTable instance for a row. + * @param JTable $table JTable instance for a row. * * @return array Associative array of all columns and values for a row in a table. * @@ -125,12 +125,12 @@ public static function getLanguageId($langCode) public function getRowData($table) { $fields = $table->getFields(); - $data = array(); + $data = array(); foreach ($fields as &$field) { - $columnName = $field->Field; - $value = $table->$columnName; + $columnName = $field->Field; + $value = $table->$columnName; $data[$columnName] = $value; } diff --git a/libraries/cms/helper/contenthistory.php b/libraries/cms/helper/contenthistory.php index 55a3834a13c45..466a62cbeee09 100644 --- a/libraries/cms/helper/contenthistory.php +++ b/libraries/cms/helper/contenthistory.php @@ -30,7 +30,7 @@ class JHelperContenthistory /** * Constructor * - * @param string $typeAlias The type of content to be versioned (for example, 'com_content.article'). + * @param string $typeAlias The type of content to be versioned (for example, 'com_content.article'). * * @since 3.2 */ @@ -42,7 +42,7 @@ public function __construct($typeAlias = null) /** * Method to delete the history for an item. * - * @param JTable $table JTable object being tagged + * @param JTable $table JTable object being tagged * * @return boolean true on success, otherwise false. * @@ -50,12 +50,12 @@ public function __construct($typeAlias = null) */ public function deleteHistory($table) { - $key = $table->getKeyName(); - $id = $table->$key; + $key = $table->getKeyName(); + $id = $table->$key; $typeTable = JTable::getInstance('Contenttype', 'JTable'); - $typeId = $typeTable->getTypeId($this->typeAlias); - $db = JFactory::getDbo(); - $query = $db->getQuery(true); + $typeId = $typeTable->getTypeId($this->typeAlias); + $db = JFactory::getDbo(); + $query = $db->getQuery(true); $query->delete($db->quoteName('#__ucm_history')) ->where($db->quoteName('ucm_item_id') . ' = ' . (int) $id) ->where($db->quoteName('ucm_type_id') . ' = ' . (int) $typeId); @@ -67,7 +67,7 @@ public function deleteHistory($table) /** * Method to get an object containing all of the table columns. * - * @param JTable $table JTable object. + * @param JTable $table JTable object. * * @return object Contains all of the columns and values. * @@ -75,12 +75,12 @@ public function deleteHistory($table) */ public function getDataObject(JTable $table) { - $fields = $table->getFields(); + $fields = $table->getFields(); $dataObject = new stdClass; foreach ($fields as $field) { - $fieldName = $field->Field; + $fieldName = $field->Field; $dataObject->$fieldName = $table->get($fieldName); } @@ -90,8 +90,8 @@ public function getDataObject(JTable $table) /** * Method to get a list of available versions of this item. * - * @param integer $typeId Type id for this component item. - * @param mixed $id Primary key of row to get history for. + * @param integer $typeId Type id for this component item. + * @param mixed $id Primary key of row to get history for. * * @return mixed The return value or null if the query failed. * @@ -99,7 +99,7 @@ public function getDataObject(JTable $table) */ public function getHistory($typeId, $id) { - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select($db->quoteName('h.version_note') . ',' . $db->quoteName('h.save_date') . ',' . $db->quoteName('u.name')) ->from($db->quoteName('#__ucm_history') . ' AS h ') @@ -115,7 +115,7 @@ public function getHistory($typeId, $id) /** * Method to save a version snapshot to the content history table. * - * @param JTable $table JTable object being tagged + * @param JTable $table JTable object being tagged * * @return boolean True on success, otherwise false. * @@ -123,9 +123,9 @@ public function getHistory($typeId, $id) */ public function store($table) { - $dataObject = $this->getDataObject($table); + $dataObject = $this->getDataObject($table); $historyTable = JTable::getInstance('Contenthistory', 'JTable'); - $typeTable = JTable::getInstance('Contenttype', 'JTable'); + $typeTable = JTable::getInstance('Contenttype', 'JTable'); $historyTable->set('ucm_type_id', $typeTable->getTypeId($this->typeAlias)); $key = $table->getKeyName(); @@ -139,7 +139,7 @@ public function store($table) $historyTable->set('version_data', json_encode($dataObject)); $input = JFactory::getApplication()->input; - $data = $input->get('jform', array(), 'array'); + $data = $input->get('jform', array(), 'array'); if (isset($data['version_note'])) { diff --git a/libraries/cms/helper/media.php b/libraries/cms/helper/media.php index 53b78c0e6b82d..d6919253c2ada 100644 --- a/libraries/cms/helper/media.php +++ b/libraries/cms/helper/media.php @@ -21,7 +21,7 @@ class JHelperMedia /** * Checks if the file is an image * - * @param string $fileName The filename + * @param string $fileName The filename * * @return boolean * @@ -30,13 +30,14 @@ class JHelperMedia public function isImage($fileName) { static $imageTypes = 'xcf|odg|gif|jpg|png|bmp'; + return preg_match("/\.(?:$imageTypes)$/i", $fileName); } /** * Gets the file extension for purposed of using an icon * - * @param string $fileName The filename + * @param string $fileName The filename * * @return string File extension to determine icon * @@ -50,8 +51,8 @@ public static function getTypeIcon($fileName) /** * Checks if the file can be uploaded * - * @param array $file File information - * @param string $component The option name for the component storing the parameters + * @param array $file File information + * @param string $component The option name for the component storing the parameters * * @return boolean * @@ -82,7 +83,7 @@ public function canUpload($file, $component = 'com_media') // Media file names should never have executable extensions buried in them. $executable = array( - 'php', 'js', 'exe', 'phtml', 'java', 'perl', 'py', 'asp','dll', 'go', 'ade', 'adp', 'bat', 'chm', 'cmd', 'com', 'cpl', 'hta', 'ins', 'isp', + 'php', 'js', 'exe', 'phtml', 'java', 'perl', 'py', 'asp', 'dll', 'go', 'ade', 'adp', 'bat', 'chm', 'cmd', 'com', 'cpl', 'hta', 'ins', 'isp', 'jse', 'lib', 'mde', 'msc', 'msp', 'mst', 'pif', 'scr', 'sct', 'shb', 'sys', 'vb', 'vbe', 'vbs', 'vxd', 'wsc', 'wsf', 'wsh' ); @@ -216,9 +217,9 @@ public function canUpload($file, $component = 'com_media') /** * Calculate the size of a resized image * - * @param integer $width Image width - * @param integer $height Image height - * @param integer $target Target size + * @param integer $width Image width + * @param integer $height Image height + * @param integer $target Target size * * @return array The new width and height * @@ -250,7 +251,7 @@ public static function imageResize($width, $height, $target) /** * Counts the files and directories in a directory that are not php or html files. * - * @param string $dir Directory name + * @param string $dir Directory name * * @return array The number of media files and directories in the given directory * @@ -268,7 +269,8 @@ public function countFiles($dir) while (false !== ($entry = $d->read())) { if (substr($entry, 0, 1) != '.' && is_file($dir . DIRECTORY_SEPARATOR . $entry) - && strpos($entry, '.html') === false && strpos($entry, '.php') === false) + && strpos($entry, '.html') === false && strpos($entry, '.php') === false + ) { $total_file++; } diff --git a/libraries/cms/helper/route.php b/libraries/cms/helper/route.php index 4824ff4184cb3..c4a4d0399c262 100644 --- a/libraries/cms/helper/route.php +++ b/libraries/cms/helper/route.php @@ -31,28 +31,28 @@ class JHelperRoute * @var string Option for the extension (such as com_content) * @since 3.1 */ - protected $extension; + protected $extension; /** * @var string Value of the primary key in the content type table * @since 3.1 */ - protected $id; + protected $id; /** * @var string Name of the view for the url * @since 3.1 */ - protected $view; + protected $view; /** * A method to get the route for a specific item * - * @param integer $id Value of the primary key for the item in its content table - * @param string $typealias The type_alias for the item being routed. Of the form extension.view. - * @param string $link The link to be routed - * @param string $language The language of the content for multilingual sites - * @param integer $catid Optional category id + * @param integer $id Value of the primary key for the item in its content table + * @param string $typealias The type_alias for the item being routed. Of the form extension.view. + * @param string $link The link to be routed + * @param string $language The language of the content for multilingual sites + * @param integer $catid Optional category id * * @return string The route of the item * @@ -62,14 +62,14 @@ public function getRoute($id, $typealias, $link = '', $language = null, $catid = { $typeExploded = explode('.', $typealias); - $this->view = $typeExploded[1]; + $this->view = $typeExploded[1]; $this->extension = $typeExploded[0]; - $name = ucfirst(substr_replace($this->extension, '', 0, 4)); + $name = ucfirst(substr_replace($this->extension, '', 0, 4)); if (isset($this->view)) { $needles = array( - $this->view => array((int) $id) + $this->view => array((int) $id) ); } if (empty($link)) @@ -86,7 +86,7 @@ public function getRoute($id, $typealias, $link = '', $language = null, $catid = $category = $categories->get((int) $catid); if ($category) { - $needles['category'] = array_reverse($category->getPath()); + $needles['category'] = array_reverse($category->getPath()); $needles['categories'] = $needles['category']; $link .= '&catid=' . $catid; } @@ -96,8 +96,8 @@ public function getRoute($id, $typealias, $link = '', $language = null, $catid = // Deal with languages only if needed if (!empty($language) && $language != '*' && JLanguageMultilang::isEnabled()) { - $db = JFactory::getDbo(); - $query = $db->getQuery(true) + $db = JFactory::getDbo(); + $query = $db->getQuery(true) ->select('a.sef AS sef') ->select('a.lang_code AS lang_code') ->from('#__languages AS a'); @@ -114,14 +114,14 @@ public function getRoute($id, $typealias, $link = '', $language = null, $catid = } } - if ($item = self::findItem($needles)) - { - $link .= '&Itemid=' . $item; - } - elseif ($item = self::findItem()) - { - $link .= '&Itemid=' . $item; - } + if ($item = self::findItem($needles)) + { + $link .= '&Itemid=' . $item; + } + elseif ($item = self::findItem()) + { + $link .= '&Itemid=' . $item; + } return $link; } @@ -129,7 +129,7 @@ public function getRoute($id, $typealias, $link = '', $language = null, $catid = /** * Method to find the item in the menu structure * - * @param array $needles Array of lookup values + * @param array $needles Array of lookup values * * @return mixed * @@ -137,9 +137,9 @@ public function getRoute($id, $typealias, $link = '', $language = null, $catid = */ protected function findItem($needles = array()) { - $app = JFactory::getApplication(); - $menus = $app->getMenu('site'); - $language = isset($needles['language']) ? $needles['language'] : '*'; + $app = JFactory::getApplication(); + $menus = $app->getMenu('site'); + $language = isset($needles['language']) ? $needles['language'] : '*'; // Prepare the reverse lookup array. if (!isset(self::$lookup[$language])) @@ -149,12 +149,12 @@ protected function findItem($needles = array()) $component = JComponentHelper::getComponent($this->extension); $attributes = array('component_id'); - $values = array($component->id); + $values = array($component->id); if ($language != '*') { $attributes[] = 'language'; - $values[] = array($needles['language'], '*'); + $values[] = array($needles['language'], '*'); } $items = $menus->getItems($attributes, $values); diff --git a/libraries/cms/helper/tags.php b/libraries/cms/helper/tags.php index 3af87156c432a..706e04d71be2f 100644 --- a/libraries/cms/helper/tags.php +++ b/libraries/cms/helper/tags.php @@ -46,9 +46,9 @@ class JHelperTags /** * Method to add tag rows to mapping table. * - * @param integer $ucmId ID of the #__ucm_content item being tagged - * @param JTable $table JTable object being tagged - * @param array $tags Array of tags to be applied. + * @param integer $ucmId ID of the #__ucm_content item being tagged + * @param JTable $table JTable object being tagged + * @param array $tags Array of tags to be applied. * * @return boolean true on success, otherwise false. * @@ -56,9 +56,9 @@ class JHelperTags */ public function addTagMapping($ucmId, $table, $tags = array()) { - $db = $table->getDbo(); - $key = $table->getKeyName(); - $item = $table->$key; + $db = $table->getDbo(); + $key = $table->getKeyName(); + $item = $table->$key; $typeId = $this->getTypeId($this->typeAlias); // Insert the new tag maps @@ -69,7 +69,7 @@ public function addTagMapping($ucmId, $table, $tags = array()) $query = $db->getQuery(true); $query->insert('#__contentitem_tag_map'); - $query->columns(array($db->quoteName('type_alias'), $db->quoteName('core_content_id'), $db->quoteName('content_item_id'), $db->quoteName('tag_id'), $db->quoteName('tag_date'), $db->quoteName('type_id'))); + $query->columns(array($db->quoteName('type_alias'), $db->quoteName('core_content_id'), $db->quoteName('content_item_id'), $db->quoteName('tag_id'), $db->quoteName('tag_date'), $db->quoteName('type_id'))); foreach ($tags as $tag) { @@ -84,7 +84,7 @@ public function addTagMapping($ucmId, $table, $tags = array()) /** * Function that converts tags paths into paths of names * - * @param array $tags Array of tags + * @param array $tags Array of tags * * @return array * @@ -169,7 +169,7 @@ public static function convertPathsToNames($tags) /** * Create any new tags by looking for #new# in the strings * - * @param array $tags Tags text array from the field + * @param array $tags Tags text array from the field * * @return mixed If successful, metadata with new tag titles replaced by tag ids. Otherwise false. * @@ -186,7 +186,7 @@ public function createTagsFromField($tags) // We will use the tags table to store them JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tags/tables'); $tagTable = JTable::getInstance('Tag', 'TagsTable'); - $newTags = array(); + $newTags = array(); foreach ($tags as $key => $tag) { @@ -210,13 +210,13 @@ public function createTagsFromField($tags) else { // Prepare tag data - $tagTable->id = 0; - $tagTable->title = $tagText; + $tagTable->id = 0; + $tagTable->title = $tagText; $tagTable->published = 1; // $tagTable->language = property_exists ($item, 'language') ? $item->language : '*'; $tagTable->language = '*'; - $tagTable->access = 1; + $tagTable->access = 1; // Make this item a child of the root tag $tagTable->setLocation($tagTable->getRootId(), 'last-child'); @@ -239,7 +239,7 @@ public function createTagsFromField($tags) // At this point $tags is an array of all tag ids $this->tags = $newTags; - $result = $newTags; + $result = $newTags; } return $result; @@ -248,7 +248,7 @@ public function createTagsFromField($tags) /** * Create any new tags by looking for #new# in the metadata * - * @param string $metadata Metadata JSON string + * @param string $metadata Metadata JSON string * * @return mixed If successful, metadata with new tag titles replaced by tag ids. Otherwise false. * @@ -274,7 +274,7 @@ public function createTagsFromMetadata($metadata) // We will use the tags table to store them JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tags/tables'); $tagTable = JTable::getInstance('Tag', 'TagsTable'); - $newTags = array(); + $newTags = array(); foreach ($tags as $tag) { @@ -298,13 +298,13 @@ public function createTagsFromMetadata($metadata) else { // Prepare tag data - $tagTable->id = 0; - $tagTable->title = $tagText; + $tagTable->id = 0; + $tagTable->title = $tagText; $tagTable->published = 1; // $tagTable->language = property_exists ($item, 'language') ? $item->language : '*'; $tagTable->language = '*'; - $tagTable->access = 1; + $tagTable->access = 1; // Make this item a child of the root tag $tagTable->setLocation($tagTable->getRootId(), 'last-child'); @@ -327,7 +327,7 @@ public function createTagsFromMetadata($metadata) // At this point $tags is an array of all tag ids $metaObject->tags = $newTags; - $result = json_encode($metaObject); + $result = json_encode($metaObject); } return $result; @@ -336,8 +336,8 @@ public function createTagsFromMetadata($metadata) /** * Method to delete the tag mappings and #__ucm_content record for for an item * - * @param JTable $table JTable object of content table where delete occurred - * @param integer $contentItemId ID of the content item. + * @param JTable $table JTable object of content table where delete occurred + * @param integer $contentItemId ID of the content item. * * @return boolean true on success, false on failure * @@ -358,9 +358,9 @@ public function deleteTagData(JTable $table, $contentItemId) /** * Method to get a list of tags for an item, optionally with the tag data. * - * @param integer $contentType Content type alias. Dot separated. - * @param integer $id Id of the item to retrieve tags for. - * @param boolean $getTagData If true, data from the tags table will be included, defaults to true. + * @param integer $contentType Content type alias. Dot separated. + * @param integer $id Id of the item to retrieve tags for. + * @param boolean $getTagData If true, data from the tags table will be included, defaults to true. * * @return array Array of of tag objects * @@ -374,7 +374,7 @@ public function getItemTags($contentType, $id, $getTagData = true) } // Initialize some variables. - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('m.tag_id')) ->from($db->quoteName('#__contentitem_tag_map') . ' AS m ') @@ -386,7 +386,7 @@ public function getItemTags($contentType, $id, $getTagData = true) ) ); - $user = JFactory::getUser(); + $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $query->where('t.access IN (' . $groups . ')'); @@ -420,8 +420,8 @@ public function getItemTags($contentType, $id, $getTagData = true) * Method to get a list of tags for a given item. * Normally used for displaying a list of tags within a layout * - * @param integer $id The id (primary key) of the item to be tagged. - * @param string $prefix Dot separated string with the option and view to be used for a url. + * @param integer $id The id (primary key) of the item to be tagged. + * @param string $prefix Dot separated string with the option and view to be used for a url. * * @return string Comma separated list of tag Ids. * @@ -452,7 +452,7 @@ public function getTagIds($id, $prefix) $db->setQuery($query); // Add the tags to the content data. - $tagsList = $db->loadColumn(); + $tagsList = $db->loadColumn(); $this->tags = implode(',', $tagsList); } else @@ -466,27 +466,27 @@ public function getTagIds($id, $prefix) /** * Method to get a query to retrieve a detailed list of items for a tag. * - * @param mixed $tagId Tag or array of tags to be matched - * @param mixed $typesr Null, type or array of type aliases for content types to be included in the results - * @param boolean $includeChildren True to include the results from child tags - * @param string $orderByOption Column to order the results by - * @param string $orderDir Direction to sort the results in - * @param boolean $anyOrAll True to include items matching at least one tag, false to include + * @param mixed $tagId Tag or array of tags to be matched + * @param mixed $typesr Null, type or array of type aliases for content types to be included in the results + * @param boolean $includeChildren True to include the results from child tags + * @param string $orderByOption Column to order the results by + * @param string $orderDir Direction to sort the results in + * @param boolean $anyOrAll True to include items matching at least one tag, false to include * items all tags in the array. - * @param string $languageFilter Optional filter on language. Options are 'all', 'current' or any string. - * @param string $stateFilter Optional filtering on publication state, defaults to published or unpublished. + * @param string $languageFilter Optional filter on language. Options are 'all', 'current' or any string. + * @param string $stateFilter Optional filtering on publication state, defaults to published or unpublished. * * @return JDatabaseQuery Query to retrieve a list of tags * * @since 3.1 */ public function getTagItemsQuery($tagId, $typesr = null, $includeChildren = false, $orderByOption = 'c.core_title', $orderDir = 'ASC', - $anyOrAll = true, $languageFilter = 'all', $stateFilter = '0,1') + $anyOrAll = true, $languageFilter = 'all', $stateFilter = '0,1') { // Create a new query object. - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $user = JFactory::getUser(); + $db = JFactory::getDbo(); + $query = $db->getQuery(true); + $user = JFactory::getUser(); $nullDate = $db->quote($db->getNullDate()); $ntagsr = substr_count($tagId, ',') + 1; @@ -606,7 +606,7 @@ public function getTagItemsQuery($tagId, $typesr = null, $includeChildren = fals /** * Function that converts tag ids to their tag names * - * @param array $tagIds Array of integer tag ids. + * @param array $tagIds Array of integer tag ids. * * @return array An array of tag names. * @@ -621,7 +621,7 @@ public function getTagNames($tagIds) JArrayHelper::toInteger($tagIds); $tagIds = implode(',', $tagIds); - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('title')) ->from($db->quoteName('#__tags')) @@ -638,8 +638,8 @@ public function getTagNames($tagIds) /** * Method to get an array of tag ids for the current tag and its children * - * @param integer $id An optional ID - * @param array &$tagTreeArray Array containing the tag tree + * @param integer $id An optional ID + * @param array &$tagTreeArray Array containing the tag tree * * @return mixed * @@ -674,7 +674,7 @@ public function getTagTreeArray($id, &$tagTreeArray = array()) /** * Method to get the type id for a type alias. * - * @param string $typeAlias A type alias. + * @param string $typeAlias A type alias. * * @return string Name of the table for a type * @@ -683,7 +683,7 @@ public function getTagTreeArray($id, &$tagTreeArray = array()) public function getTypeId($typeAlias) { // Initialize some variables. - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('type_id')) ->from($db->quoteName('#__content_types')) @@ -697,10 +697,10 @@ public function getTypeId($typeAlias) /** * Method to get a list of types with associated data. * - * @param string $arrayType Optionally specify that the returned list consist of objects, associative arrays, or arrays. + * @param string $arrayType Optionally specify that the returned list consist of objects, associative arrays, or arrays. * Options are: rowList, assocList, and objectList - * @param array $selectTypes Optional array of type ids to limit the results to. Often from a request. - * @param boolean $useAlias If true, the alias is used to match, if false the type_id is used. + * @param array $selectTypes Optional array of type ids to limit the results to. Often from a request. + * @param boolean $useAlias If true, the alias is used to match, if false the type_id is used. * * @return array Array of of types * @@ -709,7 +709,7 @@ public function getTypeId($typeAlias) public static function getTypes($arrayType = 'objectList', $selectTypes = null, $useAlias = true) { // Initialize some variables. - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('*'); @@ -756,9 +756,9 @@ public static function getTypes($arrayType = 'objectList', $selectTypes = null, /** * Function that handles saving tags used in a table class after a store() * - * @param JTable $table JTable being processed - * @param array $newTags Array of new tags - * @param boolean $replace Flag indicating if all exising tags should be replaced + * @param JTable $table JTable being processed + * @param array $newTags Array of new tags + * @param boolean $replace Flag indicating if all exising tags should be replaced * * @return boolean * @@ -768,13 +768,13 @@ public function postStoreProcess($table, $newTags = array(), $replace = true) { if (!empty($table->newTags) && empty($newTags)) { - $newTags = $table->newTags; + $newTags = $table->newTags; } // If existing row, check to see if tags have changed. $newTable = clone $table; $newTable->reset(); - $key = $newTable->getKeyName(); + $key = $newTable->getKeyName(); $typeAlias = $this->typeAlias; $result = true; @@ -785,7 +785,7 @@ public function postStoreProcess($table, $newTags = array(), $replace = true) if (!$newTags) { // Delete all tags data - $key = $table->getKeyName(); + $key = $table->getKeyName(); $result = $this->deleteTagData($table, $table->$key); } else @@ -793,31 +793,32 @@ public function postStoreProcess($table, $newTags = array(), $replace = true) // Process the tags $rowdata = new JHelperContent; - $data = $rowdata->getRowData($table); + $data = $rowdata->getRowData($table); $ucmContentTable = JTable::getInstance('Corecontent'); - $ucm = new JUcmContent($table, $this->typeAlias); + $ucm = new JUcmContent($table, $this->typeAlias); $ucmData = $data ? $ucm->mapData($data) : $ucm->ucmData; $primaryId = $ucm->getPrimaryKey($ucmData['common']['core_type_id'], $ucmData['common']['core_content_item_id']); - $result = $ucmContentTable->load($primaryId); - $result = $result && $ucmContentTable->bind($ucmData['common']); - $result = $result && $ucmContentTable->check(); - $result = $result && $ucmContentTable->store(); - $ucmId = $ucmContentTable->core_content_id; + $result = $ucmContentTable->load($primaryId); + $result = $result && $ucmContentTable->bind($ucmData['common']); + $result = $result && $ucmContentTable->check(); + $result = $result && $ucmContentTable->store(); + $ucmId = $ucmContentTable->core_content_id; // Store the tag data if the article data was saved and run related methods. $result = $result && $this->tagItem($ucmId, $table, $newTags, $replace); } } + return $result; } /** * Function that preProcesses data from a table prior to a store() to ensure proper tag handling * - * @param JTable $table JTable being processed - * @param array $newTags Array of new tags + * @param JTable $table JTable being processed + * @param array $newTags Array of new tags * * @return null * @@ -833,7 +834,7 @@ public function preStoreProcess($table, $newTags = array()) // If existing row, check to see if tags have changed. $oldTable = clone $table; $oldTable->reset(); - $key = $oldTable->getKeyName(); + $key = $oldTable->getKeyName(); $typeAlias = $this->typeAlias; if ($oldTable->$key && $oldTable->load()) @@ -852,7 +853,7 @@ public function preStoreProcess($table, $newTags = array()) /** * Function to search tags * - * @param array $filters Filter to apply to the search + * @param array $filters Filter to apply to the search * * @return array * @@ -860,7 +861,7 @@ public function preStoreProcess($table, $newTags = array()) */ public static function searchTags($filters = array()) { - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('a.id AS value') ->select('a.path AS text') @@ -882,7 +883,7 @@ public static function searchTags($filters = array()) { $query->where( '(' . $db->quoteName('a.title') . ' LIKE ' . $db->quote('%' . $filters['like'] . '%') - . ' OR ' . $db->quoteName('a.path') . ' LIKE ' . $db->quote('%' . $filters['like'] . '%') . ')' + . ' OR ' . $db->quoteName('a.path') . ' LIKE ' . $db->quote('%' . $filters['like'] . '%') . ')' ); } @@ -939,7 +940,7 @@ public static function searchTags($filters = array()) /** * Method to delete all instances of a tag from the mapping table. Generally used when a tag is deleted. * - * @param integer $tag_id The tag_id (primary key) for the deleted tag. + * @param integer $tag_id The tag_id (primary key) for the deleted tag. * * @return void * @@ -948,7 +949,7 @@ public static function searchTags($filters = array()) public function tagDeleteInstances($tag_id) { // Delete the old tag maps. - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->delete($db->quoteName('#__contentitem_tag_map')) ->where($db->quoteName('tag_id') . ' = ' . (int) $tag_id); @@ -959,10 +960,10 @@ public function tagDeleteInstances($tag_id) /** * Method to add or update tags associated with an item. * - * @param integer $ucmId Id of the #__ucm_content item being tagged - * @param JTable $table JTable object being tagged - * @param array $tags Array of tags to be applied. - * @param boolean $replace Flag indicating if all exising tags should be replaced + * @param integer $ucmId Id of the #__ucm_content item being tagged + * @param JTable $table JTable object being tagged + * @param array $tags Array of tags to be applied. + * @param boolean $replace Flag indicating if all exising tags should be replaced * * @return boolean true on success, otherwise false. * @@ -970,10 +971,10 @@ public function tagDeleteInstances($tag_id) */ public function tagItem($ucmId, $table, $tags = array(), $replace = true) { - $key = $table->get('_tbl_key'); + $key = $table->get('_tbl_key'); $oldTags = $this->getTagIds((int) $table->$key, $this->typeAlias); $oldTags = explode(',', $oldTags); - $result = $this->unTagItem($ucmId, $table); + $result = $this->unTagItem($ucmId, $table); if ($replace) { @@ -1007,9 +1008,9 @@ public function tagItem($ucmId, $table, $tags = array(), $replace = true) /** * Method to untag an item * - * @param integer $contentId ID of the content item being untagged - * @param JTable $table JTable object being untagged - * @param array $tags Array of tags to be untagged. Use an empty array to untag all existing tags. + * @param integer $contentId ID of the content item being untagged + * @param JTable $table JTable object being untagged + * @param array $tags Array of tags to be untagged. Use an empty array to untag all existing tags. * * @return boolean true on success, otherwise false. * @@ -1017,9 +1018,9 @@ public function tagItem($ucmId, $table, $tags = array(), $replace = true) */ public function unTagItem($contentId, $table, $tags = array()) { - $key = $table->getKeyName(); - $id = $table->$key; - $db = JFactory::getDbo(); + $key = $table->getKeyName(); + $id = $table->$key; + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->delete('#__contentitem_tag_map') ->where($db->quoteName('type_alias') . ' = ' . $db->quote($this->typeAlias)) diff --git a/libraries/cms/html/access.php b/libraries/cms/html/access.php index fe2cebdf669f0..b983a935b1cac 100644 --- a/libraries/cms/html/access.php +++ b/libraries/cms/html/access.php @@ -29,11 +29,11 @@ abstract class JHtmlAccess /** * Displays a list of the available access view levels * - * @param string $name The form field name. - * @param string $selected The name of the selected section. - * @param string $attribs Additional attributes to add to the select field. - * @param mixed $params True to add "All Sections" option or and array of options - * @param string $id The form field id + * @param string $name The form field name. + * @param string $selected The name of the selected section. + * @param string $attribs Additional attributes to add to the select field. + * @param mixed $params True to add "All Sections" option or and array of options + * @param string $id The form field id * * @return string The required HTML for the SELECT tag. * @@ -42,7 +42,7 @@ abstract class JHtmlAccess */ public static function level($name, $selected, $attribs = '', $params = true, $id = false) { - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('a.id AS value, a.title AS text') ->from('#__viewlevels AS a') @@ -70,9 +70,9 @@ public static function level($name, $selected, $attribs = '', $params = true, $i $options, $name, array( - 'list.attr' => $attribs, + 'list.attr' => $attribs, 'list.select' => $selected, - 'id' => $id + 'id' => $id ) ); } @@ -80,10 +80,10 @@ public static function level($name, $selected, $attribs = '', $params = true, $i /** * Displays a list of the available user groups. * - * @param string $name The form field name. - * @param string $selected The name of the selected section. - * @param string $attribs Additional attributes to add to the select field. - * @param boolean $allowAll True to add "All Groups" option. + * @param string $name The form field name. + * @param string $selected The name of the selected section. + * @param string $attribs Additional attributes to add to the select field. + * @param boolean $allowAll True to add "All Groups" option. * * @return string The required HTML for the SELECT tag. * @@ -92,7 +92,7 @@ public static function level($name, $selected, $attribs = '', $params = true, $i */ public static function usergroup($name, $selected, $attribs = '', $allowAll = true) { - $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') @@ -119,9 +119,9 @@ public static function usergroup($name, $selected, $attribs = '', $allowAll = tr /** * Returns a UL list of user groups with check boxes * - * @param string $name The name of the checkbox controls array - * @param array $selected An array of the checked boxes - * @param boolean $checkSuperAdmin If false only super admins can add to super admin groups + * @param string $name The name of the checkbox controls array + * @param array $selected An array of the checked boxes + * @param boolean $checkSuperAdmin If false only super admins can add to super admin groups * * @return string * @@ -135,7 +135,7 @@ public static function usergroups($name, $selected, $checkSuperAdmin = false) $isSuperAdmin = JFactory::getUser()->authorise('core.admin'); - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('a.*, COUNT(DISTINCT b.id) AS level') ->from($db->quoteName('#__usergroups') . ' AS a') @@ -149,7 +149,7 @@ public static function usergroups($name, $selected, $checkSuperAdmin = false) for ($i = 0, $n = count($groups); $i < $n; $i++) { - $item = &$groups[$i]; + $item = & $groups[$i]; // If checkSuperAdmin is true, only add item if the user is superadmin or the group is not super admin if ((!$checkSuperAdmin) || $isSuperAdmin || (!JAccess::checkGroup($item->id, 'core.admin'))) @@ -185,10 +185,10 @@ public static function usergroups($name, $selected, $checkSuperAdmin = false) /** * Returns a UL list of actions with check boxes * - * @param string $name The name of the checkbox controls array - * @param array $selected An array of the checked boxes - * @param string $component The component the permissions apply to - * @param string $section The section (within a component) the permissions apply to + * @param string $name The name of the checkbox controls array + * @param array $selected An array of the checked boxes + * @param string $component The component the permissions apply to + * @param string $section The section (within a component) the permissions apply to * * @return string * @@ -206,15 +206,15 @@ public static function actions($name, $selected, $component, $section = 'global' "/access/section[@name='" . $section . "']/" ); - $html = array(); + $html = array(); $html[] = '
    '; for ($i = 0, $n = count($actions); $i < $n; $i++) { - $item = &$actions[$i]; + $item = & $actions[$i]; // Setup the variable attributes. - $eid = $count . 'action_' . $item->id; + $eid = $count . 'action_' . $item->id; $checked = in_array($item->id, $selected) ? ' checked="checked"' : ''; // Build the HTML for the item. @@ -243,7 +243,7 @@ public static function assetgroups() { if (empty(static::$asset_groups)) { - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('a.id AS value, a.title AS text') ->from($db->quoteName('#__viewlevels') . ' AS a') @@ -260,10 +260,10 @@ public static function assetgroups() /** * Displays a Select list of the available asset groups * - * @param string $name The name of the select element - * @param mixed $selected The selected asset group id - * @param string $attribs Optional attributes for the select field - * @param array $config An array of options for the control + * @param string $name The name of the select element + * @param mixed $selected The selected asset group id + * @param string $attribs Optional attributes for the select field + * @param array $config An array of options for the control * * @return mixed An HTML string or null if an error occurs * @@ -285,8 +285,8 @@ public static function assetgrouplist($name, $selected, $attribs = null, $config $options, $name, array( - 'id' => isset($config['id']) ? $config['id'] : 'assetgroups_' . (++$count), - 'list.attr' => (is_null($attribs) ? 'class="inputbox" size="3"' : $attribs), + 'id' => isset($config['id']) ? $config['id'] : 'assetgroups_' . (++$count), + 'list.attr' => (is_null($attribs) ? 'class="inputbox" size="3"' : $attribs), 'list.select' => (int) $selected ) ); diff --git a/libraries/cms/html/batch.php b/libraries/cms/html/batch.php index 5c5950ff810a9..fb337fd76dc04 100644 --- a/libraries/cms/html/batch.php +++ b/libraries/cms/html/batch.php @@ -41,7 +41,7 @@ public static function access() 'class="inputbox"', array( 'title' => JText::_('JLIB_HTML_BATCH_NOCHANGE'), - 'id' => 'batch-access' + 'id' => 'batch-access' ) ); @@ -51,7 +51,7 @@ public static function access() /** * Displays a batch widget for moving or copying items. * - * @param string $extension The extension that owns the category. + * @param string $extension The extension that owns the category. * * @return string The necessary HTML for the widget. * @@ -105,7 +105,7 @@ public static function language() /** * Display a batch widget for the user selector. * - * @param boolean $noUser Choose to display a "no user" option + * @param boolean $noUser Choose to display a "no user" option * * @return string The necessary HTML for the widget. * diff --git a/libraries/cms/html/behavior.php b/libraries/cms/html/behavior.php index 362c17b5ce106..939813ccfd763 100644 --- a/libraries/cms/html/behavior.php +++ b/libraries/cms/html/behavior.php @@ -31,8 +31,8 @@ abstract class JHtmlBehavior * * If debugging mode is on an uncompressed version of MooTools is included for easier debugging. * - * @param boolean $extras Flag to determine whether to load MooTools More in addition to Core - * @param mixed $debug Is debugging mode on? [optional] + * @param boolean $extras Flag to determine whether to load MooTools More in addition to Core + * @param mixed $debug Is debugging mode on? [optional] * * @return void * @@ -52,7 +52,7 @@ public static function framework($extras = false, $debug = null) if ($debug === null) { $config = JFactory::getConfig(); - $debug = $config->get('debug'); + $debug = $config->get('debug'); } if ($type != 'core' && empty(static::$loaded[__METHOD__]['core'])) @@ -70,7 +70,7 @@ public static function framework($extras = false, $debug = null) /** * Add unobtrusive JavaScript support for image captions. * - * @param string $selector The selector for which a caption behaviour is to be applied. + * @param string $selector The selector for which a caption behaviour is to be applied. * * @return void * @@ -195,18 +195,18 @@ public static function combobox() * * Uses the core Tips class in MooTools. * - * @param string $selector The class selector for the tooltip. - * @param array $params An array of options for the tooltip. - * Options for the tooltip can be: - * - maxTitleChars integer The maximum number of characters in the tooltip title (defaults to 50). - * - offsets object The distance of your tooltip from the mouse (defaults to {'x': 16, 'y': 16}). - * - showDelay integer The millisecond delay the show event is fired (defaults to 100). - * - hideDelay integer The millisecond delay the hide hide is fired (defaults to 100). - * - className string The className your tooltip container will get. - * - fixed boolean If set to true, the toolTip will not follow the mouse. - * - onShow function The default function for the show event, passes the tip element + * @param string $selector The class selector for the tooltip. + * @param array $params An array of options for the tooltip. + * Options for the tooltip can be: + * - maxTitleChars integer The maximum number of characters in the tooltip title (defaults to 50). + * - offsets object The distance of your tooltip from the mouse (defaults to {'x': 16, 'y': 16}). + * - showDelay integer The millisecond delay the show event is fired (defaults to 100). + * - hideDelay integer The millisecond delay the hide hide is fired (defaults to 100). + * - className string The className your tooltip container will get. + * - fixed boolean If set to true, the toolTip will not follow the mouse. + * - onShow function The default function for the show event, passes the tip element * and the currently hovered element. - * - onHide function The default function for the hide event, passes the currently + * - onHide function The default function for the hide event, passes the currently * hovered element. * * @return void @@ -263,19 +263,19 @@ public static function tooltip($selector = '.hasTip', $params = array()) /** * Add unobtrusive JavaScript support for modal links. * - * @param string $selector The selector for which a modal behaviour is to be applied. - * @param array $params An array of parameters for the modal behaviour. + * @param string $selector The selector for which a modal behaviour is to be applied. + * @param array $params An array of parameters for the modal behaviour. * Options for the modal behaviour can be: - * - ajaxOptions - * - size - * - shadow - * - overlay - * - onOpen - * - onClose - * - onUpdate - * - onResize - * - onShow - * - onHide + * - ajaxOptions + * - size + * - shadow + * - overlay + * - onOpen + * - onClose + * - onUpdate + * - onResize + * - onShow + * - onHide * * @return void * @@ -324,7 +324,7 @@ public static function modal($selector = 'a.modal', $params = array()) if (isset($params['fullScreen']) && (bool) $params['fullScreen']) { - $opt['size'] = array('x' => '\\window.getSize().x-80', 'y' => '\\window.getSize().y-80'); + $opt['size'] = array('x' => '\\window.getSize().x-80', 'y' => '\\window.getSize().y-80'); } $options = JHtml::getJSObject($opt); @@ -332,15 +332,15 @@ public static function modal($selector = 'a.modal', $params = array()) // Attach modal behavior to document $document ->addScriptDeclaration( - " - window.addEvent('domready', function() { + " + window.addEvent('domready', function() { - SqueezeBox.initialize(" . $options . "); + SqueezeBox.initialize(" . $options . "); SqueezeBox.assign($$('" . $selector . "'), { parse: 'rel' }); });" - ); + ); // Set static array static::$loaded[__METHOD__][$sig] = true; @@ -351,7 +351,7 @@ public static function modal($selector = 'a.modal', $params = array()) /** * JavaScript behavior to allow shift select in grids * - * @param string $id The id of the form for which a multiselect behaviour is to be applied. + * @param string $id The id of the form for which a multiselect behaviour is to be applied. * * @return void * @@ -386,9 +386,9 @@ public static function multiselect($id = 'adminForm') /** * Add unobtrusive javascript support for a collapsible tree. * - * @param string $id An index - * @param array $params An array of options. - * @param array $root The root node + * @param string $id An index + * @param array $params An array of options. + * @param array $root The root node * * @return void * @@ -417,7 +417,7 @@ public static function tree($id, $params = array(), $root = array()) $opt['onExpand'] = (array_key_exists('onExpand', $params)) ? '\\' . $params['onExpand'] : null; $opt['onSelect'] = (array_key_exists('onSelect', $params)) ? '\\' . $params['onSelect'] : null; $opt['onClick'] = (array_key_exists('onClick', $params)) ? '\\' . $params['onClick'] - : '\\function(node){ window.open(node.data.url, node.data.target != null ? node.data.target : \'_self\'); }'; + : '\\function(node){ window.open(node.data.url, node.data.target != null ? node.data.target : \'_self\'); }'; $options = JHtml::getJSObject($opt); @@ -429,7 +429,7 @@ public static function tree($id, $params = array(), $root = array()) $rt['icon'] = (array_key_exists('icon', $root)) ? $root['icon'] : null; $rt['openicon'] = (array_key_exists('openicon', $root)) ? $root['openicon'] : null; $rt['data'] = (array_key_exists('data', $root)) ? $root['data'] : null; - $rootNode = JHtml::getJSObject($rt); + $rootNode = JHtml::getJSObject($rt); $treeName = (array_key_exists('treeName', $params)) ? $params['treeName'] : ''; @@ -463,7 +463,7 @@ public static function calendar() } $document = JFactory::getDocument(); - $tag = JFactory::getLanguage()->getTag(); + $tag = JFactory::getLanguage()->getTag(); JHtml::_('stylesheet', 'system/calendar-jos.css', array(' title' => JText::_('JLIB_HTML_BEHAVIOR_GREEN'), ' media' => 'all'), true); JHtml::_('script', $tag . '/calendar.js', false, true); @@ -562,8 +562,8 @@ public static function keepalive() // Include MooTools framework static::framework(); - $config = JFactory::getConfig(); - $lifetime = ($config->get('lifetime') * 60000); + $config = JFactory::getConfig(); + $lifetime = ($config->get('lifetime') * 60000); $refreshTime = ($lifetime <= 60000) ? 30000 : $lifetime - 60000; // Refresh time is 1 minute less than the liftime assined in the configuration.php file. @@ -575,7 +575,7 @@ public static function keepalive() } $document = JFactory::getDocument(); - $script = ''; + $script = ''; $script .= 'function keepAlive() {'; $script .= ' var myAjax = new Request({method: "get", url: "index.php"}).send();'; $script .= '}'; @@ -592,13 +592,13 @@ public static function keepalive() /** * Highlight some words via Javascript. * - * @param array $terms Array of words that should be highlighted. - * @param string $start ID of the element that marks the begin of the section in which words + * @param array $terms Array of words that should be highlighted. + * @param string $start ID of the element that marks the begin of the section in which words * should be highlighted. Note this element will be removed from the DOM. - * @param string $end ID of the element that end this section. + * @param string $end ID of the element that end this section. * Note this element will be removed from the DOM. - * @param string $className Class name of the element highlights are wrapped in. - * @param string $tag Tag that will be used to wrap the highlighted words. + * @param string $className Class name of the element highlights are wrapped in. + * @param string $tag Tag that will be used to wrap the highlighted words. * * @return void * @@ -660,7 +660,7 @@ public static function noframes() // Include MooTools framework static::framework(); - $js = "window.addEvent('domready', function () {if (top == self) {document.documentElement.style.display = 'block'; }" . + $js = "window.addEvent('domready', function () {if (top == self) {document.documentElement.style.display = 'block'; }" . " else {top.location = self.location; }});"; $document = JFactory::getDocument(); $document->addStyleDeclaration('html { display:none }'); @@ -674,7 +674,7 @@ public static function noframes() /** * Internal method to get a JavaScript object notation string from an array * - * @param array $array The array to convert to JavaScript object notation + * @param array $array The array to convert to JavaScript object notation * * @return string JavaScript object notation representation of the array * @@ -708,8 +708,8 @@ protected static function calendartranslation() $jsscript = 1; // To keep the code simple here, run strings through JText::_() using array_map() - $callback = array('JText','_'); - $weekdays_full = array_map( + $callback = array('JText', '_'); + $weekdays_full = array_map( $callback, array( 'SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY' ) @@ -720,13 +720,13 @@ protected static function calendartranslation() 'SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN' ) ); - $months_long = array_map( + $months_long = array_map( $callback, array( 'JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY', 'JUNE', 'JULY', 'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 'DECEMBER' ) ); - $months_short = array_map( + $months_short = array_map( $callback, array( 'JANUARY_SHORT', 'FEBRUARY_SHORT', 'MARCH_SHORT', 'APRIL_SHORT', 'MAY_SHORT', 'JUNE_SHORT', 'JULY_SHORT', 'AUGUST_SHORT', 'SEPTEMBER_SHORT', 'OCTOBER_SHORT', 'NOVEMBER_SHORT', 'DECEMBER_SHORT' @@ -735,10 +735,10 @@ protected static function calendartranslation() // This will become an object in Javascript but define it first in PHP for readability $today = " " . JText::_('JLIB_HTML_BEHAVIOR_TODAY') . " "; - $text = array( - 'INFO' => JText::_('JLIB_HTML_BEHAVIOR_ABOUT_THE_CALENDAR'), + $text = array( + 'INFO' => JText::_('JLIB_HTML_BEHAVIOR_ABOUT_THE_CALENDAR'), - 'ABOUT' => "DHTML Date/Time Selector\n" + 'ABOUT' => "DHTML Date/Time Selector\n" . "(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" . "For latest version visit: http://www.dynarch.com/projects/calendar/\n" . "Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." @@ -748,36 +748,36 @@ protected static function calendartranslation() . JText::_('JLIB_HTML_BEHAVIOR_MONTH_SELECT') . JText::_('JLIB_HTML_BEHAVIOR_HOLD_MOUSE'), - 'ABOUT_TIME' => "\n\n" + 'ABOUT_TIME' => "\n\n" . "Time selection:\n" . "- Click on any of the time parts to increase it\n" . "- or Shift-click to decrease it\n" . "- or click and drag for faster selection.", - 'PREV_YEAR' => JText::_('JLIB_HTML_BEHAVIOR_PREV_YEAR_HOLD_FOR_MENU'), - 'PREV_MONTH' => JText::_('JLIB_HTML_BEHAVIOR_PREV_MONTH_HOLD_FOR_MENU'), - 'GO_TODAY' => JText::_('JLIB_HTML_BEHAVIOR_GO_TODAY'), - 'NEXT_MONTH' => JText::_('JLIB_HTML_BEHAVIOR_NEXT_MONTH_HOLD_FOR_MENU'), - 'SEL_DATE' => JText::_('JLIB_HTML_BEHAVIOR_SELECT_DATE'), - 'DRAG_TO_MOVE' => JText::_('JLIB_HTML_BEHAVIOR_DRAG_TO_MOVE'), - 'PART_TODAY' => $today, - 'DAY_FIRST' => JText::_('JLIB_HTML_BEHAVIOR_DISPLAY_S_FIRST'), - 'WEEKEND' => "0,6", - 'CLOSE' => JText::_('JLIB_HTML_BEHAVIOR_CLOSE'), - 'TODAY' => JText::_('JLIB_HTML_BEHAVIOR_TODAY'), - 'TIME_PART' => JText::_('JLIB_HTML_BEHAVIOR_SHIFT_CLICK_OR_DRAG_TO_CHANGE_VALUE'), - 'DEF_DATE_FORMAT' => "%Y-%m-%d", - 'TT_DATE_FORMAT' => JText::_('JLIB_HTML_BEHAVIOR_TT_DATE_FORMAT'), - 'WK' => JText::_('JLIB_HTML_BEHAVIOR_WK'), - 'TIME' => JText::_('JLIB_HTML_BEHAVIOR_TIME') + 'PREV_YEAR' => JText::_('JLIB_HTML_BEHAVIOR_PREV_YEAR_HOLD_FOR_MENU'), + 'PREV_MONTH' => JText::_('JLIB_HTML_BEHAVIOR_PREV_MONTH_HOLD_FOR_MENU'), + 'GO_TODAY' => JText::_('JLIB_HTML_BEHAVIOR_GO_TODAY'), + 'NEXT_MONTH' => JText::_('JLIB_HTML_BEHAVIOR_NEXT_MONTH_HOLD_FOR_MENU'), + 'SEL_DATE' => JText::_('JLIB_HTML_BEHAVIOR_SELECT_DATE'), + 'DRAG_TO_MOVE' => JText::_('JLIB_HTML_BEHAVIOR_DRAG_TO_MOVE'), + 'PART_TODAY' => $today, + 'DAY_FIRST' => JText::_('JLIB_HTML_BEHAVIOR_DISPLAY_S_FIRST'), + 'WEEKEND' => "0,6", + 'CLOSE' => JText::_('JLIB_HTML_BEHAVIOR_CLOSE'), + 'TODAY' => JText::_('JLIB_HTML_BEHAVIOR_TODAY'), + 'TIME_PART' => JText::_('JLIB_HTML_BEHAVIOR_SHIFT_CLICK_OR_DRAG_TO_CHANGE_VALUE'), + 'DEF_DATE_FORMAT' => "%Y-%m-%d", + 'TT_DATE_FORMAT' => JText::_('JLIB_HTML_BEHAVIOR_TT_DATE_FORMAT'), + 'WK' => JText::_('JLIB_HTML_BEHAVIOR_WK'), + 'TIME' => JText::_('JLIB_HTML_BEHAVIOR_TIME') ); return 'Calendar._DN = ' . json_encode($weekdays_full) . ';' - . ' Calendar._SDN = ' . json_encode($weekdays_short) . ';' - . ' Calendar._FD = 0;' - . ' Calendar._MN = ' . json_encode($months_long) . ';' - . ' Calendar._SMN = ' . json_encode($months_short) . ';' - . ' Calendar._TT = ' . json_encode($text) . ';'; + . ' Calendar._SDN = ' . json_encode($weekdays_short) . ';' + . ' Calendar._FD = 0;' + . ' Calendar._MN = ' . json_encode($months_long) . ';' + . ' Calendar._SMN = ' . json_encode($months_short) . ';' + . ' Calendar._TT = ' . json_encode($text) . ';'; } /** diff --git a/libraries/cms/html/bootstrap.php b/libraries/cms/html/bootstrap.php index 367d9e4fb9ad9..17477d8e72be7 100644 --- a/libraries/cms/html/bootstrap.php +++ b/libraries/cms/html/bootstrap.php @@ -27,10 +27,10 @@ abstract class JHtmlBootstrap /** * Add javascript support for the Bootstrap affix plugin * - * @param string $selector Unique selector for the element to be affixed. - * @param array $params An array of options. - * Options for the affix plugin can be: - * - offset number|function|object Pixels to offset from screen when calculating position of scroll. + * @param string $selector Unique selector for the element to be affixed. + * @param array $params An array of options. + * Options for the affix plugin can be: + * - offset number|function|object Pixels to offset from screen when calculating position of scroll. * If a single number is provided, the offset will be applied in both top * and left directions. To listen for a single direction, or multiple * unique offsets, just provide an object offset: { x: 10 }. @@ -72,7 +72,7 @@ public static function affix($selector = 'affix', $params = array()) /** * Add javascript support for Bootstrap alerts * - * @param string $selector Common class for the alerts + * @param string $selector Common class for the alerts * * @return void * @@ -104,7 +104,7 @@ public static function alert($selector = 'alert') /** * Add javascript support for Bootstrap buttons * - * @param string $selector Common class for the buttons + * @param string $selector Common class for the buttons * * @return void * @@ -136,12 +136,12 @@ public static function button($selector = 'button') /** * Add javascript support for Bootstrap carousels * - * @param string $selector Common class for the carousels. - * @param array $params An array of options for the modal. - * Options for the modal can be: - * - interval number The amount of time to delay between automatically cycling an item. + * @param string $selector Common class for the carousels. + * @param array $params An array of options for the modal. + * Options for the modal can be: + * - interval number The amount of time to delay between automatically cycling an item. * If false, carousel will not automatically cycle. - * - pause string Pauses the cycling of the carousel on mouseenter and resumes the cycling + * - pause string Pauses the cycling of the carousel on mouseenter and resumes the cycling * of the carousel on mouseleave. * * @return void @@ -180,7 +180,7 @@ public static function carousel($selector = 'carousel', $params = array()) /** * Add javascript support for Bootstrap dropdowns * - * @param string $selector Common class for the dropdowns + * @param string $selector Common class for the dropdowns * * @return void * @@ -214,7 +214,7 @@ public static function dropdown($selector = 'dropdown-toggle') * * If debugging mode is on an uncompressed version of Bootstrap is included for easier debugging. * - * @param mixed $debug Is debugging mode on? [optional] + * @param mixed $debug Is debugging mode on? [optional] * * @return void * @@ -235,7 +235,7 @@ public static function framework($debug = null) if ($debug === null) { $config = JFactory::getConfig(); - $debug = (boolean) $config->get('debug'); + $debug = (boolean) $config->get('debug'); } JHtml::_('script', 'jui/bootstrap.min.js', false, true, false, false, $debug); @@ -247,8 +247,8 @@ public static function framework($debug = null) /** * Add javascript support for Bootstrap modals * - * @param string $selector The ID selector for the modal. - * @param array $params An array of options for the modal. + * @param string $selector The ID selector for the modal. + * @param array $params An array of options for the modal. * Options for the modal can be: * - backdrop boolean Includes a modal-backdrop element. * - keyboard boolean Closes the modal when escape key is pressed. @@ -272,7 +272,7 @@ public static function modal($selector = 'modal', $params = array()) $opt['backdrop'] = isset($params['backdrop']) ? (boolean) $params['backdrop'] : true; $opt['keyboard'] = isset($params['keyboard']) ? (boolean) $params['keyboard'] : true; $opt['show'] = isset($params['show']) ? (boolean) $params['show'] : true; - $opt['remote'] = isset($params['remote']) ? $params['remote'] : ''; + $opt['remote'] = isset($params['remote']) ? $params['remote'] : ''; $options = JHtml::getJSObject($opt); @@ -293,9 +293,9 @@ public static function modal($selector = 'modal', $params = array()) /** * Method to render a Bootstrap modal * - * @param string $selector The ID selector for the modal. - * @param array $params An array of options for the modal. - * @param string $footer Optional markup for the modal footer + * @param string $selector The ID selector for the modal. + * @param array $params An array of options for the modal. + * @param string $footer Optional markup for the modal footer * * @return string HTML markup for a modal * @@ -330,21 +330,21 @@ public static function renderModal($selector = 'modal', $params = array(), $foot * * Use element's Title as popover content * - * @param string $selector Selector for the tooltip - * @param array $params An array of options for the tooltip. - * Options for the tooltip can be: - * animation boolean apply a css fade transition to the tooltip - * html boolean Insert HTML into the tooltip. If false, jQuery's text method will be used to insert + * @param string $selector Selector for the tooltip + * @param array $params An array of options for the tooltip. + * Options for the tooltip can be: + * animation boolean apply a css fade transition to the tooltip + * html boolean Insert HTML into the tooltip. If false, jQuery's text method will be used to insert * content into the dom. - * placement string|function how to position the tooltip - top | bottom | left | right - * selector string If a selector is provided, tooltip objects will be delegated to the specified targets. - * trigger string how tooltip is triggered - hover | focus | manual - * title string|function default title value if `title` tag isn't present - * content string|function default content value if `data-content` attribute isn't present - * delay number|object delay showing and hiding the tooltip (ms) - does not apply to manual trigger type + * placement string|function how to position the tooltip - top | bottom | left | right + * selector string If a selector is provided, tooltip objects will be delegated to the specified targets. + * trigger string how tooltip is triggered - hover | focus | manual + * title string|function default title value if `title` tag isn't present + * content string|function default content value if `data-content` attribute isn't present + * delay number|object delay showing and hiding the tooltip (ms) - does not apply to manual trigger type * If a number is supplied, delay is applied to both hide/show * Object structure is: delay: { show: 500, hide: 100 } - * container string|boolean Appends the popover to a specific element: { container: 'body' } + * container string|boolean Appends the popover to a specific element: { container: 'body' } * * @return void * @@ -362,13 +362,13 @@ public static function popover($selector = '.hasPopover', $params = array()) static::framework(); $opt['animation'] = isset($params['animation']) ? $params['animation'] : null; - $opt['html'] = isset($params['html']) ? $params['html'] : true; + $opt['html'] = isset($params['html']) ? $params['html'] : true; $opt['placement'] = isset($params['placement']) ? $params['placement'] : null; - $opt['selector'] = isset($params['selector']) ? $params['selector'] : null; - $opt['title'] = isset($params['title']) ? $params['title'] : null; - $opt['trigger'] = isset($params['trigger']) ? $params['trigger'] : 'hover focus'; - $opt['content'] = isset($params['content']) ? $params['content'] : null; - $opt['delay'] = isset($params['delay']) ? $params['delay'] : null; + $opt['selector'] = isset($params['selector']) ? $params['selector'] : null; + $opt['title'] = isset($params['title']) ? $params['title'] : null; + $opt['trigger'] = isset($params['trigger']) ? $params['trigger'] : 'hover focus'; + $opt['content'] = isset($params['content']) ? $params['content'] : null; + $opt['delay'] = isset($params['delay']) ? $params['delay'] : null; $opt['container'] = isset($params['container']) ? $params['container'] : "body"; $options = JHtml::getJSObject($opt); @@ -389,8 +389,8 @@ public static function popover($selector = '.hasPopover', $params = array()) /** * Add javascript support for Bootstrap ScrollSpy * - * @param string $selector The ID selector for the ScrollSpy element. - * @param array $params An array of options for the ScrollSpy. + * @param string $selector The ID selector for the ScrollSpy element. + * @param array $params An array of options for the ScrollSpy. * Options for the modal can be: * - offset number Pixels to offset from top when calculating position of scroll. * @@ -432,20 +432,20 @@ public static function scrollspy($selector = 'navbar', $params = array()) * Add a title attribute to any element in the form * title="title::text" * - * @param string $selector The ID selector for the tooltip. - * @param array $params An array of options for the tooltip. - * Options for the tooltip can be: - * - animation boolean Apply a CSS fade transition to the tooltip - * - html boolean Insert HTML into the tooltip. If false, jQuery's text method will be used to insert + * @param string $selector The ID selector for the tooltip. + * @param array $params An array of options for the tooltip. + * Options for the tooltip can be: + * - animation boolean Apply a CSS fade transition to the tooltip + * - html boolean Insert HTML into the tooltip. If false, jQuery's text method will be used to insert * content into the dom. - * - placement string|function How to position the tooltip - top | bottom | left | right - * - selector string If a selector is provided, tooltip objects will be delegated to the specified targets. - * - title string|function Default title value if `title` tag isn't present - * - trigger string How tooltip is triggered - hover | focus | manual - * - delay integer Delay showing and hiding the tooltip (ms) - does not apply to manual trigger type + * - placement string|function How to position the tooltip - top | bottom | left | right + * - selector string If a selector is provided, tooltip objects will be delegated to the specified targets. + * - title string|function Default title value if `title` tag isn't present + * - trigger string How tooltip is triggered - hover | focus | manual + * - delay integer Delay showing and hiding the tooltip (ms) - does not apply to manual trigger type * If a number is supplied, delay is applied to both hide/show * Object structure is: delay: { show: 500, hide: 100 } - * - container string|boolean Appends the popover to a specific element: { container: 'body' } + * - container string|boolean Appends the popover to a specific element: { container: 'body' } * * @return void * @@ -489,23 +489,23 @@ public static function tooltip($selector = '.hasTooltip', $params = array()) /** * Add javascript support for Bootstrap typeahead * - * @param string $selector The selector for the typeahead element. - * @param array $params An array of options for the typeahead element. - * Options for the tooltip can be: - * - source array, function The data source to query against. May be an array of strings or a function. + * @param string $selector The selector for the typeahead element. + * @param array $params An array of options for the typeahead element. + * Options for the tooltip can be: + * - source array, function The data source to query against. May be an array of strings or a function. * The function is passed two arguments, the query value in the input field and the * process callback. The function may be used synchronously by returning the data * source directly or asynchronously via the process callback's single argument. - * - items number The max number of items to display in the dropdown. - * - minLength number The minimum character length needed before triggering autocomplete suggestions - * - matcher function The method used to determine if a query matches an item. Accepts a single argument, + * - items number The max number of items to display in the dropdown. + * - minLength number The minimum character length needed before triggering autocomplete suggestions + * - matcher function The method used to determine if a query matches an item. Accepts a single argument, * the item against which to test the query. Access the current query with this.query. * Return a boolean true if query is a match. - * - sorter function Method used to sort autocomplete results. Accepts a single argument items and has + * - sorter function Method used to sort autocomplete results. Accepts a single argument items and has * the scope of the typeahead instance. Reference the current query with this.query. - * - updater function The method used to return selected item. Accepts a single argument, the item and + * - updater function The method used to return selected item. Accepts a single argument, the item and * has the scope of the typeahead instance. - * - highlighter function Method used to highlight autocomplete results. Accepts a single argument item and + * - highlighter function Method used to highlight autocomplete results. Accepts a single argument item and * has the scope of the typeahead instance. Should return html. * * @return void @@ -548,13 +548,13 @@ public static function typeahead($selector = '.typeahead', $params = array()) /** * Add javascript support for Bootstrap accordians and insert the accordian * - * @param string $selector The ID selector for the tooltip. - * @param array $params An array of options for the tooltip. - * Options for the tooltip can be: - * - parent selector If selector then all collapsible elements under the specified parent will be closed when this + * @param string $selector The ID selector for the tooltip. + * @param array $params An array of options for the tooltip. + * Options for the tooltip can be: + * - parent selector If selector then all collapsible elements under the specified parent will be closed when this * collapsible item is shown. (similar to traditional accordion behavior) - * - toggle boolean Toggles the collapsible element on invocation - * - active string Sets the active slide during load + * - toggle boolean Toggles the collapsible element on invocation + * - active string Sets the active slide during load * * @return string HTML for the accordian * @@ -584,7 +584,7 @@ public static function startAccordion($selector = 'myAccordian', $params = array ); // Set static array - static::$loaded[__METHOD__][$sig] = true; + static::$loaded[__METHOD__][$sig] = true; static::$loaded[__METHOD__]['active'] = $opt['active']; } @@ -606,10 +606,10 @@ public static function endAccordion() /** * Begins the display of a new accordion slide. * - * @param string $selector Identifier of the accordion group. - * @param string $text Text to display. - * @param string $id Identifier of the slide. - * @param string $class Class of the accordion group. + * @param string $selector Identifier of the accordion group. + * @param string $text Text to display. + * @param string $id Identifier of the slide. + * @param string $class Class of the accordion group. * * @return string HTML to add the slide * @@ -617,7 +617,7 @@ public static function endAccordion() */ public static function addSlide($selector, $text, $id, $class = '') { - $in = (static::$loaded['JHtmlBootstrap::startAccordion']['active'] == $id) ? ' in' : ''; + $in = (static::$loaded['JHtmlBootstrap::startAccordion']['active'] == $id) ? ' in' : ''; $class = (!empty($class)) ? ' ' . $class : ''; $html = '
    ' @@ -647,8 +647,8 @@ public static function endSlide() /** * Creates a tab pane * - * @param string $selector The pane identifier. - * @param array $params The parameters for the pane + * @param string $selector The pane identifier. + * @param array $params The parameters for the pane * * @return string * @@ -671,7 +671,7 @@ public static function startTabSet($selector = 'myTab', $params = array()) ->addScriptDeclaration(JLayoutHelper::render('libraries.cms.html.bootstrap.starttabsetscript', array('selector' => $selector))); // Set static array - static::$loaded[__METHOD__][$sig] = true; + static::$loaded[__METHOD__][$sig] = true; static::$loaded[__METHOD__][$selector]['active'] = $opt['active']; } @@ -697,9 +697,9 @@ public static function endTabSet() /** * Begins the display of a new tab content panel. * - * @param string $selector Identifier of the panel. - * @param string $id The ID of the div element - * @param string $title The title text for the new UL tab + * @param string $selector Identifier of the panel. + * @param string $id The ID of the div element + * @param string $title The title text for the new UL tab * * @return string HTML to start a new panel * @@ -711,13 +711,13 @@ public static function addTab($selector, $id, $title) static $tabLayout = null; $tabScriptLayout = is_null($tabScriptLayout) ? new JLayoutFile('libraries.cms.html.bootstrap.addtabscript') : $tabScriptLayout; - $tabLayout = is_null($tabLayout) ? new JLayoutFile('libraries.cms.html.bootstrap.addtab') : $tabLayout; + $tabLayout = is_null($tabLayout) ? new JLayoutFile('libraries.cms.html.bootstrap.addtab') : $tabLayout; $active = (static::$loaded['JHtmlBootstrap::startTabSet'][$selector]['active'] == $id) ? ' active' : ''; // Inject tab into UL JFactory::getDocument() - ->addScriptDeclaration($tabScriptLayout->render(array('selector' => $selector,'id' => $id, 'active' => $active, 'title' => $title))); + ->addScriptDeclaration($tabScriptLayout->render(array('selector' => $selector, 'id' => $id, 'active' => $active, 'title' => $title))); $html = $tabLayout->render(array('id' => $id, 'active' => $active)); @@ -741,13 +741,13 @@ public static function endTab() /** * Creates a tab pane * - * @param string $selector The pane identifier. - * @param array $params The parameters for the pane + * @param string $selector The pane identifier. + * @param array $params The parameters for the pane * * @return string * - * @since 3.0 - * @deprecated 4.0 Use JHtml::_('bootstrap.startTabSet') instead. + * @since 3.0 + * @deprecated 4.0 Use JHtml::_('bootstrap.startTabSet') instead. */ public static function startPane($selector = 'myTab', $params = array()) { @@ -771,7 +771,7 @@ public static function startPane($selector = 'myTab', $params = array()) ); // Set static array - static::$loaded['JHtmlBootstrap::startTabSet'][$sig] = true; + static::$loaded['JHtmlBootstrap::startTabSet'][$sig] = true; static::$loaded['JHtmlBootstrap::startTabSet'][$selector]['active'] = $opt['active']; } @@ -783,8 +783,8 @@ public static function startPane($selector = 'myTab', $params = array()) * * @return string HTML to close the pane * - * @since 3.0 - * @deprecated 4.0 Use JHtml::_('bootstrap.endTabSet') instead. + * @since 3.0 + * @deprecated 4.0 Use JHtml::_('bootstrap.endTabSet') instead. */ public static function endPane() { @@ -794,12 +794,12 @@ public static function endPane() /** * Begins the display of a new tab content panel. * - * @param string $selector Identifier of the panel. - * @param string $id The ID of the div element + * @param string $selector Identifier of the panel. + * @param string $id The ID of the div element * * @return string HTML to start a new panel * - * @since 3.0 + * @since 3.0 * @deprecated 4.0 Use JHtml::_('bootstrap.addTab') instead. */ public static function addPanel($selector, $id) @@ -814,7 +814,7 @@ public static function addPanel($selector, $id) * * @return string HTML to close the pane * - * @since 3.0 + * @since 3.0 * @deprecated 4.0 Use JHtml::_('bootstrap.endTab') instead. */ public static function endPanel() @@ -825,9 +825,9 @@ public static function endPanel() /** * Loads CSS files needed by Bootstrap * - * @param boolean $includeMainCss If true, main bootstrap.css files are loaded - * @param string $direction rtl or ltr direction. If empty, ltr is assumed - * @param array $attribs Optional array of attributes to be passed to JHtml::_('stylesheet') + * @param boolean $includeMainCss If true, main bootstrap.css files are loaded + * @param string $direction rtl or ltr direction. If empty, ltr is assumed + * @param array $attribs Optional array of attributes to be passed to JHtml::_('stylesheet') * * @return void * diff --git a/libraries/cms/html/category.php b/libraries/cms/html/category.php index 7900811523d01..05017b6d22f11 100644 --- a/libraries/cms/html/category.php +++ b/libraries/cms/html/category.php @@ -29,8 +29,8 @@ abstract class JHtmlCategory /** * Returns an array of categories for the given extension. * - * @param string $extension The extension option e.g. com_something. - * @param array $config An array of configuration options. By default, only + * @param string $extension The extension option e.g. com_something. + * @param array $config An array of configuration options. By default, only * published and unpublished categories are returned. * * @return array @@ -44,8 +44,8 @@ public static function options($extension, $config = array('filter.published' => 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('#__categories AS a') ->where('a.parent_id > 0'); @@ -94,8 +94,8 @@ public static function options($extension, $config = array('filter.published' => 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); } } @@ -106,8 +106,8 @@ public static function options($extension, $config = array('filter.published' => /** * Returns an array of categories for the given extension. * - * @param string $extension The extension option. - * @param array $config An array of configuration options. By default, only published and unpublished categories are returned. + * @param string $extension The extension option. + * @param array $config An array of configuration options. By default, only published and unpublished categories are returned. * * @return array Categories for the extension * @@ -120,8 +120,8 @@ public static function categories($extension, $config = array('filter.published' 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, a.parent_id') ->from('#__categories AS a') ->where('a.parent_id > 0'); @@ -153,8 +153,8 @@ public static function categories($extension, $config = array('filter.published' 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); } // Special "Add to root" option: diff --git a/libraries/cms/html/content.php b/libraries/cms/html/content.php index 98fda3cf3134b..abad401f08dd8 100644 --- a/libraries/cms/html/content.php +++ b/libraries/cms/html/content.php @@ -21,9 +21,9 @@ abstract class JHtmlContent /** * Fire onContentPrepare for content that isn't part of an article. * - * @param string $text The content to be transformed. - * @param array $params The content params. - * @param string $context The context of the content to be transformed. + * @param string $text The content to be transformed. + * @param array $params The content params. + * @param string $context The context of the content to be transformed. * * @return string The content after transformation. * @@ -36,7 +36,7 @@ public static function prepare($text, $params = null, $context = 'text') $params = new JObject; } - $article = new stdClass; + $article = new stdClass; $article->text = $text; JPluginHelper::importPlugin('content'); $dispatcher = JEventDispatcher::getInstance(); diff --git a/libraries/cms/html/contentlanguage.php b/libraries/cms/html/contentlanguage.php index 4b578f9765bbc..1927060a01f65 100644 --- a/libraries/cms/html/contentlanguage.php +++ b/libraries/cms/html/contentlanguage.php @@ -29,8 +29,8 @@ abstract class JHtmlContentLanguage /** * Get a list of the available content language items. * - * @param boolean $all True to include All (*) - * @param boolean $translate True to translate All + * @param boolean $all True to include All (*) + * @param boolean $translate True to translate All * * @return string * diff --git a/libraries/cms/html/date.php b/libraries/cms/html/date.php index 225334f4256de..e0eabfb07d1e3 100644 --- a/libraries/cms/html/date.php +++ b/libraries/cms/html/date.php @@ -21,10 +21,10 @@ abstract class JHtmlDate /** * Function to convert a static time into a relative measurement * - * @param string $date The date to convert - * @param string $unit The optional unit of measurement to return + * @param string $date The date to convert + * @param string $unit The optional unit of measurement to return * if the value of the diff is greater than one - * @param string $time An optional time to compare to, defaults to now + * @param string $time An optional time to compare to, defaults to now * * @return string The converted time string * diff --git a/libraries/cms/html/dropdown.php b/libraries/cms/html/dropdown.php index 9b48701c27772..475b7f7035c04 100644 --- a/libraries/cms/html/dropdown.php +++ b/libraries/cms/html/dropdown.php @@ -73,6 +73,7 @@ public static function init() // Set static array static::$loaded[__METHOD__] = true; + return; } @@ -91,13 +92,14 @@ public static function start() return; } - $dropDownList = ''; } else { return ''; + . '" value="' . (0 !== (int) $value ? static::_('date', $value, 'Y-m-d H:i:s', null) : '') . '" ' . $attribs + . ' />'; } } @@ -1016,7 +1016,7 @@ public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attri * Add a directory where JHtml should search for helpers. You may * either pass a string or an array of directories. * - * @param string $path A path to search. + * @param string $path A path to search. * * @return array An array with directory elements * @@ -1042,7 +1042,7 @@ public static function addIncludePath($path = '') /** * Internal method to get a JavaScript object notation string from an array * - * @param array $array The array to convert to JavaScript object notation + * @param array $array The array to convert to JavaScript object notation * * @return string JavaScript object notation representation of the array * diff --git a/libraries/cms/html/icons.php b/libraries/cms/html/icons.php index 193a9cb75c101..7ce38ffb2b96a 100644 --- a/libraries/cms/html/icons.php +++ b/libraries/cms/html/icons.php @@ -21,7 +21,7 @@ abstract class JHtmlIcons /** * Method to generate html code for a list of buttons * - * @param array $buttons Array of buttons + * @param array $buttons Array of buttons * * @return string * @@ -34,13 +34,14 @@ public static function buttons($buttons) { $html[] = JHtml::_('icons.button', $button); } + return implode($html); } /** * Method to generate html code for a list of buttons * - * @param array $button Button properties + * @param array $button Button properties * * @return string * @@ -75,6 +76,7 @@ public static function button($button) // Instantiate a new JLayoutFile instance and render the layout $layout = new JLayoutFile('joomla.quickicons.icon'); + return $layout->render($button); } } diff --git a/libraries/cms/html/jgrid.php b/libraries/cms/html/jgrid.php index 7d89673b86116..84bebbf60ca85 100644 --- a/libraries/cms/html/jgrid.php +++ b/libraries/cms/html/jgrid.php @@ -21,38 +21,38 @@ abstract class JHtmlJGrid /** * Returns an action on a grid * - * @param integer $i The row index - * @param string $task The task to fire - * @param string|array $prefix An optional task prefix or an array of options - * @param string $text An optional text to display [unused - @deprecated 4.0] - * @param string $active_title An optional active tooltip to display if $enable is true - * @param string $inactive_title An optional inactive tooltip to display if $enable is true - * @param boolean $tip An optional setting for tooltip - * @param string $active_class An optional active HTML class - * @param string $inactive_class An optional inactive HTML class - * @param boolean $enabled An optional setting for access control on the action. - * @param boolean $translate An optional setting for translation. - * @param string $checkbox An optional prefix for checkboxes. + * @param integer $i The row index + * @param string $task The task to fire + * @param string|array $prefix An optional task prefix or an array of options + * @param string $text An optional text to display [unused - @deprecated 4.0] + * @param string $active_title An optional active tooltip to display if $enable is true + * @param string $inactive_title An optional inactive tooltip to display if $enable is true + * @param boolean $tip An optional setting for tooltip + * @param string $active_class An optional active HTML class + * @param string $inactive_class An optional inactive HTML class + * @param boolean $enabled An optional setting for access control on the action. + * @param boolean $translate An optional setting for translation. + * @param string $checkbox An optional prefix for checkboxes. * * @return string The HTML markup * * @since 1.6 */ public static function action($i, $task, $prefix = '', $text = '', $active_title = '', $inactive_title = '', $tip = false, $active_class = '', - $inactive_class = '', $enabled = true, $translate = true, $checkbox = 'cb') + $inactive_class = '', $enabled = true, $translate = true, $checkbox = 'cb') { if (is_array($prefix)) { - $options = $prefix; - $active_title = array_key_exists('active_title', $options) ? $options['active_title'] : $active_title; + $options = $prefix; + $active_title = array_key_exists('active_title', $options) ? $options['active_title'] : $active_title; $inactive_title = array_key_exists('inactive_title', $options) ? $options['inactive_title'] : $inactive_title; - $tip = array_key_exists('tip', $options) ? $options['tip'] : $tip; - $active_class = array_key_exists('active_class', $options) ? $options['active_class'] : $active_class; + $tip = array_key_exists('tip', $options) ? $options['tip'] : $tip; + $active_class = array_key_exists('active_class', $options) ? $options['active_class'] : $active_class; $inactive_class = array_key_exists('inactive_class', $options) ? $options['inactive_class'] : $inactive_class; - $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; - $translate = array_key_exists('translate', $options) ? $options['translate'] : $translate; - $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; - $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; + $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; + $translate = array_key_exists('translate', $options) ? $options['translate'] : $translate; + $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; + $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } if ($tip) @@ -98,17 +98,17 @@ public static function action($i, $task, $prefix = '', $text = '', $active_title /** * Returns a state on a grid * - * @param array $states array of value/state. Each state is an array of the form + * @param array $states array of value/state. Each state is an array of the form * (task, text, title,html active class, HTML inactive class) * or ('task'=>task, 'text'=>text, 'active_title'=>active title, * 'inactive_title'=>inactive title, 'tip'=>boolean, 'active_class'=>html active class, * 'inactive_class'=>html inactive class) - * @param integer $value The state value. - * @param integer $i The row index - * @param string|array $prefix An optional task prefix or an array of options - * @param boolean $enabled An optional setting for access control on the action. - * @param boolean $translate An optional setting for translation. - * @param string $checkbox An optional prefix for checkboxes. + * @param integer $value The state value. + * @param integer $i The row index + * @param string|array $prefix An optional task prefix or an array of options + * @param boolean $enabled An optional setting for access control on the action. + * @param boolean $translate An optional setting for translation. + * @param string $checkbox An optional prefix for checkboxes. * * @return string The HTML markup * @@ -118,19 +118,19 @@ public static function state($states, $value, $i, $prefix = '', $enabled = true, { if (is_array($prefix)) { - $options = $prefix; - $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; + $options = $prefix; + $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $translate = array_key_exists('translate', $options) ? $options['translate'] : $translate; - $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; - $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; + $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; + $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } - $state = JArrayHelper::getValue($states, (int) $value, $states[0]); - $task = array_key_exists('task', $state) ? $state['task'] : $state[0]; - $text = array_key_exists('text', $state) ? $state['text'] : (array_key_exists(1, $state) ? $state[1] : ''); - $active_title = array_key_exists('active_title', $state) ? $state['active_title'] : (array_key_exists(2, $state) ? $state[2] : ''); + $state = JArrayHelper::getValue($states, (int) $value, $states[0]); + $task = array_key_exists('task', $state) ? $state['task'] : $state[0]; + $text = array_key_exists('text', $state) ? $state['text'] : (array_key_exists(1, $state) ? $state[1] : ''); + $active_title = array_key_exists('active_title', $state) ? $state['active_title'] : (array_key_exists(2, $state) ? $state[2] : ''); $inactive_title = array_key_exists('inactive_title', $state) ? $state['inactive_title'] : (array_key_exists(3, $state) ? $state[3] : ''); - $tip = array_key_exists('tip', $state) ? $state['tip'] : (array_key_exists(4, $state) ? $state[4] : false); - $active_class = array_key_exists('active_class', $state) ? $state['active_class'] : (array_key_exists(5, $state) ? $state[5] : ''); + $tip = array_key_exists('tip', $state) ? $state['tip'] : (array_key_exists(4, $state) ? $state[4] : false); + $active_class = array_key_exists('active_class', $state) ? $state['active_class'] : (array_key_exists(5, $state) ? $state[5] : ''); $inactive_class = array_key_exists('inactive_class', $state) ? $state['inactive_class'] : (array_key_exists(6, $state) ? $state[6] : ''); return static::action( @@ -142,13 +142,13 @@ public static function state($states, $value, $i, $prefix = '', $enabled = true, /** * Returns a published state on a grid * - * @param integer $value The state value. - * @param integer $i The row index - * @param string|array $prefix An optional task prefix or an array of options - * @param boolean $enabled An optional setting for access control on the action. - * @param string $checkbox An optional prefix for checkboxes. - * @param string $publish_up An optional start publishing date. - * @param string $publish_down An optional finish publishing date. + * @param integer $value The state value. + * @param integer $i The row index + * @param string|array $prefix An optional task prefix or an array of options + * @param boolean $enabled An optional setting for access control on the action. + * @param string $checkbox An optional prefix for checkboxes. + * @param string $publish_up An optional start publishing date. + * @param string $publish_down An optional finish publishing date. * * @return string The HTML markup * @@ -159,26 +159,26 @@ public static function published($value, $i, $prefix = '', $enabled = true, $che { if (is_array($prefix)) { - $options = $prefix; - $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; + $options = $prefix; + $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; - $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; + $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } - $states = array(1 => array('unpublish', 'JPUBLISHED', 'JLIB_HTML_UNPUBLISH_ITEM', 'JPUBLISHED', true, 'publish', 'publish'), - 0 => array('publish', 'JUNPUBLISHED', 'JLIB_HTML_PUBLISH_ITEM', 'JUNPUBLISHED', true, 'unpublish', 'unpublish'), - 2 => array('unpublish', 'JARCHIVED', 'JLIB_HTML_UNPUBLISH_ITEM', 'JARCHIVED', true, 'archive', 'archive'), - -2 => array('publish', 'JTRASHED', 'JLIB_HTML_PUBLISH_ITEM', 'JTRASHED', true, 'trash', 'trash')); + $states = array(1 => array('unpublish', 'JPUBLISHED', 'JLIB_HTML_UNPUBLISH_ITEM', 'JPUBLISHED', true, 'publish', 'publish'), + 0 => array('publish', 'JUNPUBLISHED', 'JLIB_HTML_PUBLISH_ITEM', 'JUNPUBLISHED', true, 'unpublish', 'unpublish'), + 2 => array('unpublish', 'JARCHIVED', 'JLIB_HTML_UNPUBLISH_ITEM', 'JARCHIVED', true, 'archive', 'archive'), + -2 => array('publish', 'JTRASHED', 'JLIB_HTML_PUBLISH_ITEM', 'JTRASHED', true, 'trash', 'trash')); // Special state for dates if ($publish_up || $publish_down) { $nullDate = JFactory::getDbo()->getNullDate(); - $nowDate = JFactory::getDate()->toUnix(); + $nowDate = JFactory::getDate()->toUnix(); $tz = new DateTimeZone(JFactory::getUser()->getParam('timezone', JFactory::getConfig()->get('offset'))); - $publish_up = ($publish_up != $nullDate) ? JFactory::getDate($publish_up, 'UTC')->setTimeZone($tz) : false; + $publish_up = ($publish_up != $nullDate) ? JFactory::getDate($publish_up, 'UTC')->setTimeZone($tz) : false; $publish_down = ($publish_down != $nullDate) ? JFactory::getDate($publish_down, 'UTC')->setTimeZone($tz) : false; // Create tip text, only we have publish up or down settings @@ -236,11 +236,11 @@ public static function published($value, $i, $prefix = '', $enabled = true, $che /** * Returns a isDefault state on a grid * - * @param integer $value The state value. - * @param integer $i The row index - * @param string|array $prefix An optional task prefix or an array of options - * @param boolean $enabled An optional setting for access control on the action. - * @param string $checkbox An optional prefix for checkboxes. + * @param integer $value The state value. + * @param integer $i The row index + * @param string|array $prefix An optional task prefix or an array of options + * @param boolean $enabled An optional setting for access control on the action. + * @param string $checkbox An optional prefix for checkboxes. * * @return string The HTML markup * @@ -251,10 +251,10 @@ public static function isdefault($value, $i, $prefix = '', $enabled = true, $che { if (is_array($prefix)) { - $options = $prefix; - $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; + $options = $prefix; + $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; - $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; + $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } $states = array( @@ -268,7 +268,7 @@ public static function isdefault($value, $i, $prefix = '', $enabled = true, $che /** * Returns an array of standard published state filter options. * - * @param array $config An array of configuration options. + * @param array $config An array of configuration options. * This array can contain a list of key/value pairs where values are boolean * and keys can be taken from 'published', 'unpublished', 'archived', 'trash', 'all'. * These pairs determine which values are displayed. @@ -313,12 +313,12 @@ public static function publishedOptions($config = array()) /** * Returns a checked-out icon * - * @param integer $i The row index. - * @param string $editorName The name of the editor. - * @param string $time The time that the object was checked out. - * @param string|array $prefix An optional task prefix or an array of options - * @param boolean $enabled True to enable the action. - * @param string $checkbox An optional prefix for checkboxes. + * @param integer $i The row index. + * @param string $editorName The name of the editor. + * @param string $time The time that the object was checked out. + * @param string|array $prefix An optional task prefix or an array of options + * @param boolean $enabled True to enable the action. + * @param string $checkbox An optional prefix for checkboxes. * * @return string The HTML markup * @@ -330,14 +330,14 @@ public static function checkedout($i, $editorName, $time, $prefix = '', $enabled if (is_array($prefix)) { - $options = $prefix; - $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; + $options = $prefix; + $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; - $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; + $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } - $text = $editorName . '
    ' . JHtml::_('date', $time, JText::_('DATE_FORMAT_LC')) . '
    ' . JHtml::_('date', $time, 'H:i'); - $active_title = JHtml::tooltipText(JText::_('JLIB_HTML_CHECKIN'), $text, 0); + $text = $editorName . '
    ' . JHtml::_('date', $time, JText::_('DATE_FORMAT_LC')) . '
    ' . JHtml::_('date', $time, 'H:i'); + $active_title = JHtml::tooltipText(JText::_('JLIB_HTML_CHECKIN'), $text, 0); $inactive_title = JHtml::tooltipText(JText::_('JLIB_HTML_CHECKED_OUT'), $text, 0); return static::action( @@ -349,12 +349,12 @@ public static function checkedout($i, $editorName, $time, $prefix = '', $enabled /** * Creates a order-up action icon. * - * @param integer $i The row index. - * @param string $task An optional task to fire. - * @param string|array $prefix An optional task prefix or an array of options - * @param string $text An optional text to display - * @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 string $task An optional task to fire. + * @param string|array $prefix An optional task prefix or an array of options + * @param string $text An optional text to display + * @param boolean $enabled An optional setting for access control on the action. + * @param string $checkbox An optional prefix for checkboxes. * * @return string The HTML markup * @@ -364,24 +364,25 @@ public static function orderUp($i, $task = 'orderup', $prefix = '', $text = 'JLI { if (is_array($prefix)) { - $options = $prefix; - $text = array_key_exists('text', $options) ? $options['text'] : $text; - $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; + $options = $prefix; + $text = array_key_exists('text', $options) ? $options['text'] : $text; + $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; - $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; + $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } + return static::action($i, $task, $prefix, $text, $text, $text, false, 'uparrow', 'uparrow_disabled', $enabled, true, $checkbox); } /** * Creates a order-down action icon. * - * @param integer $i The row index. - * @param string $task An optional task to fire. - * @param string|array $prefix An optional task prefix or an array of options - * @param string $text An optional text to display - * @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 string $task An optional task to fire. + * @param string|array $prefix An optional task prefix or an array of options + * @param string $text An optional text to display + * @param boolean $enabled An optional setting for access control on the action. + * @param string $checkbox An optional prefix for checkboxes. * * @return string The HTML markup * @@ -391,11 +392,11 @@ public static function orderDown($i, $task = 'orderdown', $prefix = '', $text = { if (is_array($prefix)) { - $options = $prefix; - $text = array_key_exists('text', $options) ? $options['text'] : $text; - $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; + $options = $prefix; + $text = array_key_exists('text', $options) ? $options['text'] : $text; + $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; - $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; + $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } return static::action($i, $task, $prefix, $text, $text, $text, false, 'downarrow', 'downarrow_disabled', $enabled, true, $checkbox); diff --git a/libraries/cms/html/jquery.php b/libraries/cms/html/jquery.php index e7db4eec37885..77f0f8a658afe 100644 --- a/libraries/cms/html/jquery.php +++ b/libraries/cms/html/jquery.php @@ -29,8 +29,8 @@ abstract class JHtmlJquery * * If debugging mode is on an uncompressed version of jQuery is included for easier debugging. * - * @param boolean $noConflict True to load jQuery in noConflict mode [optional] - * @param mixed $debug Is debugging mode on? [optional] + * @param boolean $noConflict True to load jQuery in noConflict mode [optional] + * @param mixed $debug Is debugging mode on? [optional] * * @return void * @@ -69,8 +69,8 @@ public static function framework($noConflict = true, $debug = null) * * If debugging mode is on an uncompressed version of jQuery UI is included for easier debugging. * - * @param array $components The jQuery UI components to load [optional] - * @param mixed $debug Is debugging mode on? [optional] + * @param array $components The jQuery UI components to load [optional] + * @param mixed $debug Is debugging mode on? [optional] * * @return void * diff --git a/libraries/cms/html/language/en-GB/en-GB.jhtmldate.ini b/libraries/cms/html/language/en-GB/en-GB.jhtmldate.ini index 639f05d4ea1d1..f5c9a3c9e116a 100644 --- a/libraries/cms/html/language/en-GB/en-GB.jhtmldate.ini +++ b/libraries/cms/html/language/en-GB/en-GB.jhtmldate.ini @@ -3,16 +3,16 @@ ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php ; Note : All ini files need to be saved as UTF-8 - No BOM -JLIB_HTML_DATE_RELATIVE_DAYS="%s days ago" -JLIB_HTML_DATE_RELATIVE_DAYS_1="%s day ago" -JLIB_HTML_DATE_RELATIVE_DAYS_0="%s days ago" -JLIB_HTML_DATE_RELATIVE_HOURS="%s hours ago" -JLIB_HTML_DATE_RELATIVE_HOURS_1="%s hour ago" -JLIB_HTML_DATE_RELATIVE_HOURS_0="%s hours ago" -JLIB_HTML_DATE_RELATIVE_LESSTHANAMINUTE="Less than a minute ago" -JLIB_HTML_DATE_RELATIVE_MINUTES="%s minutes ago" -JLIB_HTML_DATE_RELATIVE_MINUTES_1="%s minute ago" -JLIB_HTML_DATE_RELATIVE_MINUTES_0="%s minutes ago" -JLIB_HTML_DATE_RELATIVE_WEEKS="%s weeks ago" -JLIB_HTML_DATE_RELATIVE_WEEKS_1="%s week ago" -JLIB_HTML_DATE_RELATIVE_WEEKS_0="%s weeks ago" +JLIB_HTML_DATE_RELATIVE_DAYS = "%s days ago" +JLIB_HTML_DATE_RELATIVE_DAYS_1 = "%s day ago" +JLIB_HTML_DATE_RELATIVE_DAYS_0 = "%s days ago" +JLIB_HTML_DATE_RELATIVE_HOURS = "%s hours ago" +JLIB_HTML_DATE_RELATIVE_HOURS_1 = "%s hour ago" +JLIB_HTML_DATE_RELATIVE_HOURS_0 = "%s hours ago" +JLIB_HTML_DATE_RELATIVE_LESSTHANAMINUTE = "Less than a minute ago" +JLIB_HTML_DATE_RELATIVE_MINUTES = "%s minutes ago" +JLIB_HTML_DATE_RELATIVE_MINUTES_1 = "%s minute ago" +JLIB_HTML_DATE_RELATIVE_MINUTES_0 = "%s minutes ago" +JLIB_HTML_DATE_RELATIVE_WEEKS = "%s weeks ago" +JLIB_HTML_DATE_RELATIVE_WEEKS_1 = "%s week ago" +JLIB_HTML_DATE_RELATIVE_WEEKS_0 = "%s weeks ago" diff --git a/libraries/cms/html/list.php b/libraries/cms/html/list.php index a617e826f25b1..c4521945adb89 100644 --- a/libraries/cms/html/list.php +++ b/libraries/cms/html/list.php @@ -21,11 +21,11 @@ abstract class JHtmlList /** * Build the select list to choose an image * - * @param string $name The name of the field - * @param string $active The selected item - * @param string $javascript Alternative javascript - * @param string $directory Directory the images are stored in - * @param string $extensions Allowed extensions + * @param string $name The name of the field + * @param string $active The selected item + * @param string $javascript Alternative javascript + * @param string $directory Directory the images are stored in + * @param string $extensions Allowed extensions * * @return array Image names * @@ -46,7 +46,7 @@ public static function images($name, $active = null, $javascript = null, $direct } $imageFiles = new DirectoryIterator(JPATH_SITE . '/' . $directory); - $images = array(JHtml::_('select.option', '', JText::_('JOPTION_SELECT_IMAGE'))); + $images = array(JHtml::_('select.option', '', JText::_('JOPTION_SELECT_IMAGE'))); foreach ($imageFiles as $file) { @@ -68,7 +68,7 @@ public static function images($name, $active = null, $javascript = null, $direct $images, $name, array( - 'list.attr' => 'class="inputbox" size="1" ' . $javascript, + 'list.attr' => 'class="inputbox" size="1" ' . $javascript, 'list.select' => $active ) ); @@ -79,8 +79,8 @@ public static function images($name, $active = null, $javascript = null, $direct /** * Returns an array of options * - * @param string $query SQL with 'ordering' AS value and 'name field' AS text - * @param integer $chop The length of the truncated headline + * @param string $query SQL with 'ordering' AS value and 'name field' AS text + * @param integer $chop The length of the truncated headline * * @return array An array of objects formatted for JHtml list processing * @@ -88,7 +88,7 @@ public static function images($name, $active = null, $javascript = null, $direct */ public static function genericordering($query, $chop = 30) { - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $options = array(); $db->setQuery($query); @@ -127,11 +127,11 @@ public static function genericordering($query, $chop = 30) /** * Build the select list for Ordering derived from a query * - * @param integer $name The scalar value - * @param string $query The query - * @param string $attribs HTML tag attributes - * @param string $selected The selected item - * @param integer $neworder 1 if new and first, -1 if new and last, 0 or null if existing item + * @param integer $name The scalar value + * @param string $query The query + * @param string $attribs HTML tag attributes + * @param string $selected The selected item + * @param integer $neworder 1 if new and first, -1 if new and last, 0 or null if existing item * * @return string HTML markup for the select list * @@ -147,7 +147,7 @@ public static function ordering($name, $query, $attribs = null, $selected = null if (empty($neworder)) { $orders = JHtml::_('list.genericordering', $query); - $html = JHtml::_('select.genericlist', $orders, $name, array('list.attr' => $attribs, 'list.select' => (int) $selected)); + $html = JHtml::_('select.genericlist', $orders, $name, array('list.attr' => $attribs, 'list.select' => (int) $selected)); } else { @@ -169,11 +169,11 @@ public static function ordering($name, $query, $attribs = null, $selected = null /** * Select list of active users * - * @param string $name The name of the field - * @param string $active The active user - * @param integer $nouser If set include an option to select no user - * @param string $javascript Custom javascript - * @param string $order Specify a field to order by + * @param string $name The name of the field + * @param string $active The active user + * @param integer $nouser If set include an option to select no user + * @param string $javascript Custom javascript + * @param string $order Specify a field to order by * * @return string The HTML for a list of users list of users * @@ -181,7 +181,7 @@ public static function ordering($name, $query, $attribs = null, $selected = null */ public static function users($name, $active, $nouser = 0, $javascript = null, $order = 'name') { - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('u.id AS value, u.name AS text') ->from('#__users AS u') @@ -194,7 +194,7 @@ public static function users($name, $active, $nouser = 0, $javascript = null, $o if ($nouser) { $users[] = JHtml::_('select.option', '0', JText::_('JOPTION_NO_USER')); - $users = array_merge($users, $db->loadObjectList()); + $users = array_merge($users, $db->loadObjectList()); } else { @@ -206,7 +206,7 @@ public static function users($name, $active, $nouser = 0, $javascript = null, $o $users, $name, array( - 'list.attr' => 'class="inputbox" size="1" ' . $javascript, + 'list.attr' => 'class="inputbox" size="1" ' . $javascript, 'list.select' => $active ) ); @@ -217,21 +217,21 @@ public static function users($name, $active, $nouser = 0, $javascript = null, $o /** * Select list of positions - generally used for location of images * - * @param string $name Name of the field - * @param string $active The active value - * @param string $javascript Alternative javascript - * @param boolean $none Null if not assigned - * @param boolean $center Null if not assigned - * @param boolean $left Null if not assigned - * @param boolean $right Null if not assigned - * @param boolean $id Null if not assigned + * @param string $name Name of the field + * @param string $active The active value + * @param string $javascript Alternative javascript + * @param boolean $none Null if not assigned + * @param boolean $center Null if not assigned + * @param boolean $left Null if not assigned + * @param boolean $right Null if not assigned + * @param boolean $id Null if not assigned * * @return array The positions * * @since 1.5 */ public static function positions($name, $active = null, $javascript = null, $none = true, $center = true, $left = true, $right = true, - $id = false) + $id = false) { $pos = array(); @@ -258,10 +258,10 @@ public static function positions($name, $active = null, $javascript = null, $non $positions = JHtml::_( 'select.genericlist', $pos, $name, array( - 'id' => $id, - 'list.attr' => 'class="inputbox" size="1"' . $javascript, + 'id' => $id, + 'list.attr' => 'class="inputbox" size="1"' . $javascript, 'list.select' => $active, - 'option.key' => null, + 'option.key' => null, ) ); diff --git a/libraries/cms/html/menu.php b/libraries/cms/html/menu.php index 11613d1a54bc5..b26ecd33fc14d 100644 --- a/libraries/cms/html/menu.php +++ b/libraries/cms/html/menu.php @@ -45,7 +45,7 @@ public static function menus() { if (empty(static::$menus)) { - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('menutype AS value, title AS text') ->from($db->quoteName('#__menu_types')) @@ -60,7 +60,7 @@ public static function menus() /** * Returns an array of menu items grouped by menu. * - * @param array $config An array of configuration options. + * @param array $config An array of configuration options. * * @return array * @@ -72,7 +72,7 @@ public static function menuitems($config = array()) { $menus = static::menus(); - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('a.id AS value, a.title AS text, a.level, a.menutype') ->from('#__menu AS a') @@ -108,7 +108,7 @@ public static function menuitems($config = array()) $lookup[$item->menutype] = array(); } - $lookup[$item->menutype][] = &$item; + $lookup[$item->menutype][] = & $item; $item->text = str_repeat('- ', $item->level) . $item->text; } @@ -143,10 +143,10 @@ public static function menuitems($config = array()) /** * Displays an HTML select list of menu items. * - * @param string $name The name of the control. - * @param string $selected The value of the selected option. - * @param string $attribs Attributes for the control. - * @param array $config An array of options for the control. + * @param string $name The name of the control. + * @param string $selected The value of the selected option. + * @param string $attribs Attributes for the control. + * @param array $config An array of options for the control. * * @return string * @@ -161,9 +161,9 @@ public static function menuitemlist($name, $selected = null, $attribs = null, $c return JHtml::_( 'select.genericlist', $options, $name, array( - 'id' => isset($config['id']) ? $config['id'] : 'assetgroups_' . (++$count), - 'list.attr' => (is_null($attribs) ? 'class="inputbox" size="1"' : $attribs), - 'list.select' => (int) $selected, + 'id' => isset($config['id']) ? $config['id'] : 'assetgroups_' . (++$count), + 'list.attr' => (is_null($attribs) ? 'class="inputbox" size="1"' : $attribs), + 'list.select' => (int) $selected, 'list.translate' => false ) ); @@ -172,8 +172,8 @@ public static function menuitemlist($name, $selected = null, $attribs = null, $c /** * Build the select list for Menu Ordering * - * @param object &$row The row object - * @param integer $id The id for the row. Must exist to enable menu ordering + * @param object &$row The row object + * @param integer $id The id for the row. Must exist to enable menu ordering * * @return string * @@ -183,15 +183,15 @@ public static function ordering(&$row, $id) { if ($id) { - $db = JFactory::getDbo(); - $query = $db->getQuery(true) + $db = JFactory::getDbo(); + $query = $db->getQuery(true) ->select('ordering AS value, title AS text') ->from($db->quoteName('#__menu')) ->where($db->quoteName('menutype') . ' = ' . $db->quote($row->menutype)) ->where($db->quoteName('parent_id') . ' = ' . (int) $row->parent_id) ->where($db->quoteName('published') . ' != -2') ->order('ordering'); - $order = JHtml::_('list.genericordering', $query); + $order = JHtml::_('list.genericordering', $query); $ordering = JHtml::_( 'select.genericlist', $order, 'ordering', array('list.attr' => 'class="inputbox" size="1"', 'list.select' => (int) $row->ordering) @@ -208,8 +208,8 @@ public static function ordering(&$row, $id) /** * Build the multiple select list for Menu Links/Pages * - * @param boolean $all True if all can be selected - * @param boolean $unassigned True if unassigned can be selected + * @param boolean $all True if all can be selected + * @param boolean $unassigned True if unassigned can be selected * * @return string * @@ -240,7 +240,7 @@ public static function linkoptions($all = false, $unassigned = false) // First pass - collect children foreach ($mitems as $v) { - $pt = $v->parent_id; + $pt = $v->parent_id; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; @@ -270,7 +270,7 @@ public static function linkoptions($all = false, $unassigned = false) } $lastMenuType = null; - $tmpMenuType = null; + $tmpMenuType = null; foreach ($list as $list_a) { @@ -281,9 +281,9 @@ public static function linkoptions($all = false, $unassigned = false) $mitems[] = JHtml::_('select.option', ''); } - $mitems[] = JHtml::_('select.option', '', $list_a->menutype); + $mitems[] = JHtml::_('select.option', '', $list_a->menutype); $lastMenuType = $list_a->menutype; - $tmpMenuType = $list_a->menutype; + $tmpMenuType = $list_a->menutype; } $mitems[] = JHtml::_('select.option', $list_a->id, $list_a->title); @@ -300,13 +300,13 @@ public static function linkoptions($all = false, $unassigned = false) /** * Build the list representing the menu tree * - * @param integer $id Id of the menu item - * @param string $indent The indentation string - * @param array $list The list to process - * @param array &$children The children of the current item - * @param integer $maxlevel The maximum number of levels in the tree - * @param integer $level The starting level - * @param string $type Type of link: component, URL, alias, separator + * @param integer $id Id of the menu item + * @param string $indent The indentation string + * @param array $list The list to process + * @param array &$children The children of the current item + * @param integer $maxlevel The maximum number of levels in the tree + * @param integer $level The starting level + * @param string $type Type of link: component, URL, alias, separator * * @return array * @@ -322,12 +322,12 @@ public static function treerecurse($id, $indent, $list, &$children, $maxlevel = if ($type) { - $pre = '|_ '; + $pre = '|_ '; $spacer = '.      '; } else { - $pre = '- '; + $pre = '- '; $spacer = '  '; } @@ -340,10 +340,10 @@ public static function treerecurse($id, $indent, $list, &$children, $maxlevel = $txt = $pre . $v->title; } - $list[$id] = $v; + $list[$id] = $v; $list[$id]->treename = $indent . $txt; $list[$id]->children = count(@$children[$id]); - $list = static::treerecurse($id, $indent . $spacer, $list, $children, $maxlevel, $level + 1, $type); + $list = static::treerecurse($id, $indent . $spacer, $list, $children, $maxlevel, $level + 1, $type); } } diff --git a/libraries/cms/html/number.php b/libraries/cms/html/number.php index 75d5027980a34..4881da6f55c39 100644 --- a/libraries/cms/html/number.php +++ b/libraries/cms/html/number.php @@ -25,9 +25,9 @@ abstract class JHtmlNumber * By default, the proper format will automatically be chosen. * However, one of the allowed unit types may also be used instead. * - * @param integer $bytes The number of bytes. - * @param string $unit The type of unit to return. - * @param integer $precision The number of digits to be used after the decimal place. + * @param integer $bytes The number of bytes. + * @param string $unit The type of unit to return. + * @param integer $precision The number of digits to be used after the decimal place. * * @return string The number of bytes in the proper units. * diff --git a/libraries/cms/html/rules.php b/libraries/cms/html/rules.php index c7f620f310635..185cb9ec0b94e 100644 --- a/libraries/cms/html/rules.php +++ b/libraries/cms/html/rules.php @@ -21,11 +21,11 @@ abstract class JHtmlRules /** * Creates the HTML for the permissions widget * - * @param array $actions Array of action objects - * @param integer $assetId Id of a specific asset to create a widget for. - * @param integer $parent Id of the parent of the asset - * @param string $control The form control - * @param string $idPrefix Prefix for the ids assigned to specific action-group pairs + * @param array $actions Array of action objects + * @param integer $assetId Id of a specific asset to create a widget for. + * @param integer $parent Id of the parent of the asset + * @param string $control The form control + * @param string $idPrefix Prefix for the ids assigned to specific action-group pairs * * @return string HTML for the permissions widget * @@ -42,8 +42,8 @@ public static function assetFormWidget($actions, $assetId = null, $parent = null // Get the incoming inherited rules as well as the asset specific rules. $inheriting = JAccess::getAssetRules($parent ? $parent : static::_getParentAssetId($assetId), true); - $inherited = JAccess::getAssetRules($assetId, true); - $rules = JAccess::getAssetRules($assetId); + $inherited = JAccess::getAssetRules($assetId, true); + $rules = JAccess::getAssetRules($assetId); $html = array(); @@ -71,7 +71,7 @@ public static function assetFormWidget($actions, $assetId = null, $parent = null { $html[] = ' ' . ($assetId ? ($inherited->allow($action->name, $group->identities) ? $images['allow'] : $images['deny']) - : ($inheriting->allow($action->name, $group->identities) ? $images['allow'] : $images['deny'])) . ''; + : ($inheriting->allow($action->name, $group->identities) ? $images['allow'] : $images['deny'])) . ''; } $html[] = ' '; } @@ -81,18 +81,18 @@ public static function assetFormWidget($actions, $assetId = null, $parent = null foreach ($actions as $action) { $actionTitle = JText::_($action->title); - $actionDesc = JText::_($action->description); - $html[] = JHtml::_('tabs.panel', $actionTitle, $action->name); - $html[] = '

    ' . $actionDesc . '

    '; - $html[] = ' '; - $html[] = '
    ' . JText::_('JLIB_HTML_ACCESS_MODIFY_DESC_CAPTION_ACL') . ' ' . $actionTitle . ' ' + $actionDesc = JText::_($action->description); + $html[] = JHtml::_('tabs.panel', $actionTitle, $action->name); + $html[] = '

    ' . $actionDesc . '

    '; + $html[] = ' '; + $html[] = ' '; - $html[] = ' '; - $html[] = ' '; - $html[] = ' '; - $html[] = ' '; - $html[] = ' '; - $html[] = ' '; + $html[] = ' '; + $html[] = ' '; + $html[] = ' '; + $html[] = ' '; + $html[] = ' '; + $html[] = ' '; foreach ($groups as $i => $group) { @@ -116,7 +116,7 @@ public static function assetFormWidget($actions, $assetId = null, $parent = null $html[] = ' '; $html[] = ' '; + : ($inheriting->allow($action->name, $group->identities) ? $images['allow'] : $images['deny'])) . ''; $html[] = ' '; } @@ -139,7 +139,7 @@ public static function assetFormWidget($actions, $assetId = null, $parent = null /** * Get the id of the parent asset * - * @param integer $assetId The asset for which the parentid will be returned + * @param integer $assetId The asset for which the parentid will be returned * * @return integer The id of the parent asset * @@ -148,7 +148,7 @@ public static function assetFormWidget($actions, $assetId = null, $parent = null protected static function _getParentAssetId($assetId) { // Get a database object. - $db = JFactory::getDbo(); + $db = JFactory::getDbo(); $query = $db->getQuery(true); // Get the user groups from the database. @@ -178,7 +178,7 @@ protected static function _getUserGroups() . ' FROM #__usergroups AS a LEFT JOIN #__usergroups AS b ON a.lft >= b.lft AND a.rgt <= b.rgt' . ' ORDER BY a.lft ASC, b.lft ASC' ); - $result = $db->loadObjectList(); + $result = $db->loadObjectList(); $options = array(); // Pre-compute additional values. @@ -188,9 +188,9 @@ protected static function _getUserGroups() if ($end === false || $end->value != $option->value) { - $end = $option; + $end = $option; $end->level = 0; - $options[] = $end; + $options[] = $end; } else { @@ -214,11 +214,11 @@ protected static function _getImagesArray() { $images['allow-l'] = ''; - $images['deny-l'] = ''; - $images['allow'] = ' '; - $images['deny'] = ' '; + $images['deny-l'] = ''; + $images['allow'] = ' '; + $images['deny'] = ' '; $images['allow-i'] = ' '; - $images['deny-i'] = ' '; + $images['deny-i'] = ' '; return $images; } diff --git a/libraries/cms/html/select.php b/libraries/cms/html/select.php index 3d1df1ee169d9..60190beffdc75 100644 --- a/libraries/cms/html/select.php +++ b/libraries/cms/html/select.php @@ -25,19 +25,19 @@ abstract class JHtmlSelect * @since 1.5 */ static protected $optionDefaults = array( - 'option' => array('option.attr' => null, 'option.disable' => 'disable', 'option.id' => null, 'option.key' => 'value', - 'option.key.toHtml' => true, 'option.label' => null, 'option.label.toHtml' => true, 'option.text' => 'text', - 'option.text.toHtml' => true)); + 'option' => array('option.attr' => null, 'option.disable' => 'disable', 'option.id' => null, 'option.key' => 'value', + 'option.key.toHtml' => true, 'option.label' => null, 'option.label.toHtml' => true, 'option.text' => 'text', + 'option.text.toHtml' => true)); /** * Generates a yes/no radio list. * - * @param string $name The value of the HTML name attribute - * @param array $attribs Additional HTML attributes for the tag + * @param string $selected The key that is selected + * @param string $yes Language key for Yes + * @param string $no Language key for no + * @param string $id The id for the field * * @return string HTML for the radio list * @@ -54,9 +54,9 @@ public static function booleanlist($name, $attribs = array(), $selected = null, /** * Generates an HTML selection list. * - * @param array $data An array of objects, arrays, or scalars. - * @param string $name The value of the HTML name attribute. - * @param mixed $attribs Additional HTML attributes for the tag. This * can be an array of attributes, or an array of options. Treated as options * if it is the last argument passed. Valid options are: * Format options, see {@see JHtml::$formatOptions}. @@ -67,19 +67,19 @@ public static function booleanlist($name, $attribs = array(), $selected = null, * Defaults to the same as the name. * list.select, string|array: Identifies one or more option elements * to be selected, based on the option key values. - * @param string $optKey The name of the object variable for the option value. If + * @param string $optKey The name of the object variable for the option value. If * set to null, the index of the value array is used. - * @param string $optText The name of the object variable for the option text. - * @param mixed $selected The key that is selected (accepts an array or a string). - * @param mixed $idtag Value of the field id or null by default - * @param boolean $translate True to translate + * @param string $optText The name of the object variable for the option text. + * @param mixed $selected The key that is selected (accepts an array or a string). + * @param mixed $idtag Value of the field id or null by default + * @param boolean $translate True to translate * * @return string HTML for the select list. * * @since 1.5 */ public static function genericlist($data, $name, $attribs = null, $optKey = 'value', $optText = 'text', $selected = null, $idtag = false, - $translate = false) + $translate = false) { // Set default options $options = array_merge(JHtml::$formatOptions, array('format.depth' => 0, 'id' => false)); @@ -92,12 +92,12 @@ public static function genericlist($data, $name, $attribs = null, $optKey = 'val else { // Get options from the parameters - $options['id'] = $idtag; - $options['list.attr'] = $attribs; + $options['id'] = $idtag; + $options['list.attr'] = $attribs; $options['list.translate'] = $translate; - $options['option.key'] = $optKey; - $options['option.text'] = $optText; - $options['list.select'] = $selected; + $options['option.key'] = $optKey; + $options['option.text'] = $optText; + $options['list.select'] = $selected; } $attribs = ''; @@ -123,7 +123,7 @@ public static function genericlist($data, $name, $attribs = null, $optKey = 'val $id = str_replace(array('[', ']'), '', $id); $baseIndent = str_repeat($options['format.indent'], $options['format.depth']++); - $html = $baseIndent . '' . $options['format.eol'] + $html = $baseIndent . '' . $options['format.eol'] . static::options($data, $options) . $baseIndent . '' . $options['format.eol']; return $html; @@ -132,9 +132,9 @@ public static function genericlist($data, $name, $attribs = null, $optKey = 'val /** * Generates a grouped HTML selection list from nested arrays. * - * @param array $data An array of groups, each of which is an array of options. - * @param string $name The value of the HTML name attribute - * @param array $options Options, an array of key/value pairs. Valid options are: + * @param array $data An array of groups, each of which is an array of options. + * @param string $name The value of the HTML name attribute + * @param array $options Options, an array of key/value pairs. Valid options are: * Format options, {@see JHtml::$formatOptions}. * Selection options. See {@see JHtmlSelect::options()}. * group.id: The property in each group to use as the group id @@ -200,14 +200,14 @@ public static function groupedlist($data, $name, $options = array()) // Disable groups in the options. $options['groups'] = false; - $baseIndent = str_repeat($options['format.indent'], $options['format.depth']++); - $html = $baseIndent . '' . $options['format.eol']; + $baseIndent = str_repeat($options['format.indent'], $options['format.depth']++); + $html = $baseIndent . '' . $options['format.eol']; $groupIndent = str_repeat($options['format.indent'], $options['format.depth']++); foreach ($data as $dataKey => $group) { - $label = $dataKey; - $id = ''; + $label = $dataKey; + $id = ''; $noGroup = is_int($dataKey); if ($options['group.items'] == null) @@ -222,13 +222,13 @@ public static function groupedlist($data, $name, $options = array()) if (isset($group[$options['group.label']])) { - $label = $group[$options['group.label']]; + $label = $group[$options['group.label']]; $noGroup = false; } if (isset($options['group.id']) && isset($group[$options['group.id']])) { - $id = $group[$options['group.id']]; + $id = $group[$options['group.id']]; $noGroup = false; } } @@ -239,13 +239,13 @@ public static function groupedlist($data, $name, $options = array()) if (isset($group->$options['group.label'])) { - $label = $group->$options['group.label']; + $label = $group->$options['group.label']; $noGroup = false; } if (isset($options['group.id']) && isset($group->$options['group.id'])) { - $id = $group->$options['group.id']; + $id = $group->$options['group.id']; $noGroup = false; } } @@ -274,15 +274,15 @@ public static function groupedlist($data, $name, $options = array()) /** * Generates a selection list of integers. * - * @param integer $start The start integer - * @param integer $end The end integer - * @param integer $inc The increment - * @param string $name The value of the HTML name attribute - * @param mixed $attribs Additional HTML attributes for the tag, an array of * attributes, or an array of options. Treated as options if it is the last * argument passed. - * @param mixed $selected The key that is selected - * @param string $format The printf format to be applied to the number + * @param mixed $selected The key that is selected + * @param string $format The printf format to be applied to the number * * @return string HTML for the select list * @@ -305,7 +305,7 @@ public static function integerlist($start, $end, $inc, $name, $attribs = null, $ else { // Get options from the parameters - $options['list.attr'] = $attribs; + $options['list.attr'] = $attribs; $options['list.select'] = $selected; } @@ -329,15 +329,15 @@ public static function integerlist($start, $end, $inc, $name, $attribs = null, $ /** * Create a placeholder for an option group. * - * @param string $text The text for the option - * @param string $optKey The returned object property name for the value - * @param string $optText The returned object property name for the text + * @param string $text The text for the option + * @param string $optKey The returned object property name for the value + * @param string $optText The returned object property name for the text * * @return object * * @deprecated 4.0 Use JHtmlSelect::groupedList() - * @see JHtmlSelect::groupedList() - * @since 1.5 + * @see JHtmlSelect::groupedList() + * @since 1.5 */ public static function optgroup($text, $optKey = 'value', $optText = 'text') { @@ -350,16 +350,16 @@ public static function optgroup($text, $optKey = 'value', $optText = 'text') switch ($state) { case 'open': - $obj = new stdClass; - $obj->$optKey = ''; + $obj = new stdClass; + $obj->$optKey = ''; $obj->$optText = $text; - $state = 'close'; + $state = 'close'; break; case 'close': - $obj = new stdClass; - $obj->$optKey = ''; + $obj = new stdClass; + $obj->$optKey = ''; $obj->$optText = $text; - $state = 'open'; + $state = 'open'; break; } @@ -369,9 +369,9 @@ public static function optgroup($text, $optKey = 'value', $optText = 'text') /** * Create an object that represents an option in an option list. * - * @param string $value The value of the option - * @param string $text The text for the option - * @param mixed $optKey If a string, the returned object property name for + * @param string $value The value of the option + * @param string $text The text for the option + * @param mixed $optKey If a string, the returned object property name for * the value. If an array, options. Valid options are: * attr: String|array. Additional attributes for this option. * Defaults to none. @@ -389,9 +389,9 @@ public static function optgroup($text, $optKey = 'value', $optText = 'text') * option.text: The property that will hold the the displayed text. * Defaults to "text". If set to null, the option array is assumed to be a * list of displayable scalars. - * @param string $optText The property that will hold the the displayed text. This + * @param string $optText The property that will hold the the displayed text. This * parameter is ignored if an options array is passed. - * @param boolean $disable Not used. + * @param boolean $disable Not used. * * @return object * @@ -399,8 +399,8 @@ public static function optgroup($text, $optKey = 'value', $optText = 'text') */ public static function option($value, $text = '', $optKey = 'value', $optText = 'text', $disable = false) { - $options = array('attr' => null, 'disable' => false, 'option.attr' => null, 'option.disable' => 'disable', 'option.key' => 'value', - 'option.label' => null, 'option.text' => 'text'); + $options = array('attr' => null, 'disable' => false, 'option.attr' => null, 'option.disable' => 'disable', 'option.key' => 'value', + 'option.label' => null, 'option.text' => 'text'); if (is_array($optKey)) { @@ -410,12 +410,12 @@ public static function option($value, $text = '', $optKey = 'value', $optText = else { // Get options from the parameters - $options['option.key'] = $optKey; + $options['option.key'] = $optKey; $options['option.text'] = $optText; - $options['disable'] = $disable; + $options['disable'] = $disable; } - $obj = new stdClass; - $obj->$options['option.key'] = $value; + $obj = new stdClass; + $obj->$options['option.key'] = $value; $obj->$options['option.text'] = trim($text) ? $text : $value; /* @@ -426,7 +426,7 @@ public static function option($value, $text = '', $optKey = 'value', $optText = if (isset($options['label'])) { - $labelProperty = $hasProperty ? $options['option.label'] : 'label'; + $labelProperty = $hasProperty ? $options['option.label'] : 'label'; $obj->$labelProperty = $options['label']; } elseif ($hasProperty) @@ -445,6 +445,7 @@ public static function option($value, $text = '', $optKey = 'value', $optText = { $obj->$options['option.disable'] = $options['disable']; } + return $obj; } @@ -452,40 +453,40 @@ public static function option($value, $text = '', $optKey = 'value', $optText = * Generates the option tags for an HTML select list (with no select tag * surrounding the options). * - * @param array $arr An array of objects, arrays, or values. - * @param mixed $optKey If a string, this is the name of the object variable for - * the option value. If null, the index of the array of objects is used. If - * an array, this is a set of options, as key/value pairs. Valid options are: - * -Format options, {@see JHtml::$formatOptions}. - * -groups: Boolean. If set, looks for keys with the value + * @param array $arr An array of objects, arrays, or values. + * @param mixed $optKey If a string, this is the name of the object variable for + * the option value. If null, the index of the array of objects is used. If + * an array, this is a set of options, as key/value pairs. Valid options are: + * -Format options, {@see JHtml::$formatOptions}. + * -groups: Boolean. If set, looks for keys with the value * "<optgroup>" and synthesizes groups from them. Deprecated. Defaults * true for backwards compatibility. - * -list.select: either the value of one selected option or an array + * -list.select: either the value of one selected option or an array * of selected options. Default: none. - * -list.translate: Boolean. If set, text and labels are translated via + * -list.translate: Boolean. If set, text and labels are translated via * JText::_(). Default is false. - * -option.id: The property in each option array to use as the + * -option.id: The property in each option array to use as the * selection id attribute. Defaults to none. - * -option.key: The property in each option array to use as the + * -option.key: The property in each option array to use as the * selection value. Defaults to "value". If set to null, the index of the * option array is used. - * -option.label: The property in each option array to use as the + * -option.label: The property in each option array to use as the * selection label attribute. Defaults to null (none). - * -option.text: The property in each option array to use as the - * displayed text. Defaults to "text". If set to null, the option array is - * assumed to be a list of displayable scalars. - * -option.attr: The property in each option array to use for + * -option.text: The property in each option array to use as the + * displayed text. Defaults to "text". If set to null, the option array is + * assumed to be a list of displayable scalars. + * -option.attr: The property in each option array to use for * additional selection attributes. Defaults to none. - * -option.disable: The property that will hold the disabled state. + * -option.disable: The property that will hold the disabled state. * Defaults to "disable". - * -option.key: The property that will hold the selection value. + * -option.key: The property that will hold the selection value. * Defaults to "value". - * -option.text: The property that will hold the the displayed text. - * Defaults to "text". If set to null, the option array is assumed to be a - * list of displayable scalars. - * @param string $optText The name of the object variable for the option text. - * @param mixed $selected The key that is selected (accepts an array or a string) - * @param boolean $translate Translate the option values. + * -option.text: The property that will hold the the displayed text. + * Defaults to "text". If set to null, the option array is assumed to be a + * list of displayable scalars. + * @param string $optText The name of the object variable for the option text. + * @param mixed $selected The key that is selected (accepts an array or a string) + * @param boolean $translate Translate the option values. * * @return string HTML for the select list * @@ -507,25 +508,25 @@ public static function options($arr, $optKey = 'value', $optText = 'text', $sele else { // Get options from the parameters - $options['option.key'] = $optKey; - $options['option.text'] = $optText; - $options['list.select'] = $selected; + $options['option.key'] = $optKey; + $options['option.text'] = $optText; + $options['list.select'] = $selected; $options['list.translate'] = $translate; } - $html = ''; + $html = ''; $baseIndent = str_repeat($options['format.indent'], $options['format.depth']); foreach ($arr as $elementKey => &$element) { - $attr = ''; + $attr = ''; $extra = ''; $label = ''; - $id = ''; + $id = ''; if (is_array($element)) { - $key = $options['option.key'] === null ? $elementKey : $element[$options['option.key']]; + $key = $options['option.key'] === null ? $elementKey : $element[$options['option.key']]; $text = $element[$options['option.text']]; if (isset($element[$options['option.attr']])) @@ -550,7 +551,7 @@ public static function options($arr, $optKey = 'value', $optText = 'text', $sele } elseif (is_object($element)) { - $key = $options['option.key'] === null ? $elementKey : $element->$options['option.key']; + $key = $options['option.key'] === null ? $elementKey : $element->$options['option.key']; $text = $element->$options['option.text']; if (isset($element->$options['option.attr'])) @@ -576,7 +577,7 @@ public static function options($arr, $optKey = 'value', $optText = 'text', $sele else { // This is a simple associative array - $key = $elementKey; + $key = $elementKey; $text = $element; } @@ -604,7 +605,7 @@ public static function options($arr, $optKey = 'value', $optText = 'text', $sele { // If no string after hyphen - take hyphen out $splitText = explode(' - ', $text, 2); - $text = $splitText[0]; + $text = $splitText[0]; if (isset($splitText[1])) { @@ -669,21 +670,21 @@ public static function options($arr, $optKey = 'value', $optText = 'text', $sele /** * Generates an HTML radio list. * - * @param array $data An array of objects - * @param string $name The value of the HTML name attribute - * @param string $attribs Additional HTML attributes for the tag + * @param mixed $optKey The key that is selected + * @param string $optText The name of the object variable for the option value + * @param string $selected The name of the object variable for the option text + * @param boolean $idtag Value of the field id or null by default + * @param boolean $translate True if options will be translated * * @return string HTML for the select list * * @since 1.5 */ public static function radiolist($data, $name, $attribs = null, $optKey = 'value', $optText = 'text', $selected = null, $idtag = false, - $translate = false) + $translate = false) { reset($data); @@ -698,8 +699,8 @@ public static function radiolist($data, $name, $attribs = null, $optKey = 'value foreach ($data as $obj) { - $k = $obj->$optKey; - $t = $translate ? JText::_($obj->$optText) : $obj->$optText; + $k = $obj->$optKey; + $t = $translate ? JText::_($obj->$optText) : $obj->$optText; $id = (isset($obj->id) ? $obj->id : null); $extra = ''; diff --git a/libraries/cms/html/sidebar.php b/libraries/cms/html/sidebar.php index 7550b335c96a0..553a33c03ae30 100644 --- a/libraries/cms/html/sidebar.php +++ b/libraries/cms/html/sidebar.php @@ -70,9 +70,9 @@ public static function render() /** * Method to add a menu item to submenu. * - * @param string $name Name of the menu item. - * @param string $link URL of the menu item. - * @param bool $active True if the item is active, false otherwise. + * @param string $name Name of the menu item. + * @param string $link URL of the menu item. + * @param bool $active True if the item is active, false otherwise. * * @return void * @@ -98,10 +98,10 @@ public static function getEntries() /** * Method to add a filter to the submenu * - * @param string $label Label for the menu item. - * @param string $name Name for the filter. Also used as id. - * @param string $options Options for the select field. - * @param bool $noDefault Don't the label as the empty option + * @param string $label Label for the menu item. + * @param string $name Name for the filter. Also used as id. + * @param string $options Options for the select field. + * @param bool $noDefault Don't the label as the empty option * * @return void * @@ -127,7 +127,7 @@ public static function getFilters() /** * Set value for the action attribute of the filter form * - * @param string $action Value for the action attribute of the form + * @param string $action Value for the action attribute of the form * * @return void * diff --git a/libraries/cms/html/sliders.php b/libraries/cms/html/sliders.php index c6768d9291360..b263d75f0ee18 100644 --- a/libraries/cms/html/sliders.php +++ b/libraries/cms/html/sliders.php @@ -21,8 +21,8 @@ abstract class JHtmlSliders /** * Creates a panes and loads the javascript behavior for it. * - * @param string $group The pane identifier. - * @param array $params An array of options. + * @param string $group The pane identifier. + * @param array $params An array of options. * * @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 panel * @@ -60,14 +60,14 @@ public static function end() public static function panel($text, $id) { return '

    ' . $text - . '

    '; + . '
    '; } /** * 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 @@ +
    ' . JText::_('JLIB_HTML_ACCESS_MODIFY_DESC_CAPTION_ACL') . ' ' . $actionTitle . ' ' . JText::_('JLIB_HTML_ACCESS_MODIFY_DESC_CAPTION_TABLE') . '
    ' . JText::_('JLIB_RULES_GROUP') . '' . JText::_('JLIB_RULES_INHERIT') . '' . JText::_('JMODIFY') . '' . JText::_('JCURRENT') . '
    ' . JText::_('JLIB_RULES_GROUP') . '' . JText::_('JLIB_RULES_INHERIT') . '' . JText::_('JMODIFY') . '' . JText::_('JCURRENT') . '
    ' . ($assetId ? ($inherited->allow($action->name, $group->identities) ? $images['allow'] : $images['deny']) - : ($inheriting->allow($action->name, $group->identities) ? $images['allow'] : $images['deny'])) . '