CMS  Version 3.9
BlogManager Class Reference

Static Public Member Functions

static displayBlog ($identifier, &$continue)
 
static inlineEditingControls ($blog)
 
static enumerateItems ($items)
 
static registerSearchables ($searchables)
 
static registerSolrAdapter ()
 
static buildBlogForm ($blog, $redirect, $blogView)
 
static blogTabs ($blog_id)
 
static buildBlogArticleForm ($article, $blog)
 
static getStyles ()
 
static upgradeComponent ($version)
 
static setDefaults ()
 
static setDefaultEmailTemplates ()
 For blog, need default templates: blog_subscription blog_published blog_unsubscribe_confirmation. More...
 
static setDefaultMergeCodes ()
 Merge codes: blog_title article_id blog_identifier unsubscribe_url blog_url. More...
 
static registerTaxonomyClasses ($classes)
 
static registerVersionedContent ()
 
static deleteUser ($user)
 Respond to fired event DeleteUser. More...
 
static saveBlogSubscription ($form)
 Custom save handlerf or blog_subscription_form. More...
 
static sendDigests ()
 
static registerSerializationHandler ()
 
static registerScheduledTaskWorkers ()
 

Detailed Description

Definition at line 65 of file blog_manager.inc.

Member Function Documentation

◆ blogTabs()

static BlogManager::blogTabs (   $blog_id)
static

Definition at line 156 of file blog_manager.inc.

157  {
158  $tabs = array(
159  "Blog Definition" => "blog_form",
160  "Articles" => "blog_articles"
161  );
162 
163  $bar = new TabBar("tabs", $tabs, "blog_id=$blog_id");
164 
165  return $bar;
166  }
$tabs

◆ buildBlogArticleForm()

static BlogManager::buildBlogArticleForm (   $article,
  $blog 
)
static

Definition at line 168 of file blog_manager.inc.

169  {
170  $form = new AutoForm($article);
171  $form->required("title");
172  $form->allowDelete = true;
173  $redirect = "/admin/blog_articles?blog_id={$blog->blog_id}";
174  $form->button("Cancel", $redirect);
175  $imageSelect = new ImageSelectFieldRenderer($form, "image_id");
176  $form->alias("image_id", "Associated Image");
177  $form->readonly("created_date");
178  $form->hide("author_id"); //TODO - allow author selection/re-assignment?
179  $form->hide("article_type");
180 
181  $sites = query(Site, "ORDER BY site_name");
182  $siteSelect = new CrossReferenceSelectFieldRenderer($form, "sites", "Sites", $sites, "site_name", ArticleSiteXref);
183 
184  $form->getRenderer("archive_date")->validator->required = false;
185 
186  return $form;
187  }
$form
$article
$redirect
Definition: article.inc:309
Definition: site.inc:40
$sites
Definition: event_edit.inc:83

◆ buildBlogForm()

static BlogManager::buildBlogForm (   $blog,
  $redirect,
  $blogView 
)
static

Definition at line 129 of file blog_manager.inc.

130  {
131  $form = new AutoForm($blog);
132  $form->hide("owner_id", "created_date");
133  $form->button("Cancel", $redirect);
134 
135  $blogTypes = array_keys($blogView->handlers);
136  $blogTypes = array_combine($blogTypes, $blogTypes);
137 
138  $orderSelect = new SelectFieldRenderer($form, "default_article_order", "Default Article Order", array("DESC" => "Newest to Oldest", "ASC" => "Oldest to Newest", "SORT" => "Sorted Order"));
139  $readSelect = new CheckListFieldRenderer($form, "read_access", "Read Access", SiteRole::getRolesArray());
140  $readSelect->setSize(350, 150, 10);
141  $writeSelect = new CheckListFieldRenderer($form, "write_access", "Write Access", SiteRole::getRolesArray());
142  $writeSelect->setSize(350, 150, 10);
143  $typeSelect = new SelectFieldRenderer($form, "blog_type", "Blog Type", $blogTypes);
144  $imageSelect = new ImageSelectFieldRenderer($form, "image_id", false);
145  $form->alias("image_id", "Image");
146  $form->alias("enable_rss_feed", "Enable RSS Feed");
147  $form->alias("max_rss_articles", "Max # of Articles in RSS Feed");
148  $form->annotate("max_rss_articles", "(A value of zero means no limit)");
149 
150 
152 
153  return $form;
154  }
$blog
$blogView
Definition: blog_form.inc:62
static getRolesArray()
Retrieves the array of roles and their names for the current site for use in a CMS form.
Definition: role.inc:75

◆ deleteUser()

static BlogManager::deleteUser (   $user)
static

Respond to fired event DeleteUser.

Delete any records in this component that have dependencies on user object.

Parameters
obj$user- class SiteUser or custom user class

Definition at line 272 of file blog_manager.inc.

273  {
274  $pk = $user->getPrimaryKey();
275  $user_id = $user->$pk;
276 
277  trace("Component blog is deleting objects dependent on user_id {$user_id}", 3);
278 
279  $blog = new Blog();
280  $blog->delete("WHERE owner_id={$user_id}");
281 
282  return $user;
283  }
$user_id
Definition: blog.inc:41
global $user

◆ displayBlog()

static BlogManager::displayBlog (   $identifier,
$continue 
)
static

Definition at line 67 of file blog_manager.inc.

68  {
69  try
70  {
71  trace("Searching for blog with identifier '$identifier'", 2);
73  $page = ComponentPage::findByIdentifier("blog", "WHERE enabled=1");
74  $_GET["blog"] = $identifier;
75 
76  $pageView = new ComponentPageView($page, "{$page->template}.tpl");
77 
78  $page_role = $page->role;
79 
80  if (!checkRole($page->role))
81  {
83  redirect("/login");
84  }
85 
86  echo $pageView->drawView();
87 
88  $continue = false;
89  }
90  catch(DataNotFoundException $e)
91  {
92 
93  }
94 
95  return $identifier;
96  }
$page
Definition: help.inc:39
static findByIdentifier($identifier)
Definition: blog.inc:155
static findByIdentifier($identifier, $constraint="")
ComponentPageView generates the page content for a component page, substituting page fields,...
static storeRedirectPage()
Store the page from which a user has been redirected when prompted to login or create an account.
Definition: login.inc:493
$identifier
Definition: rss.inc:37

◆ enumerateItems()

static BlogManager::enumerateItems (   $items)
static

Definition at line 107 of file blog_manager.inc.

108  {
109  $blogs = Query::create(Blog, "ORDER BY title")->execute();
110 
111  $items["Blogs"] = $blogs;
112  return $items;
113  }

◆ getStyles()

static BlogManager::getStyles ( )
static

Definition at line 189 of file blog_manager.inc.

190  {
191  $styles .= "<link href=\"/fakoli/css/tabs.css\" rel=\"stylesheet\"/>\n";
192 
193  return $styles;
194  }
$styles

◆ inlineEditingControls()

static BlogManager::inlineEditingControls (   $blog)
static

Definition at line 98 of file blog_manager.inc.

99  {
100 
101  if (Settings::getValue("settings", "enable_inline_editing") && Settings::checkPermission("settings", "editor_roles"))
102  {
103  echo "<p id='inline_editing'><a href='#' onclick='new BlogManager().editBlog({$blog->blog_id}); return false;'>Edit</a>&nbsp;&nbsp;<a href='#' onclick='new ArticleManager().editArticle(\"\", {$blog->blog_id}); return false;'>Add an Article</a></p>";
104  }
105  }
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
static checkPermission($component, $name, $account=null)
Check whether a user has a specific permission.
Definition: settings.inc:241

◆ registerScheduledTaskWorkers()

static BlogManager::registerScheduledTaskWorkers ( )
static

Definition at line 334 of file blog_manager.inc.

335  {
336  ScheduledTaskManager::registerWorker("blog", "Send Digests", array(BlogManager, sendDigests));
337  }
static sendDigests()
static registerWorker($component, $task_name, $handler, $hourly=false)
Registers a Scheduled Task worker method.

◆ registerSearchables()

static BlogManager::registerSearchables (   $searchables)
static

Definition at line 116 of file blog_manager.inc.

117  {
118  trace("BlogManager registerSearchables", 3);
119  $searchables["blog"] = array(Blog);
120  return $searchables;
121  }

◆ registerSerializationHandler()

static BlogManager::registerSerializationHandler ( )
static

Definition at line 328 of file blog_manager.inc.

329  {
330  SerializationManager::registerHandler("blog", "Articles and Blogs", new BlogSerializationHandler());
331  return true;
332  }
registerHandler($component, $title, $handler)
Registers a serialization handler for a component.

◆ registerSolrAdapter()

static BlogManager::registerSolrAdapter ( )
static

Definition at line 123 of file blog_manager.inc.

124  {
125  SolrManager::registerSolrAdapter(Blog, new BlogSolrAdapter());
126  }

◆ registerTaxonomyClasses()

static BlogManager::registerTaxonomyClasses (   $classes)
static

Definition at line 254 of file blog_manager.inc.

255  {
256  $classes[] = Blog;
257  return $classes;
258  }

◆ registerVersionedContent()

static BlogManager::registerVersionedContent ( )
static

Definition at line 260 of file blog_manager.inc.

◆ saveBlogSubscription()

static BlogManager::saveBlogSubscription (   $form)
static

Custom save handlerf or blog_subscription_form.

Avoid saving duplicate subscriptions (same email and blog_id).

Parameters
unknown$form

Definition at line 291 of file blog_manager.inc.

292  {
293  $blogSubscriber = &$form->data;
294 
295  $subscriptions = Query::create(BlogSubscriber, "WHERE subscriber_email=:email AND blog_id=:blog_id")
296  ->bind(":email", $blogSubscriber->subscriber_email, ":blog_id", $blogSubscriber->blog_id)
297  ->execute();
298 
299  $subscription = (count($subscriptions)) ? $subscriptions[0] : null;
300 
301  if($subscription && $subscription->subscription_type != $blogSubscriber->subscription_type)
302  {
303  $subscription->subscription_type = $blogSubscriber->subscription_type;
304  $subscription->filter = new InclusionFilter("subscription_type");
305  $subscription->save();
306 
307  $form->data = $subscription;
308  }
309  else if(!$subscription)
310  {
311  if (!$blogSubscriber->subscription_token)
312  {
313  $blogSubscriber->subscription_token = BlogSubscriptionManager::generateToken();
314  }
315  $blogSubscriber->save();
316  }
317 
318  return true;
319  }

◆ sendDigests()

static BlogManager::sendDigests ( )
static

Definition at line 321 of file blog_manager.inc.

322  {
323  $mgr = new BlogSubscriptionManager();
324 
325  $mgr->sendDigests();
326  }

◆ setDefaultEmailTemplates()

static BlogManager::setDefaultEmailTemplates ( )
static

For blog, need default templates: blog_subscription blog_published blog_unsubscribe_confirmation.

Definition at line 219 of file blog_manager.inc.

220  {
221  global $config;
222 
223  $sitename = $config["sitename"];
224 
225  $message = "This is an automated message from {$sitename}. You have successfully subscribed to the {Blog.title}.<br><br>To unsubscribe, <a href='{getUnsubscribeUrl()}'>click here</a> or follow this link: {getUnsubscribeUrl()}.";
226  EmailTemplate::setDefaultTemplate("blog_subscription", "{subscriber_email}", "{$sitename} Blog Subscription: {Blog.title}", $message, "BlogSubscriber");
227 
228  $message = "Greetings. This is an automated message from {$sitename}. A new post has been published on {Blog.title}. Click the link below to read it.<br><br>{getBlogUrl()}?article_id=[article_id]<br><br>You are receiving this message because you subscribed to {Blog.title}. To unsubscribe, please follow this link: {getUnsubscribeUrl()}";
229  EmailTemplate::setDefaultTemplate("blog_published", "{subscriber_email}", "{$sitename} post: {Blog.title}", $message, "BlogSubscriber");
230 
231  $message = "This is an automated message from {$sitename}. You have successfully unsubscribed to the {Blog.title}.";
232  EmailTemplate::setDefaultTemplate("blog_unsubscribe_confirmation", "{subscriber_email}", "{$sitename} Blog Subscription: {Blog.title}", $message, "BlogSubscriber");
233 
234  }
static setDefaultTemplate($name, $recipients, $subject, $message, $class_name, $sender_email="")
Create a default template for emails that are sent through Fakoli components (e.g....
global $config
Definition: import.inc:4
$message
Definition: mail_to.inc:49

◆ setDefaultMergeCodes()

static BlogManager::setDefaultMergeCodes ( )
static

Merge codes: blog_title article_id blog_identifier unsubscribe_url blog_url.

Definition at line 245 of file blog_manager.inc.

246  {
247  MergeCode::setDefaultMergeCode("blog_title", "Blog.title", "BlogSubscriber", "Blog Title");
248  MergeCode::setDefaultMergeCode("article_id", "", "BlogSubscriber", "ID of the article whose publication is the cause of the subscriber email being sent. This value is provided in the calling code b/c it can't be accessed through the blog subscriber.");
249  MergeCode::setDefaultMergeCode("blog_identifier", "Blog.identifier", "BlogSubscriber", "The CMS page identifier of the blog.");
250  MergeCode::setDefaultMergeCode("unsubscribe_url", "getUnsubscribeUrl", "BlogSubscriber", "The url to unsubscribe from a blog.");
251  MergeCode::setDefaultMergeCode("blog_url", "getBlogUrl", "BlogSubscriber", "The url to view blog posts.");
252  }
static setDefaultMergeCode($name, $map, $class_name, $description="")
Create a default merge codes for emails that are sent through Fakoli components (e....
Definition: merge_code.inc:58

◆ setDefaults()

static BlogManager::setDefaults ( )
static

Definition at line 202 of file blog_manager.inc.

203  {
204  Settings::setDefaultValue("blog", "allow_subscription_options", "0", Boolean, "Whether to allow users to choose subscription type options. Cron job must be setup for the website to call handler file 'send_digest'.");
205  Settings::setDefaultValue("blog", "weekly_digest_day", "Mon", String, "The day of the week when the weekly digest will be sent for sites that allow that option.", "", "Sun\nMon\nTue\nWed\nThu\nFri\nSat");
206  Settings::setDefaultValue("blog", "subscribe_button_format", "Subscribe to {title}", String, "Format string to use for subscribe buttons");
207  Settings::setDefaultValue("blog", "enable_extended_subscription_fields", false, Boolean, "Ask subscribers for their name and organization when subscribing");
208 
211  }
static setDefaultEmailTemplates()
For blog, need default templates: blog_subscription blog_published blog_unsubscribe_confirmation.
static setDefaultMergeCodes()
Merge codes: blog_title article_id blog_identifier unsubscribe_url blog_url.
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
Definition: settings.inc:174

◆ upgradeComponent()

static BlogManager::upgradeComponent (   $version)
static

Definition at line 196 of file blog_manager.inc.

197  {
198  $mgr = new BlogUpgradeManager();
199  $mgr->upgrade($version);
200  }

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