示例#1
0
文件: HTML.php 项目: Grapheme/amway
 /**
  * Generate a link to a JavaScript file.
  *
  * @param  string  $url
  * @param  array   $attributes
  * @param  bool    $secure
  * @return string
  */
 public static function scriptmod($url, $attributes = array(), $secure = null)
 {
     $HtmlBuilder = new HtmlBuilder();
     $filemtime = @filemtime(@dirname(@$_SERVER['SCRIPT_FILENAME']) . "/" . $url);
     $attributes['src'] = asset($url, $secure) . ($filemtime > 0 ? "?" . $filemtime : "");
     return '<script' . $HtmlBuilder->attributes($attributes) . '></script>' . PHP_EOL;
 }
示例#2
0
 public function renderAttributes(array $options)
 {
     if (!empty($options)) {
         return $options = $this->html->attributes($options);
     } else {
         return '';
     }
 }
示例#3
0
 /**
  * Generate a HTML link to a controller action.
  *
  * @param  string  $action
  * @param  string  $title
  * @param  array   $parameters
  * @param  array   $attributes
  * @return string
  */
 public function linkAction($action, $title = null, $parameters = array(), $attributes = array())
 {
     if (!$this->manager->hasActionAccess('GET', $action)) {
         return;
     }
     return parent::linkAction($action, $title, $parameters, $attributes);
 }
示例#4
0
 /**
  * Create a button element.
  *
  * @param  string  $value
  * @param  array   $options
  * @return string
  */
 public function button($value = null, $options = array())
 {
     if (!array_key_exists('type', $options)) {
         $options['type'] = 'button';
     }
     return '<button' . $this->html->attributes($options) . '>' . $value . '</button>';
 }
示例#5
0
 /**
  * @param string $key
  * @param string $value
  * @return string
  */
 protected function attributeElement($key, $value)
 {
     if (is_array($value)) {
         $value = implode(' ', $value);
     }
     return parent::attributeElement($key, $value);
 }
示例#6
0
 /**
  * Create an alert item with optional emphasis.
  *
  * @param string  $type
  * @param string  $content
  * @param string  $emphasis
  * @param boolean $dismissible
  * @param array   $attributes
  *
  * @return string
  */
 protected function alert($type = 'message', $content = null, $emphasis = null, $dismissible = false, array $attributes = array())
 {
     $attributes = array_merge(array('class' => 'alert' . ($dismissible ? ' alert-dismissable' : '') . ' alert-' . ($type != 'message' ? $type : 'default')), $attributes);
     $return = '<div ' . $this->html->attributes($attributes) . '>';
     if ($dismissible !== null) {
         $return .= '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>';
     }
     $return .= ($emphasis !== null && is_string($emphasis) ? '<strong>' . $emphasis . '</strong> ' : '') . $content . '</div>';
     return $return;
 }
示例#7
0
 public function style($url, $attributes = array(), $secure = null)
 {
     if ($this->url->isValidUrl($url) or !$this->app->environment('sae')) {
         return parent::style($url, $attributes, $secure);
     } else {
         $defaults = array('media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet');
         $attributes = $attributes + $defaults;
         $attributes['href'] = $this->patchUrl($url, $secure, 'style');
         return '<link' . $this->attributes($attributes) . '>' . PHP_EOL;
     }
 }
 public function boot()
 {
     if ($this->app->resolved('router') || $this->app->bound('router')) {
         $router = $this->app['router'];
         $router->get('assets/img/{a?}/{b?}/{c?}/{d?}/{e?}', '\\Assets\\Http\\Controller@img');
         $router->get('assets/font/{a?}/{b?}/{c?}/{d?}/{e?}', '\\Assets\\Http\\Controller@font');
         $router->get('assets/fonts/{a?}/{b?}/{c?}/{d?}/{e?}', '\\Assets\\Http\\Controller@font');
         $router->get('assets/css/{a?}/{b?}/{c?}/{d?}/{e?}', '\\Assets\\Http\\Controller@css');
         $router->get('assets/{type}/{a?}/{b?}/{c?}/{d?}/{e?}', '\\Assets\\Http\\Controller@compile');
     }
     $this->commands('\\Assets\\Console\\PublishCommand', '\\Assets\\Console\\UnpublishCommand');
     if (class_exists('\\Illuminate\\Html\\HtmlBuilder')) {
         \Illuminate\Html\HtmlBuilder::macro('assetPath', function ($path) {
             return Asset::publishedPath($path);
         });
     }
 }
示例#9
0
 /**
  * Prepare data grid columns.
  *
  * @param  bool  $results
  * @return array
  */
 protected function prepareColumns($model)
 {
     $el = [];
     foreach ($this->dataGridColumns as $attributes) {
         $type = array_pull($attributes, 'type');
         if ($type) {
             if ($type === 'a') {
                 $elementContent = '<%= r.' . array_pull($attributes, 'content') . ' %>';
                 $link = $this->html->decode($this->html->link('#', $elementContent, $attributes));
                 $link = str_replace('href="#"', 'href="<%= r.edit_uri %>"', $link);
                 $el[] = $link;
             } elseif ($type === 'checkbox') {
                 $checkBoxName = array_pull($attributes, 'name');
                 $value = array_pull($attributes, 'value');
                 $value = '<%= r.' . $value . ' %>';
                 $el[] = $this->html->decode($this->form->checkbox($checkBoxName, $value, null, $attributes));
             }
         } else {
             $el[] = '<%= r.' . array_pull($attributes, 'content') . ' %>';
         }
     }
     return $el;
 }
 /**
  * @param $url
  * @param array $attributes
  * @param null $secure
  * @param bool $force
  * @return string
  */
 public function scriptBust($url, $attributes = array(), $secure = null, $overrideConfig = true)
 {
     return parent::script($this->tryBuildBustableUrl($url, $overrideConfig), $attributes, $secure);
 }
示例#11
0
 /**
  * Convert HTML attributes into "property = value" pairs.
  *
  * @param array $attributes
  *
  * @return string
  */
 public function attributes($attributes = array())
 {
     return $this->html->attributes($attributes);
 }
示例#12
0
 /**
  * Create a listing HTML element.
  *
  * @param  string  $type
  * @param  array   $list
  * @param  array   $attributes
  * @return \Illuminate\Support\HtmlString
  */
 protected function listing($type, $list, $attributes = array())
 {
     return new HtmlString(parent::listing($type, $list, $attributes));
 }
示例#13
0
 /**
  * Generate a HTTPS HTML link to an asset.
  *
  * @param  string  $url
  * @param  string  $title
  * @param  array   $attributes
  * @param  bool    $enablePrefix
  * @return string
  */
 public function linkSecureAsset($url, $title = null, $attributes = array(), $enablePrefix = true)
 {
     return parent::linkSecureAsset(($enablePrefix ? $this->prefix : null) . $url, $title, $attributes);
 }
示例#14
0
 /**
  * Obfuscate a string to prevent spam-bots from sniffing it.
  *
  * @param string $value
  * @return string 
  * @static 
  */
 public static function obfuscate($value)
 {
     return \Illuminate\Html\HtmlBuilder::obfuscate($value);
 }
示例#15
0
 /**
  * Generate a link to a JavaScript file.
  *
  * @param  string  $name
  * @param  string  $url
  * @param  array   $attributes
  * @return string
  */
 public function script($name, $url, $attributes = array(), $secure = false)
 {
     $attributes['src'] = $this->asset($name, $url, $secure);
     return '<script' . $this->html->attributes($attributes) . '></script>' . PHP_EOL;
 }
示例#16
0
 /**
  * Create a new HTML builder instance.
  *
  * @param  \Illuminate\Routing\UrlGenerator  $url
  * @return void
  */
 public function __construct(UrlGenerator $url = null)
 {
     parent::__construct($url);
 }
示例#17
0
文件: Meta.php 项目: foxted/meta
 /**
  * Generate a self-closing tag
  * @param       $tagName
  * @param       $tagContent
  * @param array $tagAttributes
  * @return array
  */
 private function pairedTag($tagName, $tagContent, $tagAttributes = [])
 {
     return ['type' => MetaFacade::PAIRED_TAG, 'tag' => $tagName, 'content' => $tagContent, 'attributes' => $this->htmlBuilder->attributes($tagAttributes)];
 }
 /**
  * @param Element $row
  * @return string
  */
 public function rowOpen(Element $row)
 {
     $_atts = $this->htmlBuilder->attributes($row->getAttributes());
     return '<div' . $_atts . '><div class="row">';
 }
示例#19
0
 /**
  * Checks if macro is registered
  *
  * @param string $name
  * @return boolean 
  * @static 
  */
 public static function hasMacro($name)
 {
     return \Illuminate\Html\HtmlBuilder::hasMacro($name);
 }
示例#20
0
 /**
  * Some shortcuts
  */
 public function __call($method, $parameters)
 {
     // Resource verbs
     if (String::endsWith($method, 'Resource')) {
         $verb = String::remove($method, 'Resource');
         $parameters = Arrays::prepend($parameters, $verb);
         return call_user_func_array(array($this, 'resource'), $parameters);
     }
     return parent::__call($method, $parameters);
 }