_xml = new DomDocument(); $this->_xml->load($xml); } /* Return the calculator's HTML */ function getTree() { // Affichage de la page $html = '
'; $html .= '

You can still use 23 points.

'; $html .= '
'; $html .= $this->createTree(); $html .= '
'; $html .= '
'; $html .= $this->createTree(); $html .= '
'; $html .= '
'; $html .= $this->createTree(); $html .= '
'; $html .= ''; return $html; } /* Return one tree's HTML */ function createTree() { $tree = $this->_xml->getElementsByTagName('ecole'); $html = $this->getSpec($tree); $html .= '
'; $html .= $this->getSkills($tree); return $html; } /* Return the skills's HTML from one tree @tree : Tree's XML node (ecole) */ function getSkills($node) { $html =''; foreach ($node as $branch) { $html .= '
'; $html .= $this->getActive($branch); $html .= $this->getPassive($branch); $html .= '
'; } return $html; } /* Return the list of the skill trees @node : Tree's XML node (ecole) */ function getSpec($node) { $html = '
'; $html .= ''; $html .= '
'; return $html; } /* Return the active skills from one tree @node : Active's XML node (ecole > active) */ function getActive($node) { $active = $node->getElementsByTagName('active'); foreach ($active as $a) { $skill = $a->getElementsByTagName('skill'); $html = '
'; foreach ($skill as $s) { $html .= '
  • '; $html .= '
    '.$this->getSkillDetail($s).'
    '; $html .= '
  • '; } $html .= '
    '; } return $html; } /* Return the active skills from one tree @node : Passive's XML node (ecole > passive) */ function getPassive($node) { $active = $node->getElementsByTagName('passive'); foreach ($active as $a) { $skill = $a->getElementsByTagName('skill'); $html ='
    '; foreach ($skill as $s) { $html .= '
  • '; $html .= '
    '.$this->getSkillDetail($s).'
    '; $html .= '
  • '; } $html .= '
    '; } return $html; } /* Get the skill details (mana, cooldown, etc) @node : Skill's XML node (ecole > passive/active > skill) */ function getSkillDetail($node) { $html = '

    '.$node->getAttribute('name').'

    '; $stat = $node->getElementsByTagName('stat'); $desc = $node->getElementsByTagName('description'); foreach ($desc as $d) { $html .= '

    '.utf8_decode($this->renderTags($d->nodeValue)).'

    '; } $html .= '
    '; foreach ($stat as $s) { $html .= '

    '.ucfirst(utf8_decode($s->getAttribute('name'))).': '.utf8_decode($s->nodeValue).'

    '; } $html .= '
    '; return $html; } /* Transform custom tag into HTML tag @str : String @Custom tag --b-- / ++b++ => / */ function renderTags($str) { return str_replace(array('--b--', '++b++'), array('', ''), $str); } } ?>