/** * Builds the configOptions object. * * Passing an array of key value pairs will set the configuration for each * child object created from this master object. * * @param array Array of options. * @return \configOptions */ public function __construct($config) { if (is_array($config)) { foreach ($config as $option => $value) { if (in_array($option, $this->options)) { $this->{$option}($value); } else { $this->error('Ignoring "' . $option . '", not a valid configuration option.'); } } } else { $this->type_error(get_class($this) . '()', 'array', 'with valid keys as ' . array_string($this->options)); } return $this; }
/** * Where to place the chart title, compared to the chart area. Supported values: * 'in' - Draw the title inside the chart area. * 'out' - Draw the title outside the chart area. * 'none' - Omit the title. * * @param string $position * @return \Chart */ public function titlePosition($position) { $values = array('in', 'out', 'none'); if (in_array($position, $values)) { $this->addOption(array('titlePosition' => $position)); } else { $this->type_error(__FUNCTION__, 'string', 'with a value of ' . array_string($values)); } return $this; }
/** * Sets the alignment of the legend. * * Can be one of the following: * 'start' - Aligned to the start of the area allocated for the legend. * 'center' - Centered in the area allocated for the legend. * 'end' - Aligned to the end of the area allocated for the legend. * * Start, center, and end are relative to the style -- vertical or horizontal -- of the legend. * For example, in a 'right' legend, 'start' and 'end' are at the top and bottom, respectively; * for a 'top' legend, 'start' and 'end' would be at the left and right of the area, respectively. * * The default value depends on the legend's position. For 'bottom' legends, * the default is 'center'; other legends default to 'start'. * * @param string Alignment of the legend * @return \legend */ public function alignment($alignment) { $values = array('start', 'center', 'end'); if (in_array($alignment, $values)) { $this->alignment = $alignment; } else { $this->type_error(__FUNCTION__, 'string', 'with a value of ' . array_string($values)); } return $this; }
/** * Adds a column to the DataTable * * First signature has the following parameters: * type - A string with the data type of the values of the column. * The type can be one of the following: 'string' 'number' 'boolean' 'date' * 'datetime' 'timeofday'. * * opt_label - [Optional] A string with the label of the column. The column * label is typically displayed as part of the visualization, for example as * a column header in a table, or as a legend label in a pie chart. If not * value is specified, an empty string is assigned. * opt_id - [Optional] A string with a unique identifier for the column. If * not value is specified, an empty string is assigned. * * * @param string Describing the column data type * @param string A label for the column. (Optional) * @param string An ID for the column. (Optinal) * @return \DataTable */ public function addColumn($typeOrDescriptionArray, $opt_label = '', $opt_id = '') { $types = array('string', 'number', 'boolean', 'date', 'datetime', 'timeofday'); $descriptions = array('type', 'label', 'id', 'role', 'pattern'); switch (gettype($typeOrDescriptionArray)) { case 'array': foreach ($typeOrDescriptionArray as $key => $value) { if (array_key_exists('type', $typeOrDescriptionArray)) { if (in_array($typeOrDescriptionArray['type'], $types)) { $descArray['type'] = $typeOrDescriptionArray['type']; if (in_array($key, $descriptions)) { if ($key != 'type') { if (is_string($value)) { $descArray[$key] = $value; } else { $this->error('Invalid description array value, must be type (string).'); } } } else { $this->error('Invalid description array key value, must be type (string) with any key value ' . $this->_array_string($descriptions)); } } else { $this->error('Invalid type, must be type (string) with the value ' . array_string($types)); } } else { $this->error('Invalid description array, must contain (array) with at least one key type (string) value [ type ]'); } } $this->cols[] = $descArray; break; case 'string': if (in_array($typeOrDescriptionArray, $types)) { $descArray['type'] = $typeOrDescriptionArray; if (is_string($opt_label)) { $descArray['label'] = $opt_label; } else { $this->error('Invalid opt_label, must be type (string).'); } if (is_string($opt_id)) { $descArray['id'] = $opt_id; } else { $this->error('Invalid opt_id, must be type (string).'); } } else { $this->error('Invalid type, must be type (string) with the value ' . array_string($types)); } $this->cols[] = $descArray; break; default: $this->error('Invalid type or description array, must be type (string) or (array).'); break; } return $this; }
/** * Position of the axis text, relative to the chart area. * Supported values: 'out', 'in', 'none'. * * @param string Setting the position of the text. * @return \Axis */ public function textPosition($position) { $values = array('out', 'in', 'none'); if (in_array($position, $values)) { $this->textPosition = $position; } else { $this->type_error(__FUNCTION__, 'string', 'with a value of ' . array_string($values)); } return $this; }
/** * Controls the curve of the lines when the line width is not zero. Can be one of the following: * * 'none' - Straight lines without curve. * 'function' - The angles of the line will be smoothed. * * @param string $curveType * @return \LineChart */ public function curveType($curveType) { $values = array('none', 'function'); if (in_array($curveType, $values)) { $this->addOption(array('curveType' => (string) $curveType)); } else { $this->error('Invalid curveType, must be type (string) with a value of ' . array_string($values)); } return $this; }
$badchr = array('\'', '"', '`', '/', '\\', '|', '<', '>', '?', '+', '=', '^', '*', ':', ';'); $badtime = array('\'', '"', '`', '/', '\\', '|', '<', '>', '?', '+', '=', '^', '*', ';', ',', '.'); //CONFIG.PHP $new_options = array(); foreach ($options as $k => $v) { if (!array_key_exists($k, $new_options)) { $new_options[$k] = $v; } } foreach ($options as $k => $v) { if (!in_array($k, array('disableadvanceeditor', 'xpanel_filename', 'index_file', 'allowcpanel'))) { if (is_array($options[$k])) { if ($k == 'forbidden_filetypes') { $new_options[$k] = array_string(str_replace($badchr, '', stripslashes($_POST['opt_' . $k]))); } elseif ($k == 'ip_premixstat_list') { $new_options[$k] = array_string(str_replace($badip, '', stripslashes($_POST['opt_' . $k]))); } elseif (!in_array($k, array('loginCp', 'users'))) { foreach ($options[$k] as $key => $value) { if (is_bool($options[$k][$key])) { $new_options[$k][$key] = isset($_POST["opt_{$k}"][$key]) && $_POST["opt_{$k}"][$key] ? true : false; } elseif (is_numeric($options[$k][$key])) { $_POST["opt_{$k}"][$key] = filterNumericFld("opt_{$k}[{$key}]", str_replace('_', ' ', $key), $options[$k][$key]); $new_options[$k][$key] = isset($_POST["opt_{$k}"][$key]) && $_POST["opt_{$k}"][$key] ? floor($_POST["opt_{$k}"][$key]) : 0; } else { $new_options[$k][$key] = isset($_POST["opt_{$k}"][$key]) && $_POST["opt_{$k}"][$key] ? stripslashes($_POST["opt_{$k}"][$key]) : ''; } } } else { continue; } } elseif (is_bool($options[$k])) {
/** * Sets The user interaction that causes the tooltip to be displayed. * * 'focus' - The tooltip will be displayed when the user hovers over an element. * 'none' - The tooltip will not be displayed. * * @param string Type of trigger, [ focus | none ]. * @return \tooltip */ public function trigger($trigger) { $values = array('focus', 'none'); if (in_array($trigger, $values)) { $this->trigger = $trigger; } else { $this->type_error(__FUNCTION__, 'string', 'with a value of ' . array_string($values)); } return $this; }
/** * The resolution of the map borders. Choose one of the following values: * * 'countries' - Supported for all regions, except for US state regions. * 'provinces' - Supported only for country regions and US state regions. * Not supported for all countries; please test a country to * see whether this option is supported. * 'metros' - Supported for the US country region and US state regions only. * * @param string $resolution * @return \GeoChart */ public function resolution($resolution) { $values = array('countries', 'provinces', 'metros'); if (in_array($resolution, $values)) { $this->addOption(array('resolution' => $resolution)); } else { $this->type_error(__FUNCTION__, 'string', 'with a value of ' . array_string($values)); } return $this; }
/** * Where to place the axis titles, compared to the chart area. Supported values: * * in - Draw the axis titles inside the the chart area. * out - Draw the axis titles outside the chart area. * none - Omit the axis titles. * * @param string $position * @return \AreaChart */ public function axisTitlesPosition($position) { $values = array('in', 'out', 'none'); if (in_array($position, $values)) { $this->addOption(array('axisTitlesPosition' => $position)); } else { $this->error('Invalid axisTitlesPosition, must be (string) ' . array_string($values)); } return $this; }