Ejemplo n.º 1
0
function pagedText($str, $id, $field, $highlight, $chunk)
{
    $str = strip_tags(html_entity_decode($str));
    $count = 0;
    $nav = array();
    $newresult = array();
    $posnav = array();
    //If the highlight field is present replace the text with the highlighted ems
    if ($highlight != false) {
        $rhlt = replaceHighlight($str, $highlight, $field, $chunk, true);
        $str = $rhlt[0];
        $posnav = $rhlt[1];
    }
    $totelen = strlen($str);
    $lastone = false;
    while ($totelen > 0) {
        if (strlen($str) > $chunk) {
            $leng = strpos($str, " ", $chunk);
            if ($leng == false) {
                $leng = strlen($str);
                $lastone = true;
            }
        } else {
            $lastone = true;
            $leng = strlen($str);
        }
        //  Cut text
        $page = substr($str, 0, $leng);
        $newresult[] = "<div class='pt-page-" . $count . " ptp'>" . $page . "</div>";
        if (isset($posnav[$count])) {
            $nav[] = "<li><a class='pt-nav-" . $count . " highlight'>" . $count . "</a></li>";
        } else {
            if ($count == 0) {
                $nav[] = "<li><a class='pt-nav-" . $count . " active'>" . $count . "</a></li>";
            } else {
                $nav[] = "<li><a class='pt-nav-" . $count . "'>" . $count . "</a></li>";
            }
        }
        //  check length and if its less than the char leng to
        //  seperate by than set the loop to stop to prevent a never ending loop.
        if ($lastone == false) {
            $totelen = $totelen - $leng;
        } else {
            break;
        }
        $count++;
        $str = substr($str, $leng);
    }
    $count = 0;
    return "<div class='paged-text' id='pt-" . $id . "'><ul class='pt-nav'>" . implode('', $nav) . "</ul>" . implode('', $newresult) . "</div>";
    unset($nav);
    unset($newresult);
    ob_flush();
}
Ejemplo n.º 2
0
 public function fullViewMain($result, $result_config, $id, $highlight)
 {
     global $largetext, $layout, $array_fields;
     $sectionmain = array();
     $sections = array("top" => array(), "media" => array(), "object" => array(), "meta" => array(), "rights" => array());
     foreach ($result as $k => $v) {
         if (!empty($v) && $v != " ") {
             if (is_array($v)) {
                 $v = json_encode($v);
             }
             if (in_array($k, $array_fields)) {
                 $nv = explode(",", $v);
                 $v = "";
                 $v .= "<ul>";
                 for ($x = 0; $x < count($nv); $x++) {
                     $v .= "<li>" . $nv[$x] . "</li>";
                 }
                 $v .= "</ul>";
             }
             if (isset($layout["main"][$result_config['index']]) && in_array($k, $layout["main"][$result_config['index']])) {
                 $key = array_search($k, $layout["main"][$result_config['index']]);
                 if (in_array($k, $largetext)) {
                     if (strlen($v) > 2000) {
                         $sections['top'][$key] = "<li><h5 class='rslt-key' title='" . $this->title_msg . " " . $k . ".' alt='" . $k . "'>" . formatkey($k) . "</h5>" . stripslashes(pagedText($v, $id, $k, $highlight, 2000)) . "</li>";
                     } else {
                         if ($highlight != false) {
                             $sections['top'][$key] = "<li><h5 class='rslt-key' title='" . $this->title_msg . " " . $k . ".' alt='" . $k . "'>" . formatkey($k) . "</h5>" . stripslashes(replaceHighlight($v, $highlight, $k, 2000, false)) . "</li>";
                         } else {
                             $sections['top'][$key] = "<li><h5 class='rslt-key' title='" . $this->title_msg . " " . $k . ".' alt='" . $k . "'>" . formatkey($k) . "</h5><span>" . htmlentities($v) . "</span></li>";
                         }
                     }
                 } else {
                     $sections['top'][$key] = "<li><h5 class='rslt-key' title='" . $this->title_msg . " " . $k . ".' alt='" . $k . "'>" . formatkey($k) . "</h5><span>" . htmlentities($v) . "</span></li>";
                 }
             }
             if (isset($layout["media"][$result_config['index']]) && in_array($k, $layout["media"][$result_config['index']])) {
                 $key = array_search($k, $layout["media"][$result_config['index']]);
                 $sections['media'][$key] = "<li><h5 class='rslt-key' title='" . $this->title_msg . " " . $k . ".' alt='" . $k . "'>" . formatkey($k) . "</h5><span>" . htmlentities($v) . "</span></li>";
             }
             if (isset($layout["object"][$result_config['index']]) && in_array($k, $layout["object"][$result_config['index']])) {
                 $key = array_search($k, $layout["object"][$result_config['index']]);
                 $sections['object'][$key] = "<li><h5 class='rslt-key' title='" . $this->title_msg . " " . $k . ".' alt='" . $k . "'>" . formatkey($k) . "</h5><span>" . htmlentities($v) . "</span></li>";
             }
             if (isset($layout["meta"][$result_config['index']]) && in_array($k, $layout["meta"][$result_config['index']])) {
                 $key = array_search($k, $layout["meta"][$result_config['index']]);
                 $nv = "";
                 if ($k == "Keywords" || $k == "tags") {
                     $v = explode(",", $v);
                     foreach ($v as $kv => $vv) {
                         $nv .= "<em class='kw'>" . $vv . "</em>";
                     }
                     $v = $nv;
                 }
                 if ($k == "url") {
                     $v = "<a href='http://localhost" . $v . "' target='_BLANK'>" . $v . "</a>";
                 }
                 $sections['meta'][$key] = "<li><h5 class='rslt-key' title='" . $this->title_msg . " " . $k . ".' alt='" . $k . "'>" . formatkey($k) . "</h5><span>" . htmlentities($v) . "</span></li>";
             }
             if (isset($layout["rights"][$result_config['index']]) && in_array($k, $layout["rights"][$result_config['index']])) {
                 $key = array_search($k, $layout["rights"][$result_config['index']]);
                 $sections['rights'][$key] = "<li><h5 class='rslt-key' title='" . $this->title_msg . " " . $k . ".' alt='" . $k . "'>" . formatkey($k) . "</h5><span>" . htmlentities($v) . "</span></li>";
             }
         }
         //end if empty result
     }
     if (!empty($sections['top'])) {
         ksort($sections['top']);
         $sectionmain[] = "<ul style='border: 2px solid " . $result_config['color'] . "' class='fv-main'>" . html_entity_decode(implode('', $sections['top'])) . "<div class='clear'></div></ul>";
     }
     if (!empty($sections['rights'])) {
         ksort($sections['rights']);
         $sectionmain[] = "<ul class='fv-rights'><h4>Rights</h4>" . implode('', $sections['rights']) . "<div class='clear'></div></ul>";
     }
     if (!empty($sections['media'])) {
         ksort($sections['media']);
         $sectionmain[] = "<ul class='fv-media'><h4>Media</h4>" . implode('', $sections['media']) . "<div class='clear'></div></ul>";
     }
     if (!empty($sections['object'])) {
         ksort($sections['object']);
         $sectionmain[] = "<ul class='fv-object'><h4>Art Object Data</h4>" . html_entity_decode(implode('', $sections['object'])) . "<div class='clear'></div></ul>";
     }
     if (!empty($sections['meta'])) {
         ksort($sections['meta']);
         $sectionmain[] = "<ul class='fv-meta'><h4>Metadata</h4>" . implode('', $sections['meta']) . "<div class='clear'></div></ul>";
     }
     return "<section class='full-head'><ul>" . html_entity_decode(implode('', $sectionmain)) . "</ul></section>";
 }