<?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>Okada Design Blog &#187; calendar class</title>
	<atom:link href="http://www.okadadesign.no/blog/tag/calendar-class/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.okadadesign.no/blog</link>
	<description>Welcome to Okada Design Web Development Blog</description>
	<lastBuildDate>Wed, 11 Jan 2012 23:21:51 +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>Adding a third party class to CodeIgniter library</title>
		<link>http://www.okadadesign.no/blog/codeigniter/adding-a-third-party-class-to-codeigniter-library/</link>
		<comments>http://www.okadadesign.no/blog/codeigniter/adding-a-third-party-class-to-codeigniter-library/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 13:27:46 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[calendar class]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=340</guid>
		<description><![CDATA[ <p>You can find many php classes at http://www.phpclasses.org/. This time I&#8217;d like to add a new class called BBQQ calendar to library. I know that there is a calendar class for CodeIgniter, but this will show you how simple is to add a third party php class to CI.</p> Files <p>Download a zip [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/automatically-loaded-classlibrary-list-of-codeigniter/' rel='bookmark' title='Automatically Loaded Class/Library List of Codeigniter'>Automatically Loaded Class/Library List of Codeigniter</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fadding-a-third-party-class-to-codeigniter-library%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fadding-a-third-party-class-to-codeigniter-library%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>You can find many php classes at <a href="http://www.phpclasses.org/">http://www.phpclasses.org/</a>.<br />
This time I&#8217;d like to add a new class called <a href="http://www.phpclasses.org/browse/package/5743.html">BBQQ calendar</a> to library. I know that there is <a href="http://codeigniter.com/user_guide/libraries/calendar.html">a calendar class</a> for CodeIgniter, but this will show you how simple is to add a third party php class to CI.</p>
<h3>Files</h3>
<p>Download a zip file from <a href="http://www.phpclasses.org/browse/package/5743.html#download">http://www.phpclasses.org/browse/package/5743.html#download</a>. You need to register and sign-in in order to see a download link. Unzip it somewhere in your desktop.<br />
Open calendar.php and replace &lt;?php with the following code at the top and save it as BBQQ_Calendar.php in application/libraries/ directory.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
</pre>
<p><span id="more-340"></span></p>
<h3>Controller</h3>
<p>Copy, paste the following code and save it as calendar.php in controllers directory.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
class calendar extends Controller {

    function __construct() {
        parent::__construct();
        $this-&gt;load-&gt;library('BBQQ_Calendar');
    }

    function index()
    {

        $this-&gt;load-&gt;view('calendar_view');
    }
}
</pre>
<h3>View</h3>
<p>Copy, paste the following code and save it as calendar_view.php in views directory.<br />
Please note that I added &lt;base href=&#8221;&lt;?=base_url();?>&#8221; /> in head section.<br />
This allows us to link a css (and javascript if you are using) file with &lt;link href=&#8221;css/example.css&#8221; media=&#8221;screen&#8221; rel=&#8221;stylesheet&#8221; type=&#8221;text/css&#8221; > </p>
<pre class="brush: php; title: ; notranslate">
&lt;!DOCTYPE html&gt;&lt;html&gt;
&lt;head&gt;
&lt;title&gt;BBQQ CALENDAR&lt;/title&gt;
&lt;base href=&quot;&lt;?=base_url();?&gt;&quot; /&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; &gt;
&lt;link href=&quot;css/example.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; &gt;
&lt;body&gt;
&lt;h3&gt;A plain calendar with all default settings&lt;/h3&gt;
&lt;?php
$cal = new BBQQ_Calendar();
$cal-&gt;render(0);
?&gt;

&lt;h3&gt;A plain calenar with raw output, for geektool&lt;/h3&gt;
&lt;pre style=&quot;background:#333;width:420px;padding:12px;&quot;&gt;
&lt;?php
$cal-&gt;render(0, 1);
?&gt;
&lt;/pre&gt;

&lt;h3&gt;Customised Week Day Titles&lt;/h3&gt;
&lt;p&gt;change sun/sat to sunday/saturday&lt;/p&gt;
&lt;?php
$cal-&gt;setWeekDayTitle(array(
    'sun' =&gt; 'Sunday',
    'sat' =&gt; 'Saturday'
));
$cal-&gt;render(0);
?&gt;

&lt;h3&gt;Customised header&lt;/h3&gt;
&lt;?php
$cal-&gt;render(0, 0,
    '&lt;tr&gt;&lt;th colspan=&quot;7&quot; style=&quot;background:#69c;&quot;&gt;simple calendar&lt;/th&gt;&lt;/tr&gt;' .
    '&lt;tr&gt;&lt;th&gt;s&lt;/th&gt;&lt;th&gt;m&lt;/th&gt;&lt;th&gt;t&lt;/th&gt;&lt;th&gt;w&lt;/th&gt;&lt;th&gt;t&lt;/th&gt;&lt;th&gt;f&lt;/th&gt;&lt;th&gt;s&lt;/th&gt;&lt;/tr&gt;'
);
?&gt;

&lt;h3&gt;Hightlight Days With Customised Templates (Advanced Usage)&lt;/h3&gt;
&lt;?php
$days = array(
            // custom template for today
            $cal-&gt;getToday('j') =&gt; array(
                'template' =&gt; '&lt;b&gt;TODAY: :num&lt;/b&gt;'
            ),
            // highlight day: 5 with custom template/scripts and wrapper tag
            5 =&gt; array(
                'template' =&gt; '&lt;a href=&quot;event?id=event_:timestamp&quot;&gt;:num&lt;/a&gt;',
                'wrapper' =&gt; array(
                   'tag' =&gt; 'td',
                   'id'    =&gt; null,
                   'class' =&gt; 'cal-thu',
                   'format' =&gt; 'j F, Y',
                   'style' =&gt; 'color:red;background:yellow',
                   'onclick' =&gt; &quot;alert('Title: ' + this.title);return false;&quot;,
                   'title' =&gt; ':title'
                )
            ),
            // highlight day: 12 with custom template and wrapper tag
            12 =&gt; array(
                'template' =&gt; '&lt;a href=&quot;?id=event_:title&quot;&gt;:num&lt;/a&gt;',
                'wrapper' =&gt; array(
                   'tag' =&gt; 'td',
                   'id'    =&gt; null,
                   'class' =&gt; 'cal-thu',
                   'format' =&gt; 'j F, Y',
                   'style' =&gt; 'color:red;background:green',
                   'title' =&gt; 'some :title'
                )
            )
        );

$cal-&gt;highlightDays($days);
$cal-&gt;render(0);
?&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h3>CSS</h3>
<p>Create a css folder as the same level as sytem, application and img folder.<br />
Find a file called example.css in the unzipped folder. Move this file to css folder.</p>
<h3>Results</h3>
<p><a href="http://www.okadadesign.no/blog/img/BBQQ-CALENDAR.jpg"><img src="http://www.okadadesign.no/blog/wp-content/uploads/2009/10/BBQQ-CALENDAR-151x300.jpg" alt="BBQQ-CALENDAR" title="BBQQ-CALENDAR" width="151" height="300" class="alignleft size-medium wp-image-352" /></a></p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/automatically-loaded-classlibrary-list-of-codeigniter/' rel='bookmark' title='Automatically Loaded Class/Library List of Codeigniter'>Automatically Loaded Class/Library List of Codeigniter</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/codeigniter/adding-a-third-party-class-to-codeigniter-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

