Exemplo n.º 1
0
    function onContentPrepare($context, &$row, &$params, $limitstart = 0)
    {
        $gd_exists = true;
        if (!isset($row->text)) {
            return;
        }
        if (!preg_match("#{AdmirorGallery[^}]*}(.*?){/AdmirorGallery}|{AG[^}]*}(.*?){/AG}|{ag[^}]*}(.*?){/ag}#s", $row->text)) {
            return;
        }
        $doc = JFactory::getDocument();
        //check for PHP version, 5.0.0 and above are accepted
        if (strnatcmp(phpversion(), '5.0.0') <= 0) {
            $doc->addStyleSheet('plugins/content/admirorgallery/admirorgallery/AdmirorGallery.css');
            $html = '<div class="error">Admiror Gallery requires PHP version 5.0.0 or greater!</div>' . "\n";
            if (preg_match_all("#{AdmirorGallery[^}]*}(.*?){/AdmirorGallery}#s", $row->text, $matches, PREG_PATTERN_ORDER) > 0 || preg_match_all("#{AG[^}]*}(.*?){/AG}#s", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
                foreach ($matches[0] as $match) {
                    $galleryname = preg_replace("/{.+?}/", "", $match);
                    $row->text = preg_replace("#{AdmirorGallery[^}]*}" . $galleryname . "{/AdmirorGallery}|{AG[^}]*}" . $galleryname . "{/AG}#s", "<div style='clear:both'></div>" . $html, $row->text, 1);
                }
            }
            return;
        }
        // Load gallery class php script
        require_once dirname(__FILE__) . '/admirorgallery/classes/agGallery.php';
        //CreateGallerys
        if (preg_match_all("#{AdmirorGallery[^}]*}(.*?){/AdmirorGallery}|{AG[^}]*}(.*?){/AG}#s", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
            $AG = new agGallery($this->params, JURI::base(), JPATH_SITE, $doc);
            //Load current language
            JPlugin::loadLanguage('plg_content_admirorgallery', JPATH_ADMINISTRATOR);
            // Version check
            $version = new JVersion();
            if ($version->PRODUCT == "Joomla!" && $version->RELEASE == "1.5") {
                $AG->addError(JText::_('AG_ADMIROR_GALLERY_PLUGIN_FUNCTIONS_ONLY_UNDER'));
            }
            //if any image is corrupted supresses recoverable error
            ini_set('gd.jpeg_ignore_warning', $AG->params['ignoreError']);
            if ($AG->params['ignoreAllError']) {
                error_reporting('E_NOTICE');
            }
            //Joomla specific variables is passed as parametars for agGallery independce from specific CMS
            $AG->loadJS('AG_jQuery.js');
            $AG->articleID = $row->id;
            $queryArray = null;
            $queryString = strip_tags($_SERVER['QUERY_STRING']);
            parse_str($queryString, $queryArray);
            $basepath = $AG->sitePhysicalPath . $AG->staticParams['rootFolder'];
            $realBase = realpath($basepath);
            $i = 0;
            while (array_key_exists('AG_form_albumInitFolders_' . $i, $queryArray)) {
                $userpath = $basepath . $queryArray['AG_form_albumInitFolders_' . $i];
                $realUserPath = realpath($userpath);
                if ($realUserPath === false || strpos($realUserPath, $realBase) !== 0) {
                    header('Location: ' . strip_tags($_SERVER['PHP_SELF']));
                }
                $i++;
            }
            //generate gallery html
            foreach ($matches[0] as $match) {
                $AG->index++;
                $AG->initGallery($match);
                // match = ;
                // ERROR - Cannot find folder with images
                if (!file_exists($AG->imagesFolderPhysicalPath)) {
                    $AG->addError(JText::sprintf('AG_CANNOT_FIND_FOLDER_INSIDE_FOLDER', $AG->imagesFolderName, $AG->imagesFolderPhysicalPath));
                }
                //Create directory in thumbs for gallery
                JFolder::create($AG->thumbsFolderPhysicalPath, 0755);
                if (is_writable($AG->thumbsFolderPhysicalPath)) {
                    $AG->generateThumbs();
                } else {
                    $AG->addError(JText::sprintf('AG_CANNOT_CREATE_THUMBS_PERMMISIONS_ERROR', $AG->thumbsFolderPhysicalPath));
                }
                include dirname(__FILE__) . '/admirorgallery/templates/' . $AG->params['template'] . '/index.php';
                $AG->clearOldThumbs();
                $row->text = $AG->writeErrors() . preg_replace("#{AdmirorGallery[^}]*}" . $AG->imagesFolderNameOriginal . "{/AdmirorGallery}|{AG[^}]*}" . $AG->imagesFolderNameOriginal . "{/AG}#s", "<div style='clear:both'></div>" . $html, $row->text, 1);
            }
            // foreach($matches[0] as $match)
            $row->text .= '<script type="text/javascript">';
            if (strpos($_SERVER['REQUEST_URI'], 'AG_form_paginInitPages_') !== false) {
                $row->text .= '
                    AG_jQuery(document).ready(function() {
                        AG_jQuery(document).scrollTop(AG_jQuery("#AG_0' . $AG->articleID . '").offset().top);
                    });';
            }
            $row->text .= '  
            function AG_form_submit_' . $AG->articleID . '(galleryIndex,paginPage,albumFolder,linkID) {

            var AG_URL="' . strip_tags($_SERVER['REQUEST_URI']) . '";
            var split = AG_URL.split("AG_MK=0");
            if(split.length==3){
                AG_URL = split[0]+split[2];
            }
            var char = AG_URL.charAt((AG_URL.length)-1);
            if ((char != "?") && (char != "&"))
            {
                AG_URL += (AG_URL.indexOf("?")<0) ? "?" : "&";
            }
            AG_URL+="AG_MK=0&";

            AG_jQuery(".ag_hidden_ID").each(function(index) {

                var paginInitPages=eval("paginInitPages_"+AG_jQuery(this).attr(\'id\'));
                var albumInitFolders=eval("albumInitFolders_"+AG_jQuery(this).attr(\'id\'));

                if(AG_jQuery(this).attr(\'id\') == ' . $AG->articleID . '){
                    var paginInitPages_array = paginInitPages.split(",");
                    paginInitPages_array[galleryIndex] = paginPage;
                    paginInitPages = paginInitPages_array.toString();
                    var albumInitFolders_array = albumInitFolders.split(",");
                    albumInitFolders_array[galleryIndex] = albumFolder;
                    albumInitFolders = albumInitFolders_array.toString();
                }
                AG_URL+="AG_form_paginInitPages_"+AG_jQuery(this).attr(\'id\')+"="+paginInitPages+"&";
                AG_URL+="AG_form_albumInitFolders_"+AG_jQuery(this).attr(\'id\')+"="+albumInitFolders+"&";
            });

            AG_URL+="AG_MK=0";

            window.open(AG_URL,"_self");

            }
            </script>

            <span class="ag_hidden_ID" id="' . $AG->articleID . '"></span>

            ' . "\n";
            /* ========================= SIGNATURE ====================== */
            if ($AG->params['showSignature']) {
                $row->text .= '<div style="display:block; font-size:10px;">';
            } else {
                $row->text .= '<div style="display:block; font-size:10px; overflow:hidden; height:1px; padding-top:1px;">';
            }
            $row->text .= '<br /><a href="http://www.admiror-design-studio.com" target="_blank">AdmirorGallery ' . AG_VERSION . '</a>, ' . JText::_("AG_AUTHORS") . ' <a href="http://www.vasiljevski.com/" target="_blank">Vasiljevski</a> & <a href="http://www.admiror-design-studio.com" target="_blank">Kekeljevic</a>.<br /></div>';
        }
        //if (preg_match_all("#{AdmirorGallery}(.*?){/AdmirorGallery}#s", $row->text, $matches, PREG_PATTERN_ORDER)>0)
    }
Exemplo n.º 2
0
    function onPrepareContent(&$row, &$params, $limitstart)
    {
        $gd_exists = true;
        // just startup
        global $mainframe;
        if (!preg_match("#{AdmirorGallery[^}]*}(.*?){/AdmirorGallery}|{AG[^}]*}(.*?){/AG}#s", $row->text)) {
            return;
        }
        $doc =& JFactory::getDocument();
        //check for PHP version, 5.0.0 and above are accepted
        if (strnatcmp(phpversion(), '5.0.0') <= 0) {
            $doc->addStyleSheet('plugins/content/AdmirorGallery/AdmirorGallery.css');
            $html = '<div class="error">Admiror Gallery requires PHP version 5.0.0 or greater!</div>' . "\n";
            if (preg_match_all("#{AdmirorGallery[^}]*}(.*?){/AdmirorGallery}#s", $row->text, $matches, PREG_PATTERN_ORDER) > 0 || preg_match_all("#{AG[^}]*}(.*?){/AG}#s", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
                foreach ($matches[0] as $match) {
                    $galleryname = preg_replace("/{.+?}/", "", $match);
                    $row->text = preg_replace("#{AdmirorGallery[^}]*}" . $galleryname . "{/AdmirorGallery}|{AG[^}]*}" . $galleryname . "{/AG}#s", "<div style='clear:both'></div>" . $html, $row->text, 1);
                }
            }
            return;
        }
        // Load gallery class php script
        require_once dirname(__FILE__) . '/AdmirorGallery/classes/agGallery.php';
        require_once dirname(__FILE__) . '/AdmirorGallery/classes/jquery.scroll.js.php';
        //CreateGallerys
        if (preg_match_all("#{AdmirorGallery[^}]*}(.*?){/AdmirorGallery}|{AG[^}]*}(.*?){/AG}#s", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
            $plugin =& JPluginHelper::getPlugin('content', 'AdmirorGallery');
            $AG = new agGallery(new JParameter($plugin->params), JURI::base(), JPATH_SITE, $doc);
            //Load current language
            JPlugin::loadLanguage('plg_content_AdmirorGallery', JPATH_ADMINISTRATOR);
            // Version check
            $version = new JVersion();
            if ($version->PRODUCT == "Joomla!" && $version->RELEASE != "1.5") {
                $AG->addError(JText::_('Admiror Designe Studio "Admiror Gallery" Plugin functions only under Joomla! 1.5'));
            }
            //if any image is corrupted supresses recoverable error
            ini_set('gd.jpeg_ignore_warning', $AG->params['ignoreError']);
            if ($AG->params['ignoreAllError']) {
                error_reporting('E_NOTICE');
            }
            //Joomla specific variables is passed as parametars for agGallery independce from specific CMS
            $AG->loadJS('AG_jQuery.js');
            $AG->articleID = $row->id;
            //generate gallery html
            foreach ($matches[0] as $match) {
                $AG->index++;
                $AG->initGallery($match);
                // match = ;
                // ERROR - Cannot find folder with images
                if (!file_exists($AG->imagesFolderPhysicalPath)) {
                    $AG->addError(JText::sprintf('Cannot find folder inside folder', $AG->imagesFolderName, $AG->imagesFolderPhysicalPath));
                }
                //Create directory in thumbs for gallery
                JFolder::create($AG->thumbsFolderPhysicalPath, 0755);
                if (is_writable($AG->thumbsFolderPhysicalPath)) {
                    $AG->generateThumbs();
                } else {
                    $AG->addError(JText::sprintf('Admiror Gallery cannot create thumbnails in %s <br/>Check folder permmisions!', $AG->thumbsFolderPhysicalPath));
                }
                include dirname(__FILE__) . '/AdmirorGallery/templates/' . $AG->params['template'] . '/index.php';
                $AG->clearOldThumbs();
                $row->text = $AG->writeErrors() . preg_replace("#{AdmirorGallery[^}]*}" . $AG->imagesFolderNameOriginal . "{/AdmirorGallery}|{AG[^}]*}" . $AG->imagesFolderNameOriginal . "{/AG}#s", "<div style='clear:both'></div>" . $html, $row->text, 1);
            }
            // foreach($matches[0] as $match)
            // AG Form
            $row->text .= '

<script type="text/javascript">
function AG_form_submit_' . $AG->articleID . '(galleryIndex,paginPage,albumFolder,linkID) {

var AG_URL="' . JURI::getInstance()->toString() . '";
var split = AG_URL.split("AG_MK=0");
if(split.length==3){
    AG_URL = split[0]+split[2];
}
var char = AG_URL.charAt((AG_URL.length)-1);
if ((char != "?") && (char != "&"))
{
    AG_URL += (AG_URL.indexOf("?")<0) ? "?" : "&";
}
AG_URL+="AG_MK=0&";

AG_jQuery(".ag_hidden_ID").each(function(index) {

    var paginInitPages=eval("paginInitPages_"+AG_jQuery(this).attr(\'id\'));
    var albumInitFolders=eval("albumInitFolders_"+AG_jQuery(this).attr(\'id\'));

    if(AG_jQuery(this).attr(\'id\') == ' . $AG->articleID . '){
        var paginInitPages_array = paginInitPages.split(",");
        paginInitPages_array[galleryIndex] = paginPage;
        paginInitPages = paginInitPages_array.toString();
        var albumInitFolders_array = albumInitFolders.split(",");
        albumInitFolders_array[galleryIndex] = albumFolder;
        albumInitFolders = albumInitFolders_array.toString();
    }
    AG_URL+="AG_form_paginInitPages_"+AG_jQuery(this).attr(\'id\')+"="+paginInitPages+"&";
    AG_URL+="AG_form_albumInitFolders_"+AG_jQuery(this).attr(\'id\')+"="+albumInitFolders+"&";
});

AG_URL+="AG_form_scrollTop"+"="+AG_jQuery(window).scrollTop()+"&";
AG_URL+="AG_form_scrollLeft"+"="+AG_jQuery(window).scrollLeft()+"&";

AG_URL+="AG_MK=0";

window.open(AG_URL,"_self");

}
</script>

<span class="ag_hidden_ID" id="' . $AG->articleID . '"></span>

' . "\n";
            /* ========================= SIGNATURE ====================== */
            if ($AG->params['showSignature']) {
                $row->text .= '<div style="display:block; font-size:10px;">';
            } else {
                $row->text .= '<div style="display:block; font-size:10px; overflow:hidden; height:1px; padding-top:1px;">';
            }
            $row->text .= '<br /><a href="http://www.admiror-design-studio.com/admiror/en/design-resources/joomla-admiror-gallery" target="_blank">AdmirorGallery 3.0</a>, ' . JText::_("author/s") . ' <a href="http://www.vasiljevski.com/" target="_blank">Vasiljevski</a> & <a href="http://www.admiror-design-studio.com" target="_blank">Kekeljevic</a>.<br /></div>';
        }
        //if (preg_match_all("#{AdmirorGallery}(.*?){/AdmirorGallery}#s", $row->text, $matches, PREG_PATTERN_ORDER)>0)
    }
Exemplo n.º 3
0
 function onPrepareContent(&$row, &$params, $limitstart)
 {
     $gd_exists = true;
     // just startup
     global $mainframe;
     // checking
     if (!preg_match("#{AdmirorGallery[^}]*}(.*?){/AdmirorGallery}#s", $row->text)) {
         return;
     }
     // GD2 Library Check
     if (!function_exists('gd_info')) {
         // ERROR - Invalid image
         $row->text .= _AD_NOGD;
         $gd_exists = false;
     }
     // Version check
     $version = new JVersion();
     if ($version->PRODUCT == "Joomla!" && $version->RELEASE != "1.5") {
         echo '<div class="message">' . _AD_JV_CHECK . '</div>';
     }
     // Load functions
     require_once JPATH_BASE . DS . 'plugins/content/AdmirorGallery/classes/agGallery.php';
     require_once JPATH_BASE . DS . 'plugins/content/AdmirorGallery/classes/agHelper.php';
     //CreateGallerys
     if (preg_match_all("#{AdmirorGallery[^}]*}(.*?){/AdmirorGallery}#s", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
         $plugin =& JPluginHelper::getPlugin('content', 'AdmirorGallery');
         $ag = new agGallery(new JParameter($plugin->params));
         $ag->setSitePath(JURI::base());
         $ag->setThumbPath(JPATH_SITE . '/plugins/content/AdmirorGallery/thumbs/');
         agHelper::ag_cleanThumbsFolder(JPATH_SITE . $ag->params['rootFolder'], $ag->thumbsPath);
         //if any image is corrupted supresses recoverable error
         ini_set('gd.jpeg_ignore_warning', $ag->params['ignoreError']);
         if ($ag->params['ignoreAllError']) {
             error_reporting('E_NOTICE');
         }
         $ag->doc =& JFactory::getDocument();
         $ag->addCSS('/plugins/content/AdmirorGallery/AdmirorGallery.css');
         if ($ag->params['loadjQuery']) {
             $ag->addJavaScript('/plugins/content/AdmirorGallery/jquery.js');
         }
         if ($ag->params['jQueryNoConflict']) {
             $ag->addJavaScriptCode('jQuery.noConflict();');
         }
         $galleryCount = -1;
         $articleID = $row->id;
         //generate gallery html
         foreach ($matches[0] as $match) {
             $galleryCount++;
             $ag->readInlineParams($match);
             //set gallery path
             $ag->setImagesFolderName(preg_replace("/{.+?}/", "", $match));
             $ag->setImagesFolderPath(JPATH_SITE . $ag->params['rootFolder'] . $ag->imagesFolderName . '/');
             // ERROR - Cannot find folder with images
             if (!file_exists($ag->imagesFolderPath)) {
                 $row->text .= '<div class="error">Cannot find folder "' . $ag->imagesFolderName . '" inside "' . $ag->imagesFolderPath . '" folder.</div>';
             }
             // Create Image description array $imagesDescritions. Localization supported
             $ag->readDescriptionFiles();
             //include (JPATH_BASE.DS.'plugins/content/AdmirorGallery/descriptions.php');
             $ag->setThumbPath(JPATH_SITE . '/plugins/content/AdmirorGallery/thumbs/' . $ag->imagesFolderName . '/');
             $ag->loadImageFiles();
             if ($gd_exists) {
                 //                      //Create directory in thumbs for gallery
                 JFolder::create($ag->thumbsPath, 0755);
                 $row->text .= $ag->generateThumbs();
             }
             $popup = new POPUP();
             include JPATH_BASE . DS . 'plugins/content/AdmirorGallery/popup_engine/' . $ag->params['popupEngine'] . '/index.php';
             include JPATH_BASE . DS . 'plugins/content/AdmirorGallery/templates/' . $ag->params['galleryStyle'] . '/index.php';
             agHelper::ag_clearOldThumbs($ag->thumbsPath, $ag->imagesFolderPath);
             $row->text = preg_replace("#{AdmirorGallery[^}]*}" . $ag->imagesFolderName . "{/AdmirorGallery}#s", "<div style='clear:both'></div>" . $html, $row->text, 1);
         }
         // foreach($matches[0] as $match)
         /* ========================= SIGNATURE ====================== */
         //
         if ($ag->params['showSignature'] == "1") {
             $row->text .= '<div style="display:block; font-size:10px;">';
         } else {
             $row->text .= '<div style="display:block; font-size:10px; overflow:hidden; height:1px; padding-top:1px;">';
         }
         $row->text .= '<br /><a href="http://www.admiror-design-studio.com/admiror/en/design-resources/joomla-admiror-gallery" target="_blank">AdmirorGallery</a>, created by <a href="http://www.admiror-design-studio.com" target="_blank">Kekeljevic</a> & <a href="http://www.vasiljevski.com/" target="_blank">Vasiljevski</a>.<br />';
         $row->text .= '</div>';
         //
         /* ------------------------ SIGNATURE ---------------------- */
     }
     //if (preg_match_all("#{AdmirorGallery}(.*?){/AdmirorGallery}#s", $row->text, $matches, PREG_PATTERN_ORDER)>0)
 }