registerFunction( 'onPrepareContent', 'jw_gallery' ); function jw_gallery( $published, &$row, &$params, $page=0 ) { if (!$published) { $row->text = preg_replace( "#{gallery}(.*?){/gallery}#s", "" , $row->text ); return; } // Variables global $database, $mainframe, $option, $task, $mosConfig_lang, $mosConfig_absolute_path, $mosConfig_live_site, $my, $Itemid; $rootfolder = '/cg_media/'; $query = "SELECT id FROM #__mambots WHERE element = 'plugin_jw_sig' AND folder = 'content'"; $database->setQuery( $query ); $id = $database->loadResult(); $mambot = new mosMambot( $database ); $mambot->load( $id ); $param =& new mosParameters( $mambot->params ); $displaynavtip = $param->get('displaynavtip', 1); $navtip = $param->get('navtip', 'Navigation tip: Hover mouse on top of the right or left side of the image to see the next or previous image respectively.'); $displaymessage = $param->get('displaymessage', 1); $message = $param->get('message', 'You are browsing images from the article:'); if (preg_match_all("#{gallery}(.*?){/gallery}#s", $row->text, $matches, PREG_PATTERN_ORDER) > 0) { $sigcount = -1; foreach ($matches[0] as $match) { $sigcount++; $_images_dir_ = preg_replace("/{.+?}/", "", $match); unset($images); $noimage = 0; // read directory if ($dh = opendir($mosConfig_absolute_path.$rootfolder.$_images_dir_.'120')) { while (($f = readdir($dh)) !== false) { if((substr(strtolower($f),-3) == 'jpg') || (substr(strtolower($f),-3) == 'gif') || (substr(strtolower($f),-3) == 'png')) { $noimage++; $images[] = array('filename' => $f); array_multisort($images, SORT_ASC, SORT_REGULAR); } } closedir($dh); } $itemtitle = preg_replace("/\"/", "'", $row->title); if($noimage) { $html = '
'; for($a = 0;$a<$noimage;$a++) { if($images[$a]['filename'] != '') { $html .= '
'; } } $html .="\n
\n
\n"; } $row->text = preg_replace( "#{gallery}".$_images_dir_."{/gallery}#s", $html , $row->text ); } } } ?>