Skip to content

Commit

Permalink
v.1.39 with added gk_musicstate style.
Browse files Browse the repository at this point in the history
  • Loading branch information
dziudek committed Nov 2, 2013
1 parent 22fc2ff commit ad83798
Show file tree
Hide file tree
Showing 13 changed files with 1,063 additions and 3 deletions.
1 change: 1 addition & 0 deletions mod_image_show_gk4/language/en-GB.mod_image_show_gk4.ini
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ MOD_IMAGE_SHOW_ESPORT_IS_LOADING="Loading"
MOD_IMAGE_SHOW_LEAGUE_NEWS_MORE_NEWS="More news..."
MOD_IMAGE_SHOW_THE_REAL_DESIGN_IS_LOADING="Loading..."
MOD_IMAGE_SHOW_CREATIVITY_READMORE="What we do"
MOD_IMAGE_SHOW_MUSIC_STATE_READMORE="Read more"
6 changes: 3 additions & 3 deletions mod_image_show_gk4/mod_image_show_gk4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<extension type="module" version="1.6.0" client="site" method="upgrade">
<name>Image Show GK4</name>
<author>GavickPro</author>
<creationDate>02/08/2013</creationDate>
<creationDate>02/11/2013</creationDate>
<copyright>Copyright (C) 2011-2013 GavickPro. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.gavickpro.com</authorUrl>
<version>GK4 1.38</version>
<version>GK4 1.39</version>
<description><![CDATA[
<style type="text/css">
span.readonly { padding: 10px; font-family: Arial; font-size:13px !important; font-weight: normal !important; text-align: justify; color: #4d4d4d; line-height: 24px; }
Expand All @@ -18,7 +18,7 @@
span.readonly p.license { border-top: 1px solid #eee; font-size: 11px; margin: 30px 26px 0; padding: 6px 0; }
</style>
<span class="readonly"><h1>Image Show GK4<small>ver. 1.38</small></h1><p>GK4 is new generation of our extensions dedicated to Joomla 1.6+.</p><p>With Image Show GK4 module, you can create slideshow on a site which include various images and article fragments or texts defined by a user. Thanks to slide management system integrated in the module, its support is very easy, intuitive and fast. With the new method of creating module styles you can easily move your slideshow style from one template to other template.</p> <p class='homepage'><a href='http://www.gavick.com/documentation/joomla-extensions/extensions-for-joomla-1-6/image-show-gk4/' target='_blank'>Learn more at the Image Show GK4 project website.</a></p><p class='license'>Image Show GK4 is released under the <a target="_blank" href="http://www.gnu.org/licenses/gpl-2.0.html">GNU/GPL v2 license.</a></p></span>
<span class="readonly"><h1>Image Show GK4<small>ver. 1.39</small></h1><p>GK4 is new generation of our extensions dedicated to Joomla 1.6+.</p><p>With Image Show GK4 module, you can create slideshow on a site which include various images and article fragments or texts defined by a user. Thanks to slide management system integrated in the module, its support is very easy, intuitive and fast. With the new method of creating module styles you can easily move your slideshow style from one template to other template.</p> <p class='homepage'><a href='http://www.gavick.com/documentation/joomla-extensions/extensions-for-joomla-1-6/image-show-gk4/' target='_blank'>Learn more at the Image Show GK4 project website.</a></p><p class='license'>Image Show GK4 is released under the <a target="_blank" href="http://www.gnu.org/licenses/gpl-2.0.html">GNU/GPL v2 license.</a></p></span>
]]></description>
<files>
<filename module="mod_image_show_gk4">mod_image_show_gk4.php</filename>
Expand Down
162 changes: 162 additions & 0 deletions mod_image_show_gk4/styles/gk_musicstate/class.image.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<?php

/**
* @author: GavickPro
* @copyright: 2008-2012
**/

// no direct access
defined('_JEXEC') or die('Restricted access');

class GKIS_MusicState_Image {
/*
function to change file path to filename.
For example:
./images/stories/demo.jpg
will be translated to:
stories.demo.jpg
(in this situation mirror of ./images/ directory isn't necessary)
*/
function translateName($name, $mod_id) {
$name = GKIS_MusicState_Image::getRealPath($name);
$start = strpos($name, DS.'images'.DS);
$name = substr($name, $start+8);
$ext = substr($name, -4);
$name = substr($name, 0, -4);
$name = str_replace(DS,'.',$name);
$name .= $mod_id.$ext;
return $name;
}
// function to change file path to real path.
function getRealPath($path) {
$start = strpos($path, 'images/');
$path = './'.substr($path, $start);
return realpath($path);
}
/*
function to check cache
this function checks if file exists in cache directory
and checks if time of file life isn't too long
*/
function checkCache($filename, $last_modification_time) {
$cache_dir = JPATH_ROOT.DS.'modules'.DS.'mod_image_show_gk4'.DS.'cache'.DS;
$file = $cache_dir.$filename;

return (!is_file($file)) ? FALSE : (filemtime($file) > $last_modification_time);
}
// Creating thumbnails
function createThumbnail($path, $config, $width, $height, $image_bg, $image_stretch, $quality) {
if(GKIS_MusicState_Image::checkCache(GKIS_MusicState_Image::translateName($path,$config['module_id']), $config['last_modification'], $config['module_id'])){
return TRUE;
}else{
// importing classes
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.path');
//script configuration - increase memory limit to 64MB
ini_set('memory_limit', '64M');
// cache dir
$cache_dir = JPATH_ROOT.DS.'modules'.DS.'mod_image_show_gk4'.DS.'cache'.DS;
// file path
$file = GKIS_MusicState_Image::getRealPath($path);
// filename
$filename = GKIS_MusicState_Image::translateName($path,$config['module_id']);
// Getting informations about image
if(is_file($file)){
$imageData = getimagesize($file);
// loading image depends from type of image
if($imageData['mime'] == 'image/jpeg' || $imageData['mime'] == 'image/pjpeg' || $imageData['mime'] == 'image/jpg') $imageSource = @imagecreatefromjpeg($file);
elseif($imageData['mime'] == 'image/gif') $imageSource = @imagecreatefromgif($file);
else $imageSource = @imagecreatefrompng($file);
// here can be exist an error when image is to big - then class return blank page
// setting image size in variables
$imageSourceWidth = imagesx($imageSource);
$imageSourceHeight = imagesy($imageSource);
// Creating blank canvas
$imageBG = imagecreatetruecolor($width, $height);
// If image is JPG or GIF
if($imageData['mime'] == 'image/jpeg' || $imageData['mime'] == 'image/pjpeg' || $imageData['mime'] == 'image/jpg' || $imageData['mime'] == 'image/gif') {
// when bg is set to transparent - use black background
if($image_bg == 'transparent'){
$bgColorR = 0;
$bgColorG = 0;
$bgColorB = 0;
}else{ // in other situation - translate hex to RGB
$bg = $image_bg;
if(strlen($bg) == 4) $bg = $bg[0].$bg[1].$bg[1].$bg[2].$bg[2].$bg[3].$bg[3];
$hex_color = strtolower(trim($bg,'#;&Hh'));
$bg = array_map('hexdec',explode('.',wordwrap($hex_color, ceil(strlen($hex_color)/3),'.',1)));
$bgColorR = $bg[0];
$bgColorG = $bg[1];
$bgColorB = $bg[2];
}
// Creating color
$rgb = imagecolorallocate($imageBG, $bgColorR, $bgColorG, $bgColorB);
// filling canvas with new color
imagefill($imageBG, 0, 0, $rgb);
}else {// for PNG images
$imageBG = imagecreatetruecolor($width, $height);
// enable transparent background
if($image_bg == 'transparent'){
// create transparent color
$rgb = imagecolorallocatealpha($imageBG, 0, 0, 0, 127);
}else {// create normal color
$bg = $image_bg;
// translate hex to RGB
$hex_color = strtolower(trim($bg,'#;&Hh'));
$bg = array_map('hexdec',explode('.',wordwrap($hex_color, ceil(strlen($hex_color)/3),'.',1)));
// creating color
$rgb = imagecolorallocate($imageBG, $bg[0], $bg[1], $bg[2]);
}
// filling the canvas
imagefill($imageBG, 0, 0, $rgb);
// enabling transparent settings for better quality
imagealphablending($imageBG, false);
imagesavealpha($imageBG, true);
}
// when stretching is disabled
if(!$image_stretch){
// calculate ratio for first scaling
$ratio = ($imageSourceWidth > $imageSourceHeight) ? $width/$imageSourceWidth : $height/$imageSourceHeight;
// calculate new image size
$imageSourceNWidth = $imageSourceWidth * $ratio;
$imageSourceNHeight = $imageSourceHeight * $ratio;
// calculate ratio for second scaling
if($width > $height){
if($imageSourceNHeight > $height){
$ratio2 = $height / $imageSourceNHeight;
$imageSourceNHeight *= $ratio2;
$imageSourceNWidth *= $ratio2;
}
}else{
if($imageSourceNWidth > $width){
$ratio2 = $width / $imageSourceNWidth;
$imageSourceNHeight *= $ratio2;
$imageSourceNWidth *= $ratio2;
}
}
// setting position of putting thumbnail on canvas
$base_x = floor(($width - $imageSourceNWidth) / 2);
$base_y = floor(($height - $imageSourceNHeight) / 2);
}else{ // when stretching is disabled
$imageSourceNWidth = $width;
$imageSourceNHeight = $height;
$base_x = 0;
$base_y = 0;
}
// copy image
imagecopyresampled($imageBG, $imageSource, $base_x, $base_y, 0, 0, $imageSourceNWidth, $imageSourceNHeight, $imageSourceWidth, $imageSourceHeight);
// save image depends from MIME type
if($imageData['mime'] == 'image/jpeg' || $imageData['mime'] == 'image/pjpeg' || $imageData['mime'] == 'image/jpg') imagejpeg($imageBG,$cache_dir.$filename, $quality);
elseif($imageData['mime'] == 'image/gif') imagegif($imageBG, $cache_dir.$filename);
else imagepng($imageBG, $cache_dir.$filename);
return TRUE;
}else{
return FALSE;
}
}
}
}

/* eof */
138 changes: 138 additions & 0 deletions mod_image_show_gk4/styles/gk_musicstate/controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?php

/**
* GK Image Show - main PHP file
* @package Joomla!
* @Copyright (C) 2009-2012 Gavick.com
* @ All rights reserved
* @ Joomla! is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @ version $Revision: GK4 1.0 $
**/

// no direct access
defined('_JEXEC') or die;
// Image class loading
require_once (dirname(__FILE__).DS.'class.image.php');
// Model class loading
require_once (dirname(__FILE__).DS.'model.php');

class GKIS_gk_musicstate_Controller {
// configuration array
private $config;
// module info
private $module;
// article data
private $articles;
private $articlesK2;
// constructor
function __construct($module, $config) {
// init the style config
$this->config = $config;
// init the module info
$this->module = $module;
// init the articles array
$this->articles = array();
$this->articlesK2 = array();
// check the module images
$this->checkImages();
// get the articles data
$this->getArticleData();
// generate the view
$this->generateView();
}
// check the images
function checkImages() {
// if the thumbnail generation is enabled
if($this->config['generate_thumbnails'] == 1) {
// basic images params
$img_width = $this->config['config']->gk_musicstate->gk_musicstate_image_width;
$img_height = $this->config['config']->gk_musicstate->gk_musicstate_image_height;
$img_bg = $this->config['config']->gk_musicstate->gk_musicstate_image_bg;
$quality = $this->config['config']->gk_musicstate->gk_musicstate_quality;
// check the slides
foreach($this->config['image_show_data'] as $slide) {
$stretch = ($slide->stretch == 'nostretch') ? false : true;
GKIS_MusicState_Image::createThumbnail($slide->image, $this->config, $img_width, $img_height, $img_bg, $stretch, $quality);
}
}
}
// get the articles data
function getArticleData() {
// create the array
$ids = array();
$idsK2 = array();
// generate the content of the array
foreach($this->config['image_show_data'] as $slide) {
if($slide->type == 'article') {
array_push($ids, $slide->art_id);
}
if($slide->type == 'k2') {
array_push($idsK2, $slide->artK2_id);
}
}
// get the data
if(count($idsK2) > 0) {
$this->articlesK2 = GKIS_gk_musicstate_Model::getDataK2($idsK2);
}
if(count($ids) > 0) {
$this->articles = GKIS_gk_musicstate_Model::getData($ids);
}
}
// generate view
function generateView() {
// generate the head section
$document = JFactory::getDocument();
$uri = JURI::getInstance();
// get the head data
$headData = $document->getHeadData();
// generate keys of script section
$headData_js_keys = array_keys($headData["scripts"]);
// generate keys of css section
$headData_css_keys = array_keys($headData["style"]);
// set variables for false
$engine_founded = false;
$css_founded = false;
// searching engine in scripts paths
if(array_search($uri->root().'modules/mod_image_show_gk4/styles/'.$this->config['styles'].'/engine.js', $headData_js_keys) > 0) {
$engine_founded = true;
}
// searching css in CSSs paths
if(array_search($uri->root().'modules/mod_image_show_gk4/styles/'.$this->config['styles'].'/style.css', $headData_css_keys) > 0) {
$css_founded = true;
}
// if mootools file doesn't exists in document head section
if(!$engine_founded){
// add new script tag connected with mootools from module
$document->addScript($uri->root().'modules/mod_image_show_gk4/styles/'.$this->config['styles'].'/engine.js');
}
// if CSS not found
if(!$css_founded && $this->config['use_style_css'] == 1) {
// add stylesheets to document header
$document->addStyleSheet($uri->root().'modules/mod_image_show_gk4/styles/'.$this->config['styles'].'/style.css' );
}
// add script fragment
$document->addScriptDeclaration('try {$Gavick;}catch(e){$Gavick = {};};$Gavick["gkIs-'.$this->config['module_id'].'"] = { "anim_speed": '.$this->config['config']->gk_musicstate->gk_musicstate_animation_speed.', "anim_interval": '.$this->config['config']->gk_musicstate->gk_musicstate_animation_interval.', "autoanim": '.$this->config['config']->gk_musicstate->gk_musicstate_autoanimation.', "slide_links": '.$this->config['config']->gk_musicstate->gk_musicstate_slide_links.' };');
// generate necessary variables
$width = $this->config['config']->gk_musicstate->gk_musicstate_image_width;
$height = $this->config['config']->gk_musicstate->gk_musicstate_image_height;
// load view
require_once (dirname(__FILE__).DS.'view.php');
}
// function to generate blank transparent PNG images
public function generateBlankImage($width, $height){
$image = imagecreatetruecolor($width, $height);
imagesavealpha($image, true);
$transparent = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagefill($image, 0, 0, $transparent);
// cache the output
ob_start();
imagepng($image);
$img = ob_get_contents();
ob_end_clean();
// return the string
return base64_encode($img);
}
}

// EOF
Loading

0 comments on commit ad83798

Please sign in to comment.