<?php

// -*- tab-width: 3; indent-tabs-mode: 1; -*-
/*  
 * $Id$
 * Created for the StreamOnTheFly project (IST-2001-32226)
 * Authors: András Micsik, Máté Pataki, Tamás Déri 
 *          at MTA SZTAKI DSD, http://dsd.sztaki.hu
 */
require "init.inc.php";
require $config['classdir'] . "/sotf_AdvSearch.class.php";
$SQLquerySerial = sotf_Utils::getParameter('SQLquerySerial');
//the serialized query in the hidden field
$advsearch = new sotf_AdvSearch();
//create new search object object with this array
//if ($SQLquerySerial == "")							//get old search query from session if none in url
//	$SQLquerySerial = $_SESSION["SQLquerySerial"];				//get array from session
$SQLquery = $advsearch->Deserialize($SQLquerySerial);
//deserialize the content of the hidden field
if (sotf_Utils::getParameter('back') != NULL) {
    $_SESSION["SQLquerySerial"] = $SQLquerySerial;
    //save the new quey to the session
    $page->redirect("advsearch.php");
}
$query = $advsearch->GetSQLCommand();
$max = $db->getAll("SELECT count(*) FROM (" . $query . ") as count");
//get the number of results
$max = $max[0]["count"];
$limit = $page->splitList($max, "?SQLquerySerial={$SQLquerySerial}");
$result = $db->getAll($query . $limit["limit"]);
$allfields = $advsearch->GetSQLfields();
Example #2
0
        }
    }
    /*
    	// define search box
    		  $properties=array();
    		  // The name of the text input form field
    		  $properties["name"]="pattern";
    		  $properties["link"]=$config['rootUrl'] . "/search.php?language=any_language&station=$stationName";
    		  $properties["title"]="Search for:";
    		  $properties["description"]= $page->getlocalizedWithParams('search_in_station', $stationName);
    		  $rss_writer_object->addtextinput($properties);
    */
    $rss .= "\n</channel>";
} elseif ($query) {
    // ***************** SERIALIZED QUERY ****************
    $advsearch = new sotf_AdvSearch();
    $advsearch->Deserialize($query);
    // send results of advanced query given as string
    $rss .= "\n<channel>";
    $queryTags = $advsearch->GetHumanReadable();
    for ($i = 0; $i < count($queryTags); $i++) {
        // TODO: this is a rough solution
        if ($i == count($queryTags) - 1) {
            $queryTexts[] = $queryTags[$i][1] . ' ' . $queryTags[$i][2] . ' ' . $queryTags[$i][3];
        } else {
            $queryTexts[] = $queryTags[$i][1] . ' ' . $queryTags[$i][2] . ' ' . $queryTags[$i][3] . ' ' . $queryTags[$i][0];
        }
    }
    $queryText = implode(' ', $queryTexts);
    writeTag($rss, "title", "StreamOnTheFly query results");
    writeTag($rss, "description", $queryText);
function getQueryResults($params)
{
    global $config, $db;
    $query = xmlrpc_decode($params->getParam(0));
    $advsearch = new sotf_AdvSearch();
    //create new search object object with this array
    $SQLquery = $advsearch->Deserialize($query);
    //deserialize the content of the hidden field
    $query = $advsearch->GetSQLCommand();
    $results = $db->getAll($query . " LIMIT 30 OFFSET 0");
    foreach ($results as $key => $result) {
        $icon = sotf_Blob::cacheIcon($result['id']);
        $results[$key]['icon'] = $config['cacheUrl'] . "/" . $result['id'] . ".png";
        //TODO if no icon {$IMAGEDIR}/noicon.png $imageprefix????
    }
    $retval = xmlrpc_encode($results);
    return new xmlrpcresp($retval);
}
Example #4
0
 $properties = array();
 $properties["description"] = "Results of StreamOnTheFly query";
 $properties["link"] = $config['rootUrl'] . "";
 $properties["title"] = "StreamOnTheFly query results";
 //$properties["language"]="en";
 $properties["dc:date"] = getW3CDate();
 $rss_writer_object->addchannel($properties);
 //  If your channel has a logo, before adding any channel items, specify the logo details this way.
 $properties = array();
 $properties["url"] = $config['rootUrl'] . "/static/sotflogosmall.gif";
 $properties["link"] = $config['rootUrl'] . "";
 $properties["title"] = "StreamOnTheFly logo";
 $properties["description"] = "World wide network of radio archives";
 $rss_writer_object->addimage($properties);
 //  Then add your channel items one by one.
 $advsearch = new sotf_AdvSearch();
 $advsearch->Deserialize($query);
 $query = $advsearch->GetSQLCommand();
 $res = $db->limitQuery($query, $from, $count);
 $hits = array();
 while (DB_OK === $res->fetchInto($row)) {
     //$row['icon'] = sotf_Blob::cacheIcon($row['id']);
     $hits[] = $row;
 }
 foreach ($hits as $prog) {
     $properties = array();
     $properties["description"] = $prog['abstract'];
     $properties["link"] = $config['rootUrl'] . "/get.php?id=" . $prog['id'];
     $properties["title"] = $prog['title'];
     $properties["dc:date"] = $prog['production_date'];
     $rss_writer_object->additem($properties);
Example #5
0
//= < > ... values array
$SQLstring = $paramcache->getRegistered('SQLstring');
//last parameter value array
$SQLquerySerial = $paramcache->getRegistered('SQLquerySerial');
//the serialized query come from ADVSEARCH.PHP (hidden field)
if ($SQLquerySerial == "") {
    $SQLquerySerial = $_SESSION["SQLquerySerial"];
}
//  from ADVSEARCHRESULTS.PHP or somewhere else (session)
if ($SQLquerySerial == "") {
    $SQLquery = $_SESSION["SQLquery"];
    //get array from session
    $advsearch = new sotf_AdvSearch($SQLquery);
    //create search object object with this array
} else {
    $advsearch = new sotf_AdvSearch();
    //create new search object object
    $SQLquery = $advsearch->Deserialize($SQLquerySerial);
    //deserialize the content of the hidden field
}
if ($SQLquery == NULL) {
    $advsearch->SetSortOrder();
}
//set DEFAULT sort order for new queries
if (isset($sort1) and isset($sort2)) {
    $advsearch->SetSortOrder($sort1, $sort2);
    //set sort order
    $advsearch->setDir($dir1, $dir2);
    //set sort order direction
}
$max = count($SQLeq);
Example #6
0
 * $Id$
 * Created for the StreamOnTheFly project (IST-2001-32226)
 * Authors: András Micsik, Máté Pataki, Tamás Déri 
 *          at MTA SZTAKI DSD, http://dsd.sztaki.hu
 */
require "init.inc.php";
require $config['classdir'] . "/sotf_AdvSearch.class.php";
$pattern = sotf_Utils::getSQLSafeParameter('pattern');
$language = sotf_Utils::getSQLSafeParameter('language');
$station = sotf_Utils::getSQLSafeParameter('station');
if ($pattern) {
    //  debug("language", $language);
    if ($language == "any_language") {
        $language = false;
    }
    $advsearch = new sotf_AdvSearch();
    //create new search object object with this array
    $total = $advsearch->simpleSearch($pattern, $language, $station);
    $limit = $page->splitList($total, "?pattern=" . urlencode($pattern) . "&language={$language}");
    $result = $advsearch->getSimpleSearchResults($limit["from"], $limit["to"]);
    // cache icons for results
    for ($i = 0; $i < count($result); $i++) {
        $result[$i]['icon'] = sotf_Blob::cacheIcon($result[$i]['id']);
    }
    $smarty->assign('RESULTS', $result);
    $smarty->assign('PATTERN', $pattern);
    $smarty->assign('LANGUAGE', $language);
}
$searchLangs = $config['languages'];
array_unshift($searchLangs, "any_language");
for ($i = 0; $i < count($searchLangs); $i++) {
/** For portal */
function getQueryResults($params)
{
    global $config, $db;
    $query = xmlrpc_decoder($params->getParam(0));
    $advsearch = new sotf_AdvSearch();
    //create new search object object with this array
    $SQLquery = $advsearch->Deserialize($query);
    //deserialize the content of the hidden field
    $query = $advsearch->GetSQLCommand();
    $results = $db->getAll($query . " LIMIT 30 OFFSET 0");
    foreach ($results as $key => $result) {
        $icon = sotf_Blob::cacheIcon2($result);
        if ($icon) {
            $results[$key]['icon'] = $config['cacheUrl'] . "/" . $icon;
        }
        //TODO if no icon {$IMAGEDIR}/noicon.png $imageprefix????
        $prg =& new sotf_Programme($result['id']);
        // audio files for programme
        $audioFiles = $prg->listAudioFiles('true');
        $results[$key]['audioFiles'] = array();
        $results[$key]['downloadFiles'] = array();
        foreach ($audioFiles as $fileList) {
            if ($fileList['stream_access'] == "t") {
                $results[$key]['audioFiles'][] = $fileList;
            }
            if ($fileList['download_access'] == "t") {
                $results[$key]['downloadFiles'][] = $fileList;
            }
        }
    }
    $retval = xmlrpc_encoder($results);
    return new xmlrpcresp($retval);
}
Example #8
0
$saveas = sotf_Utils::getParameter('saveas');
//text field
//Current query
$SQLeq = sotf_Utils::getParameter('SQLeq');
//= < > ... values array
$SQLstring = sotf_Utils::getParameter('SQLstring');
//last parameter value array
$SQLquerySerial = sotf_Utils::getParameter('SQLquerySerial');
//the serialized query
if ($SQLquerySerial == "") {
    $SQLquery = $_SESSION["SQLquery"];
    //get array from session
    $advsearch = new sotf_AdvSearch($SQLquery);
    //create search object object with this array
} else {
    $advsearch = new sotf_AdvSearch();
    //create new search object object
    $SQLquery = $advsearch->Deserialize($SQLquerySerial);
    //deserialize the content of the hidden field
}
if ($SQLquery == NULL) {
    $advsearch->SetSortOrder("", "");
} else {
    $advsearch->SetSortOrder($sort1, $sort2);
}
//set sort order
$max = count($SQLeq);
$k = 0;
for ($i = 0; $i < $max; $i++) {
    $SQLquery[$i][2] = $SQLeq[$i];
    if ($SQLquery[$i][4] == "date") {
<?php

require "init.inc.php";
require "{$classdir}/sotf_AdvSearch.class.php";
$SQLquerySerial = sotf_Utils::getParameter('SQLquerySerial');
//the serialized query
if ($SQLquerySerial == "") {
    $SQLquery = $_SESSION["SQLquery"];
    //get array from session
    $advsearch = new sotf_AdvSearch($SQLquery);
    //create search object object with this array
} else {
    $advsearch = new sotf_AdvSearch();
    //create new search object object
    $SQLquery = $advsearch->Deserialize($SQLquerySerial);
    //deserialize the content of the hidden field
}
$query = "SELECT id FROM sotf_programmes WHERE";
//begining of the SQL command
$max = count($SQLquery);
for ($i = 0; $i < $max; $i++) {
    if ($i != 0) {
        $query = $query . " " . $SQLquery[$i][0];
    }
    if (($SQLquery[$i][0] == "AND" || $i == 0) && $SQLquery[$i + 1][0] == "OR") {
        $query = $query . " (";
    }
    //set begining of round bracket
    if ($SQLquery[$i][4] == "date") {
        $query = $query . " " . $SQLquery[$i][1];
    } else {