Esempio n. 1
0
/**
 * Translate HTML entities back into their raw UTF-8 character values
 *
 * Note that in php4 this function only converts named entities in the html 
 * translation table. This does not include some entities, like €, 
 * ™, —, etc.
 *
 * @param string $str html encoded string (named edities and/or utf-8 decimal or hex encoding)
 * @return string (plain utf-8, no html encoding)
 */
function unhtmlentities($str)
{
    if (carl_is_php5()) {
        return html_entity_decode($str, ENT_QUOTES, 'UTF-8');
    } else {
        static $utf8_trans;
        if (!$utf8_trans) {
            $utf8_trans = array();
            foreach (get_html_translation_table(HTML_ENTITIES) as $k => $v) {
                $utf8_trans[$v] = utf8_encode($k);
            }
        }
        $str = preg_replace('~&#x([0-9a-f]+);~ei', 'carl_unichr(hexdec("\\1"))', $str);
        $str = preg_replace('~&#([0-9]+);~e', 'carl_unichr("\\1")', $str);
        return strtr($str, $utf8_trans);
    }
}
Esempio n. 2
0
<?php

include_once 'paths.php';
include_once CARL_UTIL_INC . 'basic/misc.php';
/**
 * Loads the XML Parser class appropriate for the version of PHP
 */
if (carl_is_php5()) {
    require_once XML_PARSER_INC . 'xmlparser5.php';
} else {
    require_once XML_PARSER_INC . 'xmlparser4.php';
}
Esempio n. 3
0
 function _fold_text($text)
 {
     $text = str_replace("\n", '\\n', $text);
     $text = strip_tags($text);
     if (carl_is_php5()) {
         $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
     } else {
         $text = unhtmlentities($text);
     }
     /*
     		$folded_text = "";
     		while (strlen($text) > 75)
     		{
     			$folded_text .= substr($text, 0, 75) . "\r\n ";
     			$text = substr($text, 75);
     		}
     		$folded_text .= $text;
     */
     // 2014-08-14: rewritten to handle multibyte strings
     $folded_text = "";
     $break_at = 75;
     $encoding = "UTF-8";
     while (mb_strlen($text, $encoding) > $break_at) {
         $folded_text .= mb_substr($text, 0, $break_at, $encoding) . "\r\n ";
         $text = mb_substr($text, $break_at, mb_strlen($text, $encoding), $encoding);
     }
     $folded_text .= $text;
     return $folded_text;
 }
Esempio n. 4
0
 * for the parameter editing UI (otherwise users will have to edit raw JSON).
 *
 * @author Nathan White
 * @author Andrew Bacon
 * @package reason
 * @subpackage scripts
 */
/**
 * include dependencies
 */
include_once 'reason_header.php';
reason_include_once('classes/page_types.php');
reason_include_once('minisite_templates/page_types.php');
reason_include_once('classes/session_php.php');
include_once DISCO_INC . 'controller.php';
if (!carl_is_php5()) {
    echo '<p>Sorry this requires php 5 for now</p>';
    die;
}
// Require that whomever is using the form have access.
reason_require_authentication('', 'session');
// Include all of the forms.
reason_include_once('scripts/developer_tools/page_type_wizard/SelectForm.php');
reason_include_once('scripts/developer_tools/page_type_wizard/EditForm.php');
reason_include_once('scripts/developer_tools/page_type_wizard/FormatForm.php');
//Initialize the controller and set a few options.
$controller = new FormController();
$controller->set_session_class('Session_PHP');
$controller->set_session_name('REASON_SESSION');
$controller->set_data_context('page_type_wizard');
$controller->show_back_button = true;
Esempio n. 5
0
 function _fold_text($text)
 {
     $text = str_replace("\n", '\\n', $text);
     $text = strip_tags($text);
     if (carl_is_php5()) {
         $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
     } else {
         $text = unhtmlentities($text);
     }
     $folded_text = "";
     while (strlen($text) > 75) {
         $folded_text .= substr($text, 0, 75) . "\r\n ";
         $text = substr($text, 75);
     }
     $folded_text .= $text;
     return $folded_text;
 }