class Lnk
This is a system of portable, extensible link management.
The system is based around the "link specification", which is a string.
Link specifications should be stored in a TEXT field.
These specs relate to classes which extend LinkSpec.
The class name needs to start with "LinkSpec" too. Functions
Name | Visibility | Description |
atag | public (static) | Return an opening A tag for a link specification. |
editform | public (static) | Output html for editing link specifications. |
editformNeeds | public (static) | Some edit forms require additional javascript via the needs helper |
instance | private (static) | For a given link specification, instance it's class |
tryUrl | public (static) | Attempts to convert a link specification into a URL |
typename | public (static) | Output the name of the type of the linkspec. |
url | public (static) | Convert a link specification into a URL. |
valid | public (static) | Check if the data supplied for a spec is valid. |
string Lnk::atag ( string $spec , array $attributes );
Return an opening A tag for a link specification. string Lnk::editform ( string $field_name [, string $curr_spec [, bool $required ]] );
Output html for editing link specifications.
This is designed for admin use. void Lnk::editformNeeds ( );
Some edit forms require additional javascript via the needs helper
Load in all of these requirements for all LinkSpec classes array Lnk::instance ( string $spec );
For a given link specification, instance it's class string|null Lnk::tryUrl ( string $spec );
Attempts to convert a link specification into a URL
This differs in behaviour to `Lnk::url` as it will return null if the spec is
empty, but *not* malformed; it still throws an InvalidArgumentException in that case.
It will also return null if a RowMissingException is thrown by the link spec instance
during processing.
Helpful when you wish to avoid breaking pages when someone deletes the linked record, e.g. a blog post,
without updating the corresponding link(s). string Lnk::typename ( string $spec );
Output the name of the type of the linkspec. public urlstring Lnk::url ( string $spec );
Convert a link specification into a URL. bool Lnk::valid ( string $spec );
Check if the data supplied for a spec is valid.
|