Example #1
0
 /**
  * Creates a new view based on the current theme
  * If the view cannot be found in the theme it's going to use the app::views
  *
  * @param string		$file
  * @param array 		$data
  * @param bool		$encode
  * @return CCView
  */
 public function view($file = null, $data = null, $encode = false)
 {
     if (\CCView::exists($view = static::view_namespace() . '::' . $file)) {
         return \CCView::create($view, $data, $encode);
     }
     return \CCView::create($file, $data, $encode);
 }
Example #2
0
 /**
  * Mail index
  */
 public function action_index()
 {
     // set our session view
     $this->view = \CCView::create('Dev::mail');
     list($from_email, $from_name) = CCConfig::create('mail')->from;
     $this->view->from_email = $from_email;
     $this->view->from_name = $from_name;
     $this->view->config_dump = nl2br(str_replace(array(" ", "\t"), array(' ', '  '), print_r(CCConfig::create('mail')->raw(), true)));
     // title
     $this->theme->topic = 'Mail Sandbox';
     // send a mail?
     if (CCIn::method('post')) {
         // send mails
         $mail = CCMail::create();
         $mail->to(CCIn::post('to'));
         $mail->from(CCIn::post('from'), CCIn::post('from_name'));
         $mail->subject(CCIn::post('subject'));
         $mail->message(CCIn::post('message'));
         foreach (explode(',', CCIn::post('bcc')) as $address) {
             $mail->bcc($address);
         }
         $mail->is_plaintext((bool) CCIn::post('plaintext', false));
         // send
         $mail->send();
         \UI\Alert::add('success', 'Mail has been send.');
     }
 }
Example #3
0
 /**
  * show stylesheet overview
  */
 public function action_css()
 {
     // set topic
     $this->theme->topic = "CSS Overview";
     // load the css overview
     $this->view = CCView::create('development/cssView');
 }
Example #4
0
 /**
  * Session index
  */
 public function action_index()
 {
     // Did we recive post values?
     if (CCIn::method('post')) {
         $this->manager->set(CCIn::post('key'), CCIn::post('value'));
     }
     // set our session view
     $this->view = \CCView::create('Dev::session');
     // title
     $this->theme->topic = 'Session Sandbox';
     // set view data
     $this->view->data_dump = print_r($this->manager->raw(), true);
     $this->view->config_dump = print_r($this->manager, true);
 }
Example #5
0
 /**
  * Set up the basic uri filters in our static init and 
  * also add a default 404 response
  *
  * @return void
  */
 public static function _init()
 {
     // default string
     static::filter('any', '[a-zA-Z0-9' . ClanCats::$config->get('router.allowed_special_chars') . ']');
     // only numbers
     static::filter('num', '[0-9]');
     // only alpha characters
     static::filter('alpha', '[a-zA-Z]');
     // only alphanumeric characters
     static::filter('alphanum', '[a-zA-Z0-9]');
     // 404 not found error
     CCRouter::on('#404', function () {
         return CCResponse::create(CCView::create('Core::CCF/404')->render(), 404);
     });
 }
 /**
  * Sign out action
  */
 public function action_fortunes()
 {
     $view = CCView::create('bench/fortune');
     $fortunes = DB::select('Fortune')->run();
     $runtimeFortune = new stdClass();
     $runtimeFortune->id = 0;
     $runtimeFortune->message = 'Additional fortune added at request time.';
     $fortunes[] = $runtimeFortune;
     usort($fortunes, function ($left, $right) {
         if ($left->message === $right->message) {
             return 0;
         } else {
             if ($left->message > $right->message) {
                 return 1;
             } else {
                 return -1;
             }
         }
     });
     $view->fortunes = $fortunes;
     return CCResponse::create($view->render());
 }
Example #7
0
 /**
  * use a view
  */
 public function action_view()
 {
     $this->view = \CCView::create('CCUnit::test', array('foo' => 'Bar'));
 }
Example #8
0
 /**
  * tests Builder loop 
  */
 public function test_array_access()
 {
     $output = CCView::create('CCUnit::builder/each_user.view', array('users' => array(array('name' => 'jeff'), array('name' => 'john'), array('name' => 'jack'))))->render();
     $expected_output = "<ul>\n\t<li>jeff</li>\n\t<li>john</li>\n\t<li>jack</li>\n</ul>";
     $this->assertEquals($expected_output, $output);
 }
Example #9
0
 /**
  * Server error 500
  */
 public function action_500()
 {
     return CCResponse::create(CCView::create('Core::CCF/500')->render(), 500);
 }
Example #10
0
 /**
  * Render the message
  *
  * @return string
  */
 public function render()
 {
     $message = $this->message;
     reset($this->to);
     // default view parameters for the message and the layout
     $params = array('mail' => $this, 'to_email' => key($this->to), 'to_name' => $this->to[key($this->to)]);
     // if the message is a view
     if ($message instanceof \CCView) {
         $message->_data = $message->_data + $params;
         $message = $message->render();
     }
     // prepare the layout
     if ($this->layout) {
         $this->layout->content = $message;
         $this->layout->_data = $this->layout->_data + $params;
         $message = $this->layout->render();
     }
     // return the renderd message
     return $message;
 }
Example #11
0
 /**
  * Test View capture
  */
 public function testRender()
 {
     // create the view
     $view = CCView::create('CCUnit::test', array('foo' => 'bar'));
     // render
     $this->assertEquals('bar', $view->render());
     // try the magic
     $this->assertEquals('bar', (string) $view);
 }