/**
  * Controller method that allows an AJAX call to check the progress of a file
  * upload that is currently in progress.
  *
  * @access public
  * @param object $Sender
  */
 public function PostController_CheckUpload_Create($Sender)
 {
     list($ApcKey) = $Sender->RequestArgs;
     $Sender->DeliveryMethod(DELIVERY_METHOD_JSON);
     $Sender->DeliveryType(DELIVERY_TYPE_VIEW);
     $KeyData = explode('_', $ApcKey);
     array_shift($KeyData);
     $UploaderID = implode('_', $KeyData);
     $ApcAvailable = self::ApcAvailable();
     $Progress = array('key' => $ApcKey, 'uploader' => $UploaderID, 'apc' => $ApcAvailable ? 'yes' : 'no');
     if ($ApcAvailable) {
         $UploadStatus = apc_fetch('upload_' . $ApcKey, $Success);
         if (!$Success) {
             $UploadStatus = array('current' => 0, 'total' => -1);
         }
         $Progress['progress'] = $UploadStatus['current'] / $UploadStatus['total'] * 100;
         $Progress['total'] = $UploadStatus['total'];
         $Progress['format_total'] = Gdn_Format::Bytes($Progress['total'], 1);
         $Progress['cache'] = $UploadStatus;
     }
     $Sender->SetJSON('Progress', $Progress);
     $Sender->Render($this->GetView('blank.php'));
 }
Example #2
0
 /**
  * {@inheritdoc}
  * @see \rakelley\jhframe\interfaces\IRenderable::Render()
  */
 public function Render()
 {
     $this->renderer->Render($this);
 }
 /**
  * Handles different views (only monthly overview by now)
  *
  * @param object $Sender VanillaController
  * @param array $Args /Year/Month to show
  */
 public function VanillaController_EventCalendar_Create($Sender, $Args = array())
 {
     $Sender->Permission('Plugins.EventCalendar.View');
     $Sender->ClearCssFiles();
     $Sender->AddCssFile('style.css');
     $Sender->AddCssFile('eventcalendar.css', 'plugins/EventCalendar');
     $Sender->AddJsFile('eventcalendar.js', 'plugins/EventCalendar');
     $Sender->MasterView = 'default';
     $Sender->AddModule('NewDiscussionModule');
     $Sender->AddModule('CategoriesModule');
     $Sender->AddModule('BookmarkedModule');
     // only show current year +/- 1
     $Year = $Args[0];
     $CurrentYear = date('Y');
     if ($Year < $CurrentYear - 1 || $Year > $CurrentYear + 1) {
         $Year = $CurrentYear;
     }
     // sanitize month
     $Month = sprintf("%02s", $Args[1]);
     if ($Month < 1 || $Month > 12) {
         $Month = date('m');
     }
     $MonthFirst = mktime(0, 0, 0, $Month, 1, $Year);
     $DaysInMonth = date('t', $MonthFirst);
     $MonthLast = mktime(0, 0, 0, $Month, $DaysInMonth, $Year);
     $Sender->CanonicalUrl(Url('eventcalendar', TRUE));
     $Sender->SetData('Title', T('Event Calendar'));
     $Sender->SetData('Breadcrumbs', array(array('Name' => T('Event Calendar'), 'Url' => '/eventcalendar')));
     $Sender->SetData('Month', $Month);
     $Sender->SetData('Year', $Year);
     $Sender->SetData('MonthFirst', $MonthFirst);
     $Sender->SetData('MonthLast', $MonthLast);
     $Sender->SetData('PreviousMonth', date('Y', $MonthFirst - 1) . '/' . date('m', $MonthFirst - 1));
     $Sender->SetData('NextMonth', date('Y', $MonthLast + 86400) . '/' . date('m', $MonthLast + 86400));
     $Sender->SetData('DaysInMonth', $DaysInMonth);
     $Sender->SetData('Events', EventCalendarModel::Get("{$Year}-{$Month}-01", "{$Year}-{$Month}-{$DaysInMonth}"));
     $ViewName = 'month';
     $Sender->Render($ViewName, '', 'plugins/EventCalendar');
 }