本文整理汇总了PHP中Blog类的典型用法代码示例。如果您正苦于以下问题:PHP Blog类的具体用法?PHP Blog怎么用?PHP Blog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Blog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_mtwebsiteurl
function smarty_function_mtwebsiteurl($args, &$ctx)
{
// status: complete
// parameters: none
if (isset($args['id']) && is_numeric($args['id'])) {
require_once 'class.mt_website.php';
$blog = new Blog();
$ret = $blog->Load('blog_id = ' . $args['id']);
if (!$ret) {
$blog = null;
}
}
if (empty($blog)) {
$blog = $ctx->stash('blog');
}
if (empty($blog)) {
return '';
}
$website = $blog->is_blog() ? $blog->website() : $blog;
if (empty($website)) {
return '';
}
$url = $website->site_url();
if (!preg_match('!/$!', $url)) {
$url .= '/';
}
return $url;
}
示例2: smarty_function_mtblogarchiveurl
function smarty_function_mtblogarchiveurl($args, &$ctx)
{
if (isset($args['id']) && is_numeric($args['id'])) {
require_once 'class.mt_blog.php';
$blog = new Blog();
$ret = $blog->Load('blog_id = ' . $args['id']);
if (!$ret) {
$blog = null;
}
}
if (empty($blog)) {
$blog = $ctx->stash('blog');
}
if (empty($blog)) {
return '';
}
$url = $blog->archive_url();
if ($url == '') {
$url = $blog->site_url();
}
if (!preg_match('/\\/$/', $url)) {
$url .= '/';
}
return $url;
}
示例3: __construct
public function __construct($data)
{
if (isset($data['session'])) {
$guid = $data['guid'];
$title = $data['blog_title'];
$description = $data['description'];
$access_id = $data['access_id'];
$user = getUserFromSession($data['session']);
if (!$guid) {
$blog = new Blog();
$blog->owner_guid = $user->guid;
$blog->save();
} else {
$blog = getEntity($guid);
}
if ($blog->owner_guid == $user->guid) {
$blog->title = $title;
$blog->description = $description;
$blog->access_id = $access_id;
$blog->status = "draft";
$guid = $blog->save();
$blog = getEntity($guid);
echo json_encode(array("guid" => $guid, "timeago" => display("output/friendly_time", array("timestamp" => $blog->last_updated))));
}
}
}
示例4: __construct
public function __construct()
{
gateKeeper();
$guid = getInput("guid");
$title = getInput("blog_title");
$description = getInput("description");
$access_id = getInput("access_id");
$container_guid = getInput("container_guid");
$owner_guid = getLoggedInUserGuid();
if ($guid) {
$blog = getEntity($guid);
} else {
$blog = new Blog();
}
$blog->title = $title;
$blog->description = $description;
$blog->access_id = $access_id;
$blog->owner_guid = $owner_guid;
$blog->status = "published";
$blog->container_guid = $container_guid;
$blog->save();
new Activity(getLoggedInUserGuid(), "blog:add", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $blog->getURL(), $blog->title, truncate($blog->description)), "", $access_id);
new SystemMessage("Your blog has been published");
forward("blogs/all_blogs");
}
示例5: smarty_function_mtwebsitepath
function smarty_function_mtwebsitepath($args, &$ctx)
{
if (isset($args['id']) && is_numeric($args['id'])) {
require_once 'class.mt_website.php';
$blog = new Blog();
$ret = $blog->Load('blog_id = ' . $args['id']);
if (!$ret) {
$blog = null;
}
}
if (empty($blog)) {
$blog = $ctx->stash('blog');
}
if (empty($blog)) {
return '';
}
$website = $blog->is_blog() ? $blog->website() : $blog;
if (empty($website)) {
return '';
}
$path = $website->site_path();
if (!preg_match('!/$!', $path)) {
$path .= '/';
}
return $path;
}
示例6: smarty_function_mtwebsiterelativeurl
function smarty_function_mtwebsiterelativeurl($args, &$ctx)
{
// status: complete
// parameters: none
if (isset($args['id']) && is_numeric($args['id'])) {
require_once 'class.mt_website.php';
$website = new Blog();
$ret = $website->Load('blog_id = ' . $args['id']);
if (!$ret) {
$website = null;
}
} else {
$blog = $ctx->stash('blog');
if (empty($blog)) {
return '';
}
$website = $blog->is_blog() ? $blog->website() : $blog;
}
if (empty($website)) {
return '';
}
$host = $website->site_url();
if (!preg_match('!/$!', $host)) {
$host .= '/';
}
if (preg_match('!^https?://[^/]+(/.*)$!', $host, $matches)) {
return $matches[1];
} else {
return '';
}
}
示例7: delete
public function delete($id)
{
$Blog = new Blog($this->table_name, $this->action);
$sql = $Blog->destroy($id);
mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
header("Location: ../index");
}
示例8: view
public function view($query)
{
$blog = new Blog();
$params = array('blog' => $blog->find($query[0]));
$this->setParams('params', $params);
$this->render();
}
示例9: showAction
public function showAction(array $params)
{
$blogModel = new Blog();
$blog = $blogModel->getById($params['id']);
$data = array('content' => $blog);
return $this->render('show', $data);
}
示例10: delete
public function delete($id)
{
$Blog = new Blog($this->plural_resource);
$sql = $Blog->destroy($id);
mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
header("Location: ../index");
}
示例11: login
public function login(Blog $blog)
{
$this->setAuthenticated(true);
$this->setAttribute('id', $blog->getId(), 'user');
$this->setAttribute('mid', $blog->getMid(), 'user');
$this->setAttribute('name', $blog->getAuthor(), 'user');
}
示例12: blogs
function blogs()
{
$where = "blog_parent_id = " . $this->id;
require_once 'class.mt_blog.php';
$blog = new Blog();
$blogs = $blog->Find($where);
return $blogs;
}
示例13: getNewestTimestamp
public static function getNewestTimestamp(Blog $blog)
{
$c = new Criteria();
$c->addDescendingOrderByColumn(PostPeer::CREATED_AT);
$c->add(PostPeer::BLOG_ID, $blog->getId());
$post = PostPeer::doSelectOne($c);
return $post ? $post->getCreatedAt(null) : 0;
}
示例14: newPost
public function newPost($title, $content, $user_id)
{
$blog = new Blog();
$blog->newPost($title, $content, $user_id);
echo "Vaša objava je shranjena";
$view = new blogView();
$view->renderSavedPost();
}
示例15: testUpdatePostTitle
public function testUpdatePostTitle()
{
$blog = new Blog($this->pdo);
$blog->update_post_title(0, "Test Title Update");
$result = $this->getConnection()->createQueryTable("posts", "SELECT id, title FROM posts\n WHERE id = 0");
$expected = $this->createFlatXmlDataSet("seeds/expectedUpdatePostTitle.xml")->getTable("posts");
$this->assertTablesEqual($expected, $result);
}