コード例 #1
0
ファイル: imagelibs.php プロジェクト: juliano-hallac/fabrik
 function getOptions()
 {
     require_once COM_FABRIK_FRONTEND . DS . 'helpers' . DS . 'image.php';
     $imageLibs = imageHelper::getLibs();
     if (empty($imageLibs)) {
         return JHTML::_('select.option', JText::_('NO MAGE LIBRARY FOUND'));
     }
     return $imageLibs;
 }
コード例 #2
0
ファイル: imagelibs.php プロジェクト: nikshade/fabrik21
 function fetchElement($name, $value, &$node, $control_name)
 {
     require_once COM_FABRIK_FRONTEND . DS . 'helpers' . DS . 'image.php';
     $imageLibs = imageHelper::getLibs();
     if (empty($imageLibs)) {
         return JText::_('NO MAGE LIBRARY FOUND');
     }
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     return JHTML::_('select.genericlist', $imageLibs, $fullName, 'class="inputbox" size="1" ', 'value', 'text', $value);
 }
コード例 #3
0
ファイル: image.php プロジェクト: nikshade/fabrik21
 public function getLibs()
 {
     $libs = array();
     $gds = imageHelper::_testGD();
     foreach ($gds as $key => $val) {
         $libs[] = JHTML::_('select.option', $key, $val);
     }
     $im = imageHelper::_testImagemagick();
     foreach ($im as $key => $val) {
         $libs[] = JHTML::_('select.option', $key, $val);
     }
     return $libs;
 }
コード例 #4
0
ファイル: video.php プロジェクト: nickbunyan/fabrik
 /**
  *
  */
 function _processIndUpload(&$oUploader, $myFileName, $tmpFile, $arrayInc, $myFileDir = '', $file)
 {
     $params = $this->getParams();
     if ($params->get('ul_file_types') == '') {
         $params->set('ul_file_types', implode(',', $this->_aDefaultFileTypes));
     }
     $folder = $params->get('ul_directory');
     if ($myFileDir != '') {
         $folder .= JPath::clean(JPATH_SITE . DS . $myFileDir);
     }
     $oUploader->_makeRecursiveFolders($folder);
     $folder = JPath::clean(JPATH_SITE . DS . $folder);
     $err = null;
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     if ($myFileName != '') {
         $filepath = JPath::clean($folder . DS . strtolower($myFileName));
         if (!uploader::canUpload($file, $err, $params)) {
             return JError::raiseNotice(100, JText::_($err));
         }
         if (JFile::exists($filepath)) {
             if ($params->get('ul_file_increment', 0)) {
                 $filepath = uploader::incrementFileName($filepath, $filepath, 1);
             } else {
                 return JError::raiseNotice(100, JText::_('A file of that name already exists'));
             }
         }
         if (!JFile::upload($tmpFile, $filepath)) {
             $oUploader->moveError = true;
             JError::raiseWarning(100, JText::_("Error. Unable to upload file (from {$tmpFile} to {$destFile})"));
         } else {
             jimport('joomla.filesystem.path');
             JPath::setPermissions($destFile);
             //resize main image
             $oImage = imageHelper::loadLib($params->get('image_library'));
             $mainWidth = $params->get('fu_main_max_width');
             $mainHeight = $params->get('fu_main_max_height');
             if ($params->get('make_thumbnail') == '1') {
                 $thumbPath = JPath::clean($params->get('thumb_dir') . DS . $myFileDir . DS);
                 $thumbPrefix = $params->get('thumb_prefix');
                 $maxWidth = $params->get('thumb_max_width');
                 $maxHeight = $params->get('thumb_max_height');
                 if ($thumbPath != '') {
                     $oUploader->_makeRecursiveFolders($thumbPath);
                 }
                 $destThumbFile = JPath::clean(JPATH_SITE . DS . $thumbPath . DS . $thumbPrefix . basename($filepath));
                 $msg = $oImage->resize($maxWidth, $maxHeight, $filepath, $destThumbFile);
             }
             if ($mainWidth != '' || $mainHeight != '') {
                 $msg = $oImage->resize($mainWidth, $mainHeight, $filepath, $filepath);
             }
             $res = str_replace(JPATH_SITE, '', $filepath);
             return $res;
         }
     }
 }
コード例 #5
0
ファイル: download.php プロジェクト: Jobar87/fabrik
	/**
	 * do the plugin action
	 * @param object parameters
	 * @param object table model
	 */
	function process(&$params, &$model)
	{
		$ids	= JRequest::getVar('ids', array(), 'method', 'array');
		//$params = $model->getParams();
		$download_table = $params->get('download_table');
		$download_fk = $params->get('download_fk');
		$download_file = $params->get('download_file');
		$download_width = $params->get('download_width');
		$download_height = $params->get('download_height');
		$download_resize = ($download_width || $download_height) ? true : false;
		$table = $model->getTable();
		$filelist = array();
		$zip_err = '';

		if (empty($download_fk) && empty($download_file) && empty($download_table)) {
			return;
		}
		else if (empty($download_fk) && empty($download_table) && !empty($download_file)) {
			foreach ($ids AS $id) {
				$row = $model->getRow($id);
				if (isset($row->$download_file)) {
					$this_file = JPATH_SITE.DS.$row->$download_file;
					if (is_file($this_file)) {
						$filelist[] = $this_file;
					}
				}
			}
		}
		else {
			$db = FabrikWorker::getDbo();
			$ids_string = implode(',',$ids);
			$query = "SELECT $download_file FROM $download_table WHERE $download_fk IN ($ids_string)";
			$db->setQuery($query);
			$results = $db->loadObjectList();
			foreach ($results AS $result) {
				$this_file = JPATH_SITE.DS.$result->$download_file;
				if (is_file($this_file)) {
					$filelist[] = $this_file;
				}
			}
		}
		if (!empty($filelist)) {
			if ($download_resize) {
				ini_set('max_execution_time', 300);
				require_once(COM_FABRIK_FRONTEND.DS.'helpers'.DS.'image.php');
				$storage = $this->getStorage();
				$download_image_library = $params->get('download_image_library');
				$oImage 		= imageHelper::loadLib( $download_image_library);
				$oImage->setStorage($storage);
			}
			$zipfile = tempnam(sys_get_temp_dir(), "zip");
			$zipfile_basename = basename($zipfile);
			$zip = new ZipArchive;
			$zipres = $zip->open($zipfile, ZipArchive::OVERWRITE);
			if ($zipres === true) {
				$ziptot = 0;
				$tmp_files = array();
				foreach ($filelist AS $this_file) {
					$this_basename = basename($this_file);
					if ($download_resize && $oImage->GetImgType($this_file)) {
						$tmp_file = '/tmp/' . $this_basename;
						$oImage->resize($download_width, $download_height, $this_file, $tmp_file);
						$this_file = $tmp_file;
						$tmp_files[] = $tmp_file;
					}
					$zipadd = $zip->addFile($this_file, $this_basename);
					if ($zipadd === true) {
						$ziptot++;
					}
					else {
						$zip_err .= JText::_('ZipArchive add error: ' . $zipadd);
					}
				}
				if (!$zip->close()) {
					$zip_err = JText::_('ZipArchive close error') . ($zip->status);
				}

				if ($download_resize) {
					foreach ($tmp_files as $tmp_file) {
						$storage->delete($tmp_file);
					}
				}
				if ($ziptot > 0) {
					// Stream the file to the client
					$filesize = filesize($zipfile);
					if ($filesize > 0) {
						header("Content-Type: application/zip");
						header("Content-Length: " . filesize($zipfile));
						header("Content-Disposition: attachment; filename=\"$zipfile_basename.zip\"");
						echo JFile::read($zipfile);
						JFile::delete($zipfile);
						exit;
					}
					else {
						$zip_err .= JText::_('ZIP is empty');
					}
				}
			}
			else {
				$zip_err = JText::_('ZipArchive open error: ' . $zipres);
			}

		}
		else {
			$zip_err = "No files to ZIP!";
		}
		return $zip_err;
	}
コード例 #6
0
 /**
  * process the upload
  * @access private
  *
  * @param array $file info
  * @param string user selected upload folder
  * @param int repeat group counter
  * @return string location of uploaded file
  */
 function _processIndUpload(&$file, $myFileDir = '', $repeatGroupCounter = 0)
 {
     $params =& $this->getParams();
     $storage =& $this->getStorage();
     // $$$ hugh - check if we need to blow away the cached filepath, set in validation
     $myFileName = $storage->cleanName($file['name'], $repeatGroupCounter);
     if ($myFileName != $file['name']) {
         $file['name'] = $myFileName;
         unset($this->_filePaths[$repeatGroupCounter]);
     }
     $tmpFile = $file['tmp_name'];
     $uploader =& $this->getFormModel()->getUploader();
     if ($params->get('ul_file_types') == '') {
         $params->set('ul_file_types', implode(',', $this->_getAllowedExtension()));
     }
     $err = null;
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     if ($myFileName == '') {
         return;
     }
     $filepath = $this->_getFilePath($repeatGroupCounter);
     if (!uploader::canUpload($file, $err, $params)) {
         $this->setError(100, $file['name'] . ': ' . JText::_($err));
     }
     if ($storage->exists($filepath)) {
         switch ($params->get('ul_file_increment', 0)) {
             case 0:
                 break;
             case 1:
                 $filepath = uploader::incrementFileName($filepath, $filepath, 1);
                 break;
             case 2:
                 $storage->delete($filepath);
                 break;
         }
     }
     if (!$storage->upload($tmpFile, $filepath)) {
         $uploader->moveError = true;
         $this->setError(100, JText::_("Error. Unable to upload file (from {$tmpFile} to {$filepath})"));
         return;
     }
     $filepath = $storage->getUploadedFilePath();
     jimport('joomla.filesystem.path');
     $storage->setPermissions($filepath);
     // $$$ hugh @TODO - shouldn't we check to see if it's actually an image before we do any of this stuff???
     //resize main image
     $oImage = imageHelper::loadLib($params->get('image_library'));
     $oImage->setStorage($storage);
     // $$$ hugh - removing default of 200, otherwise we ALWAYS resize, whereas
     // tooltip on these options say 'leave blank for no resizing'
     $mainWidth = $params->get('fu_main_max_width', '');
     $mainHeight = $params->get('fu_main_max_height', '');
     if ($mainWidth != '' || $mainHeight != '') {
         // $$$ rob ensure that both values are integers otherwise resize fails
         if ($mainHeight == '') {
             $mainHeight = (int) $mainWidth;
         }
         if ($mainWidth == '') {
             $mainWidth = (int) $mainHeight;
         }
         $oImage->resize($mainWidth, $mainHeight, $filepath, $filepath);
     }
     // $$$ hugh - if it's a PDF, make sure option is set to attempt PDF thumb
     $make_thumbnail = $params->get('make_thumbnail') == '1' ? true : false;
     if (JFile::getExt($filepath) == 'pdf' && $params->get('fu_make_pdf_thumb', '0') == '0') {
         $make_thumbnail = false;
     }
     if ($make_thumbnail) {
         $thumbPath = $storage->clean(JPATH_SITE . DS . $params->get('thumb_dir') . DS . $myFileDir . DS, false);
         $w = new FabrikWorker();
         $thumbPath = $w->parseMessageForPlaceHolder($thumbPath);
         $thumbPrefix = $params->get('thumb_prefix');
         $maxWidth = $params->get('thumb_max_width', 125);
         $maxHeight = $params->get('thumb_max_height', 125);
         if ($thumbPath != '') {
             if (!$storage->folderExists($thumbPath)) {
                 if (!$storage->createFolder($thumbPath)) {
                     JError::raiseError(21, "Could not make dir {$thumbPath} ");
                 }
             }
         }
         $fileURL = $storage->getFileUrl(str_replace(COM_FABRIK_BASE, '', $filepath));
         $destThumbFile = $storage->_getThumb($fileURL);
         $destThumbFile = $storage->urlToPath($destThumbFile);
         $oImage->resize($maxWidth, $maxHeight, $filepath, $destThumbFile);
         $storage->setPermissions($destThumbFile);
     }
     $storage->setPermissions($filepath);
     $storage->finalFilePathParse($filepath);
     return $filepath;
 }