コード例 #1
0
ファイル: form.php プロジェクト: nickmancol/forkcms-rhcloud
 /**
  * Adds a datefield to the form
  *
  * @param string $name Name of the element.
  * @param mixed[optional] $value The value for the element.
  * @param string[optional] $type The type (from, till, range) of the datepicker.
  * @param int[optional] $date The date to use.
  * @param int[optional] $date2 The second date for a rangepicker.
  * @param string[optional] $class Class(es) that have to be applied on the element.
  * @param string[optional] $classError Class(es) that have to be applied when an error occurs on the element.
  * @return FrontendFormDate
  */
 public function addDate($name, $value = null, $type = null, $date = null, $date2 = null, $class = null, $classError = null)
 {
     $name = (string) $name;
     $value = $value !== null ? $value !== '' ? (int) $value : '' : null;
     $type = SpoonFilter::getValue($type, array('from', 'till', 'range'), 'none');
     $date = $date !== null ? (int) $date : null;
     $date2 = $date2 !== null ? (int) $date2 : null;
     $class = $class !== null ? (string) $class : 'inputText inputDate';
     $classError = $classError !== null ? (string) $classError : 'inputTextError inputDateError';
     // validate
     if ($type == 'from' && ($date == 0 || $date == null)) {
         throw new FrontendException('A datefield with type "from" should have a valid date-parameter.');
     }
     if ($type == 'till' && ($date == 0 || $date == null)) {
         throw new FrontendException('A datefield with type "till" should have a valid date-parameter.');
     }
     if ($type == 'range' && ($date == 0 || $date2 == 0 || $date == null || $date2 == null)) {
         throw new FrontendException('A datefield with type "range" should have 2 valid date-parameters.');
     }
     // @later	get prefered mask & first day
     $mask = 'd/m/Y';
     $firstday = 1;
     // build attributes
     $attributes['data-mask'] = str_replace(array('d', 'm', 'Y', 'j', 'n'), array('dd', 'mm', 'yy', 'd', 'm'), $mask);
     $attributes['data-firstday'] = $firstday;
     // add extra classes based on type
     switch ($type) {
         // start date
         case 'from':
             $class .= ' inputDatefieldFrom inputText';
             $classError .= ' inputDatefieldFrom';
             $attributes['data-startdate'] = date('Y-m-d', $date);
             break;
             // end date
         // end date
         case 'till':
             $class .= ' inputDatefieldTill inputText';
             $classError .= ' inputDatefieldTill';
             $attributes['data-enddate'] = date('Y-m-d', $date);
             break;
             // date range
         // date range
         case 'range':
             $class .= ' inputDatefieldRange inputText';
             $classError .= ' inputDatefieldRange';
             $attributes['data-startdate'] = date('Y-m-d', $date);
             $attributes['data-enddate'] = date('Y-m-d', $date2);
             break;
             // normal date field
         // normal date field
         default:
             $class .= ' inputDatefieldNormal inputText';
             $classError .= ' inputDatefieldNormal';
             break;
     }
     // create a datefield
     $this->add(new FrontendFormDate($name, $value, $mask, $class, $classError));
     // set attributes
     parent::getField($name)->setAttributes($attributes);
     // return datefield
     return parent::getField($name);
 }
コード例 #2
0
ファイル: login.php プロジェクト: jincongho/clienthub
/**
 * Client Manager
 * 
 * Login Page to the system.
 * @package Client Manager
 * @author Jin Cong<*****@*****.**>
 */
define('LOAD_TEMPLATE', true);
define('LOAD_HEADER', true);
define('IN_LOGIN', true);
require 'loader.php';
//create new SpoonForm
$frm = new SpoonForm('login');
//create form element
$frm->addText('adminname');
$frm->addPassword('adminpw');
$frm->addButton('submit', 'Submit');
if ($frm->isSubmitted()) {
    if ($frm->getField('adminname')->getValue() == ADMINNAME && $frm->getField('adminpw')->getValue() == ADMINPASSWORD) {
        $_SESSION['logined'] = true;
        $_SESSION['adminname'] = $frm->getField('adminname')->getValue();
        $_SESSION['adminpw'] = $frm->getField('adminpw')->getValue();
        $_SESSION['expired'] = time() + ADMINEXPIRED;
        header('Location: ' . BASE_URL . '/');
        $tpl->assign('tooltip', 'Login Success! System will auto redirect you to front page, <a href="' . BASE_URL . '/index.php">click here if not</a>.');
    } else {
        $tpl->assign('tooltip', 'Admin name or Admin password is not correct!');
    }
}
$frm->parse($tpl);
$tpl->display(ROOT_PATH . '/' . TEMPLATE_PATH . '/login.tpl.php');
コード例 #3
0
ファイル: index.php プロジェクト: jincongho/clienthub
    $frm->addText('companyno' . $i)->setAttribute("placeholder", "公司号码 Company number");
    $frm->addText('companyemail' . $i)->setAttribute("placeholder", "公司电邮 Company email");
    $frm->addTextarea('shareholder' . $i)->setAttribute("placeholder", "公司股东 Shareholder");
    $frm->addTextarea('registeraddr' . $i)->setAttribute("placeholder", "注册地址 Registered Address");
    $frm->addTextarea('businessaddr' . $i)->setAttribute("placeholder", "营业地址Business Address");
}
$frm->addTextareas('address', 'family', 'remarks', 'casereport');
$frm->addImage('photo');
$frm->addDropdown('gender', array('' => '', 'male' => 'Male', 'female' => 'Female'));
$frm->addText('height')->setAttribute('placeholder', 'digits only');
$frm->addText('weight')->setAttribute('placeholder', 'digits only');
$frm->addDropdown('blood', array('' => '', 'O+' => 'O+', 'A+' => 'A+', 'B+' => 'B+', 'AB+' => 'AB+', 'O-' => 'O-', 'A-' => 'A-', 'B-' => 'B-', 'AB-' => 'AB-'));
$frm->addButton('submit', 'Submit');
//if form submitted
if ($frm->isSubmitted()) {
    $frm->getField('name')->isFilled('Please Fill in Client\'s Name.');
    if ($frm->getField('email')->isFilled()) {
        $frm->getField('email')->isEmail('Please provide a valid email address.');
    }
    for ($i = 1; $i < 6; $i++) {
        if ($frm->getField('companyemail' . $i)->isFilled()) {
            $frm->getField('companyemail' . $i)->isEmail('Please provide a valid email address.');
        }
    }
    if ($frm->getField('photo')->isFilled()) {
        if ($frm->getField('photo')->isAllowedExtension(array('jpg', 'png', 'gif', 'jpeg'), 'Only jpg/gif/png/jpeg are allowed.')) {
            $frm->getField('photo')->isFilesize(IMAGE_MAX, 'kb', 'smaller', 'Too large. ' . IMAGE_MAX . 'kb maximum!');
        }
    }
    if (!in_array($frm->getField('gender')->getValue(), array('', 'male', 'female'))) {
        $frm->getField('gender')->setError('Please choose from the list only!');