本文整理汇总了PHP中Content::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::instance方法的具体用法?PHP Content::instance怎么用?PHP Content::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Content
的用法示例。
在下文中一共展示了Content::instance方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* You can pass in a locale parameter the first time you call getInstance('fr') in order to set the locale manually.
*/
public static function getInstance($locale = null)
{
if (!self::$instance instanceof self) {
self::$instance = new self();
self::$instance->setLocale($locale);
}
return self::$instance;
}
示例2: get_initial_introduction
protected function get_initial_introduction()
{
$introduction = array();
$introduction['title'] = $this->county->title;
$introduction['description'] = Content::instance('FixInternalLink', $this->county->introduction)->activate();
$introduction['image'] = $this->get_image_element($this->county->photo_category, $this->county->photo, $this->county->photo_description, 'medium');
return $introduction;
}
示例3: __construct
/**
* Initializes plugin variables and sets up WordPress hooks/actions.
*/
protected function __construct()
{
$this->plugin_path = trailingslashit(dirname(dirname(__FILE__)));
$this->plugin_dir = trailingslashit(basename($this->plugin_path));
$this->plugin_url = plugins_url($this->plugin_dir);
$this->register_theme_directory();
//debug('hi');
self::$user = User::instance();
self::$content = Content::instance();
//self::$flash = Flash::instance();
add_action('init', array($this, 'load_text_domain'), 1);
$this->add_hooks();
}
示例4: get_recent_posts
private function get_recent_posts()
{
global $container;
$postRepository = new MysqlPostRepository($container['db_connection_locator']);
$recentPosts = $postRepository->getActivePosts(3);
$recent_post_array = array();
foreach ($recentPosts as $postResult) {
$post = new stdclass();
$post->title = $postResult['title'];
$post->url = Loader::getRootUrl('blog') . "{$postResult['category']}/{$postResult['path']}/";
$post->category = ucwords(str_replace('-', ' ', $postResult['category']));
$post->thumb = Content::instance('FetchFirstPhoto', $postResult['body'])->activate();
$post->body = Content::instance('SmartTrim', $postResult['body'])->activate($post->thumb !== '' ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG);
$recent_post_array[] = $post;
}
return $recent_post_array;
}
示例5: check_for_special_redirect
protected function check_for_special_redirect($uri)
{
if(preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches))
{
global $container;
$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
$post = $repository->findPostByPath($matches[2]);
if(!$post)
{
Loader::loadNew('controller', '/Error404Controller')
->activate();
}
Loader::load('utility', 'Content');
$uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate();
}
else
{
$post_uri = URLDecode::getPiece(1);
if($post_uri !== null)
{
global $container;
$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
$post = $repository->findPostByPath($post_uri);
if($post != false)
{
Loader::load('utility', 'Content');
$uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate();
}
}
}
if($uri == '/search/')
{
if(Request::getGet('submit') == 'Submit Search' && Request::getGet('search'))
{
$uri .= Request::getGet('search');
$uri .= '/';
}
}
return $uri;
}
示例6: get_list_prev_link
protected function get_list_prev_link()
{
if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count())
return;
return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page + 1) . '/')->activate();
}
示例7: get_comments
protected function get_comments()
{
global $container;
$repository = new Jacobemerick\Web\Domain\Comment\Comment\ServiceCommentRepository($container['comment_service_api']);
$start = microtime(true);
try {
$comment_response = $repository->getComments(
'waterfallsofthekeweenaw.com',
null,
1,
5,
'-date'
);
} catch (Exception $e) {
$container['logger']->warning("CommentService | Sidebar | {$e->getMessage()}");
return;
}
$elapsed = microtime(true) - $start;
global $container;
$container['logger']->info("CommentService | Sidebar | {$elapsed}");
$array = array();
foreach($comment_response as $comment)
{
$body = Content::instance('CleanComment', $comment['body'])->activate();
$body = strip_tags($body);
$comment_obj = new stdclass();
$comment_obj->description = Content::instance('SmartTrim', $body)->activate(50);
$comment_obj->commenter = $comment['commenter']['name'];
$comment_obj->link = $comment['url'];
$array[] = $comment_obj;
}
return $array;
}
示例8: get_formatted_log_body
private function get_formatted_log_body()
{
$body = $this->log->body;
$body = Content::instance('FixPhoto', $body)->activate(false, 'standard');
$body = Content::instance('FixInternalLink', $body)->activate();
return $body;
}
示例9: get_nearby_list
private function get_nearby_list($waterfall)
{
$nearby_list = array();
$result = WaterfallCollector::getNearbyList($waterfall);
foreach ($result as $row) {
$nearby_list[] = (object) array(
'url' => "/{$row->watercourse_alias}/{$row->alias}/",
'anchor' => $row->name,
'title' => "{$row->name} of {$row->watercourse}",
'distance' => Content::instance('ImperialUnit', $row->distance)->activate(false),
);
}
return $nearby_list;
}
示例10: get_related_posts
private function get_related_posts()
{
$tag_array = array();
foreach($this->tags as $tag)
{
$tag_array[] = $tag['id'];
}
$series_posts = $this->fetch_series_posts();
$exclude_post_array = array();
foreach($series_posts as $series_post)
{
$exclude_post_array[] = $series_post['post'];
}
global $container;
$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
$post_result = $repository->getActivePostsByRelatedTags($this->post['id']);
$post_array = array();
foreach($post_result as $post_row)
{
$post = new stdclass();
$post->title = $post_row['title'];
$post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/";
$post->category = ucwords(str_replace('-', ' ', $post_row['category']));
$post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate();
$post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG);
$post_array[] = $post;
}
return $post_array;
}
示例11: get_comment_array
protected function get_comment_array($site, $path)
{
global $container;
$repository = new Jacobemerick\Web\Domain\Comment\Comment\ServiceCommentRepository($container['comment_service_api']);
$start = microtime(true);
try {
$comment_response = $repository->getComments(
$site,
$path,
1,
null,
'date'
);
} catch (Exception $e) {
$container['logger']->warning("CommentService | Path | {$e->getMessage()}");
return;
}
$elapsed = microtime(true) - $start;
global $container;
$container['logger']->info("CommentService | Path | {$elapsed}");
$array = array();
foreach((array) $comment_response as $comment)
{
$body = Content::instance('CleanComment', $comment['body'])->activate();
$body = strip_tags($body);
$comment_obj = new stdclass();
$comment_obj->id = $comment['id'];
$comment_obj->name = $comment['commenter']['name'];
$comment_obj->url = $comment['commenter']['website'];
$comment_obj->trusted = true;
$comment_obj->date = $comment['date']->format('M j, \'y');
$comment_obj->body = $body;
if ($comment['reply_to']) {
$array[$comment['reply_to']]->replies[$comment['id']] = $comment_obj;
continue;
}
$comment_obj->replies = [];
$array[$comment['id']] = $comment_obj;
}
// todo figure out commenter obj
// todo figure out how to handle errors or whatever
// todo why is this even doing all this
return [
'comments' => $array,
'commenter' => [],
'errors' => [],
'comment_count' => count($comment_response),
];
}