function processAction($data)
 {
     if (empty($data['media_action'])) {
         return $data;
     }
     $data = parent::processAction($data);
     if ($data['media_action'] == 'upload_create_thumb') {
         $oldFileUrl = $this->file_url;
         $file_name = $this->uploadFile($this->file_url_folder);
         if ($file_name) {
             if ($file_name != $oldFileUrl && !empty($this->filename)) {
                 $this->deleteFile($oldFileUrl);
             }
             $this->file_url = $this->file_url_folder . $file_name;
             $this->filename = $file_name;
             $oldFileUrlThumb = $this->file_url_thumb;
             $this->file_url_thumb = $this->createThumb();
             if ($this->file_url_thumb != $oldFileUrlThumb) {
                 $this->deleteFile($oldFileUrlThumb);
             }
         }
     } else {
         if ($data['media_action'] == 'create_thumb') {
             $this->file_url_thumb = $this->createThumb();
         }
     }
     if (empty($this->file_title) && !empty($file_name)) {
         $this->file_title = $file_name;
     }
     return $data;
 }
 function display($tpl = null)
 {
     $document = JFactory::getDocument();
     $document->setMimeEncoding('application/json');
     if ($virtuemart_media_id = vRequest::getInt('virtuemart_media_id')) {
         //JResponse::setHeader( 'Content-Disposition', 'attachment; filename="media'.$virtuemart_media_id.'.json"' );
         $model = VmModel::getModel('Media');
         $image = $model->createMediaByIds($virtuemart_media_id);
         // 			echo '<pre>'.print_r($image,1).'</pre>';
         $this->json = $image[0];
         //echo json_encode($this->json);
         if (isset($this->json->file_url)) {
             $this->json->file_root = JURI::root(true) . '/';
             $this->json->msg = 'OK';
             echo @json_encode($this->json);
         } else {
             $this->json->msg = '<b>' . vmText::_('COM_VIRTUEMART_NO_IMAGE_SET') . '</b>';
             echo @json_encode($this->json);
         }
     } else {
         if (!class_exists('VmMediaHandler')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'mediahandler.php';
         }
         $start = vRequest::getInt('start', 0);
         $type = vRequest::getCmd('mediatype', 0);
         $list = VmMediaHandler::displayImages($type, $start);
         echo @json_encode($list);
     }
     jExit();
 }
 function displayCustomMedia($media_id, $table = 'product', $absUrl = FALSE)
 {
     JLoader::register('TableMedias', JPATH_VM_ADMINISTRATOR . '/tables/medias.php');
     //$data = $this->getTable('medias');
     $db = JFactory::getDBO();
     $data = new TableMedias($db);
     $data->load((int) $media_id);
     JLoader::register('VmMediaHandler', JPATH_VM_ADMINISTRATOR . '/helpers/mediahandler.php');
     $media = VmMediaHandler::createMedia($data, $table);
     return $media->displayMediaThumb('', FALSE, '', TRUE, TRUE, $absUrl);
 }
    static function displayImages($types = '', $page = 0, $max = 16)
    {
        $Images = array();
        $list = VmMediaHandler::getImagesList($types, $page, $max);
        if (empty($list['images'])) {
            return vmText::_('COM_VIRTUEMART_NO_MEDIA_FILES');
        }
        foreach ($list['images'] as $key => $image) {
            $htmlImages = '';
            if ($image->file_url_thumb > "0") {
                /*$htmlImages .= '<div class="vm_thumb_image">
                		<span><a class="vm_thumb" rel="group1" title ="'.$image->file_title.'"href="'.JURI::root(true).'/'.$image->file_url.'" >'
                		.JHtml::image($image->file_url_thumb,$image->file_title, 'class="vm_thumb" ').'</span></a>';*/
                $htmlImages .= '<div class="vm_thumb_image">
				<span>' . JHtml::image($image->file_url_thumb, $image->file_title, 'class="vm_thumb" ') . '</span>';
            } else {
                $htmlImages .= '<div class="vm_thumb_image">' . vmText::_('COM_VIRTUEMART_NO_IMAGE_SET') . '<br />' . $image->file_title;
            }
            $Images[$key]['label'] = $htmlImages . '<input type="hidden" value="' . $image->virtuemart_media_id . '" name="virtuemart_media_id[' . $image->virtuemart_media_id . ']"><input class="ordering" type="hidden" name="mediaordering[' . $image->virtuemart_media_id . ']" value=""><div class="vmicon vmicon-16-remove" title="remove"></div><div title="edit image information" class="edit-24-grey"></div></div>';
            $Images[$key]['value'] = $image->file_title . ' :: ' . $image->virtuemart_media_id;
        }
        //$list['htmlImages'] = $htmlImages;
        return $Images;
    }
 function displayCustomMedia($media_id, $table = 'product', $absUrl = FALSE)
 {
     if (!class_exists('TableMedias')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'tables' . DS . 'medias.php';
     }
     //$data = $this->getTable('medias');
     $db = JFactory::getDBO();
     $data = new TableMedias($db);
     $data->load((int) $media_id);
     if (!class_exists('VmMediaHandler')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'mediahandler.php';
     }
     $media = VmMediaHandler::createMedia($data, $table);
     //if($media_id==0){
     //	return $media->getIcon('', FALSE, TRUE, TRUE,$absUrl);
     //}
     return $media->displayMediaThumb('', FALSE, '', TRUE, TRUE, $absUrl);
 }
Exemple #6
0
 function displayCustomMedia($media_id, $table = 'product', $width = false, $height = false, $absUrl = false)
 {
     if (!class_exists('TableMedias')) {
         require VMPATH_ADMIN . DS . 'tables' . DS . 'medias.php';
     }
     $db = JFactory::getDBO();
     $data = new TableMedias($db);
     $data->load((int) $media_id);
     if (!empty($data->file_type)) {
         $table = $data->file_type;
     }
     if (!class_exists('VmMediaHandler')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'mediahandler.php';
     }
     $media = VmMediaHandler::createMedia($data, $table);
     if (!$width) {
         $width = VmConfig::get('img_width', 90);
     }
     if (!$height) {
         $height = VmConfig::get('img_height', 90);
     }
     return $media->displayMediaThumb('', FALSE, '', TRUE, TRUE, $absUrl, $width, $height);
 }
Exemple #7
0
	/**
	 * Store an entry of a mediaItem, this means in end effect every media file in the shop
	 * images, videos, pdf, zips, exe, ...
	 *
	 * @author Max Milbers
	 */
	public function store(&$data,$type) {

		//if(empty($data['media_action'])) return $table->virtuemart_media_id;
		if (!class_exists('VmMediaHandler')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'mediahandler.php');

		$table = $this->getTable('medias');

		$table->bind($data);
		$data = VmMediaHandler::prepareStoreMedia($table,$data,$type); //this does not store the media, it process the actions and prepares data

		// workarround for media published and product published two fields in one form.

		if (isset($data['media_published'])){
			$data['published'] = $data['media_published'];
			//vmdebug('$data["published"]',$data['published']);
		}

		$table->bindChecknStore($data);
		$errors = $table->getErrors();
		foreach($errors as $error){
			vmError('store medias '.$error);
		}
// 		vmdebug('store media $table->virtuemart_media_id '.$table->virtuemart_media_id);
		return $table->virtuemart_media_id;
	}
Exemple #8
0
 /**
  * Store an entry of a mediaItem, this means in end effect every media file in the shop
  * images, videos, pdf, zips, exe, ...
  *
  * @author Max Milbers
  */
 public function store(&$data)
 {
     VmConfig::loadJLang('com_virtuemart_media');
     if (!class_exists('VmMediaHandler')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'mediahandler.php';
     }
     $table = $this->getTable('medias');
     $data['virtuemart_media_id'] = $this->getId();
     $table->bind($data);
     $data = VmMediaHandler::prepareStoreMedia($table, $data, $data['file_type']);
     //this does not store the media, it process the actions and prepares data
     // workarround for media published and product published two fields in one form.
     $tmpPublished = false;
     if (isset($data['media_published'])) {
         $tmpPublished = $data['published'];
         $data['published'] = $data['media_published'];
     }
     $table->bindChecknStore($data);
     if ($tmpPublished) {
         $data['published'] = $tmpPublished;
     }
     return $table->virtuemart_media_id;
 }
Exemple #9
0
 /**
  * Store an entry of a mediaItem, this means in end effect every media file in the shop
  * images, videos, pdf, zips, exe, ...
  *
  * @author Max Milbers
  */
 public function store(&$data, $type)
 {
     VmConfig::loadJLang('com_virtuemart_media');
     //if(empty($data['media_action'])) return $table->virtuemart_media_id;
     if (!class_exists('VmMediaHandler')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'mediahandler.php';
     }
     $table = $this->getTable('medias');
     /*	$a = trim($data['file_url_thumb']);
     		$b = trim(JText::sprintf('COM_VIRTUEMART_DEFAULT_URL',$data['file_url_thumb']));
     		vmdebug(' the miese Assi',$a,$b);
     		if( $a == $b ){
     			vmdebug('Unset the miese Assi');
     			unset($data['file_url_thumb']);
     		}*/
     //unset($data['file_url_thumb']);
     $table->bind($data);
     $data = VmMediaHandler::prepareStoreMedia($table, $data, $type);
     //this does not store the media, it process the actions and prepares data
     // workarround for media published and product published two fields in one form.
     $tmpPublished = false;
     if (isset($data['media_published'])) {
         $tmpPublished = $data['published'];
         $data['published'] = $data['media_published'];
         //vmdebug('$data["published"]',$data['published']);
     }
     $table->bindChecknStore($data);
     $errors = $table->getErrors();
     foreach ($errors as $error) {
         vmError('store medias ' . $error);
     }
     if ($tmpPublished) {
         $data['published'] = $tmpPublished;
     }
     // 		vmdebug('store media $table->virtuemart_media_id '.$table->virtuemart_media_id);
     return $table->virtuemart_media_id;
 }
    static function displayImages($types = '', $page = 0, $max = 16)
    {
        $Images = array();
        $list = VmMediaHandler::getImagesList($types, $page, $max);
        if (empty($list['images'])) {
            return tsmText::_('com_tsmart_NO_MEDIA_FILES');
        }
        foreach ($list['images'] as $key => $image) {
            $htmlImages = '';
            $image->file_url_thumb = $image->getFileUrlThumb();
            if ($image->file_url_thumb > "0") {
                $htmlImages .= '<div class="vm_thumb_image">
				<span>' . JHtml::image($image->file_url_thumb, $image->file_title, 'class="vm_thumb" ') . '</span>';
            } else {
                $htmlImages .= '<div class="vm_thumb_image">' . tsmText::_('com_tsmart_NO_IMAGE_SET') . '<br />' . $image->file_title;
            }
            $Images[$key]['label'] = $htmlImages . '<input type="hidden" value="' . $image->tsmart_media_id . '" name="tsmart_media_id[' . $image->tsmart_media_id . ']"><input class="ordering" type="hidden" name="mediaordering[' . $image->tsmart_media_id . ']" value=""><div class="vmicon vmicon-16-remove" title="remove"></div><div title="edit image information" class="edit-24-grey"></div></div>';
            $Images[$key]['value'] = $image->file_title . ' :: ' . $image->tsmart_media_id;
        }
        //$list['htmlImages'] = $htmlImages;
        return $Images;
    }
Exemple #11
0
 /**
  * Store an entry of a mediaItem, this means in end effect every media file in the shop
  * images, videos, pdf, zips, exe, ...
  *
  * @author Max Milbers
  */
 public function store(&$data)
 {
     $data['tsmart_media_id'] = $this->getId();
     if (!vmAccess::manager('media.edit')) {
         vmWarn('Insufficient permission to store media');
         return false;
     } else {
         if (empty($data['tsmart_media_id']) and !vmAccess::manager('media.create')) {
             vmWarn('Insufficient permission to create media');
             return false;
         }
     }
     tsmConfig::loadJLang('com_tsmart_media');
     if (!class_exists('VmMediaHandler')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'mediahandler.php';
     }
     $table = $this->getTable('medias');
     $table->bind($data);
     $data = VmMediaHandler::prepareStoreMedia($table, $data, $data['file_type']);
     //this does not store the media, it process the actions and prepares data
     if ($data === false) {
         return $table->tsmart_media_id;
     }
     // workarround for media published and product published two fields in one form.
     $tmpPublished = false;
     if (isset($data['media_published'])) {
         $tmpPublished = $data['published'];
         $data['published'] = $data['media_published'];
     }
     $table->bindChecknStore($data);
     if ($tmpPublished) {
         $data['published'] = $tmpPublished;
     }
     return $table->tsmart_media_id;
 }
	function displayCustomMedia ($media_id, $table = 'product', $absUrl = FALSE) {

		if (!class_exists ('TableMedias'))
			require(VMPATH_ADMIN . DS . 'tables' . DS . 'medias.php');

		$db = JFactory::getDBO ();
		$data = new TableMedias($db);
		$data->load ((int)$media_id);
		if(!empty($data->file_type)){
			$table = $data->file_type;
		}

		if (!class_exists ('VmMediaHandler'))
			require(VMPATH_ADMIN . DS . 'helpers' . DS . 'mediahandler.php');
		$media = VmMediaHandler::createMedia ($data, $table);

		return $media->displayMediaThumb ('', FALSE, '', TRUE, TRUE, $absUrl);
	}