コード例 #1
0
ファイル: BLOG.php プロジェクト: hatone/Nucleus-v3.64
 /**
  * Shows the archivelist using the given template
  */
 function showArchiveList($template, $mode = 'month', $limit = 0)
 {
     global $CONF, $catid, $manager;
     if (!isset($linkparams)) {
         $linkparams = array();
     }
     if ($catid) {
         $linkparams = array('catid' => $catid);
     }
     $template =& $manager->getTemplate($template);
     $data['blogid'] = $this->getID();
     $tplt = isset($template['ARCHIVELIST_HEADER']) ? $template['ARCHIVELIST_HEADER'] : '';
     echo TEMPLATE::fill($tplt, $data);
     $query = 'SELECT itime, SUBSTRING(itime,1,4) AS Year, SUBSTRING(itime,6,2) AS Month, SUBSTRING(itime,9,2) as Day FROM ' . sql_table('item') . ' WHERE iblog=' . $this->getID() . ' and itime <=' . mysqldate($this->getCorrectTime()) . ' and idraft=0';
     // don't show draft items
     if ($catid) {
         $query .= ' and icat=' . intval($catid);
     }
     $query .= ' GROUP BY Year';
     if ($mode == 'month' || $mode == 'day') {
         $query .= ', Month';
     }
     if ($mode == 'day') {
         $query .= ', Day';
     }
     $query .= ' ORDER BY itime DESC';
     if ($limit > 0) {
         $query .= ' LIMIT ' . intval($limit);
     }
     $res = sql_query($query);
     while ($current = sql_fetch_object($res)) {
         $current->itime = strtotime($current->itime);
         // string time -> unix timestamp
         if ($mode == 'day') {
             $archivedate = date('Y-m-d', $current->itime);
             $archive['day'] = date('d', $current->itime);
             $data['day'] = date('d', $current->itime);
             $data['month'] = date('m', $current->itime);
             $archive['month'] = $data['month'];
         } elseif ($mode == 'year') {
             $archivedate = date('Y', $current->itime);
             $data['day'] = '';
             $data['month'] = '';
             $archive['day'] = '';
             $archive['month'] = '';
         } else {
             $archivedate = date('Y-m', $current->itime);
             $data['month'] = date('m', $current->itime);
             $archive['month'] = $data['month'];
             $data['day'] = '';
             $archive['day'] = '';
         }
         $data['year'] = date('Y', $current->itime);
         $archive['year'] = $data['year'];
         $data['archivelink'] = createArchiveLink($this->getID(), $archivedate, $linkparams);
         $manager->notify('PreArchiveListItem', array('listitem' => &$data));
         $temp = TEMPLATE::fill($template['ARCHIVELIST_LISTITEM'], $data);
         echo strftimejp($temp, $current->itime);
     }
     sql_free_result($res);
     $tplt = isset($template['ARCHIVELIST_FOOTER']) ? $template['ARCHIVELIST_FOOTER'] : '';
     echo TEMPLATE::fill($tplt, $data);
 }
コード例 #2
0
ファイル: ITEMACTIONS.php プロジェクト: hatone/Nucleus-v3.64
 /**
  * Parse templatevar time
  *
  * @param format optional strftime format
  */
 function parse_time($format = '')
 {
     if (!isset($this->template['FORMAT_TIME'])) {
         $this->template['FORMAT_TIME'] = '';
     }
     echo strftimejp($format ? $format : $this->template['FORMAT_TIME'], $this->currentItem->timestamp);
 }
コード例 #3
0
ファイル: ACTIONS.php プロジェクト: hatone/Nucleus-v3.64
 /**
  * %archivedate(locale,date format)%
  */
 function parse_archivedate($locale = '-def-')
 {
     global $archive;
     if ($locale == '-def-') {
         setlocale(LC_TIME, $template['LOCALE']);
     } else {
         setlocale(LC_TIME, $locale);
     }
     // get archive date
     sscanf($archive, '%d-%d-%d', $y, $m, $d);
     // get format
     $args = func_get_args();
     // format can be spread over multiple parameters
     if (sizeof($args) > 1) {
         // take away locale
         array_shift($args);
         // implode
         $format = implode(',', $args);
     } elseif ($d == 0 && $m != 0) {
         $format = '%B %Y';
     } elseif ($m == 0) {
         $format = '%Y';
     } else {
         $format = '%d %B %Y';
     }
     echo strftimejp($format, mktime(0, 0, 0, $m ? $m : 1, $d ? $d : 1, $y));
 }
コード例 #4
0
function formatDate($format, $timestamp, $defaultFormat, &$blog)
{
    // apply blog offset (#42)
    $boffset = $blog ? $blog->getTimeOffset() * 3600 : 0;
    $offset = date('Z', $timestamp) + $boffset;
    switch ($format) {
        case 'rfc822':
            if ($offset >= 0) {
                $tz = '+';
            } else {
                $tz = '-';
                $offset = -$offset;
            }
            $tz .= sprintf("%02d%02d", floor($offset / 3600), round($offset % 3600 / 60));
            return date('D, j M Y H:i:s ', $timestamp) . $tz;
        case 'rfc822GMT':
            $timestamp -= $offset;
            return date('D, j M Y H:i:s ', $timestamp) . 'GMT';
        case 'utc':
            $timestamp -= $offset;
            return date('Y-m-d\\TH:i:s\\Z', $timestamp);
        case 'iso8601':
            if ($offset >= 0) {
                $tz = '+';
            } else {
                $tz = '-';
                $offset = -$offset;
            }
            $tz .= sprintf("%02d:%02d", floor($offset / 3600), round($offset % 3600 / 60));
            return date('Y-m-d\\TH:i:s', $timestamp) . $tz;
        default:
            return strftimejp($format ? $format : $defaultFormat, $timestamp);
    }
}
コード例 #5
0
 /**
  * Parse templatevar time
  */
 function parse_time($format = '')
 {
     echo strftimejp($format == '' ? $this->template['FORMAT_TIME'] : $format, $this->currentComment['timestamp']);
 }