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


PHP tree::instance方法代码示例

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


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

示例1: setUp

 function setUp()
 {
     $this->db =& db_factory::instance();
     $this->_clean_up();
     $this->_init_site_object();
     $this->object->set_attribute('controller_name', 'site_object_controller');
     $controller_id = site_object_controller::get_id('site_object_controller');
     $this->object->set_attribute('controller_id', $controller_id);
     debug_mock::init($this);
     $user =& user::instance();
     $user->_set_id(10);
     $tree =& tree::instance();
     $values['identifier'] = 'root';
     $values['object_id'] = 100;
     $this->root_node_id = $tree->create_root_node($values, false, true);
     $class_id = $this->object->get_class_id();
     $this->db->sql_insert('sys_site_object', array('id' => 100, 'class_id' => $class_id, 'current_version' => 1));
     $values['identifier'] = 'ru';
     $values['object_id'] = 1;
     $this->parent_node_id = $tree->create_sub_node($this->root_node_id, $values);
     $this->db->sql_insert('sys_site_object', array('id' => 1, 'class_id' => $class_id, 'current_version' => 1));
     $values['identifier'] = 'document';
     $values['object_id'] = 10;
     $this->sub_node_id = $tree->create_sub_node($this->parent_node_id, $values);
     $this->db->sql_insert('sys_site_object', array('id' => 10, 'class_id' => $class_id, 'current_version' => 1));
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:26,代码来源:site_object_manipulation_test.class.php

示例2: array

	function _get_objects_to_delete($node_ids)
	{
		$params = array(
			'restrict_by_class' => false
		);
		
		$objects =& fetch_by_node_ids($node_ids, 'site_object', $counter, $params);
		
		$result = array();
		$tree = tree :: instance();
		
		foreach($objects as $id => $item)
		{
			if (!isset($item['actions']['delete']))
			{
				$objects[$id]['delete_status'] = 1;
				$objects[$id]['delete_reason'] = strings :: get('delete_action_not_accessible', 'error');
				continue;
			}
			
			$site_object =& wrap_with_site_object($item);
			if (!$site_object->can_delete())
			{
				$objects[$id]['delete_status'] = 1;
				$objects[$id]['delete_reason'] = strings :: get('cant_be_deleted', 'error');
				continue;
			}	
			
			$objects[$id]['delete_reason'] = strings :: get('ok');
			$objects[$id]['delete_status'] = 0;
			$objects[$id]['ids'][$item['node_id']] = 1;
		}
		
		return $objects;
	}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:35,代码来源:multi_delete_action.class.php

示例3: perform

 function perform(&$request, &$response)
 {
     $tree =& tree::instance();
     $tree->initialize_expanded_parents();
     $this->_set_template_tree();
     parent::perform($request, $response);
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:7,代码来源:set_group_objects_access.class.php

示例4: validate

  function validate(&$dataspace)
  {
    if(!$value = $dataspace->get($this->field_name))
      return;

    $tree = tree :: instance();

    if(!$tree->is_node($this->parent_node_id))
      return;

    if(!$nodes = $tree->get_children($this->parent_node_id))
      return;

    foreach($nodes as $id => $node)
    {
      if($node['identifier'] != $value)
        continue;

      if($this->node_id == TREE_IDENTIFIER_RULE_UNKNOWN_NODE_ID)
      {
        $this->error(strings :: get('error_duplicate_tree_identifier', 'error'));
        break;
      }
      elseif($id != $this->node_id)
      {
        $this->error(strings :: get('error_duplicate_tree_identifier', 'error'));
        break;
      }
    }
  }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:30,代码来源:tree_identifier_rule.class.php

示例5: array

 function &search_fetch_sub_branch($path, $loader_class_name, &$counter, $params = array(), $fetch_method = 'fetch')
 {
     $tree =& tree::instance();
     $site_object =& site_object_factory::create($loader_class_name);
     if (!isset($params['restrict_by_class']) || isset($params['restrict_by_class']) && (bool) $params['restrict_by_class']) {
         $class_id = $site_object->get_class_id();
     } else {
         $class_id = null;
     }
     if (isset($params['check_expanded_parents'])) {
         $check_expanded_parents = (bool) $params['check_expanded_parents'];
     } else {
         $check_expanded_parents = false;
     }
     if (isset($params['include_parent'])) {
         $include_parent = (bool) $params['include_parent'];
     } else {
         $include_parent = false;
     }
     $depth = isset($params['depth']) ? $params['depth'] : 1;
     if (!($nodes = $tree->get_accessible_sub_branch_by_path($path, $depth, $include_parent, $check_expanded_parents, $class_id))) {
         return array();
     }
     $object_ids = complex_array::get_column_values('object_id', $nodes);
     if (!count($object_ids)) {
         return array();
     }
     $result =& $this->search_fetch_by_ids($object_ids, $loader_class_name, $counter, $params, $fetch_method);
     return $result;
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:30,代码来源:search_fetcher.class.php

示例6: setUp

  function setUp()
  {
    parent :: setUp();

    $this->db =& db_factory :: instance();

    $tree =& tree :: instance();

    $values['identifier'] = 'root';
    $this->node_id_root = $tree->create_root_node($values, false, true);

    $values['identifier'] = 'ru';
    $values['object_id'] = 1;
    $this->node_id_ru = $tree->create_sub_node($this->node_id_root, $values);

    $values['identifier'] = 'document';
    $values['object_id'] = 10;
    $this->node_id_document = $tree->create_sub_node($this->node_id_ru, $values);

    $values['identifier'] = 'doc1';
    $values['object_id'] = 20;
    $this->node_id_doc1 = $tree->create_sub_node($this->node_id_ru, $values);

    $values['identifier'] = 'doc2';
    $values['object_id'] = 30;
    $this->node_id_doc2 = $tree->create_sub_node($this->node_id_ru, $values);
  }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:27,代码来源:tree_identifier_rule_test.class.php

示例7: _valid_perform

 function _valid_perform(&$request, &$response)
 {
     $tree =& tree::instance();
     $params = array();
     $params['identifier'] = $this->dataspace->get('identifier');
     $params['class'] = $this->dataspace->get('class_name');
     $params['title'] = $this->dataspace->get('title');
     $params['parent_node_id'] = $this->dataspace->get('parent_node_id');
     $params['controller_id'] = site_object_controller::get_id($this->dataspace->get('controller_name'));
     $object =& site_object_factory::create($params['class']);
     if (!($parent_data = fetch_one_by_node_id($params['parent_node_id']))) {
         error("parent wasn't retrieved", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     $object->merge_attributes($params);
     if (!$object->create()) {
         error("object wasn't registered", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     $parent_object =& site_object_factory::create($parent_data['class_name']);
     $parent_object->merge_attributes($parent_data);
     $access_policy =& access_policy::instance();
     $access_policy->save_initial_object_access($object, $parent_object);
     $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
     if ($request->has_attribute('popup')) {
         $response->write(close_popup_response($request));
     }
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:26,代码来源:register_new_object_action.class.php

示例8: _valid_perform

 function _valid_perform()
 {
     $tree =& tree::instance();
     $params = array();
     $params['identifier'] = $this->dataspace->get('identifier');
     $params['parent_path'] = $this->dataspace->get('parent_path');
     $params['class'] = $this->dataspace->get('class_name');
     $params['title'] = $this->dataspace->get('title');
     $object =& site_object_factory::create($params['class']);
     $is_root = false;
     if (!($parent_data = fetch_one_by_path($params['parent_path']))) {
         if ($params['parent_path'] == '/') {
             $is_root = true;
         } else {
             error("parent wasn't retrieved", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
         }
     }
     if (!$is_root) {
         $params['parent_node_id'] = $parent_data['node_id'];
     } else {
         $params['parent_node_id'] = 0;
     }
     $object->import_attributes($params);
     if (!$object->create($is_root)) {
         error("object wasn't registered", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     if (!$is_root) {
         $parent_object =& site_object_factory::instance($parent_data['class_name']);
         $parent_object->import_attributes($parent_data);
         $access_policy =& access_policy::instance();
         $access_policy->save_object_access($object, $parent_object);
     }
     return new close_popup_response(RESPONSE_STATUS_FORM_SUBMITTED);
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:34,代码来源:register_new_object_action.class.php

示例9: unset

 function &_fetch(&$counter, $params)
 {
     $tree =& tree::instance();
     if (isset($params['order'])) {
         $order = $params['order'];
         unset($params['order']);
     } else {
         $order = array('priority' => 'ASC');
     }
     $tree_array =& parent::_fetch($counter, $params);
     $tree_array =& tree_sorter::sort($tree_array, $order, 'node_id', 'parent_node_id');
     $path_node = $tree->get_node_by_path($params['path']);
     if (isset($params['include_parent']) && (bool) $params['include_parent']) {
         $path_node_level = $path_node['level'] - 1;
     } else {
         $path_node_level = $path_node['level'];
     }
     $levels_status_array = array();
     $size = count($tree_array);
     $current_pos = 0;
     $parent_data = array();
     foreach ($tree_array as $id => $tree_item) {
         $parent_node_id = $tree_item['parent_node_id'];
         if (!isset($parent_data[$parent_node_id])) {
             if ($parent_node_id == 0) {
                 $parent_data[$parent_node_id]['children_amount'] = 1;
             } else {
                 $parent_data[$parent_node_id]['children_amount'] = $tree->count_accessible_children($parent_node_id);
             }
             $parent_data[$parent_node_id]['counter'] = 0;
         }
         $parent_data[$parent_node_id]['counter']++;
         if ($parent_data[$parent_node_id]['counter'] == 1) {
             $is_first_child = true;
         } else {
             $is_first_child = false;
         }
         if ($parent_data[$parent_node_id]['counter'] == $parent_data[$parent_node_id]['children_amount']) {
             $is_last_child = true;
         } else {
             $is_last_child = false;
         }
         $tree_array[$id]['level'] = $tree_array[$id]['level'] - $path_node_level;
         $levels_status_array[$tree_item['level'] - $path_node_level] = $is_last_child;
         $tree_array[$id]['level_' . $tree_array[$id]['level']] = 1;
         $tree_array[$id]['is_expanded'] = $tree->is_node_expanded($tree_item['node_id']);
         $tree_array[$id]['is_last_child'] = $is_last_child;
         $tree_array[$id]['is_first_child'] = $is_first_child;
         $tree_array[$id]['levels_status'] = $levels_status_array;
         if ($tree_array[$id]['class_name'] == 'image_object' || $tree_array[$id]['class_name'] == 'file_object') {
             $tree_array[$id]['icon'] = '/root?node_id=' . $tree_item['node_id'] . '&icon';
         } elseif (isset($tree_item['icon']) && $tree_item['icon']) {
             $tree_array[$id]['icon'] = $tree_item['icon'];
         } else {
             $tree_array[$id]['icon'] = '/shared/images/generic.gif';
         }
     }
     return $tree_array;
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:59,代码来源:fetch_tree_datasource.class.php

示例10: _load_tree

 function _load_tree()
 {
     $tree =& tree::instance();
     if (file_exists($tree->get_cache_path())) {
         unlink($tree->get_cache_path());
     }
     $tree->load_tree();
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:8,代码来源:test_artlimb.php

示例11: validate

 function validate(&$dataspace)
 {
     $value = $dataspace->get($this->field_name);
     $tree = tree::instance();
     if (!$tree->get_node_by_path($value)) {
         $this->error(strings::get('error_invalid_tree_path', 'error'));
     }
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:8,代码来源:tree_path_rule.class.php

示例12: check

	function check($value)
	{
		$tree = tree :: instance();
		
		if(empty($value))
		  $this->error(strings :: get('error_invalid_tree_node_id', 'error'));
		elseif(!$tree->get_node((int)$value))
			$this->error(strings :: get('error_invalid_tree_node_id', 'error'));
	} 
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:9,代码来源:tree_node_id_rule.class.php

示例13: perform

 function perform(&$request, &$response)
 {
     $tree =& tree::instance();
     $tree->initialize_expanded_parents();
     if ($filter_groups = session::get('filter_groups')) {
         $this->dataspace->set('filter_groups', $filter_groups);
     }
     parent::perform($request, $response);
     $this->_fill_policy();
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:10,代码来源:set_group_objects_access.class.php

示例14: _check_nesting_rules

 function _check_nesting_rules($node_id, $target_node_id, $mode)
 {
     $tree =& tree::instance();
     if ($mode == NESE_MOVE_AFTER || $mode == NESE_MOVE_BEFORE) {
         $target_node = $tree->get_node($target_node_id);
         return $this->_can_parent_accept_node($target_node['parent_id'], $node_id);
     } elseif ($mode == NESE_MOVE_BELOW) {
         return $this->_can_parent_accept_node($target_node_id, $node_id);
     }
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:10,代码来源:tree_move_item_action.class.php

示例15: _process_result_array

 function _process_result_array($arr)
 {
     $tree =& tree::instance();
     $total = $this->stats_report->fetch_total_hits();
     $result = array();
     foreach ($arr as $index => $data) {
         $data['percentage'] = round($data['hits'] / $total * 100, 2);
         $result[$index] = $data;
     }
     return $result;
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:11,代码来源:stats_keywords_list_datasource.class.php


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