public function AddCommentAction() { $request = Project::getRequest(); $item_name = $request->item_name; $comment_model = new CommentModel($item_name . '_comment', $item_name . '_id', 0); switch ($item_name) { case 'article': $item_model = new ArticleModel(); break; case 'questions': $item_model = new QuestionModel(); break; case 'photo': $item_model = new PhotoModel(); break; case 'bookmarks': $item_model = new BookmarksModel(); break; case 'social': $item_model = new SocialModel(); break; case 'blog': $item_model = new BlogModel('blog_post'); break; } $item_model->load($request->element_id); if ($item_model->id > 0 && $request->add_comment) { $comment_model->addComment(Project::getUser()->getDbUser()->id, $request->avatar_id, 0, $request->element_id, $request->comment, $request->mood_id, $request->mood_text, 0); $item_model->comments++; $item_model->save(); } Project::getResponse()->redirect($request->createUrl($request->cur_controller, $request->cur_action, array($request->element_id))); }
public function indexAction() { $page = $this->getRequest()->getParam('page') ?: 0; //unused - see Bootstrap::_initRoutes $blog = new BlogModel(); /*view*/ $this->_view->entries = $blog->fetchAll(); $this->_view->page = $page; /*layout*/ $this->_layout->meta_title = 'A Blog'; }
function actionIndex($params = '') { $objUsers = new UserModel(); $latestLogins = $objUsers->getRecentLogins(true); $objBlog = new BlogModel(); $latestComments = $objBlog->getComments(array('status' => 'pending', 'limit' => '5')); $objSearch = new SearchModel(); $popularSearches = $objSearch->getPopular(array('startDate' => date("Y-m-d", strtotime('-1 Month')), 'endDate' => date("Y-m-d"), 'howMany' => 5)); $this->view->assign('latestLogins', $latestLogins); $this->view->assign('latestComments', $latestComments); $this->view->assign('popularSearches', $popularSearches); $this->view->assign('content', $this->view->fetch('tpl/home/index.tpl')); $this->finish(); }
public function index() { $this->assign('event', EventModel::hotEvents(1)); $users = model('User')->getUserList(10); foreach ($users['data'] as &$user) { $user = model('User')->formatForApi($user, $user['uid']); } $this->assign('users', $users['data']); $blogs = BlogModel::hotBlogs(10); $this->assign('blogs', $blogs); $video = M('V')->hotVideo(8); foreach ($video as &$row) { $row['user'] = model('User')->formatForApi($row, $row['uid']); } $this->assign('videos', $video); //$this->ajaxReturn($video); //热门图片 $photos = M('Photo')->where(array('is_del' => 0))->limit(10)->order('commentCount desc,cTime desc')->select(); $this->assign('photos', $photos); //热门专题 $album = M('Album')->order('comment_count desc')->find(); $album['intro'] = htmlspecialchars_decode($album['intro']); $album['attach_info'] = model('attach')->getAttachById($album['attach']); $this->assign('album', $album); $this->display(); }
/** * Smarty {blog_archive} block plugin * * Type: block<br> * Name: blog_archive<br> * Purpose: Loads in a blog articles from the database<br> * Useage: * {blog_archive varname='archive' category='test' year='2010'} * ... * {/blog_articles} * @author Nathan Gardner <*****@*****.**> */ function smarty_block_blog_archive(&$params, $content, &$smarty, &$repeat) { if ($repeat) { $objBlog = new BlogModel(); $months = array(); $filters = array(); $filters['nolimit'] = true; if (!empty($params['year'])) { $filters['year'] = $params['year']; } if (!empty($params['category'])) { $filters['category_id'] = $objBlog->getCategoryId($params['category']); } $allArticles = $objBlog->getArticles($filters); if (!empty($allArticles)) { foreach ($allArticles as $article) { $year = substr($article['publishDate'], 0, 4); $month = substr($article['publishDate'], 5, 2); if ($params['yearly']) { $index = $year; } else { $index = $year . $month; } if (empty($months[$index])) { $months[$index] = array('month' => $month, 'year' => $year, 'count' => 1); } else { $months[$index]['count'] = $months[$index]['count'] + 1; } } } $params['data'] = $months; $repeat = count($months); } if (is_array($params['data'])) { if ($month = array_shift($params['data'])) { $smarty->assign($params['varname'], $month); } } if (empty($month)) { $repeat = false; } else { $repeat = true; } return $content; }
function smarty_function_blogmenu($params, &$smarty) { $output = ''; $objBlog = new BlogModel(); $categoryList = $objBlog->getCategories(); global $__catListTemp; if (!empty($categoryList)) { // limit to a parent if (!empty($params['parent'])) { // find parent $parent_id = $objBlog->getCategoryId($params['parent']); if ($parent_id) { smarty_function_blogmenu_parent($categoryList, $parent_id); $categoryList = $__catListTemp; } } reset($categoryList); // draw menu $output = smarty_function_blogmenu_makemenu($categoryList, $output, $smarty); } return $output; }
/** * Smarty {blog_articles} block plugin * * Type: block<br> * Name: blog_articles<br> * Purpose: Loads in a blog articles from the database<br> * Useage: * {blog_articles varname='myblog' category='test'} * {$myblog.title}<br/> * {$myblog.article}<br/> * {/blog_articles} * @author Nathan Gardner <*****@*****.**> */ function smarty_block_blog_articles(&$params, $content, &$smarty, &$repeat) { if ($repeat) { $objBlog = new BlogModel(); if (!empty($params['identifier'])) { // pull just one article $filters = array(); $filters['id'] = $objBlog->getArticleId($params['identifier']); } else { $filters = array(); $filters['status'] = 'published'; // limit to category if (!empty($params['category'])) { $filters['category_id'] = $objBlog->getCategoryId($params['category']); } // limit amount returned if (!empty($params['limit'])) { $filters['limit'] = intval($params['limit']); } // preview flag if (!empty($params['preview'])) { $filters['preview'] = true; } } $params['articles'] = $objBlog->getArticles($filters); $repeat = $params['articles']; } if (is_array($params['articles'])) { if ($article = array_shift($params['articles'])) { $smarty->assign($params['varname'], $article); } } if (empty($article)) { $repeat = false; } else { $repeat = true; } return $content; }
public function detail() { $id = $_GET['id']; $blog = BlogModel::blog($id); $blog['is_favour'] = M('Favour')->is_favour($id, $this->mid, 'blog'); $this->assign('blog', $blog); $this->assign('hot_blogs', BlogModel::hotBlogs(5)); $comments = BlogModel::comments($id, 20); if (!empty($comments)) { foreach ($comments as &$comment) { $comment = model('User')->formatForApi($comment, $comment['uid']); $comment['addtime'] = $comment['ctime']; $comment['content'] = $this->convert_img($comment['content']); } } M('Blog')->updateReadCount($id); $this->assign('comments', $comments); $this->display(); }
function SaveBranchAction() { $request = Project::getRequest(); $request_user_id = (int) Project::getUser()->getShowedUser()->id; $user_id = (int) Project::getUser()->getDbUser()->id; if ($request_user_id != $user_id) { Project::getResponse()->redirect($request->createUrl('Blog', 'EditBranch', array($branch_id))); } $branch_id = (int) $request->branch_id; $name = $request->branch_name; $catalog_id = (int) $request->blog_catalog; $parent_id = (int) $request->parent_branch; $access = (int) $request->branch_access; $this->BaseSiteData(); $info = array(); $this->BaseBlogData($info); $blog_model = new BlogModel(); $blog_model->loadByUserId($user_id); $blog_id = (int) $blog_model->id; if ($blog_id <= 0) { Project::getResponse()->redirect($request->createUrl('Blog', 'Edit')); } $parent_tree_model = new BlogTreeModel(); $parent_tree_model->load($parent_id); $parent_node = $parent_tree_model->getNode(); if ($parent_tree_model->level > 1) { $this->_view->addFlashMessage(FM::ERROR, "Неверно выбран родительский раздел"); $this->EditBranchAction($branch_id); return; } if (!$name) { $this->_view->addFlashMessage(FM::ERROR, "Имя раздела не может быть пустым"); $this->EditBranchAction($branch_id); return; } $tree_model = new BlogTreeModel(); $tree_model->load($branch_id); $n = $tree_model->getNode(); if ($n instanceof Node) { $child = $n->getLastChildKey(); } else { $child = null; } //if ($child&&$child!=$tree_model->key){ // $this -> _view -> addFlashMessage(FM::ERROR, "Невозможно изменить раздел: есть зависимые разделы"); // $this -> EditBranchAction($branch_id); // return; //} if ($request->save) { $tree_model->name = $name; $tree_model->blog_id = $blog_id; $tree_model->access = $access; $tree_model->blog_catalog_id = $catalog_id; $blogModel = new BlogModel(); $blog_banner = $blogModel->getBlogBannerById($tree_model->blog_banner_id); if ($blog_banner) { $blog_banner_id = $tree_model->blog_banner_id; $blogModel->changeBlogBanner($tree_model->blog_banner_id, $request->blog_banner_code); } else { $blog_banner_id = $blogModel->addBlogBanner($request->blog_banner_code); } $tree_model->blog_banner_id = $blog_banner_id; $n = $tree_model->getNode(); if (!$n) { $tree_model->key = ''; if ($parent_node) { $tree_model->level = 1; } else { $tree_model->level = 1; } $branch_id = $tree_model->save(); $n = new Node(new Key($branch_id), 'ub_tree'); $tree_model->key = $n->key->__toString(); } if (!$parent_node) { $node = new Node(new Key($tree_model->id), 'ub_tree'); $tree_model->key = $node->key->__toString(); $tree_model->level = 1; } $branch_id = $tree_model->save(); if ($parent_node) { $n->changeParent($parent_node); } Project::getResponse()->redirect($request->createUrl('Blog', 'PostList')); } elseif ($request->delete) { $tree_model->delete($branch_id); $blog_model->deletePostsByUb_tree_id($branch_id); Project::getResponse()->redirect($request->createUrl('Blog', 'PostList')); } }
function actionUpdateStatus($params = '') { if (!empty($params['comment_id'])) { $objBlog = new BlogModel(); $data = array(); $data['id'] = $params['comment_id']; $data['status'] = $params['status']; $objBlog->saveComment($data); return; } else { $this->messages[] = array('type' => 'error', 'message' => 'Unknown comment to save.'); } $this->actionArticles(); }
public function actionBlog() { $blogs = BlogModel::model()->order("id DESC")->findAll(); $this->view("blog", array("posts" => $blogs), false); }
function category($args) { list($id) = $args; $id = urldecode($id); $page = isset($_GET['page']) ? tin($_GET['page']) : 1; $limit = 10; $begin = ($page - 1) * $limit; //echo "<br><br><br><br>ID ".$id; $bm = new BlogModel(); $arrB = $bm->getWhere("topic_category LIKE '%{$id}%' AND topic_status = 'publish' ORDER BY topic_date DESC LIMIT {$begin},{$limit}"); $jml = $bm->getJumlah("topic_category LIKE '%{$id}%' AND topic_status = 'publish'"); $bc = new BlogCategory(); $bc->getByID($id); //categort $this->isiMetaCategory($bc); $dis = $bc->getWhere("cat_active=1"); $jmlpage = ceil($jml / $limit); // pr($arrB); // pr($dis); $arr['posts'] = $arrB; $arr['cat'] = $dis; $arr['page'] = $page; $arr['begin'] = $begin; $arr['limit'] = $limit; $arr['jmlpage'] = $jmlpage; $arr['jml'] = $jml; $arr['bc'] = $bc; $directory = get_called_class() . "_" . __FUNCTION__; // echo "<br><br><br>"; // echo $directory; // Mold::theme("Pages/".$directory.) $layout_id = "Blog_category"; $file = Layout::getFile($layout_id); // echo "Pages/".$layout_id."/".$file; Mold::theme("Pages/" . $layout_id . "/" . $file, $arr); // Mold::theme("Pages/Blog_index",$arr); }
private function _viewBlogArticle(BlogModel $blog, BlogArticleModel $article) { $view = $this->getView(); /** @var $page PageModel */ $page = $article->getLink('Page'); //$articles = $blog->getLink('BlogArticle'); $manager = \Core\user()->checkAccess('p:/blog/manage_all'); $editor = \Core\user()->checkAccess($blog->get('manage_articles_permission ')) || $manager; $author = UserModel::Construct($article->get('authorid')); //$authorid = $author->get('id'); //var_dump($page->getMeta('keywords')); die(); if (!$article->isPublished()) { // Is it actually not published, or just marked for a future publish date? if ($article->get('status') == 'published') { $publishdate = new CoreDateTime($article->get('published')); Core::SetMessage('Article is set to be published on ' . $publishdate->getFormatted('F jS, Y \\a\\t h:ia'), 'info'); } else { Core::SetMessage('Article not published yet!', 'info'); } } //$view->templatename = $page->get('page_template') ? $page->get('page_template') : 'pages/blog/article_view.tpl'; $view->templatename = 'pages/blog/article_view.tpl'; //$view->addBreadcrumb($blog->get('title'), $blog->get('rewriteurl')); $view->title = $article->get('title'); $view->meta['title'] = $article->get('title'); $view->updated = $article->get('updated'); $view->canonicalurl = \Core\resolve_link($article->get('rewriteurl')); $view->meta['og:type'] = 'article'; if ($article->get('image')) { $image = \Core\Filestore\Factory::File($article->get('image')); $view->meta['og:image'] = $image->getPreviewURL('200x200'); } //if($author){ // /** @var $author User */ // //$view->meta['author'] = $author->getDisplayName(); // $view->meta['author'] = $author; //} $view->meta['description'] = $article->getTeaser(); $view->assign('author', $author->exists() ? $author : null); $view->assign('article', $article); $view->assign('body', \Core\parse_html($article->get('body'))); if ($editor) { $view->addControl('Edit Article', '/blog/article/update/' . $article->get('id'), 'edit'); if ($article->get('status') == 'draft') { $view->addControl(['title' => 'Publish Article', 'link' => '/blog/article/publish/' . $blog->get('id') . '/' . $article->get('id'), 'icon' => 'arrow-up', 'confirm' => 'Publish article?']); } $view->addControl(array('title' => 'Delete Article', 'link' => '/blog/article/delete/' . $article->get('id'), 'icon' => 'remove', 'confirm' => 'Remove blog article?')); } // Add the extra view types for this page $view->addHead('<link rel="alternate" type="application/atom+xml" title="' . $page->get('title') . ' Atom Feed" href="' . \Core\resolve_link($blog->get('baseurl')) . '.atom"/>'); $view->addHead('<link rel="alternate" type="application/rss+xml" title="' . $page->get('title') . ' RSS Feed" href="' . \Core\resolve_link($blog->get('baseurl')) . '.rss"/>'); $view->addControl('RSS Feed', \Core\resolve_link($blog->get('baseurl')) . '.rss', 'rss'); }
function &getBlog() { $blog_model = new BlogModel(); $blog_model->loadByUserId($this->id); return $blog_model; }
<?php error_reporting(E_PARSE); //session_start(); require 'model/blogModel.php'; $model = new BlogModel('blog'); $model->renderPage('blog.tpl'); ?>
/** * Helper method to be called on cron events to pull in the latest feeds for all the remote articles. */ public static function CronRetrieveRemoteFeeds() { $blogs = BlogModel::Find(['type = remote']); foreach ($blogs as $blog) { /** @var $blog BlogModel */ echo 'Retrieving remote feed for blog #' . $blog->get('id') . "...\n"; try { $results = $blog->importFeed(); } catch (Exception $e) { echo $e->getMessage(); return false; } echo 'Added: ' . $results['added'] . "\n" . 'Updated: ' . $results['updated'] . "\n" . 'Skipped: ' . $results['skipped'] . "\n" . 'Deleted: ' . $results['deleted'] . "\n" . "\n" . $results['changelog']; } return true; }
protected function tearDown() { $this->blog->delete(); $this->article->delete(); }
/** * Remove the objects created in the database. */ public static function tearDownAfterClass() { if (self::$TestBlogID) { // Remove it! $blog = new BlogModel(self::$TestBlogID); $blog->delete(); } }
public static function init() { self::$db = new \PDO('mysql:host=localhost;dbname=blog', 'root', ''); self::$db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); }
function RegistrationAction() { //if (true || $this -> ValidateRegistrationAction()){ if ($this->ValidateRegistrationAction()) { $request = Project::getRequest(); $user_model = new UserModel(); $user_model->login = $request->login; $user_model->salt = AppCrypt::generateSalt(); $user_model->pass = AppCrypt::getHash($request->pwd, $user_model->salt); $user_model->email = $request->email; $user_model->first_name = $request->name; $user_model->last_name = $request->surname; $user_model->middle_name = $request->father_name; $user_model->birth_date = $request->year . "-" . $request->month . "-" . $request->day; $user_model->gender = (int) $request->gender; $user_model->marital_status = $request->marital_status; $user_model->icq = $request->icq; $user_model->website = $request->website; $user_model->phone = $request->phone; $user_model->mobile_phone = $request->mobile_phone; $user_model->about = $request->about; $user_model->books = $request->books; $user_model->films = $request->films; $user_model->musicians = $request->musicians; $referer = new UserModel(); $referer->loadByLogin($request->referer); $user_model->referal = $referer->id ? $referer->id : 0; $user_model->country_id = (int) $request->country; $user_model->state_id = (int) $request->state; $user_model->city_id = (int) $request->city; $user_model->user_type_id = UserTypeModel::REGISTRED; $user_model->reputation = 0; $user_model->rate = 0; $user_model->nextmoney = 0; $user_model->registration_date = date("Y-m-d H:i:s"); $user_model->banned = 0; $user_id = (int) $user_model->save(); $rate_nm = $user_model->getUserRateNMByRegistrationData($user_id); if ($rate_nm['nm']) { $user_model->changeUserMoney($user_id, 0, $rate_nm['nm'], 'За регистрацию'); } if ($rate_nm['rate']) { $user_model->changeUserRate($user_id, 0, $rate_nm['rate']); } $separator = ","; if ($user_id <= 0) { $this->_view->addFlashMessage(FM::ERROR, "Ошибка регистрации!"); $this->RegistrationFormAction(); return; } $this->sendRegistrationMail($user_model, $request->pwd); if (strlen($request->interest)) { $interest_list = explode($separator, $request->interest); foreach ($interest_list as $interest) { $interest = trim($interest); if (strlen($interest)) { $interest_model = new InterestsModel(); $interest_id = $interest_model->set($interest); $user_interest_model = new UserInterestsModel(); $user_interest_model->set($user_id, $interest_id); } } } // Blog $blog_model = new BlogModel(); $blog_model->creation_date = date("Y-m-d"); $blog_model->creation_ip = $_SERVER['REMOTE_ADDR']; $blog_model->user_id = $user_id; $blog_model->title = 'Мой блог'; $blog_model->access = 2; $blog_model->save(); Project::getResponse()->redirect(Project::getRequest()->createUrl("User", "CompleteRegistration")); } else { $this->RegistrationFormAction(); } }
public function setUid($value) { self::$uid = $value; }
public function actionBlogDelete($id) { BlogModel::model()->where("`id`='" . (int) $id . "'")->delete(); $this->redirect("/admin/blog"); }