Phundament App Class Reference
  • Package
  • Class
  • Tree

Packages

  • bootstrap
    • widgets
      • input
  • Image
  • None
  • p3admin
  • p3extensions
    • behaviors
    • commands
    • components
    • helpers
    • widgets
  • p3media
    • actions
    • controllers
    • models
  • p3pages
    • models
  • p3widgets
    • components
    • models
  • PHP
  • system
    • db
      • ar
    • gii
    • web
      • auth
      • helpers
      • widgets
  • yiiext
    • widgets
      • fancybox
      • lipsum
  • zii
    • widgets
      • grid

Classes

  • EFileUpload
  • P3MetaTreeWidget
  • Relation
 1 <?php
 2 
 3 /**
 4  * Class file
 5  */
 6 /**
 7  * Renders a hierarchical list of meta data records
 8  *
 9  * @see P3MetaDataBehavior
10  */
11 Yii::setPathOfAlias('P3MetaTreeWidget', dirname(__FILE__));
12 
13 class P3MetaTreeWidget extends CWidget {
14 
15     public $model = null;
16     public $rootNodeId = null;
17     public $view = 'tree';
18     public $routes = array(
19         'updateContent' => null,
20         'updateMetaData' => null,
21         'viewContent' => null,
22         'viewMetaData' => null,
23     );
24     public $cssClass = "p3-meta-tree-widget";
25 
26     function init() {
27 
28     }
29 
30     function run() {
31         $criteria = new CDbCriteria;
32         // SQLite workaround for <=>
33         if ($this->rootNodeId === null) {
34             $criteria->condition = "treeParent_id IS :id";
35         } else {
36             $criteria->condition = "treeParent_id = :id";
37         }
38         $criteria->params = array(':id' => $this->rootNodeId);
39         $model = new $this->model;
40         $firstLevelNodes = $model::model()->findAll($criteria);
41         //var_dump($firstLevelNodes);exit;
42         $this->renderTree($firstLevelNodes);
43     }
44 
45     private function renderTree($models) {
46         echo "<div  class='{$this->cssClass}'>";
47         echo "<ul>";
48         foreach ($models AS $model) {
49             echo "<li>";
50             $this->render($this->view, array('model' => $model));
51             $this->renderTree($model->getChildren());
52             echo "</li>";
53         }
54         echo "</ul>";
55         echo "</div>";
56     }
57 
58 }
59 
60 ?>
61 
Phundament App Class Reference API documentation generated by ApiGen 2.8.0