[geeklog-hg] geeklog: Fixed Article Directory Header tags (bug #0001598)
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sat May 18 08:16:28 EDT 2013
changeset 9068:b4addb5d3f56
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/b4addb5d3f56
user: dengen
date: Sat May 18 21:15:07 2013 +0900
description:
Fixed Article Directory Header tags (bug #0001598)
diffstat:
public_html/directory.php | 410 +++++++++++--------
public_html/layout/denim/directory.thtml | 25 +
public_html/layout/modern_curve/directory.thtml | 25 +
public_html/layout/professional/directory.thtml | 20 +
public_html/layout/professional_css/directory.thtml | 25 +
5 files changed, 327 insertions(+), 178 deletions(-)
diffs (truncated from 820 to 300 lines):
diff -r 9a01f429338b -r b4addb5d3f56 public_html/directory.php
--- a/public_html/directory.php Sun May 12 17:11:43 2013 +0900
+++ b/public_html/directory.php Sat May 18 21:15:07 2013 +0900
@@ -46,12 +46,17 @@
if (COM_isAnonUser() && (($_CONF['loginrequired'] == 1) ||
($_CONF['directoryloginrequired'] == 1))) {
- $display = COM_createHTMLDocument(SEC_loginRequiredForm(), array('pagetitle' => $LANG_DIR['title']));
-
+ $display = COM_createHTMLDocument(SEC_loginRequiredForm(),
+ array('pagetitle' => $LANG_DIR['title']));
COM_output($display);
exit;
}
+$theme = isset($_USER['theme']) ? $_USER['theme'] : $_CONF['theme'];
+clearstatcache();
+define ('TEMPLATE_EXISTS', file_exists($_CONF['path_themes']
+ . $theme . '/directory.thtml'));
+
/**
* Helper function: Calculate last day of a given month
*
@@ -64,7 +69,7 @@
* of the next month", http://www.php.net/manual/en/function.mktime.php
*
*/
-function DIR_lastDayOfMonth ($month, $year)
+function DIR_lastDayOfMonth($month, $year)
{
$month++;
if ($month > 12) {
@@ -72,7 +77,7 @@
$year++;
}
- $lastday = mktime (0, 0, 0, $month, 0, $year);
+ $lastday = mktime(0, 0, 0, $month, 0, $year);
return intval(strftime('%d', $lastday));
}
@@ -80,29 +85,26 @@
/**
* Display a topic selection drop-down menu
*
-* @param string $dir_topic current topic
-* @param int $year current year
-* @param int $month current month
-* @param boolean $standalone true: don't display form inline
+* @param string $dir_topic current topic
+* @param int $year current year
+* @param int $month current month
+* @return string HTML string of drop-down menu
*
*/
-function DIR_topicList ($dir_topic = 'all', $year = 0, $month = 0, $standalone = false)
+function DIR_topicList($dir_topic = 'all', $year = 0, $month = 0)
{
global $_CONF, $LANG21;
$retval = '';
- $url = $_CONF['site_url'] . '/' . THIS_SCRIPT;
- $retval .= '<form action="' . $url . '" method="post"';
- if (!$standalone) {
- $retval .= ' style="display:inline; float:right"' . LB;
- }
- $retval .= '><div>' . LB;
+ $retval .= '<form class="floatright" action="';
+ $retval .= $_CONF['site_url'] . '/' . THIS_SCRIPT;
+ $retval .= '" method="post" style="margin:0"><div>' . LB;
$retval .= '<select name="topic" onchange="this.form.submit()">' . LB;
- $retval .= TOPIC_getTopicListSelect($dir_topic, 2, true);
+ $retval .= TOPIC_getTopicListSelect($dir_topic, 2, true) . LB;
$retval .= '</select>' . LB;
- $retval .= '<input type="hidden" name="year" value="' . $year . '"' . XHTML . '>';
- $retval .= '<input type="hidden" name="month" value="' . $month . '"' . XHTML . '>';
+ $retval .= '<input type="hidden" name="year" value="' . $year . '"' . XHTML . '>' . LB;
+ $retval .= '<input type="hidden" name="month" value="' . $month . '"' . XHTML . '>' . LB;
$retval .= '</div></form>' . LB;
return $retval;
@@ -118,17 +120,17 @@
* @return string month name + count, as link or plain text
*
*/
-function DIR_monthLink ($dir_topic, $year, $month, $count)
+function DIR_monthLink($dir_topic, $year, $month, $count)
{
global $_CONF, $LANG_MONTH;
$retval = $LANG_MONTH[$month] . ' (' . COM_numberFormat ($count) . ')' . LB;
if ($count > 0) {
- $month_url = COM_buildUrl ($_CONF['site_url'] . '/'
+ $month_url = COM_buildUrl($_CONF['site_url'] . '/'
. THIS_SCRIPT . '?topic=' . urlencode ($dir_topic) . '&year='
. $year . '&month=' . $month);
- $retval = COM_createLink ($retval, $month_url);
+ $retval = COM_createLink($retval, $month_url);
}
$retval .= LB;
@@ -145,14 +147,12 @@
* @return string navigation bar with prev, next, and "up" links
*
*/
-function DIR_navBar ($dir_topic, $year, $month = 0)
+function DIR_navBar($dir_topic, $year, $month = 0)
{
global $_CONF, $_TABLES, $LANG05, $LANG_DIR;
$retval = '';
- $retval .= '<div class="pagenav">';
-
if ($month == 0) {
$prevyear = $year - 1;
$nextyear = $year + 1;
@@ -171,18 +171,19 @@
}
}
- $result = DB_query ("SELECT MIN(EXTRACT(Year from date)) AS year FROM {$_TABLES['stories']}");
- $A = DB_fetchArray ($result);
+ $result = DB_query("SELECT MIN(EXTRACT(Year from date)) AS year FROM {$_TABLES['stories']}");
+ $A = DB_fetchArray($result);
if ($prevyear < $A['year']) {
$prevyear = 0;
}
- $currentyear = date('Y', time());
+ $currenttime = time();
+ $currentyear = date('Y', $currenttime);
if ($nextyear > $currentyear) {
$nextyear = 0;
}
if (($month > 0) && ($nextyear > 0) && ($nextyear >= $currentyear)) {
- $currentmonth = date('n', time());
+ $currentmonth = date('n', $currenttime);
if ($nextmonth > $currentmonth) {
$nextyear = 0;
}
@@ -190,11 +191,11 @@
if ($prevyear > 0) {
$url = $_CONF['site_url'] . '/' . THIS_SCRIPT . '?topic='
- . urlencode ($dir_topic) . '&year=' . $prevyear;
+ . urlencode($dir_topic) . '&year=' . $prevyear;
if ($month > 0) {
$url .= '&month=' . $prevmonth;
}
- $retval .= COM_createLink($LANG05[6], COM_buildUrl ($url));
+ $retval .= COM_createLink($LANG05[6], COM_buildUrl($url));
} else {
$retval .= $LANG05[6];
}
@@ -203,7 +204,7 @@
$url = $_CONF['site_url'] . '/' . THIS_SCRIPT;
if ($dir_topic != 'all') {
- $url = COM_buildUrl ($url . '?topic=' . urlencode ($dir_topic));
+ $url = COM_buildUrl($url . '?topic=' . urlencode($dir_topic));
}
$retval .= COM_createLink($LANG_DIR['nav_top'] , $url);
@@ -212,107 +213,106 @@
if ($nextyear > 0) {
$url = $_CONF['site_url'] . '/' . THIS_SCRIPT . '?topic='
- . urlencode ($dir_topic) . '&year=' . $nextyear;
+ . urlencode($dir_topic) . '&year=' . $nextyear;
if ($month > 0) {
$url .= '&month=' . $nextmonth;
}
- $retval .= COM_createLink($LANG05[5], COM_buildUrl ($url));
+ $retval .= COM_createLink($LANG05[5], COM_buildUrl($url));
} else {
$retval .= $LANG05[5];
}
- $retval .= '</div>' . LB;
-
return $retval;
}
/**
* Display month view
*
+* @param ref &$template reference of the template
* @param string $dir_topic current topic
* @param int $year year to display
* @param int $month month to display
-* @param boolean $main true: display view on its own page
* @return string list of articles for the given month
*
*/
-function DIR_displayMonth ($dir_topic, $year, $month, $main = false)
+function DIR_displayMonth(&$template, $dir_topic, $year, $month)
{
global $_CONF, $_TABLES, $LANG_MONTH, $LANG_DIR;
$retval = '';
- if ($main) {
- $retval .= '<div><h1 style="display:inline">' . $LANG_MONTH[$month]
- . ' ' . $year . '</h1> ' . DIR_topicList ($dir_topic, $year, $month)
- . '</div>' . LB;
- } else {
- $retval .= '<h1>' . $LANG_MONTH[$month] . ' ' . $year . '</h1>' . LB;
- }
-
- $start = sprintf ('%04d-%02d-01 00:00:00', $year, $month);
- $lastday = DIR_lastDayOfMonth ($month, $year);
- $end = sprintf ('%04d-%02d-%02d 23:59:59', $year, $month, $lastday);
+ $start = sprintf('%04d-%02d-01 00:00:00', $year, $month);
+ $lastday = DIR_lastDayOfMonth($month, $year);
+ $end = sprintf('%04d-%02d-%02d 23:59:59', $year, $month, $lastday);
$sql = array();
- $sql['mysql'] = "SELECT sid,title,UNIX_TIMESTAMP(date) AS day,DATE_FORMAT(date, '%e') AS mday
- FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
- WHERE (date >= '$start') AND (date <= '$end') AND (draft_flag = 0) AND (date <= NOW())
+ $sql['mysql'] = "SELECT sid,title,UNIX_TIMESTAMP(date) AS day,DATE_FORMAT(date, '%e') AS mday
+ FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
+ WHERE (date >= '$start') AND (date <= '$end') AND (draft_flag = 0) AND (date <= NOW())
AND ta.type = 'article' AND ta.id = sid ";
-
+
$sql['mssql'] = $sql['mysql'];
-
- $sql['pgsql'] = "SELECT sid,title,UNIX_TIMESTAMP(date) AS day,EXTRACT(day from date) AS mday
- FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
- WHERE (date >= '$start') AND (date <= '$end') AND (draft_flag = 0) AND (date <= NOW())
+
+ $sql['pgsql'] = "SELECT sid,title,UNIX_TIMESTAMP(date) AS day,EXTRACT(day from date) AS mday
+ FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
+ WHERE (date >= '$start') AND (date <= '$end') AND (draft_flag = 0) AND (date <= NOW())
AND ta.type = 'article' AND ta.id = sid ";
-
+
if ($dir_topic != 'all') {
$sql['mysql'] .= " AND ta.tid = '$dir_topic'";
$sql['mssql'] = $sql['mysql'];
$sql['pgsql'] .= " AND ta.tid = '$dir_topic'";
}
- $sql['mysql'] .= COM_getTopicSql ('AND', 0, 'ta') . COM_getPermSql ('AND')
- . COM_getLangSQL ('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
- $sql['mssql'] .= COM_getTopicSql ('AND', 0, 'ta') . COM_getPermSql ('AND')
- . COM_getLangSQL ('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
- $sql['pgsql'] .= COM_getTopicSql ('AND', 0, 'ta') . COM_getPermSql ('AND')
- . COM_getLangSQL ('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
+ $sql['mysql'] .= COM_getTopicSql('AND', 0, 'ta') . COM_getPermSql('AND')
+ . COM_getLangSQL('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
+ $sql['mssql'] .= COM_getTopicSql('AND', 0, 'ta') . COM_getPermSql('AND')
+ . COM_getLangSQL('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
+ $sql['pgsql'] .= COM_getTopicSql('AND', 0, 'ta') . COM_getPermSql('AND')
+ . COM_getLangSQL('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
- $result = DB_query ($sql);
- $numrows = DB_numRows ($result);
+ $result = DB_query($sql);
+ $numrows = DB_numRows($result);
if ($numrows > 0) {
- $entries = array ();
+ $entries = array();
$mday = 0;
for ($i = 0; $i < $numrows; $i++) {
- $A = DB_fetchArray ($result);
+ $A = DB_fetchArray($result);
if ($mday != $A['mday']) {
if (count($entries) > 0) {
- $retval .= COM_makeList ($entries);
- $entries = array ();
+ $retval .= COM_makeList($entries);
+ $entries = array();
}
- $day = strftime ($_CONF['shortdate'], $A['day']);
+ $day = strftime($_CONF['shortdate'], $A['day']);
- $retval .= '<h2>' . $day . '</h2>' . LB;
+ if (TEMPLATE_EXISTS) {
+ $template->set_var('section_title', $day);
+ $retval .= $template->parse('title', 'section-title') . LB;
+ } else {
+ $retval .= '<h3>' . $day . '</h3>' . LB;
+ }
$mday = $A['mday'];
}
- $url = COM_buildUrl ($_CONF['site_url'] . '/article.php?story='
- . $A['sid']);
- $entries[] = COM_createLink(stripslashes ($A['title']), $url);
+ $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story='
+ . $A['sid']);
More information about the geeklog-cvs
mailing list