Esempio n. 1
0
File: Html.php Progetto: hjr3/titon
 /**
  * Create an HTML anchor link.
  *
  * @access public
  * @param string $title
  * @param string|array $url
  * @param array $attributes
  * @return string
  */
 public function anchor($title, $url, array $attributes = array())
 {
     if ($route = Router::detect($url)) {
         $url = Router::construct($route);
     }
     $attributes['href'] = $url;
     if (!isset($attributes['title'])) {
         $attributes['title'] = htmlentities($title, ENT_COMPAT, App::charset());
     }
     return $this->tag('anchor', $this->attributes($attributes), $title);
 }
Esempio n. 2
0
File: Form.php Progetto: hjr3/titon
 /**
  * Open a form by outputting the form open tag.
  *
  * @access public
  * @param string $model
  * @param array $attributes
  * @return string
  */
 public function open($model, array $attributes = array())
 {
     if (!empty($model) && is_string($model)) {
         $model = Inflector::modelize($model);
         $this->_model = $model;
     }
     // Form type
     if (isset($attributes['type'])) {
         if ($attributes['type'] == 'file') {
             $attributes['enctype'] = 'multipart/form-data';
         }
         unset($attributes['type']);
     }
     // Fieldset legend
     $legend = null;
     if (isset($attributes['legend'])) {
         $legend = $attributes['legend'];
         unset($attributes['legend']);
     }
     // Attributes
     $attributes = array_merge(array('method' => 'post', 'action' => '', 'id' => $this->_model . 'Form'), $attributes);
     if (!empty($attributes['action'])) {
         $attributes['action'] = Router::construct(Router::detect($attributes['action']));
     }
     $output = $this->tag('form_open', $this->attributes($attributes));
     // If legend, add fieldset
     if (isset($legend)) {
         $attributes['legend'] = $legend;
         $output .= $this->tag('fieldset_open');
         $output .= $this->tag('legend', $legend);
     }
     // Save its state
     $this->_forms[$this->_model] = $attributes;
     return $output;
 }