Commit fef8c68d authored by Robert Lyon's avatar Robert Lyon

Bug 1738303: Remove the obsolete $new variable being passed about when

creating a new page.

It is mostly so we can show 'No title' for page name and to have a
'back' button instead of 'edit page' when viewing ones own page.

But we don't need it as a page has a title when we click 'add page' as
we make the new view entry in database straight away and the title
will be something like 'Untitled v.2'.

And if we change the title on page settings form then block edit screen
will now show new correct title instead of 'No title'

behatnotneeded

Change-Id: I4630d53fbee734f1f4e903c05aa92b8348f3f41f
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 19a68352
{include file="header.tpl"}
{include file="view/editviewtabs.tpl" selected='share' new=$new issiteview=$issiteview}
{include file="view/editviewtabs.tpl" selected='share' issiteview=$issiteview}
<div id="accessurl-container">
......
{include file="header.tpl"}
{include file="view/editviewtabs.tpl" selected='content' new=$new issiteview=$issiteview}
{include file="view/editviewtabs.tpl" selected='content' issiteview=$issiteview}
<div id="blocksinstruction" class="lead view-description">
{str tag='blocksintructionnoajax' section='view'}
</div>
......@@ -14,11 +14,10 @@
<input type="hidden" name="change" value="1">
<input type="hidden" id="category" name="c" value="{$category}">
<input type="hidden" name="sesskey" value="{$SESSKEY}">
{if $new}<input type="hidden" name="new" value="1">{/if}
<div id="editcontent-sidebar-wrapper" class="col-collapse">
<div id="editcontent-sidebar" data-spy="affix" data-offset-top="420" data-offset-top="100" class="toolbar-affix">
{include file="view/contenteditor.tpl" selected='content' new=$new}
{include file="view/contenteditor.tpl" selected='content'}
{if $viewthemes}
<div id="select-theme" class="select dropdown theme-dropdown">
<label id="select-theme-header">{str tag=theme section=view}</label>
......@@ -81,11 +80,10 @@
<input type="hidden" name="change" value="1">
<input type="hidden" id="category" name="c" value="{$category}">
<input type="hidden" name="sesskey" value="{$SESSKEY}">
{if $new}<input type="hidden" name="new" value="1">{/if}
<div id="editcontent-sidebar-wrapper" class="col-collapse">
<div id="editcontent-sidebar">
{include file="view/contenteditor.tpl" selected='content' new=$new}
{include file="view/contenteditor.tpl" selected='content'}
{if $viewthemes}
<div id="select-theme" class="select dropdown theme-dropdown">
<label id="select-theme-header">{str tag=theme section=view}</label>
......
{include file="header.tpl"}
{include file="view/editviewtabs.tpl" selected='title' new=$new issiteview=$issiteview}
{include file="view/editviewtabs.tpl" selected='title' issiteview=$issiteview}
{if $ADMIN || $INSTITUTIONALADMIN}
<div class="row">
......
{include file="header.tpl"}
{include file="view/editviewtabs.tpl" selected='editlayout' new=$new issiteview=$issiteview}
{include file="view/editviewtabs.tpl" selected='editlayout' issiteview=$issiteview}
<!-- Layout -->
{$form|safe}
......
<div id="toolbar-buttons" class="btn-group btn-toolbar btn-group-top">
<a class="btn btn-default editviews editlayout {if $selected == 'layout' or $selected == 'editlayout'}active{/if}"
href="{$WWWROOT}view/editlayout.php?id={$viewid}{if $new}&new=1{/if}"
href="{$WWWROOT}view/editlayout.php?id={$viewid}"
title="{if $edittitle}{str tag=settings section=view}{else}{str tag=editlayout section=view}{/if}">
<span class="icon icon-lg icon-cogs"></span>
<span class="btn-title">{if $edittitle}{str tag=settings section=view}{else}{str tag=editlayout section=view}{/if}</span>
</a>
<a class="btn btn-default editviews editcontent {if $selected == 'content'}active{/if}" href="{$WWWROOT}view/blocks.php?id={$viewid}{if $new}&new=1{/if}" title="{str tag=editcontent1 section=view}">
<a class="btn btn-default editviews editcontent {if $selected == 'content'}active{/if}" href="{$WWWROOT}view/blocks.php?id={$viewid}" title="{str tag=editcontent1 section=view}">
<span class="icon icon-lg icon-pencil" aria-hidden="true" role="presentation"></span>
<span class="btn-title">{str tag=editcontent1 section=view}</span>
</a>
{if $edittitle || $viewtype == 'share'}
<a class="btn btn-default editviews editshare {if $selected == 'share'}active{/if}" href="{$WWWROOT}view/accessurl.php?id={$viewid}{if $collectionid}&collection={$collectionid}{/if}{if $new}&new=1{/if}" title="{str tag=shareview1 section=view}">
<a class="btn btn-default editviews editshare {if $selected == 'share'}active{/if}" href="{$WWWROOT}view/accessurl.php?id={$viewid}{if $collectionid}&collection={$collectionid}{/if}" title="{str tag=shareview1 section=view}">
<span class="icon icon-lg icon-unlock-alt" aria-hidden="true" role="presentation"></span>
<span class="btn-title">{str tag=shareview1 section=view}</span>
</a>
......
{include file="header.tpl"}
{include file="view/editviewtabs.tpl" selected='layout' new=$new issiteview=$issiteview}
{include file="view/editviewtabs.tpl" selected='layout' issiteview=$issiteview}
{$form|safe}
......
......@@ -22,16 +22,10 @@
<div class="btn-group btn-group-top">
{if $editurl}{strip}
{if $new}
<a class="btn btn-default" href="{$editurl}">
{str tag=back}
</a>
{else}
<a title="{str tag=editthisview section=view}" href="{$editurl}" class="btn btn-default">
<span class="icon icon-pencil icon-lg left" role="presentation" aria-hidden="true"></span>
{str tag=editthisview section=view}
</a>
{/if}
{/strip}{/if}
{if $copyurl}{strip}
......
......@@ -38,13 +38,7 @@ else {
$view = new View($viewid);
$new = param_boolean('new', 0);
if ($new) {
define('VIEWTITLE', get_string('notitle', 'view'));
}
else {
define('VIEWTITLE', $view->get('title'));
}
define('VIEWTITLE', $view->get('title'));
define('SUBSECTIONHEADING', VIEWTITLE);
if (empty($collection)) {
......
......@@ -19,7 +19,6 @@ require_once(get_config('libroot') . 'view.php');
require_once(get_config('libroot') . 'group.php');
$id = param_integer('id', 0); // if 0, we're editing our profile.
$new = param_boolean('new', false);
$profile = param_boolean('profile');
$dashboard = param_boolean('dashboard');
......@@ -69,7 +68,7 @@ if ($blockid = param_integer('blockconfig', 0)) {
if ($bi->get('view') != $view->get('id')) {
throw new AccessDeniedException(get_string('blocknotinview', 'view', $bi->get('id')));
}
$bi->build_configure_form($new);
$bi->build_configure_form();
}
}
......@@ -93,9 +92,6 @@ else if ($view->get('type') == 'grouphomepage') {
}
define('TITLE', $title);
}
else if ($new) {
define('TITLE', get_string('notitle', 'view'));
}
else {
define('TITLE', $view->get('title'));
$editabletitle = true;
......@@ -110,7 +106,7 @@ if (empty($category)) {
$category = $view->get_default_category();
}
$view->process_changes($category, $new);
$view->process_changes($category, false);
$extraconfig = array(
'sidebars' => false,
......@@ -205,7 +201,7 @@ $smarty = smarty($javascript, $stylesheets, array(
$smarty->assign('addform', $addform);
// The list of categories for the tabbed interface
$smarty->assign('category_list', $view->build_category_list($category, $new));
$smarty->assign('category_list', $view->build_category_list($category, false));
// The list of shortcut blocks
$smarty->assign('shortcut_list', $view->build_blocktype_list('shortcut'));
......@@ -236,14 +232,10 @@ foreach (array_keys($_POST + $_GET) as $key) {
$viewid = $view->get('id');
$displaylink = $view->get_url();
if ($new) {
$displaylink .= (strpos($displaylink, '?') === false ? '?' : '&') . 'new=1';
}
$smarty->assign('edittitle', $view->can_edit_title());
$smarty->assign('displaylink', $displaylink);
$smarty->assign('formurl', get_config('wwwroot') . 'view/blocks.php');
$smarty->assign('category', $category);
$smarty->assign('new', $new);
$smarty->assign('profile', $profile);
$smarty->assign('dashboard', $dashboard);
if (get_config('blockeditormaxwidth')) {
......
......@@ -56,12 +56,7 @@ if ($new && $id === false) {
$view = new View($id);
if ($new) {
define('TITLE', get_string('notitle', 'view'));
}
else {
define('TITLE', $view->get('title'));
}
define('TITLE', $view->get('title'));
define('SUBSECTIONHEADING', TITLE);
if (!$USER->can_edit_view($view)) {
......@@ -119,14 +114,13 @@ $smarty->assign('viewtype', $view->get('type'));
$smarty->assign('viewtitle', $view->get('title'));
$smarty->assign('edittitle', $view->can_edit_title());
$smarty->assign('displaylink', $view->get_url());
$smarty->assign('new', $new);
$smarty->assign('issiteview', $view->get('institution') == 'mahara');
$smarty->assign('issitetemplate', ($view->get('template') == View::SITE_TEMPLATE ? true : false));
$smarty->assign('PAGEHEADING', $state);
$smarty->display('view/editlayout.tpl');
function create_settings_pieform(){
global $view, $new, $pieformname, $caneditonlylayout;
global $view, $pieformname, $caneditonlylayout;
$inlinejavascript = '';
$issiteview = $view->get('institution') == 'mahara';
$issitetemplate = ($view->get('template') == View::SITE_TEMPLATE ? true : false);
......@@ -197,10 +191,6 @@ function create_settings_pieform(){
'type' => 'hidden',
'value' => $view->get('id'),
),
'new' => array(
'type' => 'hidden',
'value' => $new,
),
);
$hiddenelements = array_merge($hiddenelements, $hiddenlayoutelements);
......@@ -224,7 +214,7 @@ function create_settings_pieform(){
}
function get_basic_elements() {
global $view, $new, $urlallowed, $group, $institution, $USER;
global $view, $urlallowed, $group, $institution, $USER;
$formatstring = '%s (%s)';
$ownerformatoptions = array(
......@@ -254,9 +244,9 @@ function get_basic_elements() {
'title' => get_string('viewurl', 'view'),
'prehtml' => '<span class="description">' . (isset($cleanurlbase) ? $cleanurlbase : '') . '</span> ',
'description' => get_string('viewurldescription', 'view') . ' ' . get_string('cleanurlallowedcharacters'),
'defaultvalue' => $new ? null : $view->get('urlid'),
'defaultvalue' => $view->get('urlid'),
'rules' => array('maxlength' => 100, 'regex' => get_config('cleanurlvalidate')),
'ignore' => !$urlallowed || $new,
'ignore' => !$urlallowed,
),
'description' => array(
'type' => 'wysiwyg',
......@@ -437,7 +427,7 @@ JAVASCRIPT;
}
function get_skin_elements() {
global $view, $USER, $new, $pieformname;
global $view, $USER, $pieformname;
$issiteview = $view->get('institution') == 'mahara';
if (!can_use_skins(null, false, $issiteview)) {
......@@ -482,9 +472,6 @@ function get_skin_elements() {
throw new AccessDeniedException();
}
$displaylink = $view->get_url();
if ($new) {
$displaylink .= (strpos($displaylink, '?') === false ? '?' : '&') . 'new=1';
}
$snippet = smarty_core();
$snippet->assign('saved', $saved);
......@@ -499,7 +486,6 @@ function get_skin_elements() {
$snippet->assign('viewid', $view->get('id'));
$snippet->assign('viewtype', $view->get('type'));
$snippet->assign('edittitle', $view->can_edit_title());
$snippet->assign('new', $new);
$snippet->assign('issiteview', $issiteview);
$skinform = array(
'skins_html' => array(
......@@ -568,7 +554,7 @@ function settings_validate(Pieform $form, $values) {
}
function settings_submit(Pieform $form, $values) {
global $view, $SESSION, $new, $caneditonlylayout;
global $view, $SESSION, $caneditonlylayout;
$issiteview = $view->get('institution') == 'mahara';
$issitetemplate = ($view->get('template') == View::SITE_TEMPLATE ? true : false);
$canedittitle = !$caneditonlylayout;
......@@ -586,11 +572,11 @@ function settings_submit(Pieform $form, $values) {
$view->commit();
$SESSION->add_ok_msg(get_string('viewsavedsuccessfully', 'view'));
redirect('/view/blocks.php?id=' . $view->get('id') . ($new ? '&new=1' : ''));
redirect('/view/blocks.php?id=' . $view->get('id'));
}
function set_view_layout(Pieform $form, $values){
global $view, $SESSION, $new;
global $view, $SESSION;
$oldrows = $view->get('numrows');
$oldlayout = $view->get_layout();
......@@ -630,7 +616,7 @@ function set_view_layout(Pieform $form, $values){
if ($dbcolumns != $newcolumns) {
db_rollback();
$SESSION->add_error_msg(get_string('changecolumnlayoutfailed', 'view'));
redirect(get_config('wwwroot') . 'view/blocks.php?id=' . $view->get('id') . ($new ? '&new=1' : ''));
redirect(get_config('wwwroot') . 'view/blocks.php?id=' . $view->get('id'));
}
}
// add or remove rows and move content accordingly if required
......@@ -648,7 +634,7 @@ function set_view_layout(Pieform $form, $values){
if ($view->get('numrows') != $newrows) {
db_rollback();
$SESSION->add_error_msg(get_string('changerowlayoutfailed', 'view'));
redirect(get_config('wwwroot') . 'view/editlayout.php?id=' . $view->get('id') . ($new ? '&new=1' : ''));
redirect(get_config('wwwroot') . 'view/editlayout.php?id=' . $view->get('id'));
}
db_commit();
......@@ -657,7 +643,7 @@ function set_view_layout(Pieform $form, $values){
}
function set_view_title_and_description(Pieform $form, $values){
global $view, $new, $urlallowed;
global $view, $urlallowed, $new;
$view->set('title', $values['title']);
if (trim($values['description']) !== '') {
......@@ -680,13 +666,14 @@ function set_view_title_and_description(Pieform $form, $values){
if (isset($values['anonymise'])) {
$view->set('anonymise', (int)$values['anonymise']);
}
if (isset($values['urlid'])) {
$view->set('urlid', strlen($values['urlid']) == 0 ? null : $values['urlid']);
}
else if ($new && $urlallowed) {
// Change the 'untitled' urlid on first save
if ($new && $urlallowed) {
// Generate one automatically based on the title
$desired = generate_urlid($values['title'], get_config('cleanurlviewdefault'), 3, 100);
$ownerinfo = (object) array('owner' => $view->get('owner'), 'group' => $view->get('group'));
$view->set('urlid', View::new_urlid($desired, $ownerinfo));
}
else if (isset($values['urlid'])) {
$view->set('urlid', strlen($values['urlid']) == 0 ? null : $values['urlid']);
}
}
......@@ -77,7 +77,6 @@ else {
$viewid = param_integer('id');
}
$new = param_boolean('new');
$showmore = param_boolean('showmore');
if (!$showmore) {
$showmore = 0;
......@@ -357,7 +356,6 @@ if ($collection) {
$smarty->assign('canremove', $can_edit);
$smarty->assign('INLINEJAVASCRIPT', $javascript . $inlinejs);
$smarty->assign('new', $new);
$smarty->assign('viewid', $viewid);
$smarty->assign('viewtype', $viewtype);
$smarty->assign('feedback', $feedback);
......@@ -382,7 +380,7 @@ $titletext = ($collection && $shownav) ? hsc($collection->get('name')) : $view->
$smarty->assign('lastupdatedstr', $view->lastchanged_message());
$smarty->assign('visitstring', $view->visit_message());
if ($can_edit) {
$smarty->assign('editurl', get_config('wwwroot') . 'view/blocks.php?id=' . $viewid . ($new ? '&new=1' : ''));
$smarty->assign('editurl', get_config('wwwroot') . 'view/blocks.php?id=' . $viewid);
}
if ($can_copy) {
$smarty->assign('copyurl', get_config('wwwroot') . 'view/copy.php?id=' . $viewid . (!empty($collection) ? '&collection=' . $collection->get('id') : ''));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment