/**
  * main entry point for control panel as well as to poll the status of sphinx such
  * as reindexing/start/stop/rotate/etc
  *
  * @param object $Sender
  */
 public function Controller_Index($Sender)
 {
     $Sender->Permission('Vanilla.Settings.Manage');
     // Currently, only pretty URLs will work with Sphinx. This is due to how the GET query string is constructed
     if (C('Garden.RewriteUrls') != TRUE) {
         $Sender->Form->AddError("Must enable Pretty URLs for Sphinx to work properly! <br> Do so in your config.php file; Configuration['Garden']['RewriteUrls'] = TRUE;");
     }
     $Sender->SetData('PluginDescription', $this->GetPluginKey('Description'));
     $Sender->SetData('PluginVersion', $this->GetPluginKey('Version'));
     $SphinxAdmin = SphinxFactory::BuildSphinx($Sender, $this->getview('sphinxsearch.php'));
     $SphinxAdmin->Status();
     $Sender->SetData('Settings', $SphinxAdmin->GetSettings());
     $Sender->Render($this->getview('sphinxsearch.php'));
 }
 /**
  * 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');
 }