PHP Classes

File: example.ext.php

Recommend this page to a friend!
  Classes of Martin Polacik   Cup Scheduler   example.ext.php   Download  
File: example.ext.php
Role: Example script
Content type: text/plain
Description: example of use for extended version
Class: Cup Scheduler
Generate a schedule of games between teams
Author: By
Last change: added comments
Date: 15 years ago
Size: 2,739 bytes
 

Contents

Class file image Download
<?php
###################################################################################################
# Cup Scheduler LITE v1.
# Copyright (c) Martin "duno" Polacik <duncan@anachronyx.sk> 2009. All Rights Reserved.
#
# Cup Scheduler LITE is free php script writen to generate soccer schadule for league cup.
# Hope it will be usefull. This script is distributed in GNU GPL licence.
# See the GNU General Public License for more details http://www.gnu.org/licenses/.
#
# CHANGELOG
# - added function array_is_valid, which checks if items count in array is devided by 2, and also checks if
# number of teams is valid (valid counts 4, 8, 16, 32, 64 etc due to tournaments rulles)
# - added variable allow_count by using allow_count=1 you can turn of tournaments rulles validation
# - added variable show_error_msq
# TO DO
# - graphical view
###################################################################################################
 //charset setup
 
header("Content-type: text/html; charset=utf-8");
 
//include main class
 
include("class.cupScheduler.ext.php");
 
//default array, you can also load data from db
 
/*
  1. valid array
*/
 
$array = Array("Arsenal", "Liverpool", "Everton", "Tottenham", "Nantes", "Barcelona", "Lokomotiv Moskva", "Slovan Bratislava");
###################################################################################################
 /*
   2. bad items count not divisible by 2
   this is array is bad, item counts is 9 , so fixture can't be generated

   $load->show_error_msg=1; //display error
   $array = Array("Arsenal", "Liverpool", "Everton", "Tottenham", "Nantes", "Barcelona", "Lokomotiv Moskva", "Slovan Bratislava", "Bayer Munchen");
  */
###################################################################################################
 /*
   3. bad items count (item counts is 10) but still divisible by 2, and that means that we can generate the fixtures
   if you set $load->allow_count=1; script will generate the fixtures eather

   $load->allow_count=1; //ignore tournament system validation and generate pairs
  
   or you can just
   $load->allow_count=0; //not allow if tournament system validation failed
   $load->show_error_msg=1; //display error...
   $array = Array("Arsenal", "Liverpool", "Everton", "Tottenham", "Nantes", "Barcelona", "Lokomotiv Moskva", "Slovan Bratislava", "Lazio Roma", "Bayer Munchen");
  */

 //load default class
 
$load = new CupScheduler();
 
//$load->allow_count=1;
 
if($load->array_is_valid($array))
 {
  
//load default method
  
$load->generate_schedule($array);
 }
 else
 {
    if(
$load->show_error_msg==1)
    {
      echo
$load->error_msg;
    }
 }
?>