当前位置: 首页>>代码示例>>PHP>>正文


PHP cmsCore::dateDiffNow方法代码示例

本文整理汇总了PHP中cmsCore::dateDiffNow方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::dateDiffNow方法的具体用法?PHP cmsCore::dateDiffNow怎么用?PHP cmsCore::dateDiffNow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cmsCore的用法示例。


在下文中一共展示了cmsCore::dateDiffNow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPost

 /**
  * Возвращает блог по ссылке или по id
  * @param int or string $id_or_link
  * @return array $blog
  */
 public function getPost($id_or_link = 0)
 {
     if (is_numeric($id_or_link)) {
         $where = "p.id = '{$id_or_link}'";
     } else {
         $where = "p.seolink = '{$id_or_link}'";
     }
     $sql = "SELECT p.*,\r\n\t\t\t\t\t   u.nickname as author_nickname,\r\n\t\t\t\t\t   u.login as author_login,\r\n\t\t\t\t\t   up.imageurl as author_image,\r\n\t\t\t\t\t   u.is_deleted as author_deleted\r\n\t\t\t\tFROM cms_blog_posts p\r\n\t\t\t\tLEFT JOIN cms_users u ON u.id = p.user_id\r\n\t\t\t\tLEFT JOIN cms_user_profiles up ON up.user_id = u.id\r\n\t\t\t\tWHERE {$where} LIMIT 1";
     $result = $this->inDB->query($sql);
     if (!$this->inDB->num_rows($result)) {
         return false;
     }
     global $_LANG;
     $post = $this->inDB->fetch_assoc($result);
     $post['feditdate'] = cmsCore::dateFormat($post['edit_date']);
     $post['fpubdate'] = cmsCore::dateDiffNow($post['pubdate']) . ' ' . $_LANG['BACK'] . ' (' . cmsCore::dateFormat($post['pubdate']) . ')';
     //Убираем тег [cut]
     $post['content_html'] = preg_replace('/\\[(cut=)\\s*(.*?)\\]/ui', '', $post['content_html']);
     $post['author_avatar'] = cmsUser::getUserAvatarUrl($post['user_id'], 'small', $post['author_image'], $post['author_deleted']);
     return cmsCore::callEvent('GET_POST', $post);
 }
开发者ID:deltas1,项目名称:icms1,代码行数:26,代码来源:blog.class.php

示例2: getActionsLog

 /**
  * Возвращает массив событий для ленты активности
  * @return array
  */
 public function getActionsLog()
 {
     $inUser = cmsUser::getInstance();
     if (!$this->only_friends) {
         $this->inDB->where('log.is_friends_only = 0');
     }
     if (!$inUser->id) {
         $this->inDB->where('log.is_users_only = 0');
     }
     $pactions = cmsCore::callEvent('GET_BEFORE_ACTIONS', false);
     if ($pactions !== false) {
         return $pactions;
     }
     $sql = "SELECT log.*,\r\n\t\t               log.pubdate as orig_pubdate,\r\n                       a.message,\r\n                       a.name,\r\n                       u.nickname as user_nickname,\r\n                       u.login as user_login\r\n                FROM cms_actions_log log\r\n                LEFT JOIN cms_actions a ON a.id = log.action_id AND a.is_visible = 1\r\n                LEFT JOIN cms_users u ON u.id = log.user_id\r\n                WHERE 1=1 {$this->inDB->where}\r\n                ORDER BY log.id DESC\r\n\t\t\t\t";
     if ($this->inDB->limit) {
         $sql .= "LIMIT {$this->inDB->limit}";
     }
     $result = $this->inDB->query($sql);
     // Сбрасываем условия
     $this->inDB->resetConditions();
     if (!$this->inDB->num_rows($result)) {
         return false;
     }
     $actions = array();
     global $_LANG;
     $last_date = '';
     $today_date = date('j F Y');
     $yesterday_date = date('j F Y', time() - 3600 * 24);
     while ($action = $this->inDB->fetch_assoc($result)) {
         $action['item_date'] = '';
         $item_date = date('j F Y', strtotime($action['orig_pubdate']));
         if ($item_date != $last_date) {
             switch ($item_date) {
                 case $today_date:
                     $date = icms_ucfirst($_LANG['TODAY']);
                     break;
                 case $yesterday_date:
                     $date = icms_ucfirst($_LANG['YESTERDAY']);
                     break;
                 default:
                     $date = cmsCore::dateFormat($item_date, true, false, false);
             }
             $action['item_date'] = $date;
             $last_date = $item_date;
         }
         $action['object_link'] = $action['target_link'] = '';
         if ($action['object']) {
             $action['object_link'] = $action['object_url'] ? '<a href="' . $action['object_url'] . '" class="act_obj_' . $action['name'] . '">' . $action['object'] . '</a>' : $action['object'];
         }
         if ($action['target']) {
             $action['target_link'] = '<a href="' . $action['target_url'] . '" class="act_tgt_' . $action['name'] . '">' . $action['target'] . '</a>';
         }
         if ($action['message']) {
             $target_pos = mb_strpos($action['message'], '|');
             if ($target_pos !== false) {
                 if (!$this->show_targets || !$action['target']) {
                     $action['message'] = mb_substr($action['message'], 0, $target_pos);
                 } else {
                     $action['message'] = str_replace('|', '', $action['message']);
                 }
             }
             $action['message'] = sprintf($action['message'], $action['object_link'], $action['target_link']);
         }
         $action['is_new'] = (bool) (strtotime($action['pubdate']) > strtotime($inUser->logdate));
         $action['user_url'] = cmsUser::getProfileURL($action['user_login']);
         $action['pubdate'] = cmsCore::dateDiffNow($action['pubdate']);
         $actions[] = $action;
     }
     return cmsCore::callEvent('GET_ACTIONS', $actions);
 }
开发者ID:deltas1,项目名称:icms1,代码行数:74,代码来源:actions.class.php

示例3: getActionsLog

 /**
  * Возвращает массив событий для ленты активности
  * @return array
  */
 public function getActionsLog()
 {
     $inUser = cmsUser::getInstance();
     if (!$this->only_friends) {
         $this->inDB->where('log.is_friends_only = 0');
     }
     if (!$inUser->id) {
         $this->inDB->where('log.is_users_only = 0');
     }
     $sql = "SELECT log.id as id,\n                       log.user_id,\n                       log.object,\n                       log.object_url,\n                       log.target,\n                       log.target_url,\n                       log.pubdate,\n                       log.description,\n                       a.message,\n                       a.name,\n                       u.nickname as user_nickname,\n                       u.login as user_login\n                FROM cms_actions_log log\n                LEFT JOIN cms_actions a ON a.id = log.action_id AND a.is_visible = 1\n                LEFT JOIN cms_users u ON u.id = log.user_id\n                WHERE 1=1 {$this->inDB->where}\n                ORDER BY log.id DESC\n\t\t\t\t";
     if ($this->inDB->limit) {
         $sql .= "LIMIT {$this->inDB->limit}";
     }
     $result = $this->inDB->query($sql);
     // Сбрасываем условия
     $this->inDB->resetConditions();
     if (!$this->inDB->num_rows($result)) {
         return false;
     }
     $actions = array();
     while ($action = $this->inDB->fetch_assoc($result)) {
         $action['object_link'] = $action['target_link'] = '';
         if ($action['object']) {
             $action['object_link'] = $action['object_url'] ? '<a href="' . $action['object_url'] . '" class="act_obj_' . $action['name'] . '">' . $action['object'] . '</a>' : $action['object'];
         }
         if ($action['target']) {
             $action['target_link'] = '<a href="' . $action['target_url'] . '" class="act_tgt_' . $action['name'] . '">' . $action['target'] . '</a>';
         }
         if ($action['message']) {
             $target_pos = mb_strpos($action['message'], '|');
             if ($target_pos !== false) {
                 if (!$this->show_targets || !$action['target']) {
                     $action['message'] = mb_substr($action['message'], 0, $target_pos);
                 } else {
                     $action['message'] = str_replace('|', '', $action['message']);
                 }
             }
             $action['message'] = sprintf($action['message'], $action['object_link'], $action['target_link']);
         }
         $action['is_new'] = (bool) (strtotime($action['pubdate']) > strtotime($inUser->logdate));
         $action['user_url'] = cmsUser::getProfileURL($action['user_login']);
         $action['pubdate'] = cmsCore::dateDiffNow($action['pubdate']);
         $actions[] = $action;
     }
     return cmsCore::callEvent('GET_ACTIONS', $actions);
 }
开发者ID:4uva4ek,项目名称:svato,代码行数:50,代码来源:actions.class.php

示例4: getOnlineStatus

 /**
  * Возвращает отформатированную дату последнего визита
  * @param int $user_id ID пользователя
  * @param str $logdate Дата последнего визита
  * @return str
  */
 public static function getOnlineStatus($user_id, $logdate = '')
 {
     global $_LANG;
     if (self::isOnline($user_id)) {
         $status = '<span class="online">' . $_LANG['ONLINE'] . '</span>';
     } else {
         if ($logdate) {
             $status = '<span class="logdate">' . cmsCore::dateDiffNow($logdate) . ' ' . $_LANG['BACK'] . '</span>';
         } else {
             $status = '<span class="offline">' . $_LANG['OFFLINE'] . '</span>';
         }
     }
     return $status;
 }
开发者ID:vicktorwork,项目名称:cms1,代码行数:20,代码来源:user.class.php

示例5: getUser

    public function getUser($login){

		if(is_numeric($login)){
			$where = "u.id = '{$login}'";
		} else {
			$where = "u.login = '{$login}'";
		}

		$sql = "SELECT
				u.*,
                u.status as status_text,
				u.rating as user_rating,
                p.id as pid, p.city, p.description, p.showmail, p.showbirth, p.showicq,
				p.karma, p.imageurl, p.allow_who,
				p.gender as gender,	p.formsdata, p.signature,
				p.email_newmsg, p.cm_subscribe,
				g.title as grp,
				g.alias as group_alias,
				b.user_id as banned,
                IFNULL(ui.login, '') as inv_login,
                IFNULL(ui.nickname, '') as inv_nickname
                FROM cms_users u
				INNER JOIN cms_user_profiles p ON p.user_id = u.id
				INNER JOIN cms_user_groups g ON g.id = u.group_id
				LEFT JOIN cms_banlist b ON b.user_id = u.id AND b.status = 1
                LEFT JOIN cms_users ui ON ui.id = u.invited_by
                WHERE u.is_locked = 0 AND {$where}
                ORDER BY id DESC LIMIT 1";

        $result = $this->inDB->query($sql);

        if (!$this->inDB->num_rows($result)){ return false; }

        $user = $this->inDB->fetch_assoc($result);

		global $_LANG;

		$user['avatar'] = cmsUser::getUserAvatarUrl($user['id'], 'big', $user['imageurl'], $user['is_deleted']);
		$user['status_date'] = cmsCore::dateDiffNow($user['status_date']);
		$user['flogdate']    = cmsUser::getOnlineStatus($user['id'], $user['logdate']);
		$user['fregdate']    = cmsCore::dateFormat($user['regdate']);
		$user['fbirthdate']  = cmsCore::dateFormat($user['birthdate']);
		$user['cityurl']     = urlencode($user['city']);
		$user['profile_link'] = HOST . cmsUser::getProfileURL($user['login']);
		$user['fdescription'] = cmsPage::getMetaSearchLink('/users/hobby/', $user['description']);
        $user['formsdata']    = cmsCore::yamlToArray($user['formsdata']);
		if ($user['gender']) {
			switch ($user['gender']){
				case 'm': $user['fgender'] = $_LANG['MALES']; break;
				case 'f': $user['fgender'] = $_LANG['FEMALES']; break;
				default:  $user['fgender'] = '';
			}
		}

        return cmsCore::callEvent('GET_USER', $user);

    }
开发者ID:Acsac,项目名称:CMS-RuDi,代码行数:57,代码来源:model.php


注:本文中的cmsCore::dateDiffNow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。