Commit 4a3e02d9 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Make microheader optional on view pages


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent e07f17a8
......@@ -225,6 +225,7 @@ $string['numberofcolumns'] = 'Number of columns';
$string['by'] = 'by';
$string['viewtitleby'] = '%s by <a href="%s">%s</a>';
$string['in'] = 'in';
$string['noblocks'] = 'Sorry, no blocks in this category :(';
$string['Preview'] = 'Preview';
......
......@@ -2672,6 +2672,39 @@ class View {
);
}
public function display_title($long=true, $titlelink=true) {
if ($this->type == 'profile') {
$title = display_name($this->owner, null, true);
if ($long) {
return '<strong>' . get_string('usersprofile', 'mahara', hsc($title)) . '</strong>';
}
return $title;
}
$ownername = $this->formatted_owner();
$wwwroot = get_config('wwwroot');
if ($this->owner) {
$ownerlink = $wwwroot . 'user/view.php?id=' . $this->owner;
}
else if ($this->group) {
$ownerlink = $wwwroot . 'group/view.php?id=' . $this->group;
}
if ($titlelink) {
$title = '<a href="' . $wwwroot . 'view/view.php?id=' . $this->id . '">' . hsc($this->title) . '</a>';
}
else {
$title = '<strong>' . hsc($this->title) . '</strong>';
}
if ($ownerlink) {
return get_string('viewtitleby', 'view', $title, $ownerlink, $ownername);
}
return $title;
}
}
......
{include file="viewmicroheader.tpl"}
{if $microheaders}{include file="viewmicroheader.tpl"}{else}{include file="header.tpl"}{/if}
<div id="userview">
<div class="user-icon right">
{$institutions}
......@@ -43,4 +44,5 @@
</div>
</div>
</div>
{include file="microfooter.tpl"}
{if $microheaders}{include file="microfooter.tpl"}{else}{include file="footer.tpl"}{/if}
{include file="viewmicroheader.tpl"}
<h1>{$PAGEHEADING}</h1>
{if $microheaders}{include file="viewmicroheader.tpl"}{else}{include file="header.tpl"}{/if}
<h1>{$maintitle}</h1>
{if $columns}
{str tag="editblockspagedescription" section="view"}
......@@ -92,4 +93,5 @@
</div>
</div>
{/if}
{include file="microfooter.tpl"}
{if $microheaders}{include file="microfooter.tpl"}{else}{include file="footer.tpl"}{/if}
{include file="viewmicroheader.tpl"}
<h1>{$PAGEHEADING}</h1>
{if $microheaders}{include file="viewmicroheader.tpl"}{else}{include file="header.tpl"}{/if}
<h1>{$maintitle}</h1>
<div class="center">
<p>{str tag=changeviewtheme section=view}</p>
<form action="{$formurl}" method="post">
......@@ -15,4 +16,4 @@
</form>
</div>
{include file="microfooter.tpl"}
{if $microheaders}{include file="microfooter.tpl"}{else}{include file="footer.tpl"}{/if}
{include file="viewmicroheader.tpl"}
{if $microheaders}{include file="viewmicroheader.tpl"}{else}{include file="header.tpl"}{/if}
{if $viewtype != 'profile'}
<h1>{if !$new}<a href="{$WWWROOT}view/view.php?id={$viewid}">{/if}{$viewtitle|escape}{if !$new}</a>{/if}</h1>
{if $maintitle}<h1>{$maintitle}</h1>{/if}
{if !$microheaders && $mnethost}
<div class="rbuttons">
<a href="{$mnethost.url}">{str tag=backto arg1=$mnethost.name}</a>
</div>
{/if}
<p id="view-description">{$viewdescription}</p>
......@@ -31,4 +35,5 @@
{if $objectionform}<div>{$objectionform}</div>{/if}
</div>
</div>
{include file="microfooter.tpl"}
{if $microheaders}{include file="microfooter.tpl"}{else}{include file="footer.tpl"}{/if}
\ No newline at end of file
......@@ -30,8 +30,7 @@
{if $mnethost}<a href="{$mnethost.url}">{str tag=backto arg1=$mnethost.name}</a>&nbsp;{/if}
</div>
{/if}
<div class="center cb title">
<strong>{$viewtitle|escape}</strong>{if $ownername && $viewtype != 'profile'} {str tag=by section=view} <a href="{$WWWROOT}{$ownerlink}">{$ownername|escape}</a>{/if}</div>
<div class="center cb title">{$microheadertitle}</div>
</div>
</div>
<div id="main-wrapper">
......
......@@ -305,26 +305,34 @@ $smarty->assign('USERID', $userid);
$smarty->assign('userdisplayname', display_name($USER, null, true));
$smarty->assign('viewtitle', get_string('usersprofile', 'mahara', display_name($user, null, true)));
$smarty->assign('viewtype', 'profile');
if ($loggedinid && $loggedinid == $userid) {
$microheaderlinks = array(
array(
'name' => get_string('editmyprofilepage'),
'url' => get_config('wwwroot') . 'view/blocks.php?profile=1',
'type' => 'edit',
),
array(
'name' => get_string('editmyprofile', 'artefact.internal'),
'url' => get_config('wwwroot') . 'artefact/internal/index.php',
'type' => 'edit',
),
);
$smarty->assign('microheaderlinks', $microheaderlinks);
if (get_config('viewmicroheaders')) {
$smarty->assign('microheaders', true);
$smarty->assign('microheadertitle', $view->display_title(true, false));
if ($loggedinid && $loggedinid == $userid) {
$microheaderlinks = array(
array(
'name' => get_string('editmyprofilepage'),
'url' => get_config('wwwroot') . 'view/blocks.php?profile=1',
'type' => 'edit',
),
array(
'name' => get_string('editmyprofile', 'artefact.internal'),
'url' => get_config('wwwroot') . 'artefact/internal/index.php',
'type' => 'edit',
),
);
$smarty->assign('microheaderlinks', $microheaderlinks);
}
if (isset($_SERVER['HTTP_REFERER'])) {
$smarty->assign('backurl', $_SERVER['HTTP_REFERER']);
}
}
if (isset($_SERVER['HTTP_REFERER'])) {
$smarty->assign('backurl', $_SERVER['HTTP_REFERER']);
else {
$smarty->assign('PAGEHEADING', $view->display_title(false));
}
$smarty->assign('viewcontent', $view->build_columns());
$smarty->assign('PAGEHEADING', hsc(TITLE));
$smarty->display('user/view.tpl');
// Send an invitation to the user to join a group
......
......@@ -139,7 +139,7 @@ foreach (array_reverse($THEME->get_url('style/style.css', true, 'artefact/file')
// longer available to them.
if ($viewtheme && !isset($allowedthemes[$viewtheme])) {
$smarty = smarty(array(), $stylesheets, false, $extraconfig);
$smarty->assign('PAGEHEADING', hsc(TITLE));
$smarty->assign('maintitle', hsc(TITLE));
$smarty->assign('formurl', get_config('wwwroot') . 'view/blocks.php');
$smarty->assign('view', $view->get('id'));
$smarty->assign('viewtitle', $view->get('title'));
......@@ -178,7 +178,7 @@ foreach (array_keys($_POST + $_GET) as $key) {
}
}
$smarty->assign('PAGEHEADING', hsc(TITLE));
$smarty->assign('maintitle', hsc(TITLE));
$smarty->assign('formurl', get_config('wwwroot') . 'view/blocks.php');
$smarty->assign('category', $category);
$smarty->assign('new', $new);
......@@ -187,40 +187,49 @@ $viewid = $view->get('id');
$viewtype = $view->get('type');
$viewtitle = $view->get('title');
$owner = $view->get('owner');
if ($owner) {
if ($viewtype == 'profile') {
$microheaderlinks = array(
array(
'name' => get_string('viewmyprofilepage'),
'url' => get_config('wwwroot') . 'user/view.php',
),
array(
'name' => get_string('editmyprofile', 'artefact.internal'),
'url' => get_config('wwwroot') . 'artefact/internal/index.php',
'type' => 'edit',
),
);
$viewtitle = get_string('usersprofile', 'mahara', display_name($view->get('owner'), null, true));
}
else if ($new) {
$microheaderlinks = array();
}
else {
$microheaderlinks = array(
array(
'name' => get_string('edittitle', 'view'),
'url' => get_config('wwwroot') . 'view/edit.php?id=' . $viewid . '&amp;new=' . $new,
'type' => 'edit',
),
array(
'name' => get_string('editaccess', 'view'),
'url' => get_config('wwwroot') . 'view/access.php?id=' . $viewid . '&amp;new=' . $new,
'type' => 'edit',
),
);
if ($owner && $viewtype == 'profile') {
$viewtitle = get_string('usersprofile', 'mahara', display_name($view->get('owner'), null, true));
}
if (get_config('viewmicroheaders')) {
$smarty->assign('microheaders', true);
$smarty->assign('microheadertitle', $view->display_title(true, false));
if ($owner) {
if ($viewtype == 'profile') {
$microheaderlinks = array(
array(
'name' => get_string('viewmyprofilepage'),
'url' => get_config('wwwroot') . 'user/view.php',
),
array(
'name' => get_string('editmyprofile', 'artefact.internal'),
'url' => get_config('wwwroot') . 'artefact/internal/index.php',
'type' => 'edit',
),
);
}
else if ($new) {
$microheaderlinks = array();
}
else {
$microheaderlinks = array(
array(
'name' => get_string('edittitle', 'view'),
'url' => get_config('wwwroot') . 'view/edit.php?id=' . $viewid . '&amp;new=' . $new,
'type' => 'edit',
),
array(
'name' => get_string('editaccess', 'view'),
'url' => get_config('wwwroot') . 'view/access.php?id=' . $viewid . '&amp;new=' . $new,
'type' => 'edit',
),
);
}
$smarty->assign('microheaderlinks', $microheaderlinks);
}
$smarty->assign('microheaderlinks', $microheaderlinks);
}
$smarty->assign('userdisplayname', display_name($USER, null, true));
$smarty->assign('viewtype', $viewtype);
$smarty->assign('view', $view->get('id'));
......
......@@ -77,15 +77,16 @@ if (param_variable('make_private_submit', null)) {
pieform(make_private_form(param_integer('feedback')));
}
$group = $view->get('group');
$owner = $view->get('owner');
$viewtype = $view->get('type');
if ($view->get('type') == 'profile') {
$title = get_string('usersprofile', 'mahara', display_name($view->get('owner'), null, true));
if ($viewtype == 'profile') {
define('TITLE', display_name($owner, null, true));
}
else {
$title = $view->get('title');
define('TITLE', $view->get('title'));
}
define('TITLE', $title);
$title = hsc(TITLE);
$submittedgroup = (int)$view->get('submittedgroup');
if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_views($submittedgroup, $USER->get('id'))) {
......@@ -173,75 +174,80 @@ EOF;
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->assign('new', $new);
$smarty->assign('viewid', $viewid);
$smarty->assign('viewtitle', $title);
$viewtype = $view->get('type');
$smarty->assign('viewtype', $viewtype);
$smarty->assign('feedback', $feedback);
$owner = $view->get('owner');
$smarty->assign('owner', $owner);
$smarty->assign('tags', $view->get('tags'));
if ($owner) {
$smarty->assign('ownerlink', 'user/view.php?id=' . $owner);
}
else if ($group) {
$smarty->assign('ownerlink', 'group/view.php?id=' . $group);
}
if ($can_edit) {
if ($viewtype == 'profile') {
$microheaderlinks = array(
array(
'name' => get_string('editmyprofilepage'),
'url' => get_config('wwwroot') . 'view/blocks.php?profile=1',
'type' => 'edit',
),
array(
'name' => get_string('editmyprofile', 'artefact.internal'),
'url' => get_config('wwwroot') . 'artefact/internal/index.php',
'type' => 'edit',
),
);
}
else if ($new) {
$microheaderlinks = array(
array(
'name' => get_string('back'),
'url' => get_config('wwwroot') . 'view/blocks.php?id=' . $viewid . '&amp;new=1',
'type' => 'reply',
),
);
}
else {
$microheaderlinks = array(
array(
'name' => get_string('edittitle', 'view'),
'url' => get_config('wwwroot') . 'view/edit.php?id=' . $viewid . '&amp;new=' . $new,
'type' => 'edit',
),
array(
'name' => get_string('editcontent', 'view'),
'url' => get_config('wwwroot') . 'view/blocks.php?id=' . $viewid . '&amp;new=' . $new,
'type' => 'edit',
),
array(
'name' => get_string('editaccess', 'view'),
'url' => get_config('wwwroot') . 'view/access.php?id=' . $viewid . '&amp;new=' . $new,
'type' => 'edit',
),
);
if (get_config('viewmicroheaders')) {
$smarty->assign('microheaders', true);
$smarty->assign('microheadertitle', $view->display_title(true, false));
if ($can_edit) {
if ($viewtype == 'profile') {
$microheaderlinks = array(
array(
'name' => get_string('editmyprofilepage'),
'url' => get_config('wwwroot') . 'view/blocks.php?profile=1',
'type' => 'edit',
),
array(
'name' => get_string('editmyprofile', 'artefact.internal'),
'url' => get_config('wwwroot') . 'artefact/internal/index.php',
'type' => 'edit',
),
);
}
else if ($new) {
$microheaderlinks = array(
array(
'name' => get_string('back'),
'url' => get_config('wwwroot') . 'view/blocks.php?id=' . $viewid . '&amp;new=1',
'type' => 'reply',
),
);
}
else {
$microheaderlinks = array(
array(
'name' => get_string('edittitle', 'view'),
'url' => get_config('wwwroot') . 'view/edit.php?id=' . $viewid . '&amp;new=' . $new,
'type' => 'edit',
),
array(
'name' => get_string('editcontent', 'view'),
'url' => get_config('wwwroot') . 'view/blocks.php?id=' . $viewid . '&amp;new=' . $new,
'type' => 'edit',
),
array(
'name' => get_string('editaccess', 'view'),
'url' => get_config('wwwroot') . 'view/access.php?id=' . $viewid . '&amp;new=' . $new,
'type' => 'edit',
),
);
}
$smarty->assign('microheaderlinks', $microheaderlinks);
}
$smarty->assign('microheaderlinks', $microheaderlinks);
}
if ($USER->is_logged_in()) {
$smarty->assign('userdisplayname', display_name($USER, null, true));
if (!empty($_SERVER['HTTP_REFERER'])) {
$page = get_config('wwwroot') . 'view/view.php?id=' . $viewid . ($new ? '&new=1' : '');
if ($_SERVER['HTTP_REFERER'] != $page) {
$smarty->assign('backurl', $_SERVER['HTTP_REFERER']);
if ($USER->is_logged_in()) {
$smarty->assign('userdisplayname', display_name($USER, null, true));
if (!empty($_SERVER['HTTP_REFERER'])) {
$page = get_config('wwwroot') . 'view/view.php?id=' . $viewid . ($new ? '&new=1' : '');
if ($_SERVER['HTTP_REFERER'] != $page) {
$smarty->assign('backurl', $_SERVER['HTTP_REFERER']);
}
}
}
}
if ($viewtype != 'profile' && !get_config('viewmicroheaders')) {
$title = $view->display_title();
}
if ($viewtype != 'profile' || !get_config('viewmicroheaders')) {
$smarty->assign('maintitle', $title);
}
// Provide a link for roaming teachers to return
if ($mnetviewlist = $SESSION->get('mnetviewaccess')) {
if (isset($mnetviewlist[$view->get('id')])) {
......@@ -256,7 +262,6 @@ if ($mnetviewlist = $SESSION->get('mnetviewaccess')) {
}
}
$smarty->assign('ownername', $view->formatted_owner());
$smarty->assign('viewdescription', $view->get('description'));
$smarty->assign('viewcontent', $view->build_columns());
$smarty->assign('releaseform', $releaseform);
......
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