Exemplo n.º 1
0
 /**
  * output appropriate html
  */
 public function html()
 {
     global $lang;
     $helper = $this->loadHelper('loadskin', true);
     print '<div id="plugin__loadskin">';
     print $this->locale_xhtml('intro');
     $form = new Doku_Form(array());
     $form->startFieldSet('Add rule');
     $form->addHidden('id', $ID);
     $form->addHidden('do', 'admin');
     $form->addHidden('page', 'loadskin');
     $form->addHidden('act', 'add');
     $form->addElement(form_makeOpenTag('p'));
     $form->addElement(form_makeTextField('pattern', '', $this->getLang('pattern')));
     $form->addElement(form_makeCloseTag('p'));
     $form->addElement(form_makeOpenTag('p'));
     $form->addElement(form_makeListboxField('tpl', $helper->getTemplates(), '', $this->getLang('template')));
     $form->addElement(form_makeCloseTag('p'));
     $form->addElement(form_makeButton('submit', '', $lang['btn_save']));
     $form->endFieldSet();
     $form->printForm();
     if (@file_exists($this->config)) {
         $data = unserialize(io_readFile($this->config, false));
         if (!empty($data)) {
             echo '<table class="inline">' . DOKU_LF;
             echo '  <tr>' . DOKU_LF;
             echo '    <th>' . $this->getLang('pattern') . '</th>' . DOKU_LF;
             echo '    <th>' . $this->getLang('template') . '</th>' . DOKU_LF;
             echo '    <th>' . $this->getLang('action') . '</th>' . DOKU_LF;
             echo '  </tr>' . DOKU_LF;
             foreach ($data as $key => $value) {
                 echo '  <tr>' . DOKU_LF;
                 echo '    <td>' . $key . '</td>' . DOKU_LF;
                 echo '    <td>' . $value . '</td>' . DOKU_LF;
                 echo '    <td>' . DOKU_LF;
                 $form = new Doku_Form(array());
                 $form->addHidden('do', 'admin');
                 $form->addHidden('page', 'loadskin');
                 $form->addHidden('act', 'del');
                 $form->addHidden('id', $ID);
                 $form->addHidden('pattern', $key);
                 $form->addElement(form_makeButton('submit', '', $lang['btn_delete']));
                 $form->printForm();
                 echo '    </td>' . DOKU_LF;
                 echo '  </tr>' . DOKU_LF;
             }
             echo '</table>' . DOKU_LF;
         }
     }
     print '</div>';
 }
Exemplo n.º 2
0
 /**
  * render the manage_files action
  *
  */
 function render(&$event, $param)
 {
     global $ID;
     $perm = auth_quickaclcheck($ID);
     if ($event->data != 'manage_files') {
         return;
     }
     $event->preventDefault();
     if ($perm < AUTH_READ) {
         echo '<h1>Error</h1><p>You do not have permission to view this page</p>';
         return;
     }
     $project = Project::project();
     if ($project == NULL) {
         echo '<h1>Error</h1>';
         $project = getNS($ID);
         $path = explode(":", $project);
         if (!$project || $path[0] != PROJECTS_NAMESPACE) {
             echo "<p>Projects wiki has to work under the " . PROJECTS_NAMESPACE . " namespace</p>";
             return;
         }
         $parent = getNS($project);
         if (!$parent) {
             echo "<p>The namespace " . PROJECTS_NAMESPACE . " has not been created yet!</p>";
             return;
         }
         echo "<p>This project does not exist!</p>";
         $name = noNS($parent);
         $link = DOKU_URL . "/doku.php?id={$parent}:{$name}&do=manage_files";
         echo "<p>Go back to <a href=\"{$link}\">{$parent}</a>";
         return;
     }
     echo '<h1>Manage Project ' . $project->name() . '</h1>';
     $files = $project->files();
     ksort($files);
     echo "<h1>Manage Files</h1>";
     echo "<table>";
     foreach (array(SOURCE, TARGET, CROSSLINK) as $type) {
         $count = 0;
         $utype = ucfirst($type);
         echo "<tr><td></td><td></td><td><h2>{$utype} Files</h2></td></tr>";
         foreach ($files as $file) {
             if ($file->type() != $type) {
                 continue;
             }
             echo "<tr>";
             $name = $file->name();
             echo "<td>";
             if ($file->is_target() && $perm > AUTH_READ) {
                 echo button_remake($project->id($name));
             }
             echo "</td>";
             echo "<td>";
             if ($perm >= AUTH_DELETE) {
                 echo button_delete($project->id($name));
             }
             echo "</td>";
             echo "<td>";
             echo html_wikilink($project->id($name));
             if ($project->error($name) != NULL) {
                 echo "<img src=\"" . DOKU_URL . "/lib/images/error.png\"></img>";
             }
             echo "</td>";
             echo "</tr>";
             $count++;
         }
         if ($count == 0) {
             echo "<tr><td></td><td></td><td>No {$type} files in this project</td></tr>";
         }
     }
     $files = $project->subprojects();
     if ($files) {
         sort($files);
         echo "<tr><td></td><td></td><td><h2>Subprojects</h2></td></tr>";
         foreach ($files as $file) {
             $id = $project->name() . ":{$file}";
             $link = DOKU_URL . "/doku.php?id={$id}:{$file}&do=manage_files";
             echo "<tr><td></td><td></td><td>";
             echo "<a href=\"{$link}\">{$file}</a>";
             echo "</td>";
             echo "</tr>";
         }
     }
     echo "</table>";
     $parent = $project->parent();
     if ($parent != NULL) {
         echo "<h1>Parent project</h1>";
         $name = $parent->name();
         $file = end(explode(":", $name));
         $link = DOKU_URL . "/doku.php?id={$name}:{$file}&do=manage_files";
         echo "<a href=\"{$link}\">{$name}</a>";
     }
     if ($perm <= AUTH_READ) {
         return;
     }
     echo "<p/><h1>Create Files</h1>";
     $create = new Doku_Form("Create");
     $create->addHidden("do", "create");
     $create->addHidden("page", "projects_manage_files");
     $create->addHidden("id", $ID);
     $create->startFieldSet('Create a new file');
     $create->addElement(form_makeOpenTag("p"));
     $create->addElement(form_makeField('text', 'File name'));
     $create->addElement(form_makeCloseTag("p"));
     $create->addElement(form_makeOpenTag("p"));
     $create->addElement(form_makeRadioField('Type', SOURCE, "Source", "", "", array('checked' => "true")));
     $create->addElement(form_makeRadioField('Type', TARGET, 'Generated'));
     $create->addElement(form_makeRadioField('Type', CROSSLINK, 'Crosslink'));
     $create->addElement(form_makeCloseTag("p"));
     $create->addElement(form_makeButton("submit", '', "Create"));
     $create->endFieldSet();
     echo $create->getForm();
     echo "<h1>Create subproject</h1>";
     $subproject = new Doku_Form("Subproject");
     $subproject->addHidden("do", "create_subproject");
     $subproject->addHidden("page", "projects_manage_files");
     $subproject->addHidden("id", $ID);
     $subproject->startFieldSet('Create a new subproject');
     $subproject->addElement(form_makeOpenTag("p"));
     $subproject->addElement(form_makeField('text', 'Project name'));
     $subproject->addElement(form_makeCloseTag("p"));
     $subproject->addElement(form_makeButton("submit", '', "Create sub-project"));
     $subproject->endFieldSet();
     echo $subproject->getForm();
     echo "<h1>Clean up</h1>";
     $clean = new Doku_Form("Clean");
     $clean->addHidden("do", "clean");
     $clean->addHidden("page", "projects_manage_files");
     $clean->addHidden("id", $ID);
     $clean->startFieldSet('Clean the project');
     $clean->addElement(form_makeCheckboxField("Recursive"));
     $clean->addElement(form_makeButton("submit", "", "Clean"));
     $clean->endFieldSet();
     echo $clean->getForm();
     if ($perm < AUTH_ADMIN) {
         return;
     }
     echo "<h1>Rebuild the project</h1>";
     $rebuild = new Doku_Form("rebuild");
     $rebuild->addHidden("do", "rebuild");
     $rebuild->addHidden("page", "projects_manage_files");
     $rebuild->addHidden("id", $ID);
     $rebuild->startFieldSet('Rebuild the project');
     $rebuild->addElement(form_makeButton("submit", '', "Rebuild"));
     $rebuild->endFieldSet();
     echo $rebuild->getForm();
 }