Ejemplo n.º 1
0
Archivo: Form.php Proyecto: hjr3/titon
 /**
  * Check to see if a value exists in the POST/GET data, if so escape and return.
  *
  * @access public
  * @param string $model
  * @param string $field
  * @return string
  */
 public function value($model, $field)
 {
     $data =& App::$data;
     $value = Set::extract($data, $model . '.' . $field);
     if (!empty($value)) {
         return is_array($value) ? $value : htmlentities($value, ENT_COMPAT, App::charset());
     } else {
         $data = Set::insert($data, $model . '.' . $field, null);
         return null;
     }
 }
Ejemplo n.º 2
0
Archivo: Html.php Proyecto: hjr3/titon
 /**
  * Create a meta element. Has predefined values for common meta tags.
  *
  * @access public
  * @param string $type
  * @param string $content
  * @param array $attributes
  * @return string
  */
 public function meta($type, $content = null, array $attributes = array())
 {
     if (empty($content)) {
         switch (strtolower($type)) {
             case 'content-script-type':
                 $content = 'text/javascript';
                 break;
             case 'content-style-type':
                 $content = 'text/css';
                 break;
             case 'content-type':
                 $content = $this->isDoctype('xhtml') ? 'application/xhtml\\+xml' : 'text/html';
                 $content .= '; charset=' . App::charset();
                 break;
         }
     }
     $metaTypes = array('content-type' => array('http-equiv' => 'Content-Type', 'content' => $content), 'content-script-type' => array('http-equiv' => 'Content-Script-Type', 'content' => $content), 'content-style-type' => array('http-equiv' => 'Content-Style-Type', 'content' => $content), 'content-language' => array('http-equiv' => 'Content-Language', 'content' => $content), 'keywords' => array('name' => 'keywords', 'content' => $content), 'description' => array('name' => 'description', 'content' => $content), 'author' => array('name' => 'author', 'content' => $content), 'robots' => array('name' => 'robots', 'content' => $content), 'rss' => array('type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => $type, 'link' => $content), 'atom' => array('type' => 'application/atom+xml', 'title' => $type, 'link' => $content), 'icon' => array('type' => 'image/x-icon', 'rel' => 'icon', 'link' => $content));
     if (isset($metaTypes[strtolower($type)])) {
         $attributes = $attributes + $metaTypes[strtolower($type)];
     } else {
         $attributes['name'] = $type;
         $attributes['content'] = $content;
     }
     return $this->tag('meta', $this->attributes($attributes));
 }
Ejemplo n.º 3
0
 /**
  * Parses an array of attributes to the HTML equivalent.
  *
  * @access public
  * @param array $attributes
  * @param array $remove
  * @return string
  */
 public function attributes(array $attributes, array $remove = array())
 {
     $parsed = null;
     $escape = true;
     if (isset($attributes['escape']) && is_bool($attributes['escape'])) {
         $escape = $attributes['escape'];
     }
     unset($attributes['escape']);
     if (!empty($attributes)) {
         foreach ($attributes as $key => $value) {
             if (in_array($key, $remove)) {
                 unset($attributes[$key]);
                 continue;
             }
             if ($escape === true) {
                 $value = htmlentities($value, ENT_COMPAT, App::charset());
             }
             $parsed .= ' ' . strtolower($key) . '="' . $value . '"';
         }
     }
     return $parsed;
 }