Пример #1
0
/**
 * Create navigation among pages.
 *
 * @param integer $hits per page.
 * @param integer $page current page.
 * @param integer $max number of pages. 
 * @param integer $min is the first page number, usually 0 or 1. 
 * @return string as a link to this page.
 */
function getPageNavigation($hits, $page, $max, $min = 1)
{
    $nav = "<a class='aButton' href='" . htmlspecialchars(getQueryString(array('page' => $min))) . "'>&lt;&lt;</a> ";
    $nav .= "<a class='aButton' href='" . htmlspecialchars(getQueryString(array('page' => $page > $min ? $page - 1 : $min))) . "'>&lt;</a> ";
    for ($i = $min; $i <= $max; $i++) {
        $nav .= "<a class='aButton' href='" . htmlspecialchars(getQueryString(array('page' => $i))) . "'>{$i}</a> ";
    }
    $nav .= "<a class='aButton' href='" . htmlspecialchars(getQueryString(array('page' => $page < $max ? $page + 1 : $max))) . "'>&gt;</a> ";
    $nav .= "<a class='aButton' href='" . htmlspecialchars(getQueryString(array('page' => $max))) . "'>&gt;&gt;</a> ";
    return $nav;
}
Пример #2
0
 /**
  * The function for the head of the HTML catalog
  * @dataProvider providerTemplate
  */
 public function testGenerateHeader($templateName)
 {
     $_SERVER["HTTP_USER_AGENT"] = "Firefox";
     global $config;
     $headcontent = file_get_contents(dirname(__FILE__) . '/../templates/' . $templateName . '/file.html');
     $template = new doT();
     $tpl = $template->template($headcontent, NULL);
     $data = array("title" => $config['cops_title_default'], "version" => VERSION, "opds_url" => $config['cops_full_url'] . "feed.php", "customHeader" => "", "template" => $templateName, "server_side_rendering" => useServerSideRendering(), "current_css" => getCurrentCss(), "favico" => $config['cops_icon'], "getjson_url" => "getJSON.php?" . addURLParameter(getQueryString(), "complete", 1));
     $head = $tpl($data);
     $this->assertContains("<head>", $head);
     $this->assertContains("</head>", $head);
 }
Пример #3
0
function getPageLinkGet($lnum, $p, $tpage, $imgpath, $obj)
{
    $g_q = "<script>function getPageGo(n){location.href='" . str_replace("&p={$p}", "", getQueryString()) . "&p='+n;}</script>\n";
    $g_p1 = "<IMG src='{$imgpath}/prev1.gif' border='0' ALIGN=ABSMIDDLE>";
    $g_p2 = "<IMG src='{$imgpath}/prev2.gif' border='0' ALIGN=ABSMIDDLE>";
    $g_n1 = "<IMG src='{$imgpath}/next1.gif' border='0' ALIGN=ABSMIDDLE>";
    $g_n2 = "<IMG src='{$imgpath}/next2.gif' border='0' ALIGN=ABSMIDDLE>";
    $g_cn = "<IMG src='{$imgpath}/cutln.gif' border='0' ALIGN=ABSMIDDLE>";
    if ($p < $lnum + 1) {
        $g_q .= $g_p1;
    } else {
        $pp = intval(($p - 1) / $lnum) * $lnum;
        $g_q .= "<A HREF='javascript:getPageGo({$pp})';>{$g_p2}</A>";
    }
    $g_q .= $g_cn;
    $l = $term = $lnum;
    $f = 1;
    while ($f <= $tpage) {
        if ($f <= $p && $p <= $l) {
            if ($l <= $tpage) {
                for ($page = $f; $page <= $l; $page++) {
                    $page == $p ? $g_q .= "<FONT COLOR=RED>{$page}</FONT>{$g_cn}" : ($g_q .= "<A HREF='javascript:getPageGo({$page})';>{$page}</A>{$g_cn}");
                }
            } else {
                for ($page = $f; $page <= $tpage; $page++) {
                    $page == $p ? $g_q .= "<FONT COLOR=RED>{$page}</FONT>{$g_cn}" : ($g_q .= "<A HREF='javascript:getPageGo({$page})';>{$page}</A>{$g_cn}");
                }
            }
        }
        $f = $f + $term;
        $l = $l + $term;
    }
    if ($tpage < $lnum || $tpage < $page) {
        $g_q .= $g_n1;
    } else {
        $np = $page;
        $g_q .= "<A HREF='javascript:getPageGo({$np})';>{$g_n2}</A>";
    }
    return $g_q;
}
Пример #4
0
 public static function getGenres($db, $genre, $home = false)
 {
     // Get all genres that are active
     $sql = '
 SELECT DISTINCT G.name, G.id
 FROM rm_genre AS G
 INNER JOIN rm_movie2genre AS M2G
 ON G.id = M2G.idGenre
 ';
     $res = $db->ExecuteSelectQueryAndFetchAll($sql);
     $genres = null;
     foreach ($res as $val) {
         if ($val->name == $genre) {
             $genres .= "<span class='current'>{$val->name}</span> ";
         } else {
             $genres .= "<a href='" . ($home ? "movies.php?genre={$val->name}#anchor" : getQueryString(array('genre' => $val->name))) . "'>" . ($home ? "<img src='img.php?src=genre/{$val->id}.png&amp;width=40' alt='{$val->name}'/>" : null) . "{$val->name}</a> ";
         }
     }
     // Link to all genres
     $all = isset($_GET['genre']) ? "<a href='" . getQueryString(array('genre' => null)) . "'>Alla</a>" : "<span class='current'>Alla</span>";
     $home ? $all = "<a href='movies.php#anchor'><img src='img.php?src=genre/all.png&amp;width=40' alt='Alla'/>Alla</a>" : null;
     return ($home ? null : "<label>Välj genre: ") . "{$all} {$genres}" . ($home ? null : "</label>") . "\n";
 }
Пример #5
0
<?php

global $_wt_options;
if (!current_user_can($_wt_options->options("user_role"))) {
    wp_die(__('Cheatin&#8217; uh?'));
}
if (!defined('ABSPATH')) {
    define('ABSPATH', dirname(__FILE__) . '/');
}
require_once ABSPATH . 'wp-settings.php';
# need to check if i can add permission called 'edit_events'
$page = getQueryString("page");
$action = getQueryString("action");
$event_id = getQueryString("event_id");
$meta_id = getQueryString("meta_id");
if ($action === "new") {
    include 'new_event.php';
} else {
    if ($action === "edit" && !empty($event_id)) {
        include 'event.php';
    } else {
        render_edit_rows_page($event_id, $page);
    }
}
function get_query_mode_sql()
{
    $sql_array = array("all" => "WHERE e.event_published != 3", "published" => "WHERE e.event_published = 1", "upcoming" => "WHERE e.event_published = 1 AND e.event_start_date >= CURDATE()", "archive" => "WHERE e.event_published = 1 AND e.event_start_date < CURDATE()", "unpublished" => "WHERE e.event_published = 0");
    $sql = '';
    if (!empty($_GET["event_date"])) {
        $sql .= $sql_array[$_GET["event_date"]];
    } else {
Пример #6
0
<?php

global $_wt_options;
if (!current_user_can($_wt_options->options("user_role"))) {
    wp_die(__('Cheatin&#8217; uh?'));
}
$page = getQueryString("page");
$action = getQueryString("action");
$track_id = getQueryString("track_id");
if ($action === "new") {
    include 'track.php';
    exit;
} else {
    if ($action === "edit" && !empty($track_id)) {
        include 'track.php';
        exit;
    }
}
function get_query_mode_sql()
{
    $sql = array();
    if (!empty($_GET["artist"])) {
        $sql[] = "track_artist_id = {$_GET['artist']}";
    }
    if (count($sql) > 0) {
        return " WHERE " . implode(" AND ", $sql);
    }
    return "";
}
$dbQuery = array("artists" => WT_Artist::all());
# GENERATE LIST
Пример #7
0
<?php

if (!current_user_can($_wt_options->options("user_role"))) {
    wp_die(__('Cheatin&#8217; uh?'));
}
global $_wt_options;
$page = getQueryString("page");
$action = getQueryString("action");
$venue_id = getQueryString("venue_id");
if ($action === "new") {
    include 'venue.php';
    exit;
} else {
    if ($action === "edit" && !empty($venue_id)) {
        include 'venue.php';
        exit;
    }
}
# GENERATE LIST
$list = new WT_List();
$list->set_columns('venues', array('cb' => '', 'venue_id-col' => 'ID', 'venue_order-col' => 'Order', 'venue_name-col' => 'Name', 'venue_event_number-col' => 'Number of events', 'venue_address-col' => 'Address', 'venue_city-col' => 'City', 'venue_state-col' => 'State', 'venue_country-col' => 'Country'));
$list->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM " . WORDTOUR_VENUES . " ORDER BY venue_name", $_GET['paged']);
?>

<div class="wrap">
	<h2>Venues</h2>
</div>

<div style="margin-right:15px;margin-bottom:15px;margin-top:15px;">
	<div class="wordtour-alert wordtour-alert-error" style="margin-left:0px;margin-right:0px;"></div>
		<div class="wordtour-toolbar ui-corner-all" style="margin-left:0px;margin-right:0px;overflow:hidden;">
Пример #8
0
 public function getPrevLink()
 {
     $currentUrl = preg_replace("/\\&n=.*?\$/", "", "?" . getQueryString());
     if ($this->n > 1) {
         return new LinkNavigation($currentUrl . "&n=" . ($this->n - 1), "previous", localize("paging.previous.alternate"));
     }
     return NULL;
 }
Пример #9
0
        // Make status coloured
        switch ($extendedInfo['status']) {
            case 'stable':
                $extendedInfo['status'] = '<span style="color: #006600">Stable</span>';
                break;
            case 'beta':
                $extendedInfo['status'] = '<span style="color: #ffc705">Beta</span>';
                break;
            case 'alpha':
                $extendedInfo['status'] = '<span style="color: #ff0000">Alpha</span>';
                break;
        }
        $packages[$key]['eInfo'] = $extendedInfo;
    }
    $defaultMoreInfoVis = $moreinfo ? 'inline' : 'none';
}
/**
 * Build URLs for hide/show all links
 */
if ($moreinfo) {
    $showMoreInfoLink = '#';
    $hideMoreInfoLink = getQueryString($catpid, $catname, $showempty, 0);
} else {
    $showMoreInfoLink = getQueryString($catpid, $catname, $showempty, 1);
    $hideMoreInfoLink = '#';
}
/*
 * Template
 */
error_reporting(E_ALL & ~E_NOTICE);
include $template_dir . 'packages.html';
Пример #10
0
<?php

global $_wt_options;
if (!current_user_can($_wt_options->options("user_role"))) {
    wp_die(__('Cheatin&#8217; uh?'));
}
$page = getQueryString("page");
$action = getQueryString("action");
$album_id = getQueryString("album_id");
if ($action === "new") {
    include 'album.php';
    exit;
} else {
    if ($action === "edit" && !empty($album_id)) {
        include 'album.php';
        exit;
    }
}
function get_query_mode_sql()
{
    $sql = array();
    if (!empty($_GET["artist"])) {
        $sql[] = "album_artist_id = {$_GET['artist']}";
    }
    if (count($sql) > 0) {
        return " WHERE " . implode(" AND ", $sql);
    }
    return "";
}
$dbQuery = array("artists" => WT_Artist::all());
# GENERATE LIST
Пример #11
0
<?php

require "include/phpfunctions.php";
$cCharset = "utf-8";
$queryString = getQueryString();
if (!isset($queryString) || strlen($queryString) == 0) {
    return;
}
$yuiFiles = explode("&", $queryString);
$contentType = strpos($yuiFiles[0], ".js") ? 'application/x-javascript' : ' text/css';
$yuiComponents = array();
if ($contentType == 'application/x-javascript') {
    foreach ($yuiFiles as $yuiFile) {
        $parts = explode("/", $yuiFile);
        if (count($parts) == 4) {
            if (isset($parts[0]) && isset($parts[1]) && isset($parts[2])) {
                //Add module to array for loading
                $yuiComponents[] = $parts[2] . "/" . $parts[2];
            } else {
                die('<!-- Unable to determine module name! ' . $yuiFile . ' -->');
            }
        } else {
            $start = strpos($yuiFile, "/build/");
            if ($start === FALSE) {
                die('<!-- Unable to determine module name! ' . $yuiFile . ' -->');
            }
            $start += strlen("/build/");
            $end = strpos($yuiFile, ".js");
            if ($end === FALSE) {
                die('<!-- Unable to determine module name! ' . $yuiFile . ' -->');
            }
Пример #12
0
function sort_column($column)
{
    $getString = getQueryString(array("sort", "column"));
    return "<a href='?" . $getString . "&sort=desc&column=" . $column . "'><img src='images/arrow_up.gif' border='0'></a> <a href='?" . $getString . "&sort=asc&column=" . $column . "''><img src='images/arrow_down.gif' border='0'></a>";
}
Пример #13
0
 public function orderby($column)
 {
     $nav = "<a href='" . getQueryString(array('orderby' => $column, 'order' => 'asc')) . "'>&#x25B2;</a>";
     $nav .= "<a href='" . getQueryString(array('orderby' => $column, 'order' => 'desc')) . "'>&#x25BC;</a>";
     return "<span class='orderby'>" . $nav . "</span>";
 }
Пример #14
0
<?php

global $_wt_options;
if (!current_user_can($_wt_options->options("user_role"))) {
    wp_die(__('Cheatin&#8217; uh?'));
}
$page = getQueryString("page");
$action = getQueryString("action");
$tour_id = getQueryString("tour_id");
if ($action === "new") {
    include 'tour.php';
    exit;
} else {
    if ($action === "edit" && !empty($tour_id)) {
        include 'tour.php';
        exit;
    }
}
# GENERATE LIST
$list = new WT_List();
$list->set_columns('tour', array('cb' => '', 'tour_id-col' => 'ID', 'tour_order-col' => 'ORDER', 'tour_name-col' => 'Name', 'tour_event_no-col' => 'Number of Events'));
$list->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM " . WORDTOUR_TOUR . " ORDER BY tour_order,tour_name", $_GET['paged']);
?>
<div class="wrap">
	<h2>Tour</h2>
</div>

<div style="margin-right:15px;margin-bottom:15px;margin-top:15px;">
	<div class="wordtour-alert wordtour-alert-error" style="margin-left:0px;margin-right:0px;"></div>
		<div class="wordtour-toolbar ui-corner-all" style="margin-left:0px;margin-right:0px;overflow:hidden;">
			<div class="ui-helper-clearfix">
Пример #15
0
<?php

require_once "include/phpfunctions.php";
header("Content-Type: text/css");
$file = getQueryString();
$ext = substr($file, strrpos($file, '.') + 1);
if ($ext != "css" || strpos($file, '..') !== false) {
    exit;
}
$css = myfile_get_contents(getabspath($file), "r");
$css = preg_replace(array("/ :not\\(.*?\\)/", "/ :first-child/", "/ :last-child/", "/ :nth-last-child\\(.*?\\)/"), " *", $css);
$css = preg_replace(array("/:not\\(.*?\\)/", "/:first-child/", "/:last-child/", "/:nth-last-child\\(.*?\\)/"), "", $css);
echo $css;
Пример #16
0
<?php

global $_wt_options;
if (!current_user_can($_wt_options->options("user_role"))) {
    wp_die(__('Cheatin&#8217; uh?'));
}
$page = getQueryString("page");
$action = getQueryString("action");
$artist_id = getQueryString("artist_id");
if ($action === "new") {
    include 'artist.php';
    exit;
} else {
    if ($action === "edit" && !empty($artist_id)) {
        include 'artist.php';
        exit;
    }
}
# GENERATE LIST
$list = new WT_List();
$list->set_columns('events', array('cb' => '', 'artist_id-col' => 'ID', 'artist_order-col' => 'Order', 'artist_name-col' => 'Name', 'artist_track-col' => 'Tracks', 'artist_album-col' => 'Albums', 'artist_event_no-col' => 'Events'));
$list->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM " . WORDTOUR_ARTISTS . " as a ORDER BY a.artist_order,a.artist_name ASC", $_GET['paged']);
?>

<div class="wrap">
	<h2>Artists</h2>
</div>

<div style="margin-right:15px;margin-bottom:15px;margin-top:15px;">
	<div class="wordtour-alert wordtour-alert-error" style="margin-left:0px;margin-right:0px;"></div>
		<div class="wordtour-toolbar ui-corner-all" style="margin-left:0px;margin-right:0px;overflow:hidden;">
Пример #17
0
$page = getURLParam("page", Base::PAGE_INDEX);
$query = getURLParam("query");
$qid = getURLParam("id");
$n = getURLParam("n", "1");
$database = GetUrlParam(DB);
// Access the database ASAP to be sure it's readable, redirect if that's not the case.
// It has to be done before any header is sent.
Base::checkDatabaseAvailability();
if ($config['cops_fetch_protect'] == "1") {
    session_start();
    if (!isset($_SESSION['connected'])) {
        $_SESSION['connected'] = 0;
    }
}
header("Content-Type:text/html;charset=utf-8");
$data = array("title" => $config['cops_title_default'], "version" => VERSION, "opds_url" => $config['cops_full_url'] . "feed.php", "customHeader" => "", "template" => getCurrentTemplate(), "server_side_rendering" => useServerSideRendering(), "current_css" => getCurrentCss(), "favico" => $config['cops_icon'], "getjson_url" => "getJSON.php?" . addURLParameter(getQueryString(), "complete", 1));
if (preg_match("/Kindle/", $_SERVER['HTTP_USER_AGENT'])) {
    $data["customHeader"] = '<style media="screen" type="text/css"> html { font-size: 75%; -webkit-text-size-adjust: 75%; -ms-text-size-adjust: 75%; }</style>';
}
$headcontent = file_get_contents('templates/' . getCurrentTemplate() . '/file.html');
$template = new doT();
$dot = $template->template($headcontent, NULL);
echo $dot($data);
?>
<body>
<?php 
if (useServerSideRendering()) {
    // Get the data
    require_once "JSON_renderer.php";
    $data = JSONRenderer::getJson(true);
    echo serverSideRender($data);
Пример #18
0
<?php

//Get query string because $_GET does not work with mod rewrite
//This code should be rewritten at some point... It's ugly
//
//Multiple identical keys cannot be passed into pooch. This is a Limitation of this implimentation.
//Example: Give the query string "id=2&id=3" the value of $query_string['id'] would be 3.
function getQueryString()
{
    global $query_string;
    $query_string = array();
    $new_query_string = array();
    if (strpos($_SERVER['REQUEST_URI'], '?')) {
        $query_string = explode('?', $_SERVER['REQUEST_URI']);
        if (strpos($query_string[1], '&')) {
            $query_string = explode('&', $query_string[1]);
            foreach ($query_string as $value) {
                $value_array = explode('=', $value);
                $new_query_string[urldecode($value_array[0])] = urldecode($value_array[1]);
            }
            $query_string = $new_query_string;
        } else {
            $value_array = explode('=', $query_string[1]);
            $new_query_string[urldecode($value_array[0])] = urldecode($value_array[1]);
        }
    }
    $query_string = $new_query_string;
}
getQueryString();
Пример #19
0
 private function startXmlDocument($page)
 {
     global $config;
     self::getXmlStream()->startDocument('1.0', 'UTF-8');
     self::getXmlStream()->startElement("feed");
     self::getXmlStream()->writeAttribute("xmlns", "http://www.w3.org/2005/Atom");
     self::getXmlStream()->writeAttribute("xmlns:xhtml", "http://www.w3.org/1999/xhtml");
     self::getXmlStream()->writeAttribute("xmlns:opds", "http://opds-spec.org/2010/catalog");
     self::getXmlStream()->writeAttribute("xmlns:opensearch", "http://a9.com/-/spec/opensearch/1.1/");
     self::getXmlStream()->writeAttribute("xmlns:dcterms", "http://purl.org/dc/terms/");
     self::getXmlStream()->startElement("title");
     self::getXmlStream()->text($page->title);
     self::getXmlStream()->endElement();
     if ($page->subtitle != "") {
         self::getXmlStream()->startElement("subtitle");
         self::getXmlStream()->text($page->subtitle);
         self::getXmlStream()->endElement();
     }
     self::getXmlStream()->startElement("id");
     if ($page->idPage) {
         $idPage = $page->idPage;
         if (!is_null(GetUrlParam(DB))) {
             $idPage = str_replace("cops:", "cops:" . GetUrlParam(DB) . ":", $idPage);
         }
         self::getXmlStream()->text($idPage);
     } else {
         self::getXmlStream()->text($_SERVER['REQUEST_URI']);
     }
     self::getXmlStream()->endElement();
     self::getXmlStream()->startElement("updated");
     self::getXmlStream()->text(self::getUpdatedTime());
     self::getXmlStream()->endElement();
     self::getXmlStream()->startElement("icon");
     self::getXmlStream()->text($page->favicon);
     self::getXmlStream()->endElement();
     self::getXmlStream()->startElement("author");
     self::getXmlStream()->startElement("name");
     self::getXmlStream()->text($page->authorName);
     self::getXmlStream()->endElement();
     self::getXmlStream()->startElement("uri");
     self::getXmlStream()->text($page->authorUri);
     self::getXmlStream()->endElement();
     self::getXmlStream()->startElement("email");
     self::getXmlStream()->text($page->authorEmail);
     self::getXmlStream()->endElement();
     self::getXmlStream()->endElement();
     $link = new LinkNavigation("", "start", "Home");
     self::renderLink($link);
     $link = new LinkNavigation("?" . getQueryString(), "self");
     self::renderLink($link);
     $urlparam = "?";
     if (!is_null(GetUrlParam(DB))) {
         $urlparam = addURLParameter($urlparam, DB, GetUrlParam(DB));
     }
     if ($config['cops_generate_invalid_opds_stream'] == 0 || preg_match("/(MantanoReader|FBReader)/", $_SERVER['HTTP_USER_AGENT'])) {
         // Good and compliant way of handling search
         $urlparam = addURLParameter($urlparam, "page", Base::PAGE_OPENSEARCH);
         $link = new Link("feed.php" . $urlparam, "application/opensearchdescription+xml", "search", "Search here");
     } else {
         // Bad way, will be removed when OPDS client are fixed
         $urlparam = addURLParameter($urlparam, "query", "{searchTerms}");
         $urlparam = str_replace("%7B", "{", $urlparam);
         $urlparam = str_replace("%7D", "}", $urlparam);
         $link = new Link($config['cops_full_url'] . 'feed.php' . $urlparam, "application/atom+xml", "search", "Search here");
     }
     self::renderLink($link);
     if ($page->containsBook() && !is_null($config['cops_books_filter']) && count($config['cops_books_filter']) > 0) {
         $Urlfilter = getURLParam("tag", "");
         foreach ($config['cops_books_filter'] as $lib => $filter) {
             $link = new LinkFacet("?" . addURLParameter(getQueryString(), "tag", $filter), $lib, localize("tagword.title"), $filter == $Urlfilter);
             self::renderLink($link);
         }
     }
 }
Пример #20
0
/**
 * Function to create links for sorting
 *
 * @param string $column the name of the database column to sort by
 * @return string with links to order by column.
 */
function orderby($column)
{
    $nav = "<a class='sortButton' href='" . getQueryString(array('orderby' => $column, 'order' => 'asc')) . "'>&darr;</a>";
    $nav .= "<a class='sortButton' href='" . getQueryString(array('orderby' => $column, 'order' => 'desc')) . "'>&uarr;</a>";
    return "<span class='orderby'>" . $nav . "</span>";
}