PageRenderTime 53ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/components/com_oziogallery2/views/02flashgallery/view.html.php

https://github.com/DanielTichy/plagat.com
PHP | 316 lines | 244 code | 64 blank | 8 comment | 45 complexity | aad67f3ed720daea6d467d4c9d135a6a MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-3-Clause, AGPL-1.0, MIT
  1. <?php
  2. defined( '_JEXEC' ) or die( 'Restricted access' );
  3. jimport( 'joomla.application.component.view');
  4. class OzioGalleryView02FlashGallery extends JView
  5. {
  6. function display( $tpl = null )
  7. {
  8. global $mainframe;
  9. $document = & JFactory::getDocument();
  10. $menus = & JSite::getMenu();
  11. $menu = $menus->getActive();
  12. $params = $mainframe->getParams('com_oziogallery2');
  13. $larghezza = $params->def('width', 640);
  14. $altezza = $params->def('height', 480);
  15. $flickr = (int) $params->def('flickr', 0);
  16. $user_id = $params->def('user_id', 0);
  17. $folder = $params->def('folder');
  18. $modifiche = (int) $params->def('modifiche', 0);
  19. $debug = (int) $params->def('debug');
  20. $ordinamento = (int) $params->def('ordinamento');
  21. //inizio parametri settings
  22. $thumb_bg_color = $params->def('thumb_bg_color');
  23. $thumb_bg_over = $params->def('thumb_bg_over');
  24. $scroll_but_bg = $params->def('scroll_but_bg');
  25. $scroll_but_arrow = $params->def('scroll_but_arrow');
  26. $scroll_but_bg_over = $params->def('scroll_but_bg_over');
  27. $scroll_but_arrow_over = $params->def('scroll_but_arrow_over');
  28. $big_pic_border = $params->def('big_pic_border');
  29. $next_pic_bg = $params->def('next_pic_bg');
  30. $next_pic_arrow = $params->def('next_pic_arrow');
  31. $next_pic_bg_over = $params->def('next_pic_bg_over');
  32. $next_pic_arrow_over = $params->def('next_pic_arrow_over');
  33. $background_color = $params->def('background_color');
  34. $text_visible = (int) $params->def('text_visible');
  35. $text_color = $params->def('text_color');
  36. $fullscreen_visible = (int) $params->def('fullscreen_visible');
  37. $thumb_bg_color = str_replace( '#', '', $thumb_bg_color );
  38. $thumb_bg_over = str_replace( '#', '', $thumb_bg_over );
  39. $scroll_but_bg = str_replace( '#', '', $scroll_but_bg );
  40. $scroll_but_arrow = str_replace( '#', '', $scroll_but_arrow );
  41. $scroll_but_bg_over = str_replace( '#', '', $scroll_but_bg_over );
  42. $scroll_but_arrow_over = str_replace( '#', '', $scroll_but_arrow_over );
  43. $big_pic_border = str_replace( '#', '', $big_pic_border );
  44. $next_pic_bg = str_replace( '#', '', $next_pic_bg );
  45. $next_pic_arrow = str_replace( '#', '', $next_pic_arrow );
  46. $next_pic_bg_over = str_replace( '#', '', $next_pic_bg_over );
  47. $next_pic_arrow_over = str_replace( '#', '', $next_pic_arrow_over );
  48. $background_color = str_replace( '#', '', $background_color );
  49. $text_color = str_replace( '#', '', $text_color );
  50. switch ($params->get( 'rotatoralign' ))
  51. {
  52. case '0': $float = 'left'; break;
  53. case '1': $float = 'right'; break;
  54. case '2': $float = 'inherit'; break;
  55. default: $float = 'inherit'; break;
  56. }
  57. switch ($params->get( 'table' ))
  58. {
  59. case '0': $table = 'left'; break;
  60. case '1': $table = 'right'; break;
  61. case '2': $table = 'center'; break;
  62. default: $table = 'center'; break;
  63. }
  64. $document->addScript(JURI::root(true).'/components/com_oziogallery2/assets/js/15/swfobject.js');
  65. $document->addCustomTag('
  66. <style type="text/css">
  67. .oziofloat {
  68. width: '.$larghezza.';
  69. height: '.$altezza.';
  70. margin: 0px auto;
  71. float: '.$float.';
  72. }
  73. .oziotime {
  74. font-size: 0.8em;
  75. color:#ccc;
  76. }
  77. </style>
  78. ');
  79. if (is_object( $menu )) {
  80. $menu_params = new JParameter( $menu->params );
  81. if (!$menu_params->get( 'page_title')) {
  82. $params->set('page_title', $menu->name);
  83. }
  84. } else {
  85. $params->set('page_title', JText::_('Ozio'));
  86. }
  87. $document->setTitle($params->get('page_title'));
  88. $document->setMetadata( 'keywords' , $params->get('page_title') );
  89. if ($mainframe->getCfg('MetaTitle') == '1') {
  90. $mainframe->addMetaTag('title', $params->get('page_title'));
  91. }
  92. if( $flickr == 0 ) :
  93. jimport('joomla.filesystem.file');
  94. // creazione file xml al volo
  95. $VAMBpathAssoluto = JPATH_SITE;
  96. $VAMBpathAssoluto = str_replace("\\", "/" , $VAMBpathAssoluto);
  97. $path = $VAMBpathAssoluto .'/'. $folder . '/';
  98. $dir_images = rtrim(JURI::root() . $folder . '/') ;
  99. $dir_files = rtrim(JURI::root() . 'images/oziogallery2') . '/';
  100. $xmltitle = $menu->name;
  101. $xmltitle = str_replace( ' ', '', $xmltitle );
  102. $regex = array('#(\.){2,}#', '#[^A-Za-z0-9\.\_\- ]#', '#^\.#');
  103. $xmltitle = preg_replace($regex, '', $xmltitle);
  104. $xmlnamesuff = $params->def('xmlnamesuff');
  105. $xmlnamesuff = str_replace( ' ', '', $xmlnamesuff );
  106. $regex = array('#(\.){2,}#', '#[^A-Za-z0-9\.\_\- ]#', '#^\.#');
  107. $xmlnamesuff = preg_replace($regex, '', $xmlnamesuff);
  108. if ($xmlnamesuff != null) :
  109. $xmlname = $xmltitle . '_'. $xmlnamesuff;
  110. else:
  111. $xmlname = $xmltitle;
  112. endif;
  113. // nome del file creato
  114. $filename = JPATH_SITE.'/components/com_oziogallery2/skin/flashgallery/xml/flashgallery_'. $xmlname .'.xml';
  115. $settings = JPATH_SITE.'/components/com_oziogallery2/skin/flashgallery/xml/settings_'. $xmlname .'.xml';
  116. $foldername = $path;
  117. $this->assignRef('nomexml' , $xmlname);
  118. if (JFolder::exists( $path ))
  119. {
  120. if ( @filemtime($foldername) >= @filemtime($filename) )
  121. {
  122. //inizio sezione XML setting
  123. $generasetting = fopen($settings, 'w');
  124. $linea = '<?xml version="1.0" ?>'."\n";
  125. $linea .= '<colors'."\n";
  126. $linea .= 'thumb_bg_color="'. $thumb_bg_color . '"'."\n";
  127. $linea .= 'thumb_bg_over="'. $thumb_bg_over . '"'."\n";
  128. $linea .= 'scroll_but_bg="'. $scroll_but_bg . '"'."\n";
  129. $linea .= 'scroll_but_arrow="'. $scroll_but_arrow . '"'."\n";
  130. $linea .= 'scroll_but_bg_over="'. $scroll_but_bg_over . '"'."\n";
  131. $linea .= 'scroll_but_arrow_over="'. $scroll_but_arrow_over . '"'."\n";
  132. $linea .= 'big_pic_border="'. $big_pic_border . '"'."\n";
  133. $linea .= 'next_pic_bg="'. $next_pic_bg . '"'."\n";
  134. $linea .= 'next_pic_arrow="'. $next_pic_arrow . '"'."\n";
  135. $linea .= 'next_pic_bg_over="'. $next_pic_bg_over . '"'."\n";
  136. $linea .= 'next_pic_arrow_over="'. $next_pic_arrow_over . '"'."\n";
  137. $linea .= 'background_color="'. $background_color . '"'."\n";
  138. $linea .= 'text_visible="'. $text_visible . '"'."\n";
  139. $linea .= 'text_color="'. $text_color . '"'."\n";
  140. $linea .= 'fullscreen_visible="'. $fullscreen_visible . '"'."\n";
  141. $linea .= '/>'."\n";
  142. fwrite($generasetting, $linea);
  143. fclose($generasetting);
  144. //inizio sezione XML
  145. $thumb_sufix = ".th.";
  146. if ($hd = opendir($path)) {
  147. $files = array();
  148. while (false !== ($file = readdir($hd))) {
  149. if($file != '.' && $file != '..') {
  150. if (strpos($file, $thumb_sufix) === false) {
  151. if(is_file($path . $file) && preg_match('/\.(jpg|png|gif)$/i',$file)) {
  152. if( $ordinamento == 2 OR $ordinamento == 3 OR $ordinamento == 4) {
  153. $files[] = array(filemtime($path.$file), $file);
  154. }
  155. if( $ordinamento == 0 OR $ordinamento == 1) {
  156. $files[] = array(($path.$file), $file);
  157. }
  158. }
  159. }
  160. }
  161. }
  162. closedir($hd);
  163. }
  164. if(count($files)) {
  165. if( $ordinamento == 0 OR $ordinamento == 2 ) {
  166. sort($files);
  167. }else if ( $ordinamento == 1 OR $ordinamento == 3 ) {
  168. rsort($files);
  169. }else {
  170. shuffle($files);
  171. }
  172. //inizio sezione XML galleria
  173. $filehandle = fopen($filename, 'w');
  174. $string = '<pics>'."\n";
  175. $n = count($files);
  176. for ($i=0; $i<$n; $i++)
  177. {
  178. $row = &$files[$i];
  179. $title = preg_replace('/\.(jpg|png|gif)$/i','',$row[1]);
  180. $string .= '<pic src="' . $dir_images . $row[1] . '" title="/'. $title . '/"';
  181. $string .= "/>\n";
  182. }
  183. $string .= '</pics>'."\n";
  184. fwrite($filehandle, $string);
  185. fclose($filehandle);
  186. }
  187. }
  188. }
  189. else//Folder non esiste
  190. {
  191. $message = '<p><b><span style="color:#009933">'.JText::_('Attenzione').'</span><br />' . $folder
  192. .' <br /><span style="color:#009933">'.JText::_('Non corretto').'</span>
  193. <span style="color:#009933">'.JText::_('Controlla').'</span>
  194. </b></p>';
  195. $error[] = 0;
  196. echo $message;
  197. }
  198. $tempo = '<div>';
  199. $tempo .= '<span class="oziotime">';
  200. $foldername = $foldername;
  201. if (JFolder::exists($foldername)) {
  202. $tempo .= JText::_('Ultima modifica cartella'). ": " . date("d m Y H:i:s.", filemtime($foldername));
  203. $tempo .= '</span>';
  204. }
  205. $tempo .= ' | ';
  206. $filename = $filename;
  207. if (JFile::exists($filename)) {
  208. $tempo .= '<span class="oziotime">';
  209. $tempo .= JText::_('Ultima modifica file') . ": " . date("d m Y H:i:s.", filemtime($filename));
  210. $tempo .= '</span>';
  211. $tempo .= '</div>';
  212. }
  213. endif;
  214. // Debug per test interno
  215. $oziodebug = '<h2>DEBUG OZIO - FOR HELP</h2>';
  216. if( $flickr == 1 ) :
  217. $oziodebug .= '<pre>'.JText::_('PARAMETRO').' Flickr : ' .JText::_('ATTIVO').'</pre>';
  218. $oziodebug .= '<pre>'.JText::_('PARAMETRO').' User_id : ' .$user_id .'</pre>';
  219. else:
  220. $oziodebug .= '<pre>'.JText::_('PARAMETRO').' XML : ' .JText::_('ATTIVO') .'</pre>';
  221. endif;
  222. $oziodebug .= '<pre>'.JText::_('PARAMETRO').' larghezza : '.$larghezza .'</pre>';
  223. $oziodebug .= '<pre>'.JText::_('PARAMETRO').' altezza : '.$altezza .'</pre>';
  224. if( $flickr == 0 ) :
  225. if (is_writable(JPATH_SITE.DS . $folder)):
  226. $oziodebug .= '<pre>'.JText::_('CARTELLA'). ' ' . $folder . ' : '. JText::_( 'Writable' ) .'</pre>';
  227. else:
  228. $oziodebug .= '<pre>'.JText::_('CARTELLA'). ' ' . $folder . ' : '. JText::_( 'Unwritable' ) .'</pre>';
  229. endif;
  230. if (is_writable(JPATH_SITE.DS.'components'.DS.'com_oziogallery2'.DS.'skin'.DS.'flashgallery'.DS.'xml')):
  231. $oziodebug .= '<pre>'.JText::_('CARTELLA'). ' components/com_oziogallery2/skin/flashgallery/xml : '. JText::_( 'Writable' ) .'</pre>';
  232. else:
  233. $oziodebug .= '<pre>'.JText::_('CARTELLA'). ' components/com_oziogallery2/skin/flashgallery/xml : '. JText::_( 'Unwritable' ) .'</pre>';
  234. endif;
  235. endif;
  236. //fine debug
  237. $this->assignRef('params' , $params);
  238. $this->assignRef('altezza' , $altezza);
  239. $this->assignRef('larghezza' , $larghezza);
  240. $this->assignRef('flickr' , $flickr);
  241. $this->assignRef('user_id' , $user_id);
  242. $this->assignRef('table' , $table);
  243. $this->assignRef('filename' , $filename);
  244. $this->assignRef('foldername' , $foldername);
  245. $this->assignRef('tempo' , $tempo);
  246. $this->assignRef('modifiche' , $modifiche);
  247. $this->assignRef('debug' , $debug);
  248. $this->assignRef('oziodebug' , $oziodebug);
  249. parent::display($tpl);
  250. }
  251. }
  252. ?>