You are here

function homebox_get_page in Homebox 6.2

Same name and namespace in other branches
  1. 6.3 homebox.module \homebox_get_page()
  2. 7.3 homebox.module \homebox_get_page()
  3. 7.2 homebox.module \homebox_get_page()

Helper function to fetch a page from the database or from a module implementing hook_homebox()

Parameters

$name: The machine name of the page

Return value

A page object, or FALSE is one doesn't exist with given $name

12 calls to homebox_get_page()
homebox_admin_display_form_submit in ./homebox.admin.inc
Process main home blocks administration form submission.
homebox_admin_flush_form_submit in ./homebox.admin.inc
homebox_admin_page in ./homebox.admin.inc
@file Homebox admin file, takes care admin interface for homebox
homebox_admin_page_submit in ./homebox.admin.inc
homebox_configure_form_submit in ./homebox.admin.inc
Forms for administration settings

... See full list

File

./homebox.module, line 836
Homebox main file, takes care of global functions settings constants, etc.

Code

function homebox_get_page($name) {

  // Fetch page from db
  $page = db_fetch_object(db_query("SELECT * FROM {homebox_pages} WHERE name = '%s'", $name));
  if ($page) {

    // Unserialize the settings
    $page->settings = unserialize($page->settings);
    return $page;
  }
  else {

    // If not available, check other modules
    $pages = module_invoke_all('homebox');
    foreach ($pages as $id => $data) {

      // Only match page name
      if ($name == $id) {

        // Build page object
        $page = new stdClass();
        $page->name = $id;
        $page->settings = $data;

        // Check the data before using it
        $page = homebox_check_page_object($page);
      }
    }
    return $page ? $page : FALSE;
  }
}