/** * Use this constructor to create a new Walleye_email class with a given email template and values. The template should not contain * the <?php ?> tags and should use #{value} to define a value * * @static * @param string $to * @param string $subject * @param string $template the email template you want to use. ex. welcome.php will be loaded from the views/email/ dir * @param array $values the values to fill the email template with * @return Walleye_email */ public static function withTemplate($to, $subject, $template, $values = array()) { if (empty($values)) { $template = file_get_contents(Walleye::getInstance()->getServerBaseDir() . 'includes/app/views/email/' . $template); } else { foreach ($values as $tag => $value) { $template = preg_replace('/(#\\{' . $tag . '\\}?)/m', $value, file_get_contents(Walleye::getInstance()->getServerBaseDir() . 'includes/app/views/email/' . $template)); } } $instance = new \Walleye\Email($to, $subject, $template); return $instance; }
/** * Use this function to add a general log to the Logs table * * @static * @param string $message * @param string $file * @param string $line * @param boolean $store */ public static function log($message, $file = 'unknown file', $line = 'unknown line', $store = true, $type = 'log') { $logItem = array('type' => $type, 'message' => $message, 'file' => $file, 'line' => $line); $options = Walleye::getInstance()->getAppOptions(); if ($store && $options['LOG_ERRORS']) { $log_id = self::storeLog($logItem); if ($log_id) { $logItem['id'] = $log_id; } } self::$logs[] = $logItem; }
/** * Creates the Database object and sets the database connection info based on * the config file. * * You can connect to another database on the server listed in the config class by passing its * name in the constructor * * Only supports Mysql databases. * * @see includes/walleye.config.php * @param string $db */ private function __construct($db = null) { $dbOptions = Walleye::getInstance()->getDbOptions(); $server = $dbOptions['SERVER']; $user = $dbOptions['USER']; $password = $dbOptions['PASS']; $port = $dbOptions['PORT']; if (is_null($db)) { $database = $dbOptions['DATABASE']; } else { $database = $db; } parent::mysqli($server, $user, $password, $database, $port); }
/** * Returns the currently logged in user via sessions. * * @static * @see User::withSession() * @return User */ public static function getLoggedUser() { if (!self::$current_logged_user) { if (Walleye::getInstance()->isTesting()) { self::$current_logged_user = User::withId(Walleye::getInstance()->getTestingUserId()); } else { self::$current_logged_user = User::withSession(); } } return self::$current_logged_user; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->walleye = Walleye::getInstance(); }
/** * Render a template through a basic php include * * ex. view('home/index.php', array('title'=>'Title')); * * @access protected * @param string $view the view to be rendered. * @param array $values the values to be shown on the view * @return void */ protected function view($view, $values = array()) { if (!Walleye::isProduction()) { $values['logs'] = Console::getLogs(); } else { $values['logs'] = Console::getAlerts(); } include Walleye::getServerBaseDir() . 'includes/app/views/' . $view; }