[commits] [Wiki] changed: Doc/Dev/HordeAjaxApplications

Ralf Lang (B1 Systems GmbH) lang at b1-systems.de
Tue Jul 23 16:10:55 UTC 2013


rlang  Tue, 23 Jul 2013 16:10:54 +0000

Modified page: http://wiki.horde.org/Doc/Dev/HordeAjaxApplications
New Revision:  3
Change log:  better syntax for headings

@@ -1,19 +1,17 @@
-
  Documentation of Horde Ajax Applications mostly from poking around  
existing examples.

-== Convention ==
-Conventions:
++ Convention
  $app (lowercase, for example "passwd")
  $App (First Uppercase, for example "Passwd")


-== Javascript libraries used ==
++ Javascript libraries used

  JavaScript for "Dynamic" and "traditional" mode uses prototype.js
  JavaScript for "SmartMobile" mode uses query-mobile.js

-=== using jquery alongside prototype ===
+++ using jquery alongside prototype
  This is generally not accepted upstream.
  jQuery can be made coexist with dynamic/traditional mode's prototype.js

  For non-upstream custom code:
@@ -24,11 +22,11 @@
  /* Do jquery stuff here. $.* is prototype, $j.* is jQuery. Some  
plugins may not like this, but DataTables, JQuery UI and mainstream  
stuff work */
  );
  </code>

-== Files and Classes of a Horde Ajax Application ==
++ Files and Classes of a Horde Ajax Application

-=== Horde_Ajax_Application class ===
+++ Horde_Ajax_Application class
  Bare Minimum for a Horde Ajax Application (on top of a skeleton  
Horde_Registry_Application):
  A File $app/lib/Ajax/Application.php with a class
  <code>
  <?php
@@ -47,9 +45,10 @@
  parseEmailAddress
  chunkContent (process and return a template part from  
$app/templates/chunks/$chunk.php)
  setPrefValue

-=== AppCore.js file ===
+
+++ AppCore.js file

  Most apps which sport completely distinct dynamic and traditional  
views (kronolith, hermes) also have $app/js/$app.js including a Class  
$AppCore
  In Imp, the class name is
  <code>
@@ -59,17 +58,17 @@
  document.observe('dom:loaded', $AppCore.onDomLoad.bind(AppCore));
  // more observers as needed
  </code>

-=== View Selection ===
+++ View Selection

  Common, but not strictly required:

  Logic in $app/index.php to decide if traditional, ajax or other  
modes should be loaded. gollem does not have this.

  TODO: Example

-== Horde Ajax Request Service ==
+++ Horde Ajax Request Service
  The Horde Base App provides a common receiver for ajax requests by  
Ajax_Applications.
  It only works for AUTHENTICATED user requests.

  Fails silently for malformed requests and unauthenticated users
@@ -107,9 +106,9 @@
   */
  </code>


-== What is an imple? ==
+++ What is an imple?
  An Imple inherits from Horde_Core_Ajax_Imple and implements php code  
tied to a javascript request
  (how is this related to a services/ajax call?)

  Horde_Core ships some imple's, apps define theirs in  
$app/lib/Ajax/Imple/Foo.php
@@ -123,9 +122,9 @@
  </code>

  Imple methods:
  (Not much documentation available. Maybe we find a good example)
-
+<code>
   /**
       * Attach the object to a javascript event.
       */
      abstract public function attach();
@@ -135,9 +134,9 @@
       *
       * @param array $args  TODO
       */
      abstract public function handle($args, $post);
-
+</code>

  Example:

  ''This example is probably not the way they do it today as I read it  
some time ago from a very dated 2/2012 git checkout''
@@ -146,23 +145,23 @@
  The attach() method is implemented as noop.
  The handle() method takes some arguments and returns a processed  
js/html snippet

  Kronolith users should paste a snippet like this into their website  
to use the calendar widget:
-
+<code>
  <div id="kronolithCal"></div><script  
src="/services/ajax.php/kronolith/embed?token=c_T1Vso1zfaSOMEMAGICHERENHKWmg1&calendar=internal_70fhZCYOURSISDIFFERENTRWNDA&container=kronolithCal&view=month"  
type="text/javascript"></script>
-
+</code>
  So this finally calls services/ajax.php , starts/authenticates  
(HOW?) the kronolith app, passes the "embed" action and the URL  
parameters to Kronolith_Ajax_Application which runs doAction();
  (How does doAction trigger the imple?)


-== $App_Ajax_Application_Handler ==
+++ $App_Ajax_Application_Handler
  A Handler inherits from Horde_Core_Ajax_Application_Handler and can  
manage external/public (unauthenticated??) calls
  extends Horde_Core_Ajax_Application_Handler

  Seems like the difference between Horde 5 and Horde 4 is that each  
action has its own Handler class rather than a methods in the  
$App_Ajax_Application class?


-== Horde_Controllers ==
++ Horde_Controllers

  Horde Controllers seem to be somewhat independent from the stuff  
described above
  Controllers need Horde_Routes and need rewrite rules

@@ -199,8 +198,10 @@
      }
  }
  ?>
  </code>
+
+

  A Horde Controller based app needs a config/routes.php file.

  For example
@@ -221,13 +222,14 @@
  The endpoint script is horde/rampage.php  - rampage.php currently  
seems to handle only authenticated calls.

  The controller is passed the request (in this case, a json request)  
and handles it (with a json answer in this case)

-== Client side js infrastructure ==
++ Client side js infrastructure

  TODO

-== The big picture ==
++ The big picture

  * When do I use a service/ajax.php handler as opposed to a  
rampage.php Controller ?
  * Imples seem to be used to return snippets?
+




More information about the commits mailing list