PluginProbe
CSS & JavaScript Toolbox / 6.1
CSS & JavaScript Toolbox v6.1
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 / framework / developer / interface / block / shortcode / shortcode.php

shortcode.php in CSS & JavaScript Toolbox 6.1, at framework/developer/interface/block/shortcode/shortcode.php

177 lines 3.2 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 // Disallow direct access.
7 defined('ABSPATH') or die("Access denied");
8
9 /**
10 *
11 */
12 class CJT_Framework_Developer_Interface_Block_Shortcode {
13
14 /**
15 * put your comment there...
16 *
17 * @var mixed
18 */
19 protected $bcid;
20
21 /**
22 * put your comment there...
23 *
24 * @var mixed
25 */
26 protected $block = null;
27
28 /**
29 * put your comment there...
30 *
31 * @var mixed
32 */
33 protected $containerElementId = null;
34
35 /**
36 * put your comment there...
37 *
38 * @var mixed
39 */
40 protected $content = null;
41
42 /**
43 * put your comment there...
44 *
45 * @var mixed
46 */
47 protected $parameters = null;
48
49 /**
50 * put your comment there...
51 *
52 * @var CJT_Framework_Developer_Interface_Block_Shortcode_Segments
53 */
54 protected $segments = null;
55
56 /**
57 * put your comment there...
58 *
59 * @param mixed $block
60 * @param mixed $parameters
61 * @param mixed $content
62 * @return CJT_Framework_Developer_Interface_Block_Shortcode
63 */
64 public function __construct($block, $parameters, & $content) {
65 // Initialize.
66 $this->block = $block;
67 $this->content =& $content;
68 cssJSToolbox::import('framework:developer:interface:block:parameters:parameters.php');
69 $this->parameters = new CJT_Framework_Developer_Interface_Block_Parameters($parameters);
70 cssJSToolbox::import('framework:developer:interface:block:shortcode:segments:segments.php');
71 $this->segments = new CJT_Framework_Developer_Interface_Block_Shortcode_Segments($this->cleanContent());
72 // Generate Shortcode block container id.
73 $this->bcid = md5(microtime());
74 // Build block container element id.
75 $this->containerElementId = "csmi-{$this->bcid}";
76 }
77
78 /**
79 * put your comment there...
80 *
81 */
82 public function bcid() {
83 return $this->bcid;
84 }
85
86 /**
87 * put your comment there...
88 *
89 */
90 public function block() {
91 return $this->block;
92 }
93
94 /**
95 * put your comment there...
96 *
97 */
98 public function & cleanContent() {
99 // Shortcode content.
100 $content = $this->content();
101 // Strip <BR /> tags added by Wordpress.
102 $content = str_replace("<br />\n", "\n", $content);
103 // Remove first and last.
104 $content = preg_replace(array('/^\xA/', '/\xA$/'), '', $content);;
105 return $content;
106 }
107
108 /**
109 * put your comment there...
110 *
111 */
112 public function containerElementId() {
113 return $this->containerElementId;
114 }
115
116 /**
117 * put your comment there...
118 *
119 * @param mixed $new
120 */
121 public function content($value = null) {
122 // Return content until its a __setter_.
123 $result = $this->content;
124 // Set value if apssed.
125 if ($value !== null) {
126 $this->content = $value;
127 $result = $this;
128 }
129 return $result;
130 }
131
132 /**
133 * put your comment there...
134 *
135 */
136 public function fw() {
137 static $fw = null;
138 // Instantiate framework only when used.
139 if (!$fw) {
140 cssJSToolbox::import('framework:developer:developer.php');
141 $fw = new CJT_Framework_Developer($this->block);
142 }
143 return $fw;
144 }
145
146 /**
147 * put your comment there...
148 *
149 */
150 public function params() {
151 return $this->parameters;
152 }
153
154 /**
155 * put your comment there...
156 *
157 */
158 public function segments() {
159 return $this->segments;
160 }
161
162 /**
163 * put your comment there...
164 *
165 * @param mixed $done
166 */
167 public function write($done = null) {
168 if ($done) {
169 $this->content(ob_get_clean());
170 }
171 else {
172 ob_start();
173 }
174 return $this;
175 }
176
177 } // End class.