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


PHP Horde_String::convertCharset方法代码示例

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


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

示例1: postProcess

 /**
  * Executes any code necessary after applying the filter patterns.
  *
  * @param string $text  The text after the filtering.
  *
  * @return string  The modified text.
  */
 public function postProcess($text)
 {
     try {
         $dom = new Horde_Domhtml($text, $this->_params['charset']);
         $text = Horde_String::convertCharset($this->_node($dom->dom, $dom->dom), 'UTF-8', $this->_params['charset']);
         $dom_convert = true;
     } catch (Exception $e) {
         $text = strip_tags(preg_replace("/\\<br\\s*\\/?\\>/i", "\n", $text));
         $dom_convert = false;
     }
     /* Bring down number of empty lines to 2 max, and remove trailing
      * ws. */
     $text = preg_replace(array("/\\s*\n{3,}/", "/ +\n/"), array("\n\n", "\n"), $text);
     /* Wrap the text to a readable format. */
     if ($this->_params['width']) {
         $text = wordwrap($text, $this->_params['width']);
     }
     /* Add link list. */
     if (!empty($this->_linkList)) {
         $text .= "\n\n" . Horde_Text_Filter_Translation::t("Links") . ":\n" . str_repeat('-', Horde_String::length(Horde_Text_Filter_Translation::t("Links")) + 1) . "\n";
         foreach ($this->_linkList as $key => $val) {
             $text .= '[' . ($key + 1) . '] ' . $val . "\n";
         }
     }
     return ltrim(rtrim($text), "\n");
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:33,代码来源:Html2text.php

示例2: __construct

 /**
  * Constructor.
  *
  * @param array $vars  Any required parameters.
  */
 public function __construct($vars = array())
 {
     $this->_vars['folder'] = isset($vars['folder']) ? $vars['folder'] : '';
     if (empty($vars['utf8'])) {
         $this->_vars['folder'] = Horde_String::convertCharset($this->_vars['folder'], 'UTF-8', 'UTF7-IMAP');
     }
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:12,代码来源:Fileinto.php

示例3: configSpecialValues

 /**
  */
 public function configSpecialValues($what)
 {
     switch ($what) {
         case 'apps':
             $apps = Horde_Array::valuesToKeys($GLOBALS['registry']->listApps(array('active')));
             asort($apps);
             return $apps;
         case 'languages':
             $convert_numeric = function ($num) {
                 return Horde_String::convertCharset(pack('H*', $num[1]), 'ucs-2', 'UTF-8');
             };
             $convert_symbolic = function ($symbol) {
                 return Horde_String::convertCharset(html_entity_decode($symbol[1], ENT_COMPAT, 'iso-8859-1'), 'iso-8859-1', 'UTF-8');
             };
             return array_map(function ($val) {
                 return preg_replace_callback(array('/&#x([0-9a-f]{4});/i', '/(&[^;]+;)/'), array($convert_numeric, $convert_symbolic), $val);
             }, $GLOBALS['registry']->nlsconfig->languages);
         case 'blocks':
             return $GLOBALS['injector']->getInstance('Horde_Core_Factory_BlockCollection')->create()->getBlocksList();
         case 'mapsources':
             return array('Google' => 'Google', 'Bing' => 'Bing', 'Cloudmade' => 'CloudMade', 'Mytopo' => 'MyTopo', 'Osm' => 'OpenStreetMap', 'Ocm' => 'OpenCycleMap', 'Mapquest' => 'OpenMapquest');
         case 'geocoders':
             return array('None' => null, 'Google' => 'Google');
     }
 }
开发者ID:horde,项目名称:horde,代码行数:27,代码来源:Application.php

示例4: _renderInline

 /**
  * Return the rendered inline version of the Horde_Mime_Part object.
  *
  * @return array  See parent::render().
  */
 protected function _renderInline()
 {
     $text = Horde_String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset(), 'UTF-8');
     /* Check for 'flowed' text data. */
     $data = $this->_mimepart->getContentTypeParameter('format') == 'flowed' ? $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp')) : $text;
     return $this->_renderReturn($data, 'text/html; charset=UTF-8');
 }
开发者ID:horde,项目名称:horde,代码行数:12,代码来源:Plain.php

示例5: testBug9992

 public function testBug9992()
 {
     $text = base64_decode('dGVzdDogtbno6bvtu+nt/eHpu7797Txicj4K');
     $expected = '<p>test: ľščéťíťéíýáéťžýí<br/></p>';
     $dom = new Horde_Domhtml($text, 'iso-8859-2');
     $this->assertEquals(Horde_String::convertCharset($expected, 'UTF-8', 'iso-8859-2'), strtr(trim($dom->returnBody()), array("\n" => '')));
     $this->assertEquals('UTF-8', $dom->getCharset());
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:8,代码来源:DomhtmlTest.php

示例6: testBug9567

 public function testBug9567()
 {
     $text = quoted_printable_decode("pr=E9parer =E0 vendre d’ao=FBt");
     $this->assertEquals($text, Horde_Text_Filter::filter('<html><body>' . $text . '</body></html>', 'xss', array('charset' => 'iso-8859-1')));
     $this->assertEquals($text, Horde_Text_Filter::filter('<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body>' . $text . '</body></html>', 'xss', array('charset' => 'iso-8859-1')));
     $text = Horde_String::convertCharset(quoted_printable_decode("pr=E9parer =E0 vendre d&#8217;ao=FBt&nbsp;;"), 'windows-1252', 'UTF-8');
     $expected = "préparer à vendre d’août ;";
     $this->assertEquals($expected, Horde_Text_Filter::filter('<html><body>' . $text . '</body></html>', 'xss', array('charset' => 'utf-8')));
 }
开发者ID:horde,项目名称:horde,代码行数:9,代码来源:XssTest.php

示例7: save

 /**
  * Save bookmark.
  */
 public function save($crawl = true)
 {
     if (!strlen($this->url)) {
         throw new Trean_Exception('Incomplete bookmark');
     }
     $charset = $GLOBALS['trean_db']->getOption('charset');
     $c_url = Horde_String::convertCharset($this->url, 'UTF-8', $charset);
     $c_title = Horde_String::convertCharset($this->title, 'UTF-8', $charset);
     $c_description = Horde_String::convertCharset($this->description, 'UTF-8', $charset);
     $c_favicon_url = Horde_String::convertCharset($this->favicon_url, 'UTF-8', $charset);
     if ($this->id) {
         // Update an existing bookmark.
         $GLOBALS['trean_db']->update('
             UPDATE trean_bookmarks
             SET user_id = ?,
                 bookmark_url = ?,
                 bookmark_title = ?,
                 bookmark_description = ?,
                 bookmark_clicks = ?,
                 bookmark_http_status = ?,
                 favicon_url = ?
             WHERE bookmark_id = ?', array($this->userId, $c_url, $c_title, $c_description, $this->clicks, $this->http_status, $c_favicon_url, $this->id));
         $GLOBALS['injector']->getInstance('Trean_Tagger')->replaceTags((string) $this->id, $this->tags, $GLOBALS['registry']->getAuth(), 'bookmark');
     } else {
         // Saving a new bookmark.
         $bookmark_id = $GLOBALS['trean_db']->insert('
             INSERT INTO trean_bookmarks (
                 user_id,
                 bookmark_url,
                 bookmark_title,
                 bookmark_description,
                 bookmark_clicks,
                 bookmark_http_status,
                 favicon_url,
                 bookmark_dt
             ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', array($this->userId, $c_url, $c_title, $c_description, $this->clicks, $this->http_status, $c_favicon_url, $this->dt));
         $this->id = (int) $bookmark_id;
         $GLOBALS['injector']->getInstance('Trean_Tagger')->tag((string) $this->id, $this->tags, $GLOBALS['registry']->getAuth(), 'bookmark');
     }
     if ($crawl) {
         try {
             $queue = $GLOBALS['injector']->getInstance('Horde_Queue_Storage');
             $queue->add(new Trean_Queue_Task_Crawl($this->url, $this->title, $this->description, $this->id, $this->userId));
         } catch (Exception $e) {
             Horde::log($e, 'INFO');
         }
     }
     return $this->id;
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:52,代码来源:Bookmark.php

示例8: _renderInline

 /**
  * Return the rendered inline version of the Horde_Mime_Part object.
  *
  * @return array  See parent::render().
  */
 protected function _renderInline()
 {
     /* Determine the language and brush from the mime type. */
     $mimeType = $this->_mimepart->getType();
     $language = $this->_mimeTypeToLanguage($mimeType);
     $brush = $this->_languageToBrush($language);
     $page_output = $GLOBALS['injector']->getInstance('Horde_PageOutput');
     if (!self::$_shLoaded) {
         $page_output->addScriptFile('syntaxhighlighter/scripts/syntaxhighlighter.js', 'horde');
         self::$_shLoaded = true;
         $sh_js_fs = $this->getConfigParam('registry')->get('jsfs', 'horde') . '/syntaxhighlighter/styles/';
         $sh_js_uri = Horde::url($this->getConfigParam('registry')->get('jsuri', 'horde'), false, -1) . '/syntaxhighlighter/styles/';
         $page_output->addStylesheet($sh_js_fs . 'theme.css', $sh_js_uri . 'theme.css');
     }
     $results = '<pre class="brush: ' . $language . '; toolbar: false;">' . htmlspecialchars(Horde_String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset(), $this->getConfigParam('charset')), ENT_QUOTES, $this->getConfigParam('charset')) . '</pre>';
     return $this->_renderReturn($results, 'text/html; charset=' . $this->getConfigParam('charset'));
 }
开发者ID:horde,项目名称:horde,代码行数:22,代码来源:Syntaxhighlighter.php

示例9: doAction

 /**
  * Actually carry out the action.
  *
  * @return boolean  True on success.
  * @throws Ulaform_Exception
  */
 public function doAction($form_params, $form_data, $fields)
 {
     /* Check if table exists. */
     if (!in_array($form_params['table'], $this->_db->tables())) {
         try {
             $this->_createDataTable($form_params, $fields);
         } catch (Horde_Db_Exception $e) {
             throw new Ulaform_Exception($e->getMessage());
         }
     }
     /* Submit data to database. */
     $columns = array();
     $values = array();
     foreach ($fields as $field) {
         switch ($field['field_type']) {
             case 'file':
             case 'image':
                 if (count($form_data[$field['field_name']])) {
                     $data = file_get_contents($form_data[$field['field_name']]['file']);
                     if (Horde_String::lower($this->_db->adapterName()) == 'pgsql') {
                         $data = bin2hex($data);
                     }
                     $columns[] = $field['field_name'];
                     $values[] = $data;
                 }
                 break;
             case 'set':
                 $columns[] = $field['field_name'];
                 $values[] = implode(', ', $form_data[$field['field_name']]);
                 break;
             default:
                 $data = $form_data[$field['field_name']];
                 $columns[] = $field['field_name'];
                 $values[] = Horde_String::convertCharset($data, 'UTF-8', $this->_charset);
                 break;
         }
     }
     $sql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $form_params['table'], implode(', ', $columns), str_repeat('?, ', count($values) - 1) . '?');
     try {
         $this->_db->insert($sql, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Ulaform_Exception($e->getMessage());
     }
     return true;
 }
开发者ID:horde,项目名称:horde,代码行数:51,代码来源:Sql.php

示例10: postProcess

 /**
  * Executes any code necessary after applying the filter patterns.
  *
  * @param string $text  The text after the filtering.
  *
  * @return string  The modified text.
  */
 public function postProcess($text)
 {
     if (!Horde_Util::extensionExists('tidy') || $this->_params['size'] !== false && strlen($text) > $this->_params['size']) {
         return $text;
     }
     $tidy_config = array('enclose-block-text' => true, 'hide-comments' => true, 'indent' => false, 'numeric-entities' => true, 'preserve-entities' => true, 'show-body-only' => !empty($this->_params['body_only']), 'tab-size' => 0, 'wrap' => 0);
     $tidy = new tidy();
     if (strtolower($this->_params['charset']) == 'us-ascii') {
         if ($tidy->parseString($text, $tidy_config, 'ascii')) {
             $tidy->cleanRepair();
             $text = $tidy->value;
         }
     } elseif ($tidy->parseString(Horde_String::convertCharset($text, $this->_params['charset'], 'UTF-8'), $tidy_config, 'utf8')) {
         $tidy->cleanRepair();
         $text = Horde_String::convertCharset($tidy->value, 'UTF-8', $this->_params['charset']);
     }
     return $text;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:25,代码来源:Cleanhtml.php

示例11: charset

 /**
  * Sets the charset of the search text.
  *
  * @param string $charset   The charset to use for the search.
  * @param boolean $convert  Convert existing text values?
  *
  * @throws Horde_Imap_Client_Exception_SearchCharset
  */
 public function charset($charset, $convert = true)
 {
     $oldcharset = $this->_charset;
     $this->_charset = strtoupper($charset);
     if (!$convert || $oldcharset == $this->_charset) {
         return;
     }
     foreach (array('header', 'text') as $item) {
         if (isset($this->_search[$item])) {
             foreach ($this->_search[$item] as $key => $val) {
                 $new_val = Horde_String::convertCharset($val['text'], $oldcharset, $this->_charset);
                 if (Horde_String::convertCharset($new_val, $this->_charset, $oldcharset) != $val['text']) {
                     throw new Horde_Imap_Client_Exception_SearchCharset($this->_charset);
                 }
                 $this->_search[$item][$key]['text'] = $new_val;
             }
         }
     }
 }
开发者ID:netcon-source,项目名称:apps,代码行数:27,代码来源:Query.php

示例12: handleCalleePart

 /**
  * Parse the requested folder for the owner of that folder.
  *
  * @param string $req_folder The folder requested.
  *
  * @return boolean|PEAR_Error True if successful.
  */
 protected function handleCalleePart($callee_part)
 {
     /* Handle the owner/folder name and make sure the owner part is in lower case */
     $req_folder = Horde_String::convertCharset($req_folder, 'UTF-8', 'UTF7-IMAP');
     $folder = explode('/', $req_folder);
     if (count($folder) < 2) {
         return PEAR::raiseError(sprintf(Horde_Kolab_FreeBusy_Translation::t("No such folder %s"), $req_folder));
     }
     $folder[0] = Horde_String::lower($folder[0]);
     $req_folder = implode('/', $folder);
     $this->owner = $folder[0];
     unset($folder[0]);
     $this->folder = join('/', $folder);
     $result = $this->_process();
     if (is_a($result, 'PEAR_Error')) {
         return $result;
     }
     return true;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:26,代码来源:Kolab.php

示例13: testBug10431

    public function testBug10431()
    {
        $text = 'Das könnte zum Beispiel so aussehen, dass wir bei entsprechenden Anfragen diese an eine Kontaktperson bei Euch weiterleiten. Oder Ihr schnürt ein entsprechendes Paket, dass wir in unseren Angeboten mit anführen. Bei erfolgreicher Vermittlung bekämen wir eine Vermittlungsgebühr.
Wir ständen dann weiterhin für 3rd-Level-Support zur Verfügung, d.h. für alle Anfragen des Kunden bzgl. Horde, die nicht zum Tagesgeschäft gehören.';
        $text = Horde_String::convertCharset($text, 'UTF-8', 'ISO-8859-1');
        $textBody = new Horde_Mime_Part();
        $textBody->setType('text/plain');
        $textBody->setCharset('ISO-8859-1');
        $flowed = new Horde_Text_Flowed($text, 'ISO-8859-1');
        $flowed->setDelSp(true);
        $textBody->setContents($flowed->toFlowed());
        $flowed_txt = $textBody->toString(array('headers' => false));
        $textBody2 = new Horde_Mime_Part();
        $textBody2->setType('text/plain');
        $textBody2->setCharset('ISO-8859-1');
        $textBody2->setContents($flowed_txt, array('encoding' => 'quoted-printable'));
        $flowed2 = new Horde_Text_Flowed($textBody2->getContents(), 'ISO-8859-1');
        $flowed2->setMaxLength(0);
        $flowed2->setDelSp(true);
        $this->assertEquals($text, trim($flowed2->toFixed()));
    }
开发者ID:jubinpatel,项目名称:horde,代码行数:21,代码来源:ComposeTest.php

示例14: get

 /**
  * Retrieve Free/Busy data for the specified resource.
  *
  * @param string $resource Fetch the Free/Busy data for this resource.
  *
  * @return Horde_Icalendar_Vfreebusy The Free/Busy data.
  */
 public function get($resource)
 {
     global $conf;
     $url = self::getUrl($resource);
     Horde::log(sprintf('Freebusy URL for resource %s is %s', $resource, $url), 'DEBUG');
     list($user, $domain) = explode('@', $resource);
     if (empty($domain)) {
         $domain = $conf['kolab']['filter']['email_domain'];
     }
     /**
      * This section matches Kronolith_Freebusy and should be merged with it
      * again in a single Horde_Freebusy module.
      */
     $options = array('method' => 'GET', 'timeout' => 5, 'allowRedirects' => true);
     if (!empty($conf['http']['proxy']['proxy_host'])) {
         $options = array_merge($options, $conf['http']['proxy']);
     }
     $http = new HTTP_Request($url, $options);
     $http->setBasicAuth($conf['kolab']['filter']['calendar_id'] . '@' . $domain, $conf['kolab']['filter']['calendar_pass']);
     @$http->sendRequest();
     if ($http->getResponseCode() != 200) {
         throw new Horde_Kolab_Resource_Exception(sprintf('Unable to retrieve free/busy information for %s', $resource), Horde_Kolab_Resource_Exception::NO_FREEBUSY);
     }
     $vfb_text = $http->getResponseBody();
     // Detect the charset of the iCalendar data.
     $contentType = $http->getResponseHeader('Content-Type');
     if ($contentType && strpos($contentType, ';') !== false) {
         list(, $charset, ) = explode(';', $contentType);
         $vfb_text = Horde_String::convertCharset($vfb_text, trim(str_replace('charset=', '', $charset)), 'UTF-8');
     }
     $iCal = new Horde_Icalendar();
     $iCal->parsevCalendar($vfb_text, 'VCALENDAR');
     $vfb =& $iCal->findComponent('VFREEBUSY');
     if ($vfb === false) {
         throw new Horde_Kolab_Resource_Exception(sprintf('Invalid or no free/busy information available for %s', $resource), Horde_Kolab_Resource_Exception::NO_FREEBUSY);
     }
     $vfb->simplify();
     return $vfb;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:46,代码来源:Kolab.php

示例15: copy

 /**
  * Copy/move messages.
  *
  * @param string $mbox          The mailbox name to copy/move the task to.
  * @param IMP_Indices $indices  An indices object.
  * @param boolean $move         Move if true, copy if false.
  *
  * @return boolean  True on success.
  */
 public function copy($mbox, IMP_Indices $indices, $move)
 {
     global $injector;
     $success = true;
     foreach ($indices as $ob) {
         foreach ($ob->uids as $uid) {
             /* Fetch the message contents. */
             $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create($ob->mbox->getIndicesOb($uid));
             /* Fetch the message headers. */
             $subject = strval($imp_contents->getHeader()->getHeader('Subject'));
             /* Re-flow the message for prettier formatting. */
             $body_part = $imp_contents->getMimePart($imp_contents->findBody());
             if (!$body_part) {
                 $success = false;
                 continue;
             }
             $flowed = new Horde_Text_Flowed($body_part->getContents());
             if ($body_part->getContentTypeParameter('delsp') == 'yes') {
                 $flowed->setDelSp(true);
             }
             $body = $flowed->toFlowed(false);
             /* Convert to current charset */
             /* TODO: When Horde_Icalendar supports setting of charsets
              * we need to set it there instead of relying on the fact
              * that both Nag and IMP use the same charset. */
             $body = Horde_String::convertCharset($body, $body_part->getCharset(), 'UTF-8');
             if (!$this->_create($mbox, $subject, $body)) {
                 $success = false;
             }
         }
     }
     /* Delete the original messages if this is a "move" operation. */
     if ($move) {
         $indices->delete();
     }
     return $success;
 }
开发者ID:horde,项目名称:horde,代码行数:46,代码来源:Copy.php


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