<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GS Design &#187; Xoops</title>
	<atom:link href="http://www.gsdesign.ro/blog/category/web-aplications/open-source-aplications/xoops/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gsdesign.ro/blog</link>
	<description>Just another developer blog</description>
	<lastBuildDate>Thu, 06 Jan 2011 22:28:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to duplicate the SmartSection Module for XOOPS CMS.</title>
		<link>http://www.gsdesign.ro/blog/how-to-duplicate-the-smartsection-module-for-xoops-cms/</link>
		<comments>http://www.gsdesign.ro/blog/how-to-duplicate-the-smartsection-module-for-xoops-cms/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 17:05:43 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Open Source Aplications]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[Web Aplications]]></category>
		<category><![CDATA[Xoops]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/2007/10/04/lang_enhow-to-duplicate-the-smartsection-module-for-xoops-cmslang_enlang_rocum-sa-creati-un-nou-modul-smartsection-pentru-cms-ul-xoopslang_ro/langswitch_lang/en</guid>
		<description><![CDATA[A client gaved me a small task of creating 2 new sections for his website. The website is powered by the well-known CMS XOOPS. After looking at it i decided that the easy way out would be to duplicate one of the websites existing sections, and settled on the smart section. And because that gave [...]]]></description>
			<content:encoded><![CDATA[<p>A client gaved me a small task of creating 2 new sections for his website. The website is powered by the well-known CMS XOOPS. After looking at it i decided that the easy way out would be to duplicate one of the websites existing sections, and settled on the smart section. And because that gave a good run-a-round i thought i will post my solution on my blog, maybe others will benefit from it and save some time ( although others might think this is so obvious ).</p>
<p>First start by downloading SmartSection from http://smartfactory.ca/<br />
Decide on a name for the new section. For this example we will consider GSD Section as the name.</p>
<p>Next we must do a few find &amp; replaces in the files. To do that i used ReplaceEm wich you can download from http://www.orbit.org/replace/. This program let&#8217;s you do multiple find&amp;replace on multiple files at once, so you&#8217;re time alocated to this task should decrease dramaticly. The replacement you must do are :</p>
<blockquote><p> &#8216;smartsection&#8217;   =&gt; &#8216;gsdsection&#8217;<br />
&#8216;SMARTSECTION&#8217;  =&gt; &#8216;GSDSECTION&#8217;<br />
&#8216;SmartSection&#8217;  =&gt; &#8216;GsdSection&#8217;<br />
&#8216;Smart Section&#8217; =&gt; &#8216;Gsd Section&#8217;<br />
&#8216;SSECTION&#8217;      =&gt; &#8216;GSECTION&#8217;<br />
&#8216;Smartsection&#8217;  =&gt; &#8216;Gsdsection&#8217;</p></blockquote>
<p>Now you must also replace the folder name to gsdsection, and also all the template files that have smartsection in there file name. For example smartsection.css will become gsdsection.css.</p>
<p>Also we must replace the names of the mysql tables. So we will open the file /sql/mysql.sql and replace all the of: smartsection_  with the name of your module. In my case I would replace it with gsdsection_.</p>
<p>Once you have completed these steps, upload the duplicated folder (now your cloned module) and install it though the XOOPS Admin panel.</p>
<p><strong>[later_edit]</strong></p>
<p>After completing all this steps i have found an even easyer way <img src='http://www.gsdesign.ro/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
I found an already made script to duplicate smart section ( a little bit too late for me , but who knows &#8230; maybe not for others ).<br />
Make a file named clone.php and put in the root folder of you&#8217;re xoops powered website, also make sure there is a folder of the smartsection in the modules folder of the website.</p>
<p>Put the folowing code in the clone.php :</p>
<pre class="prettyprint">

// ##########################################################
//	Define your mapping here
// ##########################################################
$patterns = array(
// first one must be module directory name
'smartsection'  => 'mysection',
'SMARTSECTION'  => 'MYSECTION',
'SmartSection'  => 'MySection',
'Smart Section' => 'My Section',
'SSECTION'      => 'MSECTION',
'Smartsection'  => 'Mysection'
);

$patKeys = array_keys($patterns);
$patValues = array_values($patterns);

// work around for PHP < 5.0.x
if(!function_exists('file_put_contents')) {
  function file_put_contents($filename, $data, $file_append = false) {
    $fp = fopen($filename, (!$file_append ? 'w+' : 'a+'));
    if(!$fp) {
      trigger_error('file_put_contents cannot write in file.', E_USER_ERROR);
      return;
    }
    fputs($fp, $data);
    fclose($fp);
  }
}

// recursive clonning script
function cloneFileFolder($path)
{
  global $patKeys;
  global $patValues;

  $newPath = str_replace($patKeys[0], $patValues[0], $path);

  if (is_dir($path))
  {
    // create new dir
    mkdir($newPath);

    // check all files in dir, and process it
    if ($handle = opendir($path))
    {
      while ($file = readdir($handle))
      {
        if ($file != '.' &#038;&#038; $file != '..')
        {
          cloneFileFolder("$path/$file");
        }
      }
      closedir($handle);
    }
  }
  else
  {
    if(preg_match('/(.jpg|.gif|.png|.zip)$/i', $path))
    {
      copy($path, $newPath);
    }
    else
    {
      // file, read it
      $content = file_get_contents($path);
      $content = str_replace($patKeys, $patValues, $content);
      file_put_contents($newPath, $content);
    }
  }
}

cloneFileFolder('modules/news');

echo "Happy cloning...\n";
echo "check directory modules/" . $patterns['smartsection'] . " for cloned module \n";
echo "Consider modifying new module by editing language/english/modinfo.php and images/news_slogo.png manually (if you care)\n";

?></pre>
<p>Normaly change mysection with the desired name.</p>
<p>Cheers.</p>
<p>Awayting questions and comments <img src='http://www.gsdesign.ro/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/how-to-duplicate-the-smartsection-module-for-xoops-cms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

