Gallery G2Mod help requested.

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
stigerj

Gallery G2Mod help requested.

Post by stigerj »

I'm trying to get gallery working with CMSms.  I've installed Gallery 2.x in the /gallery directory in CMS and installed the full version of  abodb to /lib and changed the config.php.
I'm running CMS 1.1 Samoa.
I know this this is a total NEWBIE question but where does the G2Mod.module.php file need to be dropped? 
/lib/smarty/plugins ?
or /lib/modules under a new directory?

And then do I just create a page with {G2Mod}?


Thanks.

-Jeff

Code: Select all

<?php

/**
 * CMS Made Simple module for integrating Gallery 2
 * modified for use with CMSms 1.0.x by someone from forum
 * 
 * This code is licensed under the GPL
 * 
 * @author Alexander Bierbrauer
 * @version 0.1a
 *
 */
class G2Mod extends CMSModule
{
	var $g2data;
	
	function GetName()
	{
		return 'G2Mod';
	}

	function GetFriendlyName()
	{
		return 'G2Mod';
	}

	function IsPluginModule()
	{
		return true;
	}

	function HasAdmin()
	{
		return true;
	}

	function GetVersion()
	{
		return '0.1';
	}
	
	function GetAuthor()
	{
		return 'Alexander Bierbrauer';
	}

	function GetAuthorEmail()
	{
		return 'abierbrauer@gmx.org';
	}

	function GetAdminDescription()
	{
		return 'Gallery 2 CMS module';
	}
	
	function VisibleToAdminUser()
	{
		return true;
	}

	function SetParameters()
	{/*
		$this->CreateParameter('sortasc', 'true', $this->lang('helpsortasc'));
		$this->CreateParameter('sortby', 'news_date', $this->lang('helpsortby'));
		$this->CreateParameter('detailtemplate', 'sometemplate.tpl', $this->lang('helpdetailtemplate'));
		$this->CreateParameter('summarytemplate', 'sometemplate.tpl', $this->lang('helpsummarytemplate'));
		$this->CreateParameter('moretext', 'more...', $this->lang('helpmoretext'));
		$this->CreateParameter('category', 'category', $this->lang('helpcategory'));
		$this->CreateParameter('makerssbutton', 'true', $this->lang('helpmakerssbutton'));
		$this->CreateParameter('dateformat', '%b %d, %Y', $this->lang('helpdateformat'));
		$this->CreateParameter('number', '5', $this->lang('helpnumber'));
		$this->mCachable = false;*/
	}
	
	function openGallery2($page)
	{
		require_once(dirname(__FILE__) . $this->GetPreference('g2_embed_php'));
		
		$g2_relative = $this->GetPreference('g2_relative'); // '/../../../gallery2/'
		$g2_embedding = $this->GetPreference('g2_embedding'); // '/cms'
		
		// $log =& LoggerManager::getLogger('G2Mod.module.php');
		// $log->debug('openGallery2');
		
		$ret = GalleryEmbed::init(array('embedUri' => 'index.php?page='.$page, embedPath => $g2_embedding, 'relativeG2Path' => $g2_relative,
           								'loginRedirect' => null, 'activeUserId' => null));
		if($ret->isError())
		{
			$ret->getAsHtml();
			exit;
  		}

		$g2data = GalleryEmbed::handleRequest();
		if($g2data['isDone'])
		{
			// exit; // G2 has already sent output (redirect or binary data)
		}

  		// Use $g2data['headHtml'] and $g2data['bodyHtml']
  		// to display G2 content inside embedding application
  		// if you don't want to use $g2data['headHtml'] directly, you can get the css,
  		// javascript and page title separately by calling...
  		$this->g2data= $g2data;
  		
  		return true;
	}

	function Install()
	{
		// default paths if gallery 2 is the cms directory
		// /cms/gallery/...
		$this->SetPreference('g2_relative', '/../../gallery2');
		$this->SetPreference('g2_embedding', '');
		$this->SetPreference('g2_embed_php', '/../../gallery2/embed.php'); // '/../../../gallery2/embed.php'
	}

	function InstallPostMessage()
	{
		return $this->Lang('installation succesful');
	}

	function Upgrade($oldversion, $newversion)
	{
	}

	function Uninstall()
	{
		$this->RemovePreference('g2_relative');
		$this->RemovePreference('g2_embedding');
		$this->RemovePreference('g2_embed_php');
	}
	
	function showGallery()
	{ 
        if(isset($this->g2data))
			{
            if (isset($this->g2data['headHtml'])) {
                list($title, $css, $javascript) = GalleryEmbed::parseHead($this->g2data['headHtml']);
                print $css[0];
            }
            print $this->g2data['bodyHtml'];
			}
			elseif($this->openGallery2($this->cms->variables['page_id']))
         {
            if (isset($this->g2data['headHtml'])) {
                list($title, $css, $javascript) = GalleryEmbed::parseHead($this->g2data['headHtml']);
                print $css[0];
            }
            print $this->g2data['bodyHtml'];
			}
	}
	
	function showAdminSection(&$id)
	{
		#The tabs
		print $this->StartTabHeaders();
		print $this->SetTabHeader("paths","Gallery2 path settings");
		print $this->EndTabHeaders();
		
		#The content of the tabs
		print $this->StartTabContent();
		print $this->StartTab("paths");
		
		print $this->CreateFormStart($id, 'admin_updatepaths');
			print '<table';
			print '<tr><td>relative path:</td><td>'.$this->CreateInputText($id,'g2_relative',$this->GetPreference('g2_relative'),50).'</td></tr>';
			print '<tr><td>embedding path:</td><td>'.$this->CreateInputText($id,'g2_embedding',$this->GetPreference('g2_embedding'),50).'</td></tr>';
			print '<tr><td>relative path to embed.php:</td><td>'.$this->CreateInputText($id,'g2_embed_php',$this->GetPreference('g2_embed_php'),50).'</td></tr>';
			print '<tr><td colspan=2></td></tr>';
			print '<tr><td colspan=2>'.$this->CreateInputSubmit($id, 'submitbutton', 'OK').'</td></tr>';
			print '</table>';
		print $this->CreateFormEnd();
		print $this->EndTab();
	}
	
	function adminUpdatePaths(&$id,&$params)
	{
		$this->SetPreference('g2_relative', $params['g2_relative']);
		$this->SetPreference('g2_embedding', $params['g2_embedding']);
		$this->SetPreference('g2_embed_php', $params['g2_embed_php']);
		
		$this->showAdminSection($id);
	}

	function DoAction($action, $id, $params, $returnid = -1)
	{
		// $log =& LoggerManager::getLogger('G2Mod.module.php');
		// $log->debug('Starting DoAction');

		$db = $this->cms->db;
		switch ($action)
		{
			case "default":
			 	$this->showGallery();
				break;
			case 'defaultadmin':
				$this->showAdminSection($id);
				break;
			case 'admin_updatepaths':
				$this->adminUpdatePaths($id,$params);
				break;
		}
	}

    function FriendlyName()
	{
		return 'G2Mod';
	}

	function ModuleName()
	{
		return 'G2Mod';
	}

	function IsDefaultPossible()
	{
		return TRUE;
	}

	function GetChangeLog()
	{
		
	print '
		<ul>
		<li>
		<p>Version: 0.1</p>		
		<p>first offical release including administration for gallery 2 paths</p>
		</li>
		';
	}
	
	function GetHelp($lang='en_US')
	{
		return '
		<ul>
		<li>install Gallery 2 into your cms directory, e.g.: /cms/gallery2 and set it up</li>
		<li>install this module</li>
		<li>place the module tag in a page you want and are you are done !</li>
		<li>if you installed gallery 2 in another path, then you will have to change the paths in the module\'s admin section</li>
		<li>there\'s no need to edit files !</li>
		</ul>
		';
	}
}

?>
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: Gallery G2Mod help requested.

Post by Nullig »

The G2Mod directory, containing the G2Mod.module.php file, needs to be put in the modules directory. Then CMSMS will detect the module and let you install it.

Nullig
stigerj

Re: Gallery G2Mod help requested.

Post by stigerj »

Thanks Nullig.  That worked. 

How do I pass arguments to the module?  I created a page with {G2Mod} and it is blank... not sure what I am missing.

Thanks.

Nullig wrote: The G2Mod directory, containing the G2Mod.module.php file, needs to be put in the modules directory. Then CMSMS will detect the module and let you install it.

Nullig
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: Gallery G2Mod help requested.

Post by Nullig »

You may have to set up the correct paths in the admin portion of the module, if there is one. I've never used this mod, so I don't know how it's supposed to work... and it is a very old mod.

Nullig
47er

Re: Gallery G2Mod help requested.

Post by 47er »

Heyho, Did it work now?

I've the same problem, I can't integrate the Gallery2 into my CMSMS...
did you found a way?
Locked

Return to “[locked] Installation, Setup and Upgrade”