From adc5c8e908f6bbd834cdb3712acbeb2bc65e2865 Mon Sep 17 00:00:00 2001 From: Ralf Lang Date: Tue, 17 Mar 2026 15:12:26 +0100 Subject: [PATCH] refactor(routes): migrate responsive routes to builder pattern Convert responsive routes to RouteBuilder fluent interface WARNING: app/controllers/CompleteTask.php and SaveTask.php are old-style Horde_Controller_Base controllers and must keep array syntax routes. Backward compatibility maintained via secondary routes on smartmobile.php to /responsive. --- config/routes.php | 150 +++--- index.php | 3 +- js/smartmobile.js | 499 ------------------- lib/Ajax/Application/Handler/Smartmobile.php | 209 -------- lib/Application.php | 2 +- lib/Smartmobile.php | 131 ----- smartmobile.php | 26 - templates/smartmobile/lists.html.php | 7 - templates/smartmobile/main.html.php | 17 - templates/smartmobile/taskform.html.php | 67 --- 10 files changed, 66 insertions(+), 1045 deletions(-) delete mode 100644 js/smartmobile.js delete mode 100644 lib/Ajax/Application/Handler/Smartmobile.php delete mode 100644 lib/Smartmobile.php delete mode 100644 smartmobile.php delete mode 100644 templates/smartmobile/lists.html.php delete mode 100644 templates/smartmobile/main.html.php delete mode 100644 templates/smartmobile/taskform.html.php diff --git a/config/routes.php b/config/routes.php index a39b943a..01ba6478 100644 --- a/config/routes.php +++ b/config/routes.php @@ -1,11 +1,10 @@ connect('/t/complete', array( 'controller' => 'CompleteTask', @@ -16,94 +15,73 @@ 'controller' => 'SaveTask', )); -// Responsive routes -$mapper->connect( - 'ResponsiveTasks', - 'responsive', - [ - 'controller' => Responsive\ResponsiveController::class, - 'HordeAuthType' => 'authenticate', - 'stack' => [], - ] -); +// Responsive UI Routes - PSR-style builder pattern -// Responsive filter routes -$mapper->connect( - 'ResponsiveTasksAll', - 'responsive/all', - [ - 'controller' => Responsive\ResponsiveController::class, - 'HordeAuthType' => 'authenticate', - 'stack' => [], - ] -); +// Tasks List - Primary route with legacy smartmobile secondary +$mapper->buildRoute(uri: '/responsive', name: 'ResponsiveTasks') + ->withController(Responsive\ResponsiveController::class) + ->withDefaults(['HordeAuthType' => 'authenticate']) + ->noMiddleware() + ->withSecondaryRoute('/smartmobile') + ->withSecondaryRoute('/smartmobile.php') + ->add(); -$mapper->connect( - 'ResponsiveTasksIncomplete', - 'responsive/incomplete', - [ - 'controller' => Responsive\ResponsiveController::class, - 'HordeAuthType' => 'authenticate', - 'stack' => [], - ] -); +// Filter: All Tasks +$mapper->buildRoute(uri: '/responsive/all', name: 'ResponsiveTasksAll') + ->withController(Responsive\ResponsiveController::class) + ->withDefaults(['HordeAuthType' => 'authenticate']) + ->noMiddleware() + ->add(); -$mapper->connect( - 'ResponsiveTasksComplete', - 'responsive/complete', - [ - 'controller' => Responsive\ResponsiveController::class, - 'HordeAuthType' => 'authenticate', - 'stack' => [], - ] -); +// Filter: Incomplete Tasks +$mapper->buildRoute(uri: '/responsive/incomplete', name: 'ResponsiveTasksIncomplete') + ->withController(Responsive\ResponsiveController::class) + ->withDefaults(['HordeAuthType' => 'authenticate']) + ->noMiddleware() + ->add(); -$mapper->connect( - 'ResponsiveTasksFuture', - 'responsive/future', - [ - 'controller' => Responsive\ResponsiveController::class, - 'HordeAuthType' => 'authenticate', - 'stack' => [], - ] -); +// Filter: Complete Tasks +$mapper->buildRoute(uri: '/responsive/complete', name: 'ResponsiveTasksComplete') + ->withController(Responsive\ResponsiveController::class) + ->withDefaults(['HordeAuthType' => 'authenticate']) + ->noMiddleware() + ->add(); -$mapper->connect( - 'ResponsiveTasksFutureIncomplete', - 'responsive/future-incomplete', - [ - 'controller' => Responsive\ResponsiveController::class, - 'HordeAuthType' => 'authenticate', - 'stack' => [], - ] -); +// Filter: Future Tasks +$mapper->buildRoute(uri: '/responsive/future', name: 'ResponsiveTasksFuture') + ->withController(Responsive\ResponsiveController::class) + ->withDefaults(['HordeAuthType' => 'authenticate']) + ->noMiddleware() + ->add(); -$mapper->connect( - 'ResponsiveTaskAdd', - 'responsive/add', - [ - 'controller' => Responsive\ResponsiveController::class, - 'HordeAuthType' => 'authenticate', - 'stack' => [], - ] -); +// Filter: Future Incomplete Tasks +$mapper->buildRoute(uri: '/responsive/future-incomplete', name: 'ResponsiveTasksFutureIncomplete') + ->withController(Responsive\ResponsiveController::class) + ->withDefaults(['HordeAuthType' => 'authenticate']) + ->noMiddleware() + ->add(); -$mapper->connect( - 'ResponsiveTask', - 'responsive/task/:tasklist/:id', - [ - 'controller' => Responsive\ResponsiveController::class, - 'HordeAuthType' => 'authenticate', - 'stack' => [], - ] -); +// Add New Task +$mapper->buildRoute(uri: '/responsive/add', name: 'ResponsiveTaskAdd') + ->withController(Responsive\ResponsiveController::class) + ->withDefaults(['HordeAuthType' => 'authenticate']) + ->noMiddleware() + ->add(); -$mapper->connect( - 'ResponsiveTaskEdit', - 'responsive/edit/:tasklist/:id', - [ - 'controller' => Responsive\ResponsiveController::class, - 'HordeAuthType' => 'authenticate', - 'stack' => [], - ] -); +// Task Detail View +$mapper->buildRoute(uri: '/responsive/task/:tasklist/:id', name: 'ResponsiveTask') + ->withController(Responsive\ResponsiveController::class) + ->withDefaults(['HordeAuthType' => 'authenticate']) + ->requires('tasklist', '[a-zA-Z0-9\-_]+') + ->requires('id', '[a-zA-Z0-9\-_]+') + ->noMiddleware() + ->add(); + +// Task Edit View +$mapper->buildRoute(uri: '/responsive/edit/:tasklist/:id', name: 'ResponsiveTaskEdit') + ->withController(Responsive\ResponsiveController::class) + ->withDefaults(['HordeAuthType' => 'authenticate']) + ->requires('tasklist', '[a-zA-Z0-9\-_]+') + ->requires('id', '[a-zA-Z0-9\-_]+') + ->noMiddleware() + ->add(); diff --git a/index.php b/index.php index bfd513bf..70b79a23 100644 --- a/index.php +++ b/index.php @@ -12,8 +12,7 @@ switch ($registry->getView()) { case $registry::VIEW_SMARTMOBILE: - $url = new Horde_Core_Smartmobile_Url(Horde::url('smartmobile.php')); - $url->setAnchor('nag-list')->redirect(); + Horde::url('responsive')->redirect(); break; default: diff --git a/js/smartmobile.js b/js/smartmobile.js deleted file mode 100644 index 46f5503a..00000000 --- a/js/smartmobile.js +++ /dev/null @@ -1,499 +0,0 @@ -/** - * Base smartmobile application logic for Nag. - * - * Copyright 2011-2017 Horde LLC (http://www.horde.org/) - * - * See the enclosed file LICENSE for license information (GPL). If you - * did not receive this file, see http://www.horde.org/licenses/gpl. - * - * @author Michael J Rubinsky - * @category Horde - * @license http://www.horde.org/licenses/gpl GPL - * @package Nag - */ -var NagMobile = { - - tasklists: {}, - - tasks: {}, - - currentList: undefined, - - /** - * Toggle the completion status of the task. - * - * @param object d The data object. - */ - - toggleComplete: function(d) - { - var parsed = d.options.parsedUrl; - - HordeMobile.doAction( - 'smartmobileToggle', - { - task: parsed.params.task_id, - tasklist: parsed.params.tasklist - }, - function(r) { NagMobile.toggleCompleteCallback(r, d.options.data) } - ); - }, - - /** - * Callback for the toggleComplete action - * - * @param object r The response object. - * @param object elt The element containing the task. - */ - toggleCompleteCallback: function(r, elt) - { - if (!r.data) { - return; - } - - switch (r.data) { - case 'complete': - NagMobile.tasks[elt.jqmData('tasklist')][elt.jqmData('task_id')].cp = true; - if (Nag.conf.showCompleted == 'incomplete' || - Nag.conf.showCompleted == 'future-incomplete') { - // Hide the task - elt.parent().remove(); - } else { - elt.jqmData('icon', 'check') - .find('span.ui-icon') - .removeClass('ui-icon-nag-unchecked') - .addClass('ui-icon-check'); - NagMobile.styleTask(elt, NagMobile.tasks[elt.jqmData('tasklist')][elt.jqmData('task_id')]); - } - break; - - default: - NagMobile.tasks[elt.jqmData('tasklist')][elt.jqmData('task_id')].cp = false; - if (Nag.conf.showCompleted == 'complete') { - // Hide the task - elt.parent().remove(); - } else { - elt.jqmData('icon', 'minus') - .find('span.ui-icon') - .removeClass('ui-icon-check') - .addClass('ui-icon-nag-unchecked'); - NagMobile.styleTask(elt, NagMobile.tasks[elt.jqmData('tasklist')][elt.jqmData('task_id')]); - } - } - }, - - /** - * Get a task from the server. - * - * @param object d The data object. - */ - getTask: function(d) - { - var parsed = d.options.parsedUrl; - - HordeMobile.doAction( - 'getTask', - { - task: parsed.params.task_id, - tasklist: parsed.params.tasklist - }, - NagMobile.getTaskCallback - ); - $('#nag-taskform-view a[href^="#task-delete"]').show(); - HordeMobile.changePage('nag-taskform-view', d); - }, - - /** - * Callback for the getTask action. - * - * @param object r The response object. - */ - getTaskCallback: function(r) - { - if (!r.task) { - return; - } - - var task = r.task, - f = $('form')[0]; - - f.reset(); - $("#task_title").val(task.n); - $("#task_desc").val(task.de); - $("#task_assignee").val(task.as); - $("task_private").prop("checked", task.pr).checkboxradio("refresh"); - if (task.dd) { - $("#task_due").val(Date.parse(task.dd).toString('yyyy-MM-dd')); - } - if (task.s) { - $("#task_start").val(Date.parse(task.s).toString('yyyy-MM-dd')); - } - var myselect = $("#task_priority"); - myselect[0].selectedIndex = task.pr - 1; - myselect.selectmenu("refresh"); - $("#task_completed").prop("checked", task.cp).checkboxradio("refresh"); - $("#task_estimate").val(task.e); - $("#task_id").val(task.id); - $("#tasklist").val(task.l); - }, - - /** - * Get a list of tasklists from the server and display the nag-lists view. - * - * @param object d The data object. - */ - toLists: function(d) - { - HordeMobile.changePage('nag-lists', d); - HordeMobile.doAction( - 'getTaskLists', - {}, - NagMobile.getTasklistsCallback - ); - }, - - /** - * Callback for the getTaskLists action - * - * @param object r The response object. - */ - getTasklistsCallback: function(r) - { - if (!r.tasklists) { - return; - } - - var list = $('#nag-lists :jqmData(role="listview")'), - count = 0; - - list.empty(); - - $.each(r.tasklists, function(i, l) { - count = count + l.count; - NagMobile.insertTasklist(list, l, false); - }); - - NagMobile.insertTasklist( - list, - { - 'name': Nag.strings.all, - 'count': count - }, - true - ); - list.listview('refresh'); - }, - - /** - * Insert a tasklist element into the tasklist list. - * - * @param object el The UL element. - * @param object l The list hash. - * @param boolean top Place new list at top of list if true. - */ - insertTasklist: function(el, l, top) - { - var url = HordeMobile.createUrl('nag-list', { tasklist: l.id }), - list; - - NagMobile.tasklists[l.id] = l; - - list = $('
  • ').append($('').attr({ href: url }).addClass('nag-tasklist') - .append($('').attr({ 'src': Nag.conf.icons[(l.smart ? 'smartlist' : 'tasklist')] }).addClass('ui-li-icon')) - .append($('

    ').text(l.name)) - .append($('').addClass('ui-li-count' + (l.overdue ? ' overdue' : '')).text(l.count)) - ); - - if (top) { - el.prepend(list); - } else { - el.append(list); - } - }, - - /** - * Retrieve a tasklist from the server and display the nag-list view. - * - * @param object d The data object. - */ - toList: function(d) - { - var params = d.options.parsedUrl.params; - - HordeMobile.doAction( - 'listTasks', - { tasklist: params.tasklist }, - NagMobile.listTasksCallback - ); - $('#nag-list .smartmobile-title') - .text(NagMobile.tasklists[params.tasklist].name); - NagMobile.currentList = params.tasklist; - HordeMobile.changePage('nag-list', d); - }, - - /** - * Callback for the listTasks action. - * - * @param object r The response object. - */ - listTasksCallback: function(r) - { - if (!r.tasks) { - return; - } - - NagMobile.tasks = {}; - $.each(r.tasks, function(i, t) { - if (!NagMobile.tasks[t.l]) { - NagMobile.tasks[t.l] = {}; - } - NagMobile.tasks[t.l][t.id] = t; - }); - NagMobile.buildTaskList(); - if (NagMobile.tasklists[NagMobile.currentList].smart == 1) { - $('#nag-list :jqmData(role="footer") a[href^="#nag-taskform-view"]').hide(); - } else { - $('#nag-list :jqmData(role="footer") a[href^="#nag-taskform-view"]').show(); - } - }, - - /** - * Build the complete tasklist - */ - buildTaskList: function() - { - var list = $('#nag-list :jqmData(role="listview")'), - count = 0; - list.empty(); - $.each(NagMobile.tasks, function (i, l) { - $.each(l, function (i, t) { - count++; - NagMobile.insertTask(list, t); - }); - }); - if (count > 0) { - $('#nag-notasks').hide(); - } else { - $('#nag-notasks').show(); - } - list.listview('refresh'); - }, - - /** - * Insert task into the view. - * - * @param object l The UL element. - * @param object t The task hash. - */ - insertTask: function(l, t) - { - var params = { - task_id: t.id, - tasklist: t.l - }, item, view_link, toggle_link; - - view_link = $(''); - if (!!t.vl) { - view_link = view_link.attr({ - href: t.vl, - 'data-ajax': 'false' - }); - } else { - view_link = view_link.attr({ - href: HordeMobile.createUrl('nag-taskform-view', params) - }); - } - view_link = view_link.addClass('nag-task'); - - toggle_link = $(''); - if (!!t.cl) { - toggle_link = toggle_link.attr({ - href: t.cl, - 'data-ajax': 'false' - }); - } else { - toggle_link = toggle_link.attr({ - href: HordeMobile.createUrl('nag-toggle', params) - }); - } - - item = $('
  • ').jqmData('icon', t.cp ? 'check' : 'nag-unchecked') - .append( - view_link - .append( - $('

    ').text(t.n) - ).append( - $('

    ').addClass('ui-li-aside') - .text(t.dd) - ).append( - $('

    ').text((t.de ? t.de : '')) - ) - ).append( - toggle_link - ); - item.jqmData('task_id', t.id); - item.jqmData('tasklist', t.l); - NagMobile.styleTask(item, t); - l.append(item); - }, - - /** - * Handler for pageBeforeChange event - * - * @param object e The event object. - * @param object data The data object. - */ - toPage: function(e, data) - { - switch (data.options.parsedUrl.view) { - case 'nag-list': - NagMobile.toList(data); - e.preventDefault(); - break; - - case 'nag-taskform-view': - if (data.options.parsedUrl.params.task_id) { - NagMobile.getTask(data); - } else { - HordeMobile.changePage('nag-taskform-view', data); - $('#nag-taskform-view .smartmobile-title').text(Nag.strings.newTask); - } - e.preventDefault(); - break; - - case 'nag-lists': - NagMobile.toLists(data); - e.preventDefault(); - break; - - case 'nag-toggle': - NagMobile.toggleComplete(data); - e.preventDefault(); - break; - } - }, - - /** - * Add the appropriate CSS classes to the task element based on the task's - * completion, due date etc... - * - * @param object l The tasks's LI element. - * @param object t The task hash. - */ - styleTask: function(l, t) - { - var task_due = Date.parse(t.dd), - task_overdue = task_due ? (task_due.compareTo(new Date()) < 0 ? true : false) : false; - - if (!t.cp) { - l.removeClass('closed'); - if (!task_overdue) { - l.removeClass('overdue'); - } else { - l.addClass('overdue'); - } - } else { - l.addClass('closed'); - l.removeClass('overdue'); - } - }, - - /** - * Prepare the nag-taskform-view for entering a new task. - */ - prepareFormForNew: function() - { - $('#nag-task-form')[0].reset(); - - // Must explicitly call refresh when the selectedIndex changes - // programmatically or the UI won't reflect the new value. - try { - $("#task_priority").selectmenu("refresh"); - } catch(e) {} - $('#nag-task-form #tasklist').val(''); - $('#nag-task-form #task_id').val(''); - $('#nag-taskform-view a[href^="#task-delete"]').hide(); - }, - - - handleSubmit: function(e) - { - var form = $('#nag-task-form'), - data = HordeJquery.formToObject(form); - - if (!data.hasOwnProperty('task_completed')) { - data.task_completed = 'off'; - } - HordeMobile.doAction('saveTask', data, NagMobile.handleSubmitCallback); - }, - - handleSubmitCallback: function(r) - { - if (!r.task) { - return; - } - - NagMobile.tasks[r.task.l][r.task.id] = r.task; - NagMobile.buildTaskList(); - HordeMobile.changePage('nag-list'); - }, - - handleCancel: function(e) - { - HordeMobile.changePage('nag-list'); - }, - - handleDelete: function(e) - { - var taskid = $('#nag-taskform-view #task_id').val(), - tasklist = $('#nag-taskform-view #tasklist').val(); - if (taskid && tasklist) { - HordeMobile.doAction('deleteTask', { - 'task_id': taskid, - 'tasklist': tasklist, - }, - NagMobile.handleDeleteCallback - ); - } - }, - - handleDeleteCallback: function(r) - { - if (!r.l) { - return; - } - - if (r.deleted) { - delete NagMobile.tasks[r.l][r.deleted]; - } - NagMobile.buildTaskList(); - HordeMobile.changePage('nag-list'); - }, - - onDocumentReady: function() - { - $(document).bind('pagebeforechange', NagMobile.toPage); - - // Capture task completed clicks to add the current LI element to - // the page change data. - $('#nag-list :jqmData(role="listview")').on('click', 'li', function(e) { - var a = $(e.target).closest('a[href^="#nag-toggle"]'); - if (a.length) { - $.mobile.changePage(a.attr('href'), { data: $(e.currentTarget) }); - return false; - } - }); - - // Capture new task clicks. - $('#nag-list :jqmData(role="footer") a[href^="#nag-taskform-view"]').on('click', NagMobile.prepareFormForNew); - $('#nag-taskform-view a[href^="#task-submit"]').on('click', NagMobile.handleSubmit); - $('#nag-taskform-view a[href^="#task-cancel"]').on('click', NagMobile.handleCancel); - $('#nag-taskform-view a[href^="#task-delete"]').on('click', NagMobile.handleDelete); - - NagMobile.tasklists = Nag.tasklists; - NagMobile.tasklists[undefined] = { 'name': Nag.strings.all }; - } - -}; - -$(NagMobile.onDocumentReady); diff --git a/lib/Ajax/Application/Handler/Smartmobile.php b/lib/Ajax/Application/Handler/Smartmobile.php deleted file mode 100644 index c2de0a16..00000000 --- a/lib/Ajax/Application/Handler/Smartmobile.php +++ /dev/null @@ -1,209 +0,0 @@ - - * @category Horde - * @license http://www.horde.org/licenses/gpl GPL - * @package Nag - */ -class Nag_Ajax_Application_Handler_Smartmobile extends Horde_Core_Ajax_Application_Handler -{ - /** - * AJAX action: Toggle the completed flag. - * - * Variables used: - * - task: TODO - * - tasklist: TODO - * - * @return array TODO - */ - public function smartmobileToggle() - { - $out = new stdClass(); - - if (!isset($this->vars->task) || !isset($this->vars->tasklist)) { - $out->error = 'missing parameters'; - } else { - $nag_task = new Nag_CompleteTask(); - $out = (object) $nag_task->result($this->vars->task, $this->vars->tasklist); - } - - return $out; - } - - public function getTaskLists() - { - $lists = Nag::listTasklists(); - $results = []; - foreach ($lists as $name => $list) { - $tasklist = new Nag_Tasklist($list); - $results[$name] = $tasklist->toHash(); - } - $return = new stdClass(); - $return->tasklists = $results; - - return $return; - } - - /** - * AJAX action: Return a task list. - * - * @return stdClass An object containing a tasklist in the tasks property. - */ - public function listTasks() - { - $options = ['include_history' => false]; - if ($this->vars->tasklist) { - $options['tasklists'] = [$this->vars->tasklist]; - } - - $tasks = Nag::listTasks($options); - $list = []; - $tasks->reset(); - while ($task = $tasks->each()) { - $list[] = $task->toJson(true); - } - $results = new stdClass(); - $results->tasks = $list; - - return $results; - } - - public function deleteTask() - { - if (!$this->vars->task_id) { - $GLOBALS['notification']->push(_("Missing required task id"), 'horde.error'); - return $results; - } - if (!$this->vars->tasklist) { - $GLOBALS['notification']->push(_("Missing required task list"), 'horde.error'); - return $results; - } - - $results = new stdClass(); - $storage = $GLOBALS['injector'] - ->getInstance('Nag_Factory_Driver') - ->create($this->vars->tasklist); - try { - $task = $storage->get($this->vars->task_id); - } catch (Nag_Exception $e) { - $GLOBALS['notification']->push($e); - return $results; - } - try { - $share = $GLOBALS['nag_shares']->getShare($task->tasklist); - } catch (Horde_Share_Exception $e) { - $GLOBALS['notification']->push($e); - return $results; - } - if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) { - $GLOBALS['notification']->push(_("You are not allowed to delete this task."), 'horde.error'); - return $results; - } - try { - $storage->delete($this->vars->task_id); - } catch (Nag_Exception $e) { - $GLOBALS['notification']->push($e); - return $results; - } - $GLOBALS['notification']->push(_("Successfully deleted"), 'horde.success'); - $results->deleted = $this->vars->task_id; - $results->l = $this->vars->tasklist; - return $results; - } - - public function saveTask() - { - $results = new stdClass(); - $task = [ - 'name' => $this->vars->task_title, - 'desc' => $this->vars->task_desc, - 'assignee' => $this->vars->task_assignee, - 'priority' => $this->vars->task_priority, - 'owner' => $GLOBALS['registry']->getAuth(), - ]; - - if ($this->vars->task_private) { - $task['private'] = true; - } - - if ($this->vars->task_start) { - $date = new Horde_Date($this->vars->task_start); - $task['start'] = $date->timestamp(); - } - - if ($this->vars->task_due) { - $date = new Horde_Date($this->vars->task_due); - $task['due'] = $date->timestamp(); - } - - if ($this->vars->task_estimate) { - $task['estimate'] = $this->vars->task_estimate; - } - - if ($this->vars->task_completed) { - $task['completed'] = $this->vars->task_completed == 'on' ? true : false; - } - - if ($this->vars->tasklist) { - $tasklist = $this->vars->tasklist; - } else { - $tasklist = $GLOBALS['prefs']->getValue('default_tasklist'); - } - try { - $storage = $GLOBALS['injector'] - ->getInstance('Nag_Factory_Driver') - ->create($tasklist); - } catch (Nag_Exception $e) { - $GLOBALS['notification']->push($e); - return $results; - } - - if ($this->vars->task_id) { - // Existing task - try { - $existing_task = $storage->get($this->vars->task_id); - $existing_task->merge($task); - $existing_task->save(); - $results->task = $existing_task->toJson(true); - } catch (Nag_Exception $e) { - $GLOBALS['notification']->push($e); - return $results; - } catch (Horde_Exception_NotFound $e) { - $GLOBALS['notification']->push($e); - return $results; - } - } else { - try { - $ids = $storage->add($task); - $results->task = $storage->get($ids[0])->toJson(true); - } catch (Nag_Exception $e) { - $GLOBALS['notification']->push($e); - return $results; - } - } - - $GLOBALS['notification']->push(sprintf(_("Saved %s"), $task['name']), 'horde.success'); - return $results; - } - - public function getTask() - { - $out = new StdClass(); - if (!isset($this->vars->task) || !isset($this->vars->tasklist)) { - $out->error = 'Missing Parameters'; - } else { - $task = Nag::getTask($this->vars->tasklist, $this->vars->task); - $out->task = $task->toJson(true); - } - - return $out; - } -} diff --git a/lib/Application.php b/lib/Application.php index dbcbb7eb..e2d88f21 100644 --- a/lib/Application.php +++ b/lib/Application.php @@ -39,7 +39,7 @@ class Nag_Application extends Horde_Registry_Application /** */ public $features = [ - 'smartmobileView' => true, + 'smartmobileView' => true, // Redirect to responsive UI 'modseq' => true, ]; diff --git a/lib/Smartmobile.php b/lib/Smartmobile.php deleted file mode 100644 index 700bde25..00000000 --- a/lib/Smartmobile.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @category Horde - * @license http://www.horde.org/licenses/gpl GPL - * @package Nag - */ -class Nag_Smartmobile -{ - /** - * @var Horde_Variables - */ - public $vars; - - /** - * @var Horde_View - */ - public $view; - - /** - */ - public function __construct(Horde_Variables $vars) - { - global $notification, $page_output; - - $this->vars = $vars; - - $this->view = new Horde_View([ - 'templatePath' => NAG_TEMPLATES . '/smartmobile', - ]); - $this->view->addHelper('Horde_Core_Smartmobile_View_Helper'); - $this->view->addHelper('Text'); - - $this->_initPages(); - $this->_addBaseVars(); - - $datejs = str_replace('_', '-', $GLOBALS['language']) . '.js'; - if (!file_exists($GLOBALS['registry']->get('jsfs', 'horde') . '/date/' . $datejs)) { - $datejs = 'en-US.js'; - } - $page_output->addScriptFile('date/' . $datejs, 'horde'); - $page_output->addScriptFile('date/date.js', 'horde'); - $page_output->addScriptFile('horde-jquery.js', 'horde'); - - $page_output->addScriptFile('smartmobile.js'); - - $notification->notify(['listeners' => 'status']); - } - - /** - */ - public function render() - { - echo $this->view->render('main'); - echo $this->view->render('taskform'); - echo $this->view->render('lists'); - } - - /** - */ - protected function _initPages() {} - - /** - * Add base javascript variables to the page. - */ - protected function _addBaseVars() - { - global $page_output, $prefs; - - // Nag::VIEW_* constant - switch ($prefs->getValue('show_completed')) { - case Nag::VIEW_INCOMPLETE: - $show_completed = 'incomplete'; - break; - - case Nag::VIEW_ALL: - $show_completed = 'all'; - break; - - case Nag::VIEW_COMPLETE: - $show_completed = 'complete'; - break; - - case Nag::VIEW_FUTURE: - $show_completed = 'future'; - break; - - case Nag::VIEW_FUTURE_INCOMPLETE: - $show_completed = 'future-incomplete'; - break; - } - - // Tasklists. Needed in case we deep link to an existing list. - $lists = Nag::listTasklists(); - $tasklists = []; - foreach ($lists as $name => $list) { - $task = new Nag_Tasklist($list); - $tasklists[$name] = $task->toHash(); - } - - $code = [ - 'conf' => [ - 'showCompleted' => $show_completed, - 'icons' => [ - 'completed' => strval(Horde_Themes::img('checked.png')), - 'uncompleted' => strval(Horde_Themes::img('unchecked.png')), - 'smartlist' => strval(Horde_Themes::img('smart.png')), - 'tasklist' => strval(Horde_Themes::img('tasklists.png')), - ], - ], - 'strings' => [ - 'all' => _("All Tasks"), - 'newTask' => _("New Task"), - ], - 'tasklists' => $tasklists, - ]; - - $page_output->addInlineJsVars([ - 'var Nag' => $code, - ], ['top' => true]); - } - -} diff --git a/smartmobile.php b/smartmobile.php deleted file mode 100644 index 67cfb446..00000000 --- a/smartmobile.php +++ /dev/null @@ -1,26 +0,0 @@ -getInstance('Horde_Variables')); - -$page_output->header(array( - 'title' => _("My Tasks"), - 'view' => $registry::VIEW_SMARTMOBILE -)); - -$ob->render(); -$page_output->footer(); \ No newline at end of file diff --git a/templates/smartmobile/lists.html.php b/templates/smartmobile/lists.html.php deleted file mode 100644 index 01d1cc06..00000000 --- a/templates/smartmobile/lists.html.php +++ /dev/null @@ -1,7 +0,0 @@ -

    - smartmobileHeader(['logout' => true, 'portal' => true, 'title' => _("Lists")]) ?> - -
    -
      -
      -
      diff --git a/templates/smartmobile/main.html.php b/templates/smartmobile/main.html.php deleted file mode 100644 index b3f560bf..00000000 --- a/templates/smartmobile/main.html.php +++ /dev/null @@ -1,17 +0,0 @@ -
      - diff --git a/templates/smartmobile/taskform.html.php b/templates/smartmobile/taskform.html.php deleted file mode 100644 index cb2aaa49..00000000 --- a/templates/smartmobile/taskform.html.php +++ /dev/null @@ -1,67 +0,0 @@ -
      - smartmobileHeader(['backlink' => true, 'logout' => true, 'title' => _("My Tasks")]) ?> -
      -
      - - - -
      - - -
      - -
      - - -
      - -
      - - -
      - -
      - - -
      - -
      - - -
      - -
      - - -
      - -
      - - -
      - -
      - - -
      - -
      - - -
      - - -
      - - - -
      -
      -
      -
      \ No newline at end of file