| 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_Segments_Segments |
| 13 |
extends CJT_Framework_Developer_Interface_Block_Parameters_Parameters { |
| 14 |
|
| 15 |
/** |
| 16 |
* put your comment there... |
| 17 |
* |
| 18 |
* @var mixed |
| 19 |
*/ |
| 20 |
protected $content = null; |
| 21 |
|
| 22 |
/** |
| 23 |
* put your comment there... |
| 24 |
* |
| 25 |
* @param mixed $content |
| 26 |
* @return CJT_Framework_Developer_Interface_Block_Shortcode_Segments |
| 27 |
*/ |
| 28 |
public function __construct(& $content) { |
| 29 |
// Initialize. |
| 30 |
$this->content =& $content; |
| 31 |
// Initialize parent. |
| 32 |
parent::__construct(array()); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* put your comment there... |
| 37 |
* |
| 38 |
*/ |
| 39 |
public function validate() { |
| 40 |
// Read segments from Shortcode content. |
| 41 |
$segments = preg_split('/(\w+)\=\:\s+/', $this->content, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 42 |
// All even indexes if for segment names and |
| 43 |
// odd index for values. |
| 44 |
for ($index = 0; $index < count($segments); $index+=2) { |
| 45 |
// Get key from current item and value from the next. |
| 46 |
$this->uParams[$segments[$index]] = $segments[$index + 1]; |
| 47 |
} |
| 48 |
// Parent vaidation. |
| 49 |
return parent::validate(); |
| 50 |
} |
| 51 |
|
| 52 |
} // End class. |