private function buildButton($branch)
 {
     $current = isset($branch->child) && $branch->child ? ' (current)' : ' <small><small><b>(current)</b></small></small>';
     $current = isset($branch->current) && $branch->current ? $current : '';
     $child = isset($branch->child) && $branch->child ? ' child' : '';
     $parent = isset($branch->parent) && $branch->parent ? ' parent' : '';
     $value = isset($branch->value) && $branch->value ? " onclick=\"location.href='{$branch->value}'\"" : '';
     $replacements = array('current' => $current, 'child' => $child, 'parent' => $parent, 'name' => $branch->name, 'id' => ucfirst($branch->name), 'link' => $value);
     $button = TemplatesController::replaceInTemplate($this->buttonTemplate, $replacements, '@@');
     return $button . "\n";
 }
 private function parseProperties()
 {
     $includes = '';
     $this->properties->css = array_merge($this->css, $this->properties->css);
     foreach ($this->properties->css as $file) {
         $includes .= "<link rel=\"stylesheet\" href=\"/css/{$file}.css\">\n";
     }
     $this->properties->js = array_merge($this->js, $this->properties->js);
     foreach ($this->properties->js as $file) {
         $includes .= "<script type=\"text/javascript\" src=\"/js/{$file}.js\"></script>";
     }
     $options = array();
     foreach ($this->properties->options as $key => $value) {
         $options[] = "\"{$key}\": \"{$value}\"";
     }
     $this->htmlStart = TemplatesController::replaceInTemplate($this->htmlStart, array('title' => $this->properties->title, 'includes' => $includes, 'options' => implode(',', $options)));
 }
 private function replaceDiff($line)
 {
     $line = htmlspecialchars($line);
     // replace error sign
     $line = preg_replace("/^~~/", "", $line);
     // replace minus sign
     $line = preg_replace("/^-/", " ", $line);
     // replace plus sign
     $line = preg_replace("/^\\+/", " ", $line);
     // replace errors
     while (strpos($line, '@@') !== false) {
         preg_match("/(.*)@@(.+)@@(.*)/", $line, $output_array);
         $errorRaw = explode(',', $output_array[2]);
         $output_array[2] = TemplatesController::replaceInTemplate($this->errorTemplate, array('msg' => $errorRaw[1], 'code' => $errorRaw[0]));
         $line = preg_replace("/(.+)@@.+@@(.*)/", "\$1{$output_array['2']}\$2", $line);
     }
     return $line;
 }