/**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // stats
     if (LINKLIST_ENABLE_STATISTICS) {
         $this->stats = array_merge(StatsCacheBuilder::getInstance()->getData(), UserStatsCacheBuilder::getInstance()->getData());
     }
     // get categories
     $categoryTree = new LinklistCategoryNodeTree('de.incendium.linklist.category');
     $this->categoryList = $categoryTree->getIterator();
     $this->categoryList->setMaxDepth(0);
     // get featured entries
     $this->featuredEntryList = new AccessibleEntryList();
     $this->featuredEntryList->getConditionBuilder()->add('entry.isFeatured = ?', array(1));
     $this->featuredEntryList->sqlLimit = 10;
     $this->featuredEntryList->sqlOrderBy = 'RAND()';
     $this->featuredEntryList->readObjects();
     // remove default breadcrumb entry and set current page as 'website'
     if (WCF::isLandingPage()) {
         MetaTagHandler::getInstance()->addTag('og:url', 'og:url', LinkHandler::getInstance()->getLink('Linklist', array('application' => 'linklist')), true);
         MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'website', true);
         MetaTagHandler::getInstance()->addTag('og:title', 'og:title', WCF::getLanguage()->get(PAGE_TITLE), true);
         MetaTagHandler::getInstance()->addTag('og:description', 'og:description', WCF::getLanguage()->get(PAGE_DESCRIPTION), true);
     }
 }
Example #2
0
 /**
  * Creates an iterator with settings
  * Resets class-wide results
  *
  * @param  $items  array
  *
  * @return object  \RecursiveIteratorIterator
  */
 protected function _createIterator(array $items)
 {
     $this->result = [];
     $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($items));
     $iterator->setMaxDepth($this->max_depth);
     return $iterator;
 }
 /**
  * Constructor.
  *
  * @param \RecursiveIteratorIterator $iterator    The Iterator to filter
  * @param array                      $comparators An array of \NumberComparator instances
  */
 public function __construct(\RecursiveIteratorIterator $iterator, array $comparators)
 {
     $minDepth = 0;
     $maxDepth = INF;
     foreach ($comparators as $comparator) {
         switch ($comparator->getOperator()) {
             case '>':
                 $minDepth = $comparator->getTarget() + 1;
                 break;
             case '>=':
                 $minDepth = $comparator->getTarget();
                 break;
             case '<':
                 $maxDepth = $comparator->getTarget() - 1;
                 break;
             case '<=':
                 $maxDepth = $comparator->getTarget();
                 break;
             default:
                 $minDepth = $maxDepth = $comparator->getTarget();
         }
     }
     $this->minDepth = $minDepth;
     $iterator->setMaxDepth(INF === $maxDepth ? -1 : $maxDepth);
     parent::__construct($iterator);
 }
    /**
     * Constructor.
     *
     * @param \RecursiveIteratorIterator $iterator    The Iterator to filter
     * @param int                        $minDepth    The min depth
     * @param int                        $maxDepth    The max depth
     */
    public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = INF)
    {
        $this->minDepth = $minDepth;
        $iterator->setMaxDepth(INF === $maxDepth ? -1 : $maxDepth);

        parent::__construct($iterator);
    }
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // get the accessible news categories
     $categoryTree = new NewsCategoryNodeTree('de.voolia.news.category');
     $this->categoryList = $categoryTree->getIterator();
     $this->categoryList->setMaxDepth(0);
     if (empty($_POST)) {
         // multilingualism
         if (!empty($this->availableContentLanguages)) {
             if (!$this->languageID) {
                 $language = LanguageFactory::getInstance()->getUserLanguage();
                 $this->languageID = $language->languageID;
             }
             if (!isset($this->availableContentLanguages[$this->languageID])) {
                 $languageIDs = array_keys($this->availableContentLanguages);
                 $this->languageID = array_shift($languageIDs);
             }
         }
         // set default publication and archivation date
         $dateTime = DateUtil::getDateTimeByTimestamp(TIME_NOW);
         $dateTime->setTimezone(WCF::getUser()->getTimeZone());
         $this->publicationDate = $this->archivingDate = $dateTime->format('c');
     }
     // add breadcrumbs
     NEWSCore::getInstance()->setBreadcrumbs();
 }
Example #6
0
 /**
  * @param IItem $root
  * @param int $maxDepth
  * @param array $filter
  */
 public function __construct(IItem $root, $maxDepth = -1, $filter = array())
 {
     parent::__construct($root, parent::SELF_FIRST);
     parent::setMaxDepth($maxDepth);
     $this->filter = $filter;
     $this->accessor = PropertyAccess::getPropertyAccessor();
     $this->iterated = new \SplObjectStorage();
 }
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // get categories
     $categoryTree = new FilebaseCategoryNodeTree('de.incendium.filebase.category');
     $this->categoryList = $categoryTree->getIterator();
     $this->categoryList->setMaxDepth(0);
     // add breadcrumbs
     FILEBASECore::getInstance()->setLocation($this->category->getParentCategories());
 }
Example #8
0
 private function _get_rit()
 {
     $config = (array) Kohana::$config->load('finder');
     $config = Arr::merge($config, $this->filter);
     Finder_Filter_Iterator::$config = $config;
     $this->dit = new Finder_Filter_Iterator($this->dit);
     $rit = new RecursiveIteratorIterator($this->dit, RecursiveIteratorIterator::SELF_FIRST);
     $rit->setMaxDepth($this->max_depth);
     return $rit;
 }
function getFiles($path)
{
    $dir = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
    // Flatten the recursive iterator, folders come before their files
    $it = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::SELF_FIRST);
    // Maximum depth is 1 level deeper than the base folder
    $it->setMaxDepth(1);
    $res = "";
    foreach ($it as $fileinfo) {
        $res .= '<option >' . $fileinfo->getFilename() . '</option>';
    }
    return $res;
}
/**
* Load the autoloaders added by the extensions.
*
* @param string $phpbb_root_path Path to the phpbb root directory.
*/
function phpbb_load_extensions_autoloaders($phpbb_root_path)
{
    $iterator = new \RecursiveIteratorIterator(new \phpbb\recursive_dot_prefix_filter_iterator(new \RecursiveDirectoryIterator($phpbb_root_path . 'ext/', \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS)), \RecursiveIteratorIterator::SELF_FIRST);
    $iterator->setMaxDepth(2);
    foreach ($iterator as $file_info) {
        if ($file_info->getFilename() === 'vendor' && $iterator->getDepth() === 2) {
            $filename = $file_info->getRealPath() . '/autoload.php';
            if (file_exists($filename)) {
                require $filename;
            }
        }
    }
}
Example #11
0
 protected function countThemePages($path)
 {
     $result = 0;
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
     $it->setMaxDepth(1);
     while ($it->valid()) {
         if (!$it->isDot() && !$it->isDir() && $it->getExtension() == 'htm') {
             $result++;
         }
         $it->next();
     }
     return $result;
 }
 private function discoverDirectory($path, $recursive = true)
 {
     if (false) {
         Log::Warning('Not valid directory: %s', $path);
         return;
     }
     $rdi = new \RecursiveDirectoryIterator(realpath($path));
     $iterator = new \RecursiveIteratorIterator($rdi);
     $iterator->setMaxDepth($recursive ? -1 : 0);
     foreach ($iterator as $file) {
         if ($file->isFile() && $file->getExtension() == 'php') {
             $this->AddClassFile($file->getRealPath());
         }
     }
 }
function debug_dir_list($dir_recurse_depth = 0, $dir_list_root = '.')
{
    // Create a recursive file system directory iterator.
    $dir_iter = new RecursiveDirectoryIterator($dir_list_root, RecursiveDirectoryIterator::SKIP_DOTS);
    // Create a recursive iterator.
    $iter = new RecursiveIteratorIterator($dir_iter, RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD);
    // The maximum recursive path.
    $iter->setMaxDepth($dir_recurse_depth);
    // List of paths Include current paths
    $path = array($dir_list_root);
    foreach ($iter as $path => $dir) {
        if ($dir_recurse_depth == 0 && $dir->isDir()) {
            $path .= "/";
        }
        $paths[] = $path;
    }
    return $paths;
}
Example #14
0
	function dir_list($dir_recurse_depth = 0, $dir_list_root = '.') {

		$dir_iter = new RecursiveDirectoryIterator(
			$dir_list_root,
			RecursiveDirectoryIterator::SKIP_DOTS);
		$iter = new RecursiveIteratorIterator(
			$dir_iter,
			RecursiveIteratorIterator::SELF_FIRST,
			RecursiveIteratorIterator::CATCH_GET_CHILD
			);

		$iter->setMaxDepth($dir_recurse_depth);
		$path = array($dir_list_root);
		foreach ($iter as $path => $dir) {
			if ($dir_recurse_depth == 0 && $dir->isDir()) $path .= "/";
				$paths[] = substr($path,2);
		}
		return $paths;
	}
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // get categories
     $excludedCategoryIDs = array_diff(FilebaseCategory::getAccessibleCategoryIDs(), FilebaseCategory::getAccessibleCategoryIDs(array('canUseCategory')));
     $categoryTree = new FilebaseCategoryNodeTree('de.incendium.filebase.category', 0, false, $excludedCategoryIDs);
     $this->categoryList = $categoryTree->getIterator();
     $this->categoryList->setMaxDepth(0);
     if (empty($_POST)) {
         // multilingualism
         if (!empty($this->availableContentLanguages)) {
             if (!$this->languageID) {
                 $language = LanguageFactory::getInstance()->getUserLanguage();
                 $this->languageID = $language->languageID;
             }
             if (!isset($this->availableContentLanguages[$this->languageID])) {
                 $languageIDs = array_keys($this->availableContentLanguages);
                 $this->languageID = array_shift($languageIDs);
             }
         }
     }
 }
Example #16
0
 /**
  * Renders a normal menu (called from {@link renderMenu()})
  *
  * @param  Zend_Navigation_Container $container   container to render
  * @param  string                    $ulClass     CSS class for first UL
  * @param  string                    $indent      initial indentation
  * @param  int|null                  $minDepth    minimum depth
  * @param  int|null                  $maxDepth    maximum depth
  * @param  bool                      $onlyActive  render only active branch?
  * @return string
  */
 protected function _renderMenu(Zend_Navigation_Container $container, $ulClass, $indent, $minDepth, $maxDepth, $onlyActive)
 {
     $html = '';
     // find deepest active
     if ($found = $this->findActive($container, $minDepth, $maxDepth)) {
         $foundPage = $found['page'];
         $foundDepth = $found['depth'];
     } else {
         $foundPage = null;
     }
     // create iterator
     $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::SELF_FIRST);
     if (is_int($maxDepth)) {
         $iterator->setMaxDepth($maxDepth);
     }
     // iterate container
     $prevDepth = -1;
     foreach ($iterator as $page) {
         $depth = $iterator->getDepth();
         $isActive = $page->isActive(true);
         if ($depth < $minDepth || !$this->accept($page)) {
             // page is below minDepth or not accepted by acl/visibilty
             continue;
         } else {
             if ($onlyActive && !$isActive) {
                 // page is not active itself, but might be in the active branch
                 $accept = false;
                 if ($foundPage) {
                     if ($foundPage->hasPage($page)) {
                         // accept if page is a direct child of the active page
                         $accept = true;
                     } else {
                         if ($foundPage->getParent()->hasPage($page)) {
                             // page is a sibling of the active page...
                             if (!$foundPage->hasPages() || is_int($maxDepth) && $foundDepth + 1 > $maxDepth) {
                                 // accept if active page has no children, or the
                                 // children are too deep to be rendered
                                 $accept = true;
                             }
                         }
                     }
                 }
                 if (!$accept) {
                     continue;
                 }
             }
         }
         // make sure indentation is correct
         $depth -= $minDepth;
         $myIndent = $indent . str_repeat('        ', $depth);
         if ($depth > $prevDepth) {
             // start new ul tag
             if ($ulClass && $depth == 0) {
                 $ulClass = ' class="' . $ulClass . '"';
             } else {
                 $ulClass = '';
             }
             $html .= $myIndent . '<ul' . $ulClass . '>' . self::EOL;
         } else {
             if ($prevDepth > $depth) {
                 // close li/ul tags until we're at current depth
                 for ($i = $prevDepth; $i > $depth; $i--) {
                     $ind = $indent . str_repeat('        ', $i);
                     $html .= $ind . '    </li>' . self::EOL;
                     $html .= $ind . '</ul>' . self::EOL;
                 }
                 // close previous li tag
                 $html .= $myIndent . '    </li>' . self::EOL;
             } else {
                 // close previous li tag
                 $html .= $myIndent . '    </li>' . self::EOL;
             }
         }
         // render li tag and page
         $liClass = $isActive ? ' class="active"' : '';
         $html .= $myIndent . '    <li' . $liClass . '>' . self::EOL . $myIndent . '        ' . $this->htmlify($page) . self::EOL;
         // store as previous depth for next iteration
         $prevDepth = $depth;
     }
     if ($html) {
         // done iterating container; close open ul/li tags
         for ($i = $prevDepth + 1; $i > 0; $i--) {
             $myIndent = $indent . str_repeat('        ', $i - 1);
             $html .= $myIndent . '    </li>' . self::EOL . $myIndent . '</ul>' . self::EOL;
         }
         $html = rtrim($html, self::EOL);
     }
     return $html;
 }
Example #17
0
 /**
  * Retrieves a list of all available extensions on the filesystem
  *
  * @return array An array with extension names as keys and paths to the
  *               extension as values
  */
 public function all_available()
 {
     $available = array();
     if (!is_dir($this->phpbb_root_path . 'ext/')) {
         return $available;
     }
     $iterator = new \RecursiveIteratorIterator(new \phpbb\recursive_dot_prefix_filter_iterator(new \RecursiveDirectoryIterator($this->phpbb_root_path . 'ext/', \FilesystemIterator::NEW_CURRENT_AND_KEY | \FilesystemIterator::FOLLOW_SYMLINKS)), \RecursiveIteratorIterator::SELF_FIRST);
     $iterator->setMaxDepth(2);
     foreach ($iterator as $file_info) {
         if ($file_info->isFile() && $file_info->getFilename() == 'composer.json') {
             $ext_name = $iterator->getInnerIterator()->getSubPath();
             $composer_file = $iterator->getPath() . '/composer.json';
             // Ignore the extension if there is no composer.json.
             if (!is_readable($composer_file) || !($ext_info = file_get_contents($composer_file))) {
                 continue;
             }
             $ext_info = json_decode($ext_info, true);
             $ext_name = str_replace(DIRECTORY_SEPARATOR, '/', $ext_name);
             // Ignore the extension if directory depth is not correct or if the directory structure
             // does not match the name value specified in composer.json.
             if (substr_count($ext_name, '/') !== 1 || !isset($ext_info['name']) || $ext_name != $ext_info['name']) {
                 continue;
             }
             $available[$ext_name] = $this->phpbb_root_path . 'ext/' . $ext_name . '/';
         }
     }
     ksort($available);
     return $available;
 }
Example #18
0
 /**
  * Renders a normal menu (called from {@link renderMenu()})
  *
  * @param  Zend_Navigation_Container $container     container to render
  * @param  string                    $ulClass       CSS class for first UL
  * @param  string                    $indent        initial indentation
  * @param  string                    $innerIndent   inner indentation
  * @param  int|null                  $minDepth      minimum depth
  * @param  int|null                  $maxDepth      maximum depth
  * @param  bool                      $onlyActive    render only active branch?
  * @param  bool                      $expandSibs    render siblings of active
  *                                                  branch nodes?
  * @param  string|null               $ulId          unique identifier (id)
  *                                                  for first UL
  * @param  bool                      $addPageClassToLi  adds CSS class from
  *                                                      page to li element
  * @param  string|null               $activeClass       CSS class for active
  *                                                      element
  * @param  string                    $parentClass       CSS class for parent
  *                                                      li's
  * @param  bool                      $renderParentClass Render parent class?
  * @return string                                       rendered menu (HTML)
  */
 protected function _renderMenu(Zend_Navigation_Container $container, $ulClass, $indent, $innerIndent, $minDepth, $maxDepth, $onlyActive, $expandSibs, $ulId, $addPageClassToLi, $activeClass, $parentClass, $renderParentClass)
 {
     $html = '';
     // find deepest active
     if ($found = $this->findActive($container, $minDepth, $maxDepth)) {
         $foundPage = $found['page'];
         $foundDepth = $found['depth'];
     } else {
         $foundPage = null;
     }
     // create iterator
     $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::SELF_FIRST);
     if (is_int($maxDepth)) {
         $iterator->setMaxDepth($maxDepth);
     }
     // iterate container
     $prevDepth = -1;
     foreach ($iterator as $page) {
         $depth = $iterator->getDepth();
         $isActive = $page->isActive(true);
         if ($depth < $minDepth || !$this->accept($page)) {
             // page is below minDepth or not accepted by acl/visibilty
             continue;
         } else {
             if ($expandSibs && $depth > $minDepth) {
                 // page is not active itself, but might be in the active branch
                 $accept = false;
                 if ($foundPage) {
                     if ($foundPage->hasPage($page)) {
                         // accept if page is a direct child of the active page
                         $accept = true;
                     } else {
                         if ($page->getParent()->isActive(true)) {
                             // page is a sibling of the active branch...
                             $accept = true;
                         }
                     }
                 }
                 if (!$isActive && !$accept) {
                     continue;
                 }
             } else {
                 if ($onlyActive && !$isActive) {
                     // page is not active itself, but might be in the active branch
                     $accept = false;
                     if ($foundPage) {
                         if ($foundPage->hasPage($page)) {
                             // accept if page is a direct child of the active page
                             $accept = true;
                         } else {
                             if ($foundPage->getParent()->hasPage($page)) {
                                 // page is a sibling of the active page...
                                 if (!$foundPage->hasPages() || is_int($maxDepth) && $foundDepth + 1 > $maxDepth) {
                                     // accept if active page has no children, or the
                                     // children are too deep to be rendered
                                     $accept = true;
                                 }
                             }
                         }
                     }
                     if (!$accept) {
                         continue;
                     }
                 }
             }
         }
         // make sure indentation is correct
         $depth -= $minDepth;
         $myIndent = $indent . str_repeat($innerIndent, $depth * 2);
         if ($depth > $prevDepth) {
             $attribs = array();
             // start new ul tag
             if (0 == $depth) {
                 $attribs = array('class' => $ulClass, 'id' => $ulId);
             }
             // We don't need a prefix for the menu ID (backup)
             $skipValue = $this->_skipPrefixForId;
             $this->skipPrefixForId();
             $html .= $myIndent . '<ul' . $this->_htmlAttribs($attribs) . '>' . $this->getEOL();
             // Reset prefix for IDs
             $this->_skipPrefixForId = $skipValue;
         } else {
             if ($prevDepth > $depth) {
                 // close li/ul tags until we're at current depth
                 for ($i = $prevDepth; $i > $depth; $i--) {
                     $ind = $indent . str_repeat($innerIndent, $i * 2);
                     $html .= $ind . $innerIndent . '</li>' . $this->getEOL();
                     $html .= $ind . '</ul>' . $this->getEOL();
                 }
                 // close previous li tag
                 $html .= $myIndent . $innerIndent . '</li>' . $this->getEOL();
             } else {
                 // close previous li tag
                 $html .= $myIndent . $innerIndent . '</li>' . $this->getEOL();
             }
         }
         // render li tag and page
         $liClasses = array();
         // Is page active?
         if ($isActive) {
             $liClasses[] = $activeClass;
         }
         // Add CSS class from page to LI?
         if ($addPageClassToLi) {
             $liClasses[] = $page->getClass();
         }
         // Add CSS class for parents to LI?
         if ($renderParentClass && $page->hasChildren()) {
             // Check max depth
             if (is_int($maxDepth) && $depth + 1 < $maxDepth || !is_int($maxDepth)) {
                 $liClasses[] = $parentClass;
             }
         }
         $html .= $myIndent . $innerIndent . '<li' . $this->_htmlAttribs(array('class' => implode(' ', $liClasses))) . '>' . $this->getEOL() . $myIndent . str_repeat($innerIndent, 2) . $this->htmlify($page) . $this->getEOL();
         // store as previous depth for next iteration
         $prevDepth = $depth;
     }
     if ($html) {
         // done iterating container; close open ul/li tags
         for ($i = $prevDepth + 1; $i > 0; $i--) {
             $myIndent = $indent . str_repeat($innerIndent . $innerIndent, $i - 1);
             $html .= $myIndent . $innerIndent . '</li>' . $this->getEOL() . $myIndent . '</ul>' . $this->getEOL();
         }
         $html = rtrim($html, $this->getEOL());
     }
     return $html;
 }
Example #19
0
 /**
  * 显示MVC相应级别的所有菜单
  *
  * @see Zend_View_Helper_Navigation_Menu::renderMenu()
  * @param  Zend_Navigation_Container $container  [optional] container to
  *                                               render. Default is to render
  *                                               the container registered in
  *                                               the helper.
  * @param  integer                   $minDepth   the min depth
  * @param  integer                   $maxDepth   the max depth
  * @param  string                    $ulClass    [optional] CSS class to
  *                                               use for UL element. Default
  *                                               is to use the value from
  *                                               {@link getUlClass()}.
  * @param  string|int                $indent     [optional] indentation as
  *                                               a string or number of
  *                                               spaces. Default is to use
  *                                               the value retrieved from
  *                                               {@link getIndent()}.
  * @param  boolean                     $recursive  whether page should be considered
  *                                               active if any child pages are active.
  * @return string                                rendered content
  */
 protected function _renderMVCLevelMenu(Zend_Navigation_Container $container = null, $minDepth = null, $maxDepth = null, $ulClass = null, $indent = null, $recursive = false)
 {
     $html = '';
     // create iterator
     $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::SELF_FIRST);
     if (is_int($maxDepth)) {
         $iterator->setMaxDepth($maxDepth);
     }
     // iterate container
     $prevDepth = -1;
     foreach ($iterator as $page) {
         $depth = $iterator->getDepth();
         $isActive = $page->isActive($recursive);
         if ($depth < $minDepth || !$this->accept($page)) {
             // page is below minDepth or not accepted by acl/visibilty
             continue;
         }
         // make sure indentation is correct
         $depth -= $minDepth;
         $myIndent = $indent . str_repeat('        ', $depth);
         if ($depth > $prevDepth) {
             // start new ul tag
             if ($ulClass && $depth == 0) {
                 $ulClass = ' class="' . $ulClass . '"';
             } else {
                 $ulClass = '';
             }
             $html .= $myIndent . '<ul' . $ulClass . '>' . self::EOL;
         } else {
             if ($prevDepth > $depth) {
                 // close li/ul tags until we're at current depth
                 for ($i = $prevDepth; $i > $depth; $i--) {
                     $ind = $indent . str_repeat('        ', $i);
                     $html .= $ind . '    </li>' . self::EOL;
                     $html .= $ind . '</ul>' . self::EOL;
                 }
                 // close previous li tag
                 $html .= $myIndent . '    </li>' . self::EOL;
             } else {
                 // close previous li tag
                 $html .= $myIndent . '    </li>' . self::EOL;
             }
         }
         // render li tag and page
         $liClass = implode(' ', array($page->get('liclass'), $isActive ? 'active' : ''));
         $liClass = !empty($liClass) ? ' class="' . $liClass . '"' : '';
         $html .= $myIndent . '    <li' . $liClass . '>' . self::EOL . $myIndent . '        ' . $this->htmlify($page) . self::EOL;
         // store as previous depth for next iteration
         $prevDepth = $depth;
     }
     if ($html) {
         // done iterating container; close open ul/li tags
         for ($i = $prevDepth + 1; $i > 0; $i--) {
             $myIndent = $indent . str_repeat('        ', $i - 1);
             $html .= $myIndent . '    </li>' . self::EOL . $myIndent . '</ul>' . self::EOL;
         }
         $html = rtrim($html, self::EOL);
     }
     return $html;
 }
Example #20
0
/**
* Recursive file listing.
*/
function rscandirsorted($folder, $criterion = SIGPLUS_FILENAME, $order = SIGPLUS_ASCENDING, array $exceptions = array(), $depth = 0)
{
    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryExceptionFilter(new RecursiveDirectoryIterator($folder, RecursiveDirectoryIterator::KEY_AS_FILENAME | RecursiveDirectoryIterator::CURRENT_AS_SELF), $exceptions), RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
    $iterator->setMaxDepth($depth);
    switch ($criterion) {
        case SIGPLUS_UNSORTED:
            $subpaths = array();
            // an array of relative paths (with file name component)
            foreach ($iterator as $key => $item) {
                $subpaths[] = $item->getSubPathname();
            }
            break;
        case SIGPLUS_FILENAME:
            $filenames = array();
            // an array of file names (without path component)
            $subpaths = array();
            // an array of relative paths (with file name component)
            foreach ($iterator as $key => $item) {
                $filenames[] = $key;
                $subpaths[] = $item->getSubPathname();
            }
            switch ($order) {
                case SIGPLUS_ASCENDING:
                    array_multisort($filenames, SORT_ASC, SORT_STRING, $subpaths, SORT_ASC, SORT_STRING);
                    break;
                case SIGPLUS_DESCENDING:
                    array_multisort($filenames, SORT_DESC, SORT_STRING, $subpaths, SORT_DESC, SORT_STRING);
                    break;
            }
            break;
        case SIGPLUS_MTIME:
            $filetimes = array();
            // an array of times that file was last modified
            $subpaths = array();
            // an array of relative paths (with file name component)
            foreach ($iterator as $key => $item) {
                $filetimes[] = $item->current()->getMTime();
                $subpaths[] = $item->getSubPathname();
            }
            switch ($order) {
                case SIGPLUS_ASCENDING:
                    array_multisort($filetimes, SORT_ASC, SORT_NUMERIC, $subpaths, SORT_ASC, SORT_STRING);
                    break;
                case SIGPLUS_DESCENDING:
                    array_multisort($filetimes, SORT_DESC, SORT_NUMERIC, $subpaths, SORT_DESC, SORT_STRING);
                    break;
            }
            break;
        case SIGPLUS_RANDOM:
            $subpaths = array();
            // an array of relative paths (with file name component)
            foreach ($iterator as $key => $item) {
                $subpaths[] = $item->getSubPathname();
            }
            shuffle($subpaths);
            // randomize order
            break;
        default:
            return false;
    }
    if (empty($subpaths)) {
        return false;
    } else {
        return $subpaths;
    }
}
Example #21
0
 /**
  * Returns a DOMDocument containing the Sitemap XML for the given container
  *
  * @param  Zym_Navigation_Container $container  [optional] container to get
  *                                              breadcrumbs from, defaults
  *                                              to what is registered in the
  *                                              helper
  * @return DOMDocument
  * @throws DomainException  if schema validation is on and the sitemap
  *                          is invalid according to the sitemap schema, or
  *                          of sitemap validators are used and the loc
  *                          element fails validation
  */
 public function getDomSitemap(Zym_Navigation_Container $container = null)
 {
     if (null === $container) {
         $container = $this->getNavigation();
     }
     // create iterator
     $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::SELF_FIRST);
     if (is_int($this->_maxDepth)) {
         $iterator->setMaxDepth($this->_maxDepth);
     }
     // check if we should validate using our own validators
     if ($this->getUseSitemapValidators()) {
         require_once 'Zym/Validate/Sitemap/Changefreq.php';
         require_once 'Zym/Validate/Sitemap/Lastmod.php';
         require_once 'Zym/Validate/Sitemap/Loc.php';
         require_once 'Zym/Validate/Sitemap/Priority.php';
         // create validators
         $locValidator = new Zym_Validate_Sitemap_Loc();
         $lastmodValidator = new Zym_Validate_Sitemap_Lastmod();
         $changefreqValidator = new Zym_Validate_Sitemap_Changefreq();
         $priorityValidator = new Zym_Validate_Sitemap_Priority();
     }
     // create document
     $dom = new DOMDocument('1.0', 'UTF-8');
     $dom->formatOutput = $this->_formatOutput;
     // ...and urlset (root) element
     $urlSet = $dom->createElementNS(self::SITEMAP_NS, 'urlset');
     $dom->appendChild($urlSet);
     // iterate navigation
     foreach ($iterator as $page) {
         if (!$this->_accept($page)) {
             // page is not accepted
             continue;
         }
         // create url node for this page
         $urlNode = $dom->createElementNS(self::SITEMAP_NS, 'url');
         // get absolute url from page
         $url = $this->_getUrl($page);
         $urlSet->appendChild($urlNode);
         if ($this->getUseSitemapValidators() && !$locValidator->isValid($url)) {
             $msg = "Invalid sitemap URL: '{$url}'";
             throw new DomainException($msg);
         }
         // put url in 'loc' element
         $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS, 'loc', $url));
         // add 'lastmod' element if a valid lastmod is set in page
         if (isset($page->lastmod)) {
             $lastmod = strtotime((string) $page->lastmod);
             // prevent 1970-01-01...
             if ($lastmod !== false) {
                 $lastmod = date('c', $lastmod);
             }
             if (!$this->getUseSitemapValidators() || $lastmodValidator->isValid($lastmod)) {
                 $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS, 'lastmod', $lastmod));
             }
         }
         // add 'changefreq' element if a valid changefreq is set in page
         if (isset($page->changefreq)) {
             $changefreq = $page->changefreq;
             if (!$this->getUseSitemapValidators() || $changefreqValidator->isValid($changefreq)) {
                 $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS, 'changefreq', $changefreq));
             }
         }
         // add 'priority' element if a valid priority is set in page
         if (isset($page->priority)) {
             $priority = $page->priority;
             if (!$this->getUseSitemapValidators() || $priorityValidator->isValid($priority)) {
                 $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS, 'priority', $priority));
             }
         }
     }
     // validate using schema if specified
     if ($this->getUseSchemaValidation()) {
         if (!@$dom->schemaValidate(self::SITEMAP_XSD)) {
             $msg = 'Sitemap is invalid according to ' . self::SITEMAP_XSD;
             throw new DomainException($msg);
         }
     }
     return $dom;
 }
Example #22
0
 /**
  * Returns an array of all keys (files and directories)
  *
  * @param string   $key (Optional) Key of a directory to get keys from. If not set - keys will be read from the storage root.
  *
  * @param bool|int $recursive (Optional) Read all items recursively. Pass integer value to specify recursion depth.
  *
  * @return array
  */
 public function getKeys($key = '', $recursive = false)
 {
     if ($key != '') {
         $key = ltrim($key, DS);
         $key = rtrim($key, DS);
         $path = $this->directory . DS . $key;
     } else {
         $path = $this->directory;
     }
     if (!is_dir($path)) {
         return [];
     }
     if ($recursive) {
         try {
             $config = \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS;
             $directoryIterator = new \RecursiveDirectoryIterator($path, $config);
             $iterator = new \RecursiveIteratorIterator($directoryIterator);
             if (is_int($recursive) && $recursive > -1) {
                 $iterator->setMaxDepth($recursive);
             }
         } catch (\Exception $e) {
             $iterator = new \EmptyIterator();
         }
         $files = iterator_to_array($iterator);
     } else {
         $files = [];
         $iterator = new \DirectoryIterator($path);
         foreach ($iterator as $fileinfo) {
             $name = $fileinfo->getFilename();
             if ($name == '.' || $name == '..') {
                 continue;
             }
             $files[] = $fileinfo->getPathname();
         }
     }
     $keys = [];
     foreach ($files as $file) {
         $keys[] = $this->helper->getKey($file, $this->directory);
     }
     sort($keys);
     return $keys;
 }
Example #23
0
<?php

$ar = array(1, 2, array(31, 32, array(331, array(3321, array(33221)))), 4);
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($ar));
echo "===?===\n";
var_dump($it->getMaxDepth());
foreach ($it as $v) {
    echo $it->getDepth() . ": {$v}\n";
}
echo "===2===\n";
$it->setMaxDepth(2);
var_dump($it->getMaxDepth());
foreach ($it as $v) {
    echo $it->getDepth() . ": {$v}\n";
}
echo "===X===\n";
$it->setMaxDepth();
var_dump($it->getMaxDepth());
foreach ($it as $v) {
    echo $it->getDepth() . ": {$v}\n";
}
echo "===3===\n";
$it->setMaxDepth(3);
var_dump($it->getMaxDepth());
foreach ($it as $v) {
    echo $it->getDepth() . ": {$v}\n";
}
echo "===5===\n";
$it->setMaxDepth(5);
var_dump($it->getMaxDepth());
foreach ($it as $v) {
 /**
  * Constructor.
  *
  * @param RecursiveIteratorIterator $iterator The Iterator to filter
  * @param int                       $minDepth The min depth
  * @param int                       $maxDepth The max depth
  */
 public function __construct(RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX)
 {
     $this->minDepth = $minDepth;
     $iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
     parent::__construct($iterator);
 }
Example #25
0
    private function buildIterator($path)
    {
        if (PHP_VERSION_ID < 50301) {
            $iterator = new RecursiveDirectoryIteratorFixed($path);
        } else {
            $iterator = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
        }
        if ($this->exclude) {
            $filters = $this->exclude;
            $iterator = new NRecursiveCallbackFilterIterator($iterator, create_function('$file', 'extract(NClosureFix::$vars[' . NClosureFix::uses(array('filters' => $filters)) . '], EXTR_REFS);
				if (!$file->isFile()) {
					foreach ($filters as $filter) {
						if (!call_user_func($filter, $file)) {
							return FALSE;
						}
					}
				}
				return TRUE;
			'));
        }
        if ($this->maxDepth !== 0) {
            $iterator = new RecursiveIteratorIterator($iterator, $this->order);
            $iterator->setMaxDepth($this->maxDepth);
        }
        if ($this->groups) {
            $groups = $this->groups;
            $iterator = new NCallbackFilterIterator($iterator, create_function('$file', 'extract(NClosureFix::$vars[' . NClosureFix::uses(array('groups' => $groups)) . '], EXTR_REFS);
				foreach ($groups as $filters) {
					foreach ($filters as $filter) {
						if (!call_user_func($filter, $file)) {
							continue 2;
						}
					}
					return TRUE;
				}
				return FALSE;
			'));
        }
        return $iterator;
    }
Example #26
0
    /**
     * Returns a DOMDocument containing the Sitemap XML for the given container
     *
     * @param  Zend_Navigation_Container $container  [optional] container to get
     *                                               breadcrumbs from, defaults
     *                                               to what is registered in the
     *                                               helper
     * @return DOMDocument                           DOM representation of the
     *                                               container
     * @throws Zend_View_Exception                   if schema validation is on
     *                                               and the sitemap is invalid
     *                                               according to the sitemap
     *                                               schema, or if sitemap
     *                                               validators are used and the
     *                                               loc element fails validation
     */
    public function getDomSitemap(Zend_Navigation_Container $container = null)
    {
        if (null === $container) {
            $container = $this->getContainer();
        }

        // check if we should validate using our own validators
        if ($this->getUseSitemapValidators()) {
            require_once 'Zend/Validate/Sitemap/Changefreq.php';
            require_once 'Zend/Validate/Sitemap/Lastmod.php';
            require_once 'Zend/Validate/Sitemap/Loc.php';
            require_once 'Zend/Validate/Sitemap/Priority.php';

            // create validators
            $locValidator        = new Zend_Validate_Sitemap_Loc();
            $lastmodValidator    = new Zend_Validate_Sitemap_Lastmod();
            $changefreqValidator = new Zend_Validate_Sitemap_Changefreq();
            $priorityValidator   = new Zend_Validate_Sitemap_Priority();
        }

        // create document
        $dom = new DOMDocument('1.0', 'UTF-8');
        $dom->formatOutput = $this->getFormatOutput();

        // ...and urlset (root) element
        $urlSet = $dom->createElementNS(self::SITEMAP_NS, 'urlset');
        $dom->appendChild($urlSet);

        // create iterator
        $iterator = new RecursiveIteratorIterator($container,
            RecursiveIteratorIterator::SELF_FIRST);

        $maxDepth = $this->getMaxDepth();
        if (is_int($maxDepth)) {
            $iterator->setMaxDepth($maxDepth);
        }
        $minDepth = $this->getMinDepth();
        if (!is_int($minDepth) || $minDepth < 0) {
            $minDepth = 0;
        }

        // iterate container
        foreach ($iterator as $page) {
            if ($iterator->getDepth() < $minDepth || !$this->accept($page)) {
                // page should not be included
                continue;
            }

            // get absolute url from page
            if (!$url = $this->url($page)) {
                // skip page if it has no url (rare case)
                continue;
            }

            // create url node for this page
            $urlNode = $dom->createElementNS(self::SITEMAP_NS, 'url');
            $urlSet->appendChild($urlNode);

            if ($this->getUseSitemapValidators() &&
                !$locValidator->isValid($url)) {
                require_once 'Zend/View/Exception.php';
                $e = new Zend_View_Exception(sprintf(
                        'Encountered an invalid URL for Sitemap XML: "%s"',
                        $url));
                $e->setView($this->view);
                throw $e;
            }

            // put url in 'loc' element
            $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS,
                                                        'loc', $url));

            // add 'lastmod' element if a valid lastmod is set in page
            if (isset($page->lastmod)) {
                $lastmod = strtotime((string) $page->lastmod);

                // prevent 1970-01-01...
                if ($lastmod !== false) {
                    $lastmod = date('c', $lastmod);
                }

                if (!$this->getUseSitemapValidators() ||
                    $lastmodValidator->isValid($lastmod)) {
                    $urlNode->appendChild(
                        $dom->createElementNS(self::SITEMAP_NS, 'lastmod',
                                              $lastmod)
                    );
                }
            }

            // add 'changefreq' element if a valid changefreq is set in page
            if (isset($page->changefreq)) {
                $changefreq = $page->changefreq;
                if (!$this->getUseSitemapValidators() ||
                    $changefreqValidator->isValid($changefreq)) {
                    $urlNode->appendChild(
                        $dom->createElementNS(self::SITEMAP_NS, 'changefreq',
                                              $changefreq)
                    );
                }
            }

            // add 'priority' element if a valid priority is set in page
            if (isset($page->priority)) {
                $priority = $page->priority;
                if (!$this->getUseSitemapValidators() ||
                    $priorityValidator->isValid($priority)) {
                    $urlNode->appendChild(
                        $dom->createElementNS(self::SITEMAP_NS, 'priority',
                                              $priority)
                    );
                }
            }
        }

        // validate using schema if specified
        if ($this->getUseSchemaValidation()) {
            if (!@$dom->schemaValidate(self::SITEMAP_XSD)) {
                require_once 'Zend/View/Exception.php';
                $e = new Zend_View_Exception(sprintf(
                        'Sitemap is invalid according to XML Schema at "%s"',
                        self::SITEMAP_XSD));
                $e->setView($this->view);
                throw $e;
            }
        }

        return $dom;
    }
Example #27
0
<?php

namespace App\Modules\mod_slider;

$files = new \RecursiveDirectoryIterator("./public/images/slider/");
$files->setFlags(\FilesystemIterator::UNIX_PATHS | \FilesystemIterator::KEY_AS_FILENAME | \FilesystemIterator::SKIP_DOTS);
$files = new \RecursiveIteratorIterator($files, \RecursiveIteratorIterator::SELF_FIRST);
$files->setMaxDepth(2);
$extension = array('jpg', 'png', 'jpeg');
?>

<div class="wrapper">
	<div class="slider-wrapper theme-default">
		<div class="ribbon"></div>
		<div id="slider" class="nivoSlider">
            <?php 
foreach ($files as $key => $file) {
    if (in_array($file->getExtension(), $extension)) {
        echo "<img src='{$file}' />";
    }
}
?>
		</div><!-- END of slider-wrapper -->
	</div><!-- END of nivoSlider -->
</div><!-- END of WRAPPER -->


<link rel="stylesheet" href="./public/js/nivo-slider/nivo-slider.css" type="text/css" />
<link rel="stylesheet" href="./public/js/nivo-slider/themes/default/default.css" type="text/css" />

<script type="text/javascript" src="./public/js/nivo-slider/jquery.nivo.slider.pack.js"></script>
 public function preProcess($action, &$httpVars, &$fileVars)
 {
     if (isset($httpVars["simple_uploader"]) || isset($httpVars["xhr_uploader"])) {
         return;
     }
     $repository = ConfService::getRepository();
     $driver = ConfService::loadDriverForRepository($repository);
     if (method_exists($driver, "storeFileToCopy")) {
         self::$remote = true;
     }
     if ($repository->detectStreamWrapper(false)) {
         $plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
         $streamData = $plugin->detectStreamWrapper(true);
         if ($streamData["protocol"] == "ajxp.ftp" || $streamData["protocol"] == "ajxp.remotefs") {
             $this->logDebug("Skip decoding");
             self::$skipDecoding = true;
         }
         $this->logDebug("Stream ", $streamData);
         self::$wrapperIsRemote = call_user_func(array($streamData["classname"], "isRemote"));
     }
     $this->logDebug("Jumploader HttpVars", $httpVars);
     $this->logDebug("Jumploader FileVars", $fileVars);
     $httpVars["dir"] = base64_decode(str_replace(" ", "+", $httpVars["dir"]));
     $index = $httpVars["partitionIndex"];
     $realName = $fileVars["userfile_0"]["name"];
     /* if fileId is not set, request for cross-session resume (only if the protocol is not ftp)*/
     if (!isset($httpVars["fileId"])) {
         $this->logDebug("Trying Cross-Session Resume request");
         $plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
         $streamData = $plugin->detectStreamWrapper(true);
         $dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
         $destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . $dir;
         $fileHash = md5($httpVars["fileName"]);
         if (!self::$remote) {
             $resumeIndexes = array();
             $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($destStreamURL));
             $it->setMaxDepth(0);
             while ($it->valid()) {
                 if (!$it->isDot()) {
                     $subPathName = $it->getSubPathName();
                     AJXP_LOGGER::debug("Iterator SubPathName: " . $it->getSubPathName());
                     if (strstr($subPathName, $fileHash) != false) {
                         $explodedSubPathName = explode('.', $subPathName);
                         $resumeFileId = $explodedSubPathName[1];
                         $resumeIndexes[] = $explodedSubPathName[2];
                         $this->logDebug("Current Index: " . $explodedSubPathName[2]);
                     }
                 }
                 $it->next();
             }
             /* no valid temp file found. return. */
             if (empty($resumeIndexes)) {
                 $this->logDebug("No Cross-Session Resume request");
                 return;
             }
             AJXP_LOGGER::debug("ResumeFileID: " . $resumeFileId);
             AJXP_LOGGER::debug("Max Resume Index: " . max($resumeIndexes));
             $nextResumeIndex = max($resumeIndexes) + 1;
             AJXP_LOGGER::debug("Next Resume Index: " . $nextResumeIndex);
             if (isset($resumeFileId)) {
                 $this->logDebug("ResumeFileId is set. Returning values: fileId: " . $resumeFileId . ", partitionIndex: " . $nextResumeIndex);
                 $httpVars["resumeFileId"] = $resumeFileId;
                 $httpVars["resumePartitionIndex"] = $nextResumeIndex;
             }
         }
         return;
     }
     /* if the file has to be partitioned */
     if (isset($httpVars["partitionCount"]) && intval($httpVars["partitionCount"]) > 1) {
         $this->logDebug("Partitioned upload");
         $fileId = $httpVars["fileId"];
         $fileHash = md5($realName);
         /* In order to enable cross-session resume, temp files must not depend on session.
          * Now named after and md5() of the original file name.
          */
         $this->logDebug("Filename: " . $realName . ", File hash: " . $fileHash);
         $fileVars["userfile_0"]["name"] = "{$fileHash}.{$fileId}.{$index}";
         $httpVars["lastPartition"] = false;
     } else {
         /*
          * If we wan to upload a folderUpload to folderServer
          * Temporarily,put all files in this folder to folderServer.
          * But a same file name may be existed in folderServer,
          * this can cause error of uploading.
          *
          * We rename this file by his relativePath. At the postProcess session, we will use this name
          * to copy to right location
          *
          */
         $file_tmp_md5 = md5($httpVars["relativePath"]);
         $fileVars["userfile_0"]["name"] = $file_tmp_md5;
     }
     /* if we received the last partition */
     if (intval($index) == intval($httpVars["partitionCount"]) - 1) {
         $httpVars["lastPartition"] = true;
         $httpVars["partitionRealName"] = $realName;
     }
 }
 function get_script_file_array($folder)
 {
     $files = array();
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($folder));
     //TODO: make this configurable / test with a lot of websites
     $it->setMaxDepth(2);
     // this will save a LOT of time
     //bad coding if image used in file other than css
     $ext = array('.css', '.js', '.html', '.htm', '.php', '.php4', '.php5');
     while ($it->valid()) {
         if (!$it->isDot()) {
             if ($this->strposa($it->key(), $ext) !== false) {
                 //FB::log($it->key());
                 //$filename = $it->getFilename();
                 //array_push($files, $filename);
                 array_push($files, $basedir = $it->key());
                 //str_replace('\\', '/', $it->key())); //$it->getSubPathName(), $it->getSubPath()
             }
         }
         $it->next();
     }
     return $files;
 }
 private function _loopFiles($directory)
 {
     $files = array();
     $iterator = new \RecursiveIteratorIterator($directory);
     $iterator->setMaxDepth($this->depth);
     foreach ($iterator as $info) {
         if (!in_array($info->getFilename(), $this->ignoreFiles)) {
             $fileNameLength = strlen($info->getFileName());
             $extLength = strlen($info->getExtension());
             $folders = explode("/", $info->getPathname());
             $parentFolder = false;
             if (count($folders) > 1) {
                 $parentFolder = $folders[count($folders) - 2];
             }
             $name = substr($info->getFilename(), 0, $fileNameLength - $extLength - 1);
             $file = new DirectoryContents_FileModel();
             $file->name = $name;
             $file->niceName = $this->_generateNiceName($name);
             $file->fileName = $info->getFileName();
             $file->path = $info->getPathname();
             $file->parentFolder = $parentFolder;
             $file->niceParentFolder = $parentFolder ? $this->_generateNiceName($parentFolder) : $parentFolder;
             $file->extension = $info->getExtension();
             $file->size = $info->getSize();
             $file->created = $info->getCtime();
             $file->modified = $info->getMtime();
             $files[] = $file;
         }
     }
     return $files;
 }