Ejemplo n.º 1
0
 /**
  * Method called to prepare content before html output
  *
  * @param string  $context    The context of the content being passed to the plugin.
  * @param object  &$item      The content object.  Note $item->text is also available
  * @param object  &$params    The content params.
  * @param integer $page       The 'page' number.
  *
  * @return mixed Returns void on success or false otherwise
  *
  * @since 2.5
  */
 public function onContentPrepare($context, &$row, &$params, $page = 0)
 {
     require_once dirname(__FILE__) . '/helper.php';
     // Simple performance check to determine whether bot should process further.
     if (JString::strpos($row->text, '{gallery}') === false) {
         return;
     }
     $regex = "/{gallery}(.+?){\\/gallery}/is";
     preg_match_all($regex, $row->text, $matches);
     if (!count($matches)) {
         return;
     }
     // Get the path for the layout file
     $version = new JVersion();
     if ($version->isCompatible(3.0)) {
         $path = JPluginHelper::getLayoutPath('content', 'gallery');
     } else {
         $path = GalleryHelper::getLayoutPath('content', 'gallery');
     }
     foreach ($matches[1] as $source) {
         $row->gallery = GalleryHelper::getGallery($source, '200x160', true, 90, 86400, $row->id);
         ob_start();
         include $path;
         $html = ob_get_contents();
         ob_end_clean();
         $regex = '/{gallery}' . str_replace('.', '\\.', str_replace('/', '\\/', $source)) . '{\\/gallery}/is';
         $row->text = preg_replace($regex, $html, $row->text);
     }
     return true;
 }
Ejemplo n.º 2
0
 private function loadSafeRequestVars()
 {
     if (JRequest::getVar('controller') == 'file') {
         $pathObject = GalleryHelper::splitPath(JRequest::getString('path', ''), false);
         $this->currentRequestPath = JFolder::makeSafe($pathObject->folderPath);
         $this->currentRequestFilename = JFile::makeSafe($pathObject->filename);
     } else {
         $this->currentRequestPath = JFolder::makeSafe(JRequest::getString('path', ''));
         $this->currentRequestFilename = '';
     }
 }
Ejemplo n.º 3
0
 public static function splitPath($path, $makeRelative = true)
 {
     if ($makeRelative) {
         $path = GalleryHelper::makeRelative($path);
     }
     $parts = explode('/', $path);
     $object = new ArrayObject();
     $object->filename = JFile::makeSafe(array_pop($parts));
     // last element is filename
     $object->folderPath = JFolder::makeSafe(implode(DS, $parts));
     // use rest as path
     return $object;
 }
Ejemplo n.º 4
0
 public function getReadableFolderName()
 {
     return GalleryHelper::getReadableFolderName($this->getFolderName());
 }
$photosPath = JRequest::getString('photos_path', '');
// ---
$folders = JFolder::folders($parentPath, '.', false, true);
$indexOfCurrentFolder = array_search($currentPath, $folders, true);
// TODO search in a non linear way
$previousFolder = '';
$oneLayerUp = false;
$nextFolder = '';
if ($photosPath . DS != $currentPath) {
    // if not root
    if ($indexOfCurrentFolder > 0) {
        $previousFolderPath = $folders[$indexOfCurrentFolder - 1];
        $previousFolderRelativePath = str_replace($photosPath . DS, '', $previousFolderPath);
        $hrefPreviousFolder = 'index.php?option=com_gallery&path=' . $previousFolderRelativePath;
        $previousFolder = str_replace($parentPath . DS, '', $previousFolderPath);
        $previousFolder = GalleryHelper::getReadableFolderName($previousFolder);
    }
    // one layer up
    $oneLayerUpRelativePath = str_replace($photosPath, '', $parentPath);
    $hrefOneLayerUp = JRoute::_('index.php?option=com_gallery&path=' . $oneLayerUpRelativePath);
    $oneLayerUp = true;
    // ---
    if (count($folders) > $indexOfCurrentFolder + 1) {
        $nextFolderPath = $folders[$indexOfCurrentFolder + 1];
        $nextFolderRelativePath = str_replace($photosPath . DS, '', $nextFolderPath);
        $hrefNextFolder = JRoute::_('index.php?option=com_gallery&path=' . $nextFolderRelativePath);
        $nextFolder = str_replace($parentPath . DS, '', $nextFolderPath);
        $nextFolder = GalleryHelper::getReadableFolderName($nextFolder);
    }
}
require JModuleHelper::getLayoutPath('mod_gallery_navigation', 'default');
Ejemplo n.º 6
0
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
/* include files (TODO use spl autoload) */
require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'helper.php';
require_once JPATH_COMPONENT . DS . 'model' . DS . 'gallery.php';
require_once JPATH_COMPONENT . DS . 'model' . DS . 'filesystem.php';
require_once JPATH_COMPONENT . DS . 'model' . DS . 'folder.php';
require_once JPATH_COMPONENT . DS . 'model' . DS . 'iptc.php';
require_once JPATH_COMPONENT . DS . 'model' . DS . 'photo.php';
require_once JPATH_COMPONENT . DS . 'controller.php';
/* --- */
/* Require specific controller if requested */
if ($controller = JRequest::getWord('controller', 'Gallery')) {
    $path = JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php';
    if (file_exists($path)) {
        require_once $path;
    }
}
/* --- */
GalleryHelper::validateRequestPath();
JPluginHelper::importPlugin('gallery');
// execute requested controller
$controller = JControllerLegacy::getInstance($controller);
if ($controller->getName() == 'gallery') {
    $controller->execute('createHtaccessFile');
    $controller->execute('createInitialDirectories');
    $controller->execute('setModuleParams');
}
$controller->execute(true);
$controller->redirect();
Ejemplo n.º 7
0
 private function setBreadcrumbs()
 {
     foreach ($this->folder->getFolderNames() as $folderName) {
         if ($folderName == '') {
             continue;
             // skip if foldername is empty
         }
         if (isset($currentPath)) {
             $currentPath .= DS . $folderName;
         } else {
             $currentPath = $folderName;
         }
         // replace underscores
         $folderName = GalleryHelper::getReadableFolderName($folderName);
         $this->pathway->addItem($folderName, 'index.php?option=com_gallery&path=' . $currentPath);
     }
 }