/** * Process given image path. * * @return string */ public function img($path, $attrs = [], $timestamp = null, $secure = null) { // Here is a little trick: // by default in Laravel's HTML::image we pass 'alt' attribute as second param // and other attributes as third. A little weird, right? Let's fix that! return HTML::image($this->process($path, null, $timestamp), isset($attrs['alt']) ? $attrs['alt'] : null, $attrs, $secure); }
public function script() { $nret = ''; foreach ($this->script as $script) { $nret .= HTML::script($script); } return $nret; }
public function addFormMacro() { app('form')->macro('captcha', function ($options = array()) { $image = \Illuminate\Support\Facades\HTML::image(Captcha::img(), 'Captcha Image'); $label = "<label for=\"captcha\">Enter the Captcha</label> "; $input = "<input type=\"text\" name=\"captcha\" id=\"captcha\" autcomplete=\"off\" required/>"; return $image . $label . $input; }); }
/** * Renders the thumbnail of the model. * * @param string|null $size * @param array $attributes * * @return string */ public function thumbnail($size = null, $attributes = []) { if (!$this->thumb) { $upload = $this->getUploadClass(); $upload = $upload::getPlaceholder($this->getClassBasename()); return HTML::image($upload); } return $this->thumb->render($size, $attributes); }
/** * @param Currency $currency * * @return string */ public function getTransactionLink(Currency $currency) { if ($this->category == 'move') { return ''; } if ($currency->explorer) { return HTML::link(str_replace('%id', $this->txid, $currency->explorer), Str::limit($this->txid, 20), ['target' => '_blank']) . " <span class='fa fa-new-window'></span>"; } return HTML::link('#', Str::limit($this->txid, 20), ['data-toggle' => 'tooltip', 'title' => $this->txid]); }
/** * @param string $url * @param string $name * @param string $position * @param array $attributes * * @return $this */ public function link($url, $name, $position = "BL", $attributes = array()) { $match_url = trim(parse_url($url, PHP_URL_PATH), '/'); if (Request::path() != $match_url) { $url = Persistence::get($match_url); } $attributes = array_merge(array("class" => "btn btn-default"), $attributes); $this->button_container[$position][] = HTML::link($url, $name, $attributes); $this->links[] = $url; return $this; }
public static function head() { $buffer = "\n"; //css links foreach (self::$css as $item) { $buffer .= HTML::style($item); } //js links foreach (self::$js as $item) { $buffer .= HTML::script($item); } return $buffer; }
public static function styles() { $buffer = "\n"; //css links foreach (self::$css as $item) { $buffer .= HTML::style($item); } //inline styles if (count(self::$styles)) { $buffer .= sprintf("<style type=\"text/css\">\n%s\n</style>", implode("\n", self::$styles)); } return $buffer; }
public function image($email, $alt = null, $attributes = array(), $rating = null) { $dimensions = array(); if (array_key_exists('width', $attributes)) { $dimensions[] = $attributes['width']; } if (array_key_exists('height', $attributes)) { $dimensions[] = $attributes['height']; } $max_dimension = count($dimensions) ? min(512, max($dimensions)) : $this->default_size; $src = $this->src($email, $max_dimension, $rating); if (!array_key_exists('width', $attributes) && !array_key_exists('height', $attributes)) { $attributes['width'] = $this->size; $attributes['height'] = $this->size; } return HTML::image($src, $alt, $attributes); }
public function styles(array $media = array()) { $styles = array(); if (empty($media)) { $styles = $this->config['styles']; } else { foreach ($media as $query) { $styles[$query] = array_get($this->config['styles'], $query); } } $markup = ''; foreach (array_dot($styles) as $key => $href) { list($media) = explode('.', $key); $markup .= HTML::style($href, array('media' => $media)); } return $markup; }
public function draw() { if ($this->collapse) { $this->attributes['class'] .= ' collapsed-box'; } $attributes = HTML::attributes($this->attributes); $html = <<<BOX <div {$attributes}> <div class="box-header"> <h3 class="box-title">{$this->title}</h3> <div class="box-tools pull-right"> <button class="btn {$this->btn} btn-sm" data-widget="collapse"><i class="fa fa-minus"></i></button> <!-- <button class="btn {$this->btn} btn-sm" data-widget="remove"><i class="fa fa-times"></i></button> --> </div> </div> <div class="box-body" style="display: block;"> {$this->content} </div><!-- /.box-body --> </div> BOX; return $html; }
public function setPublish($id) { $post = \Post::findOrFail($id); //Conseguimos el canal puesto como principal if ($post->status == 1) { return Redirect::back()->with('error', 'Ya ha sido publicado con exito anteriormente'); } $channel = Helper::getChannel($post->channel_id); $data = array('name' => $post->title, 'link' => $post->link, 'description' => strip_tags(HTML::decode($post->text)), 'picture' => $post->img); $res = $channel->Publish($data); if (!$res['status']) { $post->status = 5; $post->result_post = $res['error']; $post->save(); return Redirect::back()->with('error', $res['error']); } else { $post->status = 1; $post->result_post = $res['status']; $post->channel_id = $channel->id; $post->save(); return Redirect::back()->with('message', 'Publicado con éxito'); } // die($post->result_status); }
private function register_view_macro() { $watcher = $this; HTML::macro('watcherScript', function ($timeout = 3000, array $additionalFolders = array(), array $otherConfigs = array()) use($watcher) { $otherConfigsString = ''; foreach ($otherConfigs as $key => $value) { if (is_array($value)) { $value = serialize($value); } $otherConfigsString .= ' data-' . $key . '=\'' . $value . '\''; } if ($watcher->watcher_enabled) { return '<script src="/watchpoller.js" id="pollscript" data-additionalfolders=\'' . serialize($additionalFolders) . '\' data-timeout="' . $timeout . '" ' . $otherConfigsString . '></script>'; } }); }
<?php /** Setting up for Namespacing **/ use Illuminate\Support\Facades\HTML; // Inspired by: http://forums.laravel.io/viewtopic.php?id=827 HTML::macro('nav_item', function ($url, $text, $a_attr = array(), $active_class = 'active', $li_attrs = array()) { $href = HTML::link($url, $text, $a_attr); $response = ''; if (Request::is($url) || Request::is($url . '/*')) { if (isset($li_attrs['class'])) { $li_attrs['class'] .= ' ' . $active_class; } else { $li_attrs['class'] = $active_class; } } return '<li ' . HTML::attributes($li_attrs) . '>' . $href . '</li>'; });
/** * Get a HTML link to the given category. * * @param \Tricks\Category $category * @return string */ protected function getCategoryLink(Category $category) { return HTML::linkRoute('tricks.browse.category', $category->name, [$category->slug]); }
/** * 保存编辑数据 * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { // $item = static::queryAll()->find($id); if (null === $item) { KMessager::push('找不到对应的数据', KMessager::ERROR); return Redirect::action(static::$action . '.show.index'); } $form = $this->_form($id, $item); if ($form->validation()) { // validate ok $this->fireCMSControllerEvent('updating', [$form, $item, $id]); $this->_store($form, $item, $id); $link = ''; try { $link .= HTML::link(URL::action(static::$action . '.show.detail', [$item->id]), ' 查看详情 ', ['target' => '_blank']); } catch (InvalidArgumentException $e) { $link .= ''; } $url = \HTMLize::create($item)->url(); if ('javascript:;' != $url && $url) { $link .= HTML::link($url, ' 查看网页 ', ['target' => '_blank']); } try { $url = URL::action(static::$action . '.edit.form', [$item->id]); } catch (InvalidArgumentException $e) { $url = null; } if ($url) { $link .= HTML::link($url, ' 重新编辑 ', ['target' => '_blank']); } KMessager::push('更新记录成功' . $link); return Redirect::action(static::$action . '.show.index'); } else { // 以下方式会导致chrome崩溃掉... //Session::flash( 'flashdata_create_form' , $form ); //return Redirect::action( static::$action . '.create' ); $this->layout->content = View::make('laravel-cms::cms/form')->with('form', $form); } }
/** * render the html code for the given position * @param string $position to render * @return html the rendered html code */ protected function render($position = 'head') { $html = null; if ($position == 'head') { $html[] = '<meta charset="' . $this->charset . '">'; $html[] = '<title>' . e($this->getTitle()) . '</title>'; if ($this->html5Ie) { $html[] = '<!--[if lt IE 9]>' . PHP_EOL . HTML::script('//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js') . '<![endif]-->'; } if (!is_null($this->cssFiles)) { ksort($this->cssFiles, SORT_NUMERIC); foreach ($this->cssFiles as $index => $items) { foreach ($items as $item) { $html[] = HTML::style($item[0]); } } } if (!is_null($this->css)) { $html[] = '<style type="text/css">' . implode($this->css) . '</style>'; } if (!is_null($this->favicon)) { $html[] = $this->getLinkTag('shortcut icon', $this->favicon, 'image/x-icon'); } if (!is_null($this->appleTouchIcon)) { $html[] = $this->getLinkTag('apple-touch-icon', $this->appleTouchIcon); } if (!is_null($this->canonical)) { $html[] = $this->getLinkTag('canonical', $this->canonical); } $meta = $this->getMetaProperties(); if (!is_null($meta)) { $html[] = $meta; } $og_tags = $this->renderOgTags(); if (!is_null($og_tags)) { $html[] = $og_tags; } } if ($position == 'footer') { if (!is_null($this->facebook_sdk)) { $html[] = '<div id="fb-root"></div>'; $this->js($this->getFacebookSdkCode(), 'footer', array('jquery' => false)); } if (!is_null($this->twitter_sdk)) { $this->js($this->getTwitterSdkCode(), 'footer', array('jquery' => false)); } if (!is_null($this->youtube_sdk) or !is_null($this->google_plus_sdk)) { $this->js($this->getGoogleSdkCode(), 'footer', array('jquery' => false)); } } if (!is_null($this->jsFiles[$position])) { ksort($this->jsFiles[$position], SORT_NUMERIC); foreach ($this->jsFiles[$position] as $index => $items) { foreach ($items as $item) { if (!in_array($item[0], $this->jsFilesLoaded)) { $html[] = HTML::script($item[0]); $this->jsFilesLoaded[] = $item[0]; } } } } if (!is_null($this->js[$position])) { ksort($this->js[$position]); foreach ($this->js[$position] as $index => $items) { foreach ($items as $item) { if (isset($item[1]['jquery']) and $item[1]['jquery'] === true) { $jquery_code[] = $item[0]; } else { $js_code[] = $item[0]; } } } if (isset($jquery_code)) { $js_code[] = 'jQuery(document).ready(function($){ ' . implode($jquery_code) . ' });'; } $html[] = '<script>' . implode($js_code) . '</script>'; } return !is_null($html) ? implode($html) : null; }
/** * 表格换行 * @param array $attributes * @return $this */ public function tr($attributes = []) { $tr = new \stdClass(); $tr->attributes = HTML::attributes($attributes); $tr->children = $this->tr; $this->tbody[] = $tr; $this->tr = []; return $this; }
/** * Renders the image at a certain size. * * @param string|null $size * @param array $attributes * * @return string */ public function render($size = null, $attributes = []) { $url = $this->file->url($size); $path = $this->file->path(); if (!file_exists($path)) { $type = $this->hasIllustrable() ? $this->illustrable->getClassBasename() : null; $url = static::getPlaceholder($type); } return HTML::image($url, null, $attributes); }
public function linkRoute($name, $title = null, $parameters = array(), $attributes = array()) { $tag = HTML::linkRoute($name, self::REPLACEMENT, $parameters, $attributes); return $this->replace($title, $tag); }
<?php use Illuminate\Support\Facades\HTML; HTML::macro('meta', function ($attr = [], $content = null) { /** * [$HtmlBuilder description] * @var Illuminate */ $HtmlBuilder = new Illuminate\Html\HtmlBuilder(); if (!is_array($attr) && !is_null($content)) { return '<meta name="' . $attr . '" content="' . $content . '" />' . PHP_EOL; } else { return '<meta' . $HtmlBuilder->attributes($attr) . ' />' . PHP_EOL; } }); HTML::macro('fbog', function ($property, $content) { /** * Facebook Open Graph Meta Tags */ return '<meta property="og:' . $property . '" content="' . $content . '" />' . PHP_EOL; }); HTML::macro('meta_twitter', function ($name, $content) { /** * Twitter Meta Tags */ return '<meta name="twitter:' . $property . '" content="' . $content . '" />' . PHP_EOL; });
/** * @return mixed */ public function formgroup() { $hidden = $this->isHide() ? 'display:none;' : ''; $hasError = $this->hasError() ? 'has-error' : ''; $options = $this->form_group; $options['class'] .= ' ' . $hasError; $options['class'] .= $this->colClass(); $options['style'] .= $hidden; return HTML::attributes($options); }
/** * Get the links to all of the registered JavaScript assets. * * @param array $attributes * @param bool $freeze * @return string */ public function scripts($attributes = array(), $freeze = false) { $this->assetCapture = Config::get('theme::assetCapture'); if ($script = $this->group('script')) { // This line fixing config path. $script = $this->configAssetUrl($script); return HTML::script($script, $attributes); } }
/** * Get HTML attribute data. * * @return mixed */ public function getAttributes() { return HTML::attributes($this->attributes); }
<?php use Illuminate\Support\Facades\HTML; HTML::macro('moment', function ($timestamp = null, $duration = null, $durationFormat = 'seconds', $fromNow = false) { if (!is_null($timestamp) && is_null($duration) && !$fromNow) { return sprintf('{{ moment(\'%s\').format(\'lll\') }}', $timestamp); } elseif (!is_null($timestamp) && is_null($duration) && $fromNow) { return sprintf('{{ moment(\'%s\').fromNow() }}', $timestamp); } elseif (is_null($timestamp) && !is_null($duration) && !$fromNow) { return sprintf('{{ momentDuration(%u, \'%s\') }}', (int) $duration, $durationFormat); } }); HTML::macro('faicon', function ($icon, $openSpan = false) { if ($openSpan) { return sprintf('<i class="fa %s"></i><span>', $icon); } return sprintf('<i class="fa %s"></i>', $icon); }); HTML::macro('ionicon', function ($icon, $openSpan = false) { if ($openSpan) { return sprintf('<i class="ion %s"></i><span>', $icon); } return sprintf('<i class="ion %s"></i>', $icon); });
/** * Add an image asset to the container. * * @param string $source * @param string $alt * @param array $attributes * * @return string */ public function image($source, $alt = null, $attributes = array()) { $url = $source; if (false === strstr($source, '://') && '//' !== substr($source, 0, 2)) { $url = $this->cdn($source); } return HTML::image($url, $alt, $attributes); }
/** * PUblish a single asset * * @param array $asset The asset data * @param string $type The asset type * @return string The link to the asset resource */ protected function publishAsset($asset, $type) { $output = ''; // prepare target directory if (!file_exists(dirname($asset['full']))) { File::makeDirectory(dirname($asset['full']), 0777, true); } // create the asset file File::put($asset['full'], $asset['contents']); // add the element $link = $asset['link'] . '?' . str_random(10); if ($type === 'styles') { $output .= HTML::style($link); } elseif ($type === 'scripts') { $output .= HTML::script($link); } return $output; }
/** * Get the link to an action. * * @param string $action * @param string|null $title * @param array $attributes * * @return string */ public function getLink($action, $title = null, array $attributes = []) { $title = $title ?: $this->name; return HTML::linkAction($this->getAction($action), $title, $this->getIdentifier(), $attributes); }