Commit 59033039 authored by Stacey Walker's avatar Stacey Walker Committed by Richard Mansfield

collection: view horizontal navigation option per collection

Signed-off-by: default avatarStacey Walker <stacey@catalyst.net.nz>
parent e6a173c0
......@@ -83,7 +83,7 @@ if ($available = Collection::available_views()) {
}
$elements['submit'] = array(
'type' => 'submit',
'value' => get_string('add','collection'),
'value' => get_string('addview','collection'),
'goto' => get_config('wwwroot') . 'collection/views.php?id='.$id,
);
......@@ -97,30 +97,42 @@ if ($available = Collection::available_views()) {
));
}
$smarty = smarty();
$elements = array();
$elements['navigation'] = array(
'type' => 'checkbox',
'title' => get_string('viewnavigation','collection'),
'description' => get_string('viewnavigationdesc','collection'),
'defaultvalue' => $collection ? $collection->get('navigation') : 1,
);
if ($new) {
$newform = pieform(array(
'name' => 'new',
'plugintype' => 'core',
'pluginname' => 'collection',
'autofocus' => false,
'method' => 'post',
'elements' => array(
'submit' => array(
'type' => 'cancelbackcreate',
'value' => array(get_string('cancel'), get_string('back','collection'), get_string('next') . ': ' . get_string('editaccess', 'collection')),
'confirm' => array(get_string('confirmcancelcreatingcollection', 'collection'), null, null),
),
),
));
$smarty->assign_by_ref('newform', $newform);
$elements['submit'] = array(
'type' => 'cancelbackcreate',
'value' => array(get_string('cancel'), get_string('back','collection'), get_string('next') . ': ' . get_string('editaccess', 'collection')),
'confirm' => array(get_string('confirmcancelcreatingcollection', 'collection'), null, null),
);
}
else {
$elements['submit'] = array(
'type' => 'submitcancel',
'value' => array(get_string('save'), get_string('cancel')),
);
}
$nextform = pieform(array(
'name' => 'next',
'plugintype' => 'core',
'pluginname' => 'collection',
'autofocus' => false,
'method' => 'post',
'elements' => $elements,
));
$smarty = smarty();
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('displayurl',get_config('wwwroot').'collection/views.php?id='.$id.$newurl);
$smarty->assign('removeurl',get_config('wwwroot').'collection/deleteview.php?id='.$id.$newurl);
$smarty->assign_by_ref('views', $views);
$smarty->assign_by_ref('viewsform', $viewsform);
$smarty->assign_by_ref('nextform', $nextform);
$smarty->display('collection/views.tpl');
function addviews_submit(Pieform $form, $values) {
......@@ -136,19 +148,28 @@ function addviews_submit(Pieform $form, $values) {
}
function new_cancel_submit() {
global $collection;
$collection->delete();
function next_cancel_submit() {
global $collection, $new;
if ($new) {
$collection->delete();
}
redirect('/collection/');
}
function new_submit(Pieform $form, $values) {
global $collection;
function next_submit(Pieform $form, $values) {
global $collection, $new;
if (param_boolean('back')) {
redirect('/collection/edit.php?id='.$collection->get('id').'&new=1');
}
else {
redirect('/view/access.php?collection='.$collection->get('id').'&new=1');
if ($new) {
redirect('/view/access.php?collection='.$collection->get('id').'&new=1');
}
else {
$collection->set('navigation',(int)$values['navigation']);
$collection->commit();
redirect('/collection/');
}
}
}
......
......@@ -86,6 +86,8 @@ $string['viewaddedtocollection'] = 'View added to collection.';
$string['viewcollection'] = 'View Collection Details';
$string['viewcount'] = 'Views';
$string['viewremovedsuccessfully'] = 'View removed successfully.';
$string['viewnavigation'] = 'View navigation bar';
$string['viewnavigationdesc'] = 'Add a horizontal navigation bar to every view in this collection by default.';
$string['views'] = 'Views';
$string['viewsaddedtocollection'] = 'Views added to collection.';
$string['viewstobeadded'] = 'Views to be added';
......
......@@ -35,6 +35,7 @@ class Collection {
private $owner;
private $mtime;
private $ctime;
private $navigation;
private $views;
public function __construct($id=0, $data=null) {
......
......@@ -798,6 +798,7 @@
<FIELD NAME="mtime" TYPE="datetime" NOTNULL="true" />
<FIELD NAME="name" TYPE="text" NOTNULL="true" />
<FIELD NAME="description" TYPE="text" NOTNULL="false" />
<FIELD NAME="navigation" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
......@@ -808,7 +809,6 @@
<FIELDS>
<FIELD NAME="collection" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="view" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="master" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0"/>
<FIELD NAME="displayorder" TYPE="int" LENGTH="10" NOTNULL="true" />
</FIELDS>
<KEYS>
......
......@@ -2110,7 +2110,6 @@ function xmldb_core_upgrade($oldversion=0) {
$table = new XMLDBTable('collection_view');
$table->addFieldInfo('view', XMLDB_TYPE_INTEGER, 10, false, XMLDB_NOTNULL);
$table->addFieldInfo('collection', XMLDB_TYPE_INTEGER, 10, false, XMLDB_NOTNULL);
$table->addFieldInfo('master', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('view','collection'));
$table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('view'), 'view', array('id'));
$table->addKeyInfo('collectionfk', XMLDB_KEY_FOREIGN, array('collection'), 'collection', array('id'));
......@@ -2143,5 +2142,12 @@ function xmldb_core_upgrade($oldversion=0) {
}
if ($oldversion < 2010080500) {
$table = new XMLDBTable('collection');
$field = new XMLDBField('navigation');
$field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 1);
add_field($table, $field);
}
return $status;
}
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010080402;
$config->version = 2010080500;
$config->release = '1.3.0beta4dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
......@@ -2743,7 +2743,7 @@ class View {
}
}
public static function set_nav($group, $institution, $profile=false, $collection) {
public static function set_nav($group, $institution, $profile=false, $collection=null) {
if ($group) {
define('MENUITEM', 'groups/views');
define('GROUP', $group);
......
......@@ -41,11 +41,7 @@
{str tag=noviewsavailable section=collection}
{/if}
</fieldset>
{if $newform}
{$newform|safe}
{else}
<div id="view-wizard-controls" class="center">
<a class="btn" href="{$WWWROOT}collection">{str tag=done}</a>
</div>
{if $nextform}
{$nextform|safe}
{/if}
{include file="footer.tpl"}
......@@ -34,6 +34,7 @@ define('SECTION_PAGE', 'view');
require(dirname(dirname(__FILE__)) . '/init.php');
require_once(get_config('libroot') . 'view.php');
require_once(get_config('libroot') . 'collection.php');
require_once('group.php');
safe_require('artefact', 'comment');
......@@ -180,12 +181,12 @@ addLoadEvent(function () {
EOF;
// collection top navigation
$allowcollections = get_config('allowcollections');
if ($allowcollections) {
require_once(get_config('libroot') . 'collection.php');
$collection = Collection::search_by_view_id($viewid);
$views = $collection->get('views');
$smarty->assign_by_ref('collection',$views['views']);
if ($collection = Collection::search_by_view_id($viewid)) {
$shownav = $collection->get('navigation');
if ($shownav) {
$views = $collection->get('views');
$smarty->assign_by_ref('collection',$views['views']);
}
}
$smarty->assign('INLINEJAVASCRIPT', $javascript);
......
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