public class Widget

class.widget.php #10

Widget is a utility class that offers a number miscellaneous of functions to help generate common HTML Forms elements as XMLElement objects for inclusion in Symphony backend pages.

Methods

static XMLElement Anchor(string $value, string $href, string $title, string $class, string $id, array $attributes)

Generates a XMLElement representation of <a>

Parameters
  • $value stringThe text of the resulting <a>

  • $href stringThe href attribute of the resulting <a>

  • $title string(optional) The title attribute of the resulting <a>

  • $class string(optional) The class attribute of the resulting <a>

  • $id string(optional) The id attribute of the resulting <a>

  • $attributes array(optional) Any additional attributes can be included in an associative array with the key being the name and the value being the value of the attribute. Attributes set from this array will override existing attributes set by previous params.

static XMLElement Apply(array $options)

Generates a XMLElement representation of a <fieldset> containing the "With selected…" menu. This uses the private function __SelectBuildOption() to build XMLElement's of options given the $options array.

Parameters
  • $options array(optional) An array containing the data for each <option> for this <select>. If the array is associative, it is assumed that <optgroup> are to be created, otherwise it's an array of the containing the option data. If no options are provided an empty <select> XMLElement is returned. array( array($value, $selected, $desc, $class, $id, $attr) ) array( array('label' => 'Optgroup', 'options' = array( array($value, $selected, $desc, $class, $id, $attr) ) )

See Also
static XMLElement Calendar(boolean $time)

Generates a XMLElement representation of a Symphony calendar.

Parameters
  • $time booleanWheather or not to display the time, defaults to true

static XMLElement Checkbox(string $name, string $value, string $description, XMLElement $wrapper, string $help)

Generates a XMLElement representation of a <input type='checkbox'>. This also includes the actual label of the Checkbox and any help text if required. Note that this includes two input fields, one is the hidden 'no' value and the other is the actual checkbox ('yes' value). This is provided so if the checkbox is not checked, 'no' is still sent in the form request for this $name.

Parameters
  • $name stringThe name attribute of the resulting checkbox

  • $value stringThe value attribute of the resulting checkbox

  • $description stringThis will be localisable and displayed after the checkbox when generated.

  • $wrapper XMLElementPassed by reference, if this is provided the elements will be automatically added to the wrapper, otherwise they will just be returned.

  • $help string(optional) A help message to show below the checkbox.

Returns

The markup for the label and the checkbox.

static XMLElement Drawer(string $id, string $label, XMLElement $content, string $default_state, string $context, array $attributes)

Generates a XMLElement representation of a Symphony drawer widget. A widget is identified by it's $label, and it's contents is defined by the XMLElement, $content.

Parameters
  • $id stringThe id attribute for this drawer

  • $label stringA name for this drawer

  • $content XMLElementAn XMLElement containing the HTML that should be contained inside the drawer.

  • $default_state stringThis parameter defines whether the drawer will be open or closed by default. It defaults to closed.

  • $attributes array(optional) Any additional attributes can be included in an associative array with the key being the name and the value being the value of the attribute. Attributes set from this array will override existing attributes set by previous params, except the id attribute.

static XMLElement Error(XMLElement $element, string $message)

Will wrap a <div> around a desired element to trigger the default Symphony error styling.

Parameters
  • $element XMLElementThe element that should be wrapped with an error

  • $message stringThe text for this error. This will be appended after the $element, but inside the wrapping <div>

static XMLElement Form(string $action, string $method, string $class, string $id, array $attributes)

Generates a XMLElement representation of <form>

Parameters
  • $action stringThe text of the resulting <form>

  • $method stringThe method attribute of the resulting <form>. Defaults to "post".

  • $class string(optional) The class attribute of the resulting <form>

  • $id string(optional) The id attribute of the resulting <form>

  • $attributes array(optional) Any additional attributes can be included in an associative array with the key being the name and the value being the value of the attribute. Attributes set from this array will override existing attributes set by previous params.

static XMLElement Input(string $name, string $value, string $type, array $attributes)

Generates a XMLElement representation of <input>

Parameters
  • $name stringThe name attribute of the resulting <input>

  • $value string(optional) The value attribute of the resulting <input>

  • $type stringThe type attribute for this <input>, defaults to "text".

  • $attributes array(optional) Any additional attributes can be included in an associative array with the key being the name and the value being the value of the attribute. Attributes set from this array will override existing attributes set by previous params.

static XMLElement Label(string $name, XMLElement $child, string $class, string $id, array $attributes)

Generates a XMLElement representation of <label>

Parameters
  • $name string(optional) The text for the resulting <label>

  • $child XMLElement(optional) An XMLElement that this

  • $class string(optional) The class attribute of the resulting <label>

  • $id string(optional) The id attribute of the resulting <label>

  • $attributes array(optional) Any additional attributes can be included in an associative array with the key being the name and the value being the value of the attribute. Attributes set from this array will override existing attributes set by previous params.

static XMLElement Select(string $name, array $options, array $attributes)

Generates a XMLElement representation of a <select>. This uses the private function __SelectBuildOption() to build XMLElements of options given the $options array.

Parameters
  • $name stringThe name attribute of the resulting <select>

  • $options array(optional) An array containing the data for each <option> for this <select>. If the array is associative, it is assumed that <optgroup> are to be created, otherwise it's an array of the containing the option data. If no options are provided an empty <select> XMLElement is returned. array( array($value, $selected, $desc, $class, $id, $attr) ) array( array('label' => 'Optgroup', 'data-label' => 'optgroup', 'options' = array( array($value, $selected, $desc, $class, $id, $attr) ) )

  • $attributes array(optional) Any additional attributes can be included in an associative array with the key being the name and the value being the value of the attribute. Attributes set from this array will override existing attributes set by previous params.

See Also
static XMLElement Table(XMLElement $header, XMLElement $footer, XMLElement $body, string $class, string $id, array $attributes)

Generates a XMLElement representation of <table> This is a simple way to create generic Symphony table wrapper

Parameters
  • $header XMLElementAn XMLElement containing the <thead>. See Widget::TableHead

  • $footer XMLElementAn XMLElement containing the <tfoot>

  • $body XMLElementAn XMLElement containing the <tbody>. See Widget::TableBody

  • $class string(optional) The class attribute of the resulting <table>

  • $id string(optional) The id attribute of the resulting <table>

  • $attributes array(optional) Any additional attributes can be included in an associative array with the key being the name and the value being the value of the attribute. Attributes set from this array will override existing attributes set by previous params.

static XMLElement TableBody(array $rows, string $class, string $id, array $attributes)

Generates a XMLElement representation of <tbody> from an array containing <tr> XMLElements

Parameters
  • $rows arrayAn array of XMLElements of <tr>'s.

  • $class string(optional) The class attribute of the resulting <tbody>

  • $id string(optional) The id attribute of the resulting <tbody>

  • $attributes array(optional) Any additional attributes can be included in an associative array with the key being the name and the value being the value of the attribute. Attributes set from this array will override existing attributes set by previous params.

See Also
static XMLElement TableData(XMLElement|string $value, string $class, string $id, integer $colspan, array $attributes)

Generates a XMLElement representation of a <td>.

Parameters
  • $value XMLElement|stringEither an XMLElement object, or a string for the value of the resulting <td>

  • $class string(optional) The class attribute of the resulting <td>

  • $id string(optional) The id attribute of the resulting <td>

  • $colspan integer(optional) The colspan attribute of the resulting <td>

  • $attributes array(optional) Any additional attributes can be included in an associative array with the key being the name and the value being the value of the attribute. Attributes set from this array will override existing attributes set by previous params.

static XMLElement TableHead(array $columns)

Generates a XMLElement representation of <thead> from an array containing column names and any other attributes.

Parameters
  • $columns arrayAn array of column arrays, where the first item is the name of the column, the second is the scope attribute, and the third is an array of possible attributes. array( array('Column Name', 'scope', array('class'=>'th-class')) )

static XMLElement TableRow(array $cells, string $class, string $id, integer $rowspan, array $attributes)

Generates a XMLElement representation of <tr> from an array containing column names and any other attributes.

Parameters
  • $cells arrayAn array of XMLElements of <td>'s. See Widget::TableData

  • $class string(optional) The class attribute of the resulting <tr>

  • $id string(optional) The id attribute of the resulting <tr>

  • $rowspan integer(optional) The rowspan attribute of the resulting <tr>

  • $attributes array(optional) Any additional attributes can be included in an associative array with the key being the name and the value being the value of the attribute. Attributes set from this array will override existing attributes set by previous params.

static XMLElement Textarea(string $name, integer $rows, integer $cols, string $value, array $attributes)

Generates a XMLElement representation of <textarea>

Parameters
  • $name stringThe name of the resulting <textarea>

  • $rows integer(optional) The height of the <textarea>, using the rows attribute. Defaults to 15

  • $cols integer(optional) The width of the <textarea>, using the cols attribute. Defaults to 50.

  • $value string(optional) The content to be displayed inside the <textarea>

  • $attributes array(optional) Any additional attributes can be included in an associative array with the key being the name and the value being the value of the attribute. Attributes set from this array will override existing attributes set by previous params.

static XMLElement Time(string $string, string $format, boolean $pubdate)

Generates a XMLElement representation of a <time>

Parameters
  • $string stringA string containing date and time, defaults to the current date and time

  • $format string(optional) A valid PHP date format, defaults to __SYM_TIME_FORMAT__

  • $pubdate boolean(optional) A flag to make the given date a publish date

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details