function _getCacheFileName($image) { $ext = File_Common::getExtension($image); return sprintf("w%s_h%s_%s%s", $this->width, $this->height, $this->image_file_md5, $ext); }
/** * Upload image form */ public function edit($force_width = 0, $force_height = 0) { $form = new PHPWS_Form(); $form->setFormId('file-form'); $form->addHidden('module', 'filecabinet'); $form->addHidden('iop', 'post_image_upload'); $form->addHidden('ms', $this->max_size); $form->addHidden('mh', $this->max_height); $form->addHidden('mw', $this->max_width); $form->addHidden('folder_id', $this->folder->id); if ($this->image->id && Current_User::allow('filecabinet', 'edit_folders', $this->folder->id, 'folder', true)) { Cabinet::moveToForm($form, $this->folder); } // if 'im' is set, then we are inside the image manage interface // the post needs to be aware of that to respond correctly if (isset($_GET['im'])) { $form->addHidden('im', 1); } if ($this->image->id) { $form->addHidden('image_id', $this->image->id); $this->title = dgettext('filecabinet', 'Update image'); } else { $this->title = dgettext('filecabinet', 'Upload image'); } $form->addFile('file_name'); $form->setClass('file_name', 'form-control'); $form->setSize('file_name', 30); $form->setMaxFileSize($this->max_size); $form->setLabel('file_name', dgettext('filecabinet', 'Image location')); $form->addText('title', $this->image->title); $form->setLabel('title', dgettext('filecabinet', 'Title')); $form->setClass('title', 'form-control'); $form->addTextArea('description', $this->image->description); $form->setRows('description', 8); $form->setCols('description', 45); $form->setLabel('description', dgettext('filecabinet', 'Description')); if ($this->image->folder_id) { $folder = new Folder($this->image->folder_id); if ($folder->public_folder) { $link_choice['folder'] = dgettext('filecabinet', 'Link to image folder'); } } if ($this->folder->max_image_dimension && $this->folder->max_image_dimension < $this->max_width) { $max_width = $this->folder->max_image_dimension; } else { $max_width = $this->max_width; } if ($force_width && $force_height) { $form->addHidden('fw', $force_width); $form->addHidden('fh', $force_height); $form->addTplTag('RESIZE_LABEL', dgettext('filecabinet', 'Images resized to:')); $form->addTplTag('RESIZE', sprintf('%s x %spx', $force_width, $force_height)); } elseif (!$this->image->id) { $resizes = Cabinet::getResizes($max_width); if (!empty($resizes)) { $form->addSelect('resize', $resizes); $form->setLabel('resize', dgettext('filecabinet', 'Resize image if over')); } } switch (1) { case empty($this->image->url): $form->setMatch('link', 'none'); $form->addTplTag('VISIBLE', 'none'); $form->setValue('url', 'http://'); break; case $this->image->url == 'parent': $form->setMatch('link', 'parent'); $form->addTplTag('VISIBLE', 'none'); break; case $this->image->url == 'folder': $form->setMatch('link', 'folder'); $form->addTplTag('VISIBLE', 'none'); break; default: $form->setMatch('link', 'url'); $form->setValue('url', $this->image->url); $form->addTplTag('VISIBLE', 'table-row'); break; } if (!empty($this->image->id)) { $form->addSubmit('submit', dgettext('filecabinet', 'Update')); } else { $form->addSubmit('submit', dgettext('filecabinet', 'Upload')); } $form->setClass('submit', 'btn btn-primary'); $template = $form->getTemplate(); $template['CANCEL'] = sprintf('<input type="button" value="%s" onclick="javascript:window.close()" />', dgettext('filecabinet', 'Cancel')); if ($this->image->id) { $template['CURRENT_IMAGE_LABEL'] = dgettext('filecabinet', 'Current image'); $template['CURRENT_IMAGE'] = $this->image->getJSView(TRUE); $template['SIZE'] = sprintf('%s x %s', $this->image->width, $this->image->height); } $template['MAX_SIZE_LABEL'] = dgettext('filecabinet', 'Maximum file size'); $template['MAX_DIMENSION_LABEL'] = dgettext('filecabinet', 'Maximum image dimension'); $template['MAX_DIMENSION'] = $this->max_width; $sys_size = str_replace('M', '', ini_get('upload_max_filesize')); $sys_size = $sys_size * 1000000; $form_max = $form->max_file_size; if ($form_max < $sys_size && $form_max < $this->max_size) { $max_size =& $form_max; } elseif ($sys_size < $form_max && $sys_size < $this->max_size) { $max_size =& $sys_size; } else { $max_size =& $this->max_size; } $template['MAX_SIZE'] = File_Common::humanReadable($max_size); $template['ERRORS'] = $this->image->printErrors(); $this->content = PHPWS_Template::process($template, 'filecabinet', 'Forms/image_edit.tpl'); }
public function settings() { $sizes = Cabinet::getMaxSizes(); $form = new PHPWS_Form('settings'); $form->addHidden('module', 'filecabinet'); $form->addHidden('aop', 'save_settings'); $form->addTplTag('DOCUMENT_SETTINGS', dgettext('filecabinet', 'Document settings')); $form->addTplTag('IMAGE_SETTINGS', dgettext('filecabinet', 'Image settings')); $form->addTplTag('MULTIMEDIA_SETTINGS', dgettext('filecabinet', 'Multimedia settings')); $form->addText('base_doc_directory', PHPWS_Settings::get('filecabinet', 'base_doc_directory')); $form->setSize('base_doc_directory', '50'); $form->setLabel('base_doc_directory', dgettext('filecabinet', 'Base document directory')); $form->addCheckBox('autofloat', 1); $form->setMatch('autofloat', PHPWS_Settings::get('filecabinet', 'autofloat')); $form->setLabel('autofloat', dgettext('filecabinet', 'Float new images under 300px to the right of content')); $form->addText('max_image_dimension', PHPWS_Settings::get('filecabinet', 'max_image_dimension')); $form->setLabel('max_image_dimension', dgettext('filecabinet', 'Maximum image pixel dimension')); $form->setSize('max_image_dimension', 4, 4); $form->addText('max_image_size', $sizes['image']); $form->setLabel('max_image_size', dgettext('filecabinet', 'Maximum image file size (in bytes)')); $form->setSize('max_image_size', 10, 10); $form->addText('max_document_size', $sizes['document']); $form->setLabel('max_document_size', dgettext('filecabinet', 'Maximum document file size (in bytes)')); $form->setSize('max_document_size', 10, 10); $form->addText('max_multimedia_size', $sizes['multimedia']); $form->setLabel('max_multimedia_size', dgettext('filecabinet', 'Maximum multimedia file size (in bytes)')); $form->setSize('max_multimedia_size', 10, 10); $form->addText('max_pinned_images', PHPWS_Settings::get('filecabinet', 'max_pinned_images')); $form->setLabel('max_pinned_images', dgettext('filecabinet', 'Maximum pinned images shown (0 for all)')); $form->setSize('max_pinned_images', 3, 3); $form->addText('max_pinned_documents', PHPWS_Settings::get('filecabinet', 'max_pinned_documents')); $form->setLabel('max_pinned_documents', dgettext('filecabinet', 'Maximum pinned documents shown (0 for all)')); $form->setSize('max_pinned_documents', 3, 3); $form->addText('crop_threshold', PHPWS_Settings::get('filecabinet', 'crop_threshold')); $form->setLabel('crop_threshold', dgettext('filecabinet', 'Crop pixel threshold')); $form->setSize('crop_threshold', 4, 4); $form->addCheck('use_ffmpeg', 1); $form->setMatch('use_ffmpeg', PHPWS_Settings::get('filecabinet', 'use_ffmpeg')); $form->addCheck('caption_images', 1); $form->setMatch('caption_images', PHPWS_Settings::get('filecabinet', 'caption_images')); $form->setLabel('caption_images', dgettext('filecabinet', 'Caption images')); $form->addCheck('allow_direct_links', 1); $form->setMatch('allow_direct_links', PHPWS_Settings::get('filecabinet', 'allow_direct_links')); $form->setLabel('allow_direct_links', dgettext('filecabinet', 'Allow direct links to documents')); $form->addCheck('force_thumbnail_dimensions', 1); $form->setMatch('force_thumbnail_dimensions', PHPWS_Settings::get('filecabinet', 'force_thumbnail_dimensions')); $form->setLabel('force_thumbnail_dimensions', dgettext('filecabinet', 'Force thumbnail dimensions on display')); $form->addCheck('popup_image_navigation', 1); $form->setMatch('popup_image_navigation', PHPWS_Settings::get('filecabinet', 'popup_image_navigation')); $form->setLabel('popup_image_navigation', dgettext('filecabinet', 'Popup images allow folder navigation')); $form->addText('max_thumbnail_size', PHPWS_Settings::get('filecabinet', 'max_thumbnail_size')); $form->setLabel('max_thumbnail_size', dgettext('filecabinet', 'Maximum thumbnail pixel dimension')); $form->setSize('max_thumbnail_size', 3, 3); $ffmpeg_directory = PHPWS_Settings::get('filecabinet', 'ffmpeg_directory'); if (empty($ffmpeg_directory) || !is_file($ffmpeg_directory . 'ffmpeg')) { $form->setDisabled('use_ffmpeg'); $form->setLabel('use_ffmpeg', dgettext('filecabinet', 'Enable FFMpeg thumbnails (enabled on ffmpeg confirmation)')); } else { $form->setLabel('use_ffmpeg', dgettext('filecabinet', 'Enable FFMpeg thumbnails')); } $form->addTplTag('CLASSIFY_SETTINGS', dgettext('filecabinet', 'Classify settings')); $form->addText('ffmpeg_directory', $ffmpeg_directory); $form->setLabel('ffmpeg_directory', dgettext('filecabinet', 'FFMpeg directory')); $form->setSize('ffmpeg_directory', 40); if (FC_ALLOW_CLASSIFY_DIR_SETTING) { $form->addText('classify_directory', PHPWS_Settings::get('filecabinet', 'classify_directory')); $form->setLabel('classify_directory', dgettext('filecabinet', 'Incoming classify directory')); $form->setSize('classify_directory', 50, 255); } $form->addRadioAssoc('jcaro_type', array(0 => dgettext('filecabinet', 'Horizontal'), 1 => dgettext('filecabinet', 'Vertical'))); $form->setMatch('jcaro_type', (int) PHPWS_Settings::get('filecabinet', 'vertical_folder')); $num = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8); $form->addSelect('number_visible', $num); $form->setMatch('number_visible', PHPWS_Settings::get('filecabinet', 'number_visible')); $form->setLabel('number_visible', dgettext('filecabinet', 'Number of thumbnails visible')); $form->addSubmit(dgettext('filecabinet', 'Save settings')); $tpl = $form->getTemplate(); $tpl['CAROUSEL'] = dgettext('filecabinet', 'Carousel defaults'); $tpl['SYSTEM_SIZE'] = dgettext('filecabinet', 'System upload limits'); $tpl['SYSTEM_LABEL'] = dgettext('filecabinet', 'Server upload limit'); $tpl['FORM_LABEL'] = dgettext('filecabinet', 'Form upload limit'); $tpl['ABSOLUTE_LABEL'] = dgettext('filecabinet', 'Absolute upload limit'); $tpl['MAX_SYSTEM_SIZE'] = File_Common::humanReadable($sizes['system']); $tpl['MAX_FORM_SIZE'] = File_Common::humanReadable($sizes['form']); $tpl['ABSOLUTE_SIZE'] = File_Common::humanReadable($sizes['absolute']); if (Current_User::isDeity()) { $link = new PHPWS_Link(null, 'filecabinet', array('aop' => 'fix_document_dir'), true); $js = array('question' => dgettext('filecabinet', 'This process will update all of your document files with the current base directory. Do not run this process unless you are sure it will fix download problems. If you are sure, type Y-E-S below.'), 'address' => $link->getAddress(), 'value_name' => 'confirm', 'link' => dgettext('filecabinet', 'Reindex document directories')); $tpl['FIX_DIRECTORIES'] = javascript('prompt', $js); } return PHPWS_Template::process($tpl, 'filecabinet', 'Forms/settings.tpl'); }