[cc-commits] [CC SVN] r14212 - in cchost/trunk: cchost_lib dig dig/js dig/lib dig/pages mixter-files/skins/strings
webmaster at creativecommons.org
webmaster at creativecommons.org
Fri Mar 5 08:03:44 EST 2010
Author: fourstones
Date: 2010-03-05 13:03:44 +0000 (Fri, 05 Mar 2010)
New Revision: 14212
Removed:
cchost/trunk/dig/pages/_canned_query.inc
cchost/trunk/dig/pages/picks.php
cchost/trunk/dig/pages/podcasts.php
cchost/trunk/dig/pages/popular.php
Modified:
cchost/trunk/cchost_lib/cc-query.php
cchost/trunk/dig/.htaccess
cchost/trunk/dig/index.php
cchost/trunk/dig/js/ccm-query.js
cchost/trunk/dig/js/ccmd.js
cchost/trunk/dig/lib/head.php
cchost/trunk/dig/lib/query.php
cchost/trunk/dig/pages/dig.php
cchost/trunk/dig/pages/featured.php
cchost/trunk/mixter-files/skins/strings/audio.php
Log:
re-architect pt ? of ?
Modified: cchost/trunk/cchost_lib/cc-query.php
===================================================================
--- cchost/trunk/cchost_lib/cc-query.php 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/cchost_lib/cc-query.php 2010-03-05 13:03:44 UTC (rev 14212)
@@ -758,6 +758,11 @@
function _gen_lic()
{
+ if( empty($this->args['lic']) )
+ {
+ return;
+ }
+
$T = array(
'by' => array('attribution','attribution_3'),
'sa' => array('share-alike','share-alike_3'),
@@ -776,7 +781,7 @@
$T['open'] = array_merge( $T['by'], $T['pd'], $T['s'],$T['splus'],$T['nd'],$T['sa'] );
$T['allnc'] = array_merge( $T['nc'], $T['ncsa'], $T['ncnd'],$T['ncsplus'] );
- $lics = split(',',$this->args['lic']);
+ $lics = split(',',trim($this->args['lic']));
$license_ids = array();
Modified: cchost/trunk/dig/.htaccess
===================================================================
--- cchost/trunk/dig/.htaccess 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/dig/.htaccess 2010-03-05 13:03:44 UTC (rev 14212)
@@ -6,16 +6,27 @@
RewriteEngine On
RewriteBase /
+#
RewriteRule ^about/?$ index.php?page=about [L,QSA]
RewriteRule ^dig/?$ index.php?page=dig [L,QSA]
RewriteRule ^featured/?$ index.php?page=featured [L,QSA]
-RewriteRule ^podcasts/?$ index.php?page=podcasts [L,QSA]
-RewriteRule ^picks/?$ index.php?page=picks [L,QSA]
-RewriteRule ^popular/?$ index.php?page=popular [L,QSA]
-RewriteRule ^podcast_music/?$ index.php?page=dig&search-type=podcasting&title=Podsafe+Music [L,QSA]
-RewriteRule ^music_for_film_and_video/?$ index.php?page=dig&search-type=videos&title=Instrumental+Music+for+Film+and+Video [L,QSA]
-RewriteRule ^music_for_games/?$ index.php?page=dig&search-type=games&title=Electro+Instrumental+Music+for+Games [L,QSA]
-RewriteRule ^free_music/?$ index.php?page=dig&search-license=open&title=Music+Free+for+Commercial+Use [L,QSA]
+
+#
+# pre-canned queries
+# N.B. There is code and html that depends on these specific mappings
+#
+
+RewriteRule ^podcasts/?$ index.php?page=dig&title=ccMixter+Podcasts&type=podcast&dataview=topics_podinfo&results_func=podcastPageQueryResults&limit=10&datasource=topics&offset=1 [L,QSA]
+RewriteRule ^picks/?$ index.php?page=dig&title=Editors'+Picks&tags=editorial_pick&dataview=diginfo [L,QSA]
+RewriteRule ^popular/?$ index.php?page=dig&title=Popular&dataview=diginfo [L,QSA]
+RewriteRule ^podcast_music/?$ index.php?page=dig&search-type=podcasting&title=Music+Safe+for+Podcasts&tags=male_vocals,female_vocals,vocals&type=any [L,QSA]
+RewriteRule ^music_for_games/?$ index.php?page=dig&search-type=games&title=Electro+Instrumental+Music+for+Games&reqtags=instrumental,-male_vocals,-female_vocals,-vocals [L,QSA]
+RewriteRule ^free_music/?$ index.php?page=dig&search-license=open&title=Music+Free+for+Commercial+Use [L,QSA]
+RewriteRule ^cubicle_music/?$ index.php?page=dig&title=Chill+Cubicle+Music&tags=chill,ambient&type=any&search-type=cubicle [L,QSA]
+RewriteRule ^party_music/?$ index.php?page=dig&title=Party+Music&tags=dance,trance,club,house&&type=any&search-type=party [L,QSA]
+
+RewriteRule ^music_for_film_and_video/?$ index.php?page=dig&search-type=videos&title=Instrumental+Music+for+Film+and+Video&tags=instrumental,-male_vocals,-female_vocals,-vocals [L,QSA]
+
RewriteRule ^api/query/?$ lib/query_proxy.php [L,QSA]
Modified: cchost/trunk/dig/index.php
===================================================================
--- cchost/trunk/dig/index.php 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/dig/index.php 2010-03-05 13:03:44 UTC (rev 14212)
@@ -18,6 +18,8 @@
*
*/
+error_reporting(E_ALL);
+
global $DIG_ROOT_URL;
global $MIXTER_ROOT_DIR;
global $QUERY_ROOT_URL;
Modified: cchost/trunk/dig/js/ccm-query.js
===================================================================
--- cchost/trunk/dig/js/ccm-query.js 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/dig/js/ccm-query.js 2010-03-05 13:03:44 UTC (rev 14212)
@@ -299,7 +299,12 @@
case 'server':
case 'remote':
{
- var url = '/' + this._options.doc + '?' + this._params;
+ var url = '/' + this._options.doc + '?';
+ if( this._options.calling_args_str )
+ {
+ url += this._options.calling_args_str;
+ }
+ url += this._params;
document.location = url;
break;
}
Modified: cchost/trunk/dig/js/ccmd.js
===================================================================
--- cchost/trunk/dig/js/ccmd.js 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/dig/js/ccmd.js 2010-03-05 13:03:44 UTC (rev 14212)
@@ -1026,141 +1026,46 @@
/*
SEARCH & POPULATE
*/
-function update_fields(parameters) {
- var search_field = $('#search-query');
- if( search_field ) { // basic search
- $('#search-query').val(parameters.s ? parameters.s : parameters.search);
- $('#search-license').val( parameters.lic );
- }
-}
+
function do_search() {
var search_val = $('#search-query').val();
var search_lic = $('#search-license').val();
var search_type = $('#search-type').val();
+ var page = 'dig';
if( original_search_type && (search_type != original_search_type) )
{
- var mapping = {
- videos: 'music_for_film_and_video',
- games: 'music_for_games',
- podcasting: 'podcast_music',
- entertainment: 'dig'
- };
-
- if( search_type )
- {
- page = mapping[search_type];
- }
- else
- {
- page = 'dig';
- }
-
-
- url = DIG_ROOT_URL + '/' + page + '?search-query=' + search_val
- + '&search-license=' + search_lic
- + '&search-type=' + search_type;
- document.location = url;
- return false;
+ page = search_type;
}
+ var q = '?';
+ url = DIG_ROOT_URL + '/' + search_type;
- var search_reqtags = 'remix';
- var search_tags = '';
- var search_param_type = 'all';
- var digging_for = default_digging_for;
-
- switch(search_type) {
- case 'videos':
- search_reqtags += ',instrumental,-male_vocals,-female_vocals';
- search_param_type = 'any';
- digging_for = '<h3 id="diggingfor">You went digging for: Music for Videos</h3>';
- break;
- case 'games':
- search_reqtags += ',instrumental,-male_vocals,-female_vocals';
- search_tags = 'electronic,experimental';
- search_param_type = 'any';
- digging_for = '<h3 id="diggingfor">You went digging for: Music for Games</h3>';
- break;
- case 'podcasting':
- search_tags = 'male_vocals,female_vocals,vocals';
- search_param_type = 'any';
- digging_for = '<h3 id="diggingfor">You went digging for: Music for Podcasting</h3>';
- break;
- case 'entertainment':
- digging_for = '<h3 id="diggingfor">You went digging for: Music for Entertainment</h3>';
- break;
+ if( search_lic == 'open' )
+ {
+ url += q + 'search-license=open';
+ q = '&';
}
-
- var parameters = get_search_param_defaults();
- parameters.search = search_val;
- parameters.lic = search_lic;
- parameters.tags = search_tags;
- parameters.reqtags = search_reqtags;
- parameters.type = search_param_type;
-
- // generic search starts here ....
-
- var form_id = "search-utility";
- var form = $('#'+form_id);
-
- $('#loading').show();
-
- // video - instrumental
- // game - instrumental + (electronic|experimental)
- // podcast - male_vocals | female_vocals
- // entertainment?
-
- var options = {
- // debug: true,
- paging: true,
- parent: '#'+form_id
- };
-
- $('#results').html(digging_for+progress_indicator());
-
- queryObj = new ccmQuery(options, parameters, query_results);
- queryObj.query();
-
- var options2 = {
- // debug: true,
- paging: false,
- parent: '#'+form_id
- };
-
- var parameters2 = {
- dataview: 'tag_alias',
- search: parameters.s ? parameters.s : parameters.search
- };
-
- $('#didumean').html('');
-
- if( parameters2.search )
+ if( search_val.length > 0 )
{
- var didUMeanQuery = new ccmQuery(options2, parameters2, didUMean_results);
- didUMeanQuery.query();
+ url += q + 'search-query=' + search_val;
+ q = '&';
}
- return false;
-}
+ if( search_type != 'dig' )
+ {
+ url += q + 'search-type=' + search_type;
+ }
-function get_search_param_defaults()
-{
- var p = {
- dataview: 'diginfo',
- ord: 'desc',
- sort: 'rank',
- offset: 0,
- /* tagexp: '(remix|original)', */
- limit: '10'
- };
-
- return p;
+ document.location = url;
+ return false;
}
+
+
function do_advanced_search() {
var today = new Date();
var search_before = prep_date(today);
@@ -1306,6 +1211,7 @@
queryObj.query();
}
+/*
function populate_popular() {
var options = {
// debug: true,
@@ -1345,6 +1251,7 @@
queryObj = new ccmQuery(options, parameters, podcastPageQueryResults);
queryObj.query();
}
+*/
function populate_home()
{
@@ -1396,6 +1303,8 @@
advanced_search_button.click(do_advanced_search);
search_button.click(do_search);
+
+ window.original_search_type = $('#search-type').val();
}
/*
@@ -1422,15 +1331,15 @@
if(jQuery('#homepage').length > 0) {
populate_home();
}
+
// if the dig page
if(jQuery('#dig').length > 0) {
populate_dig();
- execute_url();
- original_search_type = $('#search-type').val();
}
-
+
/*
+
// if the featured page
if(jQuery('#featured').length > 0) {
populate_featured();
Modified: cchost/trunk/dig/lib/head.php
===================================================================
--- cchost/trunk/dig/lib/head.php 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/dig/lib/head.php 2010-03-05 13:03:44 UTC (rev 14212)
@@ -20,54 +20,55 @@
foreach( array('home', 'dig', 'featured', 'about') as $P )
{
- $var = $P . '_class';
- if( !isset($$var) )
- $$var = '';
+ $var = $P . '_class';
+ if( !isset($$var) )
+ $$var = '';
}
if( !isset($page_title) )
{
- die('\$page_title must be set to something before using this include.');
+ die('\$page_title must be set to something before using this include.');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
- <!-- Designed by nvzion.com, 2010 -->
- <title><?= $page_title ?></title>
- <meta http-equiv="Content-type" content="text/html; charset=utf-8">
- <meta name="MSSmartTagsPreventParsing" content="true" />
- <meta name="description" content="Description goes here." />
- <meta name="keywords" content="keywords, go, here" />
- <link rel="stylesheet" href="css/site.css" type="text/css" media="screen, projection" />
- <link rel="stylesheet" href="css/print.css" type="text/css" media="print" />
- <!--[if IE]><link rel="stylesheet" href="css/ie.css" type="text/css" media="screen, projection" /><![endif]-->
- <!--[if IE 6]><link rel="stylesheet" href="css/ie6.css" type="text/css" media="screen, projection" /><![endif]-->
- <script src="js/js_config.php" type="text/javascript" charset="utf-8"></script>
- <script src="js/dd_belatedpng.js" type="text/javascript" charset="utf-8"></script>
- <script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
- <script src="js/plugins/jquery.simplemodal.js" type="text/javascript" charset="utf-8"></script>
- <script src="http://mediaplayer.yahoo.com/js" type="text/javascript" charset="utf-8"></script>
- <script src="js/ccm-query.js" type="text/javascript" charset="utf-8"></script>
- <script src="js/ccmd.js" type="text/javascript" charset="utf-8"></script>
+ <!-- Designed by nvzion.com, 2010 -->
+ <title><?= $page_title ?></title>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <meta name="MSSmartTagsPreventParsing" content="true" />
+ <meta name="description" content="Description goes here." />
+ <meta name="keywords" content="keywords, go, here" />
+ <link rel="stylesheet" href="css/site.css" type="text/css" media="screen, projection" />
+ <link rel="stylesheet" href="css/print.css" type="text/css" media="print" />
+ <!--[if IE]><link rel="stylesheet" href="css/ie.css" type="text/css" media="screen, projection" /><![endif]-->
+ <!--[if IE 6]><link rel="stylesheet" href="css/ie6.css" type="text/css" media="screen, projection" /><![endif]-->
+ <script src="js/js_config.php" type="text/javascript" charset="utf-8"></script>
+ <script src="js/dd_belatedpng.js" type="text/javascript" charset="utf-8"></script>
+ <script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
+ <script src="js/plugins/jquery.simplemodal.js" type="text/javascript" charset="utf-8"></script>
+ <script src="http://mediaplayer.yahoo.com/js" type="text/javascript" charset="utf-8"></script>
+ <script src="js/ccm-query.js" type="text/javascript" charset="utf-8"></script>
+ <script src="js/ccmd.js" type="text/javascript" charset="utf-8"></script>
<?
-if( !empty($script_for_head) )
-{
- print $script_for_head;
-}
+ if( !empty($script_heads) )
+ {
+ foreach( $script_heads as $S )
+ print $S;
+ }
?>
</head>
<body>
<div class="container">
- <div id="header">
- <h1>dig.ccmixter</h1>
- </div>
- <div id="nav">
- <ul>
- <li><a href="/" <?= $home_class ?>>home</a></li>
- <li><a href="dig" <?= $dig_class ?>>dig</a></li>
- <li><a href="featured" <?= $featured_class ?>>featured</a></li>
- <li><a href="about" <?= $about_class ?>>about</a></li>
- </ul>
- <div class="clearer"></div>
- </div>
+ <div id="header">
+ <h1>dig.ccmixter <? if(!empty($page_title)) { print $page_title; } ?></h1>
+ </div>
+ <div id="nav">
+ <ul>
+ <li><a href="/" <?= $home_class ?>>home</a></li>
+ <li><a href="dig" <?= $dig_class ?>>dig</a></li>
+ <li><a href="featured" <?= $featured_class ?>>featured</a></li>
+ <li><a href="about" <?= $about_class ?>>about</a></li>
+ </ul>
+ <div class="clearer"></div>
+ </div>
\ No newline at end of file
Modified: cchost/trunk/dig/lib/query.php
===================================================================
--- cchost/trunk/dig/lib/query.php 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/dig/lib/query.php 2010-03-05 13:03:44 UTC (rev 14212)
@@ -19,142 +19,413 @@
*/
require_once('config.php');
+require_once('lib/util.php');
if( !defined('CC_HOST_CMD_LINE') )
define('CC_HOST_CMD_LINE', 1 ); // define this exact way
+chdir( $MIXTER_ROOT_DIR ); // must be run from the cchost install root dir
+$NO_EXTRANEOUS_OUTPUT = 1; // supress tagline of this file (OPTIONAL)
+//$admin_id = 9;
+require_once( 'cc-cmd-line.inc' );
+require_once( 'cchost_lib/cc-query.php');
+chdir( dirname(__FILE__) . '/..' );
-// should be in some kind of common.inc:
-require_once( $MIXTER_ROOT_DIR . '/cchost_lib/zend/json-encoder.php' );
+define('DIG_PAGING_ON', true);
+define('DIG_PAGING_OFF', false);
-/**
- * do the actual query with ccHost
- */
-function _query(&$qi)
+class digQuery
{
- global $MIXTER_ROOT_DIR;
-
- chdir( $MIXTER_ROOT_DIR ); // must be run from the cchost install root dir
- $NO_EXTRANEOUS_OUTPUT = 1; // supress tagline of this file (OPTIONAL)
- require_once( 'cc-cmd-line.inc' );
- require_once( 'cchost_lib/cc-query.php');
-
- if( !empty($qi['query_opts']['paging'] ) )
+ function digQuery($paging=DIG_PAGING_OFF)
{
- $query = new CCQuery();
- $args = $qi['query_args'];
- $args['format'] = 'count';
- $args = $query->ProcessAdminArgs($args);
- list( $count ) = $query->Query($args);
- $qi['total'] = trim($count,'[]');
+ $this->_clear();
+ $this->_control['paging'] = $paging;
}
+
+ function Query()
+ {
+ global $MIXTER_ROOT_DIR;
+
+ $cwd = getcwd(); // there are many on-the-fly includes...
+ chdir($MIXTER_ROOT_DIR); // ...that assume cchost root dir
+
+ if( !empty($this->_control['paging']) )
+ {
+ $query = new CCQuery();
+ $args = $this->_query_args; // copy
+ $args['format'] = 'count';
+ $args = $query->ProcessAdminArgs($args);
+ list( $count ) = $query->Query($args);
+ $this->total = trim($count,'[]');
+ }
+
+ $this->queryObj = new CCQuery();
+ $A = $this->queryObj->ProcessAdminArgs($this->_query_args);
+ $A['format'] = 'php';
+ $this->queryObj->Query($A);
+ $this->results =& $this->queryObj->records;
+
+ chdir($cwd);
+
+ if( !empty($this->_control['paging']) )
+ {
+ $this->limit =& $this->queryObj->args['limit'];
+ $this->offset =& $this->queryObj->args['offset'];
+ }
+ if( !empty($this->results[0]['files']) )
+ {
+ $keys = array_keys($this->results);
+ foreach( $keys as $K )
+ {
+ $F = & $this->results[$K];
+
+ // dig js wants this fields
+ $F['num_files'] = count($F['files']);
+
+ // remove these to reduces size and not encourage
+ // nosy assholes
+
+ $keys = array_keys($F['files']);
+ foreach( $keys as $K )
+ {
+ $file =& $F['files'][$K];
+ foreach( array('local_path','file_is_remote', 'file_num_download') as $K2 )
+ {
+ if( isset($file[$K2]) )
+ unset($file[$K2]);
+ }
+ }
+
+ foreach( array('howididit','edpicks','usertags','ccud','systags','relative_dir') as $K )
+ {
+ if( !empty($F['upload_extra'][$K]) )
+ unset($F['upload_extra'][$K]);
+ }
+ }
+ }
- $query = new CCQuery();
- $args = $qi['query_args'];
- $args['format'] = 'php';
- $args = $query->ProcessAdminArgs($args);
- list( $results, $mime ) = $query->Query($args);
+ }
+ /**
+ * Parse and translate request args
+ * into query args.
+ *
+ * There are two sets of incoming request args:
+ *
+ * - 'pretty' version that is used in the browser.
+ * - the actual args as translated by ReWrite rules
+ *
+ * These need be setup for use in the following
+ * contexts:
+ *
+ * - query args passed to ccM
+ * - query count args passed to ccM
+ * - pagination URLs
+ * - converted to json for use on client side
+ *
+ *
+ */
+ function ProcessUriArgs()
+ {
+ global $DIG_ROOT_URL;
+
+ // these were as passed in the browser addr bar
+ if( preg_match('%/([^?]+)(\?([^#]+))?%',strip_slash($_SERVER['REQUEST_URI']),$m) )
+ {
+ $this->_control['doc_url'] = $m[1];
- // dbg($query);
+ $this->_page_opts['post_back_url'] = $DIG_ROOT_URL . '/' . $m[1];
+
+ $paging = !empty($this->_control['paging']);
+
+
+ if( $paging )
+ {
+ $this->_page_opts['pagination_url'] = $this->_page_opts['post_back_url'] . '?';
+ }
- chdir( dirname(__FILE__) . '/..' );
+ if( !empty($m[3]) )
+ {
+ $this->pretty_args = new digArgs($m[3],array('offset'));
+ if( $paging && !empty($this->pretty_args->stripped_query_str) )
+ {
+ $this->_page_opts['pagination_url'] .= $this->pretty_args->stripped_query_str . '&';
+ }
+ }
+ }
- $qi['results'] = & $results;
- $qi['queryObj'] = & $query;
+ // after translation by mod_rewrite:
+ $this->raw_args = new digArgs(strip_slash($_GET), array('offset')); // SERVER['QUERY_STRING'],array('offset'));
+
+ // browser args take precedence
+ if( empty($this->pretty_args) )
+ {
+ $all = $this->raw_args->args;
+ }
+ else
+ {
+ $all = array_merge($this->raw_args->args,$this->pretty_args->args);
+ }
+
+ // seperate out the html page fields
+ $this->_fields = array();
+
+ foreach( $all as $K => $V )
+ {
+ if( preg_match('/^(search|advanced)-/i',$K) )
+ {
+ $this->_fields[$K] = $V;
+ }
+ }
-}
+ $all = array_diff_assoc($all,$this->_fields);
+
+ // separate out dig control fields
+
+ foreach( array('page') as $K )
+ {
+ if( !empty($all[$K]) )
+ {
+ $this->_control[$K] = $all[$K];
+ }
+
+ }
+
+ foreach( array('results_func') as $K )
+ {
+ if( !empty($all[$K]) )
+ {
+ $this->_page_opts[$K] = $all[$K];
+ }
+
+ }
+
+ // what's left should be a request version
+ // the query args (right?)
-function perform_query(&$qi)
-{
- _query($qi);
+ $clean_all = array_diff_assoc($all,$this->_control,$this->_page_opts);
- //dbg($qi);
+ $this->req_query_args = new digArgs($clean_all);
- $args = $qi['queryObj']->args;
- if( !empty($qi['query_opts']['paging'] ) )
+ }
+
+ /**
+ * Combine admin args with any URL args
+ * (if any). Flatten all tag arguments
+ * into a tagexp
+ */
+ function ProcessAdminArgs($args)
{
- $qi['limit'] = $args['limit'];
- $qi['offset'] = $args['offset'];
+ $this->admin_args = new digArgs($args);
+
+
+ // we're not making _query_args an object
+ // because we already have all the constituent
+ // parts to calculate things out
+
+ if( empty($this->req_query_args) )
+ {
+ $this->_query_args = $args;
+ }
+ else
+ {
+ $this->_query_args = array_merge($args,$this->req_query_args->args);
+ }
+
+
+ // we have every arg and tag, now fixup tags so that all
+ // the various arg contributors get combined into one
+ // tagexpr
+
+ $exps = array();
+
+ //
+ // order specific: precedence goes left (low) to right (high)
+ //
+ foreach( array('raw_args','pretty_args','admin_args') as $aobj )
+ {
+ if( empty($this->$aobj) )
+ continue;
+
+ $O =& $this->$aobj;
+
+ // if this already has a tagexp, just use it
+
+ if( !empty($O->args['tagexp']) )
+ {
+ $exps[] = $O->args['tagexp'];
+ continue;
+ }
+
+ // reqtags are a natural
+
+ if( !empty($O->regtags) )
+ {
+ $exps[] = join('*',$O->reqtags);
+ }
+
+ // if there's no tags then we're done
+
+ if( empty($O->tags) )
+ {
+ continue;
+ }
+
+ // now add the tags
+
+ $jchar = '*';
+
+ if( !empty($O->args['type']) )
+ {
+ if( $O->args['type'] == 'any' )
+ $jchar = '|';
+ }
+
+ $exps[] = join($jchar,$O->tags);
+ }
+
+ if( !empty($exps) )
+ {
+ // yea, there might be dupes
+
+ $exps = array_unique($exps);
+
+ $this->_query_args['tagexp'] = '(' . join(')*(',$exps) . ')';
+
+ // don't confuse the query engine and just
+ // nuke out the tags argument
+
+ if( !empty($this->_query_args['tags']) )
+ {
+ unset($this->_query_args['tags']);
+ }
+ }
+
}
+
+ function _clear()
+ {
+ $this->_fields = array();
+ $this->_control = array();
+ $this->_query_args = array();
+ $this->_page_opts = array( 'mode' => 'server' );
+
+ $this->queryObj = null;
+
+ $this->admin_args = null;
+ $this->pretty_args = null;
+ $this->raw_args = null;
+ $this->req_query_args = null;
+ }
+}
- $results = & $qi['results'];
+function queries_to_jscript($queries)
+{
+ if( empty($queries) )
+ return '';
- if( !empty($results[0]['files']) )
+ $qs = '';
+ $inits = '';
+ foreach( $queries as $Q )
{
- $keys = array_keys($qi['results']);
- foreach( $keys as $K )
+ if( $Q === null )
+ continue;
+
+ $json_params = empty($Q->pretty_args->args) ? '{}' : CCZend_Json_Encoder::encode($Q->pretty_args->args);
+ $json_opts = empty($Q->_page_opts) ? '{}' : CCZend_Json_Encoder::encode($Q->_page_opts);
+ $json_results = CCZend_Json_Encoder::encode($Q->results);
+
+ $json_results = str_replace('{"upload_id"', "\n" . '{"upload_id"', $json_results);
+ $json_results = str_replace('"upload_description_plain"', "\n " . '"upload_description_plain"', $json_results );
+ $json_results = str_replace('"howididit"', "\n " . '"howididit"', $json_results );
+
+ $qs .= "queryObj = new ccmQuery({$json_opts},{$json_params},null);\n";
+
+
+ if( !empty($Q->_page_opts['paging']) )
+ {
+ $qs .= <<<EOF
+ queryObj.values = {
+ total: {$Q->total},
+ limit: {$Q->limit},
+ offset: {$Q->offset}
+ };
+
+EOF;
+ }
+
+ $inits .= "{$Q->_page_opts['results_func']}({$json_results});\n";
+
+ if( !empty($Q->_fields) )
{
- $R = & $qi['results'][$K];
- $R['num_files'] = count($R['files']);
+ foreach( $Q->_fields as $K => $F )
+ {
+ $inits .= "\t\t\t\tF = \$('#' + '{$K}'); if( F ) { F.val('{$F}'); }\n";
+ }
}
}
- $qi['json'] = CCZend_Json_Encoder::encode($results);
-
-}
-function dbg(&$obj)
-{
- $str =& _textize($obj);
- $html = '<pre style="font-size: 10pt;text-align:left;">' .
- htmlspecialchars($str) .
- '</pre>';
- print("<html><body>$html</body></html>");
- exit;
-}
+ $js =<<<EOF
+ <script type="text/javascript">
+ {$qs}
+
+ jQuery(document).ready(function() {
+ var F;
+ {$inits}
+ });
+
+ </script>
+EOF;
-function & _textize(&$var)
-{
- ob_start();
- if( is_array($var) || is_object($var) || is_resource($var) )
- print_r($var);
- else
- var_dump($var);
- $t = ob_get_contents();
- ob_end_clean();
-
- $r =& $t;
- return($r);
+ return $js;
}
-function no_script_results( &$qi )
+function queries_to_no_script($queries)
{
- global $DIG_ROOT_URL ;
+ foreach( $queries as $qi )
+ {
+ if( $qi === null )
+ continue;
+
+ print '<noscript>';
- print '<ul>';
- $recs = & $qi['results'];
- $keys = array_keys($recs);
- foreach( $keys as $K )
- {
- $R =& $recs[$K];
- if( !empty($R['file_page_url']) )
- {
- print "<li><a href='{$R['file_page_url']}'>" .
- "{$R['upload_name']}</a> by " .
- "<a href='{$R['artist_page_url']}'>{$R['user_real_name']}</a> {$R['upload_tags']}</li>\n";
- }
- elseif( !empty($R['enclosure_url']) )
- {
- print "<li><a href='{$R['enclosure_url']}'>{$R['topic_name']}</a> by {$R['user_real_name']}</li>\n";
- }
- }
- print '</ul>';
- if( !empty($qi['query_opts']['paging']) )
- {
- $base = $DIG_ROOT_URL . $qi['query_opts']['doc'] . '?ns=1';
- $keys = array_diff( array_keys($qi['query_opts']['calling_args']), array('offset','limit') );
- $args = $qi['query_opts']['calling_args'];
- foreach( $keys as $K )
- {
- $base .= '&' . $K . '=' . $args[$K];
- }
print '<ul>';
- $page = 1;
- for( $i = 0; $i < $qi['total']; $i += $qi['limit'], $page++ )
+ $recs = & $qi->results;
+ $keys = array_keys($recs);
+ foreach( $keys as $K )
+ {
+ $R =& $recs[$K];
+ if( !empty($R['file_page_url']) )
+ {
+ $tags = str_replace(',',', ',$R['upload_tags']);
+ print "<li><a href='{$R['file_page_url']}'>" .
+ "{$R['upload_name']}</a> by " .
+ "<a href='{$R['artist_page_url']}'>{$R['user_real_name']}</a> {$tags}</li>\n";
+ }
+ elseif( !empty($R['enclosure_url']) )
+ {
+ print "<li><a href='{$R['enclosure_url']}'>{$R['topic_name']}</a> by {$R['user_real_name']}</li>\n";
+ }
+ }
+ print '</ul>';
+
+ if( !empty($qi->_page_opts['paging']) )
{
- print "<li><a href='{$base}&offset={$i}'>page: {$page}</a></li>\n";
+ $base = $qi->_page_opts['pagination_url'];
+ if( $qi->offset > 0 )
+ {
+ if( ($offset = $qi->offset - $qi->limit) < 0 )
+ $offset = 0;
+
+ print "<p><a href='{$base}offset={$offset}'>prev</a></p>\n";
+ }
+ if( ($offset = $qi->offset + $qi->limit) < $qi->total )
+ {
+ print "<p><a href='{$base}offset={$offset}'>next</a></p>\n";
+ }
}
- print '</ul>';
+
+ print '</noscript>';
}
}
Deleted: cchost/trunk/dig/pages/_canned_query.inc
===================================================================
--- cchost/trunk/dig/pages/_canned_query.inc 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/dig/pages/_canned_query.inc 2010-03-05 13:03:44 UTC (rev 14212)
@@ -1,88 +0,0 @@
-<?
-/*
-* Artistech Media has made the contents of this file
-* available under a CC-GNU-GPL license:
-*
-* http://creativecommons.org/licenses/GPL/2.0/
-*
-* A copy of the full license can be found as part of this
-* distribution in the file LICENSE.TXT.
-*
-* You may use dig.ccMixter software in accordance with the
-* terms of that license. You agree that you are solely
-* responsible for your use of dig.ccMixter software and you
-* represent and warrant to Artistech Media that your use
-* of dig.ccMixter software will comply with the CC-GNU-GPL.
-*
-* $Id$
-*
-*/
-
-require_once('lib/query.php');
-
-$temp = explode('?',$_SERVER['REQUEST_URI']);
-if( count($temp) > 1 )
-{
- $uri_query_string = $temp[1];
- parse_str($uri_query_string,$uri_query_args);
-}
-else
-{
- $uri_query_string = '';
- $uri_query_args = array();
-}
-
-$query_info = array(
-
- 'query_args' => $query_args,
-
- 'query_opts' => array (
- 'paging' => true,
- 'doc' => $doc_page,
- 'calling_args_str' => $uri_query_string,
- 'calling_args' => $uri_query_args,
- 'mode' => 'server' // temp flag during tansition from ajax to server
- ),
-);
-
-$query_info['query_args'] = array_merge($query_info['query_args'],$query_info['query_opts']['calling_args']);
-perform_query($query_info);
-
-if( !empty($query_info['results']) )
-{
- $json_params = CCZend_Json_Encoder::encode($query_info['query_opts']['calling_args']);
- $json_opts = CCZend_Json_Encoder::encode($query_info['query_opts']);
-
- $script_for_head =<<<EOF
- <script type="text/javascript">
- queryObj = new ccmQuery({$json_opts},{$json_params},null);
- queryObj.values = {
- total: {$query_info['total']},
- limit: {$query_info['limit']},
- offset: {$query_info['offset']}
- };
-
- jQuery(document).ready(function() {
- {$results_func}({$query_info['json']});
- });
- </script>
-EOF;
-}
-
-require_once('lib/head.php');
-?>
- <div id="content">
- <div class="page full" id="<?= $page_div_id ?>">
- <h2><?= $h2_title ?></h2>
- <div id="results">
- </div>
- <div class="clearer"></div>
- <noscript>
- <? no_script_results( $query_info ); ?>
- </noscript>
- </div>
- <? require_once('lib/footer.php'); ?>
- </div>
- </div>
-</body>
-</html>
\ No newline at end of file
Modified: cchost/trunk/dig/pages/dig.php
===================================================================
--- cchost/trunk/dig/pages/dig.php 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/dig/pages/dig.php 2010-03-05 13:03:44 UTC (rev 14212)
@@ -17,68 +17,56 @@
* $Id$
*
*/
- $page_title = 'dig.ccmixter Dig Results';
- $dig_class = 'class="current"';
-
- require_once('lib/head.php');
-
-?>
-<script type="text/javascript" charset="utf-8">
-function execute_url()
+
+require_once('lib/util.php');
+require_once('lib/dig_util.php');
+require_once('lib/query.php');
+
+$digQuery = new digQuery(DIG_PAGING_ON);
+$digQuery->_page_opts['paging'] = true;
+$digQuery->_page_opts['parent'] = '#search-utility';
+$digQuery->_page_opts['results_func'] = 'query_results';
+$digQuery->ProcessUriArgs();
+$digQuery->ProcessAdminArgs(prep_dig_query_args($digQuery));
+$digQuery->Query();
+
+
+if( empty($digQuery->_fields['search-query']) )
{
- <?
-
- if( !empty($_GET) )
- {
- $fields = array();
- $params = array();
- foreach( $_GET as $K => $V )
- {
- if( preg_match('/^(advanced-)?search-/',$K) )
- {
- $fields[] = "\$('#{$K}').val('{$V}');";
- }
- else
- {
- if( !in_array($K,array('page','x','y')) )
- {
- $params[] = "parameters.{$K} = '{$V}';";
- }
- }
- }
- if( empty($params) )
- $params = '';
- else
- $params = join(" \n",$params);
-
- if( empty($fields) )
- $fields = '';
- else
- $fields = join(" \n",$fields);
+ $didumeanQuery = null;
+}
+else
+{
+ $didumeanQuery = new digQuery();
+ $didumeanArgs = array(
+ 'dataview' => 'tag_alias',
+ 'search' => $digQuery->_fields['search-query'],
+ );
+ $didumeanQuery->ProcessAdminArgs($didumeanArgs);
+ $didumeanQuery->Query();
+ $didumeanQuery->_page_opts = array( 'results_func' => 'didUMean_results' );
+}
+
+// ----------
+$queries = array( &$didumeanQuery, &$digQuery ) ;
+if( !empty($_REQUEST['dquery'] ) )
+{
+ $digQuery->query_str = http_build_query($digQuery->_query_args);
+ dbg($queries);
+}
+$script_heads[] = queries_to_jscript( $queries );
+$page_title = empty($digQuery->_query_args['title']) ? 'dig.ccmixter' : $digQuery->_query_args['title'];
+$dig_class = 'class="current"';
- if( !empty($params) || !empty($fields) )
- {
- $js =<<<EOF
- var parameters = {};
- {$params}
- update_fields(parameters);
- {$fields}
- do_search();
+require_once('lib/head.php');
-EOF;
- print $js;
- }
- }
- ?>
-
-}
-</script>
+?>
<div id="content">
<div class="page full" id="dig">
<!-- <h2>dig</h2> -->
<div class="search-utility round">
- <form action="#">
+ <form action="#" >
<div class="search-input-container"><input type="text" name="search-query" value="" id="search-query" /></div>
<div class="search-select-container">
<select name="search-license" id="search-license" size="1">
@@ -86,11 +74,12 @@
<option value="open">Free for commercial use</option>
</select>
<select name="search-type" id="search-type" size="1">
- <option value="">All types</option>
- <option value="videos">For video use</option>
- <option value="games">For game use</option>
- <option value="podcasting">For podcasts</option>
- <option value="entertainment">Entertain me!</option>
+ <option value="dig">All types</option>
+ <option value="music_for_film_and_video">For video use</option>
+ <option value="music_for_games">For game use</option>
+ <option value="podcast_music">For podcasts</option>
+ <option value="cubicle_music">Cubicle music</option>
+ <option value="party_music">Party music</option>
</select>
</div>
@@ -173,15 +162,16 @@
</div>
<div class="advanced"><a href="#" class="advanced-search-link">Advanced dig</a><a href="#" class="basic-search-link">Basic dig</a></div>
<?
- if( !empty($_GET['title']) )
+ if( !empty($page_title) )
{
- print '<h1 id="results-title">' . $_GET['title'] . '</h1>';
+ print "<h2>{$page_title}</h2>";
}
?>
<div id="didumean"></div>
<div id="results">
</div>
<div class="clearer"></div>
+ <? queries_to_no_script(array($digQuery)); ?>
</div>
<?
require_once('lib/footer.php');
Modified: cchost/trunk/dig/pages/featured.php
===================================================================
--- cchost/trunk/dig/pages/featured.php 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/dig/pages/featured.php 2010-03-05 13:03:44 UTC (rev 14212)
@@ -20,76 +20,51 @@
require_once('lib/query.php');
-$sections = array(
- array( // ed picks
-
- 'query_args' => array(
- 'dataview' => 'diginfo',
- 'tags' => 'editorial_pick',
- 'limit' => 6
- ),
-
- 'query_opts' => array (
- 'doc' => 'featured',
- 'func' => 'edpickQueryResults',
- 'mode' => 'server' // temp flag during tansition from ajax to server
- ),
- ),
-
- array( // popular
-
- 'query_args' => array(
- 'dataview' => 'diginfo',
- 'tags' => 'remix',
- 'sort' => 'rank',
- 'sinced' => '2 weeks ago',
- 'limit' => 6
- ),
-
- 'query_opts' => array (
- 'doc' => 'featured',
- 'func' => 'popchartQueryResults',
- 'mode' => 'server' // temp flag during tansition from ajax to server
- ),
- ),
+$query_args = array(
+ 'dataview' => 'diginfo',
+ 'tags' => 'editorial_pick',
+ 'limit' => 6,
+);
+$queries['edpicks'] = new digQuery();
+$queries['edpicks']->ProcessAdminArgs($query_args);
+$queries['edpicks']->Query();
- array( // podcasts
-
- 'query_args' => array(
- 'dataview' => 'topics_podinfo',
- 'type' => 'podcast',
- 'limit' => 10,
- 'offset' => 1
- ),
-
- 'query_opts' => array (
- 'doc' => 'featured',
- 'func' => 'podcastQueryResults',
- 'mode' => 'server' // temp flag during tansition from ajax to server
- ),
- )
+$queries['edpicks']->_page_opts['parent'] = '#edpicks';
+$queries['edpicks']->_page_opts['results_func'] = 'edpickQueryResults';
+
+
+$query_args = array(
+ 'dataview' => 'diginfo',
+ 'tags' => 'remix',
+ 'sort' => 'rank',
+ 'sinced' => '2 weeks ago',
+ 'limit' => 6
);
+$queries['popular'] = new digQuery();
+$queries['popular']->ProcessAdminArgs($query_args);
+$queries['popular']->Query();
-$script_for_head = "<script type=\"text/javascript\">\n" .
- " jQuery(document).ready(function() {\n";
+$queries['popular']->_page_opts['parent'] = '#popular';
+$queries['popular']->_page_opts['results_func'] = 'popchartQueryResults';
-foreach( $sections as $S )
-{
- perform_query($S);
- $json = CCZend_json_Encoder::encode($S['query_opts']);
- $script_for_head .=<<<EOF
- queryObj = new ccmQuery({$json},{},null);
- {$S['query_opts']['func']}({$S['json']});
-EOF;
-}
+$query_args = array(
+ 'dataview' => 'topics_podinfo',
+ 'type' => 'podcast',
+ 'limit' => 10,
+ 'offset' => 1
+);
-$script_for_head .= " });\n" .
- " </script>\n";
+$queries['podcasts'] = new digQuery();
+$queries['podcasts']->ProcessAdminArgs($query_args);
+$queries['podcasts']->Query();
+$queries['podcasts']->_page_opts['parent'] = '#podcasts';
+$queries['podcasts']->_page_opts['results_func'] = 'podcastQueryResults';
+$script_heads[] = queries_to_jscript( $queries );
$page_title = 'dig.ccmixter Featured Music';
$featured_class = 'class="current"';
@@ -108,14 +83,7 @@
</div>
</div>
<div id="no_script_results">
- <noscript>
-<?
- foreach( $sections as $S ) {
- no_script_results($S);
- print "<a href=\"{$DIG_ROOT_URL}/{$S['query_opts']['doc']}\">more</a><br />\n";
- }
-?>
- </noscript>
+ <? queries_to_no_script($queries); ?>
</div>
</div>
<? require_once('lib/footer.php'); ?>
Deleted: cchost/trunk/dig/pages/picks.php
===================================================================
--- cchost/trunk/dig/pages/picks.php 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/dig/pages/picks.php 2010-03-05 13:03:44 UTC (rev 14212)
@@ -1,36 +0,0 @@
-<?
-/*
-* Artistech Media has made the contents of this file
-* available under a CC-GNU-GPL license:
-*
-* http://creativecommons.org/licenses/GPL/2.0/
-*
-* A copy of the full license can be found as part of this
-* distribution in the file LICENSE.TXT.
-*
-* You may use dig.ccMixter software in accordance with the
-* terms of that license. You agree that you are solely
-* responsible for your use of dig.ccMixter software and you
-* represent and warrant to Artistech Media that your use
-* of dig.ccMixter software will comply with the CC-GNU-GPL.
-*
-* $Id$
-*
-*/
-
-$query_args = array(
- 'dataview' => 'diginfo',
- 'tags' => 'editorial_pick',
- 'limit' => 10,
-);
-
-$doc_page = 'picks';
-$page_title = 'dig.ccmixter Editor\'s Picks';
-$featured_class = 'class="current"';
-$page_div_id = 'pickspage';
-$h2_title = "Editors' Picks";
-$results_func = 'query_results';
-
-require_once('pages/_canned_query.inc');
-
-?>
\ No newline at end of file
Deleted: cchost/trunk/dig/pages/podcasts.php
===================================================================
--- cchost/trunk/dig/pages/podcasts.php 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/dig/pages/podcasts.php 2010-03-05 13:03:44 UTC (rev 14212)
@@ -1,38 +0,0 @@
-<?
-/*
-* Artistech Media has made the contents of this file
-* available under a CC-GNU-GPL license:
-*
-* http://creativecommons.org/licenses/GPL/2.0/
-*
-* A copy of the full license can be found as part of this
-* distribution in the file LICENSE.TXT.
-*
-* You may use dig.ccMixter software in accordance with the
-* terms of that license. You agree that you are solely
-* responsible for your use of dig.ccMixter software and you
-* represent and warrant to Artistech Media that your use
-* of dig.ccMixter software will comply with the CC-GNU-GPL.
-*
-* $Id$
-*
-*/
-
-$query_args = array(
- 'dataview' => 'topics_podinfo',
- 'datasource' => 'topics',
- 'type' => 'podcast',
- 'offset' => 1,
- 'limit' => 10,
-);
-
-$doc_page = 'podcasts';
-$page_title = 'dig.ccmixter Podcasts';
-$featured_class = 'class="current"';
-$page_div_id = 'podcastspage';
-$h2_title = 'Podcasts';
-$results_func = 'podcastPageQueryResults';
-
-require_once('pages/_canned_query.inc');
-
-?>
\ No newline at end of file
Deleted: cchost/trunk/dig/pages/popular.php
===================================================================
--- cchost/trunk/dig/pages/popular.php 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/dig/pages/popular.php 2010-03-05 13:03:44 UTC (rev 14212)
@@ -1,38 +0,0 @@
-<?
-/*
-* Artistech Media has made the contents of this file
-* available under a CC-GNU-GPL license:
-*
-* http://creativecommons.org/licenses/GPL/2.0/
-*
-* A copy of the full license can be found as part of this
-* distribution in the file LICENSE.TXT.
-*
-* You may use dig.ccMixter software in accordance with the
-* terms of that license. You agree that you are solely
-* responsible for your use of dig.ccMixter software and you
-* represent and warrant to Artistech Media that your use
-* of dig.ccMixter software will comply with the CC-GNU-GPL.
-*
-* $Id$
-*
-*/
-
-$query_args = array(
- 'dataview' => 'diginfo',
- 'tags' => 'remix',
- 'sinced' => '2 weeks ago',
- 'sort' => 'rank',
- 'limit' => 10,
-);
-
-$doc_page = 'popular';
-$page_title = 'dig.ccmixter Popular';
-$featured_class = 'class="current"';
-$page_div_id = 'popularpage';
-$h2_title = 'Popular';
-$results_func = 'query_results';
-
-require_once('pages/_canned_query.inc');
-
-?>
\ No newline at end of file
Modified: cchost/trunk/mixter-files/skins/strings/audio.php
===================================================================
--- cchost/trunk/mixter-files/skins/strings/audio.php 2010-03-02 21:27:07 UTC (rev 14211)
+++ cchost/trunk/mixter-files/skins/strings/audio.php 2010-03-05 13:03:44 UTC (rev 14212)
@@ -22,7 +22,7 @@
$GLOBALS['str_search_help_generic'] =
'<div style="text-align:center"><h2>Looking for music?</h2>' .
'<h3>Try our music discovery tool <a style="text-decoration:underline;" href="' . $GLOBALS['DIG_ROOT_URL'] . '">dig.ccMixter</a></h3><br />' .
- '<a href="' . $GLOBALS['DIG_ROOT_URL'] . '"><img src="' . $CC_GLOBALS['home-url'] . '/dig/images/logo-black.png" /></a>'.
+ '<a href="' . $GLOBALS['DIG_ROOT_URL'] . '"><img src="/dig/images/logo-black.png" /></a>'.
'</div>' .
'<hr />Otherwise, use the form below to search for text, a specific user, a forum post, etc.'
;
More information about the cc-commits
mailing list