Exemple #1
0
function _filter($html, $truncate = NULL, $params = NULL)
{
    require_once PA::$path . "/ext/InputSanitizer/InputSanitizer.php";
    $defaults = NULL;
    // bleep out cuss words
    $defaults->filter_profanity = TRUE;
    // strip most html
    $defaults->passthrough_html = FALSE;
    // and break longish strings
    $defaults->wbr = 15;
    // minimal HTML formating
    $defaults->taglist = array('ul', 'li', 'p', 'br', 'b', 'strong', 'em', 'i');
    $defaults->collapseWhitespace = TRUE;
    foreach ($defaults as $k => $v) {
        if (empty($params->{$k})) {
            $params->{$k} = $v;
        }
    }
    $sDom = new InputSanitizer(@$params->taglist, @$params->attrlist);
    $sDom->wbr = @$params->wbr;
    // break long strings every 15 chars
    $sDom->htmlAllowedEverywhere = TRUE;
    $sDom->passthrough = @$params->passthrough_html;
    $sDom->collapseWhitespace = $params->collapseWhitespace;
    $filered_drop = array();
    foreach ($sDom->dropWithChildren as $i => $tag) {
        if (!in_array($tag, $params->taglist)) {
            $filered_drop[] = $tag;
        }
    }
    $sDom->dropWithChildren = $filered_drop;
    $html = $sDom->process($html, $truncate);
    if (@$params->filter_profanity) {
        require_once PA::$path . "/api/Validation/ProfanityFilter.php";
        $html = ProfanityFilter::filterHTML($html);
    }
    return $html;
}
function chop_string($string, $length = 30, $link = "")
{
    if (has_html($string)) {
        $san = new InputSanitizer();
        $san->passthrough = TRUE;
        // we want no HTML filtering here
        $return = $san->process($string, $length);
    } else {
        $return = substr($string, 0, $length);
        if (strlen($string) > $length) {
            $return .= "..";
            /* if($length >= DESCRIPTION_LENGTH && !empty($link)) {
               $return .= "<br><a href='".$link."' class='forums-module'>read more..</a>";
               } */
        }
    }
    $return = nl2br($return);
    return $return;
}
function VideoList($content)
{
    // print_r($content);
    $sanit = new InputSanitizer();
    echo '<ul class="videolist">';
    foreach ($content as $k => $video) {
        echo '<li class="video">';
        $linkOpen = '<a href="' . $video->pageUrl . '" target="_blank">';
        echo $linkOpen . '<img class="thumbnail" src="' . $video->icon . '"></a>';
        echo '<p class="title">';
        echo $linkOpen . $sanit->process($video->title, 30);
        echo '</a></p>';
        echo '<p class="description">' . $sanit->process($video->description, 40) . '</p>';
        /*
        echo '<div class="config buttonbar"><ul><li>';
        if (isset($existingmedia[$video->url])) {
          echo '<a href="javascript://" onclick="removemedia(this, \''
            $video->url
            . '\');">';
          echo 'Eemove from Galery';
          echo '</a>';
        } else {
          echo '<a href="javascript://" onclick="addmedia(this, \''
            $video->url
            . '\');">';
          echo 'Add to Galery';
          echo '</a>';
        }
        echo '</li></ul></div>';
        */
        echo '</li>';
    }
    echo '</ul>';
    echo '<p class="header">&nbsp;</p>';
}