How to join PG and Community Builder?

Phoca Gallery - image gallery extension
foto-boss.ru
Phoca Member
Phoca Member
Posts: 16
Joined: 14 Apr 2011, 08:29
Contact:

How to join PG and Community Builder?

Post by foto-boss.ru »

How to join PG and Community Builder?
foto-boss.ru
Phoca Member
Phoca Member
Posts: 16
Joined: 14 Apr 2011, 08:29
Contact:

Re: How to join PG and Community Builder?

Post by foto-boss.ru »

Plugin work with Joomla 1.6.3, PG 3.0.0 RC5, CB 1.4
cb_PG_1.0.zip

Example

Install from CB - Plugin Management

Maybe someone else will improve the plugin:

Code: Select all

<?php
/**
* Phoca Gallery CB user plugin.
* http://phek.ru
* @version $Id: cb.connections.php 609 2006-12-13 17:30:15Z beat $
* @package Community Builder
* @subpackage phoca.php
* @copyright (C) www.phoca.cz and www.joomlapolis.com [Respective]
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL version 1.0
*/

/** ensure this file is being included by a parent file */
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );
JHtml::_('behavior.modal');
class getphocaTab extends cbTabHandler {
	/**
	 * Construnctor
	 */
	function getphocaTab() {
		$this->cbTabHandler();
	}
	/**
	 * Generates the HTML to display the user profile tab
	 * @param  moscomprofilerTab   $tab       the tab database entry
	 * @param  moscomprofilerUser  $user      the user being displayed
	 * @param  int                 $ui        1 for front-end, 2 for back-end
	 * @return mixed                          either string HTML for tab content, or false if ErrorMSG generated
	 */
	function getDisplayTab($tab,$user,$ui) {
		$return = null;
		global $mainframe;
		$db   =& JFactory::getDBO();
		$user_log =& JFactory::getUser();
		
		//Taking parameters
		$params = $this->params; 		
		$is_phoca_plug_enabled = $params->get('hwPlugEnabled', "1");
		$phoca_tab_message = $params->get('hwTabMessage', "Phoca Gallery Plugin!");
		$hwPlugShowTitle = $params->get('hwPlugShowTitle', "1");
		$hwTabStripTitle = $params->get('hwTabStripTitle', "1");
        $hwTabStripTitleLength = (int)$params->get('hwTabStripTitleLength',10);
        $hwTabNoPhotoMessage = $params->get('hwTabNoPhotoMessage','Sorry no pictures available.');

		if ($is_phoca_plug_enabled != "0") {
			//Show the description
			if($tab->description != null) {
				$return .= "\t\t<div class=\"tab_Description\">"
					. $tab->description	
					. "</div>\n";
			}

			$query="SELECT cats.id as catid"
			. "\n FROM #__phocagallery_categories as cats "
			. "\n where cats.owner_id= ".$user->id	//Take the user
			. "\n AND cats.parent_id= 0";


			$db->setQuery($query);			
			$pi=$db->loadObjectList();





			if ($pi[0]->catid>0) {
				$return .= '<div style="width:100%;float:left;text-align:center;font-size : 16pt;"><a href="'.$mosConfig_live_site.'/index.php?option=com_phocagallery&view=category&id='.$pi[0]->catid.'" style="color:red;">- Посмотреть портфолио -<a></br></br></div>';
				$return .= '<div style="width:100%;float:left;text-align:left;"><a>Последние добавленные фотографии:<a></br></div>';
				}
				else {
				$return .= '<div style="width:100%;float:left;text-align:left;"><a>Портфолио отсутствует.<a></br></div>';
				}



			$query="SELECT photos.filename as filename, photos.title as title, cats.id as catid, cats.userfolder as userfolder"
			. "\n FROM #__phocagallery as photos "
			. "\n JOIN #__phocagallery_categories as cats "
			. "\n ON cats.id = photos.catid "
			. "\n WHERE cats.published = 1 "	//Where the category is published?
			. "\n AND cats.approved= 1 "		//And the category is approved?
			. "\n AND photos.published= 1 "		//And the image is published?
			. "\n AND photos.approved= 1 "		//And the image is approved?
			. "\n AND cats.owner_id= ".$user->id	//Take the user
			. "\n ORDER BY photos.ordering DESC LIMIT 7";
			 
			$db->setQuery($query);			
			$pgitems=$db->loadObjectList();


	
			if(count($pgitems) >0 ){
				foreach($pgitems as $imageitem) {
					$photoTitle = trim($imageitem->title);
					$strippedTitle = $photoTitle;
					if($hwTabStripTitle != "0"){
						$strippedTitle = substr($photoTitle,0,$hwTabStripTitleLength);
						if($photoTitle!=$strippedTitle){
							$strippedTitle = $strippedTitle."...";
						}
					}
					
					if($hwPlugShowTitle != "0"){
					$return .='<div style="text-align: center; width: 100px; float: left;" >
									<a href="images/phocagallery/'.$imageitem->filename.'" class="modal"><strong>'.$strippedTitle.'</strong></a><br/>';
					}
					


$per = str_replace('/','/thumbs/phoca_thumb_m_',$imageitem->filename);

$return .='<div style="text-align: center; float: left;">
		<a href="images/phocagallery/'.$imageitem->filename.'" class="modal"><img src="images/phocagallery/'.$per.'"
		border="0" title="'.$photoTitle.'" alt="'.$photoTitle.'" /></a></div></div>';




				}
			}
			else{
				$return .='<div>'.$hwTabNoPhotoMessage.'</div>';
			}	

// Add pictures NOT WORK!
//			if($user->id==$user_log->id) {
//			$return .= '<div style="width:100%;float:left;text-align:center;"><a href="/galerie/bilder" target="_blank" style="color:green">Add pictures<a></div>';
//			}
			$return .= '<div style="clear: both;"> </div>';
		}
		else{
			$return = "\t\t<div class=\"tab_Description\"> This plugin was not enabled.</div>";
		}
		return $return;
	}  
}  
?>
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49191
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: How to join PG and Community Builder?

Post by Jan »

Hi, thank you very much for this improvement.

Jan
If you find Phoca extensions useful, please support the project
Post Reply