From 32aa2056a139a81eec0a8bd997437168c4fd9649 Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Wed, 15 Jul 2015 09:26:43 +0200 Subject: [PATCH 001/176] mod_article_news - remove columns specified multiple times #### Steps to reproduce the issue install test data and click on left menu item News Flash #### Expected result the module works as expected #### Actual result DB error on MSSQL ```The column 'fulltext' was specified multiple times``` #### System information MSSQL 2008 R2 10.50.4033 Apache 2.4.7 PHP 5.5.9 Joomla! 3.4.4-dev #### Additional comments the helper duplicate already selected fileds --- modules/mod_articles_news/helper.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/mod_articles_news/helper.php b/modules/mod_articles_news/helper.php index 3d1ad52c80b56..41a2422c97d1e 100644 --- a/modules/mod_articles_news/helper.php +++ b/modules/mod_articles_news/helper.php @@ -46,13 +46,8 @@ public static function getList(&$params) // Set the filters based on the module params $model->setState('list.start', 0); $model->setState('list.limit', (int) $params->get('count', 5)); - $model->setState('filter.published', 1); - $model->setState('list.select', 'a.fulltext, a.id, a.title, a.alias, a.introtext, a.state, a.catid, a.created, a.created_by, a.created_by_alias,' . - ' a.modified, a.modified_by, a.publish_up, a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access,' . - ' a.hits, a.featured, a.language'); - // Access filter $access = !JComponentHelper::getParams('com_content')->get('show_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); From f4e6e2a1f158f26b41ad9c428ab2f8874e048eda Mon Sep 17 00:00:00 2001 From: wilsonge Date: Wed, 8 Jul 2015 12:38:32 +0100 Subject: [PATCH 002/176] Add create table syntax for mysqli database importer --- libraries/joomla/database/importer/mysqli.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/libraries/joomla/database/importer/mysqli.php b/libraries/joomla/database/importer/mysqli.php index f51614d2f54ec..94cb072d5dc66 100644 --- a/libraries/joomla/database/importer/mysqli.php +++ b/libraries/joomla/database/importer/mysqli.php @@ -41,6 +41,49 @@ public function check() return $this; } + /** + * Get the SQL syntax to add a table. + * + * @param SimpleXMLElement $table The table information. + * + * @return string + * + * @since 11.1 + * @throws RuntimeException + */ + protected function xmlToCreate(SimpleXMLElement $table) + { + $existingTables = $this->db->getTableList(); + $tableName = (string) $table['name']; + + if (in_array($tableName, $existingTables)) + { + throw new RuntimeException('The table you are trying to create already exists'); + } + + $createTableStatement = 'CREATE TABLE ' . $this->db->quoteName($tableName) . ' ('; + + foreach ($table->xpath('field') as $field) + { + $createTableStatement .= $this->getColumnSQL($field) . ', '; + } + + $newLookup = $this->getKeyLookup($table->xpath('key')); + + // Loop through each key in the new structure. + foreach ($newLookup as $key) + { + $createTableStatement .= $this->getKeySQL($key) . ', '; + } + + // Remove the comma after the last key + $createTableStatement = rtrim($createTableStatement, ', '); + + $createTableStatement .= ')'; + + return $createTableStatement; + } + /** * Get the SQL syntax to add a column. * From 22c36b5e1e3e7cf9d1365dd518afee0a625da3f0 Mon Sep 17 00:00:00 2001 From: Izhar Aazmi Date: Wed, 26 Aug 2015 16:01:06 +0530 Subject: [PATCH 003/176] Minimizing JArrayHelper by using Joomla\Utilities\ArrayHelper internally with appropriate deprecation warnings. All functionality of JArrayHelper is already available there, so no point keeping duplicate code. --- libraries/joomla/utilities/arrayhelper.php | 248 ++------------------- 1 file changed, 17 insertions(+), 231 deletions(-) diff --git a/libraries/joomla/utilities/arrayhelper.php b/libraries/joomla/utilities/arrayhelper.php index 3b73a1253792c..a185bc0e1ce77 100644 --- a/libraries/joomla/utilities/arrayhelper.php +++ b/libraries/joomla/utilities/arrayhelper.php @@ -64,29 +64,7 @@ abstract class JArrayHelper */ public static function toInteger(&$array, $default = null) { - if (is_array($array)) - { - foreach ($array as $i => $v) - { - $array[$i] = (int) $v; - } - } - else - { - if ($default === null) - { - $array = array(); - } - elseif (is_array($default)) - { - self::toInteger($default, null); - $array = $default; - } - else - { - $array = array((int) $default); - } - } + $array = ArrayHelper::toInteger($array, $default); } /** @@ -111,7 +89,7 @@ public static function toObject(&$array, $class = 'stdClass', $recursive = true) } else { - JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::toObject.', JLog::WARNING, 'deprecated'); + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::' . __FUNCTION__ . '.', JLog::WARNING, 'deprecated'); } return $obj; @@ -140,7 +118,7 @@ public static function toString($array = null, $inner_glue = '=', $outer_glue = } else { - JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::toString.', JLog::WARNING, 'deprecated'); + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::' . __FUNCTION__ . '.', JLog::WARNING, 'deprecated'); } return implode($outer_glue, $output); @@ -160,63 +138,7 @@ public static function toString($array = null, $inner_glue = '=', $outer_glue = */ public static function fromObject($p_obj, $recurse = true, $regex = null) { - if (is_object($p_obj)) - { - return self::_fromObject($p_obj, $recurse, $regex); - } - else - { - return null; - } - } - - /** - * Utility function to map an object or array to an array - * - * @param mixed $item The source object or array - * @param boolean $recurse True to recurse through multi-level objects - * @param string $regex An optional regular expression to match on field names - * - * @return array The array mapped from the given object - * - * @since 11.1 - */ - protected static function _fromObject($item, $recurse, $regex) - { - if (is_object($item)) - { - $result = array(); - - foreach (get_object_vars($item) as $k => $v) - { - if (!$regex || preg_match($regex, $k)) - { - if ($recurse) - { - $result[$k] = self::_fromObject($v, $recurse, $regex); - } - else - { - $result[$k] = $v; - } - } - } - } - elseif (is_array($item)) - { - $result = array(); - - foreach ($item as $k => $v) - { - $result[$k] = self::_fromObject($v, $recurse, $regex); - } - } - else - { - $result = $item; - } - - return $result; + ArrayHelper::fromObject($p_obj, $recurse, $regex); } /** @@ -240,7 +162,7 @@ public static function getColumn(&$array, $index) } else { - JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::getColumn.', JLog::WARNING, 'deprecated'); + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::' . __FUNCTION__ . '.', JLog::WARNING, 'deprecated'); } return $result; @@ -327,64 +249,15 @@ public static function isAssociative($array) public static function pivot($source, $key = null) { $result = array(); - $counter = array(); - foreach ($source as $index => $value) + if (is_array($source)) { - // Determine the name of the pivot key, and its value. - if (is_array($value)) - { - // If the key does not exist, ignore it. - if (!isset($value[$key])) - { - continue; - } - - $resultKey = $value[$key]; - $resultValue = &$source[$index]; - } - elseif (is_object($value)) - { - // If the key does not exist, ignore it. - if (!isset($value->$key)) - { - continue; - } - - $resultKey = $value->$key; - $resultValue = &$source[$index]; - } - else - { - // Just a scalar value. - $resultKey = $value; - $resultValue = $index; - } - - // The counter tracks how many times a key has been used. - if (empty($counter[$resultKey])) - { - // The first time around we just assign the value to the key. - $result[$resultKey] = $resultValue; - $counter[$resultKey] = 1; - } - elseif ($counter[$resultKey] == 1) - { - // If there is a second time, we convert the value into an array. - $result[$resultKey] = array( - $result[$resultKey], - $resultValue, - ); - $counter[$resultKey]++; - } - else - { - // After the second time, no need to track any more. Just append to the existing array. - $result[$resultKey][] = $resultValue; - } + $result = ArrayHelper::pivot($source, $key); + } + else + { + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::' . __FUNCTION__ . '.', JLog::WARNING, 'deprecated'); } - - unset($counter); return $result; } @@ -405,86 +278,16 @@ public static function pivot($source, $key = null) */ public static function sortObjects(&$a, $k, $direction = 1, $caseSensitive = true, $locale = false) { - if (!is_array($locale) || !is_array($locale[0])) + if (is_array($a)) { - $locale = array($locale); + $a = ArrayHelper::sortObjects($a, $k, $direction, $caseSensitive, $locale); } - - self::$sortCase = (array) $caseSensitive; - self::$sortDirection = (array) $direction; - self::$sortKey = (array) $k; - self::$sortLocale = $locale; - - usort($a, array(__CLASS__, '_sortObjects')); - - self::$sortCase = null; - self::$sortDirection = null; - self::$sortKey = null; - self::$sortLocale = null; - - return $a; - } - - /** - * Callback function for sorting an array of objects on a key - * - * @param array &$a An array of objects - * @param array &$b An array of objects - * - * @return integer Comparison status - * - * @see JArrayHelper::sortObjects() - * @since 11.1 - */ - protected static function _sortObjects(&$a, &$b) - { - $key = self::$sortKey; - - for ($i = 0, $count = count($key); $i < $count; $i++) + else { - if (isset(self::$sortDirection[$i])) - { - $direction = self::$sortDirection[$i]; - } - - if (isset(self::$sortCase[$i])) - { - $caseSensitive = self::$sortCase[$i]; - } - - if (isset(self::$sortLocale[$i])) - { - $locale = self::$sortLocale[$i]; - } - - $va = $a->{$key[$i]}; - $vb = $b->{$key[$i]}; - - if ((is_bool($va) || is_numeric($va)) && (is_bool($vb) || is_numeric($vb))) - { - $cmp = $va - $vb; - } - elseif ($caseSensitive) - { - $cmp = JString::strcmp($va, $vb, $locale); - } - else - { - $cmp = JString::strcasecmp($va, $vb, $locale); - } - - if ($cmp > 0) - { - return $direction; - } - - if ($cmp < 0) - { - return -$direction; - } + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::' . __FUNCTION__ . '.', JLog::WARNING, 'deprecated'); } - return 0; + return $a; } /** @@ -500,23 +303,6 @@ protected static function _sortObjects(&$a, &$b) */ public static function arrayUnique($myArray) { - if (!is_array($myArray)) - { - return $myArray; - } - - foreach ($myArray as &$myvalue) - { - $myvalue = serialize($myvalue); - } - - $myArray = array_unique($myArray); - - foreach ($myArray as &$myvalue) - { - $myvalue = unserialize($myvalue); - } - - return $myArray; + return is_array($myArray) ? ArrayHelper::arrayUnique($myArray) : $myArray; } } From 7f9ff9d3bc875d79ceee1e0cf5172a6c920540ed Mon Sep 17 00:00:00 2001 From: Izhar Aazmi Date: Sat, 5 Sep 2015 14:15:24 +0530 Subject: [PATCH 004/176] Missing return statement Added the missing return statement that caused fromObject method to fail. --- libraries/joomla/utilities/arrayhelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/joomla/utilities/arrayhelper.php b/libraries/joomla/utilities/arrayhelper.php index a185bc0e1ce77..c0d2f21c436d6 100644 --- a/libraries/joomla/utilities/arrayhelper.php +++ b/libraries/joomla/utilities/arrayhelper.php @@ -138,7 +138,7 @@ public static function toString($array = null, $inner_glue = '=', $outer_glue = */ public static function fromObject($p_obj, $recurse = true, $regex = null) { - ArrayHelper::fromObject($p_obj, $recurse, $regex); + return ArrayHelper::fromObject($p_obj, $recurse, $regex); } /** From ad48dac00d634fdafa82fa883c3cd5123c4a1cc6 Mon Sep 17 00:00:00 2001 From: Izhar Aazmi Date: Sat, 3 Oct 2015 14:26:16 +0530 Subject: [PATCH 005/176] Change magic constant __FUNCTION__ to fixed method name strings. --- libraries/joomla/utilities/arrayhelper.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/joomla/utilities/arrayhelper.php b/libraries/joomla/utilities/arrayhelper.php index c0d2f21c436d6..01e54b6bc1535 100644 --- a/libraries/joomla/utilities/arrayhelper.php +++ b/libraries/joomla/utilities/arrayhelper.php @@ -89,7 +89,7 @@ public static function toObject(&$array, $class = 'stdClass', $recursive = true) } else { - JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::' . __FUNCTION__ . '.', JLog::WARNING, 'deprecated'); + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::toObject.', JLog::WARNING, 'deprecated'); } return $obj; @@ -118,7 +118,7 @@ public static function toString($array = null, $inner_glue = '=', $outer_glue = } else { - JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::' . __FUNCTION__ . '.', JLog::WARNING, 'deprecated'); + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::toString.', JLog::WARNING, 'deprecated'); } return implode($outer_glue, $output); @@ -162,7 +162,7 @@ public static function getColumn(&$array, $index) } else { - JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::' . __FUNCTION__ . '.', JLog::WARNING, 'deprecated'); + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::getColumn.', JLog::WARNING, 'deprecated'); } return $result; @@ -256,7 +256,7 @@ public static function pivot($source, $key = null) } else { - JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::' . __FUNCTION__ . '.', JLog::WARNING, 'deprecated'); + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::pivot.', JLog::WARNING, 'deprecated'); } return $result; @@ -284,7 +284,7 @@ public static function sortObjects(&$a, $k, $direction = 1, $caseSensitive = tru } else { - JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::' . __FUNCTION__ . '.', JLog::WARNING, 'deprecated'); + JLog::add('This method is typehinted to be an array in \Joomla\Utilities\ArrayHelper::sortObjects.', JLog::WARNING, 'deprecated'); } return $a; From 8d5f65aaf2e0c0c635262a5686bd362dde18a479 Mon Sep 17 00:00:00 2001 From: "Ing. Stefan Polzer" Date: Sun, 25 Oct 2015 01:08:37 +0200 Subject: [PATCH 006/176] add autocomplete=email to form filds --- components/com_contact/models/forms/contact.xml | 1 + components/com_contact/models/forms/form.xml | 2 +- components/com_users/models/forms/profile.xml | 1 + components/com_users/models/forms/registration.xml | 1 + components/com_users/models/forms/remind.xml | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/com_contact/models/forms/contact.xml b/components/com_contact/models/forms/contact.xml index 59902f82cd681..1500d002a6ab1 100644 --- a/components/com_contact/models/forms/contact.xml +++ b/components/com_contact/models/forms/contact.xml @@ -19,6 +19,7 @@ filter="string" validate="contactemail" required="true" + autocomplete="email" /> Date: Mon, 26 Oct 2015 20:36:39 +0100 Subject: [PATCH 007/176] Support for input elements in the searchoolbar --- media/jui/js/jquery.searchtools.js | 2 +- media/jui/js/jquery.searchtools.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/media/jui/js/jquery.searchtools.js b/media/jui/js/jquery.searchtools.js index a55e387581d57..666f358e0a3bb 100644 --- a/media/jui/js/jquery.searchtools.js +++ b/media/jui/js/jquery.searchtools.js @@ -232,7 +232,7 @@ $(chosenId).removeClass('active'); }, getFilterFields: function () { - return this.filterContainer.find('select'); + return this.filterContainer.find('select,input'); }, getListFields: function () { return this.listContainer.find('select'); diff --git a/media/jui/js/jquery.searchtools.min.js b/media/jui/js/jquery.searchtools.min.js index d48c18be262b0..1cc002054105a 100644 --- a/media/jui/js/jquery.searchtools.min.js +++ b/media/jui/js/jquery.searchtools.min.js @@ -1 +1 @@ -(function($,window,document,undefined){var pluginName="searchtools";var defaults={formSelector:".js-stools-form",searchFieldSelector:".js-stools-field-search",clearBtnSelector:".js-stools-btn-clear",mainContainerSelector:".js-stools",searchBtnSelector:".js-stools-btn-search",filterBtnSelector:".js-stools-btn-filter",filterContainerSelector:".js-stools-container-filters",filtersHidden:true,listBtnSelector:".js-stools-btn-list",listContainerSelector:".js-stools-container-list",listHidden:false,orderColumnSelector:".js-stools-column-order",orderBtnSelector:".js-stools-btn-order",orderFieldSelector:".js-stools-field-order",orderFieldName:"list[fullordering]",limitFieldSelector:".js-stools-field-limit",defaultLimit:20,activeOrder:null,activeDirection:"ASC",chosenSupport:true,clearListOptions:false};function Plugin(element,options){this.element=element;this.options=$.extend({},defaults,options);this._defaults=defaults;this.theForm=$(this.options.formSelector);this.filterButton=$(this.options.formSelector+" "+this.options.filterBtnSelector);this.filterContainer=$(this.options.formSelector+" "+this.options.filterContainerSelector);this.filtersHidden=this.options.filtersHidden;this.listButton=$(this.options.formSelector+" "+this.options.listBtnSelector);this.listContainer=$(this.options.formSelector+" "+this.options.listContainerSelector);this.listHidden=this.options.listHidden;this.mainContainer=$(this.options.mainContainerSelector);this.searchButton=$(this.options.formSelector+" "+this.options.searchBtnSelector);this.searchField=$(this.options.formSelector+" "+this.options.searchFieldSelector);this.searchString=null;this.clearButton=$(this.options.clearBtnSelector);this.orderCols=$(this.options.formSelector+" "+this.options.orderColumnSelector);this.orderField=$(this.options.formSelector+" "+this.options.orderFieldSelector);this.limitField=$(this.options.formSelector+" "+this.options.limitFieldSelector);this.activeColumn=null;this.activeDirection=this.options.activeDirection;this.activeOrder=this.options.activeOrder;this.activeLimit=null;this.chosenSupport=this.options.chosenSupport;this.clearListOptions=this.options.clearListOptions;this._name=pluginName;this.init()}Plugin.prototype={init:function(){var self=this;if(!document.addEventListener){if(this.searchField.val()===this.searchField.attr("placeholder")){this.searchField.val("")}}this.searchString=this.searchField.val();if(this.filtersHidden){this.hideFilters()}else{this.showFilters()}if(this.listHidden){this.hideList()}else{this.showList()}self.filterButton.click(function(e){self.toggleFilters();e.stopPropagation();e.preventDefault()});self.listButton.click(function(e){self.toggleList();e.stopPropagation();e.preventDefault()});self.getFilterFields().each(function(i,element){self.checkFilter(element);$(element).change(function(){self.checkFilter(element)})});self.clearButton.click(function(e){self.clear()});this.createOrderField();this.orderCols.click(function(){var newOrderCol=$(this).attr("data-order");var newDirection=$(this).attr('data-direction');var newOrdering=newOrderCol+" "+newDirection;if(newOrderCol.length){self.activeColumn=newOrderCol;if(newOrdering!==self.activeOrder){self.activeDirection=newDirection;self.activeOrder=newOrdering;self.updateFieldValue(self.orderField,newOrdering)}else{self.toggleDirection()}self.theForm.submit()}})},checkFilter:function(element){var self=this;var option=$(element).find("option:selected");if(option.val()!==""){self.activeFilter(element)}else{self.deactiveFilter(element)}},clear:function(){var self=this;self.getFilterFields().each(function(i,element){$(element).val("");self.checkFilter(element);if(self.chosenSupport){$(element).trigger("liszt:updated")}});if(self.clearListOptions){self.getListFields().each(function(i,element){$(element).val("");self.checkFilter(element);if(self.chosenSupport){$(element).trigger("liszt:updated")}});$("#list_limit").val(self.options.defaultLimit);if(self.chosenSupport){$("#list_limit").trigger("liszt:updated")}}self.searchField.val("");self.theForm.submit()},activeFilter:function(element){var self=this;$(element).addClass("active");var chosenId="#"+$(element).attr("id")+"_chzn";$(chosenId).addClass("active")},deactiveFilter:function(element){var self=this;$(element).removeClass("active");var chosenId="#"+$(element).attr("id")+"_chzn";$(chosenId).removeClass("active")},getFilterFields:function(){return this.filterContainer.find("select")},getListFields:function(){return this.listContainer.find("select")},hideContainer:function(container){$(container).hide("fast");$(container).removeClass("shown")},showContainer:function(container){$(container).show("fast");$(container).addClass("shown")},toggleContainer:function(container){if($(container).hasClass("shown")){this.hideContainer(container)}else{this.showContainer(container)}},hideList:function(){this.hideContainer(this.listContainer);this.listButton.removeClass("btn-primary")},showList:function(){this.showContainer(this.listContainer);this.listButton.addClass("btn-primary")},toggleList:function(){this.toggleContainer(this.listContainer);if(this.listContainer.hasClass("shown")){this.listButton.addClass("btn-primary")}else{this.listButton.removeClass("btn-primary")}},hideFilters:function(){this.hideContainer(this.filterContainer);this.filterButton.removeClass("btn-primary")},showFilters:function(){this.showContainer(this.filterContainer);this.filterButton.addClass("btn-primary")},toggleFilters:function(){this.toggleContainer(this.filterContainer);if(this.filterContainer.hasClass("shown")){this.filterButton.addClass("btn-primary")}else{this.filterButton.removeClass("btn-primary")}},toggleDirection:function(){var self=this;var newDirection="ASC";if(self.activeDirection.toUpperCase()=="ASC"){newDirection="DESC"}self.activeDirection=newDirection;self.activeOrder=self.activeColumn+" "+newDirection;self.updateFieldValue(self.orderField,self.activeOrder)},createOrderField:function(){var self=this;if(!this.orderField.length){this.orderField=$("").attr({type:"hidden",id:"js-stools-field-order","class":"js-stools-field-order",name:self.options.orderFieldName,value:self.activeOrder+" "+this.activeDirection});this.orderField.appendTo(this.theForm)}if(this.orderField.is("select")){this.orderCols.each(function(){var value=$(this).attr("data-order");var name=$(this).attr("data-name");var direction=$(this).attr("data-direction");if(value.length){value=value+" "+direction;var option=self.findOption(self.orderField,value);if(!option.length){var option=$("