Class ::xowiki::includelet::yui-carousel (public)
::xowiki::IncludeletClass ::xowiki::includelet::yui-carousel
Defined in /var/www/openacs.org/packages/xowiki/tcl/includelet-procs.tcl
Include YUI carousel showing the pages of the specified or current folder.
- Testcases:
- No testcase defined.
Source code: namespace eval ::xowiki::includelet {} ::nsf::object::alloc ::xowiki::IncludeletClass ::xowiki::includelet::yui-carousel {set :__default_metaclass ::xotcl::Class set :__default_superclass ::xotcl::Object set :aggregating false set :cacheable false set :localized true set :personalized true} ::xowiki::includelet::yui-carousel instproc render {} { :get_parameters set ajaxhelper 1 ::xowiki::Includelet require_YUI_CSS -ajaxhelper $ajaxhelper carousel/assets/skins/sam/carousel.css ::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper "yahoo-dom-event/yahoo-dom-event.js" ::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper "connection/connection-min.js" ::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper "animation/animation-min.js" ::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper "element/element-min.js" ::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper "carousel/carousel-min.js" ::xo::Page set_property body class "yui-skin-sam " if {![regexp {^(.*)x(.*)$} $item_size _ item_width item_height]} { error "invalid item size '$item_size'; use e.g. 300x240" } if {[info exists image_size]} { if {![regexp {^(.*)x(.*)$} $image_size _ width height]} { error "invalid image size '$image_size'; use e.g. 300x240" } } elseif {$auto_size} { set width $item_width set height $item_height } else { set width "" set height "" } set ID container_[::xowiki::Includelet html_id [self]] set play_interval [expr {int($play_interval * 1000)}] ::xo::Page requireJS [subst { YAHOO.util.Event.onDOMReady(function (ev) { var carousel = new YAHOO.widget.Carousel("$ID",{ isCircular: true, numVisible: $num_visible, autoPlayInterval: $play_interval, animation: {speed: 1.0} }); carousel.render(); // get ready for rendering the widget carousel.show(); // display the widget }); }] ::xo::Page requireStyle [subst { \#$ID { margin: 0 auto; } .yui-carousel-element .yui-carousel-item-selected { opacity: 1; } .yui-carousel-element li { height: ${item_height}px; width: ${item_width}px; } .yui-skin-sam .yui-carousel-nav ul li { margin: 0; }}] set parent_id [${:__including_page} parent_id] if {[info exists folder]} { set folder_page [::$package_id get_page_from_item_ref -parent_id $parent_id $folder] if {$folder_page eq ""} { error "no such folder '$folder'" } else { set parent_id [$folder_page item_id] } } set content "<div id='[ns_quotehtml $ID]'><ol>\n" if {$form ne ""} { set images [:form_images -package_id $package_id -parent_id $parent_id -form $form -glob $glob -width $width -height $height] } else { set images [:images -package_id $package_id -parent_id $parent_id -glob $glob -width $width -height $height] } foreach entry [$images children] { append content "<li class='item'> [$entry set html] </li>\n" } append content "</ol></div>\n<div id='spotlight'></div>\n" #if {$title eq ""} {set title $url} return $content } ::xowiki::includelet::yui-carousel instproc form_images {-package_id -parent_id {-form "en:photo.form"} {-glob ""} {-width ""} {-height ""}} { set form_item_ids [::$package_id instantiate_forms -parent_id $parent_id -forms $form] if {$form_item_ids eq ""} {error "could not find en:photo.form"} set form_item_id [lindex $form_item_ids 0] set items [::xowiki::FormPage get_form_entries -base_item_ids $form_item_ids -form_fields "" -publish_status all -always_queried_attributes * -parent_id $parent_id -package_id $package_id] #:msg "parent-id=$parent_id, glob=$glob entries=[llength [$items children]]" foreach entry [$items children] { # order? set image_name [$entry property image] if {$glob ne "" && ![string match $glob $image_name]} { $items delete $entry continue } if {![info exists entry_field_names]} { set entry_field_names [$entry field_names] set entry_form_fields [::xowiki::FormPage get_table_form_fields -base_item $form_item_id -field_names $entry_field_names -form_constraints [::$form_item_id set form_constraints]] foreach fn $entry_field_names f $entry_form_fields {set ff($fn) $f} } $entry load_values_into_form_fields $entry_form_fields foreach f $entry_form_fields {$f object $entry} if {[info exists ff(image)]} { if {$width ne ""} {$ff(image) width $width} if {$height ne ""} {$ff(image) height $height} if {$width ne "" && $height ne ""} { $ff(image) set geometry "${width}x${height}" } $ff(image) label [$entry property _title] } $entry set html [$entry render_content] #:log html=[$entry set html] } return $items } ::xowiki::includelet::yui-carousel instproc images {-package_id -parent_id {-glob ""} {-width ""} {-height ""}} { set size_info "" if {$width ne ""} {append size_info " width='[ns_quotehtml $width]'"} if {$height ne ""} {append size_info " height='[ns_quotehtml $height]'"} if {$width ne "" && $height ne ""} { set geometry "?geometry=${width}x${height}" } else { set geometry "" } set listing [::xowiki::Includelet listing -package_id $package_id -parent_id $parent_id -use_package_path false -extra_where_clause " and mime_type like 'image/%'" -orderby "name asc" -glob $glob] #:msg "parent-id=$parent_id, glob=$glob entries=[llength [$listing children]]" foreach entry [$listing children] { $entry class ::xowiki::Page $entry set html "<img src='[$entry pretty_link -download true]$geometry' $size_info> <h2>[$entry title]</h2>" } return $listing } ::xowiki::includelet::yui-carousel instparametercmd parameter_declaration ::nsf::relation::set ::xowiki::includelet::yui-carousel superclass ::xowiki::Includelet ::nx::slotObj -container slot ::xowiki::includelet::yui-carousel ::xowiki::includelet::yui-carousel::slot eval {set :__parameter { {parameter_declaration { {-title ""} {-item_size 600x400} {-image_size} {-num_visible 1} {-play_interval 0} {-auto_size 0} {-folder} {-glob ""} {-form ""} }} }} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::includelet::yui-carousel::slot::parameter_declaration {set :accessor public set :configurable true set :convert false set :default { {-title ""} {-item_size 600x400} {-image_size} {-num_visible 1} {-play_interval 0} {-auto_size 0} {-folder} {-glob ""} {-form ""} } set :defaultmethods {} set :disposition alias set :domain ::xowiki::includelet::yui-carousel set :incremental 0 set :manager ::xowiki::includelet::yui-carousel::slot::parameter_declaration set :methodname parameter_declaration set :multiplicity 1..1 set :name parameter_declaration set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init}XQL Not present: Generic, PostgreSQL, Oracle