1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Pages;
13
14 use Brickrouge\Element;
15
16 class PopPage extends Element
17 {
18 public function __toString()
19 {
20 global $core;
21
22 try
23 {
24 $model = $core->models['pages'];
25 $nodes = $model->select('nid, parentid, title')
26 ->filter_by_siteid($core->site_id)
27 ->order('weight, created_at')
28 ->all(\PDO::FETCH_OBJ);
29
30 $tree = Model::nestNodes($nodes);
31 Model::setNodesDepth($tree);
32 $entries = Model::levelNodesById($tree);
33
34 $options = array();
35
36 foreach ($entries as $entry)
37 {
38 $options[$entry->nid] = str_repeat("\xC2\xA0", $entry->depth * 4) . $entry->title;
39 }
40
41 $this[self::OPTIONS] = array(null => '') + $options;
42 }
43 catch (\Exception $e)
44 {
45 return $e->getMessage();
46 }
47
48 return parent::__toString();
49 }
50 }