當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。