Пример #1
0
 public function test_cases()
 {
     $sentence = 'пользователь должен быть у Вас в друзьях а Вы у него';
     $this->assertEquals('ПОЛЬЗОВАТЕЛЬ ДОЛЖЕН БЫТЬ У ВАС В ДРУЗЬЯХ А ВЫ У НЕГО', trim(_strtoupper($sentence)));
     $this->assertEquals('пользователь должен быть у вас в друзьях а вы у него', trim(_strtolower($sentence)));
     $this->assertNotEquals(strtoupper($sentence), _strtoupper($sentence));
     $this->assertNotEquals(strtolower($sentence), _strtolower($sentence));
     $this->assertNotEquals(ucfirst($sentence), _ucfirst($sentence));
     $this->assertNotEquals(ucwords($sentence), _ucwords($sentence));
 }
Пример #2
0
 /**
  * Makes a UTF-8 string uppercase.
  * @see http://php.net/strtoupper
  *
  * @author  Andreas Gohr <*****@*****.**>
  *
  * @param   string   mixed case string
  * @return  string
  */
 public static function strtoupper($str)
 {
     if (!isset(self::$called[__FUNCTION__])) {
         require SYSPATH . 'core/utf8/' . __FUNCTION__ . EXT;
         // Function has been called
         self::$called[__FUNCTION__] = TRUE;
     }
     return _strtoupper($str);
 }
Пример #3
0
 /**
  * Makes a UTF-8 string uppercase. This is a UTF8-aware version
  * of [strtoupper](http://php.net/strtoupper).
  *
  * @author  Andreas Gohr <*****@*****.**>
  * @param   string   mixed case string
  * @return  string
  * @uses    UTF8::$server_utf8
  * @uses    Kohana::$charset
  */
 public static function strtoupper($str)
 {
     if (UTF8::$server_utf8) {
         return mb_strtoupper($str, Kohana::$charset);
     }
     if (!isset(self::$called[__FUNCTION__])) {
         require SYSPATH . 'utf8' . DIRECTORY_SEPARATOR . __FUNCTION__ . EXT;
         // Function has been called
         self::$called[__FUNCTION__] = TRUE;
     }
     return _strtoupper($str);
 }
Пример #4
0
 public static function strtoupper($str)
 {
     if (UTF8::$server_utf8) {
         return mb_strtoupper($str, JsonApiApplication::$charset);
     }
     if (!isset(UTF8::$called[__FUNCTION__])) {
         require JsonApiApplication::find_file("utf8", __FUNCTION__);
         // Function has been called
         UTF8::$called[__FUNCTION__] = TRUE;
     }
     return _strtoupper($str);
 }
Пример #5
0
 /**
  * Makes a UTF-8 string uppercase.
  * @see http://php.net/strtoupper
  *
  * @author  Andreas Gohr <*****@*****.**>
  *
  * @param   string   mixed case string
  * @return  string
  */
 public static function strtoupper($str)
 {
     require_once dirname(__FILE__) . '/' . __FUNCTION__ . '.php';
     return _strtoupper($str);
 }
Пример #6
0
$page_title = 'Выбор информационного объекта';
include SITE_FILE_ROOT . 'template/simple_header.php';
$sort = 'name';
$sort_dir = 'asc';
$pattern = get_request_variable('pattern', '');
$letter = get_request_variable('letter', '');
$_REQUEST['callback'] = get_request_variable('callback', '');
$_REQUEST['cat_id'] = get_request_variable('cat_id', '');
$io_id = get_request_variable('io_id', '');
$save = get_request_variable('save', '');
$where = array();
if ($pattern != '') {
    $where[] = '"name" LIKE \'%' . db_class::escape_like($pattern) . '%\'';
    $letter = '';
} elseif ($letter != '') {
    $where[] = '"name" LIKE \'' . db_class::escape_like($letter) . '%\' OR  "name" LIKE \'' . db_class::escape_like(_strtoupper($letter)) . '%\' ';
}
if ($save) {
    if ($_REQUEST['io_id'] > 0 && $_REQUEST['cat_id'] > 0) {
        $io_rub = new io_rubricator();
        $io_rub->id_rubric = $_REQUEST['cat_id'];
        $io_rub->id_io_object = $io_id;
        $io_rub->Save();
    }
}
if ($_REQUEST['cat_id'] > 0) {
    $rubricator = new rubricator();
    $rubricator->id = $_REQUEST['cat_id'];
    $rubricator->Load();
    $db = db_class::get_instance();
    $query = 'SELECT id_io_object as id FROM ' . TABLE_IO_RUBRICATOR . ' WHERE id_rubric=' . $rubricator->id;
Пример #7
0
 /**
  * Makes a UTF-8 string uppercase. This is a UTF8-aware version
  * of [strtoupper](http://php.net/strtoupper).
  *
  * @author  Andreas Gohr <*****@*****.**>
  * @param   string  $str mixed case string
  * @return  string
  * @uses    UTF8::$server_utf8
  * @uses    Kohana::$charset
  */
 public static function strtoupper($str)
 {
     if (UTF8::$server_utf8) {
         return mb_strtoupper($str, Kohana::$charset);
     }
     if (!isset(UTF8::$called[__FUNCTION__])) {
         require Kohana::find_file('utf8', __FUNCTION__);
         // Function has been called
         UTF8::$called[__FUNCTION__] = TRUE;
     }
     return _strtoupper($str);
 }
Пример #8
0
 /**
  * Makes a UTF-8 string uppercase
  *
  * This is a UTF8-aware version of [strtoupper](http://php.net/strtoupper).
  *
  * @author  Andreas Gohr <*****@*****.**>
  *
  * @param   string  $str  Mixed case string
  *
  * @return  string
  *
  * @uses    UTF8::$server_utf8
  * @uses    Kohana::$charset
  * @uses    Kohana::find_file
  */
 public static function strtoupper($str)
 {
     if (self::$server_utf8) {
         return mb_strtoupper($str, Kohana::$charset);
     }
     UTF8::_load(__FUNCTION__);
     return _strtoupper($str);
 }
Пример #9
0
 /**
  * Makes a UTF-8 string uppercase. This is a UTF8-aware version
  * of [strtoupper](http://php.net/strtoupper).
  *
  * @author  Andreas Gohr <*****@*****.**>
  * @param   string  $str mixed case string
  * @return  string
  * @uses    UTF8::$server_utf8
  * @uses    Phalcana\Phalcana::$charset
  */
 public static function strtoupper($str)
 {
     if (UTF8::$server_utf8) {
         return mb_strtoupper($str, Phalcana::$charset);
     }
     if (!isset(UTF8::$called[__FUNCTION__])) {
         require Phalcana::$di->get('fs')->findFile('utf8', __FUNCTION__);
         // Function has been called
         UTF8::$called[__FUNCTION__] = true;
     }
     return _strtoupper($str);
 }
Пример #10
0
 /**
  * Translation of the given string
  *
  * Some common symbol codes in HTML:
  *	_ => '&#95;'
  *	' => '&prime;' or '&#39;'
  *	' => '&quot;'
  *	/ => '&frasl;'
  *	\ => '&#92;'
  *	[ => '&#91;'
  *	] => '&#93;'
  *	( => '&#40;'
  *	) => '&#41;'
  *	{ => '&#123;'
  *	} => '&#125;'
  *	? => '&#63;'
  *	! => '&#33;'
  *	| => '&#124;'
  *
  * @code
  *	$msg = t('You must log in below or <a href="%url">create a new account</a> before viewing the next page.',
  *			array('%url' => process_url('./?object=user&action=register')));
  * @endcode
  *
  * We have ability to use custom prefix for vars with same names in different places with different translations
  * ex. for var "welcome" we can have several vars with prefixes  "::forum::welcome"
  * Prefix syntax:	 "::[a-z_-]::text to tranlate here"
  *
  * @access	public
  * @param	$string string	Text to translate
  * @param	$args	array	Optional array of items to replace after translation
  * @return string Translation result
  */
 function translate_string($input_string, $args = 0, $lang = '')
 {
     if (DEBUG_MODE) {
         $_start_time = microtime(true);
     }
     $lang = strval($lang);
     if (!$lang) {
         $lang = $this->_get_current_lang();
     }
     if (!isset($this->_loaded[$lang])) {
         $this->_load_lang($lang);
     }
     if (!$lang || !$this->_loaded[$lang]) {
         return $input_string;
     }
     if (is_array($args) && isset($args[''])) {
         unset($args['']);
     }
     if (is_array($input_string)) {
         foreach ((array) $input_string as $k => $v) {
             $input_string[$k] = $this->translate_string($v, $args, $lang);
         }
         return $input_string;
     }
     if (!$input_string) {
         return $input_string;
     }
     $input_string = trim($input_string);
     DEBUG_MODE && $this->_calls[$input_string]++;
     if ($this->USE_TRANSLATE_CACHE && empty($args)) {
         $CACHE_NAME = $lang . '#____#' . $input_string;
         if (isset($this->_LOCALE_CACHE[$CACHE_NAME])) {
             return $this->_LOCALE_CACHE[$CACHE_NAME];
         }
     }
     $is_translated = false;
     $_source = $input_string;
     $output_string = $input_string;
     // Try to find prefix (starts with '::')
     $_prefix = '';
     $_prefix_length = 0;
     if ($input_string[0] == ':' && $input_string[1] == ':') {
         $_prefix = substr($input_string, 0, strpos($input_string, '::', 2) + 2);
         $_prefix_length = strlen($_prefix);
         $input_string = substr($input_string, $_prefix_length);
     }
     if ($this->TRANSLATE_ENABLED) {
         // Prepare for case ignore
         if ($this->VARS_IGNORE_CASE) {
             $first_input_string = $input_string;
             $input_string = strtolower($input_string);
             if ($this->REPLACE_UNDERSCORE) {
                 $input_string = str_replace('&nbsp;', ' ', $input_string);
                 $input_string = str_replace(' ', '_', $input_string);
             }
         }
         // Try to find prefix (starts with '::') again
         if (!strlen($_prefix) && isset($this->TR_VARS[$lang]['::' . $_GET['object'] . '::' . $input_string])) {
             $_prefix = '::' . $_GET['object'] . '::';
         }
         // First try to translate var with prefix
         if (strlen($_prefix) && isset($this->TR_VARS[$lang][$_prefix . $input_string])) {
             $output_string = $this->TR_VARS[$lang][$_prefix . $input_string];
             $is_translated = true;
             // Then common var
         } elseif (isset($this->TR_VARS[$lang][$input_string])) {
             $output_string = $this->TR_VARS[$lang][$input_string];
             $is_translated = true;
             // Then try _un_html_entities
         } elseif (($var_un_html = $this->_un_html_entities($input_string)) && isset($this->TR_VARS[$lang][$var_un_html])) {
             $output_string = $this->TR_VARS[$lang][$var_un_html];
             $is_translated = true;
             // Last - is untranslated
         } else {
             $output_string = $input_string;
             if (DEBUG_MODE) {
                 if (!isset($this->_NOT_TRANSLATED)) {
                     $this->_NOT_TRANSLATED = [];
                 }
                 if (!isset($this->_NOT_TRANSLATED[$lang])) {
                     $this->_NOT_TRANSLATED[$lang] = [];
                 }
                 if (!isset($this->_NOT_TRANSLATED[$lang][$input_string])) {
                     $this->_NOT_TRANSLATED[$lang][$input_string] = 0;
                 }
                 $this->_NOT_TRANSLATED[$lang][$input_string]++;
                 // Check if such variable exists
                 if ($this->AUTO_FIND_VARS && !isset($this->TR_ALL_VARS[$input_string])) {
                     $this->insert_var($input_string);
                 }
             }
         }
     }
     if ($this->REPLACE_UNDERSCORE && !$is_translated) {
         $output_string = str_replace('_', ' ', $_source);
         if ($_prefix_length) {
             $output_string = substr($output_string, $_prefix_length);
         }
     }
     if (!empty($args) && is_array($args)) {
         $output_string = $this->_process_sub_patterns($output_string, $args);
         $output_string = strtr($output_string, $args);
     }
     if ($this->TRACK_FIRST_LETTER_CASE && $is_translated) {
         $input = $this->VARS_IGNORE_CASE ? $first_input_string : $input_string;
         $first_s = substr($input, 0, 1);
         $first_t = _substr($output_string, 0, 1);
         $first_s_lower = strtolower($first_s) == $first_s;
         $first_t_lower = _strtolower($first_t) == $first_t;
         if (!$first_s_lower && $first_t_lower) {
             $output_string = _strtoupper($first_t) . _substr($output_string, 1);
         }
     }
     if (DEBUG_MODE) {
         if ($this->WRAP_VARS_FOR_INLINE_EDIT && false === strpos($output_string, 'class=localetr')) {
             $r = [' ' => '%20', '=' => '&equals;', '<' => '&lt;', '>' => '&gt;'];
             $svar = _prepare_html(str_replace(array_keys($r), array_values($r), $_source));
             $output_string = '<span class=localetr svar=' . $svar . '>' . $output_string . '</span>';
         }
         debug('i18n[]', ['name_orig' => $_source, 'name' => $input_string, 'out' => $output_string, 'lang' => $lang, 'args' => $args ?: '', 'translated' => (int) $is_translated, 'time' => round(microtime(true) - $_start_time, 5), 'trace' => main()->trace_string()]);
     }
     // Put to cache
     if ($this->USE_TRANSLATE_CACHE && empty($args)) {
         $this->_LOCALE_CACHE[$CACHE_NAME] = $output_string;
     }
     return $output_string;
 }