public function __construct($id_stream = null)
 {
     if (!empty($id_stream)) {
         $this->id_stream = $id_stream;
         $this->stream_authorizations = NewsletterStreamsCache::load()->get_stream($this->id_stream)->get_authorizations();
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->stream = NewsletterStreamsCache::load()->get_stream($request->get_int('id_stream', 0));
     if ($this->stream->get_id() == 0) {
         AppContext::get_response()->redirect(NewsletterUrlBuilder::home());
     }
     $this->init();
     $this->build_form($request);
     return $this->build_response($this->view);
 }
 private function get_streams()
 {
     $streams = array();
     $newsletter_streams = NewsletterStreamsCache::load()->get_streams();
     foreach ($newsletter_streams as $id => $stream) {
         if ($id != Category::ROOT_CATEGORY && NewsletterAuthorizationsService::id_stream($id)->subscribe()) {
             $streams[] = new FormFieldMultipleCheckboxOption($id, $stream->get_name());
         }
     }
     return $streams;
 }
Ejemplo n.º 4
0
 public static function get_streams_manager()
 {
     if (self::$streams_manager === null) {
         $categories_items_parameters = new CategoriesItemsParameters();
         $categories_items_parameters->set_table_name_contains_items(NewsletterSetup::$newsletter_table_archives);
         self::$streams_manager = new CategoriesManager(NewsletterStreamsCache::load(), $categories_items_parameters);
         self::$streams_manager->get_categories_items_parameters()->set_field_name_id_category('stream_id');
     }
     return self::$streams_manager;
 }
 private function build_response(View $view)
 {
     $body_view = new FileTemplate('newsletter/NewsletterBody.tpl');
     $body_view->add_lang($this->lang);
     $body_view->put('TEMPLATE', $view);
     $response = new SiteDisplayResponse($body_view);
     $breadcrumb = $response->get_graphical_environment()->get_breadcrumb();
     $breadcrumb->add($this->lang['newsletter'], NewsletterUrlBuilder::home()->rel());
     $breadcrumb->add($this->lang['archives.list'], NewsletterUrlBuilder::archives()->rel());
     if ($this->stream->get_id() > 0) {
         $stream = NewsletterStreamsCache::load()->get_stream($this->stream->get_id());
         $breadcrumb->add($stream->get_name(), NewsletterUrlBuilder::archives($this->stream->get_id(), $this->stream->get_rewrited_name())->rel());
     }
     $graphical_environment = $response->get_graphical_environment();
     $graphical_environment->set_page_title($this->lang['archives.list'], $this->lang['newsletter']);
     $graphical_environment->get_seo_meta_data()->set_canonical_url(NewsletterUrlBuilder::archives($this->stream->get_id(), $this->stream->get_rewrited_name()));
     return $response;
 }