コード例 #1
0
 /**
  * Method to get the field input markup for the file field.
  * Field attributes allow specification of a maximum file size and a string
  * of accepted file extensions.
  *
  * @return  string  The field input markup.
  *
  * @note    The field does not include an upload mechanism.
  * @see     JFormFieldFile
  */
 protected function getInput()
 {
     // Initialize some field attributes.
     $accept = $this->element['accept'] ? ' accept="' . (string) $this->element['accept'] . '"' : '';
     $size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     $disabled = (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : '';
     $readonly = (string) $this->element['readonly'];
     $value = $this->value;
     $width = $this->element['width'] ? $this->element['width'] : 150;
     $height = $this->element['height'] ? $this->element['height'] : 150;
     $crop = $this->element['crop'] ? $this->element['crop'] : 1;
     // Initialize JavaScript field attributes.
     $onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     if ($readonly != 'false' && $readonly) {
         return JHtml::image($this->value, $this->name, array('width' => 150));
     } else {
         $html = '';
         if ($this->value) {
             $html .= '<div class="image-' . $this->id . '">' . JHtml::image(ThumbHelper::resize($this->value, $width, $height, \JImage::CROP_RESIZE), $this->name, array()) . '</div>';
         }
         $html .= '<input type="file" name="' . $this->getName($this->element['name'] . '_upload') . '" id="' . $this->id . '"' . ' value=""' . $accept . $disabled . $class . $size . $onchange . ' />';
         $html .= '<label><input type="checkbox" name="' . $this->getName($this->element['name'] . '_delete') . '" id="' . $this->id . '"' . ' value="1" />' . JText::_('JACTION_DELETE') . '</label>';
         $html .= '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '" />';
         return $html;
     }
 }
コード例 #2
0
ファイル: uploadimage.php プロジェクト: ForAEdesWeb/AEW13
 /**
  * getThumbPath
  *
  * @return  string
  */
 protected function getThumbPath()
 {
     $width = $this->element['width'] ? $this->element['width'] : 150;
     $height = $this->element['height'] ? $this->element['height'] : 150;
     return ThumbHelper::resize($this->value, $width, $height, \JImage::CROP_RESIZE);
 }