<?php/** ** @package events* @version $Id: condition_varchar.php,v 1.2 2005/12/25 00:09:26 davidmj Exp $* @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License **//*** Event condition class for the varchar condition type.* Its purpose is the generation of the ACP page** @package acp*/class evc_varchar_acp{ /** * Outputs form elements for the (num)th step in condition creation * * @param int $num is the number of the current part of the condition, * ranging from 0 until the number for which this function returns array(EVT_DONE, output) * * @param string $name is a unique identifier which is used for form * elements in order to allow the use of one condition type multiple times * per event * * @param array $options contains all options collected in the previous steps */ function input($num, $name, $options) { global $user; switch ($num) { // First step: select a compare method case 0: $compare_methods = &evc_varchar_compare(); // Use $name to make sure the name of the input element is unique $output = '<select name="compare_varchar_' . $name . '">'; foreach ($compare_methods as $i => $compare_method) { $output .= '<option value="' . $i . '">' . $compare_method . '</option>'; } $output .= '</select>'; // continue with next step return array(EVT_CONTINUE, $output); // Second step: enter a value to compare the varchar to case 1: // Use $name to make sure the name of the input element is unique // a varchar shouldn't be longer than 255 characters $output = '<input name="compare_varchar_to_' . $name . '" type="text" maxlength="255" /> '; if ($options[0] == 0) { $output .= '<br /><span>' . $user->lang['REGEXP'] . ' <input name="compare_varchar_regexp_' . $name . '" type="checkbox" value="1" /></span>'; } // this was the last input element return array(EVT_DONE, $output); } } /** * Outputs the stored option for the (num)th step in condition creation * * @param int $num is the number of the current part of the condition, * ranging from 0 until the number for which this function returns array(EVT_DONE, output) * * @param string $name is a unique identifier which is used for form * elements in order to allow the use of one condition type multiple times * per event * * @param array $options contains all options collected in the previous steps */ function display($num, $options) { global $user; switch ($num) { // First step: Display the compare method case 0: $compare_methods = &evc_varchar_compare(); // continue with next step return array(EVT_CONTINUE, $compare_methods[$options[0]]); // Second step: display the compare string case 1: $output = $options[1]['string']; if ($options[0] == 0 && $options[1]['regexp']) { $output .= '<br /><span class="gensmall">' . $user->lang['REGEXP'] . '</span>'; } // this was the last input element return array(EVT_DONE, $output); } } /** * Return the option which shall be stored for the (num)th step, read from $_REQUEST */ function retrieve_options($num, $name, $options) { switch ($num) { // First step: get the compare method case 0: $compare_method = request_var('compare_varchar_' . $name, 0); $compare_methods = &evc_varchar_compare(); if (!isset($compare_methods[$compare_method])) { global $user; return array(EVT_ERROR, $user->lang['NO_COMPARE_METHOD']); } return array(EVT_CONTINUE, $compare_method); // Second step: get the string we compare to case 1: $string = request_var('compare_varchar_to_' . $name, ''); $regexp = request_var('compare_varchar_regexp_' . $name, false); return array(EVT_DONE, array('string' => $string, 'regexp' => $regexp)); } }}?>