本文整理汇总了PHP中Post::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::get方法的具体用法?PHP Post::get怎么用?PHP Post::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
Cache::loadPage('', 30);
$inputData = array();
$postid = 0;
$curPage = 0;
// Model::loadWithPath('home',System::getThemePath().'model/');
if ($match = Uri::match('page\\/(\\d+)')) {
$curPage = (int) $match[1];
}
$txtKeywords = addslashes(Request::get('txtKeywords', ''));
if ($match = Uri::match('\\/keyword\\/(.*?)\\/page')) {
$txtKeywords = base64_decode($match[1]);
}
$loadData = Post::get(array('limitShow' => 10, 'limitPage' => $curPage, 'cacheTime' => 30, 'where' => "where title LIKE '%{$txtKeywords}%'", 'orderby' => "order by postid desc"));
if (!isset($loadData[0]['postid'])) {
Redirect::to('404page');
}
$inputData['newPost'] = $loadData;
$inputData['keywords'] = $txtKeywords;
$inputData['listPage'] = Misc::genPage('search/keyword/' . base64_encode($txtKeywords), $curPage);
System::setTitle('Search result with keyword "' . $txtKeywords . '" results:');
self::makeContent('search', $inputData);
Cache::savePage();
}
示例2: filter_user_client
public function filter_user_client($client, $user)
{
if (intval($user->info->client) != 0) {
$client = Post::get(array('id' => $user->info->client, 'ignore_permissions' => true));
}
return $client;
}
示例3: listRss
function listRss()
{
header("Content-Type: application/xml; charset=UTF-8");
$location = Url::rss();
if ($match = Uri::match('^(.*?)$')) {
$location = ROOT_URL . $match[1];
$reLocation = base64_encode($location);
if ($loadData = Cache::loadKey($reLocation, 60)) {
$loadData = json_decode($loadData, true);
return $loadData;
}
}
$inputData = array('limitShow' => 15, 'limitPage' => 0);
if ($match = Uri::match('\\/page\\/(\\d+)')) {
$inputData['limitPage'] = $match[1];
}
if ($match = Uri::match('\\/category\\/(\\d+)')) {
$id = $match[1];
$inputData['where'] = "where catid='{$id}'";
}
if ($match = Uri::match('rss\\/products')) {
$loadData = Products::get($inputData);
} else {
$loadData = Post::get($inputData);
}
$reLocation = base64_encode($location);
Cache::saveKey($reLocation, json_encode($loadData));
return $loadData;
}
示例4: index
public function index()
{
Cache::loadPage('', 30);
$inputData = array();
$postid = 0;
Model::loadWithPath('post', System::getThemePath() . 'model/');
if (!($match = Uri::match('post\\/(.*?)\\.html$'))) {
Redirect::to('404page');
}
$friendly_url = addslashes($match[1]);
$loadData = Post::get(array('cacheTime' => 30, 'where' => "where friendly_url='{$friendly_url}'"));
if (!isset($loadData[0]['postid'])) {
Redirect::to('404page');
}
$inputData = $loadData[0];
if (Request::has('btnComment')) {
try {
sendComment($loadData[0]['postid']);
$inputData['commentAlert'] = '<div class="alert alert-success">Send comment success.</div>';
} catch (Exception $e) {
$inputData['commentAlert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>';
}
}
$postid = $loadData[0]['postid'];
$listTag = PostTags::renderToLink($postid);
$inputData['listTag'] = $listTag;
$inputData['listComments'] = Comments::get(array('where' => "where postid='{$postid}' AND status='1'", 'orderby' => "order by postid desc"));
Post::upView($postid);
System::setTitle(ucfirst($loadData[0]['title']));
$keywords = isset($loadData[0]['keywords'][4]) ? $loadData[0]['keywords'] : System::getKeywords();
System::setKeywords($keywords);
self::makeContent('post', $inputData);
Cache::savePage();
}
示例5: act
public function act($action)
{
if ($action == 'atom_feed') {
if (!isset($this->handler_vars['index'])) {
$this->handler_vars['index'] = 1;
}
$url = URL::get('atom_feed', $this->handler_vars, false);
} else {
if ($action == 'display_entry') {
if (isset($this->handler_vars['slug'])) {
$post = Post::get(array('slug' => $this->handler_vars['slug']));
// don't assume that a slug means a valid post
if ($post !== false) {
$url = URL::get('display_entry', $post, false);
} else {
$url = URL::get('display_404', $this->handler_vars->getArrayCopy(), false);
}
} else {
$post = Post::get($this->handler_vars->getArrayCopy());
if ($post !== false) {
$url = $post->permalink;
} else {
$url = URL::get('display_404', $this->handler_vars->getArrayCopy(), false);
}
}
} else {
$url = URL::get($action, $this->handler_vars->getArrayCopy(), false);
}
}
header('Location: ' . $url, true, 301);
}
示例6: execute
/**
* Exection hook
*
* @param Stencil_Interface $controller Controller that initiated this class.
*/
public function execute(Stencil_Interface $controller)
{
$list = array();
if (have_posts()) {
while (have_posts()) {
the_post();
$object = get_post();
/**
* Respect post_as_object filter
*/
$post_as_object = Stencil_Environment::filter('post_as_object', true);
if ($post_as_object) {
/**
* Apply fancy Human Made Post object if loaded
*/
if (class_exists('Post', false)) {
$item = Post::get($object->ID);
} else {
$item = $object;
}
} else {
$item = (array) $object;
}
// Add item to the list.
$list[] = $item;
// Clean up.
unset($item);
}
}
wp_reset_postdata();
$controller->set('posts', $list);
}
示例7: searchResult
function searchResult()
{
$curPage = 0;
$keywords = '';
if ($matches = Uri::match('tag\\/(.*?)\\/page\\/(\\d+)')) {
$curPage = $matches[2];
$keywords = $matches[1];
} elseif ($matches = Uri::match('tag\\/(.*?)$')) {
$curPage = 0;
$keywords = $matches[1];
}
// $loadPostNode=PostTags::get(array(
// 'limitShow'=>10,
// 'limitPage'=>$curPage,
// 'where'=>"where tag_title LIKE '%$keywords%'"
// ));
// // print_r($loadPostNode);die();
// $total=count($loadPostNode);
// $listID='';
// for($i=0;$i<$total;$i++)
// {
// $listID.="'".$loadPostNode[$i]['postid']."', ";
// }
// $listID=substr($listID, 0, strlen($listID)-2);
$loadData = Post::get(array('where' => "where postid IN (select postid from post_tags where title='{$keywords}')", 'orderby' => "group by postid order by date_added"));
return $loadData;
}
示例8: convert_post_id_to_post_object
/**
* Get Post object if available
*
* @param int $id Post ID.
*
* @return array|null|Post|WP_Post
*/
function convert_post_id_to_post_object($id)
{
if (class_exists('Post')) {
return Post::get($id);
}
return get_post($id);
}
示例9: action_plugin_act_podcast_media
/**
* Redirects the link from an embedded player, feed, or an html
* download link to the actual file
*
* @param PluginHandler $handler. Primarily used to get the handler vars
* @return Nothing.
* @TODO make sure $podcast actually holds a valid feed
* @TODO make sure $method is valid
*/
public function action_plugin_act_podcast_media($handler)
{
// $podcast is the name of the podcast
$podcast = $handler->handler_vars['podcast_name'];
// $post is the post we're using
$post = Post::get(array('slug' => $handler->handler_vars['post_name']));
// $method is the source of the link
// embed - from an on-page player
// download- from a download link under the player
// feed - from a feed
$method = $handler->handler_vars['method'];
$info = $post->info->{"{$podcast}"};
if (!empty($info) && isset($info['enclosure'])) {
$filename = $handler->handler_vars['filename'];
$url = dirname($info['enclosure']) . '/' . $filename;
// allow plugins to act. intended for stats
Plugins::act('podcast_redirect', $podcast, $post, $method, rawurldecode($filename));
header('Cache-Control: no-cache, must-revalidate');
// HTTP/1.1
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Pragma:no-cache');
// HTTP/1.0
header('Content-type: ' . Utils::mimetype($url));
header('Content-Length: ' . $info['size']);
Utils::redirect($url);
}
}
示例10: execute
/**
* Exection hook
*
* @param Stencil_Interface $controller Controller that initiated this class.
*/
public function execute(Stencil_Interface $controller)
{
$url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$controller->set('self', $url);
// Loading post(s) as object or array.
$post_as_object = Stencil_Environment::filter('post_as_object', true);
$object = get_queried_object();
if ($object && is_a($object, 'WP_Post')) {
/**
* Filter to chose whether the 'post' variable is set as array or object
*/
if ($post_as_object) {
if (class_exists('Post', false)) {
$controller->set('post', Post::get($object->ID));
} else {
$controller->set('post', $object);
}
} else {
$controller->set('post', (array) $object);
}
// Additional handy variables.
$controller->set('id', $object->ID);
$controller->set('post_type', get_post_type($object));
}
}
示例11: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$this->post_id = Post::get()->id;
$this->paramarray = array('id' => 'foofoo', 'post_id' => $this->post_id, 'name' => 'test', 'email' => 'test@example.org', 'url' => 'http://example.org', 'ip' => ip2long('127.0.0.1'), 'content' => 'test content', 'status' => Comment::STATUS_UNAPPROVED, 'date' => HabariDateTime::date_create(), 'type' => Comment::COMMENT);
$this->comment = new Comment($this->paramarray);
$this->comment->insert();
}
示例12: countStats
function countStats()
{
$resultData = array();
$today = date('Y-m-d');
$loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post"));
$resultData['post']['total'] = $loadData[0]['totalcount'];
$loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post where DATE(date_added)='{$today}'"));
$resultData['post']['today'] = $loadData[0]['totalcount'];
$loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post where status='1'"));
$resultData['post']['published'] = $loadData[0]['totalcount'];
$loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post where status='0'"));
$resultData['post']['pending'] = $loadData[0]['totalcount'];
$loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments"));
$resultData['comments']['total'] = $loadData[0]['totalcount'];
$loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments where DATE(date_added)='{$today}'"));
$resultData['comments']['today'] = $loadData[0]['totalcount'];
$loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments where status='1'"));
$resultData['comments']['approved'] = $loadData[0]['totalcount'];
$loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments where status='0'"));
$resultData['comments']['pending'] = $loadData[0]['totalcount'];
$loadData = Contactus::get(array('query' => "select count(contactid)as totalcount from " . Database::getPrefix() . "contactus"));
$resultData['contactus']['total'] = $loadData[0]['totalcount'];
$loadData = Contactus::get(array('query' => "select count(contactid)as totalcount from " . Database::getPrefix() . "contactus where DATE(date_added)='{$today}'"));
$resultData['contactus']['today'] = $loadData[0]['totalcount'];
$loadData = Users::get(array('query' => "select count(userid)as totalcount from " . Database::getPrefix() . "users"));
$resultData['users']['total'] = $loadData[0]['totalcount'];
$loadData = Users::get(array('query' => "select count(userid)as totalcount from " . Database::getPrefix() . "users where DATE(date_added)='{$today}'"));
$resultData['users']['today'] = $loadData[0]['totalcount'];
return $resultData;
}
示例13: post_delete_post
/**
* Deletes a post from the database.
*/
public function post_delete_post()
{
$extract = $this->handler_vars->filter_keys('id', 'nonce', 'timestamp', 'digest');
foreach ($extract as $key => $value) {
${$key} = $value;
}
$okay = true;
if (empty($id) || empty($nonce) || empty($timestamp) || empty($digest)) {
$okay = false;
}
$wsse = Utils::WSSE($nonce, $timestamp);
if ($digest != $wsse['digest']) {
$okay = false;
}
$post = Post::get(array('id' => $id, 'status' => Post::status('any')));
if (!ACL::access_check($post->get_access(), 'delete')) {
$okay = false;
}
if (!$okay) {
Utils::redirect(URL::get('admin', 'page=posts&type=' . Post::status('any')));
}
$post->delete();
Session::notice(_t('Deleted the %1$s titled "%2$s".', array(Post::type_name($post->content_type), Utils::htmlspecialchars($post->title))));
Utils::redirect(URL::get('admin', 'page=posts&type=' . Post::status('any')));
}
示例14: index
public function index()
{
Cache::loadPage('', 30);
$inputData = array();
$postid = 0;
$curPage = 0;
// Model::loadWithPath('home',System::getThemePath().'model/');
if (!($match = Uri::match('tag\\/(\\w+)\\/?'))) {
Redirect::to('404page');
}
$friendly_url = addslashes($match[1]);
if ($match = Uri::match('page\\/(\\d+)')) {
$curPage = (int) $match[1];
}
$loadData = Post::get(array('limitShow' => 10, 'limitPage' => $curPage, 'cacheTime' => 30, 'where' => "where postid IN (select postid from post_tags where title='{$friendly_url}')", 'orderby' => "order by postid desc"));
if (!isset($loadData[0]['postid'])) {
Redirect::to('404page');
}
$inputData['newPost'] = $loadData;
$inputData['keywords'] = $friendly_url;
$inputData['listPage'] = Misc::genPage('tag/' . $friendly_url, $curPage);
System::setTitle('Tag "' . $friendly_url . '" results:');
self::makeContent('tag', $inputData);
Cache::savePage();
}
示例15: action_comment_insert_after
public function action_comment_insert_after($comment)
{
// we should only execute on comments, not pingbacks
// and don't bother if the comment is know to be spam
if ($comment->type != Comment::COMMENT || $comment->status == Comment::STATUS_SPAM) {
return;
}
$post = Post::get(array('id' => $comment->post_id));
$author = User::get_by_id($post->user_id);
$status = $comment->status == Comment::STATUS_UNAPPROVED ? ' UNAPPROVED' : ' approved';
$title = sprintf(_t('[%1$s] New%3$s comment on: %2$s'), Options::get('title'), $post->title, $status);
$message = <<<MESSAGE
The following comment was added to the post "%1\$s".
%2\$s
Author: %3\$s <%4\$s>
URL: %5\$s
%6\$s
-----
Moderate comments: %7\$s
MESSAGE;
$message = _t($message);
$message = sprintf($message, $post->title, $post->permalink, $comment->name, $comment->email, $comment->url, $comment->content, URL::get('admin', 'page=comments'));
$headers = array('MIME-Version: 1.0', 'Content-type: text/plain; charset=utf-8', 'Content-Transfer-Encoding: 8bit', 'From: ' . $this->mh_utf8($comment->name) . ' <' . $comment->email . '>');
mail($author->email, $this->mh_utf8($title), $message, implode("\r\n", $headers));
}