コード例 #1
0
 public function testMain()
 {
     $frm = new SpoonForm('name', 'action');
     $frm->addButton('submit', 'submit');
     $frm->addCheckbox('agree', true);
     $frm->addDate('date', time(), 'd/m/Y');
     $frm->addDropdown('author', array(1 => 'Davy', 'Tijs', 'Dave'), 1);
     $frm->addFile('pdf');
     $frm->addImage('image');
     $frm->addHidden('cant_see_me', 'whoop-tie-doo');
     $frm->addMultiCheckbox('hobbies', array(array('label' => 'Swimming', 'value' => 'swimming')));
     $frm->addPassword('top_sekret', 'stars-and-stripes');
     $frm->addRadiobutton('gender', array(array('label' => 'Male', 'value' => 'male')));
     $frm->addTextarea('message', 'big piece of text');
     $frm->addText('email', '*****@*****.**');
     $frm->addText('now', date('H:i'));
 }
コード例 #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);
コード例 #3
0
ファイル: form.php プロジェクト: nickmancol/forkcms-rhcloud
 /**
  * Adds a single textfield.
  *
  * @param string $name The name of the element.
  * @param string[optional] $value The value inside the element.
  * @param int[optional] $maxlength The maximum length for the value.
  * @param string[optional] $class Class(es) that will be applied on the element.
  * @param string[optional] $classError Class(es) that will be applied on the element when an error occurs.
  * @param bool[optional] $HTML Will this element contain HTML?
  * @return SpoonFormText
  */
 public function addText($name, $value = null, $maxlength = 255, $class = null, $classError = null, $HTML = false)
 {
     $name = (string) $name;
     $value = $value !== null ? (string) $value : null;
     $maxlength = $maxlength !== null ? (int) $maxlength : null;
     $class = $class !== null ? (string) $class : 'inputText';
     $classError = $classError !== null ? (string) $classError : 'inputTextError';
     $HTML = (bool) $HTML;
     // create and return a textfield
     return parent::addText($name, $value, $maxlength, $class, $classError, $HTML);
 }
コード例 #4
0
ファイル: index.php プロジェクト: jincongho/clienthub
/**
 * Client Manager
 * 
 * Front to the system. This file build form to create a profile.
 * @package Client Manager
 * @author Jin Cong<*****@*****.**>
 */
define('LOAD_TEMPLATE', true);
define('LOAD_HEADER', true);
require 'loader.php';
//create new SpoonForm
$frm = new SpoonForm('newProfile');
//create forms elements
$frm->addTexts('file', 'case', 'name', 'ic', 'placeofbirth', 'education', 'language', 'race', 'faith', 'maritalstatus', 'nationality', 'profession', 'epf', 'banker', 'contactno', 'email', 'platesno', 'assets', 'eye', 'hair', 'skin', 'dna');
for ($i = 1; $i < 6; $i++) {
    $frm->addText('company' . $i)->setAttribute("placeholder", "公司名字 company name");
    $frm->addText('registerno' . $i)->setAttribute("placeholder", "注册号码 registration number");
    $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
コード例 #5
0
ファイル: search.php プロジェクト: jincongho/clienthub
 * Client Manager
 * 
 * Search engine.
 * @package Client Manager
 * @author Jin Cong<*****@*****.**>
 */
define('LOAD_TEMPLATE', true);
define('LOAD_HEADER', true);
require 'loader.php';
//create new SpoonForm
$frm = new SpoonForm('searchProfile');
//create forms elements
$frm->addTexts('file', 'case', 'name', 'ic', 'placeofbirth', 'education', 'language', 'race', 'faith', 'maritalstatus', 'nationality', 'profession', 'epf', 'banker', 'contactno', 'email', 'platesno', 'assets', 'eye', 'hair', 'skin', 'dna', 'company', 'registerno', 'companyno', 'companyemail');
$frm->addTextareas('address', 'family', 'registeraddr', 'businessaddr', 'remarks');
$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 ($frm->isSubmitted()) {
    //generate query
    $query = 'SELECT `id`, `photo`, `file`, `case`, `name`, `ic`, `company` FROM `profiles` WHERE `status` !=  \'trash\' ';
    $value = $frm->getValues('form', 'submit', '_utf8');
    foreach ($value as $key => $value) {
        if ($value != NULL) {
            $query .= 'AND ';
            $query .= '`' . $key . '` LIKE \'%';
            $query .= (string) $value;
            $query .= '%\' ';
        }
    }
コード例 #6
0
ファイル: edit.php プロジェクト: jincongho/clienthub
define('LOAD_HEADER', true);
require 'loader.php';
if (!isset($_GET['id'])) {
    header("Location: " . BASE_URL);
}
if (isset($_GET['delete']) && $_GET['delete'] == 1) {
    $delete = $mysql->update('profiles', array('status' => 'trash'), 'id = ?', (int) $_GET['id']);
    $tpl->assign('tooltip', $delete ? 'Profile deleted.' : 'Profile deleting failed.');
} else {
    $get_user = $mysql->getRecord('SELECT * FROM `profiles` WHERE `id` = \'' . (int) $_GET['id'] . '\' AND `status` !=  \'trash\'');
    if (empty($get_user)) {
        $tpl->assign('tooltip', 'Profile not available');
    } else {
        //create new SpoonForm
        $frm = new SpoonForm('editProfile');
        $frm->addText('file', $get_user['file']);
        $frm->addText('case', $get_user['case']);
        $frm->addImage('photo');
        if (!empty($get_user['photo'])) {
            $tpl->assign('photo_path', BASE_URL . '/images.php?thumbnail=1&id=' . (int) $_GET['id']);
        }
        $frm->addText('name', $get_user['name']);
        $frm->addText('ic', $get_user['ic']);
        $frm->addDropdown('gender', array('' => '', 'male' => 'Male', 'female' => 'Female'), $get_user['gender']);
        $frm->addText('placeofbirth', $get_user['placeofbirth']);
        $frm->addText('education', $get_user['education']);
        $frm->addText('language', $get_user['language']);
        $frm->addText('race', $get_user['race']);
        $frm->addText('faith', $get_user['faith']);
        $frm->addText('maritalstatus', $get_user['maritalstatus']);
        $frm->addText('nationality', $get_user['nationality']);
コード例 #7
0
ファイル: form.php プロジェクト: jincongho/clienthub
/**
 * Set Company Value from string
 * 
 * @param SpoonForm $frm
 * @param string $value
 */
function setCompanyValue(&$frm, $value)
{
    $values = explode(', ', $value);
    $count = -1;
    for ($i = 1; $i < 6; $i++) {
        $frm->addText('company' . $i, $values[$count += 1])->setAttribute("placeholder", "公司名字 company name");
        $frm->addText('registerno' . $i, $values[$count += 1])->setAttribute("placeholder", "注册号码 registration number");
        $frm->addText('companyno' . $i, $values[$count += 1])->setAttribute("placeholder", "公司号码 Company number");
        $frm->addText('companyemail' . $i, $values[$count += 1])->setAttribute("placeholder", "公司电邮 Company email");
        $frm->addTextarea('shareholder' . $i, $values[$count += 1])->setAttribute("placeholder", "公司股东 Shareholder");
        $frm->addTextarea('registeraddr' . $i, $values[$count += 1])->setAttribute("placeholder", "注册地址 Registered Address");
        $frm->addTextarea('businessaddr' . $i, $values[$count += 1])->setAttribute("placeholder", "营业地址Business Address");
    }
}
コード例 #8
0
ファイル: Form.php プロジェクト: forkcms/forkcms
 /**
  * Adds a single textfield.
  *
  * @param string $name       The name of the element.
  * @param string $value      The value inside the element.
  * @param int    $maxLength  The maximum length for the value.
  * @param string $class      Class(es) that will be applied on the element.
  * @param string $classError Class(es) that will be applied on the element when an error occurs.
  * @param bool   $HTML       Will this element contain HTML?
  *
  * @return \SpoonFormText
  */
 public function addText($name, $value = null, $maxLength = 255, $class = null, $classError = null, $HTML = true)
 {
     $name = (string) $name;
     $value = $value !== null ? (string) $value : null;
     $maxLength = $maxLength !== null ? (int) $maxLength : null;
     $class = $class !== null ? (string) $class : 'form-control fork-form-text';
     $classError = $classError !== null ? (string) $classError : 'error';
     $HTML = (bool) $HTML;
     // create and return a textfield
     return parent::addText($name, $value, $maxLength, $class, $classError, $HTML);
 }