/** * Spawns a new instance of Twig. * * @return object **/ protected function spawn() { // register the Twig autoloader. Twig_Autoloader::register(); // Init the Twig loader. $loader = new Twig_Loader_String(); // check if the cache dir is set. if ($this->compile_dir) { if (is_null($this->debug)) { $this->debug = is_dev_mode(); } $twig = new Twig_Environment($loader, array('autoescape' => FALSE, 'cache' => $this->compile_dir, 'debug' => $this->debug, 'charset' => $this->charset, 'base_template_class' => $this->base_template_class, 'strict_variables' => $this->strict_variables, 'autoescape' => $this->autoescape, 'optimizations' => $this->optimizations)); } else { $twig = new Twig_Environment($loader, array('autoescape' => FALSE)); } // init all functions as Twig functions. foreach ($this->allowed_functions as $function) { $twig->addFunction($function, new Twig_Function_Function($function)); } // setup debugger $twig->addExtension(new Twig_Extension_Debug()); // setup the Lexer $lexer = new Twig_Lexer($twig, $this->delimiters); $twig->setLexer($lexer); // finally, return the object. return $twig; }
public function version($version = 1, $module = NULL) { $this->_init_migrate($module); // must be in dev mode change the version to something uther then the latest or current if (!is_dev_mode()) { $this->_show_error(lang('error_not_in_dev_mode')); } $version = $this->migration->version($version); if (!$version) { $this->_show_error(); } $this->_success($version); }
public function __construct() { $validate = (php_sapi_name() == 'cli' or defined('STDIN')) ? FALSE : TRUE; parent::__construct($validate); // must be in dev mode to install modules if (!is_dev_mode()) { show_error(lang('error_not_in_dev_mode')); } // validate user has permission if ($validate) { $this->_validate_user('installer'); } }
/** * Standard function. */ function dh_fpp_helper($args) { $file_name = dirname(__FILE__) . '/dhfpp_' . escape_value($args['order_id'], 'file_name') . '.php'; $function_name = 'fpp_' . $args['order_id']; if (file_exists($file_name)) { include_once $file_name; } if (function_exists($function_name)) { return $function_name($args); } elseif (is_dev_mode()) { sys_notify('Unrecognized task was encountered by dh_fpp_helper.', 'warning'); return FALSE; } }
public function __construct() { $validate = (php_sapi_name() == 'cli' or defined('STDIN')) ? FALSE : TRUE; parent::__construct($validate); // must be in dev mode to generate if (!is_dev_mode()) { show_error(lang('error_not_in_dev_mode')); } // validate user has permission if ($validate) { $this->_validate_user('generate'); } $this->load->helper('file'); $this->load->library('parser'); }
/** * Google Analytics * * Inserts google analytics tracking code into view * If a tracking code is passed in, then it will use that uacct info * Otherwise, it will use the value defined in the google.php config file * If both values do not exist, nothing will be inserted. * * @access public * @param string The google account number (optional) * @param mixed An array or string of extra parameters to pass to GA. An array will use the key/value to add _gaq.push (optional) * @param boolean Whether to check dev mode before adding it in (optional) * @return string */ function google_analytics($uacct = '', $other_params = array(), $check_devmode = TRUE) { if ($check_devmode and (function_exists('is_dev_mode') and is_dev_mode())) { return FALSE; } $CI =& get_instance(); $CI->load->config('google'); if (empty($uacct)) { $uacct = $CI->config->item('google_uacct'); } if (!empty($uacct)) { $google_analytics_code = ' <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push([\'_setAccount\', \'' . $uacct . '\']); '; if (!empty($other_params)) { if (is_array($other_params)) { foreach ($other_params as $key => $val) { $google_analytics_code .= ' _gaq.push([\'' . $key . '\', \'' . $val . '\'])'; } } else { if (is_string($other_params)) { $google_analytics_code .= "\t" . $other_params . "\n"; } } } $google_analytics_code .= ' _gaq.push([\'_trackPageview\']); (function() { var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true; ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\'; var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s); })(); </script> '; return $google_analytics_code; } else { return FALSE; } }
/** * Sends email notification to those specified in the email_recipients field. Is called within the process method as well. * <code> $form = $this->fuel->forms->create('myform', array('email_recipients' => array('*****@*****.**'))); if ($form->notify()) { echo 'Notified'; } else { echo 'Failure in Notification'; } </code> * * @access public * @param string The message to send (optional) * @return boolean Returns TRUE/FALSE based on if the form validates or not. Is called during the "process" method as well */ public function notify($msg = NULL) { if (empty($msg)) { $msg = $this->get_email_message(); } if ($this->has_email_recipients() or $this->fuel->forms->config('test_email')) { $this->CI->load->library('email'); $this->call_hook('pre_notify', array('email' => $this->CI->email)); $email =& $this->CI->email; $forms =& $this->CI->fuel->forms; // send email $email->from($this->get_email_from(), $this->get_email_from_name()); // set the email subject $email->subject($this->get_email_subject()); // check config if we are in dev mode if (is_dev_mode()) { $email->to($this->fuel->forms->config('test_email')); $email->cc($this->email_cc); $email->bcc($this->email_bcc); } else { $email->to($this->email_recipients); $email->cc($this->email_cc); $email->bcc($this->email_bcc); } // build the email content $email->message($msg); // set the mail type $email->set_mailtype($this->mail_type); // attach any files if ($this->get_attach_files() === TRUE) { foreach ($this->attachments as $attachment) { // add this so that it can be auto-removed $email->attach($attachment); } foreach ($this->upload_files() as $upload_data) { $email->attach($upload_data['full_path']); } } // let her rip if (!$email->send()) { if (is_dev_mode()) { echo $email->print_debugger(); exit; } $this->_add_error(lang('forms_error_sending_email')); return FALSE; } // cleaup any uploaded files $this->cleanup_upload_files(); } return TRUE; }
/** * Google Analytics * * Inserts google analytics tracking code into view * If a tracking code is passed in, then it will use that uacct info * Otherwise, it will use the value defined in the google.php config file * If both values do not exist, nothing will be inserted. * * @access public * @param string The google account number (optional) * @param mixed An array or string of extra parameters to pass to GA. An array will use the key/value to add _gaq.push (optional) * @param boolean Whether to check dev mode before adding it in (optional) * @return string */ function google_analytics($uacct = '', $other_params = array(), $check_devmode = TRUE) { /* (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-2467063-1', 'thedaylightstudio.com'); ga('send', 'pageview'); */ if ($check_devmode and (function_exists('is_dev_mode') and is_dev_mode())) { return FALSE; } $CI =& get_instance(); $CI->load->config('google'); if (empty($uacct)) { $uacct = $CI->config->item('google_uacct'); } if (!empty($uacct)) { $google_analytics_code = ' <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push([\'_setAccount\', \'' . $uacct . '\']); '; if (!empty($other_params)) { if (is_array($other_params)) { foreach ($other_params as $key => $val) { $google_analytics_code .= ' _gaq.push([\'' . $key . '\', \'' . $val . '\'])'; } } else { if (is_string($other_params)) { $google_analytics_code .= "\t" . $other_params . "\n"; } } } $google_analytics_code .= ' _gaq.push([\'_trackPageview\']); (function() { var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true; ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\'; var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s); })(); </script> '; return $google_analytics_code; } else { return FALSE; } }
/** * Determines if the site is in dev mode and whether "use_dev_mode" is specified as TRUE on the object * * @access public * @return boolean */ public function is_dev_mode() { return $this->use_dev_mode == TRUE and is_dev_mode(); }