<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Orqi</title>
	<atom:link href="http://orqi.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://orqi.wordpress.com</link>
	<description>PHP MVC Framework</description>
	<lastBuildDate>Sat, 11 Apr 2009 17:25:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='orqi.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Orqi</title>
		<link>http://orqi.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://orqi.wordpress.com/osd.xml" title="Orqi" />
	<atom:link rel='hub' href='http://orqi.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Uploading Images</title>
		<link>http://orqi.wordpress.com/2009/04/11/uploading-images/</link>
		<comments>http://orqi.wordpress.com/2009/04/11/uploading-images/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 16:28:29 +0000</pubDate>
		<dc:creator>orqi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://orqi.wordpress.com/?p=218</guid>
		<description><![CDATA[Domain Object Validator Mapper Controller Template<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=218&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Domain Object</h3>
<p><pre class="brush: php;">
class Siteimage extends Object
{
  public $tmp_name;
  public $versions = array();
  
  function Siteimage($id='', $user='', $size='', $type='', $name='', $label='')
  {
    $this-&gt;id = $id;
    $this-&gt;user = $user;
    $this-&gt;size = $size;
    $this-&gt;type = $type;
    $this-&gt;name = $name;
    $this-&gt;label = $label;
  }

  function GetTmpName() { return $this-&gt;tmp_name; }
  
  function GetName()
  {
    if ($this-&gt;isGhost()) $this-&gt;PopulateMe();
    if (empty($this-&gt;name))
    {
      list($object_type, $extension) = explode('/', $this-&gt;type);
      $this-&gt;name = '/' . CodeGenerator::GetCode() . '.' . $extension;
    }
    return $this-&gt;name;
  }
  
  function SetFromRequest($file='')
  {
    $this-&gt;tmp_name = $file['tmp_name'];
    $this-&gt;type = $file['type'];
    $this-&gt;size = $file['size'];
  }

  function SaveFile()
  {
    $config = Config::GetInstance();
    $file_path = $config-&gt;resource['path'] . $this-&gt;GetName();

    if (move_uploaded_file($this-&gt;GetTmpName(), $file_path))
    {
      chmod($file_path, 0777);
      return true;
    }
    else
    {
      $this-&gt;session = new Session();
      $this-&gt;error = new Message('fileupload', &quot;I think there's something wrong saving the file to the folder.&quot;);
      return false;
    }      
  }
  
  function DeleteFile()
  {
    $config = Config::GetInstance();
    $this-&gt;DeleteVersions();
    unlink($config-&gt;resource['path'] . $this-&gt;GetName());
    return true;
  }
  
  function DeleteVersions()
  {
    $config = Config::GetInstance();
    foreach ($config-&gt;image as $version =&gt; $version_details)
    {
      $components = explode('/', $this-&gt;GetName());
      $components[count($components)-1] = $version . &quot;_&quot; . $components[count($components)-1];
      $separator = '';
      foreach ($components as $component)
      {
        $this-&gt;versions[$version] .= $separator . $component;
        $separator = &quot;/&quot;; 
      }
      
      if (file_exists($config-&gt;resource['path'] . $this-&gt;versions[$version]))
      {
        unlink($config-&gt;resource['path'] . $this-&gt;versions[$version]);
      }
    }
  }
}
</pre></p>
<h3>Validator</h3>
<p><pre class="brush: php;">
class SiteimageValidator extends BaseSiteimageValidator
{
	function SiteimageValidator($post='', $files='') { $this-&gt;Initialise($post, $files); }

	function Populate($post='', $files='')
	{
		if (is_a($post, 'Siteimage'))
		{
			$this-&gt;id = $post-&gt;GetId();
			$this-&gt;user = $post-&gt;GetUser()-&gt;GetId();
			$this-&gt;name = $post-&gt;GetName();
			$this-&gt;label = $post-&gt;GetLabel();
		}
		else 
		{
			$this-&gt;id = $post['id'];
			$this-&gt;user = $post['user'];
			$this-&gt;name = $files['name'];
			$this-&gt;label = $post['label'];
		}
	}
		
	function Save()
	{
		$siteimage = new Siteimage();
		$siteimage = (empty($this-&gt;id)) ? new Siteimage() : $siteimage-&gt;GetMapper()-&gt;Find(new SiteImage($this-&gt;id));
		if ($this-&gt;name['error'] != UPLOAD_ERR_NO_FILE) $siteimage-&gt;SetFromRequest($this-&gt;name);
		$siteimage-&gt;SetUser(new User($this-&gt;user));
		$siteimage-&gt;SetLabel($this-&gt;label);
		return ($siteimage-&gt;Save()) ? $siteimage : false;
	}
		
	function isValid()
	{
		$this-&gt;errors = array();
						
		if (empty($this-&gt;label)) $this-&gt;errors[] = new Message('label', &quot;You should type a unique label for the image.&quot;);
		else if (!$this-&gt;IsValidAlphanumeric($this-&gt;label)) $this-&gt;errors[] = new Message('label', &quot;You can only have hyphens, spaces, letters and numbers in this field.&quot;);
		else
		{
			$siteimage_mapper = new Siteimages();
			$siteimage = $siteimage_mapper-&gt;FindByLabel($this-&gt;label);
				
			if (is_a($siteimage, 'Siteimage') &amp;&amp; $siteimage-&gt;GetId() != $this-&gt;id) $this-&gt;errors[] = new Message('label', &quot;Sorry, but that label is already in use for another image.&quot;);
		}
			
		if (($this-&gt;name['error'] != UPLOAD_ERR_NO_FILE &amp;&amp; !empty($this-&gt;id)) || empty($this-&gt;id))
		{
			$file_error_message = $this-&gt;ValidateFile($this-&gt;name, array(&quot;image/jpeg&quot;, &quot;image/jpg&quot;, &quot;image/gif&quot;, &quot;image/png&quot;));
			if ((string)$file_error_message == &quot;File type is not correct.&quot;) $this-&gt;errors[] = new Message('name', &quot;You can only upload GIFs, PNGs or JPEGs. &quot;);
			else if ($file_error_message !== true) $this-&gt;errors[] = new Message('name', $file_error_message);
		}
		if (!$this-&gt;IsValidInt($this-&gt;user)) $this-&gt;errors[] = new Message('user', &quot;Can't find a user to add the image with.&quot;);

		return empty($this-&gt;errors);
	}
}
</pre></p>
<h3>Mapper</h3>
<p><pre class="brush: php;">
class Siteimages extends Mapper
{
  function Save(&amp;$object)
  {
    $action_text = ($object-&gt;isNew()) ? &quot;insert into &quot; : &quot;update &quot;;
    if (!$object-&gt;isNew()) $condition = &quot;where id=&quot; . $object-&gt;GetId();
      
    if ($object-&gt;GetTmpName() != &quot;&quot;)
    {
      if (!$object-&gt;isNew())
      {
        $old_file = $object-&gt;GetName();
        $object-&gt;SetName();
      }
      if (!$object-&gt;SaveFile())
      {
        $session = new Session();
        $session-&gt;AddMessage(new Message('save', &quot;There was a problem saving the file. &quot;));
        return false;
      }
    }
    
    $sql_string = &quot;
      $action_text  siteimages
      set        user    =&quot; . $object-&gt;GetUser()-&gt;GetId() . &quot;,
              name    ='&quot; . $object-&gt;GetName() . &quot;',
              type    ='&quot; . $object-&gt;GetType() . &quot;',
              size    ='&quot; . $object-&gt;GetSize() . &quot;',
              label    ='&quot; . $object-&gt;GetLabel() . &quot;'
      $condition
    &quot;;
        
    if ($this-&gt;dao-&gt;ExecuteQuery($sql_string))
    {
      if (!$object-&gt;isNew() &amp;&amp; $object-&gt;GetTmpName() != &quot;&quot;)
      {
        $object-&gt;SetName($old_file);
        $object-&gt;DeleteFile();
      }
      if ($object-&gt;isNew()) $object-&gt;SetId(mysql_insert_id($this-&gt;dao-&gt;conn));
      return true;
    }
    else
    {
      $object-&gt;DeleteFile();
      return false;
    }
  }
}
</pre></p>
<h3>Controller</h3>
<p><pre class="brush: php;">
class SiteimageController extends Controller
{
  function Input()
  {
    $siteimage_mapper = new Siteimages();
    $this-&gt;siteimage = $siteimage_mapper-&gt;Find(new Siteimage($this-&gt;get['id']));
    
    if (empty($this-&gt;post))
    {
      $this-&gt;form = new SiteimageValidator($this-&gt;siteimage);
      if (!is_a($this-&gt;siteimage, 'Siteimage')) $this-&gt;form-&gt;SetUser($this-&gt;session-&gt;user-&gt;GetId());
    }
    else
    {
      $this-&gt;form = new SiteimageValidator($this-&gt;post, $this-&gt;files);
        
      if ($this-&gt;form-&gt;isValid())
      {
        $siteimage = $this-&gt;form-&gt;Save();
        if ($siteimage instanceof Siteimage)
        {
          $this-&gt;session-&gt;AddMessage(new Message(&quot;success&quot;, &quot;Your picture was saved successfully. &quot;));
          $this-&gt;Redirect($this-&gt;MakeLink('siteimage', 'all'));
        }
        else
        {
          $this-&gt;session-&gt;AddMessage(new Message('database_error', &quot;Couldn't save to the database. &quot;));
        }
      }
    }
   
    $this-&gt;LoadTemplate(&quot;FormSiteimage&quot;);
  }
}
</pre></p>
<h3>Template</h3>
<p><pre class="brush: php;">
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html&gt;
  &lt;? $this-&gt;LoadComponent('HeadTag'); ?&gt;
  &lt;body&gt;
    &lt;? $this-&gt;LoadComponent('AdminHeader'); ?&gt;
    &lt;div class=&quot;pod twoCol&quot;&gt;
      &lt;h2&gt;Site Image Upload Form&lt;/h2&gt;
      &lt;div&gt;
        &lt;br&gt;
        &lt;?=$this-&gt;session-&gt;PrintMessages()?&gt;
        &lt;?=$this-&gt;form-&gt;PrintError('user')?&gt;
				
        &lt;form method='post' action='' enctype=&quot;multipart/form-data&quot;&gt;
          &lt;input type=&quot;hidden&quot; class=&quot;hidden&quot; name=&quot;MAX_FILE_SIZE&quot; value=&quot;300000&quot; /&gt; 
          &lt;input type='hidden' class=&quot;hidden&quot; name='id' value='&lt;?=$this-&gt;form-&gt;GetId()?&gt;' /&gt;
          &lt;input type='hidden' class=&quot;hidden&quot; name='user' value='&lt;?=$this-&gt;form-&gt;GetUser()?&gt;' /&gt;
					
          &lt;label for='label'&gt;Label&lt;/label&gt;
          &lt;input type='text' name='label' value=&quot;&lt;?=$this-&gt;form-&gt;GetLabel()?&gt;&quot; id='label' /&gt;
          &lt;?=$this-&gt;form-&gt;PrintError('label')?&gt;
          &lt;br&gt;

          &lt;label for='name'&gt;Image Location&lt;/label&gt;
          &lt;input type='file' name='name' value=&quot;&quot; id='name' /&gt;
          &lt;p&gt;Please choose an image file to upload.&lt;/p&gt;
          &lt;?=$this-&gt;form-&gt;PrintError('name')?&gt;
          &lt;br&gt;

          &lt;? if ($this-&gt;siteimage instanceof Siteimage) { ?&gt;
            &lt;label&gt;Current Image&lt;/label&gt;
            &lt;img src=&quot;&lt;?=$this-&gt;siteimage-&gt;GetVersion('thumbnail')?&gt;&quot; /&gt;
            &lt;br&gt;
            &lt;br&gt;
          &lt;? } ?&gt;
          &lt;label&gt;&lt;/label&gt;
          &lt;input type='submit' name='submit' value='Save' class='submit' /&gt;
        &lt;/form&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;? $this-&gt;LoadComponent('PageFooter'); ?&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orqi.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orqi.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orqi.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orqi.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/orqi.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/orqi.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/orqi.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/orqi.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orqi.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orqi.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orqi.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orqi.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orqi.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orqi.wordpress.com/218/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=218&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://orqi.wordpress.com/2009/04/11/uploading-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1a7d93abb89936c9c7f1e08089d3ef22?s=96&#38;d=identicon" medium="image">
			<media:title type="html">orqi</media:title>
		</media:content>
	</item>
		<item>
		<title>template helpers</title>
		<link>http://orqi.wordpress.com/2009/03/16/template-helpers/</link>
		<comments>http://orqi.wordpress.com/2009/03/16/template-helpers/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 11:00:35 +0000</pubDate>
		<dc:creator>orqi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://orqi.wordpress.com/?p=213</guid>
		<description><![CDATA[paths to the project directories helpers makelink() Creates an absolute url to a specified action in the site PrintMessages() Prints out all the messages in the session LoadComponent If you have a fragment to load into a page use LoadComponent() &#8211; you don&#8217;t need the .php extension<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=213&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>paths to the project directories<br />
<pre class="brush: php;">
&lt;?=$this-&gt;config-&gt;resource['img']?&gt;
&lt;?=$this-&gt;config-&gt;resource['css']?&gt;
&lt;?=$this-&gt;config-&gt;resource['js']?&gt;
</pre></p>
<p>helpers</p>
<p>makelink()<br />
Creates an absolute url to a specified action in the site<br />
<pre class="brush: php;">
&lt;?=$this-&gt;MakeLink($controller, $function, $params)?&gt;

&lt;?=$this-&gt;MakeLink('signup')?&gt;
=&gt; http://westendvip.com/signup

&lt;?=$this-&gt;MakeLink('offer', 'search', 'q=Good Offers')?&gt;
=&gt; http://westendvip.com/offer/search.html?q=Good Offers
</pre></p>
<p>PrintMessages()<br />
Prints out all the messages in the session<br />
<pre class="brush: php;">
&lt;?=$this-&gt;session-&gt;PrintMessages($list_tag='', $list_css='', $item_tag='', $item_css)?&gt;

&lt;?=$this-&gt;session-&gt;PrintErrors('ul', 'list', 'li', 'item')?&gt;
=&gt; &lt;ul class='list'&gt;&lt;li class='item'&gt;Message appears here&lt;/li&gt;&lt;/ul&gt;
</pre></p>
<p>LoadComponent<br />
If you have a fragment to load into a page use LoadComponent() &#8211; you don&#8217;t<br />
need the .php extension<br />
<pre class="brush: php;">
&lt;? $this-&gt;LoadComponent($component, $param1, $param2, $param3); ?&gt;

&lt;? $this-&gt;LoadComponent('PageFooter'); ?&gt;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orqi.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orqi.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orqi.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orqi.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/orqi.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/orqi.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/orqi.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/orqi.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orqi.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orqi.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orqi.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orqi.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orqi.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orqi.wordpress.com/213/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=213&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://orqi.wordpress.com/2009/03/16/template-helpers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1a7d93abb89936c9c7f1e08089d3ef22?s=96&#38;d=identicon" medium="image">
			<media:title type="html">orqi</media:title>
		</media:content>
	</item>
		<item>
		<title>Recent Changes</title>
		<link>http://orqi.wordpress.com/2008/11/17/recent-changes/</link>
		<comments>http://orqi.wordpress.com/2008/11/17/recent-changes/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 17:04:51 +0000</pubDate>
		<dc:creator>orqi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://orqi.wordpress.com/?p=208</guid>
		<description><![CDATA[There are two new classes that deal with file uploads they are built to mimic a domain object called FileUpload, but also handle the saving and managing of files and records corresponding the file info. Which can then be linked to objects that have files. So from now on when you get a file it&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=208&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are two new classes that deal with file uploads they are built to mimic a domain object called FileUpload, but also handle the saving and managing of files and records corresponding the file info. Which can then be linked to objects that have files.</p>
<p>So from now on when you get a file it&#8217;s an object and you access it&#8217;s location by calling its name method.</p>
<p><pre class="brush: php;">
$file = new FileUpload();
$file-&gt;SetFromRequest($_FILES);
$file-&gt;SetUser(new User());
$file-&gt;Save();
</pre></p>
<p>The reason for these changes is to a) make file uploading more simple! and b) to make the validating of the file upload more accurate.<br />
<span id="more-208"></span></p>
<p>In the controller &#8230;<br />
<pre class="brush: php;">
if (empty($this-&gt;post))
{
  $this-&gt;form = new PictureValidator($this-&gt;post, $this-&gt;files);
  if ($this-&gt;form-&gt;isValid())
  {
    $user = $this-&gt;form-&gt;Save();
    if ($user instanceof User)
    {
      $this-&gt;session-&gt;AddMessage(new Message(&quot;success&quot;, &quot;Your picture was saved successfully.&quot;));
    }
    else
    {
      $this-&gt;session-&gt;AddMessage(new Message('database_error', &quot;Couldn't save to the database&quot;));
    }
  }
}
</pre></p>
<p>The validator has now got two new functions</p>
<p><pre class="brush: php;">
function Initialise($post='', $files='')
{
  $this-&gt;config = new Config();
  $this-&gt;files = $files;
  $this-&gt;post = $post;
  $this-&gt;Populate($this-&gt;post, $this-&gt;files);
}

function Save()
{
  return $specified_domain_object;
}

function ValidateFile($value, $file_types=array())
{
  switch ($value['error'])
  {
    case UPLOAD_ERR_INI_SIZE: return &quot;The uploaded file exceeds the upload_max_filesize directive in php.ini.&quot;;
    case UPLOAD_ERR_FORM_SIZE: return &quot;The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.&quot;;
    case UPLOAD_ERR_PARTIAL: return &quot;The uploaded file was only partially uploaded.&quot;;
    case UPLOAD_ERR_NO_FILE: return &quot;No file was uploaded.&quot;;
    case UPLOAD_ERR_NO_TMP_DIR: return &quot;A server error is preventing file uploads. Please contact the site administrator.&quot;;
    case UPLOAD_ERR_CANT_WRITE: return &quot;Failed to write file to disk.&quot;;
    case UPLOAD_ERR_EXTENSION: return &quot;File upload stopped by extension.&quot;;
  }

  if (!in_array($value['type'], $file_types)) return &quot;File type is not correct.&quot;;
  return true;
}
</pre> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orqi.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orqi.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orqi.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orqi.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/orqi.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/orqi.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/orqi.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/orqi.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orqi.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orqi.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orqi.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orqi.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orqi.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orqi.wordpress.com/208/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=208&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://orqi.wordpress.com/2008/11/17/recent-changes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1a7d93abb89936c9c7f1e08089d3ef22?s=96&#38;d=identicon" medium="image">
			<media:title type="html">orqi</media:title>
		</media:content>
	</item>
		<item>
		<title>Widget Support</title>
		<link>http://orqi.wordpress.com/2008/07/30/widget-support/</link>
		<comments>http://orqi.wordpress.com/2008/07/30/widget-support/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 15:33:59 +0000</pubDate>
		<dc:creator>orqi</dc:creator>
				<category><![CDATA[Examples / Tutorials]]></category>
		<category><![CDATA[Framework Info]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://orqi.wordpress.com/?p=162</guid>
		<description><![CDATA[NB: It&#8217;s a work in progress. . To add this you need: - The Widget Controller .htaccess Changes The Widget Container Front-End Component A _widgets directory Your First Widget Widget Controller The widget controller is basically a standard controller that then mimics the Loader class and loads the widget screens. It also provides a little [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=162&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span id="more-162"></span><strong>NB: It&#8217;s a work in progress.</strong> . To add this you need: -</p>
<ul>
<li>The Widget Controller</li>
<li>.htaccess Changes</li>
<li>The Widget Container Front-End Component</li>
<li>A _widgets directory</li>
<li><a href="/2008/07/28/your-first-widget/">Your First Widget</a></li>
</ul>
<h3>Widget Controller</h3>
<p>The widget controller is basically a standard controller that then mimics the Loader class and loads the widget screens. It also provides a little support for Ajax links, so that you can put anchor links in your widgets and the response will come back to calling widget only.<br />
<pre class="brush: php;">
// ================================================================================= //		

class WidgetController extends Controller
{
	// ============================================================================= //

	function All() {}
	function Input() {}
	function Delete() {}
	
	// ============================================================================= //
	
	function Run()
	{
		// expecting parameters: -
		//
		//	$this-&gt;get['widget'] = 'raketu'
		//	$this-&gt;get['screen'] = 'home';
		//
		// this widget would be available on the following URL: -
		//
		//	http://www.blah.com/widget/raketu/home.html
		
		// basically what do we have to do ...
		//
		//	1. get the widget's controller
		require_once &quot;_widgets/&quot; . $this-&gt;get['widget'] . &quot;/Controller.php&quot;;
		//	2. get the widget 'screen' - basically this is the same as
		//	   running a regular command in Orqi.
		$controller_name = $this-&gt;get['widget'] . 'Controller';
		$action_name = $this-&gt;get['screen'];
		
		$widget_controller = new $controller_name();
		$widget_controller-&gt;Initialise($this-&gt;config, $this-&gt;session, $this-&gt;get, $this-&gt;post, $this-&gt;files);
		$widget_controller-&gt;$action_name();
	}
	
	// ============================================================================= //
	
	function LoadWidget($widget_name='', $screen='', $sendtoscreen=true)
	{
		if (!$sendtoscreen) ob_start();
		 
		switch (true)
		{
			case file_exists(&quot;_widgets/&quot; . $widget_name . &quot;/_&quot; . $screen . &quot;.php&quot;):
				require &quot;_widgets/&quot; . $widget_name . &quot;/_&quot; . $screen . &quot;.php&quot;;
				break;
			
			default:
				echo &quot;&lt;p&gt;&quot; . $widget_name . &quot;'s' &quot; . $screen . &quot; screen is missing.&lt;/p&gt;&quot;;
				break;
		}
		
		if (!$sendtoscreen)
		{
			$return_html = ob_get_contents();
			ob_end_clean();
			return $return_html;
		}
		else return false;
	}
	
	// ============================================================================= //
	
	function MakeWidgetLink($widget='', $screen='', $params='', $secure='')
	{
		if (empty($widget) || empty($screen)) return $this-&gt;config-&gt;app['location'] . '/';
		else
		{
			if ($this-&gt;config-&gt;app['mod_rewrite'] == false)
			{
				$site_text = (empty($this-&gt;config-&gt;app['default'])) ? &quot;&quot; : &quot;site=&quot; . $this-&gt;config-&gt;app['default'] . &quot;&amp;&quot;;
				$link_text = $this-&gt;config-&gt;app['location'] . &quot;/index.php?&quot; . $site_text . &quot;object=widget&amp;action=run&amp;widget=&quot; . $widget . &quot;&amp;screen=&quot; . $screen;
				$separator = &quot;&amp;&quot;;
			}
			else
			{
				$site_text = (empty($this-&gt;config-&gt;app['default'])) ? &quot;&quot; : $this-&gt;config-&gt;app['default'] . &quot;/&quot;;
				$link_text = $this-&gt;config-&gt;app['location'] . '/' . $site_text .&quot;widget/&quot; . $widget . &quot;/&quot; . $screen . &quot;.&quot; . $this-&gt;config-&gt;app['extension'];
				$separator = &quot;?&quot;;
			}
			
			if ($this-&gt;config-&gt;app['ssl'] == true &amp;&amp; (!empty($_SERVER['HTTPS']) || $secure == true))
			{
				$link_text = str_replace('http:', 'https:', $link_text);
			}
			
			if (!empty($params)) $link_text .= $separator . $params;
			return &quot;javascript: rh_&quot; . $widget . &quot;.LoadPart('widget_&quot; . $widget . &quot;', '&quot; . $link_text . &quot;');&quot;;
		}
	}
	
	// ============================================================================= //
}

// ================================================================================= //
</pre></p>
<h3>.htaccess Changes</h3>
<p>Put this line in your .htaccess file. You can get by without mod_rewrite, but I&#8217;d really recommend it as the urls can get proper tricky.</p>
<p><pre class="brush: cpp;">
RewriteRule ^widget/(.*)/(.*).html$ index.php?object=widget&amp;action=run&amp;widget=$1&amp;screen=$2&amp;%{QUERY_STRING} [L]
</pre></p>
<h3>The Widget Container Front-End Component</h3>
<p>This is a work in progress very much meaning I&#8217;m not particularly happy with it&#8217;s state, but at least it is working. It will load a div with a specified ID and then give you a slice of supporting javascript that will wait for and process ajax instructions on that specified ID only.<br />
<pre class="brush: xml;">
&lt;?
	// param1: is the name of the widget
	$separator = &quot;?&quot;;
	$extra_parameters = &quot;&quot;;
	
	if (!empty($param2))
	{
		$extra_parameters .= $separator . &quot;param1=&quot; . $param2;
		$separator = &quot;&amp;&quot;;
	}
	if (!empty($param3)) $extra_parameters .= $separator . &quot;param2=&quot; . $param3;
?&gt;

&lt;script&gt;
	var ResponseHandlerFor_&lt;?=$param1?&gt; = function()
	{
		this.FillWidget = function(request)
		{
			$('widget_&lt;?=$param1?&gt;').innerHTML = request.responseText;
		}
		
		this.Oopslol = function()
		{
			$('widget_&lt;?=$param1?&gt;').innerHTML = &quot;&lt;h3&gt;ooops.&lt;/h3&gt;&lt;p&gt;there was an error.&lt;/p&gt;&quot;;
		}
	
		this.PreLoader = function(element_id)
		{
			$(element_id).innerHTML += &quot;&lt;p&gt;&lt;img src='/_img/loading_animation.gif'&gt;&lt;/p&gt;&quot;;
			return false;
		}
		
		this.LoadPart = function(element_id, url)
		{
			this.PreLoader(element_id);
			new Ajax.Request(url, {method:'get', onComplete:rh_&lt;?=$param1?&gt;.FillWidget, onFailure:rh_&lt;?=$param1?&gt;.Oopslol});
			return false;
		}
		
		this.PostForm = function(submit_form)
		{
			$(submit_form).request({onComplete:rh_&lt;?=$param1?&gt;.FillWidget, onFailure:rh_&lt;?=$param1?&gt;.Oopslol});
			$('widget_&lt;?=$param1?&gt;').innerHTML = &quot;&lt;h2&gt;LOADING&lt;/h2&gt;&lt;p&gt;Please wait ...&lt;/p&gt;&lt;p&gt;&lt;img src='/_img/loading_animation.gif'&gt;&lt;/p&gt;&quot;;
		}
		
		this.OnLoadHandler = function()
		{
			this.LoadPart('widget_&lt;?=$param1?&gt;', '/widget/&lt;?=$param1?&gt;/home.html&lt;?=$extra_parameters?&gt;');
		}
	}
	
	var rh_&lt;?=$param1?&gt; = new ResponseHandlerFor_&lt;?=$param1?&gt;();
&lt;/script&gt;
&lt;div class=&quot;widget&quot; id=&quot;widget_&lt;?=$param1?&gt;&quot; style=&quot;margin: 0px 5px 5px 0px; float: left; width: 300px; border: 1px dotted #ccc;&quot;&gt;&lt;/div&gt;
&lt;script&gt;rh_&lt;?=$param1?&gt;.OnLoadHandler();&lt;/script&gt;
</pre></p>
<h3>A _widgets directory</h3>
<p>Create a directory called &#8220;_widgets&#8221; in your project root. It&#8217;s that simple.</p>
<h3>Scriptaculous</h3>
<p>Ah, yes. Without scriptaculous none of the AJAX stuff will work. Probably best to download it and put it  in your &#8220;_js&#8221; directory. You can include scriptaculous site wide in your _HeadTag.php component.</p>
<p><pre class="brush: xml;">
&lt;script src=&quot;&lt;?=$this-&gt;config-&gt;resource['js']?&gt;/scriptaculous.js&quot; type=&quot;text/javascript&quot; language=&quot;javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
</pre></p>
<h3>Your own widget</h3>
<p>Please see the article entitled <a href="/2008/07/28/your-first-widget/">&#8220;Your First Widget&#8221;</a> for more information.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/orqi.wordpress.com/162/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/orqi.wordpress.com/162/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orqi.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orqi.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orqi.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orqi.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/orqi.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/orqi.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/orqi.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/orqi.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orqi.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orqi.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orqi.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orqi.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orqi.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orqi.wordpress.com/162/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=162&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://orqi.wordpress.com/2008/07/30/widget-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1a7d93abb89936c9c7f1e08089d3ef22?s=96&#38;d=identicon" medium="image">
			<media:title type="html">orqi</media:title>
		</media:content>
	</item>
		<item>
		<title>Create A Simple Page Yourself</title>
		<link>http://orqi.wordpress.com/2008/07/28/create-a-simple-page-yourself/</link>
		<comments>http://orqi.wordpress.com/2008/07/28/create-a-simple-page-yourself/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 15:50:39 +0000</pubDate>
		<dc:creator>orqi</dc:creator>
				<category><![CDATA[Examples / Tutorials]]></category>
		<category><![CDATA[a simple orqi page]]></category>
		<category><![CDATA[getting started]]></category>

		<guid isPermaLink="false">http://orqi.wordpress.com/?p=148</guid>
		<description><![CDATA[Create your controller For something simple like showing a template with just html, all we need for the controller, a class declaration and a single function containing the template call. If you create a file called &#8220;ExampleController.php&#8221;, fill it with the sample code below and put it in your &#8220;_classes/_app&#8221; directory. Create your template Because [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=148&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span id="more-148"></span><br />
<h3>Create your controller</h3>
<p>For something simple like showing a template with just html, all we need for the controller, a class declaration and a single function containing the template call. If you create a file called &#8220;ExampleController.php&#8221;, fill it with the sample code below and put it in your &#8220;_classes/_app&#8221; directory.<br />
<pre class="brush: php;">
class ExampleController extends Controller
{
	function MyFirstPage()
	{
		$this-&gt;LoadTemplate(&quot;MyFirstPage&quot;);
	}
}
</pre></p>
<h3>Create your template</h3>
<p>Because we named our template &#8220;MyFirstPage&#8221; in the controller, Orqi will be expecting a file in the template directory called &#8220;MyFirstPage.php&#8221;. So create it, and put the following code inside.</p>
<p><pre class="brush: php;">
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
	&quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt;My First Orqi Page&lt;/title&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;h1&gt;My First Test Page&lt;/h1&gt;
		&lt;p&gt;Wow that was so easy, I thought people said MVC
		was heavy handed and stuff? :D&lt;/p&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre></p>
<h3>Try it in a browser</h3>
<p>Type <a href="http://localhost/yoursite/example/myfirstpage.html">http://localhost/yoursite/example/myfirstpage.html</a> in to a browser and your should see: -</p>
<p><a href="http://orqi.files.wordpress.com/2008/07/picture-2.png"><img src="http://orqi.files.wordpress.com/2008/07/picture-2.png?w=300&#038;h=162" alt="" width="300" height="162" class="alignnone size-medium wp-image-150" /></a></p>
<h3>URLs</h3>
<p>Notice the structure of the url. &#8220;example&#8221; will tell Orqi to call the &#8220;ExampleController&#8221; and &#8220;myfirstpage&#8221; will tell Orqi to look for a function within the controller called &#8220;myfirstpage&#8221;.</p>
<p><pre class="brush: cpp;">
http://localhost/yoursite/example/myfirstpage.html
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/orqi.wordpress.com/148/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/orqi.wordpress.com/148/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orqi.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orqi.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orqi.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orqi.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/orqi.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/orqi.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/orqi.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/orqi.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orqi.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orqi.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orqi.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orqi.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orqi.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orqi.wordpress.com/148/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=148&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://orqi.wordpress.com/2008/07/28/create-a-simple-page-yourself/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1a7d93abb89936c9c7f1e08089d3ef22?s=96&#38;d=identicon" medium="image">
			<media:title type="html">orqi</media:title>
		</media:content>

		<media:content url="http://orqi.files.wordpress.com/2008/07/picture-2.png?w=300" medium="image" />
	</item>
		<item>
		<title>Dynamic CSS</title>
		<link>http://orqi.wordpress.com/2008/07/28/dynamic-css/</link>
		<comments>http://orqi.wordpress.com/2008/07/28/dynamic-css/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 15:43:09 +0000</pubDate>
		<dc:creator>orqi</dc:creator>
				<category><![CDATA[Examples / Tutorials]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[dynamic css]]></category>

		<guid isPermaLink="false">http://orqi.wordpress.com/?p=155</guid>
		<description><![CDATA[CssController Create a controller called &#8220;CssController.php&#8221; in your controller folder &#8220;_classes/_app&#8221;. You don&#8217;t HAVE to call it CssController of course, I&#8217;m only doing this because I find Css a memorable name for css stuff :D CSS Template OK so we put a file &#8220;DynamicCSS.php&#8221; in our templates directory &#8220;_classes/_ui/_pc&#8221; like so &#8230; Your HTML Template [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=155&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span id="more-155"></span><br />
<h3>CssController</h3>
<p>Create a controller called &#8220;CssController.php&#8221; in your controller folder &#8220;_classes/_app&#8221;. You don&#8217;t HAVE to call it CssController of course, I&#8217;m only doing this because I find Css a memorable name for css stuff :D</p>
<p><pre class="brush: php;">
class CssController extends Controller
{
	function Dynamic()
	{
		header(&quot;Content-type: text/css&quot;);
		$this-&gt;LoadTemplate(&quot;DynamicCSS&quot;);
	}
}
</pre></p>
<h3>CSS Template</h3>
<p>OK so we put a file &#8220;DynamicCSS.php&#8221; in our templates directory &#8220;_classes/_ui/_pc&#8221; like so &#8230;</p>
<p><pre class="brush: css;">
h1
{
background: url(&lt;?=$this-&gt;config-&gt;resource['img']?&gt;/header.gif) left top no-repeat;
}
#logo
{
background-image: url(&lt;?=$this-&gt;config-&gt;resource['img']?&gt;/logo.gif);
}
</pre></p>
<h3>Your HTML Template</h3>
<p>Then in your template you add the link to the stylesheet. Personally i put it in the &#8220;_HeadTag.php&#8221; component.</p>
<p><pre class="brush: xml;">
&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?=$this-&gt;MakeLink('css', 'dynamic')?&gt;&quot; /&gt;
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/orqi.wordpress.com/155/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/orqi.wordpress.com/155/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orqi.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orqi.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orqi.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orqi.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/orqi.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/orqi.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/orqi.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/orqi.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orqi.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orqi.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orqi.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orqi.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orqi.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orqi.wordpress.com/155/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=155&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://orqi.wordpress.com/2008/07/28/dynamic-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1a7d93abb89936c9c7f1e08089d3ef22?s=96&#38;d=identicon" medium="image">
			<media:title type="html">orqi</media:title>
		</media:content>
	</item>
		<item>
		<title>Your First Widget</title>
		<link>http://orqi.wordpress.com/2008/07/28/your-first-widget/</link>
		<comments>http://orqi.wordpress.com/2008/07/28/your-first-widget/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 15:27:06 +0000</pubDate>
		<dc:creator>orqi</dc:creator>
				<category><![CDATA[Examples / Tutorials]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://orqi.wordpress.com/?p=174</guid>
		<description><![CDATA[Create a directory in your widgets directory named after your widget. It must be lower case and no spaces. In our example, let&#8217;s call the directory something like &#8220;mywidget&#8221;. You will need a Controller class in the directory that extends the WidgetController and you should name it&#8217;s file &#8220;Controller.php&#8221;. The code should look like this: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=174&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span id="more-174"></span>Create a directory in your widgets directory named after your widget. <strong>It must be lower case and no spaces.</strong></p>
<p>In our example, let&#8217;s call the directory something like &#8220;mywidget&#8221;. You will need a Controller class in the directory that extends the WidgetController and you should name it&#8217;s file &#8220;Controller.php&#8221;. The code should look like this: -</p>
<p><pre class="brush: php;">
class MyWidgetController extends WidgetController
{
	function Home()
	{
		$this-&gt;LoadWidget(&quot;mywidget&quot;, &quot;Home&quot;);
	}
}
</pre></p>
<p>Every widget controller should have a Home() function in it, as this is looked for and called by Orqi when it tries to run or call a widget.</p>
<p>The LoadWidget() function in the code is the equivalent of the LoadComponent() function in the Controller superclass and you use it to return HTML to the user. It takes in the current widget name and the component name you are calling.</p>
<p>The HTML templates for the widgets should be put in the widget directory with the controller and they should be prefixed with an underscore, much the same as components.</p>
<p><pre class="brush: xml;">
&lt;h3&gt;My Widget&lt;/h3&gt;
&lt;p&gt;Example HTML stuff.&lt;/p&gt;
&lt;p&gt;You can even say hi to &lt;?=$this-&gt;session-&gt;user-&gt;GetUsername()?&gt;,
if they are logged in&lt;/p&gt;
</pre></p>
<p>If you copy the above code, create a file called &#8220;_Home.php&#8221; in your widget directory and put the code in it that&#8217;s pretty much all you need to do to have a functioning widget working.</p>
<h3>Running the Widget</h3>
<p>If you go back to the main project, in any template add the following HTML/PHP</p>
<p><pre class="brush: php;">
&lt;? $this-&gt;LoadComponent(&quot;WidgetContainer&quot;, &quot;mywidget&quot;); ?&gt;
</pre></p>
<h3>Linking to screens in widgets</h3>
<p>The WidgetController actually provides support for constructing your links in your widget html. If you use MakeWidgetLink() you can provide links for users that will keep them within the bounds of the widget and you can still access MakeLink() if you want to send users to brand new pages altogether.</p>
<p><pre class="brush: xml;">
&lt;p&gt;&lt;a href=&quot;#&quot; onclick=&quot;&lt;?=$this-&gt;MakeWidgetLink('mywidget', 'anotherpage')?&gt;&quot;&gt;Go to another screen!&lt;/a&gt;&lt;/p&gt;
</pre></p>
<p>OK in typical Orqi fashion, for every action we expect to run in a controller there needs to be a function. &#8220;mywidget&#8221; tells Orqi to look for the &#8220;mywidget&#8221; directory in the &#8220;_widgets&#8221; directory and look for &#8220;Controller.php&#8221;.</p>
<p>&#8220;Anotherpage&#8221; tells Orqi to have a look in the controller for a function called &#8220;Anotherpage&#8221; and in that function we can execute our commands and display view, etc.</p>
<p><pre class="brush: php;">
function Anotherpage()
{
	$this-&gt;LoadWidget(&quot;mywidget&quot;, &quot;Anotherpagetemplate&quot;);
}
</pre></p>
<p>As you can see the LoadWidget() function is going to look for a template called &#8220;_Anotherpagetemplate.php&#8221;. If you create that file and paste the following code into it then you will have a working copy of a widget with links.</p>
<p>Notice that the new screen has a link back to the Home screen.</p>
<p><pre class="brush: xml;">
&lt;h3&gt;My Widget&lt;/h3&gt;
&lt;p&gt;Another page&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;#&quot; onclick=&quot;&lt;?=$this-&gt;MakeWidgetLink('mywidget', 'home')?&gt;&quot;&gt;back home&lt;/a&gt;&lt;/p&gt;
</pre></p>
<p>If you try the widget again you will notice that you can now link between the screens.</p>
<h3>Quick Word On Forms</h3>
<p>Just a quick word on posting forms in widgets. The supporting javascript that is loaded with the widget divs in the &#8220;WidgetContainer&#8221; component comes with a PostForm function that will submit the request for you without loading an entirely new page.</p>
<p>All you have to remember is the following (see the code below)</p>
<ul>
<li>set the onsubmit attribute to &#8220;return false;&#8221;</li>
<li>the action should be set to where you would normally post the form to (at the moment you should set it yourself)</li>
<li>the submit button needs to call the PostForm() function in its onclick attribute</li>
</ul>
<p><pre class="brush: xml;">
&lt;form
	method=&quot;post&quot;
	action=&quot;/widget/mywidget/somefunction.html&quot;
	id='mywidget_form'
	onsubmit=&quot;return false;&quot;&gt;
	
	&lt;button onclick=&quot;javascript: rh_mywidget.PostForm('mywidget_form');&quot;&gt;Submit&lt;/button&gt;
&lt;/form&gt;
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/orqi.wordpress.com/174/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/orqi.wordpress.com/174/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orqi.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orqi.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orqi.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orqi.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/orqi.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/orqi.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/orqi.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/orqi.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orqi.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orqi.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orqi.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orqi.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orqi.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orqi.wordpress.com/174/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=174&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://orqi.wordpress.com/2008/07/28/your-first-widget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1a7d93abb89936c9c7f1e08089d3ef22?s=96&#38;d=identicon" medium="image">
			<media:title type="html">orqi</media:title>
		</media:content>
	</item>
		<item>
		<title>Mapper Classes / Code Generator</title>
		<link>http://orqi.wordpress.com/2008/07/25/mapper-classes-code-generator/</link>
		<comments>http://orqi.wordpress.com/2008/07/25/mapper-classes-code-generator/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 10:49:43 +0000</pubDate>
		<dc:creator>orqi</dc:creator>
				<category><![CDATA[Classes]]></category>
		<category><![CDATA[Code Generators]]></category>
		<category><![CDATA[code generator]]></category>
		<category><![CDATA[lazy loading]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[object linking]]></category>

		<guid isPermaLink="false">http://orqi.wordpress.com/?p=120</guid>
		<description><![CDATA[You can create your own mappers if you like, but there are code generators to help you at http://www.orqi.co.uk/mapper-class-generator.html All domain classes should extend the Mapper superclass so that you can take advantage of the auto functions ! If have a table like this &#8230; You should fill in the mapper form like this (explanation [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=120&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span id="more-120"></span>You can create your own mappers if you like, but there are code generators to help you at <a href="http://www.orqi.co.uk/mapper-class-generator.html">http://www.orqi.co.uk/mapper-class-generator.html</a></p>
<p>All domain classes should extend the Mapper superclass so that you can take advantage of the auto functions !</p>
<p>If have a table like this &#8230;<br />
<pre class="brush: sql;">
CREATE TABLE `blogcomments` (
  `id` int(11) NOT NULL auto_increment,
  `posts_id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `timestamp` int(11) NOT NULL,
  `approved` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
</pre></p>
<p>You should fill in the mapper form like this (explanation to follow) &#8230;</p>
<p><a href="http://orqi.files.wordpress.com/2008/07/picture-12.png"><img src="http://orqi.files.wordpress.com/2008/07/picture-12.png?w=171&#038;h=300" alt="" width="171" height="300" class="alignnone size-medium wp-image-121" /></a></p>
<p>The &#8220;posts_id&#8221; field in the database table is a link to the &#8220;posts&#8221; table. This means that the BlogComment object being passed into our mapper will most likely have an object as one of it&#8217;s members. So this means we need to give it the object&#8217;s name as well. Hence &#8220;posts_id, post&#8221;.</p>
<p>The &#8220;name&#8221; and &#8220;email&#8221; values you will notice are surrounded by quotemarks. This is because these fields are text and need surrounding by quote marks in the insert/update sql statements. Putting the quotemarks simply tells Orqi to do this as well.</p>
<p>Hit &#8220;Generate&#8221; and you will get a fille looking something like this.<br />
<pre class="brush: php;">
// ================================================================================= //		

class BlogComments extends Mapper
{
	// ============================================================================= //

	function BlogComments()
	{
		$this-&gt;config = new Config();
		$this-&gt;dao = new DAO();
	}
	
	// ============================================================================= //
	
	function GetSelectBoxData()
	{
		$data = array();
		
		$sql_string = &quot;select id as value, name as text from blogcomments order by name asc&quot;;
		$recordset = $this-&gt;dao-&gt;ExecuteQuery($sql_string);
		if ($recordset) while ($record = mysql_fetch_assoc($recordset)) $data[] = $record;
		
		return $data;
	}
	
	// ============================================================================= //
	
	function GetTotalRows()
	{
		$recordset = $this-&gt;dao-&gt;ExecuteQuery(&quot;select count(*) as total_rows from blogcomments&quot;);
		$record = mysql_fetch_assoc($recordset);
		return $record['total_rows'];
	}
	
	// ============================================================================= //
	
	function FindAll($page='')
	{
		$data = array();
		$sql_string = &quot;select * from blogcomments order by name&quot;;
		
		if (!empty($page))
		{
			$cursor = ($page-1) * $this-&gt;config-&gt;page['items'];
			$sql_string .= &quot;
				limit		&quot; . $cursor . &quot;, &quot; . $this-&gt;config-&gt;page['items'] . &quot;
			&quot;;
		}

		$recordset = $this-&gt;dao-&gt;ExecuteQuery($sql_string);
		if ($recordset) while ($record = mysql_fetch_assoc($recordset)) $data[] = Caster::Cast($record, new BlogComment());
		return $data;
	}
	
	// ============================================================================= //
	
	function Save(&amp;$object)
	{
		$action_text = (!$object-&gt;GetId()) ? &quot;insert into &quot; : &quot;update &quot;;
		if ($object-&gt;GetId()) $condition = &quot;where id=&quot; . $object-&gt;GetId();
		
		$obj_post = $object-&gt;GetPost();

		$sql_string = &quot;
			$action_text	blogcomments
			set				posts_id=&quot; . $obj_post-&gt;GetId() . &quot;,
							name='&quot; . $object-&gt;GetName() . &quot;',
							email='&quot; . $object-&gt;GetEmail() . &quot;',
							timestamp=&quot; . $object-&gt;GetTimestamp() . &quot;,
							approved=&quot; . $object-&gt;GetApproved() . &quot;
			$condition
		&quot;;

		if ($this-&gt;dao-&gt;ExecuteQuery($sql_string))
		{
			$this-&gt;success = true;
			if (!$object-&gt;GetId()) $object-&gt;SetId(mysql_insert_id($this-&gt;dao-&gt;conn));
		}
		else $this-&gt;success = false;
		return $this-&gt;success;
	}
	
	// ============================================================================= //
}

// ================================================================================= //
</pre></p>
<h3>Explanation of the functions</h3>
<p>Here is a quick explanation of the functions in this class &#8230;</p>
<h4>Constructor</h4>
<p>The constructor just instantiates a couple of class variables that we will need pretty much every funtion. The DAO object is obvious since most mappers have to talk to a database at some point their lives. The Config object is there so we can access stuff like the paging variables.<br />
<pre class="brush: php;">
function BlogComments()
{
	$this-&gt;config = new Config();
	$this-&gt;dao = new DAO();
}
</pre></p>
<h4>GetSelectBoxData</h4>
<p>This function provides a full list of the table in a value/text pair form.<br />
<pre class="brush: php;">
function GetSelectBoxData()
{
	$data = array();
	
	$sql_string = &quot;select id as value, name as text from blogcomments order by name asc&quot;;
	$recordset = $this-&gt;dao-&gt;ExecuteQuery($sql_string);
	if ($recordset) while ($record = mysql_fetch_assoc($recordset)) $data[] = $record;
	
	return $data;
}
</pre></p>
<h4>GetTotalRows</h4>
<p>Returns the total number of rows in the table.<br />
<pre class="brush: php;">
function GetTotalRows()
{
	$recordset = $this-&gt;dao-&gt;ExecuteQuery(&quot;select count(*) as total_rows from blogcomments&quot;);
	$record = mysql_fetch_assoc($recordset);
	return $record['total_rows'];
}
</pre></p>
<h4>FindAll</h4>
<p>This will return either a page of items or if no page parameter is passed, all the items in the table.<br />
<pre class="brush: php;">
function FindAll($page='')
{
	$data = array();
	$sql_string = &quot;select * from blogcomments order by name&quot;;
	
	if (!empty($page))
	{
		$cursor = ($page-1) * $this-&gt;config-&gt;page['items'];
		$sql_string .= &quot;
			limit		&quot; . $cursor . &quot;, &quot; . $this-&gt;config-&gt;page['items'] . &quot;
		&quot;;
	}

	$recordset = $this-&gt;dao-&gt;ExecuteQuery($sql_string);
	if ($recordset) while ($record = mysql_fetch_assoc($recordset)) $data[] = Caster::Cast($record, new BlogComment());
	return $data;
}
</pre></p>
<p><strong>Note:</strong> That the Caster is being used to return an object as opposed to just associative mysql array.</p>
<h4>Save</h4>
<p>This will save the object passed to it. Note that the parameter is passed by reference. This is to try and mimic java a little bit so that back in the calling function we can use the id after an insert easily.<br />
<pre class="brush: php;">
function Save(&amp;$object)
{
	$action_text = (!$object-&gt;GetId()) ? &quot;insert into &quot; : &quot;update &quot;;
	if ($object-&gt;GetId()) $condition = &quot;where id=&quot; . $object-&gt;GetId();
	
	$obj_post = $object-&gt;GetPost();

	$sql_string = &quot;
		$action_text	blogcomments
		set				posts_id=&quot; . $obj_post-&gt;GetId() . &quot;,
						name='&quot; . $object-&gt;GetName() . &quot;',
						email='&quot; . $object-&gt;GetEmail() . &quot;',
						timestamp=&quot; . $object-&gt;GetTimestamp() . &quot;,
						approved=&quot; . $object-&gt;GetApproved() . &quot;
		$condition
	&quot;;

	if ($this-&gt;dao-&gt;ExecuteQuery($sql_string))
	{
		$this-&gt;success = true;
		if (!$object-&gt;GetId()) $object-&gt;SetId(mysql_insert_id($this-&gt;dao-&gt;conn));
	}
	else $this-&gt;success = false;
	return $this-&gt;success;
}
</pre></p>
<p><strong>Note:</strong> Even though there is a validator framework to check for errors, this function may soon have a type check at the start to trap invalid objects being passed &#8230;<br />
<pre class="brush: php;">
// something like this (in the example)
if (!is_a($object, 'BlogComment')) return false;
</pre></p>
<h3>Common Usages</h3>
<p><pre class="brush: php;">
$control = new SelectBox($this-&gt;config, &quot;Usergroups&quot;, &quot;usergroups_id&quot;, &quot;&quot;, &quot;&quot;, $this-&gt;form-&gt;GetUsergroupId(), 'level &lt;=' . $this-&gt;session-&gt;user_usergroup-&gt;GetLevel());
</pre></p>
<h4>List Page</h4>
<p><pre class="brush: php;">
class AdvertController extends Controller
{
	function All()
	{
		$this-&gt;object = new Adverts();
		$this-&gt;data = $this-&gt;object-&gt;FindAll($this-&gt;page['current']);
		$this-&gt;LoadTemplate(&quot;ListAdverts&quot;);
	}
}		
</pre></p>
<h4>Saving Stuff</h4>
<p><pre class="brush: php;">
$blogcomments_mapper = new BlogComments();
$blogcomment = new BlogComment();
$blogcomment-&gt;SetPost(new Post(1));
$blogcomment-&gt;SetName('N E Commenter');
$blogcomment-&gt;SetEmail('n.e.commenter@gmail.com');
$blogcomment-&gt;SetTimestamp(mktime());
$blogcomment-&gt;SetApproved(1);
$blogcomments_mapper-&gt;Save($blogcomment);
</pre></p>
<h4>In Model Classes</h4>
<p><pre class="brush: php;">
class Post extends Object
{
	var $comments = array();
	
	function GetComments()
	{
		if (empty($this-&gt;comments))
		{
			$blogcomments_mapper = new BlogComments();
			$this-&gt;comments = $blogcomments_mapper-&gt;FindByPost($this);
		}
		return $this-&gt;comments;
	}
}
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/orqi.wordpress.com/120/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/orqi.wordpress.com/120/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orqi.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orqi.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orqi.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orqi.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/orqi.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/orqi.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/orqi.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/orqi.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orqi.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orqi.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orqi.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orqi.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orqi.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orqi.wordpress.com/120/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=120&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://orqi.wordpress.com/2008/07/25/mapper-classes-code-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1a7d93abb89936c9c7f1e08089d3ef22?s=96&#38;d=identicon" medium="image">
			<media:title type="html">orqi</media:title>
		</media:content>

		<media:content url="http://orqi.files.wordpress.com/2008/07/picture-12.png?w=171" medium="image" />
	</item>
		<item>
		<title>The Site Configuration File</title>
		<link>http://orqi.wordpress.com/2008/07/24/the-site-configuration-file/</link>
		<comments>http://orqi.wordpress.com/2008/07/24/the-site-configuration-file/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 16:44:24 +0000</pubDate>
		<dc:creator>orqi</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[config file]]></category>

		<guid isPermaLink="false">http://orqi.wordpress.com/?p=107</guid>
		<description><![CDATA[The following is an explanation of the config file variables. Also explain how people should set up the config file for their particular server. Page / Paging Variables Typical values shown &#8230; Database Connection Variables These are the database details. Typical values shown &#8230; Application Variables These are the application variables. Typical values shown (the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=107&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span id="more-107"></span>The following is an explanation of the config file variables. Also explain how people should set up the config file for their particular server.<br />
<pre class="brush: php;">
$config = new Config();
</pre></p>
<h3>Page / Paging Variables</h3>
<p>Typical values shown &#8230;<br />
<pre class="brush: php;">
$config-&gt;page['referer']; // set automatically
$config-&gt;page['current']; // set automatically
$config-&gt;page['items'] = 20;
</pre></p>
<h3>Database Connection Variables</h3>
<p>These are the database details. Typical values shown &#8230;<br />
<pre class="brush: php;">
$config-&gt;db['host'] = 'localhost';
$config-&gt;db['name'] = 'databasenamehere';
$config-&gt;db['user'] = 'yourusername';
$config-&gt;db['pass'] = 'yourpassword';
</pre></p>
<h3>Application Variables</h3>
<p>These are the application variables. Typical values shown (the telephotos website used as an example in this case) &#8230;<br />
<pre class="brush: php;">
$this-&gt;app['location'] = &quot;http://telephotos.co.uk&quot;;
$this-&gt;app['title'] = &quot;Telephotos&quot;;
$this-&gt;app['author'] = &quot;David George Hamilton&quot;;
$this-&gt;app['company'] = &quot;Something Easy To Remember Ltd&quot;;
$this-&gt;app['default_lang'] = &quot;English&quot;;
$this-&gt;app['mod_rewrite'] = true;
$this-&gt;app['unicode'] = true;
$this-&gt;app['cookiename'] = &quot;telephotos&quot;;
$this-&gt;app['extension'] = &quot;html&quot;;
</pre></p>
<h3>Mail Settings</h3>
<p>These variables define whether mail is setup on the server and the email address from which notices are sent. Typical values shown (the telephotos website used as an example in this case) &#8230;<br />
<pre class="brush: php;">
$this-&gt;mail['name'] = &quot;Telephotos&quot;;
$this-&gt;mail['address'] = &quot;no-reply@telephotos.co.uk&quot;;
$this-&gt;mail['enabled'] = false;
</pre></p>
<h3>Project File Location Variables</h3>
<p>These variables are used for settings the location of your project files.<br />
<pre class="brush: php;">
$this-&gt;classes['path'] = &quot;_classes&quot;;
$this-&gt;classes['domain'] = $this-&gt;classes['path'] . &quot;/_domain&quot;;
$this-&gt;classes['inf'] = $this-&gt;classes['path'] . &quot;/_inf&quot;;
$this-&gt;classes['app'] = $this-&gt;classes['path'] . &quot;/_app&quot;;
$this-&gt;classes['ui'] = $this-&gt;classes['path'] . &quot;/_ui/_&quot; . strtolower($this-&gt;app['client']);
</pre></p>
<h3>Orqi Location Variables</h3>
<p>These variables are used for setting the location of the Orqi files.<br />
<pre class="brush: php;">
$this-&gt;orqi['path'] = &quot;_orqi&quot;;
$this-&gt;orqi['domain'] = $this-&gt;orqi['path'] . &quot;/_domain&quot;;
$this-&gt;orqi['app'] = $this-&gt;orqi['path'] . &quot;/_app&quot;;
$this-&gt;orqi['inf'] = $this-&gt;orqi['path'] . &quot;/_inf&quot;;
$this-&gt;orqi['ui'] = $this-&gt;orqi['path'] . &quot;/_ui/_&quot; . strtolower($this-&gt;app['client']);
</pre></p>
<h3>Resource Variables</h3>
<p>These variables are used for settings the location of front end stuff like images, css and javascript. The first two in the list &#8216;url&#8217; and &#8216;path&#8217; are for uploads. &#8216;path&#8217; is the physical location in the directory structure on the server and &#8216;url&#8217; is the address you then type into the browser to reach the uploaded file. Typical values shown (the telephotos website used as an example in this case) …<br />
<pre class="brush: php;">
$this-&gt;resource['path'] = '/home/htdocs/telephotos.co.uk';
$this-&gt;resource['url'] = $this-&gt;app['location'];
$this-&gt;resource['img'] = $this-&gt;app['location'] . '/_img/_' . strtolower($this-&gt;app['client']);
$this-&gt;resource['css'] = $this-&gt;app['location'] . '/_css/_' . strtolower($this-&gt;app['client']);
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/orqi.wordpress.com/107/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/orqi.wordpress.com/107/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orqi.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orqi.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orqi.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orqi.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/orqi.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/orqi.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/orqi.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/orqi.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orqi.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orqi.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orqi.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orqi.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orqi.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orqi.wordpress.com/107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=107&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://orqi.wordpress.com/2008/07/24/the-site-configuration-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1a7d93abb89936c9c7f1e08089d3ef22?s=96&#38;d=identicon" medium="image">
			<media:title type="html">orqi</media:title>
		</media:content>
	</item>
		<item>
		<title>Database Tables / Naming Conventions</title>
		<link>http://orqi.wordpress.com/2008/07/24/database-tables-naming-conventions/</link>
		<comments>http://orqi.wordpress.com/2008/07/24/database-tables-naming-conventions/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 16:03:46 +0000</pubDate>
		<dc:creator>orqi</dc:creator>
				<category><![CDATA[Framework Info]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database tables]]></category>
		<category><![CDATA[naming conventions]]></category>
		<category><![CDATA[tables]]></category>

		<guid isPermaLink="false">http://orqi.wordpress.com/?p=101</guid>
		<description><![CDATA[These are taken straight from Ruby. This means: - Table names are simply the plural state of the model class names Every table has an id field it should be the primary key it should be an auto_increment field Field names should all be in lower case. If a field links to another table, its [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=101&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span id="more-101"></span>These are taken straight from Ruby. This means: -</p>
<ul>
<li>Table names are simply the plural state of the model class names</li>
<li>
Every table has an id field</p>
<ul>
<li>it should be the primary key</li>
<li>it should be an auto_increment field</li>
</ul>
</li>
<li>Field names should all be in lower case.</li>
<li>If a field links to another table, its name should be tablename_id</li>
<li>If a field links to another table, it should be declared as an index</li>
</ul>
<p>Take a look a the diagram below. It shows a sample table from a project. You will notice: -</p>
<ul>
<li>There is an id set as the primary key and setup as an auto increment field</li>
<li>
ajaxadverttypes_id is a link to another table</p>
<ul>
<li>this field respresents the links between the object and the AjaxAdvertType object.</li>
<li>you can assume from the field name that there will be a table called ajaxadverttypes</li>
</ul>
</li>
<li>all the field names are in lowercase.</li>
</ul>
<p><pre class="brush: sql;">
CREATE TABLE `ajaxadverts` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(255) NOT NULL,
  `subtitle` varchar(255) NOT NULL,
  `details` text NOT NULL,
  `image` varchar(255) NOT NULL,
  `bkgimage` varchar(255) NOT NULL,
  `buylink` varchar(255) NOT NULL,
  `infolink` varchar(255) NOT NULL,
  `ajaxadverttypes_id` int(11) NOT NULL,
  `cssname` varchar(255) NOT NULL,
  `usage` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `AJAXADVERTTYPE` (`ajaxadverttypes_id`)
) ENGINE=MyISAM  AUTO_INCREMENT=1;
</pre></p>
<p><a href="http://orqi.files.wordpress.com/2008/07/picture-3.png"><img src="http://orqi.files.wordpress.com/2008/07/picture-3.png?w=300&#038;h=198" alt="" width="300" height="198" class="alignnone size-medium wp-image-102" /></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/orqi.wordpress.com/101/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/orqi.wordpress.com/101/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/orqi.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/orqi.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/orqi.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/orqi.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/orqi.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/orqi.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/orqi.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/orqi.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/orqi.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/orqi.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/orqi.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/orqi.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/orqi.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/orqi.wordpress.com/101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=orqi.wordpress.com&amp;blog=4294735&amp;post=101&amp;subd=orqi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://orqi.wordpress.com/2008/07/24/database-tables-naming-conventions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1a7d93abb89936c9c7f1e08089d3ef22?s=96&#38;d=identicon" medium="image">
			<media:title type="html">orqi</media:title>
		</media:content>

		<media:content url="http://orqi.files.wordpress.com/2008/07/picture-3.png?w=300" medium="image" />
	</item>
	</channel>
</rss>
