/** * Constructor. * * @param String $input_number * The number of the input in the form. * @param String $cur_value * The current value of the input field. * @param String $input_name * The name of the input. * @param String $disabled * Is this input disabled? * @param Array $other_args * An associative array of other parameters that were present in the * input definition. */ public function __construct($input_number, $cur_value, $input_name, $disabled, $other_args) { parent::__construct($input_number, $cur_value, $input_name, $disabled, $other_args); // call static setup self::setup(); $this->addJsInitFunctionData('SFI_DP_init', $this->setupJsInitAttribs()); }
/** * Constructor. * * @param String $input_number * The number of the input in the form. * @param String $cur_value * The current value of the input field. * @param String $input_name * The name of the input. * @param String $disabled * Is this input disabled? * @param Array $other_args * An associative array of other parameters that were present in the * input definition. */ public function __construct($input_number, $cur_value, $input_name, $disabled, $other_args) { parent::__construct($input_number, $cur_value, $input_name, $disabled, $other_args); // prepare sub-inputs $this->mOtherArgs["part of dtp"] = true; // find allowed values and keep only the date portion if (array_key_exists('possible_values', $this->mOtherArgs) && count($this->mOtherArgs['possible_values'])) { $this->mOtherArgs['possible_values'] = preg_replace('/^\\s*(\\d{4}\\/\\d{2}\\/\\d{2}).*/', '$1', $this->mOtherArgs['possible_values']); } $dateTimeString = trim($this->mCurrentValue); $dateString = ''; $timeString = ''; $separatorPos = strpos($dateTimeString, " "); // does it have a separating whitespace? assume it's a date & time if ($separatorPos) { $dateString = substr($dateTimeString, 0, $separatorPos); $timeString = substr($dateTimeString, $separatorPos + 1); // does it start with a time of some kind? } elseif (preg_match('/^\\d?\\d:\\d\\d/', $dateTimeString)) { $timeString = $dateTimeString; // if all else fails assume it's a date } else { $dateString = $dateTimeString; } $this->mDatePicker = new SFIDatePicker($this->mInputNumber . '_dp', $dateString, $this->mInputName, $this->mIsDisabled, $this->mOtherArgs); $this->mTimePicker = new SFITimePicker($this->mInputNumber . '_tp', $timeString, $this->mInputName, $this->mIsDisabled, $this->mOtherArgs); // add JS data $this->addJsInitFunctionData('SFI_DTP_init', $this->setupJsInitAttribs()); }
/** * Constructor for the SFTextAreaInput class. * * @param String $input_number * The number of the input in the form. For a simple HTML input element * this should end up in the id attribute in the format 'input_<number>'. * @param String $cur_value * The current value of the input field. For a simple HTML input * element this should end up in the value attribute. * @param String $input_name * The name of the input. For a simple HTML input element this should * end up in the name attribute. * @param Array $other_args * An associative array of other parameters that were present in the * input definition. */ public function __construct($input_number, $cur_value, $input_name, $disabled, $other_args) { global $wgOut; parent::__construct($input_number, $cur_value, $input_name, $disabled, $other_args); if (array_key_exists('editor', $this->mOtherArgs) && $this->mOtherArgs['editor'] == 'wikieditor' && method_exists($wgOut, 'getResourceLoader') && in_array('jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames()) && class_exists('WikiEditorHooks')) { $this->mUseWikieditor = true; $this->addJsInitFunctionData('window.ext.wikieditor.init'); } }
public function __construct($input_number, $cur_value, $input_name, $disabled, $other_args) { parent::__construct($input_number, $cur_value, $input_name, $disabled, $other_args); if (array_key_exists('max', $this->mOtherArgs)) { $this->mMax = $this->mOtherArgs['max']; } else { $this->mMax = $GLOBALS['SemanticRating_DefaultMax']; } }
/** * Constructor. * * @param String $input_number * The number of the input in the form. * @param String $cur_value * The current value of the input field. * @param String $input_name * The name of the input. * @param String $disabled * Is this input disabled? * @param Array $other_args * An associative array of other parameters that were present in the * input definition. */ public function __construct($input_number, $cur_value, $input_name, $disabled, $other_args) { parent::__construct($input_number, $cur_value, $input_name, $disabled, $other_args); // third: if the timepicker is not disabled set up JS attributes ans assemble JS call if (!$this->mIsDisabled) { self::setup(); } $this->addJsInitFunctionData('SFI_TP_init', $this->setupJsInitAttribs()); }
/** * Constructor. * * @param String $input_number * The number of the input in the form. * @param String $cur_value * The current value of the input field. * @param String $input_name * The name of the input. * @param String $disabled * Is this input disabled? * @param Array $other_args * An associative array of other parameters that were present in the * input definition. */ public function __construct($input_number, $cur_value, $input_name, $disabled, $other_args) { parent::__construct($input_number, $cur_value, $input_name, $disabled, $other_args); self::setup(); $this->addJsInitFunctionData('SFI_MS_init', 'null'); }
/** * Constructor. * * @param String $input_number * The number of the input in the form. * @param String $cur_value * The current value of the input field. * @param String $input_name * The name of the input. * @param String $disabled * Is this input disabled? * @param Array $other_args * An associative array of other parameters that were present in the * input definition. */ public function __construct($input_number, $cur_value, $input_name, $disabled, $other_args) { global $sfgFormPrinter; parent::__construct($input_number, $cur_value, $input_name, $disabled, $other_args); // call static setup self::setup(); // set OR character if (array_key_exists('or char', $this->mOtherArgs)) { $orChar = trim($this->mOtherArgs['or char']); unset($this->mOtherArgs['or char']); } else { $orChar = '!'; } // set regexp string if (array_key_exists('regexp', $this->mOtherArgs)) { $this->mRegExp = str_replace($orChar, '|', trim($this->mOtherArgs['regexp'])); unset($this->mOtherArgs['regexp']); // check for leading/trailing delimiter and remove it (else reset regexp) if (preg_match("/^\\/.*\\/\$/", $this->mRegExp)) { $this->mRegExp = substr($this->mRegExp, 1, strlen($this->mRegExp) - 2); } else { $this->mRegExp = '.*'; } } else { $this->mRegExp = '.*'; } // set inverse string if (array_key_exists('inverse', $this->mOtherArgs)) { $invertRegexp = 'true'; unset($this->mOtherArgs['inverse']); } else { $invertRegexp = 'false'; } // set failure message string if (array_key_exists('message', $this->mOtherArgs)) { $this->mErrorMessage = trim($this->mOtherArgs['message']); unset($this->mOtherArgs['message']); } else { $this->mErrorMessage = wfMsg('semanticformsinputs-wrongformat'); } // sanitize error message and regexp for JS $message = Xml::encodeJsVar($this->mErrorMessage); $regexp = Xml::encodeJsVar($this->mRegExp); // Finally set name and parameters for the validation function $this->addJsValidationFunctionData('SFI_RE_validate', "{retext: {$regexp}, inverse: {$invertRegexp}, message: {$message} }"); // set base input type name if (array_key_exists('base type', $this->mOtherArgs)) { $baseType = trim($this->mOtherArgs['base type']); unset($this->mOtherArgs['base type']); // if unknown set default base input type if (!array_key_exists($baseType, $sfgFormPrinter->mInputTypeClasses)) { $baseType = 'text'; } } else { $baseType = 'text'; } // create other_args array for base input type if base prefix was set if (array_key_exists('base prefix', $this->mOtherArgs)) { // set base prefix $basePrefix = trim($this->mOtherArgs['base prefix']) . "."; unset($this->mOtherArgs['base prefix']); // create new other_args param $newOtherArgs = array(); foreach ($this->mOtherArgs as $key => $value) { if (strpos($key, $basePrefix) === 0) { $newOtherArgs[substr($key, strlen($basePrefix))] = $value; } else { $newOtherArgs[$key] = $value; } } } else { $newOtherArgs = $this->mOtherArgs; } // create base input $this->mBaseInput = new $sfgFormPrinter->mInputTypeClasses[$baseType]($this->mInputNumber, $this->mCurrentValue, $this->mInputName, $this->mIsDisabled, $newOtherArgs); }