本文整理汇总了PHP中Utility::splitByTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Utility::splitByTitle方法的具体用法?PHP Utility::splitByTitle怎么用?PHP Utility::splitByTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utility
的用法示例。
在下文中一共展示了Utility::splitByTitle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* generate xss/atom from spreadit
*
* @param string $section_title
* @return Roumen\Feed
*/
protected function generate($section_title)
{
$sections = $this->section->getByTitle(Utility::splitByTitle($section_title));
if (empty($sections)) {
App::abort(404);
}
$section = $this->section->sectionFromSections($sections);
$posts = $this->post->getHotList(F::map($sections, function ($m) {
return $m->id;
}), $this->vote);
$feed = Feed::make();
$feed->title = $section_title;
$feed->description = "read hot posts from {$section_title}";
$feed->link = URL::to("/s/{$section_title}");
$feed->lang = 'en';
$created_at_counter = 0;
foreach ($posts as $post) {
$feed->add($post->title, $post->username, URL::to($post->url), date(DATE_ATOM, $post->created_at), $post->markdown);
if ($post->created_at > $created_at_counter) {
$created_at_counter = $post->created_at;
}
}
$feed->pubdate = date(DATE_ATOM, $created_at_counter);
return $feed;
}
示例2: get
/**
* renders a post page
*
* @param string $section_title
* @param int $post_id
* @return Illuminate\View\View
*/
public function get($section_title, $post_id)
{
$section = $this->section->sectionFromSections($this->section->getByTitle(Utility::splitByTitle($section_title)));
$section->selected = $this->vote->getSelected(Constant::SECTION_TYPE, $section);
$post = $this->post->get($post_id);
$post->section_title = $section_title;
$post->selected = $this->vote->getSelected(Constant::POST_TYPE, $post);
$commentTree = new CommentTree($this->comment->getByPostId($post_id, $this->vote));
return View::make('page.post', ['section' => $section, 'sections' => $this->section->get(), 'comments' => $commentTree->grab()->sort('new')->render(), 'post' => $post, 'sort_highlight' => Utility::getSortMode(), 'sort_timeframe_highlight' => Utility::getSortTimeframe()]);
}
示例3: make
public function make($section_title, $content, $title, $url, $nsfw, $nsfl, Section $section)
{
$section_title = strtolower($section_title);
$block = new SuccessBlock();
$block->data->section_title = $section_title;
$block->data->item_title = Utility::prettyUrl($title);
if ($block->success) {
if (Auth::user()->points < 1) {
$block->success = false;
$block->errors[] = 'You need at least one point to post';
}
}
if ($block->success) {
if (!$this->canPost()) {
$block->success = false;
$block->errors[] = 'can only post ' . Utility::availablePosts() . ' per day';
}
}
if ($block->success) {
$data = $this->prepareData(['data' => $content, 'title' => $title, 'url' => $url, 'user_id' => Auth::user()->id, 'nsfw' => $nsfw, 'nsfl' => $nsfl]);
$rules = $this->generateRules($data);
$validate = Validator::make($data, $this->generateRules($data));
if ($validate->fails()) {
$block->success = false;
foreach ($validate->messages()->all() as $v) {
$block->errors[] = $v;
}
}
}
if ($block->success) {
//check if .gif & gfycat it
$data['url'] = $this->gfycatUrl($data['url']);
if (!$section->exists($section_title)) {
$ssect = new Section(['title' => $section_title]);
if (!$ssect->save()) {
$block->success = false;
$block->errors[] = 'unable to create new spreadit';
$block->data->section_title = str_replace(' ', '_', $block->data->section_title);
}
}
}
if ($block->success) {
$section = $section->sectionFromSections($section->getByTitle(Utility::splitByTitle($section_title)));
if ($section->id < 1) {
$block->success = false;
$block->errors[] = 'can only post to a real section(you probably tried to post to /s/all)';
}
}
if ($block->success) {
$data['section_id'] = $section->id;
$item = new Post($data);
$item->save();
if (isset($rules['url'])) {
if (Utility::urlExists($data['url'])) {
Utility::thumbnailScript($item->id, $data['url']);
}
}
//add a point for adding posts
if (Auth::user()->anonymous == 0) {
Auth::user()->increment('points');
}
$block->data->item_id = $item->id;
} else {
$block->data->item_id = null;
}
return $block;
}
示例4: isset
<?php
$section_titles = isset($section) ? Utility::splitByTitle($section->title) : [];
?>
<div id="header">
<a href="#content" id="jumpToContent" tabindex="1">jump to content</a>
<div id="sr-header-area">
<div class="width-clip">
<div class="dropdown srdrop" onclick="open_menu(this)">
<span class="selected title">my subreddits</span>
</div>
<div class="sr-list">
<ul class="flat-list sr-bar hover">
<li class="selected">
<a class="choice" href="/">frontpage</a>
</li>
</ul>
<span class="separator"> | </span>
<ul class="flat-list sr-bar hover">
@foreach ($sections as $section)
<li>
<span class="separator">-</span>
<a class="choice" href="/s/{{{ $section->title }}}">{{{ $section->title }}}</a>
</li>
@endforeach
</ul>
</div>
示例5: get
/**
* renders a section page
*
* @param string $section_title
* @param string $sort_mode
* @param string $timeframe_mode
* @param bool $no_view
* @return mixed
*/
protected function get($section_title, $sort_mode, $timeframe_mode, $no_view)
{
$sections = $this->section->getByTitle(Utility::splitByTitle($section_title));
if (empty($sections)) {
App::abort(404);
}
$sections = $this->vote->getSelectedList(Constant::SECTION_TYPE, $sections);
$section = $this->section->sectionFromSections($sections);
$section->selected = $this->vote->getSelected(Constant::SECTION_TYPE, $section);
if (is_null($sort_mode)) {
$sort_mode = Utility::getSortMode();
}
if (is_null($timeframe_mode)) {
$timeframe_mode = Utility::getSortTimeframe();
}
$section_ids = F::map($sections, function ($m) {
return $m->id;
});
$posts = $this->getPosts($sort_mode, $section_ids, $this->getSecondsFromTimeframe($timeframe_mode));
if ($no_view) {
return $posts;
}
return Response::make(View::make('page.section', ['sections' => $this->section->get(), 'posts' => $posts, 'section' => $section, 'sort_highlight' => $sort_mode, 'sort_timeframe_highlight' => $timeframe_mode]))->withCookie(Cookie::make('posts_sort_mode', $sort_mode))->withCookie(Cookie::make('posts_sort_timeframe', $timeframe_mode));
}