示例#1
0
文件: Form.php 项目: stativo/helpers
 /**
  * Generates an opening HTML form tag.
  *
  * @param   string  $action form action
  * @param   string  $method Method GET|POST|PUT|DELETE
  * @param   array   $attributes html attributes
  * @return  string
  */
 public static function open($action = NULL, $method = 'POST', array $attributes = NULL)
 {
     if ($action === NULL) {
         // Use the current URI
         $action = '/' . Request::instance()->uri();
     }
     if ($action === '') {
         // Use only the base URI
         $action = URL::base();
     } elseif (strpos($action, '://') === FALSE) {
         // Make the URI absolute
         $action = URL::site($action);
     }
     // Add the form action to the attributes
     $attributes['action'] = $action;
     // Form method is always POST
     $attributes['method'] = 'post';
     return '<form' . HTML::attributes($attributes) . '>' . PHP_EOL . static::hidden('__method', $method);
 }
示例#2
0
文件: Request.php 项目: stativo/core
 /**
  * Holds subdomain if used. Will select first item in the url exploded on the dot (.)
  * @return string Get current subdomain, or FALSE if not isset
  */
 public function subdomain()
 {
     $urlSegments = parse_url(URL::base());
     $urlHostSegments = explode('.', $urlSegments['host']);
     return (count($urlHostSegments) > 2 and $urlHostSegments[0] !== 'www') ? $urlHostSegments[0] : false;
 }
示例#3
0
文件: HTML.php 项目: stativo/helpers
 /**
  * Creates a image link.
  *
  * @param   string   file name
  * @param   array    default attributes
  * @return  string
  */
 public static function image($file, array $attributes = NULL)
 {
     if (strpos($file, '://') === FALSE) {
         // Add the base URL
         $file = URL::base(FALSE) . $file;
     }
     // Add the image link
     $attributes['src'] = $file;
     return '<img' . HTML::attributes($attributes) . ' />';
 }