Example #1
0
function makeSafeEntities($str, $convertTags = 0, $encoding = "")
{
    if (is_array($arrOutput = $str)) {
        foreach (array_keys($arrOutput) as $key) {
            $arrOutput[$key] = makeSafeEntities($arrOutput[$key], $encoding);
        }
        return $arrOutput;
    } else {
        if ($str !== "") {
            $str = makeUTF8($str, $encoding);
            $str = mb_convert_encoding($str, "HTML-ENTITIES", "UTF-8");
            $str = makeAmpersandEntities($str);
            if ($convertTags) {
                $str = makeTagEntities($str);
            }
            $str = correctIllegalEntities($str);
            return $str;
        }
    }
}
Example #2
0
function wctl_loader_recurse($option, $child, $name_father = '')
{
    global $curr_area;
    $text2parse = '';
    $icon = array();
    foreach ($child->children() as $name => $children) {
        $id = $children['id'];
        switch ($option) {
            case CMS_VIEWMODE_PROJ:
                switch ($name) {
                    case 'wctl_list':
                        $text2parse .= "<div class=\"wctl_section01\">";
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_head':
                        $text2parse .= "<div class=\"wctl_head01\">";
                        $text2parse .= node_copy($children->asXML(), $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_item':
                        $text2parse .= "<div class=\"wctl_item01\">";
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_title':
                        $title = node_copy($children->asXML(), $name);
                        break;
                    case 'wctl_summary':
                        $summary = node_copy($children->asXML(), $name);
                        break;
                    case 'wctl_icon':
                        if ($children != '') {
                            $icon = $children;
                        }
                        break;
                    case 'wctl_link':
                        $link = $children;
                        $text2parse .= "<div class=\"wctl_title01\">";
                        $text2parse .= "<a href=\"" . $link . "\" ";
                        $text2parse .= "onmouseover=\"javascript: document.getElementById('wctl_preview01').src='" . WEB_WCTL_ICONS . $icon . "'; ";
                        $text2parse .= "document.getElementById('wctl_summary01').firstChild.nodeValue='" . makeSafeEntities($summary) . "';\" ";
                        $text2parse .= "onmouseout=\"javascript:document.getElementById('wctl_preview01').src='" . WEB_WCTL_ICONS . "camillo.gif'; ";
                        $text2parse .= "document.getElementById('wctl_summary01').firstChild.nodeValue='&#160;';\" ";
                        $text2parse .= "title=\"" . $icon . "\">";
                        $text2parse .= $title;
                        $text2parse .= "</a>";
                        $text2parse .= "</div>";
                        break;
                    default:
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        break;
                }
                $text2parse .= "\n";
                break;
            case CMS_VIEWMODE_LIST:
                switch ($name) {
                    case 'wctl_list':
                        $text2parse .= "<div ";
                        if ($id != '') {
                            $text2parse .= "id=\"" . $id . "\" ";
                        }
                        $text2parse .= "class=\"wctl_section02\">";
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_head':
                        $text2parse .= "<div class=\"wctl_head02\">";
                        $text2parse .= node_copy($children->asXML(), $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_item':
                        $text2parse .= "<div ";
                        if ($id != '') {
                            $text2parse .= "id=\"" . $id . "\" ";
                        }
                        $text2parse .= "class=\"wctl_item02\">";
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_caption':
                        $caption = node_copy($children->asXML(), $name);
                        break;
                    case 'wctl_title':
                        $title = node_copy($children->asXML(), $name);
                        break;
                    case 'wctl_summary':
                        $summary = node_copy($children->asXML(), $name);
                        break;
                    case 'wctl_text':
                        $text = node_copy($children->asXML(), $name);
                        break;
                    case 'wctl_note':
                        $note = node_copy($children->asXML(), $name);
                        break;
                    case 'wctl_icon':
                        if ($children != '') {
                            $icon[] = $children;
                        }
                        break;
                    case 'wctl_summary':
                        $summary = node_copy($children->asXML(), $name);
                        break;
                    case 'wctl_link':
                        $link = node_copy($children->asXML(), $name);
                        if ($caption != '') {
                            $text2parse .= "<div class=\"wctl_caption02\">";
                            $text2parse .= $caption;
                            $text2parse .= "</div>";
                        }
                        for ($ic = 0; $ic < count($icon); $ic++) {
                            $text2parse .= "<div class=\"wctl_icon02\">";
                            $f_hires = str_ireplace("_pw", "", $icon[$ic]);
                            if (is_file(WEB_WCTL_ICONS . $f_hires) && $f_hires != $icon[$ic]) {
                                $text2parse .= "<a class=\"link_pop\" title=\"(open image in a new window)\"\nhref=\"" . WEB_WCTL_ICONS . $f_hires . "\">";
                            } else {
                                $f_hires = '';
                            }
                            $text2parse .= '<img src="' . WEB_WCTL_ICONS . $icon[$ic] . '" alt="(preview)" />';
                            if ($f_hires) {
                                $text2parse .= "</a>";
                            }
                            $text2parse .= "</div>";
                        }
                        $text2parse .= "<div class=\"wctl_title02\">";
                        if ($children != '') {
                            $text2parse .= "<a class=\"link_int\" href=\"" . $link . "\" >";
                            $text2parse .= $title;
                            $text2parse .= "</a>";
                        } else {
                            $text2parse .= $title;
                        }
                        $text2parse .= "</div>";
                        if ($summary != '') {
                            $text2parse .= "<div class=\"wctl_summary02\">";
                            $text2parse .= $summary;
                            $text2parse .= "</div>";
                        }
                        if ($text != '') {
                            $text2parse .= "<div class=\"wctl_text02\">";
                            $text2parse .= $text;
                            $text2parse .= "</div>";
                        }
                        if ($note != '') {
                            $text2parse .= "<div class=\"wctl_note02\">";
                            $text2parse .= $note;
                            $text2parse .= "</div>";
                        }
                        break;
                    default:
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        break;
                }
                $text2parse .= "\n";
                break;
            case CMS_VIEWMODE_THUMB:
                switch ($name) {
                    case 'wctl_list':
                        $text2parse .= "<div class=\"spacer\"> </div>";
                        $text2parse .= "<div ";
                        if ($id != '') {
                            $text2parse .= "id=\"" . $id . "\" ";
                        }
                        $text2parse .= "class=\"wctl_section03\">";
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        $text2parse .= "</div>";
                        $text2parse .= "<div class=\"spacer\"> </div>";
                        break;
                    case 'wctl_head':
                        $text2parse .= "<div class=\"wctl_head03\">";
                        $text2parse .= node_copy($children->asXML(), $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_item':
                        $text2parse .= "<div ";
                        if ($id != '') {
                            $text2parse .= "id=\"" . $id . "\" ";
                        }
                        $text2parse .= "class=\"wctl_item03\">";
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_caption':
                        $caption = node_copy($children->asXML(), $name);
                        break;
                    case 'wctl_icon':
                        if ($children != '') {
                            $icon[] = $children;
                        }
                        break;
                    case 'wctl_link':
                        $link = node_copy($children->asXML(), $name);
                        for ($ic = 0; $ic < count($icon); $ic++) {
                            $text2parse .= "<div class=\"wctl_icon03\">";
                            $f_hires = str_ireplace("_pw", "", $icon[$ic]);
                            if (is_file(WEB_WCTL_ICONS . $f_hires) && $f_hires != $icon[$ic]) {
                                $text2parse .= "<a class=\"link_pop\" title=\"(open image in a new window)\"\nhref=\"" . WEB_WCTL_ICONS . $f_hires . "\">";
                            } else {
                                $f_hires = '';
                            }
                            $text2parse .= '<img src="' . WEB_WCTL_ICONS . $icon[$ic] . '" alt="(preview)" />';
                            if ($f_hires) {
                                $text2parse .= "</a>";
                            }
                            $text2parse .= "<br /><span class=\"wctl_caption03\">";
                            $text2parse .= $caption;
                            $text2parse .= "</span>";
                        }
                        $text2parse .= "</div>";
                        break;
                    default:
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        break;
                }
                $text2parse .= "\n";
                break;
            case CMS_VIEWMODE_PAGE:
                // PAGE
                switch ($name) {
                    case 'wctl_page':
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        break;
                    case 'wctl_caption':
                        if ($children) {
                            $text2parse .= "<div class=\"wctl_caption99\">";
                            $text2parse .= node_copy($children->asXML(), $name);
                            $text2parse .= "</div>";
                        }
                        break;
                    case 'wctl_title':
                        if ($children) {
                            $text2parse .= "<div class=\"wctl_title99\">";
                            $text2parse .= node_copy($children->asXML(), $name);
                            $text2parse .= "</div>";
                        }
                        break;
                    case 'wctl_summary':
                        if ($children) {
                            $text2parse .= "<div class=\"wctl_summary99\">";
                            $text2parse .= node_copy($children->asXML(), $name);
                            $text2parse .= "</div>";
                        }
                        break;
                    case 'wctl_text':
                        $text = node_copy($children->asXML(), $name);
                        break;
                    case 'wctl_note':
                        $note = "";
                        if ($children) {
                            $note = node_copy($children->asXML(), $name);
                        }
                        break;
                    case 'wctl_icon':
                        if ($children) {
                            $text2parse .= '<div class="wctl_icon99"><img src="' . WEB_WCTL_ICONS . $children . '" alt="(preview)" />';
                            $text2parse .= "</div>";
                        }
                        if ($text != '') {
                            $text2parse .= "<div class=\"wctl_text99\">";
                            $text2parse .= $text;
                            $text2parse .= "</div>";
                        }
                        if ($note != '') {
                            $text2parse .= "<div class=\"wctl_note99\">";
                            $text2parse .= $note;
                            $text2parse .= "</div>";
                        }
                        break;
                }
                $text2parse .= "\n";
                break;
            case CMS_VIEWMODE_NEWS:
                // BACHECA
                switch ($name) {
                    case 'wctl_list':
                        $text2parse .= "<div ";
                        if ($id != '') {
                            $text2parse .= "id=\"" . $id . "\" ";
                        }
                        $text2parse .= "class=\"wctl_section04\">";
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_head':
                        $text2parse .= "<div class=\"wctl_head04\">";
                        $text2parse .= node_copy($children->asXML(), $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_item':
                        $text2parse .= "<div ";
                        if ($id != '') {
                            switch ($id) {
                                case 'drag01':
                                    $text2parse .= "style=\"position:relative;top:0px;left:50px;\" ";
                                    break;
                                case 'drag02':
                                    $text2parse .= "style=\"position:relative;top:-130px;left:320px;\" ";
                                    break;
                                case 'drag03':
                                    $text2parse .= "style=\"position:relative;top:-200px;left:20px;\" ";
                                    break;
                                case 'drag04':
                                    $text2parse .= "style=\"position:relative;top:-350px;left:280px;\" ";
                                    break;
                                case 'drag05':
                                    $text2parse .= "style=\"position:relative;top:-400px;left:50px;\" ";
                                    break;
                                case 'drag06':
                                    $text2parse .= "style=\"position:relative;top:-550px;left:320px;\" ";
                                    break;
                            }
                            if ($id != '') {
                                $text2parse .= "id=\"" . $id . "\" ";
                            }
                            $text2parse .= "class=\"wctl_item04_drag\">";
                        } else {
                            if ($id != '') {
                                $text2parse .= "id=\"" . $id . "\" ";
                            }
                            $text2parse .= "class=\"wctl_item02\">";
                        }
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_title':
                        $title = node_copy($children->asXML(), $name);
                        break;
                    case 'wctl_text':
                        $text = node_copy($children->asXML(), $name);
                        break;
                    case 'wctl_link':
                        $link = node_copy($children->asXML(), $name);
                        $text2parse .= "<div class=\"wctl_title04\">";
                        if ($children != '') {
                            $text2parse .= "<a class=\"link_int\" href=\"" . $link . "\" >";
                            $text2parse .= $title;
                            $text2parse .= "</a>";
                        } else {
                            $text2parse .= $title;
                        }
                        $text2parse .= "<div class=\"wctl_text04\">";
                        $text2parse .= $text;
                        $text2parse .= "</div>";
                        $text2parse .= "</div>";
                        break;
                    default:
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        break;
                }
                $text2parse .= "\n";
                break;
            default:
                // ...
                switch ($name) {
                    case 'wctl_list':
                        $text2parse .= "<div class=\"wctl_section\">";
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_head':
                        $text2parse .= "<div class=\"wctl_head\">";
                        $text2parse .= node_copy($children->asXML(), $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_item':
                        $text2parse .= "<div class=\"wctl_item\">";
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_title':
                        $text2parse .= "<div class=\"wctl_title\">";
                        $text2parse .= node_copy($children->asXML(), $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_summary':
                        $text2parse .= "<div class=\"wctl_summary\">";
                        $text2parse .= node_copy($children->asXML(), $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_text':
                        $text2parse .= "<div class=\"wctl_text\">";
                        $text2parse .= node_copy($children->asXML(), $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_note':
                        $text2parse .= "<div class=\"wctl_note\">";
                        $text2parse .= node_copy($children->asXML(), $name);
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_icon':
                        if ($children != '') {
                            $text2parse .= '<div class="wctl_icon"><img src="' . WEB_WCTL_ICONS . $children . '" alt="(preview)" />';
                        }
                        $text2parse .= "</div>";
                        break;
                    case 'wctl_link':
                        $text2parse .= "<a href=\"" . $children . "\">";
                        $text2parse .= "&gt;&gt;";
                        $text2parse .= "</a>";
                        break;
                    case 'wctl_page':
                        $text2parse .= wctl_loader_recurse($option, $children, $name);
                        break;
                    default:
                        wctl_loader_recurse($option, $children, $name);
                        break;
                }
                $text2parse .= "\n";
                break;
        }
    }
    return parse_command($text2parse);
}
Example #3
0
 function makeCdata($value, $mode)
 {
     //$value = str_replace('&', '&amp;', $value);
     $value = preg_replace('/&(?!\\w+;)/', '&amp;', $value);
     // Only convert to safe characters on the way in from edit form
     if ($mode == 'content') {
         $value = makeSafeEntities($value);
     }
     if (strlen($value)) {
         $value = '<![CDATA[' . $value . ']]>';
     }
     return $value;
 }