[geeklog-cvs] Geeklog-1.x/public_html lib-common.php,1.647,1.648
Dirk Haun
dhaun at qs1489.pair.com
Sun Aug 19 11:56:05 EDT 2007
Update of /cvsroot/geeklog/Geeklog-1.x/public_html
In directory qs1489.pair.com:/tmp/cvs-serv22938/public_html
Modified Files:
lib-common.php
Log Message:
Split part of COM_topicList off into a new function, COM_topicArray, that returns the list of topics as an array
Index: lib-common.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/lib-common.php,v
retrieving revision 1.647
retrieving revision 1.648
diff -C2 -d -r1.647 -r1.648
*** lib-common.php 18 Aug 2007 18:11:14 -0000 1.647
--- lib-common.php 19 Aug 2007 15:56:02 -0000 1.648
***************
*** 1500,1508 ****
* @param string $selected Value (from $selection) to set to SELECTED or default
* @param int $sortcol Which field to sort option list by 0 (value) or 1 (label)
* @see function COM_optionList
* @return string Formated HTML of option values
*
*/
-
function COM_topicList( $selection, $selected = '', $sortcol = 1, $ignorelang = false )
{
--- 1500,1508 ----
* @param string $selected Value (from $selection) to set to SELECTED or default
* @param int $sortcol Which field to sort option list by 0 (value) or 1 (label)
+ * @param boolean $ignorelang Whether to return all topics (true) or only the ones for the current language (false)
* @see function COM_optionList
* @return string Formated HTML of option values
*
*/
function COM_topicList( $selection, $selected = '', $sortcol = 1, $ignorelang = false )
{
***************
*** 1511,1550 ****
$retval = '';
! $tmp = str_replace( 'DISTINCT ', '', $selection );
! $select_set = explode( ',', $tmp );
$sql = "SELECT $selection FROM {$_TABLES['topics']}";
! if( $ignorelang )
! {
$sql .= COM_getPermSQL();
! }
! else
! {
$permsql = COM_getPermSQL();
! if( empty( $permsql ))
! {
! $sql .= COM_getLangSQL( 'tid' );
! }
! else
! {
! $sql .= $permsql . COM_getLangSQL( 'tid', 'AND' );
}
}
$sql .= " ORDER BY $select_set[$sortcol]";
! $result = DB_query( $sql );
! $nrows = DB_numRows( $result );
!
! for( $i = 0; $i < $nrows; $i++ )
! {
! $A = DB_fetchArray( $result, true );
! $retval .= '<option value="' . $A[0] . '"';
! if( $A[0] == $selected )
! {
! $retval .= ' selected="selected"';
}
-
- $retval .= '>' . stripslashes( $A[1] ) . '</option>' . LB;
}
--- 1511,1572 ----
$retval = '';
! $topics = COM_topicArray($selection, $sortcol, $ignorelang);
! foreach ($topics as $tid => $topic) {
! $retval .= '<option value="' . $tid . '"';
! if ($tid == $selected) {
! $retval .= ' selected="selected"';
! }
! $retval .= '>' . $topic . '</option>' . LB;
! }
!
! return $retval;
! }
!
! /**
! * Return a list of topics in an array
! * (derived from COM_topicList - API may change)
! *
! * @param string $selection Comma delimited string of fields to pull The first field is the value of the option and the second is the label to be displayed. This is used in a SQL statement and can include DISTINCT to start.
! * @param int $sortcol Which field to sort option list by 0 (value) or 1 (label)
! * @param boolean $ignorelang Whether to return all topics (true) or only the ones for the current language (false)
! * @return array Array of topics
! * @see function COM_topicList
! *
! */
! function COM_topicArray($selection, $sortcol = 0, $ignorelang = false)
! {
! global $_TABLES;
!
! $retval = array();
!
! $tmp = str_replace('DISTINCT ', '', $selection);
! $select_set = explode(',', $tmp);
$sql = "SELECT $selection FROM {$_TABLES['topics']}";
! if ($ignorelang) {
$sql .= COM_getPermSQL();
! } else {
$permsql = COM_getPermSQL();
! if (empty($permsql)) {
! $sql .= COM_getLangSQL('tid');
! } else {
! $sql .= $permsql . COM_getLangSQL('tid', 'AND');
}
}
$sql .= " ORDER BY $select_set[$sortcol]";
! $result = DB_query($sql);
! $nrows = DB_numRows($result);
! if (count($select_set) > 1) {
! for ($i = 0; $i < $nrows; $i++) {
! $A = DB_fetchArray($result, true);
! $retval[$A[0]] = stripslashes($A[1]);
! }
! } else {
! for ($i = 0; $i < $nrows; $i++) {
! $A = DB_fetchArray($result, true);
! $retval[] = $A[0];
}
}
More information about the geeklog-cvs
mailing list