function board_admin_list($statusText = '') { global $_CONF, $_TABLES, $_FF_CONF, $LANG_ADMIN, $LANG_GF93, $LANG_GF01, $LANG_GF00, $LANG_GF91, $LANG_GF06; $retval = ''; $selected = ''; $menu_arr = array(); $boards = new Template($_CONF['path'] . 'plugins/forum/templates/admin/'); $boards->set_file('boards', 'boards.thtml'); $boards->set_var('block_start', COM_startBlock($LANG_GF06[10], '', COM_getBlockTemplate('_admin_block', 'header'))); $menu_arr = FF_adminNav($LANG_GF06['3']); $boards->set_var('admin_menu', ADMIN_createMenu($menu_arr, $LANG_GF00['instructions'], $_CONF['site_url'] . '/forum/images/forum.png')); $boards->set_var(array('s_form_action' => $_CONF['site_admin_url'] . '/plugins/forum/boards.php', 'lang_addcat' => $LANG_GF93['addcat'], 'lang_cat' => $LANG_GF01['category'], 'lang_edit' => $LANG_GF01['EDIT'], 'lang_delete' => $LANG_GF01['DELETE'], 'lang_topic' => $LANG_GF01['TOPIC'], 'LANG_posts' => $LANG_GF93['posts'], 'LANG_order' => $LANG_GF93['ordertitle'], 'lang_catorder' => $LANG_GF93['catorder'], 'LANG_action' => $LANG_GF93['action'], 'LANG_forumdesc' => $LANG_GF93['forumdescription'], 'lang_addforum' => $LANG_GF93['addforum'], 'lang_addcat' => $LANG_GF93['addcat'], 'lang_description' => $LANG_GF01['DESCRIPTION'], 'lang_resync' => $LANG_GF01['RESYNC'], 'lang_edit' => $LANG_GF01['EDIT'], 'lang_resync_cat' => $LANG_GF01['RESYNCCAT'], 'lang_delete' => $LANG_GF01['DELETE'], 'lang_submit' => $LANG_GF01['SUBMIT'], 'phpself' => $_CONF['site_admin_url'] . '/plugins/forum/boards.php', 'addcat' => $LANG_GF93['addcat'], 'cat' => $LANG_GF01['category'], 'edit' => $LANG_GF01['EDIT'], 'delete' => $LANG_GF01['DELETE'], 'topic' => $LANG_GF01['TOPIC'], 'catorder' => $LANG_GF93['catorder'], 'addforum' => $LANG_GF93['addforum'], 'addcat' => $LANG_GF93['addcat'], 'description' => $LANG_GF01['DESCRIPTION'], 'resync' => $LANG_GF01['RESYNC'], 'edit' => $LANG_GF01['EDIT'], 'resync_cat' => $LANG_GF01['RESYNCCAT'], 'delete' => $LANG_GF01['DELETE'], 'submit' => $LANG_GF01['SUBMIT'])); if (!empty($statusText)) { $boards->set_var('status_text', $statusText); } // Display each Forum Category $cat_sql = DB_query("SELECT * FROM {$_TABLES['ff_categories']} ORDER BY cat_order"); while ($C = DB_fetchArray($cat_sql)) { $boards->set_var('catid', $C['id']); $boards->set_var('catname', $C['cat_name']); $boards->set_var('order', $C['cat_order']); // Display each forum within this category $forum_sql_result = DB_query("SELECT * FROM {$_TABLES['ff_forums']} WHERE forum_cat=" . (int) $C['id'] . " ORDER BY forum_order"); $forum_number_of_rows = DB_numRows($forum_sql_result); $boards->set_block('boards', 'catrows', 'crow'); $boards->clear_var('frow'); $boards->set_block('boards', 'forumrows', 'frow'); for ($j = 1; $j <= $forum_number_of_rows; $j++) { $F = DB_fetchArray($forum_sql_result); $boards->set_var(array('forumname' => $F['forum_name'], 'forumid' => $F['forum_id'], 'messagecount' => $F['post_count'], 'forumorder' => $F['forum_order'])); // Check if this is a private forum if ($F['grp_id'] != '2') { $grp_name = DB_getItem($_TABLES['groups'], 'grp_name', "grp_id=" . (int) $F['grp_id']); $boards->set_var('forumdscp', "[{$LANG_GF93['private']} - {$grp_name}]<br/>{$F['forum_dscp']}"); } else { $boards->set_var('forumdscp', $F['forum_dscp']); } $boards->parse('frow', 'forumrows', true); } $boards->parse('crow', 'catrows', true); } $boards->set_var('block_end', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'))); $boards->parse('output', 'boards'); $retval .= $boards->finish($boards->get_var('output')); return $retval; }
public function testClearVarHashMultiple() { $tp2 = new Template(); $hash = array('test1' => 'test41', 'test2' => 'test42'); $tp2->set_var($hash); $this->assertEquals("test41", $tp2->get_var('test1')); $this->assertEquals("test42", $tp2->get_var('test2')); $hash2 = array('test1', 'test2'); $tp2->clear_var($hash2); $this->assertEquals("", $tp2->get_var('test1')); $this->assertEquals("", $tp2->get_var('test2')); }
$sql .= 'WHERE `directory` = "' . $section['module'] . '"'; if (!$database->get_one($sql) || !file_exists(LEPTON_PATH . '/modules/' . $section['module'])) { $edit_page = '<span class="module_disabled">' . $section['module'] . '</span>'; } else { $edit_page = ''; } $edit_page_0 = '<a id="sid' . $section['section_id'] . '" href="' . ADMIN_URL . '/pages/modify.php?page_id=' . $page_id; $edit_page_1 = $section['section_id'] . '">' . $section['module'] . '</a>'; if (SECTION_BLOCKS) { if ($edit_page == '') { $edit_page = $edit_page_0 . '#' . SEC_ANCHOR . $edit_page_1; } $input_attribute = 'input_normal'; $template->set_var(array('STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:visible;"', 'NAME_SIZE' => 300, 'INPUT_ATTRIBUTE' => $input_attribute, 'VAR_SECTION_ID' => $section['section_id'], 'VAR_POSITION' => $section['position'], 'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page, 'SELECT' => '', 'SET_NONE_DISPLAY_OPTION' => '')); // Add block options to the section_list $template->clear_var('block_list'); foreach ($block as $number => $name) { $template->set_var('NAME', htmlentities(strip_tags($name))); $template->set_var('VALUE', $number); $template->set_var('SIZE', 1); if ($section['block'] == $number) { $template->set_var('SELECTED', ' selected="selected"'); } else { $template->set_var('SELECTED', ''); } $template->parse('block_list', 'block_block', true); } } else { if ($edit_page == '') { $edit_page = $edit_page_0 . '#' . SEC_ANCHOR . $edit_page_1; }
echo "[[LibInclude?lib=" . $parts[0] . "&plugin=" . $parts[2] . "]]"; } elseif (file_exists(WB_PATH . '/modules/jqueryadmin/plugins/' . $settings['lightbox'] . '/foldergallery_template.htt')) { $viewTemplate = 'foldergallery_template.htt'; $t = new Template(WB_PATH . '/modules/jqueryadmin/plugins/' . $settings['lightbox'], 'remove'); echo "[[jQueryInclude?plugin=" . $settings['lightbox'] . "]]"; } else { $viewTemplate = 'view.htt'; // --- added by WebBird, 29.07.2010 --- $t = new Template(dirname(__FILE__) . '/templates', 'remove'); // --- end added by WebBird, 29.07.2010 --- } // --- commented by WebBird, 29.07.2010 --- $t->halt_on_error = 'no'; $t->set_file('view', $viewTemplate); $t->set_block('view', 'CommentDoc'); $t->clear_var('CommentDoc'); $t->set_block('view', 'categories', 'CATEGORIES'); $t->set_block('categories', 'show_categories', 'SHOW_CATEGORIES'); $t->set_block('view', 'images', 'IMAGES'); $t->set_block('images', 'thumbnails', 'THUMBNAILS'); $t->set_block('images', 'invisiblePre', 'INVISIBLEPRE'); // Für weitere Bilder $t->set_block('images', 'invisiblePost', 'INVISIBLEPOST'); $t->set_block('view', 'hr', 'HR'); $t->set_block('view', 'error', 'ERROR'); // Dieser Fehler wird nicht ausgegeben, BUG $t->set_block('view', 'pagenav', 'PAGE_NAV'); // As the error reporting is not implemented in the frontend, set error to false $error = false; if ($error) { $t->set_var('FRONT_END_ERROR_STRING', $MOD_FOLDERGALLERY['FRONT_END_ERROR']);
/** * Display a yearly calendar. * Dates that have events scheduled are highlighted. * * @param integer $year Year to display, default is current year * @param integer $month Starting month * @param integer $day Starting day * @param integer $cat Category to show * @param integer $cal Calendar to show * @return string HTML for calendar page */ function EVLIST_yearview($year = 0, $month = 0, $day = 0, $cat = 0, $cal = 0, $opt = '') { global $_CONF, $_EV_CONF, $LANG_MONTH; EVLIST_setViewSession('year', $year, $month, $day); $retval = ''; // Default to the current year if ($year == 0) { $year = date('Y'); } if ($month == 0) { $month = date('m'); } if ($day == 0) { $day = date('d'); } $cat = (int) $cat; $cal = (int) $cal; // Get all the dates in the year $starting_date = date('Y-m-d', mktime(0, 0, 0, 1, 1, $year)); $ending_date = date('Y-m-d', mktime(0, 0, 0, 1, 1, $year + 1)); $calendarView = Date_Calc::getCalendarYear($year, '%Y-%m-%d'); $daynames = EVLIST_getDayNames(1); $events = EVLIST_getEvents($starting_date, $ending_date, array('cat' => $cat, 'cal' => $cal)); $T = new Template(EVLIST_PI_PATH . '/templates/yearview'); $tpl = 'yearview'; if ($opt == 'print') { $tpl .= '_print'; } elseif ($_EV_CONF['cal_tmpl'] == 'json') { $tpl .= '_json'; } $T->set_file(array('yearview' => $tpl . '.thtml')); $count = 0; $T->set_block('yearview', 'month', 'mBlock'); foreach ($calendarView as $monthnum => $monthdata) { $monthnum_str = sprintf("%02d", $monthnum + 1); $count++; if (($count - 1) % 4 == 0) { $T->set_var('st_row', 'true'); } else { $T->clear_var('st_row'); } $M = new Template($_CONF['path'] . 'plugins/evlist/templates/yearview'); $M->set_file(array('smallmonth' => 'smallmonth.thtml')); $M->set_var('thisyear', $year); $M->set_var('month', $monthnum + 1); $M->set_var('monthname', $LANG_MONTH[$monthnum + 1]); $M->set_block('smallmonth', 'daynames', 'nBlock'); for ($i = 0; $i < 7; $i++) { $M->set_var('dayname', $daynames[$i]); $M->parse('nBlock', 'daynames', true); } $M->set_block('smallmonth', 'week', 'wBlock'); foreach ($monthdata as $weeknum => $weekdata) { list($weekYear, $weekMonth, $weekDay) = explode('-', $weekdata[0]); $M->set_var(array('weekyear' => $weekYear, 'weekmonth' => $weekMonth, 'weekday' => $weekDay, 'urlfilt_cat' => $cat, 'urlfilt_cal' => $cal)); $M->set_block('smallmonth', 'day', 'dBlock'); foreach ($weekdata as $daynum => $daydata) { list($y, $m, $d) = explode('-', $daydata); $M->clear_var('no_day_link'); if ($daydata == $_EV_CONF['_today']) { $dayclass = 'today'; } elseif ($m == $monthnum_str) { $dayclass = 'on'; } else { $M->set_var('no_day_link', 'true'); $dayclass = 'off'; } if (isset($events[$daydata])) { // Create the mootip hover text $popup = ''; $daylinkclass = $dayclass == 'off' ? 'nolink-events' : 'day-events'; foreach ($events[$daydata] as $event) { // Separate events by a line (if more than one) if (!empty($popup)) { $popup .= '<hr />' . LB; } // Don't show a time for all-day events if ($event['allday'] == 0) { $popup .= date($_CONF['timeonly'], strtotime($event['date_start'] . ' ' . $event['time_start1'])) . ': '; } $popup .= htmlentities($event['title']); } $M->set_var('popup', $popup); } else { $daylinkclass = 'day-noevents'; $M->clear_var('popup'); } $M->set_var(array('daylinkclass' => $daylinkclass, 'dayclass' => $dayclass, 'day' => substr($daydata, 8, 2), 'pi_url' => EVLIST_URL, 'urlfilt_cat' => $cat, 'urlfilt_cal' => $cal)); $M->parse('dBlock', 'day', true); } $M->parse('wBlock', 'week', true); $M->clear_var('dBlock'); } $M->parse('onemonth', 'smallmonth'); $T->set_var('month', $M->finish($M->get_var('onemonth'))); if ($count % 4 == 0) { $T->set_var('end_row', 'true'); } else { $T->clear_var('end_row'); } $T->parse('mBlock', 'month', true); } $T->set_var(array('pi_url' => EVLIST_URL, 'thisyear' => $year, 'prevyear' => $year - 1, 'nextyear' => $year + 1, 'cal_header' => EVLIST_calHeader($year, $month, $day, 'year', $cat, $cal), 'cal_footer' => EVLIST_calFooter($calendars_used), 'urlfilt_cat' => $cat, 'urlfilt_cal' => $cal)); $T->parse('output', 'yearview'); return $T->finish($T->get_var('output')); }
echo $section_id; ?> '; } window.setTimeout("Weiterleitung()", 2000); // in msecs 1000 => eine Sekunde </script> <?php echo "<div class=\"info\">" . $MOD_FOLDERGALLERY['REDIRECT'] . "\n</div>\n"; } else { // Template $t = new Template(dirname(__FILE__) . '/admin/templates', 'remove'); $t->halt_on_error = 'no'; $t->set_file('modify', 'modify.htt'); // clear the comment-block, if present $t->set_block('modify', 'CommentDoc'); $t->clear_var('CommentDoc'); $t->set_block('modify', 'ListElement', 'LISTELEMENT'); $t->clear_var('ListElement'); // Löschen, da dies über untenstehende Funktion erledigt wird. // Links im Template setzen $t->set_var(array('SETTINGS_ONCLICK' => 'javascript: window.location = \'' . WB_URL . '/modules/foldergallery/admin/modify_settings.php?page_id=' . $page_id . '&section_id=' . $section_id . '\';', 'SYNC_ONKLICK' => 'javascript: window.location = \'' . WB_URL . '/modules/foldergallery/admin/sync.php?page_id=' . $page_id . '&section_id=' . $section_id . '\';', 'HELP_ONCLICK' => 'javascript: window.location = \'' . WB_URL . '/modules/foldergallery/help.php?page_id=' . $page_id . '&section_id=' . $section_id . '\';', 'NEW_CAT_ONCLICK' => 'javascript: window.location = \'' . WB_URL . '/modules/foldergallery/admin/new_cat.php?page_id=' . $page_id . '&section_id=' . $section_id . '\';', 'EDIT_PAGE' => $page_id, 'EDIT_SECTION' => $section_id, 'WB_URL' => WB_URL)); // Text im Template setzten $t->set_var(array('TITEL_BACKEND_STRING' => $MOD_FOLDERGALLERY['TITEL_BACKEND'], 'TITEL_MODIFY' => $MOD_FOLDERGALLERY['TITEL_MODIFY'], 'SETTINGS_STRING' => $MOD_FOLDERGALLERY['SETTINGS'], 'FOLDER_IN_FS_STRING' => $MOD_FOLDERGALLERY['FOLDER_IN_FS'], 'CAT_TITLE_STRING' => $MOD_FOLDERGALLERY['CAT_TITLE'], 'ACTIONS_STRING' => $MOD_FOLDERGALLERY['ACTION'], 'SYNC_STRING' => $MOD_FOLDERGALLERY['SYNC'], 'EDIT_CSS_STRING' => $MOD_FOLDERGALLERY['EDIT_CSS'], 'EXPAND_COLAPSE_STRING' => $MOD_FOLDERGALLERY['EXPAND_COLAPSE'], 'HELP_STRING' => $MOD_FOLDERGALLERY['HELP_INFORMATION'], 'NEW_CAT_STRING' => $MOD_FOLDERGALLERY['NEW_CAT'])); // Template ausgeben $t->pparse('output', 'modify'); // Kategorien von der obersten Ebene aus DB hohlen $sql = "SELECT * FROM " . TABLE_PREFIX . "mod_foldergallery_categories WHERE section_id=" . $section_id . " AND niveau=0;"; $query = $database->query($sql); while ($result = $query->fetchRow()) { $results[] = $result; }
/** * Display a small monthly calendar for the current month. * Dates that have events scheduled are highlighted. * * @param integer $year Year to display, default is current year * @param integer $month Starting month * @return string HTML for calendar page */ function EVLIST_smallmonth($year = 0, $month = 0, $opts = array()) { global $_CONF, $_EV_CONF, $LANG_MONTH, $_SYSTEM; $retval = ''; // Default to the current year if ($year == 0) { $year = date('Y'); } if ($month == 0) { $month = date('m'); } $monthnum_str = sprintf("%02d", (int) $month); // Get all the dates in the period $starting_date = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year)); $ending_date = date('Y-m-d', mktime(23, 59, 59, $month, 31, $year)); $calendarView = Date_Calc::getCalendarMonth($month, $year, '%Y-%m-%d'); $events = EVLIST_getEvents($starting_date, $ending_date, $opts); $T = new Template(EVLIST_PI_PATH . '/templates'); $T->set_file(array('smallmonth' => 'phpblock_month.thtml')); $T->set_var('thisyear', $year); $T->set_var('month', $month); $T->set_var('monthname', $LANG_MONTH[(int) $month]); // Set each day column header to the first letter of the day name $T->set_block('smallmonth', 'daynames', 'nBlock'); $daynames = EVLIST_getDayNames(1); foreach ($daynames as $key => $dayname) { $T->set_var('dayname', $dayname); $T->parse('nBlock', 'daynames', true); } $T->set_block('smallmonth', 'week', 'wBlock'); USES_class_date(); $dt = new Date('now', $_CONF['timezone']); foreach ($calendarView as $weeknum => $weekdata) { list($weekYear, $weekMonth, $weekDay) = explode('-', $weekdata[0]); $T->set_var(array('weekyear' => $weekYear, 'weekmonth' => $weekMonth, 'weekday' => $weekDay)); $T->set_block('smallmonth', 'day', 'dBlock'); foreach ($weekdata as $daynum => $daydata) { list($y, $m, $d) = explode('-', $daydata); $T->clear_var('no_day_link'); if ($daydata == $_EV_CONF['_today']) { $dayclass = 'monthtoday'; } elseif ($m == $monthnum_str) { $dayclass = 'monthon'; } else { $T->set_var('no_day_link', 'true'); $dayclass = 'monthoff'; } $popup = ''; if (isset($events[$daydata])) { // Create the tooltip hover text $daylinkclass = $dayclass == 'monthoff' ? 'nolink-events' : 'day-events'; foreach ($events[$daydata] as $event) { // Show event titles on different lines if more than one if (!empty($popup)) { $popup .= EVLIST_tooltip_newline(); } // Don't show a time for all-day events if ($event['allday'] == 0 && $event['rp_date_start'] == $event['rp_date_end']) { $dt->setTimestamp(strtotime($event['rp_date_start'] . ' ' . $event['rp_time_start1'])); // Time is a localized string, not a timestamp, so // don't adjust for the timezone $popup .= $dt->format($_CONF['timeonly'], false) . ': '; } $popup .= htmlentities($event['title']); } $T->set_var('popup', $popup); } else { $daylinkclass = 'day-noevents'; $T->clear_var('popup'); } $T->set_var(array('daylinkclass' => $daylinkclass, 'dayclass' => $dayclass, 'day' => substr($daydata, 8, 2), 'pi_url' => EVLIST_URL)); $T->parse('dBlock', 'day', true); } $T->parse('wBlock', 'week', true); $T->clear_var('dBlock'); } $T->parse('output', 'smallmonth'); return $T->finish($T->get_var('output')); }
/** * Shows poll editor * * Diplays the poll editor form * * @param string $pid ID of poll to edit * @return string HTML for poll editor form * */ function editpoll($pid = '') { global $_CONF, $_PO_CONF, $_GROUPS, $_TABLES, $_USER, $LANG25, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $LANG_POLLS; $retval = ''; if (!empty($pid)) { $topic = DB_query("SELECT * FROM {$_TABLES['polltopics']} WHERE pid='{$pid}'"); $T = DB_fetchArray($topic); // Get permissions for poll $access = SEC_hasAccess($T['owner_id'], $T['group_id'], $T['perm_owner'], $T['perm_group'], $T['perm_members'], $T['perm_anon']); if ($access == 0 or $access == 2) { // User doesn't have access...bail $retval .= COM_startBlock($LANG25[21], '', COM_getBlockTemplate('_msg_block', 'header')); $retval .= $LANG25[22]; $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); COM_accessLog("User {$_USER['username']} tried to illegally submit or edit poll {$pid}."); return $retval; } } // writing the menu on top require_once $_CONF['path_system'] . 'lib-admin.php'; $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/plugins/polls/index.php', 'text' => $LANG_ADMIN['list_all']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home'])); $token = SEC_createToken(); $retval .= COM_startBlock($LANG25[5], '', COM_getBlockTemplate('_admin_block', 'header')); $retval .= ADMIN_createMenu($menu_arr, $LANG_POLLS['editinstructions'], plugin_geticon_polls()); $retval .= SEC_getTokenExpiryNotice($token); $poll_templates = new Template($_CONF['path'] . 'plugins/polls/templates/admin/'); $poll_templates->set_file(array('editor' => 'polleditor.thtml', 'question' => 'pollquestions.thtml', 'answer' => 'pollansweroption.thtml')); $poll_templates->set_var('xhtml', XHTML); $poll_templates->set_var('site_url', $_CONF['site_url']); $poll_templates->set_var('site_admin_url', $_CONF['site_admin_url']); $poll_templates->set_var('layout_url', $_CONF['layout_url']); if (!empty($pid) and $access == 3 and !empty($T['owner_id'])) { $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>'; $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"'; $poll_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm)); $poll_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, '')); } else { $T['pid'] = COM_makeSid(); $T['topic'] = ''; $T['meta_description'] = ''; $T['meta_keywords'] = ''; $T['voters'] = 0; $T['display'] = 1; $T['is_open'] = 1; $T['hideresults'] = 0; $T['owner_id'] = $_USER['uid']; if (isset($_GROUPS['Polls Admin'])) { $T['group_id'] = $_GROUPS['Polls Admin']; } else { $T['group_id'] = SEC_getFeatureGroup('polls.edit'); } SEC_setDefaultPermissions($T, $_PO_CONF['default_permissions']); $T['statuscode'] = 0; $T['commentcode'] = $_CONF['comment_code']; $access = 3; } $poll_templates->set_var('lang_pollid', $LANG25[6]); $poll_templates->set_var('poll_id', $T['pid']); $poll_templates->set_var('lang_donotusespaces', $LANG25[7]); $poll_templates->set_var('lang_topic', $LANG25[9]); $poll_templates->set_var('poll_topic', htmlspecialchars($T['topic'])); $poll_templates->set_var('lang_mode', $LANG25[1]); $poll_templates->set_var('lang_metadescription', $LANG_ADMIN['meta_description']); $poll_templates->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']); if (!empty($T['meta_description'])) { $poll_templates->set_var('meta_description', $T['meta_description']); } if (!empty($T['meta_keywords'])) { $poll_templates->set_var('meta_keywords', $T['meta_keywords']); } $poll_templates->set_var('status_options', COM_optionList($_TABLES['statuscodes'], 'code,name', $T['statuscode'])); $poll_templates->set_var('comment_options', COM_optionList($_TABLES['commentcodes'], 'code,name', $T['commentcode'])); $poll_templates->set_var('lang_appearsonhomepage', $LANG25[8]); $poll_templates->set_var('lang_openforvoting', $LANG25[33]); $poll_templates->set_var('lang_hideresults', $LANG25[37]); $poll_templates->set_var('poll_hideresults_explain', $LANG25[38]); $poll_templates->set_var('poll_topic_info', $LANG25[39]); if ($T['display'] == 1) { $poll_templates->set_var('poll_display', 'checked="checked"'); } if ($T['is_open'] == 1) { $poll_templates->set_var('poll_open', 'checked="checked"'); } if ($T['hideresults'] == 1) { $poll_templates->set_var('poll_hideresults', 'checked="checked"'); } // user access info $poll_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']); $poll_templates->set_var('lang_owner', $LANG_ACCESS['owner']); $ownername = COM_getDisplayName($T['owner_id']); $poll_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$T['owner_id']}")); $poll_templates->set_var('owner_name', $ownername); $poll_templates->set_var('owner', $ownername); $poll_templates->set_var('owner_id', $T['owner_id']); $poll_templates->set_var('lang_group', $LANG_ACCESS['group']); $poll_templates->set_var('group_dropdown', SEC_getGroupDropdown($T['group_id'], $access)); $poll_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']); $poll_templates->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']); $poll_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']); $poll_templates->set_var('permissions_editor', SEC_getPermissionsHTML($T['perm_owner'], $T['perm_group'], $T['perm_members'], $T['perm_anon'])); $poll_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']); $poll_templates->set_var('lang_answersvotes', $LANG25[10]); $poll_templates->set_var('lang_save', $LANG_ADMIN['save']); $poll_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']); // repeat for several questions $question_sql = "SELECT question,qid " . "FROM {$_TABLES['pollquestions']} WHERE pid='{$pid}' ORDER BY qid;"; $questions = DB_query($question_sql); include $_CONF['path_system'] . 'classes/navbar.class.php'; $navbar = new navbar(); for ($j = 0; $j < $_PO_CONF['maxquestions']; $j++) { $display_id = $j + 1; if ($j > 0) { $poll_templates->set_var('style', 'style="display:none;"'); } else { $poll_templates->set_var('style', ''); } $navbar->add_menuitem($LANG25[31] . " {$display_id}", "showhidePollsEditorDiv(\"{$j}\",{$j},{$_PO_CONF['maxquestions']});return false;", true); $Q = DB_fetchArray($questions); $poll_templates->set_var('question_text', $Q['question']); $poll_templates->set_var('question_id', $j); $poll_templates->set_var('lang_question', $LANG25[31] . " {$display_id}"); $poll_templates->set_var('lang_saveaddnew', $LANG25[32]); // answers $answer_sql = "SELECT answer,aid,votes,remark " . "FROM {$_TABLES['pollanswers']} WHERE qid='{$j}' AND pid='{$pid}' ORDER BY aid"; $answers = DB_query($answer_sql); for ($i = 0; $i < $_PO_CONF['maxanswers']; $i++) { if (isset($answers)) { $A = DB_fetchArray($answers); $poll_templates->set_var('answer_text', htmlspecialchars($A['answer'])); $poll_templates->set_var('answer_votes', $A['votes']); $poll_templates->set_var('remark_text', $A['remark']); } else { $poll_templates->set_var('answer_text', ''); $poll_templates->set_var('answer_votes', ''); $poll_templates->set_var('remark_text', ''); } $poll_templates->parse('answer_option', 'answer', true); } $poll_templates->parse('question_list', 'question', true); $poll_templates->clear_var('answer_option'); } $navbar->set_selected($LANG25[31] . " 1"); $poll_templates->set_var('navbar', $navbar->generate()); $poll_templates->set_var('gltoken_name', CSRF_TOKEN); $poll_templates->set_var('gltoken', $token); $poll_templates->parse('output', 'editor'); $retval .= $poll_templates->finish($poll_templates->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }
/** * Show topic administration form * * @param string tid ID of topic to edit * @param array $T An array of topic fields (optional) * @return string HTML for the topic editor * */ function TOPIC_edit($tid = '', $T = array(), $msg = '') { global $_CONF, $_GROUPS, $_TABLES, $_USER, $LANG27, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $_IMAGE_TYPE; USES_lib_admin(); $retval = ''; $topicEdit = 0; $assoc_stories_published = 0; $assoc_stories_draft = 0; $assoc_images = 0; $assoc_comments = 0; $assoc_trackbacks = 0; if (!empty($tid)) { $topicEdit = 1; // existing topic - pull fields from DB $result = DB_query("SELECT * FROM {$_TABLES['topics']} WHERE tid ='" . DB_escapeString($tid) . "'"); $A = DB_fetchArray($result); $access = SEC_inGroup('Topic Admin') ? 3 : SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']); if ($access == 0 or $access == 2) { $retval .= COM_showMessageText($LANG27[13], $LANG27[12], true); COM_accessLog("User {$_USER['username']} tried to illegally create or edit topic {$tid}."); return $retval; } // ok let's see what is associated with this topic $result2 = DB_query("SELECT bid FROM {$_TABLES['blocks']} WHERE tid = '{$tid}'"); $assoc_blocks = DB_numRows($result2); $result2 = DB_query("SELECT fid FROM {$_TABLES['syndication']} WHERE topic = '{$tid}'"); $assoc_feeds = DB_numRows($result2); $result2 = DB_query("SELECT sid FROM {$_TABLES['storysubmission']} WHERE tid = '{$tid}'"); $assoc_stories_submitted = DB_numRows($result2); $result2 = DB_query("SELECT sid, draft_flag FROM {$_TABLES['stories']} WHERE tid = '{$tid}'"); $total_assoc_stories = DB_numRows($result2); if ($total_assoc_stories > 0) { for ($i = 0; $i < $total_assoc_stories; $i++) { $S = DB_fetchArray($result2); if ($S['draft_flag'] == 0) { $assoc_stories_published += 1; } else { $assoc_stories_draft += 1; } $result3 = DB_query("SELECT ai_filename FROM {$_TABLES['article_images']} WHERE ai_sid = '{$S['sid']}'"); $assoc_images += DB_numRows($result3); $result3 = DB_query("SELECT cid FROM {$_TABLES['comments']} WHERE sid = '{$S['sid']}' AND type = 'article'"); $assoc_comments += DB_numRows($result3); $result3 = DB_query("SELECT cid FROM {$_TABLES['trackback']} WHERE sid = '{$S['sid']}' AND type = 'article'"); $assoc_trackbacks += DB_numRows($result3); } } } else { // new topic - retain field values if any in case of failed validation $A = array(); $A['tid'] = isset($T['tid']) ? $T['tid'] : ''; $A['topic'] = isset($T['topic']) ? $T['topic'] : ''; $A['sortnum'] = isset($T['sortnum']) ? $T['sortnum'] : 0; $A['limitnews'] = isset($T['limitnews']) ? $T['limitnews'] : ''; // leave empty! $A['is_default'] = isset($T['is_default']) && $T['is_default'] == 'on' ? 1 : 0; $A['archive_flag'] = isset($T['archive_flag']) && $T['archive_flag'] == 'on' ? 1 : 0; $A['sort_by'] = isset($T['sort_by']) ? $T['sort_by'] : 0; $A['sort_dir'] = isset($T['sort_dir']) && $T['sort_dir'] == 'ASC' ? 'ASC' : 'DESC'; $A['owner_id'] = isset($T['owner_id']) ? $T['owner_id'] : ''; $A['group_id'] = isset($T['group_id']) ? $T['group_id'] : ''; $A['imageurl'] = isset($T['imageurl']) ? $T['imageurl'] : ''; $assoc_stories_submitted = 0; $assoc_blocks = 0; $assoc_feeds = 0; if ($A['sortnum'] != '') { $tidSortNumber = DB_getItem($_TABLES['topics'], 'sortnum', 'tid="' . DB_escapeString($A['sortnum']) . '"'); $newSortNum = $tidSortNumber; } else { $newSortNum = 0; } $A['sortnum'] = $newSortNum; // an empty owner_id signifies this is a new block, set to current user // this will also set the default values for group_id as well as the // default values for topic permissions if (empty($A['owner_id'])) { $A['owner_id'] = $_USER['uid']; // this is the one instance where we default the group // most topics should belong to the Topic Admin group if (isset($_GROUPS['Topic Admin'])) { $A['group_id'] = $_GROUPS['Topic Admin']; } else { $A['group_id'] = SEC_getFeatureGroup('topic.edit'); } SEC_setDefaultPermissions($A, $_CONF['default_permissions_topic']); } else { if (isset($T['perm_owner'])) { $A['perm_owner'] = SEC_getPermissionValue($T['perm_owner']); $A['perm_group'] = SEC_getPermissionValue($T['perm_group']); $A['perm_members'] = SEC_getPermissionValue($T['perm_members']); $A['perm_anon'] = SEC_getPermissionValue($T['perm_anon']); } else { SEC_setDefaultPermissions($A, $_CONF['default_permissions_topic']); } } $access = 3; } // display the topic editor $topic_templates = new Template($_CONF['path_layout'] . 'admin/topic'); $topic_templates->set_file('editor', 'topiceditor.thtml'); // generate input for topic id if (!empty($topicEdit) && SEC_hasRights('topic.edit')) { $tid_input = $tid . '<input type="hidden" size="20" maxlength="128" name="tid" value="' . $tid . '"' . XHTML . '>'; $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="delete"%s' . XHTML . '>'; $jsconfirm = ' onclick="return doubleconfirm(\'' . $LANG27[40] . '\',\'' . $LANG27[6] . '\');"'; $topic_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm)); $topic_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, '')); $topic_templates->clear_var('lang_donotusespaces'); } else { $tid_input = '<input class="required alphanumeric" type="text" size="20" maxlength="128" name="tid" id="tid" value="' . $tid . '"' . XHTML . '>'; $topic_templates->set_var('lang_donotusespaces', $LANG27[5]); } $topic_templates->set_var('tid_input', $tid_input); $topic_templates->set_var('lang_topicid', $LANG27[2]); $topic_templates->set_var('topic_id', $A['tid']); $topic_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']); $topic_templates->set_var('lang_owner', $LANG_ACCESS['owner']); $ownername = COM_getDisplayName($A['owner_id']); $topic_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}")); $topic_templates->set_var('owner_name', $ownername); $topic_templates->set_var('owner', $ownername); $topic_templates->set_var('owner_id', $A['owner_id']); $topic_templates->set_var('owner_dropdown', COM_buildOwnerList('owner_id', $A['owner_id'])); $topic_templates->set_var('lang_group', $LANG_ACCESS['group']); $topic_templates->set_var('lang_save', $LANG_ADMIN['save']); $topic_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']); $topic_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access)); $topic_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']); $topic_templates->set_var('lang_permissions_key', $LANG_ACCESS['permissionskey']); $topic_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon'])); $sort_select = '<select id="sortnum" name="sortnum">' . LB; $sort_select .= '<option value="0">' . 'First Position' . '</option>' . LB; $result = DB_query("SELECT tid,topic,sortnum FROM {$_TABLES['topics']} ORDER BY sortnum ASC"); if ($topicEdit == 1) { $testvar = 10; } else { $testvar = 0; } $order = 10; while ($row = DB_fetchArray($result)) { if ($row['tid'] != $tid) { $test_sortnum = $order + $testvar; $sort_select .= '<option value="' . $row['tid'] . '"' . ($A['sortnum'] == $test_sortnum ? ' selected="selected"' : '') . '>' . $row['topic'] . ' (' . $row['tid'] . ')' . '</option>' . LB; } $order += 10; } $sort_select .= '</select>' . LB; // show sort order only if they specified sortnum as the sort method if ($_CONF['sortmethod'] != 'alpha') { $topic_templates->set_var('lang_sortorder', $LANG27[41]); if ($A['sortnum'] == 0) { $A['sortnum'] = ''; } $topic_templates->set_var('sort_order', $sort_select); } else { $topic_templates->set_var('lang_sortorder', $LANG27[14]); $topic_templates->set_var('sort_order', $LANG27[15]); } $topic_templates->set_var('lang_storiesperpage', $LANG27[11]); if ($A['limitnews'] == 0) { $topic_templates->set_var('story_limit', ''); } else { $topic_templates->set_var('story_limit', $A['limitnews']); } $topic_templates->set_var('default_limit', $_CONF['limitnews']); $topic_templates->set_var('lang_defaultis', $LANG27[16]); $topic_templates->set_var('lang_topicname', $LANG27[3]); $topic_templates->set_var('topic_name', htmlentities($A['topic'])); if (empty($A['tid'])) { $A['imageurl'] = '/images/topics/'; } $topic_templates->set_var('lang_topicimage', $LANG27[4]); $topic_templates->set_var('lang_uploadimage', $LANG27[27]); $topic_templates->set_var('icon_dimensions', $_CONF['max_topicicon_width'] . ' x ' . $_CONF['max_topicicon_height']); $topic_templates->set_var('lang_maxsize', $LANG27[28]); $topic_templates->set_var('max_url_length', 255); $topic_templates->set_var('image_url', $A['imageurl']); if (@getimagesize($_CONF['path_html'] . $A['imageurl']) !== false) { $topic_templates->set_var('topicimage', $_CONF['site_url'] . $A['imageurl']); } $topic_templates->set_var('lang_defaulttopic', $LANG27[22]); $topic_templates->set_var('lang_defaulttext', $LANG27[23]); if ($A['is_default'] == 1) { $topic_templates->set_var('default_checked', 'checked="checked"'); } else { $topic_templates->set_var('default_checked', ''); } $topic_templates->set_var('lang_sort_story_by', $LANG27[35]); $topic_templates->set_var('lang_sort_story_dir', $LANG27[36]); $sortSelect = '<select name="sort_by" id="sort_by">' . LB; $sortSelect .= '<option value="0"' . ($A['sort_by'] == 0 ? ' selected="selected"' : '') . '>' . $LANG27[30] . '</option>' . LB; $sortSelect .= '<option value="1"' . ($A['sort_by'] == 1 ? ' selected="selected"' : '') . '>' . $LANG27[31] . '</option>' . LB; $sortSelect .= '<option value="2"' . ($A['sort_by'] == 2 ? ' selected="selected"' : '') . '>' . $LANG27[32] . '</option>' . LB; $sortSelect .= '</select>' . LB; $topic_templates->set_var('story_sort_select', $sortSelect); $sort_dir = '<select name="sort_dir" id="sort_dir">' . LB; $sort_dir .= '<option value="ASC"' . ($A['sort_dir'] == 'ASC' ? ' selected="selected"' : '') . '>' . $LANG27[33] . '</option>' . LB; $sort_dir .= '<option value="DESC"' . ($A['sort_dir'] == 'DESC' ? ' selected="selected"' : '') . '>' . $LANG27[34] . '</option>' . LB; $sort_dir .= '</select>'; $topic_templates->set_var('story_sort_dir', $sort_dir); $topic_templates->set_var('lang_archivetopic', $LANG27[25]); $topic_templates->set_var('lang_archivetext', $LANG27[26]); $topic_templates->set_var('archive_disabled', ''); if ($A['archive_flag'] == 1) { $topic_templates->set_var('archive_checked', 'checked="checked"'); } else { $topic_templates->set_var('archive_checked', ''); // Only 1 topic can be the archive topic - so check if there already is one if (DB_count($_TABLES['topics'], 'archive_flag', '1') > 0) { $topic_templates->set_var('archive_disabled', 'disabled'); } } $assoc_stories = ($assoc_stories_published > 0 or $assoc_stories_draft > 0 or $assoc_stories_submitted > 0 or $assoc_images > 0 or $assoc_comments > 0 or $assoc_trackbacks > 0); if ($assoc_blocks > 0 or $assoc_feeds > 0 or $assoc_stories) { $topic_templates->set_var('lang_assoc_objects', $LANG27[43]); if ($assoc_stories_published > 0) { $topic_templates->set_var('lang_assoc_stories_published', $LANG27[44]); $topic_templates->set_var('assoc_stories_published', $assoc_stories_published); $topic_templates->set_var('published_story_admin_link', COM_createLink($LANG27[52], $_CONF['site_admin_url'] . '/story.php')); } if ($assoc_stories_draft > 0) { $topic_templates->set_var('lang_assoc_stories_draft', $LANG27[45]); $topic_templates->set_var('assoc_stories_draft', $assoc_stories_draft); $topic_templates->set_var('draft_story_admin_link', COM_createLink($LANG27[52], $_CONF['site_admin_url'] . '/story.php')); } if ($assoc_stories_submitted > 0) { $topic_templates->set_var('lang_assoc_stories_submitted', $LANG27[46]); $topic_templates->set_var('assoc_stories_submitted', $assoc_stories_submitted); $topic_templates->set_var('moderation_link', COM_createLink($LANG27[53], $_CONF['site_admin_url'] . '/moderation.php')); } if ($assoc_images > 0) { $topic_templates->set_var('lang_assoc_images', $LANG27[47]); $topic_templates->set_var('assoc_images', $assoc_images); } if ($assoc_comments > 0) { $topic_templates->set_var('lang_assoc_comments', $LANG27[48]); $topic_templates->set_var('assoc_comments', $assoc_comments); } if ($assoc_trackbacks > 0) { $topic_templates->set_var('lang_assoc_trackbacks', $LANG27[49]); $topic_templates->set_var('assoc_trackbacks', $assoc_trackbacks); } if ($assoc_blocks > 0) { $topic_templates->set_var('lang_assoc_blocks', $LANG27[50]); $topic_templates->set_var('assoc_blocks', $assoc_blocks); $topic_templates->set_var('block_admin_link', COM_createLink($LANG27[54], $_CONF['site_admin_url'] . '/block.php')); } if ($assoc_feeds > 0) { $topic_templates->set_var('lang_assoc_feeds', $LANG27[51]); $topic_templates->set_var('assoc_feeds', $assoc_feeds); $topic_templates->set_var('syndication_admin_link', COM_createLink($LANG27[55], $_CONF['site_admin_url'] . '/syndication.php')); } } $topic_templates->set_var('gltoken_name', CSRF_TOKEN); $topic_templates->set_var('gltoken', SEC_createToken()); $topic_templates->parse('output', 'editor'); if ($msg != '') { $retval .= COM_showMessageText($msg); } $retval .= COM_startBlock($LANG27[1], '', COM_getBlockTemplate('_admin_block', 'header')); $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/topic.php', 'text' => $LANG_ADMIN['topic_list']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home'])); $retval .= ADMIN_createMenu($menu_arr, $LANG27[57], $_CONF['layout_url'] . '/images/icons/topic.' . $_IMAGE_TYPE); $retval .= $topic_templates->finish($topic_templates->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }
/** * draws installation screens * @global type $urlServer * @global type $langStep * @global type $langStepTitle * @global type $langTitleInstall * @global type $langInstallProgress * @param type $toolContent */ function draw($toolContent, $options=null) { global $urlServer, $langStep, $langStepTitle, $langTitleInstall, $langInstallProgress; if (!$options) { $options = array(); } $t = new Template(); $t->set_file('fh', '../template/default/theme.html'); $t->set_block('fh', 'mainBlock', 'main'); $t->set_var('SITE_NAME', 'Open eClass'); $t->set_block('mainBlock', 'sideBarBlock', 'delete'); $t->set_block('mainBlock', 'LoggedInBlock', 'delete'); $t->set_block('mainBlock', 'LoggedOutBlock', 'delete'); $t->set_block('mainBlock', 'toolTitleBlock', 'delete'); $t->set_block('mainBlock', 'statusSwitchBlock', 'delete'); $t->set_var('logo_img', '../template/default/img/logo_eclass.png'); $t->set_var('logo_img_small', '../template/default/img/logo_eclass_small.png'); $t->set_var('template_base', '../template/default'); if (isset($options['no-menu'])) { $t->set_block('mainBlock', 'leftNavBlock', 'delete'); $t->set_block('mainBlock', 'breadCrumbs', 'delete'); $t->set_block('mainBlock', 'normalViewOpenDiv', 'delete'); } else { //display the left column (installation steps) $toolArr = installerMenu(); $numOfToolGroups = count($toolArr); $t->set_block('mainBlock', 'leftNavCategoryBlock', 'leftNavCategory'); $t->set_block('leftNavCategoryBlock', 'leftNavLinkBlock', 'leftNavLink'); $t->set_block('mainBlock', 'mobileViewOpenDiv', 'delete'); $t->set_block('mainBlock', 'searchBlock', 'delete'); if (is_array($toolArr)) { for ($i = 0; $i < $numOfToolGroups; $i++) { $t->set_var('ACTIVE_TOOLS', $langInstallProgress); $t->set_var('TOOL_GROUP_ID', $i + 1); $t->set_var('GROUP_CLASS', 'in'); $numOfTools = count($toolArr[$i][0]); for ($j = 0; $j < $numOfTools; $j++) { $t->set_var('TOOL_TEXT', $toolArr[$i][0][$j]); $t->set_var('TOOL_CLASS', $toolArr[$i][1][$j]? 'active': ''); $t->set_var('IMG_CLASS', $toolArr[$i][2][$j]); $t->set_var('TOOL_LINK', '#'); $t->parse('leftNavLink', 'leftNavLinkBlock', true); // remember current step to use as title } $t->parse('leftNavCategory', 'leftNavCategoryBlock',true); $t->clear_var('leftNavLink'); //clear inner block } $t->set_var('THIRD_BAR_TEXT', $langInstallProgress); $t->set_var('BREAD_TEXT', $langStep); $t->set_var('FOUR_BAR_TEXT', $langTitleInstall); $pageTitle = "$langTitleInstall - " . $langStepTitle . " (" . $langStep . ")"; $t->set_var('PAGE_TITLE', $pageTitle); } } $t->set_var('URL_PATH', empty($urlServer)? '../': $urlServer); $t->set_var('TOOL_CONTENT', $toolContent); $t->parse('main', 'mainBlock', false); $t->pparse('Output', 'fh'); exit; }
$sec_anchor = defined('SEC_ANCHOR') && SEC_ANCHOR != '' ? SEC_ANCHOR : ''; $edit_page_0 = '<a id="sid' . $section['section_id'] . '" href="' . ADMIN_URL . '/pages/modify.php?page_id=' . $results_array['page_id']; $edit_page_1 = $sec_anchor != '' ? '#' . $sec_anchor . $section['section_id'] . '">' : '">'; $edit_page_1 .= $section['module'] . '</a>'; if (SECTION_BLOCKS) { if ($edit_page == '') { if (defined('EDIT_ONE_SECTION') && EDIT_ONE_SECTION) { $edit_page = $edit_page_0 . '&wysiwyg=' . $section['section_id'] . $edit_page_1; } else { $edit_page = $edit_page_0 . $edit_page_1; } } $input_attribute = 'input_normal'; $tpl->set_var(array('STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:visible;"', 'NAME_SIZE' => 300, 'INPUT_ATTRIBUTE' => $input_attribute, 'VAR_SECTION_ID' => $section['section_id'], 'VAR_SECTION_IDKEY' => $admin->getIDKEY($section['section_id']), 'VAR_POSITION' => $section['position'], 'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page, 'SELECT' => '', 'SET_NONE_DISPLAY_OPTION' => '')); // Add block options to the section_list $tpl->clear_var('block_list'); foreach ($block as $number => $name) { $tpl->set_var('NAME', htmlentities(strip_tags($name))); $tpl->set_var('VALUE', $number); $tpl->set_var('SIZE', 1); if ($section['block'] == $number) { $tpl->set_var('SELECTED', ' selected="selected"'); } else { $tpl->set_var('SELECTED', ''); } $tpl->parse('block_list', 'block_block', true); } } else { if ($edit_page == '') { $edit_page = $edit_page_0 . '#wb_' . $edit_page_1; }
/** * Generates the HTML code based on the preset style * * @access public * @param array $rows_arr The rows to display in the list * @param string $title The title of the list * @param string $list_top HTML that will appear before the list is printed * @param string $list_bottom HTML that will appear after the list is printed * @param boolean $show_sort True to enable column sorting, false to disable * @param boolean $show_limit True to show page limits, false to hide * @return string HTML output * */ function getFormattedOutput($rows_arr, $title, $list_top = '', $list_bottom = '', $show_sort = true, $show_limit = true) { global $_CONF, $_IMAGE_TYPE, $LANG_ADMIN, $LANG09, $LANG05; // get all template fields. $list_templates = new Template($_CONF['path_layout'] . 'lists/' . $this->_style); $list_templates->set_file(array('list' => 'list.thtml', 'limit' => 'page_limit.thtml', 'sort' => 'page_sort.thtml', 'row' => 'item_row.thtml', 'field' => 'item_field.thtml')); $search_helper = ''; $string_offsets = ''; $string_pp = ''; for ($i = 0; $i < count($this->_limits); $i++) { if ($i != 0) { $string_offsets .= ','; $string_pp .= ','; } $name = $this->_limits[$i]['name']; $value = $this->_limits[$i]['offset']; $pp = $this->_limits[$i]['limit']; $string_offsets .= $name . '=' . $value; $string_pp .= $name . '=' . $pp; } $offset_encode = urlencode(base64_encode($string_offsets)); $pp_encode = urlencode(base64_encode($string_pp)); if (count($rows_arr) == 0) { $list_templates->set_var('message', $LANG_ADMIN['no_results']); $list_templates->set_var('list_top', $list_top); $list_templates->set_var('list_bottom', $list_bottom); $list_templates->parse('output', 'list'); // No results to show so quickly print a message and exit $retval = ''; if (!empty($title)) { $retval .= COM_startBlock($title, '', COM_getBlockTemplate('_admin_block', 'header')); } $retval .= $list_templates->finish($list_templates->get_var('output')); if (!empty($title)) { $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); } return $retval; } if ($this->_style == 'table') { foreach ($this->_fields as $field) { if ($field['display'] == true && $field['title'] != '') { $text = $sort_text . $field['title']; $href = ''; $selected = ''; $list_templates->set_var('sort_text', $text); $list_templates->set_var('sort_href', $href); $list_templates->set_var('sort_selected', $selected); $list_templates->parse('page_sort', 'sort', true); } } } $offset = ($this->_page - 1) * $this->_per_page; $list_templates->set_var('show_message', 'display:none;'); // Run through all the results $r = 1; foreach ($rows_arr as $row) { if (is_callable($this->_function)) { $row = call_user_func($this->_function, false, $row); } foreach ($this->_fields as $field) { if ($field['display'] == true) { $fieldvalue = ''; if ($field['name'] == ROW_NUMBER) { $fieldvalue = $r + $offset; } else { if (!empty($row[$field['name']])) { $fieldvalue = $row[$field['name']]; } } if ($fieldvalue != '') { $fieldvalue = sprintf($field['format'], $fieldvalue, $field['title']); // Write field $list_templates->set_var('field_text', $fieldvalue); $list_templates->parse('item_field', 'field', true); } } } // Write row $r++; $list_templates->set_var('cssid', $r % 2 + 1); $list_templates->parse('item_row', 'row', true); $list_templates->clear_var('item_field'); } // Print page numbers $page_url = $this->_page_url . 'order=' . $this->_sort_arr['field'] . '&direction=' . $this->_sort_arr['direction'] . '&results=' . $this->_per_page . '&page=' . $this->_page . '&i=' . $offset_encode . '&j=' . $pp_encode; $num_pages = ceil($this->_total_found / $this->_per_page); $gp = ''; if ($num_pages > 1) { if ($this->_page == 1) { $gp .= '[ ' . '<a href="' . $page_url . '&np=1">' . $LANG05[5] . '</a> ]'; } else { if ($this->_page < $num_pages) { $gp .= '[ ' . '<a href="' . $page_url . '&pp=1">' . $LANG05[6] . '</a> ] '; $gp .= '[ ' . '<a href="' . $page_url . '&np=1">' . $LANG05[5] . '</a> ]'; } else { $gp .= '[ ' . '<a href="' . $page_url . '&pp=1">' . $LANG05[6] . '</a> ]'; } } } $list_templates->set_var('google_paging', $gp); $list_templates->set_var('page_url', $page_url); $search_numbers = @sprintf($LANG09[64], $offset + 1, $r + $offset - 1, $this->_total_found); $list_top = $list_top . '<p>' . $search_numbers . '<br /></p>'; $list_templates->set_var('list_top', $list_top); $list_templates->set_var('list_bottom', $list_bottom); $list_templates->parse('output', 'list'); // Do the actual output $retval = '<div style="margin-top:5px;margin-bottom:5px;border-bottom:1px solid #ccc;"></div>'; $retval .= $list_templates->finish($list_templates->get_var('output')); return $retval; }
/** * Creates a list of data with a search, filter, clickable headers etc. * * @param string $component name of the list * @param string $fieldfunction name of the function that handles special entries * @param array $header_arr array of header fields with sortables and table fields * @param array $text_arr array with different text strings * @param array $query_arr array with sql-options * @param array $defsort_arr default sorting values * @param string $filter additional drop-down filters * @param string $extra additional values passed to fieldfunction * @param array $options_arr array of options - used for check-all feature * @param array $form_arr optional extra forms at top or bottom * @return string HTML output of function * */ function ADMIN_list($component, $fieldfunction, $header_arr, $text_arr, $query_arr, $defsort_arr, $filter = '', $extra = '', $options_arr = '', $form_arr = '') { global $_CONF, $_TABLES, $LANG_ADMIN, $LANG_ACCESS, $LANG01, $_IMAGE_TYPE, $MESSAGE; // retrieve the query if (isset($_GET['q'])) { $query = strip_tags($_GET['q']); } else { if (isset($_POST['q'])) { $query = strip_tags($_POST['q']); } else { $query = ''; } } // retrieve the query_limit if (isset($_GET['query_limit'])) { $query_limit = COM_applyFilter($_GET['query_limit'], true); } else { if (isset($_POST['query_limit'])) { $query_limit = COM_applyFilter($_POST['query_limit'], true); } else { $query_limit = 50; } } // get the current page from the interface. The variable is linked to the // component, i.e. the plugin/function calling this here to avoid overlap // the default page number is 1 if (isset($_GET[$component . 'listpage'])) { $page = COM_applyFilter($_GET[$component . 'listpage'], true); $curpage = $page; } else { if (isset($_POST[$component . 'listpage'])) { $page = COM_applyFilter($_POST[$component . 'listpage'], true); $curpage = $page; } else { $page = ''; $curpage = 1; } } $curpage = $curpage <= 0 ? 1 : $curpage; // curpagee has to be > 0 // process text_arr for title, help url and form url $title = (is_array($text_arr) and !empty($text_arr['title'])) ? $text_arr['title'] : ''; $help_url = (is_array($text_arr) and !empty($text_arr['help_url'])) ? $text_arr['help_url'] : ''; $form_url = (is_array($text_arr) and !empty($text_arr['form_url'])) ? $text_arr['form_url'] : ''; // determine what extra options we should use (search, limit, paging) if (isset($text_arr['has_extras']) && $text_arr['has_extras']) { # old option, denotes all $has_search = true; $has_limit = true; $has_paging = true; } else { $has_search = isset($text_arr['has_search']) && $text_arr['has_search'] ? true : false; $has_limit = isset($text_arr['has_limit']) && $text_arr['has_limit'] ? true : false; $has_paging = isset($text_arr['has_paging']) && $text_arr['has_paging'] ? true : false; } // process options_arr for chkdelete/chkselect options if any $chkselect = (is_array($options_arr) and (isset($options_arr['chkselect']) and $options_arr['chkselect'] or isset($options_arr['chkdelete']) and $options_arr['chkdelete'])) ? true : false; $chkall = (is_array($options_arr) and isset($options_arr['chkall'])) ? $options_arr['chkall'] : true; $chkname = (is_array($options_arr) and isset($options_arr['chkname'])) ? $options_arr['chkname'] : 'delitem'; $chkfield = (is_array($options_arr) and isset($options_arr['chkfield'])) ? $options_arr['chkfield'] : ''; $chkactions = (is_array($options_arr) and isset($options_arr['chkactions'])) ? $options_arr['chkactions'] : ''; $chkfunction = (is_array($options_arr) and isset($options_arr['chkfunction'])) ? $options_arr['chkfunction'] : 'ADMIN_chkDefault'; $chkminimum = (is_array($options_arr) and isset($options_arr['chkminimum'])) ? $options_arr['chkminimum'] : 1; # get all template fields. $admin_templates = new Template($_CONF['path_layout'] . 'admin/lists'); $admin_templates->set_file(array('search' => 'searchmenu.thtml', 'list' => 'list.thtml', 'header' => 'header.thtml', 'row' => 'listitem.thtml', 'field' => 'field.thtml', 'arow' => 'actionrow.thtml')); # insert std. values into the template $admin_templates->set_var('form_url', $form_url); $admin_templates->set_var('lang_edit', $LANG_ADMIN['edit']); $admin_templates->set_var('lang_delconfirm', $LANG01[125]); if (isset($form_arr['top'])) { $admin_templates->set_var('formfields_top', $form_arr['top']); } if (isset($form_arr['bottom'])) { $admin_templates->set_var('formfields_bottom', $form_arr['bottom']); } // Check if the delete checkbox and support for the delete all feature should be displayed if ($chkselect) { if ($chkall) { $admin_templates->set_var('header_text', '<input type="checkbox" name="chk_selectall" title="' . $LANG01[126] . '" onclick="caItems(this.form,\'' . $chkname . '\');"/>'); } else { $admin_templates->set_var('header_text', '<input type="checkbox" name="disabled" value="x" style="visibility:hidden" disabled="disabled" />'); } $admin_templates->set_var('class', 'admin-list-field'); $admin_templates->set_var('header_column_style', 'style="text-align:center;width:25px;"'); // always center checkbox $admin_templates->parse('header_row', 'header', true); } $icon_arr = ADMIN_getIcons(); if ($has_search) { // show search $admin_templates->set_var('lang_search', $LANG_ADMIN['search']); $admin_templates->set_var('lang_submit', $LANG_ADMIN['submit']); $admin_templates->set_var('last_query', htmlspecialchars($query)); $admin_templates->set_var('filter', $filter); } $sql = $query_arr['sql']; // get sql from array that builds data // setup list sort options if (!isset($_GET['orderby'])) { $orderby = $defsort_arr['field']; // not set - use default (this could be null) $orderidx_link = ''; $orderbyidx = ''; } else { $orderbyidx = COM_applyFilter($_GET['orderby'], true); // set - retrieve and clean $orderidx_link = "&orderby={$orderbyidx}"; // preserve the value for paging $orderby = $header_arr[$orderbyidx]['field']; // get the field name to sort by } // set sort direction. defaults to ASC $direction = isset($_GET['direction']) ? COM_applyFilter($_GET['direction']) : $defsort_arr['direction']; $direction = strtoupper($direction) == 'DESC' ? 'DESC' : 'ASC'; // retrieve previous sort order field $prevorder = isset($_GET['prevorder']) ? COM_applyFilter($_GET['prevorder']) : ''; // reverse direction if previous order field was the same (this is a toggle) if ($orderby == $prevorder) { // reverse direction if prev. order was the same $direction = $direction == 'DESC' ? 'ASC' : 'DESC'; } // ok now let's build the order sql $orderbysql = !empty($orderby) ? "ORDER BY {$orderby} {$direction}" : ''; // assign proper arrow img based upon order $arrow_img = $direction == 'ASC' ? 'ascending' : 'descending'; $img_arrow_url = "{$_CONF['layout_url']}/images/admin/{$arrow_img}.{$_IMAGE_TYPE}"; $attr['style'] = "vertical-align:text-top;"; $img_arrow = ' ' . COM_createImage($img_arrow_url, $arrow_img, $attr); # HEADER FIELDS array(text, field, sort, align, class) ===================== // number of columns in each row $ncols = count($header_arr); for ($i = 0; $i < $ncols; $i++) { $header_text = isset($header_arr[$i]['text']) && !empty($header_arr[$i]['text']) ? $header_arr[$i]['text'] : ''; // check to see if field is sortable if (isset($header_arr[$i]['sort']) && $header_arr[$i]['sort'] != false) { // add the sort indicator $header_text .= $orderby == $header_arr[$i]['field'] ? $img_arrow : ''; // change the mouse to a pointer $th_subtags = " onmouseover=\"this.style.cursor='pointer';\""; // create an index so we know what to sort $separator = strpos($form_url, '?') > 0 ? '&' : '?'; // ok now setup the parameters to preserve: // sort field and direction $th_subtags .= " onclick=\"window.location.href='{$form_url}{$separator}" . "orderby={$i}&prevorder={$orderby}&direction={$direction}"; // page number $th_subtags .= !empty($page) ? '&' . $component . 'listpage=' . $page : ''; // query $th_subtags .= !empty($query) ? '&q=' . urlencode($query) : ''; // query limit $th_subtags .= !empty($query_limit) ? '&query_limit=' . $query_limit : ''; $th_subtags .= "';\""; } else { $th_subtags = ''; } // apply field styling if specified if (!empty($header_arr[$i]['header_class'])) { $admin_templates->set_var('class', $header_arr[$i]['header_class']); } else { $admin_templates->set_var('class', 'admin-list-headerfield'); } // apply field alignment options if specified $header_column_style = ''; if (!empty($header_arr[$i]['align'])) { if ($header_arr[$i]['align'] == 'center') { $header_column_style = 'text-align:center;'; } elseif ($header_arr[$i]['align'] == 'right') { $header_column_style = 'text-align:right;'; } } // apply field wrap option if specified $header_column_style .= isset($header_arr[$i]['nowrap']) ? ' white-space:nowrap;' : ''; // apply field width option if specified $header_column_style .= isset($header_arr[$i]['width']) ? ' width:' . $header_arr[$i]['width'] . ';' : ''; // apply field style option if specified if (!empty($header_column_style)) { $admin_templates->set_var('header_column_style', 'style="' . $header_column_style . '"'); } else { $admin_templates->clear_var('header_column_style'); } // output the header field $admin_templates->set_var('header_text', $header_text); $admin_templates->set_var('th_subtags', $th_subtags); $admin_templates->parse('header_row', 'header', true); // clear all for next header $admin_templates->clear_var('th_subtags'); $admin_templates->clear_var('class'); $admin_templates->clear_var('header_text'); } if ($has_limit) { $admin_templates->set_var('lang_limit_results', $LANG_ADMIN['limit_results']); $limit = !empty($query_limit) ? $query_limit : 50; // query limit (default=50) if ($query != '') { # set query into form after search $admin_templates->set_var('query', urlencode($query)); } else { $admin_templates->set_var('query', ''); } $admin_templates->set_var('query_limit', $query_limit); # choose proper dropdown field for query limit $admin_templates->set_var($limit . '_selected', 'selected="selected"'); // set the default sql filter (if any) $filtersql = isset($query_arr['default_filter']) && !empty($query_arr['default_filter']) ? " {$query_arr['default_filter']}" : ''; // now add the query fields if (!empty($query)) { # add query fields with search term $filtersql .= " AND ("; for ($f = 0; $f < count($query_arr['query_fields']); $f++) { $filtersql .= $query_arr['query_fields'][$f] . " LIKE '%" . DB_escapeString($query) . "%'"; if ($f < count($query_arr['query_fields']) - 1) { $filtersql .= " OR "; } } $filtersql .= ")"; } $num_pagessql = $sql . $filtersql; $num_pagesresult = DB_query($num_pagessql); $num_rows = DB_numRows($num_pagesresult); $num_pages = ceil($num_rows / $limit); $curpage = $num_pages < $curpage ? 1 : $curpage; // don't go beyond possible results $offset = ($curpage - 1) * $limit; $limitsql = "LIMIT {$offset},{$limit}"; // get only current page data $admin_templates->set_var('lang_records_found', $LANG_ADMIN['records_found']); $admin_templates->set_var('records_found', COM_numberFormat($num_rows)); } if ($has_search || $has_limit || $has_paging) { $admin_templates->parse('search_menu', 'search', true); } else { $admin_templates->set_var('search_menu', ''); } # form the sql query to retrieve the data if (!isset($filtersql)) { $filtersql = ''; } if (!isset($orderbysql)) { $orderbysql = ''; } if (!isset($limitsql)) { $limitsql = ''; } $sql .= "{$filtersql} {$orderbysql} {$limitsql};"; $result = DB_query($sql); // number of rows/records to display $nrows = DB_numRows($result); $r = 1; # r is the counter for the actual displayed rows for correct coloring for ($i = 0; $i < $nrows; $i++) { # now go through actual data $A = DB_fetchArray($result); $row_output = false; # as long as no fields are returned, dont print row if ($chkselect) { $admin_templates->set_var('class', 'admin-list-field'); $admin_templates->set_var('column_style', 'style="text-align:center;"'); // always center checkbox if ($chkfunction($A)) { $admin_templates->set_var('itemtext', '<input type="checkbox" name="' . $chkname . '[]" value="' . $A[$chkfield] . '" title="' . $LANG_ADMIN['select'] . '"/>'); } else { $admin_templates->set_var('itemtext', '<input type="checkbox" name="disabled" value="x" style="visibility:hidden" disabled="disabled" />'); } $admin_templates->parse('item_field', 'field', true); } for ($j = 0; $j < $ncols; $j++) { $fieldname = $header_arr[$j]['field']; # get field name from headers $fieldvalue = ''; if (!empty($A[$fieldname])) { # is there a field in data like that? $fieldvalue = $A[$fieldname]; # yes, get its data } if (!empty($fieldfunction) && !empty($extra)) { $fieldvalue = $fieldfunction($fieldname, $fieldvalue, $A, $icon_arr, $extra); } else { if (!empty($fieldfunction)) { # do we have a fieldfunction? $fieldvalue = $fieldfunction($fieldname, $fieldvalue, $A, $icon_arr); } else { # if not just take the value $fieldvalue = $fieldvalue; } } if ($fieldvalue !== false) { # return was there, so write line $row_output = true; } else { $fieldvalue = ''; // dont give empty fields } if (!empty($header_arr[$j]['field_class'])) { $admin_templates->set_var('class', $header_arr[$j]['field_class']); } else { $admin_templates->set_var('class', 'admin-list-field'); } // process field alignment option if specified $column_style = ''; if (!empty($header_arr[$j]['align'])) { if ($header_arr[$j]['align'] == 'center') { $column_style = 'text-align:center;'; } elseif ($header_arr[$j]['align'] == 'right') { $column_style = 'text-align:right;'; } } $column_style .= isset($header_arr[$j]['nowrap']) ? ' white-space:nowrap;' : ''; if (!empty($column_style)) { $admin_templates->set_var('column_style', 'style="' . $column_style . '"'); } else { $admin_templates->clear_var('column_style'); } $admin_templates->set_var('itemtext', $fieldvalue); # write field $admin_templates->parse('item_field', 'field', true); } if ($row_output) { # there was data in at least one field, so print line $r++; # switch to next color $admin_templates->set_var('cssid', $r % 2 + 1); # make alternating table color $admin_templates->parse('item_row', 'row', true); # process the complete row } $admin_templates->clear_var('item_field'); # clear field } if ($nrows == 0) { # there is no data. return notification message. $message = isset($no_data) ? $text_arr['no_data'] : $LANG_ADMIN['no_results']; $admin_templates->set_var('message', $message); } else { // $footer_cols = ($chkselect) ? $ncols + 1 : $ncols; // $admin_templates->set_var('footer_row', '<tr><td colspan="' . $footer_cols . '"><div style="margin:2px 0 2px 0;border-top:1px solid #cccccc"></div></td></tr>'); } // if we displayed data, and chkselect option is available, display the // actions row for all selected items. provide a delete action as a minimum if ($nrows > 0 and $chkselect) { $actions = '<td style="text-align:center;">' . '<img src="' . $_CONF['layout_url'] . '/images/admin/action.' . $_IMAGE_TYPE . '" alt="" /></td>'; $actions .= '<td colspan="' . $ncols . '">' . $LANG_ADMIN['action'] . ' '; if (empty($chkactions)) { $actions .= '<input name="delbutton" type="image" src="' . $_CONF['layout_url'] . '/images/admin/delete.' . $_IMAGE_TYPE . '" style="vertical-align:text-bottom;" title="' . $LANG01[124] . '" onclick="return confirm(\'' . $LANG01[125] . '\');"' . '/> ' . $LANG_ADMIN['delete']; } else { $actions .= $chkactions; } $actions .= '</td>'; $admin_templates->set_var('actions', $actions); $admin_templates->parse('action_row', 'arow', true); } // perform the paging if ($has_paging) { $hasargs = strstr($form_url, '?'); if ($hasargs) { $sep = '&'; } else { $sep = '?'; } if (!empty($query)) { # port query to next page $base_url = $form_url . $sep . 'q=' . urlencode($query) . "&query_limit={$query_limit}{$orderidx_link}&direction={$direction}"; } else { $base_url = $form_url . $sep . "query_limit={$query_limit}{$orderidx_link}&direction={$direction}"; } if ($num_pages > 1) { # print actual google-paging $admin_templates->set_var('google_paging', COM_printPageNavigation($base_url, $curpage, $num_pages, $component . 'listpage=')); } else { $admin_templates->set_var('google_paging', ''); } } // return the html output $admin_templates->parse('output', 'list'); $retval = !empty($title) ? COM_startBlock($title, $help_url, COM_getBlockTemplate('_admin_block', 'header')) : ''; $retval .= $admin_templates->finish($admin_templates->get_var('output')); $retval .= !empty($title) ? COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')) : ''; return $retval; }
/** * Creates the edit form * @param integer $id Optional ID, current record used if zero * @return string HTML for edit form */ public function Edit($eid = '', $rp_id = 0, $saveaction = '') { global $_CONF, $_EV_CONF, $_TABLES, $_USER, $LANG_EVLIST, $LANG_ADMIN, $_GROUPS, $LANG_ACCESS, $_SYSTEM; // If an eid is specified and this is an object, then read the // event data- UNLESS a repeat ID is given in which case we're // editing a repeat and already have the info we need. // This probably needs to change, since we should always read event // data during construction. if (!$this->isSubmitter) { // At least submit privilege required COM_404(); } elseif ($eid != '' && $rp_id == 0 && is_object($this)) { // If an id is passed in, then read that record if (!$this->Read($eid)) { return 'Invalid object ID'; } } elseif (isset($_POST['eid']) && !empty($_POST['eid'])) { // Returning to an existing form, probably due to errors $this->SetVars($_POST); // Make sure the current user has access to this event. if (!$this->hasAccess(3)) { COM_404(); } } $T = new Template($_CONF['path'] . 'plugins/evlist/templates/'); if ($_SYSTEM['disable_jquery_slimbox']) { $T->set_file('editor', 'editor.uikit.thtml'); } else { $T->set_file('editor', 'editor.thtml'); } // Basic tabs for editing both events and instances, show up on // all edit forms //$tabs = array('ev_info', 'ev_schedule', 'ev_location', 'ev_contact',); $tabs = array('ev_info', 'ev_location', 'ev_contact'); $rp_id = (int) $rp_id; if ($rp_id > 0) { // Make sure the current user has access to this event. if (!$this->hasAccess(3)) { COM_404(); } if ($saveaction == 'savefuturerepeat') { $alert_msg = EVLIST_alertMessage($LANG_EVLIST['editing_future'], 'warning'); } else { $alert_msg = EVLIST_alertMessage($LANG_EVLIST['editing_instance'], 'info'); } //$T->clear_var('contact_section'); $T->clear_var('category_section'); $T->clear_var('permissions_editor'); // Set the static calendar name for the edit form. Can't // change it for a single instance. $cal_name = DB_getItem($_TABLES['evlist_calendars'], 'cal_name', "cal_id='" . (int) $this->cal_id . "'"); $T->set_var(array('contact_section' => 'true', 'is_repeat' => 'true', 'cal_name' => $cal_name)); // Override our dates & times with those from the repeat. // $rp_id is passed when this is called from class evRepeat. // Maybe that should pass in the repeat's data instead to avoid // another DB lookup. An array of values could be used. $Rep = DB_fetchArray(DB_query("SELECT * \n FROM {$_TABLES['evlist_repeat']}\n WHERE rp_id='{$rp_id}'"), false); if ($Rep) { $this->date_start1 = $Rep['rp_date_start']; $this->date_end1 = $Rep['rp_date_end']; $this->time_start1 = $Rep['rp_time_start1']; $this->time_end1 = $Rep['rp_time_end1']; $this->time_start2 = $Rep['rp_time_start2']; $this->time_end2 = $Rep['rp_time_end2']; } } else { // Editing the main event record if ($this->id != '' && $this->recurring == 1) { $alert_msg = EVLIST_alertMessage($LANG_EVLIST['editing_series'], 'error'); } if ($this->isAdmin) { $tabs[] = 'ev_perms'; // Add permissions tab, event edit only $T->set_var('permissions_editor', 'true'); } $T->set_var(array('contact_section' => 'true', 'category_section' => 'true', 'upcoming_chk' => $this->show_upcoming ? EVCHECKED : '')); } $action_url = EVLIST_URL . '/event.php'; $delaction = 'delevent'; if (isset($_GET['from']) && $_GET['from'] == 'admin') { $cancel_url = EVLIST_ADMIN_URL . '/index.php'; } else { $cancel_url = EVLIST_URL . '/index.php'; } switch ($saveaction) { case 'saverepeat': case 'savefuturerepeat': case 'saveevent': break; case 'moderate': // Approving a submission $saveaction = 'approve'; $delaction = 'disapprove'; $action_url = EVLIST_ADMIN_URL . '/index.php'; $cancel_url = $_CONF['site_admin_url'] . '/moderation.php'; break; default: $saveaction = 'saveevent'; break; } $retval = ''; //$recinterval = ''; $recweekday = ''; $ownerusername = DB_getItem($_TABLES['users'], 'username', "uid='{$this->owner_id}'"); $retval .= COM_startBlock($LANG_EVLIST['event_editor']); $summary = $this->Detail->summary; $full_description = $this->Detail->full_description; $location = $this->Detail->location; if (($this->isAdmin || $_EV_CONF['allow_html'] == '1' && $_USER['uid'] > 1) && $A['postmode'] == 'html') { $postmode = '2'; //html } else { $postmode = '1'; //plaintext $summary = htmlspecialchars(COM_undoClickableLinks(COM_undoSpecialChars($this->Detail->summary))); $full_description = htmlspecialchars(COM_undoClickableLinks(COM_undoSpecialChars($this->Detail->full_description))); $location = htmlspecialchars(COM_undoClickableLinks(COM_undoSpecialChars($this->Detail->location))); } $starthour2 = ''; $startminute2 = ''; $endhour2 = ''; $endminute2 = ''; if ($this->date_end1 == '' || $this->date_end1 == '0000-00-00') { $this->date_end1 = $this->date_start1; } if ($this->date_start1 != '' && $this->date_start1 != '0000-00-00') { list($startmonth1, $startday1, $startyear1, $starthour1, $startminute1) = $this->DateParts($this->date_start1, $this->time_start1); } else { list($startmonth1, $startday1, $startyear1, $starthour1, $startminute1) = $this->DateParts(date('Y-m-d', time()), date('H:i:s', time())); } // The end date can't be before the start date if ($this->date_end1 >= $this->date_start1) { list($endmonth1, $endday1, $endyear1, $endhour1, $endminute1) = $this->DateParts($this->date_end1, $this->time_end1); $days_interval = Date_Calc::dateDiff($endday1, $endmonth1, $endyear1, $startday1, $startmonth1, $startyear1); } else { $days_interval = 0; $endmonth1 = $startmonth1; $endday1 = $startday1; $endyear1 = $startyear1; $endhour1 = $starthour1; $endminute1 = $startminute1; } if ($this->recurring != '1') { $T->set_var(array('recurring_show' => ' style="display:none;"', 'format_opt' => '0')); //for ($i = 1; $i <= 6; $i++) { // $T->set_var('format' . $i . 'show', ' style="display:none;"'); //} } else { $option = empty($this->rec_data['type']) ? '0' : (int) $this->rec_data['type']; $T->set_var(array('recurring_show' => '', 'recurring_checked' => EVCHECKED, 'format_opt' => $option)); } if (isset($this->rec_data['stop']) && !empty($this->rec_data['stop'])) { $T->set_var(array('stopdate' => $this->rec_data['stop'], 'd_stopdate' => EVLIST_formattedDate($this->rec_data['stop']))); } if (!empty($this->rec_data['skip'])) { $T->set_var("skipnext{$this->rec_data['skip']}_checked", EVCHECKED); } if (!empty($this->rec_data['freq'])) { $freq = (int) $this->rec_data['freq']; if ($freq < 1) { $freq = 1; } } else { $freq = 1; } $T->set_var(array('freq_text' => $LANG_EVLIST['rec_periods'][$this->rec_data['type']] . '(s)', 'rec_freq' => $freq)); foreach ($LANG_EVLIST['rec_intervals'] as $key => $str) { $T->set_var('dom_int_txt_' . $key, $str); if (is_array($this->rec_data['interval'])) { if (in_array($key, $this->rec_data['interval'])) { $T->set_var('dom_int_chk_' . $key, EVCHECKED); } } } // Set up the recurring options needed for the current event switch ($option) { case 0: break; case EV_RECUR_MONTHLY: if (is_array($this->rec_data['listdays'])) { foreach ($this->rec_data['listdays'] as $mday) { $T->set_var('mdchk' . $mday, EVCHECKED); } } break; case EV_RECUR_WEEKLY: $T->set_var('listdays_val', COM_stripslashes($rec_data[0])); if (is_array($this->rec_data['listdays']) && !empty($this->rec_data['listdays'])) { foreach ($this->rec_data['listdays'] as $day) { $day = (int) $day; if ($day > 0 && $day < 8) { $T->set_var('daychk' . $day, EVCHECKED); } } } break; case EV_RECUR_DOM: $recweekday = $this->rec_data['weekday']; break; case EV_RECUR_DATES: $T->set_var(array('stopshow' => 'style="display:none;"', 'custom_val' => implode(',', $this->rec_data['custom']))); break; } $start1 = EVLIST_TimeSelect('start1', $this->time_start1); $start2 = EVLIST_TimeSelect('start2', $this->time_start2); $end1 = EVLIST_TimeSelect('end1', $this->time_end1); $end2 = EVLIST_TimeSelect('end2', $this->time_end2); $cal_select = COM_optionList($_TABLES['evlist_calendars'], 'cal_id,cal_name', $this->cal_id, 1, 'cal_status = 1 ' . COM_getPermSQL('AND', 0, 2)); USES_class_navbar(); $navbar = new navbar(); $cnt = 0; foreach ($tabs as $id) { $navbar->add_menuitem($LANG_EVLIST[$id], 'showhideEventDiv("' . $id . '",' . $cnt . ');return false;', true); $cnt++; } $navbar->set_selected($LANG_EVLIST['ev_info']); if ($this->AdminMode) { $action_url .= '?admin=true'; } $T->set_var(array('action_url' => $action_url, 'navbar' => $navbar->generate(), 'alert_msg' => $alert_msg, 'cancel_url' => $cancel_url, 'eid' => $this->id, 'rp_id' => $rp_id, 'title' => $this->Detail->title, 'summary' => $summary, 'description' => $full_description, 'location' => $location, 'status_checked' => $this->status == 1 ? EVCHECKED : '', 'url' => $this->Detail->url, 'street' => $this->Detail->street, 'city' => $this->Detail->city, 'province' => $this->Detail->province, 'country' => $this->Detail->country, 'postal' => $this->Detail->postal, 'contact' => $this->Detail->contact, 'email' => $this->Detail->email, 'phone' => $this->Detail->phone, 'startdate1' => $this->date_start1, 'enddate1' => $this->date_end1, 'd_startdate1' => EVLIST_formattedDate($this->date_start1), 'd_enddate1' => EVLIST_formattedDate($this->date_end1), 'start_hour_options1' => $start1['hour'], 'start_minute_options1' => $start1['minute'], 'startdate1_ampm' => $start1['ampm'], 'end_hour_options1' => $end1['hour'], 'end_minute_options1' => $end1['minute'], 'enddate1_ampm' => $end1['ampm'], 'start_hour_options2' => $start2['hour'], 'start_minute_options2' => $start2['minute'], 'startdate2_ampm' => $start2['ampm'], 'end_hour_options2' => $end2['hour'], 'end_minute_options2' => $end2['minute'], 'enddate2_ampm' => $end2['ampm'], 'recurring_format_options' => EVLIST_GetOptions($LANG_EVLIST['rec_formats'], $option), 'recurring_weekday_options' => EVLIST_GetOptions(Date_Calc::getWeekDays(), $recweekday, 1), 'dailystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['day_by_date'], ''), 'monthlystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['year_and_month'], $LANG_EVLIST['if_any']), 'yearlystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['year'], $LANG_EVLIST['if_any']), 'listdays_label' => sprintf($LANG_EVLIST['custom_label'], $LANG_EVLIST['days_of_week'], ''), 'listdaystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['date_l'], $LANG_EVLIST['if_any']), 'intervalstop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['year_and_month'], $LANG_EVLIST['if_any']), 'custom_label' => sprintf($LANG_EVLIST['custom_label'], $LANG_EVLIST['dates'], ''), 'datestart_note' => $LANG_EVLIST['datestart_note'], 'src' => isset($_GET['src']) && $_GET['src'] == 'a' ? '1' : '0', 'rem_status_checked' => $this->enable_reminders == 1 ? EVCHECKED : '', 'del_button' => $this->id == '' ? '' : 'true', 'saveaction' => $saveaction, 'delaction' => $delaction, 'owner_id' => $this->owner_id, 'enable_reminders' => $_EV_CONF['enable_reminders'], 'iso_lang' => EVLIST_getIsoLang(), 'hour_mode' => $_CONF['hour_mode'], 'days_interval' => $days_interval, 'display_format' => $_CONF['shortdate'], 'ts_start' => strtotime($this->date_start1), 'ts_end' => strtotime($this->date_end1), 'cal_select' => $cal_select, 'contactlink_chk' => $this->options['contactlink'] == 1 ? EVCHECKED : '', 'lat' => $this->Detail->lat, 'lng' => $this->Detail->lng, 'perm_msg' => $LANG_ACCESS['permmsg'], 'last' => $LANG_EVLIST['rec_intervals'][5], 'doc_url' => EVLIST_getDocURL('event.html'), 'mootools' => $_SYSTEM['disable_mootools'] ? '' : 'true')); if ($_EV_CONF['enable_rsvp']) { USES_evlist_class_tickettype(); $TickTypes = evTicketType::GetTicketTypes(); //$T->set_block('editor', 'Tickets', 'tTypes'); $tick_opts = ''; foreach ($TickTypes as $tick_id => $tick_obj) { // Check enabled tickets. Ticket type 1 enabled by default if (isset($this->options['tickets'][$tick_id]) || $tick_id == 1) { $checked = 'checked="checked"'; $fee = (double) $this->options['tickets'][$tick_id]['fee']; } else { $checked = ''; $fee = 0; } $tick_opts .= '<tr><td><input name="tickets[' . $tick_id . ']" type="checkbox" ' . $checked . ' value="' . $tick_id . '" /></td>' . '<td>' . $tick_obj->description . '</td>' . '<td><input type="text" name="tick_fees[' . $tick_id . ']" value="' . $fee . '" size="8" /></td></tr>' . LB; /*$T->set_var(array( 'tick_id' => $tic['id'], 'tick_desc' => $tic['description'], 'tick_fee' => $fee, 'tick_enabled' => $enabled ? 'checked="checked"' : '', ) ) ; //$T->parse('tTypes', 'Tickets', true);*/ } if ($_EV_CONF['rsvp_print'] > 0) { $rsvp_print_chk = 'rsvp_print_chk' . $this->options['rsvp_print']; $rsvp_print = 'true'; } else { $rsvp_print = ''; $rsvp_print_chk = 'no_rsvp_print'; } $T->set_var(array('enable_rsvp' => 'true', 'reg_chk' . $this->options['use_rsvp'] => EVCHECKED, 'rsvp_wait_chk' => $this->options['rsvp_waitlist'] == 1 ? EVCHECKED : '', 'max_rsvp' => $this->options['max_rsvp'], 'max_user_rsvp' => $this->options['max_user_rsvp'], 'rsvp_cutoff' => $this->options['rsvp_cutoff'], 'use_rsvp' => $this->options['use_rsvp'], 'rsvp_waitlist' => $this->options['rsvp_waitlist'], 'tick_opts' => $tick_opts, 'rsvp_print' => $rsvp_print, $rsvp_print_chk => 'checked="checked"')); } // if rsvp_enabled // Split & All-Day settings if ($this->allday == 1) { // allday, can't be split, no times $T->set_var(array('starttime1_show' => 'style="display:none;"', 'endtime1_show' => 'style="display:none;"', 'datetime2_show' => 'style="display:none;"', 'allday_checked' => EVCHECKED, 'split_checked' => '', 'split_show' => 'style="display:none;"')); } elseif ($this->split == '1') { $T->set_var(array('split_checked' => EVCHECKED, 'allday_checked' => '', 'allday_show' => 'style="display:none"')); } else { $T->set_var(array('datetime2_show' => 'style="display:none;"')); } // Category fields. If $_POST['categories'] is set, then this is a // form re-entry due to an error saving. Populate checkboxes from the // submitted form. Include the user-added category, if any. // If not from a form re-entry, get the checked categories from the // evlist_lookup table. if ($_EV_CONF['enable_categories'] == '1') { $cresult = DB_query("SELECT tc.id, tc.name\n FROM {$_TABLES['evlist_categories']} tc \n WHERE tc.status='1' ORDER BY tc.name"); while ($A = DB_fetchArray($cresult, false)) { if (isset($_POST['categories']) && is_array($_POST['categories'])) { // Coming from a form re-entry $chk = in_array($A['id'], $_POST['categories']) ? EVCHECKED : ''; } else { $chk = in_array($A['id'], $this->categories) ? EVCHECKED : ''; } $catlist .= '<input type="checkbox" name="categories[]" ' . 'value="' . $A['id'] . '" ' . $chk . ' />' . ' ' . $A['name'] . ' '; } $T->set_var('catlist', $catlist); if (isset($_POST['newcat'])) { $T->set_var('newcat', $_POST['newcat']); } if ($_USER['uid'] > 1 && $rp_id == 0) { $T->set_var('category_section', 'true'); $T->set_var('add_cat_input', 'true'); } } // Enable the post mode selector if we allow HTML and the user is // logged in, or if this user is an authorized editor if ($this->isAdmin || $_EV_CONF['allow_html'] == '1' && $_USER['uid'] > 1) { $T->set_var(array('postmode_options' => EVLIST_GetOptions($LANG_EVLIST['postmodes'], $postmode), 'allowed_html' => COM_allowedHTML('evlist.submit'))); if ($postmode == 'plaintext') { // plaintext, hide postmode selector $T->set_var('postmode_show', ' style="display:none"'); } $T->parse('event_postmode', 'edit_postmode'); } if ($this->isAdmin) { $T->set_var(array('owner_username' => COM_stripslashes($ownerusername), 'owner_dropdown' => COM_optionList($_TABLES['users'], 'uid,username', $this->owner_id, 1, "uid <> 1"), 'group_dropdown' => SEC_getGroupDropdown($this->group_id, 3))); if ($rp_id == 0) { // can only change permissions on main event $T->set_var('permissions_editor', SEC_getPermissionsHTML($this->perm_owner, $this->perm_group, $this->perm_members, $this->perm_anon)); } } else { $T->set_var('group_id', $this->group_id); } // Latitude & Longitude part of location, if Location plugin is used if ($_EV_CONF['use_locator']) { $T->set_var(array('use_locator' => 'true', 'loc_selection' => GEO_optionList())); } $T->parse('output', 'editor'); $retval .= $T->finish($T->get_var('output')); $retval .= COM_endBlock(); return $retval; }
/** * Creates a list of data with a search, filter, clickable headers etc. * * @param string $component name of the list * @param string $fieldfunction name of the function that handles special entries * @param array $header_arr array of header fields with sortables and table fields * @param array $text_arr array with different text strings * @param array $query_arr array with sql-options * @param array $defsort_arr default sorting values * @param string $filter additional drop-down filters * @param string $extra additional values passed to fieldfunction * @param array $options array of options - intially just used for the Check-All feature * @param array $form_arr optional extra forms at top or bottom * @return string HTML output of function * */ function ADMIN_list($component, $fieldfunction, $header_arr, $text_arr, $query_arr, $defsort_arr, $filter = '', $extra = '', $options = '', $form_arr = '') { global $_CONF, $_TABLES, $LANG_ADMIN, $LANG_ACCESS, $LANG01, $_IMAGE_TYPE, $MESSAGE; // set all variables to avoid warnings $retval = ''; $filter_str = ''; $order_sql = ''; $limit = ''; $prevorder = ''; if (isset($_GET['prevorder'])) { # what was the last sorting? $prevorder = COM_applyFilter($_GET['prevorder']); } $query = ''; if (isset($_REQUEST['q'])) { // get query (text-search) $query = strip_tags(COM_stripslashes($_REQUEST['q'])); } $query_limit = ''; if (isset($_REQUEST['query_limit'])) { // get query-limit (list-length) $query_limit = COM_applyFilter($_REQUEST['query_limit'], true); if ($query_limit == 0) { $query_limit = 50; } } // we assume that the current page is 1 to set it. $curpage = 1; $page = ''; // get the current page from the interface. The variable is linked to the // component, i.e. the plugin/function calling this here to avoid overlap if (isset($_REQUEST[$component . 'listpage'])) { $page = COM_applyFilter($_REQUEST[$component . 'listpage'], true); $curpage = $page; } if ($curpage <= 0) { $curpage = 1; #current page has to be larger 0 } $help_url = ''; # do we have a help url for the block-header? if (!empty($text_arr['help_url'])) { $help_url = $text_arr['help_url']; } $form_url = ''; # what is the form-url for the search button and list sorters? if (!empty($text_arr['form_url'])) { $form_url = $text_arr['form_url']; } $title = ''; # what is the title of the page? if (!empty($text_arr['title'])) { $title = $text_arr['title']; } $inline_form = false; if (isset($text_arr['inline'])) { $inline_form = $text_arr['inline']; } # get all template fields. $admin_templates = new Template($_CONF['path_layout'] . 'admin/lists'); $admin_templates->set_file(array('search' => 'searchmenu.thtml', 'list' => $inline_form ? 'inline.thtml' : 'list.thtml', 'header' => 'header.thtml', 'row' => 'listitem.thtml', 'field' => 'field.thtml')); # insert std. values into the template $admin_templates->set_var('xhtml', XHTML); $admin_templates->set_var('site_url', $_CONF['site_url']); $admin_templates->set_var('site_admin_url', $_CONF['site_admin_url']); $admin_templates->set_var('layout_url', $_CONF['layout_url']); $admin_templates->set_var('form_url', $form_url); $admin_templates->set_var('lang_edit', $LANG_ADMIN['edit']); $admin_templates->set_var('lang_deleteall', $LANG01[124]); $admin_templates->set_var('lang_delconfirm', $LANG01[125]); if (isset($form_arr['top'])) { $admin_templates->set_var('formfields_top', $form_arr['top']); } if (isset($form_arr['bottom'])) { $admin_templates->set_var('formfields_bottom', $form_arr['bottom']); } // Check if the delete checkbox and support for the delete all feature should be displayed if (is_array($options) and $options['chkdelete']) { $admin_templates->set_var('header_text', '<input type="checkbox" name="chk_selectall" title="' . $LANG01[126] . '" onclick="caItems(this.form);"' . XHTML . '>'); $admin_templates->set_var('class', "admin-list-field"); $admin_templates->set_var('show_deleteimage', ''); $admin_templates->parse('header_row', 'header', true); $admin_templates->clear_var('on_click'); } else { $admin_templates->set_var('show_deleteimage', 'display:none;'); } # define icon paths. Those will be transmitted to $fieldfunction. $icons_type_arr = array('edit', 'copy', 'list', 'addchild'); $icon_arr = array(); foreach ($icons_type_arr as $icon_type) { $icon_url = "{$_CONF['layout_url']}/images/{$icon_type}.{$_IMAGE_TYPE}"; $icon_arr[$icon_type] = COM_createImage($icon_url, $LANG_ADMIN[$icon_type]); } $has_extras = ''; if (isset($text_arr['has_extras'])) { # does this one use extras? (search, google paging) $has_extras = $text_arr['has_extras']; } if ($has_extras) { // show search $admin_templates->set_var('lang_search', $LANG_ADMIN['search']); $admin_templates->set_var('lang_submit', $LANG_ADMIN['submit']); $admin_templates->set_var('lang_limit_results', $LANG_ADMIN['limit_results']); $admin_templates->set_var('last_query', htmlspecialchars($query)); $admin_templates->set_var('filter', $filter); } $sql_query = addslashes($query); // replace quotes etc for security $sql = $query_arr['sql']; // get sql from array that builds data $order_var = ''; # number that is displayed in URL $order = ''; # field that is used in SQL $order_var_link = ''; # Variable for google paging. // is the order set in the link (when sorting the list) if (!isset($_GET['order'])) { $order = $defsort_arr['field']; // no, get the default } else { $order_var = COM_applyFilter($_GET['order'], true); $order_var_link = "&order={$order_var}"; # keep the variable for the google paging $order = $header_arr[$order_var]['field']; # current order field name } $order_for_query = $order; // this code sorts only by the field if its in table.field style. // removing this however makes match for arrow-display impossible, so removed it. // maybe now for more fields the table has to be added to the sortfield? //$order = explode ('.', $order); //if (count ($order) > 1) { // $order = $order[1]; //} else { // $order = $order[0]; //} $direction = ''; if (!isset($_GET['direction'])) { # get direction to sort after $direction = $defsort_arr['direction']; } else { $direction = COM_applyFilter($_GET['direction']); } $direction = strtoupper($direction); if ($order == $prevorder) { #reverse direction if prev. order was the same $direction = $direction == 'DESC' ? 'ASC' : 'DESC'; } else { $direction = $direction == 'DESC' ? 'DESC' : 'ASC'; } if ($direction == 'ASC') { # assign proper arrow img name dep. on sort order $arrow = 'bararrowdown'; } else { $arrow = 'bararrowup'; } # make actual order arrow image $img_arrow_url = "{$_CONF['layout_url']}/images/{$arrow}.{$_IMAGE_TYPE}"; $img_arrow = ' ' . COM_createImage($img_arrow_url, $arrow); if (!empty($order_for_query)) { # concat order string $order_sql = "ORDER BY {$order_for_query} {$direction}"; } $th_subtags = ''; // other tags in the th, such as onclick and mouseover $header_text = ''; // title as displayed to the user // HEADER FIELDS array(text, field, sort, class) // this part defines the contents & format of the header fields for ($i = 0; $i < count($header_arr); $i++) { #iterate through all headers $header_text = $header_arr[$i]['text']; $th_subtags = ''; if ($header_arr[$i]['sort'] != false) { # is this sortable? if ($order == $header_arr[$i]['field']) { # is this currently sorted? $header_text .= $img_arrow; } # make the mouseover effect is sortable $th_subtags = " onmouseover=\"this.style.cursor='pointer';\""; $order_var = $i; # assign number to field so we know what to sort if (strpos($form_url, '?') > 0) { $separator = '&'; } else { $separator = '?'; } $th_subtags .= " onclick=\"window.location.href='{$form_url}{$separator}" . "order={$order_var}&prevorder={$order}&direction={$direction}"; if (!empty($page)) { $th_subtags .= '&' . $component . 'listpage=' . $page; } if (!empty($query)) { $th_subtags .= '&q=' . urlencode($query); } if (!empty($query_limit)) { $th_subtags .= '&query_limit=' . $query_limit; } $th_subtags .= "';\""; } if (!empty($header_arr[$i]['header_class'])) { $admin_templates->set_var('class', $header_arr[$i]['header_class']); } else { $admin_templates->set_var('class', "admin-list-headerfield"); } $admin_templates->set_var('header_text', $header_text); $admin_templates->set_var('th_subtags', $th_subtags); $admin_templates->parse('header_row', 'header', true); $admin_templates->clear_var('th_subtags'); // clear all for next header $admin_templates->clear_var('class'); $admin_templates->clear_var('header_text'); } if ($has_extras) { $limit = 50; # default query limit if not other chosen. # maybe this could be a setting from the list? if (!empty($query_limit)) { $limit = $query_limit; } if ($query != '') { # set query into form after search $admin_templates->set_var('query', urlencode($query)); } else { $admin_templates->set_var('query', ''); } $admin_templates->set_var('query_limit', $query_limit); # choose proper dropdown field for query limit $admin_templates->set_var($limit . '_selected', 'selected="selected"'); if (!empty($query_arr['default_filter'])) { # add default filter to sql $filter_str = " {$query_arr['default_filter']}"; } if (!empty($query)) { # add query fields with search term $filter_str .= " AND ("; for ($f = 0; $f < count($query_arr['query_fields']); $f++) { $filter_str .= $query_arr['query_fields'][$f] . " LIKE '%{$sql_query}%'"; if ($f < count($query_arr['query_fields']) - 1) { $filter_str .= " OR "; } } $filter_str .= ")"; } $num_pages_sql = $sql . $filter_str; $num_pages_result = DB_query($num_pages_sql); $num_rows = DB_numRows($num_pages_result); $num_pages = ceil($num_rows / $limit); if ($num_pages < $curpage) { # make sure we dont go beyond possible results $curpage = 1; } $offset = ($curpage - 1) * $limit; $limit = "LIMIT {$offset},{$limit}"; # get only current page data $admin_templates->set_var('lang_records_found', $LANG_ADMIN['records_found']); $admin_templates->set_var('records_found', COM_numberFormat($num_rows)); $admin_templates->parse('search_menu', 'search', true); } # SQL $sql .= "{$filter_str} {$order_sql} {$limit};"; // echo $sql; $result = DB_query($sql); $nrows = DB_numRows($result); $r = 1; # r is the counter for the actual displayed rows for correct coloring for ($i = 0; $i < $nrows; $i++) { # now go through actual data $A = DB_fetchArray($result); $this_row = false; # as long as no fields are returned, dont print row if (is_array($options) and $options['chkdelete']) { $admin_templates->set_var('class', "admin-list-field"); $admin_templates->set_var('itemtext', '<input type="checkbox" name="delitem[]" value="' . $A[$options['chkfield']] . '"' . XHTML . '>'); $admin_templates->parse('item_field', 'field', true); } for ($j = 0; $j < count($header_arr); $j++) { $fieldname = $header_arr[$j]['field']; # get field name from headers $fieldvalue = ''; if (!empty($A[$fieldname])) { # is there a field in data like that? $fieldvalue = $A[$fieldname]; # yes, get its data } if (!empty($fieldfunction) && !empty($extra)) { $fieldvalue = $fieldfunction($fieldname, $fieldvalue, $A, $icon_arr, $extra); } else { if (!empty($fieldfunction)) { # do we have a fieldfunction? $fieldvalue = $fieldfunction($fieldname, $fieldvalue, $A, $icon_arr); } else { # if not just take the value $fieldvalue = $fieldvalue; } } if ($fieldvalue !== false) { # return was there, so write line $this_row = true; } else { $fieldvalue = ''; // dont give emtpy fields } if (!empty($header_arr[$j]['field_class'])) { $admin_templates->set_var('class', $header_arr[$j]['field_class']); } else { $admin_templates->set_var('class', "admin-list-field"); } $admin_templates->set_var('itemtext', $fieldvalue); # write field $admin_templates->parse('item_field', 'field', true); } if ($this_row) { # there was data in at least one field, so print line $r++; # switch to next color $admin_templates->set_var('cssid', $r % 2 + 1); # make alternating table color $admin_templates->parse('item_row', 'row', true); # process the complete row } $admin_templates->clear_var('item_field'); # clear field } if ($nrows == 0) { # there is no data. return notification message. if (isset($text_arr['no_data'])) { $message = $text_arr['no_data']; # there is a user-message } else { $message = $LANG_ADMIN['no_results']; # take std. } $admin_templates->set_var('message', $message); } if ($has_extras) { # now make google-paging $hasargs = strstr($form_url, '?'); if ($hasargs) { $sep = '&'; } else { $sep = '?'; } if (!empty($query)) { # port query to next page $base_url = $form_url . $sep . 'q=' . urlencode($query) . "&query_limit={$query_limit}{$order_var_link}&direction={$direction}"; } else { $base_url = $form_url . $sep . "query_limit={$query_limit}{$order_var_link}&direction={$direction}"; } if ($num_pages > 1) { # print actual google-paging $admin_templates->set_var('google_paging', COM_printPageNavigation($base_url, $curpage, $num_pages, $component . 'listpage=')); } else { $admin_templates->set_var('google_paging', ''); } } $admin_templates->parse('output', 'list'); // Do the actual output if (!empty($title)) { $retval .= COM_startBlock($title, $help_url, COM_getBlockTemplate('_admin_block', 'header')); } $retval .= $admin_templates->finish($admin_templates->get_var('output')); if (!empty($title)) { $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); } return $retval; }
if (!is_file(DirectoryHandler::DecodePath($thumb))) { FG_createThumb($file, $bildfilename, $pathToThumb, $settings['tbSettings']); } //Chio Ende $bilder[] = array('id' => $result['id'], 'file_name' => $bildfilename, 'caption' => $result['caption'], 'thumb_link' => $urlToThumb . $bildfilename); } } else { // Diese Kategorie enthält noch keine Bilder $error['noimages'] = 1; } //Template $t = new Template(dirname(__FILE__) . '/templates', 'remove'); $t->set_file('modify_cat', 'modify_cat.htt'); // clear the comment-block, if present $t->set_block('modify_cat', 'CommentDoc'); $t->clear_var('CommentDoc'); // set other blocks $t->set_block('modify_cat', 'file_loop', 'FILE_LOOP'); // Textvariablen parsen $t->set_var(array('MODIFY_CAT_TITLE' => $MOD_FOLDERGALLERY['MODIFY_CAT_TITLE'], 'MODIFY_CAT_STRING' => $MOD_FOLDERGALLERY['MODIFY_CAT'], 'FOLDER_IN_FS_STRING' => $MOD_FOLDERGALLERY['FOLDER_IN_FS'], 'FOLDER_IN_FS_VALUE' => $cat_path, 'CAT_ACTIVE_CHECKED' => $cat_active_checked, 'CAT_ACTIVE_STRING' => $MOD_FOLDERGALLERY['ACTIVE'], 'CAT_NAME_STRING' => $MOD_FOLDERGALLERY['CAT_NAME'], 'CAT_NAME_VALUE' => $categorie['cat_name'], 'CAT_DESCRIPTION_STRING' => $MOD_FOLDERGALLERY['CAT_DESCRIPTION'], 'CAT_DESCRIPTION_VALUE' => $categorie['description'], 'MODIFY_IMG_STRING' => $MOD_FOLDERGALLERY['MODIFY_IMG'], 'IMAGE_STRING' => $MOD_FOLDERGALLERY['IMAGE'], 'IMAGE_NAME_STRING' => $MOD_FOLDERGALLERY['IMAGE_NAME'], 'IMAGE_CAPTION_STRING' => $MOD_FOLDERGALLERY['IMG_CAPTION'], 'IMAGE_ACTION_STRING' => $MOD_FOLDERGALLERY['ACTION'], 'SAVE_STRING' => $TEXT['SAVE'], 'CANCEL_STRING' => $TEXT['CANCEL'], 'SORT_IMAGES_STRING' => $MOD_FOLDERGALLERY['SORT_IMAGE'], 'SECTION_ID_VALUE' => $section_id, 'PAGE_ID_VALUE' => $page_id, 'CAT_ID_VALUE' => $cat_id, 'IMAGE_DELETE_ALT' => $MOD_FOLDERGALLERY['IMAGE_DELETE_ALT'], 'THUMB_EDIT_ALT' => $MOD_FOLDERGALLERY['THUMB_EDIT_ALT'], 'EDIT_THUMB_SOURCE' => THEME_URL . '/images/resize_16.png', 'DELETE_IMG_SOURCE' => THEME_URL . '/images/delete_16.png', 'UPLOAD_FOLDER' => $uploadPath, 'UPLOAD_SEC_NUM' => $page_id . '/' . $section_id . '/' . $cat_id, 'ADD_MORE_PICS_TITLE' => $MOD_FOLDERGALLERY['ADD_MORE_PICS'])); // Links parsen $t->set_var(array('SAVE_CAT_LINK' => WB_URL . '/modules/foldergallery/admin/save_cat.php?page_id=' . $page_id . '§ion_id=' . $section_id . '&cat_id=' . $cat_id, 'SAVE_FILES_LINK' => WB_URL . '/modules/foldergallery/admin/save_files.php?page_id=' . $page_id . '§ion_id=' . $section_id . '&cat_id=' . $cat_id, 'CANCEL_ONCLICK' => 'javascript: window.location = \'' . ADMIN_URL . '/pages/modify.php?page_id=' . $page_id . '\';')); // parse Images foreach ($bilder as $bild) { $t->set_var(array('ID_VALUE' => $bild['id'], 'IMAGE_VALUE' => $bild['thumb_link'] . '?t=' . time(), 'IMAGE_NAME_VALUE' => $bild['file_name'], 'CAPTION_VALUE' => $bild['caption'], 'THUMB_EDIT_LINK' => WB_URL . "/modules/foldergallery/admin/modify_thumb.php?page_id=" . $page_id . "§ion_id=" . $section_id . "&cat_id=" . $cat_id . "&id=" . $bild['id'], 'IMAGE_DELETE_LINK' => "javascript: confirm_link(\"" . $MOD_FOLDERGALLERY['DELETE_ARE_YOU_SURE'] . "\", \"" . WB_URL . "/modules/foldergallery/admin/scripts/delete_img.php?page_id=" . $page_id . "§ion_id=" . $section_id . "&cat_id=" . $cat_id . "&id=" . $bild['id'] . "\");", 'COUNTER' => $bild['id'], 'EDIT_THUMB_SOURCE' => THEME_URL . '/images/resize_16.png', 'DELETE_IMG_SOURCE' => THEME_URL . '/images/delete_16.png')); $t->parse('FILE_LOOP', 'file_loop', true); } $t->pparse('output', 'modify_cat'); // reset the mySQL encoding mysql_set_charset($oldMysqlEncoding, $database->db_handle); $admin->print_footer();
/** * Diaplay the product catalog items. * * @return string HTML for product catalog. */ function PAYPAL_ProductList($cat = 0, $search = '') { global $_TABLES, $_CONF, $_PP_CONF, $LANG_PP, $_USER, $_PLUGINS, $_IMAGE_TYPE, $_GROUPS; USES_paypal_class_product(); if (SEC_hasRights('paypal.admin')) { $isAdmin = true; } else { $isAdmin = false; } $my_groups = implode(',', $_GROUPS); $cat_name = ''; $breadcrumbs = ''; $img_url = ''; $display = ''; if ($cat != 0) { $breadcrumbs = PAYPAL_Breadcrumbs($cat); $cat = (int) $cat; $A = DB_fetchArray(DB_query("SELECT cat_name, image\n FROM {$_TABLES['paypal.categories']}\n WHERE cat_id='{$cat}' " . COM_getPermSQL('AND')), false); if (!empty($A)) { $cat_name = $A['cat_name']; if (!empty($A['image']) && is_file($_CONF['path_html'] . $_PP_CONF['pi_name'] . '/images/categories/' . $A['image'])) { $img_url = PAYPAL_URL . '/images/categories/' . $A['image']; } } } // Display categories if (isset($_PP_CONF['cat_columns']) && $_PP_CONF['cat_columns'] > 0) { $sql = "SELECT cat.cat_id, cat.cat_name, count(prod.id) AS cnt \n FROM {$_TABLES['paypal.categories']} cat\n LEFT JOIN {$_TABLES['paypal.products']} prod\n ON prod.cat_id = cat.cat_id\n WHERE cat.enabled = '1' AND cat.parent_id = '{$cat}' \n AND prod.enabled = '1' " . COM_getPermSQL('AND', 0, 2, 'cat') . " GROUP BY cat.cat_id\n ORDER BY cat.cat_name"; //HAVING cnt > 0 //echo $sql;die; $CT = new Template(PAYPAL_PI_PATH . '/templates'); $CT->set_file(array('table' => 'category_table.thtml', 'row' => 'category_row.thtml', 'category' => 'category.thtml')); $CT->set_var('width', floor(100 / $_PP_CONF['cat_columns'])); if ($breadcrumbs != '') { $CT->set_var('breadcrumbs', $breadcrumbs); } if ($img_url != '') { $CT->set_var('catimg_url', $img_url); } $res = DB_query($sql); $A = array(); while ($C = DB_fetchArray($res, false)) { $A[$C['cat_id']] = array($C['cat_name'], $C['cnt']); } // Now get categories from plugins foreach ($_PLUGINS as $pi_name) { $function = 'USES_' . $pi_name . '_paypal'; if (function_exists($function)) { $function(); $function = 'plugin_paypal_getcategories_' . $pi_name; if (function_exists($function)) { $pi_cats = $function(); foreach ($pi_cats as $catid => $data) { $A[$catid] = $data; } } } } $i = 1; $nrows = count($A); foreach ($A as $category => $info) { $CT->set_var(array('category_name' => $info[0], 'category_link' => PAYPAL_URL . '/index.php?category=' . urlencode($category))); /*if ($category == $cat) { $CT->set_var('curr', 'current'); $cat_name = $info[0]; } else { $CT->set_var('curr', 'other'); }*/ $CT->parse('catrow', 'category', true); if ($i % $_PP_CONF['cat_columns'] == 0) { $CT->parse('categories', 'row', true); $CT->set_var('catrow', ''); } $i++; } if ($nrows % $_PP_CONF['cat_columns'] != 0) { $CT->parse('categories', 'row', true); } $display .= $CT->parse('', 'table'); } /*$sortby_opts = array( 'name' => $LANG_PP['name'], 'price' => $LANG_PP['price'], 'dt_add' => $LANG_PP['dt_add'], ); switch ($_REQUEST['sortby']){ case 'name': case 'price': case 'dt_add': $sortby = $_REQUEST['sortby']; break; default: $sortby = $_PP_CONF['order']; break; } $sortby_options = ''; foreach ($sortby_opts as $value=>$text) { $sel = $value == $sortby ? ' selected="selected"' : ''; $sortby_options .= "<option value=\"$value\" $sel>$text</option>\n"; } $sortdir = $_REQUEST['sortdir'] == 'DESC' ? 'DESC' : 'ASC';*/ $sortby = $_PP_CONF['order']; $sortdir = 'ASC'; // Get products from database. "c.enabled is null" is to allow products // with no category defined $sql = " FROM {$_TABLES['paypal.products']} p\n LEFT JOIN {$_TABLES['paypal.categories']} c\n ON p.cat_id = c.cat_id\n WHERE p.enabled=1 \n AND (\n (c.enabled=1 " . COM_getPermSQL('AND', 0, 2, 'c') . ")\n OR c.enabled IS NULL\n )\n AND (\n p.track_onhand = 0 OR p.onhand > 0 OR p.oversell < 2\n )"; $pagenav_args = array(); // If applicable, limit by category if (!empty($_REQUEST['category'])) { $cat_list = $_REQUEST['category']; $cat_list .= PAYPAL_recurseCats('PAYPAL_callbackCatCommaList', 0, $_REQUEST['category']); if (!empty($cat_list)) { $sql .= " AND c.cat_id IN ({$cat_list})"; } $pagenav_args[] = 'category=' . urlencode($_REQUEST['category']); } else { $cat_list = ''; } // If applicable, limit by search string if (!empty($_REQUEST['search_name'])) { $srch = DB_escapeString($_REQUEST['search_name']); $sql .= " AND (p.name like '%{$srch}%' OR \n p.short_description like '%{$srch}%' OR\n p.description like '%{$srch}%' OR\n p.keywords like '%{$srch}%')"; //if (!$isAdmin) $sql .= " AND p.grp_access IN ($my_groups) "; $pagenav_args[] = 'search_name=' . urlencode($_REQUEST['search_name']); } // If applicable, order by $sql .= " ORDER BY {$sortby} {$sortdir}"; // If applicable, handle pagination of query if (isset($_PP_CONF['prod_per_page']) && $_PP_CONF['prod_per_page'] > 0) { // Count products from database $res = DB_query('SELECT COUNT(*) as cnt ' . $sql); $x = DB_fetchArray($res, false); if (isset($x['cnt'])) { $count = (int) $x['cnt']; } else { $count = 0; } // Make sure page requested is reasonable, if not, fix it if (!isset($_REQUEST['page']) || $_REQUEST['page'] <= 0) { $_REQUEST['page'] = 1; } $page = (int) $_REQUEST['page']; $start_limit = ($page - 1) * $_PP_CONF['prod_per_page']; if ($start_limit > $count) { $page = ceil($count / $_PP_CONF['prod_per_page']); } // Add limit for pagination (if applicable) if ($count > $_PP_CONF['prod_per_page']) { $sql .= " LIMIT {$start_limit}, {$_PP_CONF['prod_per_page']}"; } } // Re-execute query with the limit clause in place $res = DB_query('SELECT DISTINCT p.id ' . $sql); // Create product template $product = new Template(PAYPAL_PI_PATH . '/templates'); $product->set_file(array('start' => 'product_list_start.thtml', 'end' => 'product_list_end.thtml', 'product' => 'product_list_item.thtml', 'download' => 'buttons/btn_download.thtml', 'login_req' => 'buttons/btn_login_req.thtml', 'btn_details' => 'buttons/btn_details.thtml')); if ($nrows == 0 && COM_isAnonUser()) { $product->set_var('anon_and_empty', 'true'); } $product->set_var(array('pi_url' => PAYPAL_URL, 'user_id' => $_USER['uid'], 'currency' => $_PP_CONF['currency'])); if (!empty($cat_name)) { $product->set_var('title', $cat_name); } else { $product->set_var('title', $LANG_PP['blocktitle']); } /*$product->set_var('sortby_options', $sortby_options); if ($sortdir == 'DESC') { $product->set_var('sortdir_desc_sel', ' selected="selected"'); } else { $product->set_var('sortdir_asc_sel', ' selected="selected"'); } $product->set_var('sortby', $sortby); $product->set_var('sortdir', $sortdir);*/ $display .= $product->parse('', 'start'); // Create an empty product object $P = new Product(); if ($_PP_CONF['ena_ratings'] == 1) { $PP_ratedIds = RATING_getRatedIds('paypal'); } // Display each product while ($A = DB_fetchArray($res, false)) { $P->Read($A['id']); if ($_PP_CONF['ena_ratings'] == 1 && $P->rating_enabled == 1) { if (in_array($A['id'], $PP_ratedIds)) { $static = true; $voted = 1; } elseif (plugin_canuserrate_paypal($A['id'], $_USER['uid'])) { $static = false; $voted = 0; } else { $static = true; $voted = 0; } $rating_box = RATING_ratingBar('paypal', $A['id'], $P->votes, $P->rating, $voted, 5, $static, 'sm'); $product->set_var('rating_bar', $rating_box); } else { $product->set_var('rating_bar', ''); } $product->set_var(array('id' => $A['id'], 'name' => $P->name, 'short_description' => PLG_replacetags($P->short_description), 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'encrypted' => '', 'item_url' => COM_buildURL(PAYPAL_URL . '/detail.php?id=' . $A['id']), 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'track_onhand' => $P->track_onhand ? 'true' : '', 'qty_onhand' => $P->onhand)); if ($P->price > 0) { //$product->set_var('price', COM_numberFormat($P->price, 2)); $product->set_var('price', $P->currency->Format($P->price)); } else { $product->clear_var('price'); } if ($isAdmin) { $product->set_var('is_admin', 'true'); $product->set_var('pi_admin_url', PAYPAL_ADMIN_URL); $product->set_var('edit_icon', "{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}"); } $pic_filename = DB_getItem($_TABLES['paypal.images'], 'filename', "product_id = '{$A['id']}'"); if ($pic_filename) { $product->set_var('small_pic', PAYPAL_ImageUrl($pic_filename)); } else { $product->set_var('small_pic', ''); } // FIXME: If a user purchased once with no expiration, this query // will not operate correctly /*$time = DB_getItem($_TABLES['paypal.purchases'], 'MAX(UNIX_TIMESTAMP(expiration))', "user_id = {$_USER['uid']} AND product_id ='{$A['id']}'"); */ $product->set_block('product', 'BtnBlock', 'Btn'); if (!$P->hasAttributes()) { // Buttons only show in the list if there are no options to select $buttons = $P->PurchaseLinks(); foreach ($buttons as $name => $html) { $product->set_var('button', $html); $product->parse('Btn', 'BtnBlock', true); } } else { if ($_PP_CONF['ena_cart']) { // If the product has attributes, then the cart must be // enabled to allow purchasing $button = $product->parse('', 'btn_details') . ' '; $product->set_var('button', $button); $product->parse('Btn', 'BtnBlock', true); } } $display .= $product->parse('', 'product'); $product->clear_var('Btn'); } // Get products from plugins. // For now, this hack shows plugins only on the first page, since // they're not included in the page calculation. if ($page == 1 && empty($cat_list)) { // Get the currency class for formatting prices USES_paypal_class_currency(); $Cur = new ppCurrency($_PP_CONF['currency']); $product->clear_var('rating_bar'); // no ratings for plugins (yet) foreach ($_PLUGINS as $pi_name) { $status = LGLIB_invokeService($pi_name, 'getproducts', array(), $plugin_data, $svc_msg); if ($status != PLG_RET_OK || empty($plugin_data)) { continue; } foreach ($plugin_data as $A) { // Reset button values $buttons = ''; $product->set_var(array('id' => $A['id'], 'name' => $A['name'], 'short_description' => $A['short_description'], 'display' => '; display: none', 'small_pic' => '', 'encrypted' => '', 'item_url' => $A['url'], 'track_onhand' => '')); if ($A['price'] > 0) { $product->set_var('price', $Cur->Format($A['price'])); } else { $product->clear_var('price'); } if ($A['price'] > 0 && $_USER['uid'] == 1 && !$_PP_CONF['anon_buy']) { $buttons .= $product->set_var('', 'login_req') . ' '; } elseif ($A['prod_type'] > PP_PROD_PHYSICAL && $A['price'] == 0) { // Free items or items purchases and not expired, download. $buttons .= $product->set_var('', 'download') . ' '; } elseif (is_array($A['buttons'])) { // Buttons for everyone else $product->set_block('product', 'BtnBlock', 'Btn'); foreach ($A['buttons'] as $type => $html) { $product->set_var('button', $html); $product->parse('Btn', 'BtnBlock', true); } } //$product->set_var('buttons', $buttons); $display .= $product->parse('', 'product'); $product->clear_var('Btn'); } // foreach plugin_data } // foreach $_PLUGINS } // if page == 1 $pagenav_args = empty($pagenav_args) ? '' : '?' . implode('&', $pagenav_args); // Display pagination if (isset($_PP_CONF['prod_per_page']) && $_PP_CONF['prod_per_page'] > 0 && $count > $_PP_CONF['prod_per_page']) { $product->set_var('pagination', COM_printPageNavigation(PAYPAL_URL . '/index.php' . $pagenav_args, $page, ceil($count / $_PP_CONF['prod_per_page']))); } else { $product->set_var('pagination', ''); } $display .= $product->parse('', 'end'); return $display; }
function MG_index() { global $_USER, $_MG_CONF, $_CONF, $_TABLES, $MG_albums, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $themeStyle; $display = ''; $media_size = false; $page = 0; if (isset($_GET['page'])) { $page = COM_applyFilter($_GET['page'], true); } if ($page != 0) { $page = $page - 1; } $themeStyle = MG_getThemeCSS(0); if (!isset($_MG_CONF['album_display_columns']) || $_MG_CONF['album_display_columns'] < 1) { $_MG_CONF['album_display_columns'] = 1; } switch ($_MG_CONF['album_display_columns']) { case 1: $albumListTemplate = 'gallery_page_body_1.thtml'; $albumColumnWidth = "100%"; break; case 2: $albumListTemplate = 'gallery_page_body_2.thtml'; $albumColumnWidth = "50%"; break; default: $albumListTemplate = 'gallery_page_body_3.thtml'; $albumColumnWidth = @intval(100 / $_MG_CONF['album_display_columns']) . '%'; if ($albumColumnWidth == 0) { $albumColumnWidth = "25%"; } break; } $T = new Template(MG_getTemplatePath(0)); $T->set_file(array('page' => 'gallery_page.thtml', 'body' => $albumListTemplate, 'noitems' => 'gallery_page_noitems.thtml')); $T->set_var(array('lang_menulabel' => $_MG_CONF['menulabel'], 'lang_search' => $LANG_MG01['search'], 'site_url' => $_MG_CONF['site_url'])); if ($_MG_CONF['rss_full_enabled']) { $feedUrl = MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss'); $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">'; $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" alt="" style="border:none;"/></a>'; $T->set_var('rsslink', $rsslink); $T->set_var('rsslink_url', $feedUrl); } else { $T->set_var('rsslink', ''); } $nFrame = new mgFrame(); $nFrame->constructor($_MG_CONF['indexskin']); $MG_albums[0]->albumFrameTemplate = $nFrame->getTemplate(); $MG_albums[0]->afrWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR']; $MG_albums[0]->afrHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB']; // Let's build our admin menu options $showAdminBox = 0; $admin_box_item = ''; $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0;">' . LB; $admin_box .= '<div>'; $admin_box .= '<select onchange="javascript:forms[\'adminbox\'].submit();" name="mode">' . LB; $admin_box_item .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>' . LB; if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && !COM_isAnonUser()) { $admin_box_item .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>' . LB; $showAdminBox = 1; } if ($MG_albums[0]->owner_id) { $admin_box_item .= '<option value="albumsort">' . $LANG_MG01['sort_albums'] . '</option>' . LB; $admin_box_item .= '<option value="globalattr">' . $LANG_MG01['globalattr'] . '</option>' . LB; $admin_box_item .= '<option value="globalperm">' . $LANG_MG01['globalperm'] . '</option>' . LB; $queue_count = DB_count($_TABLES['mg_media_album_queue']); $admin_box_item .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>' . LB; $admin_box_item .= '<option value="wmmanage">' . $LANG_MG01['wm_management'] . '</option>' . LB; $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($MG_albums[0]->access == 3) { $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) { $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } $admin_box .= $admin_box_item; $admin_box .= '</select>' . LB; $admin_box .= '<input type="hidden" name="album_id" value="0"/>' . LB; $admin_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>' . LB; $admin_box .= '</div>'; $admin_box .= '</form>'; // build ul $admin_menu = ''; $showAdminMenu = 0; $admin_url = $_MG_CONF['site_url'] . '/admin.php?album_id=0'; if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && !COM_isAnonUser()) { $admin_menu .= '<li><a href="' . $admin_url . '&mode=upload">' . $LANG_MG01['add_media'] . '</a></li>'; $showAdminMenu = 1; } if ($MG_albums[0]->owner_id) { $admin_menu .= '<li><a href="' . $admin_url . '&mode=albumsort">' . $LANG_MG01['sort_albums'] . '</a></li>'; $admin_menu .= '<li><a href="' . $admin_url . '&mode=globalattr">' . $LANG_MG01['globalattr'] . '</a></li>' . LB; $admin_menu .= '<li><a href="' . $admin_url . '&mode=globalperm">' . $LANG_MG01['globalperm'] . '</a></li>' . LB; $queue_count = DB_count($_TABLES['mg_media_album_queue']); $admin_menu .= '<li><a href="' . $admin_url . '&mode=moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</a></li>' . LB; $admin_menu .= '<li><a href="' . $admin_url . '&mode=wmmanage">' . $LANG_MG01['wm_management'] . '</a></li>' . LB; $admin_menu .= '<li><a href="' . $admin_url . '&mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB; $showAdminMenu = 1; } elseif ($MG_albums[0]->access == 3) { $admin_Menu .= '<li><a href="' . $abmin_url . '&mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB; $showAdminMenu = 1; } elseif ($_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) { $admin_menu .= '<li><a href="' . $admin_url . '&mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB; $showAdminMenu = 1; } // end of ul if ($showAdminBox == 0) { $admin_box = ''; $admin_box_item = ''; } if ($showAdminMenu == 1) { $T->set_var('admin_menu', $admin_menu); } $T->set_var('select_adminbox', $admin_box); $T->set_var('select_box_items', $admin_box_item); $album_count = 0; $width = intval(100 / $_MG_CONF['album_display_columns']); $rowcounter = 0; $albumCount = 0; $indexCounter = 0; if (COM_isAnonUser()) { $lastlogin = time(); } else { if (!COM_isAnonUser()) { $lastlogin = $_USER['lastlogin']; } else { $lastlogin = time(); } } $children = $MG_albums[0]->getChildren(); $nrows = count($children); $checkCounter = 0; $aCount = 0; $achild = array(); for ($i = 0; $i < $nrows; $i++) { $access = $MG_albums[$children[$i]]->access; if ($access == 0 || $MG_albums[$children[$i]]->hidden == 1 && $access != 3) { // no op } else { $achild[] = $MG_albums[$children[$i]]->id; $aCount++; } } if ($_MG_CONF['album_display_rows'] < 1) { $_MG_CONF['album_display_rows'] = 9; } $items_per_page = $_MG_CONF['album_display_columns'] * $_MG_CONF['album_display_rows']; $begin = $items_per_page * $page; $end = $items_per_page; $nrows = count($achild); $indexCounter = $begin; $noParse = 0; $needFinalParse = 0; if ($nrows > 0) { $k = 0; $T->set_block('body', 'AlbumColumn', 'AColumn'); $T->set_block('body', 'AlbumRow', 'ARow'); for ($i = $begin; $i < $begin + $items_per_page; $i += $_MG_CONF['album_display_columns']) { for ($j = $i; $j < $i + $_MG_CONF['album_display_columns']; $j++) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; if ($j >= $nrows) { $k = $i + $_MG_CONF['album_display_columns'] - $j; $m = $k % $_MG_CONF['album_display_columns']; for ($z = $m; $z > 0; $z--) { $needFinalParse = 1; } if ($needFinalParse == 1) { $T->parse('ARow', 'AlbumRow', true); $T->set_var('AColumn', ''); } $noParse = 1; break; } $access = $MG_albums[$achild[$indexCounter]]->access; if ($access == 0 || $MG_albums[$achild[$indexCounter]]->hidden == 1 && $access != 3) { $j--; $indexCounter++; continue; } $albumCount++; if ($MG_albums[$achild[$indexCounter]]->media_count > 0) { if ($MG_albums[$achild[$indexCounter]]->cover_filename != '' && $MG_albums[$achild[$indexCounter]]->cover_filename != '0') { $album_last_update = MG_getUserDateTimeFormat($MG_albums[$achild[$indexCounter]]->last_update); if (substr($MG_albums[$achild[$indexCounter]]->cover_filename, 0, 3) == 'tn_') { $offset = 3; } else { $offset = 0; } foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext); break; } } $album_media_count = $MG_albums[$achild[$indexCounter]]->media_count; if (!COM_isAnonUser()) { if ($MG_albums[$achild[$indexCounter]]->last_update > $lastlogin) { $album_last_update[0] = '<font color="red">' . $album_last_update[0] . '</font>'; } } $T->set_var(array('updated_prompt' => $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt'])); } else { $album_media_count = $MG_albums[$achild[$indexCounter]]->media_count; $album_last_update = MG_getUserDateTimeFormat($MG_albums[$achild[$indexCounter]]->last_update); $filename = $MG_albums[$achild[$indexCounter]]->findCover(); if ($filename == '') { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); } else { if (substr($filename, 0, 3) == 'tn_') { $offset = 3; } else { $offset = 0; } foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[$offset] . '/' . $filename . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[$offset] . '/' . $filename . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[$offset] . '/' . $filename . $ext); break; } } } $T->set_var(array('updated_prompt' => $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt'])); } } else { // nothing in the album yet... // here we need to search the sub-albums if any and see if we can find a picture.... $album_media_count = 0; $album_last_update[0] = ""; $filename = $MG_albums[$achild[$indexCounter]]->findCover(); if ($filename == '') { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); } else { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[0] . '/' . $filename . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext); break; } } } $T->set_var('updated_prompt', ''); } $T->clear_var(array('lang_views', 'views')); if ($MG_albums[$achild[$indexCounter]]->enable_album_views) { $T->set_var(array('lang_views' => $LANG_MG03['views'], 'views' => $MG_albums[$achild[$indexCounter]]->views)); } if ($MG_albums[$achild[$indexCounter]]->tn_attached == 1) { $media_size = false; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext); break; } } } // a little fail safe here to make sure we don't show empty boxes... if ($media_size === false || $media_size[0] == 0 || $media_size[1] == 0) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); } // set the image size here... switch ($_MG_CONF['gallery_tn_size']) { case '0': //small $tn_height = 100; $tn_width = 100; break; case '1': //medium $tn_height = 150; $tn_width = 150; break; case '2': $tn_height = 200; $tn_width = 200; break; case '3': $tn_height = $_MG_CONF['gallery_tn_height']; $tn_width = $_MG_CONF['gallery_tn_width']; break; default: $tn_height = 200; $tn_width = 200; break; } if ($media_size[0] > $media_size[1]) { $ratio = $media_size[0] / $tn_height; $newwidth = $tn_height; $newheight = @round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / $tn_height; $newheight = $tn_height; $newwidth = @round($media_size[0] / $ratio); } // pull the sub-album info here $subAlbumDisplay = ''; if (isset($_MG_CONF['subalbum_select']) && $_MG_CONF['subalbum_select'] == 1) { $subAlbumDisplay = '<form name="subalbums' . $MG_albums[$achild[$indexCounter]]->id . '" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0">'; $subAlbumDisplay .= '<select name="aid" onchange="forms[\'subalbums' . $MG_albums[$achild[$indexCounter]]->id . '\'].submit()">'; $subAlbumDisplay .= '<optgroup label="' . $LANG_MG01['select_subalbum'] . '">' . LB; } $saRows = 0; $T->clear_var(array('lang_subalbums', 'subalbumcount', 'subalbumlist')); if (!empty($MG_albums[$achild[$indexCounter]]->children)) { $SAchildren = $MG_albums[$achild[$indexCounter]]->getChildren(); foreach ($SAchildren as $SAchild) { if ($MG_albums[$SAchild]->access > 0) { if ($MG_albums[$SAchild]->hidden) { if ($MG_albums[$SAchild]->access == 3) { $mediaCount = $MG_albums[$SAchild]->getMediaCount(); if ($_MG_CONF['subalbum_select'] == 1) { if (strlen($MG_albums[$SAchild]->title) > 50) { $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...'; } else { $aTitle = $MG_albums[$SAchild]->title; } $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>'; } else { $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>'; } $saRows++; } } else { $mediaCount = $MG_albums[$SAchild]->getMediaCount(); if ($_MG_CONF['subalbum_select'] == 1) { if (strlen($MG_albums[$SAchild]->title) > 50) { $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...'; } else { $aTitle = $MG_albums[$SAchild]->title; } $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>'; } else { $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>'; } $saRows++; } } } if ($_MG_CONF['subalbum_select'] == 1) { $subAlbumDisplay .= '</optgroup></select>'; $subAlbumDisplay .= ' <input type="submit" value="' . $LANG_MG03['go'] . '" />'; $subAlbumDisplay .= '<input type="hidden" name="page" value="1"/>'; $subAlbumDisplay .= '</form>'; } if ($_MG_CONF['album_display_columns'] > 1 && $_MG_CONF['subalbum_select'] != 1) { $T->set_var(array('subalbumlist' => '<span style="font-weight:bold;">' . $LANG_MG01['subalbums'] . '</span> (' . $saRows . ')')); } else { $T->set_var(array('lang_subalbums' => $LANG_MG01['subalbums'], 'subalbumcount' => '(' . $saRows . ')', 'subalbumlist' => $subAlbumDisplay)); } } if ($saRows == 0) { $T->clear_var(array('lang_subalbums', 'subalbumcount', 'subalbumlist')); } $T->clear_var(array('saulstart', 'saulend')); if ($saRows > 0 && $_MG_CONF['subalbum_select'] != 1) { $T->set_var(array('saulstart' => '<ul>', 'saulend' => '</ul>')); } // now pull the total image count for all sub albums... $total_images_subalbums = $MG_albums[$achild[$indexCounter]]->getMediaCount(); $owner_id = $MG_albums[$achild[$indexCounter]]->owner_id; if ($owner_id == '' || !isset($MG_albums[$achild[$indexCounter]]->owner_id)) { $owner_id = 0; } $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($owner_id)); $F = new Template($_MG_CONF['template_path']); $F->set_var('media_frame', $MG_albums[0]->albumFrameTemplate); $F->set_var(array('border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'media_link_start' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => strip_tags($MG_albums[$achild[$indexCounter]]->title), 'frWidth' => $newwidth - $MG_albums[0]->afrWidth, 'frHeight' => $newheight - $MG_albums[0]->afrHeight)); $F->parse('media', 'media_frame'); $media_item_thumbnail = $F->finish($F->get_var('media')); $T->set_var(array('media_item_thumbnail' => $media_item_thumbnail, 'class' => $rowcounter % 2, 'table_column_width' => 'width="' . $width . '%"', 'album_id' => $MG_albums[$achild[$indexCounter]]->id, 'album_title' => PLG_replaceTags($MG_albums[$achild[$indexCounter]]->title, 'mediagallery', 'album_title'), 'album_desc' => $MG_albums[$achild[$indexCounter]]->description == '' ? '' : PLG_replaceTags($MG_albums[$achild[$indexCounter]]->description, 'mediagallery', 'album_description'), 'album_media_count' => $album_media_count, 'subalbum_media_count' => $total_images_subalbums, 'album_owner' => $ownername, 'album_last_update' => $album_last_update[0], 'column_width' => $albumColumnWidth, 'column_width2' => $tn_height + 35 . 'px', 'lang_album' => $LANG_MG00['album'], 'border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'media_link_start' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => strip_tags($MG_albums[$achild[$indexCounter]]->title), 'frWidth' => $newwidth - $MG_albums[0]->afrWidth, 'frHeight' => $newheight - $MG_albums[0]->afrHeight)); $T->parse('AColumn', 'AlbumColumn', true); $indexCounter++; } if ($noParse == 1) { break; } else { $T->parse('ARow', 'AlbumRow', true); $T->set_var('AColumn', ''); } } } $T->set_var(array('bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php', $page + 1, ceil($aCount / $items_per_page)), 'table_columns' => $_MG_CONF['album_display_columns'])); if ($albumCount == 0) { $T->set_var(array('noitems' => $LANG_MG03['no_album_objects'])); $T->parse('gallery_noitems', 'noitems'); } else { $T->parse('gallery_body', 'body'); } $T->parse('output', 'page'); $nCSS = $nFrame->getCSS(); if ($nCSS != '') { $outputHandle = outputHandler::getInstance(); $outputHandle->addStyle($nCSS); } $display .= MG_siteHeader($LANG_MG00['plugin']); $display .= $T->finish($T->get_var('output')); $display .= MG_siteFooter(); echo $display; exit; }
} if ($page > 1) { $offset = ($page - 1) * $show; } else { $offset = 0; } $base_url = $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . $showtopic . '&mode=' . $mode . '&show=' . $show; if (isset($_GET['onlytopic']) && $_GET['onlytopic'] == 1) { $order = $_FF_CONF['showtopic_review_order']; } else { $order = $FF_userprefs['topic_order']; // 'ASC'; } } if (!$iframe) { $topicTemplate->clear_var(array('replytopiclink', 'replytopiclinkimg', 'LANG_reply')); $printlink = $_CONF['site_url'] . '/forum/print.php?id=' . $showtopic; $printlinkimg = '<img src="' . _ff_getImage('print') . '" style="border:none;vertical-align:middle;" alt="' . $LANG_GF01['PRINTABLE'] . '" title="' . $LANG_GF01['PRINTABLE'] . '"/>'; if ($canPost != 0) { $newtopiclink = $_CONF['site_url'] . '/forum/createtopic.php?mode=newtopic&forum=' . $forum; $newtopiclinkimg = '<img src="' . _ff_getImage('post_newtopic') . '" style="border:none;" alt="' . $LANG_GF01['NEWTOPIC'] . '" title="' . $LANG_GF01['NEWTOPIC'] . '"/>'; if ($viewtopic['locked'] != 1) { $replytopiclink = $_CONF['site_url'] . '/forum/createtopic.php?mode=newreply&forum=' . $forum . '&id=' . $showtopic; $replytopiclinkimg = '<img src="' . _ff_getImage('post_reply') . '" style="border:none;" alt="' . $LANG_GF01['POSTREPLY'] . '" title="' . $LANG_GF01['POSTREPLY'] . '"/>'; $topicTemplate->set_var(array('replytopiclink' => $replytopiclink, 'replytopiclinkimg' => $replytopiclinkimg, 'LANG_reply' => $LANG_GF01['POSTREPLY'])); } } else { $newtopiclink = ''; $newtopiclinkimg = ''; } // Enable subscriptions if member
} $groupAccessList = implode(',', $groups); if ($dCat > 0) { $categoryQuery = DB_query("SELECT * FROM {$_TABLES['ff_categories']} WHERE id=" . (int) $dCat . " ORDER BY cat_order ASC"); $birdSeedStart = '<a href="' . $_CONF['site_url'] . '/forum/index.php">Forum Index</a> :: '; } else { $categoryQuery = DB_query("SELECT * FROM {$_TABLES['ff_categories']} ORDER BY cat_order ASC"); } $numCategories = DB_numRows($categoryQuery); $forumlisting = new Template(array($_CONF['path'] . 'plugins/forum/templates/', $_CONF['path'] . 'plugins/forum/templates/links/')); $forumlisting->set_file('forumlisting', 'homepage.thtml'); $forumlisting->set_var(array('forumindeximg' => '<img src="' . _ff_getImage('forumindex') . '" alt=""/>', 'phpself' => $_CONF['site_url'] . '/forum/index.php', 'layout_url' => $_CONF['layout_url'], 'forum_home' => 'Forum Index')); for ($i = 1; $i <= $numCategories; $i++) { $A = DB_fetchArray($categoryQuery, false); $forumlisting->set_block('forumlisting', 'catrows', 'crow'); $forumlisting->clear_var('frow'); if ($birdSeedStart == '') { $birdseed = $birdSeedStart . '<a href="' . $_CONF['site_url'] . '/forum/index.php?cat=' . $A['id'] . '">' . $A['cat_name'] . '</a>'; } else { $birdseed = $birdSeedStart . $A['cat_name']; } $forumlisting->set_var(array('cat_name' => $A['cat_name'], 'cat_desc' => $A['cat_dscp'], 'cat_id' => $A['id'], 'birdseed' => $birdseed)); if (!COM_isAnonUser()) { $link = 'href="' . $_CONF['site_url'] . '/forum/index.php?op=markallread&cat_id=' . $A['id'] . '">'; $forumlisting->set_var(array('markreadlink' => $link, 'LANG_markread' => $LANG_GF02['msg84'])); if ($i == 1) { $newpostslink = 'href="' . $_CONF['site_url'] . '/forum/list.php?op=newposts">'; $forumlisting->set_var(array('newpostslink' => $newpostslink, 'LANG_newposts' => $LANG_GF02['msg112'])); $viewnewpostslink = true; } else { $forumlisting->clear_var('newpostslink');
/** * Generates the HTML code based on the preset style * * @access public * @param array $rows_arr The rows to display in the list * @param string $title The title of the list * @param string $list_top HTML that will appear before the list is printed * @param string $list_bottom HTML that will appear after the list is printed * @param boolean $show_sort True to enable column sorting, false to disable * @param boolean $show_limit True to show page limits, false to hide * @return string HTML output * */ function getFormattedOutput($rows_arr, $title, $list_top = '', $list_bottom = '', $show_sort = true, $show_limit = true) { global $_CONF, $_IMAGE_TYPE, $LANG_ADMIN, $LANG09; // get all template fields. $list_templates = new Template($_CONF['path_layout'] . 'lists/' . $this->_style); $list_templates->set_file(array('list' => 'list.thtml', 'limit' => 'page_limit.thtml', 'sort' => 'page_sort.thtml', 'row' => 'item_row.thtml', 'field' => 'item_field.thtml')); // insert std. values into the template $list_templates->set_var('xhtml', XHTML); $list_templates->set_var('site_url', $_CONF['site_url']); $list_templates->set_var('layout_url', $_CONF['layout_url']); if (count($rows_arr) == 0) { $list_templates->set_var('show_sort', 'display:none;'); $list_templates->set_var('show_limit', 'display:none;'); $list_templates->set_var('message', $LANG_ADMIN['no_results']); $list_templates->set_var('list_top', $list_top); $list_templates->set_var('list_bottom', $list_bottom); $list_templates->parse('output', 'list'); // No results to show so quickly print a message and exit $retval = ''; if (!empty($title)) { $retval .= COM_startBlock($title, '', COM_getBlockTemplate('_admin_block', 'header')); } $retval .= $list_templates->finish($list_templates->get_var('output')); if (!empty($title)) { $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); } return $retval; } // Draw the page limit select box if ($show_limit) { foreach ($this->_page_limits as $key => $val) { $text = is_numeric($key) ? sprintf($LANG09[67], $val) : $key; $href = $this->_page_url . "order={$this->_sort_arr['field']}&" . "direction={$this->_sort_arr['direction']}&results={$val}"; // Prevent displaying too many limit items if ($this->_total_found <= $val) { // If this is the last item, chances are its going to be selected $selected = $this->_per_page >= $val ? ' selected="selected"' : ''; $list_templates->set_var('limit_href', $href); $list_templates->set_var('limit_text', $text); $list_templates->set_var('limit_selected', $selected); $list_templates->parse('page_limit', 'limit', true); break; } $selected = $this->_per_page == $val ? ' selected="selected"' : ''; $list_templates->set_var('limit_text', $text); $list_templates->set_var('limit_href', $href); $list_templates->set_var('limit_selected', $selected); $list_templates->parse('page_limit', 'limit', true); } if (empty($text)) { $list_templates->set_var('show_limit', 'display:none;'); } } else { $list_templates->set_var('show_limit', 'display:none;'); } // Create how to display the sort field if ($this->_style == 'table') { $arrow = $this->_sort_arr['direction'] == 'asc' ? 'bararrowdown' : 'bararrowup'; $sort_selected = "{$_CONF['layout_url']}/images/{$arrow}.{$_IMAGE_TYPE}"; $sort_selected = ' ' . COM_createImage($sort_selected, $arrow); $sort_text = ''; } else { $sort_selected = ''; $sort_text = $LANG09[68] . ' '; if (!$show_sort) { $list_templates->set_var('show_sort', 'display:none;'); } } // Draw the sorting select box/table headings foreach ($this->_fields as $field) { if ($field['display'] == true && $field['title'] != '') { $text = $sort_text . $field['title']; $href = ''; $selected = ''; if ($this->_style == 'inline' && $show_sort && $field['sort'] != false) { $direction = $this->_def_sort_arr['direction']; // Show the sort arrow if ($this->_sort_arr['field'] === $field['name']) { // Add drop down item for current sort order $list_templates->set_var('sort_text', $text . ' (' . $this->_sort_arr['direction'] . ')'); $list_templates->set_var('sort_href', ''); $list_templates->set_var('sort_selected', ' selected="selected"'); $list_templates->parse('page_sort', 'sort', true); // Set up the sort order for the opposite direction $direction = $this->_sort_arr['direction'] == 'asc' ? 'desc' : 'asc'; $text .= " ({$direction})"; } $href = $this->_page_url . "results={$this->_per_page}&" . "order={$field['name']}&direction={$direction}"; // Write field $list_templates->set_var('sort_text', $text); $list_templates->set_var('sort_href', $href); $list_templates->set_var('sort_selected', ''); $list_templates->parse('page_sort', 'sort', true); } else { if ($this->_style == 'table') { $direction = $this->_sort_arr['direction'] == 'asc' ? 'desc' : 'asc'; $href = $this->_page_url . "results={$this->_per_page}&" . "order={$field['name']}&direction={$direction}"; if ($show_sort && $field['sort'] != false) { $text = "<a href=\"{$href}\">{$text}</a>"; if ($this->_sort_arr['field'] === $field['name']) { $selected = $sort_selected; } } // Write field $list_templates->set_var('sort_text', $text); $list_templates->set_var('sort_href', $href); $list_templates->set_var('sort_selected', $selected); $list_templates->parse('page_sort', 'sort', true); } } } } $offset = ($this->_page - 1) * $this->_per_page; $list_templates->set_var('show_message', 'display:none;'); // Run through all the results $r = 1; foreach ($rows_arr as $row) { if (is_callable($this->_function)) { $row = call_user_func_array($this->_function, array(false, $row)); } foreach ($this->_fields as $field) { if ($field['display'] == true) { $fieldvalue = ''; if ($field['name'] == LF_ROW_NUMBER) { $fieldvalue = $r + $offset; } else { if (!empty($row[$field['name']])) { $fieldvalue = $row[$field['name']]; } } if ($fieldvalue != 'LF_NULL') { $fieldvalue = sprintf($field['format'], $fieldvalue, $field['title']); // Write field $list_templates->set_var('field_text', $fieldvalue); $list_templates->parse('item_field', 'field', true); } else { // Write an empty field $list_templates->set_var('field_text', ' '); $list_templates->parse('item_field', 'field', true); } } } // Write row $r++; $list_templates->set_var('cssid', $r % 2 + 1); $list_templates->parse('item_row', 'row', true); $list_templates->clear_var('item_field'); } // Print page numbers $page_url = $this->_page_url . 'order=' . $this->_sort_arr['field'] . '&direction=' . $this->_sort_arr['direction'] . '&results=' . $this->_per_page; $num_pages = ceil($this->_total_found / $this->_per_page); if ($num_pages > 1) { $list_templates->set_var('google_paging', COM_printPageNavigation($page_url, $this->_page, $num_pages, 'page=', false, '', '')); } else { $list_templates->set_var('google_paging', ''); } $list_top = sprintf($list_top, $offset + 1, $r + $offset - 1, $this->_total_found); $list_templates->set_var('list_top', $list_top); $list_templates->set_var('list_bottom', $list_bottom); $list_templates->parse('output', 'list'); // Do the actual output $retval = ''; if (!empty($title)) { $retval .= COM_startBlock($title, '', COM_getBlockTemplate('_admin_block', 'header')); } $retval .= $list_templates->finish($list_templates->get_var('output')); if (!empty($title)) { $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); } return $retval; }