<?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>SnowCMS &#187; improvement</title>
	<atom:link href="http://www.snowcms.com/tag/improvement/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.snowcms.com</link>
	<description>It snows here...a lot.</description>
	<lastBuildDate>Thu, 02 Feb 2012 03:51:53 +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>It has been awhile</title>
		<link>http://www.snowcms.com/it-has-been-awhile-43/</link>
		<comments>http://www.snowcms.com/it-has-been-awhile-43/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 02:39:26 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Developer updates]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[flakes]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[improvement]]></category>
		<category><![CDATA[mod system]]></category>

		<guid isPermaLink="false">http://www.snowcms.com/?p=43</guid>
		<description><![CDATA[It has been a bit since I have talked about SnowCMS, so I thought I should make a post to keep things going. In order to allow developers to see all of what goes on in SnowCMS in a more orderly fashion, such as API&#8217;s available, the SnowCMS SVN includes documentation which is compiled every [...]]]></description>
			<content:encoded><![CDATA[<p>It has been a bit since I have talked about SnowCMS, so I thought I should make a post to keep things going.</p>
<p>In order to allow developers to see all of what goes on in SnowCMS in a more orderly fashion, such as API&#8217;s available, the SnowCMS SVN includes documentation which is compiled every now and again (by antimatter15, not me&#8230;), which is <a href="http://snowcms.googlecode.com/svn/docs/index.html" target="_blank">available here</a>. We know that a system can be great, but that system isn&#8217;t useful if no one knows how to use what the system has to offer, so developers take advantage of what SnowCMS has to offer. Currently we have a few available classes and such to aid developers create plugins much faster, and without requiring plugins to have code that multiple plugins might end up having to include themselves, which is unnecessary. So I thought that I would, over the next week or more, make some posts about how to use the various API&#8217;s and classes available to future developers.</p>
<h1><a title="API documentation" href="http://snowcms.googlecode.com/svn/docs/files/core/api-class-php.html" target="_blank">API</a></h1>
<p>The name is pretty self explanatory, but <a title="API documentation" href="http://snowcms.googlecode.com/svn/docs/files/core/api-class-php.html" target="_blank">as you can see</a>, there are many available methods which can be used by plugins, and of course, this will no doubt be the most used by plugins.</p>
<h3><a href="http://snowcms.googlecode.com/svn/docs/files/core/api-class-php.html#API.add_hook" target="_blank">Adding a hook</a></h3>
<p>A plugin can add a hook via the $api, to modify the behavior of the system, or just do some action at the time of the hooks execution. Here is an example:<br />
<code><br />
/* ... */</p>
<p># Your function which will be called on later...<br />
function my_hook(&amp;$str)<br />
{<br />
$str = "I HOOKED YOU!";<br />
}</p>
<p># Register your hook with the API<br />
# The first parameter contains the hooks name, the second is the callback, so either a function name<br />
# or an array containing the object and the method to call, so: array($obj, 'method') would be like calling<br />
# on $obj-&gt;method(); The third parameter is the importance of your hook over any other possibly registered<br />
# callbacks. Defaults to 10, but the lower the number, the sooner that callback will be called upon. Last,<br />
# but not least is the number of arguments your callback accepts.<br />
$api-&gt;add_hook('the_hooks_name', 'my_hook', 10, 1);</p>
<p>/* ... */<br />
# Now somewhere in SnowCMS's code, a hook is ran, and if you registered a callback on that hook,<br />
# your callback, is, erm, called <img src='http://www.snowcms.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /><br />
$text = "Hi...";<br />
$api-&gt;run_hook('the_hooks_name', array(&amp;$text));<br />
echo $text;<br />
</code><br />
Now once all that was ran, &#8220;Hi&#8230;&#8221; would not be seen on the screen, but &#8220;I HOOKED YOU!&#8221; would be because the function my_hook had $str be a reference parameter, and when run_hook was called, $text was defined as a reference as well, allowing any function that hooked into this hook to change what $text contained. Of course, just changing text won&#8217;t be the only thing available through hooks, but there will be a lot more, but that depends upon the hook itself. Right now there is a <a href="http://code.google.com/p/snowcms/wiki/Hooks" target="_blank">small list available at Google Code</a> of currently available hooks in the system, but as time progresses, the list will grow <img src='http://www.snowcms.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3><a href="http://snowcms.googlecode.com/svn/docs/files/core/api-class-php.html#API.add_action" target="_blank">Adding an action</a></h3>
<p>When SnowCMS refers to an action, we mean an action in the URL. With the API, plugins can register actions to add some major, or possibly not so major, but still important, features to the system. Like say if there was a forum plugin and they wanted the forums index page to be accessible through index.php?action=forum, well, you can do that, and quite easily, I might add.</p>
<p>Adding that accessible page is done like this:<br />
<code><br />
/* ... */<br />
$api-&gt;add_action('forum', 'forum_index', 'location\of\the\forum_index.php');<br />
/* ... */<br />
</code><br />
Now when index.php?action=forum is accessed in a browser, the file &#8220;location\of\the\forum_index.php&#8221; is loaded and the function forum_index is called on. You can also leave the third parameter blank (the location of the function) and forum_index would just be called on. Through this method plugins can add pretty significant features to the system, like forums, pages, blogs, news, directories, or anything, really. Pretty slick, huh?</p>
<h3><a href="http://snowcms.googlecode.com/svn/docs/files/core/api-class-php.html#API.add_subaction" target="_blank">Adding a sub action</a></h3>
<p>Along with adding an action, you can also add a sub action, the difference is that the action must implement the usage of sub actions. Such as the forum plugin (there isn&#8217;t really one, yet, I am just using it as an example <img src='http://www.snowcms.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> ) it must use the API (which larger plugins really ought to, but don&#8217;t have to, use the API system to allow any other possible plugins to enhance the plugin itself&#8230;) to see if there are any sub actions which are registered (More on that later).</p>
<p>So now say you wanted to add a feature or something of the like to the forum plugin (index.php?action=forum) such as a statistics page. You would do this:<br />
<code><br />
/* ... */<br />
$api-&gt;add_subaction('forum', 'stats', 'stats_page', 'location\of\the\stats_page.php');<br />
/* ... */<br />
</code><br />
When you would access index.php?action=forum&amp;sa=stats &#8220;location\of\the\stats_page.php&#8221; would be loaded and stats_page would be called upon, but of course, just as with add_action, the location of the function can be left empty.</p>
<h3><a href="http://snowcms.googlecode.com/svn/docs/files/core/api-class-php.html#API.add_group" target="_blank">Adding a group</a></h3>
<p>Since we wanted to keep SnowCMS simple, we thought by default the system would only have 2 groups, an administrative group (administrator) and a member group (member, of course! But there is also a group called guest which you can&#8217;t assign yourself <img src='http://www.snowcms.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ). Why? Well, think about it. Most operating systems have 2 groups, administrators, which can really do everything, then there are members, which just plain get the privilege of using the computer <img src='http://www.snowcms.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' />  So there are only those two groups. However, plugins are likely to add features which members shouldn&#8217;t be always allowed to use, nor should administrators be the only group allowed to use it either. So to make that work, plugins can register groups, which administrators can assign to members, which therefore elevate the abilities of that member.</p>
<p>First things first, a plugin needs to register the group, otherwise an administrator can&#8217;t assign (or at least, easily) the group to a member.<br />
<code><br />
/* ... */<br />
$api-&gt;add_group('forum_moderator', l('Forum Moderator'));<br />
/* ... */<br />
</code><br />
The first parameter is the groups identifier, which is the string stored inside the database, the second parameter is the human readable name of the group, in this case, Forum Moderator (I bet you are wondering what the l() function call is for, that is for language support, but more on that later <img src='http://www.snowcms.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ).</p>
<p>Now, when you want to see if the current member is allowed to perform the tasks restricted only to forum moderators, you would do a little something like this:<br />
<code><br />
/* ... */</code></p>
<p>if($member-&gt;is_a(&#8216;forum_moderator&#8217;))<br />
{<br />
/* They are a forum moderator, proceed <img src='http://www.snowcms.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  */<br />
}<br />
else<br />
{<br />
/* They aren&#8217;t a forum moderator, yell at them! <img src='http://www.snowcms.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' />  */<br />
}</p>
<p>/* &#8230; */</p>
<p>There you have it&#8230; And of course you don&#8217;t need to worry about the checking of administrator&#8217;s, if the member is an administrator, any call to the method is_a is automatically returned as true.</p>
<p>So there you have it&#8230; A insight on how to use SnowCMS&#8217;s API class, that is all for the time being, but come back soon and I will be posting about other tools available in the SnowCMS which developers will be able to take advantage of.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.snowcms.com/it-has-been-awhile-43/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Update on the BBCode parser</title>
		<link>http://www.snowcms.com/update-on-the-bbcode-parser-16/</link>
		<comments>http://www.snowcms.com/update-on-the-bbcode-parser-16/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 06:47:38 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[News and updates]]></category>
		<category><![CDATA[bbc]]></category>
		<category><![CDATA[bbcode]]></category>
		<category><![CDATA[improvement]]></category>
		<category><![CDATA[parser]]></category>

		<guid isPermaLink="false">http://www.snowcms.com/?p=16</guid>
		<description><![CDATA[Last night I posted about me beginning the creation of a brand new BBCode parser which had the potential of allowing nested tags&#8230; Of course it has been done But I myself haven&#8217;t done it, until now!   After working on the new function for hours (And adding ~320 more lines of code) I am [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I posted about me beginning the creation of a brand new BBCode parser which had the potential of allowing nested tags&#8230; Of course it has been done <img src='http://www.snowcms.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' />  But I myself haven&#8217;t done it, until now!</p>
<p> </p>
<p>After working on the new function for hours (And adding ~320 more lines of code) I am getting really close to finishing the new product which allows nested tags! XD.  I have yet to test how fast it is because it isn&#8217;t fully finished, but it is getting there! However, I am quite sure it will be much faster than the older one because it just used regex to find tags on the message, one after another, and regex on a huge message isn&#8217;t that fast.</p>
<p> </p>
<p>I hope to finish this tomorrow! As long as I don&#8217;t run into any major problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.snowcms.com/update-on-the-bbcode-parser-16/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New BBCode parser?</title>
		<link>http://www.snowcms.com/new-bbcode-parser-13/</link>
		<comments>http://www.snowcms.com/new-bbcode-parser-13/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 07:15:52 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Developer updates]]></category>
		<category><![CDATA[bbc]]></category>
		<category><![CDATA[bbcode]]></category>
		<category><![CDATA[improvement]]></category>
		<category><![CDATA[parser]]></category>

		<guid isPermaLink="false">http://www.snowcms.com/?p=13</guid>
		<description><![CDATA[I was working on SnowCMS (Yeah, I am back again ), and I started to become super annoyed that the same BBCode tags cannot be nested within one another. So in just a couple minutes, I tried to figure out a way to get those to work. I tried doing something like this before, but [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on SnowCMS (Yeah, I am back again <img src='http://www.snowcms.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> ), and I started to become super annoyed that the same BBCode tags cannot be nested within one another. So in just a couple minutes, I tried to figure out a way to get those to work. I tried doing something like this before, but for the life of me, I couldn&#8217;t get it!</p>
<p> </p>
<p>Not to long ago I began pondering how I could approach this problem, and how other systems do it. I then thought, XML! I remembered that in PHP using <a title="XML Parser" href="http://www.php.net/manual/en/ref.xml.php" target="_blank">XML Parser</a> it parses the XML file into levels with by tags, and that is how I am approaching it <img src='http://www.snowcms.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p> </p>
<p>I already have a <em>very very very</em> (Did I say <em>very</em>?) rough prototype, only ~32 lines of code, the function parses this string:</p>
<blockquote><p>[b]Hello there![/b] [i]Why? [color=red]CAUSE![/color][/i]</p></blockquote>
<p>Into:</p>
<blockquote><p>Array<br />
(<br />
    [1] =&gt; [b]<br />
    [2] =&gt; Hello there!<br />
    [3] =&gt; [/b]<br />
    [4] =&gt; <br />
    [5] =&gt; [i]<br />
    [6] =&gt; Why?<br />
    [7] =&gt; [color=red]<br />
    [8] =&gt; CAUSE!<br />
    [9] =&gt; [/color]<br />
    [11] =&gt; [/i]<br />
)</p></blockquote>
<p>Right now it isn&#8217;t parsed very pretty like <img src='http://www.snowcms.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' />  But for the time being, it works for the most part! I can&#8217;t wait to dig deeper into this idea tomorrow&#8230; Seeya for now! (It is 12:15AM at the time I am posting this, Lol)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.snowcms.com/new-bbcode-parser-13/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

