protected function init() { parent::init(); // FIXME (CSH) Re-implement fallback / root panel submission / find a better solution ... // $this->form('POST', null, Io_Mimetype::APPLICATION_FORM_URLENCODED(), 'ISO-8859-15'); $this->form(); // $this->ajaxEnabled=false; $this->add(new Ui_Panel_Label('labela', null, 'Google.com.hk 使用下列语言: 中文(繁體) English')); $this->add(new Ui_Panel_Label('labelb', null, I18n_Script::Hans()->transformToLatn('Google.com.hk 使用下列语言: 中文(繁體) English'))); $this->add(new Ui_Panel_Label('labelc', null, I18n_Script::Hans()->transformToAscii('Google.com.hk 使用下列语言: 中文(繁體) English'))); $this->add(new Ui_Panel_Label('labeld', null, String::toLowercaseUrlIdentifier(I18n_Script::Hans()->transformToAscii('Google.com.hk 使用下列语言: 中文(繁體) English')))); $this->add(new Ui_Panel_Tabs('tabs')); $this->tabs->add(new Ui_Panel_Disclosure('disclosure', null, 'Disclosure')); $this->tabs->disclosure->add(new Ui_Panel_Datetime('date')); $this->tabs->add(new Ui_Panel_Editor_Text('text', null, 'Text')); $this->tabs->add(new Ui_Panel_Image('image', Io_Image::valueOf(__DIR__ . '/test.jpg'), 'Image')); $this->tabs->image->attribute('width', 64); $this->tabs->image->embedded = true; $this->tabs->add(new Ui_Panel_Upload_File('file', null, 'File')); $this->tabs->add(new Ui_Panel_Select('list', null, 'List', ['A', 'B', 'C'])); $this->tabs->add(new Ui_Panel_Editor_Html('html', null, 'HTML')); $button = new Ui_Panel_Button_Submit('submit', null, 'Submit'); $button->callback = [$this, 'onSubmit']; $this->add($button); }
public function render($panel_ = null) { /* @var $value \Components\Io_Image */ if (($value = $this->value()) && $value->exists()) { $image = $value; $height = (int) $this->attribute('height'); $width = (int) $this->attribute('width'); if ($width || $height) { $dimensions = $value->getDimensions(); if (!$width) { $width = round($dimensions->x / ($dimensions->y / $height)); } else { if (!$height) { $height = round($dimensions->y / ($dimensions->x / $width)); } } if ($this->embedded) { $image = Io_Image::valueOf(Environment::pathResource('ui', 'image', 'tmp', $width, $height, $value->getName())); if (false === $image->exists()) { $value->scale(Point::of($width, $height)); $value->saveAs($image); } } } $this->attribute('width', $width); $this->attribute('height', $height); if ($this->embedded) { $this->attribute('src', sprintf('data:%s;base64,%s', $image->getMimetype(), $image->getBase64())); } else { $this->attribute('src', (string) Media_Scriptlet_Engine::imageUri('thumbnail', $image->getPath(), $width, $height)); } } else { if (null !== $value && Debug::active()) { Log::debug('components/ui/panel/image', 'Image for given location does not exist [%s].', $value); } } return parent::render(); }