Exemplo n.º 1
0
 /**
  * Checks the lengths of each field whose characters were supposed to be limited
  * Sets a disco error if the maximum number of characters was exceeded
  */
 public function check_field_lengths()
 {
     foreach ($this->field_limits as $field => $char_limit) {
         $num_chars = carl_util_count_html_text_characters($this->disco_form->get_element_property($field, 'value'));
         $chars_over_limit = $num_chars - $char_limit;
         if ($chars_over_limit > 0) {
             $field_display_name = $this->disco_form->get_display_name($field);
             $this->disco_form->set_error($field, 'There are ' . $chars_over_limit . ' more characters than allowed in "' . $field_display_name . '". Please shorten the text in this field.');
         }
     }
 }
Exemplo n.º 2
0
<?php

/**
 * Simple character counting script that responds to AJAX POST
 *
 * This is used to maintain consistency in character counting between counting characters in 
 * real time in the browser and with counting characters in Reason/php/database.
 *
 * @package disco
 * @subpackage plugins
 * @author Nick Jones
 */
/**
 * Include dependencies.
 */
include_once 'paths.php';
include_once CARL_UTIL_INC . 'basic/misc.php';
if (isset($_REQUEST['text'])) {
    echo carl_util_count_html_text_characters($_REQUEST['text']);
} else {
    echo 0;
}