コード例 #1
0
 private static function formatFinalOutput($text, $nl2br = true)
 {
     global $_base_path;
     $text = str_replace('CONTENT_DIR/', '', $text);
     if ($nl2br) {
         return nl2br(ContentUtility::imageReplace(ContentUtility::makeClickable(ContentUtility::myCodes(' ' . $text, false))));
     }
     return ContentUtility::imageReplace(ContentUtility::makeClickable(ContentUtility::myCodes(' ' . $text, true)));
 }
コード例 #2
0
ファイル: output.inc.php プロジェクト: harriswong/AContent
/**
 * 	Transforms text based on formatting preferences.  Original $input is also changed (passed by reference).
 *	Can be called as:
 *	1) $output = AT_print($input, $name);
 *	   echo $output;
 *
 *	2) echo AT_print($input, $name); // prefered method
 *
 * @access	public
 * @param	string $input			text being transformed
 * @param	string $name			the unique name of this field (convension: table_name.field_name)
 * @param	boolean $runtime_html	forcefully disables html formatting for $input (only used by fields that 
 *									have the 'formatting' option
 * @return	string					transformed $input
 * @see		TR_FORMAT constants		in include/lib/constants.inc.php
 * @see		query_bit()				in include/vitals.inc.php
 * @author	Joel Kronenberg
 */
function AT_print($input, $name, $runtime_html = true)
{
    global $_field_formatting;
    if (!isset($_field_formatting[$name])) {
        /* field not set, check if there's a global setting */
        $parts = explode('.', $name);
        /* check if wildcard is set: */
        if (isset($_field_formatting[$parts[0] . '.*'])) {
            $name = $parts[0] . '.*';
        } else {
            /* field not set, and there's no global setting */
            /* same as TR_FORMTR_NONE */
            return $input;
        }
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_QUOTES)) {
        $input = str_replace('"', '"', $input);
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_CONTENT_DIR)) {
        $input = str_replace('CONTENT_DIR/', '', $input);
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_HTML) && $runtime_html) {
        /* what special things do we have to do if this is HTML ? remove unwanted HTML? validate? */
    } else {
        $input = str_replace('<', '&lt;', $input);
        $input = nl2br($input);
    }
    /* this has to be here, only because TR_FORMTR_HTML is the only check that has an else-block */
    if ($_field_formatting[$name] === TR_FORMTR_NONE) {
        return $input;
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_EMOTICONS)) {
        $input = smile_replace($input);
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_ATCODES)) {
        $input = trim(ContentUtility::myCodes(' ' . $input . ' '));
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_LINKS)) {
        $input = trim(ContentUtility::makeClickable(' ' . $input . ' '));
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_IMAGES)) {
        $input = trim(ContentUtility::imageReplace(' ' . $input . ' '));
    }
    return $input;
}