/** * 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); }
/** * 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.'); } }
/** * show stylesheet overview */ public function action_css() { // set topic $this->theme->topic = "CSS Overview"; // load the css overview $this->view = CCView::create('development/cssView'); }
/** * 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); }
/** * 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()); }
/** * use a view */ public function action_view() { $this->view = \CCView::create('CCUnit::test', array('foo' => 'Bar')); }
/** * 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); }
/** * Server error 500 */ public function action_500() { return CCResponse::create(CCView::create('Core::CCF/500')->render(), 500); }
/** * Set a view as message * * @param string $view * @return self */ public function view($view) { $this->message = \CCView::create($view); return $this; }
/** * 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); }