/** For portal */
function getProgrammes($params)
{
    global $config, $db;
    $prglist = xmlrpc_decoder($params->getParam(0));
    $query = "SELECT programmes.* FROM (";
    $query .= " SELECT sotf_programmes.*, sotf_stations.name as station, sotf_series.name as seriestitle, sotf_series.description as seriesdescription, sotf_prog_rating.rating_value as rating FROM sotf_programmes";
    $query .= " LEFT JOIN sotf_stations ON sotf_programmes.station_id = sotf_stations.id";
    $query .= " LEFT JOIN sotf_series ON sotf_programmes.series_id = sotf_series.id";
    $query .= " LEFT JOIN sotf_prog_rating ON sotf_programmes.id = sotf_prog_rating.id";
    $query .= ") as programmes WHERE published = 't'";
    $results = array();
    foreach ($prglist as $prg) {
        //		debug("------------>".$prg."<------------------");
        //		debug("------------>".$query." AND id = '$prg'<------------------");
        $p = $db->getRow($query . " AND id = '{$prg}'");
        if ($p != NULL) {
            $results[] = $p;
        }
        //else $results[] = array("id" => $prg, "title" => "DELETED");
    }
    foreach ($results as $key => $result) {
        //		debug("------------>".$result['id']."<------------------");
        $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;
            }
        }
        //		$audioFiles = $prg->listAudioFiles('true');
        //		for ($i=0;$i<count($audioFiles);$i++)
        //		{
        //			$mainAudio[$audioFiles[$i]['filename']] = $audioFiles[$i];
        //		}
    }
    $retval = xmlrpc_encoder($results);
    return new xmlrpcresp($retval);
}
    if (array_key_exists("topic", $fields)) {
        $topicname = $page->getlocalized("topic");
        $topics = $advsearch->getTopics($result[$i]["id"]);
        foreach ($topics as $topic) {
            if ($topic["name"] != "") {
                if ($values[$topicname] == "") {
                    $values[$topicname] = $topic["name"];
                } else {
                    $values[$topicname] .= "; " . $topic["name"];
                }
            }
        }
    }
    $item['title'] = $result[$i][title];
    $item['id'] = $result[$i][id];
    $item['icon'] = sotf_Blob::cacheIcon2($result[$i]);
    $item['values'] = $values;
    $selected[] = $item;
    $item = "";
    $values = "";
}
//var_dump($selected);
//if (DB::isError($result)) die($result->getMessage());
//print("<BR />".count($result));
$smarty->assign("SQLquery", $SQLquery);
//the query
$smarty->assign("SQLquerySerial", $SQLquerySerial);
//the serialized query
//$smarty->assign("SQLqueryfields", $advsearch->GetSQLqueryfields());	//translated name for all fieldnames of the query
//$smarty->assign("SQLqueryEQs", $advsearch->GetSQLqueryEQs());		//translated name for all EQs (<, >, = ...) of the query
$smarty->assign("HumanReadable", $advsearch->GetHumanReadable());
Example #3
0
    // check if user has default query
    $advsearch = new sotf_AdvSearch();
    $prefs = $user->getPreferences();
    $defQuery = $prefs->getDefaultQuery();
}
// show default query or new programmes
$maxItemsIndexPage = $sotfVars->get("maxItemsIndexPage", 10);
if ($defQuery) {
    $smarty->assign("DEF_QUERY", 1);
    debug("default query", $defQuery);
    $advsearch->Deserialize($defQuery);
    $query = $advsearch->GetSQLCommand();
    debug("query", $query);
    //get the number of results
    $max = $db->getOne("SELECT count(*) FROM ( {$query} ) as foo ");
    $smarty->assign("DEF_QUERY_MAX", $max);
    $res = $db->limitQuery($query, 0, $maxItemsIndexPage);
    $hits = '';
    while (DB_OK === $res->fetchInto($row)) {
        $row['icon'] = sotf_Blob::cacheIcon2($row);
        $hits[] = $row;
    }
    $smarty->assign("NEWS", $hits);
} else {
    // get new programmes
    $smarty->assign('NEWS', sotf_Programme::getNewProgrammes($fromDay, $maxItemsIndexPage));
}
// get topics with most content
$smarty->assign('TOPICS', $vocabularies->getTopTopics(5));
$db->commit();
$page->send();
<?php

// -*- tab-width: 3; indent-tabs-mode: 1; -*-
/*  
 * $Id: showContactProgs.php 358 2004-04-29 12:46:01Z micsik $
 * 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";
$contactId = sotf_Utils::getParameter('id');
$contact =& new sotf_Contact($contactId);
$smarty->assign('PAGETITLE', $page->getlocalizedWithParams('programs_by', $contact->get('name')));
$smarty->assign('CONTACT_ID', $contactId);
$smarty->assign('CONTACT_NAME', $contact->get('name'));
$smarty->assign('CONTACT_DATA', $contact->getAllWithIcon());
$limit = $page->splitList($contact->countProgrammes(), "{$scriptUrl}/{$contactId}");
$progs = $contact->listProgrammes($limit["from"], $limit["maxresults"]);
for ($i = 0; $i < count($progs); $i++) {
    $progs[$i]['icon'] = sotf_Blob::cacheIcon2($progs[$i]);
}
$smarty->assign('PROGS', $progs);
$page->send();
 /** get news for index page, mode can be: all, free, promoted, premium */
 function getNewProgrammes($fromDay, $maxItems, $mode = 'all')
 {
     global $config, $db;
     if ($mode == 'premium') {
         $modeSql = "i.free_content='f' AND";
     } elseif ($mode == 'promoted') {
         $modeSql = "i.free_content='t' AND i.promoted='t' AND";
     } elseif ($mode == 'free') {
         $modeSql = "i.free_content='t' AND i.promoted='f' AND";
     }
     //$sql = "SELECT i.* FROM sotf_programmes i, sotf_stations s WHERE $modeSql i.station_id = s.id AND i.published='t' AND i.entry_date >= '$fromDay' ORDER BY i.entry_date DESC";
     $sql = "SELECT i.* FROM sotf_programmes i, sotf_stations s WHERE {$modeSql} i.station_id = s.id AND i.published='t' AND i.type='sound' AND i.entry_date >= '{$fromDay}' ORDER BY i.entry_date DESC";
     //MODIFIED BY Martin Schmidt
     $res = $db->limitQuery($sql, 0, $maxItems);
     if (DB::isError($res)) {
         raiseError($res);
     }
     $results = null;
     while (DB_OK === $res->fetchInto($row)) {
         $row['icon'] = sotf_Blob::cacheIcon2($row);
         $results[] = $row;
     }
     return $results;
 }
 /** get news for index page */
 function getNewProgrammes($fromDay, $maxItems)
 {
     global $config, $db;
     $sql = "SELECT i.* FROM sotf_programmes i, sotf_stations s WHERE i.station_id = s.id AND i.published='t' AND i.entry_date >= '{$fromDay}' ORDER BY i.entry_date DESC";
     $res = $db->limitQuery($sql, 0, $maxItems);
     if (DB::isError($res)) {
         raiseError($res);
     }
     $results = null;
     while (DB_OK === $res->fetchInto($row)) {
         $row['icon'] = sotf_Blob::cacheIcon2($row);
         $results[] = $row;
     }
     return $results;
 }
 /** static returns programmes owned/edited by current user */
 function myProgrammes($series, $filter, $sort, $count = false)
 {
     global $permissions, $db, $user;
     if (!isset($permissions->currentPermissions)) {
         return NULL;
     }
     // not logged in yet
     $sql = "SELECT  s.name AS station, se.name AS series, stats.visits, stats.listens, stats.downloads, flags.flags, rating.*, p.*" . " FROM sotf_programmes p LEFT JOIN sotf_stations s ON p.station_id = s.id" . " LEFT JOIN sotf_series se ON p.series_id=se.id" . " LEFT JOIN sotf_prog_rating rating ON p.id=rating.prog_id" . " LEFT JOIN sotf_user_progs flags ON p.id=flags.prog_id AND flags.user_id='{$user->id}'" . " LEFT JOIN sotf_prog_stats stats ON stats.prog_id=p.id " . ", sotf_user_permissions u" . " WHERE u.user_id = '{$user->id}' AND u.object_id=p.id";
     if ($series != "allseries") {
         $sql .= " AND p.series_id='{$series}'";
     }
     if ($filter == "all") {
     } elseif ($filter == "published") {
         $sql .= " AND p.published='t'";
     } elseif ($filter == "unpublished") {
         $sql .= " AND p.published='f'";
     } else {
         $sql .= " AND flags = '{$filter}'";
     }
     if ($sort) {
         $sql .= " ORDER BY {$sort}";
     }
     if ($count) {
         return $db->getOne("SELECT count(*) FROM ({$sql}) as a");
     }
     $plist = $db->getAll($sql);
     /////////////////added by Klaus Temper ///////////////////////
     foreach ($plist as $item) {
         $item["icon"] = sotf_Blob::cacheIcon2($item);
         $result[] = $item;
     }
     ///////////////////////////////////////////////////////
     /*
     	 foreach($plist as $item) {
     		$retval[] = new sotf_Programme($item['id'], $item);
     	 }*/
     return $result;
 }