<?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 TOVrf; TOVrf: $lSp6_ = array(); goto nhywP; nhywP: foreach ((array) $this->getAttributes() as $ax5t3 => $FT9zA) { $wi2ea = $this->formatAttribute($ax5t3, $FT9zA); if (!is_null($wi2ea)) { $lSp6_[] = $wi2ea; } } goto S1jR9; S1jR9: return count($lSp6_) > 0 ? ' ' . implode(' ', $lSp6_) : ''; goto TVfj6; TVfj6: } private function formatAttribute($ax5t3, $FT9zA) { if (is_numeric($ax5t3)) { $ax5t3 = $FT9zA; } if (!is_null($FT9zA)) { return $ax5t3 . '="' . htmlentities($FT9zA, ENT_QUOTES, 'UTF-8') . '"'; } } protected function variables() { return array(); } protected function toString($FT9zA) { return ConvertUtil::render($FT9zA); } public function render() { $EdQjV = array_merge(array('id' => $this->id, 'attributes' => $this->formatAttributes()), $this->variables()); return view($this->view, $EdQjV)->render(); } public function __toString() { try { return $this->render(); } catch (\Exception $SXS9c) { return $SXS9c->getMessage(); } } }