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; }
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; }
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)))); } } }
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"); }
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; }
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 ''; } }
public function categoriesAction() { // $this->_request doesn't have params from staticroute $request = $this->getFrontController()->getRequest(); $this->view->list = $this->_blog->getCategories(); $this->view->category = $request->getParam('cat'); }
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"); }
public function view($query) { $blog = new Blog(); $params = array('blog' => $blog->find($query[0])); $this->setParams('params', $params); $this->render(); }
public function showAction(array $params) { $blogModel = new Blog(); $blog = $blogModel->getById($params['id']); $data = array('content' => $blog); return $this->render('show', $data); }
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"); }
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'); }
function blogs() { $where = "blog_parent_id = " . $this->id; require_once 'class.mt_blog.php'; $blog = new Blog(); $blogs = $blog->Find($where); return $blogs; }
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; }
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(); }
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); }
/** * * @param int $limit [description] * @return array */ public static function get_posts($limit = false) { $blog = new Blog('posts/'); // Get drafted posts as well if (User::is_logged_in()) { return $blog->getAllPosts($limit); } return $blog->getPosts($limit); }
public function delete() { $Blog = new Blog($this->plural_resorce, $this->option, $this->db); $sql = $Blog->delete(); var_dump($sql); mysqli_query($this->db, $sql) or die(mysqli_error($this->db)); header('Location:../index'); exit; }
function visitBlog(Blog $b) { $pages = $b->getPages(); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo '<blog>'; foreach ($pages as $pa) { $pa->accept($this); } echo '</blog>'; }
function blogs() { if ($this->class == 'blog') { return null; } $where = "blog_parent_id = " . $this->id; $blog = new Blog(); $blogs = $blog->Find($where); return $blogs; }
function visitBlog(Blog $b) { $page = $b->getPage($this->_id); echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; echo "<html><head>"; echo '<meta http-equiv="Content-type" content="text/html;charset=ISO-8859-1">'; echo "<title>" . $b->getTitle() . "</title>"; echo '<link rel="alternate" type="application/rss+xml" title="RSS" href="http://' . $_SERVER['SERVER_NAME'] . $this->_rootfolder . 'rss.php">'; echo "</head><body>"; $page->accept($this); echo "</body></html>"; }
public static function getRulesArray() { $rulesArray = []; $requset = new Blog(); $rules = $requset->rules(); foreach ($rules as $index => $rule) { $rule = explode('|', $rules[$index]); foreach ($rule as $i => $item) { $rulesArray[$index][$i] = $item; } } return $rulesArray; }
/** * @param boolean limited If true, use anonymous submission form */ public static function edit(Blog $blog, $version_id = NULL, $limited = false) { javascriptMod('blog', 'image_url'); if ($limited) { throw new \Exception(''); } $form = new PHPWS_Form('edit-blog'); $form->addHidden('module', 'blog'); $form->addHidden('action', 'admin'); $form->addHidden('command', 'post_entry'); if ($blog->id) { $form->addHidden('blog_id', $blog->id); $form->addSubmit('submit', dgettext('blog', 'Update entry')); } else { $form->addSubmit('submit', dgettext('blog', 'Add entry')); } $link_choices['none'] = dgettext('blog', 'No link and ignore image link setting'); $link_choices['default'] = dgettext('blog', 'No link but allow image link setting'); $link_choices['readmore'] = dgettext('blog', 'Link to read more'); $link_choices['parent'] = dgettext('blog', 'Link resized image to parent'); $link_choices['url'] = dgettext('blog', 'Link the url below'); $form->addText('title', $blog->title); $form->setSize('title', 40); $form->setLabel('title', dgettext('blog', 'Title')); $form->setRequired('title'); $form->addTextArea('summary', $blog->getSummaryAndEntry(false)); if (!$limited) { $form->useEditor('summary'); } $form->setRows('summary', '10'); $form->setCols('summary', '60'); $form->setLabel('summary', dgettext('blog', 'Content')); javascript('datetimepicker', null, false, true, true); $form->addText('publish_date', $blog->getPublishDate('%Y/%m/%d %H:%M')); $form->setLabel('publish_date', dgettext('blog', 'Publish date/time')); $form->setSize('publish_date', 20); $form->setClass('publish_date', 'datetimepicker'); $form->addText('expire_date', $blog->getExpireDate()); $form->setLabel('expire_date', dgettext('blog', 'Expire date/time')); $form->setSize('expire_date', 20); $form->setClass('expire_date', 'datetimepicker'); $template = $form->getTemplate(); $jscal['date_name'] = 'expire_date'; $template['EXAMPLE'] = 'YYYY/MM/DD HH:MM'; if ($blog->_error) { $template['MESSAGE'] = implode('<br />', $blog->_error); } $template['REMINDER'] = dgettext('blog', 'Add a horizontal rule to separate content into summary and body'); return PHPWS_Template::process($template, 'blog', 'edit.tpl'); }
public function getCMSFields() { $fields = FieldList::create(); $fields->push(DropdownField::create("BlogID", _t("BlogTagsWidget.Blog", "Blog"), Blog::get()->map())); $this->extend("updateCMSFields", $fields); return $fields; }
public function actionBlogs() { $data = Yii::app()->ls->createCommand('SELECT * FROM prefix_blog')->queryAll(); $transaction = Yii::app()->db->beginTransaction(); try { Blog::model()->deleteAll(); foreach ($data as $blog) { echo "Import blog '{$blog['blog_title']}' !\n"; $slug = $blog['blog_url'] ? $blog['blog_url'] : yupe\helpers\YText::translit($blog['blog_title']); $updateDate = $blog['blog_date_edit'] ? $blog['blog_date_edit'] : $blog['blog_date_add']; $icon = ''; if ($blog['blog_avatar']) { $url = parse_url($blog['blog_avatar']); if (!empty($url['path'])) { $icon = str_replace('/uploads/', '', $url['path']); } } $type = $blog['blog_type'] == 'personal' ? Blog::TYPE_PRIVATE : Blog::TYPE_PUBLIC; Yii::app()->db->createCommand(' INSERT INTO {{blog_blog}} (id, name, slug, description, create_user_id, update_user_id, create_date, update_date, icon, type) VALUES (:id, :name, :slug, :description, :create_user_id, :update_user_id, :create_date, :update_date, :icon, :type) ')->bindValue(':id', $blog['blog_id'])->bindValue(':name', $blog['blog_title'])->bindValue(':slug', $slug)->bindValue(':description', strip_tags($blog['blog_description']))->bindValue(':create_user_id', $blog['user_owner_id'])->bindValue(':update_user_id', $blog['user_owner_id'])->bindValue(':create_date', strtotime($blog['blog_date_add']))->bindValue(':update_date', strtotime($updateDate))->bindValue(':icon', $icon)->bindValue(':type', $type)->execute(); } $transaction->commit(); } catch (Exception $e) { CVarDumper::dump($e); $transaction->rollback(); die; } }
public function __construct() { parent::__construct(); if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['comment'])) { $this->addcomment(); } }
public function create($query) { $params = array('message' => null); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $blog = new Blog(); $blog->setFields($_POST); if ($blog->add()) { $params['message'] = 'Record added successfully'; } else { $params['message'] = 'Request was not successfull. Please try again'; $params['error'] = true; } } $this->setParams('params', $params); $this->render(); }
public function actionWrite() { $post = new Post(); if ($postId = (int) Yii::app()->getRequest()->getQuery('id')) { $post = Post::model()->findUserPost($postId, Yii::app()->getUser()->getId()); if (null === $post) { throw new CHttpException(404); } } if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST['Post'])) { $data = Yii::app()->getRequest()->getPost('Post'); $data['user_id'] = Yii::app()->user->getId(); if ($post->createPublicPost($data, Yii::app()->getRequest()->getPost('tags'))) { $message = Yii::t('BlogModule.blog', 'Post sent for moderation!'); $redirect = array('/blog/publisher/my'); if ($post->status === Post::STATUS_DRAFT) { $message = Yii::t('BlogModule.blog', 'Post saved!'); } if ($post->status === Post::STATUS_PUBLISHED) { $message = Yii::t('BlogModule.blog', 'Post published!'); $redirect = array('/blog/post/show', 'slug' => $post->slug); } Yii::app()->getUser()->setFlash(\yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, $message); $this->redirect($redirect); } } $blogs = Blog::model()->getListForUser(Yii::app()->getUser()->getId()); $this->render('write', array('post' => $post, 'blogs' => $blogs)); }
public function getCMSFields() { $fields = FieldList::create(); $fields->merge(array(DropdownField::create("BlogID", _t("BlogRecentPostsWidget.Blog", "Blog"), Blog::get()->map()), NumericField::create("NumberOfPosts", _t("BlogRecentPostsWidget.NumberOfPosts", "Number of Posts")))); $this->extend("updateCMSFields", $fields); return $fields; }
function blog_remove() { $this->check_login(); $id = $this->uri->segment(3); Blog::set_active($id, '0'); redirect(base_url() . 'admin/blogs'); }