PluginProbe
CSS & JavaScript Toolbox / 11.4
CSS & JavaScript Toolbox v11.4
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / models / block / parameters / base / parameters.php

parameters.php in CSS & JavaScript Toolbox 11.4, at models/block/parameters/base/parameters.php

97 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 /**
7 *
8 */
9 abstract class CJT_Models_Block_Parameters_Base_Parameters
10 extends ArrayIterator {
11
12 /**
13 * put your comment there...
14 *
15 * @var mixed
16 */
17 protected $params = array();
18
19 /**
20 * put your comment there...
21 *
22 * @var mixed
23 */
24 protected $blockId = null;
25
26 /**
27 * put your comment there...
28 *
29 * @param mixed $blockId
30 * @return CJT_Models_Block_Parameters
31 */
32 public function __construct($blockId) {
33 $this->blockId = $blockId;
34 // Query all block parameters, pass it to the ArrayIterator object.
35 parent::__construct($this->queryParameters());
36 }
37
38 /**
39 * put your comment there...
40 *
41 * @param mixed $row
42 */
43 public abstract function createModelObject($row);
44
45 /**
46 * put your comment there...
47 *
48 */
49 public function getBlockId() {
50 return $this->blockId;
51 }
52
53 /**
54 * put your comment there...
55 *
56 */
57 protected function getParams() {
58 return $this->params;
59 }
60
61 /**
62 * put your comment there...
63 *
64 */
65 protected abstract function getQuery();
66
67 /**
68 * put your comment there...
69 *
70 */
71 protected function queryParameters() {
72 // Initialize.
73 $parameters = array();
74 $query = $this->getQuery();
75 $recset = cssJSToolbox::getInstance()->getDBDriver()->select($query, ARRAY_A);
76 // Prototype to parameter model.
77 foreach (new ArrayIterator($recset) as $row) {
78 // Instantiate parameter model object.
79 $param = $this->createModelObject($row);
80 // Add as child if it has a parent or add in the root if not.
81 if (!$param->getParent()) {
82 // Add to list.
83 $parameters[$param->getId()] = $param;
84 }
85 else {
86 // Add as child parameter!
87 $parameters[$param->getParent()]->addChild($param);
88 }
89 // Flat parameters list.
90 $this->params[] = $param;
91 }
92 // Return only root parameters.
93 return $parameters;
94 }
95
96 } // End class.
97