本文整理汇总了PHP中DateTimeObj类的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeObj类的具体用法?PHP DateTimeObj怎么用?PHP DateTimeObj使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DateTimeObj类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __switchboard
function __switchboard($type)
{
$this->_page = isset($this->_context[0]) ? $this->_context[0] : 'view';
$this->_id = !empty($this->_context[1]) && is_numeric($this->_context[1]) ? $this->_context[1] : 0;
$this->_flag = $this->_context[2];
// Notices
if (isset($this->_flag)) {
$result = null;
switch ($this->_flag) {
case 'edited':
$result = __('Category updated at %1$s.');
break;
case 'deleted':
$result = __('Category deleted');
break;
case 'created':
$result = __('Category created at %1$s. <a href="%2$s">Create another?</a>');
break;
}
if ($result) {
$this->pageAlert(__($result, array(DateTimeObj::get(__SYM_TIME_FORMAT__), BASE_URL . '/list/new/' . $this->_id)), Alert::SUCCESS);
}
}
$function = ($type == 'action' ? '__action' : '__view') . ($this->_page == 'view' ? 'Index' : ucfirst($this->_page));
if (!method_exists($this, $function)) {
if ($type == 'action') {
return;
}
$this->_Parent->errorPageNotFound();
}
return $this->{$function}();
}
示例2: lastUpdateFilterList
public static function lastUpdateFilterList()
{
if (!file_exists(WORKSPACE . self::$file)) {
return false;
}
return DateTimeObj::get(DateTimeObj::getSetting('datetime_format'), filemtime(WORKSPACE . self::$file));
}
示例3: initializeContext
/**
* Initialize contextual XML (formerly params)
*/
public function initializeContext()
{
$this->View->context->register(array('system' => array('site-name' => Symphony::Configuration()->core()->symphony->sitename, 'site-url' => URL, 'admin-url' => URL . '/symphony', 'symphony-version' => Symphony::Configuration()->core()->symphony->version), 'date' => array('today' => DateTimeObj::get('Y-m-d'), 'current-time' => DateTimeObj::get('H:i'), 'this-year' => DateTimeObj::get('Y'), 'this-month' => DateTimeObj::get('m'), 'this-day' => DateTimeObj::get('d'), 'timezone' => date_default_timezone_get())));
if ($this->User) {
$this->View->context->register(array('session' => self::instance()->User->fields()));
}
}
示例4: processDependencies
public function processDependencies(array $params = array())
{
$datasources = $this->getDependencies();
if (!is_array($datasources) || empty($datasources)) {
return;
}
$datasources = array_map(create_function('$a', "return str_replace('\$ds-', '', \$a);"), $datasources);
$datasources = array_map(create_function('$a', "return str_replace('-', '_', \$a);"), $datasources);
$env = array('today' => DateTimeObj::get('Y-m-d'), 'current-time' => DateTimeObj::get('H:i'), 'this-year' => DateTimeObj::get('Y'), 'this-month' => DateTimeObj::get('m'), 'this-day' => DateTimeObj::get('d'), 'timezone' => DateTimeObj::get('P'), 'enm-newsletter-id' => $this->newsletter_id);
$this->_env['param'] = $env;
$this->_env['env']['pool'] = $params;
$dependencies = array();
foreach ($datasources as $handle) {
$profiler = Symphony::Profiler();
$profiler->seed();
$pool[$handle] =& DatasourceManager::create($handle, NULL, false);
$dependencies[$handle] = $pool[$handle]->getDependencies();
}
$dsOrder = $this->__findDatasourceOrder($dependencies);
foreach ($dsOrder as $handle) {
$ds = $pool[$handle];
$ds->processParameters($this->_env);
$ds->grab($this->_env['env']['pool']);
unset($ds);
}
$this->processParameters($this->_env);
}
示例5: handleShutdown
function handleShutdown()
{
$error = error_get_last();
if ($error !== NULL && $error['type'] <= 1) {
file_put_contents(DOCROOT . '/manifest/newsletter-log.txt', '[' . DateTimeObj::get('Y/m/d H:i:s') . '] pid: ' . getmypid() . ' - ' . $error['message'] . ' in file: ' . $error['file'] . ' on line ' . $error['line'] . "\r\n", FILE_APPEND);
}
}
示例6: view
public function view()
{
// Ensure we have been set $_POST data from Members events
if (!array_key_exists('members', $_POST)) {
$this->_status = AjaxPage::STATUS_BAD;
return;
} else {
if (!is_writable(CONFIG)) {
$this->_status = AjaxPage::STATUS_BAD;
$this->_Result->appendChild(new XMLElement('message', __('The Symphony configuration file, <code>/manifest/config.php</code>, is not writable. You will not be able to save changes to preferences.')));
return;
}
}
$settings = $_POST['members'];
// Generate Recovery Code
if (isset($settings['generate-recovery-code-template'])) {
Symphony::Configuration()->set('generate-recovery-code-template', implode(',', array_filter($settings['generate-recovery-code-template'])), 'members');
} else {
if ($settings['event'] == 'generate-recovery-code') {
Symphony::Configuration()->remove('generate-recovery-code-template', 'members');
}
}
// Reset Password
if (isset($settings['reset-password-template'])) {
Symphony::Configuration()->set('reset-password-template', implode(',', array_filter($settings['reset-password-template'])), 'members');
} else {
if ($settings['event'] == 'reset-password') {
Symphony::Configuration()->remove('reset-password-template', 'members');
}
}
if ($settings['event'] == 'reset-password') {
Symphony::Configuration()->set('reset-password-auto-login', $settings['auto-login'], 'members');
}
// Regenerate Activation Code
if (isset($settings['regenerate-activation-code-template'])) {
Symphony::Configuration()->set('regenerate-activation-code-template', implode(',', array_filter($settings['regenerate-activation-code-template'])), 'members');
} else {
if ($settings['event'] == 'regenerate-activation-code') {
Symphony::Configuration()->remove('regenerate-activation-code-template', 'members');
}
}
// Activate Account
if (isset($settings['activate-account-template'])) {
Symphony::Configuration()->set('activate-account-template', implode(',', array_filter($settings['activate-account-template'])), 'members');
} else {
if ($settings['event'] == 'activate-account') {
Symphony::Configuration()->remove('activate-account-template', 'members');
}
}
if ($settings['event'] == 'activate-account') {
Symphony::Configuration()->set('activate-account-auto-login', $settings['auto-login'], 'members');
}
// Return successful
if (Administration::instance()->saveConfig()) {
$this->_status = AjaxPage::STATUS_OK;
$this->_Result->appendChild(new XMLElement('message', __('Preferences saved.')));
$this->_Result->appendChild(new XMLElement('timestamp', '<![CDATA[' . DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__) . ']]>'));
}
}
示例7: processRecordGroup
function processRecordGroup(&$wrapper, $element, $group, $ds, &$Parent, &$entryManager, &$fieldPool, &$param_pool, $param_output_only = false)
{
$xGroup = new XMLElement($element, NULL, $group['attr']);
$key = 'ds-' . $ds->dsParamROOTELEMENT;
if (is_array($group['records']) && !empty($group['records'])) {
foreach ($group['records'] as $entry) {
$data = $entry->getData();
$fields = array();
$xEntry = new XMLElement('entry');
$xEntry->setAttribute('id', $entry->get('id'));
$associated_entry_counts = $entry->fetchAllAssociatedEntryCounts();
if (is_array($associated_entry_counts) && !empty($associated_entry_counts)) {
foreach ($associated_entry_counts as $section_id => $count) {
$section_handle = $Parent->Database->fetchVar('handle', 0, "SELECT `handle` FROM `tbl_sections` WHERE `id` = '{$section_id}' LIMIT 1");
$xEntry->setAttribute($section_handle, '' . $count . '');
}
}
if (isset($ds->dsParamPARAMOUTPUT)) {
if ($ds->dsParamPARAMOUTPUT == 'system:id') {
$param_pool[$key][] = $entry->get('id');
} elseif ($ds->dsParamPARAMOUTPUT == 'system:date') {
$param_pool[$key][] = DateTimeObj::get('c', strtotime($entry->creationDate));
} elseif ($ds->dsParamPARAMOUTPUT == 'system:author') {
$param_pool[$key][] = $entry->get('author_id');
}
}
foreach ($data as $field_id => $values) {
if (!isset($fieldPool[$field_id]) || !is_object($fieldPool[$field_id])) {
$fieldPool[$field_id] =& $entryManager->fieldManager->fetch($field_id);
}
if (isset($ds->dsParamPARAMOUTPUT) && $ds->dsParamPARAMOUTPUT == $fieldPool[$field_id]->get('element_name')) {
$param_pool[$key][] = $fieldPool[$field_id]->getParameterPoolValue($values);
}
if (!$param_output_only) {
foreach ($ds->dsParamINCLUDEDELEMENTS as $handle) {
list($handle, $mode) = preg_split('/\\s*:\\s*/', $handle, 2);
if ($fieldPool[$field_id]->get('element_name') == $handle) {
$fieldPool[$field_id]->appendFormattedElement($xEntry, $values, $ds->dsParamHTMLENCODE ? true : false, $mode);
}
}
}
}
if (!$param_output_only) {
$xGroup->appendChild($xEntry);
}
}
}
if (is_array($group['groups']) && !empty($group['groups'])) {
foreach ($group['groups'] as $element => $group) {
foreach ($group as $g) {
processRecordGroup($xGroup, $element, $g, $ds, $Parent, $entryManager, $fieldPool, $param_pool, $param_output_only);
}
}
}
if (!$param_output_only) {
$wrapper->appendChild($xGroup);
}
return;
}
示例8: getValuesFromXML
function getValuesFromXML()
{
$xml_location = $this->get('xml_location');
if (General::validateURL($xml_location) != '') {
// is a URL, check cache
$cache_id = md5($xml_location);
$cache = new Cacheable($this->_Parent->_Parent->Database);
$cachedData = $cache->check($cache_id);
$creation = DateTimeObj::get('c');
if (!$cachedData || time() - $cachedData['creation'] > 5 * 60) {
if (Mutex::acquire($cache_id, 6, TMP)) {
$ch = new Gateway();
$ch->init();
$ch->setopt('URL', $xml_location);
$ch->setopt('TIMEOUT', 6);
$xml = $ch->exec();
$writeToCache = true;
Mutex::release($cache_id, TMP);
$xml = trim($xml);
if (empty($xml) && $cachedData) {
$xml = $cachedData['data'];
}
} elseif ($cachedData) {
$xml = $cachedData['data'];
}
} else {
$xml = $cachedData['data'];
}
$xml = simplexml_load_string($xml);
} elseif (substr($xml_location, 0, 1) == '/') {
// relative to DOCROOT
$xml = simplexml_load_file(DOCROOT . $this->get('xml_location'));
} else {
// in extension's /xml folder
$xml = simplexml_load_file(EXTENSIONS . '/xml_selectbox/xml/' . $this->get('xml_location'));
}
if (!$xml) {
return;
}
$items = $xml->xpath($this->get('item_xpath'));
$options = array();
foreach ($items as $item) {
$option = array();
$text_xpath = $item->xpath($this->get('text_xpath'));
$option['text'] = General::sanitize((string) $text_xpath[0]);
if ($this->get('value_xpath') != '') {
$value_xpath = $item->xpath($this->get('value_xpath'));
$option['value'] = General::sanitize((string) $value_xpath[0]);
}
if ((string) $option['value'] == '') {
$option['value'] = $option['text'];
}
$options[] = $option;
}
return $options;
}
示例9: write
public function write()
{
$section = $this->section->get('object');
$entry = null;
$entry_data = array();
// If it's an existing entry we want to load that entry object
foreach ($this->writes as $write) {
$field = $write->get('object');
$field_data = $write->get('data');
if ($field == SymQuery::SYSTEM_ID) {
$existing = SymQuery::$em->fetch($field_data, $section->get('id'));
if (is_array($existing) && !empty($existing)) {
$entry = current($existing);
break;
}
}
}
// If $entry is null, then it's a new entry, so fill it with some default metadata
if (is_null($entry)) {
$entry = SymQuery::$em->create();
$author = SymQuery::$symphony->Author;
// Build default entry data:
$entry->set('section_id', $section->get('id'));
if (is_object($author)) {
$entry->set('author_id', $author->get('id'));
}
$entry->set('creation_date', DateTimeObj::get('Y-m-d H:i:s'));
$entry->set('creation_date_gmt', DateTimeObj::getGMT('Y-m-d H:i:s'));
}
foreach ($this->writes as $write) {
$field = $write->get('object');
$field_data = $write->get('data');
if ($field instanceof Field) {
$field_handle = $field->get('element_name');
$entry_data[$field_handle] = $field_data;
}
}
if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($entry_data, $errors, $entry->get('id') ? true : false)) {
$validation_errors = array();
foreach ($errors as $field_id => $message) {
if (!in_array($field_id, SymQuery::$field_cache)) {
SymQuery::$field_cache[$field_id] = SymQuery::$fm->fetch($field_id, $section->get('id'));
}
$validation_errors[$field_id] = array('field' => SymQuery::$field_cache[$field_id], 'error' => $message);
}
$error = new SymWriteException('Unable to validate entry.');
$error->setValidationErrors($validation_errors);
throw $error;
}
if (__ENTRY_OK__ != $entry->setDataFromPost($entry_data, $error, false, $entry->get('id') ? true : false)) {
throw new SymQueryException(sprintf('Unable to save entry: %s', $error));
}
$entry->commit();
return $entry;
}
示例10: appendScriptToHead
public function appendScriptToHead($context)
{
$this->static_section_name = '';
$entryManager = new EntryManager($this->_Parent);
$sections = $this->_Parent->Database->fetch("SELECT section_id AS id, handle FROM tbl_fields_static_section LEFT JOIN tbl_sections ON tbl_fields_static_section.section_id = tbl_sections.id");
$this->section_data = array('handles' => array(), 'entries' => array());
foreach ($sections as $key => $value) {
$this->section_data['handles'][] = $value['handle'];
$result = $entryManager->fetch(NULL, $value['id'], NULL, NULL, NULL, NULL, false, false);
if (count($result) > 0) {
$this->section_data['entries'][] = $result[0]['id'];
} else {
$this->section_data['entries'][] = NULL;
}
}
$this->_page = Administration::instance()->Page;
$section_handle = $this->_page->_context['section_handle'];
$context = $this->_page->_context['page'];
$url_entry = $this->_page->_context['entry_id'];
$flag = $this->_page->_context['flag'];
if (isset($section_handle)) {
$section = $this->_Parent->Database->fetchRow(0, "SELECT id, name FROM tbl_sections WHERE handle='{$section_handle}'");
$field = $this->_Parent->Database->fetchRow(0, "SELECT id FROM tbl_fields_static_section WHERE section_id=" . $section['id']);
if ($field) {
$entry = $this->getSectionEntry($section_handle);
if ($context == 'new' && $entry) {
redirect(URL . '/symphony/publish/' . $section_handle . '/edit/' . $entry . '/');
}
if ($context == 'index') {
if ($entry) {
redirect(URL . '/symphony/publish/' . $section_handle . '/edit/' . $entry . '/');
} else {
redirect(URL . '/symphony/publish/' . $section_handle . '/new/');
}
}
if ($context == 'edit') {
if (!$entry) {
redirect(URL . '/symphony/publish/' . $section_handle . '/new/');
}
if ($url_entry != $entry) {
redirect(URL . '/symphony/publish/' . $section_handle . '/edit/' . $entry . '/');
}
}
if ($flag == 'saved' || $flag == 'created') {
$flag_msg = 'Entry updated at %1$s.';
if ($flag == 'created') {
$flag_msg = 'Entry created at %1$s.';
}
$this->_page->pageAlert(__($flag_msg, array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__))), Alert::SUCCESS);
}
$this->static_section_name = $section['name'];
}
}
}
示例11: parseDate
private function parseDate($row)
{
$fieldname = $this->getFieldName();
if (!empty($row) && isset($row[$fieldname])) {
$value = $row[$fieldname] . ' Etc/UTC';
} else {
$value = DateTimeObj::getGMT('Y-m-d H:i:s') . ' Etc/UTC';
}
$date = DateTimeObj::parse($value);
return $date;
}
示例12: getMetaInfo
public static function getMetaInfo($file, $type)
{
$meta = array();
if (!file_exists($file) || !is_readable($file)) {
return $meta;
}
$meta['creation'] = DateTimeObj::get('c', filemtime($file));
if (General::in_iarray($type, fieldUpload::$imageMimeTypes) && ($array = @getimagesize($file))) {
$meta['width'] = $array[0];
$meta['height'] = $array[1];
}
return $meta;
}
示例13: view
public function view()
{
$this->setPageType('table');
$this->setTitle('Symphony – Cron');
$this->appendSubheading('Cron Tasks', [Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a cron task'), 'create button', null, ['accesskey' => 'c'])]);
Extension_Cron::init();
$iterator = new Lib\CronTaskIterator(realpath(MANIFEST . '/cron'), Symphony::Database());
$aTableHead = [['Name', 'col'], ['Description', 'col'], ['Enabled', 'col'], ['Last Executed', 'col'], ['Next Execution', 'col'], ['Last Output', 'col']];
$aTableBody = [];
if ($iterator->count() == 0) {
$aTableBody = [Widget::TableRow([Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))], 'odd')];
} else {
foreach ($iterator as $ii => $task) {
$td1 = Widget::TableData(Widget::Anchor($task->name, sprintf('%sedit/%s/', Administration::instance()->getCurrentPageURL(), $task->filename)));
$td1->appendChild(Widget::Label(__('Select Task %s', [$task->filename]), null, 'accessible', null, array('for' => 'task-' . $ii)));
$td1->appendChild(Widget::Input('items[' . $task->filename . ']', 'on', 'checkbox', array('id' => 'task-' . $ii)));
$td2 = Widget::TableData(is_null($task->description) ? 'None' : $task->description);
if (is_null($task->description)) {
$td2->setAttribute('class', 'inactive');
}
$td3 = Widget::TableData($task->enabledReal() == true ? 'Yes' : 'No');
if ($task->enabled == false) {
$td3->setAttribute('class', 'inactive');
}
$td4 = Widget::TableData(!is_null($task->getLastExecutionTimestamp()) ? DateTimeObj::get(__SYM_DATETIME_FORMAT__, $task->getLastExecutionTimestamp()) : 'Unknown');
if (is_null($task->getLastExecutionTimestamp())) {
$td4->setAttribute('class', 'inactive');
}
$td5 = Widget::TableData(!is_null($task->nextExecution()) ? self::__minutesToHumanReadable(ceil($task->nextExecution() * (1 / 60))) : 'Unknown');
if (is_null($task->nextExecution()) || $task->enabledReal() == false) {
$td5->setAttribute('class', 'inactive');
}
if (is_null($task->getLog())) {
$td6 = Widget::TableData('None', 'inactive');
} else {
$td6 = Widget::TableData(Widget::Anchor('view', sprintf('%slog/%s/', Administration::instance()->getCurrentPageURL(), $task->filename)));
}
$aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5, $td6));
}
}
$table = Widget::Table(Widget::TableHead($aTableHead), null, Widget::TableBody($aTableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive'));
$this->Form->appendChild($table);
$tableActions = new XMLElement('div');
$tableActions->setAttribute('class', 'actions');
$options = [[null, false, __('With Selected...')], ['enable', false, __('Enable')], ['disable', false, __('Disable')], ['delete', false, __('Delete'), 'confirm', null, ['data-message' => __('Are you sure you want to delete the selected tasks?')]]];
$tableActions->appendChild(Widget::Apply($options));
$this->Form->appendChild($tableActions);
}
示例14: __construct
function __construct(&$parent)
{
$this->_Parent = $parent;
$this->_fields = array();
$this->_required = false;
$this->_showcolumn = true;
$this->_handle = strtolower(get_class($this)) == 'field' ? 'field' : strtolower(substr(get_class($this), 5));
if (class_exists('Administration')) {
$this->_engine = Administration::instance();
} elseif (class_exists('Frontend')) {
$this->_engine = Frontend::instance();
} else {
trigger_error(__('No suitable engine object found'), E_USER_ERROR);
}
$this->creationDate = DateTimeObj::getGMT('c');
$this->Database = Symphony::Database();
}
示例15: login
/**
* Overload the Symphony::login function to bypass some code that
* forces use of the Administration class (which of course is not
* available in Shell). Hopefully this is fixed in the core Symphony code
*
*/
public static function login($username, $password, $isHash = false)
{
$username = self::Database()->cleanValue($username);
$password = self::Database()->cleanValue($password);
if (strlen(trim($username)) > 0 && strlen(trim($password)) > 0) {
$author = \AuthorManager::fetch('id', 'ASC', 1, null, sprintf("\n `username` = '%s'\n ", $username));
if (!empty($author) && \Cryptography::compare($password, current($author)->get('password'), $isHash)) {
self::$Author = current($author);
// Only migrate hashes if there is no update available as the update might change the tbl_authors table.
if (\Cryptography::requiresMigration(self::$Author->get('password'))) {
throw new ShellException('User details require updating. Please login to the admin interface.');
}
self::$Cookie->set('username', $username);
self::$Cookie->set('pass', self::$Author->get('password'));
self::Database()->update(array('last_seen' => \DateTimeObj::get('Y-m-d H:i:s')), 'tbl_authors', sprintf(" `id` = %d", self::$Author->get('id')));
return true;
}
}
return false;
}