FileCMS Core

Really simple PHP app that builds HTML files from HTML widgets.

License: Apache v2 Version: v0.1

Initial Installation

  1. Clone https://github.com/dbierer/filecms-website to the project root of your new website.
  2. Use composer to install unlikelysource/filecms-core and 3rd party source code (e.g. PHPMailer)
wget https://getcomposer.org/download/latest-stable/composer.phar
php composer.phar self-update
php composer.phar install

Basic website config

To Run Locally Using PHP

From this directory, run the following command:

php -S localhost:8888 -t public

To Run Locally Using Docker and docker-compose

Windows

Install Docker Desktop for Windows

Open the Power Shell (some commands don't work in the regular command prompt)

To bring the docker container online, run this command:

admin up

To stop the container do this:

admin down

To open a command shell into the container:

admin shell

Linux / Mac

Install Docker + docker-compose:

Open a terminal window (Terminal Application)

To bring the docker container online, run this command:

./admin.sh up

To stop the container do this:

./admin.sh down

To open a command shell into the container:

./admin.sh shell

Browser Access

To access from your browser:

http://localhost:8888/
http://10.10.10.10/

Bootstrap and Document Root

Set the website document root to /public

composer dump-autoload

Here is a summary of the three key constants defined by /bootstrap.php. Change as needed.

Constant Default Description
BASE_DIR Same directory as bootstrap.php Project root
HTML_DIR /templates/site Location of HTML snippets
SRC_DIR /src Location of source code

Pre-Processing

Before the final HTML view is rendered, /public/index.php includes /src/processsing.php. In this file you can include any pre-processing you need done.

Templates

By default templates are stored in /templates/site. You can alter this in the config file.

Config File

Default: /src/config/config.php

Layout

The overall website look-and-feel is in a single HTML file, by default in /templates/layout/layout.phtml.

Super

All admin functionality is by default located in /templates/super. The current admin pages are:

HTML

You can create HTML snippets designed to fit into layout.phtml any place in the designated HTML directory.

Cards

Important: each %%CARD%% directive you add must be on its own line!

Auto-Populate All Cards

To get an HTML file to auto-populate with cards use this syntax:

DELIM+DIR+DELIM

Example: you have a subdirectory off HTML_DIR named projects and you want to load all HTML card files under the cards folder:

%%PROJECTS%%

Auto-Populate Specific Number of Cards

To only load a certain (random) number of cards, use =. Example: you have a subdirectory off HTML_DIR named features and you want to load 3 random HTML card files under the cards folder:

%%FEATURES=3%%

Auto-Populate Specified Cards in a Certain Order

For each card, only use the base filename, no extension (i.e. do not add .html). Example: you have a directory HTML_DIR/blog/cards with files one.html, two.html, three.html, etc. You want the cards to be loaded in the order one.html, two.html, three.html, etc.:

%%BUNDLES=one,two,three,etc.%%

Editing Pages

By default, if you enter the URL /super/login you're prompted to login as a super user. Configure the username, password and secondary authentication factors in: /src/config/config.php under the SUPER config key.

SUPER config key

Example configuration for super user:

// other config not shown
'SUPER' => [
    'username' => 'admin',
    'password' => 'password',
    'attempts' => 3,
    'message'  => 'Sorry! Unable to login.  Please contact your administrator',
    // array of $_SERVER keys to store in session if authenticated
    'profile'  => ['REMOTE_ADDR','HTTP_USER_AGENT','HTTP_ACCEPT_LANGUAGE','HTTP_COOKIE'],
    // change the values to reflect the names of fiels in your login.phtml form
    'login_fields' => [
        'name'     => 'name',
        'password' => 'password',
        'other'    => 'other',
        'phrase'   => 'phrase',     // CAPTCHA phrase
    ],
    'validation'   => [
        'City' => 'London',
        'Postal Code' => '12345',
        'Last Name' => 'Smith',
    ],
    'allowed_ext'  => ['html','htm'],
    'ckeditor'     => [
        'width' => '100%',
        'height' => 400,
    ],
    'super_dir'  => BASE_DIR . '/templates', // IMPORTANT: needs to have a subdir === "super_url" setting
    'super_url'  => '/super',                // IMPORTANT: needs to be a subdir off the "super_dir" setting
    'super_menu' => BASE_DIR . '/templates/layout/super_menu.html',
    'backup_dir' => BASE_DIR . '/backups',
    'backup_cmd' => BASE_DIR . 'zip -r %%BACKUP_FN%% %%BACKUP_SRC%%',
],
// other config not shown

Here's a breakdown of the SUPER config keys

Key Explanation
username Super user login name
password Super user login password
attempts Maximum number of failed login attempts. If this number is exceeded, a random third authentication field is required for login.
message Message that displayed if login fails
profile Array of $_SERVER keys that form the super user's profile once logged in
login_fields Field names drawn from your login.phtml login form
validation You can specify as many of these as you want. If the login attemp exceeds attempts, the SimpleHtml framework will automatically add a random field drawn from this list.
allowed_ext Only files with an extension on this list can be edited.
ckeditor Default width and height of the CKeditor screen
super_dir' Location of the "super" admin pages. Default is /templates. IMPORTANT: needs to have a subdir === "super_url" setting
super_url URL to enter to access admin pages. Default is /super. IMPORTANT: needs to be a subdir off the "super_dir" setting
super_menu' Location of HTML file that contains the admin menu, present on all admin pages. Default is /templates/layout/super_menu.html
backup_dir' Location of directory where backups of pages are created when performing edits. Default is BASE_DIR . '/backups'
backup_cmd' Command used to create a global backup of the website. Default is zip -r %%BACKUP_FN%% %%BACKUP_SRC%%'

Contact Form

The skeleton app includes under /templates a file contact.phtml that implements an email contact form with a CAPTCHA

Import Feature

You can enable the import feature by setting the IMPORT::enable config key to TRUE. The importer itself is at /templates/site/super/import.phtml. Selected transformation filters can be applied to one or more pages during the import process.

Here are some notes on config file settings under the IMPORT config key:

 

Transform Feature

You can apply transformation filters on existing pages. The importer itself is at /templates/site/super/import.phtml. Included transformation classes are located in /src/Transform. You can add your own by simply extending FileCMS\Common\Transform\Base. After logging in as the admin user, go to /super/transform.

Here are some notes on config file settings under the TRANSFORM config key: