| 1 |
********************************************************************
|
| 2 |
D R U P A L M O D U L E
|
| 3 |
********************************************************************
|
| 4 |
Name: uLink module
|
| 5 |
Author: Gartheeban Ganeshapillai
|
| 6 |
AKA garthee at drupal <garthee at gmail dot com>
|
| 7 |
Dependencies: filter.module, comment.module(optional), tokens.module(optional)
|
| 8 |
Required by: uAuto.module, ulink_gallery.module, ulink_imagecache.module
|
| 9 |
|
| 10 |
********************************************************************
|
| 11 |
IMPORTANT
|
| 12 |
|
| 13 |
Users are encouraged to read at least Default implementation
|
| 14 |
section {7} of this guide before using the module.
|
| 15 |
|
| 16 |
********************************************************************
|
| 17 |
DESCRIPTION:
|
| 18 |
|
| 19 |
The uLink module provides universal filtering {1} which allows you to
|
| 20 |
define tags like [l|link_to_node|text_to_appear|attributes] and replace
|
| 21 |
them with appropriate html code {2}, user defined text or code, or
|
| 22 |
third party rendered code or text {3} to provide links, display images,
|
| 23 |
fill with text or all.
|
| 24 |
|
| 25 |
This module defines the protocol and giving the framework to generate
|
| 26 |
the outputs, which can be configured or extended through the settings page {4}
|
| 27 |
and by implementing the hooks [1]. Hence, More than one module may be giving
|
| 28 |
the rendering, in case, they can optionally be enabled, cascaded or
|
| 29 |
optionally added {5}.
|
| 30 |
|
| 31 |
The module comes with basic, but powerful default implementation {6}
|
| 32 |
and two other supporting modules ulink_gallery [2]- which provides
|
| 33 |
image gallery like feature and ulink_imagecache [3]- which provides
|
| 34 |
imagecache like feature. They also give good demonstration on how uLink
|
| 35 |
could be extended to match different filtering needs.
|
| 36 |
|
| 37 |
********************************************************************
|
| 38 |
DETAILED DESCRIPTION:
|
| 39 |
|
| 40 |
{1} universal filtering
|
| 41 |
--------------------------------------------------------------------
|
| 42 |
The main objective of the module is to provide universal filtering
|
| 43 |
which is independent of the objectives of the user i.e. expected output
|
| 44 |
text or code, limitations and expectations of the site administrator
|
| 45 |
and target (of the link) type. However filtering is dependent on the
|
| 46 |
tag ie [l|link_to_node|text_to_appear|attributes] though.
|
| 47 |
|
| 48 |
Through the powerful and complex settings {4} available in the under
|
| 49 |
administrative settings rendering can be configured individually for
|
| 50 |
different target types {7}. Alternatively, specific rendering can be
|
| 51 |
given by implementing hooks. Please refer to the developer documentation
|
| 52 |
for details.
|
| 53 |
|
| 54 |
{2} HTML code
|
| 55 |
--------------------------------------------------------------------
|
| 56 |
[l|link_to_node|text_to_appear|attributes] will be replaced by module
|
| 57 |
implementations output. This eliminates having to type html tags and
|
| 58 |
allows uniform way of entering links.
|
| 59 |
|
| 60 |
{3} Third party rendered code
|
| 61 |
--------------------------------------------------------------------
|
| 62 |
uLink module provides the skeleton for other modules to implement and
|
| 63 |
extend the functions. Other modules can implement the hooks [1] and
|
| 64 |
provide different outputs. ulink_gallery and ulink_imagecache are
|
| 65 |
two perfect examples.
|
| 66 |
|
| 67 |
{4} settings page
|
| 68 |
--------------------------------------------------------------------
|
| 69 |
Available under
|
| 70 |
Admin > Settings > ulink >
|
| 71 |
(admin/settings/ulink/files)
|
| 72 |
|
| 73 |
Settings page allows user to choose the modules implementing
|
| 74 |
hooks ie enable them and modify the order of cascading the output {5}
|
| 75 |
individually for all the types {7} supported. Through these setting pages,
|
| 76 |
other modules implementing the modules will display module specific
|
| 77 |
settings. For example ulink_gallery provides settings related to its
|
| 78 |
implementation in this page.
|
| 79 |
|
| 80 |
{5} Multiple implementations
|
| 81 |
--------------------------------------------------------------------
|
| 82 |
There may be more than one module implementing, a particular type.
|
| 83 |
For example, with the default distribution users have ulink and
|
| 84 |
ulink_gallery providing rendering for files type. In the settings page
|
| 85 |
there are three options (Disabled, Cascade the module's rendering to
|
| 86 |
the output, Cascade only if the previous output is empty) and weight.
|
| 87 |
|
| 88 |
+ Disabled: Dont use this modules rendering
|
| 89 |
+ Cascade the module's rendering to the output: Cascade the outputs
|
| 90 |
in the order given by the weight. For example if both ulink and
|
| 91 |
ulink_gallery are selected with this option where ulink is with
|
| 92 |
weight = -2 and ulink_gallery is with weight = 3, output will
|
| 93 |
be of ulinks output followed by ulink_gallerys output.
|
| 94 |
+ Cascade only if the previous output is empty: This output will
|
| 95 |
be used only when all other modules with higher priority as
|
| 96 |
determined by the weight options return null. For example,
|
| 97 |
if ulink (weight = -2) is selected with option2 and ulink_gallery (weight = 3)
|
| 98 |
is selected with option3 ulink_gallerys output will be selected
|
| 99 |
only if ulinks output is null.
|
| 100 |
|
| 101 |
As explained above, multiple renderings can be enabled, cascaded and optionally added.
|
| 102 |
|
| 103 |
{6} Default implementation
|
| 104 |
--------------------------------------------------------------------
|
| 105 |
Although this module is meant to provide only the framework for universal
|
| 106 |
filtering, it provides a powerful default implementation as follows.
|
| 107 |
|
| 108 |
Except for image type, it gives three different type of rendering
|
| 109 |
1. Hardcoded user cant modify the html output, however he can
|
| 110 |
choose what should come for the text when user fails to enter
|
| 111 |
anything for text (eg [l|node/2]) through configure option.
|
| 112 |
2. Macro substitution (Tokens) When token module is available
|
| 113 |
uLink is making use of it, by allowing users to use tokens for
|
| 114 |
the following. Here user can use tokens to insert additional
|
| 115 |
information like node-title, user-name. Detailed help on available
|
| 116 |
token is available in settings page.
|
| 117 |
a. Use this when text is empty: the text part to be added when
|
| 118 |
user fails to enter anything for text.
|
| 119 |
b. Token tag to be rendered:
|
| 120 |
The output; together with tokens and html code user have
|
| 121 |
the full control over the output.
|
| 122 |
c. Token tag to be rendered if the object is not available:
|
| 123 |
The output when the target is local (node, user, comment,
|
| 124 |
local file or local image) and it does not exist ie broken link;
|
| 125 |
together with tokens and html code user have full control
|
| 126 |
over the output.
|
| 127 |
3. PHP code user has the fullest control over the output. Detailed
|
| 128 |
help on available php variables is available in settings page.
|
| 129 |
User returns the output using return tag.
|
| 130 |
Eg: return l($text." ( ".$object->subject." )", $path, $link["attributes"]);
|
| 131 |
|
| 132 |
For image type user can choose the following outputs: Only image, Only link, Image and link
|
| 133 |
|
| 134 |
In addition, users can use macros to avoid typing similar attributes repeatedly.
|
| 135 |
Macros can be added under general settings
|
| 136 |
|
| 137 |
Admin > Settings > ulink > General settings
|
| 138 |
(admin/settings/ulink)
|
| 139 |
|
| 140 |
Here macros are entered in the following format
|
| 141 |
( "name_of_macroA" => "attribute1=value,attribute2=value",
|
| 142 |
"name_of_macroB" => "attribute3=value,attribute4=value",..)
|
| 143 |
|
| 144 |
For example,
|
| 145 |
("imagelist"=>"class=imagelist", "photos"=>"width=200,height=100")
|
| 146 |
|
| 147 |
Then in the tag it can be called easily by specifying the macro name in the following format
|
| 148 |
[l-name_of_macro1|link_to_node|text_to_appear|attributes]
|
| 149 |
|
| 150 |
For example,
|
| 151 |
[l-photos|files/image.png|my wedding photo]
|
| 152 |
which is equivalent to
|
| 153 |
[l|files/image.png|my wedding photo|width=200,height=100]
|
| 154 |
|
| 155 |
{7} Types supported
|
| 156 |
--------------------------------------------------------------------
|
| 157 |
The following target types are supported:
|
| 158 |
node, user, comments, images (local), files (local), images (external)
|
| 159 |
and files(images).
|
| 160 |
|
| 161 |
External References
|
| 162 |
--------------------------------------------------------------------
|
| 163 |
[1] Implementing uLink hooks
|
| 164 |
Developer_documentation_ulink.txt
|
| 165 |
[2] Readme of ulink_gallery module
|
| 166 |
Readme.txt
|
| 167 |
[3] Readme of ulink_imagecache module
|
| 168 |
Readme.txt
|
| 169 |
|
| 170 |
********************************************************************
|
| 171 |
SYSTEM REQUIREMENTS
|
| 172 |
|
| 173 |
Drupal 5.x
|
| 174 |
PHP 5.0.0 or greater
|
| 175 |
Filter.module installed
|
| 176 |
|
| 177 |
********************************************************************
|
| 178 |
USAGE:
|
| 179 |
|
| 180 |
[l|link] or
|
| 181 |
[l|link|text] or
|
| 182 |
[l|link|text|attributes] or
|
| 183 |
[l|link||attributes] or
|
| 184 |
[l-macro|link|text] or
|
| 185 |
[l-macro|link] or
|
| 186 |
|
| 187 |
|
| 188 |
Link can be specified in three ways
|
| 189 |
1. External links - by using complete absolute url
|
| 190 |
eg: http://www.drupal.org/project/ulink
|
| 191 |
2. Internal drupal supported links or files - by using drupal
|
| 192 |
recognizable url
|
| 193 |
eg: node/12, node/3#comment-1, user/2, files/drupal.png
|
| 194 |
3. Interal non drupal links - by starting the u
|
| 195 |
eg: /files/drupal.png, /sites/default/temp.txt
|
| 196 |
|
| 197 |
If internal drupal link is specified and, link is not found
|
| 198 |
under default implementation tags specified broken links will
|
| 199 |
be rendered.
|
| 200 |
|
| 201 |
Text can be anything user wanted to display in the link, however
|
| 202 |
for images by default this will be used for title
|
| 203 |
|
| 204 |
Attributes are additional parameters to modify the rendering,
|
| 205 |
for example, image type can be given class=image or width=120.
|
| 206 |
eg: [l|/files/myphoto.jpg|my photo|width=200,height=300]
|
| 207 |
It can also contain information to rendering modules
|
| 208 |
+ forcelink=true, is used to link the image instead of displaying it.
|
| 209 |
+ filter=images, is used to set filter in ulink_gallery
|
| 210 |
+ filter=image_extension_in_regular_expressions, is used to add parse extensions
|
| 211 |
in ulink_gallery
|
| 212 |
+ preset=preset-name, is used to get imagecache preset in ulink_imagecache
|
| 213 |
**refer to the modules' README.txt for module specific attributes.
|
| 214 |
|
| 215 |
|
| 216 |
*********
|
| 217 |
EXAMPLES:
|
| 218 |
|
| 219 |
when ulink_imagecache is enabled for image type and for other types ulink's
|
| 220 |
default implementation is used.
|
| 221 |
|
| 222 |
[l|files/CCNA.rtf|text]
|
| 223 |
[l|files/CCNA.rtf|text|title=title]
|
| 224 |
[l|http://localhost/drupal/files/The_10_90_Rule.pdf|external file|title=hello]
|
| 225 |
|
| 226 |
[l|node/6]
|
| 227 |
[l|node/6|text|title=title]
|
| 228 |
[l|node/60|text]
|
| 229 |
[l|story/node|text]
|
| 230 |
|
| 231 |
[l|node/4#comment-2|text]
|
| 232 |
[l|node/4#comment-2]
|
| 233 |
|
| 234 |
[l|files/collage.jpg]
|
| 235 |
[l|files/02.jpg|text]
|
| 236 |
[l|files/02.jpg|text|title=title]
|
| 237 |
[l|files/02.jpg|text|width=400]
|
| 238 |
|
| 239 |
|
| 240 |
********************************************************************
|
| 241 |
CREDITS:
|
| 242 |
|
| 243 |
- Basic ideas are taken from inline.module, token.module, reptag.module and imagecache.module
|
| 244 |
- Thanks to Google for sponsoring this project through GSOC 2007
|
| 245 |
- Thanks to Drupal community, Daniel DeGeest and Kaustubh Srikanth for seleting
|
| 246 |
this module for GSOC
|
| 247 |
- Thanks to Daniel DeGeest AKA dldege at drupal, for providing an excellent support,
|
| 248 |
suggestion, ideas and mentoring the project. He was there for the whole
|
| 249 |
duration of the project for the assistance. Also initially
|
| 250 |
ulink_imagecache and ulink_gallery were written by him.
|
| 251 |
|
| 252 |
********************************************************************
|
| 253 |
BUGS AND SUGGESTIONS
|
| 254 |
|
| 255 |
Please report all bug reports at:
|
| 256 |
http://drupal.org/project/issues/ulink
|
| 257 |
|
| 258 |
Contact me at:
|
| 259 |
garthee at theebgar dot net
|
| 260 |
|
| 261 |
|
| 262 |
Demos at:
|
| 263 |
http://www.project.theebgar.net
|
| 264 |
http://mwt.argz.com/ulink/tests
|
| 265 |
|
| 266 |
|
| 267 |
|