Convert GPL Mambot to 1.5 plugin?

Discuss the development and implementation of Joomla! bots/Plugins here.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
User avatar
SineMacula
Joomla! Explorer
Joomla! Explorer
Posts: 453
Joined: Sun Aug 21, 2005 5:16 am
Location: San Jose, CA
Contact:

Convert GPL Mambot to 1.5 plugin?

Post by SineMacula » Thu Jul 19, 2007 7:53 pm

I'd really like to get the Tabs & Sliders plugin working for Joomla 1.5 - but I'm not sure where to start to convert the necessary files.

Are there any easy to figure out tutorials (as in, an untrained, self-taught, code-skills-limited coder could figure out) on this process?

Or, would someone be willing to help with this? I think it's just the php and xml file that would need converting, but as I say, I don't know what I'm doing.  :laugh:

Thanks!

PS. In case any kind soul wants to take a crack at this, here's the php:

Code: Select all

<?php
/*
// "Tabs & Slides In Content Items" Plugin for Joomla! 1.0.x - Version 2.2
// License: http://www.gnu.org/copyleft/gpl.html
// Authors: Fotis Evangelou - George Chouliaras
// Copyright (c) 2006-2007 JoomlaWorks.gr - http://www.joomlaworks.gr
// Project page at http://www.joomlaworks.gr - Demos at http://demo.joomlaworks.gr
// ***Last update: January 14th, 2007***
*/

/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

$_MAMBOTS->registerFunction( 'onPrepareContent', 'jwTabs' );

function jwTabs( $published, &$row, &$params, $page=0  ) {
  if (!$published) {
    if (preg_match_all("/{tab=.+?}/", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
     foreach ($matches[0] as $match) {
      $match = str_replace("{tab=", "", $match);
      $match = str_replace("}", "", $match);
      $row->text = str_replace( "{tab=".$match."}", "", $row->text );
      $row->text = str_replace( "{/tabs}", "", $row->text );
     }     
    }
    if (preg_match_all("/{slide=.+?}/", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
      foreach ($matches[0] as $match) {
        $match = str_replace("{slide=", "", $match);
        $match = str_replace("}", "", $match);
        $row->text = str_replace( "{slide=".$match."}", "", $row->text );
        $row->text = str_replace( "{/slide}", "", $row->text );
      } 
    }  	
    return;
  }

  global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_session_type, $mainframe, $database;
  static $jwTabsAdded, $tabid; 
  $query = "SELECT id FROM #__mambots WHERE element = 'plugin_jw_tabs_slides' AND folder = 'content'";
  $database->setQuery( $query );
  $id = $database->loadResult();
  $mambot = new mosMambot( $database );
  $mambot->load( $id );
  $param =& new mosParameters( $mambot->params );  
  
  $enable_tabs = $param->get('enable_tabs', 1);
  $enable_slides = $param->get('enable_slides', 1);
  $slides_slidespeed = $param->get('slides_slidespeed', '10');
  $slides_timer = $param->get('slides_timer', '10');

  $header = "";
  
  if(!$jwTabsAdded) {
	$jwTabsAdded=1;
		$header .= "
<!-- JW \"Tabs & Slides In Content Items\" Plugin (v2.2) starts here -->		
<style type=\"text/css\" media=\"screen\">
	@import \"$mosConfig_live_site/mambots/content/plugin_jw_tabs_slides/tabs_slides.css\";
</style>
<style type=\"text/css\" media=\"print\">.tabbernav {display:none;}</style>
<script type=\"text/javascript\" src=\"$mosConfig_live_site/mambots/content/plugin_jw_tabs_slides/tabs_slides.js\"></script>
<script type=\"text/javascript\">var jw_slideSpeed = ".$slides_slidespeed."; var jw_timer = ".$slides_timer.";</script>
<!-- JW \"Tabs & Slides In Content Items\" Plugin (v2.2) ends here -->	
";
		$mainframe->addCustomHeadTag($header);
   }  
  
  // Start Tabs Replacement
  // index.php
  if($enable_tabs) {
  if(strpos($_SERVER['PHP_SELF'], "index.php")) {
   $b=1;
   if (preg_match_all("/{tab=.+?}{tab=.+?}|{tab=.+?}|{\/tabs}/", $row->text, $matches, PREG_PATTERN_ORDER) > 0) { 	
    foreach ($matches[0] as $match) {	
      if($b==1 && $match!="{/tabs}") {
    	$tabs[] = 1;
    	$b=2;
      }
      elseif($match=="{/tabs}"){
      	$tabs[]=3;
      	$b=1;
      }
      elseif(preg_match("/{tab=.+?}{tab=.+?}/", $match)){
      	$tabs[]=2;
      	$tabs[]=1;
      	$b=2;
      }
      else {
      	$tabs[]=2;
      }
    }
   }
   @reset($tabs);
   $tabscount = 0;
  if (preg_match_all("/{tab=.+?}|{\/tabs}/", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
    foreach ($matches[0] as $match) {
      if($tabs[$tabscount]==1) {
      	$match = str_replace("{tab=", "", $match);
        $match = str_replace("}", "", $match);
        $row->text = str_replace( "{tab=".$match."}", "<div class=\"tabber\" id=\"tab".$tabid."\"><div class=\"tabbertab\" title=\"".$match."\"><h2><a name=\"advtab\">".$match."</a></h2>", $row->text );        
        $tabid++;
      } elseif($tabs[$tabscount]==2) {
      	$match = str_replace("{tab=", "", $match);
        $match = str_replace("}", "", $match);
      	$row->text = str_replace( "{tab=".$match."}", "</div><div class=\"tabbertab\" title=\"".$match."\"><h2><a name=\"advtab\">".$match."</a></h2>", $row->text );
      } elseif($tabs[$tabscount]==3) {
      	$row->text = str_replace( "{/tabs}", "</div></div>", $row->text );
      }
      $tabscount++;
    }     
  }    	
  // index2.php
  } else {
   if (preg_match_all("/{tab=.+?}/", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
    foreach ($matches[0] as $match) {
      $match = str_replace("{tab=", "", $match);
      $match = str_replace("}", "", $match);
      $row->text = str_replace( "{tab=".$match."}", "</div><div><h3>".$match."</h3>", $row->text );
      $row->text = str_replace( "{/tabs}", "", $row->text );
    }     
   }   	
  }
  }
  // End Tabs Replacement
  
  // Start Slides Replacement
  // index.php
  if($enable_slides) {
  if(strpos($_SERVER['PHP_SELF'], "index.php")) {
   if (preg_match_all("/{slide=.+?}/", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
    foreach ($matches[0] as $match) {
      $match = str_replace("{slide=", "", $match);
      $match = str_replace("}", "", $match);
      $row->text = str_replace( "{slide=".$match."}", "<div class=\"jw_slidetitle\" ><div class=\"jw_st_left\" ><div class=\"jw_st_cont\" >".$match."</div></div></div><div class=\"jw_slide\"><div>", $row->text );
      $row->text = str_replace( "{/slide}", "</div></div>", $row->text );
    }   
   }
  // index2.php 
  } else {
  if (preg_match_all("/{slide=.+?}/", $row->text, $matches, PREG_PATTERN_ORDER) > 0) {
    foreach ($matches[0] as $match) {
      $match = str_replace("{slide=", "", $match);
      $match = str_replace("}", "", $match);
      $row->text = str_replace( "{slide=".$match."}", "<h3> ".$match."</h3><div>", $row->text );
      $row->text = str_replace( "{/slide}", "</div>", $row->text );
    } 
   }  	
  }
  }
  // End Slides Replacement
}

?>
And the xml:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mosinstall type="mambot" group="content">
	<name>Tabs & Slides In Content Items</name>
	<author>Fotis Evangelou - George Chouliaras (JoomlaWorks)</author>
	<creationDate>14/01/2007</creationDate>	
	<copyright>This extension in released under the GNU/GPL License - http://www.gnu.org/copyleft/gpl.html</copyright>
	<authorEmail>joomlaworks@gmail.com</authorEmail>
	<authorUrl>http://www.joomlaworks.gr</authorUrl>
	<version>2.2</version>
	<description>
		<![CDATA[
<style type="text/css" media="all">
<!--
.extension_container {padding:0px 0px 4px 0px;}
.extension_container ul,
.extension_container ol {margin:4px 16px;padding:0px;}
.extension_container ul li,
.extension_container ol li {margin:2px 8px 2px 0px;padding:0px;}
h1 {clear:both;margin:0px 0px 12px 0px;padding:0px 0px 1px 0px;color:#C64934;font-size:17px;border-bottom:1px dotted #505050;}
h2 {clear:both;margin:4px 0px;padding:0px 0px 1px 0px;color:#444;font-size:13px;font-weight:bold;}
.title {margin:4px 0px;font-size:12px;font-weight:bold;}
.red {color:#C64934;}
.code {background:#eee;border:1px solid #ccc;margin:12px;padding:4px;}
-->
</style>
<div class="extension_container">
<h1><a target="_blank" title="Visit JoomlaWorks!" href="http://www.joomlaworks.gr">"Tabs & Slides In Content Items" Plugin v2.x (by JoomlaWorks.gr)</a></h1>
<a target="_blank" title="Visit the official project website!" href="http://www.joomlaworks.gr"><img style="float:right;background:#fff;border:1px solid #ccc;padding:2px;margin:0px 0px 2px 8px;" src="../mambots/content/plugin_jw_tabs_slides/logo.gif" border="0" alt="Logo" /></a> The "<b>Tabs & Slides In Content Items</b>" Plugin gives you the ability to easily add content tabs and/or content slides within standard Joomla! content items (articles). The tabs emulate a <b>multi-page structure</b>, while the slides emulate an <b>accordion-like structure</b>, inside a single page!<br />
<br />
So, no need for your visitor to scroll through a large page or navigate between pages to read a "big" article! <br />
<br />
See the "<b>Tabs & Slides In Content Items</b>" Plugin in action in our exclusive demo site <a target="_blank" title="Visit the official JoomlaWorks demo website!" href="http://demo.joomlaworks.gr">HERE</a>! <br />
<br />
<h1>USAGE INSTRUCTIONS</h1>
<h2>Inserting "Tabs"</h2>
It is very easy to add tabs in your new content items or convert existing ones to a tabbed layout. First activate the plugin from the Mambots menu option in the backend. Then go to the items manager and start a new content item or edit an existing one. Start your first tab using the plugin string "{tab=tab title here}" (without the quotes), write some text below that, then continue with the next tab using -again- the plugin string "{tab=other tab title here}" (without the quotes), then write the second tab's text and so on. When you finish the text of your last tab, simply "close" them by adding the plugin string "{/tabs}" (without the quotes).<br />
<br />
Check out this example, it's what you would write in your content item (notice the code written in bold letters):
<div class="code">This is some text above the tabs<br />
  <br />
  <b>{tab=first tab}</b><br />
  some text<br />
  here<br />
  <b>{tab=other tab}</b><br />
  some more text here<br />
  <b>{/tabs}</b><br />
  <br />
  And some more text after the tabs! </div>
<h2>Inserting "Slides"</h2>
Adding Slides to your content is as easy as with Tabs. Again you need to activate the plugin from the Mambots menu option in the backend. Then go to the items manager and start a new content item or edit an existing one. Start your first slide using the plugin string "{slide=slide title here}" (without the quotes), write some text below that, then "close" the slide by adding the plugin string "{/slide}". We need to do that cause -unlike the tabs- slides are independent of each other. Continue with the next slide using -again- the plugin string "{slide=other slide title here}" (without the quotes), then write the second slide's text, "close" it with the plugin string "{/slide}", and so on.<br />
<br />
Check out this example, it's what you would write in your content item (notice the code written in bold letters):
<div class="code">This is some text above the slides<br />
  <br />
  <b>{slide=My first slide in Joomla!}</b><br />
  some text<br />
  here<br />
  <b>{/slide}</b><br />
  <b>{slide=Joomla! is the best}</b><br />
  some more text here<br />
  <b>{/slide}</b><br />
  <br />
  And some more text after the slides! </div>
<h2>Inserting both "Tabs" and "Slides" in your content items</h2>
Additionally, you can mix tabs with slides in your content and vise versa. So you can have tabs that include content within slides or slides that include tabbed content! <br />
<br />
<h1>CUSTOMIZING THE LOOK OF THE TABS OR THE SLIDES</h1>
You can easily customize the way tabs and slides appear on the screen. All you need to do is modify the included CSS file (<b>tabs_slides.css</b>). We already did some generic customization, so that you can easily see what can be achieved. <br />
<br />
<h1>TROUBLESHOOTING</h1>
If you insert tabs or slides in your content items and see them <b>break apart</b> on your website, try this: Check the page source and see if you can find any <b>html tags</b> that are not "<b class="red">properly closed</b>" in your content, mainly any <b><p></b> tags. This might be a common issue when your content is not properly formatted -perhaps after copied from a Microsoft Word document- so the best thing when applying tabs/slides in your content is:
<ol>
  <li>Make sure your content is clean from any Word or other bad markup. Use Notepad as an intermediate clean up method when copy-pasting your documents to Joomla.</li>
  <li>Make sure that when you press "enter" in your content, the editor does not output a <b><p></b> tag, but a simple, plain, good ol' <b><br /></b> (break tag). In the editor's parameters, there is always such an option.</li>
  <li>Insert the "tabs" or "slides" plugin strings (mambot strings). If you still encounter layout inconsistencies or broken tabs or slides, then some html tag in your text is to blame for sure!</li>
</ol>
If for some reason you don't see the "tabs" or "slides" at all, although the plugin is published, <b class="red">make sure you have disabled Joomla! cache</b>. The cache is actually problematic only with the "Frontpage Component" (core component - com_frontpage), cause it fails to load code needed from some 3PD plugins in the HEAD tag of the template. If you don't use this plugin with com_frontpage, then you can enable Joomla! caching.
<br /><br />
<h1>CHANGELOG</h1>
Version 2.2 (released on January 14th, 2007)
<ul>
  <li>Major code shape up. We optimized the scripts' size and gathered all CSS code in one file only. This will help the customization a little more.</li>
  <li>Minor code fixes in the javascript code, extended compatibility with other scripts and minimized the possibility of conflict.</li>
  <li>Added "tab persistence", that means, if you reload the page, your content sticks to the tab you were on, before reloading the page.</li>
  <li>Both "tabs" or "slides" appear now faster on pageload (they don't appear when all content -including heavy images- is loaded, as they did before).</li>
</ul>
<br />
<h1>CREDITS</h1>
This plugin uses two of the finest JS scripts around to achieve the "tabs" and "slides" effect, but with some of JoomlaWorks tweakings, optimizations and of course, the styling!
<ul>
  <li><b>Tabber</b> (for tabs) by <b>Patrick Fitzgerald</b>. More at <a target="_blank" href="http://www.barelyfitz.com/projects/tabber/">http://www.barelyfitz.com/projects/tabber/</a>. License (http://www.opensource.org/licenses/mit-license.php). Copyright (c) 2006 Patrick Fitzgerald.</li>
  <li><b>Slides</b> script from <b>Alf Magne Kalleland</b>, www.jw.com. Available on <a target="_blank" href="http://www.dhtmlgoodies.com">DHTML Goodies</a>.</li>
</ul>
<br />
<h1>FOR INFO, UPDATES, REQUESTS & CONTACT</h1>
Check out <a target="_blank" title="Visit JoomlaWorks!" href="http://www.joomlaworks.gr">JoomlaWorks.gr</a>, the official website of this Joomla extension and home to other popular ones, like the <b>AllVideos Plugin</b>, the <b>AJAX Newsflash Module</b>, the <b>Ultimate PNG Fix Plugin</b> or the <b>Simple Image Gallery Plugin</b>.<br />
<br />
<a target="_blank" title="Visit JoomlaWorks!" href="http://www.joomlaworks.gr">JoomlaWorks.gr</a> is <u style="color:#C64934;font-weight:bold;">the</u> place to read interesting articles or find useful tips and tutorials for the Joomla! CMS and web design/development in general. At <a target="_blank" title="Visit JoomlaWorks!" href="http://www.joomlaworks.gr">JoomlaWorks.gr</a> you can always download the latest software updates as well as post comments, requests or even discuss the extension.<br />
<br />
<div class="star">Please show your support by rating or commenting on this extension at the official Joomla! Extensions website <a target="_blank" href="http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1046/Itemid,35/">HERE</a>.</div>
<b>Thank you for your support!</b><br />
<br />
<strong style="color:#C64934;">This extension is released under the GNU/GPL license.</strong><br />
<br />
<i>(Last update: January 14th, 2007 - version 2.2)</i><br />
<br />
</div>
		]]>
	</description>
	<files>
		<filename mambot="plugin_jw_tabs_slides">plugin_jw_tabs_slides.php</filename>
		<filename mambot="plugin_jw_tabs_slides">plugin_jw_tabs_slides/logo.gif</filename>
		<filename mambot="plugin_jw_tabs_slides">plugin_jw_tabs_slides/slide_bg_l.png</filename>
		<filename mambot="plugin_jw_tabs_slides">plugin_jw_tabs_slides/slide_bg_r.png</filename>
		<filename mambot="plugin_jw_tabs_slides">plugin_jw_tabs_slides/star.png</filename>
		<filename mambot="plugin_jw_tabs_slides">plugin_jw_tabs_slides/tab_bg.png</filename>
		<filename mambot="plugin_jw_tabs_slides">plugin_jw_tabs_slides/tabs_slides.css</filename>
		<filename mambot="plugin_jw_tabs_slides">plugin_jw_tabs_slides/tabs_slides.js</filename>		
	</files>
	<params>
		<param name="slides_slidespeed" type="text" default="10" label="Slide Speed" description="Higher value equals faster slide speed." />
		<param name="slides_timer" type="text" default="10" label="Slide Timer" description="Lower value equals faster slide time." />						
	</params>	
</mosinstall>

Locked

Return to “Plugins/Mambots”