コード例 #1
0
ファイル: Structure.php プロジェクト: jacksleight/chalk
 public function reorder(Request $req, Response $res)
 {
     if (!$req->isPost()) {
         throw new \Chalk\Exception("Reorder action only accepts POST requests");
     }
     if (!$req->nodeData) {
         return $res->redirect($this->url(array('action' => 'index')));
     }
     $data = json_decode($req->nodeData);
     $structure = $this->em('Chalk\\Core\\Structure')->id($req->structure);
     $nodes = $this->em('Chalk\\Core\\Structure\\Node')->all(['structure' => $structure]);
     $map = [];
     foreach ($nodes as $node) {
         $map[$node->id] = $node;
     }
     $it = new \RecursiveIteratorIterator(new Iterator($data), \RecursiveIteratorIterator::SELF_FIRST);
     $stack = [];
     foreach ($it as $i => $value) {
         array_splice($stack, $it->getDepth(), count($stack), array($value));
         $depth = $it->getDepth();
         $parent = $depth > 0 ? $stack[$depth - 1] : $structure->root;
         $node = $map[$value->id];
         $node->parent->children->removeElement($node);
         $node->parent = $map[$parent->id];
         $node->sort = $i;
     }
     $this->em->flush();
     $this->notify("Content was moved successfully", 'positive');
     if (isset($req->redirect)) {
         return $res->redirect($req->redirect);
     } else {
         return $res->redirect($this->url(array('action' => 'index')));
     }
 }
コード例 #2
0
ファイル: HomeController.php プロジェクト: tomshaw/directory
 public function buildArray()
 {
     $directory = new \RecursiveDirectoryIterator('assets');
     $iterator = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::CHILD_FIRST);
     $tree = [];
     foreach ($iterator as $info) {
         //if (in_array($info->getFilename(), ['.', '..'])) continue;
         if ($iterator->getDepth() >= 2 || !$iterator->isDir() || $iterator->isDot()) {
             continue;
         }
         if ($iterator->getDepth() == 1) {
             $path = $info->isDir() ? [$iterator->getDepth() - 1 => $info->getFilename()] : [$info->getFilename()];
         } else {
             $path = $info->isDir() ? [$info->getFilename() => []] : [$info->getFilename()];
         }
         for ($depth = $iterator->getDepth() - 1; $depth >= 0; $depth--) {
             $path = [$iterator->getSubIterator($depth)->current()->getFilename() => $path];
         }
         $tree = array_merge_recursive($tree, $path);
     }
     $data = array();
     foreach ($tree as $category => $children) {
         foreach ($children as $index => $value) {
             $data[$category][] = $value;
         }
     }
     foreach ($data as $category => $children) {
         $parentId = $this->addEntry($category, '0');
         foreach ($children as $index => $value) {
             $this->addEntry($value, $parentId);
         }
     }
     return $data;
 }
コード例 #3
0
 private function _convertToDotNotation()
 {
     foreach ($this->_iterator as $leafValue) {
         $keys = [];
         foreach (range(0, $this->_iterator->getDepth()) as $depth) {
             $keys[] = $this->_iterator->getSubIterator($depth)->key();
         }
         $key = join(self::DELIMITER, $keys);
         $this->_result[$key] = $leafValue;
     }
 }
コード例 #4
0
ファイル: Module.php プロジェクト: rexmac/zf2
 public static function createResources(ProjectProfile $profile, $moduleName, Resource $targetModuleResource = null)
 {
     // find the appliction directory, it will serve as our module skeleton
     if ($targetModuleResource == null) {
         $targetModuleResource = $profile->search('applicationDirectory');
         $targetModuleEnabledResources = array('ControllersDirectory', 'ModelsDirectory', 'ViewsDirectory', 'ViewScriptsDirectory', 'ViewHelpersDirectory', 'ViewFiltersDirectory');
     }
     // find the actual modules directory we will use to house our module
     $modulesDirectory = $profile->search('modulesDirectory');
     // if there is a module directory already, except
     if ($modulesDirectory->search(array('moduleDirectory' => array('moduleName' => $moduleName)))) {
         throw new Exception\RuntimeException('A module named "' . $moduleName . '" already exists.');
     }
     // create the module directory
     $moduleDirectory = $modulesDirectory->createResource('moduleDirectory', array('moduleName' => $moduleName));
     // create a context filter so that we can pull out only what we need from the module skeleton
     $moduleContextFilterIterator = new ContextFilter($targetModuleResource, array('denyNames' => array('ModulesDirectory', 'ViewControllerScriptsDirectory'), 'denyType' => 'Zend\\Tool\\Project\\Context\\Filesystem\\File'));
     // the iterator for the module skeleton
     $targetIterator = new \RecursiveIteratorIterator($moduleContextFilterIterator, \RecursiveIteratorIterator::SELF_FIRST);
     // initialize some loop state information
     $currentDepth = 0;
     $parentResources = array();
     $currentResource = $moduleDirectory;
     $currentChildResource = null;
     // loop through the target module skeleton
     foreach ($targetIterator as $targetSubResource) {
         $depthDifference = $targetIterator->getDepth() - $currentDepth;
         $currentDepth = $targetIterator->getDepth();
         if ($depthDifference === 1) {
             // if we went down into a child, make note
             array_push($parentResources, $currentResource);
             // this will have always been set previously by another loop
             $currentResource = $currentChildResource;
         } elseif ($depthDifference < 0) {
             // if we went up to a parent, make note
             $i = $depthDifference;
             do {
                 // if we went out more than 1 parent, get to the correct parent
                 $currentResource = array_pop($parentResources);
             } while ($i-- > 0);
         }
         // get parameters for the newly created module resource
         $params = $targetSubResource->getAttributes();
         $currentChildResource = $currentResource->createResource($targetSubResource->getName(), $params);
         // based of the provided list (Currently up top), enable specific resources
         if (isset($targetModuleEnabledResources)) {
             $currentChildResource->setEnabled(in_array($targetSubResource->getName(), $targetModuleEnabledResources));
         } else {
             $currentChildResource->setEnabled($targetSubResource->isEnabled());
         }
     }
     return $moduleDirectory;
 }
コード例 #5
0
ファイル: listbox.php プロジェクト: raeldc/com_learn
	public function parents($config = array())
	{
		$config = new KConfig($config);
		$config->append(array(
			'name'	=> 'parent_id'
		));

		$query = KFactory::get('koowa:database.query')
			->where('pages_menu_id', '=', $config->pages_menu_id)
			->where('enabled', '<>', -2)
			->order(array('parent_id', 'ordering'))
			->limit(0);

		$pages = KFactory::get('com://admin/pages.database.table.pages')
			->select($query);

		if($config->pages_page_id) 
		{
			if($row = $pages->find($config->pages_page_id)) {
				$pages->removeRow($row);
			}
		}

		$html		= array();
		$selected	= $config->selected == 0 ? 'checked="checked"' : '';

		$html[] = '<input type="radio" name="'.$config->name.'" id="'.$config->name.'0" value="0" '.$selected.' />';
		$html[] = '<label for="'.$config->name.'0">'.JText::_('Top').'</label>';
		$html[] = '<br />';

		$iterator	= new RecursiveIteratorIterator($pages, RecursiveIteratorIterator::SELF_FIRST);

		foreach($iterator as $page)
		{
			$selected	= $config->selected == $page->id ? 'checked="checked"' : '';

			if($iterator->getDepth() + 1) {
				$html[] = str_repeat('.&nbsp;&nbsp;&nbsp;&nbsp;', $iterator->getDepth());
				$html[] = '<sup>|_</sup>&nbsp;';
			}

			$html[] = '<input type="radio" name="'.$config->name.'" id="'.$config->name.$page->id.'" value="'.$page->id.'" '.$selected.' />';
			$html[] = '<label for="'.$config->name.$page->id.'">'.$page->title.'</label>';
			$html[] = '<br />';
		}

		return implode(PHP_EOL, $html);
	}
コード例 #6
0
ファイル: ConfigParser.php プロジェクト: laborci/PhlexDev
 protected function parseCfg()
 {
     $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->data));
     $cfg = array();
     foreach ($iterator as $key => $value) {
         for ($i = $iterator->getDepth() - 1; $i >= 0; $i--) {
             $key = $iterator->getSubIterator($i)->key() . '.' . $key;
         }
         $cfg[$key] = $value;
     }
     foreach ($cfg as $key => $value) {
         if (is_string($value)) {
             if ($count = preg_match_all('({{(.*?)}})', $value, $matches)) {
                 for ($i = 0; $i < $count; $i++) {
                     $cfg[$key] = str_replace($matches[0][$i], $cfg[$matches[1][$i]], $value);
                 }
             }
             foreach ($this->valueParsers as $valueParser) {
                 $cfg[$key] = $valueParser($cfg[$key]);
             }
             $temp =& $this->data;
             $exploded = explode('.', $key);
             foreach ($exploded as $segment) {
                 $temp =& $temp[$segment];
             }
             $temp = $cfg[$key];
             unset($temp);
         }
     }
 }
コード例 #7
0
ファイル: XmlDriver.php プロジェクト: backstageel/neatReports
 /**
  * <pre>Converts a Doctrine array graph of the form:
  * .array
  * .  0 =>
  * .    array
  * .      'id' => '1'
  * .      'PersonaDomicilio' =>
  * .        array
  * .          0 =>
  * .            array
  * .              'id' => '1'
  * To a XML representation.
  * 
  * @param array $array The array to convert to XML
  * 
  * @return DOMDocument <pre> The XML with following structure:
  * . &lt;result&gt;
  * .   &lt;rootTable_Collection&gt;
  * .     &lt;rootTable&gt;
  * .       &lt;id&gt;&lt;/id&gt;
  * .       &lt;field1&gt;&lt;/field1&gt;
  * .       &lt;relatedTable_Collection&gt;
  * .         &lt;relatedTable&gt;
  * .         &lt;/relatedTable&gt;
  * .         &lt;relatedTable&gt;
  * .        &lt;/relatedTable&gt;
  * .         ::
  * .       &lt;/relatedTable_Collection&gt;
  * .     &lt;/rootTable&gt;
  * .     &lt;rootTable&gt;
  * .       ::
  * .     &lt;/rootTable&gt;
  * .     ::
  * .   &lt;/rootTable_Collection&gt;
  * . &lt;result&gt;
  * </pre>
  */
 public function arrayToXml(array $array)
 {
     $result = new DOMDocument();
     $rootNode = $result->createElement('result');
     $result->appendChild($rootNode);
     $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::SELF_FIRST);
     $prevLvl = 0;
     $component[$prevLvl] = $this->_queryComponents[$this->_rootAlias]['table']->getComponentName();
     $obj = $result->createElement($component[$prevLvl] . '_Collection');
     $rootNode->appendChild($obj);
     foreach ($iterator as $k => $val) {
         $depth = $iterator->getDepth();
         if ($depth < $prevLvl) {
             for ($i = 0; $i < $prevLvl - $depth; $i++) {
                 $obj = $obj->parentNode;
             }
         }
         if (!is_array($val)) {
             $son = $result->createElement($k, $val);
             $obj->appendChild($son);
         } else {
             if (is_numeric($k)) {
                 $son = $result->createElement($component[$depth]);
             } else {
                 $component[$depth + 1] = $k;
                 $son = $result->createElement($k . '_Collection');
             }
             $obj->appendChild($son);
             !empty($val) && ($obj = $son);
         }
         $prevLvl = $depth;
     }
     return $result;
 }
コード例 #8
0
ファイル: Controller.php プロジェクト: portalsway2/APEDevices
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     $behaviors = ArrayHelper::merge(parent::behaviors(), ['authenticator' => ['class' => CompositeAuth::className(), 'authMethods' => [['class' => HttpBearerAuth::className()], ['class' => QueryParamAuth::className(), 'tokenParam' => 'accessToken']]], 'exceptionFilter' => ['class' => ErrorToExceptionFilter::className()], 'corsFilter' => ['class' => \backend\rest\filters\Cors::className(), 'cors' => ['Origin' => ['*'], 'Access-Control-Request-Method' => ['POST', 'PUT', 'OPTIONS', 'PATCH', 'DELETE'], 'Access-Control-Request-Headers' => ['X-Pagination-Total-Count', 'X-Pagination-Page-Count', 'X-Pagination-Current-Page', 'X-Pagination-Per-Page', 'Content-Length', 'Content-type', 'Link'], 'Access-Control-Allow-Credentials' => true, 'Access-Control-Max-Age' => 3600, 'Access-Control-Expose-Headers' => ['X-Pagination-Total-Count', 'X-Pagination-Page-Count', 'X-Pagination-Current-Page', 'X-Pagination-Per-Page', 'Content-Length', 'Content-type', 'Link'], 'Access-Control-Allow-Headers' => ['X-Pagination-Total-Count', 'X-Pagination-Page-Count', 'X-Pagination-Current-Page', 'X-Pagination-Per-Page', 'Content-Length', 'Content-type', 'Link']]]]);
     if (isset(\Yii::$app->params['httpCacheActive']) and \Yii::$app->params['httpCacheActive']) {
         $params = \Yii::$app->getRequest()->getQueryParams();
         unset($params['accessToken']);
         $behaviors['httpCache'] = ['class' => HttpCache::className(), 'params' => $params, 'lastModified' => function ($action, $params) {
             $q = new \yii\db\Query();
             $class = $this->modelClass;
             if (in_array('updated_at', $class::getTableSchema()->getColumnNames())) {
                 return strtotime($q->from($class::tableName())->max('updated_at'));
             }
             if (in_array('modified', $class::getTableSchema()->getColumnNames())) {
                 return strtotime($q->from($class::tableName())->max('modified'));
             }
             return null;
         }, 'etagSeed' => function (Action $action, $params) {
             $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($params));
             $keys = array();
             foreach ($iterator as $key => $value) {
                 // Build long key name based on parent keys
                 for ($i = $iterator->getDepth() - 1; $i >= 0; $i--) {
                     $key = $iterator->getSubIterator($i)->key() . '_' . $key;
                     if (!is_array($iterator->getSubIterator($i)->current())) {
                         $value = $iterator->getSubIterator($i)->current() . '_' . $value;
                     }
                 }
                 $keys[] = $key . '-' . $value;
             }
             $uniqueId = implode('-', $keys);
             return $uniqueId;
         }];
     }
     return $behaviors;
 }
コード例 #9
0
function array_flatten(array $array, $key_separator = '/')
{
    $result = array();
    // a stack of strings
    $keys = array();
    $prev_depth = -1;
    $iter = new RecursiveIteratorIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::SELF_FIRST);
    // rewind() is necessary
    for ($iter->rewind(); $iter->valid(); $iter->next()) {
        $curr_depth = $iter->getDepth();
        $diff_depth = $prev_depth - $curr_depth + 1;
        //##### TODO: It would be nice to do this with a single function.
        while ($diff_depth > 0) {
            array_pop($keys);
            --$diff_depth;
        }
        /*
        Note:
        http://bugs.php.net/bug.php?id=52425
        array_shift/array_pop: add parameter that tells how many to elements to pop
        */
        array_push($keys, $iter->key());
        if (is_scalar($iter->current())) {
            $result[implode($key_separator, $keys)] = $iter->current();
        }
        $prev_depth = $curr_depth;
    }
    return $result;
}
コード例 #10
0
 /**
  * A convenience method to dump the page rows.
  */
 private function showPageItems()
 {
     $tree = PagePeer::retrieveTree();
     $iterator = new RecursiveIteratorIterator($tree, RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $item) {
         /* @var        $item Page */
         echo str_repeat('- ', $iterator->getDepth()), $item->getId(), ': ', $item->getTitle(), ' [', $item->getLeftValue(), ':', $item->getRightValue(), ']' . "\n";
     }
 }
コード例 #11
0
ファイル: listbox.php プロジェクト: janssit/nickys.janss.be
 public function categories($config = array())
 {
     $config = new Library\ObjectConfig($config);
     $config->append(array('name' => 'category', 'deselect' => true, 'selected' => $config->category, 'prompt' => '- Select -', 'table' => '', 'parent' => '', 'max_depth' => 9));
     if ($config->deselect) {
         $options[] = $this->option(array('text' => \JText::_($config->prompt), 'value' => 0));
     }
     $list = $this->getObject('com:categories.model.categories')->table($config->table)->parent($config->parent)->sort('title')->getRowset();
     $iterator = new \RecursiveIteratorIterator($list, \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $item) {
         if ($iterator->getDepth() > $config->max_depth) {
             break;
         }
         $title = substr('---------', 0, $iterator->getDepth()) . $item->title;
         $options[] = $this->option(array('text' => $title, 'value' => $item->id));
     }
     $config->options = $options;
     return $this->optionlist($config);
 }
コード例 #12
0
 function testRecursiveTreeItarator()
 {
     $structHolder = $this->getTestStructure();
     $pathBuilder = new pathBuilder('/index.html');
     $sectionData = $structHolder->getPageSection($pathBuilder, 'current');
     $section = $sectionData['curSection'];
     $level = $sectionData['level'];
     $iterator = new RecursiveIteratorIterator(new contentTreeRecursiveIterator($section), RecursiveIteratorIterator::SELF_FIRST);
     $tocItems = array();
     foreach ($iterator as $topic) {
         if ($level != -1 && $iterator->getDepth() > $level - 1) {
             continue;
         }
         $topic['href'] = ltrim($iterator->getPath() . '/' . $topic['href'], '\\/');
         $topic['level'] = $iterator->getDepth();
         $tocItems[] = $topic;
     }
     $this->assertEqual($tocItems, array(array('href' => 'introduction.html', 'title' => 'Введение', 'level' => 0), array('href' => 'installation.html', 'title' => 'Установка', 'level' => 0), array('href' => 'quickstart.html', 'title' => 'Простой пример', 'level' => 0), array('href' => 'content/index.html', 'title' => 'Книга', 'level' => 0), array('href' => 'content/bookshelf.html', 'title' => 'Книжная полка', 'level' => 1), array('href' => 'content/toc.html', 'title' => 'Структура', 'level' => 1), array('href' => 'content/text.html', 'title' => 'Текст', 'level' => 1), array('href' => 'layout/index.html', 'title' => 'Оформление', 'level' => 0), array('href' => 'layout/theme.html', 'title' => 'Темы', 'level' => 1), array('href' => 'layout/system_settings.html', 'title' => 'Системные настройки', 'level' => 1), array('href' => 'export.html', 'title' => 'Экспорт', 'level' => 0), array('href' => 'appendix/index.html', 'title' => 'Приложения', 'level' => 0), array('href' => 'appendix/topic_index.html', 'title' => 'Предметный указатель', 'level' => 1), array('href' => 'appendix/authors.html', 'title' => 'Авторы', 'level' => 1), array('href' => 'appendix/license.html', 'title' => 'Лицензия', 'level' => 1), array('href' => 'appendix/similar.html', 'title' => 'Аналоги', 'level' => 1), array('href' => 'appendix/roadmap.html', 'title' => 'Планы по развитию', 'level' => 1)), 'Correct data obtained');
 }
コード例 #13
0
ファイル: Find.php プロジェクト: JREAM/php-recursive
 /**
  * Main lookup loop
  *
  * @param  \RecursiveIteratorIterator $items
  * @param  scalar                     $needle
  * @param  const                      $findBy  mode to find by
  *
  * @return array
  */
 protected function _findLoop(\RecursiveIteratorIterator $items, $needle, $findBy)
 {
     $result = [];
     foreach ($items as $key => $value) {
         $iter_keys = [];
         for ($i = $items->getDepth() - 1; $i > 0; $i--) {
             $iter_keys[] = $items->getSubIterator($i)->key();
         }
         // Value Search
         if ($findBy === parent::FIND_BY_VALUE && $value === $needle) {
             $result[] = ['key' => $key, 'value' => $value, 'depth' => $items->getDepth(), 'parent_keys' => $iter_keys];
         } else {
             if ($findBy === parent::FIND_BY_KEY && $key === $needle) {
                 $result[] = ['key' => $key, 'value' => $value, 'depth' => $items->getDepth(), 'parent_keys' => $iter_keys];
             }
         }
     }
     return $result;
 }
コード例 #14
0
 /**
  * Liste le répertoire
  * @param string $pPath
  */
 public function __construct($pPath)
 {
     $this->_directory = $pPath;
     $ritit = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($pPath), \RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($ritit as $splFileInfo) {
         $path = $splFileInfo->isDir() ? array($splFileInfo->getFilename() => array()) : array($splFileInfo->getFilename());
         for ($depth = $ritit->getDepth() - 1; $depth >= 0; $depth--) {
             $path = array($ritit->getSubIterator($depth)->current()->getFilename() => $path);
         }
         $this->_files = array_merge_recursive($this->_files, $path);
     }
 }
コード例 #15
0
 /**
  * Copy from Zend View Helper Navigation AbstractHelper
  * 
  * @see \Zend\View\Helper\Navigation\AbstractHelper::findActive()
  */
 public function findActive($container, $minDepth = null, $maxDepth = -1)
 {
     $this->parseContainer($container);
     if (!is_int($minDepth)) {
         $minDepth = $this->getMinDepth();
     }
     if ((!is_int($maxDepth) || $maxDepth < 0) && null !== $maxDepth) {
         $maxDepth = $this->getMaxDepth();
     }
     $found = null;
     $foundDepth = -1;
     $iterator = new \RecursiveIteratorIterator($container, \RecursiveIteratorIterator::CHILD_FIRST);
     if ('index' === $this->view->url) {
         $url = '/';
     } else {
         $url = '/' . $this->view->url;
     }
     /**
      * @var \Zend\Navigation\Page\AbstractPage $page
      */
     foreach ($iterator as $page) {
         if ($url === $page->uri) {
             $page->active = 1;
         }
         $currDepth = $iterator->getDepth();
         if ($currDepth < $minDepth || !$this->accept($page)) {
             // page is not accepted
             continue;
         }
         if ($page->isActive(false) && $currDepth > $foundDepth) {
             // found an active page at a deeper level than before
             $found = $page;
             $foundDepth = $currDepth;
         }
     }
     if (is_int($maxDepth) && $foundDepth > $maxDepth) {
         while ($foundDepth > $maxDepth) {
             if (--$foundDepth < $minDepth) {
                 $found = null;
                 break;
             }
             $found = $found->getParent();
             if (!$found instanceof AbstractPage) {
                 $found = null;
                 break;
             }
         }
     }
     if ($found) {
         return array('page' => $found, 'depth' => $foundDepth);
     }
     return array();
 }
コード例 #16
0
ファイル: AdapterAbstract.php プロジェクト: jalet/tvnu-config
 /**
  * [setup description]
  * @param  Array  $array
  * @return void
  * @link   http://stackoverflow.com/a/10424516
  */
 protected function setup(array $array)
 {
     $ritit = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($array));
     $this->arr = array();
     foreach ($ritit as $leafValue) {
         $keys = array();
         foreach (range(0, $ritit->getDepth()) as $depth) {
             $keys[] = $ritit->getSubIterator($depth)->key();
         }
         $this->set(join('.', $keys), $leafValue);
     }
 }
コード例 #17
0
 protected function registerContainerParametersRecursive(ContainerBuilder $container, $alias, $config)
 {
     $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($config), \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $value) {
         $path = array();
         for ($i = 0; $i <= $iterator->getDepth(); $i++) {
             $path[] = $iterator->getSubIterator($i)->key();
         }
         $key = $alias . '.' . implode(".", $path);
         $container->setParameter($key, $value);
     }
 }
コード例 #18
0
    public function buildTOC()
    {
        $pathBuilder = new pathBuilder('/');
        $sectionData = $this->structureHolder->getPageSection($pathBuilder, 'current');
        $section = $sectionData['curSection'];
        $level = 0;
        $iterator = new RecursiveIteratorIterator(new contentTreeRecursiveIterator($section), RecursiveIteratorIterator::SELF_FIRST);
        $file_list = '';
        $html = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
<!-- Sitemap 1.0 -->
</HEAD><BODY><UL><LI><OBJECT type="text/sitemap">
		                <param name="Name" value="ќбложка">
		                <param name="Local" value="index.html">
		               </OBJECT>';
        foreach ($iterator as $topic) {
            $href = ltrim($iterator->getPath() . '/' . $topic['href'], '\\/');
            $file_list .= "{$href}\n";
            $title = $topic['title'];
            if ($iterator->getDepth() > $level) {
                $html .= '<UL>';
                $level = $iterator->getDepth();
            }
            if ($iterator->getDepth() < $level) {
                $html .= '</UL>';
                $level = $iterator->getDepth();
            }
            $icon = basename($href) == 'index.html' ? '' : '<param name="ImageNumber" value="11">';
            $html .= '<LI> <OBJECT type="text/sitemap">
		                <param name="Name" value="' . $title . '">
		                <param name="Local" value="' . $href . '">
                    ' . $icon . '
		               </OBJECT>';
        }
        $html = $html . '</UL></BODY></HTML>';
        $file_list = "[OPTIONS]\nCompatibility=1.1 or later\nCompiled file={$this->bookKey}.chm\nContents file={$this->bookKey}.hhc\nDefault Font=Verdana,8,204\nDefault topic=index.html\nDisplay compile progress=No\nIndex file={$this->bookKey}.hhk\nLanguage=" . colesoApplication::getMessage('bulldoc', 'chm_encoding') . "\nTitle={$this->bookTitle}\n\n\n[FILES]\n{$file_list}\n\n[INFOTYPES]\n\n";
        return array($html, $file_list);
    }
コード例 #19
0
ファイル: Array.php プロジェクト: romartyn/cogear
 /**
  * Transform multidimensional array to plain using key join with separator
  * Example:
  * array(3) {
  *	  ["some"] => array(1) {
  *	    ["var"] => string(10) "Some value"
  *	  }
  *	  ["second"] => array(1) {
  *	    ["var"] => string(10) "Some value"
  *	  }
  *	  ["third"] => array(1) {
  *	    ["var"] => array(1) {
  *	      ["subvar"] => string(10) "Some value"
  *	    }
  *	  }
  *	}
  *
  *
  *		 array(3) {
  *		  ["some.var"] => string(10) "Some value"
  *		  ["second.var"] => string(10) "Some value"
  *		  ["third.var.subvar"] => string(10) "Some value"
  *		}
  *
  * @param	array	$data
  * @param	string	$separator
  * @return	array
  */
 public static function multiToPlain($data, $separator = '.')
 {
     $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($data), RecursiveIteratorIterator::SELF_FIRST);
     $level = 0;
     $full_key = '';
     $result = array();
     foreach ($it as $key => $value) {
         if ($it->getDepth() > $level) {
             array_push($full_key, $key);
         } elseif ($it->getDepth() == 0) {
             $full_key = array($key);
         } elseif ($it->getDepth() == $level) {
             array_pop($full_key);
             array_push($full_key, $key);
         } elseif ($it->getDepth() < $level) {
             $diff = $level - $it->getDepth();
             for ($i = 0; $i <= $diff; $i++) {
                 array_pop($full_key);
             }
             array_push($full_key, $key);
         }
         if (!is_array($value) && !is_object($value)) {
             $result[implode($separator, $full_key)] = $value;
         }
         $level = $it->getDepth();
     }
     return $result;
 }
コード例 #20
0
ファイル: Listener.php プロジェクト: jacksleight/chalk
 public function postFlush(PostFlushEventArgs $args)
 {
     if ($this->_isFlushing || !count($this->_structures)) {
         return;
     }
     $em = $args->getEntityManager();
     $uow = $em->getUnitOfWork();
     foreach ($this->_structures as $structure) {
         $nodes = $em->getRepository('Chalk\\Core\\Structure\\Node')->all(['structure' => $structure, 'sort' => 'sort']);
         $root = null;
         foreach ($nodes as $node) {
             $node->children->setInitialized(true);
             $node->children->clear();
             if (!isset($node->parent)) {
                 $root = $node;
             }
         }
         foreach ($nodes as $node) {
             if (isset($node->parent)) {
                 $node->parent->children->add($node);
             }
         }
         $tree = new \RecursiveIteratorIterator(new \Chalk\Core\Structure\Node\Iterator([$root]), \RecursiveIteratorIterator::SELF_FIRST);
         $j = 0;
         $stack = [];
         foreach ($tree as $i => $node) {
             $slice = array_splice($stack, $tree->getDepth(), count($stack), [$node]);
             foreach (array_reverse($slice) as $reverse) {
                 $reverse->right = $j++;
             }
             $node->left = $j++;
             $node->sort = $i;
             $node->depth = $tree->getDepth();
             $nodes = $stack;
             array_shift($nodes);
             $parts = array_map(function ($node) {
                 return isset($node->slug) ? $node->slug : $node->content->slug;
             }, $nodes);
             if (isset($structure->path)) {
                 array_unshift($parts, $structure->path);
             }
             $node->path = implode('/', $parts);
         }
         foreach (array_reverse($stack) as $reverse) {
             $reverse->right = $j++;
         }
     }
     $this->_structures = [];
     $this->_isFlushing = true;
     $em->flush();
     $this->_isFlushing = false;
 }
コード例 #21
0
ファイル: Config.php プロジェクト: wispira/framework
 public function flatten()
 {
     $ritit = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->config));
     $result = array();
     foreach ($ritit as $leafValue) {
         $keys = array();
         foreach (range(0, $ritit->getDepth()) as $depth) {
             $keys[] = $ritit->getSubIterator($depth)->key();
         }
         $result[join('.', $keys)] = $leafValue;
     }
     return $result;
 }
コード例 #22
0
ファイル: ConfigDump.php プロジェクト: hpkns/laravel-config
 public function extractKeys($array, $prefix = null)
 {
     $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($array));
     $keys = [];
     foreach ($iterator as $key => $value) {
         // Build long key name based on parent keys
         for ($i = $iterator->getDepth() - 1; $i >= 0; $i--) {
             $key = $iterator->getSubIterator($i)->key() . '.' . $key;
         }
         $keys[] = $prefix . "." . $key;
     }
     return $keys;
 }
コード例 #23
0
/**
* 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;
            }
        }
    }
}
コード例 #24
0
ファイル: Pluggable.php プロジェクト: bhittani/pluggable
 private function _getPluggableFiles()
 {
     $FilePaths = array();
     $directory = new \RecursiveDirectoryIterator($this->directory);
     foreach ($F = new \RecursiveIteratorIterator($directory) as $filepath) {
         if (!$F->isDot() && $F->getDepth() === 1) {
             if ($F->getBasename() === $this->filename) {
                 $FilePaths[] = $filepath;
             }
         }
     }
     return $FilePaths;
 }
コード例 #25
0
 /**
  * Converts a multi-dimensional array to dot-notation single dimensional strings
  * Convert:
  *  [
  *      'foo'   =>  [
  *          'bar'   =>  'baz
  *      ],
  *      'baa'   =>  'sheep'
  *  ]
  *
  * TO
  *  [
  *      'foo.bar'   =>  'baz',
  *      'baa'       =>  'sheep'
  *  ]
  *
  * @param $arrayContents
  *
  * @return array
  */
 public function arrayKeyToStringPath($arrayContents)
 {
     $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($arrayContents));
     $result = [];
     foreach ($iterator as $leafValue) {
         $keys = [];
         foreach (range(0, $iterator->getDepth()) as $depth) {
             $keys[] = $iterator->getSubIterator($depth)->key();
         }
         $result[join(self::SEPARATOR, $keys)] = $leafValue;
     }
     return $result;
 }
コード例 #26
0
ファイル: Lecter.php プロジェクト: mrjuliuss/lecter
 /**
  * Get the wiki root directory files tree
  * @param  string wiki root directory
  * @return array
  */
 public function getNavBar($navPath)
 {
     $recursiveIteratorIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($navPath, \FilesystemIterator::SKIP_DOTS));
     $filesTree = [];
     foreach ($recursiveIteratorIterator as $splFileInfo) {
         $path = $splFileInfo->isDir() ? array($splFileInfo->getFilename() => []) : array($splFileInfo->getFilename());
         for ($depth = $recursiveIteratorIterator->getDepth() - 1; $depth >= 0; $depth--) {
             $path = [$recursiveIteratorIterator->getSubIterator($depth)->current()->getFilename() => $path];
         }
         $filesTree = array_merge_recursive($filesTree, $path);
     }
     return $filesTree;
 }
コード例 #27
0
 /**
  * Admin panel 
  *
  */
 function index()
 {
     /*
      * Get the media folders
      */
     $path = FCPATH . Settings::get('files_path');
     $iter = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME), RecursiveIteratorIterator::SELF_FIRST);
     // Build the folder select drop down
     $folder_select = array();
     foreach ($iter as $file => $entry) {
         if ($entry->isDir() and substr($entry->getFileName(), 0, 5) != 'thumb') {
             $pre = $iter->getDepth() > 0 ? str_repeat("&nbsp;", 2 * $iter->getDepth()) . ' &raquo; ' : '';
             $folder_select[$path . '/' . $entry->getFileName() . '/'] = $pre . $entry->getFileName();
         }
     }
     // Get groups list filtered on level <= current_user level
     $this->template['groups'] = array_filter(Connect()->model->get_groups(), array($this, '_filter_groups'));
     // Folders to template
     $this->template['fancyupload_folder'] = form_dropdown('fancyupload_folder', $folder_select, config_item('fancyupload_folder'), 'class="w160"');
     // Admin view
     $this->output('admin/fancyupload');
 }
コード例 #28
0
ファイル: DotNotation.php プロジェクト: ptheofan/dot-notation
 /**
  * Convert a php nested array to mongo like dot notation
  * @see http://stackoverflow.com/questions/10424335/php-convert-multidimensional-array-to-2d-array-with-dot-notation-keys
  * @param array $array
  * @return array
  */
 public static function compact(array $array)
 {
     $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
     $rVal = [];
     foreach ($iterator as $leafValue) {
         $keys = array();
         foreach (range(0, $iterator->getDepth()) as $depth) {
             $keys[] = $iterator->getSubIterator($depth)->key();
         }
         $rVal[join('.', $keys)] = $leafValue;
     }
     return $rVal;
 }
コード例 #29
0
ファイル: ConfigGet.php プロジェクト: gjorgiev/platform
 /**
  * Override response handler to flatten array
  */
 protected function handleResponse($response, OutputInterface $output)
 {
     $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($response));
     $result = [];
     foreach ($iterator as $leafValue) {
         $keys = [];
         foreach (range(0, $iterator->getDepth()) as $depth) {
             $keys[] = $iterator->getSubIterator($depth)->key();
         }
         $result[join('.', $keys)] = $leafValue;
     }
     return parent::handleResponse($result, $output);
 }
コード例 #30
0
ファイル: Container.php プロジェクト: sonicmaster/RPG
 /**
  * Finder method to be able to find resources by context name
  * and attributes.  Example usage:
  *
  * <code>
  *
  * </code>
  *
  * @param Zend_Tool_Project_Profile_Resource_SearchConstraints|string|array $searchParameters
  * @return Zend_Tool_Project_Profile_Resource
  */
 public function search($matchSearchConstraints, $nonMatchSearchConstraints = null)
 {
     if (!$matchSearchConstraints instanceof Zend_Tool_Project_Profile_Resource_SearchConstraints) {
         $matchSearchConstraints = new Zend_Tool_Project_Profile_Resource_SearchConstraints($matchSearchConstraints);
     }
     $this->rewind();
     /**
      * @todo This should be re-written with better support for a filter iterator, its the way to go
      */
     if ($nonMatchSearchConstraints) {
         $filterIterator = new Zend_Tool_Project_Profile_Iterator_ContextFilter($this, array('denyNames' => $nonMatchSearchConstraints));
         $riIterator = new RecursiveIteratorIterator($filterIterator, RecursiveIteratorIterator::SELF_FIRST);
     } else {
         $riIterator = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST);
     }
     $foundResource = false;
     $currentConstraint = $matchSearchConstraints->getConstraint();
     $foundDepth = 0;
     foreach ($riIterator as $currentResource) {
         // if current depth is less than found depth, end
         if ($riIterator->getDepth() < $foundDepth) {
             break;
         }
         if (strtolower($currentResource->getName()) == strtolower($currentConstraint->name)) {
             $paramsMatch = true;
             // @todo check to ensure params match (perhaps)
             if (count($currentConstraint->params) > 0) {
                 $currentResourceAttributes = $currentResource->getAttributes();
                 if (!is_array($currentConstraint->params)) {
                     require_once 'Zend/Tool/Project/Profile/Exception.php';
                     throw new Zend_Tool_Project_Profile_Exception('Search parameter specifics must be in the form of an array for key "' . $currentConstraint->name . '"');
                 }
                 foreach ($currentConstraint->params as $paramName => $paramValue) {
                     if (!isset($currentResourceAttributes[$paramName]) || $currentResourceAttributes[$paramName] != $paramValue) {
                         $paramsMatch = false;
                         break;
                     }
                 }
             }
             if ($paramsMatch) {
                 $foundDepth = $riIterator->getDepth();
                 if (($currentConstraint = $matchSearchConstraints->getConstraint()) == null) {
                     $foundResource = $currentResource;
                     break;
                 }
             }
         }
     }
     return $foundResource;
 }