Ejemplo n.º 1
0
 public function mwCalendar($params)
 {
     global $wgOut, $wgTitle, $wgScript, $wgScriptPath, $IP;
     $this->setDefaults($params);
     ## RUN FIRST ##
     helpers::debug("******** Calendar Init()-{$this->key} ******** ");
     $list = '';
     $rteJS = '';
     // set the calendar's initial date
     $now = $this->now = getdate();
     $this->month = $now['mon'];
     $this->year = $now['year'];
     $this->day = $now['mday'];
     ## load normal calendar
     $cookie_name = helpers::cookie_name($this->key);
     helpers::debug('Checking for cookie: ' . $cookie_name);
     if (isset($_COOKIE[$cookie_name])) {
         $date = getdate($_COOKIE[$cookie_name]);
         //timestamp value
         $this->month = $date['mon'];
         $this->year = $date['year'];
         helpers::debug("Coookie found ({$cookie_name}), SETTING calendar date/time: {$this->month}/{$this->year}");
     }
     $this->title = $wgScript . '?title=' . $wgTitle->getPrefixedText();
     $this->db = new CalendarDatabase();
     $this->db->validateVersion();
     //make sure db and files match
     $this->options = $this->db->getOptions($this->calendarName);
     ## this basically calls a function that evaluates $_POST[] events (new, delete, cancel, etc)
     ## no need to do anything else in the calendar until any db updates have completed
     if (helpers::is_my_calendar($this->key)) {
         EventHandler::CheckForEvents();
     }
     ## add any custom groups
     $arrParamsGrps = isset($params['groups']) ? explode(',', $params['groups']) : array();
     foreach ($arrParamsGrps as $grp) {
         $grpCount = count($this->db->getGroupUsers($grp));
         $list .= "<option>#{$grp} ({$grpCount} " . helpers::translate("mwc_members") . ")</option>";
     }
     /* 		$arrGroups = $this->db->getDatabaseGroups();
     		foreach($arrGroups as $grp){
     			$list .= "<option>#$grp</option>";
     		} 
     */
     ## build the mw user-list which should only be users with active email
     $arrUsers = $this->db->getDatabaseUsers();
     while (list($user, $realname) = each($arrUsers)) {
         $realname = htmlentities($realname, ENT_QUOTES);
         $list .= "<option>{$user} ({$realname})</option>";
     }
     $list = "<SELECT class=notifyselect id=selectNotify name=selectNotify size=8 onClick=selectedListItem()>" . $list . "</SELECT>";
     ## pull in all the html template forms we have
     $addEventHtml = file_get_contents(mwcalendar_base_path . "/html/AddEvent.html");
     $batchHtml = file_get_contents(mwcalendar_base_path . "/html/batchadd.html");
     $this->htmlData = file_get_contents(mwcalendar_base_path . "/html/default.html");
     $this->htmlOption = file_get_contents(mwcalendar_base_path . "/html/Options.html");
     $addEventHtml = str_replace('[[SELECT_OPTIONS]]', $list, $addEventHtml);
     ## building my own sytlesheets and javascript links...
     $stdJSArray = array('DatePicker.js', 'tabber.js', 'InvitePicker.js', 'TimePicker.js', 'common.js', 'rte.js');
     $rteExists = file_exists($IP . "/extensions/tinymce/jscripts/tiny_mce/tiny_mce.js");
     if ($this->useRTE && $rteExists) {
         $rteJS .= $this->buildJavascript(array('/extensions/tinymce/jscripts/tiny_mce/tiny_mce.js'), true);
         $rteJS .= $this->buildJavascript(array('rte.js'));
     }
     $this->stylesheet = $this->buildStylesheet(array('DatePicker.css', 'tabber.css', 'default.css'));
     $this->javascript = $this->buildJavascript(array('DatePicker.js', 'tabber.js', 'InvitePicker.js', 'TimePicker.js', 'common.js'));
     $this->javascript .= $rteJS;
     ## build the addEvent and batch tabs
     $tab1 = $this->buildTab(helpers::translate('mwc_event'), $addEventHtml);
     $tab2 = $this->buildTab(helpers::translate('mwc_batch'), $batchHtml);
     $this->tabHtml = '<div class="tabber">' . $tab1 . $tab2 . '</div>';
 }