<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="Tiki CMS/Groupware via FeedCreator 1.7.2.1" -->
<?xml-stylesheet href="http://tikiexpert.com/lib/rss/rss-style.css" type="text/css"?>
<?xml-stylesheet href="http://tikiexpert.com/lib/rss/rss20.xsl" type="text/xsl"?>
<rss version="2.0">
    <channel>
        <title>Tiki RSS feed for the wiki pages</title>
        <description><![CDATA[Last modifications to the Wiki.]]></description>
        <link>http://tikiexpert.com/tiki-wiki_rss.php?ver=2</link>
        <lastBuildDate>Sun, 05 Sep 2010 08:10:39 +0100</lastBuildDate>
        <generator>Tiki CMS/Groupware via FeedCreator 1.7.2.1</generator>
        <image>
            <url>http://tikiexpert.com/img/tiki/tikilogo.png</url>
            <title>TikiExpert</title>
            <link>http://tikiexpert.com/tiki-index.php</link>
            <description><![CDATA[Feed provided by TikiExpert. Click to visit.]]></description>
        </image>
        <language>en-us</language>
        <item>
            <title>HomePage</title>
            <link>http://tikiexpert.com/tiki-index.php?page=HomePage</link>
            <description><![CDATA[<style TYPE="text/css"> .diffchar { color:red; } </style>- Here are some TikiWiki <a class="wiki"  href="tiki-list_file_gallery.php" rel="">goodies</a><br />+ Here are some TikiWiki <a class="wiki"  href="tiki-list_file_gallery.php<span class="diffchar">?galleryId=1</span>" rel="">goodies</a><br />]]></description>
            <pubDate>Wed, 08 Jul 2009 17:47:09 +0100</pubDate>
        </item>
        <item>
            <title>Hello World</title>
            <link>http://tikiexpert.com/tiki-index.php?page=Hello+World</link>
            <description><![CDATA[<style TYPE="text/css"> .diffchar { color:red; } </style>+ <div class="titlebar">'Hello World' Tutorial for TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> Developers</div>+ <span id='toc'><div id='toctitle'><h3>Table of contents</h3></div><ul class="toc"><ul><li><a href='#Introduction' class='link'>Introduction</a>+ </li><li><a href='#Glossary' class='link'>Glossary</a>+ </li><li><a href='#Who_does_what_' class='link'>Who does what?</a>+ </li><li><a href='#Smarty_PHP' class='link'> Smarty/PHP</a>+ </li><li><a href='#The_Hello_World_page' class='link'> The 'Hello World' page</a>+ </li><li><a href='#tiki_setup.php' class='link'> tiki-setup.php</a>+ </li><li><a href='#How_to_debug_and_to_see_the_smarty_variables' class='link'> How to debug and to see the smarty variables</a>+ </li><li><a href='#To_execute_some_queries_in_the_php' class='link'> To execute some queries in the php</a>+ </li><li><a href='#To_introduce_a_new_feature_or_a_new_preference' class='link'> To introduce a new feature or a new preference</a>+ </li><li><a href='#To_update_the_database_schema' class='link'>To update the database schema</a>+ </li><li><a href='#To_get_set_a_user_preference' class='link'> To get/set a user preference</a>+ </li><li><a href='#To_create_a_menu_or_to_introduce_a_menu_option' class='link'> To create a menu or to introduce a menu option</a>+ </li><li><a href='#Menu_created_by_sql' class='link'> Menu created by sql</a>+ <ul><li><a href='#Menu_created_with_the_TikiWiki_API' class='link'> Menu created with the TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> API</a>+ </li></ul></li><li><a href='#Menu_created_with_a_smarty_template' class='link'> Menu created with a smarty template</a>+ </li><li><a href='#To_introduce_a_new_permission' class='link'> To introduce a new permission</a>+ </li><li><a href='#To_check_a_permission' class='link'> To check a permission</a>+ </li><li><a href='#To_wiki_parse_a_textarea' class='link'> To wiki parse a textarea</a>+ </li></ul></ul>+ </span><br />+ <br />+ <h2 class="showhide_heading" id="Introduction">Introduction</h2>+ <br />+ <br />+ <h2 class="showhide_heading" id="Glossary">Glossary</h2>+ Things are sometimes named a bit differently than in other Web Applications. Please see:<br />+ <a target="_blank" class="wiki"  href="http://tikiwiki.org/Glossary">http://tikiwiki.org/Glossary</a><br />+ <br />+ <h2 class="showhide_heading" id="Who_does_what_">Who does what?</h2>+ TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> CMS/Groupware is a vast project. It's tricky for new people to know how the TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> Community is organized, to find the right person to contact and to start to contribute. What may I expect from others within TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> Community, and what do others expect from me? Who does what? Who should I talk to? How does it work? This page is intended to help.<br />+ <br />+ Important: everyone is a volunteer. Things get done because someone, <b>like you</b> decides to take the time to make it better.<br />+ <br />+ Please see:<br />+ <a target="_blank" class="wiki"  href="http://tikiwiki.org/WhoWhat">http://tikiwiki.org/WhoWhat</a><br />+ <br />+ <h2 class="showhide_heading" id="Smarty_PHP"> Smarty/PHP</h2>+ TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> uses the <a class="wiki external" target="_blank" href="http://smarty.php.net" rel="external">Smarty template engine</a>. Its purpose is to separate the presentation layer from the programming layer.<br />+ The <a class="wiki external" target="_blank" href="http://php.net" rel="external">PHP</a> interfaces with the database, does the computation…and assigns the Smarty variables. The Smarty templates use these variables to generate the actual HTML.<br />+ <br />+ For instance:<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">&lt;?php // Smarty use sample+ $user='admin';+ $smarty-&gt;assign('user', $user);+ ?&gt;</pre><br />+ This PHP assigns the Smarty variable <i>$user</i>.<br />+ This variable will be used in a template like that<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">&lt;h1&gt;{$user}&lt;/h1&gt;</pre><br />+ This will display<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">&lt;h1&gt;admin&lt;/h1&gt;</pre><br />+ <br />+ In a Smarty template, you can loop over array of data and do some simple computation. To preserve separation and optimization, no PHP code must be inserted in a template.<br />+ <br />+ <h2 class="showhide_heading" id="The_Hello_World_page"> The 'Hello World' page</h2>+ How to display &quot;hello world&quot; in the central column of a TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> page:<br />+ <br />+ Create a php file in the TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> root directory (where <i>tiki-install.php</i> is).<br />+ <i>hello_world.php</i>:<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">&lt;?php // hello_world displayed in a TikiWiki center column+ include_once('tiki-setup.php');+ $smarty-&gt;assign('mid', 'hello_world.tpl');+ $smarty-&gt;display('tiki.tpl');+ ?&gt;</pre><br />+ Create a template located in the sub directory <i>templates/</i> (http://www.domain.com/templates/) or in <i>templates/styles/your_style/</i><br />+ <i>hello_world.tpl</i>:<br />+ <br /><pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">&lt;p&gt;Hello World&lt;/p&gt;</pre><br />+ <br />+ To test it, type the URL in your browser : <a target="_blank" class="wiki"  href="http://my.domain.com/hello_world.php">http://my.domain.com/hello_world.php</a> (where <a target="_blank" class="wiki"  href="http://my.domain.com">http://my.domain.com</a> links to your TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> root).<br />+ <br />+ <br />+ Notice the use of <i>include_once(‘tiki-setup.php’)</i> in the php code. This include initializes the context to be able to use smarty. Later we will see it is doing more.<br />+ <i>tiki.tpl</i> is the TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> global template file. It is the only(almost) template that contains a complete html page. A simplified working <i>tiki.tpl</i> file would be:<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">{* top *}+ {include file=&quot;header.tpl&quot;}+ {* middle *}+ &lt;table&gt;+    &lt;tr&gt;+       &lt;td&gt; {* left column *}+          {section name=ix loop=$left_modules}+             {$left_modules[ix].data}+          {/section}+       &lt;/td&gt;+       &lt;td&gt; {* middle column *}+             {include file=$mid} +       &lt;/td&gt;+       &lt;td&gt; {* right column *}+         {section name=ix loop=$right_modules}+               {$right_modules[ix].data}+         {/section}+       &lt;/td&gt;+    &lt;/tr&gt;+ &lt;/table&gt;+ {* bottom*}+ {include file=&quot;footer.tpl&quot;}</pre><br />+ You can see the top section <i>header.tpl</i>, the bottom section <i>footer.tpl</i> and the 3 columns. The left column displays all the left modules through a loop. Idem for the right column. The central part is an include of the <i>$mid</i> file. (Notice: in TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> 1.10, it is simply {$mid} and not <b>missing page for plugin INCLUDE</b><br />)<br />+ In our hello_world example, the $mid part is the template <i>hello_world.tpl</i> and will display the string “hello world”.<br />+ <br />+ The templates <i>hello_world.tpl</i> can be created in the sub-directory <i>templates/</i> or the sub-directory <i>templates/styles/your_style/</i> (where your_style is the name of the theme you are currently using (A theme name is the css file name without extension). If it exists, the template in your current theme directory overrides the one in the default directory. The avantage of putting your templates in your local theme directory is to better identify what you have changed from the original TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a>. (Notice: if you are using CVS and are handy with cvs conflict resolution, it may be better to directly modify the templates in the default directory to be able to update/merge the tikwiki modification with yours)<br />+ <br />+ The <i>$left_modules</i> and <i>$right_modules</i> smarty variables are set up in tiki-modules.php. You will see later in the module section how the modules are set.<br />+ <br />+ <h2 class="showhide_heading" id="tiki_setup.php"> tiki-setup.php</h2>+ <br />+ This include does everything you need to have a TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> page. It does a lot more that initializing smarty. By including this file in your php, you:<br />+ <ul><li>establish the connection with the database.+ </li><li>read all the system preferences, user preferences, permissions from the database.+ </li><li>check if the user is logged via a cookie.+ </li><li>computes all the modules (in TikiWiki1<a href="tiki-editpage.php?page=TikiWiki1" title="Create page: TikiWiki1" class="wiki wikinew">?</a>.9). In TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> 1.10 this is done in $smarty-&gt;display+ </li><li>check up for some security points+ </li><li>…+ </li></ul>+ <br />+ A couple of interesting variables are also set there<br />+ <ul><li>user (user login)+ </li><li>group (default group name)+ </li><li>language+ </li><li>all preferences+ </li><li>….+ </li></ul>+ All these variables are set for php and for smarty.<br />+ <br />+ To see your username in the hello world program, modify your template:<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">&lt;p&gt;Hello World, Dear {$user}&lt;/p&gt;</pre><br />+ <br />+ <h2 class="showhide_heading" id="How_to_debug_and_to_see_the_smarty_variables"> How to debug and to see the smarty variables</h2>+ <tt> If you want to see all the smarty variables that are set, you can use the smarty function {debug} in your templates. Smarty will display a popup window.</tt><br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">{debug}+ &lt;p&gt;Hello World&lt;/p&gt;</pre><br />+ <br />+ <br />+ You can also use the php function echo or print_r to see some php variable for debugging.<br />+ And you can use the function debug_backtrace to see the php trace.<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">&lt;?php + function test() {+    echo &quot;&lt;pre&gt;&quot;;+    print_r(debug_backtrace());+    echo &quot;&lt;/pre&gt;&quot;;+ }+ include_once('tiki-setup.php');+ echo &quot;&lt;pre&gt;user:$user&lt;/pre&gt;&quot;;+ test();+ $smarty-&gt;assign('mid', 'hello_world.tpl');+ $smarty-&gt;display('tiki.tpl');</pre><br />+ <br />+ <h2 class="showhide_heading" id="To_execute_some_queries_in_the_php"> To execute some queries in the php</h2>+ TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> uses the <a class="wiki external" target="_blank" href="http://adodb.sourceforge.net/" rel="external">ADODB</a> database abstraction library. A good description about how to code the queries can be found at <a target="_blank" class="wiki"  href="http://TikiWiki.org/tiki-index.php?page=DbAbstractionDev">http://TikiWiki.org/tiki-index.php?page=DbAbstractionDev</a><br />+ <br />+ A typical list routine without permission check.<br />+ In <i>lib/contribution/contributionlib.php</i><br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">// List a subset of contribution+ // $offset = will return the objects from there to $offset + $maxRecords (if 0 = from the beginning)	+ // $maxRecords = max number to return if = -1 returns all the objects+ // $sort_mode = order criterium+ // $find = string to search+ function list_contributions($offset=0, $maxRecords=-1, $sort_mode='name_asc', $find='') {+ 	$bindvars = array();+ 	$mid = '';+ 	if ($find) {+ 		$mid .= &quot; where (`name` like ?)&quot;;+ 		$bindvars[] = &quot;%$find%&quot;;+ 	} + 	$query = &quot;select * from `tiki_contributions` $mid order by &quot;.$this-&gt;convert_sortmode($sort_mode);+ 	$result = $this-&gt;query($query, $bindvars, $maxRecords, $offset);+ + 	$ret = array();+ 	while ($res = $result-&gt;fetchRow()) {+ 		$ret[] = $res;+ 	}+ 	$retval = array();+ 	$retval['data'] = $ret;+ 	if ($maxRecords &gt; 0) {+ 		$query_cant = &quot;select count(*) from `tiki_contributions` $mid&quot;;+ 		$retval['cant'] = $this-&gt;getOne($query_cant, $bindvars);+ 	} else {+ 		$retval['cant'] = count($ret);+ 	}+ 	return $retval;		+ }</pre><br />+ First, you have to notice that all table names and column names must be back quoted.<br />+ The <i>$sort_mode</i> is the concatenation of the column name, the underscore and asc or desc. It can be any column.<br />+ <br />+ In the main php, <i>tiki-contribution.php</i>, you will have<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">include_once('lib/contribution/contributionlib.php');+ $contributions = $contributionlib-&gt;list_contributions();+ $smarty-&gt;assign('contributions', $contributions['data']);</pre><br />+ <br />+ and in the template <i>templates/tiki-contribution.tpl</i>, you will have<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">{cycle values=&quot;even,odd&quot; print=false}+ {section name=ix loop=$contributions}+ &lt;tr&gt;+ 	&lt;td class=&quot;{cycle advance=false}&quot;&gt;{$contributions[&quot;ix&quot;].name|escape}&lt;/td&gt;+ 	&lt;td class=&quot;{cycle}&quot;&gt;{$contributions[&quot;ix&quot;].hits}&lt;/td&gt;+ &lt;/tr&gt;+ {/section}</pre><br />+ <br />+ Notice: There is not yet good method to check the perms in this kind of routine. You have to get all the objects and checked them.<br />+ <br />+ <h2 class="showhide_heading" id="To_introduce_a_new_feature_or_a_new_preference"> To introduce a new feature or a new preference</h2>+ In 2.0 lib/setup/prefs.php has been introduced. Add your preference to this file, no database hacking is necessary. For pre-2.0 times and other (fundamental) DB changes the procedure below is still valid.<br />+ <br />+ For instance, you want to create a new feature called contribution<br />+ First you have to create an entry in the database<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">INSERT IGNORE INTO tiki_preferences(name,value) VALUES ('feature_contribution', 'n');</pre><br />+ Each database update must be done in db/tiki.sql and db/tiki_1.xto1_y.sql. The first sql does the complete database creation, the second is the upgrade script. The second one can be rerun as many times as needed ((with the mysqldump option –f to ignore error).. The update of each script for each database supported by TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> is done by the script db/convertscripts/convertsqls.sh (Available in 1.10). So each time you have to update the database scheme, you have to modify 2 files and run a script.<br />+ The script can be run by<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">cd db/convertscripts+ ./convertsqls.sh &lt;virtualhost/root&gt;</pre><br />+ virtualhost/root can be localhost/tiki1.9 for instance<br />+ <br />+ After you have to insert the check box into the features administration page.<br />+ In templates/tiki-admin-include-features.tpl, you have to insert these lines :<br />+ In TikiWiki1<a href="tiki-editpage.php?page=TikiWiki1" title="Create page: TikiWiki1" class="wiki wikinew">?</a>.10<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">&lt;tr&gt;+    &lt;td&gt;+ &lt;input type=&quot;checkbox&quot; name=&quot;feature_contribution&quot;{if $prefs.feature_contribution eq 'y'} checked=&quot;checked&quot;{/if}/&gt;+    &lt;/td&gt;+    &lt;td class=&quot;form&quot;&gt;+ {if $prefs.feature_help eq 'y'}&lt;a href=&quot;{$prefs.helpurl}Contribution&quot; target=&quot;tikihelp&quot; class=&quot;tikihelp&quot; title=&quot;{tr}Contribution{/tr}&quot;&gt;{/if}+ {tr}Contribution{/tr}+ {if $prefs.feature_help eq 'y'}&lt;/a&gt;{/if}+    &lt;/td&gt;+    &lt;td colspan=&quot;3&quot;&gt; &lt;/td&gt;+ &lt;/tr&gt;</pre><br />+ In TikiWiki1<a href="tiki-editpage.php?page=TikiWiki1" title="Create page: TikiWiki1" class="wiki wikinew">?</a>.9<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">&lt;tr&gt;+    &lt;td&gt;+ &lt;input type=&quot;checkbox&quot; name=&quot;feature_contribution&quot;{if $feature_contribution eq 'y'} checked=&quot;checked&quot;{/if}/&gt;+    &lt;/td&gt;+    &lt;td class=&quot;form&quot;&gt;+ {if $feature_help eq 'y'}&lt;a href=&quot;{$helpurl}Contribution&quot; target=&quot;tikihelp&quot; class=&quot;tikihelp&quot; title=&quot;{tr}Contribution{/tr}&quot;&gt;{/if}+ {tr}Contribution{/tr}+ {if $feature_help eq 'y'}&lt;/a&gt;{/if}+    &lt;/td&gt;+    &lt;td colspan=&quot;3&quot;&gt; &lt;/td&gt;+ &lt;/tr&gt;</pre><br />+ just before these lines if you want it in the first table.<br />+ <br />+ <br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">&lt;/table&gt;+ {* ---------- Administration features ------------ *}</pre><br />+ <br />+ In tiki-admin_include_features.php, you have to insert the line &quot;feature_contribution&quot;,<br />+ in the $features_toggles table definition<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">$features_toggles = array(+ &quot;feature_contribution&quot;,+ ….+ );+ foreach ($features_toggles as $toggle) {+  	simple_set_toggle ($toggle);+  }</pre><br />+ The loop on features_toggles will to the wanted step:<br />+ -	update the database<br />+ -	update the smarty variable and the php variable<br />+ Notice: Not all the admin pages are using simple_set_toggle ($toggle);even if it is the best practice.<br />+ <br />+ You have nothing else to do, tiki-setup.php will automatically read and assign the php variable and the smarty variable $prefs in TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> 1.10 (so you can use $prefs.feature_contribution) or $feature_contribution in TikiWiki1<a href="tiki-editpage.php?page=TikiWiki1" title="Create page: TikiWiki1" class="wiki wikinew">?</a>.9 in any TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> page.<br />+ <br />+ Feature and preference are set the same way.<br />+ <br />+ You can have the list of features/preferences in the sql table tiki_preferences.<br />+ Notice: all the preferences are not necessarily there. Some old preferences have not been set in this table and are test through isset($this_preference).This is bad habit: it is better to always include your preference as described previously in the database and not to test if it is set with the isset function<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">INSERT IGNORE INTO tiki_preferences(name,value) VALUES ('my_preference', 'my_value');</pre><br />+ <br />+ <h2 class="showhide_heading" id="To_update_the_database_schema">To update the database schema</h2>+ DatabaseSchemaUpgrade<a href="tiki-editpage.php?page=DatabaseSchemaUpgrade" title="Create page: DatabaseSchemaUpgrade" class="wiki wikinew">?</a><br />+ <h2 class="showhide_heading" id="To_get_set_a_user_preference"> To get/set a user preference</h2>+ To get the value of a user preference, you can use in a function :<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">global $tikilib, $someuser;+ $foo = $tikilib-&gt;get_user_preference($someuser, $pref_name, $default_pref_value);</pre><br />+ $someuser is the user name.<br />+ $pref_name can be ‘theme’, ‘allowMsgs’…<br />+ The default for $default_pref_value is ‘’<br />+ The effect of the above code is to populate the global array variable $user_preferences<a class="wiki"  href="someuser" rel="">someuser</a>, which is also returned in the variable foo.<br />+ Notice: “global $tikilib, $someuser;” is not necessary if you add these lines in the same file that the include tiki-setup.php (the hello_world.php) but are needed in you add these lines in a function.<br />+ Notice: To access the prefs of the current user (user), it is not necessary to use the above. These are always available as variables. In version 1.10, they are available in the $prefs array.<br />+ <br />+ To set a user preference<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">global $tikilib, $someuser;+ $tikilib-&gt;set_user_preference($someuser, $pref_name, $pref_value);</pre><br />+ <br />+ Notice: we don’t include lib/tikilib.php because it is always included in tiki-setup.php. Meanwhile, the other libraries must be included like this:<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">global $categlib; include_once('lib/categories/categlib.php');</pre><br />+ Notice the use of global. Global is necessary because your library can have been included in another function that is out of scope of your new function.<br />+ <br />+ You can have a list of user preferences in the sql table tiki_user_preferences. Same remark than for tiki_preferences, the list can be incomplete.<br />+ <br />+ <h2 class="showhide_heading" id="To_create_a_menu_or_to_introduce_a_menu_option"> To create a menu or to introduce a menu option</h2>+ TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> has a couple of ways to introduce menus<br />+ -	one by creating the menu and the menu options through sql  (1)<br />+ -	one by using the tiki API (2)<br />+ -	one by using the templating / module feature (3)<br />+ -	one based on phplayers (4)<br />+ <br />+ There is not really a best method to create a menu. It depends. If your menu can be dynamically updated, you will not use the template. If your menu is fixed, perhaps a template is the best.<br />+ The phplayers method is not described here as there is no current API. (phplayers menu are interesting because they can have more than 2 levels (Means an option in an option in a section)<br />+ <h2 class="showhide_heading" id="Menu_created_by_sql"> Menu created by sql</h2>+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">INSERT INTO tiki_menus (menuId,name,description,type) VALUES ('100', ‘My menu','My very own  menu','d');+ INSERT INTO tiki_menu_options (menuId,type,name,url,position,section,perm,groupname) VALUES (‘100’,'o','My option','tiki-my_option.php',10,'','','');+ INSERT INTO tiki_menu_options (menuId,type,name,url,position,section,perm,groupname) VALUES (‘100’,'o','My other option','tiki-my_other_option.php',15,'','','');</pre><br />+ A menu affects 2 tables. One for the menu by itself, and the other one for the menu options. In the previous example, we created a menu ‘My menu’ with 2 options.<br />+ A menu type can be<br />+ - d (dynamic collapsed)<br />+ - e (dynamic extended)<br />+ - f (fixed)<br />+ an option type can be:<br />+ - s (section)<br />+ - r (sorted section)<br />+ - o (option)<br />+ - - (separator)<br />+ <br />+ The section parameter corresponds the feature. If the feature is not activated, the option will not show up.<br />+ The groupname parameter is a filter on the group.<br />+ <br />+ Notice: the menuId 42 is reserved for the application menu (the default TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> menu).<br />+ Trick: we usually don’t give consecutive number to menu options to be able later  to add additional options easier.<br />+ If an option can be see with 2 perms, you need to add 2 options with the same position and different perm. Idem if it can be see in 2 sections or 2 groups.<br />+ Some documentation can be found at <a target="_blank" class="wiki"  href="http://doc.TikiWiki.org/tiki-index.php?page=Custom+Menus.">http://doc.TikiWiki.org/tiki-index.php?page=Custom+Menus.</a><br />+ Notice: there is some bugs about the expand/collapse javascript in tw1.9.2.<br />+ <br />+ To insert this menu in a column, you need to create a user menu that uses it (admin-&gt;modules-&gt;create a new user menu) and then assign this user menu (admin-&gt;modules-&gt;assign new module)<br />+ <br />+ <h3 class="showhide_heading" id="Menu_created_with_the_TikiWiki_API"> Menu created with the TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> API</h3>+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">global $menulib; include_once(‘lib/menubuilder/menulib.php’);+ $menulib-&gt;replace_menu($menuId, $name, $description, $type);+ foreach (… optionmenu…) {+ $menulib-&gt;replace_menu_option($menuId, $optionId, $name, $url, $type, $position, $section, $perm, $groupname);+ }</pre><br />+ The parameter values are the same than described previously.<br />+ Notice: you can notice the use of global $menulib. This is very useful when you use this part of code in a function. The include can have been done somewhere else, and the global gives you the opportunity to catch the variable $menulib.<br />+ <br />+ If you don’t know the $menuId you want to use, you need to<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">$menulib-&gt;replace_menu(0, $name, $description, $type);+ $query = 'select max(`menuId`) from `tiki_menus`';+ $menuId = $tikilib-&gt;getOne($query);+ foreach (… optionmenu…) {+    $menulib-&gt;replace_menu_option($menuId, $optionId, $name, $url, $type, $position, $section, $perm, $groupname);+ }</pre><br />+ <br />+ Next, you have to create a user menu and assign it<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">global $modlib; include_once ('lib/modules/modlib.php');+ $modlib-&gt;replace_user_module($name, $title, &quot;{menu id=$menuId}&quot;);+ $modlib-&gt;assign_module($name, $title, $position, $order, 0, $rows , serialize($groups), $params, $type);</pre><br />+ $position is ‘l’ (left column) or ‘r’ (right column)<br />+ If you assign 2 modules with the same order in the same column, they will appear both in a random order.<br />+ $groups is an array of groups (ex: array(&quot;Registered&quot;, &quot;Anonymous&quot;))<br />+ $params is the value you put in the param field in admin-&gt;modules-&gt;assign module. (ex: “max=10”)<br />+ $type is ‘D’ to assign to everybody.<br />+ <h2 class="showhide_heading" id="Menu_created_with_a_smarty_template"> Menu created with a smarty template</h2>+ You can also create a menu with a template module. A good example is templates/modules/mod-application_menu.tpl. This menu is the old tikwiki menu that has been replaced by a database menu to be able to use the mods.<br />+ <br />+ You only need to create a new template in templates/modules/ with a filename beginning with mod-. This new module will automatically appear in the admin-&gt;modules scrolling list.<br />+ <br />+ <h2 class="showhide_heading" id="To_introduce_a_new_permission"> To introduce a new permission</h2>+ If you want to create a new permission, you need to add it in the database like this:<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">INSERT INTO users_permissions (permName, permDesc, level, type) +     VALUES ('tiki_p_whatever', 'Perm definition', 'level', 'feature');</pre><br />+ This must be added in db/tiki.sql and db/tiki_1.xto1.y.sql.<br />+ Where level can be editors, registered, admin … and feature is the group of perms (wiki, cms, blog..)<br />+ You can create a new group of perms there. There is no other requirement for a group of perms.<br />+ The perm will be read and set to a php variable and a smarty variable in tiki-setup.php<br />+ <br />+ In a php, the perm is used like this:<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">if ($tiki_p_whatever == 'y')</pre><br />+ Don’t forget to compare to a value a current error is to write only<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">if ($tiki_p_whatever)//wrong code</pre><br />+ <tt> We usually name a perm with a name beginning by  tiki_p_</tt><br />+ <br />+ <h2 class="showhide_heading" id="To_check_a_permission"> To check a permission</h2>+ All permissions can be overwritten at a category or object level. The rule to check if you have the tiki_p_perm on an object is:<br />+ -	check if the object has special perm. If yes, test if one of the group user has the perm tiki_p_perm otherwise returns false.<br />+ -	check if the object has a category with special perm. If yes, test if one of the group user has the perm tiki_p_perm otherwise returns false.<br />+ -	if none above, use the tiki_p_perm value<br />+ <br />+ A function is dedicated to do the job<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">include_once('tiki-setup.php');+ include_once('lib/tikilib.php');+ $perm = $tikilib-&gt;user_has_perm_on_object($user, $object_id, $object_type, $tiki_p_perm);</pre><br />+ where user is the login name, $object_id is the object id (can be the page name or the article_id or …), $object_type is the object type (can be ‘wiki page’, ‘article’….). You can use an array of perms instead of tiki_p_perm if needed.<br />+ <br />+ Example<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">if (!$tikilib-&gt;user_has_perm_on_object($user, $pageName, 'wiki_page', 'tiki_p_view') {+ 	$smarty-&gt;assign('msg', tra('Permission denied you cannot read this page'));+ 	$smarty-&gt;display('error.tpl');+ 	die;+ }</pre><br />+ <br />+ Example<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">if (!$tikilib-&gt;user_has_perm_on_object($user, $quiz_id, 'quiz', array('tiki_p_take_quiz','tiki_p_view_quiz_stats')){+ 	$smarty-&gt;assign('msg', tra('Permission denied you cannot access this quiz'));+ 	$smarty-&gt;display('error.tpl');+ 	die;+ }</pre><br />+ <br />+ Notice: This function is very convenient but it is quite a bit slow even if there are a couple of cache to optimize it. There is only one example in the TikiWiki<a href="tiki-editpage.php?page=TikiWiki" title="Create page: TikiWiki" class="wiki wikinew">?</a> code that integrates the perm checking in the sql query.<br />+ <br />+ To reassign all the permissions a user has on an object<br />+ There is actually no integrated function to do the job. This snippet reassigns the perm variables.<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">global $userlib; include_once('lib/userslib.php');+ + global $feature_categories;+ if ($userlib-&gt;object_has_one_permission($objectId, $objectType)) {+ 	$perms = $userlib-&gt;get_permissions(0, -1, 'permName_desc', '', $objectType);+ 	foreach ($perms['data'] as $perm) {+ 		$permName = $perm[&quot;permName&quot;];+ 		if ($userlib-&gt;object_has_permission($user, $objectId, $objectType, $permName)) {+ 			$permName = 'y';+ 		} else {+ 			$permName = 'n';+ 		}+ 	}+ } elseif ($feature_categories == ‘y’) {+ 	global $categlib; include_once('lib/categories/categlib.php');+ $perms_array = $categlib-&gt;get_object_categories_perms($user, $objectType, $objectId); +    	if ($perms_array) {+     		foreach ($perms_array as $permName =&gt; $value) {+     			$permName = $value;+ 		}+     	}+   }</pre><br />+ $objectId is the object identifier: Ex: the page name for a wiki page, the article_id for an article.<br />+ $ObjectType is one of  ‘wiki page’, ‘article’, ‘forum’, ‘post’, ‘blog’, ‘faq’, ‘image gallery’, ‘file gallery’, ‘comment’, ‘tracker’, ‘survey’, ‘quiz’ …<br />+ <br />+ <h2 class="showhide_heading" id="To_wiki_parse_a_textarea"> To wiki parse a textarea</h2>+ Imagine you have a textarea and you want this textarea to accept wiki format.<br />+ To parse the textarea, you will have to call<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">$tikilib-&gt;parse_data($text)+ Usually if you have a choice like “it is html”, you need to add an additional parameter+ $tikilib-&gt;parse($test, $is_html)</pre><br />+ PS: some tikwiki1.9 have bugs around the is_html parameter. There are patched by replacing $test with  htmlspecialchars($test);<br />+ <br />+ If you want to add some quicktags to the textarea<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">include_once ('lib/quicktags/quicktagslib.php');+ $quicktags = $quicktagslib-&gt;list_quicktags(0,-1,'taglabel_desc','','wiki');+ $smarty-&gt;assign_by_ref('quicktags', $quicktags[&quot;data&quot;]);+ $smarty-&gt;assign('quicktagscant', $quicktags[&quot;cant&quot;]);</pre><br />+ <br />+ In the templates in order to use the quicktags, you have to add in the template where you want the quicktags to appear:<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">{include file=&quot;tiki-edit_help_tool.tpl&quot;}</pre><br />+ <br />+ PS: only one quicktag zone per page is allowed<br />+ <br />+ If you want to add the resize buttoms, you have to add in the php:<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">include_once(&quot;textareasize.php&quot;);</pre><br />+ <br />+ And in your tpl, you have to add something like this:<br />+ <br /> <pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;">&lt;form  … id='editpageform'&gt;+ {include file=&quot;textareasize.tpl&quot; area_name='editwiki' formId='editpageform'}+ &lt;textarea id='editwiki' … rows=&quot;{$rows}&quot; cols=&quot;{$cols}&quot;&gt;{$pagedata|escape}</pre><br />]]></description>
            <pubDate>Mon, 23 Mar 2009 23:20:13 +0100</pubDate>
        </item>
        <item>
            <title>Missing tiki3.0</title>
            <link>http://tikiexpert.com/tiki-index.php?page=Missing+tiki3.0</link>
            <description><![CDATA[<style TYPE="text/css"> .diffchar { color:red; } </style>+ - extraparams do not open a line for extra param in plugin editor<br />+ - feature not to display edit plugin<br />]]></description>
            <pubDate>Tue, 27 Jan 2009 13:23:22 +0100</pubDate>
        </item>
        <item>
            <title>New in 3.0</title>
            <link>http://tikiexpert.com/tiki-index.php?page=New+in+3.0</link>
            <description><![CDATA[<style TYPE="text/css"> .diffchar { color:red; } </style>- </li><li> imp<span class="diffchar">o</span>rvment in webmail+ </li><li> impr<span class="diffchar">o</span>vment in webmail- </li><li> <b>webservice<span class="diffchar">s</span></b>+ </li><li> <b>webservice</b<span class="diffchar">> <a class="wiki external" target="_blank" href="http://dev.tikiwiki.org/tiki-index.php?page=WebservicePlugin" rel="external">http://dev.tikiwiki.org/tiki-index.php?page=WebservicePlugin</a</span>>- </li><li> plugin ftp+ </li><li> plugin ftp<span class="diffchar"><a class="wiki external" target="_blank" href="http://doc.tikiwiki.org/PluginFtp" rel="external">http://doc.tikiwiki.org/PluginFtp</a></span>+ </li><li> special little css overloading (ex: styles/my_styles+ </li></ul>+ /css/calendar.css)<br />+ <ul><li> tracker description parseable- <br />+ <ul><li> page selector field type+ </li><li> semantic links <a class="wiki external" target="_blank" href="http://doc.tikiwiki.org/Semantic+Admin" rel="external">http://doc.tikiwiki.org/Semantic+Admin</a>+ </li></ul>]]></description>
            <pubDate>Mon, 01 Dec 2008 17:10:52 +0100</pubDate>
        </item>
        <item>
            <title>what is a wiki?</title>
            <link>http://tikiexpert.com/tiki-index.php?page=what+is+a+wiki%3F</link>
            <description><![CDATA[<style TYPE="text/css"> .diffchar { color:red; } </style>+ <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="425" height="350"><param name="movie" value="http://www.youtube.com/v/-dnL00TdmLY&rel=1" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="http://www.youtube.com/v/-dnL00TdmLY&rel=1" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="425" height="350" wmode="transparent"></embed></object><br />]]></description>
            <pubDate>Tue, 08 Jul 2008 20:17:33 +0100</pubDate>
        </item>
        <item>
            <title>proto</title>
            <link>http://tikiexpert.com/tiki-index.php?page=proto</link>
            <description><![CDATA[<style TYPE="text/css"> .diffchar { color:red; } </style>+ <br />+ <br />+ <br />+ <br />+ <br />+ <br />]]></description>
            <pubDate>Mon, 17 Mar 2008 12:42:39 +0100</pubDate>
        </item>
        <item>
            <title>security</title>
            <link>http://tikiexpert.com/tiki-index.php?page=security</link>
            <description><![CDATA[<style TYPE="text/css"> .diffchar { color:red; } </style>+ <br />+ /tiki-export_pdf_reader.php?file=../../../../../../etc/passwd<br />]]></description>
            <pubDate>Wed, 05 Dec 2007 22:08:34 +0100</pubDate>
        </item>
        <item>
            <title>Etat des lieux de la recherche avec tikiwiki</title>
            <link>http://tikiexpert.com/tiki-index.php?page=Etat+des+lieux+de+la+recherche+avec+tikiwiki</link>
            <description><![CDATA[<style TYPE="text/css"> .diffchar { color:red; } </style>+ (verifier que ce n' est que sur les fichiers de gqleries et pqs sur ficheirs attaches à une page wiki)<br />]]></description>
            <pubDate>Thu, 08 Jun 2006 17:13:01 +0100</pubDate>
        </item>
        <item>
            <title>session life time</title>
            <link>http://tikiexpert.com/tiki-index.php?page=session+life+time</link>
            <description><![CDATA[<style TYPE="text/css"> .diffchar { color:red; } </style>+ <br />+ <b>session.gc_maxlifetime</b><br />+ in secongs in php.ini<br />]]></description>
            <pubDate>Mon, 01 May 2006 11:06:10 +0100</pubDate>
        </item>
        <item>
            <title>Checkpoint</title>
            <link>http://tikiexpert.com/tiki-index.php?page=Checkpoint</link>
            <description><![CDATA[<style TYPE="text/css"> .diffchar { color:red; } </style>+ <ul><li> memory limit (16M at least) . <a class="wiki external" target="_blank" href="hhttp://tikiwiki.org/art82" rel="external">more</a>+ </li><li> restart the server if you change the limit+ </li><li> browser accept cookies+ </li><li> Php session.save_path must be rewritable by apache+ </li></ul>]]></description>
            <pubDate>Sat, 26 Nov 2005 16:28:19 +0100</pubDate>
        </item>
    </channel>
</rss>
