public function vote($arguments) { if (!CheckAcl::can('voteOnNews')) { return Error::set('You can not vote on news posts.'); } if (empty($arguments[0]) || empty($arguments[1])) { return Error::set('Vote or news id not found.'); } $news = new news(ConnectionFactory::get('mongo')); $result = $news->castVote($arguments[0], $arguments[1]); $post = $news->get($arguments[0], false, true); if (is_string($result)) { return Error::set($result, false, array('Back' => Url::format('/news/view/' . Id::create($post, 'news')))); } Error::set('Vote cast!', true, array('Back' => Url::format('/news/view/' . Id::create($post, 'news')))); }
/** * Id creation * * @param array $data The array to create an id out of. * @param string $type Type of id being created. * * @return string The content's id. */ protected static function create($data, $type) { switch ($type) { case 'news': $string = trim(strtolower($data['title'])); $string = preg_replace('{(-)\\1+}', '-', preg_replace('/[^\\w\\d_ -]/si', '-', $string)); $string = trim(str_replace(' ', '_', $string), '-_'); return date('Y/m/dHi_', $data['date']) . $string; break; case 'bug': $time = $data['_id']->getTimestamp(); $number = $data['_id']->getInc(); $id = base_convert($time, 10, 36) . '-' . base_convert($number, 10, 36); return $id; break; case 'user': return $data['username']; break; case 'article': return Id::create($data, 'news'); break; } return false; }
echo $description; ?> </blockquote> <?php } ?> <p><?php echo BBCode::parse($body); ?> </p> <?php if (!empty($mlt)) { ?> <p><h4>More Like This:</h4> <?php foreach ($mlt as $fetched) { echo '<a href="' . Url::format('article/view/' . Id::create($fetched, 'news')) . '">' . $fetched['title'] . '</a><br />'; } ?> </p> <?php } if ($published && empty($revision) && empty($preview)) { $data = array('_id' => $_id, 'rating' => $rating, 'type' => 'Articles', 'where' => 'article'); echo Partial::render('like', $data); } ?> </div>
public function clearCache($id, $idlib = false) { $entry = $this->get($id, $idlib, true); if (empty($entry)) { return; } self::ApcPurge('get', $entry['_id']); self::ApcPurge('get', Id::create($this->type, $entry)); }
echo '<a style="font-size: 11px;" title="' . $fullTitle . '" href="' . $link . '">' . $shortTitle . '</a><br />'; } ?> </div></div> <div class="span6"><div class="well"> <h4>IRC Lines</h4> <em>Not implemented yet.</em> </div></div> </div> <div class="row"> <div class="span3"><div class="well"> <h4>Latest Articles</h4> <?php foreach ($newArticles['articles'] as $entry) { $link = Url::format('/article/view/' . Id::create($entry, 'news')); $fullTitle = $entry['title']; $shortTitle = html_entity_decode($fullTitle, ENT_QUOTES); $longer = strlen($shortTitle) > 30; $shortTitle = substr($shortTitle, 0, 30); $shortTitle = htmlentities($shortTitle, ENT_QUOTES) . ($longer ? '…' : ''); echo '<a style="font-size: 11px;" title="' . $fullTitle . '" href="' . $link . '">' . $shortTitle . '</a><br />'; } ?> </div></div> <div class="span6"><div class="well"> <h4>Active Forum Posts</h4> <?php if (!empty($fPosts)) { foreach ($fPosts as $post) { echo '<a href="' . Url::format($post['url']) . '">' . $post['topic'] . '</a><br />';
private function revert(&$arguments, &$model, &$revisions, &$current) { if (!empty($arguments[1]) && $arguments[1] == 'revert' && !empty($arguments[2])) { $revision = $revisions->getById($arguments[2], $current, $this->diffdFields); if (is_string($revision)) { return Error::set($revision); } unset($revision['_id'], $revision['contentId']); array_unshift($revision, $current['_id']); $return = call_user_func_array(array($model, 'edit'), $revision); if (is_string($return)) { return Error::set($return); } $current = $model->get($arguments[0], false, true); $this->view['current'] = $current; Log::activity('Reverted: ' . $this->name, '/' . substr(get_called_class(), 11) . '/view/' . Id::create($current, $this->name)); } return true; }
<div class="well"> <h3><a href="<?php echo Url::format('article/view/' . Id::create(array('date' => $date, 'title' => $title), 'news')); ?> "><?php echo $title; ?> </a></h3> <p><?php echo $description; ?> </p> </div>
<?php if (!empty($valid) && $valid) { ?> <div class="page-header"><h1>Post News</h1></div> <form class="well form-veritcal" action="<?php echo Url::format('/news/post/save'); ?> " method="post"> <label>Title: </label> <input type="text" name="title" /><br /> <label>Department: </label> <input type="text" name="department" /><br /> <label>Text: </label> <textarea style="width: 100%" rows="10" name="body"></textarea><br /> <label>Tags: </label> <input type="text" name="tags" /> <span class="help-inline">(Comma seperated list of tags)</span><br /> <label class="checkbox"><input type="checkbox" name="commentable" value="yes" /> Commentable</label> <label class="checkbox"><input type="checkbox" name="shortNews" value="yes" /> Short News</label> <input type="submit" class="btn btn-info" name="preview" value="Preview" /> <input type="submit" class="btn btn-primary" name="post" value="Post News" /> </form> <?php } elseif (!empty($valid) && !$valid) { ?> <a href="<?php echo Url::format('/news/view/' . Id::create($info, 'news')); ?> ">Read</a> <?php }
?> </div></div> <div class="span4"> <div class="span4"><div class="well"> <h3>Articles</h3> <?php if (empty($articles)) { ?> <em>No articles written.</em> <?php } else { foreach ($articles as $article) { ?> <a href="<?php echo Url::format('/article/view/' . Id::create($article, 'news')); ?> "><?php echo $article['title']; ?> </a><br /> <?php } } ?> </div></div> <div class="span4"><div class="well"> <h3>Lectures</h3> <?php if (empty($lectures)) {
public function changeStatus($arguments) { if (!CheckAcl::can('editBugStatus')) { return Error::set('You are not allowed to change bug statuses.'); } if (empty($_POST['id'])) { return Error::set('Invalid id.'); } $bugs = new bugs(ConnectionFactory::get('mongo')); $bug = $bugs->get($_POST['id'], false); if (empty($bug)) { return Error::set('Invalid id.'); } $extra = array('public', 'private', 'delete'); $acceptable = array_merge(bugs::$status, $extra); if (empty($_POST['status']) || !in_array($_POST['status'], $acceptable)) { return Error::set('Invalid status.'); } if (in_array($_POST['status'], $extra)) { // Altering switch ($_POST['status']) { case 'public': $diff = array('public' => true); break; case 'private': $diff = array('public' => false); break; case 'delete': $diff = array('ghosted' => true); break; default: $diff = array(); break; } } else { // Standard status change. $diff = array('status' => array_search($_POST['status'], bugs::$status)); } $bugs->alter($_POST['id'], $diff); $this->view['valid'] = true; Error::set('Status changed.', true); apc_delete('bugs_' . Id::create(current($bug), 'bugs')); }
</td> <td><?php echo ucwords(bugs::$category[$bug['category']]); ?> </td> <td><?php echo Date::dayFormat($bug['lastUpdate']); ?> </td> <td><?php echo ucwords(bugs::$status[$bug['status']]); ?> </td> <td> <a href="<?php echo Url::format('/bugs/view/' . Id::create($bug, 'bugs')); ?> "> <?php echo $bug['title']; ?> </a> </td> </tr> <?php } ?> </tbody> </table> <?php }