midcom_helper_metadataThis class is an interface to the metadata of MidCOM objects. It is not to be instantinated directly, as a cache is in place to avoide duplicate metadata objects for the same Midgard Object. So, basically, each of these object is a singelton.
It will use an internal mechanism to cache repeated accesses to the same metadata key during its lifetime. (Invalidating this cache will be possible though.)
All metadata is identified by their string-based keys, the original MIDCOM_META_* constants are mapped to these new keys. This has been done to allow for easier extension.
Metadata Key Reference
See also the schema in /midcom/config/metadata_default.dat
- <?php
- $nap = new midcom_helper_nav();
- $node = $nap->get_node($nap->get_current_node());
- $meta =& midcom_helper_metadata::retrieve($node[MIDCOM_NAV_GUID]);
- echo "Visible : " . $meta->is_visible() . "</br>";
- echo "Approved : " . $meta->is_approved() . "</br>";
- echo "Keywords: " . $meta->get('keywords') . "</br>";
- ?>
Example Usage, Approval
- <?php
- $article = mgd_get_article($my_article_created_id);
- $meta =& midcom_helper_metadata::retrieve($article);
- $article->approve();
- ?>
Located in /midcom/helper/metadata.php (line 70)
MidgardObject
$object
= null (line 78)
Object to which we are attached to. This object can be accessed from the outside, where neccessary.
Array
$_cache
= array() (line 86)
Holds the values alread read from the database.
midcom_helper_datamanager
$_datamanager
= null (line 102)
Datamanager instance for the given object.
Array
$_schemadb
= null (line 94)
The schema database to use for this instance.
This will construct a new metadata object for an existing content object.
You must never use this constructor directly, it is considered private in this respect. Instead, use the get method, which may be called as a class method.
You may use objects derived from any MidgardObject will do as well as long as the parameter call is available normally.
Approves the object.
This sets the approved timestamp to the current time and the approver person GUID to the GUID of the person currently authenticated.
This function will return a single metadata key from the object. Its return type depends on the metadata key that is requested (see the class introduction).
You will not get the data from the datamanager using this calls, but the only slightly post-processed metadata values. See _retrieve_value for post processing.
Return a Datamanager instance for the current object.
This is returned by reference, which must be honored, as usual.
Also, whenever the containing datamanager stores its data, you must call the on_update() method of this class. This is very important or backwards compatibility will be broken.
Checks wether the article has been approved since its last editing.
This is a helper function which indicates wether a given object may be shown onsite taking approval, scheduling and visibility settings into account. The important point here is that it also checks the global configuration defaults, so that this is basically the same base on which NAP decides wether to show an item or not.
Checks the object's visibility regarding scheduling and the hide flag.
This does not check approval, use is_approved for that.
Loads the datamanager for this instance. This will patch the schema in case we are dealing with an article.
This is the update event handler for the Metadata system. It must be called whenever metadata changes to synchronize the various backwards-compatibility values in place throughout the system.
Returns a metadata object for a given content object.
You may bass any one of the following arguments to the function:
Directly set a metadata option.
The passed value will be stored using the follow transformations:
Unapproves the object.
This resets the approved timestamp and sets the approver person GUID to the GUID of the person currently authenticated.
Retrieves a given metadata key, postprocesses it where neccessary and stores it into the local cache.
Documentation generated on Mon, 21 Nov 2005 18:18:32 +0100 by phpDocumentor 1.3.0RC3