Giter Club home page Giter Club logo

php-class's Introduction

php-class

PhP classes to create dynamic pages quickly and fully costumable. Contains the following classes:

  • Form generator (CForm)
  • Menu generator (CMenu)
  • Table generator (CTable)
  • Search on database (CSearch)
  • Manager of site (CPage)
  • MySql manager (CDatabase)

##Configuration In your index page instantiates the main class:

include(config/Autoload.php);
include(config/CONSTANT.class);
$template = new CPage($_REQUEST);

or activating the debugging mode (available in each class):

$template = new CPage($_REQUEST,true);

The first two include are needed to automatically load the specified classes need and the configuration of the server.

Now loads the page needed:

 $template->startPage();
 $pages = $template->getPage();

 foreach($pages as $page)
        if(file_exists($page))
                include($page);

Finally closes the page:

 $template->endPage();

Now you can write your own pages!

##Usage You have to put your pages, with the same name, in three different folder:

  • in "page" folder the main content of the page, with .inc extension;
  • in "php" folder eventually script to execute before the content;
  • in "js" folder all javascript, jquery script you need.

To use that classes you just have to instantiate the one you need in your pages, see some examples below. On the first line of your html page you have to close the head tag with:

$template->renderHead();

###Menu

$menu = new CMenu(true);

/***Create your menu***/
$menu->renderMenu(array(
          array('label'=>'First Element','url'=>array('r'=>'#'),
                      'items'=>array(
                          array('label'=>'Submenu_1','url'=>array('r'=>'test_menu'))
                      )
                  ),
          array('label'=>'Second Element','url'=>array('r'=>'#'),
                      'items'=>array(
                          array('label'=>'Submenu_2','url'=>array('r'=>'test_form'))
                      )
          ),)
);

###Form

$form = new CForm();

/***Build your form***/
$form->beginForm('form_test');
$form->beginFieldset();
$form->insertLegend('Static Form');

$form->addField('text','user','Text-Field',array('placeholder'=>'textfield','class'=>'text_class'));

$form->endForm();

###Table

$table = new CTable(array(
            array('id'=>1,'Name'=>'content','Third column'=>'other content'),
            array('id'=>2,'Name'=>'cdsad','Third column'=>'other evavavav'),
            array('id'=>3,'Name'=>'cdfgfgdf','Third column'=>'other acasveegve'),
          ),array(),false);

/***Add the column to show***/
$table->setVisibleField(array('name'=>'id', 'label'=>'ID'));
$table->setVisibleField(array('name'=>'Name', 'label'=>'Second Column'));
$table->setVisibleField(array('name'=>'Third column', 'label'=>'Second Column'));

/***Finally plot the table***/
$table->renderTable();

###Search

$search = new CSearch($_REQUEST,'page');

$search->beginForm('search_test');
$search->beginFieldset();
$search->insertLegend('Search a Page');

/***Create the form***/
$search->addField('text','label','Label of the page',array('placeholder'=>'textfield','class'=>'text_class'));
$search->addField('submit','submit','');
$search->endFieldset();
$search->endForm();


/***Then print the result of the search***/
$search->setVisibleField(array('name'=>'id', 'label'=>'ID'));
$search->setVisibleField(array('name'=>'label', 'label'=>'Page name'));
$search->setVisibleField(array('name'=>'level', 'label'=>'Level'));

$search->renderTable();

For more examples see the folders examples.

##License See LICENSE

php-class's People

Contributors

luca-morreale avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.