Beispiel #1
0
 private function load_block_directly($block)
 {
     PC::debug("Loading block directly.");
     $page_path = $this->blocks->get_page_path_of($block->name);
     PC::debug("versions::load_block_directly() Page Path: {$page_path}");
     if ($page_path === false) {
         PC::error("Coudn't find page path of block name '{$block->name}'");
         return;
     }
     $pending_version = $this->get_pending_or_active_page_version_id($page_path);
     PC::debug("Loading block from version {$pending_version}", "versions::load_block_directly");
     $this->db->where("version", $pending_version);
     $this->db->where("`name` = '{$block->name}'");
     $query = $this->db->get("blocks");
     $result = $query->result_array();
     if ($result) {
         $this->db->where("version", $result[0]['version']);
         $this->db->where("parent", $result[0]['name']);
         $this->db->order_by('sort_order ASC');
         $query = $this->db->get("block_relations");
         $children_result = $query->result();
         if ($children_result) {
             $children = array();
             foreach ($children_result as $entry) {
                 array_push($children, $entry->child);
             }
             $result[0]['children'] = $children;
         } else {
             $result[0]['children'] = array();
         }
         $result[0] = (object) $result[0];
         $block->initialize($result[0]);
         return true;
     } else {
         return false;
     }
 }