Horde_Core_Ui_VarRenderer_Html::_renderVarInput_image PHP Method

_renderVarInput_image() protected method

protected _renderVarInput_image ( $form, &$var, &$vars )
    protected function _renderVarInput_image($form, &$var, &$vars)
    {
        $image = $var->type->getImage($vars, $var);
        $varname = $this->_genID($var->getVarName(), false);
        $GLOBALS['injector']->getInstance('Horde_PageOutput')->addScriptFile('image.js', 'horde');
        $html = '';
        /* Check if there is existing img information stored. */
        if (isset($image['img'])) {
            /* Hidden tag to store the preview image id. */
            $html = sprintf('<input type="hidden" name="%s" id="%s" value="%s" />', htmlspecialchars($var->getVarName()) . '[hash]', $this->_genID($var->getVarName() . '[hash]', false), $var->type->getRandomId());
        }
        /* Output MAX_FILE_SIZE parameter to limit large files. */
        if ($var->type->getProperty('max_filesize')) {
            $html .= sprintf('<input type="hidden" name="MAX_FILE_SIZE" value="%d" />', $var->type->getProperty('max_filesize'));
        }
        /* Output the input tag. */
        $html .= sprintf('<input type="file" size="30" name="%s" id="%s" />', htmlspecialchars($var->getVarName()) . '[new]', $this->_genID($var->getVarName() . '[new]', false));
        /* Output the button to upload/reset the image. */
        if ($var->type->getProperty('show_upload')) {
            $html .= '&nbsp;';
            $html .= sprintf('<input class="button" name="%s" id="%s" type="submit" value="%s" /> ', 'do_' . htmlspecialchars($var->getVarName()), 'do_' . $this->_genID($var->getVarName(), false), Horde_Core_Translation::t("Upload"));
        }
        if (!empty($image['img'])) {
            $html .= '&nbsp;';
            $html .= sprintf('<input class="button" name="%s" id="%S" type="submit" value="%s" /> ', 'remove_' . htmlspecialchars($var->getVarName()), 'remove_' . $this->_genID($var->getVarName(), false), Horde_Core_Translation::t("Remove"));
            /* Image information stored, show preview, add buttons for image
             * manipulation. */
            $html .= '<br />';
            $img = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/images/view.php');
            if (isset($image['img']['vfs_id'])) {
                /* Calling an image from VFS. */
                $img->add(array('f' => $image['img']['vfs_id'], 'p' => $image['img']['vfs_path'], 's' => 'vfs'));
            } else {
                /* Calling an image from a tmp directory (uploads). */
                $img->add('f', $image['img']['file']);
            }
            /* Reset. */
            $html .= Horde::link('#', Horde_Core_Translation::t("Reset"), '', '', 'showImage(\'' . $img . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/refresh.png', Horde_Core_Translation::t("Reset")) . '</a>';
            /* Rotate 270. */
            $html .= Horde::link('#', Horde_Core_Translation::t("Rotate Left"), '', '', 'showImage(\'' . $img->copy()->add(array('a' => 'rotate', 'v' => '270')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-270.png', Horde_Core_Translation::t("Rotate Left")) . '</a>';
            /* Rotate 180. */
            $html .= Horde::link('#', Horde_Core_Translation::t("Rotate 180"), '', '', 'showImage(\'' . $img->copy()->add(array('a' => 'rotate', 'v' => '180')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-180.png', Horde_Core_Translation::t("Rotate 180")) . '</a>';
            /* Rotate 90. */
            $html .= Horde::link('#', Horde_Core_Translation::t("Rotate Right"), '', '', 'showImage(\'' . $img->copy()->add(array('a' => 'rotate', 'v' => '90')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-90.png', Horde_Core_Translation::t("Rotate Right")) . '</a>';
            /* Flip image. */
            $html .= Horde::link('#', Horde_Core_Translation::t("Flip"), '', '', 'showImage(\'' . $img->copy()->add('a', 'flip') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/flip.png', Horde_Core_Translation::t("Flip")) . '</a>';
            /* Mirror image. */
            $html .= Horde::link('#', Horde_Core_Translation::t("Mirror"), '', '', 'showImage(\'' . $img->copy()->add('a', 'mirror') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/mirror.png', Horde_Core_Translation::t("Mirror")) . '</a>';
            /* Apply grayscale. */
            $html .= Horde::link('#', Horde_Core_Translation::t("Grayscale"), '', '', 'showImage(\'' . $img->copy()->add('a', 'grayscale') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/grayscale.png', Horde_Core_Translation::t("Grayscale")) . '</a>';
            /* Resize width. */
            $html .= sprintf('%s<input type="text" size="4" onchange="src=getResizeSrc(\'%s\', \'%s\');showImage(src, \'_p_%s\', true);" %s />', Horde_Core_Translation::t("w:"), $img->copy()->add('a', 'resize'), $varname, $varname, $this->_genID('_w_' . $varname));
            /* Resize height. */
            $html .= sprintf('%s<input type="text" size="4" onchange="src=getResizeSrc(\'%s\', \'%s\');showImage(src, \'_p_%s\', true);" %s />', Horde_Core_Translation::t("h:"), $img->copy()->add('a', 'resize'), $varname, $varname, $this->_genID('_h_' . $varname));
            /* Apply fixed ratio resize. */
            $html .= Horde::link('#', Horde_Core_Translation::t("Fix ratio"), '', '', 'src=getResizeSrc(\'' . $img->copy()->add('a', 'resize') . '\', \'' . $varname . '\', \'1\');showImage(src, \'_p_' . $varname . '\', true);') . Horde::img('ratio.png', Horde_Core_Translation::t("Fix ratio")) . '</a>';
            /* Keep also original if it has been requested. */
            if ($var->type->getProperty('show_keeporig')) {
                $html .= sprintf('<input type="checkbox" class="checkbox" name="%s" id="%s"%s />%s' . "\n", htmlspecialchars($var->getVarName()) . '[keep_orig]', $varname . '[keep_orig]', !empty($image['keep_orig']) ? ' checked="checked"' : '', Horde_Core_Translation::t("Keep original?"));
            }
            /* The preview image element. */
            $html .= '<br /><img src="' . $img . '" ' . $this->_genID('_p_' . $varname) . ">\n";
        }
        return $html;
    }
Horde_Core_Ui_VarRenderer_Html