<commit_before>Fushi PHP Boilerplate
=====================


Introduction
------------

Fushi is a simple, lightweight PHP boilerplate (definition of [Boilerplate on Wikipedia](http://en.wikipedia.org/wiki/Boilerplate_code)).

It can be used for building a large variety of projects, small and large. 

It has a very simple but powerful built-in templating system, as well as a pretty backend interface.


Features
--------
- Modular, scalable and SEO friendly CSS frontend engine
- Helper classes and functions for backend administration of database tables
- Helper class for pagination
- A bunch of functions for a variety of tasks
- SEO friendly URL rewrites
- A powerful and secure session engine


Requirements
------------

In order to run Fushi, you just need:
- an Apache web server
- PHP 5.2 or newer (it should potentially run in earlier versions, although I haven't tested yet.)
- You must enable *rewrite_module* in Apache and *short open tag* in PHP settings.


Getting started
---------------

1. First of all, upload everything in the root of your web server.
2. Then go to `/db` folder and create a new database with the provided MySQL dump.
3. When you're done, go to `/config` folder and edit `database.php`. You'll also need to edit `paths.php` in the same folder.

If you have edited the above files properly, just surf to the root of your website and you should be able to see the home page.


Documentation
-------------

### File System

In alphabetical order and in a tree-structured way, I'll proceed describing the folders and their content.

- **application** all files relative to the application itself.
    - **backoffice** backend interface files.
    - **includes** files that can be included inside templates.
        - **forms**
        - **galleries**
        - **lists**
        - **menus**
    - **templates** all templates (backoffice included).
- **config** configuration files (only constants here, *not* variables).
- **db** database dump (*.sql)
- **library** The core of Fushi.
    - **classes**
    - **functions**
    - **session**
- **public** the only folder publicly accessible.
    - **css**
        - **classes** css classes, usually reusable many times inside your app.
        - **modules** css modules, (unique and independent parts of your app).
        - **templates** css relative to single templates.
    - **fonts** custom fonts (I personally use fontsquirrel.com)
    - **img** all images.
    - **icons** only sweetieplus by default.
        - **sweetieplus**
    - **js** all the JavaScript scripts.
        - **libs** all the needed libraries (only jQuery by default).
    - **media** multimedia files.
        - **pdf**
        - **video**
    - **static** static HTML docs.
        - **errordocs** HTTP error files (403 Forbidden, 404 Not Found, 500 Internal Server Error etc).
    - **plugins**
        - **tinymce** the TinyMCE editor, needed by backoffice.
        - **galleria** jQuery galleria plugin.
        - **fancybox** just another freaking jQuery plugin.
- **scripts** any script that could reveal useful.	
- **tmp** unused.
    - **cache** unused.
    - **logs** unused.
    - **sessions** unused.
    
    
### Global Variables

In the most important file, `bootstrap.php`, are declared some fundamental variables:

- **$get** is the $_GET array sanitized. It actually discards every variable in the URL that contains specials characters. It only accepts numbers, letters, hyphens and underscores.
- **$template_name** is the name of the current template, getted from the URL. It equals $get[0].
- **$template** is an array taken from the database, containing the current template data:
    - $template['_id']
    - $template['name']
    - $template['title']
    - $template['h1']
    - $template['h2']
    - $template['metaDescription']
    - $template['metaKeywords']
- **$css** contains the links to the main stylesheets: `style.css` and `templates/$template_name.css` (the current template's CSS).
- *Backoffice only:*
    - **$table_name** 
    - **$action**
    - **$id**

    
### Frontend (CSS)

The frontend engine is based upon the [HTML5 Boilerplate](https://github.com/h5bp/html5-boilerplate) (v3.0.2, released on feb 19, 2012).

You're completely free to organize and manage your CSS as you wish: however I suggest you trying to maintain your structure as modular as possible. You can always use `@import url('style.css');` but this is discouraged. Use `application/boot.php` to arbitrarily import:

- Classes from 	/classes;
- Modules from 	/modules;
- Templates from 	/templates.

So remember that when your web application has a modular piece (i.e. an header or footer), you can declare it as *module* and subsequently recall it in a specific template; you can even create new templates based on the concept of inheritance!

These "non-semantic helper classes" are available:

- .ir
- .hidden
- .visuallyhidden
- .invisible
- .clearfix

For the explaining I recommend you reading the h5bp documentation: http://html5boilerplate.com/docs

The classes `.left` and `.right` just make block elements float to left or right respectively.


### JavaScript

Just two words on JavaScript: `script.js` is the main JS file, that loads automatically in every page.<commit_msg>Resolved merge conflict<commit_after>Fushi PHP Boilerplate
=====================


Introduction
------------

Fushi is a simple, lightweight PHP boilerplate (definition of [Boilerplate on Wikipedia](http://en.wikipedia.org/wiki/Boilerplate_code)).

It can be used for building a large variety of projects, small and large. 

It has a very simple but powerful built-in templating system, as well as a pretty backend interface.


Features
--------
- Modular, scalable and SEO friendly CSS frontend engine
- Helper classes and functions for backend administration of database tables
- Helper class for pagination
- A bunch of functions for a variety of tasks
- SEO friendly URL rewrites
- A powerful and secure session engine


Requirements
------------

In order to run Fushi, you just need:
- an Apache web server
- PHP 5.2 or newer (it should potentially run in earlier versions, although I haven't tested yet.)
- You must enable *rewrite_module* in Apache and *short open tag* in PHP settings.


Getting started
---------------

1. First of all, upload everything in the root of your web server.
2. Then go to `/db` folder and create a new database with the provided MySQL dump.
3. When you're done, go to `/config` folder and edit `database.php`. You'll also need to edit `paths.php` in the same folder.

If you have edited the above files properly, just surf to the root of your website and you should be able to see the home page.


Documentation
-------------

### File System

In alphabetical order and in a tree-structured way, I'll proceed describing the folders and their content.

- **application** all files relative to the application itself.
    - **backoffice** backend interface files.
    - **includes** files that can be included inside templates.
        - **forms**
        - **galleries**
        - **lists**
        - **menus**
    - **templates** all templates (backoffice included).
- **config** configuration files (only constants here, *not* variables).
- **db** database dump (*.sql)
- **library** The core of Fushi.
    - **classes**
    - **functions**
    - **session**
- **public** the only folder publicly accessible.
    - **css**
        - **classes** css classes, usually reusable many times inside your app.
        - **modules** css modules, (unique and independent parts of your app).
        - **templates** css relative to single templates.
    - **fonts** custom fonts (I personally use fontsquirrel.com)
    - **img** all images.
    - **icons** only sweetieplus by default.
        - **sweetieplus**
    - **js** all the JavaScript scripts.
        - **libs** all the needed libraries (only jQuery by default).
    - **media** multimedia files.
        - **pdf**
        - **video**
    - **static** static HTML docs.
        - **errordocs** HTTP error files (403 Forbidden, 404 Not Found, 500 Internal Server Error etc).
    - **plugins**
        - **tinymce** the TinyMCE editor, needed by backoffice.
        - **galleria** jQuery galleria plugin.
        - **fancybox** just another freaking jQuery plugin.
- **scripts** any script that could reveal useful.	
- **tmp** unused.
    - **cache** unused.
    - **logs** unused.
    - **sessions** unused.
    
    
### Global Variables

In the most important file, `bootstrap.php`, are declared some fundamental variables:

- **$get** is the $_GET array sanitized. It actually discards every variable in the URL that contains specials characters. It only accepts numbers, letters, hyphens and underscores.
- **$template_name** is the name of the current template, getted from the URL. It equals $get[0].
- **$template** is an array taken from the database, containing the current template data:
    - $template['_id']
    - $template['name']
    - $template['title']
    - $template['h1']
    - $template['h2']
    - $template['metaDescription']
    - $template['metaKeywords']
- **$css** contains the links to the main stylesheets: `style.css` and `templates/$template_name.css` (the current template's CSS).
- *Backoffice only:*
    - **$table_name** 
    - **$action**
    - **$id**


### Frontend (CSS)

The frontend engine is based upon the [HTML5 Boilerplate](https://github.com/h5bp/html5-boilerplate) (v3.0.2, released on feb 19, 2012).

You're completely free to organize and manage your CSS as you wish: however I suggest you trying to maintain your structure as modular as possible. You can always use `@import url('style.css');` but this is discouraged. Use `application/boot.php` to arbitrarily import:

- Classes from 	/classes;
- Modules from 	/modules;
- Templates from 	/templates.

So remember that when your web application has a modular piece (i.e. an header or footer), you can declare it as *module* and subsequently recall it in a specific template; you can even create new templates based on the concept of inheritance!

These "non-semantic helper classes" are available:

- .ir
- .hidden
- .visuallyhidden
- .invisible
- .clearfix

For the explaining I recommend you reading the h5bp documentation: http://html5boilerplate.com/docs

The classes `.left` and `.right` just make block elements float to left or right respectively.


### JavaScript

Just two words on JavaScript: `script.js` is the main JS file, that loads automatically in every page.
{'fraction_non_alphanumeric': 0.11839604713036868, 'fraction_numerical': 0.00589129608513873, 'mean_word_length': 3.228605865809562, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1480170', 'n_tokens_mistral': 2936, 'n_tokens_neox': 2781, 'n_words': 1307}