示例#1
0
文件: sphinx.php 项目: ortodesign/cms
 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'));
 }
示例#2
0
文件: i18n.php 项目: Normull/core
 /**
  * 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])) {
         return I18n::$_cache[$lang];
     }
     // New translation table
     $table = array();
     // Split the language: language, region, locale, etc
     $parts = explode('-', $lang);
     do {
         // Create a path for this set of parts
         $path = implode(DIRECTORY_SEPARATOR, $parts);
         if ($files = Kohana::find_file('i18n', $path)) {
             $t = array();
             foreach ($files as $file) {
                 // Merge the language strings into the sub table
                 $t = array_merge($t, Kohana::load($file));
             }
             // Append the sub table, preventing less specific language
             // files from overloading more specific files
             $table += $t;
         }
         // Remove the last part
         array_pop($parts);
     } while ($parts);
     // Cache the translation table locally
     return I18n::$_cache[$lang] = $table;
 }
示例#3
0
 /**
  * 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 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 += Kohana::load($file);
             }
         }
         // 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 += Kohana::load($file);
             }
         }
         // Cache the translation table locally
         I18n::$_cache[$lang] = $table;
     }
     return I18n::$_cache[$lang];
 }
示例#4
0
文件: Config.php 项目: NegoCore/core
 /**
  * Load modules config
  *
  * @param $group
  * @param $module
  * @return mixed
  * @throws Kohana_Exception
  */
 public function load($group, $module)
 {
     if (empty($group) || empty($module)) {
         throw new Twig_Exception("Need to specify a config group and module name");
     }
     if (!is_string($group) || !is_string($module)) {
         throw new Twig_Exception("Config group and module name must be a string");
     }
     if (strpos($group, '.') !== FALSE) {
         // Split the config group and path
         list($group, $path) = explode('.', $group, 2);
     }
     if (isset($this->_config_groups[$group])) {
         if (isset($path)) {
             return Arr::path($this->_config_groups[$group], $path, NULL, '.');
         }
         return $this->_config_groups[$group];
     }
     $config = array();
     $file = $this->_get_config_file($group, $module);
     if (is_file($file)) {
         $config = Arr::merge($config, Kohana::load($file));
     }
     $this->_config_groups[$group] = new Config_Group(Kohana::$config, $group, $config);
     if (isset($path)) {
         return Arr::path($config, $path, NULL, '.');
     }
     return $this->_config_groups[$group];
 }
示例#5
0
文件: i18n.php 项目: ukd1/kohana
 /**
  * Loads the translation table for a given language.
  * 
  * @param   string   language to load
  * @return  array
  */
 protected static function load($lang)
 {
     if (!isset(i18n::$_cache[$lang])) {
         // Separate the language and locale
         list($language, $locale) = explode('_', strtolower($lang));
         // Start a new translation table
         $table = array();
         if ($files = Kohana::find_file('i18n', $language)) {
             foreach ($files as $file) {
                 // Load the strings that are in this file
                 $strings = Kohana::load($file);
                 // Merge the language strings into the translation table
                 $table = array_merge($table, $strings);
             }
         }
         if ($files = Kohana::find_file('i18n', $language . '/' . $locale)) {
             foreach ($files as $file) {
                 // Load the strings that are in this file
                 $strings = Kohana::load($file);
                 // Merge the locale strings into the translation table
                 $table = array_merge($table, $strings);
             }
         }
         // Cache the translation table locally
         i18n::$_cache[$lang] = $table;
     }
     return i18n::$_cache[$lang];
 }
 /**
  * Load and merge all of the configuration files in this group.
  *
  *     $config->load($name);
  *
  * @param   string  $group  configuration group name
  * @return  $this   current object
  * @uses    Kohana::load
  */
 public function load($group)
 {
     $config = array();
     if ($files = Kohana::find_file($this->_directory, $group, NULL, TRUE)) {
         foreach ($files as $file) {
             // Merge each file to the configuration array
             $config = Arr::merge($config, Kohana::load($file));
         }
     }
     return $config;
 }
示例#7
0
文件: file.php 项目: azuya/Wi3
 /**
  * Load and merge all of the configuration files in this group.
  *
  *     $config->load($name);
  *
  * @param   string  configuration group name
  * @param   array   configuration array
  * @return  $this   clone of the current object
  * @uses    Kohana::load
  */
 public function load($group, array $config = NULL)
 {
     if ($files = Kohana::find_file($this->_directory, $group, NULL, TRUE)) {
         // Initialize the config array
         $config = array();
         foreach ($files as $file) {
             // Merge each file to the configuration array
             $config = Arr::merge($config, Kohana::load($file));
         }
     }
     return parent::load($group, $config);
 }
示例#8
0
 /**
  * 
  * @param string $directory
  * @param string $file
  * @return array
  */
 public static function load_merged_array($directory, $file)
 {
     if (isset(self::$_cache[$directory][$file])) {
         return self::$_cache[$directory][$file];
     }
     $array = array();
     if ($files = Kohana::find_file($directory, $file, NULL, TRUE)) {
         foreach ($files as $file) {
             // Merge each file to the configuration array
             $array = Arr::merge($array, Kohana::load($file));
         }
     }
     self::$_cache[$directory][$file] = $array;
     return $array;
 }
示例#9
0
文件: I18n.php 项目: g-a-g/its2015
 public static function append($string, $lang)
 {
     $parts = explode('-', $lang);
     $path = implode(DIRECTORY_SEPARATOR, $parts);
     // Ищем файл для текущей локали
     $file = APPPATH . 'i18n' . DIRECTORY_SEPARATOR . $path . EXT;
     if (!file_exists($file)) {
         throw new Kohana_Exception('File :file not exists', array(':file' => $file));
     }
     if (Kohana::$profiling === TRUE) {
         $benchmark = Profiler::start('Generate i18n data', $lang);
     }
     // Загружаем файл
     $data = Kohana::load($file);
     $data[$string] = $string;
     // Генерируем массив
     $arrayString = "<?php defined( 'SYSPATH' ) OR die( 'No direct access allowed.' );\n" . "return " . var_export($data, true) . ";\n";
     // Записываем в файл
     $result = @file_put_contents($file, $arrayString, LOCK_EX);
     if (isset($benchmark)) {
         Profiler::stop($benchmark);
     }
     return $result;
 }
示例#10
0
文件: wi3.php 项目: azuya/Wi3
 public function init()
 {
     // Load session handler
     $this->session = Session::instance();
     // Set cache handler
     $this->cache = Wi3TikoCache::instance();
     // Define APPRELATIVEPATH, which is the path to the application relative to the web root
     // We can retrieve this by using the SCRIPT_NAME from the front-controller ({pathfromroot}/app/index.php), and extracting the path-from-root
     define("APPRELATIVEPATH", substr($_SERVER["SCRIPT_NAME"], 0, strpos($_SERVER["SCRIPT_NAME"], "/app/index.php")) . "/app/latest/");
     // Define document root
     // TODO: Add support for ISS (see http://www.helicron.net/php/)
     define("DOCUMENTROOT", $_SERVER["DOCUMENT_ROOT"] . "/");
     // Determine language
     $lang = Cookie::get('lang');
     if ($lang !== NULL) {
         if (!in_array($lang, array('nl-nl', 'en-us'))) {
             // Check the allowed languages, and force the default
             $lang = 'nl-nl';
         }
     } else {
         // Language not set in cookie. Get default language from i18n file.
         $i18nfiles = Kohana::find_file("config", "i18n");
         if (!empty($i18nfiles)) {
             $i18nsettings = Kohana::load($i18nfiles[0]);
             $lang = $i18nsettings["lang"];
         } else {
             $lang = 'nl-nl';
             // Fall back to default
         }
         // Save loaded language in cookie
         Cookie::set('lang', $lang);
     }
     // Set the target language
     i18n::lang($lang);
     // Set the source language to some non-existing language to prevent Kohana skipping translation lookup if source and target language are identical
     i18n::$source = "bb-bb";
     // See http://unicode.org/cldr/utility/languageid.jsp?a=bb&l=en for valid tags
     // Load wi3-kohana-specific functions
     $this->kohana = new Wi3_Kohana();
     // XSS Clean all user input!
     // TODO: only do this if the user is not an admin...
     $this->originalpost = $_POST;
     // Save original $_POST
     foreach ($_POST as $key => $val) {
         $_POST[$key] = Security::xss_clean($val);
     }
     $this->originalget = $_GET;
     // Save original $_GET
     foreach ($_GET as $key => $val) {
         $_GET[$key] = Security::xss_clean($val);
     }
     // Load some Wi3 classes
     // Load a global database configuration
     $this->database = new Wi3_Database();
     // Helper functions to create databases etc
     $this->globaldatabase = Wi3_Database::instance("global");
     Event::instance("wi3.init.globaldatabase.loaded")->execute();
     // Get routing, url and path information
     // These classes in turn add a callback to the wi3.init.site.loaded Event, after which they will update with path and urls to the site
     $this->routing = Wi3_Routing::instance();
     Event::instance("wi3.init.routing.loaded")->execute();
     $this->pathof = Wi3_Pathof::instance();
     Event::instance("wi3.init.pathof.loaded")->execute();
     $this->urlof = Wi3_Urlof::instance();
     Event::instance("wi3.init.urlof.loaded")->execute();
     // Load CSS and Javascript 'injectors'
     $this->css = Wi3_Css::instance();
     $this->javascript = Wi3_Javascript::instance();
     // Instantiate the Model class, that is an interface to the 'factory' method for any underlying model-systems
     $this->model = Wi3_Model::inst();
     Event::instance("wi3.init.model.loaded")->execute();
     // Instantiate the form-builder
     $this->formbuilder = Wi3_Formbuilder::inst();
     Event::instance("wi3.init.formbuilder.loaded")->execute();
     // Now find out what is the scope of this request
     // It most often is a site-scope (i.e. the admin or view of a site), but might also be a global scope (i.e. superadmin)
     // This depends on the controller.
     // Pagefiller-specific controllers are always for the the sitearea
     $this->scope = (substr(Request::instance()->controller, 0, 9) == "adminarea" or substr(Request::instance()->controller, 0, 10) == "pagefiller" or Request::instance()->controller == "sitearea") ? "site" : "global";
     if ($this->scope == "site") {
         $this->sitearea = Wi3_Sitearea::inst();
         // Find out what site we are working with
         // Both the admin controller and the site controller need to know this in order to work properly
         // Find the site by apache 'sitename' variable
         if (isset($_SERVER['REDIRECT_SITENAME'])) {
             $sitename = $_SERVER['REDIRECT_SITENAME'];
             // With correct loading, $_SERVER['REDIRECT_SITENAME'] should always be present, as it is set in the vhosts .htaccess that redirect here
             // Global site is the site in the global space, i.e. the Site model in the 'list of sites' that is always accesible
             // ( In the per-site database, there can only exist one Site model )
             $this->sitearea->globalsite = $this->model->factory("site")->set('name', $sitename)->load();
             Event::instance("wi3.init.sitearea.globalsite.loaded")->execute();
             $this->sitearea->site = $this->sitearea->globalsite;
             // This site instance will be replaced by the local user site. The ->name will be added to that local site, since it does not store that in the local db
         }
         // If the sitename not present, the page request came here via some illegal method.
         // If the site was not loaded correctly or is not active, we cannot show the site either
         if (!isset($_SERVER['REDIRECT_SITENAME']) or empty($sitename) or !$this->sitearea->globalsite->loaded() or $this->sitearea->globalsite->active == FALSE) {
             // Site does not exist. Quit.
             throw new Kohana_Exception("site does not exist");
         }
         // Global site has been loaded and it was found to be active
         // Now we load the local site and requested page from within the user Database
         // This requires the inclusion of the site as a module and an init on its database-config
         //
         // First, Include the whole site-tree in the find_file() function
         Kohana::modules(Kohana::modules() + array("site" => APPPATH . "../../sites/" . $sitename . "/"));
         // Because Kohana uses include_once() this will only init the new module, without double-including the others
         // Load the sitedatabase config. It will be fetched from the sites/sitename/config folder since the sites/sitename is now in the Kohana find_file paths
         $siteconfig = Kohana::config('sitedatabase')->site;
         // Set up a site database connection, to be used by the site-based-models like Site_Page, Site_User, File etc
         $this->sitearea->database = Wi3_Database::instance("site", $siteconfig);
         Event::instance("wi3.init.sitearea.database.loaded")->execute();
         // Load the user-site
         $this->sitearea->site = $this->model->factory("site_site")->set('id', 1)->load();
         $this->sitearea->site->name = $sitename;
         // Add name, since this is not stored in the local site tables, but only in the global ones
         Event::instance("wi3.init.sitearea.site.loaded")->execute();
         // Load the pageposition, page and file manager, all within the sitearea
         $this->sitearea->pagepositions = Wi3_Sitearea_Pagepositions::inst();
         $this->sitearea->pages = Wi3_Sitearea_Pages::inst();
         $this->sitearea->files = Wi3_Sitearea_Files::inst();
         $this->sitearea->users = Wi3_Sitearea_Users::inst();
     }
     // Load baseviews that are passed as $this into views in order to enable some in-view functions
     // Different setups are possible with the different parameters supplied
     // An instance is created, so that they can also be referenced simply from again loading e.g. Wi3_Baseview::instance('superadminarea');
     // These instances are used as 'object scope' for the $this variables in views. See i.e. the superadminarea-controller's ->view function and the Baseview->capture() for more details
     $this->baseview_superadminarea = Wi3_Baseview::instance('superadminarea', array('javascript_url' => $this->urlof->appfiles . 'static/javascript/', 'javascript_path' => $this->pathof->app . 'static/javascript/', 'css_url' => $this->urlof->appfiles . 'static/css/', 'css_path' => $this->pathof->app . 'static/css/'));
     //Maybe just define the asset-path(s), from which the URLs are deduced, based on the Wi3::inst()->urlof ?
     $this->baseview_adminarea = Wi3_Baseview::instance('adminarea', array('javascript_url' => $this->urlof->appfiles . 'static/javascript/', 'javascript_path' => $this->pathof->app . 'static/javascript/', 'css_url' => $this->urlof->appfiles . 'static/css/', 'css_path' => $this->pathof->app . 'static/css/'));
     $this->baseview_sitearea = Wi3_Baseview::instance('sitearea', array('javascript_url' => $this->urlof->site . 'static/javascript/', 'javascript_path' => $this->pathof->site . 'static/javascript/', 'css_url' => $this->urlof->site . 'static/css/', 'css_path' => $this->pathof->site . 'static/css/'));
     Event::instance("wi3.init.baseviews.loaded")->execute();
     // Set up an config loader
     $this->configof = Wi3_Configof::instance();
     // Set up auth. This will try to login the current user from either the site db or the global db, based on the scope
     if ($this->scope == "site") {
         $this->sitearea->auth = Wi3_Auth_Site::instance();
     } else {
         // If user is in setup, then don't yet load Auth and Database instances, since they most probably don't yet exist
         if (Request::instance()->controller != "setup") {
             $this->globalauth = Wi3_Auth_Global::instance();
         }
     }
     $this->acl = Wi3_ACL::instance();
     // Load the plugin-manager. The manager will also include the paths to the plugins in the modules-system
     $this->plugins = new Wi3_Plugins();
     if ($this->scope == "site") {
         // Make all the pageversion-plugins to load
         // The versionplugins should respond to this event call, and add them to the $this->versionplugins array
         Event::instance('wi3.sitearea.pages.versionplugins.load')->execute();
     }
 }
示例#11
0
<?php

defined('SYSPATH') or die('No direct script access.');
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
// We can't use Kohana::$config because that causes my default config file to be merged
// with the application config file, with my config file taking priority. I'm almost 100%
// sure this is not what the user wants
$files = Kohana::find_file('config', 'routes', NULL);
while (count($files) > 1) {
    // remove my copy of the config file from considerations, if its not the only one
    if (strstr($files[0], basename(__DIR__))) {
        array_shift($files);
    }
}
foreach (Kohana::load(array_shift($files)) as $name => $params) {
    $r = Route::set($name, $params['uri'], array_key_exists('rules', $params) ? $params['rules'] : null);
    if (@$params['defaults']) {
        $r->defaults($params['defaults']);
    }
}
示例#12
0
 /**
  * Get a message from a file. Messages are arbitary strings that are stored
  * in the messages/ directory and reference by a key. Translation is not
  * performed on the returned values.
  *
  *     // Get "username" from messages/text.php
  *     $username = Kohana::message('text', 'username');
  *
  * @param   string  file name
  * @param   string  key path to get
  * @param   mixed   default value if the path does not exist
  * @return  string  message string for the given path
  * @return  array   complete message list, when no path is specified
  * @uses    Arr::merge
  * @uses    Arr::path
  */
 public static function message($file, $path = NULL, $default = NULL)
 {
     static $messages;
     if (!isset($messages[$file])) {
         // Create a new message list
         $messages[$file] = array();
         if ($files = Kohana::find_file('messages', $file)) {
             foreach ($files as $f) {
                 // Combine all the messages recursively
                 $messages[$file] = Arr::merge($messages[$file], Kohana::load($f));
             }
         }
     }
     if ($path === NULL) {
         // Return all of the messages
         return $messages[$file];
     } else {
         // Get a message using the path
         return Arr::path($messages[$file], $path, $default);
     }
 }
示例#13
0
 public function action_generate()
 {
     // Restrict to cli mode
     if (!Kohana::$is_cli) {
         echo "<pre>\nUsage: php index.php --uri=\"i18nget/generate\" or\n";
         echo "       php index.php --uri=\"i18nget/generate_for/mymodule\" or\n";
         echo "       php index.php --uri=\"i18nget/generate_for/mymodule/application\"\n</pre>";
         return;
     }
     $user_paths = array($this->request->param('from_path', 'application'));
     $user_paths[] = $this->request->param('to_path', $user_paths[0]);
     //if we should check all i18n files in the projetcs or just module files
     $global_i18n = $user_paths[1] == 'application';
     foreach ($user_paths as $idx => $path_to_check) {
         //application?
         if ($path_to_check == 'application') {
             $user_paths[$idx] = APPPATH;
             continue;
         }
         //module?
         $modules = array_slice(scandir(MODPATH), 2);
         if (!in_array($path_to_check, $modules)) {
             die("Your given option '{$path_to_check}' must either match 'application'" . " or one of the module names:\n  " . join("\n  ", $modules));
         } else {
             $user_paths[$idx] = MODPATH . $path_to_check;
         }
     }
     $this->auto_render = FALSE;
     $path = $user_paths[0];
     $output_path = rtrim($user_paths[1], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     echo "\nGenerating files for \n'{$path}'\ninto\n'{$output_path}i18n'\n\n";
     $data = array();
     $unique_phrases_helper = array();
     $scan_files = $this->get_dir_files($path, array('php'));
     //echo Debug::dump($this->request, 9999);
     //print_r(Request::$current->uri());
     //print_r($user_paths);
     //print_r($scan_files); return;
     foreach ($scan_files as $file) {
         $file_path_human = substr($file, strlen($path));
         // 			echo Debug::dump($file_path_human, 9999);
         // Get each line of the file
         $file_lines = file($file, FILE_IGNORE_NEW_LINES);
         $data_file = array();
         foreach ($file_lines as $num_line => $file_line) {
             $num_line++;
             // 				echo Kohana::debug($num_line, $file_line, $file_path_human);
             // 				if (preg_match_all('/(?P<key>\w+):(?P<name>[\p{L}+|\D+])/u', $file_line, $matches))
             // 				if (preg_match('/^(?P<name>.*?[^(TO|COPYTO)]+)( TO (?P<assignedto>\w[^(COPYTO)]+))?( COPYTO (?P<copyto>\w[^(TO)]+))?$/u', trim($email['Subject']), $matches))
             // 				if (preg_match_all('/__\(\'(?P<phrase>.+)\'(, ?array\(.+\))?\)/u', $file_line, $matches))
             // 				if (preg_match_all('/__\(\'(?P<phrase>.*)(, ?array\(.+\))?\'\)/u', $file_line, $matches))
             // 				if (preg_match_all("/__\('(?P<phrase>.*?[^;])'\)/u", $file_line, $matches))
             // 				if (preg_match_all("/__\([^'.+'$]\)/u", $file_line, $matches))
             // 				if (preg_match_all("/__\([^_]+\)/u", $file_line, $matches))
             // 				if (preg_match_all("/__\([^\b__]+\)/u", $file_line, $matches))
             // 				if (preg_match_all("/__\((?P<phrase>((?!__).)+)\)/u", $file_line, $matches)) /// NOTE IT WORKS!!!
             // 				if (preg_match_all("/__\((?P<phrase>((?!__)|(?!array).)+)\)/u", $file_line, $matches))
             // 				if (preg_match_all("/__\(('|\")(?P<phrase>((?!__)|(?! ?array ?\().)+)('|\")/u", $file_line, $matches)) /// NOTE IT WORKS!!!
             if (preg_match_all("/__\\(('|\")(?P<phrase>((?!__)|(?! ?array ?\\().)+)('\\)|',|\"\\)|\",)/u", $file_line, $matches)) {
                 // 					echo Kohana::debug($file_path_human, $num_line, $file_line, $matches);
                 // 					echo Kohana::debug($file_path_human, $num_line, $file_line, $matches['phrase']);
                 // 					echo Kohana::debug($matches['phrase']);
                 $new_phrases = array_diff(array_unique($matches['phrase']), $unique_phrases_helper);
                 if ($new_phrases) {
                     $data_file[] = array('line_number' => $num_line, 'line_string' => $file_line, 'phrases' => $new_phrases);
                     $unique_phrases_helper = array_merge($new_phrases, $unique_phrases_helper);
                 }
             }
         }
         if ($data_file) {
             $data[] = array('filepath' => $file, 'filepath_human' => $file_path_human, 'lines' => $data_file);
         }
         /* if( strpos($file, 'format')!==False )
            {
                print_r($data_file);
                die('found');
            } */
     }
     //echo Debug::dump($data, 9999);
     $languages = Kohana::$config->load('i18nget.languages');
     $default_language = Kohana::$config->load('i18nget.default');
     $orphe_phrases = array();
     // Fix phrases
     foreach ($unique_phrases_helper as $key => $phrase) {
         $unique_phrases_helper[$key] = str_replace('\\\'', '\'', $unique_phrases_helper[$key]);
         $unique_phrases_helper[$key] = str_replace('\\"', '"', $unique_phrases_helper[$key]);
     }
     // Add phrases present in current i18n language files but are not present in current code
     foreach ($languages as $language_code => $language) {
         if ($global_i18n) {
             //only if we write to application we want to look at kohana's complete CFS for i18n files.
             $i18n_messages = array_keys(I18n::load($language_code));
         } else {
             //if we output in an i18n folder of a module, we are only interested in that modules current translations
             $lang_file = $this->lang_file_path($output_path, $language_code);
             if (file_exists($lang_file)) {
                 $i18n_messages = array_keys(Kohana::load($lang_file));
             } else {
                 $i18n_messages = array();
             }
         }
         $orphe_phrases = array_merge($orphe_phrases, array_diff($i18n_messages, $unique_phrases_helper));
     }
     $orphe_phrases = array_unique($orphe_phrases);
     //print_r($unique_phrases_helper);
     //print_r($i18n_messages);
     //print_r($orphe_phrases); //die();
     // Generate new i18n files
     foreach ($languages as $language_code => $language) {
         if ($default_language !== $language_code) {
             $filename = $this->lang_file_path($output_path, $language_code);
             //construct content before renaming original file
             $content = View::factory('i18nget/generate')->set(array('data' => $data, 'orphe_phrases' => $orphe_phrases, 'language_code' => $language_code, 'filename' => $filename, 'global_i18n' => $global_i18n))->render();
             //print_r($content);
             if (file_exists($filename) and Kohana::$config->load('i18nget.should_make_backups')) {
                 rename($filename, $backup_name = $filename . '.old_' . time());
                 echo "Backup file: " . substr($backup_name, strlen(DOCROOT)) . "\n";
             }
             if (FALSE === file_put_contents($filename, $content)) {
                 echo "There's an error writing the file: " . substr($filename, strlen(DOCROOT)) . "\n\n";
             } else {
                 echo "File written: " . substr($filename, strlen(DOCROOT)) . "\n\n";
             }
         }
     }
     // Fix permissions
     // 		system('chown marcalj:marcalj '.APPPATH.'logs/i18n/*');
     echo "Done!\n";
 }
示例#14
0
                $phrase_translated = Arr::get(file_exists($filename) ? Kohana::load($filename) : array(), $phrase_fixed, NULL);
            }
            $phrase_translated_fixed = str_replace('\'', '\\\'', (string) $phrase_translated);
            $not_translated = '';
            if (is_null($phrase_translated)) {
                $not_translated = '/// TODO';
                $phrase_translated_fixed = '';
            }
            // 			print($not_translated."\t'$phrase' => '".$phrase_translated_fixed."', // ".$line['line_number'].": ".$line['line_string']."\n");
            print $not_translated . "\t'{$phrase}' => '" . $phrase_translated_fixed . "', // " . $line['line_number'] . "\n";
        }
    }
    print "\n";
}
// Orphan phrases
print "\t// Orphan phrases\n";
foreach ($orphe_phrases as $phrase) {
    if ($global_i18n) {
        //I18n::get() doesnt tell us if the key is equal to the translation
        $phrase_translated = Arr::get($table, $phrase, NULL);
    } else {
        $phrase_translated = Arr::get(file_exists($filename) ? Kohana::load($filename) : array(), $phrase, NULL);
    }
    $not_translated = '';
    if (is_null($phrase_translated)) {
        $not_translated = '/// TODO';
        $phrase_translated = '';
    }
    print $not_translated . "\t'{$phrase}' => '" . $phrase_translated . "',\n";
}
print ");\n";
示例#15
0
<?php

defined('SYSPATH') or die('No direct script access.');
Kohana::load(Kohana::find_file('../vendor/erusev/parsedown', 'Parsedown'));
class markdown extends Parsedown
{
    private static $instance = false;
    public static function instance($name = null)
    {
        if (!self::$instance) {
            self::$instance = new self();
        }
        return self::$instance;
    }
    protected function identifyLink($Excerpt)
    {
        $extent = $Excerpt['text'][0] === '!' ? 1 : 0;
        if (strpos($Excerpt['text'], ']') and preg_match('/\\[((?:[^][]|(?R))*)\\]/', $Excerpt['text'], $matches)) {
            $Link = array('text' => $matches[1], 'label' => strtolower($matches[1]));
            $extent += strlen($matches[0]);
            $substring = substr($Excerpt['text'], $extent);
            if (preg_match('/^\\s*\\[([^][]+)\\]/', $substring, $matches)) {
                $Link['label'] = strtolower($matches[1]);
                if (isset($this->Definitions['Reference'][$Link['label']])) {
                    $Link += $this->Definitions['Reference'][$Link['label']];
                    $extent += strlen($matches[0]);
                } else {
                    return;
                }
            } elseif (isset($this->Definitions['Reference'][$Link['label']])) {
                $Link += $this->Definitions['Reference'][$Link['label']];
示例#16
0
 public function before()
 {
     parent::before();
     Kohana::load(Kohana::find_file('vendor/twitteroauth', 'twitteroauth'));
     $this->creds = Kohana::$config->load('secrets')->get('twitter');
 }
示例#17
0
 /**
  * gets the options array from and external file options.php
  * @param  string $theme theme to load from
  * @return array
  */
 public static function get_options($theme = NULL)
 {
     if ($theme === NULL) {
         $theme = self::$theme;
     }
     $options = self::file_path('options.php', $theme);
     //no options file found, let's try the parent
     if ($options === FALSE) {
         //child  theme can use parent license
         if (($parent = self::get_theme_parent($theme)) !== NULL) {
             $options = self::file_path('options.php', $parent);
         }
     }
     //$options = self::theme_folder($theme).DIRECTORY_SEPARATOR.'options.php';
     if ($options !== FALSE) {
         return Kohana::load($options);
     } else {
         return array();
     }
 }
示例#18
0
 /**
  * gets the options array from and external file options.php
  * @param  string $theme theme to load from
  * @return array        
  */
 public static function get_options($theme = NULL)
 {
     if ($theme === NULL) {
         $theme = self::$theme;
     }
     $options = self::theme_folder($theme) . DIRECTORY_SEPARATOR . 'options.php';
     if (file_exists($options)) {
         return Kohana::load($options);
     } else {
         return array();
     }
 }
示例#19
0
 /**
  * Деактивация плагина
  * 
  * При деактивации плагина происходит  запуск SQL из 
  * файла `plugin_path/install/drop.sql` и запуск файла
  * `plugin_path/uninstall.php`
  * 
  * @observer plugin_uninstall
  * @return \Plugin_Decorator
  */
 public function deactivate($run_script = FALSE)
 {
     $this->_status = (bool) DB::delete(self::TABLE_NAME)->where('id', '=', $this->id())->execute();
     Plugins::deactivate($this);
     $uninstall_file = $this->path() . 'uninstall' . EXT;
     if ($run_script === TRUE and file_exists($uninstall_file)) {
         Kohana::load($uninstall_file);
     }
     $drop_file = $this->path() . 'install' . DIRECTORY_SEPARATOR . 'drop.sql';
     if (file_exists($drop_file)) {
         Database_Helper::insert_sql(file_get_contents($drop_file));
     }
     Observer::notify('plugin_uninstall', $this->id());
     $this->_on_deactivate();
     return $this->_clear_cache();
 }