本文整理汇总了PHP中get_subcat_data函数的典型用法代码示例。如果您正苦于以下问题:PHP get_subcat_data函数的具体用法?PHP get_subcat_data怎么用?PHP get_subcat_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_subcat_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_subcat_data
function get_subcat_data($parent, $ident = '')
{
global $CONFIG, $CAT_LIST;
if ($CONFIG['categories_alpha_sort'] == 1) {
$sort_query = 'name';
} else {
$sort_query = 'pos';
}
$sql = "SELECT cid, name, description " . "FROM {$CONFIG['TABLE_CATEGORIES']} " . "WHERE parent = '{$parent}' " . "ORDER BY {$sort_query}";
$result = cpg_db_query($sql);
if (($cat_count = mysql_num_rows($result)) > 0) {
$rowset = cpg_db_fetch_rowset($result);
$pos = 0;
foreach ($rowset as $subcat) {
if ($pos > 0) {
$CAT_LIST[$subcat['cid']] = array('cid' => $subcat['cid'], 'parent' => $parent, 'pos' => $pos++, 'prev' => $prev_cid, 'cat_count' => $cat_count, 'name' => $ident . $subcat['name']);
$CAT_LIST[$last_index]['next'] = $subcat['cid'];
} else {
$CAT_LIST[$subcat['cid']] = array('cid' => $subcat['cid'], 'parent' => $parent, 'pos' => $pos++, 'cat_count' => $cat_count, 'name' => $ident . $subcat['name']);
}
$last_index = $prev_cid = $subcat['cid'];
// $last_index = count($CAT_LIST) -1;
get_subcat_data($subcat['cid'], $ident . ' ');
}
}
}
示例2: get_subcat_data
/**
* get_subcat_data()
*
* function get the list of all the subcategories for the given category
*/
function get_subcat_data($parent, $ident = '')
{
global $CONFIG, $catStr, $parentAlubm;
if ($parentAlubm != 1) {
$parentAlubm = 1;
if ($parent == 0) {
$catStr .= "\n{$ident}<cat>\n {$ident}<id>{$parent}</id>\n {$ident}<name>Parent</name>";
} else {
$sql = "SELECT cid, name, description " . "FROM {$CONFIG['TABLE_CATEGORIES']} " . "WHERE cid = '{$parent}' " . "ORDER BY pos";
$result = cpg_db_query($sql);
$row = cpg_db_fetch_row($result);
mysql_free_result($results);
$catStr .= "\n{$ident}<cat>\n {$ident}<id>{$row['cid']}</id>\n {$ident}<name>{$row['name']}</name>";
}
get_album_data($parent, " ");
}
if ($parent == 1) {
/**
* This is a user category and the categories inside this are not listed in categories table
* So, we need to loop in the users table and create category id's and get the albums in it
*/
if (USER_IS_ADMIN) {
//Get all user albums
$sql = "SELECT user_name, user_id FROM {$CONFIG['TABLE_USERS']}";
$result = cpg_db_query($sql);
if (($cat_count = mysql_num_rows($result)) > 0) {
$rowset = cpg_db_fetch_rowset($result);
foreach ($rowset as $cat) {
$catStr .= "\n {$ident}<cat>\n {$ident}<id>" . (FIRST_USER_CAT + $cat['user_id']) . "</id>\n {$ident}<name>{$cat['user_name']}</name>";
get_album_data(FIRST_USER_CAT + $cat['user_id'], $ident . " ");
$catStr .= "\n {$ident}</cat>";
}
}
} elseif (USER_ID) {
//Get only current users albums
$catStr .= "\n {$ident}<cat>\n {$ident}<id>" . (FIRST_USER_CAT + USER_ID) . "</id>\n {$ident}<name>" . USER_NAME . "</name>";
get_album_data(FIRST_USER_CAT + USER_ID, $ident . " ");
$catStr .= "\n {$ident}</cat>";
}
} else {
$sql = "SELECT cid, name, description " . "FROM {$CONFIG['TABLE_CATEGORIES']} " . "WHERE parent = '{$parent}' " . "ORDER BY pos";
$result = cpg_db_query($sql);
if (($cat_count = mysql_num_rows($result)) > 0) {
$rowset = cpg_db_fetch_rowset($result);
$pos = 0;
foreach ($rowset as $subcat) {
$catStr .= "\n {$ident}<cat>\n {$ident}<id>{$subcat['cid']}</id>\n {$ident}<name>{$subcat['name']}</name>";
get_album_data($subcat['cid'], $ident . " ");
get_subcat_data($subcat['cid'], $ident . " ");
$catStr .= "\n {$ident}</cat>";
}
}
}
}
示例3: get_subcat_data
function get_subcat_data($parent, $ident = '')
{
global $CAT_LIST, $xoopsDB;
$result = $xoopsDB->query("SELECT cid, name, description FROM " . $xoopsDB->prefix("xcgal_categories") . " WHERE parent = '{$parent}' AND cid != 1 ORDER BY pos");
if ($xoopsDB->getRowsNum($result) > 0) {
$rowset = db_fetch_rowset($result);
foreach ($rowset as $subcat) {
$CAT_LIST[] = array($subcat['cid'], $ident . $subcat['name']);
get_subcat_data($subcat['cid'], $ident . ' ');
}
}
}
示例4: get_subcat_data
function get_subcat_data($parent, $ident = '')
{
global $db, $CONFIG, $CAT_LIST;
$result = $db->sql_query("SELECT cid, catname, description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent = '{$parent}' AND cid != 1 ORDER BY pos");
if ($db->sql_numrows($result) > 0) {
$rowset = $db->sql_fetchrowset($result);
foreach ($rowset as $subcat) {
$CAT_LIST[] = array($subcat['cid'], $ident . $subcat['catname']);
get_subcat_data($subcat['cid'], $ident . ' ');
}
}
}
示例5: get_subcat_data
function get_subcat_data($parent, &$album_set_array, $level)
{
global $xoopsDB;
$result = $xoopsDB->query("SELECT cid, name, description FROM " . $xoopsDB->prefix("xcgal_categories") . " WHERE parent = '{$parent}'");
if ($xoopsDB->getRowsNum($result) > 0) {
$rowset = db_fetch_rowset($result);
foreach ($rowset as $subcat) {
$result = $xoopsDB->query("SELECT aid FROM " . $xoopsDB->prefix("xcgal_albums") . " WHERE category = {$subcat['cid']}");
$album_count = $xoopsDB->getRowsNum($result);
while ($row = $xoopsDB->fetchArray($result)) {
$album_set_array[] = $row['aid'];
}
// while
}
if ($level > 1) {
get_subcat_data($subcat['cid'], $album_set_array, $level - 1);
}
}
}
示例6: get_subcat_data
function get_subcat_data($parent, &$album_set_array, $level)
{
global $CONFIG;
$result = db_query("SELECT cid, name, description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent = '{$parent}'");
if (mysql_num_rows($result) > 0) {
$rowset = db_fetch_rowset($result);
foreach ($rowset as $subcat) {
$result = db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = {$subcat['cid']}");
$album_count = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
$album_set_array[] = $row['aid'];
}
// while
}
if ($level > 1) {
get_subcat_data($subcat['cid'], $album_set_array, $level - 1);
}
}
}
示例7: get_subcat_data
function get_subcat_data($parent, $ident = '')
{
global $CONFIG, $CAT_LIST, $db;
$rowset = $db->sql_ufetchrowset('SELECT cid, catname, description FROM ' . $CONFIG['TABLE_CATEGORIES'] . " WHERE parent = '{$parent}' ORDER BY pos", SQL_BOTH, __FILE__, __LINE__);
if (($cat_count = count($rowset)) > 0) {
$pos = 0;
foreach ($rowset as $subcat) {
if ($pos > 0) {
$CAT_LIST[] = array('cid' => $subcat['cid'], 'parent' => $parent, 'pos' => $pos++, 'prev' => $prev_cid, 'cat_count' => $cat_count, 'catname' => $ident . $subcat['catname']);
$CAT_LIST[$last_index]['next'] = $subcat['cid'];
} else {
$CAT_LIST[] = array('cid' => $subcat['cid'], 'parent' => $parent, 'pos' => $pos++, 'cat_count' => $cat_count, 'catname' => $ident . $subcat['catname']);
}
$prev_cid = $subcat['cid'];
$last_index = count($CAT_LIST) - 1;
get_subcat_data($subcat['cid'], $ident . ' ');
}
}
}
示例8: get_subcat_data
function get_subcat_data($parent, $ident = '')
{
global $CAT_LIST, $xoopsDB, $myts;
$sql = "SELECT cid, name, description " . "FROM " . $xoopsDB->prefix("xcgal_categories") . " " . "WHERE parent = '{$parent}' " . "ORDER BY pos";
$result = $xoopsDB->query($sql);
if (($cat_count = $xoopsDB->getRowsNum($result)) > 0) {
$rowset = db_fetch_rowset($result);
$pos = 0;
foreach ($rowset as $subcat) {
if ($pos > 0) {
$CAT_LIST[] = array('cid' => $subcat['cid'], 'parent' => $parent, 'pos' => $pos++, 'prev' => $prev_cid, 'cat_count' => $cat_count, 'name' => $ident . $myts->makeTboxData4Show($subcat['name']));
$CAT_LIST[$last_index]['next'] = $subcat['cid'];
} else {
$CAT_LIST[] = array('cid' => $subcat['cid'], 'parent' => $parent, 'pos' => $pos++, 'cat_count' => $cat_count, 'name' => $ident . $myts->makeTboxData4Show($subcat['name']));
}
$prev_cid = $subcat['cid'];
$last_index = count($CAT_LIST) - 1;
get_subcat_data($subcat['cid'], $ident . ' ');
}
}
}
示例9: html_cat_list
function html_cat_list()
{
global $CONFIG, $CAT_LIST;
global $lang_albmgr_php;
$CAT_LIST = array();
if (USER_CAN_CREATE_ALBUMS) {
$CAT_LIST[] = array(FIRST_USER_CAT + USER_ID, $lang_albmgr_php['my_gallery']);
}
$CAT_LIST[] = array(0, $lang_albmgr_php['no_category']);
get_subcat_data(0, '');
$html = "\n";
foreach ($CAT_LIST as $category) {
$html .= ' <option value="' . $category[0] . '">' . $category[1] . "</option>\n";
}
return $html;
}
示例10: form_category
function form_category($text, $name)
{
global $ALBUM_DATA, $CAT_LIST, $USER_DATA, $lang_modifyalb_php, $CONFIG;
//check if users are allowed to move their albums
if ($CONFIG['allow_user_move_album'] == 0) {
//get category name
$cat_name = $lang_modifyalb_php['user_gal'];
if ($ALBUM_DATA['category'] != FIRST_USER_CAT + USER_ID) {
$result = cpg_db_query("SELECT name FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '" . $ALBUM_DATA['category'] . "' LIMIT 1");
$cat_name = cpg_db_fetch_row($result);
$cat_name = $cat_name['name'];
}
echo <<<EOT
<tr>
<td class="tableb">
{$text}
</td>
<td class="tableb" valign="top">
<i>{$cat_name}</i>
<input type="hidden" name="{$name}" value="{$ALBUM_DATA['category']}" />
</td>
EOT;
return;
}
$CAT_LIST = array();
//only add 'no category' when user is admin
if (GALLERY_ADMIN_MODE) {
$CAT_LIST[] = array(0, $lang_modifyalb_php['no_cat']);
}
//add user catergorie
$CAT_LIST[] = array(FIRST_USER_CAT + USER_ID, $lang_modifyalb_php['my_gal']);
get_subcat_data(0, '');
echo <<<EOT
<tr>
<td class="tableb">
{$text}
</td>
<td class="tableb" valign="top">
<select name="{$name}" class="listbox">
EOT;
foreach ($CAT_LIST as $category) {
echo ' <option value="' . $category[0] . '"' . ($ALBUM_DATA['category'] == $category[0] ? ' selected' : '') . ">" . $category[1] . "</option>\n";
}
echo <<<EOT
</select>
</td>
</tr>
EOT;
}
示例11: buildCatList
/**
* Function to build the html for cat list drop down.
*/
function buildCatList()
{
global $CAT_LIST;
get_subcat_data(0);
if (isset($_REQUEST['category'])) {
$selectedCat = $_REQUEST['category'];
}
if ($_REQUEST['category'] === "0") {
$noCat = " selected";
}
$return = "<select name=\"category\" class=\"listbox\" onchange=\"this.form.submit();\">\n";
$return .= "<option value=\"none\">Select Category</option>\n<option value=\"0\"{$noCat}>No Category</option>\n";
foreach ($CAT_LIST as $cat) {
$selected = $selectedCat == $cat['cid'] ? " selected" : "";
$return .= "<option value=\"{$cat['cid']}\"{$selected}>{$cat['name']}</option>\n";
}
$return .= "</select>";
return $return;
}
示例12: get_cat_list
/**
* get_cat_list()
*
* List all categories
*
* @param string $breadcrumb
* @param array $cat_data
* @param string $statistics
* @return void
**/
function get_cat_list(&$breadcrumb, &$cat_data, &$statistics)
{
global $CONFIG, $ALBUM_SET, $CURRENT_CAT_NAME, $BREADCRUMB_TEXT, $STATS_IN_ALB_LIST, $FORBIDDEN_SET;
global $HIDE_USER_CAT, $cpg_show_private_album;
global $cat;
global $lang_list_categories, $lang_errors;
// Build the breadcrumb
breadcrumb($cat, $breadcrumb, $BREADCRUMB_TEXT);
// Build the category list
$cat_data = array();
$album_set_array = array();
get_subcat_data($cat, $cat_data, $album_set_array, $CONFIG['subcat_level']);
$album_filter = '';
$pic_filter = '';
$cat = (int) $cat;
if (!empty($FORBIDDEN_SET) && !$cpg_show_private_album) {
$album_filter = ' and ' . str_replace('p.', 'a.', $FORBIDDEN_SET);
$pic_filter = ' and ' . $FORBIDDEN_SET;
}
// Add the albums in the current category to the album set
// if ($cat) {
if ($cat == USER_GAL_CAT) {
$sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} as a WHERE category >= " . FIRST_USER_CAT . $album_filter;
$result = cpg_db_query($sql);
} else {
$sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} as a WHERE category = '{$cat}'" . $album_filter;
$result = cpg_db_query($sql);
}
while ($row = mysql_fetch_array($result)) {
$album_set_array[] = $row['aid'];
}
// while
mysql_free_result($result);
// }
if (count($album_set_array) && $cat) {
$set = '';
foreach ($album_set_array as $album) {
$set .= $album . ',';
}
$set = substr($set, 0, -1);
$current_album_set = "AND aid IN ({$set}) ";
$ALBUM_SET .= $current_album_set;
} elseif ($cat) {
$current_album_set = "AND aid IN (-1) ";
$ALBUM_SET .= $current_album_set;
}
// Gather gallery statistics - start
if ($CONFIG['display_stats_on_index'] != 0) {
if ($cat == 0) {
$result = cpg_db_query("SELECT count(aid) FROM {$CONFIG['TABLE_ALBUMS']} as a WHERE 1" . $album_filter);
$nbEnr = mysql_fetch_array($result);
$album_count = $nbEnr[0];
mysql_free_result($result);
$sql = "SELECT count(pid) FROM {$CONFIG['TABLE_PICTURES']} as p " . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON a.aid=p.aid ' . 'WHERE 1' . $pic_filter . ' AND approved=\'YES\'';
$result = cpg_db_query($sql);
$nbEnr = mysql_fetch_array($result);
$picture_count = $nbEnr[0];
mysql_free_result($result);
$sql = "SELECT count(msg_id) FROM {$CONFIG['TABLE_COMMENTS']} as c " . 'LEFT JOIN ' . $CONFIG['TABLE_PICTURES'] . ' as p ' . 'ON c.pid=p.pid ' . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON a.aid=p.aid ' . 'WHERE 1' . $pic_filter . ' AND approval=\'YES\'';
$result = cpg_db_query($sql);
$nbEnr = mysql_fetch_array($result);
$comment_count = $nbEnr[0];
mysql_free_result($result);
$sql = "SELECT count(cid) FROM {$CONFIG['TABLE_CATEGORIES']} WHERE 1";
$result = cpg_db_query($sql);
$nbEnr = mysql_fetch_array($result);
$cat_count = $nbEnr[0] - $HIDE_USER_CAT;
mysql_free_result($result);
$sql = "SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} as p " . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON p.aid=a.aid ' . 'WHERE 1' . $pic_filter;
$result = cpg_db_query($sql);
$nbEnr = mysql_fetch_array($result);
$hit_count = (int) $nbEnr[0];
mysql_free_result($result);
if (count($cat_data)) {
$statistics = strtr($lang_list_categories['stat1'], array('[pictures]' => $picture_count, '[albums]' => $album_count, '[cat]' => $cat_count, '[comments]' => $comment_count, '[views]' => $hit_count));
} else {
$STATS_IN_ALB_LIST = true;
$statistics = strtr($lang_list_categories['stat3'], array('[pictures]' => $picture_count, '[albums]' => $album_count, '[comments]' => $comment_count, '[views]' => $hit_count));
}
} elseif ($cat >= FIRST_USER_CAT && $ALBUM_SET) {
$result = cpg_db_query("SELECT count(aid) FROM {$CONFIG['TABLE_ALBUMS']} WHERE 1 {$current_album_set}");
$nbEnr = mysql_fetch_array($result);
$album_count = $nbEnr[0];
mysql_free_result($result);
$result = cpg_db_query("SELECT count(pid) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 {$current_album_set}");
$nbEnr = mysql_fetch_array($result);
$picture_count = $nbEnr[0];
mysql_free_result($result);
$result = cpg_db_query("SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 {$current_album_set} AND approved='YES'");
$nbEnr = mysql_fetch_array($result);
//.........这里部分代码省略.........
示例13: form_category
function form_category($text, $catname)
{
global $ALBUM_DATA, $CAT_LIST, $USER_DATA;
if (!GALLERY_ADMIN_MODE || $ALBUM_DATA['category'] > FIRST_USER_CAT) {
echo '
<tr>
<td class="tableb">
' . $text . '
</td>
<td class="tableb" valign="top">
<i>' . USER_GAL . '</i>
<input type="hidden" name="' . $catname . '" value="' . $ALBUM_DATA['category'] . '" />
</td>
';
return;
}
$CAT_LIST = array();
$CAT_LIST[] = array(0, NO_CAT);
get_subcat_data(0, '');
echo <<<EOT
<tr>
<td class="tableb">
{$text}
</td>
<td class="tableb" valign="top">
<form method="post" action="'.URL::index("&file=modifyalb",0,1).'" enctype="multipart/form-data" accept-charset="utf-8">
<select name="{$catname}" class="listbox">
EOT;
foreach ($CAT_LIST as $category) {
echo '<option value="' . $category[0] . '"' . ($ALBUM_DATA['category'] == $category[0] ? ' selected' : '') . ">" . $category[1] . "</option>\n";
}
echo <<<EOT
</select>
</td>
</tr>
EOT;
}
示例14: get_cat_list
function get_cat_list(&$cat_data, &$statistics)
{
global $db, $CONFIG, $BREADCRUMB_TEXT, $STATS_IN_ALB_LIST;
global $HIDE_USER_CAT;
global $cat;
// Build the category list
$cat_data = array();
$album_set_array = array();
$HIDE_USER_CAT = 1;
get_subcat_data($cat, $cat_data, $album_set_array, 0);
// Add the albums in the current category to the album set
if ($cat) {
if ($cat == USER_GAL_CAT) {
foreach (get_albums_data() as $row) {
if ($row['category'] < FIRST_USER_CAT) {
continue;
}
$album_set_array[] = $row['aid'];
}
} else {
foreach (get_albums_data() as $row) {
if ($row['category'] != $cat) {
continue;
}
$album_set_array[] = $row['aid'];
}
}
}
if (count($album_set_array) && $cat) {
$set = '';
foreach ($album_set_array as $album) {
$set .= $album . ',';
}
$set = substr($set, 0, -1);
$current_album_set = "aid IN ({$set}) ";
} elseif ($cat) {
$current_album_set = "aid IN (-1) ";
}
// Gather gallery statistics
if ($cat == 0) {
$album_count = count(get_albums_data());
$picture_count = cpg_tablecount($CONFIG['TABLE_PICTURES'], 'count(*)', __FILE__, __LINE__);
$comment_count = cpg_tablecount($CONFIG['TABLE_COMMENTS'], 'count(*)', __FILE__, __LINE__);
$cat_count = count(get_categories_data());
$hit_count = cpg_tablecount($CONFIG['TABLE_PICTURES'], 'sum(hits)', __FILE__, __LINE__);
if (count($cat_data)) {
$statistics = strtr(STAT1, array('[pictures]' => $picture_count, '[albums]' => $album_count, '[cat]' => $cat_count, '[comments]' => $comment_count, '[views]' => $hit_count));
} else {
$STATS_IN_ALB_LIST = true;
$statistics = strtr(STAT3, array('[pictures]' => $picture_count, '[albums]' => $album_count, '[comments]' => $comment_count, '[views]' => $hit_count));
}
} elseif ($cat >= FIRST_USER_CAT && $current_album_set) {
$album_count = cpg_tablecount($CONFIG['TABLE_ALBUMS'] . " WHERE {$current_album_set}", 'count(*)', __FILE__, __LINE__);
$picture_count = cpg_tablecount($CONFIG['TABLE_PICTURES'] . " WHERE {$current_album_set}", 'count(*)', __FILE__, __LINE__);
$hit_count = cpg_tablecount($CONFIG['TABLE_PICTURES'] . " WHERE {$current_album_set}", 'sum(hits)', __FILE__, __LINE__);
$statistics = strtr(STAT2, array('[pictures]' => $picture_count, '[albums]' => $album_count, '[views]' => $hit_count));
} else {
$statistics = '';
}
}
示例15: form_category
function form_category($text, $name)
{
global $ALBUM_DATA, $CAT_LIST, $USER_DATA, $lang_modifyalb_php;
if (!GALLERY_ADMIN_MODE || $ALBUM_DATA['category'] > FIRST_USER_CAT) {
echo <<<EOT
<tr>
<td class="tableb">
{$text}
</td>
<td class="tableb" valign="top">
<i>{$lang_modifyalb_php['user_gal']}</i>
<input type="hidden" name="{$name}" value="{$ALBUM_DATA['category']}">
</td>
EOT;
return;
}
$CAT_LIST = array();
$CAT_LIST[] = array(0, $lang_modifyalb_php['no_cat']);
get_subcat_data(0, '');
echo <<<EOT
<tr>
<td class="tableb">
{$text}
</td>
<td class="tableb" valign="top">
<select name="{$name}" class="listbox">
EOT;
foreach ($CAT_LIST as $category) {
echo ' <option value="' . $category[0] . '"' . ($ALBUM_DATA['category'] == $category[0] ? ' selected' : '') . ">" . $category[1] . "</option>\n";
}
echo <<<EOT
</select>
</td>
</tr>
EOT;
}