Coder Profile - Show off your skills, get a coder profile.
 
 
 
code pin board Example Framework Implementation Download Source Code
Author Details Code Information
Craige ( Craige Leeder )

Pinned 5 Codes
Posted 0 Coding Articles

Send A Message
View Coders Profile
Language PHP (Hypertext Preprocessor)
Expires Never
Length 3,233 Characters (109 Lines)
Password no password
  1. <?php
  2. $iStart = microtime();
  3.  
  4. include $_SERVER['DOCUMENT_ROOT'] . '/../Ember/system/Ember.php';
  5.  
  6. /*
  7.  * Variable initilization
  8.  */
  9.  
  10. $gcTemplateCache = true;
  11.  
  12.  
  13. /*
  14.  * Framework initilization
  15.  */
  16. Ember::setPrereq( array('iPageInput' => Ember::mciInterface,
  17.                         'iPageProcess' => Ember::mciInterface,
  18.                         'iPageDisplay' => Ember::mciInterface
  19.                        )
  20.                 );
  21.  
  22.  
  23. /*
  24.  * Class Definition
  25.  */
  26. class Page implements iPageDisplay, iPageInput {
  27.  
  28.   protected $oPage;
  29.   protected $oInput;
  30.   protected $oOutput;
  31.  
  32.  
  33.   public function __construct() {
  34.     $this->oPage = Ember::init();
  35.     $this->oPage->loadIO('html', Ember::mciOutput);
  36.     $this->oOutput = $this->oPage->Output['html'];
  37.  
  38.     $this->oOutput->setOperand('splash');
  39.     $this->oOutput->loadOperand();
  40.     $this->oOutput->setValue('title', 'Test page');
  41.   }
  42.  
  43.  
  44.   public function input() {
  45.     $this->oPage->loadIO('form', Ember::mciInput);
  46.     $this->oInput = $this->oPage->Input['form'];
  47.  
  48.     if ( $this->oOutput->getCacheStatus() == true ) {
  49.       $this->oOutput->dumpCache();
  50.       exit;
  51.     }
  52.  
  53.     /*
  54.     $oInput->sanitizeData(array('username' => array('minlen' => 3,
  55.                                                     'maxlen' => 25,
  56.                                                     'dataType' => iInput::mciString,
  57.                                                    ),
  58.                                 'password' => array('minlen' => 3,
  59.                                                     'maxlen' => 25,
  60.                                                     'dataType' => iInput::mciString,
  61.                                                     ),
  62.  
  63.                                 'firstname' => array('minlen' => 3,
  64.                                                      'maxlen' => 25,
  65.                                                      'dataType' => Input::mciInteger,
  66.                                                      ),
  67.                                 'lastname' => array('minlen' => 3,
  68.                                                     'maxlen' => 25,
  69.                                                     'dataType' => Input::mciInteger,
  70.                                                     )
  71.                                 )
  72.                          );
  73.     */
  74.   }
  75.  
  76.  
  77.   public function display() {
  78.     global $iStart;
  79.  
  80.     $this->oOutput->setValue('topics', array(array('title' => 'title 1',
  81.                                              'date' => '01/26/1990',
  82.                                              'replies' => '129'),
  83.  
  84.                                        array('title' => 'title 2',
  85.                                              'date' => '01/26/1990',
  86.                                              'replies' => '807')
  87.                                       )
  88.                       );
  89.     $this->oOutput->setValue('gen_time', (float) microtime() - $iStart);
  90.     $this->oOutput->dump();
  91.   }
  92.  
  93.  
  94. }
  95.  
  96.  
  97. /*****
  98.  * Load Page
  99.  *****/
  100. try {
  101.   Ember::setPages(new Page);
  102. }
  103. catch ( EmberException $e ) {
  104.   echo $e->getMessage();
  105. }
  106. catch ( Exception $e ) {
  107.   echo $e->getMessage();
  108. }
  109. ?>
code pin board Back To Code Pin Board Post New Code
Please login to post comments.
 
Craige     Posted 3.18 Years Ago
 
 
It is not redundant. In the demonstration, indeed it may appear so, however consider
what happens if I want to throw an exception from the end-implementation. I would be
throwing an Exception, and not an EmberException.

As well, I find it good practice to catch Exception if there is a chance it MAY be
thrown.

Additionally, so far as I know, every derived Exception class has to extend
Exception. Correct me if I'm wrong, but I do do believe that is the case.
It's all about the polymorphism.

Finally, I should note that I am further developing this implementation (of
course). All that array crap is going to be garbage soon. Ugly, and resource
intensive.
 
CyberGeek     Posted 3.18 Years Ago
 
 
Does your EmberException extend Exception? If so, remove the catch( EmberException )
block as it is redundant and not needed. EmberException would be of type Exception.
;)
Page 1 of 1
 
 
Latest News About Coder Profile
Coder Profile Poll
Why do you get bored with programming?

Not enough time to do something productive
I run out of ideas
Too hard to show people my creations
Everything i do has too many errors, and it's too hard
I don't get bored!!!


please login to cast your vote
and see the results of this poll
Latest Coder Profile Changes
Coder Profile was last updated
3.49 Years Ago
Official Blog :: Make A Donation :: Credits :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents :: Wallpapers
Version 1.46.00
Copyright © 2007 - 2012, Scott Thompson, All Rights Reserved