当前位置: 首页>>代码示例>>PHP>>正文


PHP Tree::setupMemory方法代码示例

本文整理汇总了PHP中Tree::setupMemory方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::setupMemory方法的具体用法?PHP Tree::setupMemory怎么用?PHP Tree::setupMemory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree的用法示例。


在下文中一共展示了Tree::setupMemory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public function init()
 {
     $options = array('table' => 'categories', 'order' => 'sort_order', 'columnNameMaps' => array('id' => 'categories_id', 'parentId' => 'parent_id'));
     $this->tree = Tree::setupMemory('DBsimple', DSN, $options);
     $this->tree->setup();
     $this->assign_by_ref('categoryTree', $this->tree);
     $this->cPath = array();
     if ($cPath = $this->app->GP('cPath')) {
         $this->cPath = explode('_', $cPath);
     } elseif ($productId = $this->app->GP('pId')) {
         $prodToCat = DB_DataObject::factory('products_to_categories');
         $prodToCat->get($productId);
         $path = $this->tree->getPath($prodToCat->categories_id);
         foreach ($path as $idx => $cat) {
             $this->cPath = $cat['id'];
         }
     }
     $this->currentCategory = $this->cPath[count($this->cPath) - 1];
 }
开发者ID:BackupTheBerlios,项目名称:saecommerce,代码行数:19,代码来源:SAEPage.php

示例2: demonstrate

    it reads out the entire tree upon calling the method
        'setup', then you can work on the tree in whichever way
        you want, just have a look at the examples
        there are different ways to achieve things,
        i will try to demonstrate (all of) them
*/
require_once 'Tree/Tree.php';
// define the DB-table where the data shall be read from
$options = array('table' => 'MemoryNestedTree', 'whereAddOn' => "comment=''");
// calling 'setupMemory' means to retreive a class, which works on trees,
// that are temporarily stored in the memory, in an array
// this means the entire tree is available at all time !!!
// consider the resource usage and it's not to suggested to work
// on huge trees (upto 1000 elements it should be ok, depending on your environment and requirements)
// using 'setupMemory'
$tree = Tree::setupMemory('DBnested', 'mysql://root@localhost/test', $options);
// pass the options we had assigned up there
// add a new root element in the tree
$rootId = $tree->add(array('name' => 'myElement'));
// add an element under the new element we added
$id = $tree->add(array('name' => 'subElement'), $rootId);
// add another element under the parent element we added
$id = $tree->add(array('name' => 'anotherSubElement'), $rootId, $id);
// call 'setup', to build the inner array, so we can work on the structure using the
// given methods
$tree->setup();
dumpAllNicely('dump all after creation');
// get the path of the last inserted element
dumpHelper('$tree->getPath( ' . $id . ' )', 'dump the path from "myElement/anotherSubElement"');
$id = $tree->getIdByPath('myElement/subElement');
dumpHelper('$tree->getParent(' . $id . ')', 'dump the parent of "myElement/subElement"', true);
开发者ID:vojtajina,项目名称:sitellite,代码行数:31,代码来源:Memory_DBnested.php

示例3: _setOptionsByXmlConfig

 /**
  *   applies the given xml config file
  *
  *   @access     public
  *   @version    01/12/14
  *   @author     Wolfram Kriesing <wolfram@kriesing.de>
  */
 function _setOptionsByXmlConfig($configFileOrString, $isString = false)
 {
     //print '_setOptionsByXmlConfig ... '.nl2br(htmlentities($configFileOrString))." , $isString<br>";
     // include this so i can get the xml file prepared in the tree shape
     // and i can use the tree methods to retreive the options i need to set :-)
     if (!@(include_once 'Tree/Tree.php')) {
         return $this->_error("xml-config could not be parsed, because the class 'Tree/Tree.php' could not be included<br>" . '1. pleace be sure to have the latest PEAR::Tree package installed ' . '(<a href="http://pear.php.net/package-info.php?pacid=104">you get it from here</a>)', PEAR_ERROR_DIE);
     }
     if ($isString) {
         $config = Tree::setupMemory('XML');
         $config->setupByRawData($configFileOrString);
     } else {
         $config = Tree::setupMemory('XML', $configFileOrString);
         $config->setup();
     }
     //
     //  add the filters set in the xml config files
     //
     // TODO check for prefilter defines in xml config
     if ($id = $config->getIdByPath('html_template_xipe/prefilter')) {
         $this->_applyFiltersFromXMLConfig($config, $id, true);
     }
     //
     //  apply xml given options to this class, do this after applying the filters
     //
     if ($id = $config->getIdByPath('html_template_xipe/options')) {
         $delimiter = $config->getElementByPath('delimiter', $id);
         if ($delimiter) {
             $begin = $delimiter['attributes']['begin'];
             $end = $delimiter['attributes']['end'];
             if ($begin && $end) {
                 $setOptions['delimiter'] = array(trim($begin), trim($end));
             }
         }
         if ($autoBraces = $config->getIdByPath('autobraces', $id)) {
             $setOptions['autoBraces'] = false;
             if (strtolower(trim($config->data[$autoBraces]['attributes']['value'])) == 'true') {
                 $setOptions['autoBraces'] = true;
             }
         }
         if ($localeId = $config->getIdByPath('locale', $id)) {
             $locale = trim($config->data[$localeId]['attributes']['value']);
             if ($locale) {
                 $setOptions['locale'] = $locale;
             }
         }
         //
         //  find the cache tag
         //  <cache>
         //      <time value="10" unit="minutes"/>
         //      <depends value="$_GET $_POST"/>
         //  </cache>
         //
         if ($cacheId = $config->getIdByPath('cache', $id)) {
             if (@$config->data[$cacheId]['attributes']['dontcache'] == 'true') {
                 $setOptions['cache']['time'] = false;
                 $this->_log('XMLConfig: dont cache this file!');
             } else {
                 if ($timeId = $config->getIdByPath('time', $cacheId)) {
                     $time = $config->data[$timeId]['attributes']['value'];
                     if ($unit = $config->data[$timeId]['attributes']['unit']) {
                         switch (strtolower($unit)) {
                             case 'week':
                             case 'weeks':
                                 $time = $time * 7;
                             case 'day':
                             case 'days':
                                 $time = $time * 24;
                             case 'hour':
                             case 'hours':
                                 $time = $time * 60;
                             case 'minute':
                             case 'minutes':
                                 $time = $time * 60;
                             case 'second':
                                 break;
                         }
                     }
                     //print "XML: cache this page for $time seconds<br><br>";
                     // if a valid time was found parse also the other tags, valid is also 0, that's why this strange check
                     // accept only integers
                     if ($time == (int) $time) {
                         $cacheOption['time'] = (int) $time;
                         if (($id = $config->getIdByPath('depends', $cacheId)) && ($depends = $config->data[$id]['attributes']['value'])) {
                             $cacheOption['depends'] = $depends;
                         }
                         $setOptions['cache'] = $cacheOption;
                     } else {
                         $this->_log("ERROR in your xml config, caching-time: {$time}, is not valid, in: " . $isString ? 'tpl-file-embedded config' : $configFileOrString);
                     }
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:GeekyNinja,项目名称:LifesavingCAD,代码行数:101,代码来源:XMLConfig.php

示例4: process

 function process($srcDir, $destDir)
 {
     $this->_srcDir = $srcDir;
     $packageFile = $this->_srcDir . '/package.xml';
     $cli =& Horde_CLI::singleton();
     if (!is_file($packageFile)) {
         $cli->message('No package.xml in ' . $this->_srcDir, 'cli.warning');
         return false;
     }
     $tree = Tree::setupMemory('XML', $packageFile);
     $tree->setup();
     // read package name
     $packageName = trim($tree->getElementContent('/package/name', 'cdata'));
     $cli->writeln("Processing package {$packageName}.");
     // look for filelist in '/package/release/filelist'
     $filelist = $tree->getElementByPath('/package/release/filelist');
     if ($filelist) {
         // do this better, make the tree class work case insensitive
         $baseInstallDir = $filelist['child']['attributes']['baseinstalldir'];
         $this->_baseInstallDir = $destDir;
         if ($baseInstallDir != '/') {
             $this->_baseInstallDir .= '/' . $baseInstallDir;
         }
         if (!is_dir($this->_baseInstallDir)) {
             require_once 'System.php';
             System::mkdir('-p ' . $this->_baseInstallDir);
         }
         $this->_handleFilelistTag($filelist);
     } else {
         $cli->message('No filelist tag found inside: ' . $packageFile, 'cli.warning');
     }
 }
开发者ID:Artea,项目名称:freebeer,代码行数:32,代码来源:create-symlinks.php

示例5: demonstrate

        i will try to demonstrate (all of) them     
        
        NOTE: for referening the XML-Nodes currently everything has to 
        be lower case, 
            SimpleTemplate/preFilter
        should be                   
            simpletemplate/prefilter
*/
require_once 'Tree/Tree.php';
// calling 'setupMemory' means to retreive a class, which works on trees,
// that are temporarily stored in the memory, in an array
// this means the entire tree is available at all time
// consider the resource usage and it's not to suggested to work
// on huge trees (upto 1000 elements it should be ok, depending on your environment and requirements)
// using 'setupMemory'
$tree = Tree::setupMemory('XML', 'config.xml');
// methods 'add' 'remove' and so on are not implemented yet, you can only read the tree for now
// and navigate inside of it
// call 'setup', to build the inner array, so we can work on the structure using the
// given methods
$tree->setup();
dumpAllNicely('dump all after "$tree-&gt;setup"');
// get the path of the last inserted element
print 'id=' . ($id = $tree->getIdByPath('simpletemplate/options/delimiter'));
dumpHelper($tree->getPath($id), 'dump the path from "simpletemplate/options/delimiter"');
$id = $tree->getIdByPath('simpletemplate/options');
dumpHelper(array($tree->getParent($id)), 'dump the parent of "simpletemplate/options"');
// you can also use:    $tree->data[$id]['parent']
$id = $tree->getIdByPath('simpletemplate');
dumpHelper(array($tree->getChild($id)), 'dump the child of "simpletemplate"');
// you can also use:    $tree->data[$id]['child']
开发者ID:vojtajina,项目名称:sitellite,代码行数:31,代码来源:Memory_XML.php


注:本文中的Tree::setupMemory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。