<?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; use ModStart\Support\Manager\WidgetManager; class AbstractWidget extends Fluent implements Renderable { protected $view; protected $id; public function __construct() { goto lfzNk; lfzNk: parent::__construct(); goto ul4Jn; ul4Jn: $this->id = IdUtil::generate('Widget'); goto nqttV; nqttV: WidgetManager::uses(static::class); goto kxksE; kxksE: } protected function formatAttributes() { goto kB0YU; bqi3S: return count($f6TlW) > 0 ? ' ' . implode(' ', $f6TlW) : ''; goto j1b6K; WBUvJ: foreach ((array) $this->getAttributes() as $HQKqq => $mdHu1) { $NK5jE = $this->formatAttribute($HQKqq, $mdHu1); if (!is_null($NK5jE)) { $f6TlW[] = $NK5jE; } } goto bqi3S; kB0YU: $f6TlW = array(); goto WBUvJ; j1b6K: } private function formatAttribute($HQKqq, $mdHu1) { if (is_numeric($HQKqq)) { $HQKqq = $mdHu1; } if (!is_null($mdHu1)) { return $HQKqq . '="' . htmlentities($mdHu1, ENT_QUOTES, 'UTF-8') . '"'; } } protected function variables() { return array(); } protected function toString($mdHu1) { return ConvertUtil::render($mdHu1); } public function render() { $Sj05q = array_merge(array('id' => $this->id, 'attributes' => $this->formatAttributes()), $this->variables()); return view($this->view, $Sj05q)->render(); } public function __toString() { try { return $this->render(); } catch (\Exception $tZVhb) { return $tZVhb->getMessage(); } } }