本文整理汇总了PHP中Hook::event方法的典型用法代码示例。如果您正苦于以下问题:PHP Hook::event方法的具体用法?PHP Hook::event怎么用?PHP Hook::event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hook
的用法示例。
在下文中一共展示了Hook::event方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _execute
/**
* (non-PHPdoc)
* @see app/code/Bengine/EventHandler/Handler/Bengine_Game_EventHandler_Handler_Abstract#_execute($event, $data)
*/
protected function _execute(Bengine_Game_Model_Event $event, array $data)
{
Hook::event("EhRecycling", array($event, &$data, $this));
$where = Core::getDB()->quoteInto("galaxy = ? AND system = ? AND position = ?", array($data["galaxy"], $data["system"], $data["position"]));
$result = Core::getQuery()->select("galaxy", array("metal", "silicon"), "", $where);
if ($_row = $result->fetchRow()) {
$result->closeCursor();
$capacityMetal = (int) ($data["capacity"] * 66.7 / 100);
$capacitySilicon = (int) ($data["capacity"] * 33.3 / 100);
$roundFix = $data["capacity"] - $capacityMetal - $capacitySilicon;
if ($roundFix > 0) {
$capacitySilicon += $roundFix;
}
$data["debrismetal"] = $_row["metal"];
$data["debrissilicon"] = $_row["silicon"];
$capacitySilicon += $capacityMetal > $_row["metal"] ? $capacityMetal - $_row["metal"] : 0;
$capacityMetal += $capacitySilicon > $_row["silicon"] ? $capacitySilicon - $_row["silicon"] : 0;
$data["metal"] += min($capacityMetal, $_row["metal"]);
$restMetal = $_row["metal"] - min($capacityMetal, $_row["metal"]);
$data["silicon"] += min($capacitySilicon, $_row["silicon"]);
$restSilicon = $_row["silicon"] - min($capacitySilicon, $_row["silicon"]);
$data["recycledmetal"] = abs($_row["metal"] - $restMetal);
$data["recycledsilicon"] = abs($_row["silicon"] - $restSilicon);
if ($_row["silicon"] != 0 || $_row["metal"] != 0) {
Core::getQuery()->update("galaxy", array("metal" => $restMetal, "silicon" => $restSilicon), "galaxy = ? AND system = ? AND position = ?", array($data["galaxy"], $data["system"], $data["position"]));
}
}
new Bengine_Game_AutoMsg($event["mode"], $event["userid"], $event["time"], $data);
$this->sendBack($data, $data["time"] + $event["time"]);
return $this;
}
示例2: pageAction
/**
* Alliance page action.
*
* @return Bengine_Comm_Controller_Alliance
*/
public function pageAction()
{
Core::getLanguage()->load("Alliance");
Core::getTPL()->clearHTMLHeaderFiles();
Core::getTPL()->addHTMLHeaderFile("game.css", "css");
Core::getTPL()->addHTMLHeaderFile("lib/jquery.js", "js");
$tag = $this->getParam("1");
$fNumber = array("member", "points", "rpoints", "fpoints", "dpoints");
$attr = array("a.aid", "a.name", "a.tag", "a.logo", "a.textextern", "a.homepage", "a.showhomepage", "COUNT(u2a.userid) AS member", "SUM(u.points) AS points", "SUM(u.rpoints) AS rpoints", "SUM(u.fpoints) AS fpoints", "SUM(u.dpoints) AS dpoints");
$joins = "LEFT JOIN " . PREFIX . "user2ally u2a ON (u2a.aid = a.aid) ";
$joins .= "LEFT JOIN " . PREFIX . "user u ON (u2a.userid = u.userid) ";
$result = Core::getQuery()->select("alliance a", $attr, $joins, Core::getDB()->quoteInto("tag = ?", $tag), "", 1, "a.aid");
$row = $result->fetchRow();
if ($row) {
foreach ($fNumber as $field) {
$row[$field] = fNumber($row[$field]);
}
$parser = new Bengine_Game_Alliance_Page_Parser($row["aid"]);
if (Str::length(strip_tags($row["textextern"])) > 0) {
$row["textextern"] = $parser->startParser($row["textextern"]);
} else {
$row["textextern"] = Core::getLang()->get("WELCOME");
}
$row["homepage"] = $row["homepage"] != "" ? Link::get($row["homepage"], $row["homepage"], $row["homepage"]) : "";
$row["logo"] = $row["logo"] != "" ? Image::getImage($row["logo"], "") : "";
Hook::event("ShowPublicAlliancePage", array(&$row));
$this->assign($row);
$this->setIsAjax();
} else {
$this->setNoDisplay(true);
}
return $this;
}
示例3: cleanPoints
/**
* Recalculate the points.
*
* @return Bengine_Game_Cronjob_PointClean
*/
protected function cleanPoints()
{
Hook::event("CleanPointsBegin");
$_result = Core::getQuery()->select("user", "userid");
foreach ($_result->fetchAll() as $_row) {
$points = 0;
$fpoints = 0;
$dpoints = 0;
$result = Core::getQuery()->select("planet", "planetid", "", Core::getDB()->quoteInto("userid = ?", $_row["userid"]));
foreach ($result->fetchAll() as $row) {
$points += Bengine_Game_PointRenewer::getBuildingPoints($row["planetid"]);
$points += Bengine_Game_PointRenewer::getFleetPoints($row["planetid"]);
$fpoints += Bengine_Game_PointRenewer::getFleetPoints_Fleet($row["planetid"]);
$dpoints += Bengine_Game_PointRenewer::getDefensePoints($row["planetid"]);
}
$result->closeCursor();
$points += Bengine_Game_PointRenewer::getResearchPoints($_row["userid"]);
$points += Bengine_Game_PointRenewer::getFleetEventPoints($_row["userid"]);
$fpoints += Bengine_Game_PointRenewer::getFleetEvent_Fleet($_row["userid"]);
$rpoints = Bengine_Game_PointRenewer::getResearchPoints_r($_row["userid"]);
Core::getQuery()->update("user", array("points" => $points, "fpoints" => $fpoints, "rpoints" => $rpoints, "dpoints" => $dpoints), "userid = ?", array($_row["userid"]));
}
$_result->closeCursor();
return $this;
}
示例4: run
/**
* Runs the community application.
*
* @return Comm
*/
public function run()
{
parent::run();
Hook::event("CommStart");
define("LANG", Core::getLang()->getOpt("langcode") . "/");
Core::getLang()->load("Registration");
self::setCMS();
self::initUniverses();
self::initLanguage();
Core::getTPL()->addHTMLHeaderFile("lib/jquery.js", "js");
Core::getTPL()->addHTMLHeaderFile("lib/bootstrap.js", "js");
Core::getTPL()->addHTMLHeaderFile("main.js", "js");
Core::getTPL()->addHTMLHeaderFile("sign.js", "js");
Core::getTPL()->addHTMLHeaderFile("style.css", "css");
Core::getTPL()->assign("containerClass", "content");
Core::getTPL()->addLoop("headerMenu", self::getCMS()->getMenu("h"));
$userCheck = sprintf(Core::getLanguage()->getItem("USER_CHECK"), Core::getOptions()->get("MIN_USER_CHARS"), Core::getOptions()->get("MAX_USER_CHARS"));
$passwordCheck = sprintf(Core::getLanguage()->getItem("PASSWORD_CHECK"), Core::getOptions()->get("MIN_PASSWORD_LENGTH"), Core::getOptions()->get("MAX_PASSWORD_LENGTH"));
Core::getTPL()->assign("userCheck", $userCheck);
Core::getTPL()->assign("passwordCheck", $passwordCheck);
Core::getTPL()->assign("uniSelection", self::getUnisAsOptionList());
Hook::event("CommTemplateAssign");
$this->dispatch();
Hook::event("CommEnd");
return $this;
}
示例5: reportAction
/**
* Combat report action.
*
* @return Bengine_Comm_Controller_Combat
*/
public function reportAction()
{
if (!defined("SID")) {
define("SID", "");
}
Core::getLanguage()->load(array("info", "AssaultReport"));
Core::getTPL()->clearHTMLHeaderFiles();
Core::getTPL()->addHTMLHeaderFile("game.css", "css");
Core::getTPL()->addHTMLHeaderFile("lib/jquery.js", "js");
$select = new Recipe_Database_Select();
$select->from(array("a" => "assault"))->join(array("p" => "planet"), "p.planetid = a.planetid")->attributes(array("a" => array("report"), "p" => array("planetname")))->where(array("a" => "assaultid"), $this->getParam("1"))->where(array("a" => "key"), $this->getParam("2"));
$result = $select->getStatement();
$row = $result->fetchRow();
if ($row) {
$report = $row["report"];
$report = preg_replace_callback("/\\{lang}([^\"]+)\\{\\/lang}/siU", function ($matches) {
return Core::getLanguage()->getItem($matches[1]);
}, $report);
$report = preg_replace_callback("/\\{embedded\\[([^\"]+)]}(.*)\\{\\/embedded}/siU", function ($matches) {
return sprintf(Core::getLanguage()->getItem($matches[1]), $matches[2]);
}, $report);
Hook::event("ShowCombatReport", array(&$report, &$row));
$this->assign("report", $report);
$this->assign("planetName", $row["planetname"]);
$this->setIsAjax();
} else {
$this->setNoDisplay(true);
}
return $this;
}
示例6: init
/**
* Initialize a cURL session.
*
* @return Recipe_HTTP_Session_Curl
*/
protected function init()
{
$this->resource = @curl_init();
if (!$this->resource) {
throw new Recipe_Exception_Generic("Connection faild via cURL request.");
}
Hook::event("HttpRequestInitFirst", array($this));
@curl_setopt($this->resource, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($this->resource, CURLOPT_TIMEOUT, self::TIMEOUT);
$url = $this->webpage;
if (count($this->getGetArgs()) > 0) {
$url .= "?" . $this->getGetArgs(false);
}
@curl_setopt($this->resource, CURLOPT_URL, $url);
if ($this->getRequestType() == "GET") {
@curl_setopt($this->resource, CURLOPT_HTTPGET, true);
} else {
if ($this->getRequestType() == "POST") {
@curl_setopt($this->resource, CURLOPT_POST, true);
@curl_setopt($this->resource, CURLOPT_POSTFIELDS, $this->getPostArgs(false));
} else {
if ($this->getRequestType() == "PUT") {
@curl_setopt($this->resource, CURLOPT_PUT, true);
}
}
}
$this->response = curl_exec($this->resource);
$this->errorNo = curl_errno($this->resource);
if ($this->errorNo) {
$this->error = curl_error($this->resource);
throw new Recipe_Exception_Generic("There is an error occured in cURL session (" . $this->errorNo . "): " . $this->error);
}
Hook::event("HttpRequestInitLast", array($this));
return $this;
}
示例7: getMessageField
/**
* Formats a message.
*
* @param string $message Raw log message
* @param string $mode Log mode
*
* @return string Formatted message
*/
public static function getMessageField($message, $mode = "error")
{
Core::getLanguage()->load("error");
$message = Core::getLanguage()->getItem($message);
$message = "<span class=\"field_" . $mode . "\">" . $message . "</span>";
Hook::event("MessageField", array(&$message));
return $message;
}
示例8: forwardToLogin
/**
* Forward to login page.
*
* @param string $errorid Error id to output
*
* @return void
*/
function forwardToLogin($errorid)
{
if (LOGIN_REQUIRED) {
$login = BASE_URL . "?error=" . $errorid;
Hook::event("ForwardToLoginPage", array(&$login, $errorid));
doHeaderRedirection($login, false);
}
Logger::addMessage($errorid);
Core::getTPL()->display("login");
return;
}
示例9: __construct
/**
* Constructor: Set basic variables.
*
* @return \Recipe_Cache
*/
public function __construct()
{
$this->cacheDir = APP_ROOT_DIR . "var/cache/";
$this->setLanguageCacheDir("language/");
$this->setTemplateCacheDir("templates/");
$this->setSessionCacheDir("sessions/");
$this->setPermissionCacheDir("permissions/");
$this->cacheFileClose = "\n\n// Cache-Generator finished\n?>";
Hook::event("CacheConstruct", array($this));
return;
}
示例10: norouteAction
/**
* Overriding no route action to check for CMS pages.
*
* @return Bengine_Comm_Controller_Index
*/
protected function norouteAction()
{
if ($row = Comm::getCMS()->getPage($this->_action)) {
Hook::event("ShowCMSPage", array(&$row));
$this->assign("page", $row["title"]);
$this->assign("content", $row["content"]);
$this->setTemplate("cms_page");
} else {
parent::norouteAction();
}
return $this;
}
示例11: _execute
/**
* (non-PHPdoc)
* @see app/code/Bengine/EventHandler/Handler/Bengine_Game_EventHandler_Handler_Abstract#_execute($event, $data)
*/
protected function _execute(Bengine_Game_Model_Event $event, array $data)
{
Hook::event("EhAttack", array($event, &$data, $this));
$statement = Core::getQuery()->select("assault", array("assaultid"), "", "planetid = ? AND running = 1", "", "", "", "", array($event->get("destination")));
if ($statement->fetchRow()) {
$event->set("prev_rc", null);
$event->save();
return $this;
}
$assault = new Bengine_Game_Assault($event["destination"], $event["destination_user_id"], $event);
$assault->addParticipant(1, $event["userid"], $event["planetid"], $event["time"], $data)->startAssault($data["galaxy"], $data["system"], $data["position"])->finish();
return $this;
}
示例12: loadMenuItems
/**
* Loads all menu items.
*
* @return Bengine_Comm_CMS
*/
protected function loadMenuItems()
{
$result = Core::getQuery()->select("page", array("position", "title", "label", "link"), "", Core::getDB()->quoteInto("languageid = ?", $this->langid), "displayorder ASC");
foreach ($result->fetchAll() as $row) {
$position = $row["position"];
if (!empty($row["link"])) {
$this->menuItems[$position][]["link"] = Link::get($row["link"], $row["title"], $row["title"]);
} else {
$this->menuItems[$position][]["link"] = Link::get(LANG . "index/" . $row["label"], $row["title"], $row["title"]);
}
}
Hook::event("CommLoadMenu", array(&$this->menuItems, $this));
return $this;
}
示例13: generateMenu
/**
* Generates the menu items.
*
* @return Bengine_Game_Menu
*/
protected function generateMenu()
{
$this->menu = array();
uasort($this->data, array($this, "sort"));
foreach ($this->data as $first) {
uasort($first["items"], array($this, "sort"));
$subMenu = array();
foreach ($first["items"] as $second) {
$subMenu[] = array("attributes" => isset($second["attributes"]) ? $this->getHtmlAttributesFromArray($second["attributes"]) : "", "link" => $this->getLink($second));
}
$this->menu[] = array("attributes" => isset($first["attributes"]) ? $this->getHtmlAttributesFromArray($first["attributes"]) : "", "link" => isset($first["label"]) ? $this->getLabel($first["label"]) : "", "children" => $subMenu);
}
Hook::event("GenerateMenu", array(&$this->menu, $this));
return $this;
}
示例14: _execute
/**
* (non-PHPdoc)
* @see app/code/Bengine/EventHandler/Handler/Bengine_Game_EventHandler_Handler_Abstract#_execute($event, $data)
*/
protected function _execute(Bengine_Game_Model_Event $event, array $data)
{
Hook::event("EhDowngradeBuilding", array($event, &$data, $this));
if (!$event->getPlanetid()) {
return $this;
}
$points = ($data["metal"] + $data["metal"] + $data["metal"]) / 1000;
if ($data["level"] > 0) {
Core::getQuery()->update("building2planet", array("level" => $data["level"]), "buildingid = '" . $data["buildingid"] . "' AND planetid = ?", array($event->getPlanetid()));
} else {
Core::getQuery()->delete("building2planet", "buildingid = ? AND planetid = ?", null, null, array($data["buildingid"], $event->getPlanetid()));
}
Core::getDB()->query("UPDATE " . PREFIX . "user SET points = points - ? WHERE userid = ?", array($points, $event->getUserid()));
return $this;
}
示例15: _execute
/**
* (non-PHPdoc)
* @see app/code/Bengine/EventHandler/Handler/Bengine_Game_EventHandler_Handler_Abstract#_execute($event, $data)
*/
protected function _execute(Bengine_Game_Model_Event $event, array $data)
{
Hook::event("EhAllianceAttack", array($event, &$data, $this));
$assault = new Bengine_Game_Assault($event->getDestination(), $event->getDestinationUserId(), $event);
$assault->addParticipant(Bengine_Game_Assault_Participant::ATTACKER_MODE, $event->getUserid(), $event->getPlanetid(), $event->getTime(), $data);
// Load allied fleets
$allies = Application::getCollection("game/event")->addParentIdFilter($event->getEventid());
foreach ($allies as $ally) {
$assault->addParticipant(Bengine_Game_Assault_Participant::ATTACKER_MODE, $ally->getUserid(), $ally->getPlanetid(), $event->getTime(), $ally->getData());
}
$assault->startAssault($event->getGalaxy2(), $event->getSystem2(), $event->getPosition2())->finish();
Core::getQuery()->delete("formation_invitation", "eventid = ?", null, null, array($event->getEventid()));
Core::getQuery()->delete("attack_formation", "eventid = ?", null, null, array($event->getEventid()));
return $this;
}