aboutsummaryrefslogtreecommitdiff
path: root/mod/sitepages
diff options
context:
space:
mode:
Diffstat (limited to 'mod/sitepages')
-rw-r--r--mod/sitepages/actions/add.php93
-rw-r--r--mod/sitepages/actions/addfront.php66
-rw-r--r--mod/sitepages/actions/addmeta.php59
-rw-r--r--mod/sitepages/frontpage.php70
-rw-r--r--mod/sitepages/index.php37
-rw-r--r--mod/sitepages/languages/en.php92
-rw-r--r--mod/sitepages/read.php31
-rw-r--r--mod/sitepages/sitepages_functions.php129
-rw-r--r--mod/sitepages/start.php221
-rw-r--r--mod/sitepages/views/default/sitepages/analytics.php13
-rw-r--r--mod/sitepages/views/default/sitepages/css.php9
-rw-r--r--mod/sitepages/views/default/sitepages/custom_frontpage.php17
-rw-r--r--mod/sitepages/views/default/sitepages/forms/edit.php133
-rw-r--r--mod/sitepages/views/default/sitepages/forms/editfront.php71
-rw-r--r--mod/sitepages/views/default/sitepages/forms/editmeta.php59
-rw-r--r--mod/sitepages/views/default/sitepages/keywords.php38
-rw-r--r--mod/sitepages/views/default/sitepages/menu.php27
-rw-r--r--mod/sitepages/views/default/sitepages/metatags.php44
18 files changed, 639 insertions, 570 deletions
diff --git a/mod/sitepages/actions/add.php b/mod/sitepages/actions/add.php
index 3b7f4eb2d..bc38d8067 100644
--- a/mod/sitepages/actions/add.php
+++ b/mod/sitepages/actions/add.php
@@ -1,64 +1,53 @@
<?php
/**
- * Elgg external pages: add/edit
+ * Site pages save/edit
+ *
+ * @package SitePages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ *
*/
// Make sure we're logged as admin
admin_gatekeeper();
// Get input data
-$contents = get_input('sitepagescontent', '', false);
-$type = get_input('content_type');
-$tags = get_input('sitepagestags');
-$previous_guid = get_input('expage_guid');
+$content = get_input('sitepages_content', '', FALSE);
+$page_type = get_input('page_type');
+$tags = get_input('sitepages_tags');
+$tag_array = string_to_tag_array($tags);
-// Cache to the session
-$_SESSION['sitepages_content'] = $contents;
-$_SESSION['sitepagestype'] = $type;
-$_SESSION['sitepagestags'] = $tags;
-
-// Convert string of tags into a preformatted array
-$tagarray = string_to_tag_array($tags);
-
-// Make sure the content exists
-if (empty($contents)) {
- register_error(elgg_echo("sitepages:blank"));
- forward("mod/sitepages/add.php");
-
-// Otherwise, save the new external page
+// Cache to the session for sticky forms
+// @todo make these work.
+$_SESSION['sitepages_content'] = $content;
+$_SESSION['sitepages_type'] = $type;
+$_SESSION['sitepages_tags'] = $tags;
+
+if (!$sitepage = sitepages_get_sitepage_object($page_type)) {
+ $sitepage = sitepages_create_sitepage_object($page_type);
+}
+
+if (empty($content)) {
+ register_error(elgg_echo('sitepages:blank'));
} else {
- //remove the old external page
- if(get_entity($previous_guid)){
- delete_entity($previous_guid);
- }
-
- // Initialise a new ElggObject
- $sitepages = new ElggObject();
- // Tell the system what type of external page it is
- $sitepages->subtype = $type;
- // Set its owner to the current user
- $sitepages->owner_guid = $_SESSION['user']->getGUID();
- // For now, set its access to public
- $sitepages->access_id = 2;
- // Set its title and description appropriately
- $sitepages->title = $type;
- $sitepages->description = $contents;
- // Before we can set metadata, save
- if (!$sitepages->save()) {
- register_error(elgg_echo("sitepages:error"));
- forward("mod/sitepages/add.php");
- }
- // Now let's add tags. We can pass an array directly to the object property! Easy.
- if (is_array($tagarray)) {
- $sitepages->tags = $tagarray;
+ $sitepage->title = $type;
+ $sitepage->description = $content;
+ $sitepage->tags = $tag_array;
+
+ if (!$sitepage->save()) {
+ register_error(elgg_echo('sitepages:error'));
+ } else {
+ system_message(elgg_echo('sitepages:posted'));
+ // @todo this needs to be accurate for create or update.
+ add_to_river('river/sitepages/create', 'create', $_SESSION['user']->guid, $sitepages->guid);
}
- // Success message
- system_message(elgg_echo("sitepages:posted"));
- // add to river
- add_to_river('river/sitepages/create','create',$_SESSION['user']->guid,$sitepages->guid);
- // Remove the cache
- unset($_SESSION['sitepages_content']); unset($_SESSION['sitepagestitle']); unset($_SESSION['sitepagestags']);
-
- // Forward back to the page
- forward("pg/sitepages/index.php?type={$type}");
+
+ // @todo Good intensions...
+ unset($_SESSION['sitepages_content']);
+ unset($_SESSION['sitepagestitle']);
+ unset($_SESSION['sitepagestags']);
}
+
+forward($_SERVER['HTTP_REFERER']); \ No newline at end of file
diff --git a/mod/sitepages/actions/addfront.php b/mod/sitepages/actions/addfront.php
index 5a86189db..6b8782da7 100644
--- a/mod/sitepages/actions/addfront.php
+++ b/mod/sitepages/actions/addfront.php
@@ -1,51 +1,39 @@
<?php
/**
- * Elgg front page: add/edit
+ * Site pages front page save/edit
+ *
+ * @package SitePages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ *
*/
-// Make sure we're logged as admin
admin_gatekeeper();
-// Get input data
-$frontContents = get_input('frontContents');
-$css = get_input('css');
-$previous_guid = get_input('front_guid');
-
-//remove the old front page
-if(get_entity($previous_guid)){
- delete_entity($previous_guid);
+$content = get_input('sitepages_content', '', FALSE);
+$css = get_input('css', '', FALSE);
+$loggedin_user_guid = get_loggedin_userid();
+
+// Cache to the session for sticky forms
+// @todo does nothing yet.
+$_SESSION['sitepages:content'] = $content;
+$_SESSION['sitepages:css'] = $css;
+
+if (!$sitepage = sitepages_get_sitepage_object('front')) {
+ $sitepage = sitepages_create_sitepage_object('front');
}
-//var_export($pageshell);exit;
+$sitepage->title = $css;
+$sitepage->description = $content;
-// Cache to the session
-$_SESSION['pageshell'] = $pageshell;
-$_SESSION['css'] = $css;
-
-// Initialise a new ElggObject
-$frontpage = new ElggObject();
-// Tell the system what type of external page it is
-$frontpage->subtype = "frontpage";
-// Set its owner to the current user
-$frontpage->owner_guid = $_SESSION['user']->getGUID();
-// Set its access to public
-$frontpage->access_id = 2;
-// Set its title and description appropriately
-$frontpage->title = $css;
-$frontpage->description = $frontContents;
-
-// Before we can set metadata, save
-if (!$frontpage->save()) {
+if ($sitepage->save()) {
+ system_message(elgg_echo("sitepages:posted"));
+ unset($_SESSION['sitepages:content']);
+ unset($_SESSION['sitepages:css']);
+} else {
register_error(elgg_echo("sitepages:error"));
- forward("pg/sitepages/index.php?type=front");
}
-// Success message
-system_message(elgg_echo("sitepages:posted"));
-
-// Remove the cache
-unset($_SESSION['css']); unset($_SESSION['pageshell']);
-
-
-// Forward back to the page
-forward("pg/sitepages/index.php?type=front");
+forward($_SERVER['HTTP_REFERER']); \ No newline at end of file
diff --git a/mod/sitepages/actions/addmeta.php b/mod/sitepages/actions/addmeta.php
index 432152ef1..e9f40cdb4 100644
--- a/mod/sitepages/actions/addmeta.php
+++ b/mod/sitepages/actions/addmeta.php
@@ -1,49 +1,36 @@
<?php
/**
- * Elgg SEO: add/edit
+ * Site pages meta tags and desc page save/edit
+ *
+ * @package SitePages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ *
*/
-// Make sure we're logged as admin
admin_gatekeeper();
-// Get input data
-$description = get_input('description', '', false);
-$metatags = get_input('metatags', '', false);
-$previous_guid = get_input('seo_guid');
-
-//remove the old front page
-if(get_entity($previous_guid)){
- delete_entity($previous_guid);
-}
+$description = get_input('description', '', FALSE);
+$metatags = get_input('metatags', '', FALSE);
// Cache to the session
$_SESSION['description'] = $description;
$_SESSION['metatags'] = $metatags;
-
-// Initialise a new ElggObject
-$seo = new ElggObject();
-// Tell the system what type of external page it is
-$seo->subtype = "sitemeta";
-// Set its owner to the current user
-$seo->owner_guid = $_SESSION['user']->getGUID();
-// Set its access to public
-$seo->access_id = 2;
-// Set its title and description appropriately
-$seo->title = $metatags;
-$seo->description = $description;
-
-// Before we can set metadata, save
-if (!$seo->save()) {
- register_error(elgg_echo("sitepages:error"));
- forward("pg/sitepages/index.php?type=seo");
+
+if (!$sitepage = sitepages_get_sitepage_object('front')) {
+ $sitepage = sitepages_create_sitepage_object('front');
}
-// Success message
-system_message(elgg_echo("sitepages:seocreated"));
+$sitepage->title = $metatags;
+$sitepage->description = $description;
+
+if ($sitepage->save()) {
+ system_message(elgg_echo("sitepages:seocreated"));
+ unset($_SESSION['description']); unset($_SESSION['metatags']);
+} else {
+ register_error(elgg_echo("sitepages:error"));
+}
-// Remove the cache
-unset($_SESSION['description']); unset($_SESSION['metatags']);
-
-
-// Forward back to the page
-forward("pg/sitepages/index.php?type=seo");
+forward($_SERVER['HTTP_REFERER']); \ No newline at end of file
diff --git a/mod/sitepages/frontpage.php b/mod/sitepages/frontpage.php
deleted file mode 100644
index 4f5d02a90..000000000
--- a/mod/sitepages/frontpage.php
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
- * Elgg custom frontpage
- */
-
-// Load Elgg engine will not include plugins
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-global $CONFIG;
-
-$page_contents = elgg_get_entities(array('type' => 'object', 'subtype' => 'frontpage', 'limit' => 1));
-if($page_contents){
- foreach($page_contents as $pc){
- $css = "<style>" . $pc->title . "</style>";
- $frontContents = $pc->description;
- }
-}
-
-// Set title
-$title = $CONFIG->sitename;
-
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="ElggRelease" content="<?php echo $release; ?>" />
- <meta name="ElggVersion" content="<?php echo $version; ?>" />
- <title><?php echo $title; ?></title>
- <link REL="SHORTCUT ICON" HREF="<?php echo $CONFIG->wwwroot; ?>_graphics/favicon.ico">
-
- <script type="text/javascript" src="<?php echo $CONFIG->wwwroot; ?>vendors/jquery/jquery-1.4.min.js"></script>
- <script type="text/javascript" src="<?php echo $CONFIG->wwwroot; ?>vendors/jquery/jquery-ui-1.7.2.min.js"></script>
- <script type="text/javascript" src="<?php echo $CONFIG->wwwroot; ?>vendors/jquery/jquery.form.js"></script>
- <script type="text/javascript" src="<?php echo $CONFIG->wwwroot; ?>vendors/jquery/custom-form-elements.js"></script>
- <script type="text/javascript" src="<?php echo $CONFIG->wwwroot; ?>_css/js.php?lastcache=<?php echo $CONFIG->lastcache; ?>&amp;js=initialise_elgg&amp;viewtype=<?php echo $vars['view']; ?>"></script>
-
- <?php
- echo $feedref;
- //custom css - need to cache this. It is here instead of extending the main css
- //as we don't want it appearing anywhere else throughout the site, only the frontpage.
- echo $css;
- echo elgg_view('metatags',$vars);
- ?>
- <script type="text/javascript">
- jQuery(document).ready(function($) {
- });
- </script>
-
-<?php
- global $pickerinuse;
- if (isset($pickerinuse) && $pickerinuse == true) {
-?>
- <!-- only needed on pages where we have friends collections and/or the friends picker -->
- <script type="text/javascript" src="<?php echo $CONFIG->wwwroot; ?>vendors/jquery/jquery.easing.1.3.packed.js"></script>
- <script type="text/javascript" src="<?php echo $CONFIG->wwwroot; ?>_css/js.php?lastcache=<?php echo $vars['config']->lastcache; ?>&amp;js=friendsPickerv1&amp;viewtype=<?php echo $vars['view']; ?>"></script>
-<?php
- }
-?>
- <!-- include the default css file -->
- <link rel="stylesheet" href="<?php echo $CONFIG->wwwroot; ?>_css/css.css?lastcache=<?php echo $CONFIG->lastcache; ?>&amp;viewtype=<?php echo $CONFIG->view; ?>" type="text/css" />
-</head>
-<body>
-<?php echo elgg_view('page_elements/elgg_topbar', $vars); ?>
-<?php echo elgg_view('page_elements/elgg_header', $vars); ?>
-<?php
- echo parse_frontpage($frontContents);
-?>
-<?php echo elgg_view('page_elements/elgg_footer', $vars); ?>
-<?php echo elgg_view('page_elements/html_end', $vars); ?> \ No newline at end of file
diff --git a/mod/sitepages/index.php b/mod/sitepages/index.php
deleted file mode 100644
index efc7371b7..000000000
--- a/mod/sitepages/index.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-/**
- * Elgg Site pages
- */
-
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-admin_gatekeeper();
-set_context('admin');
-$type = get_input('type'); //the type of page e.g about, terms etc
-if(!$type)
- $type = "front"; //default to the frontpage
-
-// Set admin user for user block
-set_page_owner($_SESSION['guid']);
-
-//display the title
-$title = elgg_view_title(elgg_echo('sitepages'));
-
-// Display the correct form
-if($type == "front")
- $edit = elgg_view('sitepages/forms/editfront');
-elseif($type == "seo")
- $edit = elgg_view('sitepages/forms/editmeta');
-else
- $edit = elgg_view('sitepages/forms/edit', array('type' => $type));
-
-if($type == "front")
- $area3 = elgg_view('sitepages/keywords'); //available keywords for the user
-else
- $area3 = "";
-
-// Display the menu
-$body = elgg_view('page_elements/elgg_content',array('body' => elgg_view('sitepages/menu', array('type' => $type)).$edit));
-
-// Display
-page_draw(elgg_echo('sitepages'),elgg_view_layout("one_column_with_sidebar", '', $title . $body, $area3)); \ No newline at end of file
diff --git a/mod/sitepages/languages/en.php b/mod/sitepages/languages/en.php
index 2f4916ee5..ec08493c9 100644
--- a/mod/sitepages/languages/en.php
+++ b/mod/sitepages/languages/en.php
@@ -1,48 +1,50 @@
<?php
+/**
+ * Language definitions 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/
+ */
- $english = array(
-
- /**
- * Menu items and titles
- */
-
- 'sitepages' => "Site pages",
- 'sitepages:frontpage' => "Frontpage",
- 'sitepages:about' => "About",
- 'sitepages:terms' => "Terms",
- 'sitepages:privacy' => "Privacy",
- 'sitepages:analytics' => "Analytics",
- 'sitepages:contact' => "Contact",
- 'sitepages:nopreview' => "No preview yet available",
- 'sitepages:preview' => "Preview",
- 'sitepages:notset' => "This page has not been set up yet.",
- 'sitepages:new' => "New page",
- 'sitepages:css' => "Stylesheet",
- 'sitepages:seo' => "Metatags",
- 'sitepages:metadescription' => "Meta description for search engines",
- 'sitepages:metatags' => "Meta tags for search engines (use a comma)",
- 'sitepages:seocreated' => "Your search engine information has been added",
- 'sitepages:frontContents' => "Frontpage contents",
- 'sitepages:ownfront' => "Construct your own frontpage for this network. (Note:you will need to know html and css)",
- 'sitepages:addcontent' => "You can add content here via your admin tools. Look for the external pages link under admin.",
- 'item:object:front' => 'Front page items',
-
- /**
- * Status messages
- */
-
- 'sitepages:posted' => "Your page was successfully posted.",
- 'sitepages:deleted' => "Your page was successfully deleted.",
-
- /**
- * Error messages
- */
-
- 'sitepages:deleteerror' => "There was a problem deleting the old page",
- 'sitepages:error' => "There has been an error, please try again and if the problem persists, contact the administrator",
-
- );
-
- add_translation("en",$english);
+$english = array(
+ /**
+ * Menu items and titles
+ */
+ 'sitepages' => "Site pages",
+ 'sitepages:frontpage' => "Frontpage",
+ 'sitepages:about' => "About",
+ 'sitepages:terms' => "Terms",
+ 'sitepages:privacy' => "Privacy",
+ 'sitepages:analytics' => "Analytics",
+ 'sitepages:contact' => "Contact",
+ 'sitepages:nopreview' => "No preview yet available",
+ 'sitepages:preview' => "Preview",
+ 'sitepages:notset' => "This page has not been set up yet.",
+ 'sitepages:new' => "New page",
+ 'sitepages:css' => "CSS",
+ 'sitepages:seo' => "Metatags",
+ 'sitepages:metadescription' => "Meta description for search engines",
+ 'sitepages:metatags' => "Meta tags for search engines (use a comma)",
+ 'sitepages:seocreated' => "Your search engine information has been added",
+ 'sitepages:front_content' => "Frontpage content",
+ 'sitepages:ownfront' => "Construct your own frontpage for this network. (Note:you will need to know html and css)",
+ 'sitepages:addcontent' => "You can add content here via your admin tools. Look for the external pages link under admin.",
+ 'item:object:front' => 'Front page items',
-?> \ No newline at end of file
+ /**
+ * Status messages
+ */
+ 'sitepages:posted' => "Your page was successfully posted.",
+ 'sitepages:deleted' => "Your page was successfully deleted.",
+
+ /**
+ * Error messages
+ */
+ 'sitepages:deleteerror' => "There was a problem deleting the old page",
+ 'sitepages:error' => "There has been an error, please try again and if the problem persists, contact the administrator",
+);
+
+add_translation('en', $english); \ No newline at end of file
diff --git a/mod/sitepages/read.php b/mod/sitepages/read.php
deleted file mode 100644
index 5621c486b..000000000
--- a/mod/sitepages/read.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
- * Elgg read site page
- */
-
-// Load Elgg engine
-define('externalpage',true);
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-// set some variables
-$type = get_input('sitepages');
-
-// Set the title appropriately
-$area1 = elgg_view_title(elgg_echo("sitepages:". strtolower($type)));
-
-//get contents
-$contents = elgg_get_entities(array('type' => 'object', 'subtype' => $type, 'limit' => 1));
-
-if($contents){
- foreach($contents as $c){
- $area1 .= elgg_view('page_elements/elgg_content',array('body' => $c->description));
- }
-}else{
- $area1 .= elgg_view('page_elements/elgg_content',array('body' => elgg_echo("sitepages:notset")));
-}
-
-// Display through the correct canvas area
-$body = elgg_view_layout("one_column_with_sidebar", "", $area1);
-
-// Display page
-page_draw($title,$body); \ No newline at end of file
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
diff --git a/mod/sitepages/start.php b/mod/sitepages/start.php
index c6e119959..186738bab 100644
--- a/mod/sitepages/start.php
+++ b/mod/sitepages/start.php
@@ -1,72 +1,211 @@
<?php
/**
- * Elgg external pages editor
+ * Site Pages provides interfaces to create standard content-static pages
+ * and to customize the front page layout and content.
+ *
+ * Formerly implemented as "external pages" and "custom index."
+ *
+ * @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/
+ *
+ * @todo Implement sticky pages
+ * @todo DRY up actions and views
*/
-
-require_once(dirname(__FILE__) . '/sitepages_functions.php');
+/**
+ * Start the site pages plugin.
+ */
function sitepages_init() {
+ require_once(dirname(__FILE__) . '/sitepages_functions.php');
global $CONFIG;
+
+ // register our subtype
+ run_function_once('sitepages_runonce');
+
// Register a page handler, so we can have nice URLs
- register_page_handler('sitepages','sitepages_page_handler');
-
+ register_page_handler('sitepages', 'sitepages_page_handler');
+
// Register a URL handler for external pages
- register_entity_url_handler('sitepages_url','object','sitepages');
-
- // extend views
+ register_entity_url_handler('sitepages_url', 'object', 'sitepages');
+
elgg_extend_view('footer/links', 'sitepages/footer_menu');
elgg_extend_view('metatags', 'sitepages/metatags');
-
+
// Replace the default index page if user has requested
- if (get_plugin_setting('ownfrontpage', 'externalpages') == 'yes'){
- register_plugin_hook('index','system','custom_index');
+ if (get_plugin_setting('ownfrontpage', 'sitepages') == 'yes') {
+ register_plugin_hook('index', 'system', 'sitepages_custom_index');
}
-
+
+ // parse views for keywords
+ register_plugin_hook('display', 'view', 'sitepages_parse_view');
+
+ // register the views we want to parse for the keyword replacement
+ // right now this is just the custom front page, but we can
+ // expand it to the other pages later.
+ $CONFIG->sitepages_parse_views = array(
+ 'sitepages/custom_frontpage'
+ );
+
+ // an example of how to register and respond to the get_keywords trigger
+ register_plugin_hook('get_keywords', 'sitepages', 'sitepages_keyword_hook');
+
+ // grab the list of keywords and their views from plugins
+ if ($keywords = trigger_plugin_hook('get_keywords', 'sitepages', NULL, array())) {
+ $CONFIG->sitepages_keywords = $keywords;
+ }
+
+ register_action("sitepages/add", FALSE, $CONFIG->pluginspath . "sitepages/actions/add.php");
+ register_action("sitepages/addfront", FALSE, $CONFIG->pluginspath . "sitepages/actions/addfront.php");
+ register_action("sitepages/addmeta", FALSE, $CONFIG->pluginspath . "sitepages/actions/addmeta.php");
+ register_action("sitepages/edit", FALSE, $CONFIG->pluginspath . "sitepages/actions/edit.php");
+ register_action("sitepages/delete", FALSE, $CONFIG->pluginspath . "sitepages/actions/delete.php");
+
}
-function custom_index() {
- if (!@include_once(dirname(__FILE__) . "/frontpage.php")) return false;
- return true;
+/**
+ * Registers the sitepages subtype to the right class.
+ *
+ * @return unknown_type
+ */
+function sitepages_runonce() {
+ return add_subtype('object', 'sitepages_page', 'ElggSitePage');
}
-
+
/**
- * Page setup. Adds admin controls to the admin panel.
+ * Override the index if requested.
*
+ * @return TRUE on override
+ */
+function sitepages_custom_index() {
+ // context is checked by the extended metatags view to print out its custom CSS
+ $context = get_context();
+ set_context('sitepages:front');
+
+ if ($contents = elgg_view('sitepages/custom_frontpage')) {
+ page_draw(FALSE, $contents);
+
+ set_context($context);
+ // return TRUE to tell index.php we've got its content right here.
+ return TRUE;
+ }
+
+ set_context($context);
+ return NULL;
+}
+
+/**
+ * Page setup. Adds admin controls to the admin panel.
*/
function sitepages_pagesetup(){
if (get_context() == 'admin' && isadminloggedin()) {
global $CONFIG;
- add_submenu_item(elgg_echo('sitepages'), $CONFIG->wwwroot . 'pg/sitepages/');
+ add_submenu_item(elgg_echo('sitepages'), $CONFIG->wwwroot . 'pg/sitepages/edit/front');
}
}
-
+
+/**
+ *
+ * @param unknown_type $expage
+ * @return unknown_type
+ *
+ * //@todo is this needed?
+ */
function sitepages_url($expage) {
global $CONFIG;
- return $CONFIG->url . "pg/sitepages/";
+ return $CONFIG->url . 'pg/sitepages/';
}
-
+
+/**
+ * Serve out views for site pages.
+ *
+ * @param unknown_type $page
+ * @return unknown_type
+ */
function sitepages_page_handler($page) {
global $CONFIG;
- if ($page[0]){
- switch ($page[0]){
- case "read": set_input('sitepages',$page[1]);
- include(dirname(__FILE__) . "/read.php");
- break;
- default : include($CONFIG->pluginspath . "sitepages/index.php");
+
+ // for the owner block.
+ if ($logged_in_guid = get_loggedin_userid()) {
+ set_page_owner($logged_in_guid);
+ }
+
+ // sanity checking.
+ // on bad params we'll forward so people will bookmark the correct URLs
+ // @todo valid page names need to be pulled out into some sort of config var or admin option.
+ $default_page = 'About';
+
+ $action = isset($page[0]) ? $page[0] : FALSE;
+ $page_type = isset($page[1]) ? $page[1] : FALSE;
+
+ switch ($action) {
+ case 'edit':
+ $title = elgg_echo('sitepages');
+ $content = sitepages_get_edit_section_content($page_type);
+
+ break;
+
+ case 'read':
+ $title = elgg_echo('sitepages:' . strtolower($page_type));
+ $content = sitepages_get_page_content($page_type);
+
+ break;
+
+ default:
+ forward("{$CONFIG->site->url}pg/sitepages/read/$default_page");
+ break;
+ }
+
+ page_draw($title, $content);
+}
+
+
+function sitepages_parse_view($hook, $entity_type, $return_value, $params) {
+ global $CONFIG;
+
+ if (in_array($params['view'], $CONFIG->sitepages_parse_views)) {
+ $keywords = $CONFIG->sitepages_keywords;
+ $view_options = array(
+ 'view' => $params['view']
+ );
+
+ foreach ($keywords as $keyword => $info) {
+ if ($content = elgg_view($info['view'], $view_options)) {
+ $return_value = str_replace("[[$keyword]]", $content, $return_value);
+ }
}
- }else{
- include($CONFIG->pluginspath . "sitepages/index.php");
}
+
+ return $return_value;
}
-
-// Initialise log browser
-register_elgg_event_handler('init','system','sitepages_init');
-register_elgg_event_handler('pagesetup','system','sitepages_pagesetup');
-
-// Register actions
-global $CONFIG;
-register_action("sitepages/add",false,$CONFIG->pluginspath . "sitepages/actions/add.php");
-register_action("sitepages/addfront",false,$CONFIG->pluginspath . "sitepages/actions/addfront.php");
-register_action("sitepages/addmeta",false,$CONFIG->pluginspath . "sitepages/actions/addmeta.php");
-register_action("sitepages/edit",false,$CONFIG->pluginspath . "sitepages/actions/edit.php");
-register_action("sitepages/delete",false,$CONFIG->pluginspath . "sitepages/actions/delete.php"); \ No newline at end of file
+
+/**
+ * Register some default keywords.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $return_value
+ * @param unknown_type $params
+ * @return unknown_type
+ */
+function sitepages_keyword_hook($hook, $entity_type, $return_value, $params) {
+
+ $return_value['login_box'] = array(
+ 'view' => 'account/forms/login',
+ 'description' => elgg_echo('sitepages:keywords:login_box')
+ );
+
+ $return_value['site_stats'] = array(
+ 'view' => 'this/doesnt/exist/yet',
+ 'description' => elgg_echo('sitepages:keywords:site_stats')
+ );
+
+ return $return_value;
+}
+
+
+
+register_elgg_event_handler('init', 'system', 'sitepages_init');
+register_elgg_event_handler('pagesetup', 'system', 'sitepages_pagesetup'); \ No newline at end of file
diff --git a/mod/sitepages/views/default/sitepages/analytics.php b/mod/sitepages/views/default/sitepages/analytics.php
deleted file mode 100644
index 0a8e94b67..000000000
--- a/mod/sitepages/views/default/sitepages/analytics.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-/**
- * Elgg Analytics view
- */
-
-//get analytics content
-$contents = elgg_get_entities(array('type' => 'object', 'subtype' => 'analytics', 'limit' => 1));
-if($contents){
- foreach($contents as $c){
- echo $c->description;
- }
-}
-
diff --git a/mod/sitepages/views/default/sitepages/css.php b/mod/sitepages/views/default/sitepages/css.php
deleted file mode 100644
index 5d7eabcd4..000000000
--- a/mod/sitepages/views/default/sitepages/css.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-/**
- * Elgg sitepages CSS
- */
-?>
-
-/* IE6 */
-* html #front_left_tbl { width:676px !important; }
-* html #front_right_tbl { width:676px !important; } \ No newline at end of file
diff --git a/mod/sitepages/views/default/sitepages/custom_frontpage.php b/mod/sitepages/views/default/sitepages/custom_frontpage.php
new file mode 100644
index 000000000..fb0b673cc
--- /dev/null
+++ b/mod/sitepages/views/default/sitepages/custom_frontpage.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Custom front page.
+ * This is in a view so we can parse it for keywords.
+ *
+ * @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/
+ */
+
+$object = sitepages_get_sitepage_object('front');
+
+if ($object) {
+ echo $object->description;
+} \ No newline at end of file
diff --git a/mod/sitepages/views/default/sitepages/forms/edit.php b/mod/sitepages/views/default/sitepages/forms/edit.php
index 94ec786b1..16100c10a 100644
--- a/mod/sitepages/views/default/sitepages/forms/edit.php
+++ b/mod/sitepages/views/default/sitepages/forms/edit.php
@@ -1,92 +1,51 @@
<?php
+/**
+ * Edit non front or SEO site pages.
+ *
+ * @package Elggsitepages
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ *
+ */
- /**
- * Elgg sitepages edit
- *
- * @package Elggsitepages
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.com/
- *
- */
-
- //get the page type
- $type = $vars['type'];
-
- //action
- $action = "sitepages/add";
-
- //grab the required entity
- $page_contents = elgg_get_entities(array('type' => 'object', 'subtype' => $type, 'limit' => 1));
-
- if($page_contents){
- foreach($page_contents as $pc){
- $description = $pc->description;
- $tags = $pc->tags;
- $guid = $pc->guid;
- }
- }else {
- $tags = "";
- $description = "";
- }
-
- // set the required form variables
- $input_area = elgg_view('input/longtext', array('internalname' => 'sitepagescontent', 'value' => $description));
- $tag_input = elgg_view('input/tags', array('internalname' => 'sitepagestags', 'value' => $tags));
- $submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('save')));
- $hidden_value = elgg_view('input/hidden', array('internalname' => 'content_type', 'value' => $type));
- $hidden_guid = elgg_view('input/hidden', array('internalname' => 'expage_guid', 'value' => $guid));
- $tag_label = elgg_echo('tags') . "<br/>";
-
- //type
- $type = $vars['type'];
- //set the url
- $url = $vars['url'] . "pg/sitepages/index.php?type=";
-
- if($type == 'about') {
- $external_page_title = elgg_echo('sitepages:about');
- }
- else if($type == 'terms') {
- $external_page_title = elgg_echo('sitepages:terms');
- }
- else if($type == 'privacy') {
- $external_page_title = elgg_echo('sitepages:privacy');
- }
- //preview link
- // echo "<div class=\"page_preview\"><a href=\"#preview\">" . elgg_echo('sitepages:preview') . "</a></div>";
-
- //construct the form
- $form_body = <<<EOT
+$page_type = $vars['page_type'];
+$action = 'sitepages/add';
- <h3 class='settings'>$external_page_title</h3>
- <p class='longtext_editarea'>$input_area</p>
- <p>
- $tag_label
- $tag_input
- </p>
- $hidden_value
- $hidden_guid
- <br />
- $submit_input
+if ($sitepages_object = sitepages_get_sitepage_object($page_type)) {
+ $tags = $sitepages_object->tags;
+ $description = $sitepages_object->description;
+ $guid = $sitepages_object->getGUID();
+} else {
+ $tags = array();
+ $description = '';
+ $guid = '';
+}
-EOT;
-?>
-<?php
- //display the form
- echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body));
-?>
+// set the required form variables
+$input_area = elgg_view('input/longtext', array('internalname' => 'sitepages_content', 'value' => $description));
+$tag_input = elgg_view('input/tags', array('internalname' => 'sitepages_tags', 'value' => $tags));
+
+$submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('save')));
+$hidden_value = elgg_view('input/hidden', array('internalname' => 'page_type', 'value' => $page_type));
+
+$tag_label = '<h3>' . elgg_echo('tags') . '</h3>';
+$external_page_title = elgg_echo("sitepages:$page_type");
+
+$form_body = <<<___EOT
+
+<h3 class='settings'>$external_page_title</h3>
+<p class='longtext_editarea'>$input_area</p>
+<p>
+ $tag_label
+ $tag_input
+</p>
+$hidden_value
+$hidden_guid
+<br />
+$submit_input
+
+___EOT;
-<!-- preview page contents -->
-<!--
-<div class="expage_preview">
-<a name="preview"></a>
-<h2>Preview</h2>
-<?php
- if($description)
- echo $description;
- else
- echo elgg_echo('sitepages:nopreview');
-?>
-</div>
---> \ No newline at end of file
+echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body)); \ No newline at end of file
diff --git a/mod/sitepages/views/default/sitepages/forms/editfront.php b/mod/sitepages/views/default/sitepages/forms/editfront.php
index faea356f2..cc09b8cc8 100644
--- a/mod/sitepages/views/default/sitepages/forms/editfront.php
+++ b/mod/sitepages/views/default/sitepages/forms/editfront.php
@@ -1,52 +1,51 @@
<?php
/**
- * Elgg edit frontpage
+ * Edit form for the custom front page
+ *
+ * @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/
*/
-
-//action
-$action = "sitepages/addfront";
-
-//grab the required entity
-$page_contents = elgg_get_entities(array('type' => 'object', 'subtype' => 'frontpage', 'limit' => 1));
-
-if($page_contents){
- foreach($page_contents as $pc){
- $css = $pc->title;
- $frontContents = $pc->description;
- $guid = $pc->guid;
- }
-}else {
- $tags = "";
- $description = "";
+
+$action = 'sitepages/addfront';
+
+if ($sitepages_object = sitepages_get_sitepage_object('front')) {
+ $css = $sitepages_object->title;
+ $sitepages_content = $sitepages_object->description;
+ $guid = $sitepages_object->guid;
+} else {
+ $css = '';
+ $sitepages_content = '';
+ $guid = '';
}
-
+
// set the required form variables
$input_css = elgg_view('input/plaintext', array('internalname' => 'css', 'value' => $css));
-$input_pageshell = elgg_view('input/plaintext', array('internalname' => 'frontContents', 'value' => $frontContents));
+$input_sitepages_content = elgg_view('input/plaintext', array('internalname' => 'sitepages_content', 'value' => $sitepages_content));
$submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('save')));
-$hidden_guid = elgg_view('input/hidden', array('internalname' => 'front_guid', 'value' => $guid));
-$pageshell = elgg_echo("sitepages:frontContents");
-$css = elgg_echo("sitepages:css");
-
+
+$pageshell_title = elgg_echo("sitepages:front_content");
+$css_title = elgg_echo("sitepages:css");
+
//preview link
-$preview = "<div class=\"page_preview\"><a href=\"#preview\">" . elgg_echo('sitepages:preview') . "</a></div>";
-
+// @todo this doesn't do anything.
+//$preview = "<div class=\"page_preview\"><a href=\"#preview\">" . elgg_echo('sitepages:preview') . "</a></div>";
+
//construct the form
-$form_body = <<<EOT
+$form_body = <<<___EOT
- <h3 class='settings'>$css</h3>
+ <h3 class='settings'>$css_title</h3>
<p class='longtext_editarea'>$input_css</p><br />
- <h3 class='settings'>$pageshell</h3>
- <p class='longtext_editarea'>$input_pageshell</p>
-
+ <h3 class='settings'>$pageshell_title</h3>
+ <p class='longtext_editarea'>$input_sitepages_content</p>
+
$hidden_guid
<br />
$submit_input
$preview
-EOT;
-?>
-<?php
- //display the form
- echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body));
-?> \ No newline at end of file
+___EOT;
+
+echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body)); \ No newline at end of file
diff --git a/mod/sitepages/views/default/sitepages/forms/editmeta.php b/mod/sitepages/views/default/sitepages/forms/editmeta.php
index 7eb731f76..d94f32114 100644
--- a/mod/sitepages/views/default/sitepages/forms/editmeta.php
+++ b/mod/sitepages/views/default/sitepages/forms/editmeta.php
@@ -1,48 +1,43 @@
<?php
/**
- * Elgg edit frontpage
+ * Edit form for the custom meta tags and desc
+ *
+ * @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/
*/
-
-//action
-$action = "sitepages/addmeta";
-
-//grab the required entity
-$page_contents = elgg_get_entities(array('type' => 'object', 'subtype' => 'sitemeta', 'limit' => 1));
-
-if($page_contents){
- foreach($page_contents as $pc){
- $metatags = $pc->title;
- $description = $pc->description;
- $guid = $pc->guid;
- }
-}else {
- $metatags = "";
- $description = "";
+
+$action = 'sitepages/addmeta';
+
+if ($sitepages_object = sitepages_get_sitepage_object('front')) {
+ $meta_tags = $sitepages_object->title;
+ $meta_description = $sitepages_object->description;
+} else {
+ $meta_tags = '';
+ $meta_description = '';
}
-
-// set the required form variables
-$input_keywords = elgg_view('input/plaintext', array('internalname' => 'metatags', 'value' => $metatags));
-$input_description = elgg_view('input/plaintext', array('internalname' => 'description', 'value' => $description));
+
+$input_keywords = elgg_view('input/plaintext', array('internalname' => 'metatags', 'value' => $meta_tags));
+$input_description = elgg_view('input/plaintext', array('internalname' => 'description', 'value' => $meta_description));
$submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('save')));
-$hidden_guid = elgg_view('input/hidden', array('internalname' => 'seo_guid', 'value' => $guid));
+
$description = elgg_echo("sitepages:metadescription");
$metatags = elgg_echo("sitepages:metatags");
-
-//construct the form
-$form_body = <<<EOT
+
+$form_body = <<<___EOT
<h3 class='settings'>$description</h3>
<p class='longtext_editarea'>$input_description</p><br />
<h3 class='settings'>$metatags</h3>
<p class='longtext_editarea'>$input_keywords</p>
-
+
$hidden_guid
<br />
$submit_input
-EOT;
-?>
-<?php
- //display the form
- echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body));
-?> \ No newline at end of file
+___EOT;
+
+//display the form
+echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body)); \ No newline at end of file
diff --git a/mod/sitepages/views/default/sitepages/keywords.php b/mod/sitepages/views/default/sitepages/keywords.php
index 2b4666256..e5348678a 100644
--- a/mod/sitepages/views/default/sitepages/keywords.php
+++ b/mod/sitepages/views/default/sitepages/keywords.php
@@ -1,14 +1,28 @@
<?php
/**
- * Available keywords, this will be pulled from activated plugin that expose a keyword function
- **/
-?>
-<div class="contentWrapper">
- <h3>Available keywords</h3>
- <ul>
- <li>{{element:loginbox}}</li>
- <li>{{element:stats}}</li>
- <li>{{object:blog}}</li>
- <li>{{group:4}}</li>
- </ul>
-</div> \ No newline at end of file
+ * Lists available keywords
+ *
+ * @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/
+ */
+
+$keywords = $vars['config']->sitepages_keywords;
+$title = elgg_echo('sitepages:keywords_title');
+$instructions = elgg_echo('sitepages:keywords_instructions');
+
+$keywords_html = '';
+foreach ($keywords as $keyword => $info) {
+ $desc = htmlentities($info['description']);
+ $keywords_html .= "<li><acronym title=\"$desc\">[[$keyword]]</acronym></li>";
+}
+
+echo "
+<h3>$title</h3>
+<p>$instructions</p>
+<ul>
+ $keywords_html
+</ul>
+"; \ No newline at end of file
diff --git a/mod/sitepages/views/default/sitepages/menu.php b/mod/sitepages/views/default/sitepages/menu.php
index 5f074f489..e676b6c96 100644
--- a/mod/sitepages/views/default/sitepages/menu.php
+++ b/mod/sitepages/views/default/sitepages/menu.php
@@ -1,22 +1,25 @@
<?php
/**
- * Elgg Site pages menu
+ * Displays the tabbed menu for editing 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/
*/
-
-//type
-$type = $vars['type'];
-
-//set the url
-$url = $vars['url'] . "pg/sitepages/index.php?type=";
+
+$page_type = $vars['page_type'];
+$url = $vars['url'] . 'pg/sitepages/edit/';
?>
<div class="elgg_horizontal_tabbed_nav">
<ul>
- <li <?php if($type == 'front') echo "class = 'selected'"; ?>><a href="<?php echo $url; ?>front"><?php echo elgg_echo('sitepages:frontpage'); ?></a></li>
- <li <?php if($type == 'about') echo "class = 'selected'"; ?>><a href="<?php echo $url; ?>about"><?php echo elgg_echo('sitepages:about'); ?></a></li>
- <li <?php if($type == 'terms') echo "class = 'selected'"; ?>><a href="<?php echo $url; ?>terms"><?php echo elgg_echo('sitepages:terms'); ?></a></li>
- <li <?php if($type == 'privacy') echo "class = 'selected'"; ?>><a href="<?php echo $url; ?>privacy"><?php echo elgg_echo('sitepages:privacy'); ?></a></li>
- <li <?php if($type == 'seo') echo "class = 'selected'"; ?>><a href="<?php echo $url; ?>seo"><?php echo elgg_echo('sitepages:seo'); ?></a></li>
+ <li <?php if($page_type == 'front') echo "class = 'selected'"; ?>><a href="<?php echo $url; ?>front"><?php echo elgg_echo('sitepages:frontpage'); ?></a></li>
+ <li <?php if($page_type == 'about') echo "class = 'selected'"; ?>><a href="<?php echo $url; ?>about"><?php echo elgg_echo('sitepages:about'); ?></a></li>
+ <li <?php if($page_type == 'terms') echo "class = 'selected'"; ?>><a href="<?php echo $url; ?>terms"><?php echo elgg_echo('sitepages:terms'); ?></a></li>
+ <li <?php if($page_type == 'privacy') echo "class = 'selected'"; ?>><a href="<?php echo $url; ?>privacy"><?php echo elgg_echo('sitepages:privacy'); ?></a></li>
+ <li <?php if($page_type == 'seo') echo "class = 'selected'"; ?>><a href="<?php echo $url; ?>seo"><?php echo elgg_echo('sitepages:seo'); ?></a></li>
</ul>
</div> \ No newline at end of file
diff --git a/mod/sitepages/views/default/sitepages/metatags.php b/mod/sitepages/views/default/sitepages/metatags.php
index 73a7cd17f..c536dbe29 100644
--- a/mod/sitepages/views/default/sitepages/metatags.php
+++ b/mod/sitepages/views/default/sitepages/metatags.php
@@ -1,17 +1,35 @@
<?php
/**
- * Meta tags
- **/
-
-$meta_details = elgg_get_entities(array('type' => 'object', 'subtype' => 'seo', 'limit' => 1));
-if($meta_details){
- foreach($meta_details as $md){
- $metatags = $md->title;
- $description = $md->description;
- }
+ * Add any additional defined metatags or CSS.
+ *
+ * @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/
+ */
+
+$meta_details = sitepages_get_sitepage_object('seo');
+
+if ($meta_details) {
+ $metatags = $meta_details->title;
+ $description = $meta_details->description;
+
+ echo <<<___END
+ <meta name="description" content="$description" />
+ <meta name="keywords" content="$metatags" />
+___END;
}
-
-?>
-<meta name="description" content="<?php echo $description; ?>." />
-<meta name="keywords" content="<?php echo $metatags; ?>" /> \ No newline at end of file
+// only show on the custom front page.
+if (get_context() == 'sitepages:front') {
+ $custom_css = sitepages_get_sitepage_object('front');
+
+ if ($custom_css && $custom_css->title) {
+ echo "
+ <style>
+ {$custom_css->title}
+ </style>
+ ";
+ }
+} \ No newline at end of file