public function create() { $article = new Article(); if ($this->post) { $article->title = $this->PostData('title'); $article->permalink = $this->PostData('permalink'); $article->summary = $this->PostData('summary'); $article->published = $this->PostData('published'); if ($this->PostData('publish_now') == 1) { $article->publish_at = time(); } else { $article->set_publish_at($this->PostData('publish_at')); } $article->user_id = Site::CurrentUser()->id; if ($article->save()) { $page = new ArticlePage(); $page->article_id = $article->id; $page->title = $article->title; $page->content = $this->PostData('fullbody'); $page->save(); Site::Flash("notice", "The article has been added"); Redirect("admin/articles/{$article->id}"); } $this->assign("body", $this->PostData('fullbody')); } $this->assign("article", $article); $this->tinymce = true; $this->title = "Add Article"; $this->render("article/create.tpl"); }
/** * Callback function to validate data * @return bool must return true or other hooks don't get called */ function validateArticle($editPage, $textBox1, $section, &$hookError) { $ns = $editPage->mTitle->getNamespace(); if ($ns == NS_MAIN) { $article = new ArticlePage($editPage->mTitle->getText()); $article->validate($textBox1, $section, $hookError); } return true; }
public function PaginatedArticles() { $list = ArticlePage::get(); $pages = new PaginatedList($list, $this->request); $pages->setPageLength(6); return $pages; }
public function getCMSFields() { $fields = parent::getCMSFields(); $categoriesField = new GridField('BlogCategories', 'BlogCategories', $this->BlogCategories(), GridFieldConfig_RelationEditor::create()); $fields->addFieldToTab('Root.BlogCategories', $categoriesField); $tagsField = new GridField('Tags', 'Tags', $this->Tags(), GridFieldConfig_RelationEditor::create()); $fields->addFieldToTab('Root.Tags', $tagsField); return $fields; }
public function results($data, $form, $request) { $query = $data['Search']; $filter = 'ParentID = ' . $this->ID . " AND (\"SiteTree\".\"Title\" LIKE '%{$query}%' OR \"SiteTree\".\"Content\" LIKE '%{$query}')"; $articles = ArticlePage::get()->where($filter)->sort('Date DESC'); $perPage = $this->dataRecord->config()->get('articles_per_page'); $paginatedList = new PaginatedList($articles, $request); $paginatedList->setPageLength($perPage); return $this->customise(array('NewsArticles' => $paginatedList))->renderWith(array('ArticleHolder', 'Page')); }
protected static function load_page($article, $id = null) { if (!$id) { $id = $_GET['id']; } $object = ArticlePage::find_by_id($id); if ($object && $object->article_id == $article->id) { return $object; } else { Error404(); } }
public function getArticleSummaries() { $articles = ArticlePage::get()->sort('Date', 'Desc')->toArray(); $summaries = new ArrayList(); for ($i = 0; $i < 4; $i++) { if (array_key_exists($i, $articles)) { $article = $articles[$i]; $summaries->push($article); } } return $summaries; }
public function getCMSFields() { $fields = parent::getCMSFields(); $categoriesField = new GridField('Categories', 'Categories', $this->Categories(), GridFieldConfig_RelationEditor::create()); $fields->addFieldToTab('Root.Categories', $categoriesField); $tagsField = new GridField('Tags', 'Tags', $this->Tags(), GridFieldConfig_RelationEditor::create()); $fields->addFieldToTab('Root.Tags', $tagsField); $attributesField = new GridField('ProjectAttributes', 'ProjectAttributes', $this->ProjectAttributes(), GridFieldConfig_RelationEditor::create()); $fields->addFieldToTab('Root.ProjectAttributes', $attributesField); $firstImageField = new CheckboxField('FirstImageIsPreview', 'Ignore First Image of Image Folder'); $fields->addFieldToTab('Root.Main', $firstImageField, 'ImageFolderID'); return $fields; }
public function run($request) { $this->deleteAll(ArticlePage::get()); $faker = Faker\Factory::create(); $blogPage = BlogPage::get()->first(); $img = new Image(); $imgFile = 'themes/Helix/assets/images/doof.jpg'; // var_dump($imgFile); $img->Filename = $imgFile; $img->Title = 'Template image'; $img->write(); for ($articles = 0; $articles < 20; $articles++) { $articlePage = new ArticlePage(); $articlePage->Title = "Article " . $articles; $articlePage->Content = $faker->text(400); // $articlePage->summarySize = rand(1,3); $articlePage->summarySize = 1; $articlePage->SummaryImageID = $img->ID; $articlePage->setParent($blogPage); $articlePage->write(); $articlePage->publish("Stage", "Live"); $articlePage->flushCache(); } }
public function LatestArticles($count) { return ArticlePage::get()->sort('Created', 'DESC')->limit($count); }
public function init() { parent::init(); $this->articleList = ArticlePage::get()->filter(array('ParentID' => $this->ID))->sort('Date DESC'); }
/** * @Given I verify that the article was deleted successfully */ public function i_verify_that_the_article_was_deleted_successfully() { $this->helper_context->iCanSeeInTheRegion('The Article ' . $this->article_page_title . ' has been deleted.', $this->article_page->get_message_region('SUCCESS_MESSAGE_REGION')); }
public function featurePosts() { $blog_page = ArticlePage::get()->first(); $latest_posts[] = $blog_page; return $latest_posts; }
public function pages($reload = false) { if ($reload or !$this->pages_cache) { $id = mysql_real_escape_string($this->id); $this->pages_cache = ArticlePage::find_all("articles.id = '{$id}'", "article_pages.position ASC"); } return $this->pages_cache; }
public function sourceRecords($params = null) { return ArticlePage::get()->sort('Title'); }