private function CreateLink($title, $href, $img) { $href = str_replace("{url}", urlencode($_SERVER['SCRIPT_URI']), $href); $href = str_replace("{title}", urlencode($title), $href); $href = str_replace("{domain}", urlencode($_SERVER['SERVER_NAME']), $href); $img = new Image($img, $title); $res = new Anchor($href); $res->title = $title; $res->target = "_blank"; $res->content($img); return $res; }
function Run() { $summary = $this->content(new Control('div')); $run = new Anchor(buildQuery('DocMain', 'Run'), 'Run again'); $down = new Anchor(buildQuery('DocMain', 'Download'), 'Download'); $preview = new Anchor(buildQuery('Preview'), 'Preview'); $this->content('<div style="text-align: center; font-size: 18px; font-weight: bold">'); $this->content($run->WdfRender() . " " . $down->WdfRender() . " " . $preview->WdfRender()); $this->content('</div>'); if (!file_exists(__DIR__ . '/out')) { mkdir(__DIR__ . '/out'); } foreach (system_glob_rec(__DIR__ . '/out', '*') as $file) { unlink($file); } cache_clear(); $path = realpath(__DIR__ . '/../../system/'); $i = 1; global $home, $processed_files; $home = array('funcs' => array(), 'classes' => array(), 'methods' => array(), 'tree' => array(), 'interfaces' => array(), 'namespaces' => array()); $processed_files = array(); $all_files = system_glob_rec($path, '*.php'); $cnt_all_files = count($all_files); foreach ($all_files as $file) { if ($this->skip($file)) { $cnt_all_files--; continue; } $title = str_replace($path . '/', '', $file); $fn_cls = __DIR__ . '/out/classes_' . str_replace('.php.md', '.md', str_replace('/', '_', $title) . '.md'); $fn_fnc = __DIR__ . '/out/functions_' . str_replace('.php.md', '.md', str_replace('/', '_', $title) . '.md'); $this->_startSection("FILE: {$file}"); $data = $this->process($file); if ($i++ > self::MAX_FILES) { $this->content("<h1>Stopping, still " . ($cnt_all_files - self::MAX_FILES) . " missing</h1>"); break; } // functions $lines = array(); foreach ($data['functions'] as $func) { $l = $this->funcToMd($func); if ($l) { $home['funcs'][$func['name']] = basename($fn_fnc, '.md') . "#wiki-" . md5($func['name']); $lines[] = $l; // $processed_files[$title][] = $func['name']; // we do not want functions in the folder tree } } if (count($lines) > 0) { file_put_contents($fn_fnc, $this->escapeMd("# Functions in file {$title}\n" . implode("\n", $lines))); } // classes $lines = array(); foreach ($data['classes'] as $class) { // log_if($class['name']=="uiControl",$class['name'],$class); $lines[] = $this->classToMd($class, basename($fn_cls, '.md')); if ($class['type'] == 'interface' && !isset($home['interfaces'][$class['type']])) { $home['interfaces'][$class['name']] = array(); } if (isset($class['implements'])) { foreach ($class['implements'] as $int) { if (!isset($home['interfaces'][$int])) { $home['interfaces'][$int] = array($class['name']); } else { $home['interfaces'][$int][] = $class['name']; } } } $processed_files[$title][] = $class['name']; } if (count($lines) > 0) { file_put_contents($fn_cls, $this->escapeMd("# Classes in file {$title}\n" . implode("\n", $lines))); } } $this->_endSection(); $this->writeIndexes(); $this->createLinks(); $this->writeZip(); if (array_sum($this->sums) > 0 || count($this->errors) > 0) { $summary->addClass('summary'); $summary->content("<b>Summary:</b><br/>"); if ($this->sums['comment'] > 0) { $summary->content("Missing comments: {$this->sums['comment']}<br/>"); } if ($this->sums['short'] > 0) { $summary->content("Missing short descriptions: {$this->sums['short']}<br/>"); } if ($this->sums['long'] > 0) { $summary->content("Missing long descriptions: {$this->sums['long']}<br/>"); } if ($this->sums['param'] > 0) { $summary->content("Missing param descriptions: {$this->sums['param']}<br/>"); } if ($this->sums['return'] > 0) { $summary->content("Missing return value descriptions: {$this->sums['return']}<br/>"); } foreach ($this->errors as $err) { $summary->content("{$err}<br/>"); } } }