public function GatherContentCurl::getPages in GatherContent 7.2
List pages for the selected project.
File
- includes/
curl.inc, line 278 - Contains functions used to process and retrieve data from GatherContent.
Class
- GatherContentCurl
- @file Contains functions used to process and retrieve data from GatherContent.
Code
public function getPages($save_pages = FALSE) {
$pages = $this
->get('get_pages_by_project', array(
'id' => variable_get('gathercontent_project_id'),
));
$original = array();
$new_pages = array();
$parent_array = array();
$meta_pages = array();
if ($pages && is_array($pages->pages)) {
foreach ($pages->pages as $page) {
$original[$page->id] = $page;
$parent_id = $page->parent_id;
if (!isset($parent_array[$parent_id])) {
$parent_array[$parent_id] = array();
}
$parent_array[$parent_id][$page->id] = $page;
}
foreach ($parent_array as $parent_id => $page_array) {
$array = $page_array;
@uasort($array, array(
&$this,
'sortPages',
));
$parent_array[$parent_id] = $array;
}
if (isset($parent_array[0])) {
foreach ($parent_array[0] as $id => $page) {
$new_pages[$id] = $page;
$new_pages[$id]->children = $this
->sortRecursive($parent_array, $id);
}
}
}
$this->pages = $new_pages;
$this->original_array = $original;
$this->meta_pages = $meta_pages;
if ($save_pages) {
$project_id = variable_get('gathercontent_project_id');
$saved_pages = variable_get('gathercontent_saved_pages');
if (!is_array($saved_pages)) {
$saved_pages = array();
}
$saved_pages[$project_id] = array(
'pages' => $original,
'meta' => $meta_pages,
);
variable_set('gathercontent_saved_pages', $saved_pages);
}
}