Commit b1f9a51c authored by Naomi Guyer's avatar Naomi Guyer Committed by Aaron Wells

Webservices (bootstrap)

Bug 1465107: Use Bootstrap CSS Framework

Change-Id: Iac22116f528a2b11e852d1a8dc2f8c2cb031455d
parent 0be400c0
......@@ -338,14 +338,8 @@ class Dwoo_Template_String implements Dwoo_ITemplate
public function getCompiledTemplate(Dwoo_Core $dwoo, Dwoo_ICompiler $compiler = null)
{
// echo '<pre>';
// echo 'file is:';
// print_r($dwoo);
// echo '</pre>';
$compiledFile = $this->getCompiledFilename($dwoo);
if ($this->compilationEnforced !== true && isset(self::$cache['compiled'][$this->compileId]) === true) {
// already checked, return compiled file
} elseif ($this->compilationEnforced !== true && $this->isValidCompiledFile($compiledFile)) {
......
......@@ -131,33 +131,42 @@ function _render_elements_as_multicolumn($form, $element) {
$oldrenderer = $form->get_property('renderer');
$form->set_property('renderer', 'div');
$form->include_plugin('renderer', 'div');
// We have a list of which elements are going to be the coulmn headings
// We have a list of which elements are going to be the column headings
$columns = $element['columns'];
$footer = $element['footer'];
$count = 0;
$result = '';
// If we want a description above the table we can add it as 'comment' to the fieldset element
if (!empty($element['comment'])) {
$result .= "\t<tr colspan='" . count($columns) . "'";
$result .= ">\n\t\t";
$result .= '<td';
$result .= '<p';
if (isset($element['class'])) {
$result .= ' class="' . Pieform::hsc($element['class']) . '"';
}
$result .= '>' . Pieform::hsc($element['comment']) . '</td>';
$result .= "</tr>\n";
$result .= '>' . Pieform::hsc($element['comment']);
$result .= "</p>\n";
}
$result .= '<table class="fullwidth table">';
// Now we loop through the elements chuncking them into rows based on the columns count
// but we include the labelhtml as the first column to describe what the row is about.
foreach ($element['elements'] as $name => $data) {
if (empty($count)) {
$result .= "\t<tr";
// Set the class of the enclosing <tr> to match that of the element
if (isset($data['class'])) {
$result .= ' class="' . Pieform::hsc($data['class']) . '"';
if(count($element['columns']) > 0){
$result .= '<thead>';
foreach ($columns as $name) {
$data = $element['elements'][$name];
if (empty($count)) {
$result .= "\t<tr";
// Set the class of the enclosing <tr> to match that of the element
if (isset($data['class'])) {
$result .= ' class="' . Pieform::hsc($data['class']) . '"';
}
$result .= ">\n\t\t";
}
$result .= ">\n\t\t";
}
if (array_search($name, $columns) !== false) {
if (empty($count)) {
$result .= "<th></th>\n\t";
}
......@@ -167,8 +176,24 @@ function _render_elements_as_multicolumn($form, $element) {
$result .= ' <span class="requiredmarker">*</span>';
}
$result .= "</th>\n\t";
$count ++;
}
else {
$result .= '</thead>';
$count = 0;
}
$result .= '<tbody>';
foreach ($element['elements'] as $name => $data) {
if (empty($count)) {
$result .= "\t<tr>";
}
// ignore heading columns - we've already rendered them, and footer
if (array_search($name, $columns) === false && array_search($name, $footer) === false) {
if (empty($count)) {
$result .= '<th>';
if (isset($data['labelhtml'])) {
......@@ -181,9 +206,6 @@ function _render_elements_as_multicolumn($form, $element) {
if (isset($data['name'])) {
$result .= " id=\"" . $form->get_name() . '_' . Pieform::hsc($data['name']) . '_container"';
}
if ($data['class']) {
$result .= ' class="' . Pieform::hsc($data['class']) . '"';
}
$result .= '>';
$result .= pieform_render_element($form, $data);
......@@ -200,6 +222,16 @@ function _render_elements_as_multicolumn($form, $element) {
$count = 0;
}
}
$result .= '</tbody></table>';
if(count($element['footer']) > 0){
foreach ($footer as $name) {
$data = $element['elements'][$name];
$result .= pieform_render_element($form, $data);
}
}
$form->set_property('renderer', $oldrenderer);
return $result;
}
......
......@@ -88,13 +88,19 @@ class FormRendererMultiColumnTable {/*{{{*/
}
$toggle = 0;
$datatable = false;
$result = "<table cellspacing=\"0\" border=\"0\" class=\"fullwidth\"><tbody>\n";
if(!$this->elements > 0) {
return false;
}
$result = '<table class="fullwidth table"> <thead>';
foreach ($this->elements as $title => $data) {
if ($datatable) {
$toggle = 1 - $toggle;
$data['settings']['class'] .= ' r' . $toggle;
}
}
$result .= "\t<tr";
// Set the class of the enclosing <tr> to match that of the element
if ($data['settings']['class']) {
$result .= ' class="' . Pieform::hsc($data['settings']['class']) . '"';
......@@ -147,7 +153,11 @@ class FormRendererMultiColumnTable {/*{{{*/
for ($i = count($data['builtelements']); $i < $columns; $i++) {
$result .= "\t<td></td>\n\t";
}
$result .= "</tr>\n";
if (!$datatable) {
$result .= "</thead></tr><tbody\n";
} else {
$result .= "</tr>\n";
}
// We want to add in the row class but not for the heading row so we do the check here
if (!empty($data['settings']['datatable'])) {
$datatable = true;
......
This diff is collapsed.
{include file="header.tpl"}
<p class="lead">{$pagedescription}</p>
{foreach from=$form.elements item=element}
<div class="pseudofieldset collapsible collapsed">
<span class="pseudolegend"><h4 id="{$element.name}_pseudofieldset"><a href="">{$element.legend}</a></h4></span>
<div class="collapsible-group" id="accordion" aria-multiselectable="true" role="tablist" >
{foreach from=$form.elements item=element name=elements}
<div class="pseudofieldset panel panel-default collapsible collapsible-group{if $.foreach.elements.last} last{/if}">
<h2 class="pseudolegend panel-heading has-link">
<a class="{if !$.foreach.elements.first}collapsed{/if}" href="#{$element.name}_pseudofieldset" data-toggle="collapse" aria-expanded="{if $.foreach.elements.first}true{else}false{/if}" aria-controls="{$element.name}_pseudofieldset" data-parent="#accordion">
{$element.legend}
<span class="icon icon-chevron-down pls collapse-indicator pull-right"></span>
</a>
</h2>
<div class="panel-body collapse {if $.foreach.elements.first} in{/if}" id="{$element.name}_pseudofieldset">
{foreach from=$element.elements item=item}
{$item.value|safe}
{/foreach}
</div>
</div>
{/foreach}
<div class="cl"></div>
</div>
<script type="application/javascript">
jQuery(function() {
jQuery('.pseudofieldset').each(function() {
......
......@@ -16,6 +16,25 @@
padding: 20px 0;
position: relative;
&.fake-form {
border: 0;
padding: 0;
.collapsible-group .panel.collapsible & {
border: 0;
padding: 0;
}
}
// this is a weird and somewhat broken case where form renderers are being use to render regular html
&.html form {
display: block;
.form-group,
.collapsible-group .panel.collapsible & .form-group {
border: 0;
padding: 0;
}
}
&.button,
&.submit {
background: transparent;
......
......@@ -5,6 +5,9 @@
&:not(.list-unstyled):not(.unstyled){
padding-left: 20px;
margin: 0 0 20px;
&.select2-choices {
margin-bottom: 0;
}
}
}
.sidebar & .form-group {
......
......@@ -83,7 +83,8 @@
position: relative;
padding: 20px 0;
border-bottom: 1px solid #f0f0f0;
&:last-child {
&:last-child,
&.last {
border-bottom: 0;
}
}
......
This diff is collapsed.
......@@ -294,8 +294,9 @@ function webservices_master_switch_form() {
'type' => array('type' => 'hidden', 'value' => 'webservice'),
'pluginname' => array('type' => 'hidden', 'value' => 'webservice'),
'enabled' => array('type' => 'switchbox',
'class' => 'last',
'value' => $enabled,
'labelhtml' => get_string('control_webservices', 'auth.webservice'),
'labelhtml' => '<span class="pseudolabel">'. get_string('control_webservices', 'auth.webservice') .'</span>',
),
),
)
......@@ -321,6 +322,7 @@ function webservices_protocol_switch_form() {
$elements[$proto] = array(
'title' => ' ',
'type' => 'html',
'class' => 'fake-form',
'value' =>
pieform(array(
'name' => 'activate_webservice_protos_' . $proto,
......@@ -338,7 +340,7 @@ function webservices_protocol_switch_form() {
'protocol' => array('type' => 'hidden', 'value' => $proto),
'enabled' => array('type' => 'switchbox',
'value' => $enabled,
'labelhtml' => get_string($proto, 'auth.webservice') . ': ',
'labelhtml' => '<span class="pseudolabel">' .get_string($proto, 'auth.webservice') . ': </span>',
),
),
)));
......@@ -459,7 +461,7 @@ function service_fg_edit_form() {
'value' => pieform(array(
'name' => 'webservices_function_groups_edit_' . $service->id,
'renderer' => 'div',
'class' => 'form-as-button',
'class' => 'form-as-button pull-left',
'successcallback' => 'webservices_function_groups_submit',
'jsform' => false,
'action' => get_config('wwwroot') . 'webservice/admin/index.php',
......@@ -470,7 +472,7 @@ function service_fg_edit_form() {
'type' => 'button',
'class' => 'btn btn-default btn-sm',
'usebuttontag' => true,
'value' => '<span class="'.$editicon.'"></span>' . get_string('editspecific', 'mahara', $service->id),
'value' => '<span class="'.$editicon.'"></span>' . get_string('edit', 'mahara'),
'elementtitle' => get_string('edit'),
),
),
......@@ -479,7 +481,7 @@ function service_fg_edit_form() {
pieform(array(
'name' => 'webservices_function_groups_delete_' . $service->id,
'renderer' => 'div',
'class' => 'form-as-button',
'class' => 'form-as-button pull-left',
'successcallback' => 'webservices_function_groups_submit',
'jsform' => false,
'action' => get_config('wwwroot') . 'webservice/admin/index.php',
......@@ -490,7 +492,7 @@ function service_fg_edit_form() {
'type' => 'button',
'usebuttontag' => true,
'class' => 'btn btn-default btn-sm',
'value' => '<span class="'.$deleteicon.'"></span>' . get_string('deletespecific', 'mahara', $service->id),
'value' => '<span class="'.$deleteicon.'"></span>' . get_string('delete', 'mahara'),
'elementtitle' => get_string('delete'),
),
),
......@@ -505,24 +507,27 @@ function service_fg_edit_form() {
$pieform = new pieform($form);
return $pieform->build(false) . '<div class="function_add">' .
pieform(array(
'name' => 'webservices_function_groups_add',
'renderer' => 'div',
'successcallback' => 'webservices_function_groups_submit',
'class' => 'text-inline',
'jsform' => false,
'action' => get_config('wwwroot') . 'webservice/admin/index.php',
'elements' => array(
'service' => array('type' => 'text'),
'action' => array('type' => 'hidden', 'value' => 'add'),
'submit' => array(
'type' => 'submit',
'class' => 'submit',
'value' => get_string('add')
),
),
)) .
'</div>';
pieform(array(
'name' => 'webservices_function_groups_add',
'renderer' => 'div',
'successcallback' => 'webservices_function_groups_submit',
'class' => 'form-inline',
'jsform' => false,
'action' => get_config('wwwroot') . 'webservice/admin/index.php',
'elements' => array(
'service' => array(
'type' => 'text',
'class' => 'last'
),
'action' => array('type' => 'hidden', 'value' => 'add'),
'submit' => array(
'type' => 'submit',
'class' => 'submit btn btn-success last',
'value' => get_string('add')
),
),
)) .
'</div>';
}
/**
......@@ -738,7 +743,7 @@ function service_tokens_edit_form() {
'action' => array('type' => 'hidden', 'value' => 'generate'),
'submit' => array(
'type' => 'submit',
'class' => 'submit',
'class' => 'submit btn btn-primary last',
'value' => get_string('generate', 'auth.webservice')
),
),
......@@ -950,7 +955,7 @@ function service_users_edit_form() {
'action' => array('type' => 'hidden', 'value' => 'add'),
'submit' => array(
'type' => 'submit',
'class' => 'submit',
'class' => 'submit btn btn-primary last',
'value' => get_string('add')
),
),
......@@ -993,22 +998,22 @@ function get_config_options_extended() {
// fieldset of protocol switches
'protocolswitches' => array(
'type' => 'fieldset',
'legend' => get_string('protocolswitches', 'auth.webservice'),
'elements' => array(
'protos_help' => array(
'type' => 'html',
'value' => '<div><p>' . get_string('manage_protocols', 'auth.webservice') . '</p></div>',
),
'enablewebserviceprotos' => array(
'type' => 'html',
'value' => $protos->build(false),
),
),
'collapsible' => true,
'collapsed' => true,
'name' => 'activate_webservices_protos',
),
'type' => 'fieldset',
'legend' => get_string('protocolswitches', 'auth.webservice'),
'elements' => array(
'protos_help' => array(
'type' => 'html',
'value' => '<div><p>' . get_string('manage_protocols', 'auth.webservice') . '</p></div>',
),
'enablewebserviceprotos' => array(
'type' => 'html',
'value' => $protos->build(false),
),
),
'collapsible' => true,
'collapsed' => true,
'name' => 'activate_webservices_protos',
),
// System Certificates
'certificates' => array(
......@@ -1022,7 +1027,7 @@ function get_config_options_extended() {
'pubkey' => array(
'type' => 'html',
'value' => '<div class="title">' . get_string('publickey','admin') . '</div>' .
'value' => '<h3 class="title">' . get_string('publickey','admin') . '</h3>' .
'<div class="detail">' . get_string('publickeydescription2', 'admin', 365) . '</div>' .
'<pre style="font-size: 0.7em; white-space: pre;">' . $openssl->certificate . '</pre>'
),
......
......@@ -136,7 +136,7 @@ function webservice_oauth_server_submit(Pieform $form, $values) {
$pieform = new Pieform($form);
$form = $pieform->build(false);
$smarty = smarty(array(), array('<link rel="stylesheet" type="text/css" href="' . $THEME->get_url('style/webservice.css', false, 'auth/webservice') . '">',));
$smarty = smarty();
setpageicon($smarty, 'icon-puzzle-piece');
safe_require('auth', 'webservice');
PluginAuthWebservice::menu_items($smarty, 'webservice/oauthconfig');
......@@ -419,7 +419,7 @@ function webservice_server_list_form($sopts, $iopts) {
'submit' => array(
'type' => 'button',
'usebuttontag' => true,
'alt' => get_string('deletespecific', 'mahara', $consumer->id),
'value' => get_string('deletespecific', 'mahara', $consumer->id),
'elementtitle' => get_string('delete'),
),
),
......@@ -450,17 +450,20 @@ function webservice_server_list_form($sopts, $iopts) {
),
'institution' => array(
'class' => 'no-label',
'type' => 'select',
'options' => $iopts,
),
'service' => array(
'class' => 'no-label',
'type' => 'select',
'options' => $sopts,
),
'action' => array('type' => 'hidden', 'value' => 'add'),
'submit' => array(
'type' => 'submit',
'class' => 'btn btn-primary no-label',
'value' => get_string('add', 'auth.webservice'),
),
),
......
......@@ -74,6 +74,7 @@ foreach ($dbfunctions as $function) {
$functions['elements']['submit'] = array(
'type' => 'submitcancel',
'class' => 'btn btn-primary',
'value' => array(get_string('save'), get_string('back')),
'goto' => get_config('wwwroot') . 'webservice/admin/index.php?open=webservices_function_groups',
);
......@@ -94,7 +95,7 @@ $elements = array(
'on_label' => get_string('enabled'),
'off_label' => get_string('disabled'),
'wrapperclass' => 'switch-wrapper-inline',
'labelhtml' => get_string('servicename', 'auth.webservice'),
'labelhtml' => '<span class="pseudolabel">' . get_string('servicename', 'auth.webservice') .'</span>',
),
'restrictedusers' => array(
'type' => 'switchbox',
......@@ -102,7 +103,7 @@ $elements = array(
'on_label' => get_string('usersonly', 'auth.webservice'),
'off_label' => get_string('tokensonly', 'auth.webservice'),
'wrapperclass' => 'switch-wrapper-inline',
'labelhtml' => get_string('restrictedusers', 'auth.webservice'),
'labelhtml' => '<span class="pseudolabel">' . get_string('restrictedusers', 'auth.webservice') .'</span>',
),
'tokenusers' => array(
'type' => 'switchbox',
......@@ -110,7 +111,7 @@ $elements = array(
'on_label' => get_string('enabled'),
'off_label' => get_string('disabled'),
'wrapperclass' => 'switch-wrapper-inline',
'labelhtml' => get_string('fortokenusers', 'auth.webservice'),
'labelhtml' => '<span class="pseudolabel">' . get_string('fortokenusers', 'auth.webservice') .'</span>',
),
),
'collapsible' => true,
......@@ -119,8 +120,10 @@ $elements = array(
// fieldset for managing service function list
'functions' => array(
'type' => 'fieldset',
'class' => 'last',
'renderer' => 'multicolumnfieldsettable',
'columns' => array('enabledname', 'classname', 'methodname'),
'footer' => array('submit'),
'legend' => get_string('servicefunctionlist', 'auth.webservice'),
'comment' => get_string('sfldescription', 'auth.webservice'),
'elements' => $functions['elements'],
......@@ -141,8 +144,6 @@ $heading = get_string('servicegroup', 'auth.webservice', $dbservice->name);
$form['name'] = 'serviceconfig';
$form['successcallback'] = 'serviceconfig_submit';
$form = pieform($form);
$headers[] = '<link rel="stylesheet" type="text/css" href="' . $THEME->get_url('style/webservice.css', false, 'auth/webservice') . '">';
$headers[] = '<link rel="stylesheet" type="text/css" href="' . append_version_number(get_config('wwwroot') . 'js/jquery/jquery-ui/css/ui-lightness/jquery-ui-1.10.2.min.css') .'">';
$inlinejs = <<<EOF
<script type="application/javascript">
jQuery(function() {
......
......@@ -132,7 +132,7 @@ $form = array(
);
unset($form['elements'][0]);
$form = pieform($form);
$smarty = smarty(array(), array('<link rel="stylesheet" type="text/css" href="' . $THEME->get_url('style/webservice.css', false, 'auth/webservice') . '">',));
$smarty = smarty();
setpageicon($smarty, 'icon-puzzle-piece');
safe_require('auth', 'webservice');
......
......@@ -165,6 +165,7 @@ if (!empty($dbservices)) {
'submit' => array(
'type' => 'button',
'usebuttontag' => true,
'class' => 'btn btn-default',
'value' => get_string('gen', 'auth.webservice'),
'elementtitle' => get_string('gen', 'auth.webservice')
),
......@@ -184,6 +185,7 @@ if (!empty($dbservices)) {
'submit' => array(
'type' => 'button',
'usebuttontag' => true,
'class' => 'btn btn-default',
'value' => get_string('deletespecific', 'mahara', $service->id),
'elementtitle' => get_string('delete'),
),
......@@ -425,7 +427,7 @@ function webservices_oauth_token_submit(Pieform $form, $values) {
$pieform = new pieform($form);
$form = $pieform->build(false);
$smarty = smarty(array(), array('<link rel="stylesheet" type="text/css" href="' . $THEME->get_url('style/webservice.css', false, 'auth/webservice') . '">',));
$smarty = smarty();
setpageicon($smarty, 'icon-puzzle-piece');
safe_require('auth', 'webservice');
......
......@@ -172,7 +172,7 @@ if (!empty($elements['protocol']['options'])) {
else {
$form = '';
}
$smarty = smarty(array(), array('<link rel="stylesheet" type="text/css" href="' . $THEME->get_url('style/webservice.css', false, 'auth/webservice') . '">',));
$smarty = smarty();
setpageicon($smarty, 'icon-puzzle-piece');
safe_require('auth', 'webservice');
......
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