/**
  * Return the basic form.
  */
 function get_runner_form($type)
 {
     if ($type == 'run' || $type == 'run_all' || $type == 'continue') {
         $rf = new Disco();
         if ($type == 'run_all') {
             $submit_button_text = 'Run Module(s)';
         } elseif ($type == 'run') {
             $submit_button_text = 'Run Module';
         } elseif ($type == 'continue') {
             $submit_button_text = 'Continue Upgrade';
             $rf->add_element('not_complete', 'comment', array('text' => '<strong>This upgrade is not yet complete.</strong>'));
         }
         $rf->add_element('mode', 'hidden');
         $rf->set_value('mode', 'run');
         $rf->set_actions(array($submit_button_text));
         return $rf;
     } else {
         trigger_error('The runner form type must be run, test, run_all, or continue');
     }
 }
 protected function _get_form()
 {
     $d = new Disco();
     $d->set_form_class("StackedBox");
     $d->add_element('name', 'text');
     $d->set_display_name('name', 'Creator\'s Name');
     $d->add_required('name');
     $d->add_element('email', 'text');
     $d->set_display_name('email', 'Creator\'s Email Address');
     $d->add_required('email');
     $d->add_element('class_year', 'text');
     $d->set_display_name('class_year', 'Creators\'s Class Year (if Applicable)');
     $d->add_element('media_title', 'text');
     $d->set_display_name('media_title', 'Title');
     $d->add_required('media_title');
     $d->add_element('description', 'textarea');
     $d->set_display_name('description', 'Media Description');
     $d->add_required('description');
     $d->add_element('av_type', 'radio_no_sort', array('options' => array('Audio' => 'Audio <span class="smallText formComment">(e.g. sound-only music, speech, etc.)</span>', 'Video' => 'Video <span class="smallText formComment">(e.g. movies, videos, etc.)</span>')));
     $d->set_display_name('av_type', 'Media Type');
     $d->add_required('av_type');
     //$authenticator = array("reason_username_has_access_to_site", $this->get_value("site_id"));
     $params = array('acceptable_extensions' => KalturaShim::get_recognized_extensions(), 'max_file_size' => $this->_get_actual_max_upload_size(), 'head_items' => &$this->head_items);
     $d->add_element('upload_file', 'ReasonUpload', $params);
     $d->set_display_name('upload_file', 'Media to Upload');
     //$d->add_required('upload_file');
     $d->add_comments('upload_file', form_comment('If the file is on your computer, browse to it here.'));
     $d->add_comments('upload_file', form_comment('File must have one of the following extensions: .' . implode(', .', KalturaShim::get_recognized_extensions())));
     $d->add_comments('upload_file', form_comment('<div class="maxUploadSizeNotice">Maximum file size for uploading is 100MB. </div>'));
     $d->add_element('url', 'text');
     $d->set_display_name('url', 'Media url');
     $d->add_comments('url', form_comment('If you are uploading a file larger than 100MB, enter the url of the file you are uploading here.'));
     $d->add_comments('url', form_comment('Example: http://people.carleton.edu/~huderlem/reason_import_only/video.mp4'));
     $d->add_element('permission', 'checkboxfirst');
     $d->set_display_name('permission', 'I give Carleton College the right to reproduce, display, and use this media in any manner.');
     $d->add_required('permission');
     $d->add_element('rights', 'checkboxfirst');
     $d->set_display_name('rights', 'I am the creator of this media and have full rights to its use.');
     $d->add_required('rights');
     $d->set_actions(array('save' => 'Submit your Media'));
     $d->form_enctype = 'multipart/form-data';
     $this->_populate_author($d);
     $d->add_callback(array($this, 'get_intro'), 'pre_show_form');
     $d->add_callback(array($this, 'error_check_form'), 'run_error_checks');
     $d->add_callback(array($this, 'process_form'), 'process');
     $d->add_callback(array($this, 'get_thank_you_url'), 'where_to');
     return $d;
 }
Example #3
0
 /**
  * Lists the top pages (views) and show analytics
  * 
  * @return void
  */
 function run()
 {
     $this->site_urls = $this->get_site_urls();
     asort($this->site_urls);
     $site_types = $this->get_queryable_site_types();
     $site_events = $this->get_site_type($this->has_events);
     $site_faq = $this->get_site_type($this->has_faq);
     $site_news = $this->get_site_type($this->has_news);
     $site_policies = $this->get_site_type($this->has_policies);
     $disco = new Disco();
     $disco->add_element('content_id', 'hidden', array('userland_changeable' => true));
     // placeholder for an entity's id
     $disco->add_element('content_type', 'radio_inline_no_sort', array('options' => $site_types));
     $disco->add_element('url', 'chosen_select', array('options' => $this->site_urls, 'display_name' => 'URL(s)'));
     $disco->add_element('propagate', 'checkboxfirst', array('display_name' => 'Include this page\'s sub-pages (children and grandchildren)'));
     if ($site_events) {
         $disco->add_element('events', 'chosen_select', array('options' => $site_events, 'display_name' => 'Events'));
     }
     if ($site_faq) {
         $disco->add_element('faq', 'chosen_select', array('options' => $site_faq, 'display_name' => 'FAQs'));
     }
     if ($site_news) {
         $disco->add_element('news', 'chosen_select', array('options' => $site_news, 'display_name' => 'News / Posts'));
     }
     if ($site_policies) {
         $disco->add_element('policies', 'chosen_select', array('options' => $site_policies));
     }
     $disco->add_element('location', 'radio_inline_no_sort', array('options' => array('anywhere' => 'Anywhere', 'off_campus' => 'Off-Campus', 'on_campus' => 'On-Campus'), 'default' => 'anywhere'));
     $disco->add_element('start_date', 'textdate');
     $disco->add_element('end_date', 'textdate');
     $disco->add_element('site_id', 'hidden');
     $disco->set_value('site_id', $this->site->id());
     $disco->add_element('cur_module', 'hidden');
     $disco->set_value('cur_module', 'Analytics');
     $disco->add_required('location');
     $disco->add_required('start_date');
     $disco->add_required('end_date');
     $disco->set_actions(array('Get Analytics'));
     $disco->show_error_jumps = false;
     $error_checks_callback = array($this, 'error_check_disco');
     $on_every_time_callback = array($this, 'on_every_time');
     $disco->add_callback($error_checks_callback, 'run_error_checks');
     $disco->add_callback($on_every_time_callback, 'pre_error_check_actions');
     $disco->set_value('start_date', date('Y-m-d', strtotime('-1 month -1 day')));
     $disco->set_value('end_date', date('Y-m-d', strtotime('-1 day')));
     echo '<div id="analytics-module" class="noscript">' . "\n";
     echo '<script>$("div").removeClass("noscript");</script>' . "\n";
     $disco->run();
     if (!$disco->has_errors()) {
         // Query Google Analytics and display results if any
         if ($this->get_ga_daily_data($disco)) {
             if ($this->get_ga_sources_data($disco)) {
                 $totals = $this->daily_results->getTotalsForAllResults();
                 if ($totals['ga:pageviews'] != '(none)' && !is_null($this->source_results->getRows())) {
                     $loc = $disco->get_value_for_display('location');
                     $location_text = $loc == 'Anywhere' ? '' : $loc . ' ';
                     echo '<div class="results-title"><h3>' . $location_text . 'Results for ' . date("M d, Y", strtotime($disco->get_value('start_date'))) . ' - ' . date("M d, Y", strtotime($disco->get_value('end_date'))) . '</h3></div>' . "\n";
                     $prop = $disco->get_value('propagate');
                     $display_url = '<a href="http://' . GA_HOST_NAME . $disco->get_value_for_display("url") . '"target="_blank">' . $disco->get_value_for_display('url') . '</a>';
                     if ($disco->get_value('content_type') == id_of('minisite_page') && empty($this->admin_page->request['id'])) {
                         $page_path_text = $prop == true ? '<em>' . $display_url . '</em> and all sub-pages' : '<em>' . $display_url . '</em>';
                     } else {
                         $page_path_text = '<em>' . $this->admin_page->get_name($disco->get_value('content_id')) . '</em>';
                     }
                     // Display total results
                     echo '<div class="results-title"><h4>Totals for ' . $page_path_text . '</h4></div>' . "\n";
                     $this->about = new AnalyticsAbout();
                     echo '<div id="total-results">' . "\n";
                     echo '<div class="metric" title="' . $this->about->get_help('pageviews_help', 'text') . '">Pageviews<br /><strong>' . number_format($totals['ga:pageviews']) . '</strong></div>' . "\n";
                     echo '<div id="pageviews_metric"></div>' . "\n";
                     echo '<div class="metric" title="' . $this->about->get_help('unique_pageviews_help', 'text') . '">Unique Pageviews<br /><strong>' . number_format($totals['ga:uniquePageViews']) . '</strong></div>' . "\n";
                     echo '<div id="unique_pageviews_metric"></div>' . "\n";
                     echo '<div class="metric" title="' . $this->about->get_help('entrances_help', 'text') . '">Entrances<br /><strong>' . number_format($totals['ga:entrances']) . '</strong></div>' . "\n";
                     echo '<div id="entrances_metric"></div>' . "\n";
                     $pagetext = $disco->get_value('url') == 'all_pages' ? 'pages' : 'page';
                     echo '<div class="metric" title="' . $this->about->get_help('average_time_help', 'text') . '">Avg time on ' . $pagetext . '<br /><strong>' . gmdate("i:s", round($totals['ga:avgTimeOnPage'])) . '</strong></div>' . "\n";
                     echo '<div id="average_time_metric"></div>' . "\n";
                     echo '<div class="metric" title="' . $this->about->get_help('bounce_rate_help', 'text') . '">Bounce rate<br /><strong>' . round($totals['ga:entranceBounceRate'], 2) . '%</strong></div>' . "\n";
                     echo '<div id="bounce_rate_metric"></div>' . "\n";
                     echo '<div class="metric" title="' . $this->about->get_help('exit_rate_help', 'text') . '">Exit rate<br /><strong>' . round($totals['ga:exitRate'], 2) . '%</strong></div>' . "\n";
                     echo '<div id="exit_rate_metric"></div>' . "\n";
                     echo '<div style="clear: left;"></div>' . "\n";
                     echo '</div>' . "\n";
                     //total-results
                     //Display daily results plot
                     echo '<div class="results-title"><h4>Daily Results for ' . $page_path_text . '</h4></div>' . "\n";
                     echo '<div id="daily-results-div" class="jsdisabled">' . "\n";
                     echo $this->draw_ga_table($this->daily_results, 'daily_results');
                     echo '</div>' . "\n";
                     //daily-results
                     echo '<div class="jsenabled">' . "\n";
                     if ($this->daily_results->getTotalResults() == 1) {
                         echo $this->draw_ga_table($this->daily_results, 'daily_results');
                     } else {
                         echo '<div id="placeholder" style="width:785px;height:300px;margin:20px"></div>' . "\n";
                         echo '<p>Click and drag on the overview plot below to change zoom level.<img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/zoom.png" alt="Click-drag to Zoom" /></p>' . "\n";
                         echo '<div id="overview" style="margin-left:125px;margin-top:20px;width:600px;height:50px"></div>' . "\n";
                     }
                     echo '</div>' . "\n";
                     //jsenabled
                     //Display top 20 source results
                     $top = $this->source_results->getTotalResults() > 20 ? '20' : $this->source_results->getTotalResults();
                     if (count($this->source_results->getRows()) == 1) {
                         echo '<div class="results-title"><h4>Top <a  title="' . $this->about->get_help('source_help', 'text') . '">Source</a> for ' . $page_path_text . '</h4></div>' . "\n";
                     } else {
                         echo '<div class="results-title"><h4>Top ' . $top . ' <a  title="' . $this->about->get_help('source_help', 'text') . '">Sources</a> for ' . $page_path_text . '</h4></div>' . "\n";
                     }
                     echo '<div id="source_metric"></div>' . "\n";
                     echo '<div id="source-jsdisabled-div" class="jsdisabled">' . "\n";
                     echo $this->draw_ga_table($this->source_results, 'source_results');
                     echo '</div>' . "\n";
                     //source-results
                     echo '<div id="source-jsenabled-div" class="jsenabled">' . "\n";
                     if (count($this->source_results->getRows()) == 1) {
                         echo $this->draw_ga_table($this->source_results, 'source_results');
                     } else {
                         echo '<div id="source-pie-chart" style="width:785px;height:375px;margin:20px"></div>' . "\n";
                         echo '<div id="source-pie-hover"></div>';
                         echo '</div>' . "\n";
                         //jsenabled
                     }
                     $this->draw_line_chart($this->daily_results);
                     $this->draw_pie_chart($this->source_results);
                     if (empty($this->admin_page->request['type_id'])) {
                         /**
                          * 	@todo include pages table
                          */
                         // $pages = $this->get_query_url_array($this->site_urls, $this->page_results);
                         echo '<div class="results-title"><h4>Pages</h4></div>' . "\n";
                         echo '<div id="page-results">' . "\n";
                         echo $this->draw_ga_table($this->page_results, 'page-results-table');
                         echo '<div id="source-jsenabled-div" class="jsenabled">' . "\n";
                         echo $this->draw_pager_div('page-results');
                         echo '</div>' . "\n";
                         echo '</div>' . "\n";
                         // page-results
                         if ($this->has_events) {
                             $events = $this->get_query_url_array($this->has_events, $this->event_results);
                             echo '<div class="results-title"><h4>Events</h4></div>' . "\n";
                             echo '<div id="event-results">' . "\n";
                             if ($events) {
                                 echo $this->draw_query_url_table($events, 'event-results-table');
                                 echo '<div id="source-jsenabled-div" class="jsenabled">' . "\n";
                                 echo $this->draw_pager_div('event-results');
                                 echo '</div>' . "\n";
                             } else {
                                 echo '<h5>There are no event results for this timeframe.</h5>' . "\n";
                             }
                             echo '</div>' . "\n";
                             // event-results
                         }
                         if ($this->has_faq) {
                             $faq = $this->get_query_url_array($this->has_faq, $this->faq_results);
                             echo '<div class="results-title"><h4>FAQ</h4></div>' . "\n";
                             echo '<div id="faq-results">' . "\n";
                             if ($faq) {
                                 echo $this->draw_query_url_table($faq, 'faq-results-table');
                                 echo '<div id="source-jsenabled-div" class="jsenabled">' . "\n";
                                 echo $this->draw_pager_div('faq-results');
                                 echo '</div>' . "\n";
                             } else {
                                 echo '<h5>There are no faq results for this timeframe.</h5>' . "\n";
                             }
                             echo '</div>' . "\n";
                             // faq-results
                         }
                         if ($this->has_news) {
                             $posts = $this->get_query_url_array($this->has_news, $this->news_results);
                             echo '<div class="results-title"><h4>News / Posts</h4></div>' . "\n";
                             echo '<div id="news-results">' . "\n";
                             if ($posts) {
                                 echo $this->draw_query_url_table($posts, 'news-results-table');
                                 echo '<div id="source-jsenabled-div" class="jsenabled">' . "\n";
                                 echo $this->draw_pager_div('news-results');
                                 echo '</div>' . "\n";
                             } else {
                                 echo '<h5>There are no news/post results for this timeframe.</h5>' . "\n";
                             }
                             echo '</div>' . "\n";
                             // news-results
                         }
                         if ($this->has_policies) {
                             $policies = $this->get_query_url_array($this->has_policies, $this->policy_results);
                             echo '<div class="results-title"><h4>Policies</h4></div>' . "\n";
                             echo '<div id="policy-results">' . "\n";
                             if ($policies) {
                                 echo $this->draw_query_url_table($policies, 'policy-results-table');
                                 echo '<div id="source-jsenabled-div" class="jsenabled">' . "\n";
                                 echo $this->draw_pager_div('policy-results');
                                 echo '</div>' . "\n";
                             } else {
                                 echo '<h5>There are no policy results for this timeframe.</h5>' . "\n";
                             }
                             echo '</div>' . "\n";
                             // policy-results
                         }
                     }
                 } else {
                     echo '<div class="analytics-error">There are no results for this time frame.</div>';
                 }
             }
         }
     }
     echo '<div class="analytics-footer">' . "\n";
     echo '<p>Please contact ' . REASON_CONTACT_INFO_FOR_ANALYTICS . ' for more detailed analytics.';
     echo '&nbsp;&nbsp;&nbsp;' . '<a href="' . $this->admin_page->make_link(array('site_id' => $this->site->id(), 'cur_module' => 'AnalyticsAbout')) . '">About Analytics <img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/information.png" alt="" /></a></p>';
     echo '</div>' . "\n";
     //analytics-footer
     echo '</div>' . "\n";
     //analytics-module
 }