function smarty_function_artist_altnames_list($params, &$smarty)
{
    if (empty($params['var'])) {
        $smarty->trigger_error("assign: missing 'var' parameter");
        return;
    }
    if (empty($params['query'])) {
        $smarty->trigger_error("assign: missing 'var' parameter");
        return;
    } else {
        $query = $params['query'];
    }
    $searchterm = $query['artist'];
    $searchtype = 'parentid';
    global $db, $db_prefix;
    $thesaurus = new thesaurusDB($db, $db_prefix);
    $rs = $thesaurus->query('names', $searchterm, $searchtype);
    $sql = "queried through thesaurusDB::query('names', '{$searchterm}', '{$searchtype}');";
    if (count($rs)) {
        foreach ($rs as $row) {
            array_walk($row, '__stripslashes');
            $result[$row['id']] = $row;
        }
    } else {
        $result = false;
    }
    $smarty->assign($params['var'], $result);
    if (!empty($params['sql'])) {
        $smarty->assign($params['sql'], $sql);
    }
}
function smarty_function_artist_list($params, &$smarty)
{
    if (empty($params['var'])) {
        $smarty->trigger_error("assign: missing 'var' parameter");
        return;
    }
    if (empty($params['query'])) {
        $smarty->trigger_error("assign: missing 'var' parameter");
        return;
    } else {
        $query = $params['query'];
    }
    //debug($query);
    global $db, $db_prefix;
    $thesaurus = new thesaurusDB($db, $db_prefix);
    // $frommeta indicates whether or not the data is coming from the _existing_ metadata
    $frommeta = false;
    // search for artists by the artistsearch field if given or by the meta-id otherwise
    if (empty($query['searchartist'])) {
        if (empty($query['id'])) {
            $searchtype = false;
        } else {
            extractID($query['id'], $collectionid, $imageid);
            $searchterm = "{$collectionid}:{$imageid}";
            $searchtype = 'metaid';
            $frommeta = true;
        }
    } else {
        $searchterm = $query['searchartist'];
        $searchtype = 'name';
    }
    $result = array();
    if ($searchtype != false) {
        $rs = $thesaurus->query('names', $searchterm, $searchtype);
        $sql = "queried through thesaurusDB::query('names', '{$searchterm}', '{$searchtype}');";
        /*if ($frommeta) {
              $params['query']['name1id'] = $rs[0]['id'];
              $params['query']['name1text'] = $rs[0]['name'];
              $params['query']['name1id'] = $rs[0]['id'];
              $params['query']['name1text'] = $rs[0]['name'];
              $smarty->assign('query', $params['query']);
          }*/
        //make the ids be keys, and strip slashes out
        foreach ($rs as $row) {
            array_walk($row, '__stripslashes');
            $result[$row['id']] = $row;
        }
    } else {
        $sql = 'no query';
    }
    //debug($result);
    $smarty->assign($params['var'], $result);
    if (!empty($params['sql'])) {
        $smarty->assign($params['sql'], $sql);
    }
}
Пример #3
0
function smarty_function_city_list($params, &$smarty)
{
    if (empty($params['var'])) {
        $smarty->trigger_error("assign: missing 'var' parameter");
        return;
    }
    if (empty($params['query'])) {
        $smarty->trigger_error("assign: missing 'query' parameter");
        return;
    }
    global $db, $db_prefix;
    // query the existing locations
    /*$sql = "SELECT DISTINCT city FROM {$db_prefix}meta ORDER BY city ASC";
    	$rs = $db->GetArray( $sql );*/
    //debug($_REQUEST, false);
    //debug($params['query']);
    $thesaurus = new thesaurusDB($db, $db_prefix);
    // $frommeta indicates whether or not the data is coming from the _existing_ metadata
    $frommeta = false;
    // search by the citysearch field if given, by the meta-id otherwise
    if (empty($params['query']['citysearch'])) {
        if (empty($params['query']['id'])) {
            $searchtype = false;
        } else {
            $searchterm = $params['query']['id'];
            $searchtype = 'metaid';
            $frommeta = true;
        }
    } else {
        $searchterm = $params['query']['citysearch'];
        $searchtype = 'location';
    }
    $result = array();
    if ($searchtype != false) {
        $rs = $thesaurus->query('locations', $searchterm, $searchtype);
        $sql = "queried through thesaurusDB::query('locations', '{$searchterm}', '{$searchtype}');";
        if ($frommeta) {
            $params['query']['city'] = $rs[0]['id'];
            $params['query']['cityname'] = $rs[0]['location'];
            $smarty->assign('query', $params['query']);
        }
        //make the ids be keys
        $result = array();
        foreach ($rs as $row) {
            $result[$row['id']] = $row;
        }
    } else {
        $sql = 'no query';
    }
    $smarty->assign($params['var'], $result);
    $smarty->assign($params['frommeta'], $frommeta);
    if (!empty($params['sql'])) {
        $smarty->assign($params['sql'], $sql);
    }
}