/** * Set Message Code: content-subscription * @return string */ protected function _templateContentSubscription(&$params, &$data) { # Prepare $Locale = Bal_App::getLocale(); $View = Bal_App::getView(false); $Message = $this; # Prepare Urls $rootUrl = $View->app()->getRootUrl(); $baseUrl = $View->app()->getBaseUrl(true); # -------------------------- # Prepare $Content = $this->Content; # Prepare URL $contentUrl = $rootUrl . $View->url()->content($Content)->toString(); $params['Content_url'] = $contentUrl; # Send On $send_on = strtotime($Content->published_at); $this->send_on = doctrine_timestamp($send_on); # Adjust Dates $params['Message']['Content']['published_at'] = $Locale->date($params['Message']['Content']['published_at']); # -------------------------- return true; }
} } # Retrieve Content to Update echo "\n" . 'Cron: Second Content Run:' . "\n"; # Update their Cache foreach ($Contents as $Content) { if ($Content->refresh()) { echo 'Cron: Updated Content [' . $Content->code . '] Cache' . "\n"; $Content->save(); } else { echo 'Cron: Ignored Content [' . $Content->code . '] Cache' . "\n"; } } # ========================================== # Send Pending Messages echo "\n" . 'Cron: Sending Any Pending Messages:' . "\n"; # Retrieve Messages to Send $Messages = Doctrine_Query::create()->from('Message m')->where('m.sent_on IS NULL')->andWhere('m.send_on < ?', doctrine_timestamp())->limit(25)->execute(); # Send these Messages if (!count($Messages)) { echo 'Cron: No Pending Messages To Be Sent' . "\n"; } else { foreach ($Messages as $Message) { $Message->send()->save(); echo 'Cron: Sent Message [' . $Message->code . '] to [' . $Message->UserFor->email . ']' . "\n"; } } // When doing a second round, it will cause the tags to delete. So we don't do a second round. # ========================================== # Complete echo "\n" . 'Cron: Completed' . "\n";
/** * Refresh the Content Cache */ public function refresh($update_content = true, $update_description = true) { # Prepare $save = false; # Fetch $Content = $this; # Render Content if ($update_content) { $content_rendered = Content::renderContent($Content, array('cache' => false)); $Content->set('content_rendered', $content_rendered, false); # Save $save = true; } # Render Description $description = $Content->description; $description_empty = !$description || $description === '<!--[empty/]-->'; $description_useauto = $Content->description_useauto; if ($update_description && !$description_empty) { # Disable Auto $Content->set('description_useauto', false, false); # Render Description $description_rendered = Content::renderDescription($Content, array('cache' => false)); # Set Description $Content->set('description_rendered', $description_rendered, false); # Save $save = true; } elseif ($Content->description_useauto || $description_empty) { # Use Auto $Content->set('description_useauto', true, false); # Render Auto Description $description_rendered = substr(preg_replace('/\\s\\s+/', ' ', strip_tags($Content->content_rendered)), 0, 1000); if (reallyempty($description_rendered)) { $description_rendered = '<!--[empty/]-->'; } # Set Description $Content->set('description', $description_rendered, false); $Content->set('description_rendered', $description_rendered, false); # Save $save = true; } # Update Last Refresh if ($save) { $this->last_refreshed = doctrine_timestamp(); } # Return save return $save; }
public function contentNewAction() { # Prepare $App = $this->getHelper('App'); $Request = $this->getRequest(); $type = $Request->getParam('type', 'content'); $App->activateNavigationItem('back.main', $type . '-new', true); $Content = $ContentCrumbs = array(); $Identity = $App->getUser(); # -------------------------- # Fetch and Save Item (if applicable) $Content = Bal_Doctrine_Core::fetchAndSaveItem('Content', null, array('create' => true, 'apply' => array('Author' => $Identity), 'keep' => array('code', 'content', 'description', 'Parent', 'status', 'tags', 'title', 'type', 'Avatar'), 'clean' => array('Avatar'), 'verify' => array('verifyAccess' => array('action' => 'edit', 'Identity' => $Identity)))); if (delve($Content, 'id')) { return $this->getHelper('redirector')->gotoRoute(array('action' => 'content-edit', 'content' => $Content->code), 'back', true); } # -------------------------- # Prepare New Content $Content->published_at = doctrine_timestamp(); if ($type === 'event') { $Content->event_start_at = doctrine_timestamp(); $Content->event_finish_at = doctrine_timestamp(); } # Fetch $ContentArray = $Content->toArray(); $ContentCrumbs[] = $ContentArray; # Fetch content for use in dropdown $ContentList = $this->getContentSimpleList(); # -------------------------- # Apply $this->view->type = $type; $this->view->ContentCrumbs = $ContentCrumbs; $this->view->ContentList = $ContentList; $this->view->Content = $ContentArray; # Render $this->render('content/content-edit'); # Done return true; }