protected function _media_home() { global $bio; $sql = 'SELECT * FROM _bio_media WHERE media_bio = ? ORDER BY title'; if (!($media = sql_rowset(sql_filter($sql, $bio->v('bio_id'))))) { _style('empty', array('MESSAGE' => _lang('CONTROL_A_DOWNLOADS_EMPTY'))); } $downloads_type = array(1 => '/net/icons/browse.gif', 2 => '/net/icons/store.gif'); $col = 0; foreach ($media as $i => $row) { if (!$i) { _style('downloads'); } if (!$col) { _style('downloads.row'); } _style('downloads.row.col', array('ITEM' => $row->media_id, 'URL' => _link_control('a', array('a' => $this->data['subdomain'], 'mode' => $this->mode, 'manage' => 'edit', 'd' => $row['id'])), 'POSTS_URL' => _link('a', array($this->data['subdomain'], 9, $row['id'])) . '#dpf', 'IMAGE_TYPE' => $downloads_type[$row['ud']], 'DOWNLOAD_TITLE' => $row['title'], 'VIEWS' => $row['views'], 'DOWNLOADS' => $row['downloads'], 'POSTS' => $row['posts'])); $col = $col == 2 ? 0 : $col + 1; } return; }
function _help_edit() { global $bio, $core; $error = array(); $sub = $this->control->get_var('sub', ''); $id = $this->control->get_var('id', 0); $submit = isset($_POST['submit']) ? true : false; switch ($sub) { case 'cat': $sql = 'SELECT c.*, m.* FROM _help_cat c, _help_modules m WHERE c.help_id = ' . (int) $id . ' AND c.help_module = m.module_id'; $result = $db->sql_query($sql); if (!($cat_data = $db->sql_fetchrow($result))) { fatal_error(); } $db->sql_freeresult($result); $order = $this->control->get_var('order', ''); if (!empty($order)) { if (preg_match('/_([0-9]+)/', $order)) { $sig = '-'; $order = str_replace('_', '', $order); } else { $sig = '+'; } $sql = 'UPDATE _help_cat SET help_order = help_order ' . $sig . ' ' . (int) $order . ' WHERE help_id = ' . (int) $id; $db->sql_query($sql); $this->_help_edit_move(); $cache->unload('help_cat'); redirect(_link_control('comments', array('mode' => $this->mode))); } // IF order $module_id = $cat_data['help_module']; $help_es = $cat_data['help_es']; $help_en = $cat_data['help_en']; break; case 'faq': $sql = 'SELECT * FROM _help_faq WHERE faq_id = ' . (int) $id; $result = $db->sql_query($sql); if (!($faq_data = $db->sql_fetchrow($result))) { fatal_error(); } $db->sql_freeresult($result); $question_es = $faq_data['faq_question_es']; $question_en = $faq_data['faq_question_en']; $answer_es = $faq_data['faq_answer_es']; $answer_en = $faq_data['faq_answer_en']; $help_id = $faq_data['help_id']; break; default: redirect(_link_control('comments', array('mode' => $this->mode))); break; } // IF submit if ($submit) { switch ($sub) { case 'cat': $module_id = $this->control->get_var('module_id', 0); $help_es = $this->control->get_var('help_es', ''); $help_en = $this->control->get_var('help_en', ''); if (empty($help_es) || empty($help_en)) { $error[] = 'CONTROL_COMMENTS_HELP_EMPTY'; } // Update if (!sizeof($error)) { $sql_update = array('help_es' => $help_es, 'help_en' => $help_en, 'help_module' => (int) $module_id); $sql = 'UPDATE _help_cat SET ' . $db->sql_build_array('UPDATE', $sql_update) . ' WHERE help_id = ' . (int) $id; $db->sql_query($sql); $cache->unload('help_cat'); redirect(_link_control('comments', array('mode' => $this->mode))); } break; case 'faq': $question_es = $this->control->get_var('question_es', ''); $question_en = $this->control->get_var('question_en', ''); $answer_es = $this->control->get_var('answer_es', ''); $answer_en = $this->control->get_var('answer_en', ''); $help_id = $this->control->get_var('help_id', 0); if (empty($question_es) || empty($question_en) || empty($answer_es) || empty($answer_en)) { $error[] = 'CONTROL_COMMENTS_HELP_EMPTY'; } if (!sizeof($error)) { $sql = 'SELECT * FROM _help_cat WHERE help_id = ' . (int) $help_id; $result = $db->sql_query($sql); if (!($cat_data = $db->sql_fetchrow($result))) { $error[] = 'CONTROL_COMMENTS_HELP_NOCAT'; } } // Update if (!sizeof($error)) { $sql_update = array('help_id' => (int) $help_id, 'faq_question_es' => $question_es, 'faq_question_en' => $question_en, 'faq_answer_es' => $answer_es, 'faq_answer_en' => $answer_en); $sql = 'UPDATE _help_faq SET ' . $db->sql_build_array('UPDATE', $sql_update) . ' WHERE faq_id = ' . (int) $id; $db->sql_query($sql); $cache->unload('help_faq'); redirect(_link_control('comments', array('mode' => $this->mode))); } break; } // switch if (sizeof($error)) { _style('error', array('MESSAGE' => parse_error($error))); } } $this->nav(); $this->control->set_nav(array('mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub, 'id' => $id), 'CONTROL_EDIT'); $template_vars = array('SUB' => $sub, 'S_HIDDEN' => _hidden(array('module' => $this->control->module, 'mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub, 'id' => $id))); switch ($sub) { case 'cat': $sql = 'SELECT * FROM _help_modules ORDER BY module_id'; $result = $db->sql_query($sql); $select_mod = ''; while ($row = $db->sql_fetchrow($result)) { $selected = $row['module_id'] == $module_id; $select_mod .= '<option' . ($selected ? ' class="bold"' : '') . ' value="' . $row['module_id'] . '"' . ($selected ? ' selected' : '') . '>' . $row['module_name'] . '</option>'; } $db->sql_freeresult($result); $sv += array('MODULE' => $select_mod, 'HELP_ES' => $help_es, 'HELP_EN' => $help_en); break; case 'faq': $sql = 'SELECT * FROM _help_cat ORDER BY help_id'; $result = $db->sql_query($sql); $select_cat = ''; while ($row = $db->sql_fetchrow($result)) { $selected = $row['help_id'] == $help_id; $select_cat .= '<option' . ($selected ? ' class="bold"' : '') . ' value="' . $row['help_id'] . '"' . ($selected ? ' selected' : '') . '>' . $row['help_es'] . ' | ' . $row['help_en'] . '</option>'; } $db->sql_freeresult($result); $sv += array('CATEGORY' => $select_cat, 'QUESTION_ES' => $question_es, 'QUESTION_EN' => $question_en, 'ANSWER_ES' => $answer_es, 'ANSWER_EN' => $answer_en); break; } v_style($sv); return; }