CMS  Version 3.9
Article Class Reference

Defines the Article class. More...

+ Inheritance diagram for Article:
+ Collaboration diagram for Article:

Public Member Functions

 Image ()
 
 Sites ($constraint="")
 
 Comments ($constraint="")
 
 Blog ()
 We retrieve the blog related to the article by matching the article_type field to the blog's title field. More...
 
 Author ()
 
 getAuthorName ()
 
 getBlog ()
 
 getURL ()
 
 getBlogSubscribers ()
 
 getViewIdentifier ()
 
 formatPostDate ()
 
 Article ()
 
 search ($params, $range=null)
 DataItems must implement this method to provide search functionality. More...
 

Static Public Member Functions

static fromIdentifier ($identifier)
 

Public Attributes

 $fields
 
 $relations
 
 $fieldAliases = array("message" => "Article Content")
 
 $versioned_fields = array("title", "message", "image_id", "teaser", "tags", "author", "publication")
 

Detailed Description

Defines the Article class.

Definition at line 44 of file article.inc.

Member Function Documentation

◆ Article()

Article::Article ( )

Definition at line 199 of file article.inc.

200  {
201  $this->table = "article";
202  $this->primary_key = "article_id";
203  $this->pretty_class_name = "Article";
204 
205  // Patch in the user class, since this can be overridden by the application
206  $mgr = new UserManager();
207  $this->relations["Owner"] = $mgr->getUserClass();
208 
209  $this->DataItem(func_get_args());
210  }
Provides the interface to the user model for the application.

◆ Author()

Article::Author ( )

Definition at line 110 of file article.inc.

111  {
112  $mgr = new UserManager();
113  return $mgr->getUser($this->author_id);
114  }

◆ Blog()

Article::Blog ( )

We retrieve the blog related to the article by matching the article_type field to the blog's title field.

This function may return null as an article may not be related to any blog.

Used for merge codes and for comment xref function verifyEnabled

Definition at line 101 of file article.inc.

102  {
103  $blogs = Query::create(Blog, "WHERE title=:article_type")
104  ->bind(":article_type", $this->article_type)
105  ->execute();
106 
107  return count($blogs) ? $blogs[0] : null;
108  }
$article article_type
Definition: blog.inc:41

◆ Comments()

Article::Comments (   $constraint = "")

Definition at line 89 of file article.inc.

90  {
91  return $this->crossReference(Comment, ArticleCommentXref, $constraint);
92  }
$constraint
Definition: article.inc:336

◆ formatPostDate()

Article::formatPostDate ( )

Definition at line 184 of file article.inc.

185  {
186  if ($this->post_date)
187  {
188  return $this->format("{post_date:daylong}");
189  }
190 
191  if ($this->publish_date)
192  {
193  return $this->format("{publish_date:daylong}");
194  }
195 
196  return $this->format("{created_date:daylong}");
197  }
$article publish_date

◆ fromIdentifier()

static Article::fromIdentifier (   $identifier)
static

Definition at line 134 of file article.inc.

135  {
136  $articles = Query::create(Article, "WHERE identifier=:i")
137  ->bind(":i", $identifier)
138  ->execute();
139 
140  return count($articles) > 0 ? $articles[0] : null;
141  }
Defines the Article class.
Definition: article.inc:45
$articles
Definition: rss.inc:62
$identifier
Definition: rss.inc:37

◆ getAuthorName()

Article::getAuthorName ( )

Definition at line 116 of file article.inc.

117  {
118  if ($this->author_id)
119  {
120  return $this->Author()->getFullName();
121  }
122  else return $this->author;
123  }
Author()
Definition: article.inc:110

◆ getBlog()

Article::getBlog ( )

Definition at line 125 of file article.inc.

126  {
127  $blogs = Query::create(Blog, "WHERE title=:type")
128  ->bind(":type", $this->article_type)
129  ->execute();
130 
131  return count($blogs) ? $blogs[0] : null;
132  }

◆ getBlogSubscribers()

Article::getBlogSubscribers ( )

Definition at line 156 of file article.inc.

157  {
158  $blogSubscribers = Query::create(BlogSubscriber, "where blog_id=:blog_id")
159  ->bind(":blog_id", $this->getBlog()->blog_id)
160  ->execute();
161  $email_list_array = array();
162  foreach($blogSubscribers as $blogSubscriber)
163  {
164  $email_list_array[] = $blogSubscriber->subscriber_email;
165  }
166  $email_list = implode(",", $email_list_array);
167 
168  return $email_list;
169  }
getBlog()
Definition: article.inc:125
$blogSubscriber blog_id

◆ getURL()

Article::getURL ( )

Definition at line 143 of file article.inc.

144  {
145  $blog = $this->getBlog();
146  if($blog)
147  {
148  return $blog->getURL() . "?article_id=" . $this->article_id;
149  }
150  else
151  {
152  return "article?article_id=" . $this->article_id;
153  }
154  }
$blog
$article_id
Definition: article.inc:37

◆ getViewIdentifier()

Article::getViewIdentifier ( )

Definition at line 171 of file article.inc.

172  {
173  try
174  {
175  $blog = $this->getBlog();
176  return $blog->identifier;
177  }
178  catch(DataNotFoundException $e)
179  {
180  return "article_view";
181  }
182  }

◆ Image()

Article::Image ( )

Definition at line 79 of file article.inc.

80  {
81  return $this->getRelated(ImageRecord);
82  }

◆ search()

Article::search (   $params,
  $range = null 
)

DataItems must implement this method to provide search functionality.

Parameters
mixed$paramseither search text or a SearchParameters object
array$rangean array of primary key IDs to which the search must be constrained

Implements Searchable.

Definition at line 212 of file article.inc.

213  {
214  trace("Searching Articles", 3);
215 
216  if ($range)
217  {
218  $range = " AND {$this->primary_key} IN (".implode($range, ", ").")";
219  }
220  else
221  {
222  $range = "";
223  }
224 
225  if (is_object($params))
226  {
227  $search = clone $params;
228  $search->target = $this;
229 
230  $search->remapField("keywords", "tags");
231 
232  if (!$search->get("text", "like"))
233  {
234  $search->secondaryFields("tags", "message");
235  }
236  else
237  {
238  $search->remapField("text", "message");
239  }
240 
241  $search->remapField("publication_date", "publish_date");
242 
243  $constraint = $search->generateConstraint();
244  $constraint .= $constraint ? " AND published=1" : " WHERE published=1";
245 
246  $constraint .= $range;
247 
248  $articles = Query::create(Article, $constraint)
249  ->execute();
250  }
251  else
252  {
253  $params = "%$params%";
254  $articles = Query::create(Article, "WHERE (title like :a OR teaser LIKE :b OR message like :c) AND published=1 $range")
255  ->bind(":a", $params, ":b", $params, ":c", $params)
256  ->execute();
257  }
258 
260  }
$range
Definition: error_log.inc:13
Definition: article.inc:264
static wrap($items, $resultClass)

◆ Sites()

Article::Sites (   $constraint = "")

Definition at line 84 of file article.inc.

85  {
86  return $this->crossReference(Site, ArticleSiteXref, $constraint);
87  }
Definition: article.inc:309
Definition: site.inc:40

Member Data Documentation

◆ $fieldAliases

Article::$fieldAliases = array("message" => "Article Content")

Definition at line 75 of file article.inc.

◆ $fields

Article::$fields
Initial value:
= array("article_id" => Number,
"title" => String,
"message" => HTML,
"article_type" => String,
"identifier" => String,
"image_id" => Number,
"teaser" => HTML,
"created_date" => Date,
"post_date" => Date,
"archive_date" => Date,
"publish_date" => Date,
"last_modified" => Timestamp,
"published" => Boolean,
"allow_comment" => Boolean,
"headline" => Boolean,
"tags" => String,
"author_id" => Number,
"author" => String,
"publication" => String,
"sort_order" => Number
)

Definition at line 46 of file article.inc.

◆ $relations

Article::$relations
Initial value:
= array( "Image" => ImageRecord,
"Sites" => Site,
"Comments" => Comment,
"Author" => "",
"Blog" => Blog,
)

Definition at line 68 of file article.inc.

◆ $versioned_fields

Article::$versioned_fields = array("title", "message", "image_id", "teaser", "tags", "author", "publication")

Definition at line 77 of file article.inc.


The documentation for this class was generated from the following file: