Esempio n. 1
0
/**
 * Implementation of module_content()
 */
function static_content()
{
    global $ssc_database;
    // We'll never accept params, so is gonna be a 404
    if (!empty($_GET['param'])) {
        ssc_not_found();
    }
    // Find content
    $result = $ssc_database->query("SELECT title, created, modified, body FROM #__static WHERE id = %d LIMIT 1", $_GET['path-id']);
    if ($result && ($data = $ssc_database->fetch_assoc($result))) {
        if (!ssc_load_library('sscText')) {
            ssc_not_found();
            // Strictly speaking, the library /wasn't/ found...
        }
        ssc_set_title($data['title']);
        return sscText::convert($data['body']);
    }
    ssc_not_found();
}
Esempio n. 2
0
File: rss.php Progetto: scott-t/ssc
    // Do loop due to the first read earlier on
    do {
        // Get date
        $date = date("Y/m/d", $dat['created']);
        // Echo post
        fwrite($fp, <<<ITEM
    <item>
      <title>{$dat['title']}</title>
      <link>{$ssc_site_url}/{$date}/{$dat['urltext']}</link>
      <guid>{$ssc_site_url}/id/{$dat['id']}</guid>
      <description>
ITEM
);
        //<?php  // <-- Ensure GUI happy again
        // Get markup version for Atom
        $dat['body'] = sscText::convert($dat['body']);
        // Strip tags for a text-only preview
        $stripped = preg_replace('/<[^<|>]+>?/', '', $dat['body']);
        // In shortened version, cut it off a bit too
        $stripped = substr($stripped, 0, 350) . (strlen($stripped) > 350 ? "[...]" : "");
        // Write post to RSS
        fwrite($fp, $stripped);
        fwrite($fp, "</description>\n      <pubDate>" . date("r", $dat['created']) . "</pubDate>\n    </item>\n");
        // Prepare date for Atom
        $iso = date("c", $dat['created']);
        $isou = date("c", $dat['modified']);
        // Write to Atom
        fwrite($ap, "  <entry>\n    <id>{$ssc_site_url}/id/{$dat['id']}</id>\n    <title type=\"text\">{$dat['title']}</title>\n    <updated>{$isou}</updated>\n    <published>{$iso}</published>\n    <author>\n      <name>{$dat['displayname']}</name>\n    </author>\n    <link rel=\"alternate\" type=\"text/html\" href=\"{$ssc_site_url}/{$date}/{$dat['urltext']}\" />\n    <summary type=\"text\">{$stripped}</summary>\n    <content type=\"xhtml\"><div xmlns=\"http://www.w3.org/1999/xhtml\">{$dat['body']}</div></content>\n  </entry>\n");
    } while ($dat = $ssc_database->fetch_assoc($res_posts));
    // Finish each file markup, and close the handles
    fwrite($fp, "  </channel>\n</rss>");
Esempio n. 3
0
/**
 * Implementation of module_content()
 * 
 * Results content.  At this stage, no arguments so present results for entire regatta. Bracket refers to mouse-over
 * 
 *   - /
 *     No parameters.  Should show abbr'd |sail|class|name|skip (crew)|place(corr. time)[|place(corr. time)...]
 * 
 *   - /heat/<num>   or    /heat-<num
 *     Show detailed version for a heat perhaps?  Probably not feasable.
 */
function sailing_content()
{
    global $ssc_database;
    ssc_add_js('/modules/sailing/sailing.js');
    // See if results exist
    $result = $ssc_database->query("SELECT name, description, updated, flags, heats FROM #__sailing_series WHERE id = %d LIMIT 1", $_GET['path-id']);
    if (!($result && ($data = $ssc_database->fetch_assoc($result)))) {
        ssc_not_found();
        return;
    }
    // Set up some flags
    $flags = $data['flags'];
    $prefix = $flags & SSC_SAILING_PREFIX ? "Division " : "";
    $show_class = ($flags & SSC_SAILING_CLASS) > 0;
    $show_club = ($flags & SSC_SAILING_CLUB) > 0;
    // Heat numbers
    $heats = explode(",", $data['heats']);
    // Description / title
    ssc_set_title($data['name']);
    $out = "";
    if (strlen($data['description']) > 0) {
        if (!ssc_load_library('sscText')) {
            $out .= check_plain($data['description']);
        } else {
            $out .= sscText::convert($data['description']);
        }
    }
    // Prepare for table
    $result = $ssc_database->query("SELECT r.results, r.times, r.points, r.division, e.number, e.skipper, e.crew, e.name AS boatname, e.class, e.club FROM #__sailing_results r LEFT JOIN #__sailing_entries e ON e.id = r.uid WHERE r.series_id = %d ORDER BY r.division ASC, r.points ASC", $_GET['path-id']);
    if (!$result || $ssc_database->number_rows() < 1) {
        // Empty or sql failure
        $out .= "There are no race results available for this series yet";
        return $out;
    } else {
        // Start outputting
        $out .= '<table class="sail-table" summary="Race results">';
        $col_header = _ssc_sailing_table_header($flags, $heats, $col_count);
        // Loop through results
        $div = '-1';
        while ($data = $ssc_database->fetch_assoc($result)) {
            // Re-echo headers for each division
            if ($div != $data['division']) {
                if ($div == '-1') {
                    $out .= "<thead><tr><th class=\"div-heading\" colspan=\"{$col_count['total']}\">{$prefix}{$data['division']}</th></tr>";
                    $out .= "{$col_header}</thead><tbody>";
                } else {
                    $out .= '<tr><th class="div-heading" colspan="' . $col_count['total'] . '">' . $prefix . $data['division'] . '</th></tr>';
                    $out .= $col_header;
                }
                $div = $data['division'];
            }
            // Row contents
            $out .= "<tr><td>{$data['number']}</td>" . ($show_class ? "<td>{$data['class']}</td>" : '') . "<td>{$data['boatname']}</td>";
            if ($data['crew'] != '') {
                $out .= "<td><span title=\"{$data['crew']}\">{$data['skipper']}</span></td>";
            } else {
                $out .= "<td>{$data['skipper']}</td>";
            }
            if ($show_club) {
                $out .= "<td>{$data['club']}</td>";
            }
            // Parse results
            $heats = explode(",", $data['results']);
            $times = explode(",", $data['times']);
            for ($i = 0; $i < $col_count['heats']; $i++) {
                if ($times[$i] != '') {
                    if ((double) $times[$i] > 0) {
                        $out .= '<td><span title="' . sprintf("%1.1f", (double) $times[$i]) . " min\">{$heats[$i]}</span></td>";
                    } else {
                        $out .= "<td><span title=\"{$times[$i]}\">{$heats[$i]}</span></td>";
                    }
                } else {
                    $out .= "<td>{$heats[$i]}</td>";
                }
            }
            $out .= '</tr>';
        }
        // Tidy up
        $out .= '</tbody></table>';
    }
    return $out;
}
Esempio n. 4
0
 /**
  * Parse wiki tags
  * @param string $body Markup to de-tag
  * @return string XHTML markup equivalent
  * @private
  */
 static function _parse_tags($body)
 {
     // Possible tags here.  Lets get cracking
     $prev = 0;
     $offset = 0;
     $start = 0;
     while (($start = strpos($body, "[[")) !== false) {
         $stop = strpos($body, "]]", $start + 2);
         $next = strpos($body, "[[", $start + 2);
         if ($next !== false && $next < $stop) {
             // Nexted tags - perhaps not the most efficient but most nestings will
             // be simple ones anyway so shouldn't make that much a difference
             while ($next !== false && $next < $stop) {
                 // Grab most inner one
                 $prev = $next;
                 $next = strpos($body, "[[", $next + 2);
             }
             $start = $prev;
         }
         $diff = $stop - $start;
         $tag = substr($body, $start + 2, $diff - 2);
         $tag = sscText::_convert_tag($tag);
         $body = substr_replace($body, $tag, $start, $diff + 2);
     }
     return $body;
 }
Esempio n. 5
0
/**
 * Private function to generate posts
 * @param int $perpage Number of posts per page to show
 * @param string $sql Query to retrieve the posts we want
 * @param mixed $args,... Query arguments
 * @return string Generated output
 */
function _blog_gen_post($perpage, $pagelink, $sql, $args = null)
{
    global $ssc_database;
    $args = func_get_args();
    $perpage = array_shift($args);
    $pagelink = array_shift($args);
    if (array_shift($_GET['param']) == 'page') {
        $page = array_shift($_GET['param']);
        if ((int) $page <= 0) {
            $page = 1;
        }
    } else {
        $page = 1;
    }
    array_unshift($args, $page, $perpage);
    $paged_result = call_user_func_array(array($ssc_database, 'query_paged'), $args);
    $result =& $paged_result['result'];
    $out = '';
    // For each blog post listed
    while (($data = $ssc_database->fetch_object($result)) && $perpage-- > 0) {
        $posturl = $_GET['path'] . date("/Y/m/d/", $data->created) . $data->urltext;
        $out .= "\n<h3>" . l($data->title, $posturl) . "</h3>\n";
        $out .= t("Posted !date at !time by !author\n", array('!date' => date(ssc_var_get('date_med', SSC_DATE_MED), $data->created), '!time' => date(ssc_var_get('time_short', SSC_TIME_SHORT), $data->created), '!author' => $data->author));
        // Get post tags
        $r = $ssc_database->query("SELECT tag FROM #__blog_relation r, #__blog_tag t WHERE r.tag_id = t.id AND r.post_id = %d ORDER BY tag ASC", $data->id);
        if ($ssc_database->number_rows()) {
            $out .= "<br />Tagged: ";
            $txt = '';
            while ($dat = $ssc_database->fetch_object($r)) {
                $txt .= ', ' . l($dat->tag, $_GET['path'] . '/tag/' . $dat->tag);
            }
            $txt = substr($txt, 2);
            $out .= $txt;
        }
        // Comments if listed
        if ($_GET['blog_comments'] == true) {
            // Either show number or "Add One!" links direct to comments
            if ($data->count == 0) {
                if ($data->commentsdisabled == 0) {
                    $out .= '<br />' . t("No comments - !action\n", array('!action' => l(t('Add one!'), $posturl . "#comments")));
                } else {
                    $out .= '<br />' . t("No comments\n");
                }
            } else {
                $out .= '<br />' . l($data->count . ' comments', $posturl . "#comments");
            }
        }
        if (isset($data->body)) {
            $out .= '<br />' . sscText::convert($data->body) . '<hr class="clear"/>';
        } else {
            $out .= '<hr />';
        }
    }
    // Page navigation
    $out .= '<div class="paging"><span>';
    // Is there a previous page?
    if ($page > 1) {
        $out .= l(t('Previous page'), $pagelink . ($page - 1));
    }
    $out .= '</span> <span><img src="/images/rss.png" alt="Subscribe using" /> ' . l(t('ATOM 1.0'), $_GET['path'] . '/feed') . '</span> <span>';
    // Next page?
    if ($paged_result['next']) {
        $out .= l(t('Next page'), $pagelink . ($page + 1));
    }
    $out .= '</span></div>';
    return $out;
}