Coder Profile - Show off your skills, get a coder profile.
 
 
 
Example Framework Implementation 284 2
PHP (Hypertext Preprocessor) Views Comments
MS SQL Pagination 364 0
SQL (Structured Query Language) Views Comments
MS SQL - MySQL for indra 414 0
SQL (Structured Query Language) Views Comments
Bitwise Boolean Inverse 418 4
C Views Comments
PHP-GTK Port Scaner 403 0
PHP (Hypertext Preprocessor) Views Comments
Page 1 of 1
Example Framework Implementation
  
Public URL http://www.coderprofile.com/pinned-code/228/example-framework-implementation
Language PHP (Hypertext Preprocessor)
Expires Never
Length 3,233 Characters (109 Lines)
Password no password
Download Download Source Code
Source Code
  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. ?>
Please login to post comments.
 
Craige     Posted 1.47 Year 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 1.47 Year 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
Craige Leeder (20)
Canada, Ontario
Craige has 5 fans
become a fan
» Applications
Source Codes Source Codes (2)
Code Pin Board Code Pin Board (5)
» About Me
About Me About Me
Friends Friends (17)
Résumé Résumé
» Misc
Overview Overview
Send A Friend Invite
Send Message Send A Message
RSS Whole Profile Feed
 
 
Latest News About Coder Profile
Coder Profile Poll
If you made money from keeping your profile up to date, say $30 and up, per month. What extra time would you spend on your profile?

No extra time
A few hours at weekends
A whole day each week
Every minute i can get free


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