Class ::xowiki::PageInstance (public)
::xo::db::CrClass ::xowiki::PageInstance
Defined in
- Testcases:
-
No testcase defined.
Source code:
namespace eval ::xowiki {}
::nsf::object::alloc ::xo::db::CrClass ::xowiki::PageInstance {set :__default_metaclass ::xotcl::Class
set :__default_superclass ::xotcl::Object
set :abstract_p f
set :auto_save false
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 {}}}}
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}
set :edit_form ::xowiki::PageInstanceEditForm
set :folder_id -100
set :form ::xowiki::PageInstanceForm
set :id_column page_instance_id
array set :long_text_slots {instance_attributes ::xowiki::PageInstance::slot::instance_attributes}
set :mime_type text/plain
set :name_method {}
set :non_cached_instance_var_patterns __*
set :object_type ::xowiki::PageInstance
set :object_type_key 00000000000011110001100100000010
set :pretty_name #xowiki.PageInstance_pretty_name#
set :pretty_plural #xowiki.PageInstance_pretty_plural#
set :security_inherit_p t
set :sql_package_name ::xowiki::PageInstance
set :storage_type text
set :supertype content_revision
set :table_name xowiki_page_instance
set :with_table true}
::xowiki::PageInstance proc get_list_from_form_constraints {-name -form_constraints} {
set spec [::xowiki::PageInstance get_short_spec_from_form_constraints -name $name -form_constraints $form_constraints]
set result [list]
foreach spec [split $spec ,] {
if {[regexp {^([^=]+)=(.*)$} $spec _ attr value]} {
lappend result $attr $value
} else {
:log "can't parse $spec in attribute and value; ignoring"
}
}
return $result
}
::xowiki::PageInstance proc get_short_spec_from_form_constraints {-name -form_constraints} {
set varname ::__xo_[ns_md5 $form_constraints]
set dict ""
if {![nsv_get parsed_fcs $varname dict]} {
foreach name_and_spec $form_constraints {
set p [string first : $name_and_spec]
if {$p > -1} {
dict set dict [string range $name_and_spec 0 $p-1] [string range $name_and_spec $p+1 end]
} else {
ad_log warning "get_short_spec_from_form_constraints: name_and_spec <$name_and_spec> is invalid"
}
}
nsv_set parsed_fcs $varname $dict
}
if {[dict exists $dict $name]} {
return [dict get $dict $name]
}
return ""
}
::xowiki::PageInstance instproc www-use-template {} {
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
}
::${:package_id} returnredirect [ad_return_url]
}
::xowiki::PageInstance instproc get_short_spec {{-form_constraints ""} name} {
if {$form_constraints eq ""} {
set form_constraints [:get_form_constraints]
}
if {$form_constraints ne ""} {
set s [::xowiki::PageInstance get_short_spec_from_form_constraints -name $name -form_constraints $form_constraints]
return $s
}
return ""
}
::xowiki::PageInstance instproc render_content {} {
set html [:get_html_from_content [:get_from_template text]]
set html [:adp_subst $html]
if {$html eq "" && [:is_folder_page]} {
ad_log_deprecated "folder page without a content" "[:item_id] '${:name}'"
set html [:include child-resources]
}
return "<div class='[${:page_template} css_class_name -margin_form false]'>[:substitute_markup $html]</div>"
}
::xowiki::PageInstance instproc get_form_constraints {{-trylocal false}} {
return ""
}
::xowiki::PageInstance instproc get_field_label {name value} {
set short_spec [:get_short_spec $name]
if {$short_spec ne ""} {
set f [::xowiki::formfield::FormField new -volatile -name $name -spec $short_spec]
if {![$f exists show_raw_value]} {
set value [$f field_value $value]
}
}
return $value
}
::xowiki::PageInstance instproc field_names_from_form_constraints {} {
set form_constraints [:get_form_constraints]
set result {}
foreach name_and_spec $form_constraints {
regexp {^([^:]+):} $name_and_spec _ name
if {[string range $name 0 0] eq "@"} {
continue
}
lappend result $name
}
return $result
}
::xowiki::PageInstance instproc get_field_type {name default_spec} {
set spec [:widget_spec_from_folder_object $name [${:page_template} set name]]
if {$spec ne ""} {
return $spec
}
set f [:create_raw_form_field -name $name -slot [:find_slot $name]]
if {$f ne ""} {
return [$f asWidgetSpec]
}
return $default_spec
}
::xowiki::PageInstance instproc demarshall args {
if {![info exists :anon_instances]} {
set :anon_instances "f"
}
next
}
::xowiki::PageInstance instproc count_usages {{-package_id 0} {-parent_id:integer 0} {-publish_status ready}} {
return [::xowiki::PageTemplate count_usages -package_id $package_id -parent_id $parent_id -item_id ${:item_id} -publish_status $publish_status]
}
::xowiki::PageInstance instproc get_template_object {} {
set id ${:page_template}
if {![nsf::is object ::$id]} {
::xo::db::CrClass get_instance_from_db -item_id $id
}
return ::$id
}
::xowiki::PageInstance instproc widget_spec_from_folder_object {name given_template_name} {
foreach {s widget_spec} [::${:package_id} get_parameter -check_query_parameter false WidgetSpecs] {
lassign [split $s ,] template_name var_name
if {([string match $template_name $given_template_name] || $given_template_name eq "") &&
[string match $var_name $name]} {
return $widget_spec
}
}
return ""
}
::xowiki::PageInstance instproc get_form {} {
return [:get_html_from_content [:get_from_template form]]
}
::xowiki::PageInstance instproc update {} {
::xo::dc transaction {
next
:instvar object_id page_template instance_attributes
::xo::dc dml update_xowiki_page_instance {update xowiki_page_instance
set page_template = :page_template,instance_attributes = :instance_attributes where page_instance_id = :object_id
}
}
}
::xowiki::PageInstance instproc create_raw_form_field {-name {-slot ""} {-spec ""} {-configuration ""} {-omit_field_name_spec:boolean false} {-nls_language ""} {-form_constraints ""}} {
if { $omit_field_name_spec} {
set short_spec ""
} else {
set short_spec [:get_short_spec -form_constraints $form_constraints $name]
}
set spec_list [list]
if {$spec ne ""} {lappend spec_list $spec}
if {$short_spec ne ""} {lappend spec_list $short_spec}
set f [next -name $name -slot $slot -spec [join $spec_list ,] -configuration $configuration -nls_language $nls_language ]
return $f
}
::xowiki::PageInstance instproc adp_subst content {
set __ia [dict merge [:template_vars $content] ${:instance_attributes}]
foreach var [dict keys $__ia] {
if {[string match "richtext*" [:get_field_type $var text]]} {
set value [lindex [dict get $__ia $var] 0]
} else {
set value [dict get $__ia $var]
}
if {$value eq "" && [info exists :$var]} continue
set :$var [:get_field_label $var $value]
}
next
}
::xowiki::PageInstance instproc get_from_template {var {default {}}} {
set form_obj [:get_template_object]
if {[$form_obj istype ::xowiki::PageInstance]} {
return [$form_obj property $var $default]
}
if {[$form_obj exists $var]} {
return [$form_obj set $var]
}
if {[:istype ::xowiki::FormPage] && [:exists_property $var]} {
return [:property $var]
}
return $default
}
::xowiki::PageInstance instproc template_vars content {
set result [list]
foreach {_ _ v} [regexp -inline -all [template::adp_variable_regexp] $content] {
lappend result $v ""
}
return $result
}
::xowiki::PageInstance instparametercmd page_template
::xowiki::PageInstance instparametercmd instance_attributes
::xowiki::PageInstance instparametercmd mime_type
::xowiki::PageInstance instparametercmd page_instance_id
::nsf::relation::set ::xowiki::PageInstance superclass ::xowiki::Page
::nx::slotObj -container slot ::xowiki::PageInstance
::nsf::object::alloc ::xo::db::Attribute ::xowiki::PageInstance::slot::page_instance_id {set :accessor public
set :column_name page_instance_id
set :configurable true
set :convert false
set :create_acs_attribute false
set :create_table_attribute true
set :datatype integer
set :defaultmethods {}
set :disposition alias
set :domain ::xowiki::PageInstance
set :incremental false
set :manager ::xowiki::PageInstance::slot::page_instance_id
set :max_n_values 1
set :methodname page_instance_id
set :min_n_values 1
set :multiplicity 1..1
set :name page_instance_id
set :parameterSpec -page_instance_id
set :per-object false
set :position 0
set :pretty_name ID
set :pretty_plural {}
set :references {}
set :required false
set :sqltype integer
set :trace none
: init}
::nsf::object::alloc ::xotcl::Attribute ::xowiki::PageInstance::slot::mime_type {set :accessor public
set :configurable true
set :convert false
set :default text/plain
set :defaultmethods {}
set :disposition alias
set :domain ::xowiki::PageInstance
set :incremental false
set :manager ::xowiki::PageInstance::slot::mime_type
set :methodname mime_type
set :multiplicity 1..1
set :name mime_type
set :per-object false
set :position 0
set :required false
set :substdefault 0b111
set :trace none
: init}
::nsf::object::alloc ::xo::db::CrAttribute ::xowiki::PageInstance::slot::instance_attributes {set :accessor public
set :column_name instance_attributes
set :configurable true
set :convert false
set :create_acs_attribute true
set :create_table_attribute true
set :datatype text
set :default {}
set :defaultmethods {}
set :disposition alias
set :domain ::xowiki::PageInstance
set :incremental false
set :manager ::xowiki::PageInstance::slot::instance_attributes
set :max_n_values 1
set :methodname instance_attributes
set :min_n_values 1
set :multiplicity 1..1
set :name instance_attributes
set :parameterSpec {-instance_attributes:substdefault {}}
set :per-object false
set :position 0
set :pretty_name #xowiki.PageInstance-instance_attributes#
set :pretty_plural {}
set :references {}
set :required false
set :sqltype long_text
set :substdefault 0b111
set :trace none
: init}
::nsf::object::alloc ::xo::db::CrAttribute ::xowiki::PageInstance::slot::page_template {set :accessor public
set :column_name page_template
set :configurable true
set :convert false
set :create_acs_attribute true
set :create_table_attribute true
set :datatype integer
set :defaultmethods {}
set :disposition alias
set :domain ::xowiki::PageInstance
set :incremental false
set :manager ::xowiki::PageInstance::slot::page_template
set :max_n_values 1
set :methodname page_template
set :min_n_values 1
set :multiplicity 1..1
set :name page_template
set :parameterSpec -page_template
set :per-object false
set :position 0
set :pretty_name #xowiki.PageInstance-page_template#
set :pretty_plural {}
set :references {cr_items(item_id) DEFERRABLE INITIALLY DEFERRED}
set :required false
set :sqltype integer
set :trace none
: init}
namespace eval ::xowiki {::namespace export Menu YUIMenuBar YUIMenuBarItem YUIMenu YUIMenuItem YUIMenuItemList YUIContextMenu YUIContextMenuItem}
XQL Not present:Generic, PostgreSQL, Oracle
[
hide source ]
| [
make this the default ]