Page 1 of 2

Upload images front-end using Cooliris

Posted: 18 Jun 2010, 12:08
by BeLakor
Hello,
in my website i'm using phocagallery with Cooliris 3D Wall.
In front-end, after login, the administrator have access to User Control Panel Phoca Gallery.
Here the adminstrator can create new category and upload new image in category.

Now the problem:
when the administrator upload a new image, the image is not display in Cooliris Gallery.

I have to access in back-end, select the category and the clic button "Cooliris" to generate RSS files.

Why? It isn't possible to attach the generation of RSS files during the upload of a new image?

Thanks

BeLakor

Re: Upload images front-end using Cooliris

Posted: 18 Jun 2010, 13:23
by Jan
Hi, in fact no, because of security and performace issues. The RSS is created for the category, so if you will create RSS by every change of image, this can be very problematic for the server (to write new file everytime image is edited or added :-( ) so the RSS should be created only one time if all images are ready in category. I know it is not comporfortable if you add new images continuously but opensource programm needs to follow some rules, e.g. to not overload the server - so such option needs to be customized but cannot be added as default :(

Jan

Re: Upload images front-end using Cooliris

Posted: 18 Jun 2010, 13:32
by BeLakor
Thanks Jan :|

It's a big problem for my website... :x

Can you show me how i can customize the image's upload?
Or, if it possible, how i can create a sort of script that auto-generate RSS file once a week?

BeLakor

Re: Upload images front-end using Cooliris

Posted: 19 Jun 2010, 17:43
by Jan
Hi, for now I have no experiences with such option as I didn't do it yet :-(

for such option, you will need copy the whole behaviour of category RSS creating and modify it to work with images + some behavaviour which will read the file and add new image after uploading. :idea:

Jan

Re: Upload images front-end using Cooliris

Posted: 23 Jun 2010, 12:18
by BeLakor
Ok....so....can you tell me what method is calling by button "Cooliris" in Phoca Gallery - Categorie (back-end)?
And in what file is this method?
I try to create a new file that call the same method after the Upload in front-end. :)
I send you this file if it's works :idea:

Thanks

EDIT 1: the button Cooliris call this JS function:

Code: Select all

javascript:if(document.adminForm.boxchecked.value==0){alert('Seleziona un elemento dalla lista');}else{ hideMainMenu(); submitbutton('PicLens')}
Now i try to search "submitbutton->PicLens" ;)

EDIT 2: i've found in administrator\components\com_phocagallery\controllers\phocagalleryc.php the result of generation:

Code: Select all

	function piclens() {
		$cids	= JRequest::getVar( 'cid', array(0), 'post', 'array' );	
		
		$model = $this->getModel( 'phocagalleryc' );
		
		if(!$model->piclens($cids))
		{
			echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
			$msg = JText::_( 'Error Creating PicLens RSS File(s)' );
		}
		else {
			$msg = JText::_( 'PicLens RSS File(s) created' );
		}
		
		$link = 'index.php?option=com_phocagallery&view=phocagallerycs';
		$this->setRedirect( $link, $msg  );
	}
and in administrator\components\com_phocagallery\models\phocagalleryc.php....i think....the generator:

Code: Select all

function piclens($cids) {
		$db 		=& JFactory::getDBO();
		$path 		= PhocaGalleryPath::getPath();
		$piclensImg = $path->image_rel_front.'icon-phocagallery.png';
		$paramsC= JComponentHelper::getParams('com_phocagallery') ;
		jimport('joomla.filesystem.file');
		
		// PARAMS
		// original 0, thumbnail 1
		$piclens_image 	= $paramsC->get( 'piclens_image', 1);
		
		if (JFolder::exists($path->image_abs)) {  
			
			foreach ($cids as $kcid =>$vcid) {
				$this->setXMLFile();
				
				if (!$this->_XMLFile) {
					$this->setError( 'Could not create XML builder' );
					return false;
				}
						
				if (!$node = $this->_XMLFile->createElement( 'rss' )) {
					$this->setError( 'Could not create node!' );
					return false;
				}
				
				$node->setAttribute( 'xmlns:media', 'http://search.yahoo.com/mrss' );
				$node->setAttribute( 'xmlns:atom', 'http://www.w3.org/2005/Atom' );
				$node->setAttribute( 'version', '2.0' );
				
				$this->_XMLFile->setDocumentElement( $node );
				
				if (!$root =& $this->_XMLFile->documentElement) {
					$this->setError( 'Could not obtain root element!' );
					return false;
				}
			
				$channel =& $this->_XMLFile->createElement( 'channel' );
				$atomIcon=& $this->_XMLFile->createElement( 'atom:icon' );
				$atomIcon->setText( JURI::root() . $piclensImg );
				$channel->appendChild( $atomIcon );	
				
				$query = 'SELECT a.id, a.title, a.filename, a.description, a.extid, a.extl, a.exto'
				. ' FROM #__phocagallery AS a'
				. ' WHERE a.catid = '.(int)$vcid
				. ' AND a.published = 1'
				. ' ORDER BY a.catid, a.ordering';
				
				$db->setQuery($query);
				$rows = $db->loadObjectList();
				
				foreach ($rows as $krow => $vrow) {
					$file 		= PhocaGalleryFileThumbnail::getOrCreateThumbnail($vrow->filename, '');	
					$thumbFile	= str_replace( "administrator", "",  $file['thumb_name_l_no_rel']);
					$origFile	= str_replace( "administrator", "",  $file['name_original_rel']);					

					
					$item=& $this->_XMLFile->createElement( 'item' );
					$item->appendChild( $this->_buildXMLElement( 'title', $vrow->title ) );

					
					if ($vrow->extid != '') {
						$item->appendChild( $this->_buildXMLElement( 'link', $vrow->extl  ));
					} else {
						$item->appendChild( $this->_buildXMLElement( 'link', JURI::root().$thumbFile ) );
					}
					
					//$item->appendChild( $this->_buildXMLElement( 'media:description', $vrow->description  ) );
					$item->appendChild( $this->_buildXMLElement( 'description', JFilterOutput::cleanText(strip_tags($vrow->description ))));
					$thumbnail=& $this->_XMLFile->createElement( 'media:thumbnail' );
					
					if ($vrow->extid != '') {
						$thumbnail->setAttribute( 'url', $vrow->extl );
						$content=& $this->_XMLFile->createElement( 'media:content' );
						if ($piclens_image == 1) {
							$content->setAttribute( 'url', $vrow->extl );
						} else {
							$content->setAttribute( 'url', $vrow->exto );
						}
					} else {
						$thumbnail->setAttribute( 'url', JURI::root().$thumbFile );
						$content=& $this->_XMLFile->createElement( 'media:content' );
						if ($piclens_image == 1) {
							$content->setAttribute( 'url', JURI::root().$thumbFile );
						} else {
							$content->setAttribute( 'url', JURI::root().$origFile );
						}
					}

					$item->appendChild( $thumbnail );
					$item->appendChild( $content );
					
					$guid=& $this->_XMLFile->createElement( 'guid' );
					if ($vrow->extid != '') {
						$guid->setText( $vcid .'-phocagallerypiclenscode-'.$vrow->extid );
					} else {
						$guid->setText( $vcid .'-phocagallerypiclenscode-'.$vrow->filename );
					}
					$guid->setAttribute( 'isPermaLink', "false" );
					$item->appendChild( $guid );
					
					$channel->appendChild( $this->_buildXMLElement(  'title', 'Phoca Gallery' ));
					$channel->appendChild( $this->_buildXMLElement( 'link', 'https://www.phoca.cz/' ));
					$channel->appendChild( $this->_buildXMLElement( 'description', 'Phoca Gallery' ));
					
					$channel->appendChild( $item );
				}

				$root->appendChild( $channel );	 
			
				$this->_XMLFile->setXMLDeclaration( '<?xml version="1.0" encoding="utf-8" standalone="yes"?>' );
				
				//echo $this->_XMLFile->toNormalizedString( true );exit;
				// saveXML_utf8 doesn't save setXMLDeclaration
				/*if (!$this->_XMLFile->saveXML( $path->image_abs . DS . $vcid.'.rss', true )) {
					$this->setError( 'Could not save XML file!' );
					return false;
				}*/
				ob_start();
				echo $this->_XMLFile->toNormalizedString(false, true);
				$xmlToWrite = ob_get_contents();
				ob_end_clean();
				if(!JFile::write( $path->image_abs . DS . $vcid.'.rss', $xmlToWrite)) {
					$this->setError( 'Could not save XML file!' );
					return false;
				}
			}
			return true;
		} else {
			$this->setError( 'Phoca Gallery image folder not exists' );
		}
	}
EDIT 3: in front-end, the upload of new image call function OnUploadSubmitPG(). I want to attach function piclens() in OnUploadSubmitPG() but i don't find where's this function. Can you help me Jan?

BeLakor

Re: Upload images front-end using Cooliris

Posted: 28 Jun 2010, 22:01
by Jan
Hi,
can you tell me what method is calling by button "Cooliris" in Phoca Gallery - Categorie (back-end)?
And in what file is this method?
the method is called "piclens" and it is not saved in only one file, because Phoca Gallery follows MVC pattern:

administrator\components\com_phocagallery\controllers\phocagalleryc.php
administrator\components\com_phocagallery\models\phocagalleryc.php



Jan

Re: Upload images front-end using Cooliris

Posted: 07 Jul 2010, 13:01
by BeLakor
Sure, i've just found piclens() (look my 3 EDIT :D )

In front-end, the upload of new image call function OnUploadSubmitPG(). I want to attach function piclens() in OnUploadSubmitPG() but i don't find where's this function. Can you help me Jan?

BeLakor

Re: Upload images front-end using Cooliris

Posted: 08 Jul 2010, 20:32
by Jan
Hi,

administrator\components\com_phocagallery\libraries\phocagallery\render\renderfront.php

Jan

Re: Upload images front-end using Cooliris

Posted: 20 Jul 2010, 13:28
by BeLakor
Thanks Jan.
Now i try to attach function piclens($cids) in this file. :?

BeLakor

Re: Upload images front-end using Cooliris

Posted: 14 Sep 2010, 11:38
by BeLakor
Nothing Jan.... :x
Can you insert the function piclens($cids) in administrator\components\com_phocagallery\libraries\phocagallery\render\renderfront.php? :)

BeLakor