Esempio n. 1
0
 public function exec()
 {
     $db = \Kiki\Core::getDb();
     $user = \Kiki\Core::getUser();
     if (!$this->objectId) {
         $this->objectId = 'index';
     }
     // Find page under this section through subcontroller.
     // TODO: also find subsections, instead of defining full paths in
     // sections db...  the latter is faster, but then the base paths are not
     // properly normalised.  Both should be possible.
     $this->subController = \Kiki\Router::findPage($this->objectId, $this->instanceId);
     if ($this->subController) {
         $this->subController->exec();
     } else {
         if ($this->objectId == 'index') {
             $section = new \Kiki\Section($this->instanceId);
             $this->status = 200;
             $this->template = 'pages/autoindex';
             $this->title = sprintf(_("Index of %s"), $section->title());
             $q = $db->buildQuery("SELECT cname,title FROM articles a, objects o WHERE a.object_id=o.object_id AND o.section_id=%d AND visible=true", $this->instanceId);
             $rs = $db->query($q);
             if ($db->numRows($rs) == 0) {
                 $this->template = 'pages/autoindex-empty';
                 return;
             }
             $this->content = "<ul>";
             while ($o = $db->fetchObject($rs)) {
                 $this->content .= sprintf('<li><a href="%s">%s</a></li>', $o->cname, $o->title);
             }
             $this->content .= "</ul>";
         }
     }
 }
Esempio n. 2
0
 public function getBaseUri($action = null)
 {
     $uri = $this->instanceId ? \Kiki\Router::getBaseUri('account', $this->instanceId) : \Kiki\Config::$kikiPrefix . "/account";
     if (!empty($action)) {
         if ($uri[strlen($uri) - 1] != '/') {
             $uri .= "/";
         }
         $uri .= $action;
     }
     return $uri;
 }
Esempio n. 3
0
    if (!$user->isAdmin()) {
        $errors[] = "Je hebt geen admin rechten.";
    }
    $section->setBaseURI($_POST['baseURI']);
    $section->setTitle($_POST['title']);
    $section->setType($_POST['type']);
    if (!$section->baseURI()) {
        $errors[] = "Je kunt de URL naam niet leeg laten.";
    }
    // if ( strstr( $section->baseURI(), "/" ) )
    //   $errors[] = "Een URL naam mag geen <q>/</q> bevatten.";
    if (!sizeof($errors)) {
        $section->save();
    }
    if (isset($_POST['json'])) {
        $response = array();
        $response['sectionId'] = $section->id();
        $response['errors'] = $errors;
        header('Content-type: application/json');
        echo json_encode($response);
        exit;
    }
    if (!count($errors)) {
        Router::redirect($_SERVER['HTTP_REFERER'], 303);
        exit;
    }
    $template = Template::getInstance();
    $template->load('pages/admin');
    $template->assign('content', "fouten bij opslaan:<pre>" . print_r($errors, true) . "</pre>");
    echo $template->content();
}
Esempio n. 4
0
 public function url($addSchema = false)
 {
     $sectionBaseUri = $this->sectionId ? \Kiki\Router::getBaseUri($this->sectionId) : null;
     if (!$sectionBaseUri) {
         $sectionBaseUri = "/";
     }
     // TODO: support HTTPS
     $urlPrefix = ($addSchema ? "https" : null) . "//" . $_SERVER['SERVER_NAME'];
     // TODO: what if - unlikely, but possible, we have an Article (not Page) with cname index? Really time to go Post/Article/Page
     $url = $urlPrefix . $sectionBaseUri . ($this->cname != 'index' ? $this->cname : null);
     return $url;
 }