aboutsummaryrefslogtreecommitdiff
path: root/mod/sitepages/sitepages_functions.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-09 00:52:52 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-09 00:52:52 +0000
commit4e2a58e02ae4fe55ebc801a816c6ddb304df4b18 (patch)
treef958306f06db27bc2182f30356bead605b2d4b93 /mod/sitepages/sitepages_functions.php
parent617ebb97d840cf77f3b483273f029732e8dc0db7 (diff)
downloadelgg-4e2a58e02ae4fe55ebc801a816c6ddb304df4b18.tar.gz
elgg-4e2a58e02ae4fe55ebc801a816c6ddb304df4b18.tar.bz2
Brought sitepages up to standards.
Added basic static keyword/view substitution support. git-svn-id: http://code.elgg.org/elgg/trunk@5312 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/sitepages/sitepages_functions.php')
-rw-r--r--mod/sitepages/sitepages_functions.php129
1 files changed, 124 insertions, 5 deletions
diff --git a/mod/sitepages/sitepages_functions.php b/mod/sitepages/sitepages_functions.php
index 561aae97c..7ffe8df63 100644
--- a/mod/sitepages/sitepages_functions.php
+++ b/mod/sitepages/sitepages_functions.php
@@ -1,8 +1,127 @@
<?php
/**
- * This will hold the required keyword functions to display frontpage content
- **/
-
-function parse_frontpage($frontContents){
- echo htmlspecialchars_decode($frontContents, ENT_NOQUOTES);
+ * Helper functions for Site Pages.
+ *
+ * @package SitePages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.org/
+ */
+
+
+function sitepages_parse_frontpage($contents){
+ echo htmlspecialchars_decode($contents, ENT_NOQUOTES);
+}
+
+/**
+ * Returns a single object that holds information about
+ * customizations for the $section site page. The object guid
+ * is stored as private data on the site entity. This allows the pages
+ * to still be searchable as standard entities.
+ *
+ * @param $type
+ * @return mixed ElggSitePage on success, FALSE on fail
+ */
+function sitepages_get_sitepage_object($page_type) {
+ global $CONFIG;
+
+ $page_guid = get_private_setting($CONFIG->site->getGUID(), "sitepages:$page_type");
+ $sitepage = get_entity($page_guid);
+
+ if ($sitepage instanceof ElggSitePage || $sitepage->page_type == $page_type) {
+ return $sitepage;
+ }
+
+ return FALSE;
+}
+
+/**
+ * Creates a site page object.
+ *
+ * @param str $page_type
+ * @return mixed ElggSitePage on success, FALSE on fail.
+ */
+function sitepages_create_sitepage_object($page_type) {
+ global $CONFIG;
+
+ $sitepage = new ElggSitePage();
+ $sitepage->page_type = $page_type;
+ $sitepage->access_id = ACCESS_PUBLIC;
+ $sitepage->save();
+
+ if ($sitepage->save() && set_private_setting($CONFIG->site->getGUID(), "sitepages:$page_type", $sitepage->getGUID())) {
+ return $sitepage;
+ }
+
+ return FALSE;
+}
+
+/**
+ * Assembles html for edit sections of site pages.
+ *
+ * @param str $section
+ * @return str html
+ */
+function sitepages_get_edit_section_content($page_type) {
+ set_context('admin');
+
+ $keywords = '';
+
+ $title = elgg_view_title(elgg_echo('sitepages'));
+ $menu = elgg_view('sitepages/menu', array('page_type' => $page_type));
+
+ switch ($page_type) {
+ case 'front':
+ $view = 'sitepages/forms/editfront';
+ $keywords = elgg_view('sitepages/keywords');
+ break;
+
+ case 'seo':
+ $view = 'sitepages/forms/editmeta';
+ break;
+
+ default:
+ $view = 'sitepages/forms/edit';
+ break;
+
+ }
+
+ $form .= elgg_view($view, array('page_type' => $page_type));
+ $body = $title . $menu . $form;
+
+ $content = elgg_view_layout('one_column_with_sidebar', '', $body, $keywords);
+ return $content;
+}
+
+/**
+ * Assembles html for displaying site pages
+ *
+ * @param string $page_type
+ * @return string Formatted html
+ */
+function sitepages_get_page_content($page_type) {
+ $body = elgg_view_title(elgg_echo("sitepages:". strtolower($page_type)));
+
+ $sitepage = sitepages_get_sitepage_object($page_type);
+
+ if ($sitepage) {
+ $body .= elgg_view('page_elements/elgg_content', array('body' => $sitepage->description));
+ } else {
+ $body .= elgg_view('page_elements/elgg_content', array('body' => elgg_echo('sitepages:notset')));
+ }
+
+ $content = elgg_view_layout('one_column_with_sidebar', '', $body);
+ return $content;
+}
+
+/**
+ * Utility object to store site page information.
+ */
+class ElggSitePage extends ElggObject {
+ public function initialise_attributes() {
+ parent::initialise_attributes();
+
+ $this->attributes['subtype'] = 'sitepages_page';
+ }
} \ No newline at end of file