HTML elements

string html::attributes (array $attributes, bool $includeEmpty = false)

Use for building HTML attributes.
From php array (name => value pairs) returns html tag attributes as string. Names are converted to lower case, values are html encoded. If parameter $includeEmpty is true, attributes with empty string or null are also included.
<?php
// Outputs: id="input1" size="39" maxlength="30"
echo html::attributes (array ("id" => "input1", "size" => 30, "maxLength" => 30, "class" => ""));

// Outputs: id="input1" size="39" maxlength="30" class=""
echo html::attributes (array ("id" => "input1", "size" => 30, "maxLength" => 30, "class" => ""), true);
?>

string html::options (array $options, mixed $selected = "")

Use for building HTML select element options.
From php array returns html option tags as string. Parameter $options can be one-dimensional array (value => text pairs) for simple option selects or two-dimensional (optGroupLabel => (value => text) pairs) for option group selects. $selected parameter is string value of selected option or array of selected options in multiple select element.
<?php
echo html::options (array ("AU" => "Austria", "IT" => "Italia", "SI" => "Slovenia"), "SI");

echo html::options (array ("EU" => array ("AU" => "Austria", "IT" => "Italia", "SI" => "Slovenia"), 
                           "America" => array ("USA" => "USA", "CA" => "Canada)), 
                    array ("CA","SI"));
?>
<option value="AU">Austria</option>
<option value="IT">Italia</option>
<option value="SI" selected="selected">Slovenia</option>

<optgroup label="EU">
  <option value="AU">Austria</option>
  <option value="IT">Italia</option>
  <option value="SI" selected="selected">Slovenia</option>
</optgroup>
<optgroup label="America">
  <option value="USA">USA</option>
  <option value="CA" selected="selected">Canada</option>
</optgroup>

string html::ul (mixed $items, array $attributes = array())

Use for building HTML ul+li elements.
From php array returns html ul+li structure as string. Elements can be nested. $items can be one (single ul+li structure) or multi (nested ul+li structure) dimensional array of li items or a string of function name that returns array of ul+li items. $attributes array are attributes of ul element. If $items array contains named indexes, named index is used for HTML id attribute of current li element. For escaping special characters in $items is responsible caller, $items can have valid HTML elements.
<?php
  echo html::ul (array ("Europa", "America", "E" => array ("<a href="austria.php">Austria</a>", "Italia", "SI" => "Slovenia")), array ("id" => "world"));
?>
<ul id="world">
  <li>Europa</li>
  <li>America</li>
  <li>
    <ul id="E">
      <li><a href="austria.php">Austria</a></li>
      <li>Italia</li>
      <li id="SI">Slovenia</li>
    </ul>
  </li> 
</ul>

string html::a (string $title, string $href = "", array $attributes = array())

Use for building HTML a element or just display text if $href is empty. If $title is empty $href is displayed. If $title and $href are empty and id attribute is set HTML anchor element is build (in HTML5 any element with id is anchor).
For escaping special characters in $title is responsible caller, $title can have valid HTML elements.
<?php
  // Outputs: <a href="test.php" onclick="doClick()">TEST</a>
  echo html::a ("TEST", "test.php", array ("onClick" => "doClick()"));

  // Outputs: <a href="test.php">test.php</a>
  echo html::a ("", "test.php");

  // Outputs: <a href="test.php"><img src="test.png" alt="TEST" /></a>
  echo html::a ("<img src="test.png" alt="TEST" />, "test.php");

  // Outputs: TEST
  echo html::a ("TEST", "");

  // Outputs: <a id="top" />
  echo html::a ("", "", array ("id" => "top"));
?>









sddsdsdsdsd

© 2003-17 iNeta d.o.o. | Koroška cesta 31, SI-4000 Kranj | info@ineta.si | Pravno obvestilo
Powered by BravoCMS