<?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 XnaiR; XnaiR: parent::__construct(); goto WpyX_; WpyX_: $this->id = IdUtil::generate('Widget'); goto ciOo2; ciOo2: WidgetManager::uses(static::class); goto rf6vU; rf6vU: } protected function formatAttributes() { goto SNGxC; IRsrH: return count($eAyzj) > 0 ? ' ' . implode(' ', $eAyzj) : ''; goto JvaOQ; emVpX: foreach ((array) $this->getAttributes() as $oMJcb => $cBDsM) { $CuKRJ = $this->formatAttribute($oMJcb, $cBDsM); if (!is_null($CuKRJ)) { $eAyzj[] = $CuKRJ; } } goto IRsrH; SNGxC: $eAyzj = array(); goto emVpX; JvaOQ: } private function formatAttribute($oMJcb, $cBDsM) { if (is_numeric($oMJcb)) { $oMJcb = $cBDsM; } if (!is_null($cBDsM)) { return $oMJcb . '="' . htmlentities($cBDsM, ENT_QUOTES, 'UTF-8') . '"'; } } protected function variables() { return array(); } protected function toString($cBDsM) { return ConvertUtil::render($cBDsM); } public function render() { $dTnlu = array_merge(array('id' => $this->id, 'attributes' => $this->formatAttributes()), $this->variables()); return view($this->view, $dTnlu)->render(); } public function __toString() { try { return $this->render(); } catch (\Exception $Sgh1N) { return $Sgh1N->getMessage(); } } }