_xml = simplexml_load_file($xml); } else { exit('Error while loading XML file.'); } } /* Return the calculator's HTML */ public 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 */ private function createTree() { $html = $this->getSpec(); $html .= '
'; $html .= $this->getSkills(); return $html; } /* Return the skills's HTML from one tree */ private function getSkills() { $html =''; foreach ($this->_xml->ecole as $branch) { $html .= '
'; $html .= $this->getActive($branch); $html .= $this->getPassive($branch); $html .= '
'; } return $html; } /* Return the list of the skill trees */ private function getSpec() { $html = '
'; $html .= ''; $html .= '
'; return $html; } /* Return the active skills from one tree @node : Tree's XML node (ecole) */ private function getActive($node) { $html = '
'; foreach ($node->active->skill as $s) { $html .= '
  • '; $html .= '
    '.$this->getSkillDetail($s).'
    '; $html .= '
  • '; } $html .= '
    '; return $html; } /* Return the active skills from one tree @node : Tree's XML node (ecole) */ private function getPassive($node) { $html ='
    '; foreach ($node->passive->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) */ private function getSkillDetail($node) { $html = '

    '.$node['name'].'

    '; $html .= '

    '.utf8_decode($this->renderTags($node->description)).'

    '; $html .= '
    '; foreach ($node->stat as $s) { $html .= '

    '.ucfirst(utf8_decode($s['name'])).': '.utf8_decode($s).'

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