/** * Decides whether to configure the module or not. If the configuration * setting configure.Module_Name is TRUE, it will configure it. * * @param string The module to check the settings for. */ public function shouldConfigure($module) { return (bool) Tuffy::setting("modules.{$module}"); }
public static function handleException($exc) { if ($exc instanceof Tuffy_Debug_Exit) { exit; } if (!$exc instanceof Exception) { $exc = new Exception(var_export($exc)); } $log = self::getLog(TRUE); $tuffyLoaded = class_exists('Tuffy', FALSE); if ($tuffyLoaded && !Tuffy::setting('debug')) { $callback = $tuffyLoaded ? Tuffy::setting('errorHandlerProduction', self::PRODUCTION_HANDLER) : self::PRODUCTION_HANDLER; } else { $callback = $tuffyLoaded ? Tuffy::setting('errorHandlerDev', self::DEV_HANDLER) : self::DEV_HANDLER; } call_user_func($callback, $exc, $log); return TRUE; }
/** * Sends email using the PHP standard mail() function. (This assumes your * system administrator has configured it properly.) * * @param string $from The email address to send the message from. * @param string $to The email address(es) to send the message to. * @param string $replyTo The email address to which replies should be * delivered. * @param string $subject The subject of the message. * @param string $body The content of the message. */ public static function mail($from, $to, $replyTo, $subject, $body) { $headers = "From: {$from}\r\nReply-To: {$replyTo}"; $sendmailParams = "-f" . $from; Tuffy::debug("Mail", "To: {$to}\r\n" . "From: {$from}\r\n" . "Reply-To: {$replyTo}\r\n" . "Subject: {$subject}\r\n\r\n" . $body); mail($to, $subject, $body, $headers, $sendmailParams); }
/** * Executes the statement. * * @param array $params Parameters to bind before executing the statement. * You can use this to simplify running several sequential inserts. */ public function execute($params = NULL) { $debug = Tuffy::setting('debug'); if ($params) { $this->bind($params); } if ($debug) { ob_start(); $this->debugDumpParams(); $idx = Tuffy::debug("Query", ob_get_clean()); } parent::execute(); if ($debug) { Tuffy_Debug::completeEvent($idx); } }
public function post($fields) { $this->setOption(CURLOPT_POSTFIELDS, Tuffy::buildQuery($fields)); }
date_default_timezone_set(Tuffy::setting('timezone')); } unset($tuffyTimezone); if (Tuffy::setting('useSessions')) { session_start(); if (Tuffy::setting('debug')) { Tuffy_Debug::restoreLogFromSession(); Tuffy::debug("Session " . session_id(), $_SESSION); } } if ($libraryPath = Tuffy::setting('libraryPath')) { $tuffyAppLoader = new Tuffy_Loader(Tuffy::setting('appName'), Tuffy_Util::interpretPath($libraryPath)); $tuffyAppLoader->register(); } unset($libraryPath); foreach (Tuffy::setting('initializers', array()) as $init) { call_user_func($init); } // 7. Here are a couple of completely non-namespaced utility functions // that are just too useful not to have. /** * If the $key exists in $array, returns the value stored therein. Otherwise, * returns $default. * * @param array $array The array to check. * @param mixed $key The key to search for. * @param mixed $default The value to return if the key does not exist. * (It defaults to NULL.) */ function maybe($array, $key, $default = NULL) {
/** * Registers a default set of template functions, filter, and globals * to the shared template environment. */ public static function registerDefaults() { // General // hash is very useful when creating ID's for ephemeral objects self::addFunction('hash', 'spl_object_hash'); // Tuffy self::addFunction('Tuffy::url'); self::addFunction('Tuffy::getFlashes'); // Tuffy_Debug self::addGlobal('DEBUG', Tuffy::setting('debug')); self::addFunction('getDebugLog', 'Tuffy_Debug::getLog'); }