PHP Sample Page

SSCK (Simple Site Construction Kit.

Files:

ssck-utils.php
implement class TSS that contain several static methods for generic use. all others depends of these class.
ssck-filebase.php
implements he class TSSCsvBase with basic CSV file read methods Depends: ssck-utils.php
ssck-accesscounter.ph
Implements page access counter, usefull when want to use page access counter. Depends: Nothings, but future version will depends on ssck-utils.php and ssck-filebase.php
ssck-csvdatafile.php
implements the class TSSCsvDatFile that peform loading data stored in CSV file to respect fields of class. Usefull, for example, to read setp parameters. The write method will be implemented in the future version. Depends: ssck-utils.php and ssck-filebase.php
ssck-filereader.php
implements TSSCsvFileReader class (extends TSSCsvBase) with method to read HTML file contents to output. Other main methods are to read menu, table and list from CSV file to output. The auxiliar methods will used to print menu item or table/list row from array to output. These methods are apropriate to use inside PHP code. Depends: ssck-utils.php, ssck-filebase.php, and ssck-filereader.php
ssck-extendedfilereader.php
Implements TSSExtendedFileReader class (extends TSSCsvFileReader) that read data file with keywords to include/read table, list, and html. The keyword permit some basic output control and permit to create sheet that control order and how the table, list and HTML contents are shown, without use of PHP code. Depends: ssck-utils.php, ssck-filebase.php, and ssck-filereader.php
ssck-pagegerenator.php
The main class to generate pages. Using confortable config file, will convert static page set in page with navegation menu and like. The body part of generated page are divided in header contents, navegation contents, main contents, and footer contents. Each of this will generated by HTML file contents, Data file, and PHP file. Depends: ssck-utils.php, ssck-filebase.php, ssck-filereader.php, and ssck-datafileparser.php
ssck-download.php
Download server in way to permit download counter. Depends: nothings.

Structure of generated page: case of HTML5 (default)

"PREAMBLE"
  dynamic generated contents from PreamblePhpFile (PHP file) for programming purpose. For example, will load authentication code.

<HEAD>
  head part of HeaderHtmlFile (HTML file)
  Contents defined/read by HeaderDataFile (Ssck Data file)
  dynamic generated contents (head elements) from HeaderPhpFile (PHP file)

  additioal CSS from HeaderCssUrl
  aditional keywords from HeaderKeywords
  additional raw code from HeaderHtmlRawCode
</HEAD>

<BODY>
<HEADER id="HeaderContents">
  body part from HeaderContentsHtmlFile (HTML file)
  (if HeaderContentsHtmlFile is true, get from HeaderHtmlFile)
  Contents defined/read by HeaderContentsDataFile (Ssck Data file)
  dynamic generated contents from HeaderContentsPhpFile (PHP file)
</HEADER>
<NAV id="L10nSelectionContents">
  Menu generated from L10nSelectionCsvFile (CSV text file)
  Contents defined/read by L10nSelectionDataFile (Ssck Data file)
  dynamic generated contents (like dynamic menu) from L10nSelectionPhpFile (PHP file)
  Remark: If L10nSelectionOnTop === true, place these before HeaderContents
</NAV>
<NAV id="NavegationContents">
  Menu generated from MenuCsvFile (CSV text file)
  Contents defined/read by MenuDataFile (Ssck Data file)
  dynamic generated contents (like dynamic menu) from MenuPhpFile (PHP file)
</NAV>
<MAIN id="MainContents">
  body part of MainContentsHtmlFile (HTML file)
  Contents defined/read by MainContentsDataFile (Ssck Data file)
  dynamic contents generated contents from MainContentsPhpFile (PHP file)
</MAIN>
<NAV id="BottomNavegationContents">
  Menu generated from BottomMenuCsvFile (CSV text file)
  Contents defined/read by BottomMenuDataFile (Ssck Data file)
  dynamic generated contents (like dynamic menu) from BottomMenuPhpFile (PHP file)
</NAV>
<FOOTER id="FooterContents">
  body part from FooterContentsHtmlFile (HTML file)
  Contents defined/read by FooterContentsDataFile (Ssck Data file)
  dynamic generated contents from FooterContentsPhpFile (PHP file)
</FOOTER>
</BODY>

Structure of generated page: case of HTML4

"PREAMBLE"
  dynamic generated contents from PreamblePhpFile (PHP file) for programming purpose. For example, will load authentication code.

<HEAD>
  head part of HeaderHtmlFile (HTML file)
  Contents defined/read by HeaderDataFile (Ssck Data file)
  dynamic generated contents (head elements) from HeaderPhpFile (PHP file)

  additioal CSS from HeaderCssUrl
  aditional keywords from HeaderKeywords
  additional raw code from HeaderHtmlRawCode
</HEAD>

<BODY>
<DIV id="HeaderContents">
  body part from HeaderContentsHtmlFile (HTML file)
  (if HeaderContentsHtmlFile is true, get from HeaderHtmlFile)
  Contents defined/read by HeaderContentsDataFile (Ssck Data file)
  dynamic generated contents from HeaderContentsPhpFile (PHP file)
</DIV>
<DIV id="L10nSelectionContents">
  Menu generated from L10nSelectionCsvFile (CSV text file)
  Contents defined/read by L10nSelectionDataFile (Ssck Data file)
  dynamic generated contents (like dynamic menu) from L10nSelectionPhpFile (PHP file)
  Remark: If L10nSelectionOnTop === true, place these before HeaderContents
</DIV>
<DIV id="NavegationContents">
  Menu generated from MenuCsvFile (CSV text file)
  Contents defined/read by MenuDataFile (Ssck Data file)
  dynamic generated contents (like dynamic menu) from MenuPhpFile (PHP file)
</DIV>
<DIV id="MainContents">
  body part of MainContentsHtmlFile (HTML file)
  Contents defined/read by MainContentsDataFile (Ssck Data file)
  dynamic contents generated contents from MainContentsPhpFile (PHP file)
</DIV>
<DIV id="BottomNavegationContents">
  Menu generated from BottomMenuCsvFile (CSV text file)
  Contents defined/read by BottomMenuDataFile (Ssck Data file)
  dynamic generated contents (like dynamic menu) from BottomMenuPhpFile (PHP file)
</DIV>
<DIV id="FooterContents">
  body part from FooterContentsHtmlFile (HTML file)
  Contents defined/read by FooterContentsDataFile (Ssck Data file)
  dynamic generated contents from FooterContentsPhpFile (PHP file)
</DIV>
</BODY>

Config file

The config file is an CSV that first fields is variable and seccond is value.

The default separator is tab.

The variables for config file:

For CSV file reading

BufferSize
Size of buffer used to read each line of CSV file. Default value is 0 (unlimited)
CsvDelimiter
Column delimiter for CSV file. Default is tab
CsvEnclosure
String enclosure (used if item contain column delimiter or like) for element of CSV. Default is aspas (").
CsvEscape
Escape character for fgetcsv(). Default is "\"
CsvComment
Comment marker. The line starting with this character is assumed comment and skiped. Default is "#".
CsvTrimItem
Apply tri for each item of CSV. Default is false.
CsvEmptyRowSplitData
Empty line are interpreted as data separator. Default is false.

Remark: BufferSize, CsvDelimiter, CsvEnclosure, and CsvEscape are updated after setup file loaded completelly (affects oly next reading). Other values are applied imediatelly.

To generate HTML element from CSV like menu or table.

CsvAllowHtmlFormatting
Permit to use HTML tags inside CSV. Default is false (HTML reserved char is scaped).
CsvItemNewLineReplacement
New line is repacd by this HTML equivalent. Default is "<BR />"
CsvMenuItemLinkOnTagOptions
TAG options for menu item with link. Default is "class=\"MenuItemLinkOn\"".
CsvMenuItemLinkOffTagOptions
TAG options for menu item without link. Default is "class=\"MenuItemLinkOff\"".
CsvDisabledMenuItem
Item for menu that disabled (label corresponding to current page.
CsvMenuType
Type of menu: UL (bollet list), OL (numbered list), DIV (with item enclosed by SPAN), NONE (no enclosure, with item enclosed by SPAN). CUSTOM (will customize, using CsvMenuEnclosureTag, CsvMenuItemEnclosureTag, and CsvMenuItemSeparator). Default value is UL.
CsvMenuEnclosureTag
TAG to enclosure menu. Default is UL.
CsvMenuItemEnclosureTag
TAG to enclosure menu item. Default is LI.
CsvMenuItemSeparator
Put it between each menu item. Defaltu is "\n".
CsvMenuTagOptions
Options for Menu TAG. Default is "class=\"NavegationMenu\"".

For other CSV reader (if use within PHP code).

CsvTableTagOptions
Options for table read from CSV file. Defaut is "class=\"CsvTable\""
CsvListTagOptions
Options for list read from CSV file. Default is "class=\"CsvList\"".
DefaultLinkPrefix
link prefix for link list from CSV.? Default is false.
CsvFirstCellTagOptions
Options for first cell of list? Default is "class=\"FirstCell\"".
CsvListCellEnclosureTag
First item of list is enclosed with this. Default is "span"
CsvListCellSeparator
Each item of row onn list is separated with this. Default is " "
ImageExtensions
File extensions for image files. Default is array("jpg", "jpeg", "png", "svg")
ImageTagOptions
Options for images. Default is "class=\"ImageItem\" alt=\"Picture\""
ImageThumbFolder
folder for image thumbnail.Default is "thumb".
ImageThumbPrefix
file name prefix for thumbnail. Deafult is "thumb-"
ImageThumbPostfix
file name post fix for thumbnail. Default is empty.
ImageDisplayWidthAsThumb
If thumb is not found, use the image as thumb. In this case, use this width. Default is 200

For SSCK's extended CSV file (if use DAT file)

TitleEnclosureTag
Enclosure title with this tag. Defualt is "p".
ExtendedDataTitleTagOptions
Default is "class='ExtendedDataTitle'".
ExtendedDataDefaultListType
Default is "UL".

Page generator control

HtmlVersion
HTML version of page to be generated. Will be "4" or "5". Default is "5".
ContentsFolder
folder that contain HTML, CSV, DAT or PHP files. Default is empty.
HtmlFileExtension
Default extension for HTML file. Default is empty.
DataFileExtension
Default extnsion for DAT (SSCK's extended CSV file) file. Default is empty.
CsvFileExtension
Default extension for CSV file. Default is empty.
PhpFileExtension
Default extension for PHP file. Default is empty.
PreamblePhpFile
name of PHP file for preamble (before all, like session management code). Default is empty.
HeaderHtmlFile
name of html file for header. Default is empty.
HeaderDataFile
name of DAT (SSCK's extended CSV file) for header. Default is empty.
HeaderPhpFile
name of PHP file for header. Default is empty.
HeaderCssUrl
URL for aditional style file. Default is empty.
HeaderKeyword
Aditional keywords. Default is empty.
HeaderRawHtmlCode
Aditional HTML code for header. Default is empty.
DefaultPageTitle
If all of header file are omitted (empty), use this to set title for minimal header. Default is empty.
DefaultPageCharSet
If all of header file are omitted (empty), use this to set charset for minimal header. Default is UTF8.
BodyTagOptions
Options for BODY of page. Default is "ONLOAD=\"if (window != window.top) { top.location.href=location.href }\"". If it is true, get from HTML source page ones.
ContentsEnclosureTag
TAG to enclosure contents (Header contents, main contents, footer contents). Default is DIV for HTML 4. Note that TAG for HTML 5 is HEADER for header contents and FOOTER for footer contents.
HeaderContentsTagOptions
Options for Header contents. Default is "id=\"HeaderContents\"".
HeaderContentsHtmlFile
html file name for header contents. If true, use same file as HeaderHtmlFile. Default is true.
HeaderContentsDataFile
DAT (SSCK's extendd CSV file) file name for header contents. Default is empty.
HeaderContentsPhpFile
PHP file name for header contents. Default is empty.
L10nSelectionUseOption
Use option to pass desired language to script. Default is false.
L10nSelectionOnTop
If true, L10n selection becames first contents of page (before header contents). Default is true.
L10nSelectionOptionName
option name used, if L10nSelectionUseOptijn if true. Default is "lang".
L10nSelectionContentsEnclosureTag
TAG to enclosure L10n selection contents. If true, use from NavegationContentsEnclosureTag. Default is true.
L10nSelectionContentsTagOptions
Option for L10n selection contents. Deffault is "id=\"L10nSelectionContents\"".
L10nSelectionKeepOptions
Keep option received (pass to menu link). Default is false.
L10nSelectionCsvFile
CSV file name for L10n selection (langualge list). Default is empty.
L10nSelectionDataFile
DAT (SSCK's extended CSV file) file name for L10n selection contents. Default is empty.
L10nSelectionPhpFile
PHP file name for L10n selection contents. Default is empty.
L10nSelectionCurrentItem
Current L10n (language) item in use (disable this item from language menu)
CollapsableL10nMenu
Add checkbox to show/hide L10nSelection menu. Default is false.
CollapsableL10nMenuId
Unique id for checkbox to show/hide L10nSelection menu. Default is "ShowCollapsedL10nMenu".
CollapsableL10nMenuLabel
Label for checkbox to show/hide L10nSelection menu. Default is empty.
CollapsableL10nMenuLabelOptions
Option of label for checkbox to show/hide L10nSelection menu. Default is "id=\"LabelForShowCollapsedL10nMenu\""
NavegationContentsEnclosureTag
TAG to enclosure navegation contents. Default is NAV for HTML 5 and DIV for HTML4.
NavegationContentsTagOptions
Options for navegation contents. Default is "id=\"NavegationContents\"".
MenuCsvFile
CSV file name for navegation contents (nemu). Default is empty.
MenuDataFile
DAT (SSCK's extended CSV file) file name for navegation contents (nemu). Default is empty.
MenuPhpFile
PHP file name for navegation contents (nemu). Default is empty.
CollapsableCsvMenu
Add checkbox to show/hide navegation menu. Default is false.
CollapsableCsvMenuId
Unique id for checkbox to show/hide navegation menu. Default is "ShowCollapsedCsvMenu".
CollapsableCsvMenuLabel
Label for checkbox to show/hide navegation menu. Default is empty.
CollapsableCsvMenuLabelOptions
Option of label for checkbox to show/hide navegation menu. Default is "id=\"LabelForShowCollapsedCsvMenu\""
MainContentsEnclosureTag
TAG for main contents. If true, use MAIN for HTML 5  and from ContentsEnclosureTag for HTML 4. Default is true.
MainContentsTagOptions
Options for main contents. Default is "id=\"MainContents\"".
MainContentsHtmlFile
html file name for main contents.
MainContentsDataFile
DAT (SSCK's extended CSV file) file name for main contents. Default is empty.
MainContentsPhpFile
PHP file name for navegation contents (nemu). Default is empty.
BottomNavegationContentsEnclosureTag
TAG to enclosure bottom navegation contents. If true, use from NavegationContentsEnclosureTag. Default is true.
BottomNavegationContentsTagOptions
options for bottom navegation contents. Default is "id=\"BottomNavegationContents\"".
BottomMenuCsvFile
CSV file name for navegation contents (nemu). Default is empty.
BottomMenuDataFile
DAT (SSCK's extended CSV file) file name for bottom navegation contents (nemu). Default is empty.
BottomMenuPhpFile
PHP file name for navegation contents (nemu). Default is empty.
CollapsableBottomCsvMenu
Add checkbox to show/hide bottom navegation menu. Default is false.
CollapsableBottomCsvMenuId
Unique id for checkbox to show/hide bottom navegation menu. Default is "ShowCollapsedBottomCsvMenu".
CollapsableBottomCsvMenuLabel
Label for checkbox to show/hide bottom navegation menu. Default is empty.
CollapsableBottomCsvMenuLabelOptions
Option of label for checkbox to show/hide bottom navegation menu. Default is "id=\"LabelForShowCollapsedBottomCsvMenu\""
FooterContentsTagOptions
options for footer contents. Default is "id=\"FooterContents\"".
FooterContentsHtmlFile
html file name for footer contents. Default is empty.
FooterContentsDataFile
DAT (SSCK's extended CSV file)  file name for footer contents. Default is empty.
FooterContentsPhpFile
PHP file name for footer contents. Default is empty.
Options
Additional options will set here. Put variable in seccond column and value in thrird column. The GetOptionValue() wuill used from PHP code to get these values. Note: if several config file are loaded in sequence, this options clean up preview values for options. If desire to add over existing ones, use MoreOptions. Default value: empty.
MoreOptions
Same as Options, but if several config file are loaded in sequence, the parameter are added over above ones. Default value is empty.

DAT (SSCK's extended CSV) file

The SSCK's extended data file is CSV file with additional keywords.
The keywords for ReadExtendedData()
The parameter mean colum on same row than keyword.
Data mean rows after keyword row, until empty row

Keywords

TITLE
To print parameter as title
TITLELINE
To print one line of data as title
LIST
To print data as list
TABLE
To print data as table
MENU
To print data as menu
HTML
To print data as Raw Html code.
SETUP
Parse parameter for setup change
FILE
To include external file. Required parameter are type and file_name. The parameter that follows filename are passed to corresponding reader

Valid parameters for SETUP (setting):

On/Off flags:
TitleOn/TitleOff
First row is title? Default is ON
LinkOn/LinkOff
Link contents? Default is OFF
FirstOn/FirstOff
Mark first cell on list/table? Default is ON
Attributions (key=value)
List
Valid value is UL, OL, DL, and P
LinkPrefix
Prefix on link enabled contents

Valid parameters for FILE

The following files type are supported:
TABLE
Table on CSV file

LIST
List on CSV file
MENU
Menu on CSV file
HTML
HTML file
DATA
Extended Data file like this At end of included data file, setup status before include are restored.
INCLUDE
Same as above, but setup change inside included file persists at end of included file.