- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xowiki::PageInstance
::xowiki::PageInstance create ...
Defined in
Class Relations
::xo::db::CrClass create ::xowiki::PageInstance \ -superclass ::xowiki::PageMethods (to be applied on instances)
get_from_template (scripted, public)
<instance of xowiki::PageInstance> get_from_template var \ [ default ]Get a property from the parent object (template). The parent object might by either an ::xowiki::Form or an ::xowiki::FormPage
- Parameters:
- var (required)
- default (optional)
- Returns:
- either the property value or a default value
- Testcases:
- create_form_with_form_instance
set form_obj [:get_template_object] #:msg "get $var from template form_obj=$form_obj [$form_obj info class]" # The resulting page should be either a Form (PageTemplate) or # a FormPage (PageInstance) # #:msg "parent of self ${:name} is [$form_obj name] type [$form_obj info class]" # # If it is as well a PageInstance, we find the information in the # properties of this page. Note that we cannot distinguish here between # intrinsic (starting with _) and extension variables, since get_from # template does not know about the logic with "_" (just "property" does). # if {[$form_obj istype ::xowiki::PageInstance]} { #:msg "returning property $var from parent formpage $form_obj => '[$form_obj property $var $default]'" return [$form_obj property $var $default] } # # .... otherwise, it should be an instance variable .... # if {[$form_obj exists $var]} { #:msg "returning parent instvar [$form_obj set $var]" return [$form_obj set $var] } # # .... or, we try to resolve it against a local property. # # This case is currently needed in the workflow case, where # e.g. anon_instances is tried to be fetched from the first form, # which might not contain it, if e.g. the first form is a plain # wiki page. # #:msg "resolve local property $var=>[:exists_property $var]" if {[:istype ::xowiki::FormPage] && [:exists_property $var]} { #:msg "returning local property [:property $var]" return [:property $var] } # # if everything fails, return the default. # #:msg "returning the default <$default>, parent is of type [$form_obj info class]" return $defaultwww-use-template (scripted, public)
<instance of xowiki::PageInstance> www-use-templateThis web-callable method can be used to change the "template" of a PageInstance. The caller provides the "form" as query parameter which should be used in future for handling the instance parameters of the PageInstance. This method can be as well be used for changing the associated workflow of a workflow instance.
- Testcases:
- No testcase defined.
set formName [:query_parameter "form" ""] if {$formName eq ""} { error "no form specified" } ::${:package_id} get_lang_and_name -default_lang [::xo::cc lang] -path $formName lang stripped_url set d [::${:package_id} item_ref -default_lang $lang -parent_id [::${:package_id} folder_id] $formName] set item_id [dict get $d item_id] if {$item_id == 0} { error "cannot lookup page $formName" } ::xo::db::CrClass get_instance_from_db -item_id $item_id if {![nsf::is object ::$item_id] || "::xowiki::PageTemplate" ni [::$item_id info precedence]} { error "OK $formName is not suited to be used as template. Should be a Form!" } if {${:page_template} == $item_id} { :msg "old page_template $item_id is already the same as the new one" } else { set msg "change template_id ${:page_template} to $item_id" :page_template $item_id :save #:msg "ok $msg" } ::${:package_id} returnredirect [ad_return_url]Variables
::xowiki::PageInstance set __default_metaclass ::xotcl::Class ::xowiki::PageInstance set __default_superclass ::xotcl::Object ::xowiki::PageInstance set abstract_p f ::xowiki::PageInstance set auto_save false ::xowiki::PageInstance array set db_constraints {page_template {{references \ {cr_items(item_id) DEFERRABLE INITIALLY DEFERRED}} {references \ {cr_items(item_id) DEFERRABLE INITIALLY DEFERRED}}} instance_attributes {{default {}} \ {default {}}}} ::xowiki::PageInstance array set db_slot \ {page_template ::xowiki::PageInstance::slot::page_template page_order \ ::xowiki::Page::slot::page_order creator ::xowiki::Page::slot::creator page_id \ ::xowiki::Page::slot::page_id creation_date ::xo::db::Object::slot::creation_date \ instance_attributes ::xowiki::PageInstance::slot::instance_attributes creation_user \ ::xo::db::Object::slot::creation_user object_id ::xo::db::Object::slot::object_id description \ ::xowiki::Page::slot::description text ::xowiki::Page::slot::text creation_ip \ ::xo::db::Object::slot::creation_ip package_id ::xo::db::Object::slot::package_id \ object_title ::xo::db::Object::slot::object_title nls_language \ ::xo::db::CrItem::slot::nls_language name ::xo::db::CrItem::slot::name mime_type \ ::xo::db::CrItem::slot::mime_type context_id ::xo::db::Object::slot::context_id \ security_inherit_p ::xo::db::Object::slot::security_inherit_p title \ ::xowiki::Page::slot::title revision_id ::xo::db::CrItem::slot::revision_id item_id \ ::xo::db::CrItem::slot::item_id last_modified ::xo::db::Object::slot::last_modified \ modifying_user ::xo::db::Object::slot::modifying_user publish_date \ ::xowiki::Page::slot::publish_date page_instance_id \ ::xowiki::PageInstance::slot::page_instance_id modifying_ip \ ::xo::db::Object::slot::modifying_ip} ::xowiki::PageInstance set edit_form ::xowiki::PageInstanceEditForm ::xowiki::PageInstance set folder_id -100 ::xowiki::PageInstance set form ::xowiki::PageInstanceForm ::xowiki::PageInstance set id_column page_instance_id ::xowiki::PageInstance array set long_text_slots \ {instance_attributes ::xowiki::PageInstance::slot::instance_attributes} ::xowiki::PageInstance set mime_type text/plain ::xowiki::PageInstance set name_method {} ::xowiki::PageInstance set non_cached_instance_var_patterns __* ::xowiki::PageInstance set object_type ::xowiki::PageInstance ::xowiki::PageInstance set object_type_key 00000000000011110001100100000010 ::xowiki::PageInstance set pretty_name {#xowiki.PageInstance_pretty_name#} ::xowiki::PageInstance set pretty_plural {#xowiki.PageInstance_pretty_plural#} ::xowiki::PageInstance set security_inherit_p t ::xowiki::PageInstance set sql_package_name ::xowiki::PageInstance ::xowiki::PageInstance set storage_type text ::xowiki::PageInstance set supertype content_revision ::xowiki::PageInstance set table_name xowiki_page_instance ::xowiki::PageInstance set with_table true
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables