From 1336b9e8ed9cc3f9b9b9c4427f1e0f8bccc96f7d Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 8 Mar 2010 15:51:52 +0000 Subject: Site pages will eventually replace the external pages and custom index plugins as well as introduce a new keywords system to enable dynamic content to be displayed without needing to know php or Elgg. This will be handy for frontpage layout/design. git-svn-id: http://code.elgg.org/elgg/trunk@5303 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/sitepages/actions/add.php | 64 +++++++++++++++ mod/sitepages/actions/addfront.php | 51 ++++++++++++ mod/sitepages/actions/addmeta.php | 49 ++++++++++++ mod/sitepages/frontpage.php | 70 ++++++++++++++++ mod/sitepages/index.php | 37 +++++++++ mod/sitepages/languages/en.php | 48 +++++++++++ mod/sitepages/manifest.xml | 10 +++ mod/sitepages/read.php | 31 ++++++++ mod/sitepages/sitepages_functions.php | 8 ++ mod/sitepages/start.php | 72 +++++++++++++++++ .../views/default/settings/sitepages/edit.php | 7 ++ .../views/default/sitepages/analytics.php | 13 +++ mod/sitepages/views/default/sitepages/css.php | 9 +++ .../views/default/sitepages/footer_menu.php | 11 +++ .../views/default/sitepages/forms/edit.php | 92 ++++++++++++++++++++++ .../views/default/sitepages/forms/editfront.php | 52 ++++++++++++ .../views/default/sitepages/forms/editmeta.php | 48 +++++++++++ mod/sitepages/views/default/sitepages/keywords.php | 14 ++++ mod/sitepages/views/default/sitepages/menu.php | 22 ++++++ mod/sitepages/views/default/sitepages/metatags.php | 17 ++++ 20 files changed, 725 insertions(+) create mode 100644 mod/sitepages/actions/add.php create mode 100644 mod/sitepages/actions/addfront.php create mode 100644 mod/sitepages/actions/addmeta.php create mode 100644 mod/sitepages/frontpage.php create mode 100644 mod/sitepages/index.php create mode 100644 mod/sitepages/languages/en.php create mode 100644 mod/sitepages/manifest.xml create mode 100644 mod/sitepages/read.php create mode 100644 mod/sitepages/sitepages_functions.php create mode 100644 mod/sitepages/start.php create mode 100644 mod/sitepages/views/default/settings/sitepages/edit.php create mode 100644 mod/sitepages/views/default/sitepages/analytics.php create mode 100644 mod/sitepages/views/default/sitepages/css.php create mode 100644 mod/sitepages/views/default/sitepages/footer_menu.php create mode 100644 mod/sitepages/views/default/sitepages/forms/edit.php create mode 100644 mod/sitepages/views/default/sitepages/forms/editfront.php create mode 100644 mod/sitepages/views/default/sitepages/forms/editmeta.php create mode 100644 mod/sitepages/views/default/sitepages/keywords.php create mode 100644 mod/sitepages/views/default/sitepages/menu.php create mode 100644 mod/sitepages/views/default/sitepages/metatags.php (limited to 'mod/sitepages') diff --git a/mod/sitepages/actions/add.php b/mod/sitepages/actions/add.php new file mode 100644 index 000000000..3b7f4eb2d --- /dev/null +++ b/mod/sitepages/actions/add.php @@ -0,0 +1,64 @@ +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; + } + // 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}"); +} diff --git a/mod/sitepages/actions/addfront.php b/mod/sitepages/actions/addfront.php new file mode 100644 index 000000000..5a86189db --- /dev/null +++ b/mod/sitepages/actions/addfront.php @@ -0,0 +1,51 @@ +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()) { + 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"); diff --git a/mod/sitepages/actions/addmeta.php b/mod/sitepages/actions/addmeta.php new file mode 100644 index 000000000..432152ef1 --- /dev/null +++ b/mod/sitepages/actions/addmeta.php @@ -0,0 +1,49 @@ +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"); +} + +// Success message +system_message(elgg_echo("sitepages:seocreated")); + +// Remove the cache +unset($_SESSION['description']); unset($_SESSION['metatags']); + + +// Forward back to the page +forward("pg/sitepages/index.php?type=seo"); diff --git a/mod/sitepages/frontpage.php b/mod/sitepages/frontpage.php new file mode 100644 index 000000000..4f5d02a90 --- /dev/null +++ b/mod/sitepages/frontpage.php @@ -0,0 +1,70 @@ + 'object', 'subtype' => 'frontpage', 'limit' => 1)); +if($page_contents){ + foreach($page_contents as $pc){ + $css = ""; + $frontContents = $pc->description; + } +} + +// Set title +$title = $CONFIG->sitename; + +?> + + + + + + + <?php echo $title; ?> + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mod/sitepages/index.php b/mod/sitepages/index.php new file mode 100644 index 000000000..efc7371b7 --- /dev/null +++ b/mod/sitepages/index.php @@ -0,0 +1,37 @@ + $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 new file mode 100644 index 000000000..2f4916ee5 --- /dev/null +++ b/mod/sitepages/languages/en.php @@ -0,0 +1,48 @@ + "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); + +?> \ No newline at end of file diff --git a/mod/sitepages/manifest.xml b/mod/sitepages/manifest.xml new file mode 100644 index 000000000..9714a47c5 --- /dev/null +++ b/mod/sitepages/manifest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/mod/sitepages/read.php b/mod/sitepages/read.php new file mode 100644 index 000000000..5621c486b --- /dev/null +++ b/mod/sitepages/read.php @@ -0,0 +1,31 @@ + '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 new file mode 100644 index 000000000..561aae97c --- /dev/null +++ b/mod/sitepages/sitepages_functions.php @@ -0,0 +1,8 @@ +wwwroot . 'pg/sitepages/'); + } +} + +function sitepages_url($expage) { + global $CONFIG; + return $CONFIG->url . "pg/sitepages/"; +} + +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"); + } + }else{ + include($CONFIG->pluginspath . "sitepages/index.php"); + } +} + +// 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 diff --git a/mod/sitepages/views/default/settings/sitepages/edit.php b/mod/sitepages/views/default/settings/sitepages/edit.php new file mode 100644 index 000000000..22f03abaf --- /dev/null +++ b/mod/sitepages/views/default/settings/sitepages/edit.php @@ -0,0 +1,7 @@ +

+ + +

\ No newline at end of file diff --git a/mod/sitepages/views/default/sitepages/analytics.php b/mod/sitepages/views/default/sitepages/analytics.php new file mode 100644 index 000000000..0a8e94b67 --- /dev/null +++ b/mod/sitepages/views/default/sitepages/analytics.php @@ -0,0 +1,13 @@ + '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 new file mode 100644 index 000000000..5d7eabcd4 --- /dev/null +++ b/mod/sitepages/views/default/sitepages/css.php @@ -0,0 +1,9 @@ + + +/* 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/footer_menu.php b/mod/sitepages/views/default/sitepages/footer_menu.php new file mode 100644 index 000000000..5137e0f21 --- /dev/null +++ b/mod/sitepages/views/default/sitepages/footer_menu.php @@ -0,0 +1,11 @@ + + + \ 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 new file mode 100644 index 000000000..94ec786b1 --- /dev/null +++ b/mod/sitepages/views/default/sitepages/forms/edit.php @@ -0,0 +1,92 @@ + + * @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') . "
"; + + //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 "
" . elgg_echo('sitepages:preview') . "
"; + + //construct the form + $form_body = <<$external_page_title +

$input_area

+

+ $tag_label + $tag_input +

+ $hidden_value + $hidden_guid +
+ $submit_input + +EOT; +?> + "{$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 new file mode 100644 index 000000000..faea356f2 --- /dev/null +++ b/mod/sitepages/views/default/sitepages/forms/editfront.php @@ -0,0 +1,52 @@ + '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 = ""; +} + +// 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)); +$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"); + +//preview link +$preview = ""; + +//construct the form +$form_body = <<$css +

$input_css


+

$pageshell

+

$input_pageshell

+ + $hidden_guid +
+ $submit_input + $preview + +EOT; +?> + "{$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 new file mode 100644 index 000000000..7eb731f76 --- /dev/null +++ b/mod/sitepages/views/default/sitepages/forms/editmeta.php @@ -0,0 +1,48 @@ + '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 = ""; +} + +// 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)); +$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 = <<$description +

$input_description


+

$metatags

+

$input_keywords

+ + $hidden_guid +
+ $submit_input + +EOT; +?> + "{$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 new file mode 100644 index 000000000..2b4666256 --- /dev/null +++ b/mod/sitepages/views/default/sitepages/keywords.php @@ -0,0 +1,14 @@ + +
+

Available keywords

+
    +
  • {{element:loginbox}}
  • +
  • {{element:stats}}
  • +
  • {{object:blog}}
  • +
  • {{group:4}}
  • +
+
\ No newline at end of file diff --git a/mod/sitepages/views/default/sitepages/menu.php b/mod/sitepages/views/default/sitepages/menu.php new file mode 100644 index 000000000..5f074f489 --- /dev/null +++ b/mod/sitepages/views/default/sitepages/menu.php @@ -0,0 +1,22 @@ + + +
+
    +
  • >
  • +
  • >
  • +
  • >
  • +
  • >
  • +
  • >
  • +
+
\ No newline at end of file diff --git a/mod/sitepages/views/default/sitepages/metatags.php b/mod/sitepages/views/default/sitepages/metatags.php new file mode 100644 index 000000000..73a7cd17f --- /dev/null +++ b/mod/sitepages/views/default/sitepages/metatags.php @@ -0,0 +1,17 @@ + 'object', 'subtype' => 'seo', 'limit' => 1)); +if($meta_details){ + foreach($meta_details as $md){ + $metatags = $md->title; + $description = $md->description; + } +} + +?> + + + \ No newline at end of file -- cgit v1.2.3