本文整理汇总了PHP中Core::getTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP Core::getTemplate方法的具体用法?PHP Core::getTemplate怎么用?PHP Core::getTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core
的用法示例。
在下文中一共展示了Core::getTemplate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
/**
* @return Bengine_Admin_Controller_News
*/
protected function indexAction()
{
if ($this->getParam("add")) {
$this->add($this->getParam("language_id"), $this->getParam("title"), $this->getParam("text"));
}
$first = true;
$i = 1;
$news = array();
$result = Core::getQuery()->select("news", array("news_id", "title", "text", "time", "enabled", "sort_index"), "", "", "sort_index ASC, news_id DESC");
$total = $result->rowCount();
foreach ($result->fetchAll() as $row) {
$down = "";
$up = "";
if (!$first) {
$up = Image::getImage("admin/up.gif", "", 16, 16);
$up = Link::get("admin/news/moveup/" . $row["news_id"], $up);
}
$first = false;
if ($i < $total) {
$down = Image::getImage("admin/down.gif", "", 16, 16);
$down = Link::get("admin/news/movedown/" . $row["news_id"], $down);
}
$i++;
$news[] = array("news_id" => $row["news_id"], "title" => $row["title"], "text" => $row["text"], "time" => Date::timeToString(1, $row["time"]), "enabled" => $row["enabled"], "edit" => Link::get("admin/news/edit/" . $row["news_id"], Core::getLang()->get("Edit")), "delete" => Link::get("admin/news/delete/" . $row["news_id"], Core::getLang()->get("Delete")), "enable" => Link::get("admin/news/enable/" . $row["news_id"], Core::getLang()->get("Enable"), "", "green"), "disable" => Link::get("admin/news/disable/" . $row["news_id"], Core::getLang()->get("Disable"), "", "red"), "down" => $down, "up" => $up);
}
Core::getTemplate()->addLoop("news", $news);
$languages = $this->getLanguages();
Core::getTPL()->assign("languageCount", count($languages));
if (count($languages) == 1) {
Core::getTPL()->assign("languages", key($languages));
} else {
Core::getTPL()->assign("languages", $this->getLanguageSelect());
}
return $this;
}
示例2: __construct
/**
* Constructor.
*
* @param string $template
* @param Recipe_Template_Adapter_Abstract $engine
*/
public function __construct($template, Recipe_Template_Adapter_Abstract $engine = null)
{
$this->template = $template;
if ($engine === null) {
$engine = Core::getTemplate();
}
$this->setEngine($engine);
}
示例3: dieMessage
/**
* Displays a message and shut program down.
*
* @param string $message Message to log
* @param string $mode Log mode
*
* @return void
*/
public static function dieMessage($message, $mode = "error")
{
Core::getLanguage()->load("error");
$message = Core::getLanguage()->getItem($message);
Core::getTPL()->addLogMessage("<div class=\"" . $mode . "\">" . $message . "</div>");
Core::getTemplate()->display("error");
exit;
}
示例4: infoAction
/**
* Secret action without essential purpose.
*
* @param string $key
* @throws Recipe_Exception_Generic
* @return Bengine_Game_Controller_Changelog
*/
protected function infoAction($key)
{
if (empty($key)) {
throw new Recipe_Exception_Generic("Please provide a key to view info.");
}
$content = file_get_contents('http://bengine.de/sasuke.php?action=' . $key);
if (empty($content)) {
throw new Recipe_Exception_Generic("Could not found any info on your key.");
}
Core::getTemplate()->assign("content", $content);
return $this;
}
示例5: __construct
/**
* Constructor: Set up compiler.
*
* @param string $template Template name
* @param string $type Template type
*
* @return \Recipe_Template_Default_Compiler
*/
public function __construct($template, $type)
{
$this->template = $template;
$filePath = Core::getTemplate()->getAbsoluteTemplatePath($template, $type);
$this->sourceTemplate = file_get_contents($filePath);
$this->buildPatterns()->compile();
try {
parent::putCacheContent(Core::getCache()->getTemplatePath($this->template, $type), $this->compiledTemplate->get());
} catch (Recipe_Exception_Generic $e) {
$e->printError();
}
return;
}
示例6: indexAction
/**
* @return Bengine_Admin_Controller_Auth
*/
protected function indexAction()
{
$this->setIsAjax();
$this->setMainTemplate(null);
if ($this->isPost()) {
$encryption = Core::getOptions("USE_PASSWORD_SALT") ? "md5_salt" : "md5";
$auth = new Login($this->getParam("username"), $this->getParam("password"), "admin/index", $encryption);
$auth->setRedirectOnFailure(false)->setCountLoginAttempts(false)->checkData();
if ($auth->getCanLogin()) {
$auth->startSession();
}
Core::getTemplate()->assign("loginErrors", $auth->getErrors());
}
return $this;
}
示例7: indexAction
/**
* @return Bengine_Game_Controller_Achievements
*/
public function indexAction()
{
Core::getLanguage()->load(array("Achievements"));
/* @var Bengine_Game_Model_User $user */
$user = Application::getModel("game/user")->load(Core::getUser()->get("userid"));
/* @var Bengine_Game_Model_Planet $planet */
$planet = Application::getModel("game/planet")->load(Core::getUser()->get("curplanet"));
/* @var Bengine_Game_Model_Collection_Achievement $achievements */
$achievements = Application::getCollection("game/achievement");
$achievements->addUserJoin(Core::getUser()->get("userid"))->addDefaultSorting();
Core::getTemplate()->addLoop("achievements", $achievements);
$unlocked = $achievements->checkForUnlockedAchievements($user, $planet);
Core::getTemplate()->addLoop("unlocked", $unlocked);
Core::getLanguage()->assign("leftXP", $user->getLeftXPForNextLevel());
Core::getLanguage()->assign("nextLevel", $user->get("level") + 1);
Core::getTemplate()->assign("user", $user);
Core::getLang()->assign("xp", $user->get("xp"));
Core::getLang()->assign("level", $user->get("level"));
return $this;
}
示例8: __construct
/**
* Handles lost password requests.
*
* @param string $username Entered username
* @param string $email Entered email address
*
* @return Bengine_Game_Account_Password_Lost
*/
public function __construct($username, $email)
{
$this->username = $username;
$this->email = $email;
$mode = 1;
if (!$this->getUsername()) {
$mode = 0;
}
if (!checkEmail($this->getEmail())) {
$this->printIt("EMAIL_INVALID");
}
$result = Core::getQuery()->select("user", array("userid", "username"), "", Core::getDB()->quoteInto("email = ?", $this->getEmail()));
if ($result->rowCount() <= 0) {
$this->printIt("EMAIL_NOT_FOUND");
}
$row = $result->fetchRow();
$result->closeCursor();
Core::getLanguage()->assign("username", $row["username"]);
Core::getLanguage()->assign("ipaddress", IPADDRESS);
Hook::event("LostPassword", array($this, &$row));
if ($mode == 0) {
$this->message = new Recipe_Email_Template("lost_password_username");
} else {
if (Str::compare($this->getUsername(), $row["username"])) {
$reactivate = BASE_URL . Core::getLang()->getOpt("langcode") . "/signup/activation/key:" . $this->getSecurityKey();
$url = BASE_URL . Core::getLang()->getOpt("langcode") . "/password/set/key:" . $this->getSecurityKey() . "/user:" . $row["userid"];
Core::getTemplate()->assign("newPasswordUrl", $url);
Core::getTemplate()->assign("reactivationUrl", $reactivate);
$this->message = new Recipe_Email_Template("lost_password_password");
$this->setNewPw();
} else {
$this->printIt("USERNAME_DOES_NOT_EXIST");
}
}
$this->sendMail($mode);
return;
}
示例9: proceedBan
/**
* Bans an user.
*
* @param integer $ban
* @param integer $timeEnd
* @param string $reason
* @param boolean $forceUmode
*
* @return Bengine_Game_Controller_Moderator
*/
protected function proceedBan($ban, $timeEnd, $reason, $forceUmode)
{
$to = TIME + $ban * $timeEnd;
if ($to > 9999999999) {
$to = 9999999999;
}
Hook::event("BanUser", array(&$to, $reason, $forceUmode));
$spec = array("userid" => $this->userid, "from" => TIME, "to" => $to, "reason" => $reason, "modid" => Core::getUser()->get("userid"));
Core::getQuery()->insert("ban_u", $spec);
if ($forceUmode) {
Core::getQuery()->update("user", array("umode" => 1), "userid = ?", array($this->userid));
setProdOfUser($this->userid, 0);
}
Core::getQuery()->update("sessions", array("logged" => 0), "userid = ?", array($this->userid));
$user = Game::getModel("game/user")->load($this->userid);
Core::getTemplate()->assign("banReason", $reason);
Core::getLang()->assign("banDate", Date::timeToString(1, $to, "", 0));
Core::getLang()->assign("username", $user->get("username"));
$template = new Recipe_Email_Template("ban_notification");
$mail = new Email(array($user->get("email") => $user->get("username")), Core::getLanguage()->getItem("BAN_NOTIFICATION_MAIL_SUBJECT"));
$template->send($mail);
return $this;
}
示例10: indexAction
/**
* Index action.
*
* @return Bengine_Game_Controller_Index
*/
protected function indexAction()
{
Core::getTPL()->addHTMLHeaderFile("lib/jquery.countdown.js", "js");
Core::getTPL()->addHTMLHeaderFile("lib/jquery.news.js", "js");
$this->buildingEvent = Game::getEH()->getCurPlanetBuildingEvent();
// Messages
$result = Core::getQuery()->select("message", "msgid", "", Core::getDB()->quoteInto("`receiver` = ? AND `read` = '0'", Core::getUser()->get("userid")));
$msgs = $result->rowCount();
$result->closeCursor();
Core::getTPL()->assign("unreadmsg", $msgs);
if ($msgs == 1) {
Core::getTPL()->assign("newMessages", Link::get("game/" . SID . "/MSG", Core::getLanguage()->getItem("F_NEW_MESSAGE")));
} else {
if ($msgs > 1) {
Core::getTPL()->assign("newMessages", Link::get("game/" . SID . "/MSG", sprintf(Core::getLanguage()->getItem("F_NEW_MESSAGES"), $msgs)));
}
}
// Fleet events
$fleetEvent = Game::getEH()->getFleetEvents();
$fe = array();
if ($fleetEvent) {
foreach ($fleetEvent as $f) {
$fe[$f["eventid"]] = $this->parseEvent($f);
if (!is_array($fe[$f["eventid"]])) {
unset($fe[$f["eventid"]]);
}
}
Hook::event("MainFleetEventsOutput", array(&$fe));
}
Core::getTPL()->addLoop("fleetEvents", $fe);
Core::getTPL()->assign("serverTime", Date::timeToString(1, TIME, "", false));
Core::getTPL()->assign("buildingEvent", $this->buildingEvent);
Core::getTPL()->assign("occupiedFields", Game::getPlanet()->getFields(true));
Core::getTPL()->assign("planetImage", Image::getImage("planets/" . Game::getPlanet()->getData("picture") . Core::getConfig()->get("PLANET_IMG_EXT"), Game::getPlanet()->getData("planetname"), "200px", "200px"));
Core::getTPL()->assign("freeFields", Game::getPlanet()->getMaxFields());
Core::getTPL()->assign("planetDiameter", fNumber(Game::getPlanet()->getData("diameter")));
Core::getTPL()->assign("planetNameLink", Link::get("game/" . SID . "/Index/PlanetOptions", Game::getPlanet()->getData("planetname")));
Core::getTPL()->assign("planetPosition", Game::getPlanet()->getCoords());
Core::getTPL()->assign("planetTemp", Game::getPlanet()->getData("temperature"));
Core::getTPL()->assign("points", Link::get("game/" . SID . "/Ranking", fNumber(floor(Core::getUser()->get("points")))));
// Points
$result = Core::getQuery()->select("user", "userid");
Core::getLang()->assign("totalUsers", fNumber($result->rowCount()));
$result->closeCursor();
$where = Core::getDB()->quoteInto("(`username` < ? AND `points` >= {points}) OR `points` > {points}", array(Core::getUser()->get("username")));
$where = str_replace("{points}", (double) Core::getUser()->get("points"), $where);
$result = Core::getQuery()->select("user", array("COUNT(`userid`)+1 AS rank"), "", $where, "", 1);
Core::getLang()->assign("rank", fNumber($result->fetchColumn()));
$result->closeCursor();
if (Game::getPlanet()->getData("moonid") > 0) {
if (Game::getPlanet()->getData("ismoon")) {
// Planet has moon
$where = Core::getDB()->quoteInto("g.galaxy = ? AND g.system = ? AND g.position = ?", array(Game::getPlanet()->getData("moongala"), Game::getPlanet()->getData("moonsys"), Game::getPlanet()->getData("moonpos")));
$result = Core::getQuery()->select("galaxy g", array("p.planetid", "p.planetname", "p.picture"), "LEFT JOIN " . PREFIX . "planet p ON (p.planetid = g.planetid)", $where);
} else {
// Planet of current moon
$where = Core::getDB()->quoteInto("g.galaxy = ? AND g.system = ? AND g.position = ?", array(Game::getPlanet()->getData("galaxy"), Game::getPlanet()->getData("system"), Game::getPlanet()->getData("position")));
$result = Core::getQuery()->select("galaxy g", array("p.planetid", "p.planetname", "p.picture"), "LEFT JOIN " . PREFIX . "planet p ON (p.planetid = g.moonid)", $where);
}
$row = $result->fetchRow();
$result->closeCursor();
Core::getTPL()->assign("moon", $row["planetname"]);
$img = Image::getImage("planets/" . $row["picture"] . Core::getConfig()->get("PLANET_IMG_EXT"), $row["planetname"], 50, 50);
Core::getTPL()->assign("moonImage", "<a title=\"" . $row["planetname"] . "\" class=\"goto pointer\" href=\"" . $row["planetid"] . "\">" . $img . "</a>");
} else {
Core::getTPL()->assign("moon", "");
Core::getTPL()->assign("moonImage", "");
}
// Current events
$research = Game::getEH()->getResearchEvent();
Core::getTPL()->assign("research", $research);
$shipyardMissions = Game::getEH()->getShipyardEvents();
Core::getTemplate()->assign("shipyardMissions", $shipyardMissions);
/* @var Bengine_Game_Model_Collection_News $news */
$news = Game::getCollection("game/news");
$news->addSortIndexOrder()->addEnabledFilter()->addLanguageFilter();
Core::getTPL()->addLoop("news", $news);
Hook::event("GameIndexAction");
return $this;
}
示例11: getData
/**
* Fetches the user data in term of a session id.
*
* @return Recipe_User
*/
protected function getData()
{
Hook::event("LoadUserData", array($this));
if ($this->cacheActive) {
$this->item = Core::getCache()->getUserCache($this->sid);
} else {
$select = array("u.*", "s.ipaddress");
$joins = "LEFT JOIN " . PREFIX . "user u ON (s.userid = u.userid)";
// Get custom user data from configuration
if (Core::getConfig()->exists("userselect")) {
$userConfigSelect = Core::getConfig()->get("userselect");
$select = array_merge($select, $userConfigSelect["fieldsnames"]);
}
if (Core::getConfig()->exists("userjoins")) {
$joins .= " " . Str::replace("PREFIX", PREFIX, Core::getConfig()->get("userjoins"));
}
$result = Core::getQuery()->select("sessions s", $select, $joins, Core::getDB()->quoteInto("s.sessionid = ? AND s.logged = '1'", $this->sid));
$this->item = $result->fetchRow();
$result->closeCursor();
}
if ($this->size() > 0) {
defined("SID") || define("SID", $this->sid);
if (IPCHECK && $this->get("ipcheck")) {
if ($this->get("ipaddress") != IPADDRESS) {
forwardToLogin("IPADDRESS_INVALID");
}
}
if ($this->get("templatepackage") != "") {
Core::getTemplate()->setTemplatePackage($this->get("templatepackage"));
}
} else {
if (LOGIN_REQUIRED && !defined("LOGIN_PAGE")) {
forwardToLogin("NO_ACCESS");
}
$this->setGuest();
}
Hook::event("UserDataLoaded", array($this));
return $this;
}
示例12: setMainTemplate
/**
* Sets the layout template.
*
* @param string
*
* @return Recipe_Controller_Abstract
*/
protected function setMainTemplate($mainTemplate)
{
Core::getTemplate()->setLayoutTemplate($mainTemplate);
return $this;
}
示例13: getTemplatePath
/**
* Return full path of a cached template.
*
* @param string $template Template name
* @param string $type Template type
*
* @return string Path to template
*/
public function getTemplatePath($template, $type)
{
$template = Core::getTemplate()->getTemplatePath($template, $type);
$dir = $this->getTemplateCacheDir();
if (!is_dir($dir)) {
@mkdir($dir, 0777, true);
}
$template = str_replace("/", ".", $template);
return $dir . $template . ".cache.php";
}
示例14: sendMail
/**
* Sends email with activation key.
*
* @return Bengine_Game_Account_Creator
*/
protected function sendMail()
{
if (!Core::getConfig()->get("EMAIL_ACTIVATION_DISABLED")) {
$url = BASE_URL . Core::getLang()->getOpt("langcode") . "/signup/activation/key:" . $this->getActivation();
Core::getLang()->assign("username", $this->getUsername());
Core::getLang()->assign("regPassword", $this->getPassword());
Core::getTemplate()->assign("activationLink", $url);
$template = new Recipe_Email_Template("registration");
$mail = new Email(array($this->getEmail() => $this->getUsername()), Core::getLanguage()->getItem("REGISTRATION"));
$template->send($mail);
}
return $this;
}
示例15: updateUserData
/**
* Saves the entered preferences.
*
* @param string $username
* @param string $usertitle
* @param string $email
* @param string $pw
* @param string $theme
* @param integer $language
* @param string $templatepackage
* @param integer $umode
* @param integer $delete
* @param integer $ipcheck
* @param integer $esps
* @param integer $generate_key
* @param string $js_interface
* @throws Recipe_Exception_Generic
* @return Bengine_Game_Controller_Preferences
*/
protected function updateUserData($username, $usertitle, $email, $pw, $theme, $language, $templatepackage, $umode, $delete, $ipcheck, $esps, $generate_key, $js_interface)
{
if (Core::getUser()->get("umode")) {
throw new Recipe_Exception_Generic("Vacation mode is still enabled.");
}
Core::getLanguage()->load("Registration");
Hook::event("SaveUserDataFirst");
$username = trim(str_replace(" ", " ", $username));
$usertitle = trim($usertitle);
$js_interface = trim($js_interface);
$language = (int) (empty($language) ? Core::getConfig()->get("defaultlanguage") : $language);
if (!empty($theme) && !filter_var($theme, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)) {
$theme = "";
Logger::addMessage("THEME_INVALID");
}
if (!empty($templatepackage) && !is_dir(APP_ROOT_DIR . "app/templates/" . $templatepackage)) {
$templatepackage = Core::getUser()->get("templatepackage");
}
$activation = "";
// Check language
if (Core::getUser()->get("languageid") != $language) {
$result = Core::getQuery()->select("languages", "languageid", "", Core::getDB()->quoteInto("languageid = ?", $language));
if ($result->rowCount() <= 0) {
$language = Core::getUser()->get("languageid");
}
$result->closeCursor();
}
// Check username
if (!Str::compare($username, Core::getUser()->get("username"))) {
$result = Core::getQuery()->select("user", "userid", "", Core::getDB()->quoteInto("username = ?", $username));
if ($result->rowCount() == 0) {
$result->closeCursor();
if (!checkCharacters($username)) {
$username = Core::getUser()->get("username");
Logger::addMessage("USERNAME_INVALID");
} else {
Logger::addMessage("USERNAME_CHANGED", "success");
}
} else {
$result->closeCursor();
$username = Core::getUser()->get("username");
Logger::addMessage("USERNAME_EXISTS");
}
}
// Check user title
if (!Str::compare($usertitle, Core::getUser()->get("usertitle"))) {
$length = Str::length($usertitle);
if ($length < Core::getOptions()->get("MIN_USER_CHARS") || $length > Core::getOptions()->get("MAX_USER_CHARS")) {
$usertitle = Core::getUser()->get("usertitle");
}
}
// Check email
if (!Str::compare($email, Core::getUser()->get("email"))) {
$result = Core::getQuery()->select("user", "userid", "", Core::getDB()->quoteInto("email = ?", $email));
if ($result->rowCount() == 0) {
$result->closeCursor();
if (!checkEmail($email)) {
$email = Core::getUser()->get("email");
Logger::addMessage("EMAIL_INVALID");
} else {
$successMsg = "EMAIL_CHANGED";
if (Core::getConfig()->get("EMAIL_ACTIVATION_CHANGED_EMAIL")) {
$activation = randString(8);
$url = BASE_URL . Core::getLang()->getOpt("langcode") . "/signup/activation/key:" . $activation;
Core::getLang()->assign("username", $username);
Core::getTemplate()->assign("activationUrl", $url);
$template = new Recipe_Email_Template("email_changed");
$mail = new Email($email, Core::getLanguage()->getItem("EMAIL_ACTIVATION"));
$template->send($mail);
$successMsg .= "_REVALIDATE";
}
Logger::addMessage($successMsg, "success");
}
} else {
$result->closeCursor();
Logger::addMessage("EMAIL_EXISTS");
$email = Core::getUser()->get("email");
}
}
// Check password
$pwLength = Str::length($pw);
//.........这里部分代码省略.........