There are three really important functions available to you within the WACS UI API which you really should get to know well. They will do a huge amount of legwork for you and are the easiest way to use the extensive content caching features built into WACS since release 0.9.1. Only iconlink existed in previous versions, and the other two thumblink and contentlink are new. In all cases these functions will automatically fall back to using the wacsimg, wacsthumb and wacszip methods if they can't do it smarter.
We're now going to take a look at WacsUI module's
most important function,
iconlink. It's job is simply
to display and icon with an appropriate link around it. Sounds simple
enough, doesn't it? Unfortunately it isn't - there's a lot of work that
needs to be done relating to permissions, access methods, checking caches
and resizing which actually makes it fairly complex. The good news is
iconlink function will do it all for you!
iconlink function takes quite a few arguments
which control how it works, but they are reasonably straightforward.
In most cases parameters are optional and sensible defaults will be
used instead if they are not given - obviously things like set number
and the location fields (
sarea, scategory and
sdirectory) are necessary.
Example 6.5. Using the
print $wacsui->iconlink( array( 'type'=>$setdetails, 'setno'=>$setdetails, 'sarea'=>$setdetails, 'scategory'=>$setdetails, 'sdirectory'=>$setdetails, 'model'=>$moddetails, 'resize'=> 0, 'silent'=> 'y' ))."\n";
The perl dialect is again very much the same:
print iconlink( type=>$setdetails, setno=>$setdetails, sarea=>$setdetails, scategory=>$setdetails, sdirectory=>$setdetails, model=>moddetails, resize=> 0, silent=> 'y' ))."\n";
thumblink function works very much the same
iconlink does and provides a way to produce thumbnail
images from a photoset or any of a number of additional icon images
(typically thumbnails from a movie) for a video clip. It is slightly
iconlink in that since the cache of
set thumbnails is organised by set number and not area, category, etc,
it needs on the set number, image number and type to function.
Example 6.6. Using the
print $wacsui->thumblink( array( 'setno'=>$setdetails, 'stype'=>$setdetails, 'imgno'=>$imgnumber, 'resize'=>1, 'silent'=>'y' ))."\n";
And of course using it in Perl is much the same:
print thumblink( setno=>$setdetails, stype=>$setdetails, imgno=>$imgnumber, resize=>1, silent=>'y' )."\n";
The final one of the three link functions, again joining the WACS
API reportoire in release 0.9.1, is
Once again this is similar to
thumblink in not needing
the full path within the collection as the cache mechanism it refers to is
organised by set number. As with the other two members of the link family,
it falls back gracefully to the old methods of content delivery if it cannot
find a cached version of the desired content, so you can and should use it
at all times for content link delivery.
As usual we specify both the set number and the set type, plus you
also have the option by using the
silent parameter as to
whether it should print out the link text it creates or merely return the
necessary text as the return variable from the function call. It's also
good practice to specify the desired name for the download file using the
archive parameter. Normally this name can simply be
taken from the sdownload field in the sets database.
If this variable is empty, it will default to
set1235.wmv as appropriate.
We do usually specify the
srank parameter too,
although it will function without it, to clarify the relationship of this
set to other things. The ext (for extension) is the file name extension
of this file - ie
.zip, .wmv, .mov and
. As shown in the example below, passing the
field from the database via the getvideoext function should
work right for videos.
The one rather odd parameter here is serve - this
specifies which type of file you would like on those occasions where there
is a choice. For some sets, the cache system holds both an original version
and a compilation or edited version comprising either the combination of a
number of seperate parts of a video clip, or a video clip with the leading
declarations trimmed so as not to disturb the viewing experience. In these
cases, if you want the compilation or edited version where are available,
you set serve to
cooked and where you
want the vanilla unaltered file you set serve to
Example 6.7. Using the
print $wacsui->contentlink( array( 'setno'=>$setdetails, 'stype'=>$setdetails, 'srank'=>$setdetails, 'ext'=> $wacsui->getvideoext( $setdetails ), 'serve'=>'cooked', 'archive'=>$setdetails, 'silent'=>'y' ))."\n";
As usual, the perl dialect version of this command is almost identical in how you call it:
print contentlink( setno=>$setdetails, stype=>$setdetails, srank=>$setdetails, ext=> getvideoext( $setdetails ), serve=>'cooked', archive=>$setdetails, silent=>'y' )."\n";
The content cache, unlike the icons or thumbnail caches, is NOT self-maintaining. You need to take actions to create the cached versions in the first place - please see the administration manual for more information about how to use wacscachectl to do this