From 0714f41b6369d54ead29daf6c05f3ccd45ac4598 Mon Sep 17 00:00:00 2001
From: Ralf Becker
Date: Mon, 6 Aug 2007 13:52:17 +0000
Subject: [PATCH] docu update for link widget from
aleksander.adamowski-AT-olo.org.pl
---
etemplate/doc/reference.html | 51 ++++++++++++++++++++++---
etemplate/inc/class.link_widget.inc.php | 13 ++++---
2 files changed, 53 insertions(+), 11 deletions(-)
diff --git a/etemplate/doc/reference.html b/etemplate/doc/reference.html
index 7622e86b27..18f73ea97f 100644
--- a/etemplate/doc/reference.html
+++ b/etemplate/doc/reference.html
@@ -390,7 +390,7 @@ implement only a subset of XUL. Here are the main differences:
3. if set URLs in the content get activated
4. name of form-element the label is for: gives focus to that element if the label gets clicked
5. target for the link, eg. _blank
- 6. widthxheight if a popup should be used for the link, eg. 600x400
+ 6. widthxheight if a popup should be used for the link, eg. 600x400
7. titlextitle for the link
@@ -954,17 +954,56 @@ function index($content = 0)
no |
link-to link-list link-string |
- These widget are the UI-part of the link-class ({bo|so}link) in InfoLog and maybe the API soon.
- link-to
- Widget to make a links to other entries of link-aware apps and to attach files.
+ These widgets are the UI-part of the link-class ({bo|so}link) in the API.
+ eGroupWare has a linking system that lets you link two records from different apps together.
+ For example, you can link the addressbook entry of the person you're meeting with to the meeting on your calendar,
+ or an infolog entry for the phone call you made to postpone the meeting.
+ To display links in your own application, you should use the LinkList group of widgets.
link-list
Widget to shows the links to an entry and a Unlink Button for each link.
+ It needs an array with two entries. If you name the LinkList widget 'links', you need:
+
+$data['links']['to_app'] = 'myapp';
+$data['links']['to_id'] = $record_id;
+
+ This will display links where the $record_id record of myapp is one side of the link.
+ Make sure that both variables are properly defined before the form template gets executed.
+ link-to
+ Widget to make a links to other entries of link-aware apps and to attach files.
Note: Both Widgets can be used on the same template with the same name. They share
- the content of that variable, which contains just the id of the entry in the current app.
+ the content of the variable with that name, which contains just the id of the entry in the current app.
link-string
Comma-separated list of link-titles with a link to its view-method, value is like the return
- of bolink::get_links().
+ of bolink::get_links().
+
+ Before you can use a link to your application, you need to specify some information in a 'search_link' hook.
+ In your setup.inc.php, you need to point $setup_info['myapp']['hooks']['search_link'] to a function that will return an array:
+ return array(
+'query' => 'myapp.bo_myapp.link_query',
+ // A function that takes a search string
+ // and returns a list of matching records
+'title' => 'myapp.bo_myapp.link_title',
+ // A function that takes an id from one side
+ // of a link and returns a string for that entry
+'view' => array('menuaction'=>'myapp.ui_myapp.link_view'),
+ // Function to view a link, may be an existing view function
+'view_id' => 'link_id',
+ // name of the id variable provided to the view function above
+'add' => array('menuaction' => 'myapp.ui_myapp.new_entry'),
+ // Function to add a new entry
+);
+
+ Also, make sure that the declared methods are implemented and methods from the UI class are listed in its $public_methods attribute:
+
+class ui_myapp {
+ var $public_methods = array(
+ 'view' => true,
+ 'add' => true
+ );
+...
+}
+
|
diff --git a/etemplate/inc/class.link_widget.inc.php b/etemplate/inc/class.link_widget.inc.php
index 917c2af043..6cbd16f0d2 100644
--- a/etemplate/inc/class.link_widget.inc.php
+++ b/etemplate/inc/class.link_widget.inc.php
@@ -13,20 +13,23 @@
* eTemplate Extension: several widgets as user-interface for the link-class
*
* All widgets use the link-registry, to "know" which apps use popups (and what size).
+ * Participating apps need to register a proper "search_link" hook - see eTemplate-reference (LinkWidgets) for info.
* If run in a popup and the app uses no popups, a target will be set, to open a new full decorated window.
*
* The class contains the following widgets:
* - link: Show a link to one linked entry specified by an array with keys app, id and optional title and help-message
* - link-to: Widget to create links to an other entries of link-aware apps
- * If an id was set, this widgets creats the links without further interaction with the calling code.
+ * If the variables $data['widget_id']['to_app'] = $app and $data['widget_id']['to_id'] = $entry_id
+ * are set, this widget creates the links without further interaction with the calling code.
* If the entry does not yet exist, the widget returns an array with the new links in the id. After the
- * entry was successful create, bolink::link($app,$new_id,$arr) has to be called to create the links!
- * - link-list: Widget to shows the links to an entry in a table with an unlink icon for each link
+ * entry was successfuly created, bolink::link($app,$new_id,$arr) has to be called to create the links!
+ * - link-list: Widget to show the links to an entry in a table with an unlink icon for each link. Needs the same
+ * pair of variables as link-to widget and needs to have the same id, as the data is shared with link-to.
* - link-string: comma-separated list of link-titles with a link to its view method, value is like get_links()
* or array with keys to_app and to_id (widget calls then get_links itself)
* - link-add: Add a new entry of the select app, which is already linked to a given entry
* - link-entry: Allow to select an entry of a selectable or in options specified app
- * - link-apps: Select an app registerd in the link system, options: '' or 'add'
+ * - link-apps: Select an app registered in the link system, options: '' or 'add'
*
*
* $content[$name] = array(
@@ -43,7 +46,7 @@
* );
*
*
- * This widget is independent of the UI as it only uses etemplate-widgets and has therefor no render-function.
+ * This widget is independent of the UI as it only uses etemplate-widgets and has therefore no render-function.
*
* @package etemplate
* @subpackage extensions