BcFreezeHelper::image PHP Метод

image() публичный Метод

ファイルコントロール(画像)を表示する TODO 確認画面には未チェック
public image ( string $fieldName, array $attributes = [], array $imageAttributes = [] ) : string
$fieldName string フィールド文字列
$attributes array html属性
$imageAttributes array 画像属性
Результат string htmlタグ
    public function image($fieldName, $attributes = array(), $imageAttributes = array())
    {
        if (!$attributes) {
            $attributes = array();
        }
        $output = "";
        $imageAttributes = array_merge(array('ext' => 'jpg', 'alt' => '', 'dir' => '', 'id' => ''), $imageAttributes);
        if (!empty($imageAttributes['subdir'])) {
            $imageAttributes['subdir'] .= DS;
        }
        list($model, $field) = explode('.', $fieldName);
        if ($this->freezed) {
            $attributes = array_merge($attributes, array('type' => 'hidden'));
            // 確認画面
            if (!empty($this->request->data[$model][$field]['name'])) {
                $path = "tmp" . DS . Inflector::underscore($model) . DS . "img" . DS . $field . $imageAttributes['ext'] . "?" . rand();
                unset($imageAttributes['ext']);
                $output = parent::text($fieldName . "_exists", $attributes);
                $output .= sprintf($this->Html->_tags['image'], $path, $this->Html->_parseAttributes($imageAttributes));
                return $output;
                // 通常表示
            } else {
                if (!empty($this->request->data[$model][$field . '_exists'])) {
                    $path = DS . $imageAttributes['dir'] . DS . Inflector::tableize($model) . DS . $imageAttributes['id'] . DS . $field . "." . $imageAttributes['ext'] . "?" . rand();
                    unset($imageAttributes['ext']);
                    return sprintf($this->Html->_tags['image'], $path, $this->Html->_parseAttributes($imageAttributes));
                } else {
                    return " ";
                }
            }
        } else {
            if (!empty($this->request->data[$model][$field . '_exists'])) {
                $path = DS . $imageAttributes['dir'] . DS . Inflector::tableize($model) . DS . $imageAttributes['id'] . DS . $field . "." . $imageAttributes['ext'] . "?" . rand();
                unset($imageAttributes['ext']);
                $output = sprintf($this->Html->_tags['image'], $path, $this->Html->_parseAttributes($imageAttributes));
                $output .= "<br />" . $this->checkbox($fieldName . "_delete", array('label' => '削除する'));
            }
            return parent::file($fieldName, $attributes) . "<br />" . $output;
        }
    }