/** * Test to send a real-world message * * @return void */ public function testSendEmail() { require 'fixtures/message.php'; $postmark = IoC::resolve('postmark'); $return = $postmark->send(new Message('*****@*****.**')); $this->assertTrue($return); }
/** * * @param string $name * @return object */ public function __get($name) { self::$called_class = get_called_class(); if (method_exists('\\system\\services\\SystemServiceRegistry', $name) || method_exists('\\application\\services\\AppServiceRegistry', $name)) { return IoC::resolve($name); } }
private function _isUnread() { if (Auth::guest()) { return false; } $markAsReadAfter = value(Config::get('forums::forums.mark_as_read_after')); if (!IoC::registered('topicsview')) { IoC::singleton('topicsview', function () use($markAsReadAfter) { return Forumview::where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter))->where('user_id', '=', Auth::user()->id)->lists('topic_id'); }); } $tv = IoC::resolve('topicsview'); $nb = count($tv); $view = Forumtopic::where('forumcategory_id', '=', $this->id)->where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter)); if ($nb > 0) { $view = $view->where_not_in('id', $tv); } $view = $view->count(); if ($nb == 0 && $view > 0) { return true; } if ($view > 0) { return true; } return false; }
function page_status() { if ($itm = IoC::resolve('page')) { return $itm->status; } return ''; }
private static function parse() { // get uri $uri = Request::uri(); // lets log our initial uri Log::info('Requested URI: ' . $uri); // route definitions $routes = array(); // posts host page if ($page = IoC::resolve('posts_page')) { $routes[$page->slug . '/(:any)'] = 'article/$1'; } // fallback to 'admin' $admin_folder = Config::get('application.admin_folder', 'admin'); // static routes $routes = array_merge($routes, array($admin_folder . '/(:any)/(:any)/(:any)' => 'admin/$1/$2/$3', $admin_folder . '/(:any)/(:any)' => 'admin/$1/$2', $admin_folder . '/(:any)' => 'admin/$1', $admin_folder => 'admin', 'search/(:any)' => 'search/$1', 'search' => 'search', 'rss' => 'rss', '(:any)' => 'page/$1')); // define wild-cards $search = array(':any', ':num'); $replace = array('[0-9a-zA-Z~%\\.:_\\-]+', '[0-9]+'); // parse routes foreach ($routes as $route => $translated) { // replace wildcards $route = str_replace($search, $replace, $route); // look for matches if (preg_match('#^' . $route . '#', $uri, $matches)) { // replace matched values foreach ($matches as $k => $match) { $translated = str_replace('$' . $k, $match, $translated); } // return on first match return $translated; } } return $uri; }
public function action_index() { $markdown = IoC::resolve('markdown'); $data['toc'] = $markdown->transform(File::get(VIEW_PATH . 'contents.md')); $data['default_contents'] = $markdown->transform(File::get(VIEW_PATH . 'start/install.md')); return View::make('home.index', $data); }
function is_postspage() { if ($itm = IoC::resolve('page')) { return $itm->id == Config::get('metadata.posts_page'); } return false; }
function menu_active() { if ($itm = IoC::resolve('menu_item')) { return $itm->active; } return ''; }
function comments_open() { if ($itm = IoC::resolve('article')) { return $itm->comments ? true : false; } return false; }
public function post_review() { $this->filter('before', 'jboardOnly'); $input = Input::all(); //grab our input $rules = array('decision' => 'required', 'denyreason' => 'required', 'initials' => 'required|alpha|min:2', 'amtreduce' => 'numeric', 'details' => 'required'); //validation rules $validation = Validator::make($input, $rules); //let's run the validator if ($validation->fails()) { return Redirect::to('jboard/review/' . Input::get('ticketid'))->with_errors($validation); } //insert ruling into database Ruling::create(array('decision' => Input::get('decision'), 'denyreason' => Input::get('denyreason'), 'reasoning' => Input::get('details'), 'intials' => Input::get('initials'), 'CWID' => Input::get('cwid'), 'amtReduce' => Input::get('amtreduce'), 'ticketID' => Input::get('ticketid'))); //let's close the ticket now $close = DB::table('tickets')->where('ticketID', '=', Input::get('ticketid'))->update(array('appealStatus' => '1')); return Redirect::to('jboard/')->with('alertMessage', 'Ruling submitted successfully.'); DB::table('tickets')->where('ticketID', '=', Input::get('ticketid'))->update(array('appealStatus' => '1')); ///////////////////// // Now we're going to email the appellant to let them know that their appeal has been reviewed. ///////////////////// // Get the Swift Mailer instance $mailer = IoC::resolve('mailer'); //set the appellant's email address using CWID $email = Input::get('cwid') . '@marist.edu'; //set html body of email $body = "This autogenerated email is to let you know that your appeal has been reviewed and closed by the Justice Board. Please login to the Online Parking Appeal System at <a href='http://sga.marist.edu/parkingappeals/'>http://sga.marist.edu/parkingappeals/</a>. Please do not reply to this message. <br><br> Thank you, <br> Student Government Association Justice Board"; // Construct the message $message = Swift_Message::newInstance('[Marist SGA] Your Parking Appeal Has Been Reviewed')->setFrom(array('*****@*****.**' => 'SGA Judicial Board'))->setTo(array($email => 'Appellant'))->addPart('This email is autogenerated to let you know that your appeal has been reviewed by the Justice Board. Please login to the Online Parking Appeal System at http://sga.marist.edu/parkingappeals to review the decision. ', 'text/plain')->setBody($body, 'text/html'); // Send the email $mailer->send($message); return Redirect::to('jboard/')->with('alertMessage', 'Ruling submitted successfully.'); }
/** * run() is the start-point of the CLI request, the * first argument specifies the command, and sub-sequent * arguments are passed as arguments to the chosen generator. * * @param $arguments array The command and its arguments. * @return void */ public function run($arguments = array()) { if (!count($arguments)) { $this->_help(); } // setup ansi support Common::detect_windows(); // assign the params $command = $arguments[0] !== '' ? $arguments[0] : 'help'; $args = array_slice($arguments, 1); switch ($command) { case "controller": case "c": new Generators_Controller($args); break; case "model": case "m": new Generators_Model($args); break; case "alias": new Generators_Alias($args); break; case "migration": case "mig": IoC::resolve('task: migrate')->make($args); break; case "bundle": case "b": new Generators_Bundle($args); break; case "test": case "t": new Generators_Test($args); break; case "task": case "ta": new Generators_Task($args); break; case "class": case "cl": new Generators_Class($args); break; case "install": case "i": IoC::resolve('task: bundle')->install($args); break; case "config": case "co": new Generators_Config($args); break; case "view": case "v": new Generators_View($args); break; default: $this->_help(); break; } }
/** * Run the test and create a TestLog. */ public function run() { $tester = IoC::resolve('tester'); $passed = $tester->test($this->type, $this->url, $this->options); $message = $passed ? 'Test Passed' : 'Test Failed'; #todo: more descriptive messages Test\Log::create(array('test_id' => $this->id, 'message' => $message, 'passed' => $passed)); }
public function action_index($folder = null) { //if ( ! Request::ajax()) //return; //Bundle::start('juploader'); $uploader = IoC::resolve('Uploader'); $uploader->with_uploader('Uploader\\DatabaseUploadHandler')->with_argument('1')->with_option('script_url', URL::to_action('juploader::dbupload@index'))->Start(); return $uploader->get_response(); }
public static function generate() { // create a dom xml object static::$document = new DOMDocument('1.0', 'UTF-8'); // create our rss feed $rss = static::element('rss', null, array('version' => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom')); static::$document->appendChild($rss); // create channel $channel = static::element('channel'); $rss->appendChild($channel); // title $title = static::element('title', Config::get('metadata.sitename')); $channel->appendChild($title); // link $url = 'http://' . $_SERVER['HTTP_HOST']; $link = static::element('link', $url); $channel->appendChild($link); // description $description = static::element('description', Config::get('metadata.description')); $channel->appendChild($description); // laguage // http://www.rssboard.org/rss-language-codes $language = static::element('language', Config::get('application.language', 'en')); $channel->appendChild($language); $ttl = static::element('ttl', 60); $channel->appendChild($ttl); $docs = static::element('docs', 'http://blogs.law.harvard.edu/tech/rss'); $channel->appendChild($docs); $copyright = static::element('copyright', Config::get('metadata.sitename')); $channel->appendChild($copyright); // atom self link $atom = static::element('atom:link', null, array('href' => $url, 'rel' => 'self', 'type' => 'application/rss+xml')); $channel->appendChild($atom); // articles $params = array('status' => 'published', 'sortby' => 'id', 'sortmode' => 'desc'); foreach (Posts::list_all($params) as $post) { $item = static::element('item'); $channel->appendChild($item); // title $title = static::element('title', $post->title); $item->appendChild($title); // link $url = 'http://' . $_SERVER['HTTP_HOST'] . Url::make(IoC::resolve('posts_page')->slug . '/' . $post->slug); $link = static::element('link', $url); $item->appendChild($link); // description $description = static::element('description', $post->description); $item->appendChild($description); // date $date = static::element('pubDate', date(DATE_RSS, $post->created)); $item->appendChild($date); } // dump xml tree return static::$document->saveXML(); }
function search_results() { $posts = IoC::resolve('search'); if ($result = $posts->valid()) { // register single post IoC::instance('article', $posts->current(), true); // move to next $posts->next(); } return $result; }
public static function call($name = '') { $page = IoC::resolve('page'); if (empty($name)) { $name = 'main'; } if ($func = isset(static::$stack[$page->slug][$name]) ? static::$stack[$page->slug][$name] : false) { return is_callable($func) ? $func() : ''; } return ''; }
function posts_prev($text = 'Previous', $default = '') { $per_page = Config::get('metadata.posts_per_page'); $offset = Input::get('offset', 0); $total = IoC::resolve('total_posts'); $pages = ceil($total / $per_page); $page = $offset / $per_page; if ($offset > 0) { return '<a href="' . current_url() . '?offset=' . ($offset - $per_page) . '">' . $text . '</a>'; } return $default; }
public function __construct() { parent::__construct(); $this->data['site_name'] = Config::get('settings::core.site_name'); $this->data['meta_title'] = ''; $this->data['meta_description'] = ''; $this->data['meta_keywords'] = ''; if (Bundle::exists('themes')) { $this->theme = IoC::resolve('Theme'); } // @TODO add fallback if themes module for // some reason is not installed/enabled $this->filter('before', 'mwi.base_controller_start', array($this)); }
function posts($params = array()) { if (has_posts() === false) { return false; } $posts = IoC::resolve('posts'); if ($result = $posts->valid()) { // register single post IoC::instance('article', $posts->current(), true); // move to next $posts->next(); } return $result; }
public static function extend($post) { if (is_array($post)) { $posts = array(); foreach ($post as $itm) { $posts[] = static::extend($itm); } return $posts; } if (is_object($post)) { $page = IoC::resolve('posts_page'); $post->url = Url::make($page->slug . '/' . $post->slug); return $post; } return false; }
public static function generate() { // create a dom xml object static::$document = new DOMDocument('1.0', 'UTF-8'); // create our rss feed $rss = static::element('rss', null, array('version' => '2.0')); static::$document->appendChild($rss); // create channel $channel = static::element('channel'); $rss->appendChild($channel); // title $title = static::element('title', Config::get('metadata.sitename')); $channel->appendChild($title); // link $link = static::element('link', 'http://' . $_SERVER['HTTP_HOST']); $channel->appendChild($link); // description $description = static::element('description', Config::get('metadata.description')); $channel->appendChild($description); // articles $params = array('status' => 'published', 'sortby' => 'id', 'sortmode' => 'desc'); foreach (Posts::list_all($params) as $post) { $item = static::element('item'); $channel->appendChild($item); // title $title = static::element('title', $post->title); $item->appendChild($title); // link $url = 'http://' . $_SERVER['HTTP_HOST'] . Url::make(IoC::resolve('posts_page')->slug . '/' . $post->slug); $link = static::element('link', $url); $item->appendChild($link); // description $description = static::element('description', $post->description); $item->appendChild($description); // date $date = static::element('pubDate', date(DATE_RSS, $post->created)); $item->appendChild($date); } // dump xml tree return static::$document->saveXML(); }
public function article($slug = '') { // find article $params = array('slug' => $slug); // allow admin to view unpublished posts if (Users::authed() === false) { $params['status'] = 'published'; } if (($article = Posts::find($params)) === false) { return Response::error(404); } // add comment if (Input::method() == 'POST') { if (Comments::add($article->id)) { $page = IoC::resolve('posts_page'); return Response::redirect($page->slug . '/' . $article->slug); } } // register single item for templating functions IoC::instance('article', $article, true); Template::render('article'); }
public function post_index() { $rules = array('issue' => 'required'); $validation = Validator::make(Input::all(), $rules); if ($validation->fails()) { Messages::add('error', 'Please make sure you fill out the form to let us know what problem you are having.'); return Redirect::to('admin/' . $this->views . '')->with_input(); } else { // Get the Swift Mailer instance $mailer = IoC::resolve('mailer'); // Construct the message $message = Swift_Message::newInstance('Message From Website')->setFrom(array($this->data['user']->email => $this->data['user']->fullname))->setTo(array('*****@*****.**' => 'Framework Support For ' . COMPANY_NAME))->setBody('<p><strong>' . $this->data['user']->fullname . ' has emailed you:</strong></p> <q>' . Input::get('issue') . '</q> <p><strong>Email Address: </strong> ' . $this->data['user']->email . '</p> <p><strong>IP Address: </strong> ' . Request::ip() . '</p> <p><strong>User Agent: </strong> ' . Request::server('HTTP_USER_AGENT') . '</p>', 'text/html'); // Send the email $mailer->send($message); Messages::add('success', '<strong>Support Issue Sent</strong> We\'ll be in touch shortly.'); return Redirect::to('admin/help'); } }
public static function extend($page) { if (is_array($page)) { $pages = array(); foreach ($page as $itm) { $pages[] = static::extend($itm); } return $pages; } if (is_object($page)) { $uri = Request::uri(); $page->url = Url::make($page->slug); $page->active = false; if ($current = IoC::resolve('page')) { if ($current->id == $page->id) { $page->active = true; } } return $page; } return false; }
</ul> </div> </div> </div> <div class="container"> <div class="row"> <div class="span3"> <h3>Tables of Contents</h3> <?php $markdown = IoC::resolve('markdown'); echo $markdown->transform(File::get(VIEW_PATH . 'contents.md')); ?> </div> <div class="span9"> <?php echo $contents; ?> </div> </div> </div> <footer> <div class='container'>
function customised() { if ($itm = IoC::resolve('article')) { return strlen($itm->css) > 0 or strlen($itm->js) > 0; } return false; }
if ($cache and !is_dir($cache)) { mkdir($cache); } /** * Register the Twig library with the auto-loader */ Laravel\Autoloader::underscored(array('Twig' => Bundle::path('twig') . 'lib/Twig')); /** * Instantiate a new Laravel Twig loader */ include 'loader.php'; /** * If it's registered in the IoC, resolve from there... otherwise use default */ if (IoC::registered('twig::loader')) { $loader = IoC::resolve('twig::loader'); } else { $loader = new Laravel_Twig_Loader($ext); } /** * Hook into the Laravel view loader */ Laravel\Event::override(Laravel\View::loader, function ($bundle, $view) use($loader, $ext) { // Use the custom Laravel Twig loader for Twig views... if (starts_with($view, 'twig|')) { return $loader->getPath($bundle, substr($view, 5)); } elseif (starts_with($bundle, 'twig|')) { return $loader->getPath(substr($bundle, 5), $view); } else { return View::file($bundle, $view); }
//default theme can also be defined in the theme bundle start.php file within the IoC container. $theme->title('Home Page'); //pass data to theme partial with theme->composer $theme->composer('header', function ($view) { $view->nest('header_main_menu', 'blog.mainmenu'); }); $theme->composer('footer', function ($view) { $view->nest('footer_menu', 'blog.mainmenu'); }); $theme->composer('featured', function ($view) { $view->nest('featured_content', 'blog.latestblogitems'); }); return $theme->render('blog.home'); }); Route::get('/(:any).html', function () { $theme = IoC::resolve('Theme'); $theme->set_theme("xayona"); //$theme->set_theme("zencode"); //we can also set a different theme if we want to use $theme->set_layout('blog'); // we have selected a different theme layout too. $theme->title('Home Page'); //pass data to theme partial with theme->composer $theme->composer('header', function ($view) { $view->nest('header_main_menu', 'blog.mainmenu'); }); $theme->composer('footer', function ($view) { $view->nest('footer_menu', 'blog.mainmenu'); }); $theme->composer('featured', function ($view) { $view->nest('featured_content', 'blog.latestblogitems'); });
$handler(new \ErrorException($message, $type, 0, $file, $line)); } }); /** * Setting the PHP error reporting level to -1 essentially forces * PHP to report every error, and is guranteed to show every error * on future versions of PHP. * * If error detail is turned off, we will turn off all PHP error * reporting and display since the framework will be displaying a * generic message and we don't want any sensitive details about * the exception leaking into the views. */ error_reporting(-1); // Added by Tienda Nube $new_relic = IoC::resolve('services.new_relic'); $new_relic->set_appname('Prod - API'); /** * Gather the input to the application based on the current request. * The input will be gathered based on the current request method and * will be set on the Input manager. */ $input = array(); switch (Request::method()) { case 'GET': $input = $_GET; break; case 'POST': $input = $_POST; break; case 'PUT':
static function format($str, array $info, $formatter) { if (is_array($str)) { foreach ($str as &$s) { $s = static::format($s, $info, $formatter); } return $str; } elseif (isset($str)) { if (is_callable($formatter)) { $str = call_user_func($formatter, $str, $info); } elseif ($formatter === 'raw') { $str = (string) $str; } elseif ($formatter === 'php') { $vars = array(); extract($info, EXTR_SKIP); ob_start(); eval("?>{$str}"); $str = $vars + array('content' => ob_get_clean()); } elseif (is_string($formatter)) { $type = trim(strtok($formatter, ':')); $class = trim(strtok('->')); $method = trim(strtok(null) ?: 'format', '> '); switch ($type) { case 'class': break; case 'ioc': $class = IoC::resolve($class, array($str, $info)); break; case 'event': $class = Event::first($class, array($str, $info)); break; default: throw new Exception("Text Publisher: invalid 'formatter' string value."); } if ($type === 'class' or is_object($class)) { $str = call_user_func(array($class, $method), $str, $info); } else { $str = $class; } } else { throw new Exception("Text Publisher: invalid 'formatter' value type."); } return ($str !== null and $str !== false) ? $str : null; } }