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


PHP eZTextCodec::instance方法代码示例

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


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

示例1: validateStringHTTPInput

 function validateStringHTTPInput($data, $contentObjectAttribute, $classAttribute)
 {
     $maxLen = $classAttribute->attribute(self::MAX_LEN_FIELD);
     $textCodec = eZTextCodec::instance(false);
     if ($textCodec->strlen($data) > $maxLen and $maxLen > 0) {
         $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The input text is too long. The maximum number of characters allowed is %1.'), $maxLen);
         return eZInputValidator::STATE_INVALID;
     }
     return eZInputValidator::STATE_ACCEPTED;
 }
开发者ID:legende91,项目名称:ez,代码行数:10,代码来源:ezstringtype.php

示例2: fetchAlphabet

 static function fetchAlphabet()
 {
     $contentINI = eZINI::instance('content.ini');
     $alphabetRangeList = $contentINI->hasVariable('AlphabeticalFilterSettings', 'AlphabetList') ? $contentINI->variable('AlphabeticalFilterSettings', 'AlphabetList') : array();
     $alphabetFromArray = $contentINI->hasVariable('AlphabeticalFilterSettings', 'ContentFilterList') ? $contentINI->variable('AlphabeticalFilterSettings', 'ContentFilterList') : array('default');
     // If alphabet list is empty
     if (count($alphabetFromArray) == 0) {
         return false;
     }
     $alphabetRangeList = array_merge($alphabetRangeList, array('default' => '97-122'));
     $alphabet = array();
     foreach ($alphabetFromArray as $alphabetFrom) {
         // If $alphabetFrom exists in range array $alphabetRangeList
         if (isset($alphabetRangeList[$alphabetFrom])) {
             $lettersArray = explode(',', $alphabetRangeList[$alphabetFrom]);
             foreach ($lettersArray as $letter) {
                 $rangeArray = explode('-', $letter);
                 if (isset($rangeArray[1])) {
                     $alphabet = array_merge($alphabet, range(trim($rangeArray[0]), trim($rangeArray[1])));
                 } else {
                     $alphabet = array_merge($alphabet, array(trim($letter)));
                 }
             }
         }
     }
     // Get alphabet by default (eng-GB)
     if (count($alphabet) == 0) {
         $rangeArray = explode('-', $alphabetRangeList['default']);
         $alphabet = range($rangeArray[0], $rangeArray[1]);
     }
     $resAlphabet = array();
     $i18nINI = eZINI::instance('i18n.ini');
     $charset = $i18nINI->variable('CharacterSettings', 'Charset');
     $codec = eZTextCodec::instance('utf-8', $charset);
     $utf8_codec = eZUTF8Codec::instance();
     // Convert all letters of alphabet from unicode to utf-8 and from utf-8 to current locale
     foreach ($alphabet as $item) {
         $utf8Letter = $utf8_codec->toUtf8($item);
         $resAlphabet[] = $codec ? $codec->convertString($utf8Letter) : $utf8Letter;
     }
     return $resAlphabet;
 }
开发者ID:nfrp,项目名称:ezpublish,代码行数:42,代码来源:ezalphabetoperator.php

示例3: checkObjectAttribute

 /**
  * (called for each obj attribute)
  */
 public function checkObjectAttribute(array $contentObjectAttribute)
 {
     // we adopt the ez api instead of acting on raw data
     $contentObjectAttribute = new eZContentObjectAttribute($contentObjectAttribute);
     // do not check attributes which do not even contain images
     if ($contentObjectAttribute->attribute('has_content')) {
         if ($this->maxLen > 0) {
             /// @todo check that this is the appropriate way of counting length of db data
             $textCodec = eZTextCodec::instance(false);
             $stringLength = $textCodec->strlen($contentObjectAttribute->attribute('content'));
             if ($stringLength > $this->maxLen) {
                 return array("String longer than {$this->maxLen} chars: {$stringLength}" . $this->postfixErrorMsg($contentObjectAttribute));
             }
         }
     } else {
         if (!$this->nullable) {
             return array("Attribute is null and it should not be" . $this->postfixErrorMsg($contentObjectAttribute));
         }
     }
     return array();
 }
开发者ID:gggeek,项目名称:ezdbintegrity,代码行数:24,代码来源:ezdbiezstringchecker.php

示例4: handleResourceData

 function handleResourceData($tpl, $handler, &$resourceData, $method, &$extraParameters)
 {
     // &$templateRoot, &$text, &$tstamp, $uri, $resourceName, &$path, &$keyData
     $templateRoot =& $resourceData['root-node'];
     $text =& $resourceData['text'];
     $tstamp =& $resourceData['time-stamp'];
     $uri =& $resourceData['uri'];
     $resourceName =& $resourceData['resource'];
     $path =& $resourceData['template-filename'];
     $keyData =& $resourceData['key-data'];
     $localeData =& $resourceData['locales'];
     if (!file_exists($path)) {
         return false;
     }
     $tstamp = filemtime($path);
     $result = false;
     $canCache = true;
     $templateRoot = null;
     if (!$handler->servesStaticData()) {
         $canCache = false;
     }
     if (!$tpl->isCachingAllowed()) {
         $canCache = false;
     }
     $keyData = 'file:' . $path;
     if ($method == eZTemplate::RESOURCE_FETCH) {
         if ($canCache) {
             if ($handler->hasCompiledTemplate($keyData, $uri, $resourceData, $path, $extraParameters, $tstamp)) {
                 $resourceData['compiled-template'] = true;
                 return true;
             }
         }
         if ($canCache) {
             $templateRoot = $handler->cachedTemplateTree($keyData, $uri, $resourceName, $path, $extraParameters, $tstamp);
         }
         if ($templateRoot !== null) {
             return true;
         }
         if (is_readable($path)) {
             $text = file_get_contents($path);
             $text = preg_replace("/\n|\r\n|\r/", "\n", $text);
             $tplINI = $tpl->ini();
             $charset = $tplINI->variable('CharsetSettings', 'DefaultTemplateCharset');
             $locales = array();
             $pos = strpos($text, "\n");
             if ($pos !== false) {
                 $line = substr($text, 0, $pos);
                 if (preg_match("/^\\{\\*\\?template(.+)\\?\\*\\}/", $line, $tpl_arr)) {
                     $args = explode(" ", trim($tpl_arr[1]));
                     foreach ($args as $arg) {
                         $vars = explode('=', trim($arg));
                         switch ($vars[0]) {
                             case 'charset':
                                 $val = $vars[1];
                                 if ($val[0] == '"' and strlen($val) > 0 and $val[strlen($val) - 1] == '"') {
                                     $val = substr($val, 1, strlen($val) - 2);
                                 }
                                 $charset = $val;
                                 break;
                             case 'locale':
                                 $val = $vars[1];
                                 if ($val[0] == '"' and strlen($val) > 0 and $val[strlen($val) - 1] == '"') {
                                     $val = substr($val, 1, strlen($val) - 2);
                                 }
                                 $locales = explode(',', $val);
                                 break;
                         }
                     }
                 }
             }
             /* Setting locale to allow standard PHP functions to handle
              * strtoupper/lower() */
             $defaultLocale = trim($tplINI->variable('CharsetSettings', 'DefaultTemplateLocale'));
             if ($defaultLocale != '') {
                 $locales = array_merge($locales, explode(',', $defaultLocale));
             }
             $localeData = $locales;
             if ($locales && count($locales)) {
                 setlocale(LC_CTYPE, $locales);
             }
             if (eZTemplate::isDebugEnabled()) {
                 eZDebug::writeNotice("{$path}, {$charset}");
             }
             $codec = eZTextCodec::instance($charset, false, false);
             if ($codec) {
                 eZDebug::accumulatorStart('template_resource_conversion', 'template_total', 'String conversion in template resource');
                 $text = $codec->convertString($text);
                 eZDebug::accumulatorStop('template_resource_conversion');
             }
             $result = true;
         }
     } else {
         if ($method == eZTemplate::RESOURCE_QUERY) {
             $result = true;
         }
     }
     return $result;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:98,代码来源:eztemplatefileresource.php

示例5: recode

 /**
  * Recodes $string from charset $fromCharset to charset $toCharset.
  *
  * Method from eZWebDAVServer.
  *
  * @param string $string
  * @param string $fromCharset
  * @param string $toCharset
  * @param bool $stop
  * @return string
  */
 protected static function recode($string, $fromCharset, $toCharset, $stop = false)
 {
     $codec = eZTextCodec::instance($fromCharset, $toCharset, false);
     if ($codec) {
         $string = $codec->convertString($string);
     }
     return $string;
 }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:19,代码来源:ezwebdavcontentbackend.php

示例6: parseFile

 function parseFile($file, $placement = false)
 {
     if (eZINI::isDebugEnabled()) {
         eZDebug::writeNotice("Parsing file '{$file}'", __METHOD__);
     }
     $contents = file_get_contents($file);
     if ($contents === false) {
         eZDebug::writeError("Failed opening file '{$file}' for reading", __METHOD__);
         return false;
     }
     $contents = str_replace("\r", '', $contents);
     $endOfLine = strpos($contents, "\n");
     $line = substr($contents, 0, $endOfLine);
     $currentBlock = "";
     if ($line) {
         // check for charset
         if (preg_match("/#\\?ini(.+)\\?/", $line, $ini_arr)) {
             $args = explode(" ", trim($ini_arr[1]));
             foreach ($args as $arg) {
                 $vars = explode('=', trim($arg));
                 if ($vars[0] == "charset") {
                     $val = $vars[1];
                     if ($val[0] == '"' and strlen($val) > 0 and $val[strlen($val) - 1] == '"') {
                         $val = substr($val, 1, strlen($val) - 2);
                     }
                     $this->Charset = $val;
                 }
             }
         }
     }
     unset($this->Codec);
     if ($this->UseTextCodec) {
         $this->Codec = eZTextCodec::instance($this->Charset, false, false);
         if ($this->Codec) {
             eZDebug::accumulatorStart('ini_conversion', false, 'INI string conversion');
             $contents = $this->Codec->convertString($contents);
             eZDebug::accumulatorStop('ini_conversion', false, 'INI string conversion');
         }
     } else {
         $this->Codec = null;
     }
     foreach (explode("\n", $contents) as $line) {
         if ($line == '' or $line[0] == '#') {
             continue;
         }
         if (preg_match("/^(.+)##.*/", $line, $regs)) {
             $line = $regs[1];
         }
         if (trim($line) == '') {
             continue;
         }
         // check for new block
         if (preg_match("#^\\[(.+)\\]\\s*\$#", $line, $newBlockNameArray)) {
             $newBlockName = trim($newBlockNameArray[1]);
             $currentBlock = $newBlockName;
             continue;
         }
         // check for variable
         if (preg_match("#^([\\w_*@-]+)\\[\\]\$#", $line, $valueArray)) {
             $varName = trim($valueArray[1]);
             if ($placement) {
                 if (isset($this->BlockValuesPlacement[$currentBlock][$varName]) && !is_array($this->BlockValuesPlacement[$currentBlock][$varName])) {
                     eZDebug::writeError("Wrong operation on the ini setting array '{$varName}'", __METHOD__);
                     continue;
                 }
                 $this->BlockValuesPlacement[$currentBlock][$varName][] = $file;
             } else {
                 $this->BlockValues[$currentBlock][$varName] = array();
                 // In direct access mode we create empty elements at the beginning of an array
                 // in case it is redefined in this ini file. So when we will save it, definition
                 // will be created as well.
                 if ($this->AddArrayDefinition) {
                     $this->BlockValues[$currentBlock][$varName][] = "";
                 }
             }
         } else {
             if (preg_match("#^([\\w_*@-]+)(\\[([^\\]]*)\\])?=(.*)\$#", $line, $valueArray)) {
                 $varName = trim($valueArray[1]);
                 $varValue = $valueArray[4];
                 if ($valueArray[2]) {
                     if ($valueArray[3]) {
                         $keyName = $valueArray[3];
                         if ($placement) {
                             $this->BlockValuesPlacement[$currentBlock][$varName][$keyName] = $file;
                         } else {
                             $this->BlockValues[$currentBlock][$varName][$keyName] = $varValue;
                         }
                     } else {
                         if ($placement) {
                             $this->BlockValuesPlacement[$currentBlock][$varName][] = $file;
                         } else {
                             $this->BlockValues[$currentBlock][$varName][] = $varValue;
                         }
                     }
                 } else {
                     if ($placement) {
                         $this->BlockValuesPlacement[$currentBlock][$varName] = $file;
                     } else {
                         $this->BlockValues[$currentBlock][$varName] = $varValue;
                     }
//.........这里部分代码省略.........
开发者ID:runelangseid,项目名称:ezpublish,代码行数:101,代码来源:ezini.php

示例7: validateObjectAttributeHTTPInput

 /**
  * Validates the input from the object edit form concerning this attribute.
  *
  * @param mixed  $http                   Class eZHTTPTool.
  * @param string $base                   Seems to be always 'ContentObjectAttribute'.
  * @param mixed  $contentObjectAttribute Class eZContentObjectAttribute.
  *
  * @return int eZInputValidator::STATE_INVALID/STATE_ACCEPTED
  */
 public function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
 {
     if ($http->hasPostVariable($base . '_ymcmschapv2_data_text_' . $contentObjectAttribute->attribute('id'))) {
         $data = $http->postVariable($base . '_ymcmschapv2_data_text_' . $contentObjectAttribute->attribute('id'));
         $classAttribute = $contentObjectAttribute->contentClassAttribute();
         if ($data == "") {
             if ($contentObjectAttribute->validateIsRequired()) {
                 $contentObjectAttribute->setValidationError(ezi18n('kernel/classes/datatypes', 'Input required.'));
                 return eZInputValidator::STATE_INVALID;
             }
         } else {
             $maxLen = $classAttribute->attribute(self::MAX_LEN_FIELD);
             $textCodec = eZTextCodec::instance(false);
             if ($textCodec->strlen($data) > $maxLen and $maxLen > 0) {
                 $contentObjectAttribute->setValidationError(ezi18n('kernel/classes/datatypes', 'The input text is too long. The maximum number of characters allowed is %1.'), $maxLen);
                 return eZInputValidator::STATE_INVALID;
             }
             $minLen = $classAttribute->attribute(self::MIN_LEN_FIELD);
             if ($textCodec->strlen($data) < $minLen and $minLen > 0) {
                 $contentObjectAttribute->setValidationError(ezi18n('kernel/classes/datatypes', 'The input text is too short. The minimum number of characters is %1.'), $minLen);
                 return eZInputValidator::STATE_INVALID;
             }
             //Make the user input asomething different from his normal password //start
             //ToDo: Do not return valid if the user has changed his pwassword but the new password is not in the "_POST-Array...
             $found_login = false;
             $found_password = false;
             //ToDO: Don't walk through the $_POST-array...
             foreach ($_POST as $key => $content) {
                 if (strpos($key, '_data_user_login_') != false and $content != '') {
                     $found_login = $content;
                 } else {
                     if (strpos($key, '_data_user_password_') != false and $content != '') {
                         $found_password = $content;
                     }
                 }
             }
             if ($found_password !== false and $found_password == $data) {
                 $contentObjectAttribute->setValidationError(ezi18n('kernel/classes/datatypes', 'This has to be different from your new user account password.'));
                 return eZInputValidator::STATE_INVALID;
             } else {
                 $objectID = $contentObjectAttribute->attribute('contentobject_id');
                 include_once "kernel/classes/datatypes/ezuser/ezuser.php";
                 $user = eZUser::fetch($objectID);
                 if (is_object($user)) {
                     if ($found_login === false) {
                         $found_login = $user->attribute('login');
                     }
                     $passHash = eZUser::createHash($found_login, $data, eZUser::site(), $user->attribute('password_hash_type'));
                     if ($passHash == $user->attribute('password_hash')) {
                         $contentObjectAttribute->setValidationError(ezi18n('kernel/classes/datatypes', 'This has to be different from your current user account password.'));
                         return eZInputValidator::STATE_INVALID;
                     }
                 }
             }
             //Make the user input asomething different from his normal password //end
             return eZInputValidator::STATE_ACCEPTED;
         }
     }
     return eZInputValidator::STATE_ACCEPTED;
 }
开发者ID:kmajkowski,项目名称:ymc-ezp-datatypes,代码行数:69,代码来源:ymcmschapv2type.php

示例8: modify

 function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement)
 {
     switch ($operatorName) {
         // Convert all alphabetical chars of operatorvalue to uppercase.
         case $this->UpcaseName:
             $funcName = function_exists('mb_strtoupper') ? 'mb_strtoupper' : 'strtoupper';
             $operatorValue = $funcName($operatorValue);
             break;
             // Convert all alphabetical chars of operatorvalue to lowercase.
         // Convert all alphabetical chars of operatorvalue to lowercase.
         case $this->DowncaseName:
             $funcName = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
             $operatorValue = $funcName($operatorValue);
             break;
             // Count and return the number of words in operatorvalue.
         // Count and return the number of words in operatorvalue.
         case $this->Count_wordsName:
             $operatorValue = preg_match_all("#(\\w+)#", $operatorValue, $dummy_match);
             break;
             // Count and return the number of chars in operatorvalue.
         // Count and return the number of chars in operatorvalue.
         case $this->Count_charsName:
             $funcName = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen';
             $operatorValue = $funcName($operatorValue);
             break;
             // Insert HTML line breaks before newlines.
         // Insert HTML line breaks before newlines.
         case $this->BreakName:
             $operatorValue = nl2br($operatorValue);
             break;
             // Wrap line (insert newlines).
         // Wrap line (insert newlines).
         case $this->WrapName:
             $parameters = array($operatorValue);
             if ($namedParameters['wrap_at_position']) {
                 $parameters[] = $namedParameters['wrap_at_position'];
                 if ($namedParameters['break_sequence']) {
                     $parameters[] = $namedParameters['break_sequence'];
                     if ($namedParameters['cut']) {
                         $parameters[] = $namedParameters['cut'];
                     }
                 }
             }
             $operatorValue = call_user_func_array('wordwrap', $parameters);
             break;
             // Convert the first character to uppercase.
         // Convert the first character to uppercase.
         case $this->UpfirstName:
             $i18nIni = eZINI::instance('i18n.ini');
             $hasMBString = ($i18nIni->variable('CharacterSettings', 'MBStringExtension') == 'enabled' and function_exists("mb_strtoupper") and function_exists("mb_substr") and function_exists("mb_strlen"));
             if ($hasMBString) {
                 $encoding = eZTextCodec::internalCharset();
                 $firstLetter = mb_strtoupper(mb_substr($operatorValue, 0, 1, $encoding), $encoding);
                 $remainingText = mb_substr($operatorValue, 1, mb_strlen($operatorValue, $encoding), $encoding);
                 $operatorValue = $firstLetter . $remainingText;
             } else {
                 $operatorValue = ucfirst($operatorValue);
             }
             break;
             // Simplify / transform multiple consecutive characters into one.
         // Simplify / transform multiple consecutive characters into one.
         case $this->SimplifyName:
             $simplifyCharacter = $namedParameters['char'];
             if ($namedParameters['char'] === false) {
                 $replace_this = "/ {2,}/";
                 $simplifyCharacter = ' ';
             } else {
                 $replace_this = "/" . $simplifyCharacter . "{2,}/";
             }
             $operatorValue = preg_replace($replace_this, $simplifyCharacter, $operatorValue);
             break;
             // Convert all first characters [in all words] to uppercase.
         // Convert all first characters [in all words] to uppercase.
         case $this->UpwordName:
             $i18nIni = eZINI::instance('i18n.ini');
             $hasMBString = ($i18nIni->variable('CharacterSettings', 'MBStringExtension') == 'enabled' and function_exists("mb_strtoupper") and function_exists("mb_substr") and function_exists("mb_strlen"));
             if ($hasMBString) {
                 $encoding = eZTextCodec::internalCharset();
                 $words = explode(" ", $operatorValue);
                 $newString = array();
                 foreach ($words as $word) {
                     $firstLetter = mb_strtoupper(mb_substr($word, 0, 1, $encoding), $encoding);
                     $remainingText = mb_substr($word, 1, mb_strlen($word, $encoding), $encoding);
                     $newString[] = $firstLetter . $remainingText;
                 }
                 $operatorValue = implode(" ", $newString);
                 unset($newString, $words);
             } else {
                 $operatorValue = ucwords($operatorValue);
             }
             break;
             // Strip whitespace from the beginning and end of a string.
         // Strip whitespace from the beginning and end of a string.
         case $this->TrimName:
             if ($namedParameters['chars_to_remove'] === false) {
                 $operatorValue = trim($operatorValue);
             } else {
                 $operatorValue = trim($operatorValue, $namedParameters['chars_to_remove']);
             }
             break;
//.........这里部分代码省略.........
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:101,代码来源:eztemplatestringoperator.php

示例9: file_get_contents

}

$templateContent = file_get_contents( $fileName );

/* Here we figure out the characterset of the template. If there is a charset
 * associated with the template in the header we use that one, if not we fall
 * back to the INI setting "DefaultTemplateCharset". */
if ( preg_match('|{\*\?template.*charset=([a-zA-Z0-9-]*).*\?\*}|', $templateContent, $matches ) )
{
    $templateCharset = $matches[1];
}
else
{
    $templateCharset = $templateConfig->variable( 'CharsetSettings', 'DefaultTemplateCharset');
}

/* If we're loading a template for editting we need to convert it to the HTTP
 * Charset. */
$codec = eZTextCodec::instance( $templateCharset, $outputCharset, false );
if ( $codec )
{
    $templateContent = $codec->convertString( $templateContent );
}

$tpl->setVariable( 'template', $template );
$tpl->setVariable( 'template_content', $templateContent );

$Result['content'] = $tpl->fetch( "design:visual/templateedit.tpl" );

?>
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:30,代码来源:templateedit.php

示例10: handleMessageNode

 /**
  * Handles a translation message DOM node
  * @param string $contextName
  * @param DOMNode $message
  */
 function handleMessageNode($contextName, $message)
 {
     $source = null;
     $translation = null;
     $comment = null;
     $message_children = $message->childNodes;
     for ($i = 0; $i < $message_children->length; $i++) {
         $message_child = $message_children->item($i);
         if ($message_child->nodeType == XML_ELEMENT_NODE) {
             $childName = $message_child->tagName;
             if ($childName == "source") {
                 if ($message_child->childNodes->length > 0) {
                     $source = '';
                     foreach ($message_child->childNodes as $textEl) {
                         if ($textEl instanceof DOMText) {
                             $source .= $textEl->nodeValue;
                         } else {
                             if ($textEl instanceof DOMElement && $textEl->tagName == 'byte') {
                                 $source .= chr(intval('0' . $textEl->getAttribute('value')));
                             }
                         }
                     }
                 }
             } else {
                 if ($childName == "translation") {
                     if ($message_child->childNodes->length > 0) {
                         $translation = '';
                         foreach ($message_child->childNodes as $textEl) {
                             if ($textEl instanceof DOMText) {
                                 $translation .= $textEl->nodeValue;
                             } else {
                                 if ($textEl instanceof DOMElement && $textEl->tagName == 'byte') {
                                     $translation .= chr(intval('0' . $textEl->getAttribute('value')));
                                 }
                             }
                         }
                     }
                 } else {
                     if ($childName == "comment") {
                         $comment_el = $message_child->firstChild;
                         $comment = $comment_el->nodeValue;
                     } else {
                         if ($childName == "translatorcomment") {
                             //Ignore it.
                         } else {
                             if ($childName == "location") {
                                 //Handle location element. No functionality yet.
                             } else {
                                 eZDebug::writeError("Unknown element name: " . $childName, __METHOD__);
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($source === null) {
         eZDebug::writeError("No source name found, skipping message in context '{$contextName}'", __METHOD__);
         return false;
     }
     if ($translation === null) {
         //             eZDebug::writeError( "No translation, skipping message", __METHOD__ );
         $translation = $source;
     }
     /* we need to convert ourselves if we're using libxml stuff here */
     if ($message instanceof DOMElement) {
         $codec = eZTextCodec::instance("utf8");
         $source = $codec->convertString($source);
         $translation = $codec->convertString($translation);
         $comment = $codec->convertString($comment);
     }
     $this->insert($contextName, $source, $translation, $comment);
     return true;
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:79,代码来源:eztstranslator.php

示例11: eZDBInterface

 /**
  * Creates a new eZDBInterface object and connects to the database backend.
  *
  * @param array $parameters
  */
 function eZDBInterface($parameters)
 {
     $server = $parameters['server'];
     $port = $parameters['port'];
     $user = $parameters['user'];
     $password = $parameters['password'];
     $db = $parameters['database'];
     $useSlaveServer = $parameters['use_slave_server'];
     $slaveServer = $parameters['slave_server'];
     $slavePort = $parameters['slave_port'];
     $slaveUser = $parameters['slave_user'];
     $slavePassword = $parameters['slave_password'];
     $slaveDB = $parameters['slave_database'];
     $socketPath = $parameters['socket'];
     $charset = $parameters['charset'];
     $isInternalCharset = $parameters['is_internal_charset'];
     $builtinEncoding = $parameters['builtin_encoding'];
     $connectRetries = $parameters['connect_retries'];
     if ($parameters['use_persistent_connection'] == 'enabled') {
         $this->UsePersistentConnection = true;
     }
     $this->DB = $db;
     $this->Server = $server;
     $this->Port = $port;
     $this->SocketPath = $socketPath;
     $this->User = $user;
     $this->Password = $password;
     $this->UseSlaveServer = $useSlaveServer;
     $this->SlaveDB = $slaveDB;
     $this->SlaveServer = $slaveServer;
     $this->SlavePort = $slavePort;
     $this->SlaveUser = $slaveUser;
     $this->SlavePassword = $slavePassword;
     $this->Charset = $charset;
     $this->IsInternalCharset = $isInternalCharset;
     $this->UseBuiltinEncoding = $builtinEncoding;
     $this->ConnectRetries = $connectRetries;
     $this->DBConnection = false;
     $this->DBWriteConnection = false;
     $this->TransactionCounter = 0;
     $this->TransactionIsValid = false;
     $this->TransactionStackTree = false;
     $this->OutputTextCodec = null;
     $this->InputTextCodec = null;
     $tmpOutputTextCodec = eZTextCodec::instance($charset, false, false);
     $tmpInputTextCodec = eZTextCodec::instance(false, $charset, false);
     unset($this->OutputTextCodec);
     unset($this->InputTextCodec);
     $this->OutputTextCodec = null;
     $this->InputTextCodec = null;
     if ($tmpOutputTextCodec && $tmpInputTextCodec) {
         if ($tmpOutputTextCodec->conversionRequired() && $tmpInputTextCodec->conversionRequired()) {
             $this->OutputTextCodec =& $tmpOutputTextCodec;
             $this->InputTextCodec =& $tmpInputTextCodec;
         }
     }
     $this->OutputSQL = false;
     $this->SlowSQLTimeout = 0;
     $ini = eZINI::instance();
     if ($ini->variable("DatabaseSettings", "SQLOutput") == "enabled" and $ini->variable("DebugSettings", "DebugOutput") == "enabled") {
         $this->OutputSQL = true;
         $this->SlowSQLTimeout = (int) $ini->variable("DatabaseSettings", "SlowQueriesOutput");
     }
     if ($ini->variable("DatabaseSettings", "DebugTransactions") == "enabled") {
         // Setting it to an array turns on the debugging
         $this->TransactionStackTree = array();
     }
     $this->QueryAnalysisOutput = false;
     if ($ini->variable("DatabaseSettings", "QueryAnalysisOutput") == "enabled") {
         $this->QueryAnalysisOutput = true;
     }
     $this->IsConnected = false;
     $this->NumQueries = 0;
     $this->StartTime = false;
     $this->EndTime = false;
     $this->TimeTaken = false;
     $this->AttributeVariableMap = array('database_name' => 'DB', 'database_server' => 'Server', 'database_port' => 'Port', 'database_socket_path' => 'SocketPath', 'database_user' => 'User', 'use_slave_server' => 'UseSlaveServer', 'slave_database_name' => 'SlaveDB', 'slave_database_server' => 'SlaveServer', 'slave_database_port' => 'SlavePort', 'slave_database_user' => 'SlaveUser', 'charset' => 'Charset', 'is_internal_charset' => 'IsInternalCharset', 'use_builting_encoding' => 'UseBuiltinEncoding', 'retry_count' => 'ConnectRetries');
 }
开发者ID:netbliss,项目名称:ezpublish,代码行数:83,代码来源:ezdbinterface.php

示例12: executeCommandCode

 function executeCommandCode(&$text, $command, $charsetName)
 {
     if ($command['command'] == 'url_cleanup_iri') {
         $text = eZCharTransform::commandUrlCleanupIRI($text, $charsetName);
         return true;
     } else {
         if ($command['command'] == 'url_cleanup') {
             $text = eZCharTransform::commandUrlCleanup($text, $charsetName);
             return true;
         } else {
             if ($command['command'] == 'url_cleanup_compat') {
                 $text = eZCharTransform::commandUrlCleanupCompat($text, $charsetName);
                 return true;
             } else {
                 if ($command['command'] == 'identifier_cleanup') {
                     $text = strtolower($text);
                     $text = preg_replace(array("#[^a-z0-9_ ]#", "/ /", "/__+/", "/^_|_\$/"), array(" ", "_", "_", ""), $text);
                     return true;
                 } else {
                     if ($command['command'] == 'search_cleanup') {
                         $nonCJKCharsets = $this->nonCJKCharsets();
                         if (!in_array($charsetName, $nonCJKCharsets)) {
                             // 4 Add spaces after chinese / japanese / korean multibyte characters
                             $codec = eZTextCodec::instance(false, 'unicode');
                             $unicodeValueArray = $codec->convertString($text);
                             $normalizedTextArray = array();
                             $bFlag = false;
                             foreach (array_keys($unicodeValueArray) as $valueKey) {
                                 // Check for word characters that should be broken up for search
                                 if ($unicodeValueArray[$valueKey] >= 12289 and $unicodeValueArray[$valueKey] <= 12542 or $unicodeValueArray[$valueKey] >= 13312 and $unicodeValueArray[$valueKey] <= 40863 or $unicodeValueArray[$valueKey] >= 44032 and $unicodeValueArray[$valueKey] <= 55203) {
                                     if ($bFlag) {
                                         $normalizedTextArray[] = $unicodeValueArray[$valueKey];
                                     }
                                     $normalizedTextArray[] = 32;
                                     // A space
                                     $normalizedTextArray[] = $unicodeValueArray[$valueKey];
                                     $bFlag = true;
                                 } else {
                                     if ($bFlag) {
                                         $normalizedTextArray[] = 32;
                                         // A space
                                     }
                                     $normalizedTextArray[] = $unicodeValueArray[$valueKey];
                                     $bFlag = false;
                                 }
                             }
                             if ($bFlag) {
                                 $normalizedTextArray[count($normalizedTextArray) - 1] = 32;
                             }
                             $revCodec = eZTextCodec::instance('unicode', false);
                             // false means use internal charset
                             $text = $revCodec->convertString($normalizedTextArray);
                         }
                         // Make sure dots inside words/numbers are kept, the rest is turned into space
                         $text = preg_replace(array("#(\\.){2,}#", "#^\\.#", "#\\s\\.#", "#\\.\\s#", "#\\.\$#", "#([^0-9])%#"), array(" ", " ", " ", " ", " ", "\$1 "), $text);
                         $ini = eZINI::instance();
                         if ($ini->variable('SearchSettings', 'EnableWildcard') != 'true') {
                             $text = str_replace("*", " ", $text);
                         }
                         $charset = eZTextCodec::internalCharset();
                         $hasUTF8 = $charset == "utf-8";
                         if ($hasUTF8) {
                             $text = preg_replace("#(\\s+)#u", " ", $text);
                         } else {
                             $text = preg_replace("#(\\s+)#", " ", $text);
                         }
                         return true;
                     } else {
                         $ini = eZINI::instance('transform.ini');
                         $commands = $ini->variable('Extensions', 'Commands');
                         if (isset($commands[$command['command']])) {
                             list($path, $className) = explode(':', $commands[$command['command']], 2);
                             if (file_exists($path)) {
                                 include_once $path;
                                 $text = call_user_func_array(array($className, 'executeCommand'), array($text, $command['command'], $charsetName));
                                 return true;
                             } else {
                                 eZDebug::writeError("Could not locate include file '{$path}' for transformation '" . $command['command'] . "'");
                             }
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:legende91,项目名称:ez,代码行数:87,代码来源:ezcodemapper.php

示例13: array

        $normalizedTextArray[] = 32;
        // A space
        $normalizedTextArray[] = $unicodeValueArray[$valueKey];
        $bFlag = true;
    } else {
        if ($bFlag) {
            $normalizedTextArray[] = 32;
            // A space
        }
        $normalizedTextArray[] = $unicodeValueArray[$valueKey];
        $bFlag = false;
    }
}
if ($bFlag) {
    $normalizedTextArray[count($normalizedTextArray) - 1] = 32;
}
$revCodec = eZTextCodec::instance('unicode', false);
// false means use internal charset
$text = $revCodec->convertString($normalizedTextArray);
$text = preg_replace(array("#(\\.){2,}#", "#^\\.#", "#\\s\\.#", "#\\.\\s#", "#\\.\$#", "#([^0-9])%#"), array(" ", " ", " ", " ", " ", " "), $text);
$ini = eZINI::instance();
if ($ini->variable('SearchSettings', 'EnableWildcard') != 'true') {
    $text = str_replace("*", " ", $text);
}
$charset = eZTextCodec::internalCharset();
$hasUTF8 = $charset == "utf-8";
if ($hasUTF8) {
    $text = preg_replace("#(\\s+)#u", " ", $text);
} else {
    $text = preg_replace("#(\\s+)#", " ", $text);
}
开发者ID:BGCX067,项目名称:ezpublish-thetechtalent-svn-to-git,代码行数:31,代码来源:g-search-1924056142-utf-8.ctt.php

示例14: convertFilterString

 /**
  * Converts filter string to current locale. When an user types in browser
  * url like: "/content/view/full/2/(namefilter)/a" 'a' letter should be
  * urldecoded and converted from utf-8 to current locale.
  *
  * @return string converted string
  */
 public function convertFilterString()
 {
     foreach (array_keys($this->UserArray) as $paramKey) {
         if ($paramKey == 'namefilter') {
             $char = $this->UserArray[$paramKey];
             $char = urldecode($char);
             $codec = eZTextCodec::instance('utf-8', false);
             if ($codec) {
                 $char = $codec->convertString($char);
             }
         }
     }
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:20,代码来源:ezuri.php

示例15: modify

    function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement )
    {
        $config = eZINI::instance( 'pdf.ini' );

        switch ( $namedParameters['operation'] )
        {
            case 'toc':
            {
                $operatorValue = '<C:callTOC';

                if ( count( $operatorParameters ) > 1 )
                {
                    $params = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );

                    $operatorValue .= isset( $params['size'] ) ? ':size:'. implode(',', $params['size'] ) : '';
                    $operatorValue .= isset( $params['dots'] ) ? ':dots:'. $params['dots'] : '';
                    $operatorValue .= isset( $params['contentText'] ) ? ':contentText:'. $params['contentText'] : '';
                    $operatorValue .= isset( $params['indent'] ) ? ':indent:'. implode(',', $params['indent'] ) : '';

                }

                $operatorValue .= '>';
                eZDebug::writeNotice( 'PDF: Generating TOC', __METHOD__ );
            } break;

            case 'set_font':
            {
                $params = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );

                $operatorValue = '<ezCall:callFont';

                foreach ( $params as $key => $value )
                {
                    if ( $key == 'colorCMYK' )
                    {
                        $operatorValue .= ':cmyk:' . implode( ',', $value );
                    }
                    else if ( $key == 'colorRGB' )
                    {
                        $operatorValue .= ':cmyk:' . implode( ',', eZMath::rgbToCMYK2( $value[0]/255,
                                                                                       $value[1]/255,
                                                                                       $value[2]/255 ) );
                    }
                    else
                    {
                        $operatorValue .= ':' . $key . ':' . $value;
                    }
                }
                $operatorValue .= '>';

                eZDebug::writeNotice( 'PDF: Changed font.' );
            } break;

            case 'table':
            {
                $operatorValue = '<ezGroup:callTable';

                if ( count( $operatorParameters > 2 ) )
                {
                    $tableSettings = $tpl->elementValue( $operatorParameters[2], $rootNamespace, $currentNamespace );

                    if ( is_array( $tableSettings ) )
                    {
                        foreach( array_keys( $tableSettings ) as $key )
                        {
                            switch( $key )
                            {
                                case 'headerCMYK':
                                case 'cellCMYK':
                                case 'textCMYK':
                                case 'titleCellCMYK':
                                case 'titleTextCMYK':
                                {
                                    $operatorValue .= ':' . $key . ':' . implode( ',', $tableSettings[$key] );
                                } break;

                                default:
                                {
                                    $operatorValue .= ':' . $key . ':' . $tableSettings[$key];
                                } break;
                            }
                        }
                    }
                }

                $operatorValue .= '>';

                $rows = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );

                $rows = str_replace( array( ' ', "\t", "\r\n", "\n" ),
                                                          '',
                                                          $rows );
                $httpCharset = eZTextCodec::internalCharset();
                $outputCharset = $config->hasVariable( 'PDFGeneral', 'OutputCharset' )
                                 ? $config->variable( 'PDFGeneral', 'OutputCharset' )
                                 : 'iso-8859-1';
                $codec = eZTextCodec::instance( $httpCharset, $outputCharset );
                // Convert current text to $outputCharset (by default iso-8859-1)
                $rows = $codec->convertString( $rows );

//.........这里部分代码省略.........
开发者ID:nottavi,项目名称:ezpublish,代码行数:101,代码来源:ezpdf.php


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