| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class HC3_Ui_Element_Ahref extends HC3_Ui_Abstract_Element |
| 3 |
{ |
| 4 |
protected $uiType = 'ahref'; |
| 5 |
protected $to = NULL; |
| 6 |
protected $actionMode = FALSE; |
| 7 |
|
| 8 |
public function __construct( $to, $label = NULL ) |
| 9 |
{ |
| 10 |
$this->to = $to; |
| 11 |
if( $label === NULL ){ |
| 12 |
$label = $to; |
| 13 |
} |
| 14 |
parent::__construct( 'a', $label ); |
| 15 |
|
| 16 |
// $title = strip_tags( $label ); |
| 17 |
// $title = substr_count( $label, "\n" ); |
| 18 |
|
| 19 |
// $title = str_replace( $tags, "\n", $label ); |
| 20 |
// $title = strip_tags( $title ); |
| 21 |
// $title = preg_replace( "/(\n){2,}/", "\n", $title ); |
| 22 |
|
| 23 |
$title = $label; |
| 24 |
|
| 25 |
$tags = array('</div>', '</p>','<br />', '<br>' ); |
| 26 |
$title = str_replace( $tags, ' ', $title ); |
| 27 |
|
| 28 |
$tags = array('>', '<' ); |
| 29 |
$title = str_replace( $tags, '', $title ); |
| 30 |
|
| 31 |
$title = strip_tags( $title ); |
| 32 |
$title = preg_replace( "/(\s){2,}/", " ", $title ); |
| 33 |
|
| 34 |
$this |
| 35 |
->addAttr( 'title', $title ) |
| 36 |
; |
| 37 |
} |
| 38 |
|
| 39 |
public function actionMode( $set = TRUE ) |
| 40 |
{ |
| 41 |
$this->actionMode = $set; |
| 42 |
return $this; |
| 43 |
} |
| 44 |
|
| 45 |
public function isActionMode() |
| 46 |
{ |
| 47 |
return $this->actionMode; |
| 48 |
} |
| 49 |
|
| 50 |
public function getTo() |
| 51 |
{ |
| 52 |
return $this->to; |
| 53 |
} |
| 54 |
|
| 55 |
public function newWindow( $set = TRUE ) |
| 56 |
{ |
| 57 |
$this->addAttr('target', '_blank'); |
| 58 |
return $this; |
| 59 |
} |
| 60 |
} |