function select_categories($categories, $cat_id, $current_cat_id, $exclude, $depth = 0) { if ($cat_id == 0 && is_array($categories[0])) { foreach ($categories[0] as $child_cat_id) { select_categories($categories, $child_cat_id, $current_cat_id, $exclude); } } else { if ($exclude && $cat_id == $current_cat_id) { return; } echo '<option value="' . $cat_id . '"'; if ($exclude && is_array($categories[$cat_id]['children']) && in_array($current_cat_id, $categories[$cat_id]['children'])) { echo ' selected="selected"'; } else { if (!$exclude && $cat_id == $current_cat_id) { echo ' selected="selected"'; } } echo '>'; echo str_repeat(" ", $depth * 4); echo validate_length($categories[$cat_id]['cat_name'], 45, VALIDATE_LENGTH_FOR_DISPLAY) . '</option>'; if (isset($categories[$cat_id]['children']) && is_array($categories[$cat_id]['children'])) { foreach ($categories[$cat_id]['children'] as $child_cat_id) { select_categories($categories, $child_cat_id, $current_cat_id, $exclude, $depth + 1); } } } }
$sql_search = '1'; } $sql = "SELECT * FROM " . TABLE_PREFIX . "courses WHERE access {$sql_access} AND cat_id {$sql_category} AND {$sql_search} AND hide=0 ORDER BY title"; $rows_courses_cats = queryDB($sql, array(TABLE_PREFIX)); // calculate number of results found $num_results = count($rows_courses_cats); foreach ($rows_courses_cats as $row) { if (in_array($row['course_id'], $existing_courses)) { $num_results--; } } // get the categories <select>, if there are any. // we need ob_start/ob_clean, because select_categories() outputs directly. // we do this so that if there are no categories, then the option doesn't appear. ob_start(); select_categories(get_categories(), 0, $_POST['category'], false); $categories_select = ob_get_contents(); ob_clean(); $has_categories = false; if ($categories_select != '<option value="0"></option>') { $has_categories = true; } ?> <div class="input-form" style="width:95%;"> <div class="row"> <h4><?php echo _AT('results_found', $num_results); ?> </h4> </div>
?> </label><br /> <select name="cat_parent_id" id="category_parent"><?php if ($pcat_id) { $current_cat_id = $pcat_id; $exclude = false; /* don't exclude the children */ } else { $current_cat_id = $cat_id; $exclude = true; /* exclude the children */ } echo '<option value="0"> [ ' . _AT('cats_none') . ' ] </option>'; echo '<option value="0"></option>'; /* @See: include/lib/admin_categories */ select_categories($categories, 0, $current_cat_id, $exclude); ?> </select> </div> <?php if (defined('AT_ENABLE_CATEGORY_THEMES') && AT_ENABLE_CATEGORY_THEMES) { ?> <div class="row"> <label for="category_theme"><?php echo _AT('cat_theme'); ?> </label><br /> <select name="cat_theme" id="category_theme"><?php echo '<option value="0"> [ ' . _AT('cats_none') . ' ] </option>'; $_themes = get_enabled_themes();
?> <?php if (is_array($categories)) { ?> <div class="row"> <label for="cat"><?php echo _AT('category'); ?> </label><br /> <select name="category_parent" id="cat"> <option value="0"> [ <?php echo _AT('cats_uncategorized'); ?> ] </option> <?php select_categories($categories, 0, $this->row['cat_id'], false); ?> </select> </div> <?php } ?> <div class="row"> <fieldset> <legend><?php echo _AT('export_content'); ?> </legend> <?php
// 名簿を取得 if (empty($_GET['class_id'])) { $where = null; } else { $where = array('members.class_id = :class_id', array('class_id' => $_GET['class_id'])); } $_view['members'] = select_members(array('where' => $where, 'order_by' => 'id', 'limit' => array(':offset, :limit', array('offset' => $GLOBALS['config']['limits']['member'] * ($_GET['page'] - 1), 'limit' => $GLOBALS['config']['limits']['member']))), array('associate' => true)); $_view['member_count'] = select_members(array('select' => 'COUNT(DISTINCT members.id) AS count', 'where' => $where), array('associate' => true)); $_view['member_count'] = $_view['member_count'][0]['count']; $_view['member_page'] = ceil($_view['member_count'] / $GLOBALS['config']['limits']['member']); // 教室を取得 $classes = select_classes(array('order_by' => 'sort, id')); $class_sets = array(); foreach ($classes as $class) { $class_sets[$class['id']] = $class; } $_view['class_sets'] = $class_sets; $_view['classes'] = $classes; // 分類を取得 $categories = select_categories(array('order_by' => 'sort, id')); $category_sets = array(); foreach ($categories as $category) { $category_sets[$category['id']] = $category; } $_view['category_sets'] = $category_sets; $_view['categories'] = $categories; // ページャー $pager = ui_pager(array('key' => 'page', 'count' => $_view['member_count'], 'size' => $GLOBALS['config']['limits']['member'], 'width' => $GLOBALS['config']['pagers']['member'], 'query' => '?class_id=' . $_GET['class_id'] . '&')); $_view['member_pager'] = $pager['first'] . ' ' . $pager['back'] . ' ' . implode(' | ', $pager['pages']) . ' ' . $pager['next'] . ' ' . $pager['last']; // タイトル $_view['title'] = '名簿一覧';
} } if (isset($_GET['_type']) && $_GET['_type'] === 'json') { // 名簿情報を取得 header('Content-Type: application/json; charset=' . MAIN_CHARSET); echo json_encode(array('status' => 'OK', 'data' => $_view, 'files' => array('image_01' => $_view['member']['image_01'] ? file_mimetype($_view['member']['image_01']) : null, 'image_02' => $_view['member']['image_02'] ? file_mimetype($_view['member']['image_02']) : null))); exit; } else { // 投稿セッションを初期化 unset($_SESSION['post']); unset($_SESSION['file']); } // 編集開始日時を記録 if (!empty($_GET['id'])) { $_SESSION['update']['member'] = localdate('Y-m-d H:i:s'); } } if (empty($_POST['view']) || $_POST['view'] !== 'preview') { // 名簿の表示用データ作成 $_view['member'] = view_members($_view['member']); } // 教室を取得 $_view['classes'] = select_classes(array('order_by' => 'sort, id')); // 分類を取得 $_view['categories'] = select_categories(array('order_by' => 'sort, id')); // タイトル if (empty($_GET['id'])) { $_view['title'] = '名簿登録'; } else { $_view['title'] = '名簿編集'; }
} else { if (empty($warnings)) { $_SESSION['post']['category'] = $post['category']; // フォワード forward('/admin/category_post'); } else { $_view['category'] = $post['category']; $_view['warnings'] = $warnings; } } } else { // 初期データを取得 if (empty($_GET['id'])) { $_view['category'] = default_categories(); } else { $categories = select_categories(array('where' => array('id = :id', array('id' => $_GET['id'])))); if (empty($categories)) { warning('編集データが見つかりません。'); } else { $_view['category'] = $categories[0]; } } // 投稿セッションを初期化 unset($_SESSION['post']); // 編集開始日時を記録 if (!empty($_GET['id'])) { $_SESSION['update']['category'] = localdate('Y-m-d H:i:s'); } } // タイトル if (empty($_GET['id'])) {