set_config($config); } /** * Sets the config variables. * @param array $config */ public function set_config($config) { $this->calendarWidth = $config['calendarWidth'] ? $config['calendarWidth'] : "500px"; $this->calendarHeight = $config['calendarHeight'] ? $config['calendarHeight'] : "840px"; $this->useModal = $config['useModal'] ? $config['useModal'] : "true"; $this->showExtras = $config['showExtras'] ? $config['showExtras'] : "false"; $this->enableSnow = $config['enableSnow'] ? $config['enableSnow'] : "false"; } /** * Adds a new entry to the calendar. * @param array $entry */ public function set_entry($entry) { if ($this->validate_entry($entry)) { $this->entries[] = $entry; } } /** * Checks if an entry can be added to the calendar. * @param array $entry */ public function validate_entry($entry) { if ( !array_key_exists('unlockDate', $entry) || !array_key_exists('positionTop', $entry) || !array_key_exists('positionLeft', $entry) || (!array_key_exists('doorImageLeft', $entry) && !array_key_exists('doorImageRight', $entry)) || !array_key_exists('url', $entry) ) { return false; } return true; } /** * Loads a calendar from a json string. * @param string $json */ public function load_from_json($json) { $data = json_decode($json, true); $this->set_config($data['config']); foreach ($data['entries'] as $entry) { $this->set_entry($entry); } } /** * Renders the HTML for the calendar. * @param boolean $return if set to TRUE, returns the output rather than print it. */ public function render($return = false) { $now = time(); $output = ""; $output .= '