本文整理汇总了PHP中blogPostModel::getEmptyRow方法的典型用法代码示例。如果您正苦于以下问题:PHP blogPostModel::getEmptyRow方法的具体用法?PHP blogPostModel::getEmptyRow怎么用?PHP blogPostModel::getEmptyRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blogPostModel
的用法示例。
在下文中一共展示了blogPostModel::getEmptyRow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$blog_id = wa()->getRequest()->param('blog_url_type');
if ($blog_id <= 0) {
$blog_id = waRequest::request('blog_id', 0, 'int');
}
$this->setLayout(new blogFrontendLayout());
// Get contact id and name as post author
if (wa()->getUser()->get('is_user')) {
$post_contact_id = wa()->getUser()->getId();
$post_contact_name = wa()->getUser()->getName();
} else {
foreach (blogHelper::getAuthors($blog_id) as $post_contact_id => $post_contact_name) {
break;
}
}
// Prepare empty fake post data
$post_model = new blogPostModel();
$post = $post_model->prepareView(array(array('id' => 0, 'blog_id' => $blog_id, 'contact_id' => $post_contact_id, 'contact_name' => $post_contact_name, 'datetime' => date('Y-m-d H:i:s'), 'title' => '%replace-with-real-post-title%', 'status' => 'published', 'text' => '<div class="replace-with-real-post-text"></div>' . $this->getScripts(), 'comments_allowed' => 0) + $post_model->getEmptyRow()));
$post = array_merge($post[0], array('comments' => array(), 'comment_link' => '', 'link' => ''));
$this->getResponse()->setTitle(_w('Preview'));
$this->getResponse()->setMeta('keywords', '');
$this->getResponse()->setMeta('description', '');
$current_auth = wa()->getStorage()->read('auth_user_data');
$current_auth_source = $current_auth ? $current_auth['source'] : null;
$this->view->assign(array('realtime_preview' => true, 'frontend_post' => array(), 'errors' => array(), 'form' => array(), 'show_comments' => false, 'request_captcha' => false, 'require_authorization' => false, 'theme' => waRequest::param('theme', 'default'), 'current_auth_source' => $current_auth_source, 'current_auth' => $current_auth, true, 'auth_adapters' => wa()->getAuthAdapters(), 'post' => $post));
}
示例2: execute
public function execute()
{
$post_id = waRequest::get('id', null, waRequest::TYPE_INT);
$blog_model = new blogBlogModel();
$blogs = $blog_model->getAvailable();
if (!$blogs) {
$this->setTemplate('BlogNotFound');
return;
}
$blogs = $blog_model->prepareView($blogs);
$post_model = new blogPostModel();
if ($post_id) {
// edit post
$post = $post_model->getById($post_id);
if (!$post) {
throw new waException(_w('Post not found'), 404);
}
//check rights
if (blogHelper::checkRights($post['blog_id']) < blogRightConfig::RIGHT_FULL && $post['contact_id'] != $this->getUser()->getId()) {
throw new waRightsException(_w('Access denied'));
}
$post['datetime'] = $post['datetime'] >= 1971 ? $post['datetime'] : '';
$blog_id = $post['blog_id'];
$blog = $blogs[$blog_id];
$title = trim(sprintf(_w('Editing post %s'), $post['title']));
} else {
// add post
$date = waRequest::get('date', '');
$blog = $this->getAllowedBlog($blogs, wa()->getStorage()->read('blog_last_id'));
if (!$blog) {
throw new waRightsException(_w('Access denied'));
}
$blog_id = $blog['id'];
$post = array('status' => $date ? blogPostModel::STATUS_DEADLINE : blogPostModel::STATUS_DRAFT, 'title' => $this->getRequest()->post('title', '', waRequest::TYPE_STRING_TRIM), 'text' => $this->getRequest()->post('text', '', waRequest::TYPE_STRING_TRIM), 'continued_text' => null, 'categories' => array(), 'contact_id' => wa()->getUser()->getId(), 'blog_id' => $blog_id) + $post_model->getEmptyRow();
$title = _w('Adding new post');
}
// Album tree
$albums = array();
$photos_frontend_url = null;
if (blogPhotosBridge::isAvailable()) {
if ($post['album_link_type'] != 'photos') {
$post['album_link_type'] = 'blog';
}
wa('photos');
$album_model = new photosAlbumModel();
$albums = $album_model->getAlbums();
foreach ($albums as &$a) {
if ($a['status'] == 1) {
$a['frontend_link'] = photosFrontendAlbum::getLink($a);
} else {
$a['frontend_link'] = '';
}
}
unset($a);
}
// Frontend URLs for this post
$album_link_type = $post['album_link_type'];
$post['album_link_type'] = 'blog';
$all_links = blogPostModel::getPureUrls($post);
$post['album_link_type'] = $album_link_type;
$post['other_links'] = $all_links;
$post['link'] = array_shift($post['other_links']);
$post['remaining_time'] = null;
if ($post['status'] == blogPostModel::STATUS_SCHEDULED && $post['datetime']) {
$post['remaining_time'] = $this->calculateRemainingTime($post['datetime']);
}
if ($blog['rights'] >= blogRightConfig::RIGHT_FULL) {
$users = blogHelper::getAuthors($post['blog_id']);
} else {
$user = $this->getUser();
$users = array($user->getId() => $user->getName());
}
// preview hash for all type of drafts
if ($post['status'] != blogPostModel::STATUS_PUBLISHED) {
$options = array('contact_id' => $post['contact_id'], 'blog_id' => $blog_id, 'post_id' => $post['id'], 'user_id' => wa()->getUser()->getId());
$preview_hash = blogPostModel::getPreviewHash($options);
$this->view->assign('preview_hash', base64_encode($preview_hash . $options['user_id']));
}
$this->view->assign('albums', $albums);
$this->view->assign('no_settlements', !wa()->getRouteUrl('blog/'));
$this->view->assign('params', $this->getPostParams($post['id']));
$this->view->assign('blog', $blog);
$this->view->assign('users', $users);
$this->view->assign('blogs', $blogs);
$allow_change_blog = 0;
foreach ($blogs as $blog_item) {
if ($blog_item['rights'] >= blogRightConfig::RIGHT_READ_WRITE) {
++$allow_change_blog;
}
}
$this->view->assign('allow_change_blog', $allow_change_blog);
$this->view->assign('post_id', $post_id);
$this->view->assign('datetime_timezone', waDateTime::date("T", null, wa()->getUser()->getTimezone()));
/**
* Backend post edit page
* UI hook allow extends post edit page
* @event backend_post_edit
* @param array[string]mixed $post
* @param array[string]int $post['id']
* @param array[string]int $post['blog_id']
//.........这里部分代码省略.........