]> git.openstreetmap.org Git - chef.git/commitdiff
Merge remote-tracking branch 'github/pull/183'
authorTom Hughes <tom@compton.nu>
Sat, 15 Sep 2018 13:29:52 +0000 (14:29 +0100)
committerTom Hughes <tom@compton.nu>
Sat, 15 Sep 2018 13:29:52 +0000 (14:29 +0100)
125 files changed:
Gemfile.lock
cookbooks/apt/recipes/default.rb
cookbooks/apt/resources/source.rb [deleted file]
cookbooks/apt/templates/default/default.list.erb [deleted file]
cookbooks/apt/templates/default/elasticsearch.list.erb [deleted file]
cookbooks/apt/templates/default/hp.list.erb [deleted file]
cookbooks/apt/templates/default/hwraid.list.erb [deleted file]
cookbooks/apt/templates/default/mediawiki.list.erb [deleted file]
cookbooks/apt/templates/default/nginx.list.erb [deleted file]
cookbooks/apt/templates/default/postgresql.list.erb [deleted file]
cookbooks/chef/attributes/default.rb
cookbooks/chef/libraries/subversion.rb
cookbooks/chef/recipes/default.rb
cookbooks/dmca/.foodcritic [new file with mode: 0644]
cookbooks/dmca/README.md [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/Common.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/DHTMLRulesTableless.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/PageDHTMLRulesTableless.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/Array.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/ArraySmarty.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/Default.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/ITDynamic.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/ITStatic.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/Object.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/ObjectFlexy.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/QuickHtml.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/Tableless.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Rule.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Callback.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Compare.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Email.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Range.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Regex.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Required.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/RuleRegistry.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/advcheckbox.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/autocomplete.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/button.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/checkbox.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/date.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/element.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/file.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/group.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/header.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/hidden.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/hiddenselect.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/hierselect.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/html.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/image.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/input.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/link.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/password.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/radio.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/reset.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/select.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/static.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/submit.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/text.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/textarea.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/utils.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/HTML/QuickForm/xbutton.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/favicon.ico [new file with mode: 0644]
cookbooks/dmca/files/default/html/index.php [new file with mode: 0644]
cookbooks/dmca/files/default/html/robots.txt [new file with mode: 0644]
cookbooks/dmca/files/default/html/style.css [new file with mode: 0644]
cookbooks/dmca/metadata.rb [new file with mode: 0644]
cookbooks/dmca/recipes/default.rb [new file with mode: 0644]
cookbooks/dmca/templates/default/apache.erb [new file with mode: 0644]
cookbooks/exim/recipes/default.rb
cookbooks/exim/templates/default/ssl.cnf.erb [deleted file]
cookbooks/foundation/recipes/board.rb
cookbooks/foundation/recipes/dwg.rb
cookbooks/hardware/attributes/default.rb
cookbooks/hardware/recipes/default.rb
cookbooks/hardware/templates/default/ohai.rb.erb
cookbooks/imagery/files/default/robots.txt [new file with mode: 0644]
cookbooks/imagery/resources/layer.rb
cookbooks/imagery/resources/site.rb
cookbooks/imagery/templates/default/index.html.erb
cookbooks/imagery/templates/default/mapserver.map.erb
cookbooks/imagery/templates/default/nginx_imagery.conf.erb
cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb
cookbooks/mediawiki/resources/site.rb
cookbooks/mediawiki/templates/default/LocalSettings.php.erb
cookbooks/mediawiki/templates/default/apache.erb
cookbooks/mediawiki/templates/default/mw-ext-UniversalLanguageSelector.inc.php.erb [new file with mode: 0644]
cookbooks/piwik/attributes/default.rb
cookbooks/piwik/templates/default/config.erb
cookbooks/planet/files/default/users_deleted/.htaccess [new file with mode: 0644]
cookbooks/planet/files/default/users_deleted/HEADER.html [new file with mode: 0644]
cookbooks/planet/recipes/replication.rb
cookbooks/planet/templates/default/replication.cron.erb
cookbooks/planet/templates/default/users-deleted.erb [new file with mode: 0644]
cookbooks/ssl/files/default/dhparam.pem [deleted file]
cookbooks/ssl/recipes/default.rb
cookbooks/ssl/resources/certificate.rb
cookbooks/ssl/templates/default/ssl.cnf.erb [deleted file]
cookbooks/sysctl/recipes/default.rb
cookbooks/sysfs/recipes/default.rb
cookbooks/systemd/resources/service.rb
cookbooks/taginfo/templates/default/update-planet.erb
cookbooks/tile/recipes/default.rb
cookbooks/tile/templates/default/expire-tiles.erb [moved from cookbooks/tile/templates/default/expire-tiles.bionic.erb with 100% similarity]
cookbooks/tile/templates/default/expire-tiles.xenial.erb [deleted file]
cookbooks/tilecache/attributes/default.rb
cookbooks/tilecache/recipes/default.rb
cookbooks/tilelog/attributes/default.rb
cookbooks/web/resources/rails_port.rb
cookbooks/wiki/attributes/default.rb
roles/cmok.rb
roles/draco.rb
roles/foundation.rb
roles/grindtooth.rb
roles/jakelong.rb
roles/kessie.rb
roles/osuosl.rb
roles/pyrene.rb [new file with mode: 0644]
roles/ridley.rb
roles/rimfaxe.rb [moved from roles/odin.rb with 61% similarity]
roles/sarel.rb
roles/smaug.rb [deleted file]
roles/stormfly-01.rb
roles/stormfly-02.rb

index 8102dd161b78dc2838f229721abf9f0f78fcc61f..6b29efce1afb843955c2e7cf11f648b30a449fae 100644 (file)
@@ -2,19 +2,19 @@ GEM
   remote: https://rubygems.org/
   specs:
     ast (2.4.0)
-    backports (3.11.3)
+    backports (3.11.4)
     builder (3.2.3)
-    cucumber-core (3.1.0)
+    cucumber-core (3.2.0)
       backports (>= 3.8.0)
       cucumber-tag_expressions (~> 1.1.0)
       gherkin (>= 5.0.0)
     cucumber-tag_expressions (1.1.1)
     diff-lcs (1.3)
     erubis (2.7.0)
-    ffi (1.9.23)
+    ffi (1.9.25)
     ffi-yajl (2.3.1)
       libyajl2 (~> 1.2)
-    foodcritic (13.1.1)
+    foodcritic (14.1.0)
       cucumber-core (>= 1.3)
       erubis
       ffi-yajl (~> 2.0)
@@ -22,13 +22,14 @@ GEM
       rake
       rufus-lru (~> 1.0)
       treetop (~> 1.4)
-    gherkin (5.0.0)
+    gherkin (5.1.0)
     gssapi (1.2.0)
       ffi (>= 1.0.1)
     gyoku (1.3.1)
       builder (>= 2.1.2)
     httpclient (2.8.3)
-    kitchen-vagrant (1.3.2)
+    jaro_winkler (1.5.1)
+    kitchen-vagrant (1.3.3)
       test-kitchen (~> 1.4)
     libyajl2 (1.2.0)
     little-plugger (1.1.4)
@@ -36,11 +37,11 @@ GEM
       little-plugger (~> 1.1)
       multi_json (~> 1.10)
     mini_portile2 (2.3.0)
-    mixlib-install (3.10.0)
+    mixlib-install (3.11.5)
       mixlib-shellout
       mixlib-versioning
       thor
-    mixlib-shellout (2.3.2)
+    mixlib-shellout (2.4.0)
     mixlib-versioning (1.2.2)
     multi_json (1.13.1)
     net-scp (1.2.1)
@@ -49,44 +50,45 @@ GEM
       openssl
     net-ssh-gateway (1.3.0)
       net-ssh (>= 2.6.5)
-    net-telnet (0.1.1)
-    nokogiri (1.8.2)
+    net-telnet (0.2.0)
+    nokogiri (1.8.4)
       mini_portile2 (~> 2.3.0)
     nori (2.6.0)
     openssl (2.1.0)
     parallel (1.12.1)
-    parser (2.5.1.0)
+    parser (2.5.1.2)
       ast (~> 2.4.0)
     polyglot (0.3.5)
-    powerpack (0.1.1)
+    powerpack (0.1.2)
     rainbow (3.0.0)
     rake (12.3.1)
-    rspec (3.7.0)
-      rspec-core (~> 3.7.0)
-      rspec-expectations (~> 3.7.0)
-      rspec-mocks (~> 3.7.0)
-    rspec-core (3.7.1)
-      rspec-support (~> 3.7.0)
-    rspec-expectations (3.7.0)
+    rspec (3.8.0)
+      rspec-core (~> 3.8.0)
+      rspec-expectations (~> 3.8.0)
+      rspec-mocks (~> 3.8.0)
+    rspec-core (3.8.0)
+      rspec-support (~> 3.8.0)
+    rspec-expectations (3.8.1)
       diff-lcs (>= 1.2.0, < 2.0)
-      rspec-support (~> 3.7.0)
+      rspec-support (~> 3.8.0)
     rspec-its (1.2.0)
       rspec-core (>= 3.0.0)
       rspec-expectations (>= 3.0.0)
-    rspec-mocks (3.7.0)
+    rspec-mocks (3.8.0)
       diff-lcs (>= 1.2.0, < 2.0)
-      rspec-support (~> 3.7.0)
-    rspec-support (3.7.1)
-    rubocop (0.56.0)
+      rspec-support (~> 3.8.0)
+    rspec-support (3.8.0)
+    rubocop (0.59.0)
+      jaro_winkler (~> 1.5.1)
       parallel (~> 1.10)
-      parser (>= 2.5)
+      parser (>= 2.5, != 2.5.1.1)
       powerpack (~> 0.1)
       rainbow (>= 2.2.2, < 4.0)
       ruby-progressbar (~> 1.7)
       unicode-display_width (~> 1.0, >= 1.0.1)
-    ruby-progressbar (1.9.0)
+    ruby-progressbar (1.10.0)
     rubyntlm (0.6.2)
-    rubyzip (1.2.1)
+    rubyzip (1.2.2)
     rufus-lru (1.1.0)
     serverspec (2.41.3)
       multi_json
@@ -94,12 +96,12 @@ GEM
       rspec-its
       specinfra (~> 2.72)
     sfl (2.3)
-    specinfra (2.73.3)
+    specinfra (2.76.1)
       net-scp
-      net-ssh (>= 2.7, < 5.0)
+      net-ssh (>= 2.7)
       net-telnet
       sfl
-    test-kitchen (1.21.2)
+    test-kitchen (1.23.2)
       mixlib-install (~> 3.6)
       mixlib-shellout (>= 1.2, < 3.0)
       net-scp (~> 1.1)
@@ -112,7 +114,7 @@ GEM
     thor (0.20.0)
     treetop (1.6.10)
       polyglot (~> 0.3)
-    unicode-display_width (1.3.2)
+    unicode-display_width (1.4.0)
     winrm (2.2.3)
       builder (>= 2.1.2)
       erubis (~> 2.7)
@@ -125,7 +127,7 @@ GEM
     winrm-elevated (1.1.0)
       winrm (~> 2.0)
       winrm-fs (~> 1.0)
-    winrm-fs (1.2.0)
+    winrm-fs (1.3.0)
       erubis (~> 2.7)
       logging (>= 1.6.1, < 3.0)
       rubyzip (~> 1.1)
index 51586d61b460dbff4f7fffa9a692191fe4c600b9..4282ba107687b0d012c00e5032add03915700a51 100644 (file)
@@ -31,9 +31,8 @@ file "/etc/motd.tail" do
   action :delete
 end
 
-execute "apt-update" do
+apt_update "/etc/apt/sources.list" do
   action :nothing
-  command "/usr/bin/apt-get update"
 end
 
 archive_host = if node[:country]
@@ -48,110 +47,106 @@ template "/etc/apt/sources.list" do
   group "root"
   mode 0o644
   variables :archive_host => archive_host, :codename => node[:lsb][:codename]
-  notifies :run, "execute[apt-update]", :immediately
+  notifies :update, "apt_update[/etc/apt/sources.list]", :immediately
 end
 
-if node[:lsb][:release].to_f >= 16.04
-  apt_source "brightbox-ruby-ng" do
-    action :delete
-  end
-else
-  apt_source "brightbox-ruby-ng" do
-    url "http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu"
-    key "F5DA5F09C3173AA6"
-  end
+repository_actions = Hash.new do |_, repository|
+  node[:apt][:sources].include?(repository) ? :add : :remove
 end
 
-apt_source "ubuntugis-stable" do
-  url "http://ppa.launchpad.net/ubuntugis/ppa/ubuntu"
-  key "089EBE08314DF160"
+apt_repository "brightbox-ruby-ng" do
+  action repository_actions["brightbox-ruby-ng"]
+  uri "ppa:brightbox/ruby-ng"
 end
 
-apt_source "ubuntugis-unstable" do
-  url "http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu"
-  key "089EBE08314DF160"
+apt_repository "ubuntugis-stable" do
+  action repository_actions["ubuntugis-stable"]
+  uri "ppa:ubuntugis/ppa"
 end
 
-apt_source "openstreetmap" do
-  url "http://ppa.launchpad.net/osmadmins/ppa/ubuntu"
-  key "D57F48750AC4F2CB"
-  update true
+apt_repository "ubuntugis-unstable" do
+  action repository_actions["ubuntugis-unstable"]
+  uri "ppa:ubuntugis/ubuntugis-unstable"
 end
 
-apt_source "squid2" do
-  url "http://ppa.launchpad.net/osmadmins/squid2/ubuntu"
-  key "D57F48750AC4F2CB"
-  update true
+apt_repository "openstreetmap" do
+  action repository_actions["openstreetmap"]
+  uri "ppa:osmadmins/ppa"
 end
 
-apt_source "squid3" do
-  url "http://ppa.launchpad.net/osmadmins/squid3/ubuntu"
-  key "D57F48750AC4F2CB"
-  update true
+apt_repository "squid2" do
+  action repository_actions["squid2"]
+  uri "ppa:osmadmins/squid2"
 end
 
-apt_source "management-component-pack" do
-  source_template "hp.list.erb"
-  url "https://downloads.linux.hpe.com/SDR/repo/mcp"
-  key "C208ADDE26C2B797"
-  key_url "https://downloads.linux.hpe.com/SDR/hpePublicKey2048_key1.pub"
+apt_repository "squid3" do
+  action repository_actions["squid3"]
+  uri "ppa:osmadmins/squid3"
 end
 
-apt_source "hwraid" do
-  source_template "hwraid.list.erb"
-  url "https://hwraid.le-vert.net/ubuntu"
-  key "6005210E23B3D3B4"
+apt_repository "management-component-pack" do
+  action repository_actions["management-component-pack"]
+  uri "https://downloads.linux.hpe.com/SDR/repo/mcp"
+  if node[:lsb][:release].to_f >= 16.04
+    distribution "xenial/current"
+  else
+    distribution "#{node[:lsb][:codename]}/current"
+  end
+  components ["non-free"]
+  key "C208ADDE26C2B797"
 end
 
-apt_source "mapnik-v210" do
-  url "http://ppa.launchpad.net/mapnik/v2.1.0/ubuntu"
-  key "4F7B93595D50B6BA"
+apt_repository "hwraid" do
+  action repository_actions["hwraid"]
+  uri "https://hwraid.le-vert.net/ubuntu"
+  distribution "precise"
+  components ["main"]
+  key "6005210E23B3D3B4"
 end
 
-apt_source "nginx" do
-  source_template "nginx.list.erb"
-  url "https://nginx.org/packages/ubuntu"
+apt_repository "nginx" do
+  action repository_actions["nginx"]
+  uri "https://nginx.org/packages/ubuntu"
+  components ["nginx"]
   key "ABF5BD827BD9BF62"
 end
 
-apt_source "elasticsearch1.7" do
-  source_template "elasticsearch.list.erb"
-  url "https://packages.elasticsearch.org/elasticsearch/1.7/debian"
-  key "D27D666CD88E42B4"
-end
-
-apt_source "elasticsearch2.x" do
-  source_template "elasticsearch.list.erb"
-  url "https://packages.elasticsearch.org/elasticsearch/2.x/debian"
-  key "D27D666CD88E42B4"
-end
-
-apt_source "elasticsearch5.x" do
-  source_template "elasticsearch.list.erb"
-  url "https://artifacts.elastic.co/packages/5.x/apt"
+apt_repository "elasticsearch5.x" do
+  action repository_actions["elasticsearch5.x"]
+  uri "https://artifacts.elastic.co/packages/5.x/apt"
+  distribution "stable"
+  components ["main"]
   key "D27D666CD88E42B4"
 end
 
-apt_source "logstash" do
-  source_template "elasticsearch.list.erb"
-  url "https://packages.elasticsearch.org/logstash/2.3/debian"
+apt_repository "logstash" do
+  action repository_actions["logstash"]
+  uri "https://packages.elasticsearch.org/logstash/2.3/debian"
+  distribution "stable"
+  components ["main"]
   key "D27D666CD88E42B4"
 end
 
-apt_source "passenger" do
-  url "https://oss-binaries.phusionpassenger.com/apt/passenger"
+apt_repository "passenger" do
+  action repository_actions["passenger"]
+  uri "https://oss-binaries.phusionpassenger.com/apt/passenger"
+  components ["main"]
   key "561F9B9CAC40B2F7"
 end
 
-apt_source "postgresql" do
-  source_template "postgresql.list.erb"
-  url "https://apt.postgresql.org/pub/repos/apt"
+apt_repository "postgresql" do
+  action repository_actions["postgresql"]
+  uri "https://apt.postgresql.org/pub/repos/apt"
+  distribution "#{node[:lsb][:codename]}-pgdg"
+  components ["main"]
   key "7FCC7D46ACCC4CF8"
 end
 
-apt_source "mediawiki" do
-  source_template "mediawiki.list.erb"
-  url "https://releases.wikimedia.org/debian"
+apt_repository "mediawiki" do
+  action repository_actions["mediawiki"]
+  uri "https://releases.wikimedia.org/debian"
+  distribution "jessie-mediawiki"
+  components ["main"]
   key "90E9F83F22250DD7"
 end
 
diff --git a/cookbooks/apt/resources/source.rb b/cookbooks/apt/resources/source.rb
deleted file mode 100644 (file)
index d678ccc..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# Cookbook Name:: apt
-# Resource:: apt_source
-#
-# Copyright 2015, OpenStreetMap Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-default_action :create
-
-property :source_name, String, :name_property => true
-property :source_template, String, :default => "default.list.erb"
-property :url, String, :required => true
-property :key, String
-property :key_url, String
-property :update, [TrueClass, FalseClass], :default => false
-
-def initialize(name, run_context = nil)
-  super(name, run_context)
-
-  @action = node[:apt][:sources].include?(name) ? :create : :delete
-end
-
-action :create do
-  if new_resource.key
-    execute "apt-key-#{new_resource.key}-clean" do
-      command "/usr/bin/apt-key adv --batch --delete-key --yes #key}"
-      only_if "/usr/bin/apt-key adv --list-keys #{new_resource.key} | fgrep expired"
-    end
-
-    if new_resource.key_url
-      execute "apt-key-#{new_resource.key}-install" do
-        command "/usr/bin/apt-key adv --fetch-keys #{new_resource.key_url}"
-        not_if "/usr/bin/apt-key adv --list-keys #{new_resource.key}"
-        notifies :run, "execute[apt-update-#{new_resource.source_name}]"
-      end
-    else
-      execute "apt-key-#{new_resource.key}-install" do
-        command "/usr/bin/apt-key adv --keyserver hkp://keys.gnupg.net --recv-keys #{new_resource.key}"
-        not_if "/usr/bin/apt-key adv --list-keys #{new_resource.key}"
-        notifies :run, "execute[apt-update-#{new_resource.source_name}]"
-      end
-    end
-  end
-
-  template source_path do
-    source new_resource.source_template
-    owner "root"
-    group "root"
-    mode 0o644
-    variables :url => new_resource.url
-    notifies :run, "execute[apt-update-#{new_resource.source_name}]"
-  end
-
-  execute "apt-update-#{new_resource.source_name}" do
-    action new_resource.update ? :run : :nothing
-    command "/usr/bin/apt-get update --no-list-cleanup -o Dir::Etc::sourcelist='#{source_path}' -o Dir::Etc::sourceparts='-'"
-  end
-end
-
-action :delete do
-  file source_path do
-    action :delete
-  end
-end
-
-action_class do
-  def source_path
-    "/etc/apt/sources.list.d/#{new_resource.source_name}.list"
-  end
-end
diff --git a/cookbooks/apt/templates/default/default.list.erb b/cookbooks/apt/templates/default/default.list.erb
deleted file mode 100644 (file)
index 50622ad..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-deb <%= @url %> <%= node[:lsb][:codename] %> main
-deb-src <%= @url %> <%= node[:lsb][:codename] %> main
diff --git a/cookbooks/apt/templates/default/elasticsearch.list.erb b/cookbooks/apt/templates/default/elasticsearch.list.erb
deleted file mode 100644 (file)
index d78b447..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-deb <%= @url %> stable main
diff --git a/cookbooks/apt/templates/default/hp.list.erb b/cookbooks/apt/templates/default/hp.list.erb
deleted file mode 100644 (file)
index f76d66e..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-<% if node[:lsb][:release].to_f >= 16.04 -%>
-deb <%= @url %> xenial/current non-free
-<% else -%>
-deb <%= @url %> trusty/current non-free
-<% end -%>
diff --git a/cookbooks/apt/templates/default/hwraid.list.erb b/cookbooks/apt/templates/default/hwraid.list.erb
deleted file mode 100644 (file)
index 211e6b9..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-deb <%= @url %> precise main
-deb-src <%= @url %> precise main
diff --git a/cookbooks/apt/templates/default/mediawiki.list.erb b/cookbooks/apt/templates/default/mediawiki.list.erb
deleted file mode 100644 (file)
index 3d0062a..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-deb <%= @url %> jessie-mediawiki main
-deb-src <%= @url %> jessie-mediawiki main
diff --git a/cookbooks/apt/templates/default/nginx.list.erb b/cookbooks/apt/templates/default/nginx.list.erb
deleted file mode 100644 (file)
index 02bab54..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-deb <%= @url %> <%= node[:lsb][:codename] %> nginx
-deb-src <%= @url %> <%= node[:lsb][:codename] %> nginx
diff --git a/cookbooks/apt/templates/default/postgresql.list.erb b/cookbooks/apt/templates/default/postgresql.list.erb
deleted file mode 100644 (file)
index 1f62a0d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-deb <%= @url %> <%= node[:lsb][:codename] %>-pgdg main
-deb-src <%= @url %> <%= node[:lsb][:codename] %>-pgdg main
index 63d5759201e0c55db4f2780c4fc02e04e44f83e7..956852a933b449546be9738a3f3bb53b7a2710e5 100644 (file)
@@ -5,4 +5,4 @@ default[:apt][:sources] = node[:apt][:sources] | ["opscode"]
 default[:chef][:server][:version] = "12.17.33"
 
 # Set the default client version
-default[:chef][:client][:version] = "13.10.0"
+default[:chef][:client][:version] = "14.4.56"
index dec188cec0f4c8eb8ebd5b426fdf9363cd04cbc5..cbcce026a8c772268d8eb9c32ae5d87f7b0848dd 100644 (file)
@@ -29,6 +29,7 @@ class Chef
 
         @repo_attrs ||= svn_info.lines.each_with_object({}) do |line, attrs|
           next unless line =~ SVN_INFO_PATTERN
+
           property = Regexp.last_match[1]
           value = Regexp.last_match[2]
           attrs[property] = value
index 73228580e375524f6d949ad1ba82de29e8e87db8..32c8a7dc674b89bed3353cf59003fb41a60807ee 100644 (file)
@@ -36,7 +36,7 @@ Dir.glob("/var/cache/chef/chef_*.deb").each do |deb|
 end
 
 remote_file "/var/cache/chef/#{chef_package}" do
-  source "https://packages.chef.io/files/stable/chef/#{chef_version}/ubuntu/16.04/#{chef_package}"
+  source "https://packages.chef.io/files/stable/chef/#{chef_version}/ubuntu/#{node[:lsb][:release]}/#{chef_package}"
   owner "root"
   group "root"
   mode 0o644
diff --git a/cookbooks/dmca/.foodcritic b/cookbooks/dmca/.foodcritic
new file mode 100644 (file)
index 0000000..0c118ec
--- /dev/null
@@ -0,0 +1,5 @@
+~FC001
+~FC064
+~FC065
+~FC066
+~FC071
diff --git a/cookbooks/dmca/README.md b/cookbooks/dmca/README.md
new file mode 100644 (file)
index 0000000..319bcca
--- /dev/null
@@ -0,0 +1,3 @@
+# DMCA Cookbook
+
+This cookbook configures the DMCA form available at https://dmca.openstreetmap.org
diff --git a/cookbooks/dmca/files/default/html/HTML/Common.php b/cookbooks/dmca/files/default/html/HTML/Common.php
new file mode 100644 (file)
index 0000000..8823ea4
--- /dev/null
@@ -0,0 +1,465 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Base class for all HTML classes
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ * 
+ * @category    HTML
+ * @package     HTML_Common
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @copyright   2001-2009 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id: Common.php,v 1.15 2009/04/03 15:26:22 avb Exp $
+ * @link        http://pear.php.net/package/HTML_Common/
+ */ 
+
+/**
+ * Base class for all HTML classes
+ *
+ * @category    HTML
+ * @package     HTML_Common
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @version     Release: 1.2.5
+ * @abstract
+ */
+class HTML_Common
+{
+    /**
+     * Associative array of attributes
+     * @var     array
+     * @access  private
+     */
+    var $_attributes = array();
+
+    /**
+     * Tab offset of the tag
+     * @var     int
+     * @access  private
+     */
+    var $_tabOffset = 0;
+
+    /**
+     * Tab string
+     * @var       string
+     * @since     1.7
+     * @access    private
+     */
+    var $_tab = "\11";
+
+    /**
+     * Contains the line end string
+     * @var       string
+     * @since     1.7
+     * @access    private
+     */
+    var $_lineEnd = "\12";
+
+    /**
+     * HTML comment on the object
+     * @var       string
+     * @since     1.5
+     * @access    private
+     */
+    var $_comment = '';
+
+    /**
+     * Class constructor
+     * @param    mixed   $attributes     Associative array of table tag attributes
+     *                                   or HTML attributes name="value" pairs
+     * @param    int     $tabOffset      Indent offset in tabs
+     * @access   public
+     */
+    function HTML_Common($attributes = null, $tabOffset = 0)
+    {
+        $this->setAttributes($attributes);
+        $this->setTabOffset($tabOffset);
+    } // end constructor
+
+    /**
+     * Returns the current API version
+     * @access   public
+     * @returns  double
+     */
+    function apiVersion()
+    {
+        return 1.7;
+    } // end func apiVersion
+
+    /**
+     * Returns the lineEnd
+     *
+     * @since     1.7
+     * @access    private
+     * @return    string
+     */
+    function _getLineEnd()
+    {
+        return $this->_lineEnd;
+    } // end func getLineEnd
+
+    /**
+     * Returns a string containing the unit for indenting HTML
+     *
+     * @since     1.7
+     * @access    private
+     * @return    string
+     */
+    function _getTab()
+    {
+        return $this->_tab;
+    } // end func _getTab
+
+    /**
+     * Returns a string containing the offset for the whole HTML code
+     *
+     * @return    string
+     * @access   private
+     */
+    function _getTabs()
+    {
+        return str_repeat($this->_getTab(), $this->_tabOffset);
+    } // end func _getTabs
+
+    /**
+     * Returns an HTML formatted attribute string
+     * @param    array   $attributes
+     * @return   string
+     * @access   private
+     */
+    function _getAttrString($attributes)
+    {
+        $strAttr = '';
+
+        if (is_array($attributes)) {
+            $charset = HTML_Common::charset();
+            foreach ($attributes as $key => $value) {
+                $strAttr .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, $charset) . '"';
+            }
+        }
+        return $strAttr;
+    } // end func _getAttrString
+
+    /**
+     * Returns a valid atrributes array from either a string or array
+     * @param    mixed   $attributes     Either a typical HTML attribute string or an associative array
+     * @access   private
+     * @return   array
+     */
+    function _parseAttributes($attributes)
+    {
+        if (is_array($attributes)) {
+            $ret = array();
+            foreach ($attributes as $key => $value) {
+                if (is_int($key)) {
+                    $key = $value = strtolower($value);
+                } else {
+                    $key = strtolower($key);
+                }
+                $ret[$key] = $value;
+            }
+            return $ret;
+
+        } elseif (is_string($attributes)) {
+            $preg = "/(([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*)" .
+                "([ \\n\\t\\r]+)?(=([ \\n\\t\\r]+)?(\"[^\"]*\"|'[^']*'|[^ \\n\\t\\r]*))?/";
+            if (preg_match_all($preg, $attributes, $regs)) {
+                for ($counter=0; $counter<count($regs[1]); $counter++) {
+                    $name  = $regs[1][$counter];
+                    $check = $regs[0][$counter];
+                    $value = $regs[7][$counter];
+                    if (trim($name) == trim($check)) {
+                        $arrAttr[strtolower(trim($name))] = strtolower(trim($name));
+                    } else {
+                        if (substr($value, 0, 1) == "\"" || substr($value, 0, 1) == "'") {
+                            $arrAttr[strtolower(trim($name))] = substr($value, 1, -1);
+                        } else {
+                            $arrAttr[strtolower(trim($name))] = trim($value);
+                        }
+                    }
+                }
+                return $arrAttr;
+            }
+        }
+    } // end func _parseAttributes
+
+    /**
+     * Returns the array key for the given non-name-value pair attribute
+     *
+     * @param     string    $attr         Attribute
+     * @param     array     $attributes   Array of attribute
+     * @since     1.0
+     * @access    private
+     * @return    bool
+     */
+    function _getAttrKey($attr, $attributes)
+    {
+        if (isset($attributes[strtolower($attr)])) {
+            return true;
+        } else {
+            return null;
+        }
+    } //end func _getAttrKey
+
+    /**
+     * Updates the attributes in $attr1 with the values in $attr2 without changing the other existing attributes
+     * @param    array   $attr1      Original attributes array
+     * @param    array   $attr2      New attributes array
+     * @access   private
+     */
+    function _updateAttrArray(&$attr1, $attr2)
+    {
+        if (!is_array($attr2)) {
+            return false;
+        }
+        foreach ($attr2 as $key => $value) {
+            $attr1[$key] = $value;
+        }
+    } // end func _updateAtrrArray
+
+    /**
+     * Removes the given attribute from the given array
+     *
+     * @param     string    $attr           Attribute name
+     * @param     array     $attributes     Attribute array
+     * @since     1.4
+     * @access    private
+     * @return    void
+     */
+    function _removeAttr($attr, &$attributes)
+    {
+        $attr = strtolower($attr);
+        if (isset($attributes[$attr])) {
+            unset($attributes[$attr]);
+        }
+    } //end func _removeAttr
+
+    /**
+     * Returns the value of the given attribute
+     *
+     * @param     string    $attr   Attribute name
+     * @since     1.5
+     * @access    public
+     * @return    string|null   returns null if an attribute does not exist
+     */
+    function getAttribute($attr)
+    {
+        $attr = strtolower($attr);
+        if (isset($this->_attributes[$attr])) {
+            return $this->_attributes[$attr];
+        }
+        return null;
+    } //end func getAttribute
+
+    /**
+     * Sets the value of the attribute
+     *
+     * @param   string  Attribute name
+     * @param   string  Attribute value (will be set to $name if omitted)
+     * @access  public
+     */
+    function setAttribute($name, $value = null)
+    {
+        $name = strtolower($name);
+        if (is_null($value)) {
+            $value = $name;
+        }
+        $this->_attributes[$name] = $value;
+    } // end func setAttribute
+
+    /**
+     * Sets the HTML attributes
+     * @param    mixed   $attributes     Either a typical HTML attribute string or an associative array
+     * @access   public
+     */
+    function setAttributes($attributes)
+    {
+        $this->_attributes = $this->_parseAttributes($attributes);
+    } // end func setAttributes
+
+    /**
+     * Returns the assoc array (default) or string of attributes
+     *
+     * @param     bool    Whether to return the attributes as string
+     * @since     1.6
+     * @access    public
+     * @return    mixed   attributes
+     */
+    function getAttributes($asString = false)
+    {
+        if ($asString) {
+            return $this->_getAttrString($this->_attributes);
+        } else {
+            return $this->_attributes;
+        }
+    } //end func getAttributes
+
+    /**
+     * Updates the passed attributes without changing the other existing attributes
+     * @param    mixed   $attributes     Either a typical HTML attribute string or an associative array
+     * @access   public
+     */
+    function updateAttributes($attributes)
+    {
+        $this->_updateAttrArray($this->_attributes, $this->_parseAttributes($attributes));
+    } // end func updateAttributes
+
+    /**
+     * Removes an attribute
+     *
+     * @param     string    $attr   Attribute name
+     * @since     1.4
+     * @access    public
+     * @return    void
+     */
+    function removeAttribute($attr)
+    {
+        $this->_removeAttr($attr, $this->_attributes);
+    } //end func removeAttribute
+
+    /**
+     * Sets the line end style to Windows, Mac, Unix or a custom string.
+     *
+     * @param   string  $style  "win", "mac", "unix" or custom string.
+     * @since   1.7
+     * @access  public
+     * @return  void
+     */
+    function setLineEnd($style)
+    {
+        switch ($style) {
+            case 'win':
+                $this->_lineEnd = "\15\12";
+                break;
+            case 'unix':
+                $this->_lineEnd = "\12";
+                break;
+            case 'mac':
+                $this->_lineEnd = "\15";
+                break;
+            default:
+                $this->_lineEnd = $style;
+        }
+    } // end func setLineEnd
+
+    /**
+     * Sets the tab offset
+     *
+     * @param    int     $offset
+     * @access   public
+     */
+    function setTabOffset($offset)
+    {
+        $this->_tabOffset = $offset;
+    } // end func setTabOffset
+
+    /**
+     * Returns the tabOffset
+     *
+     * @since     1.5
+     * @access    public
+     * @return    int
+     */
+    function getTabOffset()
+    {
+        return $this->_tabOffset;
+    } //end func getTabOffset
+
+    /**
+     * Sets the string used to indent HTML
+     *
+     * @since     1.7
+     * @param     string    $string     String used to indent ("\11", "\t", '  ', etc.).
+     * @access    public
+     * @return    void
+     */
+    function setTab($string)
+    {
+        $this->_tab = $string;
+    } // end func setTab
+
+    /**
+     * Sets the HTML comment to be displayed at the beginning of the HTML string
+     *
+     * @param     string
+     * @since     1.4
+     * @access    public
+     * @return    void
+     */
+    function setComment($comment)
+    {
+        $this->_comment = $comment;
+    } // end func setHtmlComment
+
+    /**
+     * Returns the HTML comment
+     *
+     * @since     1.5
+     * @access    public
+     * @return    string
+     */
+    function getComment()
+    {
+        return $this->_comment;
+    } //end func getComment
+
+    /**
+     * Abstract method.  Must be extended to return the objects HTML
+     *
+     * @access    public
+     * @return    string
+     * @abstract
+     */
+    function toHtml()
+    {
+        return '';
+    } // end func toHtml
+
+    /**
+     * Displays the HTML to the screen
+     *
+     * @access    public
+     */
+    function display()
+    {
+        print $this->toHtml();
+    } // end func display
+
+    /**
+     * Sets the charset to use by htmlspecialchars() function
+     *
+     * Since this parameter is expected to be global, the function is designed
+     * to be called statically:
+     * <code>
+     * HTML_Common::charset('utf-8');
+     * </code>
+     * or
+     * <code>
+     * $charset = HTML_Common::charset();
+     * </code>
+     *
+     * @param   string  New charset to use. Omit if just getting the 
+     *                  current value. Consult the htmlspecialchars() docs 
+     *                  for a list of supported character sets.
+     * @return  string  Current charset
+     * @access  public
+     * @static
+     */
+    function charset($newCharset = null)
+    {
+        static $charset = 'ISO-8859-1';
+
+        if (!is_null($newCharset)) {
+            $charset = $newCharset;
+        }
+        return $charset;
+    } // end func charset
+} // end class HTML_Common
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm.php b/cookbooks/dmca/files/default/html/HTML/QuickForm.php
new file mode 100644 (file)
index 0000000..f769b1f
--- /dev/null
@@ -0,0 +1,2073 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Create, validate and process HTML forms
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * PEAR and PEAR_Error classes, for error handling
+ */
+require_once 'PEAR.php';
+/**
+ * Base class for all HTML classes
+ */
+require_once 'HTML/Common.php';
+/**
+ * Static utility methods
+ */
+require_once 'HTML/QuickForm/utils.php';
+
+/**
+ * Element types known to HTML_QuickForm
+ * @see HTML_QuickForm::registerElementType(), HTML_QuickForm::getRegisteredTypes(),
+ *      HTML_QuickForm::isTypeRegistered()
+ * @global array $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES']
+ */
+$GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] =
+        array(
+            'group'         =>array('HTML/QuickForm/group.php','HTML_QuickForm_group'),
+            'hidden'        =>array('HTML/QuickForm/hidden.php','HTML_QuickForm_hidden'),
+            'reset'         =>array('HTML/QuickForm/reset.php','HTML_QuickForm_reset'),
+            'checkbox'      =>array('HTML/QuickForm/checkbox.php','HTML_QuickForm_checkbox'),
+            'file'          =>array('HTML/QuickForm/file.php','HTML_QuickForm_file'),
+            'image'         =>array('HTML/QuickForm/image.php','HTML_QuickForm_image'),
+            'password'      =>array('HTML/QuickForm/password.php','HTML_QuickForm_password'),
+            'radio'         =>array('HTML/QuickForm/radio.php','HTML_QuickForm_radio'),
+            'button'        =>array('HTML/QuickForm/button.php','HTML_QuickForm_button'),
+            'submit'        =>array('HTML/QuickForm/submit.php','HTML_QuickForm_submit'),
+            'select'        =>array('HTML/QuickForm/select.php','HTML_QuickForm_select'),
+            'hiddenselect'  =>array('HTML/QuickForm/hiddenselect.php','HTML_QuickForm_hiddenselect'),
+            'text'          =>array('HTML/QuickForm/text.php','HTML_QuickForm_text'),
+            'textarea'      =>array('HTML/QuickForm/textarea.php','HTML_QuickForm_textarea'),
+            'link'          =>array('HTML/QuickForm/link.php','HTML_QuickForm_link'),
+            'advcheckbox'   =>array('HTML/QuickForm/advcheckbox.php','HTML_QuickForm_advcheckbox'),
+            'date'          =>array('HTML/QuickForm/date.php','HTML_QuickForm_date'),
+            'static'        =>array('HTML/QuickForm/static.php','HTML_QuickForm_static'),
+            'header'        =>array('HTML/QuickForm/header.php', 'HTML_QuickForm_header'),
+            'html'          =>array('HTML/QuickForm/html.php', 'HTML_QuickForm_html'),
+            'hierselect'    =>array('HTML/QuickForm/hierselect.php', 'HTML_QuickForm_hierselect'),
+            'autocomplete'  =>array('HTML/QuickForm/autocomplete.php', 'HTML_QuickForm_autocomplete'),
+            'xbutton'       =>array('HTML/QuickForm/xbutton.php','HTML_QuickForm_xbutton')
+        );
+
+/**
+ * Validation rules known to HTML_QuickForm
+ * @see HTML_QuickForm::registerRule(), HTML_QuickForm::getRegisteredRules(),
+ *      HTML_QuickForm::isRuleRegistered()
+ * @global array $GLOBALS['_HTML_QuickForm_registered_rules']
+ */
+$GLOBALS['_HTML_QuickForm_registered_rules'] = array(
+    'required'      => array('html_quickform_rule_required', 'HTML/QuickForm/Rule/Required.php'),
+    'maxlength'     => array('html_quickform_rule_range',    'HTML/QuickForm/Rule/Range.php'),
+    'minlength'     => array('html_quickform_rule_range',    'HTML/QuickForm/Rule/Range.php'),
+    'rangelength'   => array('html_quickform_rule_range',    'HTML/QuickForm/Rule/Range.php'),
+    'email'         => array('html_quickform_rule_email',    'HTML/QuickForm/Rule/Email.php'),
+    'regex'         => array('html_quickform_rule_regex',    'HTML/QuickForm/Rule/Regex.php'),
+    'lettersonly'   => array('html_quickform_rule_regex',    'HTML/QuickForm/Rule/Regex.php'),
+    'alphanumeric'  => array('html_quickform_rule_regex',    'HTML/QuickForm/Rule/Regex.php'),
+    'numeric'       => array('html_quickform_rule_regex',    'HTML/QuickForm/Rule/Regex.php'),
+    'nopunctuation' => array('html_quickform_rule_regex',    'HTML/QuickForm/Rule/Regex.php'),
+    'nonzero'       => array('html_quickform_rule_regex',    'HTML/QuickForm/Rule/Regex.php'),
+    'callback'      => array('html_quickform_rule_callback', 'HTML/QuickForm/Rule/Callback.php'),
+    'compare'       => array('html_quickform_rule_compare',  'HTML/QuickForm/Rule/Compare.php')
+);
+
+// {{{ error codes
+
+/**#@+
+ * Error codes for HTML_QuickForm
+ *
+ * Codes are mapped to textual messages by errorMessage() method, if you add a
+ * new code be sure to add a new message for it to errorMessage()
+ *
+ * @see HTML_QuickForm::errorMessage()
+ */
+define('QUICKFORM_OK',                      1);
+define('QUICKFORM_ERROR',                  -1);
+define('QUICKFORM_INVALID_RULE',           -2);
+define('QUICKFORM_NONEXIST_ELEMENT',       -3);
+define('QUICKFORM_INVALID_FILTER',         -4);
+define('QUICKFORM_UNREGISTERED_ELEMENT',   -5);
+define('QUICKFORM_INVALID_ELEMENT_NAME',   -6);
+define('QUICKFORM_INVALID_PROCESS',        -7);
+define('QUICKFORM_DEPRECATED',             -8);
+define('QUICKFORM_INVALID_DATASOURCE',     -9);
+/**#@-*/
+
+// }}}
+
+/**
+ * Create, validate and process HTML forms
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ */
+class HTML_QuickForm extends HTML_Common
+{
+    // {{{ properties
+
+    /**
+     * Array containing the form fields
+     * @since     1.0
+     * @var  array
+     * @access   private
+     */
+    var $_elements = array();
+
+    /**
+     * Array containing element name to index map
+     * @since     1.1
+     * @var  array
+     * @access   private
+     */
+    var $_elementIndex = array();
+
+    /**
+     * Array containing indexes of duplicate elements
+     * @since     2.10
+     * @var  array
+     * @access   private
+     */
+    var $_duplicateIndex = array();
+
+    /**
+     * Array containing required field IDs
+     * @since     1.0
+     * @var  array
+     * @access   private
+     */
+    var $_required = array();
+
+    /**
+     * Prefix message in javascript alert if error
+     * @since     1.0
+     * @var  string
+     * @access   public
+     */
+    var $_jsPrefix = 'Invalid information entered.';
+
+    /**
+     * Postfix message in javascript alert if error
+     * @since     1.0
+     * @var  string
+     * @access   public
+     */
+    var $_jsPostfix = 'Please correct these fields.';
+
+    /**
+     * Datasource object implementing the informal
+     * datasource protocol
+     * @since     3.3
+     * @var  object
+     * @access   private
+     */
+    var $_datasource;
+
+    /**
+     * Array of default form values
+     * @since     2.0
+     * @var  array
+     * @access   private
+     */
+    var $_defaultValues = array();
+
+    /**
+     * Array of constant form values
+     * @since     2.0
+     * @var  array
+     * @access   private
+     */
+    var $_constantValues = array();
+
+    /**
+     * Array of submitted form values
+     * @since     1.0
+     * @var  array
+     * @access   private
+     */
+    var $_submitValues = array();
+
+    /**
+     * Array of submitted form files
+     * @since     1.0
+     * @var  integer
+     * @access   public
+     */
+    var $_submitFiles = array();
+
+    /**
+     * Value for maxfilesize hidden element if form contains file input
+     * @since     1.0
+     * @var  integer
+     * @access   public
+     */
+    var $_maxFileSize = 1048576; // 1 Mb = 1048576
+
+    /**
+     * Flag to know if all fields are frozen
+     * @since     1.0
+     * @var  boolean
+     * @access   private
+     */
+    var $_freezeAll = false;
+
+    /**
+     * Array containing the form rules
+     * @since     1.0
+     * @var  array
+     * @access   private
+     */
+    var $_rules = array();
+
+    /**
+     * Form rules, global variety
+     * @var     array
+     * @access  private
+     */
+    var $_formRules = array();
+
+    /**
+     * Array containing the validation errors
+     * @since     1.0
+     * @var  array
+     * @access   private
+     */
+    var $_errors = array();
+
+    /**
+     * Note for required fields in the form
+     * @var       string
+     * @since     1.0
+     * @access    private
+     */
+    var $_requiredNote = '<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;"> denotes required field</span>';
+
+    /**
+     * Whether the form was submitted
+     * @var       boolean
+     * @access    private
+     */
+    var $_flagSubmitted = false;
+
+    // }}}
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * @param    string      $formName          Form's name.
+     * @param    string      $method            (optional)Form's method defaults to 'POST'
+     * @param    string      $action            (optional)Form's action
+     * @param    string      $target            (optional)Form's target defaults to '_self'
+     * @param    mixed       $attributes        (optional)Extra attributes for <form> tag
+     * @param    bool        $trackSubmit       (optional)Whether to track if the form was submitted by adding a special hidden field
+     * @access   public
+     */
+    function HTML_QuickForm($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false)
+    {
+        HTML_Common::HTML_Common($attributes);
+        $method = (strtoupper($method) == 'GET') ? 'get' : 'post';
+        $action = ($action == '') ? $_SERVER['PHP_SELF'] : $action;
+        $target = empty($target) ? array() : array('target' => $target);
+        $attributes = array('action'=>$action, 'method'=>$method, 'name'=>$formName, 'id'=>$formName) + $target;
+        $this->updateAttributes($attributes);
+        if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) {
+            if (1 == get_magic_quotes_gpc()) {
+                $this->_submitValues = $this->_recursiveFilter('stripslashes', 'get' == $method? $_GET: $_POST);
+                foreach ($_FILES as $keyFirst => $valFirst) {
+                    foreach ($valFirst as $keySecond => $valSecond) {
+                        if ('name' == $keySecond) {
+                            $this->_submitFiles[$keyFirst][$keySecond] = $this->_recursiveFilter('stripslashes', $valSecond);
+                        } else {
+                            $this->_submitFiles[$keyFirst][$keySecond] = $valSecond;
+                        }
+                    }
+                }
+            } else {
+                $this->_submitValues = 'get' == $method? $_GET: $_POST;
+                $this->_submitFiles  = $_FILES;
+            }
+            $this->_flagSubmitted = count($this->_submitValues) > 0 || count($this->_submitFiles) > 0;
+        }
+        if ($trackSubmit) {
+            unset($this->_submitValues['_qf__' . $formName]);
+            $this->addElement('hidden', '_qf__' . $formName, null);
+        }
+        if (preg_match('/^([0-9]+)([a-zA-Z]*)$/', ini_get('upload_max_filesize'), $matches)) {
+            // see http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
+            switch (strtoupper($matches['2'])) {
+                case 'G':
+                    $this->_maxFileSize = $matches['1'] * 1073741824;
+                    break;
+                case 'M':
+                    $this->_maxFileSize = $matches['1'] * 1048576;
+                    break;
+                case 'K':
+                    $this->_maxFileSize = $matches['1'] * 1024;
+                    break;
+                default:
+                    $this->_maxFileSize = $matches['1'];
+            }
+        }
+    } // end constructor
+
+    // }}}
+    // {{{ apiVersion()
+
+    /**
+     * Returns the current API version
+     *
+     * @since     1.0
+     * @access    public
+     * @return    float
+     */
+    function apiVersion()
+    {
+        return 3.2;
+    } // end func apiVersion
+
+    // }}}
+    // {{{ registerElementType()
+
+    /**
+     * Registers a new element type
+     *
+     * @param     string    $typeName   Name of element type
+     * @param     string    $include    Include path for element type
+     * @param     string    $className  Element class name
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function registerElementType($typeName, $include, $className)
+    {
+        $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][strtolower($typeName)] = array($include, $className);
+    } // end func registerElementType
+
+    // }}}
+    // {{{ registerRule()
+
+    /**
+     * Registers a new validation rule
+     *
+     * @param     string    $ruleName   Name of validation rule
+     * @param     string    $type       Either: 'regex', 'function' or 'rule' for an HTML_QuickForm_Rule object
+     * @param     string    $data1      Name of function, regular expression or HTML_QuickForm_Rule classname
+     * @param     string    $data2      Object parent of above function or HTML_QuickForm_Rule file path
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function registerRule($ruleName, $type, $data1, $data2 = null)
+    {
+        include_once('HTML/QuickForm/RuleRegistry.php');
+        $registry =& HTML_QuickForm_RuleRegistry::singleton();
+        $registry->registerRule($ruleName, $type, $data1, $data2);
+    } // end func registerRule
+
+    // }}}
+    // {{{ elementExists()
+
+    /**
+     * Returns true if element is in the form
+     *
+     * @param     string   $element         form name of element to check
+     * @since     1.0
+     * @access    public
+     * @return    boolean
+     */
+    function elementExists($element=null)
+    {
+        return isset($this->_elementIndex[$element]);
+    } // end func elementExists
+
+    // }}}
+    // {{{ setDatasource()
+
+    /**
+     * Sets a datasource object for this form object
+     *
+     * Datasource default and constant values will feed the QuickForm object if
+     * the datasource implements defaultValues() and constantValues() methods.
+     *
+     * @param     object   $datasource          datasource object implementing the informal datasource protocol
+     * @param     mixed    $defaultsFilter      string or array of filter(s) to apply to default values
+     * @param     mixed    $constantsFilter     string or array of filter(s) to apply to constants values
+     * @since     3.3
+     * @access    public
+     * @return    void
+     * @throws    HTML_QuickForm_Error
+     */
+    function setDatasource(&$datasource, $defaultsFilter = null, $constantsFilter = null)
+    {
+        if (is_object($datasource)) {
+            $this->_datasource =& $datasource;
+            if (is_callable(array($datasource, 'defaultValues'))) {
+                $this->setDefaults($datasource->defaultValues($this), $defaultsFilter);
+            }
+            if (is_callable(array($datasource, 'constantValues'))) {
+                $this->setConstants($datasource->constantValues($this), $constantsFilter);
+            }
+        } else {
+            return PEAR::raiseError(null, QUICKFORM_INVALID_DATASOURCE, null, E_USER_WARNING, "Datasource is not an object in QuickForm::setDatasource()", 'HTML_QuickForm_Error', true);
+        }
+    } // end func setDatasource
+
+    // }}}
+    // {{{ setDefaults()
+
+    /**
+     * Initializes default form values
+     *
+     * @param     array    $defaultValues       values used to fill the form
+     * @param     mixed    $filter              (optional) filter(s) to apply to all default values
+     * @since     1.0
+     * @access    public
+     * @return    void
+     * @throws    HTML_QuickForm_Error
+     */
+    function setDefaults($defaultValues = null, $filter = null)
+    {
+        if (is_array($defaultValues)) {
+            if (isset($filter)) {
+                if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) {
+                    foreach ($filter as $val) {
+                        if (!is_callable($val)) {
+                            return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
+                        } else {
+                            $defaultValues = $this->_recursiveFilter($val, $defaultValues);
+                        }
+                    }
+                } elseif (!is_callable($filter)) {
+                    return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
+                } else {
+                    $defaultValues = $this->_recursiveFilter($filter, $defaultValues);
+                }
+            }
+            $this->_defaultValues = HTML_QuickForm::arrayMerge($this->_defaultValues, $defaultValues);
+            foreach (array_keys($this->_elements) as $key) {
+                $this->_elements[$key]->onQuickFormEvent('updateValue', null, $this);
+            }
+        }
+    } // end func setDefaults
+
+    // }}}
+    // {{{ setConstants()
+
+    /**
+     * Initializes constant form values.
+     * These values won't get overridden by POST or GET vars
+     *
+     * @param     array   $constantValues        values used to fill the form
+     * @param     mixed    $filter              (optional) filter(s) to apply to all default values
+     *
+     * @since     2.0
+     * @access    public
+     * @return    void
+     * @throws    HTML_QuickForm_Error
+     */
+    function setConstants($constantValues = null, $filter = null)
+    {
+        if (is_array($constantValues)) {
+            if (isset($filter)) {
+                if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) {
+                    foreach ($filter as $val) {
+                        if (!is_callable($val)) {
+                            return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true);
+                        } else {
+                            $constantValues = $this->_recursiveFilter($val, $constantValues);
+                        }
+                    }
+                } elseif (!is_callable($filter)) {
+                    return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true);
+                } else {
+                    $constantValues = $this->_recursiveFilter($filter, $constantValues);
+                }
+            }
+            $this->_constantValues = HTML_QuickForm::arrayMerge($this->_constantValues, $constantValues);
+            foreach (array_keys($this->_elements) as $key) {
+                $this->_elements[$key]->onQuickFormEvent('updateValue', null, $this);
+            }
+        }
+    } // end func setConstants
+
+    // }}}
+    // {{{ setMaxFileSize()
+
+    /**
+     * Sets the value of MAX_FILE_SIZE hidden element
+     *
+     * @param     int    $bytes    Size in bytes
+     * @since     3.0
+     * @access    public
+     * @return    void
+     */
+    function setMaxFileSize($bytes = 0)
+    {
+        if ($bytes > 0) {
+            $this->_maxFileSize = $bytes;
+        }
+        if (!$this->elementExists('MAX_FILE_SIZE')) {
+            $this->addElement('hidden', 'MAX_FILE_SIZE', $this->_maxFileSize);
+        } else {
+            $el =& $this->getElement('MAX_FILE_SIZE');
+            $el->updateAttributes(array('value' => $this->_maxFileSize));
+        }
+    } // end func setMaxFileSize
+
+    // }}}
+    // {{{ getMaxFileSize()
+
+    /**
+     * Returns the value of MAX_FILE_SIZE hidden element
+     *
+     * @since     3.0
+     * @access    public
+     * @return    int   max file size in bytes
+     */
+    function getMaxFileSize()
+    {
+        return $this->_maxFileSize;
+    } // end func getMaxFileSize
+
+    // }}}
+    // {{{ &createElement()
+
+    /**
+     * Creates a new form element of the given type.
+     *
+     * This method accepts variable number of parameters, their
+     * meaning and count depending on $elementType
+     *
+     * @param     string     $elementType    type of element to add (text, textarea, file...)
+     * @since     1.0
+     * @access    public
+     * @return    HTML_QuickForm_Element
+     * @throws    HTML_QuickForm_Error
+     */
+    function &createElement($elementType)
+    {
+        $args    =  func_get_args();
+        $element =& HTML_QuickForm::_loadElement('createElement', $elementType, array_slice($args, 1), null);
+        return $element;
+    } // end func createElement
+
+    // }}}
+    // {{{ _loadElement()
+
+    /**
+     * Returns a form element of the given type
+     *
+     * @param     string   $event   event to send to newly created element ('createElement' or 'addElement')
+     * @param     string   $type    element type
+     * @param     array    $args    arguments for event
+     * @since     2.0
+     * @access    private
+     * @return    HTML_QuickForm_Element
+     * @throws    HTML_QuickForm_Error
+     */
+    function &_loadElement($event, $type, $args, $form)
+    {
+        $type = strtolower($type);
+        if (!HTML_QuickForm::isTypeRegistered($type)) {
+            $error = PEAR::raiseError(null, QUICKFORM_UNREGISTERED_ELEMENT, null, E_USER_WARNING, "Element '$type' does not exist in HTML_QuickForm::_loadElement()", 'HTML_QuickForm_Error', true);
+            return $error;
+        }
+        $className = $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][$type][1];
+        $includeFile = $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][$type][0];
+        include_once($includeFile);
+        $elementObject = new $className();
+        for ($i = 0; $i < 5; $i++) {
+            if (!isset($args[$i])) {
+                $args[$i] = null;
+            }
+        }
+        $err = $elementObject->onQuickFormEvent($event, $args, $form);
+        if ($err !== true) {
+            return $err;
+        }
+        return $elementObject;
+    } // end func _loadElement
+
+    // }}}
+    // {{{ addElement()
+
+    /**
+     * Adds an element into the form
+     *
+     * If $element is a string representing element type, then this
+     * method accepts variable number of parameters, their meaning
+     * and count depending on $element
+     *
+     * @param    mixed      $element        element object or type of element to add (text, textarea, file...)
+     * @since    1.0
+     * @return   HTML_QuickForm_Element     a reference to newly added element
+     * @access   public
+     * @throws   HTML_QuickForm_Error
+     */
+    function &addElement($element)
+    {
+        if (is_object($element) && is_subclass_of($element, 'html_quickform_element')) {
+           $elementObject = &$element;
+           $elementObject->onQuickFormEvent('updateValue', null, $this);
+        } else {
+            $args = func_get_args();
+            $elementObject =& $this->_loadElement('addElement', $element, array_slice($args, 1), $this);
+            if (PEAR::isError($elementObject)) {
+                return $elementObject;
+            }
+        }
+        $elementName = $elementObject->getName();
+
+        // Add the element if it is not an incompatible duplicate
+        if (!empty($elementName) && isset($this->_elementIndex[$elementName])) {
+            if ($this->_elements[$this->_elementIndex[$elementName]]->getType() ==
+                $elementObject->getType()) {
+                $this->_elements[] =& $elementObject;
+                $elKeys = array_keys($this->_elements);
+                $this->_duplicateIndex[$elementName][] = end($elKeys);
+            } else {
+                $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::addElement()", 'HTML_QuickForm_Error', true);
+                return $error;
+            }
+        } else {
+            $this->_elements[] =& $elementObject;
+            $elKeys = array_keys($this->_elements);
+            $this->_elementIndex[$elementName] = end($elKeys);
+        }
+        if ($this->_freezeAll) {
+            $elementObject->freeze();
+        }
+
+        return $elementObject;
+    } // end func addElement
+
+    // }}}
+    // {{{ insertElementBefore()
+
+   /**
+    * Inserts a new element right before the other element
+    *
+    * Warning: it is not possible to check whether the $element is already
+    * added to the form, therefore if you want to move the existing form
+    * element to a new position, you'll have to use removeElement():
+    * $form->insertElementBefore($form->removeElement('foo', false), 'bar');
+    *
+    * @access   public
+    * @since    3.2.4
+    * @param    HTML_QuickForm_element  Element to insert
+    * @param    string                  Name of the element before which the new
+    *                                   one is inserted
+    * @return   HTML_QuickForm_element  reference to inserted element
+    * @throws   HTML_QuickForm_Error
+    */
+    function &insertElementBefore(&$element, $nameAfter)
+    {
+        if (!empty($this->_duplicateIndex[$nameAfter])) {
+            $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, 'Several elements named "' . $nameAfter . '" exist in HTML_QuickForm::insertElementBefore().', 'HTML_QuickForm_Error', true);
+            return $error;
+        } elseif (!$this->elementExists($nameAfter)) {
+            $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$nameAfter' does not exist in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true);
+            return $error;
+        }
+        $elementName = $element->getName();
+        $targetIdx   = $this->_elementIndex[$nameAfter];
+        $duplicate   = false;
+        // Like in addElement(), check that it's not an incompatible duplicate
+        if (!empty($elementName) && isset($this->_elementIndex[$elementName])) {
+            if ($this->_elements[$this->_elementIndex[$elementName]]->getType() != $element->getType()) {
+                $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true);
+                return $error;
+            }
+            $duplicate = true;
+        }
+        // Move all the elements after added back one place, reindex _elementIndex and/or _duplicateIndex
+        $elKeys = array_keys($this->_elements);
+        for ($i = end($elKeys); $i >= $targetIdx; $i--) {
+            if (isset($this->_elements[$i])) {
+                $currentName = $this->_elements[$i]->getName();
+                $this->_elements[$i + 1] =& $this->_elements[$i];
+                if ($this->_elementIndex[$currentName] == $i) {
+                    $this->_elementIndex[$currentName] = $i + 1;
+                } else {
+                    $dupIdx = array_search($i, $this->_duplicateIndex[$currentName]);
+                    $this->_duplicateIndex[$currentName][$dupIdx] = $i + 1;
+                }
+                unset($this->_elements[$i]);
+            }
+        }
+        // Put the element in place finally
+        $this->_elements[$targetIdx] =& $element;
+        if (!$duplicate) {
+            $this->_elementIndex[$elementName] = $targetIdx;
+        } else {
+            $this->_duplicateIndex[$elementName][] = $targetIdx;
+        }
+        $element->onQuickFormEvent('updateValue', null, $this);
+        if ($this->_freezeAll) {
+            $element->freeze();
+        }
+        // If not done, the elements will appear in reverse order
+        ksort($this->_elements);
+        return $element;
+    }
+
+    // }}}
+    // {{{ addGroup()
+
+    /**
+     * Adds an element group
+     * @param    array      $elements       array of elements composing the group
+     * @param    string     $name           (optional)group name
+     * @param    string     $groupLabel     (optional)group label
+     * @param    string     $separator      (optional)string to separate elements
+     * @param    string     $appendName     (optional)specify whether the group name should be
+     *                                      used in the form element name ex: group[element]
+     * @return   HTML_QuickForm_group       reference to a newly added group
+     * @since    2.8
+     * @access   public
+     * @throws   HTML_QuickForm_Error
+     */
+    function &addGroup($elements, $name=null, $groupLabel='', $separator=null, $appendName = true)
+    {
+        static $anonGroups = 1;
+
+        if (0 == strlen($name)) {
+            $name       = 'qf_group_' . $anonGroups++;
+            $appendName = false;
+        }
+        $group =& $this->addElement('group', $name, $groupLabel, $elements, $separator, $appendName);
+        return $group;
+    } // end func addGroup
+
+    // }}}
+    // {{{ &getElement()
+
+    /**
+     * Returns a reference to the element
+     *
+     * @param     string     $element    Element name
+     * @since     2.0
+     * @access    public
+     * @return    HTML_QuickForm_element    reference to element
+     * @throws    HTML_QuickForm_Error
+     */
+    function &getElement($element)
+    {
+        if (isset($this->_elementIndex[$element])) {
+            return $this->_elements[$this->_elementIndex[$element]];
+        } else {
+            $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElement()", 'HTML_QuickForm_Error', true);
+            return $error;
+        }
+    } // end func getElement
+
+    // }}}
+    // {{{ &getElementValue()
+
+    /**
+     * Returns the element's raw value
+     *
+     * This returns the value as submitted by the form (not filtered)
+     * or set via setDefaults() or setConstants()
+     *
+     * @param     string     $element    Element name
+     * @since     2.0
+     * @access    public
+     * @return    mixed     element value
+     * @throws    HTML_QuickForm_Error
+     */
+    function &getElementValue($element)
+    {
+        if (!isset($this->_elementIndex[$element])) {
+            $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElementValue()", 'HTML_QuickForm_Error', true);
+            return $error;
+        }
+        $value = $this->_elements[$this->_elementIndex[$element]]->getValue();
+        if (isset($this->_duplicateIndex[$element])) {
+            foreach ($this->_duplicateIndex[$element] as $index) {
+                if (null !== ($v = $this->_elements[$index]->getValue())) {
+                    if (is_array($value)) {
+                        $value[] = $v;
+                    } else {
+                        $value = (null === $value)? $v: array($value, $v);
+                    }
+                }
+            }
+        }
+        return $value;
+    } // end func getElementValue
+
+    // }}}
+    // {{{ getSubmitValue()
+
+    /**
+     * Returns the elements value after submit and filter
+     *
+     * @param     string     Element name
+     * @since     2.0
+     * @access    public
+     * @return    mixed     submitted element value or null if not set
+     */
+    function getSubmitValue($elementName)
+    {
+        $value = null;
+        if (isset($this->_submitValues[$elementName]) || isset($this->_submitFiles[$elementName])) {
+            $value = isset($this->_submitValues[$elementName])? $this->_submitValues[$elementName]: array();
+            if (is_array($value) && isset($this->_submitFiles[$elementName])) {
+                foreach ($this->_submitFiles[$elementName] as $k => $v) {
+                    $value = HTML_QuickForm::arrayMerge($value, $this->_reindexFiles($this->_submitFiles[$elementName][$k], $k));
+                }
+            }
+
+        } elseif ('file' == $this->getElementType($elementName)) {
+            return $this->getElementValue($elementName);
+
+        } elseif (false !== ($pos = strpos($elementName, '['))) {
+            $base = str_replace(
+                        array('\\', '\''), array('\\\\', '\\\''),
+                        substr($elementName, 0, $pos)
+                    );
+
+            $keys = str_replace(
+                array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"),
+                substr($elementName, $pos + 1, -1)
+                );
+            $idx  = "['" . $keys . "']";
+            $keyArray = explode("']['", $keys);
+
+            if (isset($this->_submitValues[$base])) {
+                $value = HTML_QuickForm_utils::recursiveValue($this->_submitValues[$base], $keyArray, NULL);
+            }
+
+            if ((is_array($value) || null === $value) && isset($this->_submitFiles[$base])) {
+                $props = array('name', 'type', 'size', 'tmp_name', 'error');
+                $code  = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n" .
+                         "    return null;\n" .
+                         "} else {\n" .
+                         "    \$v = array();\n";
+                foreach ($props as $prop) {
+                    $code .= "    \$v = HTML_QuickForm::arrayMerge(\$v, \$this->_reindexFiles(\$this->_submitFiles['{$base}']['{$prop}']{$idx}, '{$prop}'));\n";
+                }
+                $fileValue = eval($code . "    return \$v;\n}\n");
+                if (null !== $fileValue) {
+                    $value = null === $value? $fileValue: HTML_QuickForm::arrayMerge($value, $fileValue);
+                }
+            }
+        }
+
+        // This is only supposed to work for groups with appendName = false
+        if (null === $value && 'group' == $this->getElementType($elementName)) {
+            $group    =& $this->getElement($elementName);
+            $elements =& $group->getElements();
+            foreach (array_keys($elements) as $key) {
+                $name = $group->getElementName($key);
+                // prevent endless recursion in case of radios and such
+                if ($name != $elementName) {
+                    if (null !== ($v = $this->getSubmitValue($name))) {
+                        $value[$name] = $v;
+                    }
+                }
+            }
+        }
+        return $value;
+    } // end func getSubmitValue
+
+    // }}}
+    // {{{ _reindexFiles()
+
+   /**
+    * A helper function to change the indexes in $_FILES array
+    *
+    * @param  mixed   Some value from the $_FILES array
+    * @param  string  The key from the $_FILES array that should be appended
+    * @return array
+    */
+    function _reindexFiles($value, $key)
+    {
+        if (!is_array($value)) {
+            return array($key => $value);
+        } else {
+            $ret = array();
+            foreach ($value as $k => $v) {
+                $ret[$k] = $this->_reindexFiles($v, $key);
+            }
+            return $ret;
+        }
+    }
+
+    // }}}
+    // {{{ getElementError()
+
+    /**
+     * Returns error corresponding to validated element
+     *
+     * @param     string    $element        Name of form element to check
+     * @since     1.0
+     * @access    public
+     * @return    string    error message corresponding to checked element
+     */
+    function getElementError($element)
+    {
+        if (isset($this->_errors[$element])) {
+            return $this->_errors[$element];
+        }
+    } // end func getElementError
+
+    // }}}
+    // {{{ setElementError()
+
+    /**
+     * Set error message for a form element
+     *
+     * @param     string    $element    Name of form element to set error for
+     * @param     string    $message    Error message, if empty then removes the current error message
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setElementError($element, $message = null)
+    {
+        if (!empty($message)) {
+            $this->_errors[$element] = $message;
+        } else {
+            unset($this->_errors[$element]);
+        }
+    } // end func setElementError
+
+     // }}}
+     // {{{ getElementType()
+
+     /**
+      * Returns the type of the given element
+      *
+      * @param      string    $element    Name of form element
+      * @since      1.1
+      * @access     public
+      * @return     string    Type of the element, false if the element is not found
+      */
+     function getElementType($element)
+     {
+         if (isset($this->_elementIndex[$element])) {
+             return $this->_elements[$this->_elementIndex[$element]]->getType();
+         }
+         return false;
+     } // end func getElementType
+
+     // }}}
+     // {{{ updateElementAttr()
+
+    /**
+     * Updates Attributes for one or more elements
+     *
+     * @param      mixed    $elements   Array of element names/objects or string of elements to be updated
+     * @param      mixed    $attrs      Array or sting of html attributes
+     * @since      2.10
+     * @access     public
+     * @return     void
+     */
+    function updateElementAttr($elements, $attrs)
+    {
+        if (is_string($elements)) {
+            $elements = preg_split('/[ ]?,[ ]?/', $elements);
+        }
+        foreach (array_keys($elements) as $key) {
+            if (is_object($elements[$key]) && is_a($elements[$key], 'HTML_QuickForm_element')) {
+                $elements[$key]->updateAttributes($attrs);
+            } elseif (isset($this->_elementIndex[$elements[$key]])) {
+                $this->_elements[$this->_elementIndex[$elements[$key]]]->updateAttributes($attrs);
+                if (isset($this->_duplicateIndex[$elements[$key]])) {
+                    foreach ($this->_duplicateIndex[$elements[$key]] as $index) {
+                        $this->_elements[$index]->updateAttributes($attrs);
+                    }
+                }
+            }
+        }
+    } // end func updateElementAttr
+
+    // }}}
+    // {{{ removeElement()
+
+    /**
+     * Removes an element
+     *
+     * The method "unlinks" an element from the form, returning the reference
+     * to the element object. If several elements named $elementName exist,
+     * it removes the first one, leaving the others intact.
+     *
+     * @param string    $elementName The element name
+     * @param boolean   $removeRules True if rules for this element are to be removed too
+     * @access public
+     * @since 2.0
+     * @return HTML_QuickForm_element    a reference to the removed element
+     * @throws HTML_QuickForm_Error
+     */
+    function &removeElement($elementName, $removeRules = true)
+    {
+        if (!isset($this->_elementIndex[$elementName])) {
+            $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$elementName' does not exist in HTML_QuickForm::removeElement()", 'HTML_QuickForm_Error', true);
+            return $error;
+        }
+        $el =& $this->_elements[$this->_elementIndex[$elementName]];
+        unset($this->_elements[$this->_elementIndex[$elementName]]);
+        if (empty($this->_duplicateIndex[$elementName])) {
+            unset($this->_elementIndex[$elementName]);
+        } else {
+            $this->_elementIndex[$elementName] = array_shift($this->_duplicateIndex[$elementName]);
+        }
+        if ($removeRules) {
+            $this->_required = array_diff($this->_required, array($elementName));
+            unset($this->_rules[$elementName], $this->_errors[$elementName]);
+            if ('group' == $el->getType()) {
+                foreach (array_keys($el->getElements()) as $key) {
+                    unset($this->_rules[$el->getElementName($key)]);
+                }
+            }
+        }
+        return $el;
+    } // end func removeElement
+
+    // }}}
+    // {{{ addRule()
+
+    /**
+     * Adds a validation rule for the given field
+     *
+     * If the element is in fact a group, it will be considered as a whole.
+     * To validate grouped elements as separated entities,
+     * use addGroupRule instead of addRule.
+     *
+     * @param    string     $element       Form element name
+     * @param    string     $message       Message to display for invalid data
+     * @param    string     $type          Rule type, use getRegisteredRules() to get types
+     * @param    string     $format        (optional)Required for extra rule data
+     * @param    string     $validation    (optional)Where to perform validation: "server", "client"
+     * @param    boolean    $reset         Client-side validation: reset the form element to its original value if there is an error?
+     * @param    boolean    $force         Force the rule to be applied, even if the target form element does not exist
+     * @since    1.0
+     * @access   public
+     * @throws   HTML_QuickForm_Error
+     */
+    function addRule($element, $message, $type, $format=null, $validation='server', $reset = false, $force = false)
+    {
+        if (!$force) {
+            if (!is_array($element) && !$this->elementExists($element)) {
+                return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
+            } elseif (is_array($element)) {
+                foreach ($element as $el) {
+                    if (!$this->elementExists($el)) {
+                        return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$el' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
+                    }
+                }
+            }
+        }
+        if (false === ($newName = $this->isRuleRegistered($type, true))) {
+            return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
+        } elseif (is_string($newName)) {
+            $type = $newName;
+        }
+        if (is_array($element)) {
+            $dependent = $element;
+            $element   = array_shift($dependent);
+        } else {
+            $dependent = null;
+        }
+        if ($type == 'required' || $type == 'uploadedfile') {
+            $this->_required[] = $element;
+        }
+        if (!isset($this->_rules[$element])) {
+            $this->_rules[$element] = array();
+        }
+        if ($validation == 'client') {
+            $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);'));
+        }
+        $this->_rules[$element][] = array(
+            'type'        => $type,
+            'format'      => $format,
+            'message'     => $message,
+            'validation'  => $validation,
+            'reset'       => $reset,
+            'dependent'   => $dependent
+        );
+    } // end func addRule
+
+    // }}}
+    // {{{ addGroupRule()
+
+    /**
+     * Adds a validation rule for the given group of elements
+     *
+     * Only groups with a name can be assigned a validation rule
+     * Use addGroupRule when you need to validate elements inside the group.
+     * Use addRule if you need to validate the group as a whole. In this case,
+     * the same rule will be applied to all elements in the group.
+     * Use addRule if you need to validate the group against a function.
+     *
+     * @param    string     $group         Form group name
+     * @param    mixed      $arg1          Array for multiple elements or error message string for one element
+     * @param    string     $type          (optional)Rule type use getRegisteredRules() to get types
+     * @param    string     $format        (optional)Required for extra rule data
+     * @param    int        $howmany       (optional)How many valid elements should be in the group
+     * @param    string     $validation    (optional)Where to perform validation: "server", "client"
+     * @param    bool       $reset         Client-side: whether to reset the element's value to its original state if validation failed.
+     * @since    2.5
+     * @access   public
+     * @throws   HTML_QuickForm_Error
+     */
+    function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $validation = 'server', $reset = false)
+    {
+        if (!$this->elementExists($group)) {
+            return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Group '$group' does not exist in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
+        }
+
+        $groupObj =& $this->getElement($group);
+        if (is_array($arg1)) {
+            $required = 0;
+            foreach ($arg1 as $elementIndex => $rules) {
+                $elementName = $groupObj->getElementName($elementIndex);
+                foreach ($rules as $rule) {
+                    $format = (isset($rule[2])) ? $rule[2] : null;
+                    $validation = (isset($rule[3]) && 'client' == $rule[3])? 'client': 'server';
+                    $reset = isset($rule[4]) && $rule[4];
+                    $type = $rule[1];
+                    if (false === ($newName = $this->isRuleRegistered($type, true))) {
+                        return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
+                    } elseif (is_string($newName)) {
+                        $type = $newName;
+                    }
+
+                    $this->_rules[$elementName][] = array(
+                                                        'type'        => $type,
+                                                        'format'      => $format,
+                                                        'message'     => $rule[0],
+                                                        'validation'  => $validation,
+                                                        'reset'       => $reset,
+                                                        'group'       => $group);
+
+                    if ('required' == $type || 'uploadedfile' == $type) {
+                        $groupObj->_required[] = $elementName;
+                        $this->_required[] = $elementName;
+                        $required++;
+                    }
+                    if ('client' == $validation) {
+                        $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);'));
+                    }
+                }
+            }
+            if ($required > 0 && count($groupObj->getElements()) == $required) {
+                $this->_required[] = $group;
+            }
+        } elseif (is_string($arg1)) {
+            if (false === ($newName = $this->isRuleRegistered($type, true))) {
+                return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
+            } elseif (is_string($newName)) {
+                $type = $newName;
+            }
+
+            // addGroupRule() should also handle <select multiple>
+            if (is_a($groupObj, 'html_quickform_group')) {
+                // Radios need to be handled differently when required
+                if ($type == 'required' && $groupObj->getGroupType() == 'radio') {
+                    $howmany = ($howmany == 0) ? 1 : $howmany;
+                } else {
+                    $howmany = ($howmany == 0) ? count($groupObj->getElements()) : $howmany;
+                }
+            }
+
+            $this->_rules[$group][] = array('type'       => $type,
+                                            'format'     => $format,
+                                            'message'    => $arg1,
+                                            'validation' => $validation,
+                                            'howmany'    => $howmany,
+                                            'reset'      => $reset);
+            if ($type == 'required') {
+                $this->_required[] = $group;
+            }
+            if ($validation == 'client') {
+                $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);'));
+            }
+        }
+    } // end func addGroupRule
+
+    // }}}
+    // {{{ addFormRule()
+
+   /**
+    * Adds a global validation rule
+    *
+    * This should be used when for a rule involving several fields or if
+    * you want to use some completely custom validation for your form.
+    * The rule function/method should return true in case of successful
+    * validation and array('element name' => 'error') when there were errors.
+    *
+    * @access   public
+    * @param    mixed   Callback, either function name or array(&$object, 'method')
+    * @throws   HTML_QuickForm_Error
+    */
+    function addFormRule($rule)
+    {
+        if (!is_callable($rule)) {
+            return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, 'Callback function does not exist in HTML_QuickForm::addFormRule()', 'HTML_QuickForm_Error', true);
+        }
+        $this->_formRules[] = $rule;
+    }
+
+    // }}}
+    // {{{ applyFilter()
+
+    /**
+     * Applies a data filter for the given field(s)
+     *
+     * @param    mixed     $element       Form element name or array of such names
+     * @param    mixed     $filter        Callback, either function name or array(&$object, 'method')
+     * @since    2.0
+     * @access   public
+     * @throws   HTML_QuickForm_Error
+     */
+    function applyFilter($element, $filter)
+    {
+        if (!is_callable($filter)) {
+            return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::applyFilter()", 'HTML_QuickForm_Error', true);
+        }
+        if ($element == '__ALL__') {
+            $this->_submitValues = $this->_recursiveFilter($filter, $this->_submitValues);
+        } else {
+            if (!is_array($element)) {
+                $element = array($element);
+            }
+            foreach ($element as $elName) {
+                $value = $this->getSubmitValue($elName);
+                if (null !== $value) {
+                    if (false === strpos($elName, '[')) {
+                        $this->_submitValues[$elName] = $this->_recursiveFilter($filter, $value);
+                    } else {
+                        $idx  = "['" . str_replace(
+                                    array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"),
+                                    $elName
+                                ) . "']";
+                        eval("\$this->_submitValues{$idx} = \$this->_recursiveFilter(\$filter, \$value);");
+                    }
+                }
+            }
+        }
+    } // end func applyFilter
+
+    // }}}
+    // {{{ _recursiveFilter()
+
+    /**
+     * Recursively apply a filter function
+     *
+     * @param     string   $filter    filter to apply
+     * @param     mixed    $value     submitted values
+     * @since     2.0
+     * @access    private
+     * @return    cleaned values
+     */
+    function _recursiveFilter($filter, $value)
+    {
+        if (is_array($value)) {
+            $cleanValues = array();
+            foreach ($value as $k => $v) {
+                $cleanValues[$k] = $this->_recursiveFilter($filter, $v);
+            }
+            return $cleanValues;
+        } else {
+            return call_user_func($filter, $value);
+        }
+    } // end func _recursiveFilter
+
+    // }}}
+    // {{{ arrayMerge()
+
+   /**
+    * Merges two arrays
+    *
+    * Merges two array like the PHP function array_merge but recursively.
+    * The main difference is that existing keys will not be renumbered
+    * if they are integers.
+    *
+    * @access   public
+    * @param    array   $a  original array
+    * @param    array   $b  array which will be merged into first one
+    * @return   array   merged array
+    */
+    function arrayMerge($a, $b)
+    {
+        foreach ($b as $k => $v) {
+            if (is_array($v)) {
+                if (isset($a[$k]) && !is_array($a[$k])) {
+                    $a[$k] = $v;
+                } else {
+                    if (!isset($a[$k])) {
+                        $a[$k] = array();
+                    }
+                    $a[$k] = HTML_QuickForm::arrayMerge($a[$k], $v);
+                }
+            } else {
+                $a[$k] = $v;
+            }
+        }
+        return $a;
+    } // end func arrayMerge
+
+    // }}}
+    // {{{ isTypeRegistered()
+
+    /**
+     * Returns whether or not the form element type is supported
+     *
+     * @param     string   $type     Form element type
+     * @since     1.0
+     * @access    public
+     * @return    boolean
+     */
+    function isTypeRegistered($type)
+    {
+        return isset($GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][strtolower($type)]);
+    } // end func isTypeRegistered
+
+    // }}}
+    // {{{ getRegisteredTypes()
+
+    /**
+     * Returns an array of registered element types
+     *
+     * @since     1.0
+     * @access    public
+     * @return    array
+     */
+    function getRegisteredTypes()
+    {
+        return array_keys($GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES']);
+    } // end func getRegisteredTypes
+
+    // }}}
+    // {{{ isRuleRegistered()
+
+    /**
+     * Returns whether or not the given rule is supported
+     *
+     * @param     string   $name    Validation rule name
+     * @param     bool     Whether to automatically register subclasses of HTML_QuickForm_Rule
+     * @since     1.0
+     * @access    public
+     * @return    mixed    true if previously registered, false if not, new rule name if auto-registering worked
+     */
+    function isRuleRegistered($name, $autoRegister = false)
+    {
+        if (is_scalar($name) && isset($GLOBALS['_HTML_QuickForm_registered_rules'][$name])) {
+            return true;
+        } elseif (!$autoRegister) {
+            return false;
+        }
+        // automatically register the rule if requested
+        include_once 'HTML/QuickForm/RuleRegistry.php';
+        $ruleName = false;
+        if (is_object($name) && is_a($name, 'html_quickform_rule')) {
+            $ruleName = !empty($name->name)? $name->name: strtolower(get_class($name));
+        } elseif (is_string($name) && class_exists($name)) {
+            $parent = strtolower($name);
+            do {
+                if ('html_quickform_rule' == strtolower($parent)) {
+                    $ruleName = strtolower($name);
+                    break;
+                }
+            } while ($parent = get_parent_class($parent));
+        }
+        if ($ruleName) {
+            $registry =& HTML_QuickForm_RuleRegistry::singleton();
+            $registry->registerRule($ruleName, null, $name);
+        }
+        return $ruleName;
+    } // end func isRuleRegistered
+
+    // }}}
+    // {{{ getRegisteredRules()
+
+    /**
+     * Returns an array of registered validation rules
+     *
+     * @since     1.0
+     * @access    public
+     * @return    array
+     */
+    function getRegisteredRules()
+    {
+        return array_keys($GLOBALS['_HTML_QuickForm_registered_rules']);
+    } // end func getRegisteredRules
+
+    // }}}
+    // {{{ isElementRequired()
+
+    /**
+     * Returns whether or not the form element is required
+     *
+     * @param     string   $element     Form element name
+     * @since     1.0
+     * @access    public
+     * @return    boolean
+     */
+    function isElementRequired($element)
+    {
+        return in_array($element, $this->_required, true);
+    } // end func isElementRequired
+
+    // }}}
+    // {{{ isElementFrozen()
+
+    /**
+     * Returns whether or not the form element is frozen
+     *
+     * @param     string   $element     Form element name
+     * @since     1.0
+     * @access    public
+     * @return    boolean
+     */
+    function isElementFrozen($element)
+    {
+         if (isset($this->_elementIndex[$element])) {
+             return $this->_elements[$this->_elementIndex[$element]]->isFrozen();
+         }
+         return false;
+    } // end func isElementFrozen
+
+    // }}}
+    // {{{ setJsWarnings()
+
+    /**
+     * Sets JavaScript warning messages
+     *
+     * @param     string   $pref        Prefix warning
+     * @param     string   $post        Postfix warning
+     * @since     1.1
+     * @access    public
+     * @return    void
+     */
+    function setJsWarnings($pref, $post)
+    {
+        $this->_jsPrefix = $pref;
+        $this->_jsPostfix = $post;
+    } // end func setJsWarnings
+
+    // }}}
+    // {{{ setRequiredNote()
+
+    /**
+     * Sets required-note
+     *
+     * @param     string   $note        Message indicating some elements are required
+     * @since     1.1
+     * @access    public
+     * @return    void
+     */
+    function setRequiredNote($note)
+    {
+        $this->_requiredNote = $note;
+    } // end func setRequiredNote
+
+    // }}}
+    // {{{ getRequiredNote()
+
+    /**
+     * Returns the required note
+     *
+     * @since     2.0
+     * @access    public
+     * @return    string
+     */
+    function getRequiredNote()
+    {
+        return $this->_requiredNote;
+    } // end func getRequiredNote
+
+    // }}}
+    // {{{ validate()
+
+    /**
+     * Performs the server side validation
+     * @access    public
+     * @since     1.0
+     * @return    boolean   true if no error found
+     * @throws    HTML_QuickForm_Error
+     */
+    function validate()
+    {
+        if (count($this->_rules) == 0 && count($this->_formRules) == 0 &&
+            $this->isSubmitted()) {
+            return (0 == count($this->_errors));
+        } elseif (!$this->isSubmitted()) {
+            return false;
+        }
+
+        include_once('HTML/QuickForm/RuleRegistry.php');
+        $registry =& HTML_QuickForm_RuleRegistry::singleton();
+
+        foreach ($this->_rules as $target => $rules) {
+            $submitValue = $this->getSubmitValue($target);
+
+            foreach ($rules as $rule) {
+                if ((isset($rule['group']) && isset($this->_errors[$rule['group']])) ||
+                     isset($this->_errors[$target])) {
+                    continue 2;
+                }
+                // If element is not required and is empty, we shouldn't validate it
+                if (!$this->isElementRequired($target)) {
+                    if (!isset($submitValue) || '' == $submitValue) {
+                        continue 2;
+                    // Fix for bug #3501: we shouldn't validate not uploaded files, either.
+                    // Unfortunately, we can't just use $element->isUploadedFile() since
+                    // the element in question can be buried in group. Thus this hack.
+                    // See also bug #12014, we should only consider a file that has
+                    // status UPLOAD_ERR_NO_FILE as not uploaded, in all other cases
+                    // validation should be performed, so that e.g. 'maxfilesize' rule
+                    // will display an error if status is UPLOAD_ERR_INI_SIZE
+                    // or UPLOAD_ERR_FORM_SIZE
+                    } elseif (is_array($submitValue)) {
+                        if (false === ($pos = strpos($target, '['))) {
+                            $isUpload = !empty($this->_submitFiles[$target]);
+                        } else {
+                            $base = str_replace(
+                                        array('\\', '\''), array('\\\\', '\\\''),
+                                        substr($target, 0, $pos)
+                                    );
+                            $idx  = "['" . str_replace(
+                                        array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"),
+                                        substr($target, $pos + 1, -1)
+                                    ) . "']";
+                            eval("\$isUpload = isset(\$this->_submitFiles['{$base}']['name']{$idx});");
+                        }
+                        if ($isUpload && (!isset($submitValue['error']) || UPLOAD_ERR_NO_FILE == $submitValue['error'])) {
+                            continue 2;
+                        }
+                    }
+                }
+                if (isset($rule['dependent']) && is_array($rule['dependent'])) {
+                    $values = array($submitValue);
+                    foreach ($rule['dependent'] as $elName) {
+                        $values[] = $this->getSubmitValue($elName);
+                    }
+                    $result = $registry->validate($rule['type'], $values, $rule['format'], true);
+                } elseif (is_array($submitValue) && !isset($rule['howmany'])) {
+                    $result = $registry->validate($rule['type'], $submitValue, $rule['format'], true);
+                } else {
+                    $result = $registry->validate($rule['type'], $submitValue, $rule['format'], false);
+                }
+
+                if (!$result || (!empty($rule['howmany']) && $rule['howmany'] > (int)$result)) {
+                    if (isset($rule['group'])) {
+                        $this->_errors[$rule['group']] = $rule['message'];
+                    } else {
+                        $this->_errors[$target] = $rule['message'];
+                    }
+                }
+            }
+        }
+
+        // process the global rules now
+        foreach ($this->_formRules as $rule) {
+            if (true !== ($res = call_user_func($rule, $this->_submitValues, $this->_submitFiles))) {
+                if (is_array($res)) {
+                    $this->_errors += $res;
+                } else {
+                    return PEAR::raiseError(null, QUICKFORM_ERROR, null, E_USER_WARNING, 'Form rule callback returned invalid value in HTML_QuickForm::validate()', 'HTML_QuickForm_Error', true);
+                }
+            }
+        }
+
+        return (0 == count($this->_errors));
+    } // end func validate
+
+    // }}}
+    // {{{ freeze()
+
+    /**
+     * Displays elements without HTML input tags
+     *
+     * @param    mixed   $elementList       array or string of element(s) to be frozen
+     * @since     1.0
+     * @access   public
+     * @throws   HTML_QuickForm_Error
+     */
+    function freeze($elementList=null)
+    {
+        if (!isset($elementList)) {
+            $this->_freezeAll = true;
+            $elementList = array();
+        } else {
+            if (!is_array($elementList)) {
+                $elementList = preg_split('/[ ]*,[ ]*/', $elementList);
+            }
+            $elementList = array_flip($elementList);
+        }
+
+        foreach (array_keys($this->_elements) as $key) {
+            $name = $this->_elements[$key]->getName();
+            if ($this->_freezeAll || isset($elementList[$name])) {
+                $this->_elements[$key]->freeze();
+                unset($elementList[$name]);
+            }
+        }
+
+        if (!empty($elementList)) {
+            return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '" . implode("', '", array_keys($elementList)) . "' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true);
+        }
+        return true;
+    } // end func freeze
+
+    // }}}
+    // {{{ isFrozen()
+
+    /**
+     * Returns whether or not the whole form is frozen
+     *
+     * @since     3.0
+     * @access    public
+     * @return    boolean
+     */
+    function isFrozen()
+    {
+         return $this->_freezeAll;
+    } // end func isFrozen
+
+    // }}}
+    // {{{ process()
+
+    /**
+     * Performs the form data processing
+     *
+     * @param    mixed     $callback        Callback, either function name or array(&$object, 'method')
+     * @param    bool      $mergeFiles      Whether uploaded files should be processed too
+     * @since    1.0
+     * @access   public
+     * @throws   HTML_QuickForm_Error
+     * @return   mixed     Whatever value the $callback function returns
+     */
+    function process($callback, $mergeFiles = true)
+    {
+        if (!is_callable($callback)) {
+            return PEAR::raiseError(null, QUICKFORM_INVALID_PROCESS, null, E_USER_WARNING, "Callback function does not exist in QuickForm::process()", 'HTML_QuickForm_Error', true);
+        }
+        $values = ($mergeFiles === true) ? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles) : $this->_submitValues;
+        return call_user_func($callback, $values);
+    } // end func process
+
+    // }}}
+    // {{{ accept()
+
+   /**
+    * Accepts a renderer
+    *
+    * @param object     An HTML_QuickForm_Renderer object
+    * @since 3.0
+    * @access public
+    * @return void
+    */
+    function accept(&$renderer)
+    {
+        $renderer->startForm($this);
+        foreach (array_keys($this->_elements) as $key) {
+            $element =& $this->_elements[$key];
+            $elementName = $element->getName();
+            $required    = ($this->isElementRequired($elementName) && !$element->isFrozen());
+            $error       = $this->getElementError($elementName);
+            $element->accept($renderer, $required, $error);
+        }
+        $renderer->finishForm($this);
+    } // end func accept
+
+    // }}}
+    // {{{ defaultRenderer()
+
+   /**
+    * Returns a reference to default renderer object
+    *
+    * @access public
+    * @since 3.0
+    * @return object a default renderer object
+    */
+    function &defaultRenderer()
+    {
+        if (!isset($GLOBALS['_HTML_QuickForm_default_renderer'])) {
+            include_once('HTML/QuickForm/Renderer/Default.php');
+            $GLOBALS['_HTML_QuickForm_default_renderer'] = new HTML_QuickForm_Renderer_Default();
+        }
+        return $GLOBALS['_HTML_QuickForm_default_renderer'];
+    } // end func defaultRenderer
+
+    // }}}
+    // {{{ toHtml ()
+
+    /**
+     * Returns an HTML version of the form
+     *
+     * @param string $in_data (optional) Any extra data to insert right
+     *               before form is rendered.  Useful when using templates.
+     *
+     * @return   string     Html version of the form
+     * @since     1.0
+     * @access   public
+     */
+    function toHtml ($in_data = null)
+    {
+        if (!is_null($in_data)) {
+            $this->addElement('html', $in_data);
+        }
+        $renderer =& $this->defaultRenderer();
+        $this->accept($renderer);
+        return $renderer->toHtml();
+    } // end func toHtml
+
+    // }}}
+    // {{{ getValidationScript()
+
+    /**
+     * Returns the client side validation script
+     *
+     * @since     2.0
+     * @access    public
+     * @return    string    Javascript to perform validation, empty string if no 'client' rules were added
+     */
+    function getValidationScript()
+    {
+        if (empty($this->_rules) || empty($this->_attributes['onsubmit'])) {
+            return '';
+        }
+
+        include_once('HTML/QuickForm/RuleRegistry.php');
+        $registry =& HTML_QuickForm_RuleRegistry::singleton();
+        $test = array();
+        $js_escape = array(
+            "\r"    => '\r',
+            "\n"    => '\n',
+            "\t"    => '\t',
+            "'"     => "\\'",
+            '"'     => '\"',
+            '\\'    => '\\\\'
+        );
+
+        foreach ($this->_rules as $elementName => $rules) {
+            foreach ($rules as $rule) {
+                if ('client' == $rule['validation']) {
+                    unset($element);
+
+                    $dependent  = isset($rule['dependent']) && is_array($rule['dependent']);
+                    $rule['message'] = strtr($rule['message'], $js_escape);
+
+                    if (isset($rule['group'])) {
+                        $group    =& $this->getElement($rule['group']);
+                        // No JavaScript validation for frozen elements
+                        if ($group->isFrozen()) {
+                            continue 2;
+                        }
+                        $elements =& $group->getElements();
+                        foreach (array_keys($elements) as $key) {
+                            if ($elementName == $group->getElementName($key)) {
+                                $element =& $elements[$key];
+                                break;
+                            }
+                        }
+                    } elseif ($dependent) {
+                        $element   =  array();
+                        $element[] =& $this->getElement($elementName);
+                        foreach ($rule['dependent'] as $elName) {
+                            $element[] =& $this->getElement($elName);
+                        }
+                    } else {
+                        $element =& $this->getElement($elementName);
+                    }
+                    // No JavaScript validation for frozen elements
+                    if (is_object($element) && $element->isFrozen()) {
+                        continue 2;
+                    } elseif (is_array($element)) {
+                        foreach (array_keys($element) as $key) {
+                            if ($element[$key]->isFrozen()) {
+                                continue 3;
+                            }
+                        }
+                    }
+
+                    $test[] = $registry->getValidationScript($element, $elementName, $rule);
+                }
+            }
+        }
+        if (count($test) > 0) {
+            return
+                "\n<script type=\"text/javascript\">\n" .
+                "//<![CDATA[\n" .
+                "function validate_" . $this->_attributes['id'] . "(frm) {\n" .
+                "  var value = '';\n" .
+                "  var errFlag = new Array();\n" .
+                "  var _qfGroups = {};\n" .
+                "  _qfMsg = '';\n\n" .
+                join("\n", $test) .
+                "\n  if (_qfMsg != '') {\n" .
+                "    _qfMsg = '" . strtr($this->_jsPrefix, $js_escape) . "' + _qfMsg;\n" .
+                "    _qfMsg = _qfMsg + '\\n" . strtr($this->_jsPostfix, $js_escape) . "';\n" .
+                "    alert(_qfMsg);\n" .
+                "    return false;\n" .
+                "  }\n" .
+                "  return true;\n" .
+                "}\n" .
+                "//]]>\n" .
+                "</script>";
+        }
+        return '';
+    } // end func getValidationScript
+
+    // }}}
+    // {{{ getSubmitValues()
+
+    /**
+     * Returns the values submitted by the form
+     *
+     * @since     2.0
+     * @access    public
+     * @param     bool      Whether uploaded files should be returned too
+     * @return    array
+     */
+    function getSubmitValues($mergeFiles = false)
+    {
+        return $mergeFiles? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles): $this->_submitValues;
+    } // end func getSubmitValues
+
+    // }}}
+    // {{{ toArray()
+
+    /**
+     * Returns the form's contents in an array.
+     *
+     * The description of the array structure is in HTML_QuickForm_Renderer_Array docs
+     *
+     * @since     2.0
+     * @access    public
+     * @param     bool      Whether to collect hidden elements (passed to the Renderer's constructor)
+     * @return    array of form contents
+     */
+    function toArray($collectHidden = false)
+    {
+        include_once 'HTML/QuickForm/Renderer/Array.php';
+        $renderer = new HTML_QuickForm_Renderer_Array($collectHidden);
+        $this->accept($renderer);
+        return $renderer->toArray();
+     } // end func toArray
+
+    // }}}
+    // {{{ exportValue()
+
+    /**
+     * Returns a 'safe' element's value
+     *
+     * This method first tries to find a cleaned-up submitted value,
+     * it will return a value set by setValue()/setDefaults()/setConstants()
+     * if submitted value does not exist for the given element.
+     *
+     * @param  string   Name of an element
+     * @access public
+     * @return mixed
+     * @throws HTML_QuickForm_Error
+     */
+    function exportValue($element)
+    {
+        if (!isset($this->_elementIndex[$element])) {
+            return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElementValue()", 'HTML_QuickForm_Error', true);
+        }
+        $value = $this->_elements[$this->_elementIndex[$element]]->exportValue($this->_submitValues, false);
+        if (isset($this->_duplicateIndex[$element])) {
+            foreach ($this->_duplicateIndex[$element] as $index) {
+                if (null !== ($v = $this->_elements[$index]->exportValue($this->_submitValues, false))) {
+                    if (is_array($value)) {
+                        $value[] = $v;
+                    } else {
+                        $value = (null === $value)? $v: array($value, $v);
+                    }
+                }
+            }
+        }
+        return $value;
+    }
+
+    // }}}
+    // {{{ exportValues()
+
+    /**
+     * Returns 'safe' elements' values
+     *
+     * Unlike getSubmitValues(), this will return only the values
+     * corresponding to the elements present in the form.
+     *
+     * @param   mixed   Array/string of element names, whose values we want. If not set then return all elements.
+     * @access  public
+     * @return  array   An assoc array of elements' values
+     * @throws  HTML_QuickForm_Error
+     */
+    function exportValues($elementList = null)
+    {
+        $values = array();
+        if (null === $elementList) {
+            // iterate over all elements, calling their exportValue() methods
+            foreach (array_keys($this->_elements) as $key) {
+                $value = $this->_elements[$key]->exportValue($this->_submitValues, true);
+                if (is_array($value)) {
+                    // This shit throws a bogus warning in PHP 4.3.x
+                    $values = HTML_QuickForm::arrayMerge($values, $value);
+                }
+            }
+        } else {
+            if (!is_array($elementList)) {
+                $elementList = array_map('trim', explode(',', $elementList));
+            }
+            foreach ($elementList as $elementName) {
+                $value = $this->exportValue($elementName);
+                if (PEAR::isError($value)) {
+                    return $value;
+                }
+                $values[$elementName] = $value;
+            }
+        }
+        return $values;
+    }
+
+    // }}}
+    // {{{ isSubmitted()
+
+   /**
+    * Tells whether the form was already submitted
+    *
+    * This is useful since the _submitFiles and _submitValues arrays
+    * may be completely empty after the trackSubmit value is removed.
+    *
+    * @access public
+    * @return bool
+    */
+    function isSubmitted()
+    {
+        return $this->_flagSubmitted;
+    }
+
+
+    // }}}
+    // {{{ isError()
+
+    /**
+     * Tell whether a result from a QuickForm method is an error (an instance of HTML_QuickForm_Error)
+     *
+     * @access public
+     * @param mixed     result code
+     * @return bool     whether $value is an error
+     * @static
+     */
+    function isError($value)
+    {
+        return (is_object($value) && is_a($value, 'html_quickform_error'));
+    } // end func isError
+
+    // }}}
+    // {{{ errorMessage()
+
+    /**
+     * Return a textual error message for an QuickForm error code
+     *
+     * @access  public
+     * @param   int     error code
+     * @return  string  error message
+     * @static
+     */
+    function errorMessage($value)
+    {
+        // make the variable static so that it only has to do the defining on the first call
+        static $errorMessages;
+
+        // define the varies error messages
+        if (!isset($errorMessages)) {
+            $errorMessages = array(
+                QUICKFORM_OK                    => 'no error',
+                QUICKFORM_ERROR                 => 'unknown error',
+                QUICKFORM_INVALID_RULE          => 'the rule does not exist as a registered rule',
+                QUICKFORM_NONEXIST_ELEMENT      => 'nonexistent html element',
+                QUICKFORM_INVALID_FILTER        => 'invalid filter',
+                QUICKFORM_UNREGISTERED_ELEMENT  => 'unregistered element',
+                QUICKFORM_INVALID_ELEMENT_NAME  => 'element already exists',
+                QUICKFORM_INVALID_PROCESS       => 'process callback does not exist',
+                QUICKFORM_DEPRECATED            => 'method is deprecated',
+                QUICKFORM_INVALID_DATASOURCE    => 'datasource is not an object'
+            );
+        }
+
+        // If this is an error object, then grab the corresponding error code
+        if (HTML_QuickForm::isError($value)) {
+            $value = $value->getCode();
+        }
+
+        // return the textual error message corresponding to the code
+        return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[QUICKFORM_ERROR];
+    } // end func errorMessage
+
+    // }}}
+} // end class HTML_QuickForm
+
+/**
+ * Class for errors thrown by HTML_QuickForm package
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ */
+class HTML_QuickForm_Error extends PEAR_Error {
+
+    // {{{ properties
+
+    /**
+    * Prefix for all error messages
+    * @var string
+    */
+    var $error_message_prefix = 'QuickForm Error: ';
+
+    // }}}
+    // {{{ constructor
+
+    /**
+    * Creates a quickform error object, extending the PEAR_Error class
+    *
+    * @param int   $code the error code
+    * @param int   $mode the reaction to the error, either return, die or trigger/callback
+    * @param int   $level intensity of the error (PHP error code)
+    * @param mixed $debuginfo any information that can inform user as to nature of the error
+    */
+    function HTML_QuickForm_Error($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN,
+                         $level = E_USER_NOTICE, $debuginfo = null)
+    {
+        if (is_int($code)) {
+            $this->PEAR_Error(HTML_QuickForm::errorMessage($code), $code, $mode, $level, $debuginfo);
+        } else {
+            $this->PEAR_Error("Invalid error code: $code", QUICKFORM_ERROR, $mode, $level, $debuginfo);
+        }
+    }
+
+    // }}}
+} // end class HTML_QuickForm_Error
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/DHTMLRulesTableless.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/DHTMLRulesTableless.php
new file mode 100644 (file)
index 0000000..e0a8823
--- /dev/null
@@ -0,0 +1,284 @@
+<?php
+/**
+ * DHTML replacement for the standard JavaScript alert window for client-side
+ * validation
+ *
+ * LICENSE:
+ * 
+ * Copyright (c) 2005-2007, Mark Wiesemann <wiesemann@php.net>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the 
+ *      documentation and/or other materials provided with the distribution.
+ *    * The names of the authors may not be used to endorse or promote products 
+ *      derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   HTML
+ * @package    HTML_QuickForm_DHTMLRulesTableless
+ * @author     Alexey Borzov <borz_off@cs.msu.su>
+ * @author     Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author     Bertrand Mansion <bmansion@mamasam.com>
+ * @author     Justin Patrin <papercrane@gmail.com>
+ * @author     Mark Wiesemann <wiesemann@php.net>
+ * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
+ * @version    CVS: $Id: DHTMLRulesTableless.php,v 1.10 2007/10/24 20:36:11 wiesemann Exp $
+ * @link       http://pear.php.net/package/HTML_QuickForm_DHTMLRulesTableless
+ */
+
+require_once 'HTML/QuickForm.php';
+
+/**
+ * This is a DHTML replacement for the standard JavaScript alert window for
+ * client-side validation of forms built with HTML_QuickForm
+ *
+ * @category   HTML
+ * @package    HTML_QuickForm_DHTMLRulesTableless
+ * @author     Alexey Borzov <borz_off@cs.msu.su>
+ * @author     Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author     Bertrand Mansion <bmansion@mamasam.com>
+ * @author     Justin Patrin <papercrane@gmail.com>
+ * @author     Mark Wiesemann <wiesemann@php.net>
+ * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
+ * @version    Release: 0.3.3
+ * @link       http://pear.php.net/package/HTML_QuickForm_DHTMLRulesTableless
+ */
+class HTML_QuickForm_DHTMLRulesTableless extends HTML_QuickForm {
+    // {{{ getValidationScript()
+
+    /**
+     * Returns the client side validation script
+     *
+     * The code here was copied from HTML_QuickForm and slightly modified to run rules per-element
+     *
+     * @access    public
+     * @return    string    Javascript to perform validation, empty string if no 'client' rules were added
+     */
+    function getValidationScript()
+    {
+        if (empty($this->_rules) || empty($this->_attributes['onsubmit'])) {
+            return '';
+        }
+
+        include_once('HTML/QuickForm/RuleRegistry.php');
+        $registry =& HTML_QuickForm_RuleRegistry::singleton();
+        $test = array();
+        $js_escape = array(
+            "\r"    => '\r',
+            "\n"    => '\n',
+            "\t"    => '\t',
+            "'"     => "\\'",
+            '"'     => '\"',
+            '\\'    => '\\\\'
+        );
+
+        foreach ($this->_rules as $elementName => $rules) {
+            foreach ($rules as $rule) {
+                if ('client' == $rule['validation']) {
+                    unset($element);
+
+                    $dependent  = isset($rule['dependent']) && is_array($rule['dependent']);
+                    $rule['message'] = strtr($rule['message'], $js_escape);
+
+                    if (isset($rule['group'])) {
+                        $group    =& $this->getElement($rule['group']);
+                        // No JavaScript validation for frozen elements
+                        if ($group->isFrozen()) {
+                            continue 2;
+                        }
+                        $elements =& $group->getElements();
+                        foreach (array_keys($elements) as $key) {
+                            if ($elementName == $group->getElementName($key)) {
+                                $element =& $elements[$key];
+                                break;
+                            }
+                        }
+                    } elseif ($dependent) {
+                        $element   =  array();
+                        $element[] =& $this->getElement($elementName);
+                        foreach ($rule['dependent'] as $idx => $elName) {
+                            $element[] =& $this->getElement($elName);
+                        }
+                    } else {
+                        $element =& $this->getElement($elementName);
+                    }
+                    // No JavaScript validation for frozen elements
+                    if (is_object($element) && $element->isFrozen()) {
+                        continue 2;
+                    } elseif (is_array($element)) {
+                        foreach (array_keys($element) as $key) {
+                            if ($element[$key]->isFrozen()) {
+                                continue 3;
+                            }
+                        }
+                    }
+
+                    $test[$elementName][] = $registry->getValidationScript($element, $elementName, $rule);
+                }
+            }
+        }
+        $js = '
+<script type="text/javascript"><!--//--><![CDATA[//><!--
+qf_errorHandler = function(element, _qfMsg) {
+  div = element.parentNode;
+  var elementName = element.name.replace(/\[/, "_____");
+  var elementName = elementName.replace(/\]/, "_____");
+  if (_qfMsg != \'\') {
+    span = document.createElement("span");
+    span.className = "error";
+    _qfMsg = _qfMsg.substring(4);
+    span.appendChild(document.createTextNode(_qfMsg));
+    br = document.createElement("br");
+
+    var errorDiv = document.getElementById(elementName + \'_errorDiv\');
+    if (!errorDiv) {
+      errorDiv = document.createElement("div");
+      errorDiv.id = elementName + \'_errorDiv\';
+    } else {
+      if (   div.firstChild.textContent == \'\'
+          || _qfMsg == div.firstChild.textContent
+         ) {
+        return false;
+      }
+    }
+    while (errorDiv.firstChild) {
+      errorDiv.removeChild(errorDiv.firstChild);
+    }
+
+    errorDiv.insertBefore(br, errorDiv.firstChild);
+    errorDiv.insertBefore(span, errorDiv.firstChild);
+
+    errorDivInserted = false;
+    for (var i = element.parentNode.childNodes.length - 1; i >= 0; i--) {
+      j = i - 1;
+      if (j >= 0 && element.parentNode.childNodes[j].nodeName == "DIV") {
+        element.parentNode.insertBefore(errorDiv, element.parentNode.childNodes[i]);
+        errorDivInserted = true;
+        break;
+      }
+    }
+    if (!errorDivInserted) {
+      element.parentNode.insertBefore(errorDiv, element.parentNode.firstChild);
+    }
+
+    if (div.className.substr(div.className.length - 6, 6) != " error"
+        && div.className != "error") {
+      div.className += " error";
+    }
+
+    return false;
+  } else {
+    var errorDiv = document.getElementById(elementName + \'_errorDiv\');
+    if (errorDiv) {
+      errorDiv.parentNode.removeChild(errorDiv);
+    }
+    
+    // do not remove the error style from the div tag if there is still an error
+    // message
+    if (div.firstChild.innerHTML != "") {
+      return true;
+    }
+
+    if (div.className.substr(div.className.length - 6, 6) == " error") {
+      div.className = div.className.substr(0, div.className.length - 6);
+    } else if (div.className == "error") {
+      div.className = "";
+    }
+
+    return true;
+  }
+}';
+        $validateJS = '';
+        foreach ($test as $elementName => $jsArr) {
+            // remove group element part of the element name to avoid JS errors
+            $singleElementName = $elementName;
+            $shortNameForJS = str_replace(array('[', ']'), '__', $elementName);
+            $bracketPos = strpos($elementName, '[');
+            if ($bracketPos !== false) {
+                $singleElementName = substr($elementName, 0, $bracketPos);
+                $groupElementName = substr($elementName, $bracketPos + 1, -1);
+            }
+            if ($bracketPos === false || !$this->elementExists($singleElementName)) {
+                $groupElementName = $elementName;
+                $singleElementName = $elementName;
+            }
+            $id = str_replace('-', '_', $this->_attributes['id']);
+            $js .= '
+validate_' . $id . '_' . $shortNameForJS . ' = function(element) {
+  var value = \'\';
+  var errFlag = new Array();
+  var _qfGroups = {};
+  var _qfMsg = \'\';
+  var frm = element.parentNode;
+  while (frm && frm.nodeName != "FORM") {
+    frm = frm.parentNode;
+  }
+' . join("\n", $jsArr) . '
+  return qf_errorHandler(element, _qfMsg);
+}
+';
+            unset($element);
+            $element =& $this->getElement($singleElementName);
+            $elementNameForJS = 'frm.elements[\'' . $elementName . '\']';
+            if ($element->getType() === 'group' && $singleElementName === $elementName) {
+                $elementNameForJS = 'document.getElementById(\'' . $element->_elements[0]->getAttribute('id') . '\')';
+            }
+            $validateJS .= '
+  ret = validate_' . $id . '_' . $shortNameForJS . '('. $elementNameForJS . ') && ret;';
+            if ($element->getType() !== 'group') {  // not a group
+                $valFunc = 'validate_' . $id . '_' . $shortNameForJS . '(this)';
+                $onBlur = $element->getAttribute('onBlur');
+                $onChange = $element->getAttribute('onChange');
+                $element->updateAttributes(array('onBlur' => $onBlur . $valFunc,
+                                                 'onChange' => $onChange . $valFunc));
+            } else {  // group
+                $elements =& $element->getElements();
+                for ($i = 0; $i < count($elements); $i++) {
+                    // $groupElementName is a substring of attribute name of the element
+                    if (strpos($elements[$i]->getAttribute('name'), $groupElementName) === 0) {
+                        $valFunc = 'validate_' . $id . '_' . $shortNameForJS . '(this)';
+                        $onBlur = $elements[$i]->getAttribute('onBlur');
+                        $onChange = $elements[$i]->getAttribute('onChange');
+                        $elements[$i]->updateAttributes(array('onBlur'   => $onBlur . $valFunc,
+                                                              'onChange' => $onChange . $valFunc));
+                    }
+                }
+            }
+        }
+        $js .= '
+validate_' . $id . ' = function(frm) {
+  var ret = true;
+' . $validateJS . ';
+  return ret;
+}
+//--><!]]></script>';
+        return $js;
+    } // end func getValidationScript
+
+    // }}}
+
+    function display() {
+        $this->getValidationScript();
+        return parent::display();
+    }
+}
+
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/PageDHTMLRulesTableless.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/PageDHTMLRulesTableless.php
new file mode 100644 (file)
index 0000000..6d42150
--- /dev/null
@@ -0,0 +1,296 @@
+<?php
+/**
+ * DHTML replacement for the standard JavaScript alert window for client-side
+ * validation
+ *
+ * LICENSE:
+ * 
+ * Copyright (c) 2005-2007, Mark Wiesemann <wiesemann@php.net>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the 
+ *      documentation and/or other materials provided with the distribution.
+ *    * The names of the authors may not be used to endorse or promote products 
+ *      derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   HTML
+ * @package    HTML_QuickForm_DHTMLRulesTableless
+ * @author     Alexey Borzov <borz_off@cs.msu.su>
+ * @author     Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author     Bertrand Mansion <bmansion@mamasam.com>
+ * @author     Justin Patrin <papercrane@gmail.com>
+ * @author     Mark Wiesemann <wiesemann@php.net>
+ * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
+ * @version    CVS: $Id: PageDHTMLRulesTableless.php,v 1.3 2007/10/24 20:36:11 wiesemann Exp $
+ * @link       http://pear.php.net/package/HTML_QuickForm_DHTMLRulesTableless
+ */
+
+require_once 'HTML/QuickForm/Page.php';
+
+/**
+ * This is a DHTML replacement for the standard JavaScript alert window for
+ * client-side validation of forms built with HTML_QuickForm
+ *
+ * @category   HTML
+ * @package    HTML_QuickForm_DHTMLRulesTableless
+ * @author     Alexey Borzov <borz_off@cs.msu.su>
+ * @author     Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author     Bertrand Mansion <bmansion@mamasam.com>
+ * @author     Justin Patrin <papercrane@gmail.com>
+ * @author     Mark Wiesemann <wiesemann@php.net>
+ * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
+ * @version    Release: 0.3.3
+ * @link       http://pear.php.net/package/HTML_QuickForm_DHTMLRulesTableless
+ */
+class HTML_QuickForm_PageDHTMLRulesTableless extends HTML_QuickForm_Page
+{
+   /**
+    * Class constructor
+    * 
+    * @access public
+    */
+    function HTML_QuickForm_PageDHTMLRulesTableless($formName, $method = 'post',
+        $target = '', $attributes = null)
+    {
+        $this->HTML_QuickForm_Page($formName, $method, '', $target, $attributes);
+    }
+
+    // {{{ getValidationScript()
+
+    /**
+     * Returns the client side validation script
+     *
+     * The code here was copied from HTML_QuickForm and slightly modified to run rules per-element
+     *
+     * @access    public
+     * @return    string    Javascript to perform validation, empty string if no 'client' rules were added
+     */
+    function getValidationScript()
+    {
+        if (empty($this->_rules) || empty($this->_attributes['onsubmit'])) {
+            return '';
+        }
+
+        include_once('HTML/QuickForm/RuleRegistry.php');
+        $registry =& HTML_QuickForm_RuleRegistry::singleton();
+        $test = array();
+        $js_escape = array(
+            "\r"    => '\r',
+            "\n"    => '\n',
+            "\t"    => '\t',
+            "'"     => "\\'",
+            '"'     => '\"',
+            '\\'    => '\\\\'
+        );
+
+        foreach ($this->_rules as $elementName => $rules) {
+            foreach ($rules as $rule) {
+                if ('client' == $rule['validation']) {
+                    unset($element);
+
+                    $dependent  = isset($rule['dependent']) && is_array($rule['dependent']);
+                    $rule['message'] = strtr($rule['message'], $js_escape);
+
+                    if (isset($rule['group'])) {
+                        $group    =& $this->getElement($rule['group']);
+                        // No JavaScript validation for frozen elements
+                        if ($group->isFrozen()) {
+                            continue 2;
+                        }
+                        $elements =& $group->getElements();
+                        foreach (array_keys($elements) as $key) {
+                            if ($elementName == $group->getElementName($key)) {
+                                $element =& $elements[$key];
+                                break;
+                            }
+                        }
+                    } elseif ($dependent) {
+                        $element   =  array();
+                        $element[] =& $this->getElement($elementName);
+                        foreach ($rule['dependent'] as $idx => $elName) {
+                            $element[] =& $this->getElement($elName);
+                        }
+                    } else {
+                        $element =& $this->getElement($elementName);
+                    }
+                    // No JavaScript validation for frozen elements
+                    if (is_object($element) && $element->isFrozen()) {
+                        continue 2;
+                    } elseif (is_array($element)) {
+                        foreach (array_keys($element) as $key) {
+                            if ($element[$key]->isFrozen()) {
+                                continue 3;
+                            }
+                        }
+                    }
+
+                    $test[$elementName][] = $registry->getValidationScript($element, $elementName, $rule);
+                }
+            }
+        }
+        $js = '
+<script type="text/javascript"><!--//--><![CDATA[//><!--
+qf_errorHandler = function(element, _qfMsg) {
+  div = element.parentNode;
+  var elementName = element.name.replace(/\[/, "_____");
+  var elementName = elementName.replace(/\]/, "_____");
+  if (_qfMsg != \'\') {
+    span = document.createElement("span");
+    span.className = "error";
+    _qfMsg = _qfMsg.substring(4);
+    span.appendChild(document.createTextNode(_qfMsg));
+    br = document.createElement("br");
+
+    var errorDiv = document.getElementById(elementName + \'_errorDiv\');
+    if (!errorDiv) {
+      errorDiv = document.createElement("div");
+      errorDiv.id = elementName + \'_errorDiv\';
+    } else {
+      if (   div.firstChild.textContent == \'\'
+          || _qfMsg == div.firstChild.textContent
+         ) {
+        return false;
+      }
+    }
+    while (errorDiv.firstChild) {
+      errorDiv.removeChild(errorDiv.firstChild);
+    }
+
+    errorDiv.insertBefore(br, errorDiv.firstChild);
+    errorDiv.insertBefore(span, errorDiv.firstChild);
+
+    errorDivInserted = false;
+    for (var i = element.parentNode.childNodes.length - 1; i >= 0; i--) {
+      j = i - 1;
+      if (j >= 0 && element.parentNode.childNodes[j].nodeName == "DIV") {
+        element.parentNode.insertBefore(errorDiv, element.parentNode.childNodes[i]);
+        errorDivInserted = true;
+        break;
+      }
+    }
+    if (!errorDivInserted) {
+      element.parentNode.insertBefore(errorDiv, element.parentNode.firstChild);
+    }
+
+    if (div.className.substr(div.className.length - 6, 6) != " error"
+        && div.className != "error") {
+      div.className += " error";
+    }
+
+    return false;
+  } else {
+    var errorDiv = document.getElementById(elementName + \'_errorDiv\');
+    if (errorDiv) {
+      errorDiv.parentNode.removeChild(errorDiv);
+    }
+    
+    // do not remove the error style from the div tag if there is still an error
+    // message
+    if (div.firstChild.innerHTML != "") {
+      return true;
+    }
+
+    if (div.className.substr(div.className.length - 6, 6) == " error") {
+      div.className = div.className.substr(0, div.className.length - 6);
+    } else if (div.className == "error") {
+      div.className = "";
+    }
+
+    return true;
+  }
+}';
+        $validateJS = '';
+        foreach ($test as $elementName => $jsArr) {
+            // remove group element part of the element name to avoid JS errors
+            $singleElementName = $elementName;
+            $shortNameForJS = str_replace(array('[', ']'), '__', $elementName);
+            $bracketPos = strpos($elementName, '[');
+            if ($bracketPos !== false) {
+                $singleElementName = substr($elementName, 0, $bracketPos);
+                $groupElementName = substr($elementName, $bracketPos + 1, -1);
+            }
+            if ($bracketPos === false || !$this->elementExists($singleElementName)) {
+                $groupElementName = $elementName;
+                $singleElementName = $elementName;
+            }
+            $id = str_replace('-', '_', $this->_attributes['id']);
+            $js .= '
+validate_' . $id . '_' . $shortNameForJS . ' = function(element) {
+  var value = \'\';
+  var errFlag = new Array();
+  var _qfGroups = {};
+  var _qfMsg = \'\';
+  var frm = element.parentNode;
+  while (frm && frm.nodeName != "FORM") {
+    frm = frm.parentNode;
+  }
+' . join("\n", $jsArr) . '
+  return qf_errorHandler(element, _qfMsg);
+}
+';
+            unset($element);
+            $element =& $this->getElement($singleElementName);
+            $elementNameForJS = 'frm.elements[\'' . $elementName . '\']';
+            if ($element->getType() === 'group' && $singleElementName === $elementName) {
+                $elementNameForJS = 'document.getElementById(\'' . $element->_elements[0]->getAttribute('id') . '\')';
+            }
+            $validateJS .= '
+  ret = validate_' . $id . '_' . $shortNameForJS . '('. $elementNameForJS . ') && ret;';
+            if ($element->getType() !== 'group') {  // not a group
+                $valFunc = 'validate_' . $id . '_' . $shortNameForJS . '(this)';
+                $onBlur = $element->getAttribute('onBlur');
+                $onChange = $element->getAttribute('onChange');
+                $element->updateAttributes(array('onBlur' => $onBlur . $valFunc,
+                                                 'onChange' => $onChange . $valFunc));
+            } else {  // group
+                $elements =& $element->getElements();
+                for ($i = 0; $i < count($elements); $i++) {
+                    // $groupElementName is a substring of attribute name of the element
+                    if (strpos($elements[$i]->getAttribute('name'), $groupElementName) === 0) {
+                        $valFunc = 'validate_' . $id . '_' . $shortNameForJS . '(this)';
+                        $onBlur = $elements[$i]->getAttribute('onBlur');
+                        $onChange = $elements[$i]->getAttribute('onChange');
+                        $elements[$i]->updateAttributes(array('onBlur'   => $onBlur . $valFunc,
+                                                              'onChange' => $onChange . $valFunc));
+                    }
+                }
+            }
+        }
+        $js .= '
+validate_' . $id . ' = function (frm) {
+  var ret = true;
+' . $validateJS . ';
+  return ret;
+}
+//--><!]]></script>';
+        return $js;
+    } // end func getValidationScript
+
+    // }}}
+
+    function display() {
+        $this->getValidationScript();
+        return parent::display();
+    }
+}
+
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer.php
new file mode 100644 (file)
index 0000000..3a20504
--- /dev/null
@@ -0,0 +1,158 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * An abstract base class for QuickForm renderers
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * An abstract base class for QuickForm renderers
+ * 
+ * The class implements a Visitor design pattern
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       3.0
+ * @abstract
+ */
+class HTML_QuickForm_Renderer
+{
+   /**
+    * Constructor
+    *
+    * @access public
+    */
+    function HTML_QuickForm_Renderer()
+    {
+    } // end constructor
+
+   /**
+    * Called when visiting a form, before processing any form elements
+    *
+    * @param    HTML_QuickForm  a form being visited
+    * @access   public
+    * @return   void 
+    * @abstract
+    */
+    function startForm(&$form)
+    {
+        return;
+    } // end func startForm
+
+   /**
+    * Called when visiting a form, after processing all form elements
+    * 
+    * @param    HTML_QuickForm  a form being visited
+    * @access   public
+    * @return   void 
+    * @abstract
+    */
+    function finishForm(&$form)
+    {
+        return;
+    } // end func finishForm
+
+   /**
+    * Called when visiting a header element
+    *
+    * @param    HTML_QuickForm_header   a header element being visited
+    * @access   public
+    * @return   void 
+    * @abstract
+    */
+    function renderHeader(&$header)
+    {
+        return;
+    } // end func renderHeader
+
+   /**
+    * Called when visiting an element
+    *
+    * @param    HTML_QuickForm_element  form element being visited
+    * @param    bool                    Whether an element is required
+    * @param    string                  An error message associated with an element
+    * @access   public
+    * @return   void 
+    * @abstract
+    */
+    function renderElement(&$element, $required, $error)
+    {
+        return;
+    } // end func renderElement
+
+   /**
+    * Called when visiting a hidden element
+    * 
+    * @param    HTML_QuickForm_element  a hidden element being visited
+    * @access   public
+    * @return   void
+    * @abstract 
+    */
+    function renderHidden(&$element)
+    {
+        return;
+    } // end func renderHidden
+
+   /**
+    * Called when visiting a raw HTML/text pseudo-element
+    * 
+    * Only implemented in Default renderer. Usage of 'html' elements is 
+    * discouraged, templates should be used instead.
+    *
+    * @param    HTML_QuickForm_html     a 'raw html' element being visited
+    * @access   public
+    * @return   void 
+    * @abstract
+    */
+    function renderHtml(&$data)
+    {
+        return;
+    } // end func renderHtml
+
+   /**
+    * Called when visiting a group, before processing any group elements
+    *
+    * @param    HTML_QuickForm_group    A group being visited
+    * @param    bool                    Whether a group is required
+    * @param    string                  An error message associated with a group
+    * @access   public
+    * @return   void 
+    * @abstract
+    */
+    function startGroup(&$group, $required, $error)
+    {
+        return;
+    } // end func startGroup
+
+   /**
+    * Called when visiting a group, after processing all group elements
+    *
+    * @param    HTML_QuickForm_group    A group being visited
+    * @access   public
+    * @return   void 
+    * @abstract
+    */
+    function finishGroup(&$group)
+    {
+        return;
+    } // end func finishGroup
+} // end class HTML_QuickForm_Renderer
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/Array.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/Array.php
new file mode 100644 (file)
index 0000000..81c62e1
--- /dev/null
@@ -0,0 +1,340 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * A concrete renderer for HTML_QuickForm, makes an array of form contents
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Thomas Schulz <ths@4bconsult.de>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * An abstract base class for QuickForm renderers
+ */
+require_once 'HTML/QuickForm/Renderer.php';
+
+/**
+ * A concrete renderer for HTML_QuickForm, makes an array of form contents
+ *
+ * Based on old HTML_QuickForm::toArray() code.
+ *
+ * The form array structure is the following:
+ * <pre>
+ * array(
+ *   'frozen'           => 'whether the form is frozen',
+ *   'javascript'       => 'javascript for client-side validation',
+ *   'attributes'       => 'attributes for <form> tag',
+ *   'requirednote      => 'note about the required elements',
+ *   // if we set the option to collect hidden elements
+ *   'hidden'           => 'collected html of all hidden elements',
+ *   // if there were some validation errors:
+ *   'errors' => array(
+ *     '1st element name' => 'Error for the 1st element',
+ *     ...
+ *     'nth element name' => 'Error for the nth element'
+ *   ),
+ *   // if there are no headers in the form:
+ *   'elements' => array(
+ *     element_1,
+ *     ...
+ *     element_N
+ *   )
+ *   // if there are headers in the form:
+ *   'sections' => array(
+ *     array(
+ *       'header'   => 'Header text for the first header',
+ *       'name'     => 'Header name for the first header',
+ *       'elements' => array(
+ *          element_1,
+ *          ...
+ *          element_K1
+ *       )
+ *     ),
+ *     ...
+ *     array(
+ *       'header'   => 'Header text for the Mth header',
+ *       'name'     => 'Header name for the Mth header',
+ *       'elements' => array(
+ *          element_1,
+ *          ...
+ *          element_KM
+ *       )
+ *     )
+ *   )
+ * );
+ * </pre>
+ *
+ * where element_i is an array of the form:
+ * <pre>
+ * array(
+ *   'name'      => 'element name',
+ *   'value'     => 'element value',
+ *   'type'      => 'type of the element',
+ *   'frozen'    => 'whether element is frozen',
+ *   'label'     => 'label for the element',
+ *   'required'  => 'whether element is required',
+ *   'error'     => 'error associated with the element',
+ *   'style'     => 'some information about element style (e.g. for Smarty)',
+ *   // if element is not a group
+ *   'html'      => 'HTML for the element'
+ *   // if element is a group
+ *   'separator' => 'separator for group elements',
+ *   'elements'  => array(
+ *     element_1,
+ *     ...
+ *     element_N
+ *   )
+ * );
+ * </pre>
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Thomas Schulz <ths@4bconsult.de>
+ * @version     Release: 3.2.16
+ * @since       3.0
+ */
+class HTML_QuickForm_Renderer_Array extends HTML_QuickForm_Renderer
+{
+   /**#@+
+    * @access private
+    */
+   /**
+    * An array being generated
+    * @var array
+    */
+    var $_ary;
+
+   /**
+    * Number of sections in the form (i.e. number of headers in it)
+    * @var integer
+    */
+    var $_sectionCount;
+
+   /**
+    * Current section number
+    * @var integer
+    */
+    var $_currentSection;
+
+   /**
+    * Array representing current group
+    * @var array
+    */
+    var $_currentGroup = null;
+
+   /**
+    * Additional style information for different elements
+    * @var array
+    */
+    var $_elementStyles = array();
+
+   /**
+    * true: collect all hidden elements into string; false: process them as usual form elements
+    * @var bool
+    */
+    var $_collectHidden = false;
+
+   /**
+    * true:  render an array of labels to many labels, $key 0 named 'label', the rest "label_$key"
+    * false: leave labels as defined
+    * @var bool
+    */
+    var $_staticLabels = false;
+   /**#@-*/
+
+   /**
+    * Constructor
+    *
+    * @param  bool    true: collect all hidden elements into string; false: process them as usual form elements
+    * @param  bool    true: render an array of labels to many labels, $key 0 to 'label' and the oterh to "label_$key"
+    * @access public
+    */
+    function HTML_QuickForm_Renderer_Array($collectHidden = false, $staticLabels = false)
+    {
+        $this->HTML_QuickForm_Renderer();
+        $this->_collectHidden = $collectHidden;
+        $this->_staticLabels  = $staticLabels;
+    } // end constructor
+
+
+   /**
+    * Returns the resultant array
+    *
+    * @access public
+    * @return array
+    */
+    function toArray()
+    {
+        return $this->_ary;
+    }
+
+
+    function startForm(&$form)
+    {
+        $this->_ary = array(
+            'frozen'            => $form->isFrozen(),
+            'javascript'        => $form->getValidationScript(),
+            'attributes'        => $form->getAttributes(true),
+            'requirednote'      => $form->getRequiredNote(),
+            'errors'            => array()
+        );
+        if ($this->_collectHidden) {
+            $this->_ary['hidden'] = '';
+        }
+        $this->_elementIdx     = 1;
+        $this->_currentSection = null;
+        $this->_sectionCount   = 0;
+    } // end func startForm
+
+
+    function renderHeader(&$header)
+    {
+        $this->_ary['sections'][$this->_sectionCount] = array(
+            'header' => $header->toHtml(),
+            'name'   => $header->getName()
+        );
+        $this->_currentSection = $this->_sectionCount++;
+    } // end func renderHeader
+
+
+    function renderElement(&$element, $required, $error)
+    {
+        $elAry = $this->_elementToArray($element, $required, $error);
+        if (!empty($error)) {
+            $this->_ary['errors'][$elAry['name']] = $error;
+        }
+        $this->_storeArray($elAry);
+    } // end func renderElement
+
+
+    function renderHidden(&$element)
+    {
+        if ($this->_collectHidden) {
+            $this->_ary['hidden'] .= $element->toHtml() . "\n";
+        } else {
+            $this->renderElement($element, false, null);
+        }
+    } // end func renderHidden
+
+
+    function startGroup(&$group, $required, $error)
+    {
+        $this->_currentGroup = $this->_elementToArray($group, $required, $error);
+        if (!empty($error)) {
+            $this->_ary['errors'][$this->_currentGroup['name']] = $error;
+        }
+    } // end func startGroup
+
+
+    function finishGroup(&$group)
+    {
+        $this->_storeArray($this->_currentGroup);
+        $this->_currentGroup = null;
+    } // end func finishGroup
+
+
+   /**
+    * Creates an array representing an element
+    *
+    * @access private
+    * @param  HTML_QuickForm_element    element being processed
+    * @param  bool                      Whether an element is required
+    * @param  string                    Error associated with the element
+    * @return array
+    */
+    function _elementToArray(&$element, $required, $error)
+    {
+        $ret = array(
+            'name'      => $element->getName(),
+            'value'     => $element->getValue(),
+            'type'      => $element->getType(),
+            'frozen'    => $element->isFrozen(),
+            'required'  => $required,
+            'error'     => $error
+        );
+        // render label(s)
+        $labels = $element->getLabel();
+        if (is_array($labels) && $this->_staticLabels) {
+            foreach($labels as $key => $label) {
+                $key = is_int($key)? $key + 1: $key;
+                if (1 === $key) {
+                    $ret['label'] = $label;
+                } else {
+                    $ret['label_' . $key] = $label;
+                }
+            }
+        } else {
+            $ret['label'] = $labels;
+        }
+
+        // set the style for the element
+        if (isset($this->_elementStyles[$ret['name']])) {
+            $ret['style'] = $this->_elementStyles[$ret['name']];
+        }
+        if ('group' == $ret['type']) {
+            $ret['separator'] = $element->_separator;
+            $ret['elements']  = array();
+        } else {
+            $ret['html']      = $element->toHtml();
+        }
+        return $ret;
+    }
+
+
+   /**
+    * Stores an array representation of an element in the form array
+    *
+    * @access private
+    * @param array  Array representation of an element
+    * @return void
+    */
+    function _storeArray($elAry)
+    {
+        // where should we put this element...
+        if (is_array($this->_currentGroup) && ('group' != $elAry['type'])) {
+            $this->_currentGroup['elements'][] = $elAry;
+        } elseif (isset($this->_currentSection)) {
+            $this->_ary['sections'][$this->_currentSection]['elements'][] = $elAry;
+        } else {
+            $this->_ary['elements'][] = $elAry;
+        }
+    }
+
+
+   /**
+    * Sets a style to use for element rendering
+    *
+    * @param mixed      element name or array ('element name' => 'style name')
+    * @param string     style name if $elementName is not an array
+    * @access public
+    * @return void
+    */
+    function setElementStyle($elementName, $styleName = null)
+    {
+        if (is_array($elementName)) {
+            $this->_elementStyles = array_merge($this->_elementStyles, $elementName);
+        } else {
+            $this->_elementStyles[$elementName] = $styleName;
+        }
+    }
+}
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/ArraySmarty.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/ArraySmarty.php
new file mode 100644 (file)
index 0000000..d1e20f1
--- /dev/null
@@ -0,0 +1,403 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * A static renderer for HTML_QuickForm, makes an array of form content
+ * useful for a Smarty template
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Thomas Schulz <ths@4bconsult.de>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * A concrete renderer for HTML_QuickForm, makes an array of form contents
+ */ 
+require_once 'HTML/QuickForm/Renderer/Array.php';
+
+/**
+ * A static renderer for HTML_QuickForm, makes an array of form content
+ * useful for a Smarty template
+ *
+ * Based on old HTML_QuickForm::toArray() code and ITStatic renderer.
+ *
+ * The form array structure is the following:
+ * <pre>
+ * Array (
+ *  [frozen]       => whether the complete form is frozen'
+ *  [javascript]   => javascript for client-side validation
+ *  [attributes]   => attributes for <form> tag
+ *  [hidden]       => html of all hidden elements
+ *  [requirednote] => note about the required elements
+ *  [errors] => Array
+ *      (
+ *          [1st_element_name] => Error for the 1st element
+ *          ...
+ *          [nth_element_name] => Error for the nth element
+ *      )
+ *
+ *  [header] => Array
+ *      (
+ *          [1st_header_name] => Header text for the 1st header
+ *          ...
+ *          [nth_header_name] => Header text for the nth header
+ *      )
+ *
+ *  [1st_element_name] => Array for the 1st element
+ *  ...
+ *  [nth_element_name] => Array for the nth element
+ * </pre>
+ *
+ * where an element array has the form:
+ * <pre>
+ *      (
+ *          [name]      => element name
+ *          [value]     => element value,
+ *          [type]      => type of the element
+ *          [frozen]    => whether element is frozen
+ *          [label]     => label for the element
+ *          [required]  => whether element is required
+ * // if element is not a group:
+ *          [html]      => HTML for the element
+ * // if element is a group:
+ *          [separator] => separator for group elements
+ *          [1st_gitem_name] => Array for the 1st element in group
+ *          ...
+ *          [nth_gitem_name] => Array for the nth element in group
+ *      )
+ * )
+ * </pre>
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Thomas Schulz <ths@4bconsult.de>
+ * @version     Release: 3.2.16
+ * @since       3.0
+ */
+class HTML_QuickForm_Renderer_ArraySmarty extends HTML_QuickForm_Renderer_Array
+{
+   /**#@+
+    * @access private
+    */
+   /**
+    * The Smarty template engine instance
+    * @var object
+    */
+    var $_tpl = null;
+
+   /**
+    * Current element index
+    * @var integer
+    */
+    var $_elementIdx = 0;
+
+    /**
+    * The current element index inside a group
+    * @var integer
+    */
+    var $_groupElementIdx = 0;
+
+   /**
+    * How to handle the required tag for required fields
+    * @var string
+    * @see      setRequiredTemplate()
+    */
+    var $_required = '';
+
+   /**
+    * How to handle error messages in form validation
+    * @var string
+    * @see      setErrorTemplate()
+    */
+    var $_error = '';
+   /**#@-*/
+
+   /**
+    * Constructor
+    *
+    * @param  Smarty  reference to the Smarty template engine instance
+    * @param  bool    true: render an array of labels to many labels, $key 0 to 'label' and the oterh to "label_$key"
+    * @param  bool    true: collect all hidden elements into string; false: process them as usual form elements
+    * @access public
+    */
+    function HTML_QuickForm_Renderer_ArraySmarty(&$tpl, $staticLabels = false, $collectHidden = true)
+    {
+        $this->HTML_QuickForm_Renderer_Array($collectHidden, $staticLabels);
+        $this->_tpl =& $tpl;
+    } // end constructor
+
+   /**
+    * Called when visiting a header element
+    *
+    * @param    HTML_QuickForm_header   header element being visited
+    * @access   public
+    * @return   void
+    */
+    function renderHeader(&$header)
+    {
+        if ($name = $header->getName()) {
+            $this->_ary['header'][$name] = $header->toHtml();
+        } else {
+            $this->_ary['header'][$this->_sectionCount] = $header->toHtml();
+        }
+        $this->_currentSection = $this->_sectionCount++;
+    } // end func renderHeader
+
+   /**
+    * Called when visiting a group, before processing any group elements
+    *
+    * @param    HTML_QuickForm_group    group being visited
+    * @param    bool                    Whether a group is required
+    * @param    string                  An error message associated with a group
+    * @access   public
+    * @return   void
+    */
+    function startGroup(&$group, $required, $error)
+    {
+        parent::startGroup($group, $required, $error);
+        $this->_groupElementIdx = 1;
+    } // end func startGroup
+
+   /**
+    * Creates an array representing an element containing
+    * the key for storing this
+    *
+    * @access private
+    * @param  HTML_QuickForm_element    form element being visited
+    * @param  bool                      Whether an element is required
+    * @param  string                    Error associated with the element
+    * @return array
+    */
+    function _elementToArray(&$element, $required, $error)
+    {
+        $ret = parent::_elementToArray($element, $required, $error);
+
+        if ('group' == $ret['type']) {
+            $ret['html'] = $element->toHtml();
+            // we don't need the elements, see the array structure
+            unset($ret['elements']);
+        }
+        if (($required || $error) && !empty($this->_required)){
+            $this->_renderRequired($ret['label'], $ret['html'], $required, $error);
+        }
+        if ($error && !empty($this->_error)) {
+            $this->_renderError($ret['label'], $ret['html'], $error);
+            $ret['error'] = $error;
+        }
+        // create keys for elements grouped by native group or name
+        if (strstr($ret['name'], '[') or $this->_currentGroup) {
+            // Fix for bug #8123: escape backslashes and quotes to prevent errors 
+            // in eval(). The code below seems to handle the case where element
+            // name has unbalanced square brackets. Dunno whether we really
+            // need this after the fix for #8123, but I'm wary of making big
+            // changes to this code.  
+            preg_match('/([^]]*)\\[([^]]*)\\]/', $ret['name'], $matches);
+            if (isset($matches[1])) {
+                $sKeysSub = substr_replace($ret['name'], '', 0, strlen($matches[1]));
+                $sKeysSub = str_replace(
+                    array('\\',   '\'',   '['  ,   ']', '[\'\']'),
+                    array('\\\\', '\\\'', '[\'', '\']', '[]'    ),
+                    $sKeysSub
+                );
+                $sKeys = '[\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $matches[1]) . '\']' . $sKeysSub;
+            } else {
+                $sKeys = '[\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret['name']) . '\']';
+            }
+            // special handling for elements in native groups
+            if ($this->_currentGroup) {
+                // skip unnamed group items unless radios: no name -> no static access
+                // identification: have the same key string as the parent group
+                if ($this->_currentGroup['keys'] == $sKeys and 'radio' != $ret['type']) {
+                    return false;
+                }
+                // reduce string of keys by remove leading group keys
+                if (0 === strpos($sKeys, $this->_currentGroup['keys'])) {
+                    $sKeys = substr_replace($sKeys, '', 0, strlen($this->_currentGroup['keys']));
+                }
+            }
+        // element without a name
+        } elseif ($ret['name'] == '') {
+            $sKeys = '[\'element_' . $this->_elementIdx . '\']';
+        // other elements
+        } else {
+            $sKeys = '[\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret['name']) . '\']';
+        }
+        // for radios: add extra key from value
+        if ('radio' == $ret['type'] and substr($sKeys, -2) != '[]') {
+            $sKeys .= '[\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret['value']) . '\']';
+        }
+        $this->_elementIdx++;
+        $ret['keys'] = $sKeys;
+        return $ret;
+    } // end func _elementToArray
+
+   /**
+    * Stores an array representation of an element in the form array
+    *
+    * @access private
+    * @param array  Array representation of an element
+    * @return void
+    */
+    function _storeArray($elAry)
+    {
+        if ($elAry) {
+            $sKeys = $elAry['keys'];
+            unset($elAry['keys']);
+            // where should we put this element...
+            if (is_array($this->_currentGroup) && ('group' != $elAry['type'])) {
+                $toEval = '$this->_currentGroup' . $sKeys . ' = $elAry;';
+            } else {
+                $toEval = '$this->_ary' . $sKeys . ' = $elAry;';
+            }
+            eval($toEval);
+        }
+        return;
+    }
+
+   /**
+    * Called when an element is required
+    *
+    * This method will add the required tag to the element label and/or the element html
+    * such as defined with the method setRequiredTemplate.
+    *
+    * @param    string      The element label
+    * @param    string      The element html rendering
+    * @param    boolean     The element required
+    * @param    string      The element error
+    * @see      setRequiredTemplate()
+    * @access   private
+    * @return   void
+    */
+    function _renderRequired(&$label, &$html, &$required, &$error)
+    {
+        $this->_tpl->assign(array(
+            'label'    => $label,
+            'html'     => $html,
+            'required' => $required,
+            'error'    => $error
+        ));
+        if (!empty($label) && strpos($this->_required, $this->_tpl->left_delimiter . '$label') !== false) {
+            $label = $this->_tplFetch($this->_required);
+        }
+        if (!empty($html) && strpos($this->_required, $this->_tpl->left_delimiter . '$html') !== false) {
+            $html = $this->_tplFetch($this->_required);
+        }
+        $this->_tpl->clear_assign(array('label', 'html', 'required'));
+    } // end func _renderRequired
+
+   /**
+    * Called when an element has a validation error
+    *
+    * This method will add the error message to the element label or the element html
+    * such as defined with the method setErrorTemplate. If the error placeholder is not found
+    * in the template, the error will be displayed in the form error block.
+    *
+    * @param    string      The element label
+    * @param    string      The element html rendering
+    * @param    string      The element error
+    * @see      setErrorTemplate()
+    * @access   private
+    * @return   void
+    */
+    function _renderError(&$label, &$html, &$error)
+    {
+        $this->_tpl->assign(array('label' => '', 'html' => '', 'error' => $error));
+        $error = $this->_tplFetch($this->_error);
+        $this->_tpl->assign(array('label' => $label, 'html'  => $html));
+
+        if (!empty($label) && strpos($this->_error, $this->_tpl->left_delimiter . '$label') !== false) {
+            $label = $this->_tplFetch($this->_error);
+        } elseif (!empty($html) && strpos($this->_error, $this->_tpl->left_delimiter . '$html') !== false) {
+            $html = $this->_tplFetch($this->_error);
+        }
+        $this->_tpl->clear_assign(array('label', 'html', 'error'));
+    } // end func _renderError
+
+   /**
+    * Process an template sourced in a string with Smarty
+    *
+    * Smarty has no core function to render    a template given as a string.
+    * So we use the smarty eval plugin function        to do this.
+    *
+    * @param    string      The template source
+    * @access   private
+    * @return   void
+    */
+    function _tplFetch($tplSource)
+    {
+        if (!function_exists('smarty_function_eval')) {
+            require SMARTY_DIR . '/plugins/function.eval.php';
+        }
+        return smarty_function_eval(array('var' => $tplSource), $this->_tpl);
+    }// end func _tplFetch
+
+   /**
+    * Sets the way required elements are rendered
+    *
+    * You can use {$label} or {$html} placeholders to let the renderer know where
+    * where the element label or the element html are positionned according to the
+    * required tag. They will be replaced accordingly with the right value.    You
+    * can use the full smarty syntax here, especially a custom modifier for I18N.
+    * For example:
+    * {if $required}<span style="color: red;">*</span>{/if}{$label|translate}
+    * will put a red star in front of the label if the element is required and
+    * translate the label.
+    *
+    *
+    * @param    string      The required element template
+    * @access   public
+    * @return   void
+    */
+    function setRequiredTemplate($template)
+    {
+        $this->_required = $template;
+    } // end func setRequiredTemplate
+
+   /**
+    * Sets the way elements with validation errors are rendered
+    *
+    * You can use {$label} or {$html} placeholders to let the renderer know where
+    * where the element label or the element html are positionned according to the
+    * error message. They will be replaced accordingly with the right value.
+    * The error message will replace the {$error} placeholder.
+    * For example:
+    * {if $error}<span style="color: red;">{$error}</span>{/if}<br />{$html}
+    * will put the error message in red on top of the element html.
+    *
+    * If you want all error messages to be output in the main error block, use
+    * the {$form.errors} part of the rendered array that collects all raw error
+    * messages.
+    *
+    * If you want to place all error messages manually, do not specify {$html}
+    * nor {$label}.
+    *
+    * Groups can have special layouts. With this kind of groups, you have to
+    * place the formated error message manually. In this case, use {$form.group.error}
+    * where you want the formated error message to appear in the form.
+    *
+    * @param    string      The element error template
+    * @access   public
+    * @return   void
+    */
+    function setErrorTemplate($template)
+    {
+        $this->_error = $template;
+    } // end func setErrorTemplate
+}
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/Default.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/Default.php
new file mode 100644 (file)
index 0000000..74c5ce1
--- /dev/null
@@ -0,0 +1,485 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * A concrete renderer for HTML_QuickForm, based on QuickForm 2.x built-in one
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * An abstract base class for QuickForm renderers
+ */
+require_once 'HTML/QuickForm/Renderer.php';
+
+/**
+ * A concrete renderer for HTML_QuickForm, based on QuickForm 2.x built-in one
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       3.0
+ */
+class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer
+{
+   /**
+    * The HTML of the form  
+    * @var      string
+    * @access   private
+    */
+    var $_html;
+
+   /**
+    * Header Template string
+    * @var      string
+    * @access   private
+    */
+    var $_headerTemplate = 
+        "\n\t<tr>\n\t\t<td style=\"white-space: nowrap; background-color: #CCCCCC;\" align=\"left\" valign=\"top\" colspan=\"2\"><b>{header}</b></td>\n\t</tr>";
+
+   /**
+    * Element template string
+    * @var      string
+    * @access   private
+    */
+    var $_elementTemplate = 
+        "\n\t<tr>\n\t\t<td align=\"right\" valign=\"top\"><!-- BEGIN required --><span style=\"color: #ff0000\">*</span><!-- END required --><b>{label}</b></td>\n\t\t<td valign=\"top\" align=\"left\"><!-- BEGIN error --><span style=\"color: #ff0000\">{error}</span><br /><!-- END error -->\t{element}</td>\n\t</tr>";
+
+   /**
+    * Form template string
+    * @var      string
+    * @access   private
+    */
+    var $_formTemplate = 
+        "\n<form{attributes}>\n<div>\n{hidden}<table border=\"0\">\n{content}\n</table>\n</div>\n</form>";
+
+   /**
+    * Required Note template string
+    * @var      string
+    * @access   private
+    */
+    var $_requiredNoteTemplate = 
+        "\n\t<tr>\n\t\t<td></td>\n\t<td align=\"left\" valign=\"top\">{requiredNote}</td>\n\t</tr>";
+
+   /**
+    * Array containing the templates for customised elements
+    * @var      array
+    * @access   private
+    */
+    var $_templates = array();
+
+   /**
+    * Array containing the templates for group wraps.
+    * 
+    * These templates are wrapped around group elements and groups' own
+    * templates wrap around them. This is set by setGroupTemplate().
+    * 
+    * @var      array
+    * @access   private
+    */
+    var $_groupWraps = array();
+
+   /**
+    * Array containing the templates for elements within groups
+    * @var      array
+    * @access   private
+    */
+    var $_groupTemplates = array();
+
+   /**
+    * True if we are inside a group 
+    * @var      bool
+    * @access   private
+    */
+    var $_inGroup = false;
+
+   /**
+    * Array with HTML generated for group elements
+    * @var      array
+    * @access   private
+    */
+    var $_groupElements = array();
+
+   /**
+    * Template for an element inside a group
+    * @var      string
+    * @access   private
+    */
+    var $_groupElementTemplate = '';
+
+   /**
+    * HTML that wraps around the group elements
+    * @var      string
+    * @access   private
+    */
+    var $_groupWrap = '';
+
+   /**
+    * HTML for the current group
+    * @var      string
+    * @access   private
+    */
+    var $_groupTemplate = '';
+    
+   /**
+    * Collected HTML of the hidden fields
+    * @var      string
+    * @access   private
+    */
+    var $_hiddenHtml = '';
+
+   /**
+    * Constructor
+    *
+    * @access public
+    */
+    function HTML_QuickForm_Renderer_Default()
+    {
+        $this->HTML_QuickForm_Renderer();
+    } // end constructor
+
+   /**
+    * returns the HTML generated for the form
+    *
+    * @access public
+    * @return string
+    */
+    function toHtml()
+    {
+        // _hiddenHtml is cleared in finishForm(), so this only matters when
+        // finishForm() was not called (e.g. group::toHtml(), bug #3511)
+        return $this->_hiddenHtml . $this->_html;
+    } // end func toHtml
+    
+   /**
+    * Called when visiting a form, before processing any form elements
+    *
+    * @param    HTML_QuickForm  form object being visited
+    * @access   public
+    * @return   void
+    */
+    function startForm(&$form)
+    {
+        $this->_html = '';
+        $this->_hiddenHtml = '';
+    } // end func startForm
+
+   /**
+    * Called when visiting a form, after processing all form elements
+    * Adds required note, form attributes, validation javascript and form content.
+    * 
+    * @param    HTML_QuickForm  form object being visited
+    * @access   public
+    * @return   void
+    */
+    function finishForm(&$form)
+    {
+        // add a required note, if one is needed
+        if (!empty($form->_required) && !$form->_freezeAll) {
+            $this->_html .= str_replace('{requiredNote}', $form->getRequiredNote(), $this->_requiredNoteTemplate);
+        }
+        // add form attributes and content
+        $html = str_replace('{attributes}', $form->getAttributes(true), $this->_formTemplate);
+        if (strpos($this->_formTemplate, '{hidden}')) {
+            $html = str_replace('{hidden}', $this->_hiddenHtml, $html);
+        } else {
+            $this->_html .= $this->_hiddenHtml;
+        }
+        $this->_hiddenHtml = '';
+        $this->_html = str_replace('{content}', $this->_html, $html);
+        // add a validation script
+        if ('' != ($script = $form->getValidationScript())) {
+            $this->_html = $script . "\n" . $this->_html;
+        }
+    } // end func finishForm
+      
+   /**
+    * Called when visiting a header element
+    *
+    * @param    HTML_QuickForm_header   header element being visited
+    * @access   public
+    * @return   void
+    */
+    function renderHeader(&$header)
+    {
+        $name = $header->getName();
+        if (!empty($name) && isset($this->_templates[$name])) {
+            $this->_html .= str_replace('{header}', $header->toHtml(), $this->_templates[$name]);
+        } else {
+            $this->_html .= str_replace('{header}', $header->toHtml(), $this->_headerTemplate);
+        }
+    } // end func renderHeader
+
+   /**
+    * Helper method for renderElement
+    *
+    * @param    string      Element name
+    * @param    mixed       Element label (if using an array of labels, you should set the appropriate template)
+    * @param    bool        Whether an element is required
+    * @param    string      Error message associated with the element
+    * @access   private
+    * @see      renderElement()
+    * @return   string      Html for element
+    */
+    function _prepareTemplate($name, $label, $required, $error)
+    {
+        if (is_array($label)) {
+            $nameLabel = array_shift($label);
+        } else {
+            $nameLabel = $label;
+        }
+        if (isset($this->_templates[$name])) {
+            $html = str_replace('{label}', $nameLabel, $this->_templates[$name]);
+        } else {
+            $html = str_replace('{label}', $nameLabel, $this->_elementTemplate);
+        }
+        if ($required) {
+            $html = str_replace('<!-- BEGIN required -->', '', $html);
+            $html = str_replace('<!-- END required -->', '', $html);
+        } else {
+            $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->.*<!-- END required -->([ \t\n\r]*)?/isU", '', $html);
+        }
+        if (isset($error)) {
+            $html = str_replace('{error}', $error, $html);
+            $html = str_replace('<!-- BEGIN error -->', '', $html);
+            $html = str_replace('<!-- END error -->', '', $html);
+        } else {
+            $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN error -->.*<!-- END error -->([ \t\n\r]*)?/isU", '', $html);
+        }
+        if (is_array($label)) {
+            foreach($label as $key => $text) {
+                $key  = is_int($key)? $key + 2: $key;
+                $html = str_replace("{label_{$key}}", $text, $html);
+                $html = str_replace("<!-- BEGIN label_{$key} -->", '', $html);
+                $html = str_replace("<!-- END label_{$key} -->", '', $html);
+            }
+        }
+        if (strpos($html, '{label_')) {
+            $html = preg_replace('/\s*<!-- BEGIN label_(\S+) -->.*<!-- END label_\1 -->\s*/is', '', $html);
+        }
+        return $html;
+    } // end func _prepareTemplate
+
+   /**
+    * Renders an element Html
+    * Called when visiting an element
+    *
+    * @param HTML_QuickForm_element form element being visited
+    * @param bool                   Whether an element is required
+    * @param string                 An error message associated with an element
+    * @access public
+    * @return void
+    */
+    function renderElement(&$element, $required, $error)
+    {
+        if (!$this->_inGroup) {
+            $html = $this->_prepareTemplate($element->getName(), $element->getLabel(), $required, $error);
+            $this->_html .= str_replace('{element}', $element->toHtml(), $html);
+
+        } elseif (!empty($this->_groupElementTemplate)) {
+            $html = str_replace('{label}', $element->getLabel(), $this->_groupElementTemplate);
+            if ($required) {
+                $html = str_replace('<!-- BEGIN required -->', '', $html);
+                $html = str_replace('<!-- END required -->', '', $html);
+            } else {
+                $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->.*<!-- END required -->([ \t\n\r]*)?/isU", '', $html);
+            }
+            $this->_groupElements[] = str_replace('{element}', $element->toHtml(), $html);
+
+        } else {
+            $this->_groupElements[] = $element->toHtml();
+        }
+    } // end func renderElement
+   
+   /**
+    * Renders an hidden element
+    * Called when visiting a hidden element
+    * 
+    * @param HTML_QuickForm_element     form element being visited
+    * @access public
+    * @return void
+    */
+    function renderHidden(&$element)
+    {
+        $this->_hiddenHtml .= $element->toHtml() . "\n";
+    } // end func renderHidden
+
+   /**
+    * Called when visiting a raw HTML/text pseudo-element
+    * 
+    * @param  HTML_QuickForm_html   element being visited
+    * @access public
+    * @return void
+    */
+    function renderHtml(&$data)
+    {
+        $this->_html .= $data->toHtml();
+    } // end func renderHtml
+
+   /**
+    * Called when visiting a group, before processing any group elements
+    *
+    * @param HTML_QuickForm_group   group being visited
+    * @param bool       Whether a group is required
+    * @param string     An error message associated with a group
+    * @access public
+    * @return void
+    */
+    function startGroup(&$group, $required, $error)
+    {
+        $name = $group->getName();
+        $this->_groupTemplate        = $this->_prepareTemplate($name, $group->getLabel(), $required, $error);
+        $this->_groupElementTemplate = empty($this->_groupTemplates[$name])? '': $this->_groupTemplates[$name];
+        $this->_groupWrap            = empty($this->_groupWraps[$name])? '': $this->_groupWraps[$name];
+        $this->_groupElements        = array();
+        $this->_inGroup              = true;
+    } // end func startGroup
+
+   /**
+    * Called when visiting a group, after processing all group elements
+    *
+    * @param    HTML_QuickForm_group    group being visited
+    * @access   public
+    * @return   void
+    */
+    function finishGroup(&$group)
+    {
+        $separator = $group->_separator;
+        if (is_array($separator)) {
+            $count = count($separator);
+            $html  = '';
+            for ($i = 0; $i < count($this->_groupElements); $i++) {
+                $html .= (0 == $i? '': $separator[($i - 1) % $count]) . $this->_groupElements[$i];
+            }
+        } else {
+            if (is_null($separator)) {
+                $separator = '&nbsp;';
+            }
+            $html = implode((string)$separator, $this->_groupElements);
+        }
+        if (!empty($this->_groupWrap)) {
+            $html = str_replace('{content}', $html, $this->_groupWrap);
+        }
+        $this->_html   .= str_replace('{element}', $html, $this->_groupTemplate);
+        $this->_inGroup = false;
+    } // end func finishGroup
+
+    /**
+     * Sets element template 
+     *
+     * @param       string      The HTML surrounding an element 
+     * @param       string      (optional) Name of the element to apply template for
+     * @access      public
+     * @return      void
+     */
+    function setElementTemplate($html, $element = null)
+    {
+        if (is_null($element)) {
+            $this->_elementTemplate = $html;
+        } else {
+            $this->_templates[$element] = $html;
+        }
+    } // end func setElementTemplate
+
+
+    /**
+     * Sets template for a group wrapper 
+     * 
+     * This template is contained within a group-as-element template 
+     * set via setTemplate() and contains group's element templates, set
+     * via setGroupElementTemplate()
+     *
+     * @param       string      The HTML surrounding group elements
+     * @param       string      Name of the group to apply template for
+     * @access      public
+     * @return      void
+     */
+    function setGroupTemplate($html, $group)
+    {
+        $this->_groupWraps[$group] = $html;
+    } // end func setGroupTemplate
+
+    /**
+     * Sets element template for elements within a group
+     *
+     * @param       string      The HTML surrounding an element 
+     * @param       string      Name of the group to apply template for
+     * @access      public
+     * @return      void
+     */
+    function setGroupElementTemplate($html, $group)
+    {
+        $this->_groupTemplates[$group] = $html;
+    } // end func setGroupElementTemplate
+
+    /**
+     * Sets header template
+     *
+     * @param       string      The HTML surrounding the header 
+     * @access      public
+     * @return      void
+     */
+    function setHeaderTemplate($html)
+    {
+        $this->_headerTemplate = $html;
+    } // end func setHeaderTemplate
+
+    /**
+     * Sets form template 
+     *
+     * @param     string    The HTML surrounding the form tags 
+     * @access    public
+     * @return    void
+     */
+    function setFormTemplate($html)
+    {
+        $this->_formTemplate = $html;
+    } // end func setFormTemplate
+
+    /**
+     * Sets the note indicating required fields template
+     *
+     * @param       string      The HTML surrounding the required note 
+     * @access      public
+     * @return      void
+     */
+    function setRequiredNoteTemplate($html)
+    {
+        $this->_requiredNoteTemplate = $html;
+    } // end func setRequiredNoteTemplate
+
+    /**
+     * Clears all the HTML out of the templates that surround notes, elements, etc.
+     * Useful when you want to use addData() to create a completely custom form look
+     *
+     * @access  public
+     * @return  void
+     */
+    function clearAllTemplates()
+    {
+        $this->setElementTemplate('{element}');
+        $this->setFormTemplate("\n\t<form{attributes}>{content}\n\t</form>\n");
+        $this->setRequiredNoteTemplate('');
+        $this->_templates = array();
+    } // end func clearAllTemplates
+} // end class HTML_QuickForm_Renderer_Default
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/ITDynamic.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/ITDynamic.php
new file mode 100644 (file)
index 0000000..02a0d35
--- /dev/null
@@ -0,0 +1,300 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * A concrete renderer for HTML_QuickForm, using Integrated Templates.
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * An abstract base class for QuickForm renderers
+ */
+require_once 'HTML/QuickForm/Renderer.php';
+
+/**
+ * A concrete renderer for HTML_QuickForm, using Integrated Templates.
+ * 
+ * This is a "dynamic" renderer, which means that concrete form look 
+ * is defined at runtime. This also means that you can define 
+ * <b>one</b> template file for <b>all</b> your forms. That template
+ * should contain a block for every element 'look' appearing in your 
+ * forms and also some special blocks (consult the examples). If a
+ * special block is not set for an element, the renderer falls back to
+ * a default one.
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       3.0
+ */
+class HTML_QuickForm_Renderer_ITDynamic extends HTML_QuickForm_Renderer
+{
+   /**#@+
+    * @access private
+    */
+   /**
+    * A template class (HTML_Template_ITX or HTML_Template_Sigma) instance
+    * @var HTML_Template_ITX|HTML_Template_Sigma
+    */
+    var $_tpl = null;
+
+   /**
+    * The errors that were not shown near concrete fields go here
+    * @var array
+    */
+    var $_errors = array();
+
+   /**
+    * Show the block with required note?
+    * @var bool
+    */
+    var $_showRequired = false;
+
+   /**
+    * A separator for group elements
+    * @var mixed
+    */
+    var $_groupSeparator = null;
+
+   /**
+    * The current element index inside a group
+    * @var integer
+    */
+    var $_groupElementIdx = 0;
+
+   /**
+    * Blocks to use for different elements  
+    * @var array
+    */
+    var $_elementBlocks = array();
+
+   /**
+    * Block to use for headers
+    * @var string
+    */
+    var $_headerBlock = null;
+   /**#@-*/
+
+
+   /**
+    * Constructor
+    *
+    * @param HTML_Template_ITX|HTML_Template_Sigma     Template object to use
+    */
+    function HTML_QuickForm_Renderer_ITDynamic(&$tpl)
+    {
+        $this->HTML_QuickForm_Renderer();
+        $this->_tpl =& $tpl;
+        $this->_tpl->setCurrentBlock('qf_main_loop');
+    }
+
+
+    function finishForm(&$form)
+    {
+        // display errors above form
+        if (!empty($this->_errors) && $this->_tpl->blockExists('qf_error_loop')) {
+            foreach ($this->_errors as $error) {
+                $this->_tpl->setVariable('qf_error', $error);
+                $this->_tpl->parse('qf_error_loop');
+            }
+        }
+        // show required note
+        if ($this->_showRequired) {
+            $this->_tpl->setVariable('qf_required_note', $form->getRequiredNote());
+        }
+        // assign form attributes
+        $this->_tpl->setVariable('qf_attributes', $form->getAttributes(true));
+        // assign javascript validation rules
+        $this->_tpl->setVariable('qf_javascript', $form->getValidationScript());
+    }
+      
+
+    function renderHeader(&$header)
+    {
+        $blockName = $this->_matchBlock($header);
+        if ('qf_header' == $blockName && isset($this->_headerBlock)) {
+            $blockName = $this->_headerBlock;
+        }
+        $this->_tpl->setVariable('qf_header', $header->toHtml());
+        $this->_tpl->parse($blockName);
+        $this->_tpl->parse('qf_main_loop');
+    }
+
+
+    function renderElement(&$element, $required, $error)
+    {
+        $blockName = $this->_matchBlock($element);
+        // are we inside a group?
+        if ('qf_main_loop' != $this->_tpl->currentBlock) {
+            if (0 != $this->_groupElementIdx && $this->_tpl->placeholderExists('qf_separator', $blockName)) {
+                if (is_array($this->_groupSeparator)) {
+                    $this->_tpl->setVariable('qf_separator', $this->_groupSeparator[($this->_groupElementIdx - 1) % count($this->_groupSeparator)]);
+                } else {
+                    $this->_tpl->setVariable('qf_separator', (string)$this->_groupSeparator);
+                }
+            }
+            $this->_groupElementIdx++;
+
+        } elseif(!empty($error)) {
+            // show the error message or keep it for later use
+            if ($this->_tpl->blockExists($blockName . '_error')) {
+                $this->_tpl->setVariable('qf_error', $error);
+            } else {
+                $this->_errors[] = $error;
+            }
+        }
+        // show an '*' near the required element
+        if ($required) {
+            $this->_showRequired = true;
+            if ($this->_tpl->blockExists($blockName . '_required')) {
+                $this->_tpl->touchBlock($blockName . '_required');
+            }
+        }
+        // Prepare multiple labels
+        $labels = $element->getLabel();
+        if (is_array($labels)) {
+            $mainLabel = array_shift($labels);
+        } else {
+            $mainLabel = $labels;
+        }
+        // render the element itself with its main label
+        $this->_tpl->setVariable('qf_element', $element->toHtml());
+        if ($this->_tpl->placeholderExists('qf_label', $blockName)) {
+            $this->_tpl->setVariable('qf_label', $mainLabel);
+        }
+        // render extra labels, if any
+        if (is_array($labels)) {
+            foreach($labels as $key => $label) {
+                $key = is_int($key)? $key + 2: $key;
+                if ($this->_tpl->blockExists($blockName . '_label_' . $key)) {
+                    $this->_tpl->setVariable('qf_label_' . $key, $label);
+                }
+            }
+        }
+        $this->_tpl->parse($blockName);
+        $this->_tpl->parseCurrentBlock();
+    }
+   
+
+    function renderHidden(&$element)
+    {
+        $this->_tpl->setVariable('qf_hidden', $element->toHtml());
+        $this->_tpl->parse('qf_hidden_loop');
+    }
+
+
+    function startGroup(&$group, $required, $error)
+    {
+        $blockName = $this->_matchBlock($group);
+        $this->_tpl->setCurrentBlock($blockName . '_loop');
+        $this->_groupElementIdx = 0;
+        $this->_groupSeparator  = is_null($group->_separator)? '&nbsp;': $group->_separator;
+        // show an '*' near the required element
+        if ($required) {
+            $this->_showRequired = true;
+            if ($this->_tpl->blockExists($blockName . '_required')) {
+                $this->_tpl->touchBlock($blockName . '_required');
+            }
+        }
+        // show the error message or keep it for later use
+        if (!empty($error)) {
+            if ($this->_tpl->blockExists($blockName . '_error')) {
+                $this->_tpl->setVariable('qf_error', $error);
+            } else {
+                $this->_errors[] = $error;
+            }
+        }
+        $this->_tpl->setVariable('qf_group_label', $group->getLabel());
+    }
+
+
+    function finishGroup(&$group)
+    {
+        $this->_tpl->parse($this->_matchBlock($group));
+        $this->_tpl->setCurrentBlock('qf_main_loop');
+        $this->_tpl->parseCurrentBlock();
+    }
+
+
+   /**
+    * Returns the name of a block to use for element rendering
+    * 
+    * If a name was not explicitly set via setElementBlock(), it tries
+    * the names '{prefix}_{element type}' and '{prefix}_{element}', where
+    * prefix is either 'qf' or the name of the current group's block
+    * 
+    * @param HTML_QuickForm_element     form element being rendered
+    * @access private
+    * @return string    block name
+    */
+    function _matchBlock(&$element)
+    {
+        $name = $element->getName();
+        $type = $element->getType();
+        if (isset($this->_elementBlocks[$name]) && $this->_tpl->blockExists($this->_elementBlocks[$name])) {
+            if (('group' == $type) || ($this->_elementBlocks[$name] . '_loop' != $this->_tpl->currentBlock)) {
+                return $this->_elementBlocks[$name];
+            }
+        }
+        if ('group' != $type && 'qf_main_loop' != $this->_tpl->currentBlock) {
+            $prefix = substr($this->_tpl->currentBlock, 0, -5); // omit '_loop' postfix
+        } else {
+            $prefix = 'qf';
+        }
+        if ($this->_tpl->blockExists($prefix . '_' . $type)) {
+            return $prefix . '_' . $type;
+        } elseif ($this->_tpl->blockExists($prefix . '_' . $name)) {
+            return $prefix . '_' . $name;
+        } else {
+            return $prefix . '_element';
+        }
+    }
+
+
+   /**
+    * Sets the block to use for element rendering
+    * 
+    * @param mixed      element name or array ('element name' => 'block name')
+    * @param string     block name if $elementName is not an array
+    * @access public
+    * @return void
+    */
+    function setElementBlock($elementName, $blockName = null)
+    {
+        if (is_array($elementName)) {
+            $this->_elementBlocks = array_merge($this->_elementBlocks, $elementName);
+        } else {
+            $this->_elementBlocks[$elementName] = $blockName;
+        }
+    }
+
+
+   /**
+    * Sets the name of a block to use for header rendering
+    *
+    * @param string     block name
+    * @access public
+    * @return void
+    */
+    function setHeaderBlock($blockName)
+    {
+        $this->_headerBlock = $blockName;
+    }
+}
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/ITStatic.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/ITStatic.php
new file mode 100644 (file)
index 0000000..e699707
--- /dev/null
@@ -0,0 +1,504 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * A static renderer for HTML_QuickForm compatible 
+ * with HTML_Template_IT and HTML_Template_Sigma.
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * An abstract base class for QuickForm renderers
+ */
+require_once 'HTML/QuickForm/Renderer.php';
+
+/**
+ * A static renderer for HTML_QuickForm compatible 
+ * with HTML_Template_IT and HTML_Template_Sigma.
+ *
+ * As opposed to the dynamic renderer, this renderer needs
+ * every elements and labels in the form to be specified by
+ * placeholders at the position you want them to be displayed.
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       3.0
+ */
+class HTML_QuickForm_Renderer_ITStatic extends HTML_QuickForm_Renderer
+{
+   /**#@+
+    * @access private
+    */
+   /**
+    * An HTML_Template_IT or some other API compatible Template instance
+    * @var object
+    */
+    var $_tpl = null;
+
+   /**
+    * Rendered form name
+    * @var string
+    */
+    var $_formName = 'form';
+
+   /**
+    * The errors that were not shown near concrete fields go here
+    * @var array
+    */
+    var $_errors = array();
+
+   /**
+    * Show the block with required note?
+    * @var bool
+    */
+    var $_showRequired = false;
+
+   /**
+    * Which group are we currently parsing ?
+    * @var string
+    */
+    var $_inGroup;
+
+   /**
+    * Index of the element in its group
+    * @var int
+    */
+    var $_elementIndex = 0;
+
+   /**
+    * If elements have been added with the same name
+    * @var array
+    */
+    var $_duplicateElements = array();
+
+   /**
+    * How to handle the required tag for required fields
+    * @var string
+    */
+    var $_required = '{label}<font size="1" color="red">*</font>';
+
+   /**
+    * How to handle error messages in form validation
+    * @var string
+    */
+    var $_error = '<font color="red">{error}</font><br />{html}';
+
+   /**
+    * Collected HTML for hidden elements, if needed  
+    * @var string
+    */
+    var $_hidden = '';
+   /**#@-*/
+
+   /**
+    * Constructor
+    *
+    * @param HTML_Template_IT|HTML_Template_Sigma   Template object to use
+    */
+    function HTML_QuickForm_Renderer_ITStatic(&$tpl)
+    {
+        $this->HTML_QuickForm_Renderer();
+        $this->_tpl =& $tpl;
+    } // end constructor
+
+   /**
+    * Called when visiting a form, before processing any form elements
+    *
+    * @param    HTML_QuickForm  form object being visited
+    * @access   public
+    * @return   void
+    */
+    function startForm(&$form)
+    {
+        $this->_formName = $form->getAttribute('id');
+
+        if (count($form->_duplicateIndex) > 0) {
+            // Take care of duplicate elements
+            foreach ($form->_duplicateIndex as $elementName => $indexes) {
+                $this->_duplicateElements[$elementName] = 0;
+            }
+        }
+    } // end func startForm
+
+   /**
+    * Called when visiting a form, after processing all form elements
+    * 
+    * @param    HTML_QuickForm  form object being visited
+    * @access   public
+    * @return   void
+    */
+    function finishForm(&$form)
+    {
+        // display errors above form
+        if (!empty($this->_errors) && $this->_tpl->blockExists($this->_formName.'_error_loop')) {
+            foreach ($this->_errors as $error) {
+                $this->_tpl->setVariable($this->_formName.'_error', $error);
+                $this->_tpl->parse($this->_formName.'_error_loop');
+            }
+        }
+        // show required note
+        if ($this->_showRequired) {
+            $this->_tpl->setVariable($this->_formName.'_required_note', $form->getRequiredNote());
+        }
+        // add hidden elements, if collected
+        if (!empty($this->_hidden)) {
+            $this->_tpl->setVariable($this->_formName . '_hidden', $this->_hidden);
+        }
+        // assign form attributes
+        $this->_tpl->setVariable($this->_formName.'_attributes', $form->getAttributes(true));
+        // assign javascript validation rules
+        $this->_tpl->setVariable($this->_formName.'_javascript', $form->getValidationScript());
+    } // end func finishForm
+
+   /**
+    * Called when visiting a header element
+    *
+    * @param    HTML_QuickForm_header   header element being visited
+    * @access   public
+    * @return   void
+    */
+    function renderHeader(&$header)
+    {
+        $name = $header->getName();
+        $varName = $this->_formName.'_header';
+
+        // Find placeHolder
+        if (!empty($name) && $this->_tpl->placeHolderExists($this->_formName.'_header_'.$name)) {
+            $varName = $this->_formName.'_header_'.$name;
+        }
+        $this->_tpl->setVariable($varName, $header->toHtml());
+    } // end func renderHeader
+
+   /**
+    * Called when visiting an element
+    *
+    * @param    HTML_QuickForm_element  form element being visited
+    * @param    bool                    Whether an element is required
+    * @param    string                  An error message associated with an element
+    * @access   public
+    * @return   void
+    */
+    function renderElement(&$element, $required, $error)
+    {
+        $name = $element->getName();
+
+        // are we inside a group?
+        if (!empty($this->_inGroup)) {
+            $varName = $this->_formName.'_'.str_replace(array('[', ']'), '_', $name);
+            if (substr($varName, -2) == '__') {
+                // element name is of type : group[]
+                $varName = $this->_inGroup.'_'.$this->_elementIndex.'_';
+                $this->_elementIndex++;
+            }
+            if ($varName != $this->_inGroup) {
+                $varName .= '_' == substr($varName, -1)? '': '_';
+                // element name is of type : group[name]
+                $label = $element->getLabel();
+                $html = $element->toHtml();
+
+                if ($required && !$element->isFrozen()) {
+                    $this->_renderRequired($label, $html);
+                    $this->_showRequired = true;
+                }
+                if (!empty($label)) {
+                    if (is_array($label)) {
+                        foreach ($label as $key => $value) {
+                            $this->_tpl->setVariable($varName.'label_'.$key, $value);
+                        }
+                    } else {
+                        $this->_tpl->setVariable($varName.'label', $label);
+                    }
+                }
+                $this->_tpl->setVariable($varName.'html', $html);
+            }
+
+        } else {
+
+            $name = str_replace(array('[', ']'), array('_', ''), $name);
+
+            if (isset($this->_duplicateElements[$name])) {
+                // Element is a duplicate
+                $varName = $this->_formName.'_'.$name.'_'.$this->_duplicateElements[$name];
+                $this->_duplicateElements[$name]++;
+            } else {
+                $varName = $this->_formName.'_'.$name;
+            }
+
+            $label = $element->getLabel();
+            $html = $element->toHtml();
+
+            if ($required) {
+                $this->_showRequired = true;
+                $this->_renderRequired($label, $html);
+            }
+            if (!empty($error)) {
+                $this->_renderError($label, $html, $error);
+            }
+            if (is_array($label)) {
+                foreach ($label as $key => $value) {
+                    $this->_tpl->setVariable($varName.'_label_'.$key, $value);
+                }
+            } else {
+                $this->_tpl->setVariable($varName.'_label', $label);
+            }
+            $this->_tpl->setVariable($varName.'_html', $html);
+        }
+    } // end func renderElement
+
+   /**
+    * Called when visiting a hidden element
+    * 
+    * @param    HTML_QuickForm_element  hidden element being visited
+    * @access   public
+    * @return   void
+    */
+    function renderHidden(&$element)
+    {
+        if ($this->_tpl->placeholderExists($this->_formName . '_hidden')) {
+            $this->_hidden .= $element->toHtml();
+        } else {
+            $name = $element->getName();
+            $name = str_replace(array('[', ']'), array('_', ''), $name);
+            $this->_tpl->setVariable($this->_formName.'_'.$name.'_html', $element->toHtml());
+        }
+    } // end func renderHidden
+
+   /**
+    * Called when visiting a group, before processing any group elements
+    *
+    * @param    HTML_QuickForm_group    group being visited
+    * @param    bool                    Whether a group is required
+    * @param    string                  An error message associated with a group
+    * @access   public
+    * @return   void
+    */
+    function startGroup(&$group, $required, $error)
+    {
+        $name = $group->getName();
+        $varName = $this->_formName.'_'.$name;
+
+        $this->_elementIndex = 0;
+
+        $html = $this->_tpl->placeholderExists($varName.'_html') ? $group->toHtml() : '';
+        $label = $group->getLabel();
+
+        if ($required) {
+            $this->_renderRequired($label, $html);
+        }
+        if (!empty($error)) {
+            $this->_renderError($label, $html, $error);
+        }
+        if (!empty($html)) {
+            $this->_tpl->setVariable($varName.'_html', $html);
+        } else {
+            // Uses error blocks to set the special groups layout error
+            // <!-- BEGIN form_group_error -->{form_group_error}<!-- END form_group_error -->
+            if (!empty($error)) {
+                if ($this->_tpl->placeholderExists($varName.'_error')) {
+                    if ($this->_tpl->blockExists($this->_formName . '_error_block')) {
+                        $this->_tpl->setVariable($this->_formName . '_error', $error);
+                        $error = $this->_getTplBlock($this->_formName . '_error_block');
+                    } elseif (strpos($this->_error, '{html}') !== false || strpos($this->_error, '{label}') !== false) {
+                        $error = str_replace('{error}', $error, $this->_error);
+                    }
+                }
+                $this->_tpl->setVariable($varName . '_error', $error);
+                array_pop($this->_errors);
+            }
+        }
+        if (is_array($label)) {
+            foreach ($label as $key => $value) {
+                $this->_tpl->setVariable($varName.'_label_'.$key, $value);
+            }
+        } else {
+            $this->_tpl->setVariable($varName.'_label', $label);
+        }
+        $this->_inGroup = $varName;
+    } // end func startGroup
+
+   /**
+    * Called when visiting a group, after processing all group elements
+    *
+    * @param    HTML_QuickForm_group    group being visited
+    * @access   public
+    * @return   void
+    */
+    function finishGroup(&$group)
+    {
+        $this->_inGroup = '';
+    } // end func finishGroup
+
+   /**
+    * Sets the way required elements are rendered
+    *
+    * You can use {label} or {html} placeholders to let the renderer know where
+    * where the element label or the element html are positionned according to the
+    * required tag. They will be replaced accordingly with the right value.
+    * For example:
+    * <font color="red">*</font>{label}
+    * will put a red star in front of the label if the element is required.
+    *
+    * @param    string      The required element template
+    * @access   public
+    * @return   void
+    */
+    function setRequiredTemplate($template)
+    {
+        $this->_required = $template;
+    } // end func setRequiredTemplate
+
+   /**
+    * Sets the way elements with validation errors are rendered
+    *
+    * You can use {label} or {html} placeholders to let the renderer know where
+    * where the element label or the element html are positionned according to the
+    * error message. They will be replaced accordingly with the right value.
+    * The error message will replace the {error} place holder.
+    * For example:
+    * <font color="red">{error}</font><br />{html}
+    * will put the error message in red on top of the element html.
+    *
+    * If you want all error messages to be output in the main error block, do not specify
+    * {html} nor {label}.
+    *
+    * Groups can have special layouts. With this kind of groups, the renderer will need
+    * to know where to place the error message. In this case, use error blocks like:
+    * <!-- BEGIN form_group_error -->{form_group_error}<!-- END form_group_error -->
+    * where you want the error message to appear in the form.
+    *
+    * @param    string      The element error template
+    * @access   public
+    * @return   void
+    */
+    function setErrorTemplate($template)
+    {
+        $this->_error = $template;
+    } // end func setErrorTemplate
+
+   /**
+    * Called when an element is required
+    *
+    * This method will add the required tag to the element label and/or the element html
+    * such as defined with the method setRequiredTemplate
+    *
+    * @param    string      The element label
+    * @param    string      The element html rendering
+    * @see      setRequiredTemplate()
+    * @access   private
+    * @return   void
+    */
+    function _renderRequired(&$label, &$html)
+    {
+        if ($this->_tpl->blockExists($tplBlock = $this->_formName . '_required_block')) {
+            if (!empty($label) && $this->_tpl->placeholderExists($this->_formName . '_label', $tplBlock)) {
+                $this->_tpl->setVariable($this->_formName . '_label', is_array($label)? $label[0]: $label);
+                if (is_array($label)) {
+                    $label[0] = $this->_getTplBlock($tplBlock);
+                } else {
+                    $label    = $this->_getTplBlock($tplBlock);
+                }
+            }
+            if (!empty($html) && $this->_tpl->placeholderExists($this->_formName . '_html', $tplBlock)) {
+                $this->_tpl->setVariable($this->_formName . '_html', $html);
+                $html = $this->_getTplBlock($tplBlock);
+            }
+        } else {
+            if (!empty($label) && strpos($this->_required, '{label}') !== false) {
+                if (is_array($label)) {
+                    $label[0] = str_replace('{label}', $label[0], $this->_required);
+                } else {
+                    $label = str_replace('{label}', $label, $this->_required);
+                }
+            }
+            if (!empty($html) && strpos($this->_required, '{html}') !== false) {
+                $html = str_replace('{html}', $html, $this->_required);
+            }
+        }
+    } // end func _renderRequired
+
+   /**
+    * Called when an element has a validation error
+    *
+    * This method will add the error message to the element label or the element html
+    * such as defined with the method setErrorTemplate. If the error placeholder is not found
+    * in the template, the error will be displayed in the form error block.
+    *
+    * @param    string      The element label
+    * @param    string      The element html rendering
+    * @param    string      The element error
+    * @see      setErrorTemplate()
+    * @access   private
+    * @return   void
+    */
+    function _renderError(&$label, &$html, $error)
+    {
+        if ($this->_tpl->blockExists($tplBlock = $this->_formName . '_error_block')) {
+            $this->_tpl->setVariable($this->_formName . '_error', $error);
+            if (!empty($label) && $this->_tpl->placeholderExists($this->_formName . '_label', $tplBlock)) {
+                $this->_tpl->setVariable($this->_formName . '_label', is_array($label)? $label[0]: $label);
+                if (is_array($label)) {
+                    $label[0] = $this->_getTplBlock($tplBlock);
+                } else {
+                    $label    = $this->_getTplBlock($tplBlock);
+                }
+            } elseif (!empty($html) && $this->_tpl->placeholderExists($this->_formName . '_html', $tplBlock)) {
+                $this->_tpl->setVariable($this->_formName . '_html', $html);
+                $html = $this->_getTplBlock($tplBlock);
+            }
+            // clean up after ourselves
+            $this->_tpl->setVariable($this->_formName . '_error', null);
+        } elseif (!empty($label) && strpos($this->_error, '{label}') !== false) {
+            if (is_array($label)) {
+                $label[0] = str_replace(array('{label}', '{error}'), array($label[0], $error), $this->_error);
+            } else {
+                $label = str_replace(array('{label}', '{error}'), array($label, $error), $this->_error);
+            }
+        } elseif (!empty($html) && strpos($this->_error, '{html}') !== false) {
+            $html = str_replace(array('{html}', '{error}'), array($html, $error), $this->_error);
+        } else {
+            $this->_errors[] = $error;
+        }
+    }// end func _renderError
+
+
+   /**
+    * Returns the block's contents
+    *
+    * The method is needed because ITX and Sigma implement clearing
+    * the block contents on get() a bit differently
+    *
+    * @param    string  Block name
+    * @return   string  Block contents
+    */
+    function _getTplBlock($block)
+    {
+        $this->_tpl->parse($block);
+        if (is_a($this->_tpl, 'html_template_sigma')) {
+            $ret = $this->_tpl->get($block, true);
+        } else {
+            $oldClear = $this->_tpl->clearCache;
+            $this->_tpl->clearCache = true;
+            $ret = $this->_tpl->get($block);
+            $this->_tpl->clearCache = $oldClear;
+        }
+        return $ret;
+    }
+} // end class HTML_QuickForm_Renderer_ITStatic
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/Object.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/Object.php
new file mode 100644 (file)
index 0000000..afd3aa6
--- /dev/null
@@ -0,0 +1,461 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * A concrete renderer for HTML_QuickForm, makes an object from form contents
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Ron McClain <ron@humaniq.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * An abstract base class for QuickForm renderers
+ */
+require_once 'HTML/QuickForm/Renderer.php';
+
+/**
+ * A concrete renderer for HTML_QuickForm, makes an object from form contents
+ *
+ * Based on HTML_Quickform_Renderer_Array code
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Ron McClain <ron@humaniq.com>
+ * @version     Release: 3.2.16
+ * @since       3.1.1
+ */
+class HTML_QuickForm_Renderer_Object extends HTML_QuickForm_Renderer
+{
+   /**#@+
+    * @access private
+    */
+    /**
+     * The object being generated
+     * @var QuickformForm
+     */
+    var $_obj= null;
+
+    /**
+     * Number of sections in the form (i.e. number of headers in it)
+     * @var integer $_sectionCount
+     */
+    var $_sectionCount;
+
+    /**
+    * Current section number
+    * @var integer $_currentSection
+    */
+    var $_currentSection;
+
+    /**
+    * Object representing current group
+    * @var object $_currentGroup
+    */
+    var $_currentGroup = null;
+
+    /**
+     * Class of Element Objects
+     * @var object $_elementType
+     */
+    var $_elementType = 'QuickFormElement';
+
+    /**
+    * Additional style information for different elements  
+    * @var array $_elementStyles
+    */
+    var $_elementStyles = array();
+
+    /**
+    * true: collect all hidden elements into string; false: process them as usual form elements
+    * @var bool $_collectHidden
+    */
+    var $_collectHidden = false;
+   /**#@-*/
+
+
+    /**
+     * Constructor
+     *
+     * @param bool    true: collect all hidden elements
+     * @access public
+     */
+    function HTML_QuickForm_Renderer_Object($collecthidden = false) 
+    {
+        $this->HTML_QuickForm_Renderer();
+        $this->_collectHidden = $collecthidden;
+        $this->_obj = new QuickformForm;
+    }
+
+    /**
+     * Return the rendered Object
+     * @access public
+     */
+    function toObject() 
+    {
+        return $this->_obj;
+    }
+
+    /**
+     * Set the class of the form elements.  Defaults to QuickformElement.
+     * @param string   Name of element class
+     * @access public
+     */
+    function setElementType($type)
+    {
+        $this->_elementType = $type;
+    }
+
+    function startForm(&$form) 
+    {
+        $this->_obj->frozen = $form->isFrozen();
+        $this->_obj->javascript = $form->getValidationScript();
+        $this->_obj->attributes = $form->getAttributes(true);
+        $this->_obj->requirednote = $form->getRequiredNote();
+        $this->_obj->errors = new StdClass;
+
+        if($this->_collectHidden) {
+            $this->_obj->hidden = '';
+        }
+        $this->_elementIdx = 1;
+        $this->_currentSection = null;
+        $this->_sectionCount = 0;
+    } // end func startForm
+
+    function renderHeader(&$header) 
+    {
+        $hobj = new StdClass;
+        $hobj->header = $header->toHtml();
+        $this->_obj->sections[$this->_sectionCount] = $hobj;
+        $this->_currentSection = $this->_sectionCount++;
+    }
+
+    function renderElement(&$element, $required, $error) 
+    {
+        $elObj = $this->_elementToObject($element, $required, $error);
+        if(!empty($error)) {
+            $name = $elObj->name;
+            $this->_obj->errors->$name = $error;
+        }
+        $this->_storeObject($elObj);
+    } // end func renderElement
+
+    function renderHidden(&$element)
+    {
+        if($this->_collectHidden) {
+            $this->_obj->hidden .= $element->toHtml() . "\n";
+        } else {
+            $this->renderElement($element, false, null);
+        }
+    } //end func renderHidden
+
+    function startGroup(&$group, $required, $error) 
+    {
+        $this->_currentGroup = $this->_elementToObject($group, $required, $error);
+        if(!empty($error)) {
+            $name = $this->_currentGroup->name;
+            $this->_obj->errors->$name = $error;
+        }
+    } // end func startGroup
+
+    function finishGroup(&$group) 
+    {
+        $this->_storeObject($this->_currentGroup);
+        $this->_currentGroup = null;
+    } // end func finishGroup
+
+    /**
+     * Creates an object representing an element
+     *
+     * @access private
+     * @param HTML_QuickForm_element    form element being rendered
+     * @param required bool         Whether an element is required
+     * @param error string    Error associated with the element
+     * @return object
+     */
+    function _elementToObject(&$element, $required, $error) 
+    {
+        if($this->_elementType) {
+            $ret = new $this->_elementType;
+        }
+        $ret->name = $element->getName();
+        $ret->value = $element->getValue();
+        $ret->type = $element->getType();
+        $ret->frozen = $element->isFrozen();
+        $labels = $element->getLabel();
+        if (is_array($labels)) {
+            $ret->label = array_shift($labels);
+            foreach ($labels as $key => $label) {
+                $key = is_int($key)? $key + 2: $key;
+                $ret->{'label_' . $key} = $label;
+            }
+        } else {
+            $ret->label = $labels;
+        }
+        $ret->required = $required;
+        $ret->error = $error;
+
+        if(isset($this->_elementStyles[$ret->name])) {
+            $ret->style = $this->_elementStyles[$ret->name];
+            $ret->styleTemplate = "styles/". $ret->style .".html";
+        }
+        if($ret->type == 'group') {
+            $ret->separator = $element->_separator;
+            $ret->elements = array();
+        } else {
+            $ret->html = $element->toHtml();
+        }
+        return $ret;
+    }
+
+    /** 
+     * Stores an object representation of an element in the form array
+     *
+     * @access private
+     * @param QuickformElement     Object representation of an element
+     * @return void
+     */
+    function _storeObject($elObj) 
+    {
+        $name = $elObj->name;
+        if(is_object($this->_currentGroup) && $elObj->type != 'group') {
+            $this->_currentGroup->elements[] = $elObj;
+        } elseif (isset($this->_currentSection)) {
+            $this->_obj->sections[$this->_currentSection]->elements[] = $elObj;
+        } else {
+            $this->_obj->elements[] = $elObj;
+        }
+    }
+
+    function setElementStyle($elementName, $styleName = null)
+    {
+        if(is_array($elementName)) {
+            $this->_elementStyles = array_merge($this->_elementStyles, $elementName);
+        } else {
+            $this->_elementStyles[$elementName] = $styleName;
+        }
+    }
+
+} // end class HTML_QuickForm_Renderer_Object
+
+
+
+/**
+ * Convenience class for the form object passed to outputObject()
+ * 
+ * Eg.
+ * <pre>  
+ * {form.outputJavaScript():h}
+ * {form.outputHeader():h}
+ *   <table>
+ *     <tr>
+ *       <td>{form.name.label:h}</td><td>{form.name.html:h}</td>
+ *     </tr>
+ *   </table>
+ * </form>
+ * </pre>
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Ron McClain <ron@humaniq.com>
+ * @version     Release: 3.2.16
+ * @since       3.1.1
+ */
+class QuickformForm
+{
+   /**
+    * Whether the form has been frozen
+    * @var boolean $frozen
+    */
+    var $frozen;
+
+   /**
+    * Javascript for client-side validation
+    * @var string $javascript
+    */
+    var $javascript;
+
+   /**
+    * Attributes for form tag
+    * @var string $attributes
+    */
+    var $attributes;
+
+   /**
+    * Note about required elements
+    * @var string $requirednote
+    */
+    var $requirednote;
+
+   /**
+    * Collected html of all hidden variables
+    * @var string $hidden
+    */
+    var $hidden;
+
+   /**
+    * Set if there were validation errors.  
+    * StdClass object with element names for keys and their
+    * error messages as values
+    * @var object $errors
+    */
+    var $errors;
+
+   /**
+    * Array of QuickformElementObject elements.  If there are headers in the form
+    * this will be empty and the elements will be in the 
+    * separate sections
+    * @var array $elements
+    */
+    var $elements;
+
+   /**
+    * Array of sections contained in the document
+    * @var array $sections
+    */
+    var $sections;
+
+   /**
+    * Output &lt;form&gt; header
+    * {form.outputHeader():h} 
+    * @return string    &lt;form attributes&gt;
+    */
+    function outputHeader()
+    {
+        return "<form " . $this->attributes . ">\n";
+    }
+
+   /**
+    * Output form javascript
+    * {form.outputJavaScript():h}
+    * @return string    Javascript
+    */
+    function outputJavaScript()
+    {
+        return $this->javascript;
+    }
+} // end class QuickformForm
+
+
+/**
+ * Convenience class describing a form element.
+ *
+ * The properties defined here will be available from 
+ * your flexy templates by referencing
+ * {form.zip.label:h}, {form.zip.html:h}, etc.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Ron McClain <ron@humaniq.com>
+ * @version     Release: 3.2.16
+ * @since       3.1.1
+ */
+class QuickformElement
+{
+    /**
+     * Element name
+     * @var string $name
+     */
+    var $name;
+
+    /**
+     * Element value
+     * @var mixed $value
+     */
+    var $value;
+
+    /**
+     * Type of element
+     * @var string $type
+     */
+    var $type;
+
+    /**
+     * Whether the element is frozen
+     * @var boolean $frozen
+     */
+    var $frozen;
+
+    /**
+     * Label for the element
+     * @var string $label
+     */
+    var $label;
+
+    /**
+     * Whether element is required
+     * @var boolean $required
+     */
+    var $required;
+
+    /**
+     * Error associated with the element
+     * @var string $error
+     */
+    var $error;
+
+    /**
+     * Some information about element style
+     * @var string $style
+     */
+    var $style;
+
+    /**
+     * HTML for the element
+     * @var string $html
+     */
+    var $html;
+
+    /**
+     * If element is a group, the group separator
+     * @var mixed $separator
+     */
+    var $separator;
+
+    /**
+     * If element is a group, an array of subelements
+     * @var array $elements
+     */
+    var $elements;
+
+    function isType($type)
+    {
+        return ($this->type == $type);
+    }
+
+    function notFrozen()
+    {
+        return !$this->frozen;
+    }
+
+    function isButton()
+    {
+        return ($this->type == "submit" || $this->type == "reset");
+    }
+
+
+   /**
+    * XXX: why does it use Flexy when all other stuff here does not depend on it?
+    */
+    function outputStyle()
+    {
+        ob_start();
+        HTML_Template_Flexy::staticQuickTemplate('styles/' . $this->style . '.html', $this);
+        $ret = ob_get_contents();
+        ob_end_clean();
+        return $ret;
+    }
+} // end class QuickformElement
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/ObjectFlexy.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/ObjectFlexy.php
new file mode 100644 (file)
index 0000000..048e556
--- /dev/null
@@ -0,0 +1,291 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * QuickForm renderer for Flexy template engine, static version.
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Ron McClain <ron@humaniq.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * A concrete renderer for HTML_QuickForm, makes an object from form contents
+ */ 
+require_once 'HTML/QuickForm/Renderer/Object.php';
+
+/**
+ * QuickForm renderer for Flexy template engine, static version.
+ * 
+ * A static renderer for HTML_Quickform.  Makes a QuickFormFlexyObject
+ * from the form content suitable for use with a Flexy template
+ *
+ * Usage:
+ * <code>
+ * $form =& new HTML_QuickForm('form', 'POST');
+ * $template =& new HTML_Template_Flexy();
+ * $renderer =& new HTML_QuickForm_Renderer_ObjectFlexy(&$template);
+ * $renderer->setHtmlTemplate("html.html");
+ * $renderer->setLabelTemplate("label.html");
+ * $form->accept($renderer);
+ * $view = new StdClass;
+ * $view->form = $renderer->toObject();
+ * $template->compile("mytemplate.html");
+ * </code>
+ *
+ * Based on the code for HTML_QuickForm_Renderer_ArraySmarty
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Ron McClain <ron@humaniq.com>
+ * @version     Release: 3.2.16
+ * @since       3.1.1
+ */
+class HTML_QuickForm_Renderer_ObjectFlexy extends HTML_QuickForm_Renderer_Object
+{
+   /**#@+
+    * @access private
+    */
+    /**
+     * HTML_Template_Flexy instance
+     * @var object $_flexy
+     */
+    var $_flexy;
+
+    /**
+     * Current element index
+     * @var integer $_elementIdx
+     */
+    var $_elementIdx;
+
+    /**
+     * The current element index inside a group
+     * @var integer $_groupElementIdx
+     */
+    var $_groupElementIdx = 0;
+
+    /**
+     * Name of template file for form html
+     * @var string $_html
+     * @see     setRequiredTemplate()
+     */
+    var $_html = '';
+
+    /**
+     * Name of template file for form labels
+     * @var string $label
+     * @see        setErrorTemplate()
+     */
+    var $label = '';
+
+    /**
+     * Class of the element objects, so you can add your own
+     * element methods
+     * @var string $_elementType
+     */
+    var $_elementType = 'QuickformFlexyElement';
+   /**#@-*/
+
+    /**
+     * Constructor
+     *
+     * @param HTML_Template_Flexy   template object to use
+     * @public
+     */
+    function HTML_QuickForm_Renderer_ObjectFlexy(&$flexy)
+    {
+        $this->HTML_QuickForm_Renderer_Object(true);
+        $this->_obj = new QuickformFlexyForm();
+        $this->_flexy =& $flexy;
+    } // end constructor
+
+    function renderHeader(&$header)
+    {
+        if($name = $header->getName()) {
+            $this->_obj->header->$name = $header->toHtml();
+        } else {
+            $this->_obj->header[$this->_sectionCount] = $header->toHtml();
+        }
+        $this->_currentSection = $this->_sectionCount++;
+    } // end func renderHeader
+
+    function startGroup(&$group, $required, $error)
+    {
+        parent::startGroup($group, $required, $error);
+        $this->_groupElementIdx = 1;
+    } //end func startGroup
+
+    /**
+     * Creates an object representing an element containing
+     * the key for storing this
+     *
+     * @access private
+     * @param HTML_QuickForm_element    form element being rendered
+     * @param bool        Whether an element is required
+     * @param string    Error associated with the element
+     * @return object
+     */
+    function _elementToObject(&$element, $required, $error)
+    {
+        $ret = parent::_elementToObject($element, $required, $error);
+        if($ret->type == 'group') {
+            $ret->html = $element->toHtml();
+            unset($ret->elements);
+        }
+        if(!empty($this->_label)) {
+            $this->_renderLabel($ret);
+        }
+
+        if(!empty($this->_html)) {
+            $this->_renderHtml($ret);
+            $ret->error = $error;
+        }
+
+        // Create an element key from the name
+        if (false !== ($pos = strpos($ret->name, '[')) || is_object($this->_currentGroup)) {
+            if (!$pos) {
+                $keys = '->{\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret->name) . '\'}';
+            } else {
+                $keys = '->{\'' . str_replace(
+                            array('\\', '\'', '[', ']'), array('\\\\', '\\\'', '\'}->{\'', ''), 
+                            $ret->name
+                        ) . '\'}';
+            }
+            // special handling for elements in native groups
+            if (is_object($this->_currentGroup)) {
+                // skip unnamed group items unless radios: no name -> no static access
+                // identification: have the same key string as the parent group
+                if ($this->_currentGroup->keys == $keys && 'radio' != $ret->type) {
+                    return false;
+                }
+                // reduce string of keys by remove leading group keys
+                if (0 === strpos($keys, $this->_currentGroup->keys)) {
+                    $keys = substr_replace($keys, '', 0, strlen($this->_currentGroup->keys));
+                }
+            }
+        } elseif (0 == strlen($ret->name)) {
+            $keys = '->{\'element_' . $this->_elementIdx . '\'}';
+        } else {
+            $keys = '->{\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret->name) . '\'}';
+        }
+        // for radios: add extra key from value
+        if ('radio' == $ret->type && '[]' != substr($keys, -2)) {
+            $keys .= '->{\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret->value) . '\'}';
+        }
+        $ret->keys = $keys;
+        $this->_elementIdx++;
+        return $ret;
+    }
+
+    /**
+     * Stores an object representation of an element in the 
+     * QuickformFormObject instance
+     *
+     * @access private
+     * @param QuickformElement  Object representation of an element
+     * @return void
+     */
+    function _storeObject($elObj) 
+    {
+        if ($elObj) {
+            $keys = $elObj->keys;
+            unset($elObj->keys);
+            if(is_object($this->_currentGroup) && ('group' != $elObj->type)) {
+                $code = '$this->_currentGroup' . $keys . ' = $elObj;';
+            } else {
+                $code = '$this->_obj' . $keys . ' = $elObj;';
+            }
+            eval($code);
+        }
+    }
+
+    /**
+     * Set the filename of the template to render html elements.
+     * In your template, {html} is replaced by the unmodified html.
+     * If the element is required, {required} will be true.
+     * Eg.
+     * <pre>
+     * {if:error}
+     *   <font color="red" size="1">{error:h}</font><br />
+     * {end:}
+     * {html:h}
+     * </pre>
+     *
+     * @access public
+     * @param string   Filename of template
+     * @return void
+     */
+    function setHtmlTemplate($template)
+    {
+        $this->_html = $template;
+    } 
+
+    /**
+     * Set the filename of the template to render form labels
+     * In your template, {label} is replaced by the unmodified label.
+     * {error} will be set to the error, if any.  {required} will
+     * be true if this is a required field
+     * Eg.
+     * <pre>
+     * {if:required}
+     * <font color="orange" size="1">*</font>
+     * {end:}
+     * {label:h}
+     * </pre>
+     *
+     * @access public
+     * @param string   Filename of template
+     * @return void
+     */
+    function setLabelTemplate($template) 
+    {
+        $this->_label = $template;
+    }
+
+    function _renderLabel(&$ret)
+    {
+        $this->_flexy->compile($this->_label);
+        $ret->label = $this->_flexy->bufferedOutputObject($ret);
+    }
+
+    function _renderHtml(&$ret)
+    {
+        $this->_flexy->compile($this->_html);
+        $ret->html = $this->_flexy->bufferedOutputObject($ret);
+    }
+} // end class HTML_QuickForm_Renderer_ObjectFlexy
+
+/**
+ * Adds nothing to QuickformForm, left for backwards compatibility
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @ignore
+ */
+class QuickformFlexyForm extends QuickformForm
+{
+}
+
+/**
+ * Adds nothing to QuickformElement, left for backwards compatibility
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @ignore
+ */
+class QuickformFlexyElement extends QuickformElement
+{
+}
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/QuickHtml.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/QuickHtml.php
new file mode 100644 (file)
index 0000000..13a0c4e
--- /dev/null
@@ -0,0 +1,213 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * A renderer that makes it quick and easy to create customized forms.
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Jason Rust <jrust@rustyparts.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * A concrete renderer for HTML_QuickForm, based on QuickForm 2.x built-in one
+ */ 
+require_once 'HTML/QuickForm/Renderer/Default.php';
+
+/**
+ * A renderer that makes it quick and easy to create customized forms.
+ *
+ * This renderer has three main distinctives: an easy way to create
+ * custom-looking forms, the ability to separate the creation of form
+ * elements from their display, and being able to use QuickForm in
+ * widget-based template systems.  See the online docs for more info.
+ * For a usage example see: docs/renderers/QuickHtml_example.php
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Jason Rust <jrust@rustyparts.com>
+ * @version     Release: 3.2.16
+ * @since       3.1.1
+ */
+class HTML_QuickForm_Renderer_QuickHtml extends HTML_QuickForm_Renderer_Default {
+    // {{{ properties
+
+    /**
+     * The array of rendered elements
+     * @var array
+     */
+    var $renderedElements = array();
+
+    // }}}
+    // {{{ constructor
+    
+    /**
+     * Constructor
+     *
+     * @access public
+     * @return void
+     */
+    function HTML_QuickForm_Renderer_QuickHtml()
+    {
+        $this->HTML_QuickForm_Renderer_Default();
+        // The default templates aren't used for this renderer
+        $this->clearAllTemplates();
+    } // end constructor
+
+    // }}}
+    // {{{ toHtml()
+
+    /**
+     * returns the HTML generated for the form
+     *
+     * @param string $data (optional) Any extra data to put before the end of the form
+     *
+     * @access public
+     * @return string
+     */
+    function toHtml($data = '')
+    {
+        // Render any elements that haven't been rendered explicitly by elementToHtml()
+        foreach (array_keys($this->renderedElements) as $key) {
+            if (!$this->renderedElements[$key]['rendered']) {
+                $this->renderedElements[$key]['rendered'] = true;
+                $data .= $this->renderedElements[$key]['html'] . "\n";
+            }
+        }
+
+        // Insert the extra data and form elements at the end of the form
+        $this->_html = str_replace('</form>', $data . "\n</form>", $this->_html);
+        return $this->_html;
+    } // end func toHtml
+
+    // }}}
+    // {{{ elementToHtml()
+
+    /**
+     * Gets the html for an element and marks it as rendered.
+     *
+     * @param string $elementName The element name
+     * @param string $elementValue (optional) The value of the element.  This is only useful
+     *               for elements that have the same name (i.e. radio and checkbox), but
+     *               different values
+     *
+     * @access public
+     * @return string The html for the QuickForm element
+     * @throws HTML_QuickForm_Error
+     */
+    function elementToHtml($elementName, $elementValue = null)
+    {
+        $elementKey = null;
+        // Find the key for the element
+        foreach ($this->renderedElements as $key => $data) {
+            if ($data['name'] == $elementName && 
+                // See if the value must match as well
+                (is_null($elementValue) ||
+                 $data['value'] == $elementValue)) {
+                $elementKey = $key;
+                break;
+            }
+        }
+
+        if (is_null($elementKey)) {
+            $msg = is_null($elementValue) ? "Element $elementName does not exist." : 
+                "Element $elementName with value of $elementValue does not exist.";
+            return PEAR::raiseError(null, QUICKFORM_UNREGISTERED_ELEMENT, null, E_USER_WARNING, $msg, 'HTML_QuickForm_Error', true);
+        } else {
+            if ($this->renderedElements[$elementKey]['rendered']) {
+                $msg = is_null($elementValue) ? "Element $elementName has already been rendered." : 
+                    "Element $elementName with value of $elementValue has already been rendered.";
+                return PEAR::raiseError(null, QUICKFORM_ERROR, null, E_USER_WARNING, $msg, 'HTML_QuickForm_Error', true);
+            } else {
+                $this->renderedElements[$elementKey]['rendered'] = true;
+                return $this->renderedElements[$elementKey]['html'];
+            }
+        }
+    } // end func elementToHtml
+
+    // }}}
+    // {{{ renderElement()
+
+    /**
+     * Gets the html for an element and adds it to the array by calling
+     * parent::renderElement()
+     *
+     * @param HTML_QuickForm_element    form element being visited
+     * @param bool                      Whether an element is required
+     * @param string                    An error message associated with an element
+     *
+     * @access public
+     * @return mixed HTML string of element if $immediateRender is set, else we just add the
+     *               html to the global _html string 
+     */
+    function renderElement(&$element, $required, $error)
+    {
+        $this->_html = '';
+        parent::renderElement($element, $required, $error);
+        if (!$this->_inGroup) {
+            $this->renderedElements[] = array(
+                    'name' => $element->getName(), 
+                    'value' => $element->getValue(), 
+                    'html' => $this->_html, 
+                    'rendered' => false);
+        }
+        $this->_html = '';
+    } // end func renderElement
+
+    // }}}
+    // {{{ renderHidden()
+
+    /**
+     * Gets the html for a hidden element and adds it to the array.
+     * 
+     * @param HTML_QuickForm_element    hidden form element being visited
+     * @access public
+     * @return void
+     */
+    function renderHidden(&$element)
+    {
+        $this->renderedElements[] = array(
+                'name' => $element->getName(), 
+                'value' => $element->getValue(), 
+                'html' => $element->toHtml(), 
+                'rendered' => false);
+    } // end func renderHidden
+    
+    // }}}
+    // {{{ finishGroup()
+
+    /**
+     * Gets the html for the group element and adds it to the array by calling
+     * parent::finishGroup()
+     *
+     * @param    HTML_QuickForm_group   group being visited
+     * @access   public
+     * @return   void
+     */
+    function finishGroup(&$group)
+    {
+        $this->_html = '';
+        parent::finishGroup($group);
+        $this->renderedElements[] = array(
+                'name' => $group->getName(), 
+                'value' => $group->getValue(), 
+                'html' => $this->_html, 
+                'rendered' => false);
+        $this->_html = '';
+    } // end func finishGroup
+
+    // }}}
+} // end class HTML_QuickForm_Renderer_QuickHtml
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/Tableless.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Renderer/Tableless.php
new file mode 100644 (file)
index 0000000..92cb7bb
--- /dev/null
@@ -0,0 +1,506 @@
+<?php
+/**
+ * Replacement for the default renderer of HTML_QuickForm that uses only XHTML
+ * and CSS but no table tags, and generates fully valid XHTML output
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE:
+ *
+ * Copyright (c) 2005-2007, Mark Wiesemann <wiesemann@php.net>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the
+ *      documentation and/or other materials provided with the distribution.
+ *    * The names of the authors may not be used to endorse or promote products
+ *      derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   HTML
+ * @package    HTML_QuickForm_Renderer_Tableless
+ * @author     Alexey Borzov <borz_off@cs.msu.su>
+ * @author     Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author     Bertrand Mansion <bmansion@mamasam.com>
+ * @author     Mark Wiesemann <wiesemann@php.net>
+ * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
+ * @version    CVS: $Id: Tableless.php 271939 2008-12-26 20:22:30Z wiesemann $
+ * @link       http://pear.php.net/package/HTML_QuickForm_Renderer_Tableless
+ */
+
+require_once 'HTML/QuickForm/Renderer/Default.php';
+
+/**
+ * Replacement for the default renderer of HTML_QuickForm that uses only XHTML
+ * and CSS but no table tags, and generates fully valid XHTML output
+ *
+ * You need to specify a stylesheet like the one that you find in
+ * data/stylesheet.css to make this work.
+ *
+ * @category   HTML
+ * @package    HTML_QuickForm_Renderer_Tableless
+ * @author     Alexey Borzov <borz_off@cs.msu.su>
+ * @author     Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author     Bertrand Mansion <bmansion@mamasam.com>
+ * @author     Mark Wiesemann <wiesemann@php.net>
+ * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
+ * @version    Release: 0.6.2
+ * @link       http://pear.php.net/package/HTML_QuickForm_Renderer_Tableless
+ */
+class HTML_QuickForm_Renderer_Tableless extends HTML_QuickForm_Renderer_Default
+{
+   /**
+    * Header Template string
+    * @var      string
+    * @access   private
+    */
+    var $_headerTemplate = "\n\t\t<legend>{header}</legend>\n\t\t<ol>";
+
+   /**
+    * Element template string
+    * @var      string
+    * @access   private
+    */
+    var $_elementTemplate =
+        "\n\t\t\t<li><label class=\"element\"><!-- BEGIN required --><span class=\"required\">*</span><!-- END required -->{label}</label><div class=\"element<!-- BEGIN error --> error<!-- END error -->\"><!-- BEGIN error --><span class=\"error\">{error}</span><br /><!-- END error -->{element}</div></li>";
+
+   /**
+    * Form template string
+    * @var      string
+    * @access   private
+    */
+    var $_formTemplate =
+        "\n<form{attributes}>\n\t<div style=\"display: none;\">\n{hidden}\t</div>\n{content}\n</form>";
+
+   /**
+    * Template used when opening a fieldset
+    * @var      string
+    * @access   private
+    */
+    var $_openFieldsetTemplate = "\n\t<fieldset{id}{attributes}>";
+
+   /**
+    * Template used when opening a hidden fieldset
+    * (i.e. a fieldset that is opened when there is no header element)
+    * @var      string
+    * @access   private
+    */
+    var $_openHiddenFieldsetTemplate = "\n\t<fieldset class=\"hidden{class}\">\n\t\t<ol>";
+
+   /**
+    * Template used when closing a fieldset
+    * @var      string
+    * @access   private
+    */
+    var $_closeFieldsetTemplate = "\n\t\t</ol>\n\t</fieldset>";
+
+   /**
+    * Required Note template string
+    * @var      string
+    * @access   private
+    */
+    var $_requiredNoteTemplate =
+        "\n\t\t\t<li class=\"reqnote\"><label class=\"element\">&nbsp;</label>{requiredNote}</li>";
+
+   /**
+    * How many fieldsets are open
+    * @var      integer
+    * @access   private
+    */
+   var $_fieldsetsOpen = 0;
+
+   /**
+    * Array of element names that indicate the end of a fieldset
+    * (a new one will be opened when the next header element occurs)
+    * @var      array
+    * @access   private
+    */
+    var $_stopFieldsetElements = array();
+
+   /**
+    * Name of the currently active group
+    * @var      string
+    * @access   private
+    */
+    var $_currentGroupName = '';
+
+   /**
+    * Constructor
+    *
+    * @access public
+    */
+    function HTML_QuickForm_Renderer_Tableless()
+    {
+        $this->HTML_QuickForm_Renderer_Default();
+    } // end constructor
+
+   /**
+    * Called when visiting a header element
+    *
+    * @param    object     An HTML_QuickForm_header element being visited
+    * @access   public
+    * @return   void
+    */
+    function renderHeader(&$header)
+    {
+        $name = $header->getName();
+        $id = empty($name) ? '' : ' id="' . $name . '"';
+        if (!empty($name) && isset($this->_templates[$name])) {
+            $header_html = str_replace('{header}', $header->toHtml(), $this->_templates[$name]);
+        } else {
+            $header_html = str_replace('{header}', $header->toHtml(), $this->_headerTemplate);
+        }
+        $attributes = $header->getAttributes();
+        $strAttr = '';
+        if (is_array($attributes)) {
+            $charset = HTML_Common::charset();
+            foreach ($attributes as $key => $value) {
+                if ($key == 'name') {
+                    continue;
+                }
+                $strAttr .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, $charset) . '"';
+            }
+        }
+        if ($this->_fieldsetsOpen > 0) {
+            $this->_html .= $this->_closeFieldsetTemplate;
+            $this->_fieldsetsOpen--;
+        }
+        $openFieldsetTemplate = str_replace('{id}', $id, $this->_openFieldsetTemplate);
+        $openFieldsetTemplate = str_replace('{attributes}',
+                                            $strAttr,
+                                            $openFieldsetTemplate);
+        $this->_html .= $openFieldsetTemplate . $header_html;
+        $this->_fieldsetsOpen++;
+    } // end func renderHeader
+
+   /**
+    * Renders an element Html
+    * Called when visiting an element
+    *
+    * @param object     An HTML_QuickForm_element object being visited
+    * @param bool       Whether an element is required
+    * @param string     An error message associated with an element
+    * @access public
+    * @return void
+    */
+    function renderElement(&$element, $required, $error)
+    {
+        $this->_handleStopFieldsetElements($element->getName());
+        if (!$this->_inGroup) {
+            $html = $this->_prepareTemplate($element->getName(), $element->getLabel(), $required, $error);
+            // the following lines (until the "elseif") were changed / added
+            // compared to the default renderer
+            $element_html = $element->toHtml();
+            if (!is_null($element->getAttribute('id'))) {
+                $id = $element->getAttribute('id');
+            } else {
+                $id = $element->getName();
+            }
+            if ($element->getType() != 'static' && !empty($id)) {
+                $html = str_replace('<label', '<label for="' . $id . '"', $html);
+                $element_html = preg_replace(preg_quote('#name="' . $id . '#'),
+                                             'id="' . $id . '" name="' . $id,
+                                             $element_html,
+                                             1);
+            }
+            $this->_html .= str_replace('{element}', $element_html, $html);
+        } elseif (!empty($this->_groupElementTemplate)) {
+            $html = str_replace('{label}', $element->getLabel(), $this->_groupElementTemplate);
+            if ($required) {
+                $html = str_replace('<!-- BEGIN required -->', '', $html);
+                $html = str_replace('<!-- END required -->', '', $html);
+            } else {
+                $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->(\s|\S)*<!-- END required -->([ \t\n\r]*)?/i", '', $html);
+            }
+            $this->_groupElements[] = str_replace('{element}', $element->toHtml(), $html);
+
+        } else {
+            $element_html = $element->toHtml();
+            // add "id" attribute to first element of the group
+            if (count($this->_groupElements) === 0) {
+                if (!is_null($element->getAttribute('id'))) {
+                    $id = $element->getAttribute('id');
+                } else {
+                    $id = $element->getName();
+                }
+                $groupId = $this->_currentGroupName;
+                if ($element->getType() != 'static' && !empty($id)) {
+                    $element_html = preg_replace(preg_quote('#name="' . $id . '#'),
+                                                 'id="' . $groupId . '" name="' . $id,
+                                                 $element_html,
+                                                 1);
+                }
+            }
+            $this->_groupElements[] = $element_html;
+        }
+    } // end func renderElement
+
+   /**
+    * Renders an hidden element
+    * Called when visiting a hidden element
+    *
+    * @param object     An HTML_QuickForm_hidden object being visited
+    * @access public
+    * @return void
+    */
+    function renderHidden(&$element)
+    {
+        if (!is_null($element->getAttribute('id'))) {
+            $id = $element->getAttribute('id');
+        } else {
+            $id = $element->getName();
+        }
+        $html = $element->toHtml();
+        if (!empty($id)) {
+            $html = str_replace('name="' . $id,
+                                'id="' . $id . '" name="' . $id,
+                                $html);
+        }
+        $this->_hiddenHtml .= $html . "\n";
+    } // end func renderHidden
+
+   /**
+    * Called when visiting a group, before processing any group elements
+    *
+    * @param object     An HTML_QuickForm_group object being visited
+    * @param bool       Whether a group is required
+    * @param string     An error message associated with a group
+    * @access public
+    * @return void
+    */
+    function startGroup(&$group, $required, $error)
+    {
+        $this->_handleStopFieldsetElements($group->getName());
+        $name = $group->getName();
+        $this->_groupTemplate        = $this->_prepareTemplate($name, $group->getLabel(), $required, $error);
+        $this->_groupTemplate        = str_replace('<label', '<label for="' . $name . '"', $this->_groupTemplate);
+        $this->_groupElementTemplate = empty($this->_groupTemplates[$name])? '': $this->_groupTemplates[$name];
+        $this->_groupWrap            = empty($this->_groupWraps[$name])? '': $this->_groupWraps[$name];
+        $this->_groupElements        = array();
+        $this->_inGroup              = true;
+        $this->_currentGroupName     = $name;
+    } // end func startGroup
+
+    /**
+    * Called when visiting a group, after processing all group elements
+    *
+    * @param    object      An HTML_QuickForm_group object being visited
+    * @access   public
+    * @return   void
+    */
+    function finishGroup(&$group)
+    {
+        $separator = $group->_separator;
+        if (is_array($separator)) {
+            $count = count($separator);
+            $html  = '';
+            for ($i = 0; $i < count($this->_groupElements); $i++) {
+                $html .= (0 == $i? '': $separator[($i - 1) % $count]) . $this->_groupElements[$i];
+            }
+        } else {
+            if (is_null($separator)) {
+                $separator = '&nbsp;';
+            }
+            $html = implode((string)$separator, $this->_groupElements);
+        }
+        if (!empty($this->_groupWrap)) {
+            $html = str_replace('{content}', $html, $this->_groupWrap);
+        }
+        if (!is_null($group->getAttribute('id'))) {
+            $id = $group->getAttribute('id');
+        } else {
+            $id = $group->getName();
+        }
+        $groupTemplate = $this->_groupTemplate;
+
+        $this->_html   .= str_replace('{element}', $html, $groupTemplate);
+        $this->_inGroup = false;
+    } // end func finishGroup
+
+    /**
+    * Called when visiting a form, before processing any form elements
+    *
+    * @param    object      An HTML_QuickForm object being visited
+    * @access   public
+    * @return   void
+    */
+    function startForm(&$form)
+    {
+        $this->_fieldsetsOpen = 0;
+        parent::startForm($form);
+    } // end func startForm
+
+   /**
+    * Called when visiting a form, after processing all form elements
+    * Adds required note, form attributes, validation javascript and form content.
+    *
+    * @param    object      An HTML_QuickForm object being visited
+    * @access   public
+    * @return   void
+    */
+    function finishForm(&$form)
+    {
+        // add a required note, if one is needed
+        if (!empty($form->_required) && !$form->_freezeAll) {
+            $requiredNote = $form->getRequiredNote();
+            // replace default required note by DOM/XHTML optimized note
+            if ($requiredNote == '<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;"> denotes required field</span>') {
+                $requiredNote = '<span class="required">*</span> denotes required field';
+            }
+            $this->_html .= str_replace('{requiredNote}', $requiredNote, $this->_requiredNoteTemplate);
+        }
+        // close the open fieldset
+        if ($this->_fieldsetsOpen > 0) {
+            $this->_html .= $this->_closeFieldsetTemplate;
+            $this->_fieldsetsOpen--;
+        }
+        // add form attributes and content
+        $html = str_replace('{attributes}', $form->getAttributes(true), $this->_formTemplate);
+        if (strpos($this->_formTemplate, '{hidden}')) {
+            $html = str_replace('{hidden}', $this->_hiddenHtml, $html);
+        } else {
+            $this->_html .= $this->_hiddenHtml;
+        }
+        $this->_hiddenHtml = '';
+        $this->_html = str_replace('{content}', $this->_html, $html);
+        $this->_html = str_replace('></label>', '>&nbsp;</label>', $this->_html);
+        // add a validation script
+        if ('' != ($script = $form->getValidationScript())) {
+            $this->_html = $script . "\n" . $this->_html;
+        }
+    } // end func finishForm
+
+    /**
+     * Sets the template used when opening a fieldset
+     *
+     * @param       string      The HTML used when opening a fieldset
+     * @access      public
+     * @return      void
+     */
+    function setOpenFieldsetTemplate($html)
+    {
+        $this->_openFieldsetTemplate = $html;
+    } // end func setOpenFieldsetTemplate
+
+    /**
+     * Sets the template used when opening a hidden fieldset
+     * (i.e. a fieldset that is opened when there is no header element)
+     *
+     * @param       string      The HTML used when opening a hidden fieldset
+     * @access      public
+     * @return      void
+     */
+    function setOpenHiddenFieldsetTemplate($html)
+    {
+        $this->_openHiddenFieldsetTemplate = $html;
+    } // end func setOpenHiddenFieldsetTemplate
+
+    /**
+     * Sets the template used when closing a fieldset
+     *
+     * @param       string      The HTML used when closing a fieldset
+     * @access      public
+     * @return      void
+     */
+    function setCloseFieldsetTemplate($html)
+    {
+        $this->_closeFieldsetTemplate = $html;
+    } // end func setCloseFieldsetTemplate
+
+    /**
+     * Adds one or more element names that indicate the end of a fieldset
+     * (a new one will be opened when a the next header element occurs)
+     *
+     * @param       mixed      Element name(s) (as array or string)
+     * @param       string     (optional) Class name for the fieldset(s)
+     * @access      public
+     * @return      void
+     */
+    function addStopFieldsetElements($element, $class = '')
+    {
+        if (is_array($element)) {
+            $elements = array();
+            foreach ($element as $name) {
+                $elements[$name] = $class;
+            }
+            $this->_stopFieldsetElements = array_merge($this->_stopFieldsetElements,
+                                                       $elements);
+        } else {
+            $this->_stopFieldsetElements[$element] = $class;
+        }
+    } // end func addStopFieldsetElements
+
+    /**
+     * Handle element/group names that indicate the end of a group
+     *
+     * @param string     The name of the element or group
+     * @access private
+     * @return void
+     */
+    function _handleStopFieldsetElements($element)
+    {
+        // if the element/group name indicates the end of a fieldset, close
+        // the fieldset
+        if (   array_key_exists($element, $this->_stopFieldsetElements)
+            && $this->_fieldsetsOpen > 0
+           ) {
+            $this->_html .= $this->_closeFieldsetTemplate;
+            $this->_fieldsetsOpen--;
+        }
+        // if no fieldset was opened, we need to open a hidden one here to get
+        // XHTML validity
+        if ($this->_fieldsetsOpen === 0) {
+            $replace = '';
+            if (   array_key_exists($element, $this->_stopFieldsetElements)
+                && $this->_stopFieldsetElements[$element] != ''
+               ) {
+                $replace = ' ' . $this->_stopFieldsetElements[$element];
+            }
+            $this->_html .= str_replace('{class}', $replace,
+                                        $this->_openHiddenFieldsetTemplate);
+            $this->_fieldsetsOpen++;
+        }
+    } // end func _handleStopFieldsetElements
+
+    /**
+     * Sets element template
+     *
+     * @param   string    The HTML surrounding an element
+     * @param   mixed     (optional) Name(s) of the element to apply template
+     *                    for (either single element name as string or multiple
+     *                    element names as an array)
+     * @access  public
+     * @return  void
+     */
+    function setElementTemplate($html, $element = null)
+    {
+        if (is_null($element)) {
+            $this->_elementTemplate = $html;
+        } elseif (is_array($element)) {
+            foreach ($element as $name) {
+                $this->_templates[$name] = $html;
+            }
+        } else {
+            $this->_templates[$element] = $html;
+        }
+    } // end func setElementTemplate
+
+} // end class HTML_QuickForm_Renderer_Default
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule.php
new file mode 100644 (file)
index 0000000..9d95020
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Abstract base class for QuickForm validation rules 
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Abstract base class for QuickForm validation rules 
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       3.2
+ * @abstract
+ */
+class HTML_QuickForm_Rule
+{
+   /**
+    * Name of the rule to use in validate method
+    *
+    * This property is used in more global rules like Callback and Regex
+    * to determine which callback and which regex is to be used for validation
+    *
+    * @var  string
+    * @access   public
+    */
+    var $name;
+
+   /**
+    * Validates a value
+    * 
+    * @access public
+    * @abstract
+    */
+    function validate($value)
+    {
+        return true;
+    }
+
+   /**
+    * Sets the rule name
+    *
+    * @param  string    rule name
+    * @access public
+    */
+    function setName($ruleName)
+    {
+        $this->name = $ruleName;
+    }
+
+    /**
+     * Returns the javascript test (the test should return true if the value is INVALID)
+     *
+     * @param     mixed     Options for the rule
+     * @access    public
+     * @return    array     first element is code to setup validation, second is the check itself
+     * @abstract
+     */
+    function getValidationScript($options = null)
+    {
+        return array('', '');
+    }
+}
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Callback.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Callback.php
new file mode 100644 (file)
index 0000000..1557506
--- /dev/null
@@ -0,0 +1,124 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Validates values using callback functions or methods
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Abstract base class for QuickForm validation rules 
+ */
+require_once 'HTML/QuickForm/Rule.php';
+
+/**
+ * Validates values using callback functions or methods
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       3.2
+ */
+class HTML_QuickForm_Rule_Callback extends HTML_QuickForm_Rule
+{
+    /**
+     * Array of callbacks
+     *
+     * Array is in the format:
+     * $_data['rulename'] = array('functionname', 'classname');
+     * If the callback is not a method, then the class name is not set.
+     *
+     * @var     array
+     * @access  private
+     */
+    var $_data = array();
+
+   /**
+    * Whether to use BC mode for specific rules
+    * 
+    * Previous versions of QF passed element's name as a first parameter
+    * to validation functions, but not to validation methods. This behaviour
+    * is emulated if you are using 'function' as rule type when registering.
+    * 
+    * @var array
+    * @access private
+    */
+    var $_BCMode = array();
+
+    /**
+     * Validates a value using a callback
+     *
+     * @param     string    $value      Value to be checked
+     * @param     mixed     $options    Options for callback
+     * @access    public
+     * @return    boolean   true if value is valid
+     */
+    function validate($value, $options = null)
+    {
+        if (isset($this->_data[$this->name])) {
+            $callback = $this->_data[$this->name];
+            if (isset($callback[1])) {
+                return call_user_func(array($callback[1], $callback[0]), $value, $options);
+            } elseif ($this->_BCMode[$this->name]) {
+                return $callback[0]('', $value, $options);
+            } else {
+                return $callback[0]($value, $options);
+            }
+        } elseif (is_callable($options)) {
+            return call_user_func($options, $value);
+        } else {
+            return true;
+        }
+    } // end func validate
+
+    /**
+     * Adds new callbacks to the callbacks list
+     *
+     * @param     string    $name       Name of rule
+     * @param     string    $callback   Name of function or method
+     * @param     string    $class      Name of class containing the method
+     * @param     bool      $BCMode     Backwards compatibility mode 
+     * @access    public
+     */
+    function addData($name, $callback, $class = null, $BCMode = false)
+    {
+        if (!empty($class)) {
+            $this->_data[$name] = array($callback, $class);
+        } else {
+            $this->_data[$name] = array($callback);
+        }
+        $this->_BCMode[$name] = $BCMode;
+    } // end func addData
+
+
+    function getValidationScript($options = null)
+    {
+        if (isset($this->_data[$this->name])) {
+            $callback = $this->_data[$this->name][0];
+            $params   = ($this->_BCMode[$this->name]? "'', {jsVar}": '{jsVar}') .
+                        (isset($options)? ", '{$options}'": '');
+        } else {
+            $callback = is_array($options)? $options[1]: $options;
+            $params   = '{jsVar}';
+        }
+        return array('', "{jsVar} != '' && !{$callback}({$params})");
+    } // end func getValidationScript
+
+} // end class HTML_QuickForm_Rule_Callback
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Compare.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Compare.php
new file mode 100644 (file)
index 0000000..82d38c7
--- /dev/null
@@ -0,0 +1,105 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Rule to compare two form fields
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Abstract base class for QuickForm validation rules 
+ */
+require_once 'HTML/QuickForm/Rule.php';
+
+/**
+ * Rule to compare two form fields
+ * 
+ * The most common usage for this is to ensure that the password 
+ * confirmation field matches the password field
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       3.2
+ */
+class HTML_QuickForm_Rule_Compare extends HTML_QuickForm_Rule
+{
+   /**
+    * Possible operators to use
+    * @var array
+    * @access private
+    */
+    var $_operators = array(
+        'eq'  => '===',
+        'neq' => '!==',
+        'gt'  => '>',
+        'gte' => '>=',
+        'lt'  => '<',
+        'lte' => '<=',
+        '=='  => '===',
+        '!='  => '!=='
+    );
+
+
+   /**
+    * Returns the operator to use for comparing the values
+    * 
+    * @access private
+    * @param  string     operator name
+    * @return string     operator to use for validation
+    */
+    function _findOperator($name)
+    {
+        if (empty($name)) {
+            return '===';
+        } elseif (isset($this->_operators[$name])) {
+            return $this->_operators[$name];
+        } elseif (in_array($name, $this->_operators)) {
+            return $name;
+        } else {
+            return '===';
+        }
+    }
+
+
+    function validate($values, $operator = null)
+    {
+        $operator = $this->_findOperator($operator);
+        if ('===' != $operator && '!==' != $operator) {
+            $compareFn = create_function('$a, $b', 'return floatval($a) ' . $operator . ' floatval($b);');
+        } else {
+            $compareFn = create_function('$a, $b', 'return strval($a) ' . $operator . ' strval($b);');
+        }
+        
+        return $compareFn($values[0], $values[1]);
+    }
+
+
+    function getValidationScript($operator = null)
+    {
+        $operator = $this->_findOperator($operator);
+        if ('===' != $operator && '!==' != $operator) {
+            $check = "!(Number({jsVar}[0]) {$operator} Number({jsVar}[1]))";
+        } else {
+            $check = "!(String({jsVar}[0]) {$operator} String({jsVar}[1]))";
+        }
+        return array('', "'' != {jsVar}[0] && {$check}");
+    }
+}
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Email.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Email.php
new file mode 100644 (file)
index 0000000..d38acd5
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Email validation rule
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Abstract base class for QuickForm validation rules 
+ */
+require_once 'HTML/QuickForm/Rule.php';
+
+/**
+ * Email validation rule
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       3.2
+ */
+class HTML_QuickForm_Rule_Email extends HTML_QuickForm_Rule
+{
+    var $regex = '/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/';
+
+    /**
+     * Validates an email address
+     *
+     * @param     string    $email          Email address
+     * @param     boolean   $checkDomain    True if dns check should be performed
+     * @access    public
+     * @return    boolean   true if email is valid
+     */
+    function validate($email, $checkDomain = false)
+    {
+        // Fix for bug #10799: add 'D' modifier to regex
+        if (preg_match($this->regex . 'D', $email)) {
+            if ($checkDomain && function_exists('checkdnsrr')) {
+                $tokens = explode('@', $email);
+                if (checkdnsrr($tokens[1], 'MX') || checkdnsrr($tokens[1], 'A')) {
+                    return true;
+                }
+                return false;
+            }
+            return true;
+        }
+        return false;
+    } // end func validate
+
+
+    function getValidationScript($options = null)
+    {
+        return array("  var regex = " . $this->regex . ";\n", "{jsVar} != '' && !regex.test({jsVar})");
+    } // end func getValidationScript
+
+} // end class HTML_QuickForm_Rule_Email
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Range.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Range.php
new file mode 100644 (file)
index 0000000..14118f5
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Checks that the length of value is within range
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Abstract base class for QuickForm validation rules 
+ */
+require_once 'HTML/QuickForm/Rule.php';
+
+/**
+ * Checks that the length of value is within range
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       3.2
+ */
+class HTML_QuickForm_Rule_Range extends HTML_QuickForm_Rule
+{
+    /**
+     * Validates a value using a range comparison
+     *
+     * @param     string    $value      Value to be checked
+     * @param     mixed     $options    Int for length, array for range
+     * @access    public
+     * @return    boolean   true if value is valid
+     */
+    function validate($value, $options = null)
+    {
+        $length = strlen($value);
+        switch ($this->name) {
+            case 'minlength': return ($length >= $options);
+            case 'maxlength': return ($length <= $options);
+            default:          return ($length >= $options[0] && $length <= $options[1]);
+        }
+    } // end func validate
+
+
+    function getValidationScript($options = null)
+    {
+        switch ($this->name) {
+            case 'minlength': 
+                $test = '{jsVar}.length < '.$options;
+                break;
+            case 'maxlength': 
+                $test = '{jsVar}.length > '.$options;
+                break;
+            default: 
+                $test = '({jsVar}.length < '.$options[0].' || {jsVar}.length > '.$options[1].')';
+        }
+        return array('', "{jsVar} != '' && {$test}");
+    } // end func getValidationScript
+
+} // end class HTML_QuickForm_Rule_Range
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Regex.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Regex.php
new file mode 100644 (file)
index 0000000..2d3d702
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Validates values using regular expressions
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Abstract base class for QuickForm validation rules 
+ */
+require_once 'HTML/QuickForm/Rule.php';
+
+/**
+ * Validates values using regular expressions
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       3.2
+ */
+class HTML_QuickForm_Rule_Regex extends HTML_QuickForm_Rule
+{
+    /**
+     * Array of regular expressions
+     *
+     * Array is in the format:
+     * $_data['rulename'] = 'pattern';
+     *
+     * @var     array
+     * @access  private
+     */
+    var $_data = array(
+                    'lettersonly'   => '/^[a-zA-Z]+$/',
+                    'alphanumeric'  => '/^[a-zA-Z0-9]+$/',
+                    'numeric'       => '/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/',
+                    'nopunctuation' => '/^[^().\/\*\^\?#!@$%+=,\"\'><~\[\]{}]+$/',
+                    'nonzero'       => '/^-?[1-9][0-9]*/'
+                    );
+
+    /**
+     * Validates a value using a regular expression
+     *
+     * @param     string    $value      Value to be checked
+     * @param     string    $regex      Regular expression
+     * @access    public
+     * @return    boolean   true if value is valid
+     */
+    function validate($value, $regex = null)
+    {
+        // Fix for bug #10799: add 'D' modifier to regex
+        if (isset($this->_data[$this->name])) {
+            if (!preg_match($this->_data[$this->name] . 'D', $value)) {
+                return false;
+            }
+        } else {
+            if (!preg_match($regex . 'D', $value)) {
+                return false;
+            }
+        }
+        return true;
+    } // end func validate
+
+    /**
+     * Adds new regular expressions to the list
+     *
+     * @param     string    $name       Name of rule
+     * @param     string    $pattern    Regular expression pattern
+     * @access    public
+     */
+    function addData($name, $pattern)
+    {
+        $this->_data[$name] = $pattern;
+    } // end func addData
+
+
+    function getValidationScript($options = null)
+    {
+        $regex = isset($this->_data[$this->name]) ? $this->_data[$this->name] : $options;
+
+        // bug #12376, converting unicode escapes and stripping 'u' modifier
+        if ($pos = strpos($regex, 'u', strrpos($regex, '/'))) {
+            $regex = substr($regex, 0, $pos) . substr($regex, $pos + 1);
+            $regex = preg_replace('/(?<!\\\\)(?>\\\\\\\\)*\\\\x{([a-fA-F0-9]+)}/', '\\u$1', $regex);
+        }
+
+        return array("  var regex = " . $regex . ";\n", "{jsVar} != '' && !regex.test({jsVar})");
+    } // end func getValidationScript
+
+} // end class HTML_QuickForm_Rule_Regex
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Required.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/Rule/Required.php
new file mode 100644 (file)
index 0000000..26ff62f
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Required elements validation
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Abstract base class for QuickForm validation rules 
+ */
+require_once 'HTML/QuickForm/Rule.php';
+
+/**
+ * Required elements validation
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       3.2
+ */
+class HTML_QuickForm_Rule_Required extends HTML_QuickForm_Rule
+{
+    /**
+     * Checks if an element is empty
+     *
+     * @param     string    $value      Value to check
+     * @param     mixed     $options    Not used yet
+     * @access    public
+     * @return    boolean   true if value is not empty
+     */
+    function validate($value, $options = null)
+    {
+        if (is_array($value)) {
+            return (bool) $value;
+        } else if ((string)$value == '') {
+            return false;
+        }
+        return true;
+    } // end func validate
+
+
+    function getValidationScript($options = null)
+    {
+        return array('', "{jsVar} == ''");
+    } // end func getValidationScript
+
+} // end class HTML_QuickForm_Rule_Required
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/RuleRegistry.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/RuleRegistry.php
new file mode 100644 (file)
index 0000000..3d23716
--- /dev/null
@@ -0,0 +1,349 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Registers rule objects and uses them for validation
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Registers rule objects and uses them for validation
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       3.2
+ */
+class HTML_QuickForm_RuleRegistry
+{
+    /**
+     * Array containing references to used rules
+     * @var     array
+     * @access  private
+     */
+    var $_rules = array();
+
+
+    /**
+     * Returns a singleton of HTML_QuickForm_RuleRegistry
+     *
+     * Usually, only one RuleRegistry object is needed, this is the reason
+     * why it is recommended to use this method to get the validation object. 
+     *
+     * @access    public
+     * @static
+     * @return    HTML_QuickForm_RuleRegistry
+     */
+    function &singleton()
+    {
+        static $obj;
+        if (!isset($obj)) {
+            $obj = new HTML_QuickForm_RuleRegistry();
+        }
+        return $obj;
+    } // end func singleton
+
+    /**
+     * Registers a new validation rule
+     *
+     * In order to use a custom rule in your form, you need to register it
+     * first. For regular expressions, one can directly use the 'regex' type
+     * rule in addRule(), this is faster than registering the rule.
+     *
+     * Functions and methods can be registered. Use the 'function' type.
+     * When registering a method, specify the class name as second parameter.
+     *
+     * You can also register an HTML_QuickForm_Rule subclass with its own
+     * validate() method.
+     *
+     * @param     string    $ruleName   Name of validation rule
+     * @param     string    $type       Either: 'regex', 'function' or null
+     * @param     string    $data1      Name of function, regular expression or
+     *                                  HTML_QuickForm_Rule object class name
+     * @param     string    $data2      Object parent of above function or HTML_QuickForm_Rule file path
+     * @access    public
+     * @return    void
+     */
+    function registerRule($ruleName, $type, $data1, $data2 = null)
+    {
+        $type = strtolower($type);
+        if ($type == 'regex') {
+            // Regular expression
+            $rule =& $this->getRule('regex');
+            $rule->addData($ruleName, $data1);
+            $GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = $GLOBALS['_HTML_QuickForm_registered_rules']['regex'];
+
+        } elseif ($type == 'function' || $type == 'callback') {
+            // Callback function
+            $rule =& $this->getRule('callback');
+            $rule->addData($ruleName, $data1, $data2, 'function' == $type);
+            $GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = $GLOBALS['_HTML_QuickForm_registered_rules']['callback'];
+
+        } elseif (is_object($data1)) {
+            // An instance of HTML_QuickForm_Rule
+            $this->_rules[strtolower(get_class($data1))] = $data1;
+            $GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = array(strtolower(get_class($data1)), null);
+
+        } else {
+            // Rule class name
+            $GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = array(strtolower($data1), $data2);
+        }
+    } // end func registerRule
+
+    /**
+     * Returns a reference to the requested rule object
+     *
+     * @param     string   $ruleName        Name of the requested rule
+     * @access    public
+     * @return    HTML_QuickForm_Rule
+     */
+    function &getRule($ruleName)
+    {
+        list($class, $path) = $GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName];
+
+        if (!isset($this->_rules[$class])) {
+            if (!empty($path)) {
+                include_once($path);
+            }
+            $this->_rules[$class] = new $class();
+        }
+        $this->_rules[$class]->setName($ruleName);
+        return $this->_rules[$class];
+    } // end func getRule
+
+    /**
+     * Performs validation on the given values
+     *
+     * @param     string   $ruleName        Name of the rule to be used
+     * @param     mixed    $values          Can be a scalar or an array of values 
+     *                                      to be validated
+     * @param     mixed    $options         Options used by the rule
+     * @param     mixed    $multiple        Whether to validate an array of values altogether
+     * @access    public
+     * @return    mixed    true if no error found, int of valid values (when an array of values is given) or false if error
+     */
+    function validate($ruleName, $values, $options = null, $multiple = false)
+    {
+        $rule =& $this->getRule($ruleName);
+
+        if (is_array($values) && !$multiple) {
+            $result = 0;
+            foreach ($values as $value) {
+                if ($rule->validate($value, $options) === true) {
+                    $result++;
+                }
+            }
+            return ($result == 0) ? false : $result;
+        } else {
+            return $rule->validate($values, $options);
+        }
+    } // end func validate
+
+    /**
+     * Returns the validation test in javascript code
+     *
+     * @param     array|HTML_QuickForm_element  Element(s) the rule applies to
+     * @param     string                        Element name, in case $element is 
+     *                                          not an array
+     * @param     array                         Rule data
+     * @access    public
+     * @return    string    JavaScript for the rule
+     */
+    function getValidationScript(&$element, $elementName, $ruleData)
+    {
+        $reset =  (isset($ruleData['reset'])) ? $ruleData['reset'] : false;
+        $rule  =& $this->getRule($ruleData['type']);
+        if (!is_array($element)) {
+            list($jsValue, $jsReset) = $this->_getJsValue($element, $elementName, $reset, null);
+        } else {
+            $jsValue = "  value = new Array();\n";
+            $jsReset = '';
+            for ($i = 0; $i < count($element); $i++) {
+                list($tmp_value, $tmp_reset) = $this->_getJsValue($element[$i], $element[$i]->getName(), $reset, $i);
+                $jsValue .= "\n" . $tmp_value;
+                $jsReset .= $tmp_reset;
+            }
+        }
+        $jsField = isset($ruleData['group'])? $ruleData['group']: $elementName;
+        list ($jsPrefix, $jsCheck) = $rule->getValidationScript($ruleData['format']);
+        if (!isset($ruleData['howmany'])) {
+            $js = $jsValue . "\n" . $jsPrefix . 
+                  "  if (" . str_replace('{jsVar}', 'value', $jsCheck) . " && !errFlag['{$jsField}']) {\n" .
+                  "    errFlag['{$jsField}'] = true;\n" .
+                  "    _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" .
+                  $jsReset .
+                  "  }\n";
+        } else {
+            $js = $jsValue . "\n" . $jsPrefix . 
+                  "  var res = 0;\n" .
+                  "  for (var i = 0; i < value.length; i++) {\n" .
+                  "    if (!(" . str_replace('{jsVar}', 'value[i]', $jsCheck) . ")) {\n" .
+                  "      res++;\n" .
+                  "    }\n" .
+                  "  }\n" . 
+                  "  if (res < {$ruleData['howmany']} && !errFlag['{$jsField}']) {\n" . 
+                  "    errFlag['{$jsField}'] = true;\n" .
+                  "    _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" .
+                  $jsReset .
+                  "  }\n";
+        }
+        return $js;
+    } // end func getValidationScript
+
+
+   /**
+    * Returns JavaScript to get and to reset the element's value 
+    * 
+    * @access private
+    * @param  HTML_QuickForm_element    element being processed
+    * @param  string                    element's name
+    * @param  bool                      whether to generate JavaScript to reset 
+    *                                   the value
+    * @param  integer                   value's index in the array (only used for
+    *                                   multielement rules)
+    * @return array     first item is value javascript, second is reset
+    */
+    function _getJsValue(&$element, $elementName, $reset = false, $index = null)
+    {
+        $jsIndex = isset($index)? '[' . $index . ']': '';
+        $tmp_reset = $reset? "    var field = frm.elements['$elementName'];\n": '';
+        if (is_a($element, 'html_quickform_group')) {
+            $value = "  _qfGroups['{$elementName}'] = {";
+            $elements =& $element->getElements();
+            for ($i = 0, $count = count($elements); $i < $count; $i++) {
+                $append = ($elements[$i]->getType() == 'select' && $elements[$i]->getMultiple())? '[]': '';
+                $value .= "'" . $element->getElementName($i) . $append . "': true" .
+                          ($i < $count - 1? ', ': '');
+            }
+            $value .=
+                "};\n" .
+                "  value{$jsIndex} = new Array();\n" .
+                "  var valueIdx = 0;\n" .
+                "  for (var i = 0; i < frm.elements.length; i++) {\n" .
+                "    var _element = frm.elements[i];\n" .
+                "    if (_element.name in _qfGroups['{$elementName}']) {\n" . 
+                "      switch (_element.type) {\n" .
+                "        case 'checkbox':\n" .
+                "        case 'radio':\n" .
+                "          if (_element.checked) {\n" .
+                "            value{$jsIndex}[valueIdx++] = _element.value;\n" .
+                "          }\n" .
+                "          break;\n" .
+                "        case 'select-one':\n" .
+                "          if (-1 != _element.selectedIndex) {\n" .
+                "            value{$jsIndex}[valueIdx++] = _element.options[_element.selectedIndex].value;\n" .
+                "          }\n" .
+                "          break;\n" .
+                "        case 'select-multiple':\n" .
+                "          var tmpVal = new Array();\n" .
+                "          var tmpIdx = 0;\n" .
+                "          for (var j = 0; j < _element.options.length; j++) {\n" .
+                "            if (_element.options[j].selected) {\n" .
+                "              tmpVal[tmpIdx++] = _element.options[j].value;\n" .
+                "            }\n" .
+                "          }\n" .
+                "          if (tmpIdx > 0) {\n" .
+                "            value{$jsIndex}[valueIdx++] = tmpVal;\n" .
+                "          }\n" .
+                "          break;\n" .
+                "        default:\n" .
+                "          value{$jsIndex}[valueIdx++] = _element.value;\n" .
+                "      }\n" .
+                "    }\n" .
+                "  }\n";
+            if ($reset) {
+                $tmp_reset =
+                    "    for (var i = 0; i < frm.elements.length; i++) {\n" .
+                    "      var _element = frm.elements[i];\n" .
+                    "      if (_element.name in _qfGroups['{$elementName}']) {\n" . 
+                    "        switch (_element.type) {\n" .
+                    "          case 'checkbox':\n" .
+                    "          case 'radio':\n" .
+                    "            _element.checked = _element.defaultChecked;\n" .
+                    "            break;\n" .
+                    "          case 'select-one':\n" .
+                    "          case 'select-multiple':\n" .
+                    "            for (var j = 0; j < _element.options.length; j++) {\n" .
+                    "              _element.options[j].selected = _element.options[j].defaultSelected;\n" .
+                    "            }\n" .
+                    "            break;\n" .
+                    "          default:\n" .
+                    "            _element.value = _element.defaultValue;\n" .
+                    "        }\n" .
+                    "      }\n" .
+                    "    }\n";
+            }
+
+        } elseif ($element->getType() == 'select') {
+            if ($element->getMultiple()) {
+                $elementName .= '[]';
+                $value =
+                    "  value{$jsIndex} = new Array();\n" .
+                    "  var valueIdx = 0;\n" .
+                    "  for (var i = 0; i < frm.elements['{$elementName}'].options.length; i++) {\n" . 
+                    "    if (frm.elements['{$elementName}'].options[i].selected) {\n" .
+                    "      value{$jsIndex}[valueIdx++] = frm.elements['{$elementName}'].options[i].value;\n" .
+                    "    }\n" .
+                    "  }\n";
+            } else {
+                $value = "  value{$jsIndex} = frm.elements['{$elementName}'].selectedIndex == -1? '': frm.elements['{$elementName}'].options[frm.elements['{$elementName}'].selectedIndex].value;\n";
+            }
+            if ($reset) {
+                $tmp_reset .= 
+                    "    for (var i = 0; i < field.options.length; i++) {\n" .
+                    "      field.options[i].selected = field.options[i].defaultSelected;\n" .
+                    "    }\n";
+            }
+
+        } elseif ($element->getType() == 'checkbox') {
+            if (is_a($element, 'html_quickform_advcheckbox')) {
+                $value = "  value{$jsIndex} = frm.elements['$elementName'][1].checked? frm.elements['$elementName'][1].value: frm.elements['$elementName'][0].value;\n";
+                $tmp_reset .= $reset ? "    field[1].checked = field[1].defaultChecked;\n" : '';
+            } else {
+                $value = "  value{$jsIndex} = frm.elements['$elementName'].checked? '1': '';\n";
+                $tmp_reset .= $reset ? "    field.checked = field.defaultChecked;\n" : '';
+            }
+
+        } elseif ($element->getType() == 'radio') {
+            $value = "  value{$jsIndex} = '';\n" .
+                     // Fix for bug #5644
+                     "  var els = 'length' in frm.elements['$elementName']? frm.elements['$elementName']: [ frm.elements['$elementName'] ];\n" .
+                     "  for (var i = 0; i < els.length; i++) {\n" .
+                     "    if (els[i].checked) {\n" .
+                     "      value{$jsIndex} = els[i].value;\n" .
+                     "    }\n" .
+                     "  }";
+            if ($reset) {
+                $tmp_reset .= "    for (var i = 0; i < field.length; i++) {\n" .
+                              "      field[i].checked = field[i].defaultChecked;\n" .
+                              "    }";
+            }
+
+        } else {
+            $value = "  value{$jsIndex} = frm.elements['$elementName'].value;";
+            $tmp_reset .= ($reset) ? "    field.value = field.defaultValue;\n" : '';
+        }
+        return array($value, $tmp_reset);
+    }
+} // end class HTML_QuickForm_RuleRegistry
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/advcheckbox.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/advcheckbox.php
new file mode 100644 (file)
index 0000000..6d72be6
--- /dev/null
@@ -0,0 +1,286 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for an advanced checkbox type field
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Jason Rust <jrust@php.net>
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * HTML class for a checkbox type field
+ */
+require_once 'HTML/QuickForm/checkbox.php';
+
+/**
+ * HTML class for an advanced checkbox type field
+ *
+ * Basically this fixes a problem that HTML has had
+ * where checkboxes can only pass a single value (the
+ * value of the checkbox when checked).  A value for when
+ * the checkbox is not checked cannot be passed, and 
+ * furthermore the checkbox variable doesn't even exist if
+ * the checkbox was submitted unchecked.
+ *
+ * It works by prepending a hidden field with the same name and
+ * another "unchecked" value to the checbox. If the checkbox is
+ * checked, PHP overwrites the value of the hidden field with
+ * its value. 
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Jason Rust <jrust@php.net>
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       2.0
+ */
+class HTML_QuickForm_advcheckbox extends HTML_QuickForm_checkbox
+{
+    // {{{ properties
+
+    /**
+     * The values passed by the hidden elment
+     *
+     * @var array
+     * @access private
+     */
+    var $_values = null;
+
+    /**
+     * The default value
+     *
+     * @var boolean
+     * @access private
+     */
+    var $_currentValue = null;
+
+    // }}}
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * 
+     * @param     string    $elementName    (optional)Input field name attribute
+     * @param     string    $elementLabel   (optional)Input field label 
+     * @param     string    $text           (optional)Text to put after the checkbox
+     * @param     mixed     $attributes     (optional)Either a typical HTML attribute string 
+     *                                      or an associative array
+     * @param     mixed     $values         (optional)Values to pass if checked or not checked 
+     *
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_advcheckbox($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null)
+    {
+        $this->HTML_QuickForm_checkbox($elementName, $elementLabel, $text, $attributes);
+        $this->setValues($values);
+    } //end constructor
+    
+    // }}}
+    // {{{ getPrivateName()
+
+    /**
+     * Gets the private name for the element
+     *
+     * @param   string  $elementName The element name to make private
+     *
+     * @access public
+     * @return string
+     *
+     * @deprecated          Deprecated since 3.2.6, both generated elements have the same name
+     */
+    function getPrivateName($elementName)
+    {
+        return '__'.$elementName;
+    }
+
+    // }}}
+    // {{{ getOnclickJs()
+
+    /**
+     * Create the javascript for the onclick event which will
+     * set the value of the hidden field
+     *
+     * @param     string    $elementName    The element name
+     *
+     * @access public
+     * @return string
+     *
+     * @deprecated          Deprecated since 3.2.6, this element no longer uses any javascript
+     */
+    function getOnclickJs($elementName)
+    {
+        $onclickJs = 'if (this.checked) { this.form[\''.$elementName.'\'].value=\''.addcslashes($this->_values[1], '\'').'\'; }';
+        $onclickJs .= 'else { this.form[\''.$elementName.'\'].value=\''.addcslashes($this->_values[0], '\'').'\'; }';
+        return $onclickJs;
+    }
+
+    // }}}
+    // {{{ setValues()
+
+    /**
+     * Sets the values used by the hidden element
+     *
+     * @param   mixed   $values The values, either a string or an array
+     *
+     * @access public
+     * @return void
+     */
+    function setValues($values)
+    {
+        if (empty($values)) {
+            // give it default checkbox behavior
+            $this->_values = array('', 1);
+        } elseif (is_scalar($values)) {
+            // if it's string, then assume the value to 
+            // be passed is for when the element is checked
+            $this->_values = array('', $values);
+        } else {
+            $this->_values = $values;
+        }
+        $this->updateAttributes(array('value' => $this->_values[1]));
+        $this->setChecked($this->_currentValue == $this->_values[1]);
+    }
+
+    // }}}
+    // {{{ setValue()
+
+   /**
+    * Sets the element's value
+    * 
+    * @param    mixed   Element's value
+    * @access   public
+    */
+    function setValue($value)
+    {
+        $this->setChecked(isset($this->_values[1]) && $value == $this->_values[1]);
+        $this->_currentValue = $value;
+    }
+
+    // }}}
+    // {{{ getValue()
+
+   /**
+    * Returns the element's value
+    *
+    * @access   public
+    * @return   mixed
+    */
+    function getValue()
+    {
+        if (is_array($this->_values)) {
+            return $this->_values[$this->getChecked()? 1: 0];
+        } else {
+            return null;
+        }
+    }
+
+    // }}}
+    // {{{ toHtml()
+
+    /**
+     * Returns the checkbox element in HTML
+     * and the additional hidden element in HTML
+     * 
+     * @access    public
+     * @return    string
+     */
+    function toHtml()
+    {
+        if ($this->_flagFrozen) {
+            return parent::toHtml();
+        } else {
+            return '<input' . $this->_getAttrString(array(
+                        'type'  => 'hidden', 
+                        'name'  => $this->getName(), 
+                        'value' => $this->_values[0]
+                   )) . ' />' . parent::toHtml();
+            
+        }
+    } //end func toHtml
+    
+    // }}}
+    // {{{ getFrozenHtml()
+
+   /**
+    * Unlike checkbox, this has to append a hidden input in both
+    * checked and non-checked states
+    */
+    function getFrozenHtml()
+    {
+        return ($this->getChecked()? '<tt>[x]</tt>': '<tt>[ ]</tt>') .
+               $this->_getPersistantData();
+    }
+
+    // }}}
+    // {{{ onQuickFormEvent()
+
+    /**
+     * Called by HTML_QuickForm whenever form event is made on this element
+     *
+     * @param     string    $event  Name of event
+     * @param     mixed     $arg    event arguments
+     * @param     object    &$caller calling object
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function onQuickFormEvent($event, $arg, &$caller)
+    {
+        switch ($event) {
+            case 'updateValue':
+                // constant values override both default and submitted ones
+                // default values are overriden by submitted
+                $value = $this->_findValue($caller->_constantValues);
+                if (null === $value) {
+                    $value = $this->_findValue($caller->_submitValues);
+                    if (null === $value) {
+                        $value = $this->_findValue($caller->_defaultValues);
+                    }
+                }
+                if (null !== $value) {
+                    $this->setValue($value);
+                }
+                break;
+            default:
+                parent::onQuickFormEvent($event, $arg, $caller);
+        }
+        return true;
+    } // end func onQuickFormLoad
+
+    // }}}
+    // {{{ exportValue()
+
+   /**
+    * This element has a value even if it is not checked, thus we override
+    * checkbox's behaviour here
+    */
+    function exportValue(&$submitValues, $assoc = false)
+    {
+        $value = $this->_findValue($submitValues);
+        if (null === $value) {
+            $value = $this->getValue();
+        } elseif (is_array($this->_values) && ($value != $this->_values[0]) && ($value != $this->_values[1])) {
+            $value = null;
+        }
+        return $this->_prepareValue($value, $assoc);
+    }
+    // }}}
+} //end class HTML_QuickForm_advcheckbox
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/autocomplete.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/autocomplete.php
new file mode 100644 (file)
index 0000000..bb6fe31
--- /dev/null
@@ -0,0 +1,258 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for an autocomplete element
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Matteo Di Giovinazzo <matteodg@infinito.it>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * HTML class for a text field
+ */
+require_once 'HTML/QuickForm/text.php';
+
+/**
+ * HTML class for an autocomplete element
+ *
+ * Creates an HTML input text element that
+ * at every keypressed javascript event checks in an array of options
+ * if there's a match and autocompletes the text in case of match.
+ *
+ * For the JavaScript code thanks to Martin Honnen and Nicholas C. Zakas
+ * See {@link http://www.faqts.com/knowledge_base/view.phtml/aid/13562} and
+ * {@link http://www.sitepoint.com/article/1220}
+ *
+ * Example:
+ * <code>
+ * $autocomplete =& $form->addElement('autocomplete', 'fruit', 'Favourite fruit:');
+ * $options = array("Apple", "Orange", "Pear", "Strawberry");
+ * $autocomplete->setOptions($options);
+ * </code>
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Matteo Di Giovinazzo <matteodg@infinito.it>
+ * @version     Release: 3.2.16
+ * @since       3.2
+ */
+class HTML_QuickForm_autocomplete extends HTML_QuickForm_text
+{
+    // {{{ properties
+
+    /**
+     * Options for the autocomplete input text element
+     *
+     * @var       array
+     * @access    private
+     */
+    var $_options = array();
+
+    /**
+     * "One-time" javascript (containing functions), see bug #4611
+     *
+     * @var     string
+     * @access  private
+     */
+    var $_js = '';
+
+    // }}}
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     *
+     * @param     string    $elementName    (optional)Input field name attribute
+     * @param     string    $elementLabel   (optional)Input field label in form
+     * @param     array     $options        (optional)Autocomplete options
+     * @param     mixed     $attributes     (optional)Either a typical HTML attribute string
+     *                                      or an associative array. Date format is passed along the attributes.
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_autocomplete($elementName = null, $elementLabel = null, $options = null, $attributes = null)
+    {
+        $this->HTML_QuickForm_text($elementName, $elementLabel, $attributes);
+        $this->_persistantFreeze = true;
+        $this->_type = 'autocomplete';
+        if (isset($options)) {
+            $this->setOptions($options);
+        }
+    } //end constructor
+
+    // }}}
+    // {{{ setOptions()
+
+    /**
+     * Sets the options for the autocomplete input text element
+     *
+     * @param     array    $options    Array of options for the autocomplete input text element
+     * @access    public
+     * @return    void
+     */
+    function setOptions($options)
+    {
+        $this->_options = array_values($options);
+    } // end func setOptions
+
+    // }}}
+    // {{{ toHtml()
+
+    /**
+     * Returns Html for the autocomplete input text element
+     *
+     * @access      public
+     * @return      string
+     */
+    function toHtml()
+    {
+        // prevent problems with grouped elements
+        $arrayName = str_replace(array('[', ']'), array('__', ''), $this->getName()) . '_values';
+
+        $this->updateAttributes(array(
+            'onkeypress' => 'return window.autocomplete(this, event, ' . $arrayName . ');'
+        ));
+        if ($this->_flagFrozen) {
+            $js = '';
+        } else {
+            $js = "<script type=\"text/javascript\">\n//<![CDATA[\n";
+            if (!defined('HTML_QUICKFORM_AUTOCOMPLETE_EXISTS')) {
+                $this->_js .= <<<EOS
+
+/* begin javascript for autocomplete */
+function setSelectionRange(input, selectionStart, selectionEnd) {
+    if (input.setSelectionRange) {
+        input.setSelectionRange(selectionStart, selectionEnd);
+    }
+    else if (input.createTextRange) {
+        var range = input.createTextRange();
+        range.collapse(true);
+        range.moveEnd("character", selectionEnd);
+        range.moveStart("character", selectionStart);
+        range.select();
+    }
+    input.focus();
+}
+
+function setCaretToPosition(input, position) {
+    setSelectionRange(input, position, position);
+}
+
+function replaceSelection (input, replaceString) {
+       var len = replaceString.length;
+    if (input.setSelectionRange) {
+        var selectionStart = input.selectionStart;
+        var selectionEnd = input.selectionEnd;
+
+        input.value = input.value.substring(0, selectionStart) + replaceString + input.value.substring(selectionEnd);
+               input.selectionStart  = selectionStart + len;
+               input.selectionEnd  = selectionStart + len;
+    }
+    else if (document.selection) {
+        var range = document.selection.createRange();
+               var saved_range = range.duplicate();
+
+        if (range.parentElement() == input) {
+            range.text = replaceString;
+                       range.moveEnd("character", saved_range.selectionStart + len);
+                       range.moveStart("character", saved_range.selectionStart + len);
+                       range.select();
+        }
+    }
+    input.focus();
+}
+
+
+function autocompleteMatch (text, values) {
+    for (var i = 0; i < values.length; i++) {
+        if (values[i].toUpperCase().indexOf(text.toUpperCase()) == 0) {
+            return values[i];
+        }
+    }
+
+    return null;
+}
+
+function autocomplete(textbox, event, values) {
+    if (textbox.setSelectionRange || textbox.createTextRange) {
+        switch (event.keyCode) {
+            case 38:    // up arrow
+            case 40:    // down arrow
+            case 37:    // left arrow
+            case 39:    // right arrow
+            case 33:    // page up
+            case 34:    // page down
+            case 36:    // home
+            case 35:    // end
+            case 13:    // enter
+            case 9:     // tab
+            case 27:    // esc
+            case 16:    // shift
+            case 17:    // ctrl
+            case 18:    // alt
+            case 20:    // caps lock
+            case 8:     // backspace
+            case 46:    // delete
+                return true;
+                break;
+
+            default:
+                var c = String.fromCharCode(
+                    (event.charCode == undefined) ? event.keyCode : event.charCode
+                );
+                replaceSelection(textbox, c);
+                sMatch = autocompleteMatch(textbox.value, values);
+                var len = textbox.value.length;
+
+                if (sMatch != null) {
+                    textbox.value = sMatch;
+                    setSelectionRange(textbox, len, textbox.value.length);
+                }
+                return false;
+        }
+    }
+    else {
+        return true;
+    }
+}
+/* end javascript for autocomplete */
+
+EOS;
+                define('HTML_QUICKFORM_AUTOCOMPLETE_EXISTS', true);
+            }
+            $jsEscape = array(
+                "\r"    => '\r',
+                "\n"    => '\n',
+                "\t"    => '\t',
+                "'"     => "\\'",
+                '"'     => '\"',
+                '\\'    => '\\\\'
+            );
+
+            $js .= $this->_js;
+            $js .= 'var ' . $arrayName . " = new Array();\n";
+            for ($i = 0; $i < count($this->_options); $i++) {
+                $js .= $arrayName . '[' . $i . "] = '" . strtr($this->_options[$i], $jsEscape) . "';\n";
+            }
+            $js .= "//]]>\n</script>";
+        }
+        return $js . parent::toHtml();
+    }// end func toHtml
+
+    // }}}
+} // end class HTML_QuickForm_autocomplete
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/button.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/button.php
new file mode 100644 (file)
index 0000000..e658cd4
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for an <input type="button" /> elements
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for <input /> form elements
+ */
+require_once 'HTML/QuickForm/input.php';
+
+/**
+ * HTML class for an <input type="button" /> elements
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_button extends HTML_QuickForm_input
+{
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * 
+     * @param     string    $elementName    (optional)Input field name attribute
+     * @param     string    $value          (optional)Input field value
+     * @param     mixed     $attributes     (optional)Either a typical HTML attribute string 
+     *                                      or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_button($elementName=null, $value=null, $attributes=null)
+    {
+        HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes);
+        $this->_persistantFreeze = false;
+        $this->setValue($value);
+        $this->setType('button');
+    } //end constructor
+    
+    // }}}
+    // {{{ freeze()
+
+    /**
+     * Freeze the element so that only its value is returned
+     * 
+     * @access    public
+     * @return    void
+     */
+    function freeze()
+    {
+        return false;
+    } //end func freeze
+
+    // }}}
+} //end class HTML_QuickForm_button
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/checkbox.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/checkbox.php
new file mode 100644 (file)
index 0000000..0bebe08
--- /dev/null
@@ -0,0 +1,277 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for a checkbox type field
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for <input /> form elements
+ */
+require_once 'HTML/QuickForm/input.php';
+
+/**
+ * HTML class for a checkbox type field
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_checkbox extends HTML_QuickForm_input
+{
+    // {{{ properties
+
+    /**
+     * Checkbox display text
+     * @var       string
+     * @since     1.1
+     * @access    private
+     */
+    var $_text = '';
+
+    // }}}
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * 
+     * @param     string    $elementName    (optional)Input field name attribute
+     * @param     string    $elementLabel   (optional)Input field value
+     * @param     string    $text           (optional)Checkbox display text
+     * @param     mixed     $attributes     (optional)Either a typical HTML attribute string 
+     *                                      or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_checkbox($elementName=null, $elementLabel=null, $text='', $attributes=null)
+    {
+        HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
+        $this->_persistantFreeze = true;
+        $this->_text = $text;
+        $this->setType('checkbox');
+        $this->updateAttributes(array('value'=>1));
+        $this->_generateId();
+    } //end constructor
+    
+    // }}}
+    // {{{ setChecked()
+
+    /**
+     * Sets whether a checkbox is checked
+     * 
+     * @param     bool    $checked  Whether the field is checked or not
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setChecked($checked)
+    {
+        if (!$checked) {
+            $this->removeAttribute('checked');
+        } else {
+            $this->updateAttributes(array('checked'=>'checked'));
+        }
+    } //end func setChecked
+
+    // }}}
+    // {{{ getChecked()
+
+    /**
+     * Returns whether a checkbox is checked
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    bool
+     */
+    function getChecked()
+    {
+        return (bool)$this->getAttribute('checked');
+    } //end func getChecked
+    
+    // }}}
+    // {{{ toHtml()
+
+    /**
+     * Returns the checkbox element in HTML
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function toHtml()
+    {
+        if (0 == strlen($this->_text)) {
+            $label = '';
+        } elseif ($this->_flagFrozen) {
+            $label = $this->_text;
+        } else {
+            $label = '<label for="' . $this->getAttribute('id') . '">' . $this->_text . '</label>';
+        }
+        return HTML_QuickForm_input::toHtml() . $label;
+    } //end func toHtml
+    
+    // }}}
+    // {{{ getFrozenHtml()
+
+    /**
+     * Returns the value of field without HTML tags
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getFrozenHtml()
+    {
+        if ($this->getChecked()) {
+            return '<tt>[x]</tt>' .
+                   $this->_getPersistantData();
+        } else {
+            return '<tt>[ ]</tt>';
+        }
+    } //end func getFrozenHtml
+
+    // }}}
+    // {{{ setText()
+
+    /**
+     * Sets the checkbox text
+     * 
+     * @param     string    $text  
+     * @since     1.1
+     * @access    public
+     * @return    void
+     */
+    function setText($text)
+    {
+        $this->_text = $text;
+    } //end func setText
+
+    // }}}
+    // {{{ getText()
+
+    /**
+     * Returns the checkbox text 
+     * 
+     * @since     1.1
+     * @access    public
+     * @return    string
+     */
+    function getText()
+    {
+        return $this->_text;
+    } //end func getText
+
+    // }}}
+    // {{{ setValue()
+
+    /**
+     * Sets the value of the form element
+     *
+     * @param     string    $value      Default value of the form element
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setValue($value)
+    {
+        return $this->setChecked($value);
+    } // end func setValue
+
+    // }}}
+    // {{{ getValue()
+
+    /**
+     * Returns the value of the form element
+     *
+     * @since     1.0
+     * @access    public
+     * @return    bool
+     */
+    function getValue()
+    {
+        return $this->getChecked();
+    } // end func getValue
+
+    // }}}
+    // {{{ onQuickFormEvent()
+
+    /**
+     * Called by HTML_QuickForm whenever form event is made on this element
+     *
+     * @param     string    $event  Name of event
+     * @param     mixed     $arg    event arguments
+     * @param     object    &$caller calling object
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function onQuickFormEvent($event, $arg, &$caller)
+    {
+        switch ($event) {
+            case 'updateValue':
+                // constant values override both default and submitted ones
+                // default values are overriden by submitted
+                $value = $this->_findValue($caller->_constantValues);
+                if (null === $value) {
+                    // if no boxes were checked, then there is no value in the array
+                    // yet we don't want to display default value in this case
+                    if ($caller->isSubmitted()) {
+                        $value = $this->_findValue($caller->_submitValues);
+                    } else {
+                        $value = $this->_findValue($caller->_defaultValues);
+                    }
+                }
+                if (null !== $value || $caller->isSubmitted()) {
+                    $this->setChecked($value);
+                }
+                break;
+            case 'setGroupValue':
+                $this->setChecked($arg);
+                break;
+            default:
+                parent::onQuickFormEvent($event, $arg, $caller);
+        }
+        return true;
+    } // end func onQuickFormEvent
+
+    // }}}
+    // {{{ exportValue()
+
+   /**
+    * Return true if the checkbox is checked, null if it is not checked (getValue() returns false)
+    */
+    function exportValue(&$submitValues, $assoc = false)
+    {
+        $value = $this->_findValue($submitValues);
+        if (null === $value) {
+            $value = $this->getChecked()? true: null;
+        }
+        return $this->_prepareValue($value, $assoc);
+    }
+    
+    // }}}
+} //end class HTML_QuickForm_checkbox
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/date.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/date.php
new file mode 100644 (file)
index 0000000..c14cca8
--- /dev/null
@@ -0,0 +1,544 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Class for a group of elements used to input dates (and times).
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Class for a group of form elements
+ */
+require_once 'HTML/QuickForm/group.php';
+/**
+ * Class for <select></select> elements
+ */
+require_once 'HTML/QuickForm/select.php';
+
+/**
+ * Class for a group of elements used to input dates (and times).
+ *
+ * Inspired by original 'date' element but reimplemented as a subclass
+ * of HTML_QuickForm_group
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       3.1
+ */
+class HTML_QuickForm_date extends HTML_QuickForm_group
+{
+    // {{{ properties
+
+   /**
+    * Various options to control the element's display.
+    *
+    * @access   private
+    * @var      array
+    */
+    var $_options = array(
+        'language'         => 'en',
+        'format'           => 'dMY',
+        'minYear'          => 2001,
+        'maxYear'          => null, // set in the constructor
+        'addEmptyOption'   => false,
+        'emptyOptionValue' => '',
+        'emptyOptionText'  => '&nbsp;',
+        'optionIncrement'  => array('i' => 1, 's' => 1)
+    );
+
+   /**
+    * These complement separators, they are appended to the resultant HTML
+    * @access   private
+    * @var      array
+    */
+    var $_wrap = array('', '');
+
+   /**
+    * Options in different languages
+    *
+    * Note to potential translators: to avoid encoding problems please send
+    * your translations with "weird" letters encoded as HTML Unicode entities
+    *
+    * @access   private
+    * @var      array
+    */
+    var $_locale = array(
+        'en'    => array (
+            'weekdays_short'=> array ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'),
+            'weekdays_long' => array ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'),
+            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
+            'months_long'   => array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
+        ),
+        'de'    => array (
+            'weekdays_short'=> array ('So', 'Mon', 'Di', 'Mi', 'Do', 'Fr', 'Sa'),
+            'weekdays_long' => array ('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'),
+            'months_short'  => array ('Jan', 'Feb', 'M&#xe4;rz', 'April', 'Mai', 'Juni', 'Juli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dez'),
+            'months_long'   => array ('Januar', 'Februar', 'M&#xe4;rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember')
+        ),
+        'fr'    => array (
+            'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'),
+            'weekdays_long' => array ('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'),
+            'months_short'  => array ('Jan', 'F&#xe9;v', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Ao&#xfb;t', 'Sep', 'Oct', 'Nov', 'D&#xe9;c'),
+            'months_long'   => array ('Janvier', 'F&#xe9;vrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Ao&#xfb;t', 'Septembre', 'Octobre', 'Novembre', 'D&#xe9;cembre')
+        ),
+        'hu'    => array (
+            'weekdays_short'=> array ('V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'),
+            'weekdays_long' => array ('vas&#xe1;rnap', 'h&#xe9;tf&#x151;', 'kedd', 'szerda', 'cs&#xfc;t&#xf6;rt&#xf6;k', 'p&#xe9;ntek', 'szombat'),
+            'months_short'  => array ('jan', 'feb', 'm&#xe1;rc', '&#xe1;pr', 'm&#xe1;j', 'j&#xfa;n', 'j&#xfa;l', 'aug', 'szept', 'okt', 'nov', 'dec'),
+            'months_long'   => array ('janu&#xe1;r', 'febru&#xe1;r', 'm&#xe1;rcius', '&#xe1;prilis', 'm&#xe1;jus', 'j&#xfa;nius', 'j&#xfa;lius', 'augusztus', 'szeptember', 'okt&#xf3;ber', 'november', 'december')
+        ),
+        'pl'    => array (
+            'weekdays_short'=> array ('Nie', 'Pn', 'Wt', '&#x15a;r', 'Czw', 'Pt', 'Sob'),
+            'weekdays_long' => array ('Niedziela', 'Poniedzia&#x142;ek', 'Wtorek', '&#x15a;roda', 'Czwartek', 'Pi&#x105;tek', 'Sobota'),
+            'months_short'  => array ('Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Pa&#x17a;', 'Lis', 'Gru'),
+            'months_long'   => array ('Stycze&#x144;', 'Luty', 'Marzec', 'Kwiecie&#x144;', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpie&#x144;', 'Wrzesie&#x144;', 'Pa&#x17a;dziernik', 'Listopad', 'Grudzie&#x144;')
+        ),
+        'sl'    => array (
+            'weekdays_short'=> array ('Ned', 'Pon', 'Tor', 'Sre', 'Cet', 'Pet', 'Sob'),
+            'weekdays_long' => array ('Nedelja', 'Ponedeljek', 'Torek', 'Sreda', 'Cetrtek', 'Petek', 'Sobota'),
+            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Avg', 'Sep', 'Okt', 'Nov', 'Dec'),
+            'months_long'   => array ('Januar', 'Februar', 'Marec', 'April', 'Maj', 'Junij', 'Julij', 'Avgust', 'September', 'Oktober', 'November', 'December')
+        ),
+        'ru'    => array (
+            'weekdays_short'=> array ('&#x412;&#x441;', '&#x41f;&#x43d;', '&#x412;&#x442;', '&#x421;&#x440;', '&#x427;&#x442;', '&#x41f;&#x442;', '&#x421;&#x431;'),
+            'weekdays_long' => array ('&#x412;&#x43e;&#x441;&#x43a;&#x440;&#x435;&#x441;&#x435;&#x43d;&#x44c;&#x435;', '&#x41f;&#x43e;&#x43d;&#x435;&#x434;&#x435;&#x43b;&#x44c;&#x43d;&#x438;&#x43a;', '&#x412;&#x442;&#x43e;&#x440;&#x43d;&#x438;&#x43a;', '&#x421;&#x440;&#x435;&#x434;&#x430;', '&#x427;&#x435;&#x442;&#x432;&#x435;&#x440;&#x433;', '&#x41f;&#x44f;&#x442;&#x43d;&#x438;&#x446;&#x430;', '&#x421;&#x443;&#x431;&#x431;&#x43e;&#x442;&#x430;'),
+            'months_short'  => array ('&#x42f;&#x43d;&#x432;', '&#x424;&#x435;&#x432;', '&#x41c;&#x430;&#x440;', '&#x410;&#x43f;&#x440;', '&#x41c;&#x430;&#x439;', '&#x418;&#x44e;&#x43d;', '&#x418;&#x44e;&#x43b;', '&#x410;&#x432;&#x433;', '&#x421;&#x435;&#x43d;', '&#x41e;&#x43a;&#x442;', '&#x41d;&#x43e;&#x44f;', '&#x414;&#x435;&#x43a;'),
+            'months_long'   => array ('&#x42f;&#x43d;&#x432;&#x430;&#x440;&#x44c;', '&#x424;&#x435;&#x432;&#x440;&#x430;&#x43b;&#x44c;', '&#x41c;&#x430;&#x440;&#x442;', '&#x410;&#x43f;&#x440;&#x435;&#x43b;&#x44c;', '&#x41c;&#x430;&#x439;', '&#x418;&#x44e;&#x43d;&#x44c;', '&#x418;&#x44e;&#x43b;&#x44c;', '&#x410;&#x432;&#x433;&#x443;&#x441;&#x442;', '&#x421;&#x435;&#x43d;&#x442;&#x44f;&#x431;&#x440;&#x44c;', '&#x41e;&#x43a;&#x442;&#x44f;&#x431;&#x440;&#x44c;', '&#x41d;&#x43e;&#x44f;&#x431;&#x440;&#x44c;', '&#x414;&#x435;&#x43a;&#x430;&#x431;&#x440;&#x44c;')
+        ),
+        'es'    => array (
+            'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mi&#xe9;', 'Jue', 'Vie', 'S&#xe1;b'),
+            'weekdays_long' => array ('Domingo', 'Lunes', 'Martes', 'Mi&#xe9;rcoles', 'Jueves', 'Viernes', 'S&#xe1;bado'),
+            'months_short'  => array ('Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'),
+            'months_long'   => array ('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')
+        ),
+        'da'    => array (
+            'weekdays_short'=> array ('S&#xf8;n', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'L&#xf8;r'),
+            'weekdays_long' => array ('S&#xf8;ndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&#xf8;rdag'),
+            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
+            'months_long'   => array ('Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December')
+        ),
+        'is'    => array (
+            'weekdays_short'=> array ('Sun', 'M&#xe1;n', '&#xde;ri', 'Mi&#xf0;', 'Fim', 'F&#xf6;s', 'Lau'),
+            'weekdays_long' => array ('Sunnudagur', 'M&#xe1;nudagur', '&#xde;ri&#xf0;judagur', 'Mi&#xf0;vikudagur', 'Fimmtudagur', 'F&#xf6;studagur', 'Laugardagur'),
+            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Ma&#xed;', 'J&#xfa;n', 'J&#xfa;l', '&#xc1;g&#xfa;', 'Sep', 'Okt', 'N&#xf3;v', 'Des'),
+            'months_long'   => array ('Jan&#xfa;ar', 'Febr&#xfa;ar', 'Mars', 'Apr&#xed;l', 'Ma&#xed;', 'J&#xfa;n&#xed;', 'J&#xfa;l&#xed;', '&#xc1;g&#xfa;st', 'September', 'Okt&#xf3;ber', 'N&#xf3;vember', 'Desember')
+        ),
+        'it'    => array (
+            'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'),
+            'weekdays_long' => array ('Domenica', 'Luned&#xec;', 'Marted&#xec;', 'Mercoled&#xec;', 'Gioved&#xec;', 'Venerd&#xec;', 'Sabato'),
+            'months_short'  => array ('Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'),
+            'months_long'   => array ('Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre')
+        ),
+        'sk'    => array (
+            'weekdays_short'=> array ('Ned', 'Pon', 'Uto', 'Str', '&#x8a;tv', 'Pia', 'Sob'),
+            'weekdays_long' => array ('Nede&#x17e;a', 'Pondelok', 'Utorok', 'Streda', '&#x8a;tvrtok', 'Piatok', 'Sobota'),
+            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'M&#xe1;j', 'J&#xfa;n', 'J&#xfa;l', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
+            'months_long'   => array ('Janu&#xe1;r', 'Febru&#xe1;r', 'Marec', 'Apr&#xed;l', 'M&#xe1;j', 'J&#xfa;n', 'J&#xfa;l', 'August', 'September', 'Okt&#xf3;ber', 'November', 'December')
+        ),
+        'cs'    => array (
+            'weekdays_short'=> array ('Ne', 'Po', '&#xda;t', 'St', '&#x10c;t', 'P&#xe1;', 'So'),
+            'weekdays_long' => array ('Ned&#x11b;le', 'Pond&#x11b;l&#xed;', '&#xda;ter&#xfd;', 'St&#x159;eda', '&#x10c;tvrtek', 'P&#xe1;tek', 'Sobota'),
+            'months_short'  => array ('Led', '&#xda;no', 'B&#x159;e', 'Dub', 'Kv&#x11b;', '&#x10c;en', '&#x10c;ec', 'Srp', 'Z&#xe1;&#x159;', '&#x158;&#xed;j', 'Lis', 'Pro'),
+            'months_long'   => array ('Leden', '&#xda;nor', 'B&#x159;ezen', 'Duben', 'Kv&#x11b;ten', '&#x10c;erven', '&#x10c;ervenec', 'Srpen', 'Z&#xe1;&#x159;&#xed;', '&#x158;&#xed;jen', 'Listopad', 'Prosinec')
+        ),
+        'hy'    => array (
+            'weekdays_short'=> array ('&#x53f;&#x580;&#x56f;', '&#x535;&#x580;&#x56f;', '&#x535;&#x580;&#x584;', '&#x549;&#x580;&#x584;', '&#x540;&#x576;&#x563;', '&#x548;&#x582;&#x580;', '&#x547;&#x562;&#x569;'),
+            'weekdays_long' => array ('&#x53f;&#x56b;&#x580;&#x561;&#x56f;&#x56b;', '&#x535;&#x580;&#x56f;&#x578;&#x582;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x535;&#x580;&#x565;&#x584;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x549;&#x578;&#x580;&#x565;&#x584;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x540;&#x56b;&#x576;&#x563;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x548;&#x582;&#x580;&#x562;&#x561;&#x569;', '&#x547;&#x561;&#x562;&#x561;&#x569;'),
+            'months_short'  => array ('&#x540;&#x576;&#x57e;', '&#x553;&#x57f;&#x580;', '&#x544;&#x580;&#x57f;', '&#x531;&#x57a;&#x580;', '&#x544;&#x575;&#x57d;', '&#x540;&#x576;&#x57d;', '&#x540;&#x56c;&#x57d;', '&#x555;&#x563;&#x57d;', '&#x54d;&#x57a;&#x57f;', '&#x540;&#x56f;&#x57f;', '&#x546;&#x575;&#x574;', '&#x534;&#x56f;&#x57f;'),
+            'months_long'   => array ('&#x540;&#x578;&#x582;&#x576;&#x57e;&#x561;&#x580;', '&#x553;&#x565;&#x57f;&#x580;&#x57e;&#x561;&#x580;', '&#x544;&#x561;&#x580;&#x57f;', '&#x531;&#x57a;&#x580;&#x56b;&#x56c;', '&#x544;&#x561;&#x575;&#x56b;&#x57d;', '&#x540;&#x578;&#x582;&#x576;&#x56b;&#x57d;', '&#x540;&#x578;&#x582;&#x56c;&#x56b;&#x57d;', '&#x555;&#x563;&#x578;&#x57d;&#x57f;&#x578;&#x57d;', '&#x54d;&#x565;&#x57a;&#x57f;&#x565;&#x574;&#x562;&#x565;&#x580;', '&#x540;&#x578;&#x56f;&#x57f;&#x565;&#x574;&#x562;&#x565;&#x580;', '&#x546;&#x578;&#x575;&#x565;&#x574;&#x562;&#x565;&#x580;', '&#x534;&#x565;&#x56f;&#x57f;&#x565;&#x574;&#x562;&#x565;&#x580;')
+        ),
+        'nl'    => array (
+            'weekdays_short'=> array ('Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'),
+            'weekdays_long' => array ('Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'),
+            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
+            'months_long'   => array ('Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December')
+        ),
+        'et'    => array (
+            'weekdays_short'=> array ('P', 'E', 'T', 'K', 'N', 'R', 'L'),
+            'weekdays_long' => array ('P&#xfc;hap&#xe4;ev', 'Esmasp&#xe4;ev', 'Teisip&#xe4;ev', 'Kolmap&#xe4;ev', 'Neljap&#xe4;ev', 'Reede', 'Laup&#xe4;ev'),
+            'months_short'  => array ('Jaan', 'Veebr', 'M&#xe4;rts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dets'),
+            'months_long'   => array ('Jaanuar', 'Veebruar', 'M&#xe4;rts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'August', 'September', 'Oktoober', 'November', 'Detsember')
+        ),
+        'tr'    => array (
+            'weekdays_short'=> array ('Paz', 'Pzt', 'Sal', '&#xc7;ar', 'Per', 'Cum', 'Cts'),
+            'weekdays_long' => array ('Pazar', 'Pazartesi', 'Sal&#x131;', '&#xc7;ar&#x15f;amba', 'Per&#x15f;embe', 'Cuma', 'Cumartesi'),
+            'months_short'  => array ('Ock', '&#x15e;bt', 'Mrt', 'Nsn', 'Mys', 'Hzrn', 'Tmmz', 'A&#x11f;st', 'Eyl', 'Ekm', 'Ksm', 'Arlk'),
+            'months_long'   => array ('Ocak', '&#x15e;ubat', 'Mart', 'Nisan', 'May&#x131;s', 'Haziran', 'Temmuz', 'A&#x11f;ustos', 'Eyl&#xfc;l', 'Ekim', 'Kas&#x131;m', 'Aral&#x131;k')
+        ),
+        'no'    => array (
+            'weekdays_short'=> array ('S&#xf8;n', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'L&#xf8;r'),
+            'weekdays_long' => array ('S&#xf8;ndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&#xf8;rdag'),
+            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des'),
+            'months_long'   => array ('Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember')
+        ),
+        'eo'    => array (
+            'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', '&#x134;a&#x16D;', 'Ven', 'Sab'),
+            'weekdays_long' => array ('Diman&#x109;o', 'Lundo', 'Mardo', 'Merkredo', '&#x134;a&#x16D;do', 'Vendredo', 'Sabato'),
+            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'A&#x16D;g', 'Sep', 'Okt', 'Nov', 'Dec'),
+            'months_long'   => array ('Januaro', 'Februaro', 'Marto', 'Aprilo', 'Majo', 'Junio', 'Julio', 'A&#x16D;gusto', 'Septembro', 'Oktobro', 'Novembro', 'Decembro')
+        ),
+        'ua'    => array (
+            'weekdays_short'=> array('&#x41d;&#x434;&#x43b;', '&#x41f;&#x43d;&#x434;', '&#x412;&#x442;&#x440;', '&#x421;&#x440;&#x434;', '&#x427;&#x442;&#x432;', '&#x41f;&#x442;&#x43d;', '&#x421;&#x431;&#x442;'),
+            'weekdays_long' => array('&#x41d;&#x435;&#x434;&#x456;&#x43b;&#x44f;', '&#x41f;&#x43e;&#x43d;&#x435;&#x434;&#x456;&#x43b;&#x43e;&#x43a;', '&#x412;&#x456;&#x432;&#x442;&#x43e;&#x440;&#x43e;&#x43a;', '&#x421;&#x435;&#x440;&#x435;&#x434;&#x430;', '&#x427;&#x435;&#x442;&#x432;&#x435;&#x440;', '&#x41f;\'&#x44f;&#x442;&#x43d;&#x438;&#x446;&#x44f;', '&#x421;&#x443;&#x431;&#x43e;&#x442;&#x430;'),
+            'months_short'  => array('&#x421;&#x456;&#x447;', '&#x41b;&#x44e;&#x442;', '&#x411;&#x435;&#x440;', '&#x41a;&#x432;&#x456;', '&#x422;&#x440;&#x430;', '&#x427;&#x435;&#x440;', '&#x41b;&#x438;&#x43f;', '&#x421;&#x435;&#x440;', '&#x412;&#x435;&#x440;', '&#x416;&#x43e;&#x432;', '&#x41b;&#x438;&#x441;', '&#x413;&#x440;&#x443;'),
+            'months_long'   => array('&#x421;&#x456;&#x447;&#x435;&#x43d;&#x44c;', '&#x41b;&#x44e;&#x442;&#x438;&#x439;', '&#x411;&#x435;&#x440;&#x435;&#x437;&#x435;&#x43d;&#x44c;', '&#x41a;&#x432;&#x456;&#x442;&#x435;&#x43d;&#x44c;', '&#x422;&#x440;&#x430;&#x432;&#x435;&#x43d;&#x44c;', '&#x427;&#x435;&#x440;&#x432;&#x435;&#x43d;&#x44c;', '&#x41b;&#x438;&#x43f;&#x435;&#x43d;&#x44c;', '&#x421;&#x435;&#x440;&#x43f;&#x435;&#x43d;&#x44c;', '&#x412;&#x435;&#x440;&#x435;&#x441;&#x435;&#x43d;&#x44c;', '&#x416;&#x43e;&#x432;&#x442;&#x435;&#x43d;&#x44c;', '&#x41b;&#x438;&#x441;&#x442;&#x43e;&#x43f;&#x430;&#x434;', '&#x413;&#x440;&#x443;&#x434;&#x435;&#x43d;&#x44c;')
+        ),
+        'ro'    => array (
+            'weekdays_short'=> array ('Dum', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sam'),
+            'weekdays_long' => array ('Duminica', 'Luni', 'Marti', 'Miercuri', 'Joi', 'Vineri', 'Sambata'),
+            'months_short'  => array ('Ian', 'Feb', 'Mar', 'Apr', 'Mai', 'Iun', 'Iul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
+            'months_long'   => array ('Ianuarie', 'Februarie', 'Martie', 'Aprilie', 'Mai', 'Iunie', 'Iulie', 'August', 'Septembrie', 'Octombrie', 'Noiembrie', 'Decembrie')
+        ),
+        'he'    => array (
+            'weekdays_short'=> array ('&#1512;&#1488;&#1513;&#1493;&#1503;', '&#1513;&#1504;&#1497;', '&#1513;&#1500;&#1497;&#1513;&#1497;', '&#1512;&#1489;&#1497;&#1506;&#1497;', '&#1495;&#1502;&#1497;&#1513;&#1497;', '&#1513;&#1497;&#1513;&#1497;', '&#1513;&#1489;&#1514;'),
+            'weekdays_long' => array ('&#1497;&#1493;&#1501; &#1512;&#1488;&#1513;&#1493;&#1503;', '&#1497;&#1493;&#1501; &#1513;&#1504;&#1497;', '&#1497;&#1493;&#1501; &#1513;&#1500;&#1497;&#1513;&#1497;', '&#1497;&#1493;&#1501; &#1512;&#1489;&#1497;&#1506;&#1497;', '&#1497;&#1493;&#1501; &#1495;&#1502;&#1497;&#1513;&#1497;', '&#1497;&#1493;&#1501; &#1513;&#1497;&#1513;&#1497;', '&#1513;&#1489;&#1514;'),
+            'months_short'  => array ('&#1497;&#1504;&#1493;&#1488;&#1512;', '&#1508;&#1489;&#1512;&#1493;&#1488;&#1512;', '&#1502;&#1512;&#1509;', '&#1488;&#1508;&#1512;&#1497;&#1500;', '&#1502;&#1488;&#1497;', '&#1497;&#1493;&#1504;&#1497;', '&#1497;&#1493;&#1500;&#1497;', '&#1488;&#1493;&#1490;&#1493;&#1505;&#1496;', '&#1505;&#1508;&#1496;&#1502;&#1489;&#1512;', '&#1488;&#1493;&#1511;&#1496;&#1493;&#1489;&#1512;', '&#1504;&#1493;&#1489;&#1502;&#1489;&#1512;', '&#1491;&#1510;&#1502;&#1489;&#1512;'),
+            'months_long'   => array ('&#1497;&#1504;&#1493;&#1488;&#1512;', '&#1508;&#1489;&#1512;&#1493;&#1488;&#1512;', '&#1502;&#1512;&#1509;', '&#1488;&#1508;&#1512;&#1497;&#1500;', '&#1502;&#1488;&#1497;', '&#1497;&#1493;&#1504;&#1497;', '&#1497;&#1493;&#1500;&#1497;', '&#1488;&#1493;&#1490;&#1493;&#1505;&#1496;', '&#1505;&#1508;&#1496;&#1502;&#1489;&#1512;', '&#1488;&#1493;&#1511;&#1496;&#1493;&#1489;&#1512;', '&#1504;&#1493;&#1489;&#1502;&#1489;&#1512;', '&#1491;&#1510;&#1502;&#1489;&#1512;')
+        ),
+        'sv'    => array (
+            'weekdays_short'=> array ('S&#xf6;n', 'M&#xe5;n', 'Tis', 'Ons', 'Tor', 'Fre', 'L&#xf6;r'),
+            'weekdays_long' => array ('S&#xf6;ndag', 'M&#xe5;ndag', 'Tisdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&#xf6;rdag'),
+            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
+            'months_long'   => array ('Januari', 'Februari', 'Mars', 'April', 'Maj', 'Juni', 'Juli', 'Augusti', 'September', 'Oktober', 'November', 'December')
+        ),
+        'pt'    => array (
+            'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'S&aacute;b'),
+            'weekdays_long' => array ('Domingo', 'Segunda-feira', 'Ter&ccedil;a-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'S&aacute;bado'),
+            'months_short'  => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'),
+            'months_long'   => array ('Janeiro', 'Fevereiro', 'Mar&ccedil;o', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro')
+        ),
+        'tw'    => array (
+            'weekdays_short'=> array ('&#36913;&#26085;','&#36913;&#19968;', '&#36913;&#20108;','&#36913;&#19977;', '&#36913;&#22235;','&#36913;&#20116;', '&#36913;&#20845;'),
+            'weekdays_long' => array ('&#26143;&#26399;&#26085;', '&#26143;&#26399;&#19968;', '&#26143;&#26399;&#20108;', '&#26143;&#26399;&#19977;', '&#26143;&#26399;&#22235;', '&#26143;&#26399;&#20116;', '&#26143;&#26399;&#20845;'),
+            'months_short'  => array ('&#19968;&#26376;', '&#20108;&#26376;', '&#19977;&#26376;', '&#22235;&#26376;', '&#20116;&#26376;', '&#20845;&#26376;', '&#19971;&#26376;', '&#20843;&#26376;', '&#20061;&#26376;', '&#21313;&#26376;', '&#21313;&#19968;&#26376;', '&#21313;&#20108;&#26376;'),
+            'months_long'   => array ('&#19968;&#26376;', '&#20108;&#26376;', '&#19977;&#26376;', '&#22235;&#26376;', '&#20116;&#26376;', '&#20845;&#26376;', '&#19971;&#26376;', '&#20843;&#26376;', '&#20061;&#26376;', '&#21313;&#26376;', '&#21313;&#19968;&#26376;', '&#21313;&#20108;&#26376;')
+        ),
+        'pt-br' => array (
+            'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'S&aacute;b'),
+            'weekdays_long' => array ('Domingo', 'Segunda', 'Ter&ccedil;a', 'Quarta', 'Quinta', 'Sexta', 'S&aacute;bado'),
+            'months_short'  => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'),
+            'months_long'   => array ('Janeiro', 'Fevereiro', 'Mar&ccedil;o', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro')
+        ),
+        'sr'    => array (
+            'weekdays_short'=> array ('&#1053;&#1077;&#1076;', '&#1055;&#1086;&#1085;', '&#1059;&#1090;&#1086;', '&#1057;&#1088;&#1077;', '&#1063;&#1077;&#1090;', '&#1055;&#1077;&#1090;', '&#1057;&#1091;&#1073;'),
+            'weekdays_long' => array ('&#1053;&#1077;&#1076;&#1077;&#1113;&#1072;', '&#1055;&#1086;&#1085;&#1077;&#1076;&#1077;&#1113;&#1072;&#1082;', '&#1059;&#1090;&#1086;&#1088;&#1072;&#1082;', '&#1057;&#1088;&#1077;&#1076;&#1072;', '&#1063;&#1077;&#1090;&#1074;&#1088;&#1090;&#1072;&#1082;', '&#1055;&#1077;&#1090;&#1072;&#1082;', '&#1057;&#1091;&#1073;&#1086;&#1090;&#1072;'),
+            'months_short'  => array ('&#1032;&#1072;&#1085;', '&#1060;&#1077;&#1073;', '&#1052;&#1072;&#1088;', '&#1040;&#1087;&#1088;', '&#1052;&#1072;&#1112;', '&#1032;&#1091;&#1085;', '&#1032;&#1091;&#1083;', '&#1040;&#1074;&#1075;', '&#1057;&#1077;&#1087;', '&#1054;&#1082;&#1090;', '&#1053;&#1086;&#1074;', '&#1044;&#1077;&#1094;'),
+            'months_long'   => array ('&#1032;&#1072;&#1085;&#1091;&#1072;&#1088;', '&#1060;&#1077;&#1073;&#1088;&#1091;&#1072;&#1088;', '&#1052;&#1072;&#1088;&#1090;', '&#1040;&#1087;&#1088;&#1080;&#1083;', '&#1052;&#1072;&#1112;', '&#1032;&#1091;&#1085;', '&#1032;&#1091;&#1083;', '&#1040;&#1074;&#1075;&#1091;&#1089;&#1090;', '&#1057;&#1077;&#1087;&#1090;&#1077;&#1084;&#1073;&#1072;&#1088;', '&#1054;&#1082;&#1090;&#1086;&#1073;&#1072;&#1088;', '&#1053;&#1086;&#1074;&#1077;&#1084;&#1073;&#1072;&#1088;', '&#1044;&#1077;&#1094;&#1077;&#1084;&#1073;&#1072;&#1088;')
+        ),
+        'el' => array (
+            'weekdays_short'=> array ('&#916;&#949;&#965;', '&#932;&#961;&#943;', '&#932;&#949;&#964;', '&#928;&#941;&#956;', '&#928;&#945;&#961;', '&#931;&#940;&#946;', '&#922;&#965;&#961;'),
+            'weekdays_long' => array ('&#916;&#949;&#965;&#964;&#941;&#961;&#945;', '&#932;&#961;&#943;&#964;&#951;', '&#932;&#949;&#964;&#940;&#961;&#964;&#951;', '&#928;&#941;&#956;&#960;&#964;&#951;', '&#928;&#945;&#961;&#945;&#963;&#954;&#949;&#965;&#942;', '&#931;&#940;&#946;&#946;&#945;&#964;&#959;', '&#922;&#965;&#961;&#953;&#945;&#954;&#942;'),
+            'months_short'  => array ('&#921;&#945;&#957;', '&#934;&#949;&#946;', '&#924;&#940;&#961;', '&#913;&#960;&#961;', '&#924;&#940;&#970;', 'Io&#973;&#957;', '&#921;&#959;&#973;&#955;', '&#913;&#973;&#947;', '&#931;&#949;&#960;', '&#927;&#954;&#964;', '&#925;&#959;&#941;', '&#916;&#949;&#954;'),
+            'months_long'   => array ('&#921;&#945;&#957;&#959;&#965;&#940;&#961;&#953;&#959;&#962;', '&#934;&#949;&#946;&#961;&#959;&#965;&#940;&#961;&#953;&#959;&#962;', '&#924;&#940;&#961;&#964;&#953;&#959;&#962;', '&#913;&#960;&#961;&#943;&#955;&#953;&#959;&#962;', '&#924;&#940;&#970;&#959;&#962;', '&#921;&#959;&#973;&#957;&#953;&#959;&#962;', 'Io&#973;&#955;&#953;&#959;&#962;', '&#913;&#973;&#947;&#959;&#965;&#963;&#964;&#959;&#962;', '&#931;&#949;&#960;&#964;&#941;&#956;&#946;&#961;&#953;&#959;&#962;', '&#927;&#954;&#964;&#974;&#946;&#961;&#953;&#959;&#962;', '&#925;&#959;&#941;&#956;&#946;&#961;&#953;&#959;&#962;', '&#916;&#949;&#954;&#941;&#956;&#946;&#961;&#953;&#959;&#962;')
+        )
+    );
+
+    // }}}
+    // {{{ constructor
+
+   /**
+    * Class constructor
+    *
+    * The following keys may appear in $options array:
+    * - 'language': date language
+    * - 'format': Format of the date, based on PHP's date() function.
+    *   The following characters are currently recognised in format string:
+    *   <pre>
+    *       D => Short names of days
+    *       l => Long names of days
+    *       d => Day numbers
+    *       M => Short names of months
+    *       F => Long names of months
+    *       m => Month numbers
+    *       Y => Four digit year
+    *       y => Two digit year
+    *       h => 12 hour format
+    *       H => 23 hour  format
+    *       i => Minutes
+    *       s => Seconds
+    *       a => am/pm
+    *       A => AM/PM
+    *   </pre>
+    * - 'minYear': Minimum year in year select
+    * - 'maxYear': Maximum year in year select
+    * - 'addEmptyOption': Should an empty option be added to the top of
+    *    each select box?
+    * - 'emptyOptionValue': The value passed by the empty option.
+    * - 'emptyOptionText': The text displayed for the empty option.
+    * - 'optionIncrement': Step to increase the option values by (works for 'i' and 's')
+    *
+    * @access   public
+    * @param    string  Element's name
+    * @param    mixed   Label(s) for an element
+    * @param    array   Options to control the element's display
+    * @param    mixed   Either a typical HTML attribute string or an associative array
+    */
+    function HTML_QuickForm_date($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
+    {
+        $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
+        $this->_persistantFreeze = true;
+        $this->_appendName = true;
+        $this->_type = 'date';
+
+        // http://pear.php.net/bugs/bug.php?id=18171
+        $this->_options['maxYear'] = date('Y');
+
+        // set the options, do not bother setting bogus ones
+        if (is_array($options)) {
+            foreach ($options as $name => $value) {
+                if ('language' == $name) {
+                    $this->_options['language'] = isset($this->_locale[$value])? $value: 'en';
+                } elseif (isset($this->_options[$name])) {
+                    if (is_array($value) && is_array($this->_options[$name])) {
+                        $this->_options[$name] = @array_merge($this->_options[$name], $value);
+                    } else {
+                        $this->_options[$name] = $value;
+                    }
+                }
+            }
+        }
+    }
+
+    // }}}
+    // {{{ _createElements()
+
+    function _createElements()
+    {
+        $this->_separator = $this->_elements = array();
+        $separator =  '';
+        $locale    =& $this->_locale[$this->_options['language']];
+        $backslash =  false;
+        for ($i = 0, $length = strlen($this->_options['format']); $i < $length; $i++) {
+            $sign = $this->_options['format']{$i};
+            if ($backslash) {
+                $backslash  = false;
+                $separator .= $sign;
+            } else {
+                $loadSelect = true;
+                switch ($sign) {
+                    case 'D':
+                        // Sunday is 0 like with 'w' in date()
+                        $options = $locale['weekdays_short'];
+                        break;
+                    case 'l':
+                        $options = $locale['weekdays_long'];
+                        break;
+                    case 'd':
+                        $options = $this->_createOptionList(1, 31);
+                        break;
+                    case 'M':
+                        $options = $locale['months_short'];
+                        array_unshift($options , '');
+                        unset($options[0]);
+                        break;
+                    case 'm':
+                        $options = $this->_createOptionList(1, 12);
+                        break;
+                    case 'F':
+                        $options = $locale['months_long'];
+                        array_unshift($options , '');
+                        unset($options[0]);
+                        break;
+                    case 'Y':
+                        $options = $this->_createOptionList(
+                            $this->_options['minYear'],
+                            $this->_options['maxYear'],
+                            $this->_options['minYear'] > $this->_options['maxYear']? -1: 1
+                        );
+                        break;
+                    case 'y':
+                        $options = $this->_createOptionList(
+                            $this->_options['minYear'],
+                            $this->_options['maxYear'],
+                            $this->_options['minYear'] > $this->_options['maxYear']? -1: 1
+                        );
+                        array_walk($options, create_function('&$v,$k','$v = substr($v,-2);'));
+                        break;
+                    case 'h':
+                        $options = $this->_createOptionList(1, 12);
+                        break;
+                    case 'g':
+                        $options = $this->_createOptionList(1, 12);
+                        array_walk($options, create_function('&$v,$k', '$v = intval($v);'));
+                        break;
+                    case 'H':
+                        $options = $this->_createOptionList(0, 23);
+                        break;
+                    case 'i':
+                        $options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['i']);
+                        break;
+                    case 's':
+                        $options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['s']);
+                        break;
+                    case 'a':
+                        $options = array('am' => 'am', 'pm' => 'pm');
+                        break;
+                    case 'A':
+                        $options = array('AM' => 'AM', 'PM' => 'PM');
+                        break;
+                    case 'W':
+                        $options = $this->_createOptionList(1, 53);
+                        break;
+                    case '\\':
+                        $backslash  = true;
+                        $loadSelect = false;
+                        break;
+                    default:
+                        $separator .= (' ' == $sign? '&nbsp;': $sign);
+                        $loadSelect = false;
+                }
+
+                if ($loadSelect) {
+                    if (0 < count($this->_elements)) {
+                        $this->_separator[] = $separator;
+                    } else {
+                        $this->_wrap[0] = $separator;
+                    }
+                    $separator = '';
+                    // Should we add an empty option to the top of the select?
+                    if (!is_array($this->_options['addEmptyOption']) && $this->_options['addEmptyOption'] ||
+                        is_array($this->_options['addEmptyOption']) && !empty($this->_options['addEmptyOption'][$sign])) {
+
+                        // Using '+' array operator to preserve the keys
+                        if (is_array($this->_options['emptyOptionText']) && !empty($this->_options['emptyOptionText'][$sign])) {
+                            $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText'][$sign]) + $options;
+                        } else {
+                            $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText']) + $options;
+                        }
+                    }
+                    $this->_elements[] =& new HTML_QuickForm_select($sign, null, $options, $this->getAttributes());
+                }
+            }
+        }
+        $this->_wrap[1] = $separator . ($backslash? '\\': '');
+    }
+
+    // }}}
+    // {{{ _createOptionList()
+
+   /**
+    * Creates an option list containing the numbers from the start number to the end, inclusive
+    *
+    * @param    int     The start number
+    * @param    int     The end number
+    * @param    int     Increment by this value
+    * @access   private
+    * @return   array   An array of numeric options.
+    */
+    function _createOptionList($start, $end, $step = 1)
+    {
+        for ($i = $start, $options = array(); $start > $end? $i >= $end: $i <= $end; $i += $step) {
+            $options[$i] = sprintf('%02d', $i);
+        }
+        return $options;
+    }
+
+    // }}}
+    // {{{ _trimLeadingZeros()
+
+   /**
+    * Trims leading zeros from the (numeric) string
+    *
+    * @param    string  A numeric string, possibly with leading zeros
+    * @return   string  String with leading zeros removed
+    */
+    function _trimLeadingZeros($str)
+    {
+        if (0 == strcmp($str, $this->_options['emptyOptionValue'])) {
+            return $str;
+        }
+        $trimmed = ltrim($str, '0');
+        return strlen($trimmed)? $trimmed: '0';
+    }
+
+    // }}}
+    // {{{ setValue()
+
+    function setValue($value)
+    {
+        if (empty($value)) {
+            $value = array();
+        } elseif (is_scalar($value)) {
+            if (!is_numeric($value)) {
+                $value = strtotime($value);
+            }
+            // might be a unix epoch, then we fill all possible values
+            $arr = explode('-', date('w-j-n-Y-g-G-i-s-a-A-W', (int)$value));
+            $value = array(
+                'D' => $arr[0],
+                'l' => $arr[0],
+                'd' => $arr[1],
+                'M' => $arr[2],
+                'm' => $arr[2],
+                'F' => $arr[2],
+                'Y' => $arr[3],
+                'y' => $arr[3],
+                'h' => $arr[4],
+                'g' => $arr[4],
+                'H' => $arr[5],
+                'i' => $this->_trimLeadingZeros($arr[6]),
+                's' => $this->_trimLeadingZeros($arr[7]),
+                'a' => $arr[8],
+                'A' => $arr[9],
+                'W' => $this->_trimLeadingZeros($arr[10])
+            );
+        } else {
+            $value = array_map(array($this, '_trimLeadingZeros'), $value);
+        }
+        parent::setValue($value);
+    }
+
+    // }}}
+    // {{{ toHtml()
+
+    function toHtml()
+    {
+        include_once('HTML/QuickForm/Renderer/Default.php');
+        $renderer =& new HTML_QuickForm_Renderer_Default();
+        $renderer->setElementTemplate('{element}');
+        parent::accept($renderer);
+        return $this->_wrap[0] . $renderer->toHtml() . $this->_wrap[1];
+    }
+
+    // }}}
+    // {{{ accept()
+
+    function accept(&$renderer, $required = false, $error = null)
+    {
+        $renderer->renderElement($this, $required, $error);
+    }
+
+    // }}}
+    // {{{ onQuickFormEvent()
+
+    function onQuickFormEvent($event, $arg, &$caller)
+    {
+        if ('updateValue' == $event) {
+            // we need to call setValue(), 'cause the default/constant value
+            // may be in fact a timestamp, not an array
+            return HTML_QuickForm_element::onQuickFormEvent($event, $arg, $caller);
+        } else {
+            return parent::onQuickFormEvent($event, $arg, $caller);
+        }
+    }
+
+    // }}}
+}
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/element.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/element.php
new file mode 100644 (file)
index 0000000..caa35b0
--- /dev/null
@@ -0,0 +1,501 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Base class for form elements
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for all HTML classes
+ */
+require_once 'HTML/Common.php';
+/**
+ * Static utility methods
+ */
+require_once 'HTML/QuickForm/utils.php';
+
+/**
+ * Base class for form elements
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ * @abstract
+ */
+class HTML_QuickForm_element extends HTML_Common
+{
+    // {{{ properties
+
+    /**
+     * Label of the field
+     * @var       string
+     * @since     1.3
+     * @access    private
+     */
+    var $_label = '';
+
+    /**
+     * Form element type
+     * @var       string
+     * @since     1.0
+     * @access    private
+     */
+    var $_type = '';
+
+    /**
+     * Flag to tell if element is frozen
+     * @var       boolean
+     * @since     1.0
+     * @access    private
+     */
+    var $_flagFrozen = false;
+
+    /**
+     * Does the element support persistant data when frozen
+     * @var       boolean
+     * @since     1.3
+     * @access    private
+     */
+    var $_persistantFreeze = false;
+
+    // }}}
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     *
+     * @param    string     Name of the element
+     * @param    mixed      Label(s) for the element
+     * @param    mixed      Associative array of tag attributes or HTML attributes name="value" pairs
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_element($elementName=null, $elementLabel=null, $attributes=null)
+    {
+        HTML_Common::HTML_Common($attributes);
+        if (isset($elementName)) {
+            $this->setName($elementName);
+        }
+        if (isset($elementLabel)) {
+            $this->setLabel($elementLabel);
+        }
+    } //end constructor
+
+    // }}}
+    // {{{ apiVersion()
+
+    /**
+     * Returns the current API version
+     *
+     * @since     1.0
+     * @access    public
+     * @return    float
+     */
+    function apiVersion()
+    {
+        return 3.2;
+    } // end func apiVersion
+
+    // }}}
+    // {{{ getType()
+
+    /**
+     * Returns element type
+     *
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getType()
+    {
+        return $this->_type;
+    } // end func getType
+
+    // }}}
+    // {{{ setName()
+
+    /**
+     * Sets the input field name
+     *
+     * @param     string    $name   Input field name attribute
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setName($name)
+    {
+        // interface method
+    } //end func setName
+
+    // }}}
+    // {{{ getName()
+
+    /**
+     * Returns the element name
+     *
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getName()
+    {
+        // interface method
+    } //end func getName
+
+    // }}}
+    // {{{ setValue()
+
+    /**
+     * Sets the value of the form element
+     *
+     * @param     string    $value      Default value of the form element
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setValue($value)
+    {
+        // interface
+    } // end func setValue
+
+    // }}}
+    // {{{ getValue()
+
+    /**
+     * Returns the value of the form element
+     *
+     * @since     1.0
+     * @access    public
+     * @return    mixed
+     */
+    function getValue()
+    {
+        // interface
+        return null;
+    } // end func getValue
+
+    // }}}
+    // {{{ freeze()
+
+    /**
+     * Freeze the element so that only its value is returned
+     *
+     * @access    public
+     * @return    void
+     */
+    function freeze()
+    {
+        $this->_flagFrozen = true;
+    } //end func freeze
+
+    // }}}
+    // {{{ unfreeze()
+
+   /**
+    * Unfreezes the element so that it becomes editable
+    *
+    * @access public
+    * @return void
+    * @since  3.2.4
+    */
+    function unfreeze()
+    {
+        $this->_flagFrozen = false;
+    }
+
+    // }}}
+    // {{{ getFrozenHtml()
+
+    /**
+     * Returns the value of field without HTML tags
+     *
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getFrozenHtml()
+    {
+        $value = $this->getValue();
+        return (strlen($value)? htmlspecialchars($value): '&nbsp;') .
+               $this->_getPersistantData();
+    } //end func getFrozenHtml
+
+    // }}}
+    // {{{ _getPersistantData()
+
+   /**
+    * Used by getFrozenHtml() to pass the element's value if _persistantFreeze is on
+    *
+    * @access private
+    * @return string
+    */
+    function _getPersistantData()
+    {
+        if (!$this->_persistantFreeze) {
+            return '';
+        } else {
+            $id = $this->getAttribute('id');
+            return '<input' . $this->_getAttrString(array(
+                       'type'  => 'hidden',
+                       'name'  => $this->getName(),
+                       'value' => $this->getValue()
+                   ) + (isset($id)? array('id' => $id): array())) . ' />';
+        }
+    }
+
+    // }}}
+    // {{{ isFrozen()
+
+    /**
+     * Returns whether or not the element is frozen
+     *
+     * @since     1.3
+     * @access    public
+     * @return    bool
+     */
+    function isFrozen()
+    {
+        return $this->_flagFrozen;
+    } // end func isFrozen
+
+    // }}}
+    // {{{ setPersistantFreeze()
+
+    /**
+     * Sets wether an element value should be kept in an hidden field
+     * when the element is frozen or not
+     *
+     * @param     bool    $persistant   True if persistant value
+     * @since     2.0
+     * @access    public
+     * @return    void
+     */
+    function setPersistantFreeze($persistant=false)
+    {
+        $this->_persistantFreeze = $persistant;
+    } //end func setPersistantFreeze
+
+    // }}}
+    // {{{ setLabel()
+
+    /**
+     * Sets display text for the element
+     *
+     * @param     string    $label  Display text for the element
+     * @since     1.3
+     * @access    public
+     * @return    void
+     */
+    function setLabel($label)
+    {
+        $this->_label = $label;
+    } //end func setLabel
+
+    // }}}
+    // {{{ getLabel()
+
+    /**
+     * Returns display text for the element
+     *
+     * @since     1.3
+     * @access    public
+     * @return    string
+     */
+    function getLabel()
+    {
+        return $this->_label;
+    } //end func getLabel
+
+    // }}}
+    // {{{ _findValue()
+
+    /**
+     * Tries to find the element value from the values array
+     *
+     * @since     2.7
+     * @access    private
+     * @return    mixed
+     */
+    function _findValue(&$values)
+    {
+        if (empty($values)) {
+            return null;
+        }
+        $elementName = $this->getName();
+        if (isset($values[$elementName])) {
+            return $values[$elementName];
+        } elseif (strpos($elementName, '[')) {
+
+            $keys = str_replace(
+                array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"),
+                $elementName
+            );
+            $arrayKeys = explode("']['", $keys);
+            return HTML_QuickForm_utils::recursiveValue($values, $arrayKeys);
+
+        } else {
+            return null;
+        }
+    } //end func _findValue
+
+    // }}}
+    // {{{ onQuickFormEvent()
+
+    /**
+     * Called by HTML_QuickForm whenever form event is made on this element
+     *
+     * @param     string    $event  Name of event
+     * @param     mixed     $arg    event arguments
+     * @param     object    &$caller calling object
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function onQuickFormEvent($event, $arg, &$caller)
+    {
+        switch ($event) {
+            case 'createElement':
+                $className = get_class($this);
+                $this->$className($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]);
+                break;
+            case 'addElement':
+                $this->onQuickFormEvent('createElement', $arg, $caller);
+                $this->onQuickFormEvent('updateValue', null, $caller);
+                break;
+            case 'updateValue':
+                // constant values override both default and submitted ones
+                // default values are overriden by submitted
+                $value = $this->_findValue($caller->_constantValues);
+                if (null === $value) {
+                    $value = $this->_findValue($caller->_submitValues);
+                    if (null === $value) {
+                        $value = $this->_findValue($caller->_defaultValues);
+                    }
+                }
+                if (null !== $value) {
+                    $this->setValue($value);
+                }
+                break;
+            case 'setGroupValue':
+                $this->setValue($arg);
+        }
+        return true;
+    } // end func onQuickFormEvent
+
+    // }}}
+    // {{{ accept()
+
+   /**
+    * Accepts a renderer
+    *
+    * @param HTML_QuickForm_Renderer    renderer object
+    * @param bool                       Whether an element is required
+    * @param string                     An error message associated with an element
+    * @access public
+    * @return void
+    */
+    function accept(&$renderer, $required=false, $error=null)
+    {
+        $renderer->renderElement($this, $required, $error);
+    } // end func accept
+
+    // }}}
+    // {{{ _generateId()
+
+   /**
+    * Automatically generates and assigns an 'id' attribute for the element.
+    *
+    * Currently used to ensure that labels work on radio buttons and
+    * checkboxes. Per idea of Alexander Radivanovich.
+    *
+    * @access private
+    * @return void
+    */
+    function _generateId()
+    {
+        static $idx = 1;
+
+        if (!$this->getAttribute('id')) {
+            $this->updateAttributes(array('id' => 'qf_' . substr(md5(microtime() . $idx++), 0, 6)));
+        }
+    } // end func _generateId
+
+    // }}}
+    // {{{ exportValue()
+
+   /**
+    * Returns a 'safe' element's value
+    *
+    * @param  array   array of submitted values to search
+    * @param  bool    whether to return the value as associative array
+    * @access public
+    * @return mixed
+    */
+    function exportValue(&$submitValues, $assoc = false)
+    {
+        $value = $this->_findValue($submitValues);
+        if (null === $value) {
+            $value = $this->getValue();
+        }
+        return $this->_prepareValue($value, $assoc);
+    }
+
+    // }}}
+    // {{{ _prepareValue()
+
+   /**
+    * Used by exportValue() to prepare the value for returning
+    *
+    * @param  mixed   the value found in exportValue()
+    * @param  bool    whether to return the value as associative array
+    * @access private
+    * @return mixed
+    */
+    function _prepareValue($value, $assoc)
+    {
+        if (null === $value) {
+            return null;
+        } elseif (!$assoc) {
+            return $value;
+        } else {
+            $name = $this->getName();
+            if (!strpos($name, '[')) {
+                return array($name => $value);
+            } else {
+
+                $keys = str_replace(
+                    array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"),
+                    $name
+                );
+                $keysArray = explode("']['", $keys);
+                return HTML_QuickForm_utils::recursiveBuild($keysArray, $value);
+            }
+        }
+    }
+
+    // }}}
+} // end class HTML_QuickForm_element
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/file.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/file.php
new file mode 100644 (file)
index 0000000..02b220d
--- /dev/null
@@ -0,0 +1,360 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for a file upload field
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for <input /> form elements
+ */
+require_once 'HTML/QuickForm/input.php';
+
+// register file-related rules
+if (class_exists('HTML_QuickForm')) {
+    HTML_QuickForm::registerRule('uploadedfile', 'callback', '_ruleIsUploadedFile', 'HTML_QuickForm_file');
+    HTML_QuickForm::registerRule('maxfilesize', 'callback', '_ruleCheckMaxFileSize', 'HTML_QuickForm_file');
+    HTML_QuickForm::registerRule('mimetype', 'callback', '_ruleCheckMimeType', 'HTML_QuickForm_file');
+    HTML_QuickForm::registerRule('filename', 'callback', '_ruleCheckFileName', 'HTML_QuickForm_file');
+}
+
+/**
+ * HTML class for a file upload field
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_file extends HTML_QuickForm_input
+{
+    // {{{ properties
+
+   /**
+    * Uploaded file data, from $_FILES
+    * @var array
+    */
+    var $_value = null;
+
+    // }}}
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * 
+     * @param     string    Input field name attribute
+     * @param     string    Input field label
+     * @param     mixed     (optional)Either a typical HTML attribute string 
+     *                      or an associative array
+     * @since     1.0
+     * @access    public
+     */
+    function HTML_QuickForm_file($elementName=null, $elementLabel=null, $attributes=null)
+    {
+        HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
+        $this->setType('file');
+    } //end constructor
+    
+    // }}}
+    // {{{ setSize()
+
+    /**
+     * Sets size of file element
+     * 
+     * @param     int    Size of file element
+     * @since     1.0
+     * @access    public
+     */
+    function setSize($size)
+    {
+        $this->updateAttributes(array('size' => $size));
+    } //end func setSize
+    
+    // }}}
+    // {{{ getSize()
+
+    /**
+     * Returns size of file element
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    int
+     */
+    function getSize()
+    {
+        return $this->getAttribute('size');
+    } //end func getSize
+
+    // }}}
+    // {{{ freeze()
+
+    /**
+     * Freeze the element so that only its value is returned
+     * 
+     * @access    public
+     * @return    bool
+     */
+    function freeze()
+    {
+        return false;
+    } //end func freeze
+
+    // }}}
+    // {{{ setValue()
+
+    /**
+     * Sets value for file element.
+     * 
+     * Actually this does nothing. The function is defined here to override
+     * HTML_Quickform_input's behaviour of setting the 'value' attribute. As
+     * no sane user-agent uses <input type="file">'s value for anything 
+     * (because of security implications) we implement file's value as a 
+     * read-only property with a special meaning.
+     * 
+     * @param     mixed    Value for file element
+     * @since     3.0
+     * @access    public
+     */
+    function setValue($value)
+    {
+        return null;
+    } //end func setValue
+    
+    // }}}
+    // {{{ getValue()
+
+    /**
+     * Returns information about the uploaded file
+     *
+     * @since     3.0
+     * @access    public
+     * @return    array
+     */
+    function getValue()
+    {
+        return $this->_value;
+    } // end func getValue
+
+    // }}}
+    // {{{ onQuickFormEvent()
+
+    /**
+     * Called by HTML_QuickForm whenever form event is made on this element
+     *
+     * @param     string    Name of event
+     * @param     mixed     event arguments
+     * @param     object    calling object
+     * @since     1.0
+     * @access    public
+     * @return    bool
+     */
+    function onQuickFormEvent($event, $arg, &$caller)
+    {
+        switch ($event) {
+            case 'updateValue':
+                if ($caller->getAttribute('method') == 'get') {
+                    return PEAR::raiseError('Cannot add a file upload field to a GET method form');
+                }
+                $this->_value = $this->_findValue();
+                $caller->updateAttributes(array('enctype' => 'multipart/form-data'));
+                $caller->setMaxFileSize();
+                break;
+            case 'addElement':
+                $this->onQuickFormEvent('createElement', $arg, $caller);
+                return $this->onQuickFormEvent('updateValue', null, $caller);
+                break;
+            case 'createElement':
+                $className = get_class($this);
+                $this->$className($arg[0], $arg[1], $arg[2]);
+                break;
+        }
+        return true;
+    } // end func onQuickFormEvent
+
+    // }}}
+    // {{{ moveUploadedFile()
+
+    /**
+     * Moves an uploaded file into the destination 
+     * 
+     * @param    string  Destination directory path
+     * @param    string  New file name
+     * @access   public
+     * @return   bool    Whether the file was moved successfully
+     */
+    function moveUploadedFile($dest, $fileName = '')
+    {
+        if ($dest != ''  && substr($dest, -1) != '/') {
+            $dest .= '/';
+        }
+        $fileName = ($fileName != '') ? $fileName : basename($this->_value['name']);
+        return move_uploaded_file($this->_value['tmp_name'], $dest . $fileName); 
+    } // end func moveUploadedFile
+    
+    // }}}
+    // {{{ isUploadedFile()
+
+    /**
+     * Checks if the element contains an uploaded file
+     *
+     * @access    public
+     * @return    bool      true if file has been uploaded, false otherwise
+     */
+    function isUploadedFile()
+    {
+        return $this->_ruleIsUploadedFile($this->_value);
+    } // end func isUploadedFile
+
+    // }}}
+    // {{{ _ruleIsUploadedFile()
+
+    /**
+     * Checks if the given element contains an uploaded file
+     *
+     * @param     array     Uploaded file info (from $_FILES)
+     * @access    private
+     * @return    bool      true if file has been uploaded, false otherwise
+     */
+    function _ruleIsUploadedFile($elementValue)
+    {
+        if ((isset($elementValue['error']) && $elementValue['error'] == 0) ||
+            (!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) {
+            return is_uploaded_file($elementValue['tmp_name']);
+        } else {
+            return false;
+        }
+    } // end func _ruleIsUploadedFile
+    
+    // }}}
+    // {{{ _ruleCheckMaxFileSize()
+
+    /**
+     * Checks that the file does not exceed the max file size
+     *
+     * @param     array     Uploaded file info (from $_FILES)
+     * @param     int       Max file size
+     * @access    private
+     * @return    bool      true if filesize is lower than maxsize, false otherwise
+     */
+    function _ruleCheckMaxFileSize($elementValue, $maxSize)
+    {
+        if (!empty($elementValue['error']) && 
+            (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error'])) {
+            return false;
+        }
+        if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) {
+            return true;
+        }
+        return ($maxSize >= @filesize($elementValue['tmp_name']));
+    } // end func _ruleCheckMaxFileSize
+
+    // }}}
+    // {{{ _ruleCheckMimeType()
+
+    /**
+     * Checks if the given element contains an uploaded file of the right mime type
+     *
+     * @param     array     Uploaded file info (from $_FILES)
+     * @param     mixed     Mime Type (can be an array of allowed types)
+     * @access    private
+     * @return    bool      true if mimetype is correct, false otherwise
+     */
+    function _ruleCheckMimeType($elementValue, $mimeType)
+    {
+        if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) {
+            return true;
+        }
+        if (is_array($mimeType)) {
+            return in_array($elementValue['type'], $mimeType);
+        }
+        return $elementValue['type'] == $mimeType;
+    } // end func _ruleCheckMimeType
+
+    // }}}
+    // {{{ _ruleCheckFileName()
+
+    /**
+     * Checks if the given element contains an uploaded file of the filename regex
+     *
+     * @param     array     Uploaded file info (from $_FILES)
+     * @param     string    Regular expression
+     * @access    private
+     * @return    bool      true if name matches regex, false otherwise
+     */
+    function _ruleCheckFileName($elementValue, $regex)
+    {
+        if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) {
+            return true;
+        }
+        return (bool)preg_match($regex, $elementValue['name']);
+    } // end func _ruleCheckFileName
+    
+    // }}}
+    // {{{ _findValue()
+
+   /**
+    * Tries to find the element value from the values array
+    * 
+    * Needs to be redefined here as $_FILES is populated differently from 
+    * other arrays when element name is of the form foo[bar]
+    * 
+    * @param bool $sc1   unused, for signature compatibility
+    *
+    * @access    private
+    * @return    mixed
+    */
+    function _findValue(&$sc1 = null)
+    {
+        if (empty($_FILES)) {
+            return null;
+        }
+        $elementName = $this->getName();
+        if (isset($_FILES[$elementName])) {
+            return $_FILES[$elementName];
+        } elseif (false !== ($pos = strpos($elementName, '['))) {
+            $base  = str_replace(
+                        array('\\', '\''), array('\\\\', '\\\''),
+                        substr($elementName, 0, $pos)
+                    ); 
+            $idx   = "['" . str_replace(
+                        array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"),
+                        substr($elementName, $pos + 1, -1)
+                     ) . "']";
+            $props = array('name', 'type', 'size', 'tmp_name', 'error');
+            $code  = "if (!isset(\$_FILES['{$base}']['name']{$idx})) {\n" .
+                     "    return null;\n" .
+                     "} else {\n" .
+                     "    \$value = array();\n";
+            foreach ($props as $prop) {
+                $code .= "    \$value['{$prop}'] = \$_FILES['{$base}']['{$prop}']{$idx};\n";
+            }
+            return eval($code . "    return \$value;\n}\n");
+        } else {
+            return null;
+        }
+    }
+
+    // }}}
+} // end class HTML_QuickForm_file
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/group.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/group.php
new file mode 100644 (file)
index 0000000..af1b27f
--- /dev/null
@@ -0,0 +1,588 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for a form element group
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for form elements
+ */ 
+require_once 'HTML/QuickForm/element.php';
+
+/**
+ * HTML class for a form element group
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_group extends HTML_QuickForm_element
+{
+    // {{{ properties
+        
+    /**
+     * Name of the element
+     * @var       string
+     * @since     1.0
+     * @access    private
+     */
+    var $_name = '';
+
+    /**
+     * Array of grouped elements
+     * @var       array
+     * @since     1.0
+     * @access    private
+     */
+    var $_elements = array();
+
+    /**
+     * String to separate elements
+     * @var       mixed
+     * @since     2.5
+     * @access    private
+     */
+    var $_separator = null;
+
+    /**
+     * Required elements in this group
+     * @var       array
+     * @since     2.5
+     * @access    private
+     */
+    var $_required = array();
+
+   /**
+    * Whether to change elements' names to $groupName[$elementName] or leave them as is 
+    * @var      bool
+    * @since    3.0
+    * @access   private
+    */
+    var $_appendName = true;
+
+    // }}}
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * 
+     * @param     string    $elementName    (optional)Group name
+     * @param     array     $elementLabel   (optional)Group label
+     * @param     array     $elements       (optional)Group elements
+     * @param     mixed     $separator      (optional)Use a string for one separator,
+     *                                      use an array to alternate the separators.
+     * @param     bool      $appendName     (optional)whether to change elements' names to
+     *                                      the form $groupName[$elementName] or leave 
+     *                                      them as is.
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_group($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true)
+    {
+        $this->HTML_QuickForm_element($elementName, $elementLabel);
+        $this->_type = 'group';
+        if (isset($elements) && is_array($elements)) {
+            $this->setElements($elements);
+        }
+        if (isset($separator)) {
+            $this->_separator = $separator;
+        }
+        if (isset($appendName)) {
+            $this->_appendName = $appendName;
+        }
+    } //end constructor
+    
+    // }}}
+    // {{{ setName()
+
+    /**
+     * Sets the group name
+     * 
+     * @param     string    $name   Group name
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setName($name)
+    {
+        $this->_name = $name;
+    } //end func setName
+    
+    // }}}
+    // {{{ getName()
+
+    /**
+     * Returns the group name
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getName()
+    {
+        return $this->_name;
+    } //end func getName
+
+    // }}}
+    // {{{ setValue()
+
+    /**
+     * Sets values for group's elements
+     * 
+     * @param     mixed    Values for group's elements
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setValue($value)
+    {
+        $this->_createElementsIfNotExist();
+        foreach (array_keys($this->_elements) as $key) {
+            if (!$this->_appendName) {
+                $v = $this->_elements[$key]->_findValue($value);
+                if (null !== $v) {
+                    $this->_elements[$key]->onQuickFormEvent('setGroupValue', $v, $this);
+                }
+
+            } else {
+                $elementName = $this->_elements[$key]->getName();
+                $index       = strlen($elementName) ? $elementName : $key;
+                if (is_array($value)) {
+                    if (isset($value[$index])) {
+                        $this->_elements[$key]->onQuickFormEvent('setGroupValue', $value[$index], $this);
+                    }
+                } elseif (isset($value)) {
+                    $this->_elements[$key]->onQuickFormEvent('setGroupValue', $value, $this);
+                }
+            }
+        }
+    } //end func setValue
+    
+    // }}}
+    // {{{ getValue()
+
+    /**
+     * Returns the value of the group
+     *
+     * @since     1.0
+     * @access    public
+     * @return    mixed
+     */
+    function getValue()
+    {
+        $value = null;
+        foreach (array_keys($this->_elements) as $key) {
+            $element =& $this->_elements[$key];
+            switch ($element->getType()) {
+                case 'radio': 
+                    $v = $element->getChecked()? $element->getValue(): null;
+                    break;
+                case 'checkbox': 
+                    $v = $element->getChecked()? true: null;
+                    break;
+                default:
+                    $v = $element->getValue();
+            }
+            if (null !== $v) {
+                $elementName = $element->getName();
+                if (is_null($elementName)) {
+                    $value = $v;
+                } else {
+                    if (!is_array($value)) {
+                        $value = is_null($value)? array(): array($value);
+                    }
+                    if ('' === $elementName) {
+                        $value[] = $v;
+                    } else {
+                        $value[$elementName] = $v;
+                    }
+                }
+            }
+        }
+        return $value;
+    } // end func getValue
+
+    // }}}
+    // {{{ setElements()
+
+    /**
+     * Sets the grouped elements
+     *
+     * @param     array     $elements   Array of elements
+     * @since     1.1
+     * @access    public
+     * @return    void
+     */
+    function setElements($elements)
+    {
+        $this->_elements = array_values($elements);
+        if ($this->_flagFrozen) {
+            $this->freeze();
+        }
+    } // end func setElements
+
+    // }}}
+    // {{{ getElements()
+
+    /**
+     * Gets the grouped elements
+     *
+     * @since     2.4
+     * @access    public
+     * @return    array
+     */
+    function &getElements()
+    {
+        $this->_createElementsIfNotExist();
+        return $this->_elements;
+    } // end func getElements
+
+    // }}}
+    // {{{ getGroupType()
+
+    /**
+     * Gets the group type based on its elements
+     * Will return 'mixed' if elements contained in the group
+     * are of different types.
+     *
+     * @access    public
+     * @return    string    group elements type
+     */
+    function getGroupType()
+    {
+        $this->_createElementsIfNotExist();
+        $prevType = '';
+        foreach (array_keys($this->_elements) as $key) {
+            $type = $this->_elements[$key]->getType();
+            if ($type != $prevType && $prevType != '') {
+                return 'mixed';
+            }
+            $prevType = $type;
+        }
+        return $type;
+    } // end func getGroupType
+
+    // }}}
+    // {{{ toHtml()
+
+    /**
+     * Returns Html for the group
+     * 
+     * @since       1.0
+     * @access      public
+     * @return      string
+     */
+    function toHtml()
+    {
+        include_once('HTML/QuickForm/Renderer/Default.php');
+        $renderer = new HTML_QuickForm_Renderer_Default();
+        $renderer->setElementTemplate('{element}');
+        $this->accept($renderer);
+        return $renderer->toHtml();
+    } //end func toHtml
+    
+    // }}}
+    // {{{ getElementName()
+
+    /**
+     * Returns the element name inside the group such as found in the html form
+     * 
+     * @param     mixed     $index  Element name or element index in the group
+     * @since     3.0
+     * @access    public
+     * @return    mixed     string with element name, false if not found
+     */
+    function getElementName($index)
+    {
+        $this->_createElementsIfNotExist();
+        $elementName = false;
+        if (is_int($index) && isset($this->_elements[$index])) {
+            $elementName = $this->_elements[$index]->getName();
+            if (isset($elementName) && $elementName == '') {
+                $elementName = $index;
+            }
+            if ($this->_appendName) {
+                if (is_null($elementName)) {
+                    $elementName = $this->getName();
+                } else {
+                    $elementName = $this->getName().'['.$elementName.']';
+                }
+            }
+
+        } elseif (is_string($index)) {
+            foreach (array_keys($this->_elements) as $key) {
+                $elementName = $this->_elements[$key]->getName();
+                if ($index == $elementName) {
+                    if ($this->_appendName) {
+                        $elementName = $this->getName().'['.$elementName.']';
+                    }
+                    break;
+                } elseif ($this->_appendName && $this->getName().'['.$elementName.']' == $index) {
+                    break;
+                }
+            }
+        }
+        return $elementName;
+    } //end func getElementName
+
+    // }}}
+    // {{{ getFrozenHtml()
+
+    /**
+     * Returns the value of field without HTML tags
+     * 
+     * @since     1.3
+     * @access    public
+     * @return    string
+     */
+    function getFrozenHtml()
+    {
+        $flags = array();
+        $this->_createElementsIfNotExist();
+        foreach (array_keys($this->_elements) as $key) {
+            if (false === ($flags[$key] = $this->_elements[$key]->isFrozen())) {
+                $this->_elements[$key]->freeze();
+            }
+        }
+        $html = $this->toHtml();
+        foreach (array_keys($this->_elements) as $key) {
+            if (!$flags[$key]) {
+                $this->_elements[$key]->unfreeze();
+            }
+        }
+        return $html;
+    } //end func getFrozenHtml
+
+    // }}}
+    // {{{ onQuickFormEvent()
+
+    /**
+     * Called by HTML_QuickForm whenever form event is made on this element
+     *
+     * @param     string    $event  Name of event
+     * @param     mixed     $arg    event arguments
+     * @param     object    &$caller calling object
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function onQuickFormEvent($event, $arg, &$caller)
+    {
+        switch ($event) {
+            case 'updateValue':
+                $this->_createElementsIfNotExist();
+                foreach (array_keys($this->_elements) as $key) {
+                    if ($this->_appendName) {
+                        $elementName = $this->_elements[$key]->getName();
+                        if (is_null($elementName)) {
+                            $this->_elements[$key]->setName($this->getName());
+                        } elseif ('' === $elementName) {
+                            $this->_elements[$key]->setName($this->getName() . '[' . $key . ']');
+                        } else {
+                            $this->_elements[$key]->setName($this->getName() . '[' . $elementName . ']');
+                        }
+                    }
+                    $this->_elements[$key]->onQuickFormEvent('updateValue', $arg, $caller);
+                    if ($this->_appendName) {
+                        $this->_elements[$key]->setName($elementName);
+                    }
+                }
+                break;
+
+            default:
+                parent::onQuickFormEvent($event, $arg, $caller);
+        }
+        return true;
+    } // end func onQuickFormEvent
+
+    // }}}
+    // {{{ accept()
+
+   /**
+    * Accepts a renderer
+    *
+    * @param HTML_QuickForm_Renderer    renderer object
+    * @param bool                       Whether a group is required
+    * @param string                     An error message associated with a group
+    * @access public
+    * @return void 
+    */
+    function accept(&$renderer, $required = false, $error = null)
+    {
+        $this->_createElementsIfNotExist();
+        $renderer->startGroup($this, $required, $error);
+        $name = $this->getName();
+        foreach (array_keys($this->_elements) as $key) {
+            $element =& $this->_elements[$key];
+            
+            if ($this->_appendName) {
+                $elementName = $element->getName();
+                if (isset($elementName)) {
+                    $element->setName($name . '['. (strlen($elementName)? $elementName: $key) .']');
+                } else {
+                    $element->setName($name);
+                }
+            }
+
+            $required = !$element->isFrozen() && in_array($element->getName(), $this->_required);
+
+            $element->accept($renderer, $required);
+
+            // restore the element's name
+            if ($this->_appendName) {
+                $element->setName($elementName);
+            }
+        }
+        $renderer->finishGroup($this);
+    } // end func accept
+
+    // }}}
+    // {{{ exportValue()
+
+   /**
+    * As usual, to get the group's value we access its elements and call
+    * their exportValue() methods
+    */
+    function exportValue(&$submitValues, $assoc = false)
+    {
+        $value = null;
+        foreach (array_keys($this->_elements) as $key) {
+            $elementName = $this->_elements[$key]->getName();
+            if ($this->_appendName) {
+                if (is_null($elementName)) {
+                    $this->_elements[$key]->setName($this->getName());
+                } elseif ('' === $elementName) {
+                    $this->_elements[$key]->setName($this->getName() . '[' . $key . ']');
+                } else {
+                    $this->_elements[$key]->setName($this->getName() . '[' . $elementName . ']');
+                }
+            }
+            $v = $this->_elements[$key]->exportValue($submitValues, $assoc);
+            if ($this->_appendName) {
+                $this->_elements[$key]->setName($elementName);
+            }
+            if (null !== $v) {
+                // Make $value an array, we will use it like one
+                if (null === $value) {
+                    $value = array();
+                }
+                if ($assoc) {
+                    // just like HTML_QuickForm::exportValues()
+                    $value = HTML_QuickForm::arrayMerge($value, $v);
+                } else {
+                    // just like getValue(), but should work OK every time here
+                    if (is_null($elementName)) {
+                        $value = $v;
+                    } elseif ('' === $elementName) {
+                        $value[] = $v;
+                    } else {
+                        $value[$elementName] = $v;
+                    }
+                }
+            }
+        }
+        // do not pass the value through _prepareValue, we took care of this already
+        return $value;
+    }
+
+    // }}}
+    // {{{ _createElements()
+
+   /**
+    * Creates the group's elements.
+    * 
+    * This should be overriden by child classes that need to create their 
+    * elements. The method will be called automatically when needed, calling
+    * it from the constructor is discouraged as the constructor is usually
+    * called _twice_ on element creation, first time with _no_ parameters.
+    * 
+    * @access private
+    * @abstract
+    */
+    function _createElements()
+    {
+        // abstract
+    }
+
+    // }}}
+    // {{{ _createElementsIfNotExist()
+
+   /**
+    * A wrapper around _createElements()
+    *
+    * This method calls _createElements() if the group's _elements array
+    * is empty. It also performs some updates, e.g. freezes the created
+    * elements if the group is already frozen.
+    *
+    * @access private
+    */
+    function _createElementsIfNotExist()
+    {
+        if (empty($this->_elements)) {
+            $this->_createElements();
+            if ($this->_flagFrozen) {
+                $this->freeze();
+            }
+        }
+    }
+
+    // }}}
+    // {{{ freeze()
+
+    function freeze()
+    {
+        parent::freeze();
+        foreach (array_keys($this->_elements) as $key) {
+            $this->_elements[$key]->freeze();
+        }
+    }
+
+    // }}}
+    // {{{ unfreeze()
+
+    function unfreeze()
+    {
+        parent::unfreeze();
+        foreach (array_keys($this->_elements) as $key) {
+            $this->_elements[$key]->unfreeze();
+        }
+    }
+
+    // }}}
+    // {{{ setPersistantFreeze()
+
+    function setPersistantFreeze($persistant = false)
+    {
+        parent::setPersistantFreeze($persistant);
+        foreach (array_keys($this->_elements) as $key) {
+            $this->_elements[$key]->setPersistantFreeze($persistant);
+        }
+    }
+
+    // }}}
+} //end class HTML_QuickForm_group
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/header.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/header.php
new file mode 100644 (file)
index 0000000..6265a39
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * A pseudo-element used for adding headers to form
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * HTML class for static data
+ */ 
+require_once 'HTML/QuickForm/static.php';
+
+/**
+ * A pseudo-element used for adding headers to form  
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       3.0
+ */
+class HTML_QuickForm_header extends HTML_QuickForm_static
+{
+    // {{{ constructor
+
+   /**
+    * Class constructor
+    * 
+    * @param string $elementName    Header name
+    * @param string $text           Header text
+    * @access public
+    * @return void
+    */
+    function HTML_QuickForm_header($elementName = null, $text = null)
+    {
+        $this->HTML_QuickForm_static($elementName, null, $text);
+        $this->_type = 'header';
+    }
+
+    // }}}
+    // {{{ accept()
+
+   /**
+    * Accepts a renderer
+    *
+    * @param HTML_QuickForm_Renderer    renderer object
+    * @param bool $sc1                  unused, for signature compatibility
+    * @param bool $sc2                  unused, for signature compatibility
+    * @access public
+    * @return void 
+    */
+    function accept(&$renderer, $sc1 = false, $sc2 = null)
+    {
+        $renderer->renderHeader($this);
+    } // end func accept
+
+    // }}}
+
+} //end class HTML_QuickForm_header
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/hidden.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/hidden.php
new file mode 100644 (file)
index 0000000..e3a9a8b
--- /dev/null
@@ -0,0 +1,96 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for a hidden type element
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for <input /> form elements
+ */
+require_once 'HTML/QuickForm/input.php';
+
+/**
+ * HTML class for a hidden type element
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_hidden extends HTML_QuickForm_input
+{
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * 
+     * @param     string    $elementName    (optional)Input field name attribute
+     * @param     string    $value          (optional)Input field value
+     * @param     mixed     $attributes     (optional)Either a typical HTML attribute string 
+     *                                      or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_hidden($elementName=null, $value='', $attributes=null)
+    {
+        HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes);
+        $this->setType('hidden');
+        $this->setValue($value);
+    } //end constructor
+        
+    // }}}
+    // {{{ freeze()
+
+    /**
+     * Freeze the element so that only its value is returned
+     * 
+     * @access    public
+     * @return    void
+     */
+    function freeze()
+    {
+        return false;
+    } //end func freeze
+
+    // }}}
+    // {{{ accept()
+
+   /**
+    * Accepts a renderer
+    *
+    * @param HTML_QuickForm_Renderer    renderer object
+    * @param bool $sc1                  unused, for signature compatibility
+    * @param bool $sc2                  unused, for signature compatibility
+    * @access public
+    * @return void 
+    */
+    function accept(&$renderer, $sc1 = false, $sc2 = null)
+    {
+        $renderer->renderHidden($this);
+    } // end func accept
+
+    // }}}
+
+} //end class HTML_QuickForm_hidden
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/hiddenselect.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/hiddenselect.php
new file mode 100644 (file)
index 0000000..be32ddf
--- /dev/null
@@ -0,0 +1,122 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Hidden select pseudo-element
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Isaac Shepard <ishepard@bsiweb.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Class for <select></select> elements
+ */
+require_once 'HTML/QuickForm/select.php';
+
+/**
+ * Hidden select pseudo-element
+ *
+ * This class takes the same arguments as a select element, but instead
+ * of creating a select ring it creates hidden elements for all values
+ * already selected with setDefault or setConstant.  This is useful if
+ * you have a select ring that you don't want visible, but you need all
+ * selected values to be passed.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Isaac Shepard <ishepard@bsiweb.com>
+ * @version     Release: 3.2.16
+ * @since       2.1
+ */
+class HTML_QuickForm_hiddenselect extends HTML_QuickForm_select
+{
+    // {{{ constructor
+        
+    /**
+     * Class constructor
+     * 
+     * @param     string    Select name attribute
+     * @param     mixed     Label(s) for the select (not used)
+     * @param     mixed     Data to be used to populate options
+     * @param     mixed     Either a typical HTML attribute string or an associative array (not used)
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_hiddenselect($elementName=null, $elementLabel=null, $options=null, $attributes=null)
+    {
+        HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
+        $this->_persistantFreeze = true;
+        $this->_type = 'hiddenselect';
+        if (isset($options)) {
+            $this->load($options);
+        }
+    } //end constructor
+    
+    // }}}
+    // {{{ toHtml()
+
+    /**
+     * Returns the SELECT in HTML
+     *
+     * @since     1.0
+     * @access    public
+     * @return    string
+     * @throws    
+     */
+    function toHtml()
+    {
+        if (empty($this->_values)) {
+            return '';
+        }
+
+        $tabs    = $this->_getTabs();
+        $name    = $this->getPrivateName();
+        $strHtml = '';
+
+        foreach ($this->_values as $key => $val) {
+            for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) {
+                if ($val == $this->_options[$i]['attr']['value']) {
+                    $strHtml .= $tabs . '<input' . $this->_getAttrString(array(
+                        'type'  => 'hidden',
+                        'name'  => $name,
+                        'value' => $val
+                    )) . " />\n" ;
+                }
+            }
+        }
+
+        return $strHtml;
+    } //end func toHtml
+    
+    // }}}
+    // {{{ accept()
+
+   /**
+    * This is essentially a hidden element and should be rendered as one  
+    *
+    * @param HTML_QuickForm_Renderer    renderer object
+    * @param bool $sc1                  unused, for signature compatibility
+    * @param bool $sc2                  unused, for signature compatibility
+    */
+    function accept(&$renderer, $sc1 = false, $sc2 = null)
+    {
+        $renderer->renderHidden($this);
+    }
+
+    // }}}
+} //end class HTML_QuickForm_hiddenselect
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/hierselect.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/hierselect.php
new file mode 100644 (file)
index 0000000..e63a8b7
--- /dev/null
@@ -0,0 +1,650 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Hierarchical select element
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Herim Vasquez <vasquezh@iro.umontreal.ca>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Class for a group of form elements
+ */
+require_once 'HTML/QuickForm/group.php';
+/**
+ * Class for <select></select> elements
+ */
+require_once 'HTML/QuickForm/select.php';
+/**
+ * Static utility methods
+ */
+require_once 'HTML/QuickForm/utils.php';
+
+/**
+ * Hierarchical select element
+ *
+ * Class to dynamically create two or more HTML Select elements
+ * The first select changes the content of the second select and so on.
+ * This element is considered as a group. Selects will be named
+ * groupName[0], groupName[1], groupName[2]...
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Herim Vasquez <vasquezh@iro.umontreal.ca>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       3.1
+ */
+class HTML_QuickForm_hierselect extends HTML_QuickForm_group
+{
+    // {{{ properties
+
+    /**
+     * Options for all the select elements
+     *
+     * @see       setOptions()
+     * @var       array
+     * @access    private
+     */
+    var $_options = array();
+
+    /**
+     * Number of select elements on this group
+     *
+     * @var       int
+     * @access    private
+     */
+    var $_nbElements = 0;
+
+    /**
+     * The javascript used to set and change the options
+     *
+     * @var       string
+     * @access    private
+     */
+    var $_js = '';
+
+    // }}}
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     *
+     * @param     string    $elementName    (optional)Input field name attribute
+     * @param     string    $elementLabel   (optional)Input field label in form
+     * @param     mixed     $attributes     (optional)Either a typical HTML attribute string
+     *                                      or an associative array. Date format is passed along the attributes.
+     * @param     mixed     $separator      (optional)Use a string for one separator,
+     *                                      use an array to alternate the separators.
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_hierselect($elementName=null, $elementLabel=null, $attributes=null, $separator=null)
+    {
+        $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
+        $this->_persistantFreeze = true;
+        if (isset($separator)) {
+            $this->_separator = $separator;
+        }
+        $this->_type = 'hierselect';
+        $this->_appendName = true;
+    } //end constructor
+
+    // }}}
+    // {{{ setOptions()
+
+    /**
+     * Initialize the array structure containing the options for each select element.
+     * Call the functions that actually do the magic.
+     *
+     * Format is a bit more complex than for a simple select as we need to know
+     * which options are related to the ones in the previous select:
+     *
+     * Ex:
+     * <code>
+     * // first select
+     * $select1[0] = 'Pop';
+     * $select1[1] = 'Classical';
+     * $select1[2] = 'Funeral doom';
+     *
+     * // second select
+     * $select2[0][0] = 'Red Hot Chil Peppers';
+     * $select2[0][1] = 'The Pixies';
+     * $select2[1][0] = 'Wagner';
+     * $select2[1][1] = 'Strauss';
+     * $select2[2][0] = 'Pantheist';
+     * $select2[2][1] = 'Skepticism';
+     *
+     * // If only need two selects
+     * //     - and using the deprecated functions
+     * $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:');
+     * $sel->setMainOptions($select1);
+     * $sel->setSecOptions($select2);
+     *
+     * //     - and using the new setOptions function
+     * $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:');
+     * $sel->setOptions(array($select1, $select2));
+     *
+     * // If you have a third select with prices for the cds
+     * $select3[0][0][0] = '15.00$';
+     * $select3[0][0][1] = '17.00$';
+     * // etc
+     *
+     * // You can now use
+     * $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:');
+     * $sel->setOptions(array($select1, $select2, $select3));
+     * </code>
+     *
+     * @param     array    $options    Array of options defining each element
+     * @access    public
+     * @return    void
+     */
+    function setOptions($options)
+    {
+        $this->_options = $options;
+
+        if (empty($this->_elements)) {
+            $this->_nbElements = count($this->_options);
+            $this->_createElements();
+        } else {
+            // setDefaults has probably been called before this function
+            // check if all elements have been created
+            $totalNbElements = count($this->_options);
+            for ($i = $this->_nbElements; $i < $totalNbElements; $i ++) {
+                $this->_elements[] =& new HTML_QuickForm_select($i, null, array(), $this->getAttributes());
+                $this->_nbElements++;
+            }
+        }
+
+        $this->_setOptions();
+    } // end func setMainOptions
+
+    // }}}
+    // {{{ setMainOptions()
+
+    /**
+     * Sets the options for the first select element. Deprecated. setOptions() should be used.
+     *
+     * @param     array     $array    Options for the first select element
+     *
+     * @access    public
+     * @deprecated          Deprecated since release 3.2.2
+     * @return    void
+     */
+    function setMainOptions($array)
+    {
+        $this->_options[0] = $array;
+
+        if (empty($this->_elements)) {
+            $this->_nbElements = 2;
+            $this->_createElements();
+        }
+    } // end func setMainOptions
+
+    // }}}
+    // {{{ setSecOptions()
+
+    /**
+     * Sets the options for the second select element. Deprecated. setOptions() should be used.
+     * The main _options array is initialized and the _setOptions function is called.
+     *
+     * @param     array     $array    Options for the second select element
+     *
+     * @access    public
+     * @deprecated          Deprecated since release 3.2.2
+     * @return    void
+     */
+    function setSecOptions($array)
+    {
+        $this->_options[1] = $array;
+
+        if (empty($this->_elements)) {
+            $this->_nbElements = 2;
+            $this->_createElements();
+        } else {
+            // setDefaults has probably been called before this function
+            // check if all elements have been created
+            $totalNbElements = 2;
+            for ($i = $this->_nbElements; $i < $totalNbElements; $i ++) {
+                $this->_elements[] =& new HTML_QuickForm_select($i, null, array(), $this->getAttributes());
+                $this->_nbElements++;
+            }
+        }
+
+        $this->_setOptions();
+    } // end func setSecOptions
+
+    // }}}
+    // {{{ _setOptions()
+
+    /**
+     * Sets the options for each select element
+     *
+     * @access    private
+     * @return    void
+     */
+    function _setOptions()
+    {
+        $arrayKeys = array();
+        foreach (array_keys($this->_elements) AS $key) {
+            if (isset($this->_options[$key])) {
+                if ((empty($arrayKeys)) || HTML_QuickForm_utils::recursiveIsset($this->_options[$key], $arrayKeys)) {
+                    $array = empty($arrayKeys) ? $this->_options[$key] : HTML_QuickForm_utils::recursiveValue($this->_options[$key], $arrayKeys);
+                    if (is_array($array)) {
+                        $select =& $this->_elements[$key];
+                        $select->_options = array();
+                        $select->loadArray($array);
+
+                        $value = is_array($v = $select->getValue()) ? $v[0] : key($array);
+                        $arrayKeys[] = $value;
+                    }
+                }
+            }
+        }
+    } // end func _setOptions
+
+    // }}}
+    // {{{ setValue()
+
+    /**
+     * Sets values for group's elements
+     *
+     * @param     array     $value    An array of 2 or more values, for the first,
+     *                                the second, the third etc. select
+     *
+     * @access    public
+     * @return    void
+     */
+    function setValue($value)
+    {
+        // fix for bug #6766. Hope this doesn't break anything more
+        // after bug #7961. Forgot that _nbElements was used in
+        // _createElements() called in several places...
+        $this->_nbElements = max($this->_nbElements, count($value));
+        parent::setValue($value);
+        $this->_setOptions();
+    } // end func setValue
+
+    // }}}
+    // {{{ _createElements()
+
+    /**
+     * Creates all the elements for the group
+     *
+     * @access    private
+     * @return    void
+     */
+    function _createElements()
+    {
+        for ($i = 0; $i < $this->_nbElements; $i++) {
+            $this->_elements[] =& new HTML_QuickForm_select($i, null, array(), $this->getAttributes());
+        }
+    } // end func _createElements
+
+    // }}}
+    // {{{ toHtml()
+
+    function toHtml()
+    {
+        $this->_js = '';
+        if (!$this->_flagFrozen) {
+            // set the onchange attribute for each element except last
+            $keys     = array_keys($this->_elements);
+            $onChange = array();
+            for ($i = 0; $i < count($keys) - 1; $i++) {
+                $select =& $this->_elements[$keys[$i]];
+                $onChange[$i] = $select->getAttribute('onchange');
+                $select->updateAttributes(
+                    array('onchange' => '_hs_swapOptions(this.form, \'' . $this->_escapeString($this->getName()) . '\', ' . $keys[$i] . ');' . $onChange[$i])
+                );
+            }
+
+            // create the js function to call
+            if (!defined('HTML_QUICKFORM_HIERSELECT_EXISTS')) {
+                $this->_js .= <<<JAVASCRIPT
+function _hs_findOptions(ary, keys)
+{
+    if (ary == undefined) {
+        return {};
+    }
+    var key = keys.shift();
+    if (!key in ary) {
+        return {};
+    } else if (0 == keys.length) {
+        return ary[key];
+    } else {
+        return _hs_findOptions(ary[key], keys);
+    }
+}
+
+function _hs_findSelect(form, groupName, selectIndex)
+{
+    if (groupName+'['+ selectIndex +']' in form) {
+        return form[groupName+'['+ selectIndex +']'];
+    } else {
+        return form[groupName+'['+ selectIndex +'][]'];
+    }
+}
+
+function _hs_unescapeEntities(str)
+{
+    var div = document.createElement('div');
+    div.innerHTML = str;
+    return div.childNodes[0] ? div.childNodes[0].nodeValue : '';
+}
+
+function _hs_replaceOptions(ctl, options)
+{
+    var j = 0;
+    ctl.options.length = 0;
+    for (var i = 0; i < options.values.length; i++) {
+        ctl.options[i] = new Option(
+            (-1 == String(options.texts[i]).indexOf('&'))? options.texts[i]: _hs_unescapeEntities(options.texts[i]),
+            options.values[i], false, false
+        );
+    }
+}
+
+function _hs_setValue(ctl, value)
+{
+    var testValue = {};
+    if (value instanceof Array) {
+        for (var i = 0; i < value.length; i++) {
+            testValue[value[i]] = true;
+        }
+    } else {
+        testValue[value] = true;
+    }
+    for (var i = 0; i < ctl.options.length; i++) {
+        if (ctl.options[i].value in testValue) {
+            ctl.options[i].selected = true;
+        }
+    }
+}
+
+function _hs_swapOptions(form, groupName, selectIndex)
+{
+    var hsValue = [];
+    for (var i = 0; i <= selectIndex; i++) {
+        hsValue[i] = _hs_findSelect(form, groupName, i).value;
+    }
+
+    _hs_replaceOptions(_hs_findSelect(form, groupName, selectIndex + 1),
+                       _hs_findOptions(_hs_options[groupName][selectIndex], hsValue));
+    if (selectIndex + 1 < _hs_options[groupName].length) {
+        _hs_swapOptions(form, groupName, selectIndex + 1);
+    }
+}
+
+function _hs_onReset(form, groupNames)
+{
+    for (var i = 0; i < groupNames.length; i++) {
+        try {
+            for (var j = 0; j <= _hs_options[groupNames[i]].length; j++) {
+                _hs_setValue(_hs_findSelect(form, groupNames[i], j), _hs_defaults[groupNames[i]][j]);
+                if (j < _hs_options[groupNames[i]].length) {
+                    _hs_replaceOptions(_hs_findSelect(form, groupNames[i], j + 1),
+                                       _hs_findOptions(_hs_options[groupNames[i]][j], _hs_defaults[groupNames[i]].slice(0, j + 1)));
+                }
+            }
+        } catch (e) {
+            if (!(e instanceof TypeError)) {
+                throw e;
+            }
+        }
+    }
+}
+
+function _hs_setupOnReset(form, groupNames)
+{
+    setTimeout(function() { _hs_onReset(form, groupNames); }, 25);
+}
+
+function _hs_onReload()
+{
+    var ctl;
+    for (var i = 0; i < document.forms.length; i++) {
+        for (var j in _hs_defaults) {
+            if (ctl = _hs_findSelect(document.forms[i], j, 0)) {
+                for (var k = 0; k < _hs_defaults[j].length; k++) {
+                    _hs_setValue(_hs_findSelect(document.forms[i], j, k), _hs_defaults[j][k]);
+                }
+            }
+        }
+    }
+
+    if (_hs_prevOnload) {
+        _hs_prevOnload();
+    }
+}
+
+var _hs_prevOnload = null;
+if (window.onload) {
+    _hs_prevOnload = window.onload;
+}
+window.onload = _hs_onReload;
+
+var _hs_options = {};
+var _hs_defaults = {};
+
+JAVASCRIPT;
+                define('HTML_QUICKFORM_HIERSELECT_EXISTS', true);
+            }
+            // option lists
+            $jsParts = array();
+            for ($i = 1; $i < $this->_nbElements; $i++) {
+                $jsParts[] = $this->_convertArrayToJavascript($this->_prepareOptions($this->_options[$i], $i));
+            }
+            $this->_js .= "\n_hs_options['" . $this->_escapeString($this->getName()) . "'] = [\n" .
+                          implode(",\n", $jsParts) .
+                          "\n];\n";
+            // default value; if we don't actually have any values yet just use
+            // the first option (for single selects) or empty array (for multiple)
+            $values = array();
+            foreach (array_keys($this->_elements) as $key) {
+                if (is_array($v = $this->_elements[$key]->getValue())) {
+                    $values[] = count($v) > 1? $v: $v[0];
+                } else {
+                    // XXX: accessing the supposedly private _options array
+                    $values[] = $this->_elements[$key]->getMultiple() || empty($this->_elements[$key]->_options[0])?
+                                array():
+                                $this->_elements[$key]->_options[0]['attr']['value'];
+                }
+            }
+            $this->_js .= "_hs_defaults['" . $this->_escapeString($this->getName()) . "'] = " .
+                          $this->_convertArrayToJavascript($values) . ";\n";
+        }
+        include_once('HTML/QuickForm/Renderer/Default.php');
+        $renderer =& new HTML_QuickForm_Renderer_Default();
+        $renderer->setElementTemplate('{element}');
+        parent::accept($renderer);
+
+        if (!empty($onChange)) {
+            $keys     = array_keys($this->_elements);
+            for ($i = 0; $i < count($keys) - 1; $i++) {
+                $this->_elements[$keys[$i]]->updateAttributes(array('onchange' => $onChange[$i]));
+            }
+        }
+        return (empty($this->_js)? '': "<script type=\"text/javascript\">\n//<![CDATA[\n" . $this->_js . "//]]>\n</script>") .
+               $renderer->toHtml();
+    } // end func toHtml
+
+    // }}}
+    // {{{ accept()
+
+    function accept(&$renderer, $required = false, $error = null)
+    {
+        $renderer->renderElement($this, $required, $error);
+    } // end func accept
+
+    // }}}
+    // {{{ onQuickFormEvent()
+
+    function onQuickFormEvent($event, $arg, &$caller)
+    {
+        if ('updateValue' == $event) {
+            // we need to call setValue() so that the secondary option
+            // matches the main option
+            return HTML_QuickForm_element::onQuickFormEvent($event, $arg, $caller);
+        } else {
+            $ret = parent::onQuickFormEvent($event, $arg, $caller);
+            // add onreset handler to form to properly reset hierselect (see bug #2970)
+            if ('addElement' == $event) {
+                $onReset = $caller->getAttribute('onreset');
+                if (strlen($onReset)) {
+                    if (strpos($onReset, '_hs_setupOnReset')) {
+                        $caller->updateAttributes(array('onreset' => str_replace('_hs_setupOnReset(this, [', "_hs_setupOnReset(this, ['" . $this->_escapeString($this->getName()) . "', ", $onReset)));
+                    } else {
+                        $caller->updateAttributes(array('onreset' => "var temp = function() { {$onReset} } ; if (!temp()) { return false; } ; if (typeof _hs_setupOnReset != 'undefined') { return _hs_setupOnReset(this, ['" . $this->_escapeString($this->getName()) . "']); } "));
+                    }
+                } else {
+                    $caller->updateAttributes(array('onreset' => "if (typeof _hs_setupOnReset != 'undefined') { return _hs_setupOnReset(this, ['" . $this->_escapeString($this->getName()) . "']); } "));
+                }
+            }
+            return $ret;
+        }
+    } // end func onQuickFormEvent
+
+    // }}}
+    // {{{ _prepareOptions()
+
+   /**
+    * Prepares options for JS encoding
+    *
+    * We need to preserve order of options when adding them via javascript, so
+    * cannot use object literal and for/in loop (see bug #16603). Therefore we
+    * convert an associative array of options to two arrays of their values
+    * and texts. Backport from HTML_QuickForm2.
+    *
+    * @param    array   Options array
+    * @param    int     Depth within options array
+    * @link     http://pear.php.net/bugs/bug.php?id=16603
+    * @return   array
+    * @access   private
+    */
+    function _prepareOptions($ary, $depth)
+    {
+        if (!is_array($ary)) {
+            $ret = $ary;
+        } elseif (0 == $depth) {
+            $ret = array('values' => array_keys($ary), 'texts' => array_values($ary));
+        } else {
+            $ret = array();
+            foreach ($ary as $k => $v) {
+                $ret[$k] = $this->_prepareOptions($v, $depth - 1);
+            }
+        }
+        return $ret;
+    }
+
+    // }}}
+    // {{{ _convertArrayToJavascript()
+
+   /**
+    * Converts PHP array to its Javascript analog
+    *
+    * @access private
+    * @param  array     PHP array to convert
+    * @return string    Javascript representation of the value
+    */
+    function _convertArrayToJavascript($array)
+    {
+        if (!is_array($array)) {
+            return $this->_convertScalarToJavascript($array);
+        } elseif (count($array) && array_keys($array) != range(0, count($array) - 1)) {
+            return '{' . implode(',', array_map(
+                array($this, '_encodeNameValue'),
+                array_keys($array), array_values($array)
+            )) . '}';
+        } else {
+            return '[' . implode(',', array_map(
+                array($this, '_convertArrayToJavascript'),
+                $array
+            )) . ']';
+        }
+    }
+
+    // }}}
+    // {{{ _encodeNameValue()
+
+   /**
+    * Callback for array_map used to generate JS name-value pairs
+    *
+    * @param    mixed
+    * @param    mixed
+    * @return   string
+    */
+    function _encodeNameValue($name, $value)
+    {
+        return $this->_convertScalarToJavascript((string)$name) . ':'
+               . $this->_convertArrayToJavascript($value);
+    }
+
+    // }}}
+    // {{{ _convertScalarToJavascript()
+
+   /**
+    * Converts PHP's scalar value to its Javascript analog
+    *
+    * @access private
+    * @param  mixed     PHP value to convert
+    * @return string    Javascript representation of the value
+    */
+    function _convertScalarToJavascript($val)
+    {
+        if (is_bool($val)) {
+            return $val ? 'true' : 'false';
+        } elseif (is_int($val) || is_double($val)) {
+            return $val;
+        } elseif (is_string($val)) {
+            return "'" . $this->_escapeString($val) . "'";
+        } elseif (is_null($val)) {
+            return 'null';
+        } else {
+            // don't bother
+            return '{}';
+        }
+    }
+
+    // }}}
+    // {{{ _escapeString()
+
+   /**
+    * Quotes the string so that it can be used in Javascript string constants
+    *
+    * @access private
+    * @param  string
+    * @return string
+    */
+    function _escapeString($str)
+    {
+        return strtr($str,array(
+            "\r"    => '\r',
+            "\n"    => '\n',
+            "\t"    => '\t',
+            "'"     => "\\'",
+            '"'     => '\"',
+            '\\'    => '\\\\'
+        ));
+    }
+
+    // }}}
+} // end class HTML_QuickForm_hierselect
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/html.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/html.php
new file mode 100644 (file)
index 0000000..64ac858
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * A pseudo-element used for adding raw HTML to form
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * HTML class for static data
+ */
+require_once 'HTML/QuickForm/static.php';
+
+/**
+ * A pseudo-element used for adding raw HTML to form
+ * 
+ * Intended for use with the default renderer only, template-based
+ * ones may (and probably will) completely ignore this
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       3.0
+ * @deprecated  Please use the templates rather than add raw HTML via this element
+ */
+class HTML_QuickForm_html extends HTML_QuickForm_static
+{
+    // {{{ constructor
+
+   /**
+    * Class constructor
+    * 
+    * @param string $text   raw HTML to add
+    * @access public
+    * @return void
+    */
+    function HTML_QuickForm_html($text = null)
+    {
+        $this->HTML_QuickForm_static(null, null, $text);
+        $this->_type = 'html';
+    }
+
+    // }}}
+    // {{{ accept()
+
+   /**
+    * Accepts a renderer
+    *
+    * @param HTML_QuickForm_Renderer    renderer object (only works with Default renderer!)
+    * @param bool $sc1                  unused, for signature compatibility
+    * @param bool $sc2                  unused, for signature compatibility
+    * @access public
+    * @return void 
+    */
+    function accept(&$renderer, $sc1 = false, $sc2 = null)
+    {
+        $renderer->renderHtml($this);
+    } // end func accept
+
+    // }}}
+
+} //end class HTML_QuickForm_html
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/image.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/image.php
new file mode 100644 (file)
index 0000000..bf8a8aa
--- /dev/null
@@ -0,0 +1,127 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for an <input type="image" /> element
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for <input /> form elements
+ */
+require_once 'HTML/QuickForm/input.php';
+
+/**
+ * HTML class for an <input type="image" /> element
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_image extends HTML_QuickForm_input
+{
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * 
+     * @param     string    $elementName    (optional)Element name attribute
+     * @param     string    $src            (optional)Image source
+     * @param     mixed     $attributes     (optional)Either a typical HTML attribute string 
+     *                                      or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_image($elementName=null, $src='', $attributes=null)
+    {
+        HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes);
+        $this->setType('image');
+        $this->setSource($src);
+    } // end class constructor
+
+    // }}}
+    // {{{ setSource()
+
+    /**
+     * Sets source for image element
+     * 
+     * @param     string    $src  source for image element
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setSource($src)
+    {
+        $this->updateAttributes(array('src' => $src));
+    } // end func setSource
+
+    // }}}
+    // {{{ setBorder()
+
+    /**
+     * Sets border size for image element
+     * 
+     * @param     string    $border  border for image element
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setBorder($border)
+    {
+        $this->updateAttributes(array('border' => $border));
+    } // end func setBorder
+
+    // }}}
+    // {{{ setAlign()
+
+    /**
+     * Sets alignment for image element
+     * 
+     * @param     string    $align  alignment for image element
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setAlign($align)
+    {
+        $this->updateAttributes(array('align' => $align));
+    } // end func setAlign
+
+    // }}}
+    // {{{ freeze()
+
+    /**
+     * Freeze the element so that only its value is returned
+     * 
+     * @access    public
+     * @return    void
+     */
+    function freeze()
+    {
+        return false;
+    } //end func freeze
+
+    // }}}
+
+} // end class HTML_QuickForm_image
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/input.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/input.php
new file mode 100644 (file)
index 0000000..0a1f3aa
--- /dev/null
@@ -0,0 +1,209 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Base class for <input /> form elements
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for form elements
+ */ 
+require_once 'HTML/QuickForm/element.php';
+
+/**
+ * Base class for <input /> form elements
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ * @abstract
+ */
+class HTML_QuickForm_input extends HTML_QuickForm_element
+{
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * 
+     * @param    string     Input field name attribute
+     * @param    mixed      Label(s) for the input field
+     * @param    mixed      Either a typical HTML attribute string or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_input($elementName=null, $elementLabel=null, $attributes=null)
+    {
+        $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
+    } //end constructor
+
+    // }}}
+    // {{{ setType()
+
+    /**
+     * Sets the element type
+     *
+     * @param     string    $type   Element type
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setType($type)
+    {
+        $this->_type = $type;
+        $this->updateAttributes(array('type'=>$type));
+    } // end func setType
+    
+    // }}}
+    // {{{ setName()
+
+    /**
+     * Sets the input field name
+     * 
+     * @param     string    $name   Input field name attribute
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setName($name)
+    {
+        $this->updateAttributes(array('name'=>$name));
+    } //end func setName
+    
+    // }}}
+    // {{{ getName()
+
+    /**
+     * Returns the element name
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getName()
+    {
+        return $this->getAttribute('name');
+    } //end func getName
+    
+    // }}}
+    // {{{ setValue()
+
+    /**
+     * Sets the value of the form element
+     *
+     * @param     string    $value      Default value of the form element
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setValue($value)
+    {
+        $this->updateAttributes(array('value'=>$value));
+    } // end func setValue
+
+    // }}}
+    // {{{ getValue()
+
+    /**
+     * Returns the value of the form element
+     *
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getValue()
+    {
+        return $this->getAttribute('value');
+    } // end func getValue
+    
+    // }}}
+    // {{{ toHtml()
+
+    /**
+     * Returns the input field in HTML
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function toHtml()
+    {
+        if ($this->_flagFrozen) {
+            return $this->getFrozenHtml();
+        } else {
+            return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />';
+        }
+    } //end func toHtml
+
+    // }}}
+    // {{{ onQuickFormEvent()
+
+    /**
+     * Called by HTML_QuickForm whenever form event is made on this element
+     *
+     * @param     string    $event  Name of event
+     * @param     mixed     $arg    event arguments
+     * @param     object    &$caller calling object
+     * @since     1.0
+     * @access    public
+     * @return    void
+     * @throws    
+     */
+    function onQuickFormEvent($event, $arg, &$caller)
+    {
+        // do not use submit values for button-type elements
+        $type = $this->getType();
+        if (('updateValue' != $event) ||
+            ('submit' != $type && 'reset' != $type && 'image' != $type && 'button' != $type)) {
+            parent::onQuickFormEvent($event, $arg, $caller);
+        } else {
+            $value = $this->_findValue($caller->_constantValues);
+            if (null === $value) {
+                $value = $this->_findValue($caller->_defaultValues);
+            }
+            if (null !== $value) {
+                $this->setValue($value);
+            }
+        }
+        return true;
+    } // end func onQuickFormEvent
+
+    // }}}
+    // {{{ exportValue()
+
+   /**
+    * We don't need values from button-type elements (except submit) and files
+    */
+    function exportValue(&$submitValues, $assoc = false)
+    {
+        $type = $this->getType();
+        if ('reset' == $type || 'image' == $type || 'button' == $type || 'file' == $type) {
+            return null;
+        } else {
+            return parent::exportValue($submitValues, $assoc);
+        }
+    }
+    
+    // }}}
+} // end class HTML_QuickForm_element
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/link.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/link.php
new file mode 100644 (file)
index 0000000..acca0e2
--- /dev/null
@@ -0,0 +1,200 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for a link type field
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * HTML class for static data
+ */ 
+require_once 'HTML/QuickForm/static.php';
+
+/**
+ * HTML class for a link type field
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       2.0
+ */
+class HTML_QuickForm_link extends HTML_QuickForm_static
+{
+    // {{{ properties
+
+    /**
+     * Link display text
+     * @var       string
+     * @since     1.0
+     * @access    private
+     */
+    var $_text = "";
+
+    // }}}
+    // {{{ constructor
+    
+    /**
+     * Class constructor
+     * 
+     * @param     string    $elementLabel   (optional)Link label
+     * @param     string    $href           (optional)Link href
+     * @param     string    $text           (optional)Link display text
+     * @param     mixed     $attributes     (optional)Either a typical HTML attribute string 
+     *                                      or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     * @throws    
+     */
+    function HTML_QuickForm_link($elementName=null, $elementLabel=null, $href=null, $text=null, $attributes=null)
+    {
+        HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
+        $this->_persistantFreeze = false;
+        $this->_type = 'link';
+        $this->setHref($href);
+        $this->_text = $text;
+    } //end constructor
+    
+    // }}}
+    // {{{ setName()
+
+    /**
+     * Sets the input field name
+     * 
+     * @param     string    $name   Input field name attribute
+     * @since     1.0
+     * @access    public
+     * @return    void
+     * @throws    
+     */
+    function setName($name)
+    {
+        $this->updateAttributes(array('name'=>$name));
+    } //end func setName
+    
+    // }}}
+    // {{{ getName()
+
+    /**
+     * Returns the element name
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     * @throws    
+     */
+    function getName()
+    {
+        return $this->getAttribute('name');
+    } //end func getName
+
+    // }}}
+    // {{{ setValue()
+
+    /**
+     * Sets value for textarea element
+     * 
+     * @param     string    $value  Value for password element
+     * @since     1.0
+     * @access    public
+     * @return    void
+     * @throws    
+     */
+    function setValue($value)
+    {
+        return;
+    } //end func setValue
+    
+    // }}}
+    // {{{ getValue()
+
+    /**
+     * Returns the value of the form element
+     *
+     * @since     1.0
+     * @access    public
+     * @return    void
+     * @throws    
+     */
+    function getValue()
+    {
+        return;
+    } // end func getValue
+
+    
+    // }}}
+    // {{{ setHref()
+
+    /**
+     * Sets the links href
+     *
+     * @param     string    $href
+     * @since     1.0
+     * @access    public
+     * @return    void
+     * @throws    
+     */
+    function setHref($href)
+    {
+        $this->updateAttributes(array('href'=>$href));
+    } // end func setHref
+
+    // }}}
+    // {{{ toHtml()
+
+    /**
+     * Returns the textarea element in HTML
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     * @throws    
+     */
+    function toHtml()
+    {
+        $tabs = $this->_getTabs();
+        $html = "$tabs<a".$this->_getAttrString($this->_attributes).">";
+        $html .= $this->_text;
+        $html .= "</a>";
+        return $html;
+    } //end func toHtml
+    
+    // }}}
+    // {{{ getFrozenHtml()
+
+    /**
+     * Returns the value of field without HTML tags (in this case, value is changed to a mask)
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     * @throws    
+     */
+    function getFrozenHtml()
+    {
+        return;
+    } //end func getFrozenHtml
+
+    // }}}
+
+} //end class HTML_QuickForm_textarea
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/password.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/password.php
new file mode 100644 (file)
index 0000000..5d41e9a
--- /dev/null
@@ -0,0 +1,115 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for a password type field
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for <input /> form elements
+ */
+require_once 'HTML/QuickForm/input.php';
+
+/**
+ * HTML class for a password type field
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_password extends HTML_QuickForm_input
+{
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * 
+     * @param     string    $elementName    (optional)Input field name attribute
+     * @param     string    $elementLabel   (optional)Input field label
+     * @param     mixed     $attributes     (optional)Either a typical HTML attribute string 
+     *                                      or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     * @throws    
+     */
+    function HTML_QuickForm_password($elementName=null, $elementLabel=null, $attributes=null)
+    {
+        HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
+        $this->setType('password');
+    } //end constructor
+    
+    // }}}
+    // {{{ setSize()
+
+    /**
+     * Sets size of password element
+     * 
+     * @param     string    $size  Size of password field
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setSize($size)
+    {
+        $this->updateAttributes(array('size'=>$size));
+    } //end func setSize
+
+    // }}}
+    // {{{ setMaxlength()
+
+    /**
+     * Sets maxlength of password element
+     * 
+     * @param     string    $maxlength  Maximum length of password field
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setMaxlength($maxlength)
+    {
+        $this->updateAttributes(array('maxlength'=>$maxlength));
+    } //end func setMaxlength
+        
+    // }}}
+    // {{{ getFrozenHtml()
+
+    /**
+     * Returns the value of field without HTML tags (in this case, value is changed to a mask)
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     * @throws    
+     */
+    function getFrozenHtml()
+    {
+        $value = $this->getValue();
+        return ('' != $value? '**********': '&nbsp;') .
+               $this->_getPersistantData();
+    } //end func getFrozenHtml
+
+    // }}}
+
+} //end class HTML_QuickForm_password
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/radio.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/radio.php
new file mode 100644 (file)
index 0000000..97b4eba
--- /dev/null
@@ -0,0 +1,251 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for a radio type element
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for <input /> form elements
+ */
+require_once 'HTML/QuickForm/input.php';
+
+/**
+ * HTML class for a radio type element
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_radio extends HTML_QuickForm_input
+{
+    // {{{ properties
+
+    /**
+     * Radio display text
+     * @var       string
+     * @since     1.1
+     * @access    private
+     */
+    var $_text = '';
+
+    // }}}
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * 
+     * @param     string    Input field name attribute
+     * @param     mixed     Label(s) for a field
+     * @param     string    Text to display near the radio
+     * @param     string    Input field value
+     * @param     mixed     Either a typical HTML attribute string or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_radio($elementName=null, $elementLabel=null, $text=null, $value=null, $attributes=null)
+    {
+        $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
+        if (isset($value)) {
+            $this->setValue($value);
+        }
+        $this->_persistantFreeze = true;
+        $this->setType('radio');
+        $this->_text = $text;
+        $this->_generateId();
+    } //end constructor
+    
+    // }}}
+    // {{{ setChecked()
+
+    /**
+     * Sets whether radio button is checked
+     * 
+     * @param     bool    $checked  Whether the field is checked or not
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setChecked($checked)
+    {
+        if (!$checked) {
+            $this->removeAttribute('checked');
+        } else {
+            $this->updateAttributes(array('checked'=>'checked'));
+        }
+    } //end func setChecked
+
+    // }}}
+    // {{{ getChecked()
+
+    /**
+     * Returns whether radio button is checked
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getChecked()
+    {
+        return $this->getAttribute('checked');
+    } //end func getChecked
+        
+    // }}}
+    // {{{ toHtml()
+
+    /**
+     * Returns the radio element in HTML
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function toHtml()
+    {
+        if (0 == strlen($this->_text)) {
+            $label = '';
+        } elseif ($this->_flagFrozen) {
+            $label = $this->_text;
+        } else {
+            $label = '<label for="' . $this->getAttribute('id') . '">' . $this->_text . '</label>';
+        }
+        return HTML_QuickForm_input::toHtml() . $label;
+    } //end func toHtml
+    
+    // }}}
+    // {{{ getFrozenHtml()
+
+    /**
+     * Returns the value of field without HTML tags
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getFrozenHtml()
+    {
+        if ($this->getChecked()) {
+            return '<tt>(x)</tt>' .
+                   $this->_getPersistantData();
+        } else {
+            return '<tt>( )</tt>';
+        }
+    } //end func getFrozenHtml
+
+    // }}}
+    // {{{ setText()
+
+    /**
+     * Sets the radio text
+     * 
+     * @param     string    $text  Text to display near the radio button
+     * @since     1.1
+     * @access    public
+     * @return    void
+     */
+    function setText($text)
+    {
+        $this->_text = $text;
+    } //end func setText
+
+    // }}}
+    // {{{ getText()
+
+    /**
+     * Returns the radio text 
+     * 
+     * @since     1.1
+     * @access    public
+     * @return    string
+     */
+    function getText()
+    {
+        return $this->_text;
+    } //end func getText
+
+    // }}}
+    // {{{ onQuickFormEvent()
+
+    /**
+     * Called by HTML_QuickForm whenever form event is made on this element
+     *
+     * @param     string    $event  Name of event
+     * @param     mixed     $arg    event arguments
+     * @param     object    &$caller calling object
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function onQuickFormEvent($event, $arg, &$caller)
+    {
+        switch ($event) {
+            case 'updateValue':
+                // constant values override both default and submitted ones
+                // default values are overriden by submitted
+                $value = $this->_findValue($caller->_constantValues);
+                if (null === $value) {
+                    $value = $this->_findValue($caller->_submitValues);
+                    if (null === $value) {
+                        $value = $this->_findValue($caller->_defaultValues);
+                    }
+                }
+                if (!is_null($value) && $value == $this->getValue()) {
+                    $this->setChecked(true);
+                } else {
+                    $this->setChecked(false);
+                }
+                break;
+            case 'setGroupValue':
+                if ($arg == $this->getValue()) {
+                    $this->setChecked(true);
+                } else {
+                    $this->setChecked(false);
+                }
+                break;
+            default:
+                parent::onQuickFormEvent($event, $arg, $caller);
+        }
+        return true;
+    } // end func onQuickFormLoad
+
+    // }}}
+    // {{{ exportValue()
+
+   /**
+    * Returns the value attribute if the radio is checked, null if it is not
+    */
+    function exportValue(&$submitValues, $assoc = false)
+    {
+        $value = $this->_findValue($submitValues);
+        if (null === $value) {
+            $value = $this->getChecked()? $this->getValue(): null;
+        } elseif ($value != $this->getValue()) {
+            $value = null;
+        }
+        return $this->_prepareValue($value, $assoc);
+    }
+    
+    // }}}
+} //end class HTML_QuickForm_radio
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/reset.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/reset.php
new file mode 100644 (file)
index 0000000..6c8dade
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for a reset type element
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for <input /> form elements
+ */
+require_once 'HTML/QuickForm/input.php';
+
+/**
+ * HTML class for a reset type element
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_reset extends HTML_QuickForm_input
+{
+    // {{{ constructor
+    
+    /**
+     * Class constructor
+     * 
+     * @param     string    $elementName    (optional)Input field name attribute
+     * @param     string    $value          (optional)Input field value
+     * @param     mixed     $attributes     (optional)Either a typical HTML attribute string 
+     *                                      or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_reset($elementName=null, $value=null, $attributes=null)
+    {
+        HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes);
+        $this->setValue($value);
+        $this->setType('reset');
+    } //end constructor
+
+    // }}}
+    // {{{ freeze()
+
+    /**
+     * Freeze the element so that only its value is returned
+     * 
+     * @access    public
+     * @return    void
+     */
+    function freeze()
+    {
+        return false;
+    } //end func freeze
+
+    // }}}
+
+} //end class HTML_QuickForm_reset
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/select.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/select.php
new file mode 100644 (file)
index 0000000..c6ada54
--- /dev/null
@@ -0,0 +1,614 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Class to dynamically create an HTML SELECT
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for form elements
+ */ 
+require_once 'HTML/QuickForm/element.php';
+
+/**
+ * Class to dynamically create an HTML SELECT
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_select extends HTML_QuickForm_element {
+    
+    // {{{ properties
+
+    /**
+     * Contains the select options
+     *
+     * @var       array
+     * @since     1.0
+     * @access    private
+     */
+    var $_options = array();
+    
+    /**
+     * Default values of the SELECT
+     * 
+     * @var       string
+     * @since     1.0
+     * @access    private
+     */
+    var $_values = null;
+
+    // }}}
+    // {{{ constructor
+        
+    /**
+     * Class constructor
+     * 
+     * @param     string    Select name attribute
+     * @param     mixed     Label(s) for the select
+     * @param     mixed     Data to be used to populate options
+     * @param     mixed     Either a typical HTML attribute string or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_select($elementName=null, $elementLabel=null, $options=null, $attributes=null)
+    {
+        HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
+        $this->_persistantFreeze = true;
+        $this->_type = 'select';
+        if (isset($options)) {
+            $this->load($options);
+        }
+    } //end constructor
+    
+    // }}}
+    // {{{ apiVersion()
+
+    /**
+     * Returns the current API version 
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    double
+     */
+    function apiVersion()
+    {
+        return 2.3;
+    } //end func apiVersion
+
+    // }}}
+    // {{{ setSelected()
+
+    /**
+     * Sets the default values of the select box
+     * 
+     * @param     mixed    $values  Array or comma delimited string of selected values
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setSelected($values)
+    {
+        if (is_string($values) && $this->getMultiple()) {
+            $values = preg_split("/[ ]?,[ ]?/", $values);
+        }
+        if (is_array($values)) {
+            $this->_values = array_values($values);
+        } else {
+            $this->_values = array($values);
+        }
+    } //end func setSelected
+    
+    // }}}
+    // {{{ getSelected()
+
+    /**
+     * Returns an array of the selected values
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    array of selected values
+     */
+    function getSelected()
+    {
+        return $this->_values;
+    } // end func getSelected
+
+    // }}}
+    // {{{ setName()
+
+    /**
+     * Sets the input field name
+     * 
+     * @param     string    $name   Input field name attribute
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setName($name)
+    {
+        $this->updateAttributes(array('name' => $name));
+    } //end func setName
+    
+    // }}}
+    // {{{ getName()
+
+    /**
+     * Returns the element name
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getName()
+    {
+        return $this->getAttribute('name');
+    } //end func getName
+
+    // }}}
+    // {{{ getPrivateName()
+
+    /**
+     * Returns the element name (possibly with brackets appended)
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getPrivateName()
+    {
+        if ($this->getAttribute('multiple')) {
+            return $this->getName() . '[]';
+        } else {
+            return $this->getName();
+        }
+    } //end func getPrivateName
+
+    // }}}
+    // {{{ setValue()
+
+    /**
+     * Sets the value of the form element
+     *
+     * @param     mixed    $values  Array or comma delimited string of selected values
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setValue($value)
+    {
+        $this->setSelected($value);
+    } // end func setValue
+
+    // }}}
+    // {{{ getValue()
+
+    /**
+     * Returns an array of the selected values
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    array of selected values
+     */
+    function getValue()
+    {
+        return $this->_values;
+    } // end func getValue
+
+    // }}}
+    // {{{ setSize()
+
+    /**
+     * Sets the select field size, only applies to 'multiple' selects
+     * 
+     * @param     int    $size  Size of select  field
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setSize($size)
+    {
+        $this->updateAttributes(array('size' => $size));
+    } //end func setSize
+    
+    // }}}
+    // {{{ getSize()
+
+    /**
+     * Returns the select field size
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    int
+     */
+    function getSize()
+    {
+        return $this->getAttribute('size');
+    } //end func getSize
+
+    // }}}
+    // {{{ setMultiple()
+
+    /**
+     * Sets the select mutiple attribute
+     * 
+     * @param     bool    $multiple  Whether the select supports multi-selections
+     * @since     1.2
+     * @access    public
+     * @return    void
+     */
+    function setMultiple($multiple)
+    {
+        if ($multiple) {
+            $this->updateAttributes(array('multiple' => 'multiple'));
+        } else {
+            $this->removeAttribute('multiple');
+        }
+    } //end func setMultiple
+    
+    // }}}
+    // {{{ getMultiple()
+
+    /**
+     * Returns the select mutiple attribute
+     * 
+     * @since     1.2
+     * @access    public
+     * @return    bool    true if multiple select, false otherwise
+     */
+    function getMultiple()
+    {
+        return (bool)$this->getAttribute('multiple');
+    } //end func getMultiple
+
+    // }}}
+    // {{{ addOption()
+
+    /**
+     * Adds a new OPTION to the SELECT
+     *
+     * @param     string    $text       Display text for the OPTION
+     * @param     string    $value      Value for the OPTION
+     * @param     mixed     $attributes Either a typical HTML attribute string 
+     *                                  or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function addOption($text, $value, $attributes=null)
+    {
+        if (null === $attributes) {
+            $attributes = array('value' => (string)$value);
+        } else {
+            $attributes = $this->_parseAttributes($attributes);
+            if (isset($attributes['selected'])) {
+                // the 'selected' attribute will be set in toHtml()
+                $this->_removeAttr('selected', $attributes);
+                if (is_null($this->_values)) {
+                    $this->_values = array($value);
+                } elseif (!in_array($value, $this->_values)) {
+                    $this->_values[] = $value;
+                }
+            }
+            $this->_updateAttrArray($attributes, array('value' => (string)$value));
+        }
+        $this->_options[] = array('text' => $text, 'attr' => $attributes);
+    } // end func addOption
+    
+    // }}}
+    // {{{ loadArray()
+
+    /**
+     * Loads the options from an associative array
+     * 
+     * @param     array    $arr     Associative array of options
+     * @param     mixed    $values  (optional) Array or comma delimited string of selected values
+     * @since     1.0
+     * @access    public
+     * @return    PEAR_Error on error or true
+     * @throws    PEAR_Error
+     */
+    function loadArray($arr, $values=null)
+    {
+        if (!is_array($arr)) {
+            return PEAR::raiseError('Argument 1 of HTML_Select::loadArray is not a valid array');
+        }
+        if (isset($values)) {
+            $this->setSelected($values);
+        }
+        foreach ($arr as $key => $val) {
+            // Warning: new API since release 2.3
+            $this->addOption($val, $key);
+        }
+        return true;
+    } // end func loadArray
+
+    // }}}
+    // {{{ loadDbResult()
+
+    /**
+     * Loads the options from DB_result object
+     * 
+     * If no column names are specified the first two columns of the result are
+     * used as the text and value columns respectively
+     * @param     object    $result     DB_result object 
+     * @param     string    $textCol    (optional) Name of column to display as the OPTION text 
+     * @param     string    $valueCol   (optional) Name of column to use as the OPTION value 
+     * @param     mixed     $values     (optional) Array or comma delimited string of selected values
+     * @since     1.0
+     * @access    public
+     * @return    PEAR_Error on error or true
+     * @throws    PEAR_Error
+     */
+    function loadDbResult(&$result, $textCol=null, $valueCol=null, $values=null)
+    {
+        if (!is_object($result) || !is_a($result, 'db_result')) {
+            return PEAR::raiseError('Argument 1 of HTML_Select::loadDbResult is not a valid DB_result');
+        }
+        if (isset($values)) {
+            $this->setValue($values);
+        }
+        $fetchMode = ($textCol && $valueCol) ? DB_FETCHMODE_ASSOC : DB_FETCHMODE_ORDERED;
+        while (is_array($row = $result->fetchRow($fetchMode)) ) {
+            if ($fetchMode == DB_FETCHMODE_ASSOC) {
+                $this->addOption($row[$textCol], $row[$valueCol]);
+            } else {
+                $this->addOption($row[0], $row[1]);
+            }
+        }
+        return true;
+    } // end func loadDbResult
+    
+    // }}}
+    // {{{ loadQuery()
+
+    /**
+     * Queries a database and loads the options from the results
+     *
+     * @param     mixed     $conn       Either an existing DB connection or a valid dsn 
+     * @param     string    $sql        SQL query string
+     * @param     string    $textCol    (optional) Name of column to display as the OPTION text 
+     * @param     string    $valueCol   (optional) Name of column to use as the OPTION value 
+     * @param     mixed     $values     (optional) Array or comma delimited string of selected values
+     * @since     1.1
+     * @access    public
+     * @return    void
+     * @throws    PEAR_Error
+     */
+    function loadQuery(&$conn, $sql, $textCol=null, $valueCol=null, $values=null)
+    {
+        if (is_string($conn)) {
+            require_once('DB.php');
+            $dbConn = &DB::connect($conn, true);
+            if (DB::isError($dbConn)) {
+                return $dbConn;
+            }
+        } elseif (is_subclass_of($conn, "db_common")) {
+            $dbConn = &$conn;
+        } else {
+            return PEAR::raiseError('Argument 1 of HTML_Select::loadQuery is not a valid type');
+        }
+        $result = $dbConn->query($sql);
+        if (DB::isError($result)) {
+            return $result;
+        }
+        $this->loadDbResult($result, $textCol, $valueCol, $values);
+        $result->free();
+        if (is_string($conn)) {
+            $dbConn->disconnect();
+        }
+        return true;
+    } // end func loadQuery
+
+    // }}}
+    // {{{ load()
+
+    /**
+     * Loads options from different types of data sources
+     *
+     * This method is a simulated overloaded method.  The arguments, other than the
+     * first are optional and only mean something depending on the type of the first argument.
+     * If the first argument is an array then all arguments are passed in order to loadArray.
+     * If the first argument is a db_result then all arguments are passed in order to loadDbResult.
+     * If the first argument is a string or a DB connection then all arguments are 
+     * passed in order to loadQuery.
+     * @param     mixed     $options     Options source currently supports assoc array or DB_result
+     * @param     mixed     $param1     (optional) See function detail
+     * @param     mixed     $param2     (optional) See function detail
+     * @param     mixed     $param3     (optional) See function detail
+     * @param     mixed     $param4     (optional) See function detail
+     * @since     1.1
+     * @access    public
+     * @return    PEAR_Error on error or true
+     * @throws    PEAR_Error
+     */
+    function load(&$options, $param1=null, $param2=null, $param3=null, $param4=null)
+    {
+        switch (true) {
+            case is_array($options):
+                return $this->loadArray($options, $param1);
+                break;
+            case (is_a($options, 'db_result')):
+                return $this->loadDbResult($options, $param1, $param2, $param3);
+                break;
+            case (is_string($options) && !empty($options) || is_subclass_of($options, "db_common")):
+                return $this->loadQuery($options, $param1, $param2, $param3, $param4);
+                break;
+        }
+    } // end func load
+    
+    // }}}
+    // {{{ toHtml()
+
+    /**
+     * Returns the SELECT in HTML
+     *
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function toHtml()
+    {
+        if ($this->_flagFrozen) {
+            return $this->getFrozenHtml();
+        } else {
+            $tabs    = $this->_getTabs();
+            $strHtml = '';
+
+            if ($this->getComment() != '') {
+                $strHtml .= $tabs . '<!-- ' . $this->getComment() . " //-->\n";
+            }
+
+            if (!$this->getMultiple()) {
+                $attrString = $this->_getAttrString($this->_attributes);
+            } else {
+                $myName = $this->getName();
+                $this->setName($myName . '[]');
+                $attrString = $this->_getAttrString($this->_attributes);
+                $this->setName($myName);
+            }
+            $strHtml .= $tabs . '<select' . $attrString . ">\n";
+
+            $strValues = is_array($this->_values)? array_map('strval', $this->_values): array();
+            foreach ($this->_options as $option) {
+                if (!empty($strValues) && in_array($option['attr']['value'], $strValues, true)) {
+                    $option['attr']['selected'] = 'selected';
+                }
+                $strHtml .= $tabs . "\t<option" . $this->_getAttrString($option['attr']) . '>' .
+                            $option['text'] . "</option>\n";
+            }
+
+            return $strHtml . $tabs . '</select>';
+        }
+    } //end func toHtml
+    
+    // }}}
+    // {{{ getFrozenHtml()
+
+    /**
+     * Returns the value of field without HTML tags
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getFrozenHtml()
+    {
+        $value = array();
+        if (is_array($this->_values)) {
+            foreach ($this->_values as $key => $val) {
+                for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) {
+                    if (0 == strcmp($val, $this->_options[$i]['attr']['value'])) {
+                        $value[$key] = $this->_options[$i]['text'];
+                        break;
+                    }
+                }
+            }
+        }
+        $html = empty($value)? '&nbsp;': join('<br />', $value);
+        if ($this->_persistantFreeze) {
+            $name = $this->getPrivateName();
+            // Only use id attribute if doing single hidden input
+            if (1 == count($value)) {
+                $id     = $this->getAttribute('id');
+                $idAttr = isset($id)? array('id' => $id): array();
+            } else {
+                $idAttr = array();
+            }
+            foreach ($value as $key => $item) {
+                $html .= '<input' . $this->_getAttrString(array(
+                             'type'  => 'hidden',
+                             'name'  => $name,
+                             'value' => $this->_values[$key]
+                         ) + $idAttr) . ' />';
+            }
+        }
+        return $html;
+    } //end func getFrozenHtml
+
+    // }}}
+    // {{{ exportValue()
+
+   /**
+    * We check the options and return only the values that _could_ have been
+    * selected. We also return a scalar value if select is not "multiple"
+    */
+    function exportValue(&$submitValues, $assoc = false)
+    {
+        $value = $this->_findValue($submitValues);
+        if (is_null($value)) {
+            $value = $this->getValue();
+        } elseif(!is_array($value)) {
+            $value = array($value);
+        }
+        if (is_array($value) && !empty($this->_options)) {
+            $cleanValue = null;
+            foreach ($value as $v) {
+                for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) {
+                    if (0 == strcmp($v, $this->_options[$i]['attr']['value'])) {
+                        $cleanValue[] = $v;
+                        break;
+                    }
+                }
+            }
+        } else {
+            $cleanValue = $value;
+        }
+        if (is_array($cleanValue) && !$this->getMultiple()) {
+            return $this->_prepareValue($cleanValue[0], $assoc);
+        } else {
+            return $this->_prepareValue($cleanValue, $assoc);
+        }
+    }
+    
+    // }}}
+    // {{{ onQuickFormEvent()
+
+    function onQuickFormEvent($event, $arg, &$caller)
+    {
+        if ('updateValue' == $event) {
+            $value = $this->_findValue($caller->_constantValues);
+            if (null === $value) {
+                $value = $this->_findValue($caller->_submitValues);
+                // Fix for bug #4465 & #5269
+                // XXX: should we push this to element::onQuickFormEvent()?
+                if (null === $value && (!$caller->isSubmitted() || !$this->getMultiple())) {
+                    $value = $this->_findValue($caller->_defaultValues);
+                }
+            }
+            if (null !== $value) {
+                $this->setValue($value);
+            }
+            return true;
+        } else {
+            return parent::onQuickFormEvent($event, $arg, $caller);
+        }
+    }
+
+    // }}}
+} //end class HTML_QuickForm_select
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/static.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/static.php
new file mode 100644 (file)
index 0000000..acff7c3
--- /dev/null
@@ -0,0 +1,201 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for static data
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Wojciech Gdela <eltehaem@poczta.onet.pl>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for form elements
+ */ 
+require_once 'HTML/QuickForm/element.php';
+
+/**
+ * HTML class for static data
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Wojciech Gdela <eltehaem@poczta.onet.pl>
+ * @version     Release: 3.2.16
+ * @since       2.7
+ */
+class HTML_QuickForm_static extends HTML_QuickForm_element {
+    
+    // {{{ properties
+
+    /**
+     * Display text
+     * @var       string
+     * @access    private
+     */
+    var $_text = null;
+
+    // }}}
+    // {{{ constructor
+    
+    /**
+     * Class constructor
+     * 
+     * @param     string    $elementLabel   (optional)Label
+     * @param     string    $text           (optional)Display text
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_static($elementName=null, $elementLabel=null, $text=null)
+    {
+        HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel);
+        $this->_persistantFreeze = false;
+        $this->_type = 'static';
+        $this->_text = $text;
+    } //end constructor
+    
+    // }}}
+    // {{{ setName()
+
+    /**
+     * Sets the element name
+     * 
+     * @param     string    $name   Element name
+     * @access    public
+     * @return    void
+     */
+    function setName($name)
+    {
+        $this->updateAttributes(array('name'=>$name));
+    } //end func setName
+    
+    // }}}
+    // {{{ getName()
+
+    /**
+     * Returns the element name
+     * 
+     * @access    public
+     * @return    string
+     */
+    function getName()
+    {
+        return $this->getAttribute('name');
+    } //end func getName
+
+    // }}}
+    // {{{ setText()
+
+    /**
+     * Sets the text
+     *
+     * @param     string    $text
+     * @access    public
+     * @return    void
+     */
+    function setText($text)
+    {
+        $this->_text = $text;
+    } // end func setText
+
+    // }}}
+    // {{{ setValue()
+
+    /**
+     * Sets the text (uses the standard setValue call to emulate a form element.
+     *
+     * @param     string    $text
+     * @access    public
+     * @return    void
+     */
+    function setValue($text)
+    {
+        $this->setText($text);
+    } // end func setValue
+
+    // }}}    
+    // {{{ toHtml()
+
+    /**
+     * Returns the static text element in HTML
+     * 
+     * @access    public
+     * @return    string
+     */
+    function toHtml()
+    {
+        return $this->_getTabs() . $this->_text;
+    } //end func toHtml
+    
+    // }}}
+    // {{{ getFrozenHtml()
+
+    /**
+     * Returns the value of field without HTML tags
+     * 
+     * @access    public
+     * @return    string
+     */
+    function getFrozenHtml()
+    {
+        return $this->toHtml();
+    } //end func getFrozenHtml
+
+    // }}}
+    // {{{ onQuickFormEvent()
+
+    /**
+     * Called by HTML_QuickForm whenever form event is made on this element
+     *
+     * @param     string    $event  Name of event
+     * @param     mixed     $arg    event arguments
+     * @param     object    &$caller calling object
+     * @since     1.0
+     * @access    public
+     * @return    void
+     * @throws    
+     */
+    function onQuickFormEvent($event, $arg, &$caller)
+    {
+        switch ($event) {
+            case 'updateValue':
+                // do NOT use submitted values for static elements
+                $value = $this->_findValue($caller->_constantValues);
+                if (null === $value) {
+                    $value = $this->_findValue($caller->_defaultValues);
+                }
+                if (null !== $value) {
+                    $this->setValue($value);
+                }
+                break;
+            default:
+                parent::onQuickFormEvent($event, $arg, $caller);
+        }
+        return true;
+    } // end func onQuickFormEvent
+
+    // }}}
+    // {{{ exportValue()
+
+   /**
+    * We override this here because we don't want any values from static elements
+    */
+    function exportValue(&$submitValues, $assoc = false)
+    {
+        return null;
+    }
+    
+    // }}}
+} //end class HTML_QuickForm_static
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/submit.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/submit.php
new file mode 100644 (file)
index 0000000..cd39475
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for a submit type element
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for <input /> form elements
+ */
+require_once 'HTML/QuickForm/input.php';
+
+/**
+ * HTML class for a submit type element
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_submit extends HTML_QuickForm_input
+{
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * 
+     * @param     string    Input field name attribute
+     * @param     string    Input field value
+     * @param     mixed     Either a typical HTML attribute string or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_submit($elementName=null, $value=null, $attributes=null)
+    {
+        HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes);
+        $this->setValue($value);
+        $this->setType('submit');
+    } //end constructor
+    
+    // }}}
+    // {{{ freeze()
+
+    /**
+     * Freeze the element so that only its value is returned
+     * 
+     * @access    public
+     * @return    void
+     */
+    function freeze()
+    {
+        return false;
+    } //end func freeze
+
+    // }}}
+    // {{{ exportValue()
+
+   /**
+    * Only return the value if it is found within $submitValues (i.e. if
+    * this particular submit button was clicked)
+    */
+    function exportValue(&$submitValues, $assoc = false)
+    {
+        return $this->_prepareValue($this->_findValue($submitValues), $assoc);
+    }
+
+    // }}}
+} //end class HTML_QuickForm_submit
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/text.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/text.php
new file mode 100644 (file)
index 0000000..76b9849
--- /dev/null
@@ -0,0 +1,98 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for a text field
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for <input /> form elements
+ */
+require_once 'HTML/QuickForm/input.php';
+
+/**
+ * HTML class for a text field
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_text extends HTML_QuickForm_input
+{
+                
+    // {{{ constructor
+
+    /**
+     * Class constructor
+     * 
+     * @param     string    $elementName    (optional)Input field name attribute
+     * @param     string    $elementLabel   (optional)Input field label
+     * @param     mixed     $attributes     (optional)Either a typical HTML attribute string 
+     *                                      or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_text($elementName=null, $elementLabel=null, $attributes=null)
+    {
+        HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
+        $this->_persistantFreeze = true;
+        $this->setType('text');
+    } //end constructor
+        
+    // }}}
+    // {{{ setSize()
+
+    /**
+     * Sets size of text field
+     * 
+     * @param     string    $size  Size of text field
+     * @since     1.3
+     * @access    public
+     * @return    void
+     */
+    function setSize($size)
+    {
+        $this->updateAttributes(array('size'=>$size));
+    } //end func setSize
+
+    // }}}
+    // {{{ setMaxlength()
+
+    /**
+     * Sets maxlength of text field
+     * 
+     * @param     string    $maxlength  Maximum length of text field
+     * @since     1.3
+     * @access    public
+     * @return    void
+     */
+    function setMaxlength($maxlength)
+    {
+        $this->updateAttributes(array('maxlength'=>$maxlength));
+    } //end func setMaxlength
+
+    // }}}
+    
+} //end class HTML_QuickForm_text
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/textarea.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/textarea.php
new file mode 100644 (file)
index 0000000..492c270
--- /dev/null
@@ -0,0 +1,229 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * HTML class for a textarea type field
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for form elements
+ */ 
+require_once 'HTML/QuickForm/element.php';
+
+/**
+ * HTML class for a textarea type field
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Adam Daniel <adaniel1@eesus.jnj.com>
+ * @author      Bertrand Mansion <bmansion@mamasam.com>
+ * @version     Release: 3.2.16
+ * @since       1.0
+ */
+class HTML_QuickForm_textarea extends HTML_QuickForm_element
+{
+    // {{{ properties
+
+    /**
+     * Field value
+     * @var       string
+     * @since     1.0
+     * @access    private
+     */
+    var $_value = null;
+
+    // }}}
+    // {{{ constructor
+        
+    /**
+     * Class constructor
+     * 
+     * @param     string    Input field name attribute
+     * @param     mixed     Label(s) for a field
+     * @param     mixed     Either a typical HTML attribute string or an associative array
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function HTML_QuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null)
+    {
+        HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
+        $this->_persistantFreeze = true;
+        $this->_type = 'textarea';
+    } //end constructor
+    
+    // }}}
+    // {{{ setName()
+
+    /**
+     * Sets the input field name
+     * 
+     * @param     string    $name   Input field name attribute
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setName($name)
+    {
+        $this->updateAttributes(array('name'=>$name));
+    } //end func setName
+    
+    // }}}
+    // {{{ getName()
+
+    /**
+     * Returns the element name
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getName()
+    {
+        return $this->getAttribute('name');
+    } //end func getName
+
+    // }}}
+    // {{{ setValue()
+
+    /**
+     * Sets value for textarea element
+     * 
+     * @param     string    $value  Value for textarea element
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setValue($value)
+    {
+        $this->_value = $value;
+    } //end func setValue
+    
+    // }}}
+    // {{{ getValue()
+
+    /**
+     * Returns the value of the form element
+     *
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getValue()
+    {
+        return $this->_value;
+    } // end func getValue
+
+    // }}}
+    // {{{ setWrap()
+
+    /**
+     * Sets wrap type for textarea element
+     * 
+     * @param     string    $wrap  Wrap type
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setWrap($wrap)
+    {
+        $this->updateAttributes(array('wrap' => $wrap));
+    } //end func setWrap
+    
+    // }}}
+    // {{{ setRows()
+
+    /**
+     * Sets height in rows for textarea element
+     * 
+     * @param     string    $rows  Height expressed in rows
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */
+    function setRows($rows)
+    {
+        $this->updateAttributes(array('rows' => $rows));
+    } //end func setRows
+
+    // }}}
+    // {{{ setCols()
+
+    /**
+     * Sets width in cols for textarea element
+     * 
+     * @param     string    $cols  Width expressed in cols
+     * @since     1.0
+     * @access    public
+     * @return    void
+     */ 
+    function setCols($cols)
+    {
+        $this->updateAttributes(array('cols' => $cols));
+    } //end func setCols
+
+    // }}}
+    // {{{ toHtml()
+
+    /**
+     * Returns the textarea element in HTML
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function toHtml()
+    {
+        if ($this->_flagFrozen) {
+            return $this->getFrozenHtml();
+        } else {
+            return $this->_getTabs() .
+                   '<textarea' . $this->_getAttrString($this->_attributes) . '>' .
+                   // because we wrap the form later we don't want the text indented
+                   preg_replace("/(\r\n|\n|\r)/", '&#010;', htmlspecialchars($this->_value)) .
+                   '</textarea>';
+        }
+    } //end func toHtml
+    
+    // }}}
+    // {{{ getFrozenHtml()
+
+    /**
+     * Returns the value of field without HTML tags (in this case, value is changed to a mask)
+     * 
+     * @since     1.0
+     * @access    public
+     * @return    string
+     */
+    function getFrozenHtml()
+    {
+        $value = htmlspecialchars($this->getValue());
+        if ($this->getAttribute('wrap') == 'off') {
+            $html = $this->_getTabs() . '<pre>' . $value."</pre>\n";
+        } else {
+            $html = nl2br($value)."\n";
+        }
+        return $html . $this->_getPersistantData();
+    } //end func getFrozenHtml
+
+    // }}}
+
+} //end class HTML_QuickForm_textarea
+?>
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/utils.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/utils.php
new file mode 100644 (file)
index 0000000..3b60679
--- /dev/null
@@ -0,0 +1,159 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * utility functions
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Chuck Burgess <ashnazg@php.net>
+ * @copyright   2001-2018 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Provides a collection of static methods for array manipulation.
+ *
+ * (courtesy of CiviCRM project (https://civicrm.org/)
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Chuck Burgess <ashnazg@php.net>
+ * @version     Release: 3.2.16
+ * @since       3.2
+ */
+class HTML_QuickForm_utils
+{
+    /**
+     * Get a single value from an array-tree.
+     *
+     * @param   array     $values   Ex: ['foo' => ['bar' => 123]].
+     * @param   array     $path     Ex: ['foo', 'bar'].
+     * @param   mixed     $default
+     * @return  mixed               Ex 123.
+     *
+     * @access  public
+     * @static
+     */
+    function pathGet($values, $path, $default = NULL) {
+        foreach ($path as $key) {
+            if (!is_array($values) || !isset($values[$key])) {
+                return $default;
+            }
+            $values = $values[$key];
+        }
+        return $values;
+    }
+
+    /**
+     * Check if a key isset which may be several layers deep.
+     *
+     * This is a helper for when the calling function does not know how many layers deep
+     * the path array is so cannot easily check.
+     *
+     * @param   array $values
+     * @param   array $path
+     * @return  bool
+     *
+     * @access  public
+     * @static
+     */
+    function pathIsset($values, $path) {
+        foreach ($path as $key) {
+            if (!is_array($values) || !isset($values[$key])) {
+                return FALSE;
+            }
+            $values = $values[$key];
+        }
+        return TRUE;
+    }
+
+    /**
+     * Set a single value in an array tree.
+     *
+     * @param   array   $values     Ex: ['foo' => ['bar' => 123]].
+     * @param   array   $pathParts  Ex: ['foo', 'bar'].
+     * @param   mixed   $value      Ex: 456.
+     * @return  void
+     *
+     * @access  public
+     * @static
+     */
+    function pathSet(&$values, $pathParts, $value) {
+        $r = &$values;
+        $last = array_pop($pathParts);
+        foreach ($pathParts as $part) {
+            if (!isset($r[$part])) {
+                $r[$part] = array();
+            }
+            $r = &$r[$part];
+        }
+        $r[$last] = $value;
+    }
+
+    /**
+     * Check if a key isset which may be several layers deep.
+     *
+     * This is a helper for when the calling function does not know how many layers deep the
+     * path array is so cannot easily check.
+     *
+     * @param   array $array
+     * @param   array $path
+     * @return  bool
+     *
+     * @access  public
+     * @static
+     */
+    function recursiveIsset($array, $path) {
+        return self::pathIsset($array, $path);
+    }
+
+    /**
+     * Check if a key isset which may be several layers deep.
+     *
+     * This is a helper for when the calling function does not know how many layers deep the
+     * path array is so cannot easily check.
+     *
+     * @param   array   $array
+     * @param   array   $path       An array of keys,
+     *                              e.g [0, 'bob', 8] where we want to check if $array[0]['bob'][8]
+     * @param   mixed   $default    Value to return if not found.
+     * @return  bool
+     *
+     * @access  public
+     * @static
+     */
+    function recursiveValue($array, $path, $default = NULL) {
+        return self::pathGet($array, $path, $default);
+    }
+
+    /**
+     * Append the value to the array using the key provided.
+     *
+     * e.g if value is 'llama' & path is [0, 'email', 'location'] result will be
+     * [0 => ['email' => ['location' => 'llama']]
+     *
+     * @param           $path
+     * @param           $value
+     * @param   array   $source
+     * @return  array
+     *
+     * @access  public
+     * @static
+     */
+    function recursiveBuild($path, $value, $source = array()) {
+        self::pathSet($source, $path, $value);
+        return $source;
+    }
+}
+?>
\ No newline at end of file
diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/xbutton.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/xbutton.php
new file mode 100644 (file)
index 0000000..0737e39
--- /dev/null
@@ -0,0 +1,153 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Class for HTML 4.0 <button> element
+ * 
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_01.txt If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2001-2011 The PHP Group
+ * @license     http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTML_QuickForm
+ */
+
+/**
+ * Base class for form elements
+ */ 
+require_once 'HTML/QuickForm/element.php';
+
+/**
+ * Class for HTML 4.0 <button> element
+ * 
+ * @category    HTML
+ * @package     HTML_QuickForm
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 3.2.16
+ * @since       3.2.3
+ */
+class HTML_QuickForm_xbutton extends HTML_QuickForm_element
+{
+   /**
+    * Contents of the <button> tag
+    * @var      string
+    * @access   private
+    */
+    var $_content; 
+
+   /**
+    * Class constructor
+    * 
+    * @param    string  Button name
+    * @param    string  Button content (HTML to add between <button></button> tags)
+    * @param    mixed   Either a typical HTML attribute string or an associative array
+    * @access   public
+    */
+    function HTML_QuickForm_xbutton($elementName = null, $elementContent = null, $attributes = null)
+    {
+        $this->HTML_QuickForm_element($elementName, null, $attributes);
+        $this->setContent($elementContent);
+        $this->setPersistantFreeze(false);
+        $this->_type = 'xbutton';
+    }
+
+
+    function toHtml()
+    {
+        return '<button' . $this->getAttributes(true) . '>' . $this->_content . '</button>';
+    }
+
+
+    function getFrozenHtml()
+    {
+        return $this->toHtml();
+    }
+
+
+    function freeze()
+    {
+        return false;
+    }
+
+
+    function setName($name)
+    {
+        $this->updateAttributes(array(
+            'name' => $name 
+        ));
+    }
+
+
+    function getName()
+    {
+        return $this->getAttribute('name');
+    }
+
+
+    function setValue($value)
+    {
+        $this->updateAttributes(array(
+            'value' => $value
+        ));
+    }
+
+
+    function getValue()
+    {
+        return $this->getAttribute('value');
+    }
+
+
+   /**
+    * Sets the contents of the button element
+    *
+    * @param    string  Button content (HTML to add between <button></button> tags)
+    */
+    function setContent($content)
+    {
+        $this->_content = $content;
+    }
+
+
+    function onQuickFormEvent($event, $arg, &$caller)
+    {
+        if ('updateValue' != $event) {
+            return parent::onQuickFormEvent($event, $arg, $caller);
+        } else {
+            $value = $this->_findValue($caller->_constantValues);
+            if (null === $value) {
+                $value = $this->_findValue($caller->_defaultValues);
+            }
+            if (null !== $value) {
+                $this->setValue($value);
+            }
+        }
+        return true;
+    }
+
+
+   /**
+    * Returns a 'safe' element's value
+    * 
+    * The value is only returned if the button's type is "submit" and if this
+    * particlular button was clicked
+    */
+    function exportValue(&$submitValues, $assoc = false)
+    {
+        if ('submit' == $this->getAttribute('type')) {
+            return $this->_prepareValue($this->_findValue($submitValues), $assoc);
+        } else {
+            return null;
+        }
+    }
+}
+?>
diff --git a/cookbooks/dmca/files/default/html/favicon.ico b/cookbooks/dmca/files/default/html/favicon.ico
new file mode 100644 (file)
index 0000000..27b042b
Binary files /dev/null and b/cookbooks/dmca/files/default/html/favicon.ico differ
diff --git a/cookbooks/dmca/files/default/html/index.php b/cookbooks/dmca/files/default/html/index.php
new file mode 100644 (file)
index 0000000..6e6aa97
--- /dev/null
@@ -0,0 +1,113 @@
+<?php
+session_start();
+require_once 'HTML/QuickForm.php';
+require_once 'HTML/QuickForm/DHTMLRulesTableless.php';
+require_once 'HTML/QuickForm/Renderer/Tableless.php';
+
+function process_data ($values) {
+        echo '<h1>Thank you</h1>';
+        echo 'Your report has been submitted';
+        $email_body = 'OpenStreetMap - Claim of Copyright Infringement form:'."\n\n";
+        $email_body .= 'Automated Email - Form Posted.'."\n\n";
+        $email_body .= print_r($values, true);
+        mail('dmca@osmfoundation.org','OSM Claim of Copyright Infringement', $email_body, 'From: OSMF Copyright Form <dmca@osmfoundation.org>', '-fdmca@osmfoundation.org');
+}
+?>
+<!DOCTYPE html>
+<html>
+<head>
+<title>OpenStreetMap Legal - Claim of Copyright Infringement</title>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
+ <link rel="stylesheet" type="text/css" href="/style.css" />
+</head>
+<body>
+<div class="regForm">
+<?php
+// Instantiate the HTML_QuickForm object
+$form = new HTML_QuickForm_DHTMLRulesTableless('osm_legal_claim_of_copyright');
+$renderer = new HTML_QuickForm_Renderer_Tableless();
+
+$form->addElement('header', null, 'OpenStreetMap: Claim of Copyright Infringement');
+
+$form->addElement('static', null, '<p>To file a copyright infringement notification with us, you will need to send a written communication that includes the following (please consult your legal counsel or see Section 512(c)(3) of the Digital Millennium Copyright Act to confirm these requirements):</p>
+<ul><li> A physical or electronic signature of a person authorized to act on behalf of the owner of an exclusive right that is allegedly infringed.
+<li>Identification of the copyrighted work claimed to have been infringed or, if multiple copyrighted works at a single online site are covered by a single notification, a representative list of such works at that site.
+<li>Identification of the material that is claimed to be infringing or to be the subject of infringing activity and that is to be removed or access to which is to be disabled, and information reasonably sufficient to permit the service provider to locate the material. Providing URLs in the body of an email is the best way to help us locate content quickly.
+<li>Information reasonably sufficient to permit the service provider to contact the complaining party, such as an address, telephone number, and, if available, an electronic mail address at which the complaining party may be contacted.
+<li>A statement that the complaining party has a good faith belief that use of the material in the manner complained of is not authorized by the copyright owner, its agent, or the law.
+<li>A statement that the information in the notification is accurate and, under penalty of perjury, that the complaining party is authorized to act on behalf of the owner of an exclusive right that is allegedly infringed.
+</ul><p>To expedite our ability to process your request, such written notice should be sent to our designated agent via our online copyright complaint form below.</p>
+<p>This form is only for cases where you believe that material on OpenStreetMap\'s websites or in its geodata database infringes your copyright or that of your clients. For example, you claim someone has copied material from a map belonging to you. If you have come here for another reason, <a href="http://www.osmfoundation.org/wiki/License/Takedown_procedure/When_To_Use_The_Form">Go here</a>.</p>');
+
+$form->addElement('text', 'url',                'URL of Allegedly Infringing Material', array('size' => 50, 'maxlength' => 255));
+$form->addRule('url', 'Please enter URL of Allegedly Infringing Material', 'required', null, 'client');
+
+$form->addElement('textarea', 'work',           'Describe the work allegedly infringed. For example, which map has been copied and what specifically has been copied.',  array('rows' => 20, 'cols' => 70));
+$form->addRule('work', 'Please describe the work allegedly infringed', 'required', null, 'client');
+
+$form->addElement('text', 'territory',          'Territories where infringement occurred', array('size' => 50, 'maxlength' => 255));
+$form->addRule('territory', 'Please enter the territories where infringement occurred', 'required', null, 'client');
+
+$form->addElement('text', 'name_first',         'First Name', array('size' => 50, 'maxlength' => 255));
+$form->addRule('name_first', 'Please enter your First Name', 'required', null, 'client');
+
+$form->addElement('text', 'name_last',          'Last Name', array('size' => 50, 'maxlength' => 255));
+$form->addRule('name_last', 'Please enter your Last Name', 'required', null, 'client');
+
+
+$form->addElement('text', 'company',            'Company Name', array('size' => 50, 'maxlength' => 255));
+$form->addElement('text', 'company_tile',       'Title/Position');
+
+$form->addElement('text', 'address',            'Street Address');
+$form->addRule('address', 'Please enter Street Address', 'required', null, 'client');
+
+$form->addElement('text', 'city',               'City', array('size' => 50, 'maxlength' => 255));
+$form->addRule('city', 'Please enter City', 'required', null, 'client');
+
+$form->addElement('text', 'state',              'State/Province', array('size' => 50, 'maxlength' => 255));
+$form->addElement('text', 'postal_code',        'Zip/Postal Code', array('size' => 50, 'maxlength' => 255));
+
+$form->addElement('text', 'country',            'Country', array('size' => 50, 'maxlength' => 255));
+$form->addRule('country', 'Please enter Country', 'required', null, 'client');
+
+$form->addElement('text', 'phone_number',       'Phone Number', array('size' => 50, 'maxlength' => 255));
+$form->addRule('phone_number', 'Please enter Phone Number', 'required', null, 'client');
+
+$form->addElement('text', 'mobile_number',      'Mobile Number', array('size' => 50, 'maxlength' => 255));
+
+$form->addElement('text', 'email',              'Email Address', array('size' => 50, 'maxlength' => 255));
+$form->addRule('email', 'Please enter Email Address', 'required', null, 'client');
+$form->addRule('email', 'Please enter a valid Email Address', 'email', null, 'client');
+
+$form->addElement('text', 'fax',                'Fax', array('size' => 50, 'maxlength' => 255));
+
+$complaint_options = array();
+$complaint_options[] = &HTML_QuickForm::createElement('checkbox', '1_of_4_owner_or_authorised', null, 'I am the owner, or an agent authorized to act on behalf of the owner, of an exclusive right that is allegedly infringed.');
+$complaint_options[] = &HTML_QuickForm::createElement('checkbox', '2_of_4_good_faith', null, 'I have a good faith belief that the use of the material in the manner complained of is not authorized by the copyright owner, its agent, or the law; and');
+$complaint_options[] = &HTML_QuickForm::createElement('checkbox', '3_of_4_accurate', null, 'This notification is accurate.');
+$complaint_options[] = &HTML_QuickForm::createElement('checkbox', '4_of_4_not_misrepresent', null, 'I acknowledge that under Section 512(f) any person who knowingly materially misrepresents that material or activity is infringing may be subject to liability for damages.');
+
+$form->addGroup($complaint_options, 'complaint_confirm', 'By checking the following boxes, I state UNDER PENALTY OF PERJURY that (choose all of the options)', '<br />');
+
+$form->addElement('text', 'signature', 'Typing your full name in this box will act as your digital signature.', array('size' => 25, 'maxlength' => 255));
+$form->addRule('signature', 'Field is required', 'required', null, 'client');
+
+$form->addElement('submit', null, 'Send');
+
+$form->removeAttribute('name');
+$form->getValidationScript();
+
+if ($form->validate()) {
+    // Do some stuff
+      $form->freeze();
+      $form->process('process_data', false);
+
+} else {
+        // Output the form
+        $form->accept($renderer);
+        echo $renderer->toHtml();
+}
+?>
+</div>
+</body>
+</html>
diff --git a/cookbooks/dmca/files/default/html/robots.txt b/cookbooks/dmca/files/default/html/robots.txt
new file mode 100644 (file)
index 0000000..1f53798
--- /dev/null
@@ -0,0 +1,2 @@
+User-agent: *
+Disallow: /
diff --git a/cookbooks/dmca/files/default/html/style.css b/cookbooks/dmca/files/default/html/style.css
new file mode 100644 (file)
index 0000000..d3efdb4
--- /dev/null
@@ -0,0 +1,226 @@
+/* Forms
+-----------------------------------------------------------------------------*/
+
+.regForm {
+       padding: 0;
+       margin: 0;
+       max-width: 730px;
+}
+
+.regForm fieldset {
+       padding: 15px;
+       border: 1px solid #747577;
+       margin-top: 20px;
+}
+
+.regForm legend {
+       padding: 0px 10px 0px 5px;
+       font-size: 1.1em;
+       color: #000000;
+}
+
+#regFormHeader {
+       border-style: none;
+       padding: 0px;
+       margin: 10px 0px 2px 0px;
+       font-size: 1.2em;
+}
+
+#regFormSubHeader {
+       font-size: 1em;
+       padding: 0px;
+       margin: 0px 0px 2px 0px;
+       border: none;
+}
+
+.regForm fieldset .inputbox {
+       padding:0!important;
+       padding-top:0!important;
+       padding-bottom:0!important;
+}
+
+.regForm input {
+       color: #747577;
+       padding: 6px;
+       margin-bottom: 0px;
+       margin-top: 0px;
+
+       -webkit-border-radius:5px;
+       -moz-border-radius:5px;
+       border-radius: 5px;
+       border:1px solid #ccc;
+       -webkit-box-shadow: 0 2px 4px rgba(0,0,0,0.5);
+       -moz-box-shadow: 0 2px 4px rgba(0,0,0,0.5);
+       box-sizing: border-box;
+       -moz-box-sizing: border-box;
+       -webkit-box-sizing: border-box;
+}
+
+.regForm textarea {
+       color: #747577;
+       padding: 6px;
+       margin-bottom: 5px;
+
+       -webkit-border-radius:5px;
+       -moz-border-radius:5px;
+       border-radius: 5px;
+       border:1px solid #ccc;
+       -webkit-box-shadow: 0 2px 4px rgba(0,0,0,0.5);
+       -moz-box-shadow: 0 2px 4px rgba(0,0,0,0.5);
+       box-sizing: border-box;
+       -moz-box-sizing: border-box;
+       -webkit-box-sizing: border-box;
+}
+
+.regForm select {
+       color: #747577;
+       padding: 6px;
+       margin-bottom: 5px;
+
+       -webkit-border-radius:5px;
+       -moz-border-radius:5px;
+       border-radius: 5px;
+       border:1px solid #ccc;
+       -webkit-box-shadow: 0 2px 4px rgba(0,0,0,0.5);
+       -moz-box-shadow: 0 2px 4px rgba(0,0,0,0.5);
+       box-sizing: border-box;
+       -moz-box-sizing: border-box;
+       -webkit-box-sizing: border-box;
+}
+
+.regForm button {
+       padding: 0px 5px 0px 0px;
+}
+
+.regForm ol > li {
+       list-style: none;
+       background-image: none;
+       padding: 3px 0px 5px 0px;
+       border-top: 1px solid #f0f0f0;
+       color: #747577;
+}
+
+.regForm li.formList-top {
+       border-top: none;
+       font-size: .8em;
+       padding: 10px 0px;
+}
+
+.regForm li.formList {
+       font-size: .8em;
+       padding: 10px 0px;
+}
+
+.regForm li.opt {
+       border-top: 0;
+       display: none;
+}
+
+.elementItem {
+       padding: 0;
+       display: block;
+       clear: left;
+       border-style: none;
+}
+
+.elementItemGroup {
+       padding: 0;
+       margin: 0;
+       display: block;
+       border-top: 2px solid #C0C0C0;
+}
+
+li.elementItemEnd {
+       padding: 0;
+       display: block;
+       clear: left;
+       border-style: none;
+}
+
+.elementGroup {
+       padding: 0;
+}
+
+.elementGroup ul {
+       float: left;
+       margin-left: 0px;
+       margin-top: 0px;
+       padding: 0;
+}
+
+.elementGroup li {
+       margin: 0;
+       margin-left: 0px;
+       margin-top: 2px;
+       margin-right: 5px;
+       padding: 2px 2px 2px 0px;
+       border-style: none;
+       min-width: 255px;
+       list-style: none;
+}
+
+.elementGroupEnd {
+       border-style: none;
+       margin: 0;
+       padding: 0;
+       height: 1px;
+}
+
+.regForm ol {
+       margin: 0px;
+       padding: 0px;
+}
+
+.regForm p {
+       font-size: 1.2em;
+}
+
+.regForm .error {
+       color: #ff0000;
+       font-weight: bold;
+}
+
+.regForm .required {
+       color: #ff0000;
+}
+
+.regForm label.element {
+       color: #000000;
+       padding: 0px 5px 2px 0px;
+       margin: 0px;
+}
+
+.regForm div.element {
+       color: #747577;
+       padding: 1px 0px 0px 0px;
+}
+
+.regForm div.element label {
+       padding: 0px 15px 0px 4px;
+}
+
+.regForm input[type="submit"] {
+/*     border: 1px solid #f0f0f0;*/
+       color: #747577;
+       margin: 10px 0px;
+}
+
+.regForm input[type="submit"]:hover {
+       color: #CCCCCC;
+       text-decoration: none;
+}
+
+.regForm option {
+       color: #747577;
+}
+
+.regForm .reqnote {
+       font-size: 90%;
+       color: #747577;
+       font-weight: bold;
+}
+
+.regForm input[type="radio"] {
+       border: 0;
+}
+
diff --git a/cookbooks/dmca/metadata.rb b/cookbooks/dmca/metadata.rb
new file mode 100644 (file)
index 0000000..819f94c
--- /dev/null
@@ -0,0 +1,9 @@
+name              "dmca"
+maintainer        "OpenStreetMap Administrators"
+maintainer_email  "admins@openstreetmap.org"
+license           "Apache-2.0"
+description       "Configure DMCA form"
+long_description  IO.read(File.join(File.dirname(__FILE__), "README.md"))
+version           "1.0.0"
+supports          "ubuntu"
+depends           "apache"
diff --git a/cookbooks/dmca/recipes/default.rb b/cookbooks/dmca/recipes/default.rb
new file mode 100644 (file)
index 0000000..b91fdc9
--- /dev/null
@@ -0,0 +1,49 @@
+#
+# Cookbook Name:: dmca
+# Recipe:: default
+#
+# Copyright 2018, OpenStreetMap Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include_recipe "apache"
+
+apache_module "php7.2"
+
+directory "/srv/dmca.openstreetmap.org" do
+  owner "root"
+  group "root"
+  mode 0o755
+end
+
+remote_directory "/srv/dmca.openstreetmap.org/html" do
+  source "html"
+  owner "root"
+  group "root"
+  mode 0o755
+  files_owner "root"
+  files_group "root"
+  files_mode 0o644
+end
+
+ssl_certificate "dmca.openstreetmap.org" do
+  domains ["dmca.openstreetmap.org", "dmca.osm.org"]
+  notifies :reload, "service[apache2]"
+end
+
+apache_site "dmca.openstreetmap.org" do
+  template "apache.erb"
+  directory "/srv/dmca.openstreetmap.org"
+  variables :aliases => ["dmca.osm.org"]
+end
diff --git a/cookbooks/dmca/templates/default/apache.erb b/cookbooks/dmca/templates/default/apache.erb
new file mode 100644 (file)
index 0000000..bf53e2d
--- /dev/null
@@ -0,0 +1,54 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+<VirtualHost *:80>
+  ServerName <%= @name %>
+<% @aliases.each do |alias_name| -%>
+  ServerAlias <%= alias_name %>
+<% end -%>
+  ServerAdmin webmaster@openstreetmap.org
+
+  CustomLog /var/log/apache2/<%= @name %>-access.log combined
+  ErrorLog /var/log/apache2/<%= @name %>-error.log
+
+  RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
+  RedirectPermanent / https://<%= @name %>/
+</VirtualHost>
+<% unless @aliases.empty? -%>
+
+<VirtualHost *:443>
+  ServerName <%= @aliases.first %>
+<% @aliases.drop(1).each do |alias_name| -%>
+  ServerAlias <%= alias_name %>
+<% end -%>
+  ServerAdmin webmaster@openstreetmap.org
+
+  SSLEngine on
+  SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem
+  SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key
+
+  CustomLog /var/log/apache2/<%= @name %>-access.log combined
+  ErrorLog /var/log/apache2/<%= @name %>-error.log
+
+  RedirectPermanent / https://<%= @name %>/
+</VirtualHost>
+<% end -%>
+
+<VirtualHost *:443>
+  ServerName <%= @name %>
+  ServerAdmin webmaster@openstreetmap.org
+
+  SSLEngine on
+  SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem
+  SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key
+
+  CustomLog /var/log/apache2/<%= @name %>-access.log combined
+  ErrorLog /var/log/apache2/<%= @name %>-error.log
+
+  DocumentRoot <%= @directory %>/html
+
+  Options -Indexes
+</VirtualHost>
+
+<Directory <%= @directory %>/html>
+  Require all granted
+</Directory>
index 65ab8342fd2f068cfb7bb7933627c021e3f45f1c..6b20f5181592f7c7213069fd129b086ca61f85bc 100644 (file)
@@ -33,23 +33,15 @@ group "ssl-cert" do
   append true
 end
 
-template "/tmp/exim.ssl.cnf" do
-  source "ssl.cnf.erb"
+openssl_x509_certificate "/etc/ssl/certs/exim.pem" do
+  key_file "/etc/ssl/private/exim.key"
   owner "root"
-  group "root"
-  mode 0o644
-  not_if do
-    File.exist?("/etc/ssl/certs/exim.pem") && File.exist?("/etc/ssl/private/exim.key")
-  end
-end
-
-execute "/etc/ssl/certs/exim.pem" do
-  command "openssl req -x509 -newkey rsa:2048 -keyout /etc/ssl/private/exim.key -out /etc/ssl/certs/exim.pem -days 3650 -nodes -config /tmp/exim.ssl.cnf"
-  user "root"
   group "ssl-cert"
-  not_if do
-    File.exist?("/etc/ssl/certs/exim.pem") && File.exist?("/etc/ssl/private/exim.key")
-  end
+  mode 0o640
+  org "OpenStreetMap"
+  email "postmaster@openstreetmap.org"
+  common_name node[:fqdn]
+  expire 3650
 end
 
 service "exim4" do
diff --git a/cookbooks/exim/templates/default/ssl.cnf.erb b/cookbooks/exim/templates/default/ssl.cnf.erb
deleted file mode 100644 (file)
index 406dcb9..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-[req]
-prompt = no
-distinguished_name = req_dn
-
-[req_dn]
-organizationName = OpenStreetMap
-commonName = <%= node[:fqdn] %>
-emailAddress = postmaster@openstreetmap.org
index cf41dcb486fef66c980e529646705d02b195ec33..fb94144165d8efe47c3b403e472996297154b485 100644 (file)
@@ -33,7 +33,7 @@ mediawiki_site "board.osmfoundation.org" do
   email_contact "webmaster@openstreetmap.org"
   email_sender "webmaster@openstreetmap.org"
   email_sender_name "OSMF Board Wiki"
-  private true
+  private_site true
   recaptcha_public_key "6LflIQATAAAAAMXyDWpba-FgipVzE-aGF4HIR59N"
   recaptcha_private_key passwords["board"]["recaptcha"]
 end
index cb2cca10524e774787df70fb8a728d6acc61397d..5df9442eee9fd4a9f75ff91e362fa20af214edaf 100644 (file)
@@ -33,7 +33,7 @@ mediawiki_site "dwg.osmfoundation.org" do
   email_contact "webmaster@openstreetmap.org"
   email_sender "webmaster@openstreetmap.org"
   email_sender_name "OSMF Board Wiki"
-  private true
+  private_site true
   recaptcha_public_key "6LflIQATAAAAAMXyDWpba-FgipVzE-aGF4HIR59N"
   recaptcha_private_key passwords["dwg"]["recaptcha"]
 end
index f270740826bb04025a5375fd62763c039f230154..2527e16224a13c5e5b720a1079145313f0518d39 100644 (file)
@@ -15,7 +15,7 @@ if node[:dmi] && node[:dmi][:system]
     default[:apt][:sources] |= ["management-component-pack"]
 
     case node[:dmi][:system][:product_name]
-    when "ProLiant DL360 G6", "ProLiant DL360 G7"
+    when "ProLiant DL360 G6", "ProLiant DL360 G7", "ProLiant SE326M1R2"
       default[:hardware][:sensors][:"power_meter-*"][:power][:power1] = { :ignore => true }
     end
   end
index 5dda7409a164d251458f0b63f5bc6e3dc43bfd99..f2af6c9863af0365a1ec0081777f1c670da4ba7c 100644 (file)
@@ -65,6 +65,18 @@ when "HP"
     supports :status => true, :restart => true
   end
 
+  if product.end_with?("Gen8", "Gen9")
+    package "hp-ams" do
+      action :install
+      notifies :restart, "service[hp-ams]"
+    end
+
+    service "hp-ams" do
+      action [:enable, :start]
+      supports :status => true, :restart => true
+    end
+  end
+
   units << "1"
 when "TYAN"
   units << "0"
@@ -81,21 +93,6 @@ when "IBM"
   units << "0"
 end
 
-# Remove legacy HP G4 support which breaks modern hp-health 10.4
-if manufacturer == "HP"
-  %w[/opt/hp/hp-health/bin/hpasmd /usr/lib/libhpasmintrfc.so.3.0 /usr/lib/libhpasmintrfc.so.3 /usr/lib/libhpasmintrfc.so].each do |filename|
-    file filename do
-      action :delete
-      manage_symlink_source false
-    end
-  end
-
-  directory "/opt/hp/hp-legacy" do
-    action :delete
-    recursive true
-  end
-end
-
 units.sort.uniq.each do |unit|
   if node[:lsb][:release].to_f >= 16.04
     service "serial-getty@ttyS#{unit}" do
@@ -358,16 +355,19 @@ disks = disks.map do |disk|
 
   if disk[:smart_device]
     controller = node[:hardware][:disk][:controllers][disk[:controller]]
-    device = controller[:device].sub("/dev/", "")
-    smart = disk[:smart_device]
-
-    if device.start_with?("cciss/") && smart =~ /^cciss,(\d+)$/
-      array = node[:hardware][:disk][:arrays][disk[:arrays].first]
-      munin = "cciss-3#{array[:wwn]}-#{Regexp.last_match(1)}"
-    elsif smart =~ /^.*,(\d+)$/
-      munin = "#{device}-#{Regexp.last_match(1)}"
-    elsif smart =~ %r{^.*,(\d+)/(\d+)$}
-      munin = "#{device}-#{Regexp.last_match(1)}:#{Regexp.last_match(2)}"
+
+    if controller && controller[:device]
+      device = controller[:device].sub("/dev/", "")
+      smart = disk[:smart_device]
+
+      if device.start_with?("cciss/") && smart =~ /^cciss,(\d+)$/
+        array = node[:hardware][:disk][:arrays][disk[:arrays].first]
+        munin = "cciss-3#{array[:wwn]}-#{Regexp.last_match(1)}"
+      elsif smart =~ /^.*,(\d+)$/
+        munin = "#{device}-#{Regexp.last_match(1)}"
+      elsif smart =~ %r{^.*,(\d+)/(\d+)$}
+        munin = "#{device}-#{Regexp.last_match(1)}:#{Regexp.last_match(2)}"
+      end
     end
   elsif disk[:device]
     device = disk[:device].sub("/dev/", "")
index 23965c8bd601fd4f1071acd711ebee4a715d3d63..7757dca80d0f70f9132d02a00048eab2462a385e 100644 (file)
@@ -359,7 +359,7 @@ Ohai.plugin(:Hardware) do
         controller[:device] = File.basename(device).sub(/^cciss(\d+)$/, "/dev/cciss/c\\1d0")
       elsif device = Dir.glob("/sys/bus/pci/devices/#{controller[:pci_slot]}/host*/target*:3:0/*:3:0:0/scsi_generic/sg*").first
         controller[:device] = "/dev/#{File.basename(device)}"
-      elsif device = Dir.glob("/sys/bus/pci/devices/#{controller[:pci_slot]}/host*/target*:1:0/*:1:0:0/scsi_generic/sg*").first
+      elsif device = Dir.glob("/sys/bus/pci/devices/#{controller[:pci_slot]}/host*/target*:1:0/*:1:0:*/scsi_generic/sg*").first
         controller[:device] = "/dev/#{File.basename(device)}"
       end
     end
diff --git a/cookbooks/imagery/files/default/robots.txt b/cookbooks/imagery/files/default/robots.txt
new file mode 100644 (file)
index 0000000..5312873
--- /dev/null
@@ -0,0 +1,2 @@
+User-agent: *
+Disallow: /layer/
index ede9b5d478479dc35e63b214e742a3379c9f485c..5b457e8557ed5a1dc6d55c51a0725594219ed9bd 100644 (file)
@@ -63,36 +63,14 @@ action :create do
     variables new_resource.to_hash
   end
 
-  systemd_service "mapserv-fcgi-#{new_resource.layer}" do
-    description "Map server for #{new_resource.layer} layer"
-    environment "MS_MAPFILE" => "/srv/imagery/mapserver/layer-#{new_resource.layer}.map",
-                "MS_MAP_PATTERN" => "^/srv/imagery/mapserver/",
-                "MS_DEBUGLEVEL" => "0",
-                "MS_ERRORFILE" => "stderr",
-                "GDAL_CACHEMAX" => "128"
-    limit_nofile 16384
-    memory_high "512M"
-    memory_max "2G"
-    user "imagery"
-    group "imagery"
-    exec_start_pre "/bin/rm -f /run/mapserver-fastcgi/layer-#{new_resource.layer}.socket"
-    exec_start "/usr/bin/spawn-fcgi -n -b 8192 -s /run/mapserver-fastcgi/layer-#{new_resource.layer}.socket -M 0666 -P /run/mapserver-fastcgi/layer-#{new_resource.layer}.pid -- /usr/bin/multiwatch -f 4 --signal=TERM -- /usr/lib/cgi-bin/mapserv"
-    private_tmp true
-    private_devices true
-    private_network true
-    protect_system "full"
-    protect_home true
-    no_new_privileges true
-    restart "always"
-    pid_file "/run/mapserver-fastcgi/layer-#{new_resource.layer}.pid"
+  # Disable legacy service
+  service "mapserv-fcgi-#{new_resource.layer}" do
+    action [:stop, :disable]
   end
 
-  service "mapserv-fcgi-#{new_resource.layer}" do
-    provider Chef::Provider::Service::Systemd
-    action [:enable, :start]
-    supports :status => true, :restart => true, :reload => false
-    subscribes :restart, "template[/srv/imagery/mapserver/layer-#{new_resource.layer}.map]"
-    subscribes :restart, "systemd_service[mapserv-fcgi-#{new_resource.layer}]"
+  # Remove legacy service
+  systemd_service "mapserv-fcgi-#{new_resource.layer}" do
+    action :delete
   end
 
   directory "/srv/imagery/nginx/#{new_resource.site}" do
@@ -137,4 +115,5 @@ end
 def after_created
   notifies :create, "imagery_site[#{site}]"
   notifies :reload, "service[nginx]"
+  # notifies :restart, "service[mapserv-fcgi-#{site}]"
 end
index 9519b63bdaa304421e081b50ce2c34f83c0c9874..daa517af7d23ac2fb4818fae7f44df2b738fb7a6 100644 (file)
@@ -55,6 +55,13 @@ action :create do
     variables :title => new_resource.title
   end
 
+  cookbook_file "/srv/#{new_resource.site}/robots.txt" do
+    source "robots.txt"
+    user "root"
+    group "root"
+    mode 0o644
+  end
+
   cookbook_file "/srv/#{new_resource.site}/imagery.css" do
     source "imagery.css"
     user "root"
@@ -91,6 +98,35 @@ action :create do
   base_domains = [new_resource.site] + Array(new_resource.aliases)
   tile_domains = base_domains.flat_map { |d| [d, "a.#{d}", "b.#{d}", "c.#{d}"] }
 
+  systemd_service "mapserv-fcgi-#{new_resource.site}" do
+    description "Map server for #{new_resource.site} layer"
+    environment "MS_MAP_PATTERN" => "^/srv/imagery/mapserver/",
+                "MS_DEBUGLEVEL" => "0",
+                "MS_ERRORFILE" => "stderr",
+                "GDAL_CACHEMAX" => "512"
+    limit_nofile 16384
+    memory_max "2G"
+    user "imagery"
+    group "imagery"
+    exec_start_pre "/bin/rm -f /run/mapserver-fastcgi/layer-#{new_resource.site}.socket"
+    exec_start "/usr/bin/spawn-fcgi -n -b 8192 -s /run/mapserver-fastcgi/layer-#{new_resource.site}.socket -M 0666 -P /run/mapserver-fastcgi/layer-#{new_resource.site}.pid -- /usr/bin/multiwatch -f 8 --signal=TERM -- /usr/lib/cgi-bin/mapserv"
+    private_tmp true
+    private_devices true
+    private_network true
+    protect_system "full"
+    protect_home true
+    no_new_privileges true
+    restart "always"
+    pid_file "/run/mapserver-fastcgi/layer-#{new_resource.site}.pid"
+  end
+
+  service "mapserv-fcgi-#{new_resource.site}" do
+    provider Chef::Provider::Service::Systemd
+    action [:enable, :start]
+    supports :status => true, :restart => true, :reload => false
+    subscribes :restart, "systemd_service[mapserv-fcgi-#{new_resource.site}]"
+  end
+
   ssl_certificate new_resource.site do
     domains tile_domains
   end
@@ -103,6 +139,20 @@ action :create do
   end
 end
 
+action :delete do
+  service "mapserv-fcgi-#{new_resource.site}" do
+    action [:stop, :disable]
+  end
+
+  systemd_service "mapserv-fcgi-#{new_resource.site}" do
+    action :delete
+  end
+
+  nginx_site new_resource.site do
+    action :delete
+  end
+end
+
 def after_created
   notifies :reload, "service[nginx]"
 end
index 246b3653d92f2138c7dcdd605fd939f91792589c..b85aa527c548f85104c120f82bd4e0420237851e 100644 (file)
@@ -4,11 +4,11 @@
     <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
     <title><%= @title %></title>
     <link rel="stylesheet" href="imagery.css" type="text/css" media="all" />
-    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.0/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin="anonymous" />
-    <script src="https://unpkg.com/leaflet@1.3.0/dist/leaflet.js" integrity="sha512-C7BBF9irt5R7hqbUm2uxtODlUVs+IsNu2UULGuZN7gM+k/mmeG4xvIEac01BtQa4YIkUpp23zZC4wIwuXaPMQA==" crossorigin="anonymous"></script>
-    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-plugins/3.0.2/control/Permalink.min.js" integrity="sha256-9LLRsP8htmk6Ez4PqwxRBNVMp6r9Od32KerZLTMK9HA=" crossorigin="anonymous"></script>
-    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-plugins/3.0.2/control/Permalink.Layer.min.js" integrity="sha256-IR3dLMDgW61PPbrjYPe8eD7ou3RBAaVyoD4CNcq+8tw=" crossorigin="anonymous"></script>
-    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-plugins/3.0.2/control/Permalink.Overlay.min.js" integrity="sha256-xoP/txAKIYDr3MjZh1f2qtNn8lEa6zmhhkPxoejGgQM=" crossorigin="anonymous"></script>
+    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css" integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==" crossorigin="anonymous"/>
+    <script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js" integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA==" crossorigin="anonymous"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-plugins/3.0.3/control/Permalink.min.js" integrity="sha256-fJOBktFkvheDaGxagOcgNU+745zyvIDOkHioVJDXujc=" crossorigin="anonymous"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-plugins/3.0.3/control/Permalink.Layer.min.js" integrity="sha256-IR3dLMDgW61PPbrjYPe8eD7ou3RBAaVyoD4CNcq+8tw=" crossorigin="anonymous"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-plugins/3.0.3/control/Permalink.Overlay.min.js" integrity="sha256-xoP/txAKIYDr3MjZh1f2qtNn8lEa6zmhhkPxoejGgQM=" crossorigin="anonymous"></script>
     <script type="text/javascript" src="imagery.js"></script>
     <style type="text/css">
     @media print {
index 84a3803d01256f76d373898d2c189561a72b1341..d44f3ec781d717260a0f174030a4c04222a8d945 100644 (file)
@@ -49,6 +49,6 @@ MAP
     STATUS       DEFAULT
     TYPE         RASTER
     PROCESSING   "RESAMPLE=AVERAGE"
-    PROCESSING   "CLOSE_CONNECTION=DEFER"
+    PROCESSING   "CLOSE_CONNECTION=NORMAL"
   END # layer
 END
index ec8a7ca312fe815f475bcf44d94b8fe65afa4592..20e8d5642a39e94b3bd4df842e1369ecd5dd2d4f 100644 (file)
@@ -7,6 +7,11 @@ server {
     return 301 https://$host$request_uri;
 }
 
+upstream <%= @name %>_fastcgi {
+    server "unix:/var/run/mapserver-fastcgi/layer-<%= @name %>.socket";
+    server "unix:/var/run/mapserver-fastcgi/layer-<%= @name %>.socket";
+}
+
 server {
     listen [::]:443 ssl;
     listen *:443 ssl;
index e527f125053c084b6f0bf49c41e00a12b9f5585d..b96a6719c1e8d2951d84c30bcb185aeb059f42f9 100644 (file)
@@ -1,28 +1,34 @@
 # DO NOT EDIT - This file is being maintained by Chef
-
 location ~* "^/layer/<%= @layer %>/(\d+)/(\d+)/(\d+)\.(png|jpg|jpeg)$" {
   # Override QUERY_STRING to force mapserver query parameters
   fastcgi_param QUERY_STRING "map=/srv/imagery/mapserver/layer-<%= @layer %>.map&mode=tile&layers=<%= @layer %>&tilemode=gmap&tile=$2+$3+$1";
-  fastcgi_pass "unix:/var/run/mapserver-fastcgi/layer-<%= @layer %>.socket";
+  fastcgi_pass "<%= @site %>_fastcgi";
   fastcgi_buffers 8 64k;
   include fastcgi_params;
   fastcgi_param REQUEST_METHOD "GET";
   fastcgi_param HTTP_PROXY "";
-  fastcgi_read_timeout 300s;
+  fastcgi_read_timeout 60s;
 
   # Caching
   fastcgi_cache "fastcgi_cache_zone";
   fastcgi_cache_key "<%= @layer %><%= @revision %> $request_method $1 $2 $3";
-  fastcgi_keep_conn on;
+
+  # Free connection to socket for other requests
+  fastcgi_keep_conn off;
+
   fastcgi_cache_lock on;
-  fastcgi_cache_lock_timeout 60s;
+  fastcgi_cache_lock_timeout 30s;
   fastcgi_cache_valid 200 21d;
   fastcgi_cache_use_stale error timeout updating http_500 http_503;
 
-  fastcgi_ignore_client_abort on;
+  # Leaflet aborts connection still in flight to free up resources
+  fastcgi_ignore_client_abort off;
 
   fastcgi_catch_stderr "Image handling error";
 
+  fastcgi_next_upstream error timeout invalid_header http_500 http_503;
+  fastcgi_next_upstream_tries 3;
+
   # Do not GZIP tiles
   gzip off;
 
index 185798bc6adb0b30d47bc52e278ef35db17e6e62..3324e1f9f6d05325a081791b6f14f830765432fb 100644 (file)
@@ -39,7 +39,7 @@ property :site_readonly, :kind_of => [String, TrueClass, FalseClass], :default =
 property :admin_user, :kind_of => String, :default => "Admin"
 property :admin_password, :kind_of => String, :required => true
 property :private_accounts, :kind_of => [TrueClass, FalseClass], :default => false
-property :private, :kind_of => [TrueClass, FalseClass], :default => false
+property :private_site, :kind_of => [TrueClass, FalseClass], :default => false
 property :recaptcha_public_key, :kind_of => String
 property :recaptcha_private_key, :kind_of => String
 property :extra_file_extensions, :kind_of => [String, Array], :default => []
@@ -217,7 +217,7 @@ action :create do
     update_site false
   end
 
-  if new_resource.private_accounts || new_resource.private
+  if new_resource.private_accounts || new_resource.private_site
     mediawiki_extension "ConfirmEdit" do
       site new_resource.site
       update_site false
@@ -351,6 +351,7 @@ action :create do
 
   mediawiki_extension "UniversalLanguageSelector" do
     site new_resource.site
+    template "mw-ext-UniversalLanguageSelector.inc.php.erb"
     update_site false
   end
 
@@ -471,7 +472,7 @@ action :create do
     template "apache.erb"
     directory site_directory
     variables :aliases => Array(new_resource.aliases),
-              :private => new_resource.private
+              :private_site => new_resource.private_site
     reload_apache false
   end
 
@@ -562,7 +563,7 @@ action_class do
       :site_readonly => new_resource.site_readonly,
       :extra_file_extensions => new_resource.extra_file_extensions,
       :private_accounts => new_resource.private_accounts,
-      :private => new_resource.private
+      :private_site => new_resource.private_site
     }
   end
 end
index dc14397503a09a4d0b28d19097808fdc8c1fc1b3..11bbd022ba319f281a2246e0da477ebf6aa1e691 100644 (file)
@@ -168,10 +168,10 @@ $wgResourceLoaderMaxQueryLength = -1;
 # End of automatically generated settings.
 # Add more configuration options below.
 
-#Only Allow Signed-in users to edit
+# Only Allow Signed-in users to edit
 $wgGroupPermissions['*']['edit'] = false;
 
-#Only allow autoconfirmed for a few actions
+# Only allow autoconfirmed for a few actions
 $wgGroupPermissions['user']['move'] = false;
 $wgGroupPermissions['user']['movefile'] = false;
 $wgGroupPermissions['user']['move-categorypages'] = false;
@@ -181,7 +181,7 @@ $wgGroupPermissions['autoconfirmed']['movefile'] = true;
 $wgGroupPermissions['autoconfirmed']['move-categorypages'] = true;
 $wgGroupPermissions['autoconfirmed']['upload'] = true;
 
-#Allow bureaucrat group access to oversight options
+# Allow bureaucrat group access to oversight options
 $wgGroupPermissions['bureaucrat']['hideuser'] = true;
 $wgGroupPermissions['bureaucrat']['deletelogentry'] = true;
 $wgGroupPermissions['bureaucrat']['deleterevision'] = true;
@@ -189,33 +189,33 @@ $wgGroupPermissions['bureaucrat']['suppressrevision'] = true;
 $wgGroupPermissions['bureaucrat']['suppressionlog'] = true;
 
 <% if @mediawiki[:private_accounts] -%>
-#Prevent new user registrations except by existing users
+# Prevent new user registrations except by existing users
 $wgGroupPermissions['*']['createaccount'] = false;
 $wgGroupPermissions['user']['createaccount'] = true;
 <% end -%>
-<% if @mediawiki[:private] -%>
+<% if @mediawiki[:private_site] -%>
 
-#Disable reading by anonymous users
+# Disable reading by anonymous users
 $wgGroupPermissions['*']['read'] = false;
 
-#Allow anonymous users to access the login page
+# Allow anonymous users to access the login page
 $wgWhitelistRead = array ("Special:Userlogin");
 
-#Prevent new user registrations except by sysops
+# Prevent new user registrations except by sysops
 $wgGroupPermissions['*']['createaccount'] = false;
 
-#Restrict access to the upload directory
+# Restrict access to the upload directory
 $wgUploadPath = "$wgScriptPath/img_auth.php";
 <% end -%>
 
-#Allow Subpages on Main Namespace
+# Allow Subpages on Main Namespace
 $wgNamespacesWithSubpages[NS_MAIN] = true;
 
-#DNS Blacklists to use
+# DNS Blacklists to use
 $wgEnableDnsBlacklist = true;
 $wgDnsBlacklistUrls = array( 'proxies.dnsbl.sorbs.net.', 'opm.tornevall.org.', 'xbl.spamhaus.org.', 'dnsbl-3.uceprotect.net.' );
 
-#Require validated email to edit
+# Require validated email to edit
 $wgEmailConfirmToEdit = true;
 
 # Extend autoblock period
@@ -224,16 +224,16 @@ $wgAutoblockExpiry = 7776000; // 90 days
 # Spam filter regex
 $wgSpamRegex = '/\b(gmail|dell|asus|eps(o|0)n|br(o|0)ther|can(o|0)n|hp|k(o|0)dak|lexmark|mcafee|bitdefender|n(o|0)rt(o|0)n( 360)?|avira|kaspersky|avg|avast|micr(o|0)s(o|0)ft|(o|0)utl(o|0)(o|0)k|printer|netgear( r(o|0)uter)?|quickb(o|0)(o|0)ks( payr(o|0)ll)?)( antivirus)?( helpline| cust(o|0)mer|( technical| tech)| cust(o|0)mer service)? (supp(o|0)rt number|ph(o|0)ne number|supp(o|0)rt ph(o|0)ne number|care number|helpdesk number)\b/i';
 
-#Autopromote users to autoconfirmed
+# Autopromote users to autoconfirmed
 $wgAutoConfirmAge = 345600; // 4 days
 $wgAutoConfirmCount = 10;
 
-#Disable Hit Counter for Performance
+# Disable Hit Counter for Performance
 $wgDisableCounters = TRUE;
-#Disable IP in Header to avoid cache issue
+# Disable IP in Header to avoid cache issue
 $wgShowIPinHeader = FALSE;
 
-#Job Runs by cron
+# Job Runs by cron
 $wgJobRunRate = 0;
 
 # Allow external images from a few sites
@@ -241,15 +241,15 @@ $wgAllowExternalImagesFrom = array( 'http://tile.openstreetmap.org/', 'http://sv
 
 $wgNoFollowDomainExceptions = array( 'www.openstreetmap.org', 'josm.openstreetmap.de', 'taginfo.openstreetmap.org', 'blog.openstreetmap.org', 'wiki.osmfoundation.org' );
 
-#FIXME - move to specific
+# FIXME - move to specific
 $wgForceUIMsgAsContentMsg = array( 'mainpage-url', 'portal-url', 'mapfeatures-url', 'helppage' );
 
-#FIXME - move to specific
+# FIXME - move to specific
 $wgAllowUserJs = TRUE;
 $wgAllowUserCss = TRUE;
 
-#FIXME - move to specific
-#DE
+# FIXME - move to specific
+# DE
 define('NS_LANG_DE', 200);
 $wgExtraNamespaces[NS_LANG_DE] = 'DE';
 $wgNamespacesWithSubpages[NS_LANG_DE] = TRUE;
@@ -258,7 +258,7 @@ define('NS_LANG_DE_TALK', 201);
 $wgExtraNamespaces[NS_LANG_DE_TALK] = 'DE_talk';
 $wgNamespacesWithSubpages[NS_LANG_DE_TALK] = TRUE;
 
-#FR
+# FR
 define('NS_LANG_FR', 202);
 $wgExtraNamespaces[NS_LANG_FR] = 'FR';
 $wgNamespacesWithSubpages[NS_LANG_FR] = TRUE;
@@ -267,7 +267,7 @@ define('NS_LANG_FR_TALK', 203);
 $wgExtraNamespaces[NS_LANG_FR_TALK] = 'FR_talk';
 $wgNamespacesWithSubpages[NS_LANG_FR_TALK] = TRUE;
 
-#ES
+# ES
 define('NS_LANG_ES', 204);
 $wgExtraNamespaces[NS_LANG_ES] = 'ES';
 $wgNamespacesWithSubpages[NS_LANG_ES] = TRUE;
@@ -276,7 +276,7 @@ define('NS_LANG_ES_TALK', 205);
 $wgExtraNamespaces[NS_LANG_ES_TALK] = 'ES_talk';
 $wgNamespacesWithSubpages[NS_LANG_ES_TALK] = TRUE;
 
-#IT
+# IT
 define('NS_LANG_IT', 206);
 $wgExtraNamespaces[NS_LANG_IT] = 'IT';
 $wgNamespacesWithSubpages[NS_LANG_IT] = TRUE;
@@ -285,7 +285,7 @@ define('NS_LANG_IT_TALK', 207);
 $wgExtraNamespaces[NS_LANG_IT_TALK] = 'IT_talk';
 $wgNamespacesWithSubpages[NS_LANG_IT_TALK] = TRUE;
 
-#NL
+# NL
 define('NS_LANG_NL', 208);
 $wgExtraNamespaces[NS_LANG_NL] = 'NL';
 $wgNamespacesWithSubpages[NS_LANG_NL] = TRUE;
@@ -294,7 +294,7 @@ define('NS_LANG_NL_TALK', 209);
 $wgExtraNamespaces[NS_LANG_NL_TALK] = 'NL_talk';
 $wgNamespacesWithSubpages[NS_LANG_NL_TALK] = TRUE;
 
-#RU
+# RU
 define('NS_LANG_RU', 210);
 $wgExtraNamespaces[NS_LANG_RU] = 'RU';
 $wgNamespacesWithSubpages[NS_LANG_RU] = TRUE;
@@ -303,7 +303,7 @@ define('NS_LANG_RU_TALK', 211);
 $wgExtraNamespaces[NS_LANG_RU_TALK] = 'RU_talk';
 $wgNamespacesWithSubpages[NS_LANG_RU_TALK] = TRUE;
 
-#JA
+# JA
 define('NS_LANG_JA', 212);
 $wgExtraNamespaces[NS_LANG_JA] = 'JA';
 $wgNamespacesWithSubpages[NS_LANG_JA] = TRUE;
index ab16ce428eeafd724aebbd1b4860e833c480fe48..f41e4ca50e0304663b0138a4c73e7d9d4db1ff6f 100644 (file)
@@ -80,7 +80,7 @@
     Options -ExecCGI -Includes -Indexes
     AllowOverride None
     AddType text/plain .html .htm .shtml
-<% if @private -%>
+<% if @private_site -%>
     Require all denied
 <% end -%>
   </Directory>
diff --git a/cookbooks/mediawiki/templates/default/mw-ext-UniversalLanguageSelector.inc.php.erb b/cookbooks/mediawiki/templates/default/mw-ext-UniversalLanguageSelector.inc.php.erb
new file mode 100644 (file)
index 0000000..b0d3104
--- /dev/null
@@ -0,0 +1,3 @@
+<?php wfLoadExtension( 'UniversalLanguageSelector' );
+# Disable GeoIP service
+$wgULSGeoService=false;
index b7dab831a83c25aa4a31a04f502d1be100fa7de4..630971bba1c5feeb1706293562706c87a2ab11ae 100644 (file)
@@ -1,4 +1,4 @@
-default[:piwik][:version] = "3.5.1"
+default[:piwik][:version] = "3.6.0"
 default[:piwik][:plugins] = %w[
   Actions Annotations API BulkTracking Contents CoreAdminHome CoreConsole
   CoreHome CorePluginsAdmin CoreUpdater CoreVisualizations CustomPiwikJs
index 744f7cd773ea1601e511e3632ccf7cc43a32d656..3e4b940b81c6ce3d9957923ff906edfe0331e246 100644 (file)
@@ -9,6 +9,7 @@ tables_prefix = "piwik_"
 charset = "utf8"
 
 [General]
+force_ssl = 1
 force_ssl_login = 1
 proxy_client_headers[] = "HTTP_X_FORWARDED_FOR"
 trusted_hosts[] = "piwik.openstreetmap.org"
diff --git a/cookbooks/planet/files/default/users_deleted/.htaccess b/cookbooks/planet/files/default/users_deleted/.htaccess
new file mode 100644 (file)
index 0000000..7f851da
--- /dev/null
@@ -0,0 +1 @@
+HeaderName HEADER.html
diff --git a/cookbooks/planet/files/default/users_deleted/HEADER.html b/cookbooks/planet/files/default/users_deleted/HEADER.html
new file mode 100644 (file)
index 0000000..104ebed
--- /dev/null
@@ -0,0 +1,3 @@
+<h1>Deleted user id list</h1>
+<p><i>users_deleted.txt</i> contains a list of user ids where the corresponding accounts have been deleted. The list is updated daily.</p>
+<p>More information on what happens when an account is deleted can be found in our <a href="https://wiki.osmfoundation.org/wiki/Privacy_Policy#Account_Removal">privacy policy</a>
index feedac7dab59fd41f2f092e771a2b2378ea2f360..8e309246a0ddb69318c488916f931e485bbce77e 100644 (file)
@@ -69,6 +69,23 @@ template "/usr/local/bin/users-agreed" do
   mode 0o755
 end
 
+template "/usr/local/bin/users-deleted" do
+  source "users-deleted.erb"
+  owner "root"
+  group "root"
+  mode 0o755
+end
+
+remote_directory "/store/planet/users_deleted" do
+  source "users_deleted"
+  owner "planet"
+  group "planet"
+  mode 0o755
+  files_owner "root"
+  files_group "root"
+  files_mode 0o644
+end
+
 remote_directory "/store/planet/replication" do
   source "replication-cgi"
   owner "root"
index 5300781be048de6043e3a223a766ff3b7a52cad7..0ccffdd1e27780d75e067387883bc0f5bf85cf89 100644 (file)
@@ -5,6 +5,7 @@ TZ=UTC
 MAILTO=zerebubuth@gmail.com
 
 0 7 * * * planet /usr/local/bin/users-agreed
+0 17 * * * planet /usr/local/bin/users-deleted
 * * * * * planet /usr/local/bin/replicate-changesets /etc/replication/changesets.conf
 
 MAILTO=brett@bretth.com
diff --git a/cookbooks/planet/templates/default/users-deleted.erb b/cookbooks/planet/templates/default/users-deleted.erb
new file mode 100644 (file)
index 0000000..1f739d1
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+T=$(mktemp -d -t -p /var/tmp users.XXXXXXXXXX)
+
+# use the same as for the users-agreed template
+export PGPASSFILE=/etc/replication/users-agreed.conf
+
+echo "# user IDs of deleted users. " > $T/users_deleted
+psql -h <%= node[:web][:readonly_database_host] %> -U planetdiff -t -c "select id from users where status='deleted' order by id asc" openstreetmap >> $T/users_deleted
+
+if cmp -s "${T}/users_deleted" "/store/planet/users_deleted/users_deleted.txt"; then
+  : # do nothing
+else
+  cp $T/users_deleted /store/planet/users_deleted/users_deleted.txt
+fi
+
+rm -rf $T
diff --git a/cookbooks/ssl/files/default/dhparam.pem b/cookbooks/ssl/files/default/dhparam.pem
deleted file mode 100644 (file)
index c895dd7..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
------BEGIN DH PARAMETERS-----
-MIIBCAKCAQEApDYHQhAm+Wje/kmAWAzCIOhzxJj6RjjKbOfsUp31PpBaeQKwdIZZ
-jStXfkdo1/c4FfpKczO4WMQJBJjCts6nmEfaPTq/ybcVtG0GQDwO6NIjM8sSymUF
-Qcnd9aH2jfUyciPqkAfTavvy+zZIU+3HxTvCA3I6JY5qLZ4YOpNheRu5Q9azBMLo
-vfb+6oQGMnMvUVCSU8aw8BQ1qwhzJJQNAszQqA3DrxG17jsk0mBzsR3KSs4eNcjx
-+65YhKArG76J1NolcP1rocehK5nrH2IO3cU2G/m2Y09DkXSP9thRSxUQ7rVKSgbC
-KhA263146gEf+bbKdMf6zrsNpjisMZ62ewIBAg==
------END DH PARAMETERS-----
index fa4ab02d8f1bf8cd3cec1dc6a984f42a658bc03c..ccb3508be195e7f54329aedb66e63258089e9f32 100644 (file)
 package "openssl"
 package "ssl-cert"
 
-%w[letsencrypt dhparam].each do |certificate|
-  cookbook_file "/etc/ssl/certs/#{certificate}.pem" do
-    owner "root"
-    group "root"
-    mode 0o444
-    backup false
-  end
+cookbook_file "/etc/ssl/certs/letsencrypt.pem" do
+  owner "root"
+  group "root"
+  mode 0o444
+  backup false
+end
+
+openssl_dhparam "/etc/ssl/certs/dhparam.pem" do
+  owner "root"
+  group "root"
+  mode 0o444
 end
index facb59ad754b1487e4cbc97e043c2fa03e7a5c31..7348a6726af6870818233368c501aabd2c5f8b07 100644 (file)
@@ -53,25 +53,19 @@ action :create do
       force_unlink true
     end
   else
-    template "/tmp/#{new_resource.certificate}.ssl.cnf" do
-      cookbook "ssl"
-      source "ssl.cnf.erb"
-      owner "root"
-      group "root"
-      mode 0o644
-      variables :domains => Array(new_resource.domains)
-      not_if do
-        ::File.exist?("/etc/ssl/certs/#{new_resource.certificate}.pem") && ::File.exist?("/etc/ssl/private/#{new_resource.certificate}.key")
-      end
-    end
+    alt_names = new_resource.domains.collect { |domain| "DNS:#{domain}" }
 
-    execute "/etc/ssl/certs/#{new_resource.certificate}.pem" do
-      command "openssl req -x509 -newkey rsa:2048 -keyout /etc/ssl/private/#{new_resource.certificate}.key -out /etc/ssl/certs/#{new_resource.certificate}.pem -days 365 -nodes -config /tmp/#{new_resource.certificate}.ssl.cnf"
-      user "root"
+    openssl_x509_certificate "/etc/ssl/certs/#{new_resource.certificate}.pem" do
+      key_file "/etc/ssl/private/#{new_resource.certificate}.key"
+      owner "root"
       group "ssl-cert"
-      not_if do
-        ::File.exist?("/etc/ssl/certs/#{new_resource.certificate}.pem") && ::File.exist?("/etc/ssl/private/#{new_resource.certificate}.key")
-      end
+      mode 0o640
+      org "OpenStreetMap"
+      email "operations@osmfoundation.org"
+      common_name new_resource.domains.first
+      subject_alt_name alt_names
+      extensions "keyUsage" => { "values" => %w[digitalSignature keyEncipherment] },
+                 "extendedKeyUsage" => { "values" => %w[serverAuth clientAuth] }
     end
   end
 end
diff --git a/cookbooks/ssl/templates/default/ssl.cnf.erb b/cookbooks/ssl/templates/default/ssl.cnf.erb
deleted file mode 100644 (file)
index 64c3c08..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-[req]
-prompt = no
-distinguished_name = req_dn
-x509_extensions = v3_req
-
-[req_dn]
-organizationName = OpenStreetMap
-commonName = <%= @domains.first %>
-emailAddress = operations@osmfoundation.org
-
-[v3_req]
-basicConstraints = CA:FALSE
-keyUsage = digitalSignature, keyEncipherment
-extendedKeyUsage = serverAuth, clientAuth
-subjectAltName = @alt_names
-
-[alt_names]
-<% @domains.each_with_index do |d, i| -%>
-DNS.<%= i + 1 %> = <%= d %>
-<% end -%>
index 44562a7baf515e0343a66f48a927bfa01e2166c5..b65b12a21b36d5ef9e1cb991b4630e4e53a4ac22 100644 (file)
 # limitations under the License.
 #
 
-package "procps"
+if node[:virtualization][:role] == "guest" &&
+   node[:virtualization][:system] == "lxd"
+  file "/etc/sysctl.d/60-chef.conf" do
+    action :delete
+  end
+else
+  package "procps"
 
-directory "/etc/sysctl.d" do
-  owner "root"
-  group "root"
-  mode 0o755
-end
+  directory "/etc/sysctl.d" do
+    owner "root"
+    group "root"
+    mode 0o755
+  end
 
-execute "sysctl" do
-  action :nothing
-  command "/sbin/sysctl -p /etc/sysctl.d/60-chef.conf"
-end
+  execute "sysctl" do
+    action :nothing
+    command "/sbin/sysctl -p /etc/sysctl.d/60-chef.conf"
+  end
 
-template "/etc/sysctl.d/60-chef.conf" do
-  source "chef.conf.erb"
-  owner "root"
-  group "root"
-  mode 0o644
-  notifies :run, "execute[sysctl]"
-end
+  template "/etc/sysctl.d/60-chef.conf" do
+    source "chef.conf.erb"
+    owner "root"
+    group "root"
+    mode 0o644
+    notifies :run, "execute[sysctl]"
+  end
 
-node[:sysctl].each_value do |group|
-  group[:parameters].each do |key, value|
-    sysctl_file = "/proc/sys/#{key.tr('.', '/')}"
+  node[:sysctl].each_value do |group|
+    group[:parameters].each do |key, value|
+      sysctl_file = "/proc/sys/#{key.tr('.', '/')}"
 
-    file sysctl_file do
-      content "#{value}\n"
-      atomic_update false
-      only_if { File.exist?(sysctl_file) }
+      file sysctl_file do
+        content "#{value}\n"
+        atomic_update false
+        ignore_failure true
+      end
     end
   end
 end
index fa7983d626b96d22df7db04d78c7e4abb1aa012c..9b08c44cf6fbeadde1b56cf380fc2aaf112afa88 100644 (file)
 # limitations under the License.
 #
 
-package "sysfsutils"
+if node[:virtualization][:role] == "guest" &&
+   node[:virtualization][:system] == "lxd"
+  package "sysfsutils" do
+    action :purge
+  end
+else
+  package "sysfsutils"
 
-service "sysfsutils" do
-  action :enable
-  supports :status => false, :restart => true, :reload => false
-end
+  service "sysfsutils" do
+    action :enable
+    supports :status => false, :restart => true, :reload => false
+  end
 
-template "/etc/sysfs.conf" do
-  source "sysfs.conf.erb"
-  owner "root"
-  group "root"
-  mode 0o644
-  notifies :restart, "service[sysfsutils]"
-end
+  template "/etc/sysfs.conf" do
+    source "sysfs.conf.erb"
+    owner "root"
+    group "root"
+    mode 0o644
+    notifies :restart, "service[sysfsutils]"
+  end
 
-node[:sysfs].each_value do |group|
-  group[:parameters].each do |key, value|
-    sysfs_file = "/sys/#{key}"
+  node[:sysfs].each_value do |group|
+    group[:parameters].each do |key, value|
+      sysfs_file = "/sys/#{key}"
 
-    file sysfs_file do
-      content "#{value}\n"
-      atomic_update false
-      only_if { File.exist?(sysfs_file) }
+      file sysfs_file do
+        content "#{value}\n"
+        atomic_update false
+        ignore_failure true
+      end
     end
   end
 end
index c31b6d0bc782695bcad2e3089bb12db45f6ab298..772999f1d81c1e624bcbb6b79633f72246f7aff0 100644 (file)
@@ -97,7 +97,7 @@ end
 action :delete do
   file "/etc/default/#{new_resource.service}" do
     action :delete
-    only_if { environment_file.is_a?(Hash) }
+    only_if { new_resource.environment_file.is_a?(Hash) }
   end
 
   file "/etc/systemd/system/#{new_resource.service}.service" do
index 1d8ba1b126e843fdc5ab20b76c04a2f6b74c4252..50e058632a8d9167ea832cd481d4c37bcf0c5c5c 100644 (file)
@@ -9,15 +9,20 @@ LOGDIR="${PLANETDIR}/log"
 PLANETPREV="${PLANETDIR}/planet-previous.pbf"
 PLANETCURR="${PLANETDIR}/planet.pbf"
 PLANETNEW="${PLANETDIR}/planet-new.pbf"
+PLANETTMP="${PLANETDIR}/planet-tmp.pbf"
 
 # start logging
 
 exec > "${LOGDIR}/$(date +%Y%m%d-%H%M).log" 2>&1
 
-retval=1
+pyosmium-up-to-date -v -o $PLANETNEW $PLANETCURR
+retval=$?
+
 while [ $retval -eq 1 ]; do
-    pyosmium-up-to-date -v -o $PLANETNEW $PLANETCURR
+    mv "$PLANETNEW" "$PLANETTMP"
+    pyosmium-up-to-date -v -o $PLANETNEW $PLANETTMP
     retval=$?
+    rm "$PLANETTMP"
 done
 
 if [ $retval -ne 0 ]; then
index 3e9f6a813d2f3697d2536bd55a2587ecbfe044cc..645bb0998499c901d766aa140a1208087f711c1c 100644 (file)
@@ -434,57 +434,26 @@ end
 package %w[
   osm2pgsql
   osmosis
+  ruby
+  pyosmium
+  python-pyproj
 ]
 
-if node[:lsb][:release].to_f >= 18.04
-  package %w[
-    pyosmium
-    python-pyproj
-  ]
-
-  remote_directory "/usr/local/bin" do
-    source "bin"
-    owner "root"
-    group "root"
-    mode 0o755
-    files_owner "root"
-    files_group "root"
-    files_mode 0o755
-  end
-
-  template "/usr/local/bin/expire-tiles" do
-    source "expire-tiles.bionic.erb"
-    owner "root"
-    group "root"
-    mode 0o755
-  end
-else
-  package %w[
-    ruby
-    ruby-dev
-    libproj-dev
-    libxml2-dev
-  ]
-
-  gem_package "proj4rb"
-  gem_package "libxml-ruby"
-
-  remote_directory "/usr/local/lib/site_ruby" do
-    source "ruby"
-    owner "root"
-    group "root"
-    mode 0o755
-    files_owner "root"
-    files_group "root"
-    files_mode 0o644
-  end
+remote_directory "/usr/local/bin" do
+  source "bin"
+  owner "root"
+  group "root"
+  mode 0o755
+  files_owner "root"
+  files_group "root"
+  files_mode 0o755
+end
 
-  template "/usr/local/bin/expire-tiles" do
-    source "expire-tiles.xenial.erb"
-    owner "root"
-    group "root"
-    mode 0o755
-  end
+template "/usr/local/bin/expire-tiles" do
+  source "expire-tiles.erb"
+  owner "root"
+  group "root"
+  mode 0o755
 end
 
 directory "/var/lib/replicate" do
diff --git a/cookbooks/tile/templates/default/expire-tiles.xenial.erb b/cookbooks/tile/templates/default/expire-tiles.xenial.erb
deleted file mode 100644 (file)
index 1a8a01a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/ruby
-
-# DO NOT EDIT - This file is being maintained by Chef
-
-require 'expire'
-
-tile_dirs = [
-<% node[:tile][:styles].each do |name,details| -%>
-  "/srv/tile.openstreetmap.org/tiles/<%= name %>",
-<% end -%>
-]
-
-max_zoom = <%= node[:tile][:styles].collect { |n,d| d[:max_zoom] }.max %>
-
-Dir.glob("/var/lib/replicate/expire-queue/changes-*.gz").each do |f|
-   Expire::expire(f, 13, max_zoom, tile_dirs)
-   File::unlink(f)
-end
index 6ef75527e22e382aa352792a50bc47762b956a89..a552ee6fc2a22e7f52703c5db00cf16b3884d9e2 100644 (file)
@@ -1,4 +1,3 @@
-
 default[:tilecache][:tile_parent] = "render.openstreetmap.org"
 default[:tilecache][:tile_siblings] = []
 
index 3417708f33835623efb0846c6ec747b3b454e90b..5c4907b69c7805b98c78452a4f8c8fcb37cddeb8 100644 (file)
@@ -77,6 +77,8 @@ squid_fragment "tilecache" do
   variables :caches => tilecaches, :renders => tilerenders
 end
 
+package "rsync"
+
 template "/etc/logrotate.d/squid" do
   source "logrotate.squid.erb"
   owner "root"
index d07a287bfbd9ff63731ea77ddfea6b243702b720..3846951a5d393696ad432ce35fa83706bc105a14 100644 (file)
@@ -1,4 +1,3 @@
-
 default[:tilelog][:source_directory] = "/opt/tilelog"
 default[:tilelog][:input_directory] = "/store/logs/tile.openstreetmap.org"
 default[:tilelog][:output_directory] = "/store/planet/tile_logs"
index 778d24ff4927d6b112b0e80f36abbb14f60d07b9..067c1334c2ef6a01dede62dd9e7db1bf4297022f 100644 (file)
@@ -125,6 +125,7 @@ action :create do
     user new_resource.user
     group new_resource.group
     notifies :run, "execute[#{rails_directory}/Gemfile]"
+    notifies :run, "execute[#{rails_directory}/app/assets/javascripts/i18n]"
     notifies :run, "execute[#{rails_directory}/public/assets]"
     notifies :delete, "file[#{rails_directory}/public/export/embed.html]"
     notifies :restart, "passenger_application[#{rails_directory}]"
@@ -320,6 +321,16 @@ action :create do
     only_if { new_resource.run_migrations }
   end
 
+  execute "#{rails_directory}/app/assets/javascripts/i18n" do
+    action :nothing
+    command "bundle#{new_resource.ruby} exec rake i18n:js:export"
+    environment "RAILS_ENV" => "production"
+    cwd rails_directory
+    user new_resource.user
+    group new_resource.group
+    notifies :run, "execute[#{rails_directory}/public/assets]"
+  end
+
   execute "#{rails_directory}/public/assets" do
     action :nothing
     command "bundle#{new_resource.ruby} exec rake assets:precompile"
index 1d73d9ff0d2a366dc4f341aebbbf507789cc2c5f..0cde6a3138df85835c600f4c004c958a7112cb4f 100644 (file)
@@ -1,3 +1,2 @@
-
 # Force apache to listen only on localhost
 # default[:apache][:listen_address] = "127.0.0.1"
index 659a2399738b3174690a1982b5d2c9090bab15b2..69365957c965a0dc030c55a3340939ade9cc7b2f 100644 (file)
@@ -18,7 +18,7 @@ default_attributes(
         :family => :inet6,
         :address => "2001:67c:2268:1005:21e:8cff:fe8c:8d3b",
         :prefix => "64",
-        :gateway => "fe80::20c:42ff:feb2:8ff9"
+        :gateway => "fe80::20c:42ff:feb2:8ff8"
       }
     }
   },
index 7b2f4f1bd90c23be0ef2a95ba53ce62ae35a0ff8..6d837159ff900b493ffb91eeb8fa07f50f9a9f36 100644 (file)
@@ -5,13 +5,13 @@ default_attributes(
   :networking => {
     :interfaces => {
       :internal_ipv4 => {
-        :interface => "eth0.2801",
+        :interface => "enp3s0f0.2801",
         :role => :internal,
         :family => :inet,
         :address => "10.0.0.11"
       },
       :external_ipv4 => {
-        :interface => "eth0.2800",
+        :interface => "enp3s0f0.2800",
         :role => :external,
         :family => :inet,
         :address => "193.60.236.12"
@@ -30,6 +30,5 @@ default_attributes(
 )
 
 run_list(
-  "role[ucl]",
-  "role[hp-g5]"
+  "role[ucl]"
 )
index 02b880d5d65a2d3834c34202995de63381965d57..02bc8afa440cbae4511c5b3fb871fc030fa271af 100644 (file)
@@ -8,7 +8,7 @@ default_attributes(
     :keepalive => false
   },
   :apt => {
-    :sources => ["passenger", "brightbox-ruby-ng"]
+    :sources => ["passenger"]
   },
   :elasticsearch => {
     :version => "5.x",
index f24618d0edce0e36a9291c461e7cf18fbfa12353..2d78c10b79b6ca43027f9d6000e6ba59b85c18f1 100644 (file)
@@ -22,6 +22,5 @@ default_attributes(
 
 run_list(
   "role[ucl]",
-  "role[hp-dl360-g6]",
   "role[taginfo]"
 )
index bed6b295d57a4e0385758896b8ecdfd542f75ab7..3af3e5152ba6bba5bf22ec8889816dff53321cdb 100644 (file)
@@ -23,7 +23,7 @@ default_attributes(
     }
   },
   :squid => {
-    :cache_mem => "250 MB",
+    :cache_mem => "200 MB",
     :cache_dir => "coss /store/squid/coss-01 7500 block-size=8192 max-size=262144 membufs=30"
   },
   :sysctl => {
index defd93021e7a7650980c9241711e4209a2daef68..941e9b2b232309fae03c5d1e59d87dffddcd0441 100644 (file)
@@ -2,6 +2,14 @@ name "kessie"
 description "Master role applied to kessie"
 
 default_attributes(
+  :sysctl => {
+    :swappiness => {
+      :comment => "Only swap in an emergency",
+      :parameters => {
+        "vm.swappiness" => "1"
+      }
+    }
+  },
   :munin => {
     :plugins => {
       :sensors_temp => {
index 33f18e7eea59f2f25e084a1bfaa8e2558c247080..1e5e65036c557bd1f5f3e28709b40f109eb16aae 100644 (file)
@@ -14,10 +14,6 @@ default_attributes(
     :roles => {
       :external => {
         :zone => "ool",
-        :inet => {
-          :prefix => "28",
-          :gateway => "140.211.167.97"
-        },
         :inet6 => {
           :prefix => "64",
           :gateway => "2605:bc80:3010:700::1"
diff --git a/roles/pyrene.rb b/roles/pyrene.rb
new file mode 100644 (file)
index 0000000..e9d7f02
--- /dev/null
@@ -0,0 +1,66 @@
+name "pyrene"
+description "Master role applied to pyrene"
+
+default_attributes(
+  :apt => {
+    :sources => ["postgresql"]
+  },
+  :munin => {
+    :plugins => {
+      :hpasmcli2_temp => {
+        :temp15 => { :warning => "59.5", :critical => "70" },
+        :temp17 => { :warning => "59.5", :critical => "70" }
+      }
+    }
+  },
+  :networking => {
+    :interfaces => {
+      :external_ipv4 => {
+        :interface => "eno1",
+        :role => :external,
+        :family => :inet,
+        :address => "140.211.15.29",
+        :prefix => "24",
+        :gateway => "140.211.15.1"
+      }
+    }
+  },
+  :postgresql => {
+    :versions => ["10"],
+    :settings => {
+      :defaults => {
+        :shared_buffers => "8GB",
+        :maintenance_work_mem => "7144MB",
+        :effective_cache_size => "16GB"
+      }
+    }
+  },
+  :sysctl => {
+    :postgres => {
+      :comment => "Increase shared memory for postgres",
+      :parameters => {
+        "kernel.shmmax" => 9 * 1024 * 1024 * 1024,
+        "kernel.shmall" => 9 * 1024 * 1024 * 1024 / 4096
+      }
+    }
+  },
+  :tile => {
+    :database => {
+      :cluster => "10/main",
+      :postgis => "2.4"
+    },
+    :node_file => "/store/database/nodes",
+    :styles => {
+      :default => {
+        :tile_directories => [
+          { :name => "/store/tiles/default", :min_zoom => 0, :max_zoom => 19 }
+        ]
+      }
+    }
+  }
+)
+
+run_list(
+  "role[osuosl]",
+  "role[tile]"
+)
index 62228f5bc399e57ea14f682979e175a9a78de58f..ec985da04a56922af308e3b56770e18e738b8064 100644 (file)
@@ -73,6 +73,7 @@ run_list(
   "role[otrs]",
   "role[donate]",
   "recipe[hot]",
+  "recipe[dmca]",
   "recipe[dhcpd]",
   "recipe[openvpn]"
 )
similarity index 61%
rename from roles/odin.rb
rename to roles/rimfaxe.rb
index aa5700e32aa62bcb3c6107c8817c25d3f98880b4..94c76dc1b0f4584531329398f9b0c14ffe1f02a7 100644 (file)
@@ -1,36 +1,29 @@
-name "odin"
-description "Master role applied to odin"
+name "rimfaxe"
+description "Master role applied to rimfaxe"
 
 default_attributes(
   :networking => {
     :interfaces => {
       :external_ipv4 => {
-        :interface => "bond0",
+        :interface => "eth0",
         :role => :external,
         :family => :inet,
-        :address => "130.225.254.123",
-        :prefix => "23",
-        :gateway => "130.225.254.97",
-        :bond => {
-          :mode => "802.3ad",
-          :miimon => "100",
-          :xmithashpolicy => "layer3+4",
-          :lacprate => "fast",
-          :slaves => %w[eno1 eno2]
-        }
+        :address => "130.225.254.109",
+        :prefix => "27",
+        :gateway => "130.225.254.97"
       },
       :external_ipv6 => {
-        :interface => "bond0",
+        :interface => "eth0",
         :role => :external,
         :family => :inet6,
-        :address => "2001:878:346::123",
+        :address => "2001:878:346::109",
         :prefix => "64",
         :gateway => "2001:878:346::97"
       }
     }
   },
   :squid => {
-    :cache_mem => "14000 MB",
+    :cache_mem => "7000 MB",
     :cache_dir => "coss /store/squid/coss-01 128000 block-size=8192 max-size=262144 membufs=80"
   },
   :tilecache => {
index cc9a3fd126f2f570c55eedca6c2e1d1be5b5ff92..647aa57c5e7a0f963c092729d2b426a6f6267dcc 100644 (file)
@@ -10,13 +10,13 @@ default_attributes(
   :networking => {
     :interfaces => {
       :internal_ipv4 => {
-        :interface => "eth0.2801",
+        :interface => "enp3s0f0.2801",
         :role => :internal,
         :family => :inet,
         :address => "10.0.0.12"
       },
       :external_ipv4 => {
-        :interface => "eth0.2800",
+        :interface => "enp3s0f0.2800",
         :role => :external,
         :family => :inet,
         :address => "193.60.236.20"
@@ -27,7 +27,6 @@ default_attributes(
 
 run_list(
   "role[ucl]",
-  "role[hp-g5]",
   "role[chef-server]",
   "role[chef-repository]",
   "role[letsencrypt]",
diff --git a/roles/smaug.rb b/roles/smaug.rb
deleted file mode 100644 (file)
index 3adb0f0..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-name "smaug"
-description "Master role applied to smaug"
-
-default_attributes(
-  :accounts => {
-    :users => {
-      :gravitystorm => { :status => :user }
-    }
-  },
-  :apt => {
-    :sources => ["brightbox-ruby-ng"]
-  },
-  :db => {
-    :cluster => "9.1/main"
-  },
-  :munin => {
-    :plugins => {
-      :ipmi_fans => {
-        :Fan4 => { :graph => "no" },
-        :Fan7CPU1 => { :graph => "no" },
-        :Fan8CPU2 => { :graph => "no" }
-      },
-      :sensors_volt => {
-        :contacts => "null",
-        :volt10 => {
-          :warning => "3.11:3.50",
-          :critical => "2.98:3.63"
-        }
-      }
-    }
-  },
-  :networking => {
-    :interfaces => {
-      :internal_ipv4 => {
-        :interface => "eth0",
-        :role => :internal,
-        :family => :inet,
-        :address => "146.179.159.168"
-      }
-    }
-  },
-  :postgresql => {
-    :settings => {
-      :defaults => {
-        :shared_buffers => "16GB",
-        :work_mem => "32MB",
-        :maintenance_work_mem => "512MB",
-        :effective_cache_size => "45GB"
-      }
-    }
-  },
-  :sysctl => {
-    :postgres => {
-      :comment => "Increase shared memory for postgres",
-      :parameters => {
-        "kernel.shmmax" => 17 * 1024 * 1024 * 1024,
-        "kernel.shmall" => 17 * 1024 * 1024 * 1024 / 4096
-      }
-    }
-  },
-  :sysfs => {
-    :hdd_tune => {
-      :comment => "Tune the queue for improved performance",
-      :parameters => {
-        "block/sda/queue/nr_requests" => "512",
-        "block/sdb/queue/nr_requests" => "512",
-        "block/sda/queue/scheduler" => "noop",
-        "block/sdb/queue/scheduler" => "noop"
-      }
-    }
-  }
-)
-
-run_list(
-  "role[ucl]",
-  "role[db-slave]"
-)
index ada5971f9671e8962ca0811db2e99f73874a60af..904ed8138607a717381c229b0ecebde4aa79d2b8 100644 (file)
@@ -8,7 +8,9 @@ default_attributes(
         :interface => "em1",
         :role => :external,
         :family => :inet,
-        :address => "140.211.167.104"
+        :address => "140.211.167.104",
+        :prefix => "28",
+        :gateway => "140.211.167.97"
       },
       :external_ipv6 => {
         :interface => "em1",
@@ -22,5 +24,6 @@ default_attributes(
 
 run_list(
   "role[osuosl]",
-  "role[hp-dl360-g6]"
+  "role[hp-dl360-g6]",
+  "role[taginfo]"
 )
index 865ba66a0caec5cb37ff363f35f71f31910af073..47307292dd0122401964447e08e232f867d12a4c 100644 (file)
@@ -8,7 +8,9 @@ default_attributes(
         :interface => "em1",
         :role => :external,
         :family => :inet,
-        :address => "140.211.167.105"
+        :address => "140.211.167.105",
+        :prefix => "28",
+        :gateway => "140.211.167.97"
       },
       :external_ipv6 => {
         :interface => "em1",