public function getHtml($forceHtml5 = false) { $template = new Template('parts/google/youtube'); $template->assign('youtubeCode', $this->code); $template->assign('forceHtml5', $forceHtml5); return $template->fetch(); }
public function exec() { $db = \Kiki\Core::getDb(); $user = \Kiki\Core::getUser(); $article = new \Kiki\Article($this->instanceId); $this->title = $article->title(); $template = \Kiki\Template::getInstance(); $template->append('stylesheets', \Kiki\Config::$kikiPrefix . "/scripts/prettify/prettify.css"); if ($article->visible() || $article->userId() == $user->id()) { $this->title = $article->title(); $this->status = 200; $this->template = 'pages/default'; $template = new \Kiki\Template('content/pages-single'); $template->assign('page', $article->templateData()); $this->content = $template->fetch(); } }
$update->setSectionId($_POST['sectionId']); $update->setVisible(true); $update->setUserId($user->id()); $update->save(); foreach ($_POST['connections'] as $id => $value) { if ($value != 'on') { continue; } $connection = $user->getConnection($id); if ($connection) { $rs = $connection->post($update->objectId(), $msg); if (isset($rs->id)) { echo "<p>" . $connection->serviceName() . " status geupdate: <a target=\"_blank\" href=\"" . $rs->url . "\">" . $rs->url . "</a></p>\n"; } else { if ($rs->error == 'Read-only application cannot POST') { $template = new Template('parts/connections/twitter/insufficient-rights'); echo $template->content(); } else { echo "<p>\nEr is een fout opgetreden bij het updaten van je " . $connection->serviceName() . " status:</p>\n<pre>" . print_r($rs->error, true) . "</pre>\n"; } } } } } else { echo "<p>\nJe kunt geen lege status versturen.</p>\n"; } } if ($user->anyUser()) { echo Form::open("socialForm"); $q = $db->buildQuery("select id,title from sections where type='%s' order by title asc", 'articles'); $rs = $db->query($q);
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(); }
public function exec() { $db = Core::getDb(); $user = Core::getUser(); $template = Template::getInstance(); $template->append('stylesheets', \Kiki\Config::$kikiPrefix . "/scripts/prettify/prettify.css"); $q = $db->buildQuery("SELECT id FROM articles a LEFT JOIN objects o ON o.object_id=a.object_id WHERE o.section_id=%d AND ((o.visible=1 AND o.ctime<=now()) OR o.user_id=%d) ORDER BY o.ctime DESC LIMIT 10", $this->instanceId, $user->id()); $articleIds = $db->getObjectIds($q); $articles = array(); foreach ($articleIds as $articleId) { $article = new Article($articleId); $articles[] = array('url' => $article->url(), 'title' => $article->title()); } $template->assign('latestArticles', $articles); if (preg_match('/^page-([\\d]+)$/', $this->objectId, $matches) && isset($matches[1])) { $this->objectId = null; $currentPage = $matches[1]; } if (isset($this->objectId) && $this->objectId) { $matches = array(); if (preg_match('/^socialupdate-([\\d]+)$/', $this->objectId, $matches) && isset($matches[1])) { $updateId = $matches[1]; $update = new SocialUpdate($updateId); if (!$update->id()) { return; } $this->status = 200; $this->title = \Kiki\Misc::textSummary($update->body(), 50); $this->template = 'pages/default'; $template = new Template('content/socialupdates-single'); $template->assign('update', $update->templateData()); $this->content = $template->fetch(); return; } $article = new Article(0, $this->objectId); if ($article->id() && $article->sectionId() == $this->instanceId && ($article->visible() || $article->userId() == $user->id())) { $this->status = 200; $this->title = $article->title(); $this->template = 'pages/default'; $template = new Template('content/articles-single'); $GLOBALS['articleAlbumId'] = $article->albumId(); $template->assign('article', $article->templateData()); $this->content = $template->fetch(); } else { // $this->template = 'pages/default'; // $template = new Template( 'content/articles-404' ); // $this->content = $template->fetch(); return false; } } else { $section = new \Kiki\Section($this->instanceId); $itemsPerPage = 25; if (!isset($currentPage)) { $currentPage = 1; } $this->status = 200; $this->title = $section->title(); $this->template = 'pages/default'; $this->content = null; // MultiBanner::articles( $section->id() ); $article = new Article(); $update = new SocialUpdate(); $q = $db->buildQuery("SELECT count(*) FROM objects WHERE type IN ('%s', '%s', '%s', '%s') AND section_id=%d AND ((visible=1 AND ctime<=now()) OR user_id=%d)", 'Article', 'Kiki\\Article', 'SocialUpdate', 'Kiki\\SocialUpdate', $this->instanceId, $user->id()); $totalPosts = $db->getSingleValue($q); $paging = new \Kiki\Paging(); $paging->setCurrentPage($currentPage); $paging->setItemsPerPage($itemsPerPage); $paging->setTotalItems($totalPosts); $q = $db->buildQuery("SELECT object_id, ctime, type FROM objects WHERE type IN ('%s', '%s', '%s', '%s') AND section_id=%d AND ( (visible=1 AND ctime<=now()) OR user_id=%d) ORDER BY ctime DESC LIMIT %d,%d", 'Article', 'Kiki\\Article', 'SocialUpdate', 'Kiki\\SocialUpdate', $this->instanceId, $user->id(), $paging->firstItem() - 1, $itemsPerPage); $rs = $db->query($q); while ($o = $db->fetchObject($rs)) { switch ($o->type) { case 'Article': case 'Kiki\\Article': $article->reset(); $article->setObjectId($o->object_id); $article->load(); $template = new Template('content/articles-summary'); $template->assign('article', $article->templateData()); $this->content .= $template->fetch(); break; case 'SocialUpdate': case 'Kiki\\SocialUpdate': $update->reset(); $update->setObjectId($o->object_id); $update->load(); $template = new Template('content/socialupdates-summary'); $template->assign('update', $update->templateData()); $this->content .= $template->fetch(); break; default: } } $this->content .= $paging->html(); } }
public function verifyAction() { $this->status = 200; $this->template = 'pages/default'; $this->title = _("Verify account"); $template = new \Kiki\Template('content/account-verify'); $errors = array(); $warnings = array(); $user = \Kiki\Core::getUser(); $token = isset($_GET['token']) ? $_GET['token'] : null; if (empty($token)) { $errors[] = "Auth token missing."; } else { // Get user by auth token. $verifyUserId = $user->getIdByToken($token); if (!$verifyUserId) { $errors[] = "Invalid auth token. Auth tokens expire. [Send new verification e-mail]"; } else { $verifyUser = new \Kiki\User($verifyUserId); $verifyUser->setIsVerified(true); $verifyUser->save(); if ($user->id() && $user->id() != $verifyUser->id()) { $warnings[] = sprintf("Because you verified account <strong>%s</strong> (%d), you are no longer logged in as <strong>%s</strong> (%d).", $verifyUser->email(), $verifyUser->id(), $user->email(), $user->id()); } else { Auth::setCookie($verifyUser->id()); $user = $verifyUser; \Kiki\Core::setUser($verifyUser); $mainTemplate = \Kiki\Template::getInstance(); $mainTemplate->assign('user', $user->templateData()); } } } $template->assign('warnings', $warnings); $template->assign('errors', $errors); $this->content = $template->fetch(); return true; }