public function generateContent()
 {
     // Can't download the documectation directly (required facebook login)
     $form = new Form(array('class' => 'form-horizontal', 'legend' => 'Paste HTML from https://developers.facebook.com/docs/reference/api/$model/', 'fields' => array('HTML' => new Input(array('type' => 'textarea', 'name' => 'source')), new Input(array('type' => 'submit', 'value' => 'Generate class', 'class' => 'btn btn-primary')))));
     $data = $form->import($error);
     if ($data) {
         $dom = new \DOMDocument();
         @$dom->loadHTML($data['source']);
         $xml = simplexml_import_dom($dom);
         $link = $xml->xpath('//div[@class="breadcrumbs"]/a[last()]');
         $path = explode('/', trim($link[0]['href'], '/'));
         $elements = $xml->xpath('//div[@id="bodyText"]');
         $info = array('class' => ucfirst(end($path)), 'link' => 'https://developers.facebook.com/' . implode('/', $path) . '/', 'description' => strip_tags($elements[0]->p[0]->asXML()), 'fields' => $this->extractFields($elements[0]->table[0]->tr), 'connections' => array(), 'constructor' => strpos($elements[0]->table[0]->asXML(), 'only returned if'));
         if ($elements[0]->table[1] !== null) {
             $info['connections'] = $this->extractFields($elements[0]->table[1]->tr);
         }
         if (count($info['fields']) == 0 && count($info['connections']) != 0) {
             // Thread documentation
             $info['fields'] = $info['connections'];
             $info['connections'] = $this->extractFields($elements[0]->table[2]->tr);
         }
         return new Dump($this->generatePhp($info));
     } else {
         return $form;
     }
 }
 public function execute()
 {
     // Genereer een formulier waarmee je 2 environments kan kiezen.
     $environments = array('development', 'staging', 'production');
     $Form = new Form(array('method' => 'get'), array(new Fieldset('Compare environments', array('environments' => new FieldLabel('Environments', new Fields(array('source' => new SelectBox('source', $environments, [], new NotEmptyValidator()), 'target' => new SelectBox('target', $environments, [], new NotEmptyValidator()), new Input('submit', null, array('value' => 'Compare')))))))));
     $values = $Form->import($errors);
     if (!$values) {
         // Zijn er geen environments gekozen?
         return $Form;
     }
     $source = $values[0]['environments']['source'];
     $target = $values[0]['environments']['target'];
     $modules = Sledgehammer::getModules($this->paths['modules']);
     $constants_diff = [];
     /*
               // Loop door alle modules en vergelijk de constantes
               foreach($modules as $module) {
               $constants_ini = DEVHOOK_PATH.$module['folder'].'settings/constants.ini';
               if (!file_exists($constants_ini)) {
               continue;
               }
               $constants = parse_ini_file($constants_ini, true);
               $source_constants = isset($constants[$source]) ? $constants[$source] : [];
               $target_constants = isset($constants[$target]) ? $constants[$target] : [];
               $data = formatted_diff($source_constants, $target_constants);
               if (count($data) > 0) {
               foreach($data as $row) {
               $row['Module'] = $module['name'];
               $constants_diff[] = $row;
               }
               }
               } */
     // Vergelijk database instellingen
     $database_diff = [];
     $db_links_compared = [];
     $database_ini = $this->paths['project'] . 'app/database.ini';
     if (file_exists($database_ini)) {
         $database_settings = parse_ini_file($database_ini, true);
         foreach ($database_settings as $env_and_link => $settings) {
             $exploded_env_and_link = explode('.', $env_and_link);
             $environment = $exploded_env_and_link[0];
             $link = $exploded_env_and_link[1];
             if (in_array($link, $db_links_compared)) {
                 // Is deze link al gecontroleerd?
                 continue;
                 // door met de volgende link
             }
             $data = false;
             if ($environment == $source) {
                 // Is deze database setting voor de bron environment?
                 if (isset($database_settings[$target . '.' . $link])) {
                     // Is deze link ook voor de target environment geconfigureerd?
                     $target_settings = $database_settings[$target . '.' . $link];
                 } else {
                     $target_settings = [];
                     // Er zijn geen target settings
                 }
                 $data = formatted_diff($settings, $target_settings);
             } elseif ($environment == $target) {
                 if (isset($database_settings[$source . '.' . $link])) {
                     // Is deze link ook voor de target environment geconfigureerd?
                     $source_settings = $database_settings[$source . '.' . $link];
                 } else {
                     $source_settings = [];
                     // Er zijn geen target settings
                 }
                 $data = formatted_diff($source_settings, $settings);
             }
             if ($data) {
                 foreach ($data as $row) {
                     $row['Link'] = '[' . $link . ']';
                     $database_diff[] = $row;
                 }
                 $db_links_compared[] = $link;
             }
         }
     }
     $output = '';
     if (count($constants_diff) > 0) {
         $ConstantsDiff = new InteractiveTable(array('Module', 'setting', 'source', 'target'), '#');
         $ConstantsDiff->headers = array('setting' => 'Constant', 'source' => '[' . $source . ']', 'target' => '[' . $target . ']');
         $ConstantsDiff->Iterator = $constants_diff;
         $output .= '<h2>Constants.ini\'s</h2>' . view_to_string($ConstantsDiff);
     }
     if (count($database_diff) > 0) {
         $DatabaseDiff = new InteractiveTable(array('Link', 'setting', 'source', 'target'), '#');
         $DatabaseDiff->headers = array('setting' => 'Setting', 'source' => '[' . $source . ']', 'target' => '[' . $target . ']');
         $DatabaseDiff->Iterator = $database_diff;
         $output .= '<h2>Database.ini</h2>' . view_to_string($DatabaseDiff);
     }
     if ($output == '') {
         $output .= view_to_string(Alert::info('<h3>No differences found</h3>The environments are identical'));
     }
     return new Html(view_to_string($Form) . '<br />' . $output);
 }