コード例 #1
0
ファイル: Checkboxes.php プロジェクト: adisonc/MaineLearning
 function set_rule($rule)
 {
     foreach ($this->checkboxes as $ii => $checkbox) {
         $this->checkboxes[$ii]->set_rule($rule);
     }
     parent::set_rule($rule);
 }
コード例 #2
0
ファイル: Container.php プロジェクト: adisonc/MaineLearning
 /**
  *  Constructor of the class
  *
  *  @return void
  *
  *  @access private
  */
 function MyZebra_Form_Container($id = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     $this->controls = array();
     $this->attributes = array('locked' => false, 'disable_xss_filters' => false, 'disable_spam_filters' => false, 'id' => $id, 'type' => 'container', 'name' => '', 'class' => 'myzebra-container-control');
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'locked', 'repeatable', 'name', 'type');
     $this->_is_container = true;
 }
コード例 #3
0
ファイル: Captcha.php プロジェクト: adisonc/MaineLearning
 /**
  *  Adds a CAPTCHA image to the form.
  *
  *  <b>Do not instantiate this class directly! Use the {@link MyZebra_Form::add() add()} method instead!</b>
  *
  *  <b>You must also place a {@link MyZebra_Form_Text textbox} control on the form and set the "captcha" rule to it!
  *  (through {@link set_rule()})</b>
  *
  *  Properties of the CAPTCHA image can be altered by editing the file includes/captcha.php.
  *
  *  <code>
  *  // create a new form
  *  $form = new MyZebra_Form('my_form');
  *
  *  // add a CAPTCHA image
  *  $form->add('captcha', 'my_captcha', 'my_text');
  *
  *  // add a label for the textbox
  *  $form->add('label', 'label_my_text', 'my_text', 'Are you human?');
  *
  *  // add a CAPTCHA to the form
  *  // the "&" symbol is there so that $obj will be a reference to the object in PHP 4;
  *  // for PHP 5+ there is no need for it
  *  $obj = &$form->add('text', 'my_text');
  *
  *  // set the "captcha" rule to the textbox
  *  $obj->set_rule(array(
  *      'captcha' => array('error', 'Characters not entered correctly!')
  *  ));
  *
  *  // don't forget to always call this method before rendering the form
  *  if ($form->validate()) {
  *      // put code here
  *  }
  *
  *  // output the form using an automatically generated template
  *  $form->render();
  *  </code>
  *
  *  @param  string  $id             Unique name to identify the control in the form.
  *
  *                                  This is the name of the variable to be used in the template file, containing
  *                                  the generated HTML for the control.
  *
  *                                  <code>
  *                                  // in a template file, in order to print the generated HTML
  *                                  // for a control named "my_captcha", one would use:
  *                                  echo $my_captcha;
  *                                  </code>
  *
  *  @param  string  $attach_to      The <b>id</b> attribute of the {@link MyZebra_Form_Text textbox} control to attach
  *                                  the CAPTCHA image to.
  *
  *  @return void
  */
 function MyZebra_Form_Captcha($id, $attach_to)
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_xss_filters', 'for', 'locked', 'repeatable');
     // set the default attributes for the text control
     // put them in the order you'd like them rendered
     $this->set_attributes(array('type' => 'captcha', 'name' => $id, 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'for' => $attach_to));
 }
コード例 #4
0
ファイル: Messages.php プロジェクト: adisonc/MaineLearning
 function MyZebra_Form_Messages($id, $value = '', $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'locked', 'name', 'type', 'repeatable', 'errors', 'messages');
     // set the default attributes for the HTML control
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'class' => 'myzebra-messages-control', 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'name' => $id, 'type' => 'messages', 'errors' => '', 'messages' => ''));
     // sets user specified attributes for the control
     $this->set_attributes($attributes);
 }
コード例 #5
0
ファイル: Password.php プロジェクト: adisonc/MaineLearning
 /**
  *  Adds an <input type="password"> control to the form.
  *
  *  <b>Do not instantiate this class directly! Use the {@link MyZebra_Form::add() add()} method instead!</b>
  *
  *  <code>
  *  // create a new form
  *  $form = new MyZebra_Form('my_form');
  *
  *  // add a password control to the form
  *  // the "&" symbol is there so that $obj will be a reference to the object in PHP 4
  *  // for PHP 5+ there is no need for it
  *  $obj = &$form->add('password', 'my_password');
  *
  *  // don't forget to always call this method before rendering the form
  *  if ($form->validate()) {
  *      // put code here
  *  }
  *
  *  // output the form using an automatically generated template
  *  $form->render();
  *  </code>
  *
  *  @param  string  $id             Unique name to identify the control in the form.
  *
  *                                  The control's <b>name</b> attribute will be the same as the <b>id</b> attribute!
  *
  *                                  This is the name to be used when referring to the control's value in the
  *                                  POST/GET superglobals, after the form is submitted.
  *
  *                                  This is also the name of the variable to be used in custom template files, in
  *                                  order to display the control.
  *
  *                                  <code>
  *                                  // in a template file, in order to print the generated HTML
  *                                  // for a control named "my_password", one would use:
  *                                  echo $my_password;
  *                                  </code>
  *
  *  @param  string  $default        (Optional) Default value of the password field.
  *
  *  @param  array   $attributes     (Optional) An array of attributes valid for
  *                                  {@link http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4 input}
  *                                  controls (size, readonly, style, etc)
  *
  *                                  Must be specified as an associative array, in the form of <i>attribute => value</i>.
  *                                  <code>
  *                                  // setting the "disabled" attribute
  *                                  $obj = &$form->add(
  *                                      'password',
  *                                      'my_password',
  *                                      '',
  *                                      array(
  *                                          'disabled' => 'disabled'
  *                                      )
  *                                  );
  *                                  </code>
  *
  *                                  See {@link MyZebra_Form_Control::set_attributes() set_attributes()} on how to set
  *                                  attributes, other than through the constructor.
  *
  *                                  The following attributes are automatically set when the control is created and
  *                                  should not be altered manually:<br>
  *
  *                                  <b>type</b>, <b>id</b>, <b>name</b>, <b>value</b>, <b>class</b>
  *
  *  @return void
  */
 function MyZebra_Form_Password($id, $default = '', $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_spam_filter', 'default_value', 'disable_xss_filters', 'locked', 'repeatable');
     // set the default attributes for the button control
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'type' => 'password', 'name' => $id, 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'value' => $default, 'class' => 'myzebra-control myzebra-password', 'placeholder' => ''));
     // sets user specified attributes for the control
     $this->set_attributes($attributes);
 }
コード例 #6
0
ファイル: Image.php プロジェクト: adisonc/MaineLearning
 /**
  *  Adds an <input type="image"> control to the form.
  *
  *  <b>Do not instantiate this class directly! Use the {@link MyZebra_Form::add() add()} method instead!</b>
  *
  *  <code>
  *  // create a new form
  *  $form = new MyZebra_Form('my_form');
  *
  *  // add an image control to the form
  *  // the "&" symbol is there so that $obj will be a reference to the object in PHP 4
  *  // for PHP 5+ there is no need for it
  *  $obj = &$form->add('image', 'my_image', 'path/to/image');
  *
  *  // don't forget to always call this method before rendering the form
  *  if ($form->validate()) {
  *      // put code here
  *  }
  *
  *  // output the form using an automatically generated template
  *  $form->render();
  *  </code>
  *
  *  @param  string  $id             Unique name to identify the control in the form.
  *
  *                                  The control's <b>name</b> attribute will be the same as the <b>id</b> attribute!
  *
  *                                  This is the name to be used when referring to the control's value in the
  *                                  POST/GET superglobals, after the form is submitted.
  *
  *                                  This is also the name of the variable to be used in custom template files, in
  *                                  order to display the control.
  *
  *                                  <code>
  *                                  // in a template file, in order to print the generated HTML
  *                                  // for a control named "my_image", one would use:
  *                                  echo $my_image;
  *                                  </code>
  *
  *  @param  string  $src            (Optional) Path to an image file.
  *
  *  @param  array   $attributes     (Optional) An array of attributes valid for
  *                                  {@link http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4 input}
  *                                  controls (size, readonly, style, etc)
  *
  *                                  Must be specified as an associative array, in the form of <i>attribute => value</i>.
  *                                  <code>
  *                                  // setting the "alt" attribute
  *                                  $obj = &$form->add(
  *                                      'image',
  *                                      'my_image',
  *                                      'path/to/image',
  *                                      array(
  *                                          'alt' => 'Click to submit form'
  *                                      )
  *                                  );
  *                                  </code>
  *
  *                                  See {@link MyZebra_Form_Control::set_attributes() set_attributes()} on how to set
  *                                  attributes, other than through the constructor.
  *
  *                                  The following attributes are automatically set when the control is created and
  *                                  should not be altered manually:<br>
  *
  *                                  <b>type</b>, <b>id</b>, <b>name</b>, <b>src</b>, <b>class</b>
  *
  *  @return void
  */
 function MyZebra_Form_Image($id, $src, $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'locked', 'repeatable', 'display_featured', 'display_featured_html');
     // set the default attributes for the image control
     // put them in the order you'd like them rendered
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'type' => 'image', 'name' => $id, 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'src' => $src, 'class' => 'myzebra-image', 'display_featured' => false, 'display_featured_html' => ''));
     // sets user specified attributes for the table cell
     $this->set_attributes($attributes);
 }
コード例 #7
0
 function MyZebra_Form_Taxonomyhierarchicaladdnew($id, $default = '', $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'locked', 'default_value', 'repeatable', 'master_taxonomy_id', 'add_new_text', 'add_text', 'parent_text');
     // set the default attributes for the text control
     // put them in the order you'd like them rendered
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'type' => 'text', 'name' => $id, 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'value' => $default, 'class' => 'myzebra-control myzebra-taxonomy-hierarchical-addnew', 'master_taxonomy_id' => '', 'add_new_text' => '', 'add_text' => '', 'parent_text' => ''));
     // sets user specified attributes for the control
     $this->set_attributes($attributes);
 }
コード例 #8
0
 function MyZebra_Form_Taxonomypopular($id, $default = '', $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'locked', 'default_value', 'repeatable', 'popular', 'master_taxonomy_id', 'min_font_size', 'max_font_size', 'font_unit', 'show_popular_text', 'hide_popular_text');
     // set the default attributes for the text control
     // put them in the order you'd like them rendered
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'type' => 'text', 'name' => $id, 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'value' => $default, 'class' => 'myzebra-control myzebra-taxonomy-popular', 'popular' => array(), 'master_taxonomy_id' => '', 'min_font_size' => 11, 'max_font_size' => 32, 'font_unit' => 'pt', 'show_popular_text' => 'Show Popular', 'hide_popular_text' => 'Hide Popular'));
     // sets user specified attributes for the control
     $this->set_attributes($attributes);
 }
コード例 #9
0
ファイル: Skype.php プロジェクト: adisonc/MaineLearning
 /**
  *  Adds an <input type="text"> control to the form.
  *
  *  <b>Do not instantiate this class directly! Use the {@link MyZebra_Form::add() add()} method instead!</b>
  *
  *  <code>
  *  // create a new form
  *  $form = new MyZebra_Form('my_form');
  *
  *  // add a text control to the form
  *  // the "&" symbol is there so that $obj will be a reference to the object in PHP 4
  *  // for PHP 5+ there is no need for it
  *  $obj = &$form->add('text', 'my_text');
  *
  *  // don't forget to always call this method before rendering the form
  *  if ($form->validate()) {
  *      // put code here
  *  }
  *
  *  // output the form using an automatically generated template
  *  $form->render();
  *  </code>
  *
  *  @param  string  $id             Unique name to identify the control in the form.
  *
  *                                  The control's <b>name</b> attribute will be the same as the <b>id</b> attribute!
  *
  *                                  This is the name to be used when referring to the control's value in the
  *                                  POST/GET superglobals, after the form is submitted.
  *
  *                                  This is also the name of the variable to be used in custom template files, in
  *                                  order to display the control.
  *
  *                                  <code>
  *                                  // in a template file, in order to print the generated HTML
  *                                  // for a control named "my_text", one would use:
  *                                  echo $my_text;
  *                                  </code>
  *
  *  @param  string  $default        (Optional) Default value of the text box.
  *
  *  @param  array   $attributes     (Optional) An array of attributes valid for
  *                                  {@link http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4 input}
  *                                  controls (size, readonly, style, etc)
  *
  *                                  Must be specified as an associative array, in the form of <i>attribute => value</i>.
  *                                  <code>
  *                                  // setting the "readonly" attribute
  *                                  $obj = &$form->add(
  *                                      'text',
  *                                      'my_text',
  *                                      '',
  *                                      array(
  *                                          'readonly' => 'readonly'
  *                                      )
  *                                  );
  *                                  </code>
  *
  *                                  See {@link MyZebra_Form_Control::set_attributes() set_attributes()} on how to set
  *                                  attributes, other than through the constructor.
  *
  *                                  The following attributes are automatically set when the control is created and
  *                                  should not be altered manually:<br>
  *
  *                                  <b>type</b>, <b>id</b>, <b>name</b>, <b>value</b>, <b>class</b>
  *
  *  @return void
  */
 function MyZebra_Form_Skype($id, $default = '', $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'locked', 'default_value', 'edit_skype_text', '_nonce', 'ajax_url', 'repeatable');
     // set the default attributes for the text control
     // put them in the order you'd like them rendered
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'type' => 'skype', 'name' => $id, 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'value' => array(), 'class' => 'myzebra-control myzebra-skype myzebra-text', 'edit_skype_text' => '', '_nonce' => '', 'ajax_url' => ''));
     // sets user specified attributes for the control
     $this->set_attributes($attributes);
 }
コード例 #10
0
ファイル: Wysiwyg.php プロジェクト: adisonc/MaineLearning
 /**
  *  Adds an <textarea> control to the form.
  *
  *  <b>Do not instantiate this class directly! Use the {@link MyZebra_Form::add() add()} method instead!</b>
  *
  *  <code>
  *  // create a new form
  *  $form = new MyZebra_Form('my_form');
  *
  *  // add a textarea control to the form
  *  // the "&" symbol is there so that $obj will be a reference to the object in PHP 4
  *  // for PHP 5+ there is no need for it
  *  $obj = &$form->add('textarea', 'my_textarea');
  *
  *  // don't forget to always call this method before rendering the form
  *  if ($form->validate()) {
  *      // put code here
  *  }
  *
  *  // output the form using an automatically generated template
  *  $form->render();
  *  </code>
  *
  *  @param  string  $id             Unique name to identify the control in the form.
  *
  *                                  The control's <b>name</b> attribute will be the same as the <b>id</b> attribute!
  *
  *                                  This is the name to be used when referring to the control's value in the
  *                                  POST/GET superglobals, after the form is submitted.
  *
  *                                  This is also the name of the variable to be used in custom template files, in
  *                                  order to display the control.
  *
  *                                  <code>
  *                                  // in a template file, in order to print the generated HTML
  *                                  // for a control named "my_textarea", one would use:
  *                                  echo $my_textarea;
  *                                  </code>
  *
  *  @param  string  $default        (Optional) Default value of the textarea.
  *
  *  @param  array   $attributes     (Optional) An array of attributes valid for
  *                                  <b>{@link http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.7 textarea}</b>
  *                                  controls (rows, cols, style, etc)
  *
  *                                  Must be specified as an associative array, in the form of <i>attribute => value</i>.
  *                                  <code>
  *                                  // setting the "rows" attribute
  *                                  $obj = &$form->add(
  *                                      'textarea',
  *                                      'my_textarea',
  *                                      '',
  *                                      array(
  *                                          'rows' => 10
  *                                      )
  *                                  );
  *                                  </code>
  *
  *                                  See {@link MyZebra_Form_Control::set_attributes() set_attributes()} on how to set
  *                                  attributes, other than through the constructor.
  *
  *                                  The following attributes are automatically set when the control is created and
  *                                  should not be altered manually:<br>
  *
  *                                  <b>id</b>, <b>name</b>, <b>class</b>
  *
  *  @return void
  */
 function MyZebra_Form_Wysiwyg($id, $default = '', $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('default_value', 'disable_xss_filters', 'disable_spam_filter', 'locked', 'type', 'value', 'repeatable', 'has_media_button');
     // set the default attributes for the textarea control
     // put them in the order you'd like them rendered
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => true, 'name' => $id, 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'rows' => 5, 'cols' => '80', 'class' => 'myzebra-control myzebra-textarea myzebra-wysiwyg', 'type' => 'textarea', 'value' => $default, 'has_media_button' => false));
     // sets user specified attributes for the control
     $this->set_attributes($attributes);
 }
コード例 #11
0
ファイル: Taxonomy.php プロジェクト: adisonc/MaineLearning
 function MyZebra_Form_Taxonomy($id, $default = '', $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'locked', 'default_value', 'terms', 'add_text', 'remove_text', 'auto_suggest', 'ajax_url', 'repeatable');
     // set the default attributes for the text control
     // put them in the order you'd like them rendered
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'type' => 'text', 'name' => $id, 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'value' => $default, 'class' => 'myzebra-taxonomy-control myzebra-taxonomy', 'terms' => array(), 'add_text' => 'Add', 'remove_text' => 'Remove', 'auto_suggest' => false, 'ajax_url' => ''));
     // sets user specified attributes for the control
     $this->set_attributes($attributes);
     $this->submitted_value = 'add{}remove{}';
 }
コード例 #12
0
ファイル: Hidden.php プロジェクト: adisonc/MaineLearning
 /**
  *  Adds an <input type="hidden"> control to the form.
  *
  *  <b>Do not instantiate this class directly! Use the {@link MyZebra_Form::add() add()} method instead!</b>
  *
  *  <code>
  *  // create a new form
  *  $form = new MyZebra_Form('my_form');
  *
  *  // add a hidden control to the form
  *  // the "&" symbol is there so that $obj will be a reference to the object in PHP 4
  *  // for PHP 5+ there is no need for it
  *  $obj = &$form->add('hidden', 'my_hidden', 'Secret value');
  *
  *  // don't forget to always call this method before rendering the form
  *  if ($form->validate()) {
  *      // put code here
  *  }
  *
  *  // output the form using an automatically generated template
  *  $form->render();
  *  </code>
  *
  *  @param  string  $id             Unique name to identify the control in the form.
  *
  *                                  The control's <b>name</b> attribute will be the same as the <b>id</b> attribute!
  *
  *                                  This is the name to be used when referring to the control's value in the
  *                                  POST/GET superglobals, after the form is submitted.
  *
  *                                  <b>Hidden controls are automatically rendered when the {@link MyZebra_Form::render() render()}
  *                                  method is called!</b><br>
  *                                  <b>Do not print them in template files!</b>
  *
  *  @param  string  $default        (Optional) Default value of the text box.
  *
  *  @return void
  */
 function MyZebra_Form_Hidden($id, $default = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'locked', 'repeatable', 'default', 'user-defined');
     // set the default attributes for the hidden control
     // put them in the order you'd like them rendered
     // notice that if control's name is 'MAX_FILE_SIZE' we'll generate a random ID attribute for the control
     // as, with multiple forms having upload controls on them, this hidden control appears as many times as the
     // forms do and we don't want to have the same ID assigned to multiple controls
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'type' => 'hidden', 'name' => $id, 'id' => $id != 'MAX_FILE_SIZE' ? preg_replace('/\\[.*\\]$/', '', $id) : 'mfs_' . rand(0, 100000), 'value' => $default, 'user_defined' => false));
 }
コード例 #13
0
ファイル: Radios.php プロジェクト: adisonc/MaineLearning
 function MyZebra_Form_Radios($id, $radios, $labels)
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'locked', 'repeatable');
     $this->radios = $radios;
     $this->labels = $labels;
     // set the default attributes for the radio button control
     // put them in the order you'd like them rendered
     $this->set_attributes($this->radios[0]->attributes);
     $this->attributes['id'] = $id;
     // sets user specified attributes for the control
     //$this->set_attributes($attributes);
 }
コード例 #14
0
 /**
  *  Constructor of the class
  *
  *  @return void
  *
  *  @access private
  */
 function MyZebra_Form_RepeatableControl(&$control)
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     $this->controls = array();
     $this->mastercontrol =& $control;
     $this->prime_name = $control->prime_name;
     $this->mastercontrol->set_attributes(array('repeatable' => true));
     if (isset($this->mastercontrol->javascript_attributes)) {
         $this->javascript_attributes =& $this->mastercontrol->javascript_attributes;
     } else {
         $this->javascript_attributes = null;
     }
     $this->rules = $this->mastercontrol->rules;
     $this->attributes = $this->mastercontrol->attributes;
     $this->private_attributes = $this->mastercontrol->private_attributes;
     $this->controls[] = clone $this->mastercontrol;
 }
コード例 #15
0
ファイル: Time.php プロジェクト: adisonc/MaineLearning
 /**
  *  Adds a time picker control to the form.
  *
  *  <b>Do not instantiate this class directly! Use the {@link MyZebra_Form::add() add()} method instead!</b>
  *
  *  The output of this control will be one, two, three or four {@link MyZebra_Form_Select select} controls for hour,
  *  minutes, seconds and AM/PM respectively, according to the given format as set by the <i>$attributes</i> argument.
  *
  *  Note that even though there will be more select boxes, the submitted values will be available as a single merged
  *  value (in the form of hh:mm:ss AM/PM, depending on the format), with the name as given by the <i>id</i> argument.
  *
  *  <code>
  *  // create a new form
  *  $form = new MyZebra_Form('my_form');
  *
  *  // add a time picker control for hour and minutes
  *  // the "&" symbol is there so that $obj will be a reference to the object in PHP 4
  *  // for PHP 5+ there is no need for it
  *  $obj = &$form->add('time', 'my_time', date('H:i'), array('format' => 'hm'));
  *
  *  // don't forget to always call this method before rendering the form
  *  if ($form->validate()) {
  *
  *      // note that even though there will be more select boxes, the submitted
  *      // values will be available as a single merged value (in the form of
  *      // mm:mm:ss AM/PM, depending on the format), with the name as given by
  *      // the "id" argument:
  *      echo $_POST['my_time'];
  *
  *  }
  *
  *  // output the form using an automatically generated template
  *  $form->render();
  *  </code>
  *
  *  @param  string  $id             Unique name to identify the control in the form.
  *
  *                                  The control's <b>name</b> attribute will be the same as the <b>id</b> attribute!
  *
  *                                  This is the name to be used when referring to the control's value in the
  *                                  POST/GET superglobals, after the form is submitted.
  *
  *                                  This is also the name of the variable to be used in custom template files, in
  *                                  order to display the control.
  *
  *                                  <code>
  *                                  // in a template file, in order to print the generated HTML
  *                                  // for a control named "my_time", one would use:
  *                                  echo $my_time;
  *                                  </code>
  *
  *  @param  string  $default        (Optional) String representing the default time to be shown. Must be set according
  *                                  to the format of the time, as specified in <i>$attributes</i>. For example, for a
  *                                  time format of "hm", one would set the default time in the form of "hh:mm" while
  *                                  for a time format of "hms", one would set the time in the form of "hh:mm:ss".
  *
  *                                  Default is current system time.
  *
  *  @param  array   $attributes     (Optional) An array of user specified attributes valid for an time picker
  *                                  control (format, hours, minutes, seconds, am/pm).
  *
  *                                  Must be specified as an associative array, in the form of <i>attribute => value</i>.
  *
  *                                  Available attributes are:
  *
  *                                  -   format - format of time; a string containing one, or a combination of the four
  *                                      allowed characters: "h" (hours), "m" (minutes) and "s" (seconds) and "g" for
  *                                      using 12-hours format instead of the default 23-hours format; (i.e. setting the
  *                                      format to "hm" would allow the selection of hours and minutes, setting the
  *                                      format to "hms" would allow the selection of hours, minutes and seconds, and
  *                                      setting the format to "hmg" would allow the selection of hours and minutes
  *                                      using the 12-hours format instead of the 24-hours format)
  *
  *                                  -   hours - an array of selectable hours (i.e. array(10, 11, 12))
  *
  *                                  -   minutes - an array of selectable minutes (i.e. array(15, 30, 45))
  *
  *                                  -   seconds - an array of selectable seconds
  *
  *                                  See {@link MyZebra_Form_Control::set_attributes() set_attributes()} on how to set
  *                                  attributes, other than through the constructor.
  *
  *  @return void
  */
 function MyZebra_Form_Time($id, $default = '', $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // these will hold the default selectable hours, minutes and seconds
     $hours = $minutes = $seconds = array();
     // all the 24 hours are available by default
     for ($i = 0; $i < 24; $i++) {
         $hours[] = $i;
     }
     // all the minutes and seconds are available by default
     for ($i = 0; $i < 60; $i++) {
         $minutes[] = $seconds[] = $i;
     }
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'locked', 'repeatable');
     // set the default attributes for the text control
     // put them in the order you'd like them rendered
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'type' => 'time', 'name' => $id, 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'value' => $default, 'class' => 'myzebra-control myzebra-time', 'format' => 'hm', 'hours' => $hours, 'minutes' => $minutes, 'seconds' => $seconds));
     // sets user specified attributes for the control
     $this->set_attributes($attributes);
 }
コード例 #16
0
ファイル: Checkbox.php プロジェクト: adisonc/MaineLearning
 /**
  *  Adds an <input type="checkbox"> control to the form.
  *
  *  <b>Do not instantiate this class directly! Use the {@link MyZebra_Form::add() add()} method instead!</b>
  *
  *  <code>
  *  // create a new form
  *  $form = new MyZebra_Form('my_form');
  *
  *  // single checkbox
  *  // the "&" symbol is there so that $obj will be a reference to the object in PHP 4
  *  // for PHP 5+ there is no need for it
  *  $obj = &$form->add('checkbox', 'my_checkbox', 'my_checkbox_value');
  *
  *  // multiple checkboxes
  *  // notice that is "checkboxes" instead of "checkbox"
  *  // label controls will be automatically created having the names "more_checkboxes_value_1",
  *  // "more_checkboxes_value_2" and so on
  *  // $obj is a reference to the first checkbox
  *  // checkboxes values will be "0", "1" and "2", respectively
  *  $obj = &$form->add('checkboxes', 'more_checkboxes',
  *      array(
  *          'Value 1',
  *          'Value 2',
  *          'Value 3'
  *      )
  *  );
  *
  *  // multiple checkboxes with specific indexes
  *  // checkboxes values will be "v1", "v2" and "v3", respectively
  *  // label controls will be automatically created having the names "some_more_checkboxes_value_1",
  *  // "some_more_checkboxes_value_2" and so on
  *  $obj = &$form->add('checkboxes', 'some_more_checkboxes',
  *      array(
  *          'v1' => 'Value 1',
  *          'v2' => 'Value 2',
  *          'v3' => 'Value 3'
  *      )
  *  );
  *
  *  // multiple checkboxes with preselected value
  *  // "Value 2" will be the preselected value
  *  // note that for preselecting values you must use the actual indexes of the values, if available, (like
  *  // in the current example) or the default, zero-based index, otherwise (like in the next example)
  *  // label controls will be automatically created having the names "and_some_more_checkboxes_value_v1",
  *  // "and_some_more_checkboxes_value_v2" and so on
  *  $obj = &$form->add('checkboxes', 'and_some_more_checkboxes',
  *      array(
  *          'v1'    =>  'Value 1',
  *          'v2'    =>  'Value 2',
  *          'v3'    =>  'Value 3'
  *      ),
  *      'v2'    // note the index!
  *  );
  *
  *  // "Value 2" will be the preselected value.
  *  // note that for preselecting values you must use the actual indexes of the values, if available, (like
  *  // in the example above) or the default, zero-based index, otherwise (like in the current example)
  *  // label controls will be automatically created having the names "and_some_more_checkboxes_value_0",
  *  // "and_some_more_checkboxes_value_1" and so on
  *  $obj = &$form->add('checkboxes', 'and_some_more_checkboxes',
  *      array(
  *          'Value 1',
  *          'Value 2',
  *          'Value 3'
  *      ),
  *      1    // note the index!
  *  );
  *
  *  // multiple checkboxes with multiple preselected values
  *  $obj = &$form->add('checkboxes', 'other_checkboxes[]',
  *      array(
  *          'v1'    =>  'Value 1',
  *          'v2'    =>  'Value 2',
  *          'v3'    =>  'Value 3'
  *      ),
  *      array('v1', 'v2')
  *  );
  *
  *  // don't forget to always call this method before rendering the form
  *  if ($form->validate()) {
  *      // put code here
  *  }
  *
  *  // output the form using an automatically generated template
  *  $form->render();
  *  </code>
  *
  *  <samp>By default, for checkboxes, radio buttons and select boxes, the library will prevent the submission of other
  *  values than those declared when creating the form, by triggering the error: "SPAM attempt detected!". Therefore,
  *  if you plan on adding/removing values dynamically, from JavaScript, you will have to call the
  *  {@link MyZebra_Form_Control::disable_spam_filter() disable_spam_filter()} method to prevent that from happening!</samp>
  *
  *  @param  string  $id             Unique name to identify the control in the form.
  *
  *                                  <b>$id needs to be suffixed with square brackets if there are more checkboxes
  *                                  sharing the same name, so that PHP treats them as an array!</b>
  *
  *                                  The control's <b>name</b> attribute will be as indicated by <i>$id</i>
  *                                  argument while the control's <b>id</b> attribute will be <i>$id</i>, stripped of
  *                                  square brackets (if any), followed by an underscore and followed by <i>$value</i>
  *                                  with all the spaces replaced by <i>underscores</i>.
  *
  *                                  So, if the <i>$id</i> arguments is "my_checkbox" and the <i>$value</i> argument
  *                                  is "value 1", the control's <b>id</b> attribute will be <b>my_checkbox_value_1</b>.
  *
  *                                  This is the name to be used when referring to the control's value in the
  *                                  POST/GET superglobals, after the form is submitted.
  *
  *                                  This is also the name of the variable to be used in custom template files, in
  *                                  order to display the control.
  *
  *                                  <code>
  *                                  // in a template file, in order to print the generated HTML
  *                                  // for a control named "my_checkbox" and having the value of "value 1",
  *                                  // one would use:
  *                                  echo $my_checkbox_value_1;
  *                                  </code>
  *
  *                                  <i>Note that when adding the required rule to a group of checkboxes (checkboxes
  *                                  sharing the same name), it is sufficient to add the rule to the first checkbox!</i>
  *
  *  @param  mixed   $value          Value of the checkbox.
  *
  *  @param  array   $attributes     (Optional) An array of attributes valid for
  *                                  {@link http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4 input}
  *                                  controls (disabled, readonly, style, etc)
  *
  *                                  Must be specified as an associative array, in the form of <i>attribute => value</i>.
  *                                  <code>
  *                                  // setting the "checked" attribute
  *                                  $obj = &$form->add(
  *                                      'checkbox',
  *                                      'my_checkbox',
  *                                      'v1',
  *                                      array(
  *                                          'checked' => 'checked'
  *                                      )
  *                                  );
  *                                  </code>
  *
  *                                  See {@link MyZebra_Form_Control::set_attributes() set_attributes()} on how to set
  *                                  attributes, other than through the constructor.
  *
  *                                  The following attributes are automatically set when the control is created and
  *                                  should not be altered manually:<br>
  *
  *                                  <b>type</b>, <b>id</b>, <b>name</b>, <b>value</b>, <b>class</b>
  *
  *  @return void
  */
 function MyZebra_Form_Checkbox($id, $value, $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'locked', 'repeatable', 'actual_value');
     // set the default attributes for the checkbox control
     // put them in the order you'd like them rendered
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'type' => 'checkbox', 'name' => $id, 'id' => str_replace(array(' ', '[', ']'), array('_', ''), preg_replace('/\\[.*\\]$/', '', $id)) . '_' . str_replace(' ', '_', $value), 'value' => $value, 'class' => 'myzebra-control myzebra-checkbox', 'actual_value' => ''));
     // sets user specified attributes for the control
     $this->set_attributes($attributes);
 }
コード例 #17
0
ファイル: Label.php プロジェクト: adisonc/MaineLearning
 /**
  *  Add an <label> control to the form.
  *
  *  <b>Do not instantiate this class directly! Use the {@link MyZebra_Form::add() add()} method instead!</b>
  *
  *  <code>
  *  // create a new form
  *  $form = new MyZebra_Form('my_form');
  *
  *  // add a label, attached to a textbox control
  *  $form->add('label', 'label_my_text', 'my_text', 'Enter some text:');
  *
  *  // add a text control to the form
  *  // the "&" symbol is there so that $obj will be a reference to the object in PHP 4
  *  // for PHP 5+ there is no need for it
  *  $obj = &$form->add('text', 'my_text');
  *
  *  // don't forget to always call this method before rendering the form
  *  if ($form->validate()) {
  *      // put code here
  *  }
  *
  *  // output the form using an automatically generated template
  *  $form->render();
  *  </code>
  *
  *  @param  string  $id             Unique name to identify the control in the form.
  *
  *                                  This is the name of the variable to be used in the template file, containing
  *                                  the generated HTML for the control.
  *
  *                                  <code>
  *                                  // in a template file, in order to print the generated HTML
  *                                  // for a control named "my_label", one would use:
  *                                  echo $my_label;
  *                                  </code>
  *
  *  @param  string  $attach_to      The <b>id</b> attribute of the control to attach the note to.
  *
  *                                  <i>Notice that this must be the "id" attribute of the control you are attaching
  *                                  the label to, and not the "name" attribute!</i>
  *
  *                                  This is important as while most of the controls have their <b>id</b> attribute
  *                                  set to the same value as their <b>name</b> attribute, for {@link MyZebra_Form_Checkbox checkboxes},
  *                                  {@link MyZebra_Form_Select selects} and {@link MyZebra_Form_Radio radio&nbsp;buttons} this
  *                                  is different.
  *
  *                                  <b>Exception to the rule:</b>
  *
  *                                  Just like in the case of {@link MyZebra_Form_Note notes}, if you want a <b>master</b>
  *                                  label, a label that is attached to a <b>group</b> of checkboxes/radio buttons
  *                                  rather than individual controls, this attribute must instead refer to the <b>name</b>
  *                                  of the controls (which, for groups of checkboxes/radio buttons, is one and the same).
  *                                  This is important because if the group of checkboxes/radio buttons have the
  *                                  <i>required</i> rule set, this is the only way in which the "required" symbol
  *                                  (the red asterisk) will be attached to the master label instead of being attached
  *                                  to the first checkbox/radio button from the group.
  *
  *  @param  mixed   $caption        Caption of the label.
  *
  *                                  <i>Putting a $ (dollar) sign before a character will turn that specific character into
  *                                  the accesskey.</i><br>
  *                                  <i>If you need the dollar sign in the label, escape it with</i> \ <i>(backslash)</i>
  *
  *  @param  array   $attributes     (Optional) An array of attributes valid for
  *                                  {@link http://www.w3.org/TR/REC-html40/interact/forms.html#edef-LABEL label}
  *                                  elements (style, etc)
  *
  *                                  Must be specified as an associative array, in the form of <i>attribute => value</i>.
  *                                  <code>
  *                                  // setting the "style" attribute
  *                                  $obj = &$form->add(
  *                                      'label',
  *                                      'label_my_text',
  *                                      'my_text',
  *                                      'My Label:'
  *                                      array(
  *                                          'style' => 'font-weight: normal'
  *                                      )
  *                                  );
  *                                  </code>
  *
  *                                  <b>Special attribute:</b>
  *
  *                                  When setting the special attribute <b>inside</b> to <b>true</b>, the label will
  *                                  appear inside the control is attached to (if the control the label is attached to
  *                                  is a {@link MyZebra_Form_Text textbox} or a {@link MyZebra_Form_Textarea textarea}) and
  *                                  will disappear when the control will receive focus. When the inside attribute is
  *                                  set to TRUE, the label will not be available in the template file as it will be
  *                                  contained by the control the label is attached to!
  *
  *                                  <code>
  *                                  $form->add('label', 'my_label', 'my_control', 'My Label:', array('inside' => true));
  *                                  </code>
  *
  *                                  See {@link MyZebra_Form_Control::set_attributes() set_attributes()} on how to set
  *                                  attributes, other than through the constructor.
  *
  *                                  The following attributes are automatically set when the control is created and
  *                                  should not be altered manually:<br>
  *                                  <b>id</b>, <b>for</b>
  *
  *  @return void
  */
 function MyZebra_Form_Label($id, $attach_to, $caption, $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'inside', 'label', 'locked', 'for_group', 'name', 'type', 'repeatable');
     // set the default attributes for the label
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'for' => $attach_to, 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'label' => $caption, 'name' => $id, 'type' => 'label'));
     // sets user specified attributes for the table cell
     $this->set_attributes($attributes);
 }
コード例 #18
0
ファイル: Recaptcha.php プロジェクト: adisonc/MaineLearning
 function MyZebra_Form_Recaptcha($id, $messages, $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_spam_filter', 'disable_xss_filters', 'locked', 'default_value', 'open', 'repeatable', 'value', 'public_key', 'private_key', 'error_message', 'show_link', 'no_keys');
     // set the default attributes for the text control
     // put them in the order you'd like them rendered
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'type' => 'text', 'name' => $id, 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'value' => '', 'class' => 'myzebra-control myzebra-recaptcha', 'open' => false, 'public_key' => '', 'private_key' => '', 'error_message' => '', 'show_link' => '', 'no_keys' => ''));
     // sets user specified attributes for the control
     $this->set_attributes($attributes);
 }
コード例 #19
0
ファイル: Date.php プロジェクト: adisonc/MaineLearning
 /**
  *  Adds a date control to the form.
  *
  *  <b>Do not instantiate this class directly! Use the {@link MyZebra_Form::add() add()} method instead!</b>
  *
  *  The output of this control will be a {@link MyZebra_Form_Text textbox} control with an icon to the right of it.<br>
  *  Clicking the icon will open an inline JavaScript date picker.<br>
  *
  *  <code>
  *  // create a new form
  *  $form = new MyZebra_Form('my_form');
  *
  *  // add a date control to the form
  *  // the "&" symbol is there so that $obj will be a reference to the object in PHP 4
  *  // for PHP 5+ there is no need for it
  *  $obj = &$form->add('date', 'my_date', date('Y-m-d'));
  *
  *  // set the date's format
  *  $obj->format('Y-m-d');
  *
  *  // don't forget to always call this method before rendering the form
  *  if ($form->validate()) {
  *      // put code here
  *  }
  *
  *  // output the form using an automatically generated template
  *  $form->render();
  *  </code>
  *
  *  @param  string  $id             Unique name to identify the control in the form.
  *
  *                                  The control's <b>name</b> attribute will be the same as the <b>id</b> attribute!
  *
  *                                  This is the name to be used when referring to the control's value in the
  *                                  POST/GET superglobals, after the form is submitted.
  *
  *                                  This is also the name of the variable to be used in custom template files, in
  *                                  order to display the control.
  *
  *                                  <code>
  *                                  // in a template file, in order to print the generated HTML
  *                                  // for a control named "my_date", one would use:
  *                                  echo $my_date;
  *                                  </code>
  *
  *  @param  string  $default        (Optional) Default date, formatted according to {@link format() format}.
  *
  *  @param  array   $attributes     (Optional) An array of attributes valid for
  *                                  {@link http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4 input}
  *                                  controls (size, readonly, style, etc)
  *
  *                                  Must be specified as an associative array, in the form of <i>attribute => value</i>.
  *                                  <code>
  *                                  // setting the "readonly" attribute
  *                                  $obj = &$form->add(
  *                                      'date',
  *                                      'my_date',
  *                                      '',
  *                                      array(
  *                                          'readonly' => 'readonly'
  *                                      )
  *                                  );
  *                                  </code>
  *
  *                                  See {@link MyZebra_Form_Control::set_attributes() set_attributes()} on how to set
  *                                  attributes, other than through the constructor.
  *
  *                                  The following attributes are automatically set when the control is created and
  *                                  should not be altered manually:<br>
  *
  *                                  <b>type</b>, <b>id</b>, <b>name</b>, <b>value</b>, <b>class</b>
  *
  *  @return void
  */
 function MyZebra_Form_Date($id, $default = '', $attributes = '')
 {
     // call the constructor of the parent class
     parent::MyZebra_Form_Control();
     // set the private attributes of this control
     // these attributes are private for this control and are for internal use only
     // and will not be rendered by the _render_attributes() method
     $this->private_attributes = array('disable_spam_filter', 'locked', 'disable_xss_filters', 'date', 'always_show_clear', 'always_visible', 'days', 'direction', 'disabled_dates', 'first_day_of_week', 'format', 'inside_icon', 'months', 'offset', 'pair', 'readonly_element', 'show_week_number', 'start_date', 'view', 'weekend_days', 'repeatable');
     // set the javascript attributes of this control
     // these attributes will be used by the JavaScript date picker object
     $this->javascript_attributes = array('always_show_clear', 'always_visible', 'days', 'disabled_dates', 'direction', 'first_day_of_week', 'format', 'inside_icon', 'months', 'offset', 'pair', 'readonly_element', 'show_week_number', 'start_date', 'view', 'weekend_days');
     // set the default attributes for the text control
     // put them in the order you'd like them rendered
     $this->set_attributes(array('disable_spam_filter' => false, 'disable_xss_filters' => false, 'type' => 'text', 'name' => $id, 'id' => preg_replace('/\\[.*\\]$/', '', $id), 'value' => $default, 'class' => 'myzebra-control myzebra-text myzebra-date', 'always_show_clear' => null, 'always_visible' => null, 'days' => null, 'direction' => null, 'disabled_dates' => null, 'first_day_of_week' => null, 'format' => 'Y-m-d', 'inside_icon' => null, 'months' => null, 'offset' => null, 'pair' => null, 'readonly_element' => null, 'show_week_number' => null, 'start_date' => null, 'view' => null, 'weekend_days' => null));
     // sets user specified attributes for the control
     $this->set_attributes($attributes);
 }