<?php include 'PerchContent_Pages.class.php'; include 'PerchContent_Page.class.php'; include 'PerchContent_Regions.class.php'; include 'PerchContent_Region.class.php'; $Pages = new PerchContent_Pages(); $pages = $Pages->get_by_parent(0); $Regions = new PerchContent_Regions(); $shared = $Regions->get_shared(); ?> <div class="widget"> <h2> <?php echo PerchLang::get('Pages'); if ($CurrentUser->has_priv('content.pages.create')) { echo '<a href="' . PerchUtil::html(PERCH_LOGINPATH . '/core/apps/content/page/add/') . '" class="add button">' . PerchLang::get('Add Page') . '</a>'; } ?> </h2> <div class="bd"> <?php if (PerchUtil::count($pages)) { echo '<ul>'; if (PerchUtil::count($shared)) { echo '<li>'; echo '<a href="' . PerchUtil::html(PERCH_LOGINPATH) . '/core/apps/content/page/?id=-1">'; echo PerchUtil::html(PerchLang::get('Shared')); echo '</a>'; echo '</li>'; }
default: $pages = $Pages->get_page_tree(); if (PERCH_RUNWAY && PerchUtil::count($pages) == 0) { $Pages->create_defaults($CurrentUser); $pages = $Pages->get_page_tree_collapsed(array(0)); } break; } } // Preload regions if ($filter == 'all') { $Regions->preload_regions(); } // get shared regions if ($show_shared) { switch ($filter) { case 'template': $shared_regions = $Regions->get_shared($template_to_filter); break; default: $shared_regions = $Regions->get_shared(); break; } if (PerchUtil::count($shared_regions)) { $SharedPage = $Pages->get_mock_shared_page(); if (!PerchUtil::count($pages)) { $pages = array(); } array_unshift($pages, $SharedPage); } }
<?php $Pages = new PerchContent_Pages(); $Regions = new PerchContent_Regions(); $Page = false; $collections = false; // Find the page if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; if ($id == -1) { $Page = $Pages->get_mock_shared_page(); } else { $Page = $Pages->find($id); } } // Check we have a page if (!$Page || !is_object($Page)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/'); } if (PERCH_RUNWAY) { $Collections = new PerchContent_Collections(); if ($Page->pageCollections()) { $collections = $Collections->get_by_id_string($Page->pageCollections()); } } if ($Page->pagePath() == '*') { $regions = $Regions->get_shared(); } else { $regions = $Regions->get_for_page($Page->id(), $include_shared = false); }