Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-9437

lib/listlib.php

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.9
    • None
    • Libraries, Questions
    • None
    • Tested on php 4 and 5.
    • Any
    • MOODLE_19_STABLE

    Description

      I've created a couple of new classes for displaying and editing a nested list of items.

      listlib itself is now only 606 lines of code. Does it belong in lib/listlib.php or in weblib.php??

      Classes handle functionality for :

      • Can construct a list by instantiating a list object and manually adding options to it.
      • Or you can construct a nested list from db records with some key pointing to a parent id.
      • Display of list with or without editing icons (move left / up / down / right) with optional pagination.
      • Reordering of items works across pages.
      • Processing of editing actions on list.

      The patch attached shows the class in use in question/category.php for editing the hierarchy of question categories.

      It seems to make sense to have code for nested lists like this abstracted. At some stage we might add support for drag and drop of list items and for collapsible lists. Lists could be used in other places in code for example for course categories, menus and other areas.

      Attachments

        1. category.html
          24 kB
        2. moodle-HEAD.patch
          32 kB
        3. questioncategories.gif
          questioncategories.gif
          17 kB

        Activity

          People

            dougiamas Martin Dougiamas
            jamiesensei Jamie Pratt
            Nobody Nobody
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona), Tim Hunt, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: