Exemplo n.º 1
0
    private function _getMap($address = null, $gmapRegion = '', $width = '500px', $height = '500px', $gmapLib = 'http://maps.google.com/maps/api/js?sensor=false')
    {
        $googleMap = '';
        $gmapLocations = '';
        //-- Add google Map API
        if ($address) {
            include_once 'google_geoloc.class.inc';
            //-- Output the Address results
            if (class_exists("geoLocator") && $address) {
                //-- Split addresses for multiple points on the map
                $addressList = explode('|', $address);
                $mygeoloc = new geoLocator();
                $mygeoloc->region = $gmapRegion;
                //$mygeoloc->host = $this->config['GOOGLE_MAP_HOST'];
                //$mygeoloc->apikey = $this->config['GOOGLE_MAP_KEY'];
                //$mygeoloc->canvas = $this->config['mxcGoogleMapDisplayCanvasID'];
                //$mygeoloc->autofitmap = (count($addressList) > 1 ? true : false);
                foreach ($addressList as $loc) {
                    $mygeoloc->getGEO($loc);
                }
                $googleMap = '<div id="map_canvas" style="width:' . $width . '; height:' . $height . ';"></div>';
                $gmapLocations = $mygeoloc->mapJSv3;
            } else {
                $googleMap = 'No class found.';
            }
            return $googleMap . '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
                        <script type="text/javascript">
                                // -- mxCalendar :: location map -- //
                                function initialize() {
                                    //' . $gmapLocations . '
                                };

                                if (window.attachEvent) {window.attachEvent(\'onload\', initialize);}
                                else if (window.addEventListener) {window.addEventListener(\'load\', initialize, false);}
                                else {document.addEventListener(\'load\', initialize, false);}

                        </script>';
        }
    }
Exemplo n.º 2
0
        function MakeEventDetail($id, $param)
        {
            global $modx;
            $table = $modx->getFullTableName($this->tables['events']);
            $result = $modx->db->select('*', $table, 'id=' . $id);
            $eventSQL = 'SELECT *, (SELECT DATEDIFF(E.enddate, E.startdate)) as DurationDays, (SELECT TIMEDIFF(E.endtime, E.starttime)) as DurationTime
				FROM ' . $table . ' as E WHERE E.id=' . $id . ' LIMIT 1';
            $result = $modx->db->query($eventSQL);
            $content = $modx->db->makeArray($result);
            //-- OS Type check to switch varible for strftime()
            //$OS = $_SERVER['SERVER_SOFTWARE'];
            //echo '(#1038) OS TYPE => '.$OS.'<br />';
            $defaultParam = array('mxcTplEventDetail' => null, 'mxcDateTimeSeperator' => !empty($this->config['mxcDateTimeSeperator']) ? $this->config['mxcDateTimeSeperator'] : _mxCalendar_gl_datetimeseperator, 'mxcEventDetailBackBtnClass' => !empty($this->config['mxcEventDetailBackBtnClass']) ? $this->config['mxcEventDetailBackBtnClass'] : '', 'mxcEventDetailBackBtnTitle' => !empty($this->config['mxcEventDetailBackBtnTitle']) ? $this->config['mxcEventDetailBackBtnTitle'] : _mxCalendar_ed_backToCaltitle);
            $param = array_merge($defaultParam, $param);
            //-- Display back to calendar button
            if ((int) $param['mxcFullCalendarPgId'] == (int) $modx->documentIdentifier) {
                $backID = $param['mxcAjaxPageId'] != $param['mxcFullCalendarPgId'] && empty($param['mxcFullCalendarPgId']) ? $param['mxcAjaxPageId'] : $param['mxcFullCalendarPgId'];
                $modx->setPlaceholder('mxcEventDetailBackToCal', _mxCalendar_ed_backToCal);
                $modx->setPlaceholder('mxcEventDetailBackBtnURL', $modx->makeUrl((int) $backID));
                $modx->setPlaceholder('mxcEventDetailBackBtnClass', $param['mxcEventDetailBackBtnClass']);
                $modx->setPlaceholder('mxcEventDetailBackBtnTitle', $param['mxcEventDetailBackBtnTitle']);
            } else {
                $modx->setPlaceholder('mxcEventDetailBackToCal', '');
            }
            //-- Parse through returned results and format for UI
            if ($modx->db->getRecordCount($result)) {
                foreach ($content as $p_val) {
                    //-- Build the reoccurring date output list
                    $dateList = array();
                    if (!empty($p_val['repeat'])) {
                        $dates = explode(',', $p_val['repeat']);
                        $subDateX = 0;
                        foreach ($dates as $o) {
                            $dateList[] = strftime(_mxCalendar_ed_dateformat, mktime(date('H', strtotime($p_val['start'])), date('i', strtotime($p_val['start'])), 0, date('m', strtotime($o)), date('d', strtotime($o)), date('y', strtotime($o)))) . $param['mxcDateTimeSeperator'] . ($p_val['DurationDays'] ? strftime(_mxCalendar_ed_dateformat, mktime(date('H', strtotime($p_val['end'])), date('i', strtotime($p_val['end'])), 0, date('m', strtotime($o)), date('d', strtotime($o)) + (int) $p_val['DurationDays'], date('y', strtotime($o)))) : strftime(_mxCalendar_ed_dateformat, mktime(date('H', strtotime($p_val['end'])), date('i', strtotime($p_val['end'])), 0, date('m', strtotime($o)), date('d', strtotime($o)), date('y', strtotime($o)))));
                            $subDateX++;
                        }
                        //-- Strikeout past date times
                        $datetime_now = date(_mxCalendar_ed_dateformat);
                        $str_dates = '';
                        foreach ($dateList as $d) {
                            $str_dates .= $d > $datetime_now ? '<li style="text-decoration:line-through;color:red;">' . $d . '</li>' : $d;
                        }
                        $str_repeatDates = count($dateList) && $this->config['eventlist_multiday'] ? "<span ='mxcRepeatEventItem'>" . $str_dates . implode('<br />', $dateList) . "</span>" : '';
                        //-- Display only the selected event occurance date/time value
                        $str_repeatDates = $dates[$param['r']];
                    }
                    //-- Parse Event Detail Template
                    if (!empty($param['mxcTplEventDetail'])) {
                        //--Get user modified theme over-ride
                        $this->output = $modx->getChunk($param['mxcTplEventDetail']);
                    } else {
                        //--Get the theme details view
                        $this->output = $this->_getTheme('event.detail', $this->config['mxCalendarTheme']);
                    }
                    //-- Setup the title link check
                    $title = !empty($p_val['link']) ? is_numeric($p_val['link']) ? $modx->makeUrl((int) $p_val['link']) : '<a href="' . $p_val['link'] . '" rel="' . $p_val['linkrel'] . '" target="' . $p_val['linktarget'] . '">' . $p_val['title'] . '</a>' : $p_val['title'];
                    //-- Add google Map API
                    if ($p_val['location'] && $p_val['displayGoogleMap']) {
                        include_once $modx->config['base_path'] . 'assets/modules/mxCalendar/includes/google_geoloc.class.inc';
                        //-- Output the Address results
                        if (class_exists("geoLocator") && $p_val['location']) {
                            //-- Split addresses for multiple points on the map
                            $addressList = explode('|', $p_val['location']);
                            $mygeoloc = new geoLocator();
                            $mygeoloc->host = $this->config['GOOGLE_MAP_HOST'];
                            $mygeoloc->apikey = $this->config['GOOGLE_MAP_KEY'];
                            $mygeoloc->canvas = $this->config['mxcGoogleMapDisplayCanvasID'];
                            $mygeoloc->autofitmap = count($addressList) > 1 ? true : false;
                            foreach ($addressList as $loc) {
                                $mygeoloc->getGEO($loc);
                            }
                            $googleMap = '';
                            //-- Build Google MAP JS Section
                            if ($param['ajaxPageId'] != $modx->documentIdentifier && (int) $param['ajaxPageId'] !== 0) {
                                $googleMap = '<div id="' . $this->config['mxcGoogleMapDisplayCanvasID'] . '" style="width: ' . $this->config['mxcGoogleMapDisplayWidth'] . '; height: ' . $this->config['mxcGoogleMapDisplayHeigh'] . '"><img src="/blank.gif" alt="" onload="initialize();" /></div>';
                                if ($this->config['mxcGoogleMapDisplayLngLat']) {
                                    $googleMap .= $mygeoloc->output;
                                }
                                $this->_addGoogleMapJS($mygeoloc->mapJSv3, true);
                            } else {
                                $googleMap = '<div id="' . $this->config['mxcGoogleMapDisplayCanvasID'] . '" style="width: ' . $this->config['mxcGoogleMapDisplayWidth'] . '; height: ' . $this->config['mxcGoogleMapDisplayHeigh'] . ';"><img src="/blank.gif" alt="" onload="initialize();" /></div>';
                                if ($this->config['mxcGoogleMapDisplayLngLat']) {
                                    $googleMap .= $mygeoloc->output;
                                }
                                $googleMap .= $this->_addGoogleMapJS($mygeoloc->mapJSv3, null, true);
                            }
                        } else {
                            echo 'No class found.';
                        }
                    }
                    //-- Adjust Repeat Date Value r0.0.6
                    if (isset($_REQUEST['r']) && !empty($_REQUEST['r'])) {
                    }
                    //-- Replace placeholders w/UI values
                    $modx->setPlaceholder('mxcEventDetailId', $this->config['mxcEventDetailId']);
                    $modx->setPlaceholder('mxcEventDetailClass', $this->config['mxcEventDetailClass']);
                    $modx->setPlaceholder('mxcEventDetailTitle', $title);
                    $modx->setPlaceholder('mxcEventDetailLabelDateTime', $this->config['mxcEventDetailLabelDateTime'] ? $this->config['mxcEventDetailLabelDateTime'] : _mxCalendar_ed_dt);
                    $modx->setPlaceholder('mxcEventDetailDateTimeSeperator', $param['mxcDateTimeSeperator']);
                    $modx->setPlaceholder('mxcEventDetailStartDateTime', strftime(isset($param['mxcStartDateFormat']) ? $param['mxcStartDateFormat'] : _mxCalendar_ed_start_dateformat, strtotime(isset($_REQUEST['r']) && $_REQUEST['r'] != "" ? $dates[$_REQUEST['r']] . ' ' . $p_val['starttime'] : $p_val['start'])));
                    $modx->setPlaceholder('mxcEventDetailEndDateTime', strftime(isset($param['mxcEndDateFormat']) ? $param['mxcEndDateFormat'] : _mxCalendar_ed_end_dateformat, strtotime(isset($_REQUEST['r']) && $_REQUEST['r'] != "" ? $dates[$_REQUEST['r']] . ' ' . $p_val['endtime'] : $p_val['end'])));
                    $modx->setPlaceholder('mxcEventDetailDateTimeReoccurrences', $str_repeatDates);
                    $modx->setPlaceholder('mxcEventDetailLabelLocation', $p_val['location'] ? $this->config['mxcEventDetailLabelLocation'] ? $this->config['mxcEventDetailLabelLocation'] : _mxCalendar_ed_location : '');
                    $modx->setPlaceholder('mxcEventDetailLocation', str_replace('|', '<br />', $p_val['location']));
                    $modx->setPlaceholder('mxcEventDetailDescription', $p_val['description']);
                    $modx->setPlaceholder('mxcEventDetailGoogleMap', $googleMap);
                    /** START THE CUSTOM FIELDs **/
                    $EventArr_cft = array();
                    $cft_event = json_decode($p_val['customFields'], true);
                    $dyn_config_opts = json_decode($this->config['mxcCustomFieldTypes'], true);
                    $dyn_resource_opts = array();
                    //-- Grab the "resource" field type to get the TV's that should be used
                    if ($dyn_config_opts) {
                        foreach ($dyn_config_opts as $cft) {
                            $cft_type = $cft['type'];
                            if ($cft_type == 'resource') {
                                $dyn_resource_opts[$cft['name']] = $cft['options'];
                            }
                        }
                        //-- end loop of custom field types
                    }
                    //-- Loop through the custom fields
                    if (count($cft_event)) {
                        foreach ($cft_event as $l => $v) {
                            switch ($v['type']) {
                                default:
                                    $modx->setPlaceholder('mxc' . $l, $v['val']);
                                    break;
                                case 'image':
                                    $modx->setPlaceholder('mxc' . $l, '<img src="' . $v['val'] . '" alt="" />');
                                    break;
                                case 'resource':
                                    //-- Get the TV's as set in the options for the resource in the configuration tab of mxCalendar
                                    if (!empty($dyn_resource_opts[$l])) {
                                        $tvVals = $modx->getTemplateVarOutput(explode(',', $dyn_resource_opts[$l]), (int) $v['val'], 1);
                                        if (count($tvVals) && is_array($tvVals)) {
                                            foreach ($tvVals as $k => $tvVal) {
                                                $modx->setPlaceholder('mxc' . $k, $tvVal);
                                            }
                                        }
                                    }
                                    //-- Get predefined document values to use in mxCalendar
                                    $array_doc = $modx->getPageInfo((int) $v['val'], 1, 'pagetitle, description, alias, content');
                                    $modx->setPlaceholder('mxcpagetitle', $array_doc['pagetitle']);
                                    $modx->setPlaceholder('mxcdescription', $array_doc['description']);
                                    $modx->setPlaceholder('mxcalias', $array_doc['alias']);
                                    $modx->setPlaceholder('mxccontent', $array_doc['content']);
                                    $modx->setPlaceholder('mxc' . $l, $v['val']);
                                    break;
                            }
                        }
                    }
                    /** END THE CUSTOM FIELDs **/
                    // event date start
                    $modx->setPlaceholder('mxcEventDetailStateDateStamp', $param['mxcEventDetailStateDateStamp'] ? strftime($param['mxcEventDetailStateDateStamp'], strtotime($p_val['start'])) : $p_val['start']);
                    // event time end
                    $modx->setPlaceholder('mxcEventDetailStateTimeStamp', $param['mxcEventDetailStateTimeStamp'] ? strftime($param['mxcEventDetailStateTimeStamp'], strtotime($p_val['start'])) : $p_val['start']);
                    // event date end
                    $modx->setPlaceholder('mxcEventDetailEndDateStamp', $param['mxcEventDetailEndDateStamp'] ? strftime($param['mxcEventDetailEndDateStamp'], strtotime($p_val['end'])) : $p_val['end']);
                    // event time end
                    $modx->setPlaceholder('mxcEventDetailEndTimeStamp', $param['mxcEventDetailEndTimeStamp'] ? strftime($param['mxcEventDetailEndTimeStamp'], strtotime($p_val['end'])) : $p_val['end']);
                }
                //end loop
            }
            if (!empty($this->config["mxCalendarTheme"])) {
                $activeTheme = $this->_getActiveTheme();
                $this->_addCSS('<link rel="stylesheet" type="text/css" href="assets/modules/mxCalendar/themes/' . $this->config['mxCalendarTheme'] . '/' . $activeTheme["themecss"] . '" /> ');
            }
            if ($param['mxcAddMooJS'] || $param['mxcJSCodeLibrary']) {
                $this->_addMooJS();
            }
            return $this->output;
        }