From b027f962af16d074398d1351a90d863aaf5469f3 Mon Sep 17 00:00:00 2001 From: nickw Date: Wed, 26 May 2010 18:25:08 +0000 Subject: Updating Sitepages plugin settings for new administration layout. git-svn-id: http://code.elgg.org/elgg/trunk@6242 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/sitepages/actions/add.php | 53 -------------- mod/sitepages/actions/addfront.php | 48 ------------- mod/sitepages/actions/addfrontsimple.php | 45 ------------ mod/sitepages/actions/addmeta.php | 36 ---------- mod/sitepages/actions/edit_settings.php | 50 +++++++++++++ mod/sitepages/sitepages_functions.php | 15 ++-- mod/sitepages/start.php | 22 +----- .../views/default/settings/sitepages/edit.php | 14 ++-- .../views/default/sitepages/forms/edit.php | 23 +++--- .../views/default/sitepages/forms/editfront.php | 82 ---------------------- .../default/sitepages/forms/editfrontsimple.php | 74 +++++++++++++------ .../views/default/sitepages/forms/editmeta.php | 37 +++++----- mod/sitepages/views/default/sitepages/menu.php | 4 +- 13 files changed, 151 insertions(+), 352 deletions(-) delete mode 100644 mod/sitepages/actions/add.php delete mode 100644 mod/sitepages/actions/addfront.php delete mode 100644 mod/sitepages/actions/addfrontsimple.php delete mode 100644 mod/sitepages/actions/addmeta.php create mode 100644 mod/sitepages/actions/edit_settings.php delete mode 100644 mod/sitepages/views/default/sitepages/forms/editfront.php (limited to 'mod') diff --git a/mod/sitepages/actions/add.php b/mod/sitepages/actions/add.php deleted file mode 100644 index bc38d8067..000000000 --- a/mod/sitepages/actions/add.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Curverider Ltd 2008-2010 - * @link http://elgg.com/ - * - */ - -// Make sure we're logged as admin -admin_gatekeeper(); - -// Get input data -$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 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 { - $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); - } - - // @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 deleted file mode 100644 index 00b04dbcb..000000000 --- a/mod/sitepages/actions/addfront.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Curverider Ltd 2008-2010 - * @link http://elgg.com/ - * - */ - -admin_gatekeeper(); - -$logged_in_content = get_input('logged_in_content', '', FALSE); -$logged_out_content = get_input('logged_out_content', '', FALSE); - -// do some error checking to make sure you can't lock yourself out of your front page. -if (FALSE === strpos($logged_out_content, '[loginbox]')) { - register_error(elgg_echo('sitepages:error:no_login')); - forward($_SERVER['HTTP_REFERER']); -} - -$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'); -} - -$sitepage->css = $css; -$sitepage->logged_in_content = $logged_in_content; -$sitepage->logged_out_content = $logged_out_content; - -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($_SERVER['HTTP_REFERER']); diff --git a/mod/sitepages/actions/addfrontsimple.php b/mod/sitepages/actions/addfrontsimple.php deleted file mode 100644 index ee26723e8..000000000 --- a/mod/sitepages/actions/addfrontsimple.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Curverider Ltd 2008-2010 - * @link http://elgg.com/ - * - */ - -admin_gatekeeper(); - -$logged_in_content = get_input('logged_in_content', '', FALSE); -$logged_out_content = get_input('logged_out_content', '', FALSE); - -$welcometitle = get_input('welcometitle', '', FALSE); -$welcomemessage = get_input('welcomemessage', '', FALSE); -$sidebartitle = get_input('sidebartitle', '', FALSE); -$sidebarmessage = get_input('sidebarmessage', '', 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 (!$sitepagesimple = sitepages_get_sitepage_object('frontsimple')) { - $sitepagesimple = sitepages_create_sitepage_object('frontsimple'); -} - -$sitepagesimple->welcometitle = $welcometitle; -$sitepagesimple->welcomemessage = $welcomemessage; -$sitepagesimple->sidebartitle = $sidebartitle; -$sitepagesimple->sidebarmessage = $sidebarmessage; - -if ($sitepagesimple->save()) { - system_message(elgg_echo("sitepagessimple:posted")); -} else { - register_error(elgg_echo("sitepages:error")); -} - -forward($_SERVER['HTTP_REFERER']); diff --git a/mod/sitepages/actions/addmeta.php b/mod/sitepages/actions/addmeta.php deleted file mode 100644 index ec72d6339..000000000 --- a/mod/sitepages/actions/addmeta.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Curverider Ltd 2008-2010 - * @link http://elgg.com/ - * - */ - -admin_gatekeeper(); - -$description = get_input('description', '', FALSE); -$metatags = get_input('metatags', '', FALSE); - -// Cache to the session -$_SESSION['description'] = $description; -$_SESSION['metatags'] = $metatags; - -if (!$sitepage = sitepages_get_sitepage_object('seo')) { - $sitepage = sitepages_create_sitepage_object('seo'); -} - -$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")); -} - -forward($_SERVER['HTTP_REFERER']); \ No newline at end of file diff --git a/mod/sitepages/actions/edit_settings.php b/mod/sitepages/actions/edit_settings.php new file mode 100644 index 000000000..d79c38240 --- /dev/null +++ b/mod/sitepages/actions/edit_settings.php @@ -0,0 +1,50 @@ +title = $page_type; + $sitepage->description = $content; + $sitepage->tags = string_to_tag_array(get_input('sitepages_tags')); + + break; + case 'seo': + $sitepage->title = get_input('metatags', '', FALSE);; + $sitepage->description = get_input('description', '', FALSE); + + break; + case 'frontsimple': + default: + $params = get_input('params', array()); + set_plugin_setting('ownfrontpage', $params['ownfrontpage'], 'sitepages'); + + $sitepage->welcometitle = get_input('welcometitle', '', FALSE); + $sitepage->welcomemessage = get_input('welcomemessage', '', FALSE); + $sitepage->sidebartitle = get_input('sidebartitle', '', FALSE); + $sitepage->sidebarmessage = get_input('sidebarmessage', '', FALSE); + + break; +} + +if ($sitepage->save()) { + system_message(elgg_echo('sitepages:posted')); +} else { + register_error(elgg_echo('sitepages:error')); +} + +forward($_SERVER['HTTP_REFERER']); diff --git a/mod/sitepages/sitepages_functions.php b/mod/sitepages/sitepages_functions.php index 5e9a4adc2..72418e81b 100644 --- a/mod/sitepages/sitepages_functions.php +++ b/mod/sitepages/sitepages_functions.php @@ -59,10 +59,7 @@ function sitepages_create_sitepage_object($page_type) { * @param str $section * @return str html */ -function sitepages_get_edit_section_content($page_type) { - set_context('admin'); - - $title = elgg_view_title(elgg_echo('sitepages')); +function sitepages_get_edit_section_content($page_type, $entity=NULL) { $menu = elgg_view('sitepages/menu', array('page_type' => $page_type)); switch ($page_type) { @@ -80,11 +77,11 @@ function sitepages_get_edit_section_content($page_type) { } - $form .= elgg_view($view, array('page_type' => $page_type)); - $body = $title . $menu . $form; - - $content = elgg_view_layout('administration', $body); - return $content; + $form .= elgg_view($view, array( + 'page_type' => $page_type, + 'entity' => $entity, + )); + return $menu . $form; } /** diff --git a/mod/sitepages/start.php b/mod/sitepages/start.php index 180739cca..943688020 100644 --- a/mod/sitepages/start.php +++ b/mod/sitepages/start.php @@ -16,7 +16,7 @@ * DRY up actions and views * Use $entity->view to redirect to url of page. * The tool settings view is probably not needed as it can be added to the front page edit tab. - * You can say pg/sitepages/edit|read/any_page_i_want and it will let you. + * You can say pg/sitepages/read/any_page_i_want and it will let you. */ /** @@ -50,18 +50,7 @@ function sitepages_init() { // hook into the walled garden pages register_plugin_hook('public_pages', 'walled_garden', 'sitepages_public_pages'); - 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/addfrontsimple", FALSE, $CONFIG->pluginspath . "sitepages/actions/addfrontsimple.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"); - - elgg_add_submenu_item(array( - 'text' => elgg_echo('sitepages'), - 'href' => "{$CONFIG->wwwroot}pg/sitepages/edit/front", - 'parent_id' => 'site', - ), 'admin', 'default'); + register_action('settings/sitepages/save', FALSE, "{$CONFIG->pluginspath}sitepages/actions/edit_settings.php"); } /** @@ -136,13 +125,6 @@ function sitepages_page_handler($page) { $page_type = isset($page[1]) ? $page[1] : FALSE; switch ($action) { - case 'edit': - admin_gatekeeper(); - $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); diff --git a/mod/sitepages/views/default/settings/sitepages/edit.php b/mod/sitepages/views/default/settings/sitepages/edit.php index 8a8a2d271..86cf6760c 100644 --- a/mod/sitepages/views/default/settings/sitepages/edit.php +++ b/mod/sitepages/views/default/settings/sitepages/edit.php @@ -8,12 +8,10 @@ * @copyright Curverider Ltd 2008-2010 * @link http://elgg.org/ */ -?> -

- - -

\ No newline at end of file +$page_type = 'front'; +if (isset($vars['page'][2])) { + $page_type = $vars['page'][2]; +} + +echo sitepages_get_edit_section_content($page_type, $vars['entity']); diff --git a/mod/sitepages/views/default/sitepages/forms/edit.php b/mod/sitepages/views/default/sitepages/forms/edit.php index 72fb42ccf..940289dcf 100644 --- a/mod/sitepages/views/default/sitepages/forms/edit.php +++ b/mod/sitepages/views/default/sitepages/forms/edit.php @@ -11,7 +11,6 @@ */ $page_type = $vars['page_type']; -$action = 'sitepages/add'; if ($sitepages_object = sitepages_get_sitepage_object($page_type)) { $tags = $sitepages_object->tags; @@ -24,11 +23,19 @@ if ($sitepages_object = sitepages_get_sitepage_object($page_type)) { } // 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)); +$input_area = elgg_view('input/longtext', array( + 'internalname' => 'sitepages_content', + 'value' => $description +)); +$tag_input = elgg_view('input/tags', array( + 'internalname' => 'sitepages_tags', + 'value' => $tags +)); + +$hidden_value = elgg_view('input/hidden', array( + 'internalname' => 'page_type', + 'value' => $page_type +)); $tag_label = elgg_echo('tags'); $external_page_title = elgg_echo("sitepages:$page_type"); @@ -42,9 +49,7 @@ $input_area

$tag_input

$hidden_value -$hidden_guid -$submit_input ___EOT; -echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body)); \ No newline at end of file +echo $form_body; diff --git a/mod/sitepages/views/default/sitepages/forms/editfront.php b/mod/sitepages/views/default/sitepages/forms/editfront.php deleted file mode 100644 index 818bdfd8b..000000000 --- a/mod/sitepages/views/default/sitepages/forms/editfront.php +++ /dev/null @@ -1,82 +0,0 @@ -css; - $logged_in_content = $sitepages_object->logged_in_content; - $logged_out_content = $sitepages_object->logged_out_content; -} else { - $css = <<<___EOT -#elgg_sidebar .entity_listing_info {width:173px;} -___EOT; - $logged_in_content = <<<___EOT - -___EOT; - $logged_out_content = <<<___EOT - -___EOT; -} - -// set the required form variables -$input_css = elgg_view('input/plaintext', array('internalname' => 'css', 'value' => $css, 'class' => 'input_textarea monospace')); -$input_logged_in_content = elgg_view('input/plaintext', array('internalname' => 'logged_in_content', 'value' => $logged_in_content, 'class' => 'input_textarea monospace')); -$input_logged_out_content = elgg_view('input/plaintext', array('internalname' => 'logged_out_content', 'value' => $logged_out_content, 'class' => 'input_textarea monospace')); -$submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('save'))); - -$logged_in_content_title = elgg_echo("sitepages:logged_in_front_content"); -$logged_out_content_title = elgg_echo("sitepages:logged_out_front_content"); -$css_title = elgg_echo("sitepages:css"); - -//preview link -// @todo this doesn't do anything. -//$preview = "
" . elgg_echo('sitepages:preview') . "
"; - -//construct the form -$form_body = <<<___EOT - -

- -

- -

- - $hidden_guid - $submit_input - $preview - -___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/editfrontsimple.php b/mod/sitepages/views/default/sitepages/forms/editfrontsimple.php index 89f4e5673..b1038d982 100644 --- a/mod/sitepages/views/default/sitepages/forms/editfrontsimple.php +++ b/mod/sitepages/views/default/sitepages/forms/editfrontsimple.php @@ -9,38 +9,69 @@ * @link http://elgg.org/ */ -$action = 'sitepages/addfrontsimple'; - if($sitepages_object = sitepages_get_sitepage_object('frontsimple')){ $welcometitle = $sitepages_object->welcometitle; $welcomemessage = $sitepages_object->welcomemessage; $sidebartitle = $sitepages_object->sidebartitle; $sidebarmessage = $sitepages_object->sidebarmessage; }else{ - $welcometitle = ""; - $welcomemessage = ""; - $sidebartitle = ""; - $sidebarmessage = ""; + $welcometitle = ''; + $welcomemessage = ''; + $sidebartitle = ''; + $sidebarmessage = ''; } // set the required form variables -$welcometitle_form = elgg_view('input/text', array('internalname' => 'welcometitle', 'value' => $welcometitle)); -$welcomemessage_form = elgg_view('input/longtext', array('internalname' => 'welcomemessage', 'value' => $welcomemessage, 'class' => 'input_textarea monospace')); -$sidebartitle_form = elgg_view('input/text', array('internalname' => 'sidebartitle', 'value' => $sidebartitle)); -$sidebarmessage_form = elgg_view('input/longtext', array('internalname' => 'sidebarmessage', 'value' => $sidebarmessage, 'class' => 'input_textarea monospace'));; -$submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('save'))); - -$welcomemessage_title = elgg_echo("sitepages:welcomemessage"); -$sidebarmessage_title = elgg_echo("sitepages:sidebarmessage"); -$welcometitle_title = elgg_echo("sitepages:welcometitle"); -$sidebartitle_title = elgg_echo("sitepages:sidebartitle"); -$welcome_intro = elgg_echo("sitepages:welcomeintro"); -$sidebar_intro = elgg_echo("sitepages:sidebarintro"); +$welcometitle_form = elgg_view('input/text', array( + 'internalname' => 'welcometitle', + 'value' => $welcometitle +)); +$welcomemessage_form = elgg_view('input/longtext', array( + 'internalname' => 'welcomemessage', + 'value' => $welcomemessage, + 'class' => 'input_textarea monospace' +)); +$sidebartitle_form = elgg_view('input/text', array( + 'internalname' => 'sidebartitle', + 'value' => $sidebartitle +)); +$sidebarmessage_form = elgg_view('input/longtext', array( + 'internalname' => 'sidebarmessage', + 'value' => $sidebarmessage, + 'class' => 'input_textarea monospace' +));; + +$page_type = elgg_view('input/hidden', array( + 'internalname' => 'page_type', + 'value' => 'frontsimple', +)); + +$welcomemessage_title = elgg_echo('sitepages:welcomemessage'); +$sidebarmessage_title = elgg_echo('sitepages:sidebarmessage'); +$welcometitle_title = elgg_echo('sitepages:welcometitle'); +$sidebartitle_title = elgg_echo('sitepages:sidebartitle'); +$welcome_intro = elgg_echo('sitepages:welcomeintro'); +$sidebar_intro = elgg_echo('sitepages:sidebarintro'); + +$ownfrontpage_message = elgg_echo('sitepages:ownfront'); +$ownfrontpage = elgg_view('input/pulldown', array( + 'internalname' => 'params[ownfrontpage]', + 'value' => isset($vars['entity']->ownfrontpage) ? $vars['entity']->ownfrontpage : 'no', + 'options_values' => array( + 'yes' => elgg_echo('option:yes'), + 'no' => elgg_echo('option:no'), + ), +)); //construct the form $form_body = <<<___EOT +

+ $ownfrontpage_message + $ownfrontpage +

+

$welcome_intro

@@ -52,10 +83,9 @@ $form_body = <<<___EOT $sidebartitle_form

- - $hidden_guid - $submit_input + $page_type + ___EOT; -echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body)); \ No newline at end of file +echo $form_body; diff --git a/mod/sitepages/views/default/sitepages/forms/editmeta.php b/mod/sitepages/views/default/sitepages/forms/editmeta.php index b9a454bbf..403c01de1 100644 --- a/mod/sitepages/views/default/sitepages/forms/editmeta.php +++ b/mod/sitepages/views/default/sitepages/forms/editmeta.php @@ -9,8 +9,6 @@ * @link http://elgg.org/ */ -$action = 'sitepages/addmeta'; - if ($sitepages_object = sitepages_get_sitepage_object('seo')) { $meta_tags = $sitepages_object->title; $meta_description = $sitepages_object->description; @@ -19,25 +17,28 @@ if ($sitepages_object = sitepages_get_sitepage_object('seo')) { $meta_description = ''; } -$input_keywords = elgg_view('input/text', 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'))); - -$description = elgg_echo("sitepages:metadescription"); -$metatags = elgg_echo("sitepages:metatags"); - -$form_body = <<<___EOT - -

+$description = elgg_echo('sitepages:metadescription'); +$input_description = elgg_view('input/plaintext', array( + 'internalname' => 'description', + 'value' => $meta_description +)); -

+$metatags = elgg_echo('sitepages:metatags'); +$input_keywords = elgg_view('input/text', array( + 'internalname' => 'metatags', + 'value' => $meta_tags +)); -$hidden_guid -$submit_input +$page_type = elgg_view('input/hidden', array( + 'internalname' => 'page_type', + 'value' => 'seo', +)); +$form_body = <<<___EOT +

+

+$page_type ___EOT; //display the form -echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body)); \ No newline at end of file +echo $form_body; \ 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 9c4e39821..4e2ab0c52 100644 --- a/mod/sitepages/views/default/sitepages/menu.php +++ b/mod/sitepages/views/default/sitepages/menu.php @@ -10,7 +10,7 @@ */ $page_type = $vars['page_type']; -$url = $vars['url'] . 'pg/sitepages/edit/'; +$url = "{$vars['url']}pg/admin/plugin_settings/sitepages/"; ?>
@@ -21,7 +21,7 @@ $url = $vars['url'] . 'pg/sitepages/edit/'; foreach ($pages as $page) { $selected = ($page_type == $page) ? 'class = "selected"' : ''; - echo "
  • " . elgg_echo("sitepages:$page") . "
  • "; + echo "
  • " . elgg_echo("sitepages:$page") . "
  • "; } ?> -- cgit v1.2.3