| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class HC3_Ui_Filter |
| 3 |
{ |
| 4 |
protected $filters = array(); |
| 5 |
|
| 6 |
public $acl, $uri, $uriAction, $htmlFactory; |
| 7 |
|
| 8 |
public function __construct( |
| 9 |
HC3_Dic $dic, |
| 10 |
HC3_Uri $uri, |
| 11 |
HC3_UriAction $uriAction, |
| 12 |
HC3_Acl $acl, |
| 13 |
HC3_Ui $htmlFactory |
| 14 |
) |
| 15 |
{ |
| 16 |
$this->acl = $acl; |
| 17 |
$this->uri = $uri; |
| 18 |
$this->uriAction = $uriAction; |
| 19 |
$this->htmlFactory = $htmlFactory; |
| 20 |
|
| 21 |
$this->filters = array(); |
| 22 |
|
| 23 |
$this->filters[] = new HC3_Ui_Filter_Acl_Ahref( $this->acl ); |
| 24 |
$this->filters[] = new HC3_Ui_Filter_Acl_Form( $this->acl ); |
| 25 |
$this->filters[] = new HC3_Ui_Filter_Acl_Submit( $this->acl ); |
| 26 |
|
| 27 |
$this->filters[] = new HC3_Ui_Filter_Buttons( $this->htmlFactory ); |
| 28 |
|
| 29 |
$this->filters[] = $dic->make('HC3_Ui_Filter_Print_Ahref'); |
| 30 |
$this->filters[] = $dic->make('HC3_Ui_Filter_Print_Form'); |
| 31 |
$this->filters[] = $dic->make('HC3_Ui_Filter_Print_Collapse'); |
| 32 |
|
| 33 |
$this->filters[] = new HC3_Ui_Filter_Uri_Ahref( $this->uri ); |
| 34 |
$this->filters[] = new HC3_Ui_Filter_Uri_Form( $this->uriAction ); |
| 35 |
$this->filters[] = new HC3_Ui_Filter_Uri_Ajax( $this->uriAction ); |
| 36 |
$this->filters[] = new HC3_Ui_Filter_Uri_Submit( $this->uriAction ); |
| 37 |
|
| 38 |
$this->filters[] = new HC3_Ui_Filter_Input_Fill(); |
| 39 |
$this->filters[] = new HC3_Ui_Filter_Input_Error( $this->htmlFactory ); |
| 40 |
$this->filters[] = new HC3_Ui_Filter_SubHeader( $this->htmlFactory ); |
| 41 |
$this->filters[] = new HC3_Ui_Filter_PageHeader( $this->htmlFactory ); |
| 42 |
$this->filters[] = new HC3_Ui_Filter_Breadcrumb( $this->htmlFactory ); |
| 43 |
$this->filters[] = new HC3_Ui_Filter_Border( $this->htmlFactory ); |
| 44 |
$this->filters[] = new HC3_Ui_Filter_BorderColor( $this->htmlFactory ); |
| 45 |
|
| 46 |
$this->filters[] = new HC3_Ui_Filter_Padding( $this->htmlFactory ); |
| 47 |
$this->filters[] = new HC3_Ui_Filter_Margin( $this->htmlFactory ); |
| 48 |
|
| 49 |
$this->filters[] = new HC3_Ui_Filter_Color( $this->htmlFactory ); |
| 50 |
$this->filters[] = new HC3_Ui_Filter_BgColor( $this->htmlFactory ); |
| 51 |
|
| 52 |
$this->filters[] = new HC3_Ui_Filter_Block( $this->htmlFactory ); |
| 53 |
$this->filters[] = new HC3_Ui_Filter_Align( $this->htmlFactory ); |
| 54 |
$this->filters[] = new HC3_Ui_Filter_Valign( $this->htmlFactory ); |
| 55 |
$this->filters[] = new HC3_Ui_Filter_Nowrap( $this->htmlFactory ); |
| 56 |
$this->filters[] = new HC3_Ui_Filter_Hide( $this->htmlFactory ); |
| 57 |
$this->filters[] = new HC3_Ui_Filter_Muted( $this->htmlFactory ); |
| 58 |
|
| 59 |
$this->filters[] = new HC3_Ui_Filter_Font_Size( $this->htmlFactory ); |
| 60 |
$this->filters[] = new HC3_Ui_Filter_Font_Style( $this->htmlFactory ); |
| 61 |
|
| 62 |
$this->filters[] = new HC3_Ui_Filter_AutoDismiss( $this->htmlFactory ); |
| 63 |
} |
| 64 |
|
| 65 |
public function filter( $element ) |
| 66 |
{ |
| 67 |
if( ! is_object($element) ){ |
| 68 |
return $element; |
| 69 |
} |
| 70 |
|
| 71 |
if( method_exists($element, 'getChildren') ){ |
| 72 |
$children = $element->getChildren(); |
| 73 |
$keys = array_keys($children); |
| 74 |
foreach( $keys as $key ){ |
| 75 |
$child = $children[$key]; |
| 76 |
$child = $this->filter( $child ); |
| 77 |
$element->setChild( $key, $child ); |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
// keep tags |
| 82 |
$tags = $element->getTags(); |
| 83 |
|
| 84 |
reset( $this->filters ); |
| 85 |
foreach( $this->filters as $filter ){ |
| 86 |
if( ! is_object($element) ){ |
| 87 |
continue; |
| 88 |
} |
| 89 |
$element = $filter->process($element); |
| 90 |
if( $element === NULL ){ |
| 91 |
break; |
| 92 |
} |
| 93 |
|
| 94 |
// restore tags |
| 95 |
// foreach( $tags as $tag => $param ){ |
| 96 |
// if( is_object($element) ){ |
| 97 |
// $element->tag( $tag, $param ); |
| 98 |
// } |
| 99 |
// } |
| 100 |
} |
| 101 |
|
| 102 |
return $element; |
| 103 |
} |
| 104 |
} |
| 105 |
|