Ferreteria/v0.5/dropin: Difference between revisions

From Woozle Writes Code
Jump to navigation Jump to search
No edit summary
No edit summary
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
A '''dropin''' is a collection of code-files which can be included in a [[Ferreteria]] project by simply being "dropped in" to the appropriate folder (as designated by the local configuration). Each dropin must have an index file which tells Ferreteria what classes, actions, files, etc. are involved.
A '''dropin''' is a collection of code-files which can be included in a [[Ferreteria]] project by simply being "dropped in" to the appropriate folder (as designated by the local configuration). Each dropin must have an index file which tells Ferreteria what classes, actions, files, etc. are involved.
==Files/Classses==
* {{l/ferreteria/code|base/dropin.php}} for dropin-specific loading
** <code>csDropinManager</code>: the Dropin Manager
** <code>cDropIndex</code>: encapsulates a single Dropin Index file
*** {{l/ver|registry/feature|Feature-object registration}} happens in <code>cDropIndex->RegisterMenuBits()</code>, where the Feature'saction list is pulled from <code>$arSect['actions']</code>.
*** Feature-spec registration takes place... somewhere. Currently tracking that down (2022-06-04).
* {{l/ferreteria/code|loader/ClassLoader.php}} (see {{l/ver|ClassLoader}}) for generic class registration
==Process==
==Process==
===loading/display===
 
* <code>(ctDropInManager)</code> looks through each subfolder within the dropins folder.
===loading===
* For each folder found, <code>(ctDropInManager)->CheckFolder()</code> checks for an index file.
* The Dropin Manager looks through each subfolder within the dropins folder.
* For each folder found, <code>csDropInManager::CheckFolder()</code> checks for an index file.
* If the index file is found, it creates a <code>crcDropIndex</code> object and calls <code>(crcDropIndex)->ProcessIndex()</code>
* If the index file is found, it creates a <code>crcDropIndex</code> object and calls <code>(crcDropIndex)->ProcessIndex()</code>
* <code>->ProcessIndex()</code> loads the <code>$arDropin</code> data into a <code>crcDropIndex</code> object, which more or less encapsulates it.
* <code>->ProcessIndex()</code>
** loads the <code>$arDropin</code> data into a <code>crcDropIndex</code> object, which more or less encapsulates it.
** calls <code>->RegisterClasses()</code>, which processes the Dropin array's 'classes' subarray
** calls <code>->RegisterMenuBits()</code>, which processes the Dropin array's 'actions' subarray
===display===
* The '''Navbar''' shows only Features that the current user has permission to access.
** <code>cMenuFolder</code> ({{l/ferreteria/code|tree/nav/MenuFolder.php}}) manages the display of each Dropin and its Features.
* The '''Software Feature''' in the Basics dropin displays a list of all available Modules and Dropins.
 
===URL interpretation===
===URL interpretation===
* in fcArrayLink:
Understanding how this works requires understanding how we end up processing the Dropin code, which requires understanding the {{l/ver|startup}} process.
 
''documentation in progress''
 
* in <code>cArrayLink</code>( {{l/ferreteria/code|tree/items/ArrayLink.php}}):
** GetLinkURL() calls GetLinkArray()
** GetLinkURL() calls GetLinkArray()
** GetLinkArray() calls GetLinkArray_figured()
** GetLinkArray() calls GetLinkArray_figured()
** GetLinkArray_figured() calls cDropinLink&rarr;GetLinkArray_self()
** GetLinkArray_figured() calls cDropinLink&rarr;GetLinkArray_self()
* in cDropinLink:
* in cDropinLink {{l/ferreteria/code|tree/menu/DropinLink.php}}):
** The internal events (evint) system is used for passing Render requests (using a <code>cRender</code> event object) down to the appropriate Feature, which returns content via the passed event object.
** OnEventAfter() calls PageEvent(); Render() calls AddPageRendering();  
** OnEventAfter() calls PageEvent(); Render() calls AddPageRendering();  
** PageEvent(), AddPageRendering(), and GetLinkArray_self() each call MakeActionObject() to get the table or record to act on.
** PageEvent(), AddPageRendering(), and GetLinkArray_self() each call MakeActionObject() to get the table or record to act on.
** MakeActionObject() looks up a record or table object from the URL, and returns the result.
** InvokeFeature() parses the URL for a Feature spec, and returns the corresponding Feature object.
*** It's also supposed to pass the rest of the URI data on to the Feature object, but I don't know if this has been implemented here, or at all, as of 2022-05-25.
 
==Classes==
==Classes==
===loading/display===
===loading/display===
These classes make heavy use of the {{l/same|ClassLoader}} system.
These classes make heavy use of the {{l/same|ClassLoader}} system.
* '''csDropinManager''': static class which runs the whole process; analogous (but not related) to '''csLoader'''
* '''csDropinManager''': static class which runs the whole process; analogous (but not related) to '''csLoader'''
* '''cDropIndex''': manages index to dropin library; descends from '''caLibrary'''
* '''cDropIndex''' manages the Dropin library's index file (typically index.dropin.php); descends from '''caLibrary'''
** '''cDropinLink''' displays the Feature link, if the user has permission to access it
 
===URL interpretation===
===URL interpretation===
* '''cDropinLink'''
* '''cDropinLink'''
Line 39: Line 65:
** '''actions''': array of items to appear within the section
** '''actions''': array of items to appear within the section
*** '''array[{{arg|item key}}]''': indexed array of information for a single actionable item
*** '''array[{{arg|item key}}]''': indexed array of information for a single actionable item
**** '''class''': name of action class to invoke
**** <s>'''class''': name of action class to invoke</s>
**** '''feature''': slug for Feature class (singleton object) (replaces "class")
**** '''text''': text to display in section listing
**** '''text''': text to display in section listing
**** '''summary''': one-line description of item (used for hover-over text but may appear in other places)
**** '''summary''': one-line description of item (used for hover-over text but may appear in other places)

Latest revision as of 14:22, 17 June 2022

A dropin is a collection of code-files which can be included in a Ferreteria project by simply being "dropped in" to the appropriate folder (as designated by the local configuration). Each dropin must have an index file which tells Ferreteria what classes, actions, files, etc. are involved.

Files/Classses

  • base/dropin.php for dropin-specific loading
    • csDropinManager: the Dropin Manager
    • cDropIndex: encapsulates a single Dropin Index file
      • Feature-object registration happens in cDropIndex->RegisterMenuBits(), where the Feature'saction list is pulled from $arSect['actions'].
      • Feature-spec registration takes place... somewhere. Currently tracking that down (2022-06-04).
  • loader/ClassLoader.php (see ClassLoader) for generic class registration

Process

loading

  • The Dropin Manager looks through each subfolder within the dropins folder.
  • For each folder found, csDropInManager::CheckFolder() checks for an index file.
  • If the index file is found, it creates a crcDropIndex object and calls (crcDropIndex)->ProcessIndex()
  • ->ProcessIndex()
    • loads the $arDropin data into a crcDropIndex object, which more or less encapsulates it.
    • calls ->RegisterClasses(), which processes the Dropin array's 'classes' subarray
    • calls ->RegisterMenuBits(), which processes the Dropin array's 'actions' subarray

display

  • The Navbar shows only Features that the current user has permission to access.
  • The Software Feature in the Basics dropin displays a list of all available Modules and Dropins.

URL interpretation

Understanding how this works requires understanding how we end up processing the Dropin code, which requires understanding the startup process.

documentation in progress

  • in cArrayLink( tree/items/ArrayLink.php):
    • GetLinkURL() calls GetLinkArray()
    • GetLinkArray() calls GetLinkArray_figured()
    • GetLinkArray_figured() calls cDropinLink→GetLinkArray_self()
  • in cDropinLink tree/menu/DropinLink.php):
    • The internal events (evint) system is used for passing Render requests (using a cRender event object) down to the appropriate Feature, which returns content via the passed event object.
    • OnEventAfter() calls PageEvent(); Render() calls AddPageRendering();
    • PageEvent(), AddPageRendering(), and GetLinkArray_self() each call MakeActionObject() to get the table or record to act on.
    • InvokeFeature() parses the URL for a Feature spec, and returns the corresponding Feature object.
      • It's also supposed to pass the rest of the URI data on to the Feature object, but I don't know if this has been implemented here, or at all, as of 2022-05-25.

Classes

loading/display

These classes make heavy use of the ClassLoader system.

  • csDropinManager: static class which runs the whole process; analogous (but not related) to csLoader
  • cDropIndex manages the Dropin library's index file (typically index.dropin.php); descends from caLibrary
    • cDropinLink displays the Feature link, if the user has permission to access it

URL interpretation

  • cDropinLink
    • cDropinAction
  • value\cDropin

Index File

By convention, the index file is named index.dropin.php; this name can be changed via the global settings object. The index file's primary task is to define the $arDropin array, with the following elements:

  • name: the name of the dropin
  • descr: one-line description
  • version: version number
  • date: release date, in YYYY-MM-DD format
  • URL: full URL to documentation
  • db.spec: name of class for database spec (must descend from cDatabaseSpec)
    • If omitted, uses the site's default db spec.
    • if NULL, Tabloid class is constructed without a db.
  • section: array which defines how the dropin will be listed in the dropins bar
    • title: what to display at the top of the section
    • popup: (optional) text to appear when mouse hovers over the dropin name
    • actions: array of items to appear within the section
      • array[<item key>]: indexed array of information for a single actionable item
        • class: name of action class to invoke
        • feature: slug for Feature class (singleton object) (replaces "class")
        • text: text to display in section listing
        • summary: one-line description of item (used for hover-over text but may appear in other places)
        • perms: permits required in order to invoke this item. If user lacks permission, item will not be displayed.
  • classes: array of files and the classes they contain
    • array[<relative filespec>]: collection array of classes available in the given code-file