예제 #1
0
 protected function dropdown()
 {
     $attributes = array_merge(array('id' => '', 'width' => 'quarter', 'edit_perms' => null, 'view_perms' => null, 'node_edit_perms' => null, 'node_view_perms' => null), $this->_attributes());
     extract($attributes);
     if (empty($id)) {
         throw new Exception('Missing id attribute on dropdown');
     }
     if (substr($id, 0, 1) != '#') {
         throw new Exception('The id attribute must be a valid role beginning with #');
     }
     if (!$this->__hasPermission($view_perms) || !$this->__hasNodePermission($node_view_perms)) {
         return;
     }
     $id = ltrim($id, '#');
     $schemafield = $this->schema->getMetaDef($id);
     if (!$this->xml->isEmptyElement) {
         require_once PATH_SYSTEM . '/vendors/Xml2Assoc.php';
         $children = (array) Xml2Assoc::parseXml($this->xml, true);
     } else {
         $children = array();
     }
     $uid = $this->_generateUniqueID($id);
     $fullid = "#{$id}";
     $fulluid = "#{$uid}";
     $this->xhtml[] = "          <li class=\"input-{$width}-width field {$this->_fieldClasses($schemafield)}\">";
     $this->xhtml[] = "              <label for=\"{$uid}\">{$schemafield->Title}</label>";
     $this->xhtml[] = "              <div>";
     if ($this->__hasPermission($edit_perms) && $this->__hasNodePermission($node_edit_perms)) {
         $this->xhtml[] = "                  <select name=\"{$fulluid}\" id=\"{$uid}\">";
         if (!empty($children) && array_key_exists('option', $children)) {
             foreach ($children['option'] as $raw_option) {
                 $selected = '';
                 if (is_array($raw_option)) {
                     if (array_key_exists('selected', $raw_option) && ($raw_option['selected'] == 'true' || $raw_option['selected'] == 'yes')) {
                         $selected = 'selected';
                     }
                     $option = array_shift($raw_option);
                     $value = $raw_option['value'];
                 } else {
                     $option = $value = $raw_option;
                 }
                 $this->xhtml[] = "                          <option value='{$value}' {% if Data:{$fullid} eq '{$value}' %}selected{% else %}{% if !Data:{$fullid} %}{$selected}{% endif %}{% endif %}>{$option}</option>";
             }
         }
         $this->xhtml[] = "                  </select>";
     } else {
         $this->xhtml[] = "                  <p class=\"read-only\">%{$fullid}%</p>";
     }
     $this->xhtml[] = "              </div>";
     $this->__closeLI();
 }
예제 #2
0
<?php

include_once 'xml.php';
$xmlObj = new Xml2Assoc();
$assoc = $xmlObj->parseFile('names.xml', true);
$xml = new XMLReader();
$xml->open('names.xml');
$assoc1 = $xmlObj->xml2assocTagsChildsAttrs($xml);
echo "<pre>";
//print_r($assoc);
print_r($assoc1);
//foreach($assoc['names']['name'] as $name){
//	echo $name['fname']." ".$name['lname']."<br>";
//}
echo "</pre>";