本文整理汇总了PHP中DateUtil::formatDatetime方法的典型用法代码示例。如果您正苦于以下问题:PHP DateUtil::formatDatetime方法的具体用法?PHP DateUtil::formatDatetime怎么用?PHP DateUtil::formatDatetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateUtil
的用法示例。
在下文中一共展示了DateUtil::formatDatetime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContent
public function getContent($args)
{
switch ($args['pluginid']) {
case 1:
//$uid = $args['uid'];
// Get matching news stories published since last newsletter
// No selection on categories made !!
$items = ModUtil::apiFunc('News', 'user', 'getall',
array('numitems' => $this->getVar('itemsperpage'),
'status' => 0,
'from' => DateUtil::getDatetime($args['last']),
'filterbydate' => true));
if ($items != false) {
if ($args['contenttype'] == 't') {
$counter = 0;
$output.="\n";
foreach ($items as $item) {
$counter++;
$output .= $counter . '. ' . $item['title'] . " (" . $this->__f('by %1$s on %2$s', array($item['contributor'], DateUtil::formatDatetime($item['from'], 'datebrief'))) . ")\n";
}
} else {
$render = Zikula_View::getInstance('News');
$render->assign('readperm', SecurityUtil::checkPermission('News::', "::", ACCESS_READ));
$render->assign('articles', $items);
$output = $render->fetch('mailz/listarticles.tpl');
}
} else {
$output = $this->__f('No News publisher articles since last newsletter on %s.', DateUtil::formatDatetime($args['last'], 'datebrief')) . "\n";
}
return $output;
}
return '';
}
示例2: smarty_modifier_dateformatHuman
/**
* Smarty modifier to format datetimes in a more Human Readable form
* (like tomorow, 4 days from now, 6 hours ago)
*
* Example
* <!--[$futuredate|dateformatHuman:'%x':'2']-->
*
* @author Erik Spaan
* @since 05/03/09
* @param string $string input datetime string
* @param string $format The format of the regular date output (default %x)
* @param string $niceval [1|2|3|4] Choose the nice value of the output (default 2)
* 1 = full human readable
* 2 = past date > 1 day with dateformat, otherwise human readable
* 3 = within 1 day human readable, otherwise dateformat
* 4 = only use the specified format
* @return string the modified output
*/
function smarty_modifier_dateformatHuman($string, $format = '%x', $niceval = 2)
{
$dom = ZLanguage::getModuleDomain('News');
if (empty($format)) {
$format = '%x';
}
// store the current datetime in a variable
$now = DateUtil::getDatetime();
if (empty($string)) {
return DateUtil::formatDatetime($now, $format);
}
if (empty($niceval)) {
$niceval = 2;
}
// now format the date with respect to the current datetime
$res = '';
$diff = DateUtil::getDatetimeDiff($now, $string);
if ($diff['d'] < 0) {
if ($niceval == 1) {
$res = _fn('%s day ago', '%s days ago', abs($diff['d']), abs($diff['d']), $dom);
} elseif ($niceval < 4 && $diff['d'] == -1) {
$res = __('yesterday', $dom);
} else {
$res = DateUtil::formatDatetime($string, $format);
}
} elseif ($diff['d'] > 0) {
if ($niceval > 2) {
$res = DateUtil::formatDatetime($string, $format);
} elseif ($diff['d'] == 1) {
$res = __('tomorrow', $dom);
} else {
$res = _fn('%s day from now', '%s days from now', $diff['d'], $diff['d'], $dom);
}
} else {
// no day difference
if ($diff['h'] < 0) {
$res = _fn('%s hour ago', '%s hours ago', abs($diff['h']), abs($diff['h']), $dom);
} elseif ($diff['h'] > 0) {
$res = _fn('%s hour from now', '%s hours from now', $diff['h'], $diff['h'], $dom);
} else {
// no hour difference
if ($diff['m'] < 0) {
$res = _fn('%s minute ago', '%s minutes ago', abs($diff['m']), abs($diff['m']), $dom);
} elseif ($diff['m'] > 0) {
$res = _fn('%s minute from now', '%s minutes from now', $diff['m'], $diff['m'], $dom);
} else {
// no min difference
if ($diff['s'] < 0) {
$res = _fn('%s second ago', '%s seconds ago', abs($diff['s']), abs($diff['s']), $dom);
} else {
$res = _fn('%s second from now', '%s seconds from now', $diff['s'], $diff['s'], $dom);
}
}
}
}
return $res;
}
示例3: smarty_function_datetime
/**
* Zikula_View function to display the current date and time
*
* Example
* {datetime}
*
* {datetime format='datebrief'}
*
* {datetime format='%b %d, %Y - %I:%M %p'}
*
* Format:
* %a - abbreviated weekday name according to the current locale
* %A = full weekday name according to the current locale
* %b = abbreviated month name according to the current locale
* %B = full month name according to the current locale
* %d = day of the month as a decimal number (range 01 to 31)
* %D = same as %m/%d/%y
* %y = year as a decimal number without a century (range 00 to 99)
* %Y = year as a decimal number including the century
* %H = hour as a decimal number using a 24-hour clock (range 00 to 23)
* %I = hour as a decimal number using a 12-hour clock (range 01 to 12)
* %M = minute as a decimal number
* %S = second as a decimal number
* %p = either 'am' or 'pm' according to the given time value, or the corresponding strings for the current locale
*
* http://www.php.net/manual/en/function.strftime.php
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @see function.datetime.php::smarty_function_datetime()
*
* @return string
*/
function smarty_function_datetime($params, Zikula_View $view)
{
// set some defaults
$format = isset($params['format']) ? $params['format'] : __('%b %d, %Y - %I:%M %p');
if (strpos($format, '%') !== false) {
// allow the use of conversion specifiers
return DateUtil::formatDatetime('', $format);
}
return DateUtil::formatDatetime('', $format);
}
示例4: smarty_modifier_dateformat
/**
* Zikula_View modifier to format datestamps via strftime according to locale setting in Zikula.
*
* @param string $string Input date string.
* @param string $format Strftime format for output.
* @param string $default_date Default date if $string is empty.
*
* @uses smarty_make_timestamp()
*
* @return string The modified output.
*/
function smarty_modifier_dateformat($string, $format = 'datebrief', $default_date = null)
{
if (empty($format)) {
$format = 'datebrief';
}
if (!empty($string)) {
return DateUtil::formatDatetime($string, $format);
} elseif (!empty($default_date)) {
return DateUtil::formatDatetime($default_date, $format);
}
return '';
}
示例5: formatValue
/**
* Format the value to specific format.
*
* @param Zikula_Form_View $view Reference to Zikula_Form_View object.
* @param string $value The value to format.
*
* @return string Formatted value.
*/
public function formatValue(Zikula_Form_View $view, $value)
{
return DateUtil::formatDatetime($value, $this->ifFormat, false);
}
示例6: display
/**
* display block
*
* @author The Zikula Development Team
* @param array $blockinfo a blockinfo structure
* @return output the rendered bock
*/
public function display($blockinfo)
{
// security check
if (!SecurityUtil::checkPermission('Pastblock::', "$blockinfo[bid]::", ACCESS_READ)) {
return;
}
// get the number of stories shown on the frontpage
$storyhome = $this->getVar('storyhome', 10);
// Break out options from our content field
$vars = BlockUtil::varsFromContent($blockinfo['content']);
// Defaults
if (empty($vars['limit'])) {
$vars['limit'] = 10;
}
if ($this->getVar('enablecategorization')) {
$catregistry = CategoryRegistryUtil::getRegisteredModuleCategories('News', 'news');
}
// call the API
$articles = ModUtil::apiFunc('News', 'user', 'getall', array(
'displayonindex' => 1,
'order' => 'from',
'status' => News_Api_User::STATUS_PUBLISHED,
'startnum' => $storyhome + 1,
'numitems' => $vars['limit'],
'catregistry' => isset($catregistry) ? $catregistry : null));
if (($articles === false) || (empty($articles))) {
return;
}
// loop round the return articles grouping by date
$count = 0;
$news = array();
$newscumul = array();
$limitreached = false;
foreach ($articles as $article)
{
$info = ModUtil::apiFunc('News', 'user', 'getArticleInfo', $article);
$links = ModUtil::apiFunc('News', 'user', 'getArticleLinks', $info);
if (SecurityUtil::checkPermission('News::', "$info[cr_uid]::$info[sid]", ACCESS_READ)) {
$preformat['title'] = "<a href=\"$links[fullarticle]\">$info[title]</a>";
} else {
$preformat['title'] = $info['title'];
}
$daydate = DateUtil::formatDatetime(strtotime($info['from']), '%Y-%m-%d');
// Reset the time
if (!isset($currentday)) {
$currentday = $daydate;
}
// If it's a different date, save the cumul and continue
if ($currentday != $daydate) {
$news[$currentday] = $newscumul;
$newscumul = array();
$currentday = $daydate;
}
$newscumul[] = array('info' => $info,
'links' => $links,
'preformat' => $preformat);
}
if (!isset($news[$currentday])) {
$news[$currentday] = $newscumul;
}
$this->view->assign('news', $news);
if (empty($blockinfo['title'])) {
//! default past block title
$blockinfo['title'] = $this->__('Past articles');
}
$blockinfo['content'] = $this->view->fetch('block/past.tpl');
return BlockUtil::themeBlock($blockinfo);
}
示例7: setObjectDate
/**
* Sets the object date.
*
* @param string $date
*/
public function setObjectDate($date)
{
$this->date = DateUtil::formatDatetime($date, 'datetimebrief');
}
示例8: denyRegistration
/**
* Render and process a form confirming the administrator's rejection of a registration.
*
* If the denial is confirmed, the registration is deleted from the database.
*
* Parameters passed via GET:
* --------------------------
* numeric uid The id of the registration request (id) to deny.
* string restorview To restore the main view to use the filtering options present prior to executing this function, then 'view',
* otherwise not present.
*
* Parameters passed via POST:
* ---------------------------
* numeric uid The id of the registration request (uid) to deny.
* boolean confirmed True to execute this function's action.
* boolean usernorify True to notify the user that his registration request was denied; otherwise false.
* string reason The reason the registration request was denied, included in the notification.
* string restorview To restore the main view to use the filtering options present prior to executing this function, then 'view',
* otherwise not present.
*
* Parameters passed via SESSION:
* ------------------------------
* None.
*
* @return string|bool The rendered template; true on success; otherwise false.
*
* @throws Zikula_Exception_Forbidden Thrown if the user does not have delete access, or if the method used to access this function is improper.
*/
public function denyRegistration()
{
if (!SecurityUtil::checkPermission('Users::', '::', ACCESS_DELETE)) {
throw new Zikula_Exception_Forbidden();
}
if ($this->request->isGet()) {
$uid = $this->request->query->get('uid', null);
$restoreView = $this->request->query->get('restoreview', 'view');
$confirmed = false;
} elseif ($this->request->isPost()) {
$this->checkCsrfToken();
$uid = $this->request->request->get('uid', null);
$restoreView = $this->request->request->get('restoreview', 'view');
$sendNotification = $this->request->request->get('usernotify', false);
$reason = $this->request->request->get('reason', '');
$confirmed = $this->request->request->get('confirmed', false);
} else {
throw new Zikula_Exception_Forbidden();
}
if (!isset($uid) || !is_numeric($uid) || ((int)$uid != $uid)) {
$this->registerError(LogUtil::getErrorMsgArgs());
return false;
}
// Got just a uid.
$reginfo = ModUtil::apiFunc($this->name, 'registration', 'get', array('uid' => $uid));
if (!$reginfo) {
$this->registerError($this->__f('Error! Unable to retrieve registration record with uid \'%1$s\'', $uid));
return false;
}
if ($restoreView == 'display') {
$cancelUrl = ModUtil::url($this->name, 'admin', 'displayRegistration', array('uid' => $reginfo['uid']));
} else {
$cancelUrl = ModUtil::url($this->name, 'admin', 'viewRegistrations', array('restoreview' => true));
}
if (!$confirmed) {
// Bad or no auth key, or bad or no confirmation, so display confirmation.
// So expiration can be displayed
$regExpireDays = $this->getVar('reg_expiredays', 0);
if (!$reginfo['isverified'] && !empty($reginfo['verificationsent']) && ($regExpireDays > 0)) {
try {
$expiresUTC = new DateTime($reginfo['verificationsent'], new DateTimeZone('UTC'));
} catch (Exception $e) {
$expiresUTC = new DateTime(Users_Constant::EXPIRED, new DateTimeZone('UTC'));
}
$expiresUTC->modify("+{$regExpireDays} days");
$reginfo['validuntil'] = DateUtil::formatDatetime($expiresUTC->format(Users_Constant::DATETIME_FORMAT),
$this->__('%m-%d-%Y %H:%M'));
}
return $this->view->assign('reginfo', $reginfo)
->assign('restoreview', $restoreView)
->assign('cancelurl', $cancelUrl)
->fetch('users_admin_denyregistration.tpl');
} else {
$denied = ModUtil::apiFunc($this->name, 'registration', 'remove', array(
'reginfo' => $reginfo,
));
if (!$denied) {
$this->registerError($this->__f('Sorry! There was a problem deleting the registration for \'%1$s\'.', $reginfo['uname']));
$this->redirect($cancelUrl);
} else {
//.........这里部分代码省略.........
示例9: view
/**
* Display full list of ephemerides
* @author The Zikula Development Team
* @return string HTML string
*/
public function view($args)
{
// security check
if (!SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_EDIT)) {
return LogUtil::registerPermissionError();
}
// Get parameters from whatever input we need.
$startnum = FormUtil::getPassedValue('startnum', isset($args['startnum']) ? $args['startnum'] : null, 'GET');
$keyword = FormUtil::getPassedValue('ephemerides_keyword', isset($args['ephemerides_keyword']) ? $args['ephemerides_keyword'] : '', 'POST');
$keyword_GET = FormUtil::getPassedValue('keyword', isset($args['keyword']) ? $args['keyword'] : '', 'GET');
if ($keyword_GET) {
$keyword = $keyword_GET;
}
$property = FormUtil::getPassedValue('ephemerides_property', isset($args['ephemerides_property']) ? $args['ephemerides_property'] : null, 'POST');
$property_GET = FormUtil::getPassedValue("property", isset($args["property"]) ? $args["property"] : null, 'GET');
if ($property_GET) {
$property = $property_GET;
}
$category = FormUtil::getPassedValue("ephemerides_{$property}_category", isset($args["ephemerides_{$property}_category"]) ? $args["ephemerides_{$property}_category"] : null, 'POST');
$category_GET = FormUtil::getPassedValue("category", isset($args["category"]) ? $args["category"] : null, 'GET');
if ($category_GET) {
$category = $category_GET;
}
$clear = FormUtil::getPassedValue('clear', false, 'POST');
if ($clear) {
$property = $category = $keyword = null;
}
$sort = FormUtil::getPassedValue('sort', '', 'GET');
$sortdir = FormUtil::getPassedValue('sortdir', '', 'GET');
if ($sortdir != 'ASC' && $sortdir != 'DESC') {
$sortdir = 'ASC';
}
// get all module vars
$modvars = ModUtil::getVar($this->name);
if ($modvars['enablecategorization']) {
$catregistry = CategoryRegistryUtil::getRegisteredModuleCategories($this->name, 'ephem');
$properties = array_keys($catregistry);
// validate and build the category filter - mateo
if (!empty($property) && in_array($property, $properties) && !empty($category)) {
$catFilter = array($property => $category);
}
// assign a default property - mateo
if (empty($property) || !in_array($property, $properties)) {
$property = $properties[0];
}
// plan ahead for ML features
$propArray = array();
foreach ($properties as $prop) {
$propArray[$prop] = $prop;
}
}
$filter = array('startnum' => $startnum, 'sort' => $sort, 'sortdir' => $sortdir, 'numitems' => $modvars['itemsperpage'], 'keyword' => $keyword, 'category' => isset($catFilter) ? $catFilter : null, 'catregistry' => isset($catregistry) ? $catregistry : null);
// get the matching ephemerides
$ephemerides = ModUtil::apiFunc($this->name, 'user', 'getall', $filter);
$items = array();
foreach ($ephemerides as $key => $item) {
// options for the item
$options = array();
$ephemerides[$key]['options'][] = array('url' => ModUtil::url($this->name, 'user', 'display', array('eid' => $item['eid'])), 'image' => 'demo.png', 'title' => $this->__('View'));
if (SecurityUtil::checkPermission($this->name . '::', "::" . $item['eid'], ACCESS_EDIT)) {
$ephemerides[$key]['options'][] = array('url' => ModUtil::url($this->name, 'admin', 'modify', array('eid' => $item['eid'])), 'image' => 'xedit.png', 'title' => $this->__('Edit'));
if (SecurityUtil::checkPermission($this->name . '::', "::" . $item['eid'], ACCESS_DELETE)) {
$ephemerides[$key]['options'][] = array('url' => ModUtil::url($this->name, 'admin', 'delete', array('eid' => $item['eid'])), 'image' => '14_layer_deletelayer.png', 'title' => $this->__('Delete'));
}
}
/*if ($item['yid'] < 1970) {
$item['yid'] = 1970;
}*/
//$ephemerides[$key]['datetime'] = DateUtil::formatDatetime(mktime(0, 0, 0, $item['mid'], $item['did'], $item['yid']), 'datelong');
// bug corrected, NP
$ephemerides[$key]['datetime'] = DateUtil::formatDatetime(mktime(12, 0, 0, $item['mid'], $item['did'], $item['yid']), 'datelong');
$items[] = $ephemerides[$key];
}
$this->view->setCaching(false);
// assign the default language
$this->view->assign('lang', ZLanguage::getLanguageCode());
// assign the items and modvars to the template
$this->view->assign('ephemerides', $items);
$this->view->assign($modvars);
// add the current filters
$this->view->assign('ephemerides_keyword', $keyword);
$this->view->assign('sort', $sort);
$this->view->assign('sortdir', $sortdir);
$this->view->assign('filter_active', empty($keyword) && empty($category) ? false : true);
// assign the categories information if enabled
if ($modvars['enablecategorization']) {
$this->view->assign('catregistry', $catregistry);
$this->view->assign('numproperties', count($propArray));
$this->view->assign('properties', $propArray);
$this->view->assign('property', $property);
$this->view->assign("category", $category);
} else {
$this->view->assign('property', '');
$this->view->assign("category", '');
}
//.........这里部分代码省略.........
示例10: parseDate
/**
* Parses and reformats a date for user entry validation.
*
* @param string &$datestring The entered date string to be parsed; NOTE: passed by reference, the value will be changed to a date reformatted with
* the "%d.%m.%Y" date format string; required.
*
* @return string The parsed date string, as returned by {@link DateUtil::parseUIDate()}.
*/
protected function parseDate(&$datestring) {
$dateformats = array(null,"%d.%m.%Y", "%Y-%m-%d", "%e.%n.%Y", "%e.%n.%y", "%Y/%m/%d", "%y/%m/%d");
$result = null;
foreach ($dateformats as $format) {
$result = DateUtil::parseUIDate($datestring, $format);
if ($result != null) {
$datestring = DateUtil::formatDatetime($result, "%d.%m.%Y", false);
break;
}
}
return $result;
}
示例11: getUserRank
/**
*
*/
public static function getUserRank($uid, $kind = 0)
{
$dom = ZLanguage::getModuleDomain('MUBoard');
$request = new Zikula_Request_Http();
$id = $request->query->filter('id', 0, FILTER_SANITIZE_NUMBER_INT);
if ($uid > 1) {
// we get a repository for users
$userrepository = MUBoard_Util_Model::getUserRepository();
// get infos of the relevant user
$where = 'tbl.userid = \'' . DataUtil::formatForStore($uid) . '\'';
$user = $userrepository->selectWhere($where);
if (count($user) == 1) {
$user = $user[0];
}
$userregDate = UserUtil::getVar('user_regdate', $uid);
$userregDate = DateUtil::formatDatetime($userregDate, 'datebrief');
$lastVisit = DateUtil::formatDatetime($user['lastVisit'], 'datebrief');
} else {
$userregDate = '';
$lastVisit = '';
}
$out = '';
$out .= __('Registered: ', $dom) . $userregDate . '<br />';
$isLoggedIn = ModUtil::apiFunc('MUBoard', 'selection', 'userOnline', array('uid' => $uid));
if ($isLoggedIn == false) {
$out .= __('Last Visit: ', $dom) . $lastVisit . '<br />';
} else {
$out .= '<span class="muboard-online">' . __('Online', $dom) . '</span><br />';
}
if ($uid > 1) {
if ($kind == 0) {
$out .= __('Postings: ', $dom) . $user['numberPostings'] . '<br />';
} else {
if ($id == 0) {
$user['numberPostings'] = $user['numberPostings'] + 1;
}
$out .= __('Postings: ', $dom) . $user['numberPostings'] . '<br />';
}
} else {
$out .= __('Postings: ', $dom) . '' . '<br />';
}
if ($uid > 1) {
$out .= __('Rank: ', $dom) . $user['rank']['name'] . '<br />';
} else {
$out .= __('Rank: ', $dom) . '' . '<br />';
}
if ($uid > 1) {
if ($user['rank']['special'] == 0) {
$imagepath = ModUtil::getVar('MUBoard', 'standardIcon');
for ($i = 0; $i < $user['rank']['numberOfIcons']; $i++) {
$out .= "<img src='" . $imagepath . "' />";
}
} else {
$out .= '<img src="';
if ($user[rank][uploadImageFullPath] != '') {
$out .= $user[rank][uploadImageFullPath];
} else {
$imagepath = ModUtil::getVar('MUBoard', 'specialIcon');
$out .= $imagepath;
}
$out .= '" />';
}
} else {
$out = '';
}
$out .= "<br />";
return $out;
}
示例12: create
/**
* create a new News item
*
* @param $args['name'] name of the item
* @param $args['number'] number of the item
* @return mixed News item ID on success, false on failure
*/
public function create($args)
{
// Argument check
if (!isset($args['title']) || empty($args['title']) ||
!isset($args['hometext']) ||
!isset($args['hometextcontenttype']) ||
!isset($args['bodytext']) ||
!isset($args['bodytextcontenttype']) ||
!isset($args['notes'])) {
return LogUtil::registerArgsError();
}
// evaluates the input action
$args['action'] = isset($args['action']) ? $args['action'] : null;
switch ($args['action'])
{
case News_Controller_User::ACTION_SUBMIT: // submitted => pending
$args['published_status'] = self::STATUS_PENDING;
break;
case News_Controller_User::ACTION_PUBLISH:
case News_Controller_User::ACTION_REJECT:
case News_Controller_User::ACTION_SAVEPENDING:
case News_Controller_User::ACTION_ARCHIVE:
$args['published_status'] = $args['action']-2;
break;
case News_Controller_User::ACTION_SAVEDRAFT:
case News_Controller_User::ACTION_SAVEDRAFT_RETURN:
$args['published_status'] = self::STATUS_DRAFT;
break;
}
// Security check
if (!SecurityUtil::checkPermission('News::', '::', ACCESS_COMMENT)) {
return LogUtil::registerPermissionError();
} elseif (SecurityUtil::checkPermission('News::', '::', ACCESS_ADD)) {
if (!isset($args['published_status'])) {
$args['published_status'] = self::STATUS_PUBLISHED;
}
} else {
$args['published_status'] = self::STATUS_PENDING;
}
// calculate the format type
$args['format_type'] = ($args['bodytextcontenttype']%4)*4 + $args['hometextcontenttype']%4;
// define the lowercase permalink, using the title as slug, if not present
if (!isset($args['urltitle']) || empty($args['urltitle'])) {
$args['urltitle'] = strtolower(DataUtil::formatPermalink($args['title']));
}
// check the publishing date options
if ((!isset($args['from']) && !isset($args['to'])) || (isset($args['unlimited']) && !empty($args['unlimited']))) {
$args['from'] = null;
$args['to'] = null;
} elseif (isset($args['from']) && (isset($args['tonolimit']) && !empty($args['tonolimit']))) {
$args['from'] = DateUtil::formatDatetime($args['from']);
$args['to'] = null;
} else {
$args['from'] = DateUtil::formatDatetime($args['from']);
$args['to'] = DateUtil::formatDatetime($args['to']);
}
// Work out name of story submitter and approver
$args['approver'] = 0;
if (!UserUtil::isLoggedIn() && empty($args['contributor'])) {
$args['contributor'] = System::getVar('anonymous');
} else {
$args['contributor'] = UserUtil::getVar('uname');
if ($args['published_status'] == self::STATUS_PUBLISHED) {
$args['approver'] = UserUtil::getVar('uid');
}
}
$args['counter'] = 0;
$args['comments'] = 0;
if (!($obj = DBUtil::insertObject($args, 'news', 'sid'))) {
return LogUtil::registerError($this->__('Error! Could not create new article.'));
}
// update the from field to the same cr_date if it's null
if (is_null($args['from'])) {
$obj = array('sid' => $obj['sid'], 'from' => $obj['cr_date']);
if (!DBUtil::updateObject($obj, 'news', '', 'sid')) {
LogUtil::registerError($this->__('Error! Could not save your changes.'));
}
}
// Return the id of the newly created item to the calling process
return $args['sid'];
}
示例13: completeqvinfo
/**
* Gets complementary information of a qv activity
* @author Sara Arjona Téllez (sarjona@xtec.cat)
* @param args The qv ($item) to add more information
* @return An array with the qv activity information
*/
public function completeqvinfo($args) {
extract($args);
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$user = ModUtil::func('IWmain', 'user', 'getUserInfo', array('sv' => $sv,
'uid' => $item['teacher'],
'info' => 'ncc'));
$item['teachername'] = $user;
$item['briefcrdate'] = DateUtil::formatDatetime($item['cr_date']);
return $item;
}
示例14: create_date
function create_date($format, $gmepoch, $tz)
{
// Begin PNphpBB2 Module
/*
global $board_config, $lang;
static $translate;
if ( empty($translate) && $board_config['default_lang'] != 'english' )
{
@reset($lang['datetime']);
while ( list($match, $replace) = @each($lang['datetime']) )
{
$translate[$match] = $replace;
}
}
return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz));
*/
//return ml_ftime($format, GetUserTime( $gmepoch )); // not functional in Zikula 1.2.x
return DateUtil::formatDatetime($gmepoch, $format);
// this works with Zikula 1.2.x
// End PNphpBB2 Module
}
示例15: update
/**
* update a News item
*
* @author Mark West
* @param int $args['sid'] the id of the item to be updated
* @param int $args['objectid'] generic object id maps to sid if present
* @param string $args['title'] the title of the news item
* @param string $args['urltitle'] the title of the news item formatted for the url
* @param string $args['language'] the language of the news item
* @param string $args['hometext'] the summary text of the news item
* @param int $args['hometextcontenttype'] the content type of the summary text
* @param string $args['bodytext'] the body text of the news item
* @param int $args['bodytextcontenttype'] the content type of the body text
* @param string $args['notes'] any administrator notes
* @param int $args['published_status'] the published status of the item
* @param int $args['displayonindex'] display the article on the index page
* @return bool true on update success, false on failiure
*/
public function update($args)
{
// Argument check
if (!isset($args['sid']) ||
!isset($args['title']) ||
!isset($args['hometext']) ||
!isset($args['hometextcontenttype']) ||
!isset($args['bodytext']) ||
!isset($args['bodytextcontenttype']) ||
!isset($args['notes']) ||
!isset($args['from']) ||
!isset($args['to'])) {
return LogUtil::registerArgsError();
}
if (!isset($args['language'])) {
$args['language'] = '';
}
// Get the news item
$item = ModUtil::apiFunc('News', 'user', 'get', array('sid' => $args['sid']));
if ($item == false) {
return LogUtil::registerError($this->__('Error! No such article found.'));
}
$this->throwForbiddenUnless($this->_isSubmittor($item) || SecurityUtil::checkPermission('News::', $item['cr_uid'] . '::' . $args['sid'], ACCESS_EDIT), LogUtil::getErrorMsgPermission());
// evaluates the input action
$args['action'] = isset($args['action']) ? $args['action'] : null;
switch ($args['action'])
{
case 1: // submitted => pending
$args['published_status'] = 2;
break;
case 2: // published
case 3: // rejected
case 4: // pending
case 5: // archived
case 6: // draft
$args['published_status'] = $args['action']-2;
break;
}
// calculate the format type
$args['format_type'] = ($args['bodytextcontenttype']%4)*4 + $args['hometextcontenttype']%4;
// define the lowercase permalink, using the title as slug, if not present
if (!isset($args['urltitle']) || empty($args['urltitle'])) {
$args['urltitle'] = strtolower(DataUtil::formatPermalink($args['title']));
}
// check the publishing date options
if (!empty($args['unlimited'])) {
$args['from'] = $item['cr_date'];
$args['to'] = null;
} elseif (!empty($args['tonolimit'])) {
$args['from'] = DateUtil::formatDatetime($args['from']);
$args['to'] = null;
} else {
$args['from'] = DateUtil::formatDatetime($args['from']);
$args['to'] = DateUtil::formatDatetime($args['to']);
}
if (!DBUtil::updateObject($args, 'news', '', 'sid')) {
return LogUtil::registerError($this->__('Error! Could not save your changes.'));
}
// Let the calling process know that we have finished successfully
return true;
}