当前位置: 首页>>代码示例>>PHP>>正文


PHP Kohana::find_file方法代码示例

本文整理汇总了PHP中Kohana::find_file方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana::find_file方法的具体用法?PHP Kohana::find_file怎么用?PHP Kohana::find_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kohana的用法示例。


在下文中一共展示了Kohana::find_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_index

 public function action_index()
 {
     $this->template->title = __('Contact');
     $this->template->content = View::factory('page/contact')->bind('errors', $errors);
     // Validate the required fields
     $data = Validate::factory($_POST)->filter('name', 'trim')->rule('name', 'not_empty')->filter('email', 'trim')->rule('email', 'not_empty')->rule('email', 'email')->filter('message', 'trim')->filter('message', 'Security::xss_clean')->filter('message', 'strip_tags')->rule('message', 'not_empty');
     if ($data->check()) {
         // Load Swift Mailer
         require Kohana::find_file('vendor', 'swiftmailer/lib/swift_required');
         $transport = Swift_MailTransport::newInstance();
         $mailer = Swift_Mailer::newInstance($transport);
         // Get the email config
         $config = Kohana::config('site.contact');
         $recipient = $config['recipient'];
         $subject = $config['subject'];
         // Create an email message
         $message = Swift_Message::newInstance()->setSubject(__($subject, array(':name' => $data['name'])))->setFrom(array($data['email'] => $data['name']))->setTo($recipient)->addPart($data['message'], 'text/plain');
         // Send the message
         Swift_Mailer::newInstance($transport)->send($message);
         // Set the activity and flash message
         Activity::set(Activity::SUCCESS, __('Message sent from :email', array(':email' => $data['email'])));
         Message::set(Message::SUCCESS, __('Message successfully sent.'));
         // Redirect to prevent POST refresh
         $this->request->redirect($this->request->uri);
     }
     if ($errors = $data->errors('contact')) {
         // Set the error flash message
         Message::set(Message::ERROR, __('Please correct the errors.'));
     }
     $_POST = $data->as_array();
 }
开发者ID:Oaks,项目名称:kohana3-examples,代码行数:31,代码来源:contact.php

示例2: load

 /**
  * Returns the translation table for a given language.
  *
  * @param   string   language to load
  * @return  array
  */
 public static function load($lang)
 {
     if (!isset(I18n::$_cache[$lang])) {
         // Separate the language and locale
         list($language, $locale) = explode('-', strtolower($lang), 2);
         // Start a new translation table
         $table = array();
         // Add the non-specific language strings
         if ($files = Kohana::find_file('i18n', $language)) {
             foreach ($files as $file) {
                 // Merge the language strings into the translation table
                 $table = array_merge($table, require $file);
             }
         }
         // Add the locale-specific language strings
         if ($files = Kohana::find_file('i18n', $language . '/' . $locale)) {
             foreach ($files as $file) {
                 // Merge the locale strings into the translation table
                 $table = array_merge($table, require $file);
             }
         }
         // Cache the translation table locally
         I18n::$_cache[$lang] = $table;
     }
     return I18n::$_cache[$lang];
 }
开发者ID:ascseb,项目名称:core,代码行数:32,代码来源:i18n.php

示例3: before

 public function before()
 {
     parent::before();
     // Borrowed from userguide
     if (isset($_GET['lang'])) {
         $lang = $_GET['lang'];
         // Make sure the translations is valid
         $translations = Kohana::message('langify', 'translations');
         if (in_array($lang, array_keys($translations))) {
             // Set the language cookie
             Cookie::set('langify_language', $lang, Date::YEAR);
         }
         // Reload the page
         $this->request->redirect($this->request->uri());
     }
     // Set the translation language
     I18n::$lang = Cookie::get('langify_language', Kohana::config('langify')->lang);
     // Borrowed from Vendo
     // Automaticly load a view class based on action.
     $view_name = $this->view_prefix . Request::current()->action();
     if (Kohana::find_file('classes', strtolower(str_replace('_', '/', $view_name)))) {
         $this->view = new $view_name();
         $this->view->set('version', $this->version);
     }
 }
开发者ID:Hinton,项目名称:langify,代码行数:25,代码来源:base.php

示例4: __construct

 /**
  * @param $filename
  */
 public function __construct($filename)
 {
     //\Route::name(\Request::current()->uri());
     $path = \Kohana::find_file('views', $filename, 'tpl');
     $this->_filename = $path && ($f_path = str_replace('.tpl', '', $path)) ? $f_path : '';
     $this->_instance = self::init();
 }
开发者ID:astar3086,项目名称:studio_logistic,代码行数:10,代码来源:View.php

示例5: render_markdown_template

 protected function render_markdown_template($content)
 {
     require Kohana::find_file('vendor', 'Markdown');
     $this->template->content = $content->render(FALSE, 'Markdown');
     $this->template->title = implode(' | ', $this->template->title);
     $this->template->render(TRUE);
 }
开发者ID:jverkoey,项目名称:uwdata.ca,代码行数:7,代码来源:uwdata.php

示例6: index

 public function index()
 {
     define('DEBUG', true);
     // an array of file extensions to accept
     $accepted_extensions = array("png", "jpg", "gif");
     // http://your-web-site.domain/base/url
     $base_url = url::base() . Kohana::config('upload.relative_directory', TRUE) . "jwysiwyg";
     // the root path of the upload directory on the server
     $uploads_dir = Kohana::config('upload.directory', TRUE) . "jwysiwyg";
     // the root path that the files are available from the webserver
     $uploads_access_dir = Kohana::config('upload.directory', TRUE) . "jwysiwyg";
     if (!file_exists($uploads_access_dir)) {
         mkdir($uploads_access_dir, 0775);
     }
     if (DEBUG) {
         if (!file_exists($uploads_access_dir)) {
             $error = 'Folder "' . $uploads_access_dir . '" doesn\'t exists.';
             header('Content-type: text/html; charset=UTF-8');
             print '{"error":"config.php: ' . htmlentities($error) . '","success":false}';
             exit;
         }
     }
     $capabilities = array("move" => false, "rename" => true, "remove" => true, "mkdir" => false, "upload" => true);
     if (extension_loaded('mbstring')) {
         mb_internal_encoding('UTF-8');
         mb_regex_encoding('UTF-8');
     }
     require_once Kohana::find_file('libraries/jwysiwyg', 'common', TRUE);
     require_once Kohana::find_file('libraries/jwysiwyg', 'handlers', TRUE);
     ResponseRouter::getInstance()->run();
 }
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:31,代码来源:filemanager.php

示例7: test_autoload

function test_autoload($class)
{
    $file = str_replace('_', '/', $class);
    if ($file = Kohana::find_file('tests/classes', $file)) {
        require_once $file;
    }
}
开发者ID:openbuildings,项目名称:timestamped-migrations,代码行数:7,代码来源:bootstrap.php

示例8: send

 /**
  * Send The SMS Message Using Default Provider
  *
  * @param to mixed	The destination address.
  * @param from mixed  The source/sender address
  * @param text mixed  The text content of the message
  * @return mixed/bool (returns TRUE if sent FALSE or other text for fail)
  */
 public static function send($to = NULL, $from = NULL, $message = NULL)
 {
     if (!$to or !$message) {
         return "Missing Recipients and/or Message";
     }
     // 1. Do we have an SMS Provider?
     $provider = Kohana::config("settings.sms_provider");
     if ($provider) {
         // 2. Does the plugin exist, and if so, is it active?
         $plugin = ORM::factory("plugin")->where("plugin_name", $provider)->where("plugin_active", 1)->find();
         // Plugin loaded
         if ($plugin->loaded) {
             // 3. Does this plugin have the SMS Library in place?
             // SMS libaries should be suffixed with "_Sms_Provider"
             $class = ucfirst($provider) . '_Sms_Provider';
             if (Kohana::find_file('libraries', $class)) {
                 $provider = new $class();
                 // Sanity check - Ensure all SMS providers are sub-classes of Sms_Provider_Core
                 if (!$provider instanceof Sms_Provider_Core) {
                     throw new Kohana_Exception('All SMS Provider libraries must be be sub-classes of Sms_Provider_Core');
                 }
                 // Proceed
                 $response = $provider->send($to, $from, $message);
                 // Return
                 return $response;
             }
         }
     }
     return "No SMS Sending Provider In System";
 }
开发者ID:nemmy,项目名称:Ushahidi_Web,代码行数:38,代码来源:sms.php

示例9: __construct

 public function __construct(array $config)
 {
     parent::__construct($config);
     Kohana::load(Kohana::find_file('vendors', 'sphinxapi'));
     $this->_client = new SphinxClient();
     $this->_client->SetServer($this->config('host'), $this->config('port'));
 }
开发者ID:ortodesign,项目名称:cms,代码行数:7,代码来源:sphinx.php

示例10: before

 public function before()
 {
     if (Kohana::find_file('views', $this->main_template)) {
         $this->main_template = View::factory($this->main_template);
         $system_settings = ORM::factory('Systemsetting')->where('name', 'IN', array('language', 'title', 'keywords', 'description', 'copyright'))->find_all()->as_array('name', 'value');
         $language_parts = explode('-', $system_settings['language']);
         $this->main_template->head_style = '';
         $this->main_template->html_lang = $language_parts[0];
         /* Print language as ISO: from "en-us" only "en", described at: http://www.w3schools.com/Tags/ref_language_codes.asp */
         $this->main_template->title = $system_settings['title'];
         $this->main_template->meta_keywords = $system_settings['keywords'];
         $this->main_template->meta_description = $system_settings['description'];
         $this->main_template->meta_copyright = $system_settings['copyright'];
         $this->main_template->content = '';
     }
     $dir = strtolower($this->request->directory()) . "/" . str_replace('_', '/', strtolower($this->request->controller()));
     $file = $this->request->action();
     if (Kohana::find_file('views/' . $dir, $file)) {
         $this->template = View::factory($dir . '/' . $file);
         $this->template->data = array();
         $this->template->data["errors"] = array();
         $this->template->data["values"] = array();
     }
     parent::before();
 }
开发者ID:Workhaven,项目名称:workhaven,代码行数:25,代码来源:Template.php

示例11: save

 public function save()
 {
     if (!$_POST) {
         die;
     }
     $this->rsp = Response::instance();
     if (!valid::email($_POST['email'])) {
         $this->rsp->msg = 'Invalid Email!';
         $this->rsp->send();
     } elseif ($this->owner->unique_key_exists($_POST['email'])) {
         $this->rsp->msg = 'Email already exists!';
         $this->rsp->send();
     }
     $pw = text::random('alnum', 8);
     $this->owner->email = $_POST['email'];
     $this->owner->password = $pw;
     $this->owner->save();
     $replyto = 'unknown';
     $body = "Hi there, thanks for saving your progess over at http://pluspanda.com \r\n" . "Your auto-generated password is: {$pw} \r\n" . "Change your password to something more appropriate by going here:\r\n" . "http://pluspanda.com/admin/account?old={$pw} \r\n\n" . "Thank you! - Jade from pluspanda";
     # to do FIX THE HEADERS.
     $subject = 'Your Pluspanda account information =)';
     $headers = "From: welcome@pluspanda.com \r\n" . "Reply-To: Jade \r\n" . 'X-Mailer: PHP/' . phpversion();
     mail($_POST['email'], $subject, $body, $headers);
     # add to mailing list.
     include Kohana::find_file('vendor/mailchimp', 'MCAPI');
     $config = Kohana::config('mailchimp');
     $mailchimp = new MCAPI($config['apikey']);
     $mailchimp->listSubscribe($config['list_id'], $_POST['email'], '', 'text', FALSE, TRUE, TRUE, FALSE);
     $this->rsp->status = 'success';
     $this->rsp->msg = 'Thanks, Account Saved!';
     $this->rsp->send();
 }
开发者ID:plusjade,项目名称:pluspanda-php,代码行数:32,代码来源:account.php

示例12: action_captcha

 public function action_captcha()
 {
     Session::instance();
     $path = Kohana::find_file('vendor', 'cool-php-captcha-0.3.1/captcha');
     require_once $path;
     $captcha = new SimpleCaptcha();
     // OPTIONAL Change configuration...
     $captcha->wordsFile = 'words/en.php';
     $captcha->session_var = 'captcha';
     $captcha->imageFormat = 'png';
     $captcha->lineWidth = 3;
     //$captcha->scale = 3; $captcha->blur = true;
     $captcha->resourcesPath = APPPATH . "vendor/cool-php-captcha-0.3.1/resources";
     // OPTIONAL Simple autodetect language example
     /*
     if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $langs = array('en', 'es');
         $lang  = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
         if (in_array($lang, $langs)) {
             $captcha->wordsFile = "words/$lang.php";
         }
     }
     */
     // Image generation
     ob_start();
     $captcha->CreateImage();
     $content = ob_get_contents();
     ob_end_clean();
     $this->response->headers('Content-type', 'image/png');
     $this->response->send_headers();
     $this->response->body($content);
 }
开发者ID:creat2012,项目名称:hustoj_official,代码行数:32,代码来源:Index.php

示例13: send

 /**
  * sends an email using our configs
  * @param  string/array $to       array(array('name'=>'chema','email'=>'chema@'),)
  * @param  [type] $to_name   [description]
  * @param  [type] $subject   [description]
  * @param  [type] $body      [description]
  * @param  [type] $reply     [description]
  * @param  [type] $replyName [description]
  * @param  [type] $file      [description]
  * @return boolean
  */
 public static function send($to, $to_name = '', $subject, $body, $reply, $replyName, $file = NULL)
 {
     require_once Kohana::find_file('vendor', 'php-mailer/phpmailer', 'php');
     $body = Text::bb2html($body, TRUE);
     //get the template from the html email boilerplate
     $body = View::factory('email', array('title' => $subject, 'content' => nl2br($body)))->render();
     $mail = new PHPMailer();
     $mail->CharSet = Kohana::$charset;
     if (core::config('email.smtp_active') == TRUE) {
         $mail->IsSMTP();
         //SMTP HOST config
         if (core::config('email.smtp_host') != "") {
             $mail->Host = core::config('email.smtp_host');
             // sets custom SMTP server
         }
         //SMTP PORT config
         if (core::config('email.smtp_port') != "") {
             $mail->Port = core::config('email.smtp_port');
             // set a custom SMTP port
         }
         //SMTP AUTH config
         if (core::config('email.smtp_auth') == TRUE) {
             $mail->SMTPAuth = TRUE;
             // enable SMTP authentication
             $mail->Username = core::config('email.smtp_user');
             // SMTP username
             $mail->Password = core::config('email.smtp_pass');
             // SMTP password
             if (core::config('email.smtp_ssl') == TRUE) {
                 $mail->SMTPSecure = "ssl";
                 // sets the prefix to the server
             }
         }
     }
     $mail->From = core::config('email.notify_email');
     $mail->FromName = "no-reply " . core::config('general.site_name');
     $mail->Subject = $subject;
     $mail->MsgHTML($body);
     if ($file !== NULL) {
         $mail->AddAttachment($file['tmp_name'], $file['name']);
     }
     $mail->AddReplyTo($reply, $replyName);
     //they answer here
     if (is_array($to)) {
         foreach ($to as $contact) {
             $mail->AddBCC($contact['email'], $contact['name']);
         }
     } else {
         $mail->AddAddress($to, $to_name);
     }
     $mail->IsHTML(TRUE);
     // send as HTML
     if (!$mail->Send()) {
         //to see if we return a message or a value bolean
         Alert::set(Alert::ALERT, "Mailer Error: " . $mail->ErrorInfo);
         return FALSE;
     } else {
         return TRUE;
     }
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:71,代码来源:email.php

示例14: action_index

 /**
  * Serve the file to the browser AND cache it for direct access if in STAGING OR PRODUCTION.
  */
 public function action_index()
 {
     $file = $this->request->param('file');
     $ext = pathinfo($file, PATHINFO_EXTENSION);
     $path = Kohana::find_file('assets', $file, FALSE);
     if ($path === FALSE) {
         throw HTTP_Exception::factory('404', 'File not found!');
     }
     $dir = DOCROOT . 'assets' . DIRECTORY_SEPARATOR;
     // Set the proper headers for browser caching
     $this->response->headers('content-type', File::mime_by_ext($ext));
     $this->response->headers('last-modified', date('r', filemtime($path)));
     $content = file_get_contents($path);
     $this->response->body($content);
     // Don't cache the assets unless we are in STAGING OR PRODUCTION.
     if (Kohana::$environment >= Kohana::STAGING) {
         return;
     }
     // Only cache for specific extensions.
     if (!in_array($ext, $this->_cache_extensions)) {
         return;
     }
     // Check if assets sub dir exist.
     $parts = explode('/', $file);
     $file = array_pop($parts);
     foreach ($parts as $part) {
         $dir .= $part . DIRECTORY_SEPARATOR;
         if (!is_dir($dir)) {
             mkdir($dir);
         }
     }
     file_put_contents($dir . $file, $content);
 }
开发者ID:modulargaming,项目名称:core,代码行数:36,代码来源:Assets.php

示例15: __construct

 public function __construct(array $options = array())
 {
     $this->_basedir = isset($options['base']) ? $options['base'] : 'aceui';
     $this->type = isset($options['type']) ? $options['type'] : 'page';
     //page or layout?
     $this->name = $options["name"];
     //page or layout name
     $this->data_dir = $options['path']['data'];
     $data = $this->_load_file($options['base'], "{$this->data_dir}/{$this->type}s/{$this->name}", 'json');
     //file_get_contents($filename);
     $this->vars = json_decode($data, TRUE);
     if (isset($this->vars['alias'])) {
         $this->name = $this->vars['alias'];
         $data = $this->_load_file($options['base'], "{$this->data_dir}/{$this->type}s/{$this->name}", 'json');
         $this->vars = array_merge(json_decode($data, TRUE), $this->vars);
     }
     if ($this->type != "layout" && !isset($this->vars["layout"])) {
         //if no default layout for this page, then consider it to be "default"
         $this->vars["layout"] = "default";
     }
     $this->views_dir = $options['path']['views'];
     if ($this->type == 'page') {
         if (is_file(Kohana::find_file($this->_basedir, "{$this->views_dir}/assets/scripts/{$this->name}", 'js'))) {
             $this->vars['inline_scripts'] = $this->_load_file($options['base'], "{$this->views_dir}/assets/scripts/{$this->name}", 'js');
         }
         if (is_file(Kohana::find_file($this->_basedir, "{$this->views_dir}/assets/styles/{$this->name}", 'css'))) {
             $this->vars['inline_styles'] = $this->_load_file($options['base'], "{$this->views_dir}/assets/styles/{$this->name}", 'css');
         }
     }
     $this->map_script_names();
     //now load all data relating to this page
     $this->load_data($this->data_dir);
 }
开发者ID:oscoder,项目名称:Koace,代码行数:33,代码来源:Page.php


注:本文中的Kohana::find_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。