Browse Source

* Stick / Unstick buttons at the bottom of the page for the admin (first name in 'mods.txt')

(some finishing off and polishing remains)
* Updated the image generation script for the above change as well as a little re-organisation
master
Kroc Camen 8 years ago
parent
commit
d16c4322d6
13 changed files with 215 additions and 177 deletions
  1. +3
    -0
      HISTORY.txt
  2. +6
    -11
      index.php
  3. +11
    -0
      lib/functions.php
  4. BIN
      metro-tile.default.png
  5. +3
    -0
      start.php
  6. +139
    -148
      themes/greyscale/img/generate_imgs.bat
  7. BIN
      themes/greyscale/img/sticky.png
  8. +1
    -1
      themes/greyscale/index.html
  9. +4
    -2
      themes/greyscale/lang.example.php
  10. BIN
      themes/greyscale/metro-tile.png
  11. +11
    -4
      themes/greyscale/theme.css
  12. +8
    -3
      themes/greyscale/thread.html
  13. +29
    -8
      thread.php

+ 3
- 0
HISTORY.txt View File

@@ -1,4 +1,7 @@
v26
* Stick and Unstick thread buttons when logged in as the Admin (the admin is now the first person listed in mods.txt)
NOTE: the lock and unlock links have been changed into buttons, make sure to update custom translations / CSS!
* Windows 8 snap-view
* Apache version is now verified (1&1 are still using v1.3!)
* Updated to DOMTemplate v17, fix for major bug corrupting querystrings and attributes,
with thanks to Bruno Héridet for narrowing down and Zegnat for suggesting a fix

+ 6
- 11
index.php View File

@@ -76,18 +76,13 @@ if ($threads = preg_grep ('/\.rss$/', scandir ('.'))) {
//order by last modified date
array_multisort (array_map ('filemtime', $threads), SORT_DESC, $threads);
//get sticky list, trimming any files that no longer exist
//get sticky list (see 'lib/functions.php')
//(the use of `array_intersect` will only return filenames in `sticky.txt` that were also in the directory)
if ($stickies = array_intersect (
//`file` returns NULL on failure, so we can cast it to an array to get an array with one blank item,
//then `array_filter` removes blank items. this way saves having to check if the file exists first
array_filter ((array) @file ('sticky.txt', FILE_IGNORE_NEW_LINES)), $threads
)) {
//order the stickies by reverse date order
array_multisort (array_map ('filemtime', $stickies), SORT_DESC, $stickies);
//remove the stickies from the thread list
$threads = array_diff ($threads, $stickies);
}
$stickies = array_intersect (getStickies (), $threads);
//order the stickies by reverse date order
array_multisort (array_map ('filemtime', $stickies), SORT_DESC, $stickies);
//remove the stickies from the thread list
$threads = array_diff ($threads, $stickies);
//handle a rounding problem with working out the number of pages (PHP 5.3 has a fix for this)
$PAGES = count ($threads) % FORUM_THREADS == 1 ? floor (count ($threads) / FORUM_THREADS)

+ 11
- 0
lib/functions.php View File

@@ -143,6 +143,10 @@ function prepareTemplate (

/* ====================================================================================================================== */

//the first mod on the list is the site administrator and has extra privileges such as stickying threads
function isAdmin ($name) {
global $MODS; return strtolower ($name) === strtolower ((string) @$MODS['GLOBAL'][0]);
}
//check to see if a name is a known moderator
function isMod ($name) {
global $MODS; return in_array (strtolower ($name), array_map ('strtolower', $MODS['GLOBAL'] + $MODS['LOCAL']));
@@ -152,6 +156,13 @@ function isMember ($name) {
global $MEMBERS; return in_array (strtolower ($name), array_map ('strtolower', $MEMBERS));
}

//get the list of sticky threads in the current forum / sub-forum
function getStickies () {
//`file` returns NULL on failure, so we can cast it to an array to get an array with one blank item,
//then `array_filter` removes blank items. this way saves having to check if the file exists first
return array_filter ((array) @file ('sticky.txt', FILE_IGNORE_NEW_LINES));
}

/* ====================================================================================================================== */

//take the author's message, process markup, and encode it safely for the RSS feed

BIN
metro-tile.default.png View File

Before After
Width: 144  |  Height: 144  |  Size: 101KB Width: 144  |  Height: 144  |  Size: 101KB

+ 3
- 0
start.php View File

@@ -41,6 +41,7 @@
see section 5 in the README file
$MODS array of the names of moderators for the whole forum, and the current sub-forum
$MEMBERS array of the names of members for the current sub-forum
IS_ADMIN b if the current viewer is the site admin (first name in 'mods.txt')
IS_MOD b if the current viewer is a moderator for the current forum
IS_MEMBER b if the current viewer is a member of the current forum
@@ -232,6 +233,8 @@ $MODS = array (
//get the list (if any) of users allowed to access this current forum
$MEMBERS = array_filter ((array) @file ('members.txt', FILE_IGNORE_NEW_LINES));

//is the current user the site admin? (first name in the root 'mods.txt')
define ('IS_ADMIN', AUTH && isAdmin (NAME));
//is the current user a moderator in this forum?
define ('IS_MOD', AUTH && isMod (NAME));
//is the current user a member of this forum?

+ 139
- 148
themes/greyscale/img/generate_imgs.bat View File

@@ -16,8 +16,14 @@ TITLE Generating images...
REM Change to the current directory
CD /d %~dp0

:: white 1x
IF NOT EXIST bin\pngout.exe ECHO Please download PNGOut to "bin\pngout.exe" & PAUSE & EXIT
IF NOT EXIST bin\optipng.exe ECHO Please download OptiPNG to "bin\optipng.exe" & PAUSE & EXIT
IF NOT EXIST bin\pngcrush.exe ECHO Please download PNGCrush to "bin\pngcrush.exe" & PAUSE & EXIT

:: generate spritesheets to work from
:: =========================================================================================================================
:: white 1x
:: -------------------------------------------------------------------------------------------------------------------------
:: convert the vector EPS to PNG, masking the alpha.
:: the antialias applied by default is no good, so we do it manually by resizing a very hires image down
IF NOT EXIST icons_white_1x.png (
@@ -26,6 +32,40 @@ IF NOT EXIST icons_white_1x.png (
-background "#f4f3f5" -resize 998x702 -alpha Shape -channel a -negate ^
icons_white_1x.png
)
:: white 2x
:: -------------------------------------------------------------------------------------------------------------------------
:: produce a version double the size for hi-DPI screens
IF NOT EXIST icons_white_2x.png (
ECHO icons white 2x...
convert +antialias -density 648 refs\brightmixIconset_v02.eps -colorspace RGB ^
-background "#f4f3f5" -resize 1996x1404 -alpha Shape -channel a -negate ^
icons_white_2x.png
)
:: black half size
:: -------------------------------------------------------------------------------------------------------------------------
:: the append icon is only available in large size (default:32x32), create a ½-size image so that we can get a 16x16 icon
IF NOT EXIST icons_black_half.png (
ECHO icons_black_half.png
convert +antialias -density 144 refs\brightmixIconset_v02.eps -colorspace RGB ^
-background "#f4f3f5" -resize 499x351 -alpha Shape -channel a -negate ^
icons_black_half.png
convert icons_black_half.png -negate icons_black_half.png
)
:: black 1x
:: -------------------------------------------------------------------------------------------------------------------------
:: invert to produce the black set
IF NOT EXIST icons_black_1x.png (
ECHO icons black 1x...
convert icons_white_1x.png -negate icons_black_1x.png
)
:: black 2x
:: -------------------------------------------------------------------------------------------------------------------------
:: invert to produce the black 2x set
IF NOT EXIST icons_black_2x.png (
ECHO icons black 2x...
convert icons_white_2x.png -negate icons_black_2x.png
)
ECHO.

:: crop and save the individual icons needed
:: -------------------------------------------------------------------------------------------------------------------------
@@ -35,235 +75,183 @@ IF NOT EXIST icons_white_1x.png (
:: `-define png:depth=8` and output as 8-bit too
:: `-define png:compression...` don’t compress, we’re going to optimise all the PNGs compression afterwards

ECHO * deletetitle.png
convert icons_white_1x.png -crop "32x32+625+270" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
deletetitle.png

ECHO * folders.png
convert icons_white_1x.png -crop "32x32+478+54" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
folders.png

ECHO * help.png
convert icons_white_1x.png -crop "32x32+273+432" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
help.png

ECHO * new.png
convert icons_white_1x.png -crop "32x32+273+54" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
new.png

ECHO * replies.png
convert icons_white_1x.png -crop "32x32+273+487" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
replies.png

ECHO * threads.png
convert icons_white_1x.png -crop "32x32+273+0" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
threads.png

:: black 1x
:: =========================================================================================================================
:: invert to produce the black set
IF NOT EXIST icons_black_1x.png (
ECHO. & ECHO icons black 1x...
convert icons_white_1x.png -negate icons_black_1x.png
)

ECHO * add.png
convert icons_black_1x.png -crop "16x16+875+152" ^
-background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
add.png

REM ECHO * delete.png
REM convert icons_black_1x.png -crop "16x16+875+177" ^
REM -background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
REM -define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
REM delete.png

ECHO * here.png
convert icons_black_1x.png -crop "16x20+979+58" ^
-background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
here.png

ECHO * rss.png
convert icons_black_1x.png -crop "16x16+182+62" ^
ECHO * add_2x.png
convert icons_black_2x.png -crop "32x32+1750+304" ^
-background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
rss.png

ECHO * search.png
convert icons_black_1x.png -crop "13x17+536+224" ^
-background "#ffffff" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
search.png

:: the append icon is only available in large size (default:32x32), create a ½-size image so that we can get a 16x16 icon
IF NOT EXIST icons_black_half.png (
ECHO (icons black half-size...)
convert +antialias -density 144 refs\brightmixIconset_v02.eps -colorspace RGB ^
-background "#f4f3f5" -resize 499x351 -alpha Shape -channel a -negate ^
icons_black_half.png
convert icons_black_half.png -negate icons_black_half.png
)
add_2x.png

ECHO * append.png
convert icons_black_half.png -crop "16x16+137+27" ^
-background "#888888" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
append.png
ECHO * append_2x.png
convert icons_black_1x.png -crop "32x32+273+54" ^
-background "#888888" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
append_2x.png

ECHO * delete.png
convert icons_black_half.png -crop "16x16+312+135" ^
-background "#888888" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
delete.png
ECHO * delete_2x.png
convert icons_black_1x.png -crop "32x32+625+270" ^
-background "#888888" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
delete_2x.png

:: white 2x
:: =========================================================================================================================
:: produce a version double the size for hi-DPI screens
IF NOT EXIST icons_white_2x.png (
ECHO. & ECHO icons white 2x...
convert +antialias -density 648 refs\brightmixIconset_v02.eps -colorspace RGB ^
-background "#f4f3f5" -resize 1996x1404 -alpha Shape -channel a -negate ^
icons_white_2x.png
)

ECHO * deletetitle.png
convert icons_white_1x.png -crop "32x32+625+270" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
deletetitle.png
ECHO * deletetitle_2x.png
convert icons_white_2x.png -crop "64x64+1250+540" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
deletetitle_2x.png

ECHO * folders.png
convert icons_white_1x.png -crop "32x32+478+54" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
folders.png
ECHO * folders_2x.png
convert icons_white_2x.png -crop "64x64+956+108" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
folders_2x.png

ECHO * go.png (2x)
convert icons_black_2x.png -crop "40x40+1352+228" ^
-background "#ffffff" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
go.png

ECHO * help.png
convert icons_white_1x.png -crop "32x32+273+432" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
help.png
ECHO * help_2x.png
convert icons_white_2x.png -crop "64x64+546+864" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
help_2x.png

ECHO * here.png
convert icons_black_1x.png -crop "16x20+979+58" ^
-background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
here.png
ECHO * here_2x.png
convert icons_black_2x.png -crop "32x40+1958+116" ^
-background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
here_2x.png

ECHO * lang.png (2x)
convert icons_black_2x.png -crop "40x40+1956+234" ^
-background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
lang.png

ECHO * logo.png (2x)
convert icons_white_2x.png -crop "64x64+956+0" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
logo.png

ECHO * new.png
convert icons_white_1x.png -crop "32x32+273+54" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
new.png
ECHO * new_2x.png
convert icons_white_2x.png -crop "64x64+546+108" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
new_2x.png

ECHO * replies.png
convert icons_white_1x.png -crop "32x32+273+487" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
replies.png
ECHO * replies_2x.png
convert icons_white_2x.png -crop "64x64+546+974" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
replies_2x.png

ECHO * submit.png (2x)
convert icons_white_2x.png -crop "80x80+1332+208" ^
-background "#444444" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
submit.png

ECHO * threads_2x.png
convert icons_white_2x.png -crop "64x64+546+0" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
threads_2x.png

:: black 2x
:: =========================================================================================================================
:: invert to produce the black 2x set
IF NOT EXIST icons_black_2x.png (
ECHO. & ECHO icons black 2x...
convert icons_white_2x.png -negate icons_black_2x.png
)

ECHO * add_2x.png
convert icons_black_2x.png -crop "32x32+1750+304" ^
-background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
add_2x.png

REM ECHO * delete_2x.png
REM convert icons_black_2x.png -crop "32x32+1750+354" ^
REM -background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
REM -define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
REM delete_2x.png

ECHO * go.png (2x)
convert icons_black_2x.png -crop "40x40+1352+228" ^
-background "#ffffff" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
go.png

ECHO * here_2x.png
convert icons_black_2x.png -crop "32x40+1958+116" ^
-background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
here_2x.png

ECHO * lang.png (2x)
convert icons_black_2x.png -crop "40x40+1956+234" ^
ECHO * rss.png
convert icons_black_1x.png -crop "16x16+182+62" ^
-background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
lang.png

rss.png
ECHO * rss_2x.png
convert icons_black_2x.png -crop "32x32+364+124" ^
-background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
rss_2x.png

ECHO * search.png
convert icons_black_1x.png -crop "13x17+536+224" ^
-background "#ffffff" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
search.png
ECHO * search_2x.png
convert icons_black_2x.png -crop "26x34+1072+448" ^
-background "#ffffff" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
search_2x.png

ECHO * sticky.png (2x)
convert icons_black_2x.png -crop "32x32+362+446" ^
ECHO * sticky.png
convert icons_black_1x.png -crop "16x16+182+223" ^
-background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
sticky.png
ECHO * sticky_2x.png
convert icons_black_2x.png -crop "32x32+362+446" ^
-background "#eeeeee" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
sticky_2x.png

::the 2x append / delete icon (32x32) actually comes from the 1x sheet
ECHO * append_2x.png
convert icons_black_1x.png -crop "32x32+273+54" ^
-background "#888888" -type Grayscale -depth 8 -alpha On ^
ECHO * submit.png (2x)
convert icons_white_2x.png -crop "80x80+1332+208" ^
-background "#444444" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
append_2x.png
submit.png

ECHO * delete_2x.png
convert icons_black_1x.png -crop "32x32+625+270" ^
-background "#888888" -type Grayscale -depth 8 -alpha On ^
ECHO * threads.png
convert icons_white_1x.png -crop "32x32+273+0" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
delete_2x.png
threads.png
ECHO * threads_2x.png
convert icons_white_2x.png -crop "64x64+546+0" ^
-background "#222222" -type Grayscale -depth 8 -alpha On ^
-define png:bit-depth=8 -define png:color-type=4 -define png:compression-level=0 ^
threads_2x.png
ECHO.

:: apple-touch-icon
ECHO. & ECHO apple-touch-icon.png
:: =========================================================================================================================
ECHO apple-touch-icon.png
convert +antialias -density 648 refs\brightmixIconset_v02.eps -colorspace RGB ^
-background "#f4f3f5" -resize 2495x1755 -alpha Shape -channel a -negate +channel ^
-crop "76x76+1196+2" -background "#222222" -gravity Center -extent 144x144 ^
-type Grayscale -define png:bit-depth=8 -define png:color-type=0 -define png:compression-level=0 ^
apple-touch-icon.png
ECHO.

:: compress PNGs
:: =========================================================================================================================
@@ -276,6 +264,7 @@ FOR %%F in (*.png) DO (
bin\optipng.exe -o7 -clobber -quiet "%%F"
bin\pngcrush.exe -brute -fix -keep bKGD -l 9 -reduce -q "%%F"
IF %ERRORLEVEL% EQU 0 ERASE "%%F" & REN "pngout.png" "%%F"
PAUSE
)

DEL ..\..\..\apple-touch-icon.default.png
@@ -283,11 +272,13 @@ COPY /Y apple-touch-icon.png ..\..\..\apple-touch-icon.default.png

DEL ..\apple-touch-icon.png
MOVE /Y apple-touch-icon.png ..
ECHO.

:: windows 8 tile icon
:: windows 8 Metro icon
:: =========================================================================================================================
:: due to a bug in Windows 8 this icon cannot be 8-bit, it must be 24-bit, so we have to render it after the others have
:: been optimised as the optimisations usually reduce bit-depth
ECHO. & ECHO metro-tile.png
ECHO metro-tile.png
convert +antialias -density 720 refs/brightmixIconset_v02.eps -colorspace RGB ^
-background "#ffffff" -resize 3992x2808 -alpha Shape -channel a -negate +channel ^
-crop "128x128+1912+4" -bordercolor none -border 8 ^

BIN
themes/greyscale/img/sticky.png View File

Before After
Width: 32  |  Height: 32  |  Size: 752B Width: 16  |  Height: 16  |  Size: 336B

+ 1
- 1
themes/greyscale/index.html View File

@@ -85,7 +85,7 @@
</ol></nav>
<ol class="ui"><li class="nnf_thread nnf_sticky">
<a class="nnf_thread-post" href="/thread#id"><time class="nnf_thread-time" datetime="2012-01-01T00:00:00+00:00">01 Jan ’12 · 00:00</time></a>
<i class="nnf_thread-replies">99</i> <b class="nnf_thread-author nnf_mod">Kroc</b> <img class="nnf_thread-sticky" src="/themes/greyscale/img/sticky.png" width="16" height="16" alt="Announcement:" title="Announcement:"><img class="nnf_thread-locked" src="/themes/greyscale/img/security_closed_32.png" width="16" height="16" alt="Locked:" title="Locked:">
<i class="nnf_thread-replies">99</i> <b class="nnf_thread-author nnf_mod">Kroc</b> <img class="nnf_thread-sticky" src="/themes/greyscale/img/sticky_2x.png" width="16" height="16" alt="Announcement:" title="Announcement:"><img class="nnf_thread-locked" src="/themes/greyscale/img/security_closed_32.png" width="16" height="16" alt="Locked:" title="Locked:">
<a class="nnf_thread-name" href="thread_title">The quick brown fox jumps over the lazy dog</a>
</li></ol>
<nav><ol class="nnf_pages">

+ 4
- 2
themes/greyscale/lang.example.php View File

@@ -498,8 +498,10 @@ HTML

/* site footer
---------------------------------------------------------------------------------------------------------------------- */
,'#nnf_lock' => 'Lock' //Lock link in 'thread.html'
,'#nnf_unlock' => 'Unlock' //Unlock link in 'thread.html'
,'#nnf_stick@value' => 'Stick' //Stick button in 'thread.html'
,'#nnf_unstick@value' => 'Unstick' //Unstick button in 'thread.html'
,'#nnf_lock@value' => 'Lock' //Lock button in 'thread.html'
,'#nnf_unlock@value' => 'Unlock' //Unlock button in 'thread.html'

,'#nnf_mods-local' => <<<HTML
Moderators for this sub-forum:

BIN
themes/greyscale/metro-tile.png View File

Before After
Width: 144  |  Height: 144  |  Size: 101KB Width: 144  |  Height: 144  |  Size: 101KB

+ 11
- 4
themes/greyscale/theme.css View File

@@ -365,12 +365,17 @@ input[type=text],

/* site footer
====================================================================================================================== */
#nnf_admin {float: right;}
a#nnf_lock, a#nnf_unlock {margin-left: 20px; padding-left: 25px; text-transform: uppercase;}
form#nnf_admin {float: right; border: none;}
form#nnf_admin input {margin-left: 20px; padding-left: 20px; border: none;
text-transform: uppercase; cursor: pointer;
/* TODO: webkit-appearance: none */}
/* lock / unlock icons courtesy of <picol.org>, under a Creative Commons Share-Alike 3.0 licence
<creativecommons.org/licenses/by-sa/3.0/> */
a#nnf_lock {background: url("img/security_closed_16.png") no-repeat 0 50%; background-size: 16px 16px;}
a#nnf_unlock {background: url("img/security_open_16.png") no-repeat 0 50%; background-size: 16px 16px;}
/* to-do: 1x & 2x */
#nnf_stick {background: url("img/sticky.png") no-repeat 0 50%; background-size: 16px 16px;}
#nnf_unstick {background: url("img/sticky.png") no-repeat 0 50%; background-size: 16px 16px;}
#nnf_lock {background: url("img/security_closed_16.png") no-repeat 0 50%; background-size: 16px 16px;}
#nnf_unlock {background: url("img/security_open_16.png") no-repeat 0 50%; background-size: 16px 16px;}

footer {position: absolute; height: 60px; margin: 0; padding: 20px 0 0; left: 0; right: 0;
_width: 125%; /*< IE6 has to override the 80% with a reverse %'age gain */
@@ -545,6 +550,8 @@ a.append {background-image: url("img/append_2x.png");}
#nnf_new-form h1,
#nnf_reply-form h1, #append h1{background-image: url("img/new_2x.png");}
#delete h1 {background-image: url("img/deletetitle_2x.png");}
a#nnf_stick {background-image: url("img/sticky_x2.png");}
a#nnf_unstick {background-image: url("img/sticky_x2.png");}
a#nnf_lock {background-image: url("img/security_closed_32.png");}
a#nnf_unlock {background-image: url("img/security_open_32.png");}


+ 8
- 3
themes/greyscale/thread.html View File

@@ -165,9 +165,14 @@
</form>
</section>
<!-- =================================================================================================================== -->
<div id="mods"><p id="nnf_admin">
<a id="nnf_lock" href="?lock" rel="noindex nofollow noarchive">Lock</a><a id="nnf_unlock" href="?unlock" rel="noindex nofollow noarchive">Unlock</a>
</p><p id="nnf_mods-local">
<div id="mods"><form id="nnf_admin" method="post"><!--
--><input type="submit" id="nnf_stick" name="stick" value="Stick" /><!--
--><input type="submit" id="nnf_unstick" name="unstick" value="Unstick" /><!--
--><input type="submit" id="nnf_lock" name="lock" value="Lock" /><!--
--><input type="submit" id="nnf_unlock" name="unlock" value="Unlock" /><!--
--><!--<a id="nnf_lock" href="?lock" rel="noindex nofollow noarchive">Lock</a>--><!--
--><!--<a id="nnf_unlock" href="?unlock" rel="noindex nofollow noarchive">Unlock</a>--><!--
--></form><p id="nnf_mods-local">
Moderators for this sub-forum:
<span id="nnf_mods-local-list"><b class="nnf_mod">Alice</b></span>
</p><p id="nnf_mods">

+ 29
- 8
thread.php View File

@@ -37,11 +37,28 @@ define ('CAN_REPLY', FORUM_ENABLED && (
(!(bool) $xml->channel->xpath ('category[.="locked"]') && (!FORUM_LOCK || FORUM_LOCK == 'threads'))
));

/* ======================================================================================================================
thread stick / unstick action
====================================================================================================================== */
if ( (isset ($_POST['stick']) || isset ($_POST['unstick'])) &&
//the site admin, or the first mod of the sub-forum have stick / unstick rights
(IS_ADMIN || strtolower (NAME) === strtolower ((string) @$MODS['LOCAL'][0]))
) {
if (in_array ("$FILE.rss", $stickies = getStickies ())) {
$stickies = array_diff ($stickies, array ("$FILE.rss"));
} else {
$stickies[] = "$FILE.rss";
};
file_put_contents ('sticky.txt', implode ("\r\n", $stickies), LOCK_EX);
//TODO: redirect to eat the form submission
}

/* ======================================================================================================================
thread lock / unlock action
====================================================================================================================== */
if ((isset ($_GET['lock']) || isset ($_GET['unlock'])) && IS_MOD && AUTH) {
if ((isset ($_POST['lock']) || isset ($_POST['unlock'])) && IS_MOD) {
//get a read/write lock on the file so that between now and saving, no other posts could slip in
//normally we could use a write-only lock 'c', but on Windows you can't read the file when write-locked!
$f = fopen ("$FILE.rss", 'r+'); flock ($f, LOCK_EX);
@@ -442,7 +459,11 @@ if (CAN_REPLY && AUTH && TEXT) {
/* ======================================================================================================================
template thread
====================================================================================================================== */
//load the template into DOM where we can manipulate it:
//is this thread stickied?
define ('IS_STICKY', in_array ("$FILE.rss", $stickies = getStickies ()));

/* load the template into DOM where we can manipulate it:
--------------------------------------------------------------------------------------------------------------------- */
//(see 'lib/domtemplate.php' or <camendesign.com/dom_templating> for more details)
$template = prepareTemplate (
THEME_ROOT.'thread.html',
@@ -458,21 +479,21 @@ $template = prepareTemplate (
)->set (array (
//the thread itself is the RSS feed :)
'//link[@rel="alternate"]/@href, '.
'a#nnf_rss@href' => FORUM_PATH.PATH_URL."$FILE.rss",
//set the hyperlinks for lock / unlock actions (append current URL with 'lock' / 'unlock' querystrings)
'a#nnf_lock@href' => url (PATH_URL, $FILE, $PAGE, 'lock'),
'a#nnf_unlock@href' => url (PATH_URL, $FILE, $PAGE, 'unlock')
'a#nnf_rss@href' => FORUM_PATH.PATH_URL."$FILE.rss"
))->remove (array (
//if replies can't be added (forum or thread is locked, user is not moderator / member),
//remove the "add reply" link and anything else (like the input form) related to posting
'#nnf_reply, #nnf_reply-form' => !CAN_REPLY,
//if the forum is not post-locked (only mods can post / reply) then remove the warning message
'.nnf_forum-locked' => FORUM_LOCK != 'posts',
//is the user a mod and can lock / unlock the thread?
//is the user a mod and can lock / unlock / stick / unstick the thread?
'#nnf_admin' => !IS_MOD,
//is the thread already locked?
'#nnf_lock' => $xml->channel->xpath ('category[.="locked"]'),
'#nnf_unlock' => !$xml->channel->xpath ('category[.="locked"]')
'#nnf_unlock' => !$xml->channel->xpath ('category[.="locked"]'),
//is the thread already stickied?
'#nnf_stick' => IS_STICKY,
'#nnf_unstick' => !IS_STICKY
));

/* post

Loading…
Cancel
Save