示例#1
0
 function grab()
 {
     $value = $this->grab_value();
     if (!$this->userland_changeable && $value !== NULL && $value != $this->get() && preg_replace('/\\s+/', '', $value) != preg_replace('/\\s+/', '', $this->get())) {
         trigger_error('hidden element (' . $this->name . ') value changed in userland (' . $value . ' != ' . $this->get() . '). If you wish to permit userland changes to this field, set the userland_changeable param.');
     }
     parent::grab();
 }
示例#2
0
 function grab()
 {
     parent::grab();
     $length = strlen($this->value);
     $length_limits = array('tinytext' => 255, 'text' => 65535, 'mediumtext' => 16777215);
     if (!empty($this->db_type) && array_key_exists($this->db_type, $length_limits)) {
         if ($length > $length_limits[$this->db_type]) {
             $name_to_display = trim($this->display_name);
             if (empty($name_to_display)) {
                 $name_to_display = prettify_string($this->name);
             }
             $this->set_error('There is more text in ' . $name_to_display . ' than can be stored; this field can hold no more than ' . $length_limits[$this->db_type] . ' characters.');
         }
     }
 }
示例#3
0
 /**
  * Finds the value of this element from userland (in {@link _request}) and returns it
  * @return mixed array, integer, or string if available, otherwise NULL if no value from userland
  */
 function grab_value()
 {
     $value = parent::grab_value();
     if ($this->_array_val_ok() && !empty($this->disabled_options)) {
         $val_array = is_array($this->value) ? $this->value : array($this->value);
         if ($disabled_selected = array_intersect($this->disabled_options, $val_array, array_keys($this->options))) {
             if (is_array($value)) {
                 $value = array_merge($value, $disabled_selected);
             } elseif (!is_null($value)) {
                 $value = array_merge(array($value), $disabled_selected);
             } else {
                 $value = $disabled_selected;
             }
         }
     }
     if ($this->_array_val_ok() && is_array($value)) {
         foreach ($value as $k => $v) {
             if (!$this->_validate_submitted_value($v)) {
                 unset($value[$k]);
             }
         }
         return $value;
     } elseif ($this->_string_val_ok() && $this->_validate_submitted_value($value)) {
         return $value;
     }
     return NULL;
 }
 public function getCourseName($blti)
 {
     return parent::getCourseName($blti);
 }
示例#5
0
 function init($args = array())
 {
     parent::init($args);
     // $attachPoints = array('init','on_first_time','on_every_time','pre_show_form','post_show_form','no_show_form','pre_error_check_actions','run_error_checks','post_error_check_actions','post_error_checks','process','where_to');
     // foreach ($attachPoints as $ap) { $this->parentContentManager->add_callback(array($this, 'discoEventTester_' . $ap), $ap); }
     // $this->parentContentManager->add_callback(array($this, 'discoEventTester'), "on_first_time");
     // $this->parentContentManager->add_callback(array($this, 'discoEventTester2'), "on_every_time");
     // echo "<HR>INITING FLASH.PHP<HR>";
     // $this->ensure_temp_db_table_exists();
     if (!$this->can_run()) {
         trigger_error('thor needs a db connection name (thor_db_conn_name)');
         return;
     }
     include_once CARL_UTIL_INC . 'db/db.php';
     $this->original_db_conn_name = get_current_db_connection_name();
     $this->set($this->value);
     return true;
     /*
     		// if $this->value doesn't contain an xml declaration,assume it's a tmp_id
     		if ( strpos($this->value, '<' . '?xml') === false )
     		{
     			prp('in init, matches number');
     			prp($this->value, 'this->value, in init (early)');
     			$this->tmp_id = $this->value;
     			// Use file('getXML.php'), instead of a direct call to
     			// the database, because connecting to the test
     			// database here seems to screw up the connection to
     			// cms. Possibly only one mysql link can be open at
     			// once.
     			$this->value = implode("\n", file('http://'.HTTP_HOST_NAME.THOR_HTTP_PATH.'getXML.php?tmp_id=' . $this->tmp_id));
     			prp($this->value, 'this->value, in init (late)');
     		}
     		// otherwise, assume $this->value contains the XML
     		else
     		{
     			connectDB($this->thor_db_conn_name);
     			include_once(CARL_UTIL_INC . 'db/sqler.php');
     			$sqler = new SQLER;
     			$sqler->insert('thor', Array('content' => $this->value));
     			$this->tmp_id = mysql_insert_id();
     			connectDB($this->original_db_conn_name);
     		}
     */
 }
示例#6
0
 /**
  * Print the HTML for an element with no label
  *
  * Replaces {@link show_text_span_element}
  *
  * Called by {@link show_form}.  Part of the display phase
  * @param string $key Name of the element
  * @param defaultType $element The actual element object
  * @param mixed $b box class (passed by reference)
  * 
  */
 function show_unlabeled_element($key, $element, &$b)
 {
     $anchor = '<a name="' . $key . '_error"></a>';
     ob_start();
     $element->display();
     $display = ob_get_contents();
     ob_end_clean();
     $content = $anchor . "\n" . $element->get_comments('before') . $display . $element->get_comments() . "\n";
     $b->box_item_no_label($content, $this->has_error($key), $key);
 }
示例#7
0
 function init($args = array())
 {
     parent::init($args);
     if (!$this->can_run()) {
         trigger_error('thor needs a db connection name (thor_db_conn_name)');
         return;
     }
     include_once CARL_UTIL_INC . 'db/db.php';
     $this->original_db_conn_name = get_current_db_connection_name();
     $this->set($this->value);
     return true;
     // if $this->value doesn't contain an xml declaration,assume it's a tmp_id
     if (strpos($this->value, '<' . '?xml') === false) {
         prp('in init, matches number');
         prp($this->value, 'this->value, in init (early)');
         $this->tmp_id = $this->value;
         // Use file('getXML.php'), instead of a direct call to
         // the database, because connecting to the test
         // database here seems to screw up the connection to
         // cms. Possibly only one mysql link can be open at
         // once.
         $this->value = implode("\n", file('http://' . HTTP_HOST_NAME . THOR_HTTP_PATH . 'getXML.php?tmp_id=' . $this->tmp_id));
         prp($this->value, 'this->value, in init (late)');
     } else {
         connectDB($this->thor_db_conn_name);
         include_once CARL_UTIL_INC . 'db/sqler.php';
         $sqler = new SQLER();
         $sqler->insert('thor', array('content' => $this->value));
         $this->tmp_id = mysql_insert_id();
         connectDB($this->original_db_conn_name);
     }
 }
示例#8
0
 /**
  * Make sure the other value is visible in the request
  **/
 function get_cleanup_rules()
 {
     $rules = parent::get_cleanup_rules();
     if ($this->add_other) {
         return array_merge($rules, array($this->name . '_other' => array('function' => 'turn_into_string')));
     } else {
         return $rules;
     }
 }