$db->query($query); // Pêtla wyswietlaj¹ca wszystkie wpisy + stronnicowanie ich while ($db->next_record()) { $category_id = $db->f("category_id"); $category_order = $db->f("category_order"); $category_name = $db->f("category_name"); $category_description = $db->f("category_description"); $count = $db->f("count"); // obcinamy opis kategorii, jesli dluzszy niz 70 znakow $category_description = strlen($category_description) > 70 ? substr_replace($category_description, '...', 70) : $category_description; $ft->assign(array('CATEGORY_ID' => $category_id, 'CATEGORY_NAME' => $category_name, 'COUNT' => $count, 'CATEGORY_DESC' => empty($category_description) ? $i18n['edit_category'][4] : $category_description, 'STRING' => $page_string = empty($page_string) ? '' : $page_string)); if ($category_order == $max_order) { $ft->assign(array('REORDER_DOWN' => false, 'REORDER_UP' => true)); } elseif ($category_order == $min_order) { $ft->assign(array('REORDER_DOWN' => true, 'REORDER_UP' => false)); } else { $ft->assign(array('REORDER_DOWN' => true, 'REORDER_UP' => true)); } $ft->assign('STRING', $page_string); // deklaracja zmiennej $idx1::color switcher $idx1 = empty($idx1) ? '' : $idx1; $idx1++; $ft->define("editlist_category", "editlist_category.tpl"); $ft->define_dynamic("row", "editlist_category"); // naprzemienne kolorowanie wierszy tabeli $ft->assign('ID_CLASS', $idx1 % 2 ? 'mainList' : 'mainListAlter'); $ft->parse('ROWS', ".row"); get_editcategory_cat($category_id, 2); } $ft->parse('ROWS', "editlist_category"); }
function get_editcategory_cat($category_id, $level) { global $ft, $idx1, $count, $i18n; $lang = get_config('language_set'); $query = sprintf("\n SELECT \n a.*, count(b.id) AS count \n FROM \n %1\$s a \n LEFT JOIN \n %2\$s b \n ON \n a.category_id = b.category_id \n WHERE \n category_parent_id = '%3\$d'\n GROUP BY \n category_id \n ORDER BY \n category_id \n ASC", TABLE_CATEGORY, TABLE_ASSIGN2CAT, $category_id); $db = new DB_SQL(); $db->query($query); while ($db->next_record()) { $category_id = $db->f("category_id"); $category_name = $db->f("category_name"); $cat_parent_id = $db->f("category_parent_id"); $category_descrition = $db->f("category_description"); $count = $db->f("count"); $ft->assign(array('CATEGORY_ID' => $category_id, 'CATEGORY_NAME' => str_repeat(' ', $level) . '<img src="templates/' . $lang . '/images/ar.gif" /> ' . $category_name, 'COUNT' => $count, 'REORDER_DOWN' => false, 'REORDER_UP' => false, 'CATEGORY_DESC' => empty($category_description) ? $i18n['edit_category'][4] : $category_description)); // deklaracja zmiennej $idx1::color switcher $idx1 = empty($idx1) ? '' : $idx1; $idx1++; // naprzemienne kolorowanie wierszy tabeli $ft->assign('ID_CLASS', $idx1 % 2 ? 'mainList' : 'mainListAlter'); $ft->parse('ROWS', ".row"); get_editcategory_cat($category_id, $level + 2); } }