function UseModule($Identifer, $Parameters) { $Parameters = explode('&', $Parameters); $all = false; $count = 6; $location = '%'; foreach ($Parameters as $parameter) { $parameter = explode('=', $parameter, 2); if (empty($parameter[1])) { $parameter[1] = true; } ${$parameter}[0] = $parameter[1]; } $dates = new Dates($this->_SqlConnection, $this->_ComaLib, $this->_User, $this->_Config); if ($all) { $count = -1; } $datesArray = array(); if ($location != '%') { $datesArray = $dates->ExtendedFillArray($location, $count); } else { $datesArray = $dates->FillArray($count); } $this->_ComaLate->SetReplacement('DATES', $datesArray); return "</p><table class=\"text_table full_width\">\r\n\t\t\t\t<thead>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<th class=\"table_date_width\">\r\n\t\t\t\t\t\t\t{$this->_Lang['date']}\r\n\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t<th class=\"small_width\">\r\n\t\t\t\t\t\t\t{$this->_Lang['location']}\r\n\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t<th>\r\n\t\t\t\t\t\t\t{$this->_Lang['topic']}\r\n\t\t\t\t\t\t</th>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</thead>\r\n\t\t\t\t<tbody>\r\n\t\t\t\t\t<DATES:loop>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t{DATE_DATE}\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t{DATE_LOCATION}\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t{DATE_TOPIC}\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t</DATES>\r\n\t\t\t\t</tbody>\r\n \t\t\t</table><p>"; }
/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { $category = explode('_', $id); $category = $this->loadModel($category[0]); $events = array(); $dates = Dates::model()->findAllByAttributes(array('status_date' => 1), array('order' => 't.date_date ASC')); foreach ($dates as $key => $date) { $eventsDate = Events::model()->findAllByAttributes(array('dates_id_date' => $date->id_date, 'status_event' => 1, 'great_event' => 1, 'event_categories_id_category' => $category->id_category), array('order' => 't.hour_event ASC')); $events = array_merge($events, $eventsDate); } if (isset($_GET['event'])) { $event = Events::model()->findByAttributes(array('status_event' => 1, 'great_event' => 1, 'event_categories_id_category' => $category->id_category, 'id_event' => $_GET['event'])); if ($event == null) { throw new CHttpException(404, 'The requested page does not exist.'); } } else { if (isset($events[0])) { $event = $events[0]; $this->pageTitle = 'Eventos ' . $category->name_category . ' - ' . $this->pageTitle; $this->pageDescription = 'Los esperamos sin falta en nuestros eventos religiosos, teatro, danza, noches de música, cabalgata, carrozas y comparsas, deportes extremos y actividades para toda la familia.'; $this->tagImage = '/images/events/' . $event->image_event; } else { $event = null; } } $this->render('view', array('category' => $category, 'events' => $events, 'event' => $event)); }
public static function monthes_list_extended() { $temp = array(); $temp[0] = Dates::monthes_list(); $temp[1] = array(1 => 'января', 2 => 'февраля', 3 => 'марта', 4 => 'апреля', 5 => 'мая', 6 => 'июня', 7 => 'июля', 8 => 'августа', 9 => 'сентября', 10 => 'октября', 11 => 'ноября', 12 => 'декабря'); return $temp; }
public function delete($user_id) { $deleted_at = Input::get('active') == 1 ? null : new DateTime(); DB::table(DB_USERS)->where('id', $user_id)->update(array('updated_by' => Auth::user()->id, 'updated_at' => new DateTime(), 'deleted_at' => $deleted_at)); $updated = DB::table(DB_USERS)->where('id', $user_id)->pluck('updated_at'); return Dates::relative($updated); }
public function build_comment($cats, $parent_id, $ansver, $fio) { if (is_array($cats) and isset($cats[$parent_id])) { $tree = '<ul>'; foreach ($cats[$parent_id] as $cat) { $date = Dates::output_date($cat['date_update']); $time = Dates::output_time($cat['date_update']); $id = $cat['id']; $author = $cat['author']; $tree .= '<li>' . '<div><p>' . $date . ' ' . $time . ' ' . $author . '</p>'; $tree .= "<p class=\"message_p\" id=\"message_full_" . $id . "\">"; $tree .= $cat['message'] . '</p>'; if ($ansver == true) { $tree .= "<p class=\"half\">"; $tree .= "<a data-toggle=\"modal\" href=\"#modal\" data-target=\"#modal\" data-id=\"{$id}\" id=\"modal_act\">Ответить</a>"; $tree .= '</p>'; } if ($fio == $author) { $tree .= "<p class=\"half\">"; $tree .= "<a data-toggle=\"modal\" href=\"#modal_1\" data-target=\"#modal_1\" data-id=\"{$id}\" id=\"modal_edit\">Редактировать</a>"; $tree .= '</p>'; } $tree .= '</div>'; $tree .= $this->build_comment($cats, $cat['id'], $ansver, $fio); $tree .= '</li>'; } $tree .= '</ul>'; } else { return null; } return $tree; }
function GetFormattedDateTime($value) { $str = Dates::DateTimeToString($value); if ($str == '') { return array('', ''); } return explode(' ', $str); }
public static function updateEndingDate($id, $newEndingDate, $oldEndingDate) { if (strcmp($newEndingDate, $oldEndingDate) === 0) { return false; } Dates::initDateTime($newEndingDate, $oldEndingDate); ScheduleFetcher::updateSingleColumn($id, ScheduleFetcher::DB_COLUMN_END_TIME, $newEndingDate, PDO::PARAM_STR); return true; }
public function actionProgramacion() { $this->pageTitle = 'Programación - ' . $this->pageTitle; $this->pageDescription = 'Consulta la programacion oficial de las ferias. Los esperamos sin falta en nuestros eventos religiosos, teatro, danza, noches de música, cabalgata, carrozas y comparsas, deportes extremos y actividades para toda la familia.'; $this->tagImage = '/images/facebook-programacion.png'; $events = array(); $dates = Dates::model()->findAllByAttributes(array('status_date' => 1), array('order' => 't.date_date ASC')); foreach ($dates as $key => $date) { $eventsDate = Events::model()->findAllByAttributes(array('status_event' => 1, 'dates_id_date' => $date->id_date), array('order' => 't.hour_event ASC')); if ($eventsDate != null) { $events[] = array('events' => $eventsDate, 'date' => $date); } } $this->render('programacion', array('events' => $events)); }
/** * render a calendar * * The provided anchor can reference: * - a section 'section:123' * - nothing * * @param string the anchor (e.g. 'section:123') * @return string the rendered text **/ public function render($matches) { global $context; $anchor = count($matches) ? $matches[0] : ''; // a list of dates include_once $context['path_to_root'] . 'dates/dates.php'; // get records if ($anchor && strpos($anchor, 'section:') === 0) { $items = Dates::list_for_prefix(NULL, 'compact', trim($anchor)); } else { $items = Dates::list_for_prefix(NULL, 'compact', NULL); } // build calendar for current month $text = Dates::build_months($items, FALSE, TRUE, FALSE, TRUE, gmstrftime('%Y'), gmstrftime('%m'), 'compact calendar'); // job done return $text; }
if (!Surfer::is_crawler()) { // previous year $previous = $year - 1; // next year $next = $year + 1; // neighbours $neighbours = array(Dates::get_url($previous, 'year'), $previous, Dates::get_url($next, 'year'), $next, NULL, NULL); // links to display previous and next years $text .= Skin::neighbours($neighbours, 'slideshow'); } // one calendar per month for ($index = 1; $index <= 12; $index++) { // items for this month $items =& Dates::list_for_month($year, $index, 'links'); // draw all months - force empty months $text .= Dates::build_months($items, TRUE, TRUE, TRUE, FALSE, $year, $index); } // cache, whatever change, for 5 minutes Cache::put($cache_id, $text, 'stable', 300); } $context['text'] .= $text; } // page extra content $cache_id = 'dates/year.php#extra'; if (!($text = Cache::get($cache_id))) { // side bar with the list of most recent pages if ($items =& Articles::list_by('publication', 0, COMPACT_LIST_SIZE, 'compact')) { $text =& Skin::build_box(i18n::s('Recent pages'), Skin::build_list($items, 'compact'), 'boxes'); } Cache::put($cache_id, $text, 'articles'); }
/** * @access private * @return string */ function _deletePage() { $confirmation = GetPostOrGet('confirmation'); $dateID = GetPostOrGet('dateID'); $dates = new Dates($this->_SqlConnection, $this->_ComaLib, $this->_User, $this->_Config); // has the user confirmed that he is sure to delete the date? if ($confirmation == 1 && is_numeric($dateID)) { $dates->DeleteDate($dateID); } else { if (is_numeric($dateID)) { $dateEntry = $dates->GetDate($dateID); if (count($dateEntry) > 0) { $out = "<h2>{$this->_Lang['delete_date']}</h2>\r\n"; $out .= sprintf($this->_Lang['Do_you_really_want_to_delete_the_date_%date_topic%_for_the_%date%_at_%time%_o_clock'], $dateEntry['DATE_TOPIC'], date("d.m.Y", $dateEntry['DATE_DATE']), date("H:i", $dateEntry['DATE_DATE'])); $out .= "<br />\r\n\t\t\t<a class=\"button\" href=\"admin.php?page=module_dates&action=delete&dateID={$dateID}&confirmation=1\" title=\"Wirklich Löschen\">{$this->_Lang['yes']}</a>\r\n\t\t\t<a class=\"button\" href=\"admin.php?page=module_dates\" title=\"Nicht Löschen\">{$this->_Lang['no']}</a>"; return $out; } } } return $this->_homePage(); }
$cache_id = 'dates/day.php#text#' . $target; if (!($text = Cache::get($cache_id))) { // draw one day if ($items = Dates::list_for_day($year, $month, $day, 'decorated')) { $text .= Skin::build_list($items, 'decorated'); } else { $text .= '<p>' . i18n::s('Nothing has been recorded for this date.') . '</p>'; } // robots cannot navigate if (!Surfer::is_crawler()) { // previous day $previous = gmstrftime('%Y/%m/%d', gmmktime(0, 0, 0, $month, $day - 1, $year)); // next day $next = gmstrftime('%Y/%m/%d', gmmktime(0, 0, 0, $month, $day + 1, $year)); // neighbours $neighbours = array(Dates::get_url($previous, 'day'), Skin::build_date($previous, 'standalone'), Dates::get_url($next, 'day'), Skin::build_date($next, 'standalone'), Dates::get_url($year . '/' . $month, 'month'), Dates::get_month_label($year . '/' . $month)); // links to display previous and next days $text .= Skin::neighbours($neighbours, 'slideshow'); } // cache, whatever change, for 1 minute Cache::put($cache_id, $text, 'stable', 60); } // in the main panel $context['text'] .= $text; } } // side bar with the list of most recent pages $cache_id = 'dates/day.php#extra'; if (!($text = Cache::get($cache_id))) { if ($items =& Articles::list_by('publication', 0, COMPACT_LIST_SIZE, 'compact')) { $text =& Skin::build_box(i18n::s('Recent pages'), Skin::build_list($items, 'compact'), 'boxes');
public function days() { return Dates::converTo($this->date)->diffForHumans(); }
/** * count related items * * This function draws a nice table to show how many items are related to * the anchor that has the focus. * * @param string the target reference * @param string the label to use, if any * @return string some XHTML snippet to send to the browser */ public static function stat_related_to($anchor, $label = NULL) { global $context; // describe related content $related = ''; $lines = 2; // stats for related categories, but only within categories if (strpos($anchor, 'category:') === 0) { if (($stats = Categories::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Categories'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } } // stats for related sections, but only within sections if (strpos($anchor, 'section:') === 0) { if (($stats = Sections::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Sections'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } } // stats for related articles, but only within sections if (strpos($anchor, 'section:') === 0) { if (($stats = Articles::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Pages'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } } // stats for related images include_once $context['path_to_root'] . 'images/images.php'; if (($stats = Images::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Images'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related locations include_once $context['path_to_root'] . 'locations/locations.php'; if (($stats = Locations::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Locations'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related tables include_once $context['path_to_root'] . 'tables/tables.php'; if (($stats = Tables::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Tables'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related files if (($stats = Files::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Files'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related dates include_once $context['path_to_root'] . 'dates/dates.php'; if (($stats = Dates::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Dates'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related comments include_once $context['path_to_root'] . 'comments/comments.php'; if (($stats = Comments::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Comments'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related links include_once $context['path_to_root'] . 'links/links.php'; if (($stats = Links::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Links'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // stats for related versions include_once $context['path_to_root'] . 'versions/versions.php'; if (($stats = Versions::stat_for_anchor($anchor)) && $stats['count']) { $cells = array(); $cells[] = i18n::s('Versions'); $cells[] = 'center=' . $stats['count']; $cells[] = 'center=' . Skin::build_date($stats['oldest_date']); $cells[] = 'center=' . Skin::build_date($stats['newest_date']); $related .= Skin::table_row($cells, $lines++); } // ensure we have a label if (!$label) { $label = i18n::s('Following items are attached to this record and will be impacted as well.'); } // stats for related items in a neat table if ($related) { // make a nice table $related = '<p>' . $label . "</p>\n" . Skin::table_prefix('') . Skin::table_row(array(i18n::s('Table'), i18n::s('Records'), i18n::s('Creation date'), i18n::s('Last edition')), 'header') . $related . Skin::table_suffix(); // put it in a box $related = Skin::build_box(i18n::s('Related items'), $related); } // job done return $related; }
/** * post a new date or an updated date * * This function populates the error context, where applicable. * * @param array an array of fields * @return integer the id of the new or updated record, else 0 on error * * @see dates/edit.php **/ public static function post(&$fields) { global $context; // no date if (!$fields['date_stamp']) { Logger::error(i18n::s('Please provide a date.')); return 0; } // no anchor reference if (!$fields['anchor']) { Logger::error(i18n::s('No anchor has been found.')); return 0; } // set default values for this editor Surfer::check_default_editor($fields); // update the existing record if (isset($fields['id'])) { // id cannot be empty if (!isset($fields['id']) || !is_numeric($fields['id'])) { Logger::error(i18n::s('No item has the provided id.')); return FALSE; } // update the existing record $query = "UPDATE " . SQL::table_name('dates') . " SET " . "date_stamp='" . SQL::escape($fields['date_stamp']) . "'"; // maybe a silent update if (!isset($fields['silent']) || $fields['silent'] != 'Y') { $query .= ", " . "edit_name='" . SQL::escape($fields['edit_name']) . "', " . "edit_id=" . SQL::escape($fields['edit_id']) . ", " . "edit_address='" . SQL::escape($fields['edit_address']) . "', " . "edit_date='" . SQL::escape($fields['edit_date']) . "'"; } $query .= " WHERE id = " . SQL::escape($fields['id']); if (SQL::query($query) === FALSE) { return 0; } // insert a new record } else { // always remember the date $query = "INSERT INTO " . SQL::table_name('dates') . " SET " . "anchor='" . SQL::escape($fields['anchor']) . "', " . "anchor_id=SUBSTRING_INDEX('" . SQL::escape($fields['anchor']) . "', ':', -1)," . "anchor_type=SUBSTRING_INDEX('" . SQL::escape($fields['anchor']) . "', ':', 1)," . "date_stamp='" . SQL::escape($fields['date_stamp']) . "', " . "edit_name='" . SQL::escape($fields['edit_name']) . "', " . "edit_id=" . SQL::escape($fields['edit_id']) . ", " . "edit_address='" . SQL::escape($fields['edit_address']) . "', " . "edit_date='" . SQL::escape($fields['edit_date']) . "'"; if (SQL::query($query) === FALSE) { return 0; } // id of the new record $fields['id'] = SQL::get_last_id($context['connection']); } // clear the cache for dates Dates::clear($fields); // end of job return $fields['id']; }
* * @author Bernard Paques * @reference * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License */ // common definitions and initial processing include_once '../shared/global.php'; include_once '../dates/dates.php'; // load the skin load_skin('dates'); // the path to this page $context['path_bar'] = array('users/' => i18n::s('Dates')); // the title of the page $context['page_title'] = i18n::s('Dates'); // list upcoming events $text = Dates::list_future_for_anchor(NULL, 0, 100, 'ics'); // no encoding, no compression and no yacs handler... if (!headers_sent()) { Safe::header('Content-Type: text/calendar'); Safe::header('Content-Transfer-Encoding: binary'); Safe::header('Content-Length: ' . strlen($text)); } // suggest a download if (!headers_sent()) { $file_name = utf8::to_ascii(Skin::strip($context['page_title']) . '.ics'); Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"'); } // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download http::expire(1800); // strong validator $etag = '"' . md5($text) . '"';
return; // parse the whole list } else { // fetch one anchor and the linked member $errors_count = 0; while ($row = SQL::fetch($result)) { // animate user screen and take care of time $count++; if (!($count % 100)) { $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n"; // ensure enough execution time Safe::set_time_limit(30); } // check that the anchor exists, if any if ($row['anchor'] && !Anchors::get($row['anchor'])) { $context['text'] .= sprintf(i18n::s('Orphan: %s'), 'date ' . Skin::build_link(Dates::get_url($row['id']), $row['id'] . ' ' . $row['date_stamp'])) . BR . "\n"; if (++$errors_count >= 25) { $context['text'] .= i18n::s('Too many successive errors. Aborted') . BR . "\n"; break; } } else { $errors_count = 0; } } } // ending message $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n"; // display the execution time $time = round(get_micro_time() - $context['start_time'], 2); $context['text'] .= '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>'; // forward to the index page
function UseModule($Identifer, $Parameters) { $Parameters = explode('&', $Parameters); $all = false; $count = 6; $location = '%'; // parse all parameters foreach ($Parameters as $parameter) { $parameter = explode('=', $parameter, 2); if (empty($parameter[1])) { $parameter[1] = true; } ${$parameter}[0] = $parameter[1]; } $dates = new Dates($this->_SqlConnection, $this->_ComaLib, $this->_User, $this->_Config); // we want to get "all" dates if ($all) { $count = -1; } $datesArray = array(); $found = 0; // get the count of all possible matches // if location is set, it is a conditional request if ($location != '%') { $found = $dates->GetExtendedCount($location); } else { $found = $dates->GetCount(); } $start = 0; $linksArray = array(); $linksTemplate = ''; $links = uniqid('LINKS_'); // it is usefull to use "page links" if ($found > $count && $count > 1) { $parts = $found / $count; $max = round($parts, 0); $max = $max >= $parts ? $max : $max + 1; $linksTemplate = '<' . $links . ':loop> <a href="?page={PAGE_ID}&page_nr={LINK_NR}">{LINK_TEXT}</a> {LINK_MINUS} </' . $links . '>'; $pageNr = GetPostOrGet('page_nr'); if (!is_numeric($pageNr)) { $pageNr = 0; } if ($pageNr > 0) { $linksTemplate = '<a href="?page={PAGE_ID}&page_nr=' . ($pageNr - 1) . '">{LANG_PREVIOUS}</a> -' . $linksTemplate; } if ($pageNr < $max - 1) { $linksTemplate .= ' - <a href="?page={PAGE_ID}&page_nr=' . ($pageNr + 1) . '">{LANG_NEXT}</a>'; } for ($i = 0; $i < $parts; $i++) { $linksArray[$i] = array('LINK_NR' => $i, 'LINK_TEXT' => $i + 1, 'LINK_MINUS' => '-'); } $linksArray[$max - 1]['LINK_MINUS'] = ''; $this->_ComaLate->SetReplacement($links, $linksArray); $this->_ComaLate->SetReplacement('LANG_NEXT', $this->_Translation->GetTranslation('next')); $this->_ComaLate->SetReplacement('LANG_PREVIOUS', $this->_Translation->GetTranslation('previous')); $linksTemplate = '<div>' . $linksTemplate . '</div>'; $start = $count * $pageNr; if ($start > $found) { $start = ($max - 1) * $count; } } // Get the array with the dates if ($location != '%') { $datesArray = $dates->ExtendedFillArray($location, $count, $start); } else { $datesArray = $dates->FillArray($count, $start); } $name = uniqid('EVENTS_'); $this->_ComaLate->SetReplacement($name, $datesArray); $this->_ComaLate->SetReplacement('PAGE_ID', GetPostOrGet('page')); $this->_ComaLate->SetReplacement('LANG_DATE', $this->_Translation->GetTranslation('date')); $this->_ComaLate->SetReplacement('LANG_LOCATION', $this->_Translation->GetTranslation('location')); $this->_ComaLate->SetReplacement('LANG_TOPIC', $this->_Translation->GetTranslation('topic')); $template = '</p>' . $linksTemplate . ' <table class="full_width"> <thead> <tr> <th class="table_date_width"> {LANG_DATE} </th> <th class="small_width"> {LANG_LOCATION} </th> <th> {LANG_TOPIC} </th> </tr> </thead> <tbody> <' . $name . ':loop> <tr> <td> {EVENT_DATE} </td> <td> {EVENT_LOCATION} </td> <td> {EVENT_TOPIC_HTML} </td> </tr> </' . $name . '> </tbody> </table>' . $linksTemplate . '<p>'; return $template; }
/** * Get human readable time from seconds * @param int $seconds - count of seconds that come from count of seconds * @return string - human readable time (H:i) with zeros */ public static function getHumanTime($seconds) { $hrs = Dates::getTime($seconds, 'hrs'); $hrs = Support::addZero($hrs); $min = Dates::getTime($seconds, 'min'); $min = Support::addZero($min); return $hrs . ':' . $min; }
$follow_up = i18n::s('What do you want to do now?'); $menu = array(); $menu = array_merge($menu, array($anchor->get_url() => i18n::s('View the page'))); $menu = array_merge($menu, array($anchor->get_url('edit') => i18n::s('Edit the page'))); $follow_up .= Skin::build_list($menu, 'menu_bar'); $context['text'] .= Skin::build_block($follow_up, 'bottom'); // update of an existing date } else { // increment the post counter of the surfer Users::increment_posts(Surfer::get_id()); // touch the related anchor $anchor->touch('date:update', $_REQUEST['id'], isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y'); // clear cache Dates::clear($_REQUEST); // forward to the view page Safe::redirect($context['url_to_home'] . $context['url_to_root'] . Dates::get_url($_REQUEST['id'])); } // display the form on GET } else { $with_form = TRUE; } // display the form if ($with_form) { // reference the anchor page if (is_object($anchor) && $anchor->is_viewable()) { $context['text'] .= '<p>' . Skin::build_link($anchor->get_url(), $anchor->get_title()) . "</p>\n"; } // the form to edit an date $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" onsubmit="return validateDocumentPost(this)" id="main_form"><div>'; // form fields $fields = array();
include_once 'dates.php'; // load the skin load_skin('dates'); // the title of the page $context['page_title'] = i18n::s('Dates'); // count dates in the database $stats = Dates::stat(); if ($stats['count']) { $context['page_menu'] += array('_count' => sprintf(i18n::ns('%d date', '%d dates', $stats['count']), $stats['count'])); } // page main content $cache_id = 'dates/index.php#text'; if (!($text = Cache::get($cache_id))) { // get and draw upcoming events with links to global calendars if ($items =& Dates::list_future(0, 200, 'links')) { $text = Dates::build_months($items, TRUE); } else { $text = i18n::s('No event has been planned so far'); } // cache, whatever changes, for 1 minute Cache::put($cache_id, $text, 'stable', 60); } $context['text'] .= $text; // page tools if (Surfer::is_associate()) { $context['page_tools'][] = Skin::build_link('dates/check.php', i18n::s('Maintenance'), 'basic'); } // subscribe to this calendar if (!isset($context['skins_general_without_feed']) || $context['skins_general_without_feed'] != 'Y') { $lines = array(); $lines[] = Skin::build_link($context['url_to_home'] . $context['url_to_root'] . 'dates/fetch_ics.php', i18n::s('Get calendar'), 'basic');
/** * Format a date * * Accept either a time stamp, or a formatted string as input parameter: * - YYYY-MM-DD HH:MM:SS * - YYMMDD HH:MM:SS GMT * * The variant is processed as follows: * - 'day' - only day, month and year --no time information * - 'with_hour' - adapts to time scale, and mention hours for today and yesterday * - 'no_hour' - adapts to time scale, but don't mention hours * - 'full' - display the full date * - 'month' - only month and year * - 'publishing' - allows for smart skinning * - 'standalone' - like full, but without the 'on ' prefix * - 'iso8601' - special format * - 'plain' - example 'Feb 26 2010 22:30:31 GMT' * - 'yyyy-mm-dd' - only day, month and year --no time information * * The date provided is considered to be GMT-based. * It is adjusted to the time zone of the surfer, if applicable. * This adjustment does not apply to following variants: * - 'day' * - 'iso8601' * - 'standalone' * * * @link http://www.w3.org/TR/NOTE-datetime the w3c profile of ISO 8601 * @link http://www.cs.tut.fi/~jkorpela/iso8601.html short description of ISO 8601 * @link http://fr2.php.net/date Code for ISO 8601 formatting * * @param int or string the date to be displayed * @param string the variant * @param string the language to express this stamp * @param int offset to GMT of the provided date, if any * @return the HTML to be used */ public static function &build_date($stamp, $variant = 'with_hour', $language = NULL, $gmt_offset = 0) { global $context, $local; // return by reference $output = ''; // sanity check if (!isset($stamp) || !$stamp) { return $output; } // surfer offset, except on 'day' and 'iso8601' if ($variant == 'day' || $variant == 'iso8601' || $variant == 'standalone' || $variant == 'local') { $surfer_offset = 0; } else { $surfer_offset = Surfer::get_gmt_offset(); } // YYMMDD-HH:MM:SS GMT -- this one is natively GMT if (preg_match('/GMT$/', $stamp) && strlen($stamp) == 19) { // YYMMDD-HH:MM:SS GMT -> HH, MM, SS, MM, DD, YY $actual_stamp = mktime(substr($stamp, 7, 2), substr($stamp, 10, 2), substr($stamp, 13, 2), substr($stamp, 2, 2), substr($stamp, 4, 2), substr($stamp, 0, 2)); // adjust to surfer time zone $actual_stamp += $surfer_offset * 3600; // time()-like stamp } elseif (intval($stamp) > 10000000) { // adjust to surfer time zone $actual_stamp = intval($stamp) + ($surfer_offset - $gmt_offset) * 3600; // YYYY-MM-DD HH:MM:SS, or a string that can be readed } elseif (($actual_stamp = strtotime($stamp)) != -1) { // adjust to surfer time zone $actual_stamp += ($surfer_offset - $gmt_offset) * 3600; } else { $output = '*' . $stamp . '*'; return $output; } if (!($items = @getdate($actual_stamp))) { $output = '*' . $stamp . '*'; return $output; } // if undefined language, use preferred language for absolute formats if ($language) { } elseif ($variant == 'full' || $variant == 'iso8601' || $variant == 'local') { $language = $context['preferred_language']; } else { $language = $context['language']; } // in French '1' -> '1er' if ($language == 'fr' && $items['mday'] == 1) { $items['mday'] = '1er'; } // allow for months localization through i18n $months = array('*', i18n::s('Jan.'), i18n::s('Feb.'), i18n::s('Mar.'), i18n::s('Apr.'), i18n::s('May'), i18n::s('June'), i18n::s('Jul.'), i18n::s('Aug.'), i18n::s('Sep.'), i18n::s('Oct.'), i18n::s('Nov.'), i18n::s('Dec.')); // load month labels adapted to required language $months = array('*', i18n::lookup($context['l10n'][$language], 'Jan.'), i18n::lookup($context['l10n'][$language], 'Feb.'), i18n::lookup($context['l10n'][$language], 'Mar.'), i18n::lookup($context['l10n'][$language], 'Apr.'), i18n::lookup($context['l10n'][$language], 'May'), i18n::lookup($context['l10n'][$language], 'June'), i18n::lookup($context['l10n'][$language], 'Jul.'), i18n::lookup($context['l10n'][$language], 'Aug.'), i18n::lookup($context['l10n'][$language], 'Sep.'), i18n::lookup($context['l10n'][$language], 'Oct.'), i18n::lookup($context['l10n'][$language], 'Nov.'), i18n::lookup($context['l10n'][$language], 'Dec.')); // now $now = time(); // server actual offset -- provided as a parameter // $gmt_offset = intval((strtotime(date('M d Y H:i:s')) - strtotime(gmdate('M d Y H:i:s'))) / 3600); // server stamp, as seen by surfer $today = getdate($now + ($surfer_offset - $gmt_offset) * 3600); // time stamp only if (preg_match('/00:00/', date('H:i', $actual_stamp))) { $time = ''; } else { $trailer = ''; if (!$surfer_offset && $variant !== 'local') { $trailer = ' GMT'; } $time = sprintf(i18n::s(' at %s%s'), date(i18n::s('h:i a'), $actual_stamp), $trailer); } // format a date as an absolute string if ($variant == 'full' || $variant == 'local') { if ($language == 'fr') { $output .= $items['mday'] . ' ' . $months[$items['mon']] . ' ' . $items['year'] . $time; } else { $output .= $months[$items['mon']] . ' ' . $items['mday'] . ' ' . $items['year'] . $time; } return $output; } // publishing date is in the future if ($variant == 'publishing' && strcmp($stamp, $context['now']) > 0) { $output .= DRAFT_FLAG; } // allow for smart skinning -- http://www.wplover.com/1449/easier-date-display-technique-with-css-3/ if ($variant == 'publishing') { $output .= '<span class="day">' . $items['mday'] . '</span>' . '<span class="month">' . $months[$items['mon']] . '</span>' . '<span class="year">' . $items['year'] . '</span>'; return $output; } // the same, but without prefix if ($variant == 'standalone') { if ($language == 'fr') { $output .= $items['mday'] . ' ' . $months[$items['mon']] . ' ' . $items['year'] . $time; } else { $output .= $months[$items['mon']] . ' ' . $items['mday'] . ' ' . $items['year'] . $time; } return $output; } // month only if ($variant == 'month') { if ($language == 'fr') { $output .= $months[$items['mon']] . ' ' . $items['year']; } else { $output .= $months[$items['mon']] . ' ' . $items['year']; } return $output; } // day only if ($variant == 'day') { // same year, don't mention it if ($items['year'] == $today['year']) { if ($language == 'fr') { $output .= $items['mday'] . ' ' . $months[$items['mon']]; } else { $output .= $months[$items['mon']] . ' ' . $items['mday']; } // different year } else { if ($language == 'fr') { $output .= $items['mday'] . ' ' . $months[$items['mon']] . ' ' . $items['year']; } else { $output .= $months[$items['mon']] . ' ' . $items['mday'] . ' ' . $items['year']; } } return $output; } // in a calendar if ($variant == 'calendar') { include_once $context['path_to_root'] . 'dates/dates.php'; $month_link =& Skin::build_link(Dates::get_url($items['year'] . '/' . $items['mon'], 'month'), $months[$items['mon']], 'basic', i18n::s('Calendar of this month')); $year_link =& Skin::build_link(Dates::get_url($items['year'], 'year'), $items['year'], 'basic', i18n::s('Calendar of this year')); if ($language == 'fr') { $output .= $items['mday'] . ' ' . $month_link . ' ' . $year_link; } else { $output .= $month_link . ' ' . $items['mday'] . ' ' . $year_link; } return $output; } // format a date according to ISO 8601 format if ($variant == 'iso8601') { $tzd = date('O', $actual_stamp); $tzd = $tzd[0] . str_pad((int) ($tzd / 100), 2, "0", STR_PAD_LEFT) . ':' . str_pad((int) ($tzd % 100), 2, "0", STR_PAD_LEFT); $output = date('Y-m-d\\TH:i:s', $actual_stamp) . $tzd; return $output; } // format a raw date if ($variant == 'yyyy-mm-dd') { $output = date('Y-m-d', $actual_stamp); return $output; } // plain date if ($variant == 'plain') { $output = date('M d Y H:i:s', $actual_stamp) . ' GMT'; return $output; } // less than 24 hours if ($items['yday'] == $today['yday'] && $items['year'] == $today['year']) { $time = date('H:i', $actual_stamp); if ($variant == 'no_hour' || preg_match('/00:00/', $time)) { $local['today_en'] = 'today'; $local['today_fr'] = 'aujourd\'hui'; } else { $trailer = ''; if (!$surfer_offset) { $trailer = ' GMT'; } $local['today_en'] = 'today at ' . date('h:i a', $actual_stamp) . $trailer; $local['today_fr'] = 'aujourd\'hui à ' . date('H:i', $actual_stamp) . $trailer; } $output = i18n::user('today'); return $output; // less than 48 hours } elseif ($items['yday'] + 1 == $today['yday'] && $items['year'] == $today['year']) { $time = date('H:i', $actual_stamp); if ($variant == 'no_hour' || preg_match('/00:00/', $time)) { $local['yesterday_en'] = 'yesterday'; $local['yesterday_fr'] = 'hier'; } else { $trailer = ''; if (!$surfer_offset) { $trailer = ' GMT'; } $local['yesterday_en'] = 'yesterday at ' . date('h:i a', $actual_stamp) . $trailer; $local['yesterday_fr'] = 'hier à ' . date('H:i', $actual_stamp) . $trailer; } $output = i18n::user('yesterday'); return $output; // this year } elseif ($stamp <= $now && $items['year'] == $today['year']) { if ($language == 'fr') { $output .= 'le ' . $items['mday'] . ' ' . $months[$items['mon']]; } else { $output .= 'on ' . $months[$items['mon']] . ' ' . $items['mday']; } return $output; // date in fr: le dd mmm yy } elseif ($language == 'fr') { $output .= 'le ' . $items['mday'] . ' ' . $months[$items['mon']] . ' ' . $items['year']; // date in en: on mmm dd yy } else { $output .= 'on ' . $months[$items['mon']] . ' ' . $items['mday'] . ' ' . $items['year']; } $output .= $time ? ' ' . $time : ''; return $output; }
protected function saveModel($event = false) { if (Input::get('id')) { $event = Events::find(Input::get('id')); } if (!$event) { $event = new Events(); } $event->name = Input::get('name'); $event->proposed_opening_time = Input::get('proposed_opening_time'); $event->proposed_closing_time = Input::get('proposed_closing_time'); $event->proposed_local_sponsors = Input::get('proposed_local_sponsors'); $event->promotional_activities = Input::get('promotional_activities'); $event->eval_financial_score = Input::get('eval_financial_score'); $event->eval_financial_text = Input::get('eval_financial_text'); $event->eval_marketing_score = Input::get('eval_marketing_score'); $event->eval_marketing_text = Input::get('eval_marketing_text'); $event->eval_travel_score = Input::get('eval_travel_score'); $event->eval_travel_text = Input::get('eval_travel_text'); $event->eval_production_score = Input::get('eval_production_score'); $event->eval_production_text = Input::get('eval_production_text'); $event->eval_extra_text = Input::get('eval_extra_text'); // new stuff 1 $event->curfew = Input::get('curfew'); $event->minimal_age_limit = Input::get('minimal_age_limit'); $event->alcohol_license = Input::get('alcohol_license'); $event->restrictions_on_merchandise_sales = Input::get('restrictions_on_merchandise_sales'); $event->sound_restrictions = Input::get('sound_restrictions'); $event->booked_for_setup_from = Input::get('booked_for_setup_from'); $event->booked_for_break_until = Input::get('booked_for_break_until'); // new stuff 2 $event->hotel1_name = Input::get('hotel1_name'); $event->hotel2_name = Input::get('hotel2_name'); $event->hotel1_website = Input::get('hotel1_website'); $event->hotel2_website = Input::get('hotel2_website'); $event->hotel1_travel_time_from_airport = Input::get('hotel1_travel_time_from_airport'); $event->hotel2_travel_time_from_airport = Input::get('hotel2_travel_time_from_airport'); $event->hotel1_travel_time_from_venue = Input::get('hotel1_travel_time_from_venue'); $event->hotel2_travel_time_from_venue = Input::get('hotel2_travel_time_from_venue'); $event->ticketsystem_enabled = Input::get('ticketsystem_enabled'); $event->currency_id = Input::get('currency_id'); $event->ticketsystem_recording_startdate = Input::get('ticketsystem_recording_startdate'); $event->ticketsystem_locked_for_promoter = Input::get('ticketsystem_locked_for_promoter'); $event->ticketsystem_autoremind_user_id = Input::get('ticketsystem_autoremind_user_id'); $event->ticketsystem_autoremind = Input::get('ticketsystem_autoremind'); $event->save(); if (Input::get('event_date')) { //error_log('Event date '.json_encode(Input::get('event_date'))); $input_date = strtotime(Input::get('event_date')); $date = $event->date()->first(); if ($date) { // update current date $date->datetime_start = date("Y-m-d H:i:s", $input_date); $date->datetime_end = date("Y-m-d H:i:s", $input_date); $date->update(); } else { // create new date $event_date = new Dates(['datetime_start' => date("Y-m-d H:i:s", $input_date), 'datetime_end' => date("Y-m-d H:i:s", $input_date)]); $event_date->save(); $event->date()->attach($event_date); } $response = Event::fire('event.datechanged', array($event)); } if (Input::get('contact_id')) { $event->contacts()->detach(Contact::find(Input::get('contact_id'))); $event->contacts()->attach(Contact::find(Input::get('contact_id'))); } if (Input::get('venue_id')) { $event->venues()->detach(Venue::find(Input::get('venue_id'))); $event->venues()->attach(Venue::find(Input::get('venue_id'))); } if (Input::get('company_id')) { $event->companies()->detach(Company::find(Input::get('company_id'))); $event->companies()->attach(Company::find(Input::get('company_id'))); } if (Input::get('promoter_id')) { $event->users()->detach(User::find(Input::get('promoter_id'))); $event->users()->attach(User::find(Input::get('promoter_id'))); } return $event; }
$context['text'] .= Skin::build_block(Skin::finalize_list($menu, 'menu_bar'), 'bottom'); } // // populate the extra panel // // commands for associates and editors if (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned()) { $context['page_tools'][] = Skin::build_link(Dates::get_url($id, 'edit'), i18n::s('Edit')); $context['page_tools'][] = Skin::build_link(Dates::get_url($id, 'delete'), i18n::s('Delete')); // commands for the author } elseif (Surfer::is($item['edit_id'])) { $context['page_tools'][] = Skin::build_link(Dates::get_url($id, 'edit'), i18n::s('Edit')); } // the navigation sidebar // // buttons to display previous and next pages, if any if (is_object($anchor)) { $neighbours = $anchor->get_neighbours('date', $item); $text .= Skin::neighbours($neighbours, 'sidebar'); } // build a nice sidebar box if ($text) { $text =& Skin::build_box(i18n::s('Navigation'), $text, 'neighbours', 'neighbours'); } $context['components']['neighbours'] = $text; // the referrals, if any, in a sidebar // $context['components']['referrals'] =& Skin::build_referrals(Dates::get_url($item['id'])); } // render the skin render_skin();
public function getDelete($idCourse, $idUserType, $idDate = '') { if ($idDate == '') { return Redirect::to(self::parseRoute($idCourse, $idUserType))->with('msg_error', Lang::get('messages.teachers_display_err')); } else { $date = Dates::find($idDate); $delete = Dates::destroy($idDate); if (!$delete) { return Redirect::to(self::parseRoute($idCourse, $idUserType))->with('msg_error', Lang::get('messages.dates_delete_err')); } else { return Redirect::to(self::parseRoute($idCourse, $idUserType))->with('msg_success', Lang::get('messages.dates_delete')); } } }
public function draw($class = false) { if ($class) { $class = ' ' . $class; } //start up if (self::$draggable) { array_unshift(self::$columns, ['head' => '', 'type' => 'draggy']); } if (self::$deletable) { self::$columns[] = ['head' => '', 'type' => 'delete']; } if (self::$grouped) { $last_group = ''; } $colspan = count(self::$columns); $rowspan = count(self::$rows); //build <thead> $columns = self::$columns; foreach ($columns as &$column) { if ($column['type'] == 'color') { $column['head'] = ' '; } $column = '<th class="' . self::column_class($column['type']) . '">' . $column['head'] . '</th>'; } $columns = implode($columns); $head = '<thead><tr>' . $columns . '</tr></thead>'; //build rows $bodies = $rows = []; foreach (self::$rows as $row) { $columns = []; $link = true; foreach (self::$columns as $column) { //handle groupings if (self::$grouped && $last_group != $row->{self::$grouped}) { $last_group = $row->{self::$grouped}; if (count($rows)) { $bodies[] = '<tbody>' . implode($rows) . '</tbody>'; } $bodies[] = '<tr class="group"><td colspan=' . $colspan . '">' . $last_group . '</td></tr>'; $rows = []; } //process value if necessary if ($column['type'] == 'draggy') { $value = '<i class="glyphicon glyphicon-align-justify"></i>'; } elseif ($column['type'] == 'delete') { $value = '<a href="' . $row->delete . '">' . (!$row->deleted_at ? '<i class="glyphicon glyphicon-ok-circle"></i>' : '<i class="glyphicon glyphicon-remove-circle"></i>') . '</a>'; } elseif ($column['type'] == 'image') { $value = '<a href="' . $row->link . '"><img src="' . $row->{$column['key'] . '_url'} . '" width="' . $column['width'] . '" height="' . $column['height'] . '"></a>'; } else { $value = Str::limit(strip_tags($row->{$column['key']})); if ($column['type'] == 'updated_at') { $value = Dates::relative($value); } elseif ($column['type'] == 'time') { $value = Dates::time($value); } elseif ($column['type'] == 'date') { $value = Dates::absolute($value); } elseif ($column['type'] == 'date-relative') { $value = Dates::relative($value); } elseif (in_array($column['type'], ['datetime', 'timestamp'])) { $value = Dates::absolute($value); } if (isset($row->link) && $link) { if ($column['type'] == 'color') { $value = '<a href="' . $row->link . '" style="background-color: ' . $value . '"></a>'; } else { if ($value == '') { $value = '…'; } $value = '<a href="' . $row->link . '">' . $value . '</a>'; $link = false; } } } //create cell $columns[] = '<td class="' . self::column_class($column['type']) . '">' . $value . '</td>'; } //create row $rows[] = '<tr' . (empty($row->id) ?: ' id="' . $row->id . '"') . (self::$deletable && $row->deleted_at ? ' class="inactive"' : '') . '>' . implode($columns) . '</tr>'; } $bodies[] = '<tbody>' . implode($rows) . '</tbody>'; //output return '<table id="foobar" class="table table-condensed' . $class . (self::$draggable ? ' draggable" data-draggable-url="' . self::$draggable : '') . '">' . $head . implode($bodies) . '</table>'; }
/** * a compact list of dates at some anchor * * @param string the anchor to consider (e.g., 'section:123') * @param int maximum number of items * @return array of ($prefix, $label, $suffix, $type, $icon, $hover) */ function render_list_for_anchor($anchor, $count = 7) { global $context; // we will build a list of dates include_once $context['path_to_root'] . 'dates/dates.php'; // list past dates as well if (preg_match('/\\bwith_past_dates\\b/i', $this->attributes['overlay_parameters'])) { $items = Dates::list_for_anchor($anchor, 0, $count, 'compact'); } else { $items = Dates::list_future_for_anchor($anchor, 0, $count, 'compact'); } // we return an array return $items; }
/** * dynamically generate the page * * @see skins/index.php */ function send_body() { global $context, $action; // check that the user is an admin, but only if there is at least one user record $query = "SELECT count(*) FROM " . SQL::table_name('users'); if (!Surfer::is_associate() && SQL::query($query) !== FALSE) { Safe::header('Status: 401 Unauthorized', TRUE, 401); echo '<p>' . i18n::s('You are not allowed to perform this operation.') . "</p>\n"; return; } // log the current surfer as an associate if not yet the case if (!Surfer::is_associate()) { $fields = array(); $fields['id'] = 1; $fields['nick_name'] = 'admin'; $fields['email'] = ''; $fields['capability'] = 'A'; Surfer::set($fields); echo '<p>' . i18n::s('You have associate privilege') . '</p>'; } // check every table of the database if ($action == 'build') { // maybe we will have to switch the server off $temporary_off = FALSE; // ensure nobody else will access the database during the operation if (file_exists('../parameters/switch.on')) { if (Safe::rename($context['path_to_root'] . 'parameters/switch.on', $context['path_to_root'] . 'parameters/switch.off')) { echo BR . i18n::s('The server has been switched off.'); $temporary_off = TRUE; } // let concurrent on-going transactions finish properly Safe::sleep(3); // first installation } elseif (!file_exists('../parameters/switch.off')) { echo '<p>' . i18n::s('Review provided information and go to the bottom of the page to move forward.') . "</a></p>\n"; } // ensure utf8 character set for this database $query = "ALTER DATABASE `" . $context['database'] . "` DEFAULT CHARACTER SET utf8"; SQL::query($query); // create tables for users echo Users::setup(); // create tables for activities echo Activities::setup(); // create tables for notifications include_once '../users/notifications.php'; echo Notifications::setup(); // create tables for messages echo Mailer::setup(); // create tables for visits include_once '../users/visits.php'; echo Visits::setup(); // create tables for sections echo Sections::setup(); // create tables for articles echo Articles::setup(); // create tables for images include_once '../images/images.php'; echo Images::setup(); // create tables for tables include_once '../tables/tables.php'; echo Tables::setup(); // create tables for files echo Files::setup(); // create tables for links include_once '../links/links.php'; echo Links::setup(); // create tables for locations include_once '../locations/locations.php'; echo Locations::setup(); // create tables for comments include_once '../comments/comments.php'; echo Comments::setup(); // create tables for categories echo Categories::setup(); // create tables for members include_once '../shared/members.php'; echo Members::setup(); // create tables for dates include_once '../dates/dates.php'; echo Dates::setup(); // create tables for servers include_once '../servers/servers.php'; echo Servers::setup(); // create tables for versions include_once '../versions/versions.php'; echo Versions::setup(); // create tables for enrolments include_once '../shared/enrolments.php'; echo Enrolments::setup(); // create tables for values include_once '../shared/values.php'; echo Values::setup(); // create tables for the cache echo Cache::setup(); // create tables for the php documentation include_once '../scripts/phpdoc.php'; echo PhpDoc::setup(); // the setup hook if (is_callable(array('Hooks', 'include_scripts'))) { echo Hooks::include_scripts('control/setup.php'); } // reopen the server for others if ($temporary_off && Safe::rename($context['path_to_root'] . 'parameters/switch.off', $context['path_to_root'] . 'parameters/switch.on')) { echo '<p>' . i18n::s('The server has been switched on.') . '</p>'; } // in the middle of an update if (file_exists('../parameters/switch.off')) { echo Skin::build_block('<form method="get" action="../scripts/run_once.php">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Run one-time scripts and go to the Control Panel')) . '</p>' . "\n" . '</form>', 'bottom'); // this may take several minutes echo '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>'; // populate the database on first installation } elseif (!file_exists('../parameters/switch.on')) { echo Skin::build_block('<form method="get" action="populate.php">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Initialize the database')) . '</p>' . "\n" . '</form>', 'bottom'); // or back to the control panel } else { $menu = array('control/' => i18n::s('Control Panel')); echo Skin::build_list($menu, 'menu_bar'); } // clear the cache Cache::clear(); // remember the change $label = i18n::c('The database has been optimised'); Logger::remember('control/setup.php: ' . $label); // ask for confirmation } else { // the splash message echo '<p>' . i18n::s('This script will check the structure of the database and optimize data storage:') . '</p>' . "\n" . '<ul>' . "\n" . '<li>' . i18n::s('Missing tables will be created, if necessary.') . '</li>' . "\n" . '<li>' . i18n::s('Some columns may be created or converted if their type has evolved.') . '</li>' . "\n" . '<li>' . i18n::s('All indexes will be (re)built.') . '</li>' . "\n" . '<li>' . i18n::s('Data files will be optimized as well.') . '</li>' . "\n" . '</ul>' . "\n"; // the submit button echo '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . Skin::build_submit_button(i18n::s('Ensure the database structure is accurate'), NULL, NULL, 'confirmed') . '<input type="hidden" name="action" value="build" />' . '</p></form>'; // the script used for form handling at the browser Page::insert_script('$("#confirmed").focus();'); // this may take several minutes echo '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>'; } }
public static function type_interval($field, $container = null, $output = 'string', $html = array()) { $field = self::parse($field, $container); if (is_scalar($field)) { return false; } $min = clone $field; $min->_id[] = 'min'; $min->_name[] = 'min'; $min->type = 'date'; $min->{'data-type'} = 'min'; $min->value = ''; $min->class = array(); $min->placeholder = esc_attr__('yyyy-mm-dd', self::plugin); $max = clone $field; $max->_id[] = 'max'; $max->_name[] = 'max'; $max->type = 'date'; $max->{'data-type'} = 'max'; $max->class = array(); $max->value = ''; $max->placeholder = esc_attr__('yyyy-mm-dd', self::plugin); $interval = clone $field; $interval->_id[] = 'name'; $interval->_name[] = 'name'; $interval->type = 'dropdown'; $interval->class = array(); $interval->{'data-placeholder'} = esc_attr__('Select an Interval', self::plugin); $interval->options = Dates::get_intervals(); $content[] = self::type_dropdown($interval, null, 'string'); $content[] = self::type_date($min, null, 'string'); $content[] = '<div class="dashicons dashicons-arrow-right-alt2 dashicon-date" style="display: inline-block;"></div>'; $content[] = self::type_date($max, null, 'string'); if (is_a($container, __CLASS__)) { $html[] = $container->build($content); } else { $html = $content; } if ('string' === $output) { return implode("\r\n", $html); } else { return $html; } }
public function delete($object_name, $instance_id) { $object = DB::table(DB_OBJECTS)->where('name', $object_name)->first(); //toggle instance with active or inactive $deleted_at = Input::get('active') == 1 ? null : new DateTime(); DB::table($object->name)->where('id', $instance_id)->update(array('deleted_at' => $deleted_at, 'updated_at' => new DateTime(), 'updated_by' => Auth::user()->id)); //update object meta DB::table(DB_OBJECTS)->where('id', $object->id)->update(array('count' => DB::table($object->name)->whereNull('deleted_at')->count(), 'updated_at' => new DateTime(), 'updated_by' => Auth::user()->id)); $updated = DB::table($object->name)->where('id', $instance_id)->pluck('updated_at'); return Dates::relative($updated); }