public function customValid($field, $datas)
 {
     if (!property_exists($this, $field)) {
         return false;
     }
     //Get value
     $value = trim($this->{$field});
     $errors = array();
     if (!empty($datas)) {
         //Check Required
         $required = false;
         $messageCategory = '';
         $message = '';
         foreach ($datas as $r) {
             $check = $r['check'];
             if ($r['check'] == 'required') {
                 $messageCategory = $r['message_category'];
                 $message = $r['message'];
                 $required = true;
                 break;
             }
         }
         //Check empty value
         if ($required === true && $value == '') {
             $errors[] = TQWebapp::getApp()->t($messageCategory, $message);
         }
         //Check other valid
         foreach ($datas as $r) {
             if (!empty($errors)) {
                 break;
             }
             $check = $r['check'];
             $valid = '';
             if (!empty($r['valid'])) {
                 $valid = $r['valid'];
             }
             $message = $r['message'];
             $messageCategory = $r['message_category'];
             switch ($check) {
                 case "only":
                     if ($value == '*****@*****.**') {
                         $errors[] = TQWebapp::getApp()->t($messageCategory, $message, array('valid' => $valid));
                     }
                     break;
                 default:
                     break;
             }
         }
     }
     if (!empty($errors)) {
         $this->error[$field] = $errors;
     }
 }
Example #2
0
 public function fetchView($vFile, $datas = array(), $showHtml = true)
 {
     $viewFile = $this->parseAliasPath('tqapp.widgets.views.' . $vFile);
     if (!file_exists($viewFile)) {
         $mes = $this->t('tqbase', 'Unable to load {file}', array('file' => $vFile));
         throw new TQExceptionHandle($mes, 500);
     }
     //Include TQApp
     $datas['TQApp'] = TQWebapp::getApp();
     // Extract the variables to be used by the view
     if (!empty($datas)) {
         extract($datas);
     }
     //Get View file
     ob_start();
     include $viewFile;
     $contents = ob_get_contents();
     ob_end_clean();
     if ($showHtml == false) {
         return $contents;
     } else {
         echo $contents;
     }
 }
Example #3
0
 public function delete()
 {
     $con = $this->getCon();
     $this->beforeDelete();
     //Build SQL
     //Add Where
     $pks = $this->getPk();
     $sql = "DELETE FROM " . $this->getTableName() . " ";
     $arrayPk = array();
     foreach ($pks as $pk) {
         $arrayPk[] = "{$pk}='" . $this->_attributes[$pk] . "'";
     }
     $sql .= "WHERE " . implode(' AND ', $arrayPk);
     $checkProcess = false;
     try {
         $con->beginTransaction();
         $result = $con->executeSQL($sql);
         if ($result > 0) {
             $checkProcess = true;
             $this->afterDelete();
         }
     } catch (Exception $e) {
         $mes = TQBase::getApp()->t('tqbase', 'Transaction failed: {message}', array('message' => $e->getMessage()));
         throw new TQExceptionHandle($mes, 500);
         $con->rollback();
     }
     $con->endTransaction();
     return $checkProcess;
 }
 public function loadController()
 {
     $cName = ucwords($this->getCid()) . 'Controller';
     $this->_tqRequire('tqapp.controllers.' . $cName);
     return TQBase::createApp("TQAPP\\{$cName}", $this->getConfig());
 }
Example #5
0
 public function executeSQL($sql)
 {
     $result = 0;
     if ($this->getCon()->query($sql)) {
         $result = $this->getCon()->affected_rows;
     } else {
         $mes = TQBase::getApp()->t('tqbase', 'Query [{sql}]. Has error: {error}', array('sql' => $sql, 'error' => $this->getCon()->error));
         throw new TQExceptionHandle($mes, 500);
     }
     $this->resetOption();
     return $result;
 }
 public function widget($wName, $datas = array(), $showHtml = true)
 {
     $wName = ucwords($wName) . 'Widget';
     $this->_tqRequire('tqapp.widgets.' . $wName);
     return TQWebapp::createApp("TQAPP\\{$wName}", $this->getConfig())->run($datas, $showHtml);
 }
Example #7
0
<?php

session_start();
define('DS', DIRECTORY_SEPARATOR);
define('TQAPP_DEBUG', true);
include dirname(__FILE__) . DS . '..' . DS . '..' . DS . 'tqframework' . DS . 'TQBase.php';
$config = dirname(__FILE__) . DS . 'private' . DS . 'config' . DS . 'config.php';
use TQFramework\TQBase as TQWebapp;
TQWebapp::runApp($config)->run()->importByConfig()->dispatch();