Exemple #1
0
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 . '   ');
        }
    }
}
Exemple #2
0
/**
 * 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>";
            }
        }
    }
}
Exemple #3
0
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 . '&nbsp;&nbsp;&nbsp;');
        }
    }
}
Exemple #4
0
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 . '&nbsp;&nbsp;&nbsp;');
        }
    }
}
Exemple #5
0
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);
        }
    }
}
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);
        }
    }
}
Exemple #7
0
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 . '&nbsp;&nbsp;&nbsp;');
        }
    }
}
Exemple #8
0
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 . '&nbsp;&nbsp;&nbsp;');
        }
    }
}
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;
}
Exemple #10
0
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;
}
Exemple #11
0
/**
 * 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;
}
Exemple #12
0
/**
 * 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);
            $hit_count = (int) $nbEnr[0];
            mysql_free_result($result);
            $statistics = strtr($lang_list_categories['stat2'], array('[pictures]' => $picture_count, '[albums]' => $album_count, '[views]' => $hit_count));
        } else {
            $statistics = '';
        }
    } else {
        // Gather gallery statistics - end
        $statistics = '';
    }
}
Exemple #13
0
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("&amp;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;
}
Exemple #14
0
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 = '';
    }
}
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;
}
Exemple #16
0
/**
 * 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, $BREADCRUMB_TEXT, $STATS_IN_ALB_LIST, $FORBIDDEN_SET;
    global $HIDE_USER_CAT, $cpg_show_private_album;
    global $cat;
    global $lang_list_categories;
    // Build the breadcrumb
    breadcrumb($cat, $breadcrumb, $BREADCRUMB_TEXT);
    // Build the category list
    $cat_data = array();
    get_subcat_data($cat_data);
    $album_filter = '';
    $pic_filter = '';
    $cat = (int) $cat;
    if (!empty($FORBIDDEN_SET) && !$cpg_show_private_album) {
        $album_filter = ' ' . str_replace('p.', 'a.', $FORBIDDEN_SET);
        $pic_filter = $FORBIDDEN_SET;
    }
    // Gather gallery statistics - start
    if ($CONFIG['display_stats_on_index'] != 0) {
        if ($cat == 0) {
            $result = cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_ALBUMS']} AS a WHERE 1 " . $album_filter);
            $nbEnr = $result->fetchRow(true);
            $album_count = $nbEnr[0];
            $sql = "SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']}";
            if ($pic_filter) {
                $sql .= " AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE approved = 'YES' {$pic_filter}";
            } else {
                $sql .= " WHERE approved = 'YES'";
            }
            $result = cpg_db_query($sql);
            $nbEnr = $result->fetchRow(true);
            $picture_count = $nbEnr[0];
            $sql = "SELECT COUNT(*) FROM {$CONFIG['TABLE_COMMENTS']}";
            if ($pic_filter) {
                $sql .= " AS c INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.pid = c.pid INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE 1 {$pic_filter}";
            }
            if ($CONFIG['comment_approval']) {
                if ($pic_filter) {
                    $sql .= " AND approval = 'YES'";
                } else {
                    $sql .= " WHERE approval = 'YES'";
                }
            }
            $result = cpg_db_query($sql);
            $nbEnr = $result->fetchRow(true);
            $comment_count = $nbEnr[0];
            $sql = "SELECT COUNT(*) FROM {$CONFIG['TABLE_CATEGORIES']}";
            $result = cpg_db_query($sql);
            $nbEnr = $result->fetchRow(true);
            $cat_count = $nbEnr[0] - $HIDE_USER_CAT;
            $sql = "SELECT SUM(hits) FROM {$CONFIG['TABLE_PICTURES']}";
            if ($pic_filter) {
                $sql .= " AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE approved = 'YES' {$pic_filter}";
            } else {
                $sql .= " WHERE approved = 'YES'";
            }
            $result = cpg_db_query($sql);
            $nbEnr = $result->fetchRow(true);
            $hit_count = (int) $nbEnr[0];
            if (count($cat_data)) {
                $statistics = strtr($lang_list_categories['stat1'], array('[pictures]' => '<strong>' . cpg_float2decimal($picture_count) . '</strong>', '[albums]' => '<strong>' . cpg_float2decimal($album_count) . '</strong>', '[cat]' => '<strong>' . cpg_float2decimal($cat_count) . '</strong>', '[comments]' => '<strong>' . cpg_float2decimal($comment_count) . '</strong>', '[views]' => '<strong>' . cpg_float2decimal($hit_count) . '</strong>'));
            } else {
                $STATS_IN_ALB_LIST = true;
                $statistics = strtr($lang_list_categories['stat3'], array('[pictures]' => '<strong>' . cpg_float2decimal($picture_count) . '</strong>', '[albums]' => '<strong>' . cpg_float2decimal($album_count) . '</strong>', '[comments]' => '<strong>' . cpg_float2decimal($comment_count) . '</strong>', '[views]' => '<strong>' . cpg_float2decimal($hit_count) . '</strong>'));
            }
        } else {
            $statistics = '';
        }
    } else {
        // Gather gallery statistics - end
        $statistics = '';
    }
}
Exemple #17
0
        if (!$result->numRows()) {
            cpg_die(ERROR, $lang_catmgr_php['unknown_cat'], __FILE__, __LINE__);
        }
        $del_category = $result->fetchAssoc(true);
        $parent = $del_category['parent'];
        cpg_db_query("UPDATE {$CONFIG['TABLE_CATEGORIES']} SET parent = {$parent}, lft = 0 WHERE parent = {$cid}");
        cpg_db_query("UPDATE {$CONFIG['TABLE_ALBUMS']} SET category = {$parent} WHERE category = {$cid}");
        cpg_db_query("DELETE FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = {$cid}");
        //delete from categorymap
        cpg_db_query("DELETE FROM {$CONFIG['TABLE_CATMAP']} WHERE cid = {$cid}");
        break;
}
if ($op) {
    check_rebuild_tree();
}
get_subcat_data(0);
pageheader($lang_catmgr_php['manage_cat']);
starttable('100%', cpg_fetch_icon('cat_mgr', 2) . $lang_catmgr_php['category'] . '&nbsp;' . cpg_display_help('f=categories.htm&amp;as=cat_cp&amp;ae=cat_cp_end&amp;top=1', '800', '600'), 1);
echo <<<EOT
    <tr>
        <td class="tableb">
EOT;
starttable('100%');
// configure sort category alphabetically
$yes_selected = $CONFIG['categories_alpha_sort'] ? 'checked="checked"' : '';
$no_selected = !$CONFIG['categories_alpha_sort'] ? 'checked="checked"' : '';
$help = '&nbsp;' . cpg_display_help('f=configuration.htm&amp;as=admin_album_list_alphasort_start&amp;ae=admin_album_list_alphasort_end&amp;top=1', '600', '250');
echo <<<EOT
        <tr>
            <td class="tablef" colspan="8">
                        <form name="catsortconfig" action="{$CPG_PHP_SELF}" method="post">
Exemple #18
0
function get_cat_list(&$breadcrumb, &$cat_data, &$statistics)
{
    global $_GET, $xoopsModuleConfig, $ALBUM_SET, $CURRENT_CAT_NAME, $BREADCRUMB_TEXT, $STATS_IN_ALB_LIST;
    global $HIDE_USER_CAT;
    global $xoopsDB, $xoopsModule;
    $cat = isset($_GET['cat']) ? (int) $_GET['cat'] : 0;
    // 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, $xoopsModuleConfig['subcat_level']);
    // Treat the album set
    if ($cat) {
        if ($cat == USER_GAL_CAT) {
            $result = $xoopsDB->query("SELECT aid FROM " . $xoopsDB->prefix("xcgal_albums") . " WHERE category >= " . FIRST_USER_CAT);
        } else {
            $result = $xoopsDB->query("SELECT aid FROM " . $xoopsDB->prefix("xcgal_albums") . " WHERE category = '{$cat}'");
        }
        while ($row = $xoopsDB->fetchArray($result)) {
            $album_set_array[] = $row['aid'];
        }
        // while
        $xoopsDB->freeRecordSet($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
    if ($cat == 0) {
        $result = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix("xcgal_albums") . " WHERE 1");
        $album_count = $xoopsDB->getRowsNum($result);
        $xoopsDB->freeRecordSet($result);
        $result = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix("xcgal_pictures") . " WHERE 1 AND approved='YES'");
        $picture_count = $xoopsDB->getRowsNum($result);
        $xoopsDB->freeRecordSet($result);
        $comment_count = xoops_comment_count($xoopsModule->mid());
        $result = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix("xcgal_categories") . " WHERE 1");
        $cat_count = $xoopsDB->getRowsNum($result) - $HIDE_USER_CAT;
        $xoopsDB->freeRecordSet($result);
        $result = $xoopsDB->query("SELECT sum(hits) FROM " . $xoopsDB->prefix("xcgal_pictures") . " WHERE 1");
        $nbEnr = $xoopsDB->fetchArray($result);
        $hit_count = (int) $nbEnr['sum(hits)'];
        $xoopsDB->freeRecordSet($result);
        if (count($cat_data)) {
            $statistics = strtr(_MD_INDEX_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(_MD_INDEX_STAT3, array('[pictures]' => $picture_count, '[albums]' => $album_count, '[comments]' => $comment_count, '[views]' => $hit_count));
        }
    } elseif ($cat >= FIRST_USER_CAT && $ALBUM_SET) {
        $result = $xoopsDB->query("SELECT count(*) FROM " . $xoopsDB->prefix("xcgal_albums") . " WHERE 1 {$current_album_set}");
        $nbEnr = $xoopsDB->fetchArray($result);
        $album_count = $nbEnr['count(*)'];
        $xoopsDB->freeRecordSet($result);
        $result = $xoopsDB->query("SELECT count(*) FROM " . $xoopsDB->prefix("xcgal_pictures") . " WHERE 1 {$current_album_set}");
        $nbEnr = $xoopsDB->fetchArray($result);
        $picture_count = $nbEnr['count(*)'];
        $xoopsDB->freeRecordSet($result);
        $result = $xoopsDB->query("SELECT sum(hits) FROM " . $xoopsDB->prefix("xcgal_pictures") . " WHERE 1 {$current_album_set}");
        $nbEnr = $xoopsDB->fetchArray($result);
        $hit_count = (int) $nbEnr['sum(hits)'];
        $xoopsDB->freeRecordSet($result);
        $statistics = strtr(_MD_INDEX_STAT2, array('[pictures]' => $picture_count, '[albums]' => $album_count, '[views]' => $hit_count));
    } else {
        $statistics = '';
    }
}