<?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 FTT7d; z0HqE: WidgetManager::uses(static::class); goto ukIkF; FTT7d: parent::__construct(); goto ZolwK; ZolwK: $this->id = IdUtil::generate('Widget'); goto z0HqE; ukIkF: } protected function formatAttributes() { goto A9Zl4; FIBed: foreach ((array) $this->getAttributes() as $jPfeB => $Gttsd) { $D5Q3D = $this->formatAttribute($jPfeB, $Gttsd); if (!is_null($D5Q3D)) { $A1nut[] = $D5Q3D; } } goto bPuHm; A9Zl4: $A1nut = array(); goto FIBed; bPuHm: return count($A1nut) > 0 ? ' ' . implode(' ', $A1nut) : ''; goto y6cZ0; y6cZ0: } private function formatAttribute($jPfeB, $Gttsd) { if (is_numeric($jPfeB)) { $jPfeB = $Gttsd; } if (!is_null($Gttsd)) { return $jPfeB . '="' . htmlentities($Gttsd, ENT_QUOTES, 'UTF-8') . '"'; } } protected function variables() { return array(); } protected function toString($Gttsd) { return ConvertUtil::render($Gttsd); } public function render() { $CnWtd = array_merge(array('id' => $this->id, 'attributes' => $this->formatAttributes()), $this->variables()); return view($this->view, $CnWtd)->render(); } public function __toString() { try { return $this->render(); } catch (\Exception $WVwSN) { return $WVwSN->getMessage(); } } }