Jump to content


Old Portal Plugin


  • You cannot reply to this topic
No replies to this topic

#1 Paul

    Member

  • Members
  • PipPip
  • 16 posts

Posted 28 July 2009 - 02:53 AM

First can i say a great big thankyou for this portal and the hard work put into it,

I used to use bfarber portal on my 2.3 board and have certain custom blocks, is there anyway of converting them?

This is a sample plugin that gives you a random images from the gallery (but only items that are pinned) useful if you just want to display certain images, any help would be great.

Thanks in advance

Paul

<?php
/*===================================================================
|--------------------------------------------------------------------
|
|	Pinned Picture image plugin
|	
|
|--------------------------------------------------------------------
===================================================================*/


class pinnedpicture {

	function auto_run() {

			$this->ipsclass->DB->query("SELECT * FROM ibf_gallery_albums RIGHT JOIN ibf_gallery_images ON ibf_gallery_albums.id=ibf_gallery_images.album_id WHERE pinned=1 ORDER BY RAND() LIMIT 0,1");
			if($this->ipsclass->DB->get_num_rows($query) <= 0) {
				return '';
			} else {
				$to_output = "";
				while ($row = $this->ipsclass->DB->fetch_row($query)) {
                                                                                $i_dir = str_replace("//","/","uploads/{$row['directory']}/");
					$to_output .=  "<b><font color='#800000'>{$row['last_name']}</font></b><br><br><b>{$row['caption']}</b><br>
<a href='{$ibforums->base_url}index.php?automodule=gallery&req=si&img={$row['id']}'><img  src='".$i_dir."{$row['masked_file_name']}' alt='{$row['caption']}' width='400'></a><br>
<i>{$row['description']}</i><br>
<br>
<b><a href='{$ibforums->base_url}index.php?automodule=gallery&req=si&img={$row['id']}'>Total Views: {$row['views']}</a> | <a href='{$ibforums->base_url}index.php?act=module&module=gallery&cmd=si&img={$row['id']}'>Total Comments {$row['comments']}</a></b>";




				}



			}

			$collapsed_ids = ','.$this->ipsclass->my_getcookie('collapseprefs').',';
		
			$final['DIV_FO'] = 'show';
			$final['DIV_FC'] = 'none';
			if ( strstr( $collapsed_ids, ',p_randomimg,' ) )
			{
				$final['DIV_FO'] = 'none';
				$final['DIV_FC'] = 'show';
			}
			$final['OUTPUT'] = $to_output;

			$html = $this->loaditup("pinnedpicture/pinnedpicture_template.html");
			$html = $this->parseit($html, $final);

			return $html;
	}


	function loaditup($filename) {

		$filename = ROOT_PATH."cfg/portal_plugins/".$filename;
	
		if ( file_exists($filename) ) {
			if ( $FH = fopen($filename, 'r') ) {
				$template = fread( $FH, filesize($filename) );
				fclose($FH);
			} else {
				echo("Couldn't open the template file");
				return '';
			}
		} else {
			echo("Template file does not exist");
			return '';
		}
	
		return $template;
	}

	function parseit($temp,$words=array()) {

		foreach( $words as $word => $replace)
		{
			$temp = preg_replace( "/\{$word\}/i", "$replace", $temp );
		}
		return $temp;
	}
}

?>






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users