Greg,
first of all thanks for the interest!
I entered the codes as indicated and I removed 'Random' from function name, but unfortunately it doesn't work and a white page appears :-(
I have to customize some lines in your code perhaps?
For your information:
Runs on: Tested on coppermine 1.3.2,
* HTML: Generates XHTML (as far as I can tell)
* PHP: Tested on version 4
* RELEASE VERSION 2.0.0
*
* @version $Revision: 1.12 $
* @package cpmfetch
cpmfetch.php (last lines original file and your new code):
/**
*
* @access private
*/
function clearOptions( ) {
$this->optionHash = array();
$this->styleHash = array();
}
/**
* GMC Addition:
* http://forum.coppermine-gallery.net/index.php/topic,65412.msg384710.html#msg384710
*
* Displays sorted images from specific album or category
*
* This will generate a table and populate it with sorted media from the combination of
* categories and albums specified and style it based on entries in the style hash.
* The number of photos returned matches the number of rows multiplied by the number of columns.
* Supports the setReturnType option.
*
* @param int $rows The number of rows desired in the output
* @param int $columns The number of columns desired in the output
* @param int $sources The sources you want to draw from ("cat=1,4,5:album=6,7,8")
* @param array $options Optional, Configuration options
* @tutorial explainations.optionsarray.pkg
* @tutorial explainations.sourcetag.pkg
*
* @todo allow for media to be specified / filtered - jpg, mp3, etc
*/
function cpm_viewMediaFrom($source,$rows, $columns, $options="") {
$this->loadOptions($options);
$resultset = $this->getImageFrom ($source, $rows*$columns);
$this->addDescriptionsToResultSet($resultset);
$retval = "";
switch ($this->returntype) {
case ('resultset'):
$retval = $resultset;
break;
case ('html'):
$retval = $this->createTable($resultset,$rows,$columns);
break;
case ('print'):
default:
print $this->createTable($resultset,$rows,$columns);
}
$this->clearOptions();
return ($retval);
}
} // end class
?>
And cpmfetch_dao.php (last lines original file and your new code):
/**
*
* @access private
*/
function getRandomSeed() {
return microtime()*1000000;
}
/**
* GMC Addition:
* http://forum.coppermine-gallery.net/index.php/topic,65412.msg384710.html#msg384710
*
* Returns a 'sorted' image from a category in cpm
* Sort order from CPG config at time of CPMFETCH install
* Available options:
* ("ta") - Title ascending
* ("td") - Title descending
* ("na") - Name ascending
* ("nd") - Name descending
* ("da") - Date ascending
* ("dd") - Date descending
* ("pa") - Position ascending
* ("pd") - Position descending
*
* @access private
*/
function getImageFrom ($source, $count) {
global $config_cpgSettings;
$resultset = array();
if (is_numeric($count)) {
$sourceSql = $this->makeSourceSql($source);
switch($config_cpgSettings['default_sort_order']) {
case 'ta':
$orderby = "title";
break;
case 'td':
$orderby = "title DESC";
break;
case 'na':
$orderby = "filename";
break;
case 'nd':
$orderby = "filename DESC";
break;
case 'da':
$orderby = "ctime";
break;
case 'dd':
$orderby = "ctime DESC";
break;
case 'pa':
$orderby = "position";
break;
case 'pd':
$orderby = "position DESC";
break;
default:
$orderby = "filename";
break;
}
if ($sourceSql != "") $sourceSql = " AND " . $sourceSql;
$sqlcode = "SELECT {$this->sqlPostSelect} " . $this->sqlSelect . " FROM "
. $this->sqlTableSelect
. " WHERE 1 "
. $this->sqlUserDataLink
. " AND p.approved='YES' "
. $this->filetypefilter . " "
. $this->privacyfilter . $sourceSql
. " ORDER BY $orderby) LIMIT $count";
$resultset = $this->dbExecuteSql($sqlcode);
$this->addPathInfo($resultset);
} //end if
elseif ($this->cfg['cfDebugMode'] == 'true'){
debugPrint("Non numeric count submitted");
}
return($resultset);
} //end function
} //END OF CLASS
?>
David