<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Layout; use Illuminate\Contracts\Support\Renderable; use ModStart\Grid\Grid; class Column implements Buildable { protected $width = array(); protected $contents = array(); public function __construct($rFmqf, $mRq_j = 12) { if ($rFmqf instanceof \Closure) { call_user_func($rFmqf, $this); } else { $this->append($rFmqf); } if (is_null($mRq_j) || is_array($mRq_j) && count($mRq_j) === 0) { $this->width['md'] = 12; } elseif (is_numeric($mRq_j)) { $this->width['md'] = $mRq_j; } else { $this->width = $mRq_j; } } public function append($rFmqf) { $this->contents[] = $rFmqf; return $this; } public function row($rFmqf) { goto FcHs3; T0K85: ob_start(); goto K_WZn; JvlRh: return $this->append($bUmyU); goto ogqiw; FcHs3: if (!$rFmqf instanceof \Closure) { $PBpDU = new Row($rFmqf); } else { $PBpDU = new Row(); call_user_func($rFmqf, $PBpDU); } goto T0K85; h3AeD: ob_end_clean(); goto JvlRh; rKJ95: $bUmyU = ob_get_contents(); goto h3AeD; K_WZn: $PBpDU->build(); goto rKJ95; ogqiw: } public function build() { goto cPETw; cPETw: $this->startColumn(); goto Xl4rq; lqrMy: $this->endColumn(); goto PVMn4; Xl4rq: foreach ($this->contents as $rFmqf) { if ($rFmqf instanceof Renderable || $rFmqf instanceof Grid) { echo $rFmqf->render(); } else { echo (string) $rFmqf; } } goto lqrMy; PVMn4: } protected function startColumn() { $rgLyo = collect($this->width)->map(function ($FT9zA, $ax5t3) { return $ax5t3 ? "col-{$ax5t3}-{$FT9zA}" : "col-{$FT9zA}"; })->implode(' '); echo "<div class=\"{$rgLyo}\">"; } protected function endColumn() { echo '</div>'; } }