?
Path : /home/admin/domains/happytokorea.com/public_html_bk/test3/plugins/content/ |
Current File : /home/admin/domains/happytokorea.com/public_html_bk/test3/plugins/content/phocagalleryslideshow.php |
<?php /* * @package Joomla 1.5 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * * @plugin Phoca Plugin * @copyright Copyright (C) Jan Pavelka www.phoca.cz * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL */ defined( '_JEXEC' ) or die( 'Restricted access' ); defined('_JEXEC') or die('Restricted access');// no direct access if (!JComponentHelper::isEnabled('com_phocagallery', true)) { return JError::raiseError(JText::_('Phoca Gallery Error'), JText::_('Phoca Gallery is not installed on your system')); } if (! class_exists('PhocaGalleryLoader')) { require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_phocagallery'.DS.'libraries'.DS.'loader.php'); } phocagalleryimport('phocagallery.path.path'); phocagalleryimport('phocagallery.file.file'); phocagalleryimport('phocagallery.file.filethumbnail'); class plgContentPhocaGalleryslideshow extends JPlugin { function plgContentPhocaGalleryslideshow( &$subject, $params ){ parent::__construct( $subject, $params ); } function onPrepareContent( &$article, &$params, $limitstart ) { $db = &JFactory::getDBO(); $document = &JFactory::getDocument(); $path = PhocaGalleryPath::getPath(); $document->addScript( JURI::base(true) . '/plugins/content/phocagalleryslideshow.js'); // Start Plugin $regex_one = '/({pgslideshow\s*)(.*?)(})/si'; $regex_all = '/{pgslideshow\s*.*?}/si'; $matches = array(); $count_matches = preg_match_all($regex_all,$article->text,$matches,PREG_OFFSET_CAPTURE | PREG_PATTERN_ORDER); $customCSS = ''; $customCSS2 = ''; for($j = 0; $j < $count_matches; $j++) { // Plugin variables $id = 0; $width = 640; $height = 480; $delay = 3000; $image = 'L'; // Get plugin parameters $phocagallery = $matches[0][$j][0]; preg_match($regex_one,$phocagallery,$phocagallery_parts); $parts = explode("|", $phocagallery_parts[2]); $values_replace = array ("/^'/", "/'$/", "/^'/", "/'$/", "/<br \/>/"); foreach($parts as $key => $value) { $values = explode("=", $value, 2); foreach ($values_replace as $key2 => $values2) { $values = preg_replace($values2, '', $values); } // Get plugin parameters from article if($values[0]=='id') {$id = $values[1];} else if($values[0]=='height') {$height = $values[1];} else if($values[0]=='width') {$width = $values[1];} else if($values[0]=='delay') {$delay = $values[1];} else if($values[0]=='image') {$image = $values[1];} } if ($id > 0) { $c = time() * rand(0,10); $query = ' SELECT a.filename' . ' FROM #__phocagallery_categories AS cc' . ' LEFT JOIN #__phocagallery AS a ON a.catid = cc.id' . ' WHERE cc.published = 1 AND a.published = 1 AND a.catid = ' . (int)$id; $db->setQuery($query); $images = $db->loadObjectList(); $script = '<script type="text/javascript">' . "\n"; $script .= 'fadeimages'.$c.' = new Array();' . "\n"; $n = count( $images ); for ($i = 0; $i < $n; $i++) { switch ($image) { case 'S': $imageName = PhocaGalleryFileThumbnail::getThumbnailName($images[$i]->filename, 'small'); break; case 'M': $imageName = PhocaGalleryFileThumbnail::getThumbnailName($images[$i]->filename, 'medium'); break; case 'O': $imageName->rel = PhocaGalleryFile::getFileOriginal($images[$i]->filename , 1); break; case 'L': $imageName = PhocaGalleryFileThumbnail::getThumbnailName($images[$i]->filename, 'large'); default: break; } $script .= 'fadeimages'.$c.'['.$i.'] = [\'' . JURI::base(true).'/'.$imageName->rel . '\', \'\', \'\'];'. "\n"; } //$script .= 'new fadeshow(fadeimages'.$c.', '.$width.', '.$height.', 0, '.$delay.', 1, \'R\')' . "\n"; // Added by Ingo $script .= "function fadeshowladen() {\n"; $script .= 'new fadeshow(fadeimages'.$c.', '.$width.', '.$height.', 0, '.$delay.', 1, \'R\');' . "\n"; $script .= "}\n"; $script .= "if(window.onload) {\n"; $script .= "var temp = window.onload;\n"; $script .= "window.onload=function(e) {\n"; $script .= "temp(e);\n"; $script .= "fadeshowladen();\n"; $script .= "};\n}\n else{\n window.onload=function(e) {\n"; $script .= "fadeshowladen();\n"; $script .= "};\n}"; /* $script .= 'new fadeshow(fadeimages'.$c.', '.$width.', '.$height.', 0, '.$delay.', 1, \'R\')' . "\n";*/ $script .= '</script>'. "\n"; $c++; $output = ''; $output .= '<div class="phocagalleryslideshow" style="text-align:center;"><div id="phocagallerycontent"></div>' . "\n"; $output .= $script; $output .='</div>'; $article->text = preg_replace($regex_all, $output, $article->text, 1); } } return true; } } ?>