<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Widget; use Illuminate\Contracts\Support\Renderable; use Illuminate\Support\Fluent; use ModStart\Core\Util\ConvertUtil; use ModStart\Core\Util\IdUtil; class AbstractWidget extends Fluent implements Renderable { protected $view; protected $id; public function __construct() { $this->id = IdUtil::generate('Widget'); } protected function formatAttributes() { goto AiVHo; YOdMA: return count($B8MP1) > 0 ? ' ' . implode(' ', $B8MP1) : ''; goto qndi5; i2KLS: foreach ((array) $this->getAttributes() as $m1RYi => $tzAUI) { $vYKL4 = $this->formatAttribute($m1RYi, $tzAUI); if (!is_null($vYKL4)) { $B8MP1[] = $vYKL4; } } goto YOdMA; AiVHo: $B8MP1 = array(); goto i2KLS; qndi5: } private function formatAttribute($m1RYi, $tzAUI) { if (is_numeric($m1RYi)) { $m1RYi = $tzAUI; } if (!is_null($tzAUI)) { return $m1RYi . '="' . htmlentities($tzAUI, ENT_QUOTES, 'UTF-8') . '"'; } } protected function variables() { return array(); } protected function toString($tzAUI) { return ConvertUtil::render($tzAUI); } public function render() { $Y0YxF = array_merge(array('id' => $this->id, 'attributes' => $this->formatAttributes()), $this->variables()); return view($this->view, $Y0YxF)->render(); } public function __toString() { try { return $this->render(); } catch (\Exception $vBRkZ) { return $vBRkZ->getMessage(); } } }