-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from wilsonge/development
Changes for version 1.3.3
- Loading branch information
Showing
4 changed files
with
289 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,7 @@ | |
<license>http://www.gnu.org/licenses/gpl-3.0.html</license> | ||
<authorEmail>[email protected]</authorEmail> | ||
<authorUrl>http://www.joomjunk.co.uk</authorUrl> | ||
<version>1.3.2</version> | ||
<description>JJ_SOCIAL_SLIDER_DESC</description> | ||
<version>1.3.3</version> | ||
|
||
<files> | ||
<filename module="mod_social_slider">mod_social_slider.php</filename> | ||
|
@@ -21,7 +20,9 @@ | |
<updateservers> | ||
<server type="extension" name="JJ Social Slider" priority="1">http://www.joomjunk.co.uk/updates/social_slider_update.xml</server> | ||
</updateservers> | ||
|
||
|
||
<scriptfile>script.php</scriptfile> | ||
|
||
<languages folder="language"> | ||
<language tag="en-GB">en-GB/en-GB.mod_social_slider.ini</language> | ||
<language tag="en-GB">en-GB/en-GB.mod_social_slider.sys.ini</language> | ||
|
@@ -205,7 +206,7 @@ | |
</fieldset> | ||
|
||
<fieldset name="Other" addfieldpath="/modules/mod_social_slider/fields"> | ||
<field name="slide_colour" type="color" default="33353B" label="JJ_SOCIAL_SLIDER_SLIDE_COLOUR" description="JJ_SOCIAL_SLIDER_SLIDE_COLOUR_DESC" /> | ||
<field name="slide_colour" type="color" default="#33353B" label="JJ_SOCIAL_SLIDER_SLIDE_COLOUR" description="JJ_SOCIAL_SLIDER_SLIDE_COLOUR_DESC" /> | ||
<field name="position" type="list" default="left" label="JJ_SOCIAL_SLIDER_POSITION" description="JJ_SOCIAL_SLIDER_POSITION_DESC"> | ||
<option value="left">JJ_SOCIAL_SLIDER_LEFT</option> | ||
<option value="right">JJ_SOCIAL_SLIDER_RIGHT</option> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,279 @@ | ||
<?php | ||
/** | ||
* @package JJ_Social_Slider | ||
* @author JoomJunk <[email protected]> | ||
* @copyright Copyright (C) 2011 - 2013 JoomJunk. All Rights Reserved | ||
* @license GPL v3.0 or later http://www.gnu.org/licenses/gpl-3.0.html | ||
*/ | ||
// No direct access to this file | ||
defined('_JEXEC') or die('Restricted access'); | ||
|
||
/** | ||
* Social Slider installation script class. | ||
* | ||
* @since 1.3.3 | ||
*/ | ||
class Mod_Social_SliderInstallerScript | ||
{ | ||
/** | ||
* @var string The version number of the module. | ||
* @since 1.3.3 | ||
*/ | ||
protected $release = ''; | ||
|
||
/** | ||
* @var string The table the parameters are stored in. | ||
* @since 1.3.3 | ||
*/ | ||
protected $paramTable = '#__modules'; | ||
|
||
/** | ||
* @var string The extension name. | ||
* @since 1.3.3 | ||
*/ | ||
protected $extension = 'mod_social_slider'; | ||
|
||
/** | ||
* Function called before module installation/update/removal procedure commences | ||
* | ||
* @param string $type The type of change (install, update or discover_install | ||
* , not uninstall) | ||
* @param JInstallerAdapterModule $parent The class calling this method | ||
* | ||
* @return mixed void on success and false on failure | ||
* | ||
* @since 1.3.3 | ||
*/ | ||
public function preflight($type, $parent) | ||
{ | ||
// Module manifest file version | ||
$this->release = $parent->get("manifest")->version; | ||
|
||
// Abort if the module being installed is not newer than the currently installed version | ||
if ($type == 'Update') | ||
{ | ||
$manifest = $this->getItemArray('manifest_cache', '#__extensions', 'element', $this->extension); | ||
$oldRelease = $manifest['version']; | ||
|
||
if (version_compare($oldRelease, $this->release, '<')) | ||
{ | ||
// Update to reflect colour form field change in 1.3.2 | ||
if (version_compare($oldRelease, '1.3.2', '<=')) | ||
{ | ||
$this->update132(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Function called on install of module | ||
* | ||
* @param JInstallerAdapterModule $parent The class calling this method | ||
* | ||
* @return void | ||
* | ||
* @since 1.3.3 | ||
*/ | ||
public function install($parent) | ||
{ | ||
echo '<p>' . JText::_('JJ_SOCIAL_SLIDER_DESC') . '</p>'; | ||
} | ||
|
||
/** | ||
* Function called on update of module | ||
* | ||
* @param JInstallerAdapterModule $parent The class calling this method | ||
* | ||
* @return void | ||
* | ||
* @since 1.3.3 | ||
*/ | ||
public function update($parent) | ||
{ | ||
echo '<p>' . JText::_('JJ_SOCIAL_SLIDER_DESC') . '</p>'; | ||
} | ||
|
||
/** | ||
* Gets each instance of a module in the #__modules table | ||
* For all other extensions see alternate query | ||
* | ||
* @param string $extensionType The type of extension (Component, Module or Plugin) | ||
* | ||
* @return array An array of ID's of the extension | ||
* | ||
* @since 1.3.3 | ||
* @see getExtensionInstance | ||
*/ | ||
protected function getInstances($extensionType) | ||
{ | ||
$db = JFactory::getDbo(); | ||
$query = $db->getQuery(true); | ||
|
||
// Select the item(s) and retrieve the id | ||
$query->select($db->quoteName('id')); | ||
|
||
if ($extensionType == 'module') | ||
{ | ||
$query->from($db->quoteName('#__modules')) | ||
->where('module = ' . $db->Quote($this->extension)); | ||
} | ||
else | ||
{ | ||
$query->from($db->quoteName('#__extensions')) | ||
->where('element = ' . $db->Quote($this->extension)); | ||
} | ||
|
||
// Set the query and obtain an array of id's | ||
$db->setQuery($query); | ||
$items = $db->loadColumn(); | ||
|
||
return $items; | ||
} | ||
|
||
/** | ||
* Gets parameter value in the extensions row of the extension table | ||
* | ||
* @param string $name The name of the parameter to be retrieved | ||
* @param integer $id The id of the item in the Param Table | ||
* | ||
* @return string The parameter desired | ||
* | ||
* @since 1.3.3 | ||
*/ | ||
protected function getParam($name, $id = 0) | ||
{ | ||
if (!is_int($id) || $id == 0) | ||
{ | ||
// Return false if there is no item given | ||
return false; | ||
} | ||
|
||
$params = $this->getItemArray('params', $this->paramTable, 'id', $id); | ||
|
||
return $params[$name]; | ||
} | ||
|
||
/** | ||
* Sets parameter values in the extensions row of the extension table. Note that the | ||
* this must be called separately for deleting and editing. Note if edit is called as a | ||
* type then if the param doesn't exist it will be created | ||
* | ||
* @param array $param_array The array of parameters to be added/edited/removed | ||
* @param string $type The type of change to be made to the param (edit/remove) | ||
* @param integer $id The id of the item in the relevant table | ||
* | ||
* @return mixed false on failure, void otherwise | ||
*/ | ||
protected function setParams($param_array = null, $type = 'edit', $id = 0) | ||
{ | ||
if (!is_int($id) || $id == 0) | ||
{ | ||
// Return false if there is no valid item given | ||
return false; | ||
} | ||
|
||
$params = $this->getItemArray('params', $this->paramTable, 'id', $id); | ||
|
||
if ($param_array) | ||
{ | ||
foreach ($param_array as $name => $value) | ||
{ | ||
if ($type == 'edit') | ||
{ | ||
// Add or edit the new variable(s) to the existing params | ||
$params[(string) $name] = (string) $value; | ||
} | ||
elseif ($type == 'remove') | ||
{ | ||
// Unset the parameter from the array | ||
unset($params[(string) $name]); | ||
} | ||
} | ||
} | ||
|
||
// Store the combined new and existing values back as a JSON string | ||
$paramsString = json_encode($params); | ||
|
||
$db = JFactory::getDbo(); | ||
$query = $db->getQuery(true); | ||
$query->update($db->quoteName($this->paramTable)) | ||
->set('params = ' . $db->quote($paramsString)) | ||
->where('id = ' . $id); | ||
|
||
// Update table | ||
$db->setQuery($query); | ||
|
||
if (version_compare(JVERSION, '3.0.0', 'ge')) | ||
{ | ||
$db->execute(); | ||
} | ||
else | ||
{ | ||
$db->query(); | ||
} | ||
} | ||
|
||
/** | ||
* Builds a standard select query to produce better DRY code in this script. | ||
* This should produce a single unique cell which is json encoded | ||
* | ||
* @param string $element The element to get from the query | ||
* @param string $table The table to search for the data in | ||
* @param string $column The column of the database to search from | ||
* @param string $identifier The property of the column to search for | ||
* | ||
* @return array associated array containing data from the cell | ||
* | ||
* @since 1.3.3 | ||
*/ | ||
protected function getItemArray($element, $table, $column, $identifier) | ||
{ | ||
// Get the DB and query objects | ||
$db = JFactory::getDbo(); | ||
$query = $db->getQuery(true); | ||
|
||
// Build the query | ||
$query->select($db->quoteName($element)) | ||
->from($db->quoteName($table)) | ||
->where($column . ' = ' . $db->Quote($identifier)); | ||
$db->setQuery($query); | ||
|
||
// Load the single cell and json_decode data | ||
$array = json_decode($db->loadResult(), true); | ||
|
||
return $array; | ||
} | ||
|
||
/** | ||
* Function to update the file structure and params for the Social Slider Version 1.3.2 updates | ||
* | ||
* @return void | ||
* | ||
* @since 1.3.3 | ||
*/ | ||
protected function update132() | ||
{ | ||
/* | ||
* We have moved to use the colour form field so a hash must be applied | ||
* to the parameters for them to function as expected still. | ||
*/ | ||
$modules = $this->getInstances('module'); | ||
|
||
foreach ($modules as $module) | ||
{ | ||
// Convert string to integer | ||
$module = (int) $module; | ||
|
||
// Create array of params to change | ||
$colours = array(); | ||
$colours['slide_colour'] = '#' . $this->getParam('slide_colour', $module); | ||
|
||
// Set the param values | ||
$this->setParams($colours, 'edit', $module); | ||
|
||
// Unset the array for the next loop | ||
unset($colours); | ||
} | ||
} | ||
} |