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


PHP Globals::user方法代码示例

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


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

示例1: single

	public function single ($query) {

		$config = Globals::user('comments', 'single_item');

		$perpage = $config['per_page'];
		$display = $config['display'];
		$inverted = $config['inverted'];

		if ($query['page'] != 'all') {			
			$page = $query['page'];
			$start = ($page - 1) * $perpage;
			$limit = " limit $start, $perpage";	
		} else {
			$limit = "";
			$page = 1;
			$start = 0;
		}
		
		$root = $display == 'ladder' ? "and root = 0" : "";		
		$direction = (bool) $inverted ? "desc" : "asc";
		
		$params = array('deleted', $query['place'], $query['item_id']);
		$condition = "area != ? and place = ? and item_id = ? $root order by date $direction $limit";

		$comments = Database::set_counter()->get_full_vector('comment', $condition, $params, false);
		
		$total = Database::get_counter();
		$current = (bool) $inverted ? $total - $start : $start;
			
		if ($display == 'ladder') {
			$roots = array_keys($comments);
			
			$condition = "area != ? and place = ? and item_id = ? and ".
				Database::array_in('root', $roots)." order by date";
			$params = array_merge($params, $roots);
			
			$children = Database::get_full_vector('comment', $condition, $params, false);
			$this->build_tree($children);
		} else {
			$children = array();
		}
		
		if ($display == 'quotation') {
			$parents = array();
			
			foreach ($comments as $comment) {
				$parents[] = $comment['parent'];
			}
			
			$condition = "area != ? and place = ? and item_id = ? and ".
				Database::array_in('id', $parents);
			$params = array_merge($params, $parents);
							
			$parents = Database::get_full_vector('comment', $condition, $params, false);
		} else {
			$parents = array();
		}		

		foreach ($comments as $id => $comment) {
			$item_children = array();
			$item_parent = null;
			
			foreach ($children as $child_id => $child) {
				if ($id == $child['root']) {				
					$item_children[$child_id] = new Item_Comment($child, $display);
				}
			}
			
			foreach ($parents as $parent_id => $parent) {
				if ($parent_id == $comment['parent']) {				
					$item_parent = new Item_Comment($parent);
				}
			}
			
			$this->items[$id] = new Item_Comment(
				array_merge(
					$comment, 
					array(
						'items' => $item_children,
						'quotation' => $item_parent,
						'index' => (bool) $inverted ? $current-- : ++$current,
					)
				),
				$display
			);
		}

		$this->items[] = new Item_Comment_Navi(array(
			'curr_page' => $page,
			'pagecount' => ceil($total / $perpage),
			'query' => $query,
			'module' => 'comments',
		));
	}
开发者ID:4otaku,项目名称:draw,代码行数:94,代码来源:output.php

示例2: postprocess

	public function postprocess () {

		switch ($this->flag) {
			case 'quotation':
			
				if (
					empty($this->data['quotation']) &&
					!empty($this->data['parent']) && 
					!empty($this->parent->data['items'][$this->data['parent']])
				) {
					$this->data['quotation'] = $this->parent->data['items'][$this->data['parent']];
				}
				break;
			case 'ladder':

				if (!empty($this->parent)) {

					$keys = array_keys($this->parent->data['items']);
					$local_index = array_search($this->data['id'], $keys) + 1;
					
					$this->data['index'] = $this->parent->data['index'].'.'.$local_index;
				}
			
				if (!empty($this->data['items'])) {
					if (empty($this->parent)) {
						$tree_length = 0;
						
						foreach ($this->data['items'] as $child) {
							$tree_length = max($tree_length, count($child['tree']));
						}
						
						$config = Globals::user('comments', 'single_item');
						
						if ($tree_length * $config['max_single_margin'] < $config['max_margin']) {
							$this->data['margin'] = $config['max_single_margin'];
						} else {
							$this->data['margin'] = round($config['max_margin'] / $tree_length);
						}
					}
					
					$indirect_children = array();
					
					foreach ($this->data['items'] as $id => $child) {
						if ($this->data['id'] != $child->last_of('tree')) {
							$indirect_children[$id] = $child;
							unset($this->data['items'][$id]);
						}
					}
					
					foreach ($this->data['items'] as $id => $child) {
						foreach ($indirect_children as $indirect_id => $indirect_child) {
							if (in_array($id, $indirect_child['tree'])) {
								$this->data['items'][$id]->add_to('items', $indirect_child, $indirect_id);
							}
						}
					}
				}
				break;
			default: 
				break;
		}
		
		parent::postprocess();
		
		if (!empty($this->parent) && !empty($this->parent->data['place'])) {
			$this->data['place'] = $this->parent->data['place'];
			$this->data['link'] = $this->parent['link'];
		}
	}
开发者ID:4otaku,项目名称:draw,代码行数:69,代码来源:comment.php


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