/** Creates objects an chapter object that is to be inserted into the database */ function book_create_objects($pageobjects, $bookid) { $chapters = array(); $chapter = new stdClass(); // same for all chapters $chapter->bookid = $bookid; $chapter->pagenum = count_records('book_chapters', 'bookid', $bookid) + 1; $chapter->timecreated = time(); $chapter->timemodified = time(); $chapter->subchapter = 0; $i = 1; foreach ($pageobjects as $pageobject) { $page = prep_page($pageobject, $i); // get title and contents $chapter->importsrc = addslashes($pageobject->source); // add the source $chapter->title = $page->title; $chapter->content = $page->contents; $chapters[] = $chapter; // increment our page number and our counter $chapter->pagenum = $chapter->pagenum + 1; $i++; } return $chapters; }
/** Displays a template wrapped in the header and footer as needed. * * Example use: * display_page('add.tpl', 'Homepage', get_current_vars(get_defined_vars()), array()); */ function display_page($template, $title = null, $local_vars = array(), $options = null) { prep_page($template, $title, $local_vars, $options)->fullDisplay(); }
} // Fetch the news try { $news = new model\News(); if (in('tag_query')) { // Search for specific tag $all_news = $news->findByTag(in('tag_query')); $parts['search_title'] = 'Result for #' . htmlentities(in('tag_query')); } else { $all_news = $news->all(); } } catch (InvalidArgumentException $e) { $all_news = array(); } $parts['all_news'] = $all_news; $template = prep_page($view, 'News Board', $parts, array()); function to_tags($str_tags) { $tags = array(); if (strpos($str_tags, ',') !== false) { $tags = explode(',', $str_tags); } elseif (!empty($str_tags)) { $tags = array($str_tags); } if (empty($tags)) { return '-'; } else { $str_tags = ''; foreach ($tags as $tag) { // Build tag anchors $tag = trim($tag);
$sentMessage = in('message'); $sent = false; $user_id = self_char_id(); $target = $_SERVER['PHP_SELF']; $channel = 1; $chatlength = min(3000, max(30, $chatlength)); // Min 30, max 3000 // Take in a chat and record it to the database. if ($user_id) { if ($command == "postnow" && $message) { send_chat($user_id, $message); redirect('/village.php'); } } // Output section. $message_count = get_chat_count(); $chats = get_chats($view_all ? null : $chatlength); // Limit by chatlength unless a request to view all came in. $chats = $chats->fetchAll(); $more_chats_to_see = count($chats) < $message_count ? true : null; $parts = get_certain_vars(get_defined_vars(), array('chats')); function get_time_ago($p_params, &$tpl) { return time_ago($p_params['ago'], $p_params['previous_date']); } $template = prep_page('village.tpl', 'Chat Board', $parts, array('quickstat' => false)); //$template->register_function('time_ago', 'get_time_ago'); $template->registerPlugin("function", "time_ago", "get_time_ago"); $template->fullDisplay(); } // End of player-is-live so no error block
$same_clan = false; $player_info = format_health_percent($player_info); // Player clan and clan members if ($clan) { $viewer_clan = is_logged_in() ? get_clan_by_player_id($viewing_player_obj->vo->player_id) : null; $clan_members = get_clan_members($clan->getID())->fetchAll(); // TODO - When we switch to Smarty 3, remove fetchAll for foreach $clan_id = $clan->getID(); $clan_name = $clan->getName(); if ($viewer_clan) { $same_clan = $clan->getID() == $viewer_clan->getID(); $display_clan_options = $username && !$self && $same_clan && is_clan_leader($viewing_player_obj->vo->player_id); } else { $same_clan = $display_clan_options = false; } } // Send the info to the template. $template = 'player.tpl'; $parts = get_certain_vars(get_defined_vars(), array('char_info', 'viewing_player_obj', 'target_player_obj', 'combat_skills', 'targeted_skills', 'player_info', 'self', 'rank_spot', 'kills_today', 'level_category', 'gravatar_url', 'status_list', 'clan', 'clan_members', 'items', 'duel_checked')); } } function getTurnCost($p_params, &$tpl) { $skillListObj = new Skill(); return $skillListObj->getTurnCost($p_params['skillName']); } $template = prep_page($template, 'Ninja' . ($viewed_name_for_title ? ": {$viewed_name_for_title}" : ' Profile'), $parts, array('quickstat' => 'player')); $template->registerPlugin("function", "getTurnCost", "getTurnCost"); $template->fullDisplay(); } // End of no display_error area.