Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
design_area_constant_button.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/designs/design_area/design_area.inc';
19 
32 {
33 
34 
41  function __construct($assetid=0)
42  {
43  parent::__construct($assetid);
44 
45  }//end constructor
46 
47 
56  protected function _printInitCode()
57  {
58  $assetid = (int) $this->attr('assetid');
59  $url = $this->attr('url');
60 
61  // return true because it just means that they haven't set anything yet
62  if (empty($assetid) && empty($url)) {
63  return TRUE;
64  }
65 
66  // if there is an assetid then do some prep work before printing the area
67  if (!empty($assetid)) {
68  echo '<', '?php
69  $constant_btn_'.$this->attr('id_name').'_url = $am->getAssetURL('.$assetid.').((SQ_LIMBO_EDITING) ? \'/\'.SQ_CONF_LIMBO_SUFFIX.\'?SQ_BACKEND_PAGE=main\' : \'\');
70  ?', '>';
71  }// end if
72 
73  }//end _printInitCode()
74 
75 
82  protected function _canInit()
83  {
84  return ($this->attr('url')) || ($this->attr('assetid'));
85 
86  }//end _canInit()
87 
88 
100  public function printVar($var, Array $args, $value_prefix='', $value_suffix='')
101  {
102  switch ($var) {
103  case 'href' :
104  $assetid = (int) $this->attr('assetid');
105 
106  if (empty($assetid)) {
107  $url_code = $this->attr('url');
108  } else {
109  $url_code = '<'.'?php echo $constant_btn_'.$this->attr('id_name').'_url; ?'.'>';
110  }
111 
112  // if we are poping up in a new window, adjust the vars accordingly
113  if ($this->attr('new_window')) {
114  $width = (int) $this->attr('new_window_width');
115  $height = (int) $this->attr('new_window_height');
116  // some defaults just in case
117  if ($width <= 0) $width = 640;
118  if ($height <= 0) $height = 600;
119  $url_code = 'Javascript: new_window = window.open(\''.$url_code.'\', \'constant_btn_'.$this->attr('id_name').'\', \'toolbar=no,width='.$width.',height='.$height.',titlebar=false,scrollbars=yes\');new_window.focus();';
120  }// end if
121 
122  echo 'href="'.$url_code.'"';
123  break;
124 
125  default :
126  parent::printVar($var, $args);
127 
128  }// end switch
129 
130  }//end printVar()
131 
132 
133 }//end class
134 ?>