PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Kreshnik Hasanaj   Site Configuration   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: This is an example file on how you can use the class
Class: Site Configuration
Get the CSS and JavaScript for different Web pages
Author: By
Last change:
Date: 12 years ago
Size: 2,222 bytes
 

Contents

Class file image Download
<?php

include('configuration.php');

// This is an example on how the class should be used.
$site = new Configuration();
$site->css = array(
   
'default' => array('awesome.css'),
   
'home' => array('ie.css', 'second.css'),
   
'page' => array('page.css', 'style.css'),
   
'newsletter' => array('fix.css', 'base.css'),
   
'gallery' => array('style.css', 'gallery.css')
);

$site->js = array(
   
'default' => array('needed.js'),
   
'home' => array('jquery.js', 'mordernizr.js'),
   
'page' => array('loader.js', 'bootstrap.js'),
   
'newsletter' => array('jquery.small.js', 'base.js'),
   
'gallery' => array('demo.js', 'gallery.js'),
   
'super' => array('2' => array('not_important.js'), '1' => array('main.js'))
);

//Generate CSS includes
print $site->get_output('css', 'home');
print
$site->get_output('css', 'page');
print
'<pre>';
print_r($site->get_output('css', 'newsletter', false)); // Return an array don't include files
print '</pre>';
print
$site->get_output('css', 'gallery');

print
$site->get_output('js', 'home');
print
$site->get_output('js', 'page');
print
'<pre>';
print_r($site->get_output('js', 'newsletter', false)); // Return an array don't include files
print '</pre>';
print
$site->get_output('js', 'gallery');


// New future include default scripts
$site->include_default = true;
print
'Default scripts included';
print
'<pre>';
print_r($site->get_output('js','home',false));
print
'</pre>';
$site->include_default = false; //Reset to false
 
//New sorting future
$site->sort = true;
$site->sort_by = 'key';

print
'Sorting future (by key)';
print
'<pre>';
$site->sort_type = 'normal';
print_r($site->get_output('js','super',false));
print
'</pre>';

print
'Reverse sorting (by key)';
print
'<pre>';
$site->sort_type = 'reverse';
print_r($site->get_output('js','super',false));
print
'</pre>';

$site->sort_by = 'array';
print
'Sorting future (by array)';
print
'<pre>';
$site->sort_type = 'normal';
print_r($site->get_output('js','home',false));
print
'</pre>';

print
'Reverse sorting (by array)';
print
'<pre>';
$site->sort_type = 'reverse';
print_r($site->get_output('js','home',false));
print
'</pre>';

?>