Location: PHPKode > projects > Nuke Modules CVS > modules/PostCalendar/pnadminapi.php
<?php
// $Id: pnadminapi.php,v 1.3 2002/04/01 16:23:03 epsilon7 Exp $
/********************************************************/
/* PostCalendar                                         */
/* Version 2.6,  see changes.txt for details            */
/* Originally by Rob Sutton (Events Calendar)           */
/* Development continued by                             */
/*                                                      */
/*  The PostCalendar Development Team                   */
/*     Mahmood Al-Yousif - hide@address.com          */
/*     Craig Hamlin - hide@address.com             */
/*     HotBird - hide@address.com                        */
/*     Roger Raymond - hide@address.com                 */
/*                                                      */
/* This program is opensource so you can do whatever    */
/* you want with it. However, I'm happy about any       */
/* clever idea or nifty change you might have or have   */
/* done, send them to                                   */
/* hide@address.com                                 */
/*                                                      */
/* Any new versions can be found at                     */
/* http://www.bahraini.tv first                         */
/********************************************************/

/**
 *  Returns an array of form data for FormSelectMultiple
 */
function PostCalendar_adminapi_buildMonthSelect($args) 
{
    extract($args);
    
    if(!isset($pc_month)) {   
        $pc_month = Date('m');
    } 
    
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    
    // create the return object to be inserted into the form
    $options = array();
    $count = 0;
    for ($i = 1; $i <= 12; $i++) {
        $sel = '';
        if ($i == $pc_month) {
            $sel = 'selected';
        } 
        $options[$count]['id']         = $i;
        $options[$count]['selected']   = $sel;
        $options[$count]['name']       = $i < 10 ? '0'.$i : $i;
        $count++;
    }
    
    $output->FormSelectMultiple('pc_month',$options);
    return $output->GetOutput();
}

/**
 *  Returns an array of form data for FormSelectMultiple
 */
function PostCalendar_adminapi_buildDaySelect($args) 
{   
    extract($args);

    if(!isset($pc_day)) {   
        $pc_day = Date('d');
    }
    
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    
    // create the return object to be inserted into the form
    $options = array();
    $count = 0;
    for ($i = 1; $i <= 31; $i++) {   
        $sel = '';
        if ($i == $pc_day) {
            $sel = "selected";
        } 
        $options[$count]['id']         = $i;
        $options[$count]['selected']   = $sel;
        $options[$count]['name']       = $i;
        $count++;
    }
    
    $output->FormSelectMultiple('pc_day',$options);
    return $output->GetOutput();
}

/**
 *  Returns an array of form data for FormSelectMultiple
 */
function PostCalendar_adminapi_buildYearSelect($args) 
{   
    extract($args);
    
    if(!isset($pc_year)) {   
        $pc_year = Date('Y');
    }
    
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    
    // create the return object to be inserted into the form
    $options = array();
    // we want the list to contain 10 year before today and 30 years after
    // maybe this will eventually become a user defined value
    $pc_start_year = $pc_year - 10;
    $pc_end_year = $pc_year + 30;
    $count = 0;
    for ($i = $pc_start_year; $i <= $pc_end_year; $i++) {   
        $sel = false;
        if ($i == $pc_year) {
            $sel = true;
        }
        $options[$count]['id']         = $i;
        $options[$count]['selected']   = $sel;
        $options[$count]['name']       = $i;
        $count++;
    }
    
    $output->FormSelectMultiple('pc_year',$options);
    return $output->GetOutput();
}

function PostCalendar_adminapi_buildHourSelect($args) 
{
    extract($args)
    $time24hours = pnModGetVar('PostCalendar','time24hours')
    
    if(!isset($hour)){
        $hour = $time24hours ? date('H') : date('h'); 
    }
    
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    
    $options = array();
	if($time24hours) {
        for($i = 0; $i < 24; $i++) {
            $sel = false;
            if($i == $hour) {
                $sel = true;
            }
            $options[$i]['id']       = $i;
            $options[$i]['selected'] = $sel;
            $options[$i]['name']     = $i < 10 ? '0'.$i : $i;  
        }
    } else {
        for($i = 0; $i < 12; $i++) {
            $sel = false;
            if($i == $hour) {
                $sel = true;
            }
            $options[$i]['id']       = $i+1;
            $options[$i]['selected'] = $sel;
            $options[$i]['name']     = $i+1 < 10 ? '0'.$i+1 : $i+1;     
        }
    }
    
    $output->FormSelectMultiple('pc_hour',$options);
    return $output->GetOutput();
}

function PostCalendar_adminapi_buildMinSelect($args) 
{
    extract($args);
    
    if(!isset($min)){
        $min = date('i'); 
    }
    
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    
    $options = array();
    for ($i = 0; $i <= 45; $i+5) {
        $options[$i]['id']       = $i;
        $options[$i]['selected'] = false;
        $options[$i]['name']     = $i < 10 ? '0'.$i+1 : $i+1;            
    }
    
    $output->FormSelectMultiple('pc_min',$options);
    return $output->GetOutput();
}

function PostCalendar_adminapi_buildAMPMSelect($args) 
{   
    extract($args);
    
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    
    $options = array();
    if(pnModGetVar('PostCalendar','time24hours')) {
        return false;
    } else {
        $options[0]['id']        = 'AM';
        $options[0]['selected']  = '';
        $options[0]['name']      = 'AM';
        $options[1]['id']        = 'PM';
        $options[1]['selected']  = '';
        $options[1]['name']      = 'PM';
    }
    
    $output->FormSelectMultiple('pc_ampm',$options);
    return $output->GetOutput();
}
?>
Return current item: Nuke Modules CVS