本文整理汇总了PHP中DateUtil::getDatetimeDiff_AsField方法的典型用法代码示例。如果您正苦于以下问题:PHP DateUtil::getDatetimeDiff_AsField方法的具体用法?PHP DateUtil::getDatetimeDiff_AsField怎么用?PHP DateUtil::getDatetimeDiff_AsField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateUtil
的用法示例。
在下文中一共展示了DateUtil::getDatetimeDiff_AsField方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modify
/**
* modify a news entry (incl. delete) via ajax
*
* @author Frank Schummertz
* @param 'sid' int the story id
* @param 'page' int the story page
* @return string HTML string
*/
public function modify()
{
$this->checkAjaxToken();
$sid = $this->request->getPost()->get('sid');
$page = $this->request->getPost()->get('page', 1);
// Get the news article
$item = ModUtil::apiFunc('News', 'User', 'get', array('sid' => $sid));
if ($item == false) {
throw new Zikula_Exception_NotFound($this->__('Error! No such article found.'));
}
// Security check
$this->throwForbiddenUnless(SecurityUtil::checkPermission('News::', "{$item['cr_uid']}::$sid", ACCESS_EDIT));
// Get the format types. 'home' string is bits 0-1, 'body' is bits 2-3.
$item['hometextcontenttype'] = ($item['format_type'] % 4);
$item['bodytextcontenttype'] = (($item['format_type'] / 4) % 4);
// Set the publishing date options.
if (!isset($item['to'])) {
if (DateUtil::getDatetimeDiff_AsField($item['from'], $item['cr_date'], 6) >= 0 && is_null($item['to'])) {
$item['unlimited'] = 1;
$item['tonolimit'] = 1;
} elseif (DateUtil::getDatetimeDiff_AsField($item['from'], $item['cr_date'], 6) < 0 && is_null($item['to'])) {
$item['unlimited'] = 0;
$item['tonolimit'] = 1;
}
} else {
$item['unlimited'] = 0;
$item['tonolimit'] = 0;
}
Zikula_AbstractController::configureView();
$this->view->setCaching(false);
$modvars = $this->getVars();
if ($modvars['enablecategorization']) {
$catregistry = CategoryRegistryUtil::getRegisteredModuleCategories('News', 'news');
$this->view->assign('catregistry', $catregistry);
}
$this->view->assign('accessadd', 0);
if (SecurityUtil::checkPermission('News::', '::', ACCESS_ADD)) {
$this->view->assign('accessadd', 1);
$this->view->assign('accesspicupload', 1);
$this->view->assign('accesspubdetails', 1);
} else {
$this->view->assign('accesspicupload', SecurityUtil::checkPermission('News:pictureupload:', '::', ACCESS_ADD));
$this->view->assign('accesspubdetails', SecurityUtil::checkPermission('News:publicationdetails:', '::', ACCESS_ADD));
}
// Assign the item to the template
$this->view->assign('item', $item);
// Assign the current page
$this->view->assign('page', $page);
// Assign the default languagecode
$this->view->assign('lang', ZLanguage::getLanguageCode());
// Assign the content format
$formattedcontent = ModUtil::apiFunc('News', 'User', 'isformatted', array('func' => 'modify'));
$this->view->assign('formattedcontent', $formattedcontent);
//lock the page so others cannot edit it
if (ModUtil::available('PageLock')) {
$returnUrl = ModUtil::url('News', 'admin', 'view');
ModUtil::apiFunc('PageLock', 'user', 'pageLock',
array('lockName' => "Newsnews{$item['sid']}",
'returnUrl' => $returnUrl));
}
// Return the output that has been generated by this function
return new Zikula_Response_Ajax(array('result' => $this->view->fetch('ajax/modify.tpl')));
}
示例2: display
//.........这里部分代码省略.........
if ($this->dispuname) {
$anonymous = System::getVar('anonymous');
}
// check for an empty return
if (!empty($items)) {
// loop through the items and prepare for display
foreach (array_keys($items) as $k)
{
// Get specific information from the article. It was a choice not to use the pnuserapi functions
// GetArticleInfo, GetArticleLinks and getArticlesPreformat because of speed etc.
// --- Check for Topic related properties like topicimage, topicsearchurl etc.
if ($enablecategorization && !empty($items[$k]['__CATEGORIES__']) && isset($items[$k]['__CATEGORIES__'][$topicField])) {
$items[$k]['topicid'] = $items[$k]['__CATEGORIES__'][$topicField]['id'];
$items[$k]['topicname'] = isset($items[$k]['__CATEGORIES__'][$topicField]['display_name'][$lang]) ? $items[$k]['__CATEGORIES__'][$topicField]['display_name'][$lang] : $items[$k]['__CATEGORIES__'][$topicField]['name'];
// set the topic image if topic_image category property exists
$items[$k]['topicimage'] = (isset($items[$k]['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']) && isset($items[$k]['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']['topic_image'])) ? $items[$k]['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']['topic_image'] : '';
// set the topic description if exists
$items[$k]['topictext'] = isset($items[$k]['__CATEGORIES__'][$topicField]['display_desc'][$lang]) ? $items[$k]['__CATEGORIES__'][$topicField]['display_desc'][$lang] : '';
// set the path of the topic
$items[$k]['topicpath'] = isset($items[$k]['__CATEGORIES__'][$topicField]['path_relative']) ? $items[$k]['__CATEGORIES__'][$topicField]['path_relative'] : '';
// set the url to search for this topic
if (System::getVar('shorturls', false)) {
$items[$k]['topicsearchurl'] = DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'view', array('prop' => $topicField, 'cat' => $items[$k]['topicpath'])));
} else {
$items[$k]['topicsearchurl'] = DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'view', array('prop' => $topicField, 'cat' => $items[$k]['topicid'])));
}
} else {
$items[$k]['topicid'] = null;
$items[$k]['topicname'] = '';
$items[$k]['topicimage'] = '';
$items[$k]['topictext'] = '';
$items[$k]['topicpath'] = '';
$items[$k]['topicsearchurl'] = '';
}
// Optional new image if the difference in days from the publishing date and now < the specified limit
$items[$k]['dispnewimage'] = ($this->dispnewimage && DateUtil::getDatetimeDiff_AsField($items[$k]['from'], DateUtil::getDatetime(), 3) < (int) $this->newimagelimit);
// Wrap the title if needed
$items[$k]['titlewrapped'] = false;
if ((int) $this->maxtitlelength > 0 && strlen($items[$k]['title']) > (int) $this->maxtitlelength) {
// wrap the title
$items[$k]['title'] = substr($items[$k]['title'], 0, (int) $this->maxtitlelength);
$items[$k]['titlewrapped'] = true;
//$items[$k]['title'] .= $this->titlewraptext;
}
// Get the user information from the author id
if ($this->dispuname) {
if ($items[$k]['cr_uid'] == 0) {
$items[$k]['uname'] = $anonymous;
$items[$k]['aid_name'] = $anonymous;
} else {
$user = UserUtil::getVars($items[$k]['cr_uid']);
$items[$k]['uname'] = $user['uname'];
$items[$k]['aid_name'] = $user['uname'];
}
}
// Get the optional commentcount if EZComments is available
if ($this->dispcomments && ModUtil::available('EZComments')) {
$items[$k]['comments'] = ModUtil::apiFunc('EZComments', 'user', 'countitems', array('mod' => 'News', 'objectid' => $items[$k]['sid'], 'status' => 0));
}
// Optional display of the hometext (frontpage teaser)
if ($this->disphometext) {
if ($this->maxhometextlength > 0 && strlen(strip_tags($items[$k]['hometext'])) > (int) $this->maxhometextlength) {
$items[$k]['hometextwrapped'] = true;
}
}
$items[$k]['readperm'] = (SecurityUtil::checkPermission('News::', "$items[$k][cr_uid]::$items[$k][sid]", ACCESS_READ));
}
if ($this->dispuname || $this->dispdate || $this->dispreads || $this->dispcomments) {
$this->view->assign('dispinfo', true);
$this->view->assign('dispuname', $this->dispuname);
$this->view->assign('dispdate', $this->dispdate);
$this->view->assign('dispreads', $this->dispreads);
$this->view->assign('dispcomments', $this->dispcomments);
$this->view->assign('dispsplitchar', $this->dispsplitchar);
} else {
$this->view->assign('dispinfo', false);
}
if ($this->dispnewimage) {
$this->view->assign('newimageset', $this->newimageset);
$this->view->assign('newimagesrc', $this->newimagesrc);
}
$this->view->assign('disphometext', $this->disphometext);
if ($this->disphometext) {
$this->view->assign('hometextwraptext', $this->hometextwraptext);
$this->view->assign('maxhometextlength', $this->maxhometextlength);
}
$this->view->assign('titlewraptext', $this->titlewraptext);
}
$this->view->assign('News', ModUtil::getVar('News'));
$this->view->assign('dateformat', $this->dateformat);
$this->view->assign('linktosubmit', $this->linktosubmit);
$this->view->assign('stories', $items);
$this->view->assign('title', $this->title);
$this->view->assign('displayStoryImage', $this->displayStoryImage);
$this->view->assign('useshorturls', System::getVar('shorturls', false));
return $this->view->fetch($this->getTemplate());
}
示例3: display
//.........这里部分代码省略.........
} else {
$rowtemplate = 'block/storiesext/row.tpl';
}
// --- loop through the items and prepare every News item for display
foreach ($items as $item) {
// Get specific information from the article. It was a choice not to use the pnuserapi functions
// GetArticleInfo, GetArticleLinks and getArticlesPreformat because of speed etc.
// --- Check for Topic related properties like topicimage, topicsearchurl etc.
if ($enablecategorization && !empty($item['__CATEGORIES__']) && isset($item['__CATEGORIES__'][$topicField])) {
$item['topicid'] = $item['__CATEGORIES__'][$topicField]['id'];
$item['topicname'] = isset($item['__CATEGORIES__'][$topicField]['display_name'][$lang]) ? $item['__CATEGORIES__'][$topicField]['display_name'][$lang] : $item['__CATEGORIES__'][$topicField]['name'];
// set the topic image if topic_image category property exists
$item['topicimage'] = (isset($item['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']) && isset($item['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']['topic_image'])) ? $item['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']['topic_image'] : '';
// set the topic description if exists
$item['topictext'] = isset($item['__CATEGORIES__'][$topicField]['display_desc'][$lang]) ? $item['__CATEGORIES__'][$topicField]['display_desc'][$lang] : '';
// set the path of the topic
$item['topicpath'] = $item['__CATEGORIES__'][$topicField]['path_relative'];
// set the url to search for this topic
if (System::getVar('shorturls', false)) {
$item['topicsearchurl'] = DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'view', array('prop' => $topicField, 'cat' => $item['topicpath'])));
} else {
$item['topicsearchurl'] = DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'view', array('prop' => $topicField, 'cat' => $item['topicid'])));
}
} else {
$item['topicid'] = null;
$item['topicname'] = '';
$item['topicimage'] = '';
$item['topictext'] = '';
$item['topicpath'] = '';
$item['topicsearchurl'] = '';
}
// Optional new image if the difference in days from the publishing date and now < the limit
$item['itemnewimage'] = ($vars['dispnewimage'] && DateUtil::getDatetimeDiff_AsField($item['from'], DateUtil::getDatetime(), 3) < (int)$vars['newimagelimit']);
// Wrap the title if needed
$item['titlewrapped'] = false;
if ($vars['maxtitlelength'] > 0 && strlen($item['title']) > (int)$vars['maxtitlelength']) {
// wrap the title with wordwrap (instead of substr)
$a = explode('[[[wrap]]]', wordwrap($item['title'], (int)$vars['maxtitlelength'], '[[[wrap]]]'));
$item['title'] = $a[0];
$item['titlewrapped'] = true;
}
if ($vars['dispuname']) {
// Get the user information from the author id
if ($item['cr_uid'] == 0) {
$this->view->assign('uname', $anonymous);
$this->view->assign('aid_name', $anonymous);
} else {
$user = UserUtil::getVars($item['cr_uid']);
$this->view->assign('uname', $user['uname']);
$this->view->assign('aid_name', $user['name']);
}
}
// Check for EZComments
if ($vars['dispcomments'] && ModUtil::available('EZComments')) {
$item['comments'] = ModUtil::apiFunc('EZComments', 'user', 'countitems', array('mod' => 'News', 'objectid' => $item['sid'], 'status' => 0));
}
if ($vars['disphometext']) {
if ($vars['maxhometextlength'] > 0 && strlen(strip_tags($item['hometext'])) > (int)$vars['maxhometextlength']) {
$item['hometextwrapped'] = true;
}
}
if ($vars['dispuname']||$vars['dispdate']||$vars['dispreads']||$vars['dispcomments']) {
$this->view->assign('dispinfo', true);
}
$this->view->assign('readperm',(bool)SecurityUtil::checkPermission('News::', "$item[cr_uid]::$item[sid]", ACCESS_READ));
示例4: getPages
//.........这里部分代码省略.........
$ca[] = 'translatedTitle';
$ca[] = 'translatedMetaDescription';
$ca[] = 'translatedMetaKeywords';
$ca[] = 'uname';
$sql = "
SELECT DISTINCT
$cols,
$translatedColumn[title],
$translatedColumn[metadescription],
$translatedColumn[metakeywords],
$userColumn[uname]
FROM $pageTable
LEFT JOIN $translatedTable t
ON t.$translatedColumn[pageId] = $pageColumn[id]
AND t.$translatedColumn[language] = '$language'
LEFT JOIN $userTable usr
ON usr.$userColumn[uid] = $pageColumn[lu_uid]
$join
$where
$orderBy";
if ($pageSize > 0) {
$dbresult = DBUtil::executeSQL($sql, $pageSize * $pageIndex, $pageSize);
} else {
$dbresult = DBUtil::executeSQL($sql);
}
$pages = DBUtil::marshallObjects($dbresult, $ca);
if (isset($filter['expandedPageIds']) && is_array($filter['expandedPageIds'])) {
$expandedPageIdsMap = $filter['expandedPageIds'];
} else {
$expandedPageIdsMap = null;
}
for ($i = 0, $cou = count($pages); $i < $cou; ++$i) {
$p = &$pages[$i];
$p['translated'] = array('title' => $p['translatedTitle'], 'metadescription' => $p['translatedMetaDescription'], 'metakeywords' => $p['translatedMetaKeywords']);
if ($includeLayout) {
$p['layoutData'] = ModUtil::apiFunc('Content', 'Layout', 'getLayout',
array('layout' => $p['layout']));
$p['layoutTemplate'] = $p['layoutData']['template'];
$p['layoutEditTemplate'] = $p['layoutData']['editTemplate'];
$p['titleintemplate'] = $p['layoutData']['plugin']->titleInTemplate;
} else {
$p['layoutData'] = array();
$p['layoutTemplate'] = $p['layoutEditTemplate'] = '';
}
if ($includeCategories) {
$p['categories'] = $this->contentGetPageCategories($p['id']);
}
if ($includeVersionNo) {
$p['versionNo'] = ModUtil::apiFunc('Content', 'History', 'getPageVersionNo', array('pageId' => $p['id']));
}
if (!empty($p['translatedTitle'])) {
if ($translate) {
$p = array_merge($p, $p['translated']);
}
$p['isTranslated'] = true;
} else {
$p['isTranslated'] = false;
}
// create page variables that represent the Online and Menu status, much like the old db fields
$now = DateUtil::getDatetime();
$p['isOnline'] = $p['active'] && (DateUtil::getDatetimeDiff_AsField($p['activeFrom'], $now, 6) >= 0 || $p['activeFrom'] == null) && (DateUtil::getDatetimeDiff_AsField($p['activeTo'], $now, 6) < 0 || $p['activeTo'] == null);
$p['isInMenu'] = $p['isOnline'] && $p['inMenu'];
$content = null;
if ($includeContent) {
$content = ModUtil::apiFunc('Content', 'Content', 'getPageContent', array(
'pageId' => $p['id'],
'editing' => $editing,
'translate' => $translate,
'expandContent' => $expandContent));
if ($content === false) {
return false;
}
}
$p['content'] = $content;
if ($expandedPageIdsMap !== null) {
if (!empty($expandedPageIdsMap[$p['id']])) {
$p['isExpanded'] = 1;
} else {
$p['isExpanded'] = 0;
}
}
}
if ($makeTree && count($pages) > 0) {
$i = 0;
$pages = $this->contentMakePageTree($pages, $i, $pages[0]['level']);
}
return $pages;
}
示例5: view
//.........这里部分代码省略.........
$status = $news_status;
}
}
// Get all news stories
$getallargs = array('startnum' => $startnum,
'status' => $status,
'numitems' => $modvars['itemsperadminpage'],
'ignoreml' => true,
'language' => $language,
'order' => isset($order) ? $order : 'from',
'orderdir' => isset($orderdir) ? $orderdir : 'DESC',
'from' => isset($from) ? $from : null,
'to' => isset($to) ? $to : null,
'filterbydate' => false,
'category' => null,
'catfilter' => isset($catsarray) ? $catsarray : null,
'catregistry' => isset($catregistry) ? $catregistry : null);
$items = ModUtil::apiFunc('News', 'user', 'getall', $getallargs);
$total_articles = ModUtil::apiFunc('News', 'user', 'countitems', $getallargs);
// Set the possible status for later use
$itemstatus = array(
'' => $this->__('All'),
News_Api_User::STATUS_PUBLISHED => $this->__('Published'),
News_Api_User::STATUS_REJECTED => $this->__('Rejected'),
News_Api_User::STATUS_PENDING => $this->__('Pending Review'),
News_Api_User::STATUS_ARCHIVED => $this->__('Archived'),
News_Api_User::STATUS_DRAFT => $this->__('Draft'),
News_Api_User::STATUS_SCHEDULED => $this->__('Scheduled')
);
$newsitems = array();
foreach ($items as $item)
{
$options = array();
if (System::getVar('shorturls', false)) {
$options[] = array('url' => ModUtil::url('News', 'user', 'display', array('sid' => $item['sid'], 'from' => $item['from'], 'urltitle' => $item['urltitle'])),
'image' => '14_layer_visible.png',
'title' => $this->__('View'));
} else {
$options[] = array('url' => ModUtil::url('News', 'user', 'display', array('sid' => $item['sid'])),
'image' => '14_layer_visible.png',
'title' => $this->__('View'));
}
if (SecurityUtil::checkPermission('News::', "{$item['cr_uid']}::{$item['sid']}", ACCESS_EDIT)) {
if ($item['published_status'] == News_Api_User::STATUS_PENDING) {
$options[] = array('url' => ModUtil::url('News', 'admin', 'modify', array('sid' => $item['sid'])),
'image' => 'editcut.png',
'title' => $this->__('Review'));
} else {
$options[] = array('url' => ModUtil::url('News', 'admin', 'modify', array('sid' => $item['sid'])),
'image' => 'xedit.png',
'title' => $this->__('Edit'));
}
if (($item['published_status'] != News_Api_User::STATUS_PENDING &&
(SecurityUtil::checkPermission('News::', "{$item['cr_uid']}::{$item['sid']}", ACCESS_DELETE))) ||
SecurityUtil::checkPermission('News::', "{$item['cr_uid']}::{$item['sid']}", ACCESS_ADMIN)) {
$options[] = array('url' => ModUtil::url('News', 'admin', 'delete', array('sid' => $item['sid'])),
'image' => '14_layer_deletelayer.png',
'title' => $this->__('Delete'));
}
}
$item['options'] = $options;
if (in_array($item['published_status'], array_keys($itemstatus))) {
$item['status'] = $itemstatus[$item['published_status']];
} else {
$item['status'] = $this->__('Unknown');
}
$item['infuture'] = DateUtil::getDatetimeDiff_AsField($item['from'], DateUtil::getDatetime(), 6) < 0;
$newsitems[] = $item;
}
// Assign the items to the template
$this->view->assign('newsitems', $newsitems);
$this->view->assign('total_articles', $total_articles);
// Assign the current status filter and the possible ones
$this->view->assign('news_status', $news_status);
$this->view->assign('itemstatus', $itemstatus);
$this->view->assign('order', $order);
$selectedcategories = array();
if (is_array($filtercats)) {
$catsarray = $filtercats['__CATEGORIES__'];
foreach ($catsarray as $propname => $propid) {
if ($propid > 0) {
$selectedcategories[$propname] = $propid; // removes categories set to 'all'
}
}
}
$this->view->assign('selectedcategories', $selectedcategories);
// Return the output that has been generated by this function
return $this->view->fetch('admin/view.tpl');
}