Beispiel #1
0
function driver_getRecommendation($lastJump)
{
    $currentPage = $lastJump['page'];
    if (isset($lastJump['section'])) {
        $currentPage = $lastJump['page'] . '#' . sectionId($lastJump['section']) . '=' . $lastJump['section'];
    }
    $output = '';
    $output .= '<div id=driver_recommendation class=driver_rbox>';
    //$output .= '<table class=driver_rbox_table>';
    //$output .= '<tr><td class=driver_rbox_table_title_column>Try these...</td></tr>';
    //$output .= '<tr><td class=driver_rbox_table_column >';
    if (!page_exists($currentPage)) {
        $output .= '<div align="center" style="font-style:italic"> nowhere yet...</div>';
        $output .= '</div>';
        return $output;
    }
    error_log("currentPage: " . print_r($currentPage, true));
    $recommend = driverdb_getMostNextSteps($currentPage);
    error_log("recommend: " . print_r($recommend, true));
    foreach ($recommend as $page => $count) {
        unset($trailPage);
        // is it section?
        $pageParts = explode("#", $page);
        if (sizeof($pageParts) > 1) {
            //its section, then parse title
            $sectionParts = explode("=", $pageParts[1]);
            $trailPage['section'] = $sectionParts[1];
        }
        $trailPage['id'] = $pageParts[0];
        $trailPage['name'] = trimPageTitle(get_first_heading($pageParts[0]), 40);
        $output .= printTrailPage($trailPage, '_parent', '', '', 'trail_page_recommend', $count);
    }
    //$output .= '</td></tr>';
    //$output .='</table>';
    $output .= '</div>';
    return $output;
}
Beispiel #2
0
function printTrailPage($page, $target = '', $callback = '', $previewer = '', $div_class = 'trail_page', $count = 0)
{
    $result = '';
    if (strcmp($page['flag'], 'ignore') == 0) {
        return $result;
    }
    $url = wl($page['id']);
    $label = $page['name'];
    $linkClass = '';
    $tooltip = $label;
    $sectionId = '';
    // check is its section
    $isSection = isset($page['section']);
    // parse section data to see how its encoded and decode it...
    // it can be (1) the section title, or (2) in the format: <sectionId>'='<section title>
    $sectionParts = explode("=", $page['section']);
    if (sizeof($sectionParts) > 1) {
        $page['section'] = $sectionParts[1];
    }
    if ($isSection) {
        $sectionId = sectionId($page['section'], $check);
        $url .= '#' . $sectionId;
        $label = $page['section'] . ' <sub>(' . substr($label, 0, 5) . '...)</sub>';
        $linkClass = 'class="trail_section_link"';
        $tooltip = $page['section'] . ' (in [' . $page['name'] . '])';
    }
    // process callback and previewer
    $onclick = '';
    if (strcmp($callback, '') != 0) {
        if (strcmp($previewer, '') != 0) {
            // pageSearch case
            $onclick .= 'onclick="return ' . $callback . '(\'' . $previewer . '\',\'' . $page['id'] . '\', \'' . $sectionId . '\')"';
        } else {
            // pathPruner case
            $onclick .= 'return onclick="return ' . $callback . '(\'' . $page['id'] . '\', \'' . $sectionId . '\')"';
        }
        //$url = '#';
    }
    // id must contains flags for later POST purposes via JavaScript
    $page_id = $page['id'];
    if ($isSection) {
        $page_id .= '#' . $sectionId . '=' . $page['section'];
    }
    $page_id .= '|' . $page['flag'];
    // main div, no flag
    $add = '<div id="' . $page_id . '" class="' . $div_class . '">';
    //recommendation count
    if ($count > 0) {
        $add .= '<div class="recommend_count">(' . $count . ')</div>';
    }
    //flag
    if (strcmp($page['flag'], 'start') == 0) {
        $add .= '<a class="trail_flag_start" target="' . $target . '" href="' . $url . '" ' . $onclick . '></a>';
    }
    if (strcmp($page['flag'], 'visited') == 0) {
        $add .= '<a class="trail_flag_visited" target="' . $target . '" href="' . $url . '" ' . $onclick . '></a>';
    }
    if (strcmp($page['flag'], 'landmark') == 0) {
        $add .= '<a class="trail_flag_highlight" target="' . $target . '" href="' . $url . '" ' . $onclick . '></a>';
    }
    $result .= $add;
    // link
    $result .= '<a ' . $linkClass . ' title="' . $tooltip . '" target="' . $target . '" href="' . $url . '" ' . $onclick . '>' . $label . '</a>';
    // end main div
    $result .= '</div>';
    return $result;
}