Exemplo n.º 1
0
 function init($args = array())
 {
     parent::init($args);
     if ($this->controller->get_form_data('page_type_name') != false) {
         $rpt =& get_reason_page_types();
         $pt = new ReasonPageType();
         if ($this->controller->get_form_data('page_type_name') != 'new') {
             $pt = $rpt->get_page_type($this->controller->get_form_data('page_type_name'));
         } else {
             $pt = $rpt->get_page_type('default');
         }
         if ($pt->get_region_names() != null) {
             $this->loci = $pt->get_region_names();
         }
         $this->add_element('page_type_name_new', 'text');
         $this->set_display_name('page_type_name_new', 'Page type name');
         foreach ($this->loci as $region_name) {
             $regionInfo = $pt->get_region($region_name);
             $this->add_element($region_name . '_header', 'comment', array('text' => '<h2 class="region">' . $region_name . '</h2>'));
             $this->add_element($region_name . '_module', 'text');
             $this->set_display_name($region_name . '_module', 'Module');
             $this->add_element($region_name . '_params', 'text', array('maxlength' => 40000));
             $this->set_display_name($region_name . '_params', 'Parameters');
         }
     }
 }
Exemplo n.º 2
0
 function init($args = array())
 {
     parent::init($args);
     if ($this->controller->get_current_step() != 'EditNewsletter') {
         return;
     }
     $site_id = (int) $_REQUEST['site_id'];
     $editor_name = html_editor_name($site_id);
     $params = html_editor_params($site_id, $this->controller->user_id);
     $this->add_element('newsletter_loki', $editor_name, $params);
     $this->set_display_name('newsletter_loki', ' ');
 }
Exemplo n.º 3
0
 function init($args = array())
 {
     parent::init($args);
     $pts = new ReasonPageTypes();
     $pageTypeList = $pts->get_page_type_names();
     // change element types here
     foreach ($pageTypeList as $index => $pageType) {
         $options[$pageType] = $pageType;
     }
     natsort($options);
     $options = array("new" => "New Page Type") + $options;
     $this->change_element_type('page_type_name', 'select_no_sort', array('options' => $options));
 }
Exemplo n.º 4
0
 function init($args = array())
 {
     parent::init($args);
     $pt = new ReasonPageType();
     $formats = $pt->get_export_formats();
     foreach ($formats as $format => $formatInfo) {
         // !TODO: Should I add a check here to make it only show types that make sense?
         if ($formatInfo['printable'] == true) {
             $formatNames[$format] = $formatInfo['name'];
         }
     }
     $this->add_element('Format', 'radio', array("options" => $formatNames));
 }
Exemplo n.º 5
0
 function init($args = array())
 {
     if ($this->controller->get_current_step() != 'SelectTemplate') {
         return;
     }
     parent::init($args);
     $exporter = new NewsletterExporter();
     $formats = $exporter->get_export_formats();
     foreach ($formats as $format => $info) {
         $templates[$format] = $info['name'];
     }
     $this->add_element('templateChooser', 'radio_inline', array('options' => $templates, 'display_name' => 'Template'));
     $this->add_required('templateChooser');
 }
Exemplo n.º 6
0
 function init($args = array())
 {
     parent::init($args);
 }
Exemplo n.º 7
0
 function init($args = array())
 {
     parent::init($args);
     if ($this->controller->get_current_step() != 'SelectItems') {
         return;
     }
     if ($this->controller->get_form_data('selected_publications') != '' || $this->controller->get_form_data('events_start_date') != '') {
         $this->add_element('select_instructions', 'comment', array('text' => '<p>Items from the publications and calendar dates which you picked are displayed below. Select the posts and events that you would like to include in your newsletter from the lists below.</p>'));
     }
     if ($this->controller->get_form_data('selected_publications') != '') {
         $pubs = $this->controller->get_form_data('selected_publications');
         $this->add_element('pub_items_header', 'comment', array('text' => '<h2 class="region">Posts</h2>'));
         foreach ($pubs as $pub) {
             $post_options = array();
             $ph_new = new PublicationHelper($pub);
             if ($startDate = $this->controller->get_form_data('publication_start_date')) {
                 $ph_new->set_start_date($startDate);
             }
             if ($endDate = $this->controller->get_form_data('publication_end_date')) {
                 $ph_new->set_end_date($endDate);
             }
             $pub_posts = $ph_new->get_published_items();
             $page_of_publication = $ph_new->get_right_relationship('page_to_publication');
             if ($pub_posts) {
                 foreach ($pub_posts as $pub_post) {
                     $available_posts[$pub][$pub_post->get_value('id')] = array('id' => $pub_post->get_value('id'), 'name' => $pub_post->get_value('name'), 'date_released' => $pub_post->get_value('datetime'), 'created_by' => $pub_post->get_value('created_by'), 'url' => reason_get_page_url($page_of_publication[0]->get_value('id')) . "?story_id=" . $pub_post->get_value('id'));
                 }
             }
             if (!empty($available_posts)) {
                 if (empty($available_posts[$pub])) {
                     $this->add_element("pub_items_number_{$pub}", 'comment', array('text' => '<p>No live posts were found for the publication "' . $ph_new->get_value('name') . '".</p>'));
                 } else {
                     $count = count($available_posts[$pub]);
                     $text = "{$count}" . ($count > 1 ? ' posts were' : ' post was');
                     $text .= ' found for the publication "' . $ph_new->get_value('name') . '"';
                     foreach ($available_posts[$pub] as $post) {
                         $post_options[$post['id'] . '_post'] = $post['name'] . ' (<a target="_blank" href="' . $post['url'] . '">link</a>)';
                         //						$this->add_element($item['id'].'_info', 'comment', array('text' => '<p>Date released: '.$item['date_released'].'</p>'));
                     }
                     $this->add_element("pub_posts_group_{$pub}", 'checkboxgroup', array('options' => $post_options));
                     $this->set_display_name("pub_posts_group_{$pub}", $text);
                 }
             } else {
                 $this->add_element("pub_items_none_{$pub}", 'comment', array('text' => '<p>No posts were found for "' . $ph_new->get_value('name') . '" during the selected timeframe.</p>'));
             }
         }
     }
     if ($this->controller->get_form_data('events_start_date') != '') {
         $site_id = (int) $_REQUEST['site_id'];
         $site = new entity($site_id);
         $start_date = $this->controller->get_form_data('events_start_date');
         $end_date = $this->controller->get_form_data('events_end_date');
         $end_date = !empty($end_date) ? $end_date : date('Y-m-d');
         $cal = new reasonCalendar(array('site' => $site, 'start_date' => $start_date, 'end_date' => $end_date));
         $cal->run();
         $events = $cal->get_all_events();
         $days = $cal->get_all_days();
         $this->add_element('events_header', 'comment', array('text' => '<h2 class="region">Calendar events</h2>'));
         if ($days) {
             // This is a bit of a hack. We want to know the number of deepest-level elements
             // _before_ we've  iterated through the array, creating elements for each deepest-level
             // element... hence the double foreach.
             $count = 0;
             foreach ($days as $day => $event_ID_array) {
                 foreach ($event_ID_array as $event_item) {
                     $count++;
                 }
             }
             $text = "<p>{$count}" . ($count > 1 ? ' calendar events were found.</p>' : ' calendar event was found.</p>');
             $this->add_element('events_number', 'comment', array('text' => $text));
             foreach ($days as $day => $event_ID_array) {
                 $event_options = array();
                 $events_from_today = array();
                 foreach ($event_ID_array as $event_ID) {
                     $events_from_today[$event_ID] = $events[$event_ID];
                 }
                 uasort($events_from_today, "sort_events");
                 foreach ($events_from_today as $event_id => $event_item) {
                     $prettyDate = date("g:i a", strtotime($event_item->get_value('datetime')));
                     $eHelper = new EventHelper();
                     @$eHelper->set_page_link($event_item);
                     $eventURL = $event_item->get_value('url') . date("Y-m-d", strtotime($event_item->get_value('datetime')));
                     $event_options[$event_id . '_event'] = '<strong>' . $prettyDate . '</strong> ' . $event_item->get_value('name') . ' (<a target="_blank" href="' . $eventURL . '">link</a>)';
                 }
                 $this->add_element('events_group_day_' . $day, 'checkboxgroup_no_sort', array('options' => $event_options));
                 $rows[] = date("D, M j Y", strtotime($day));
                 $elements_to_add_to_group['events_group_day_' . $day] = 'events_group_day_' . $day;
             }
             $args = array('rows' => $rows, 'use_element_labels' => false, 'use_group_display_name' => false, 'wrapper_class' => 'events_wrapper');
             $this->add_element_group('wrappertable', 'events_group', $elements_to_add_to_group, $args);
         } else {
             $this->add_element('events_number', 'comment', array('text' => '<p>No events were found.</p>'));
         }
     }
 }
Exemplo n.º 8
0
 /**
  * Grabs a list of all publications and events attached to the site, offers them to 
  * 
  * The bulk of this form step. 
  * 
  * 
  */
 function init($args = array())
 {
     parent::init($args);
     $site_id = (int) $_REQUEST['site_id'];
     // Only do this init if we're on the step that needs it.
     if ($this->controller->get_current_step() != 'SelectIncludes') {
         return;
     }
     //////////////// PUBLICATIONS /////////////////
     // Select all publications that are attached to this site.
     $pub_factory = new PubHelperFactory();
     $es = new entity_selector($site_id);
     $es->add_type(id_of('publication_type'));
     // Add the page_id to which the pub belongs (so we can get url)
     $es->add_right_relationship_field('page_to_publication', 'entity', 'id', 'page_id');
     $es->enable_multivalue_results();
     $es->set_entity_factory($pub_factory);
     $pub_helper_entities = $es->run_one();
     if ($pub_helper_entities) {
         $this->add_element('pub_posts_header1', 'comment', array('text' => '<h2 class="region">Publications</h2>'));
         foreach ($pub_helper_entities as $ph) {
             $name = $ph->get_value('name');
             $entityID = $ph->get_value('id');
             $page_id = $ph->get_value('page_id');
             if (is_array($page_id)) {
                 $strlength = 0;
                 $page_url = '';
                 foreach ($page_id as $one_id) {
                     $page_entity = new entity($one_id);
                     if ($page_entity->get_value('state') == 'Live') {
                         $owner = $page_entity->get_owner();
                         if ($owner->get_value('state') == 'Live') {
                             $url = reason_get_page_url($one_id);
                             if (strlen($url) > $strlength) {
                                 $strlength = strlen($url);
                                 $page_url = $url;
                             }
                         }
                     }
                 }
                 $box_name = '<a target="_blank" href="' . $page_url . '">' . $name . '</a>';
                 $opts[$entityID] = $box_name;
             } else {
                 $page_entity = new entity($page_id);
                 if ($page_entity->get_value('state') == 'Live') {
                     $owner = $page_entity->get_owner();
                     if ($owner->get_value('state') == 'Live') {
                         $page_url = reason_get_page_url($page_id);
                         $box_name = '<a target="_blank" href="' . $page_url . '">' . $name . '</a>';
                         $opts[$entityID] = $box_name;
                     }
                 }
             }
         }
         $this->add_element('selected_publications', 'checkboxgroup', array('options' => $opts));
         $this->set_value('selected_publications', array_keys($opts));
         $this->set_display_name('selected_publications', 'Select the publications from which you wish to draw posts');
         $this->add_element('publication_start_date', 'textDate');
         $monthAgo = date("Y-m-d", strtotime("-1 month"));
         $today = date("Y-m-d", time());
         $this->set_value('publication_start_date', $monthAgo);
         $this->set_display_name('publication_start_date', 'From this date');
         $this->add_element('publication_end_date', 'textDate');
         $this->set_value('publication_end_date', $today);
         $this->set_display_name('publication_end_date', 'To this date');
     }
     //////////////// EVENTS ///////////////////
     // !todo: Find any page on the site $site_id which uses the module 'events', and list
     // 		  that page title as a 'calendar' (there are apparently no calendar entities,
     //		  only the events module which acts as a calendar.
     //		  The extra information should be found in the page_type def for the page containing
     //		  the events module.
     /* $eh = new reasonCalendar();
     		
     		$site = new entity($site_id);
     		$cal = new reasonCalendar(array('site'=>$site));
     		$cal->run();
     		$events = $cal->get_all_events(); */
     $es = new entity_selector($site_id);
     $es->add_type(id_of('event_type'));
     $es->set_num(1);
     $es->limit_tables();
     $es->limit_fields();
     $events = $es->run_one();
     if ($events) {
         $this->add_element('events_header1', 'comment', array('text' => '<h2 class="region">Calendars</h2>'));
         $this->add_element('events_start_date', 'textDate');
         $monthAhead = date("Y-m-d", strtotime("+1 month"));
         $today = date("Y-m-d", time());
         $this->set_value('events_start_date', $today);
         $this->set_display_name('events_start_date', 'From this date');
         $this->add_element('events_end_date', 'textDate');
         $this->set_value('events_end_date', $monthAhead);
         $this->set_display_name('events_end_date', 'To this date');
     }
     if (!$events && !$pub_helper_entities) {
         $this->add_element('sucks_to_be_you', 'comment', array('text' => '<h3>There are no publications or calendars associated with this site. Press continue if you would like to use the newsletter builder anyway.'));
     }
 }