本文整理汇总了PHP中DateUtil::getDatetime_Field方法的典型用法代码示例。如果您正苦于以下问题:PHP DateUtil::getDatetime_Field方法的具体用法?PHP DateUtil::getDatetime_Field怎么用?PHP DateUtil::getDatetime_Field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateUtil
的用法示例。
在下文中一共展示了DateUtil::getDatetime_Field方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: archives
/**
* display article archives
*
* @author Andreas Krapohl
* @author Mark West
* @return string HTML string
*/
public function archives($args)
{
// Get parameters from whatever input we need
$year = (int)FormUtil::getPassedValue('year', null, 'REQUEST');
$month = (int)FormUtil::getPassedValue('month', null, 'REQUEST');
$day = '31';
$this->throwForbiddenUnless(SecurityUtil::checkPermission('News::', '::', ACCESS_OVERVIEW), LogUtil::getErrorMsgPermission());
// Dates validation
$currentdate = explode(',', DateUtil::getDatetime('', '%Y,%m,%d'));
if (!empty($year) || !empty($month)) {
if ((empty($year) || empty($month)) ||
($year > (int)$currentdate[0] || ($year == (int)$currentdate[0] && $month > (int)$currentdate[1]))) {
$this->redirect(ModUtil::url('News', 'user', 'archives'));
} elseif ($year == (int)$currentdate[0] && $month == (int)$currentdate[1]) {
$day = (int)$currentdate[2];
}
}
// Load localized month names
$monthnames = explode(' ', $this->__('January February March April May June July August September October November December'));
// Create output object
// For caching reasons you must pass a cache ID
$cacheid = '_'.$year.'|'.$month; // to prevent colision year with article id
$this->view->setCacheId($cacheid);
$template = 'user/archives.tpl';
if ($this->view->is_cached($template)) {
return $this->view->fetch($template);
}
// output vars
$archivemonths = array();
$archiveyears = array();
if (!empty($year) && !empty($month)) {
$items = ModUtil::apiFunc('News', 'user', 'getall', array('order' => 'from',
'from' => "$year-$month-01 00:00:00",
'to' => "$year-$month-$day 23:59:59",
'status' => 0));
$this->view->assign('year', $year);
$this->view->assign('month', $monthnames[$month - 1]);
} else {
// get all matching news articles
$monthsyears = ModUtil::apiFunc('News', 'user', 'getMonthsWithNews');
foreach ($monthsyears as $monthyear) {
$month = DateUtil::getDatetime_Field($monthyear, 2);
$year = DateUtil::getDatetime_Field($monthyear, 1);
$dates[$year][] = $month;
}
foreach ($dates as $year => $years) {
foreach ($years as $month) {
//$linktext = $monthnames[$month-1]." $year";
$linktext = $monthnames[$month - 1];
$nrofarticles = ModUtil::apiFunc('News', 'user', 'countitems', array('from' => "$year-$month-01 00:00:00",
'to' => "$year-$month-$day 23:59:59",
'status' => 0));
$archivemonths[$year][$month] = array('url' => ModUtil::url('News', 'user', 'archives', array('month' => $month, 'year' => $year)),
'title' => $linktext,
'nrofarticles' => $nrofarticles);
}
}
$items = false;
}
$this->view->assign('archivemonths', $archivemonths);
$this->view->assign('archiveitems', $items);
$this->view->assign('enablecategorization', $this->getVar('enablecategorization'));
// Return the output that has been generated by this function
return $this->view->fetch($template);
}
示例2: clearItemCache
/**
* Clear cache for given item. Can be called from other modules to clear an item cache.
*
* @param $item - the item: array with data or id of the item
*/
public function clearItemCache($item)
{
if ($item && !is_array($item)) {
$item = ModUtil::apiFunc('News', 'user', 'get', array('sid' => $item));
}
if ($item) {
// Clear View_cache
$cache_ids = array();
$cache_ids[] = $item['sid'];
$view = Zikula_View::getInstance('News');
foreach ($cache_ids as $cache_id) {
$view->clear_cache(null, $cache_id);
}
// Clear Theme_cache
$cache_ids = array();
$cache_ids[] = 'News/user/display/sid_'.$item['sid']; // for given article Id, according to new cache_id structure in Zikula 1.3.2.dev (1.3.3)
$cache_ids[] = 'homepage'; // for homepage (it can be adjustment in module settings)
$cache_ids[] = 'News/user/view'; // view function (articles list)
$cache_ids[] = 'News/user/main'; // main function
$cache_ids[] = 'News/user/archives/month_'.DateUtil::getDatetime_Field($item['ffrom'], 2).'/year_'.DateUtil::getDatetime_Field($item['ffrom'], 1); // archives
$theme = Zikula_View_Theme::getInstance();
//if (Zikula_Core::VERSION_NUM > '1.3.2') {
if (method_exists($theme, 'clear_cacheid_allthemes')) {
$theme->clear_cacheid_allthemes($cache_ids);
} else {
// clear cache for current theme only
foreach ($cache_ids as $cache_id) {
$theme->clear_cache(null, $cache_id);
}
}
}
}