Ejemplo n.º 1
0
 private function loadBlocks($itemId)
 {
     $sql = "SELECT * FROM block\n                LEFT JOIN `block_item` ON `block_item`.`block_id` = block.`block_id`\n                LEFT JOIN `block_group` ON `block_group`.`block_id` = block.`block_id`\n                WHERE\n                ((`block`.`item_exclusive` = 0 AND `block_item`.`item_id` = :itemId)\n                OR\n                (`block`.`item_exclusive` = 1 AND `block_item`.`item_id` IS NULL))\n                AND\n                ((`block`.`group_exclusive` = 0 AND `block_group`.`group_id` IN (:aGroupId))\n                OR\n                (`block`.`group_exclusive` = 1 AND (`block_group`.`group_id` IS NULL OR `block_group`.`group_id` NOT IN (:aGroupId))))\n                GROUP BY `block`.`block_id`;";
     $sth = DKY_DB::query($sql);
     $sth->bind("itemId", $itemId);
     $sth->bind("aGroupId", $_SESSION["aGroupId"]);
     $sth->execute();
     while ($aBlock = $sth->fetch()) {
         $block = $this->getBlock($aBlock["block_name"], $aBlock["component_name"]);
         if (!empty($block)) {
             $block->init($aBlock, $this->_request);
             $this->aBlocks[$block->position][] = $block;
         }
     }
 }
Ejemplo n.º 2
0
 public static function run()
 {
     // TODO: Filters.. exceptions..?
     if ($_SERVER["REQUEST_URI"] == "/favicon.ico") {
         DKY_HTTP::redirect("/www/favicon.ico");
     }
     DKY_Config::initialize();
     DKY_DB::initialize(array("host" => DKY_Config::get("db_host"), "database" => DKY_Config::get("db_database"), "username" => DKY_Config::get("db_username"), "password" => DKY_Config::get("db_password")));
     DKY_Log::initialize(array("path" => DKY_Config::get("log_path")));
     DKY_Log::i("REQUEST: " . $_SERVER["REQUEST_URI"]);
     DKY_SessionHandler::startSession();
     DKY_SessionHandler::cachePermissions();
     //$strLogTail = "<div style='font:10px sans-serif;height:100px;overflow:auto;'>" . implode("<br />", DKY_Log::tail(20)) . "</div>";
     //DKY_Output::raiseMessage($strLogTail, DKY_MSG_INFO);
     DKY_RequestHandler::process();
 }
Ejemplo n.º 3
0
 /**
  * Get paginated data from a DB statement using the specified
  * 
  * @param DKY_DB_Statement $sth
  * @param unknown $aQueryParams
  * @return array Paged data array.
  */
 public static function getPagedData($sth, $page, $limit, $delta)
 {
     $aPagedData = array();
     $aPagedData["pageNum"] = $page;
     $aPagedData["pageLimit"] = $limit;
     $aPagedData["pageDelta"] = $delta;
     $aStatementParams = $sth->getStatementParams();
     $query = $sth->getSelectQuery();
     // Get the total number of rows for the query.
     $queryNoLimit = "SELECT COUNT(*) AS `total_rows` FROM (" . $query . ") AS `data`;";
     $sthNoLimit = DKY_DB::query($queryNoLimit);
     $sthNoLimit->bindParams($aStatementParams);
     $sthNoLimit->execute();
     $row = $sthNoLimit->fetch();
     $aPagedData["totalRows"] = $row["total_rows"];
     // Get paged rows.
     $sthPage = DKY_DB::query("SELECT * FROM ({$query}) AS `data` LIMIT :pager_offset, :pager_limit;");
     $sthPage->bindParams($aStatementParams);
     $pagerOffset = $aPagedData["pageLimit"] * ($aPagedData["pageNum"] - 1);
     $pagerLimit = $aPagedData["pageLimit"];
     $sthPage->bind("pager_offset", $pagerOffset);
     $sthPage->bind("pager_limit", $pagerLimit);
     $sthPage->execute();
     $aPagedData["rowCount"] = $sthPage->getRowCount();
     $aPagedData["aData"] = $sthPage->fetchAll();
     if (!empty($aPagedData["rowCount"])) {
         $aPagedData["totalPages"] = ceil($aPagedData["totalRows"] / $aPagedData["pageLimit"]);
     } else {
         $aPagedData["totalPages"] = 0;
     }
     $aPagedData["rowsAfter"] = $aPagedData["totalRows"] - $aPagedData["pageNum"] * $aPagedData["pageLimit"];
     $aPagedData["rowsBefore"] = ($aPagedData["pageNum"] - 1) * $aPagedData["pageLimit"];
     $aPagedData["pagesAfter"] = ceil($aPagedData["rowsAfter"] / $aPagedData["pageLimit"]);
     $aPagedData["pagesBefore"] = ceil($aPagedData["rowsBefore"] / $aPagedData["pageLimit"]);
     return $aPagedData;
 }
Ejemplo n.º 4
0
 public function getGroup($groupId)
 {
     return DKY_DB::get("group", "group_id", $groupId);
 }
Ejemplo n.º 5
0
 public function insert($aValues)
 {
     $this->_query = "INSERT INTO `" . $this->_table . "` (`" . implode("`,`", array_keys($aValues)) . "`)\n             VALUES (:" . implode(",:", array_keys($aValues)) . ");";
     $this->bindParams($aValues);
     $this->prepare($this->_query);
     $this->execute();
     return DKY_DB::getLastInsertId();
 }
Ejemplo n.º 6
0
 public static function deleteItemGroups($itemId)
 {
     $do_item_group = DKY_DB::build("item_group");
     $do_item_group->where("`item_id` = :itemId", "itemId", $itemId);
     return $do_item_group->delete();
 }
Ejemplo n.º 7
0
 public function deleteBranch($nodeId)
 {
     DKY_DB::beginTransaction();
     $aNode = $this->getNodeById($nodeId);
     $do_set = DKY_DB::query("DELETE FROM `" . $this->_table . "` WHERE `left_id` >= :leftId AND `right_id` <= :rightId");
     $do_set->bind("leftId", $aNode["left_id"]);
     $do_set->bind("rightId", $aNode["right_id"]);
     $do_set = $sth->execute();
     $this->_shiftNodesLeft($aNode["right_id"] - $aNode["left_id"] + 1, $aNode["left_id"]);
     return DKY_DB::commit();
 }
Ejemplo n.º 8
0
 public static function getColumns($table)
 {
     $sth = DKY_DB::query("DESCRIBE `" . $table . "`;");
     $sth->execute();
     return $sth->fetchAll();
 }
Ejemplo n.º 9
0
 public static function getMenuById($menuId)
 {
     return DKY_DB::get("menu", "menu_id", $menuId);
 }