本文整理汇总了PHP中Jaws_Date类的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_Date类的具体用法?PHP Jaws_Date怎么用?PHP Jaws_Date使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Jaws_Date类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetYearEvents
/**
* Fetches number of events per month
*
* @access public
* @param int $user User ID
* @return array Query result
*/
function GetYearEvents($user = null, $shared = null, $foreign = null, $year)
{
$table = Jaws_ORM::getInstance()->table('ec_events as events');
$jdate = Jaws_Date::getInstance();
$eventsByMonth = array();
for ($m = 1; $m <= 12; $m++) {
$table->reset();
$table->select('events.id');
$table->join('ec_recurrences as recs', 'events.id', 'recs.event');
$table->join('ec_users', 'events.id', 'ec_users.event');
if ($user !== null) {
$table->where('ec_users.user', $user)->and();
}
if ($shared === true) {
$table->where('shared', true)->and();
$table->where('events.user', $user)->and();
}
if ($foreign === true) {
$table->where('ec_users.owner', $user, '<>')->and();
}
$daysInMonth = $jdate->monthDays($year, $m);
$start = $jdate->ToBaseDate($year, $m, 1);
$start = $GLOBALS['app']->UserTime2UTC($start['timestamp']);
$stop = $jdate->ToBaseDate($year, $m, $daysInMonth, 23, 59, 59);
$stop = $GLOBALS['app']->UserTime2UTC($stop['timestamp']);
$table->where('recs.start_time', $stop, '<')->and();
$table->where('recs.stop_time', $start, '>');
$table->groupBy('events.id');
$eventsByMonth[$m] = count($table->fetchAll());
}
return $eventsByMonth;
}
示例2: GetOnlineUsers
/**
* Prepares list of online users for datagrid
*
* @access public
* @return array Grid data
*/
function GetOnlineUsers()
{
$filters = jaws()->request->fetch(array('active', 'logged', 'session_type', 'offset'), 'post');
$filters['active'] = $filters['active'] == '-1' ? null : (bool) $filters['active'];
$filters['logged'] = $filters['logged'] == '-1' ? null : (bool) $filters['logged'];
$filters['type'] = $filters['session_type'] == '-1' ? null : $filters['session_type'];
$filters['offset'] = (int) $filters['offset'];
$sessions = $GLOBALS['app']->Session->GetSessions($filters['active'], $filters['logged'], $filters['type'], 50, $filters['offset']);
if (Jaws_Error::IsError($sessions)) {
return array();
}
$retData = array();
$objDate = Jaws_Date::getInstance();
foreach ($sessions as $session) {
$usrData = array();
$usrData['__KEY__'] = $session['sid'];
if (empty($session['username'])) {
$usrData['username'] = _t('USERS_ONLINE_ANONY');
} else {
$uProfile =& Piwi::CreateWidget('Link', $session['username'], $this->gadget->urlMap('Profile', array('user' => $session['username'])));
$usrData['username'] = $uProfile->Get();
}
$usrData['nickname'] = $session['nickname'];
$usrData['superadmin'] = $session['superadmin'] ? _t('GLOBAL_YES') : _t('GLOBAL_NO');
$usrData['ip'] = "<abbr title='{$session['agent']}'>" . long2ip($session['ip']) . "</abbr>";
$usrData['type'] = $session['type'];
if ($session['online']) {
$usrData['last_activetime'] = "<label class='lastactive' title='" . _t('USERS_ONLINE_ACTIVE') . "'>" . $objDate->Format($session['updatetime'], 'Y-m-d H:i') . "</label>";
} else {
$usrData['last_activetime'] = "<s class='lastactive' title='" . _t('USERS_ONLINE_INACTIVE') . "'>" . $objDate->Format($session['updatetime'], 'Y-m-d H:i') . "</s>";
}
$retData[] = $usrData;
}
return $retData;
}
示例3: Execute
/**
* Fetches files having specific tag
*
* @access public
* @param string $action Action name
* @param array $references Array of References
* @return array An array of entries that matches a certain pattern
*/
function Execute($action, $references)
{
if (empty($action) || !is_array($references) || empty($references)) {
return false;
}
$table = Jaws_ORM::getInstance()->table('directory');
$table->select('id:integer', 'title', 'description', 'update_time');
$result = $table->where('hidden', false)->and()->where('id', $references, 'in')->fetchAll();
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$files = array();
foreach ($result as $r) {
$file = array();
$file['title'] = $r['title'];
$file['url'] = $this->gadget->urlMap('Directory', array('id' => $r['id']));
$file['outer'] = false;
$file['image'] = 'gadgets/Directory/Resources/images/logo.png';
$file['snippet'] = $r['description'];
$file['date'] = $date->ToISO($r['update_time']);
$files[$r['id']] = $file;
}
return $files;
}
示例4: Execute
/**
* Returns an array with the results of a tag content
*
* @access public
* @param string $action Action name
* @param array $references Array of References
* @return array An array of entries that matches a certain pattern
*/
function Execute($action, $references)
{
if (empty($action) || !is_array($references) || empty($references)) {
return false;
}
$table = Jaws_ORM::getInstance()->table('linkdump_links');
$table->select('id:integer', 'title', 'description', 'updatetime');
$result = $table->where('id', $references, 'in')->fetchAll();
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$links = array();
foreach ($result as $r) {
$link = array();
$link['title'] = $r['title'];
$link['url'] = $this->gadget->urlMap('Link', array('id' => $r['id']));
$link['outer'] = true;
$link['image'] = 'gadgets/LinkDump/Resources/images/logo.png';
$link['snippet'] = $r['description'];
$link['date'] = $date->ToISO($r['updatetime']);
$links[$r['id']] = $link;
}
return $links;
}
示例5: GetActivitiesCount
/**
* Get activities count
*
* @access public
* @param array $filters
* @return bool True or error
*/
function GetActivitiesCount($filters = null)
{
$saTable = Jaws_ORM::getInstance()->table('activities')->select('count(id):integer');
if (!empty($filters) && count($filters) > 0) {
// from_date
if (isset($filters['from_date']) && !empty($filters['from_date'])) {
if (!is_numeric($filters['from_date'])) {
$objDate = Jaws_Date::getInstance();
$filters['from_date'] = $GLOBALS['app']->UserTime2UTC((int) $objDate->ToBaseDate(preg_split('/[- :]/', $filters['from_date']), 'U'));
}
$saTable->and()->where('date', $filters['from_date'], '>=');
}
// to_date
if (isset($filters['to_date']) && !empty($filters['to_date'])) {
if (!is_numeric($filters['to_date'])) {
$objDate = Jaws_Date::getInstance();
$filters['to_date'] = $GLOBALS['app']->UserTime2UTC((int) $objDate->ToBaseDate(preg_split('/[- :]/', $filters['to_date']), 'U'));
}
$saTable->and()->where('date', $filters['to_date'], '<=');
}
// gadget
if (isset($filters['gadget']) && !empty($filters['gadget'])) {
$saTable->and()->where('gadget', $filters['gadget']);
}
// domain
if ($filters['domain'] != '-1') {
$saTable->and()->where('domain', $filters['domain']);
}
// sync
if (isset($filters['sync'])) {
$saTable->and()->where('sync', (bool) $filters['sync']);
}
}
return $saTable->fetchOne();
}
示例6: ShowTrackbacks
/**
* Shows existing trackbacks for a given entry
*
* @access public
* @param int $id entry id
* @return string XHTML template content
*/
function ShowTrackbacks($id)
{
if ($this->gadget->registry->fetch('trackback') == 'true') {
$model = $this->gadget->model->load('Trackbacks');
$trackbacks = $model->GetTrackbacks($id);
$tpl = $this->gadget->template->load('Trackbacks.html');
$tpl->SetBlock('trackbacks');
$tburi = $this->gadget->urlMap('Trackback', array('id' => $id), true);
$tpl->SetVariable('TrackbackURI', $tburi);
if (!Jaws_Error::IsError($trackbacks)) {
$date = Jaws_Date::getInstance();
foreach ($trackbacks as $tb) {
$tpl->SetBlock('trackbacks/item');
$tpl->SetVariablesArray($tb);
$tpl->SetVariable('createtime-iso', $tb['createtime']);
$tpl->SetVariable('createtime', $date->Format($tb['createtime']));
$tpl->SetVariable('createtime-monthname', $date->Format($tb['createtime'], 'MN'));
$tpl->SetVariable('createtime-monthabbr', $date->Format($tb['createtime'], 'M'));
$tpl->SetVariable('createtime-month', $date->Format($tb['createtime'], 'm'));
$tpl->SetVariable('createtime-dayname', $date->Format($tb['createtime'], 'DN'));
$tpl->SetVariable('createtime-dayabbr', $date->Format($tb['createtime'], 'D'));
$tpl->SetVariable('createtime-day', $date->Format($tb['createtime'], 'd'));
$tpl->SetVariable('createtime-year', $date->Format($tb['createtime'], 'Y'));
$tpl->SetVariable('createtime-time', $date->Format($tb['createtime'], 'g:ia'));
$tpl->ParseBlock('trackbacks/item');
}
}
$tpl->ParseBlock('trackbacks');
return $tpl->Get();
}
}
示例7: UpdateQuote
/**
* Updates the quote
*
* @access public
* @param int $id Quote ID
* @param string $title
* @param string $quotation
* @param int $gid Group ID
* @param string $start_time
* @param string $stop_time
* @param bool $show_title
* @param bool $published
* @return mixed True on Success or Jaws_Error on failure
*/
function UpdateQuote($id, $title, $quotation, $gid, $start_time, $stop_time, $show_title, $published)
{
$date = Jaws_Date::getInstance();
$params['title'] = $title;
$params['quotation'] = $quotation;
$params['gid'] = $gid;
$params['start_time'] = null;
$params['stop_time'] = null;
if (!empty($start_time)) {
$start_time = $date->ToBaseDate(preg_split('/[- :]/', $start_time), 'Y-m-d H:i:s');
$params['start_time'] = $GLOBALS['app']->UserTime2UTC($start_time, 'Y-m-d H:i:s');
}
if (!empty($stop_time)) {
$stop_time = $date->ToBaseDate(preg_split('/[- :]/', $stop_time), 'Y-m-d H:i:s');
$params['stop_time'] = $GLOBALS['app']->UserTime2UTC($stop_time, 'Y-m-d H:i:s');
}
$params['updatetime'] = Jaws_DB::getInstance()->date();
$params['show_title'] = (bool) $show_title;
$params['published'] = (bool) $published;
$quotesTable = Jaws_ORM::getInstance()->table('quotes');
$result = $quotesTable->update($params)->where('id', (int) $id)->exec();
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushLastResponse(_t('QUOTES_QUOTE_NOT_UPDATED'), RESPONSE_ERROR);
return new Jaws_Error(_t('QUOTES_QUOTE_NOT_UPDATED'));
}
$GLOBALS['app']->Session->PushLastResponse(_t('QUOTES_QUOTE_UPDATED'), RESPONSE_NOTICE);
return true;
}
示例8: Execute
/**
* Returns an array with the results of a tag content
*
* @access public
* @param string $action Action name
* @param array $references Array of References
* @return array An array of entries that matches a certain pattern
*/
function Execute($action, $references)
{
if (empty($action) || !is_array($references) || empty($references)) {
return false;
}
$sptTable = Jaws_ORM::getInstance()->table('static_pages_translation');
$sptTable->select('page_id:integer', 'group_id', 'title', 'content', 'language', 'fast_url', 'static_pages_translation.updated');
$sptTable->join('static_pages', 'static_pages.page_id', 'static_pages_translation.base_id');
$result = $sptTable->where('translation_id', $references, 'in')->fetchAll();
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$pages = array();
foreach ($result as $p) {
if (!$this->gadget->GetPermission('AccessGroup', $p['group_id'])) {
continue;
}
$page = array();
$page['title'] = $p['title'];
$url = $this->gadget->urlMap('Page', array('pid' => empty($p['fast_url']) ? $p['page_id'] : $p['fast_url'], 'language' => $p['language']));
$page['url'] = $url;
$page['image'] = 'gadgets/StaticPage/Resources/images/logo.png';
$page['snippet'] = $p['content'];
$page['date'] = $date->ToISO($p['updated']);
$pages[$p['page_id']] = $page;
}
return $pages;
}
示例9: Album
/**
* Displays an index of gallerie.
*
* @access public
* @return string XHTML template content
*/
function Album()
{
$tpl = $this->gadget->template->load('Albums.html');
$tpl->SetBlock('albums');
$tpl->SetVariable('title', _t('PHOO_ALBUMS'));
$model = $this->gadget->model->load('Albums');
$albums = $model->GetAlbumList();
if (!Jaws_Error::IsError($albums)) {
$date = Jaws_Date::getInstance();
foreach ($albums as $album) {
if (!isset($album['qty'])) {
continue;
}
$tpl->SetBlock('albums/item');
$imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $album['thumb']);
if (!Jaws_Error::IsError($imgData)) {
$tpl->SetVariable('width', $imgData[0]);
$tpl->SetVariable('height', $imgData[1]);
}
$url = $this->gadget->urlMap('ViewAlbum', array('id' => $album['id']));
$tpl->SetVariable('url', $url);
$tpl->SetVariable('name', $album['name']);
$tpl->SetVariable('filename', $album['filename']);
$tpl->SetVariable('thumb', $GLOBALS['app']->getDataURL('phoo/' . $album['thumb']));
$tpl->SetVariable('howmany', _t('PHOO_NUM_PHOTOS_ALBUM', $album['qty']));
$tpl->SetVariable('description', $this->gadget->ParseText($album['description']));
$tpl->SetVariable('createtime', $date->Format($album['createtime']));
$tpl->ParseBlock('albums/item');
}
}
$tpl->ParseBlock('albums');
return $tpl->Get();
}
示例10: LoginHistory
/**
*
* @access public
* @return string HTML content with menu and menu items
*/
function LoginHistory($limit = 5)
{
if (!$GLOBALS['app']->Session->Logged()) {
return false;
}
$logModel = Jaws_Gadget::getInstance('Logs')->model->load('Logs');
$logs = $logModel->GetLogs(array('gadget' => 'Users', 'action' => 'Login', 'user' => $GLOBALS['app']->Session->GetAttribute('user')), $limit);
if (Jaws_Error::IsError($logs) || empty($logs)) {
return false;
}
$tpl = $this->gadget->template->load('LoginHistory.html');
$tpl->SetBlock('history');
$date = Jaws_Date::getInstance();
$tpl->SetVariable('title', _t('LOGS_LOGIN_HISTORY'));
foreach ($logs as $log) {
$tpl->SetBlock('history/' . $log['status']);
$tpl->SetVariable('ip', long2ip($log['ip']));
$tpl->SetVariable('agent', $log['agent']);
$tpl->SetVariable('status_title', _t('GLOBAL_HTTP_ERROR_TITLE_' . $log['status']));
$tpl->SetVariable('date', $date->Format($log['insert_time'], 'd MN Y H:i'));
$tpl->ParseBlock('history/' . $log['status']);
}
$tpl->ParseBlock('history');
return $tpl->Get();
}
示例11: ViewTerm
/**
* Look for a term and prints it
*
* @access public
* @return string XHTML template content
*/
function ViewTerm()
{
$term = jaws()->request->fetch('term', 'get');
$term = Jaws_XSS::defilter($term);
$model = $this->gadget->model->load('Term');
$term = $model->GetTerm($term);
if (!Jaws_Error::IsError($term) && isset($term['term'])) {
$this->SetTitle($term['term']);
$tpl = $this->gadget->template->load('ViewTerm.html');
$tpl->SetBlock('definition');
$tpl->SetVariable('title', $this->gadget->title);
$date = Jaws_Date::getInstance();
$tpl->SetBlock('definition/term');
$tpl->SetVariable('term', $term['term']);
$tid = empty($term['fast_url']) ? $term['id'] : $term['fast_url'];
$tpl->SetVariable('url', $this->gadget->urlMap('ViewTerm', array('term' => $tid)));
$tpl->SetVariable('description', $this->gadget->ParseText($term['description']));
$tpl->SetVariable('created_in', _t('GLOBAL_CREATETIME'));
$tpl->SetVariable('updated_in', _t('GLOBAL_UPDATETIME'));
$tpl->SetVariable('createtime', $date->Format($term['createtime']));
$tpl->SetVariable('updatetime', $date->Format($term['updatetime']));
$tpl->ParseBlock('definition/term');
$tpl->ParseBlock('definition');
} else {
return Jaws_HTTPError::Get(404);
}
return $tpl->Get();
}
示例12: Execute
/**
* Returns an array with the results of a search
*
* @access public
* @param string $pSql Prepared search(WHERE) SQL
* @return array An array of entries that matches a certain pattern
*/
function Execute($pSql = '')
{
$sql = '
SELECT
[id], [title], [description], [user_filename], [update_time]
FROM [[directory]]
WHERE
[hidden] = {hidden}
';
$sql .= ' AND ' . $pSql;
$sql .= ' ORDER BY id desc';
$params = array();
$params['hidden'] = false;
$types = array('text', 'text', 'text', 'integer');
$result = Jaws_DB::getInstance()->queryAll($sql, $params, $types);
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$files = array();
foreach ($result as $p) {
$file = array();
$file['title'] = $p['title'];
$file['url'] = $this->gadget->urlMap('Directory', array('id' => $p['id']));
$file['image'] = 'gadgets/Directory/Resources/images/logo.png';
$file['snippet'] = $p['description'];
$file['date'] = $p['update_time'];
$stamp = $p['update_time'];
$files[$stamp] = $file;
}
return $files;
}
示例13: Execute
/**
* Returns an array with the results of a tag content
*
* @access public
* @param string $action Action name
* @param array $references Array of References
* @return array An array of entries that matches a certain pattern
*/
function Execute($action, $references)
{
if (empty($action) || !is_array($references) || empty($references)) {
return false;
}
$table = Jaws_ORM::getInstance()->table('blog');
$table->select('id:integer', 'fast_url', 'title', 'summary', 'text', 'updatetime');
$result = $table->where('id', $references, 'in')->fetchAll();
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$posts = array();
foreach ($result as $r) {
$post = array();
$post['title'] = $r['title'];
$post['url'] = $this->gadget->urlMap('SingleView', array('id' => $r['fast_url']));
$post['outer'] = false;
$post['image'] = 'gadgets/Blog/Resources/images/logo.png';
$post['snippet'] = $r['summary'];
$post['date'] = $date->ToISO($r['updatetime']);
$posts[$r['id']] = $post;
}
return $posts;
}
示例14: Execute
/**
* Returns an array with the results of a search
*
* @access public
* @param string $pSql Prepared search (WHERE) SQL
* @return array An array of entries that matches a certain pattern
*/
function Execute($pSql = '')
{
// TODO: must be converted to Jaws_ORM
$sql = '
SELECT
[id], [title], [contents], [updatetime]
FROM [[blocks]]
';
$sql .= ' WHERE ' . $pSql;
$sql .= ' ORDER BY [createtime] desc';
$result = Jaws_DB::getInstance()->queryAll($sql);
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$blocks = array();
foreach ($result as $r) {
$block = array();
$block['title'] = $r['title'];
$block['url'] = $this->gadget->urlMap('Block', array('id' => $r['id']));
$block['image'] = 'gadgets/Blocks/Resources/images/logo.png';
$block['snippet'] = $r['contents'];
$block['date'] = $date->ToISO($r['updatetime']);
$blocks[] = $block;
}
return $blocks;
}
示例15: Execute
/**
* Returns an array with the results of a search
*
* @access public
* @param string $pSql Prepared search (WHERE) SQL
* @return array An array of entries that matches a certain pattern
*/
function Execute($pSql = '')
{
$sql = '
SELECT
[id], [title], [url], [description], [updatetime]
FROM [[linkdump_links]]
';
$sql .= ' WHERE ' . $pSql;
$sql .= ' ORDER BY [createtime] desc';
$result = Jaws_DB::getInstance()->queryAll($sql);
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$links = array();
foreach ($result as $r) {
$link = array();
$link['title'] = $r['title'];
$link['url'] = $this->gadget->urlMap('Link', array('id' => $r['id']));
$link['outer'] = true;
$link['image'] = 'gadgets/LinkDump/Resources/images/logo.png';
$link['snippet'] = $r['description'];
$link['date'] = $date->ToISO($r['updatetime']);
$links[] = $link;
}
return $links;
}