| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace MGModule\DNSManager2\mgLibs\process;
- use MGModule\DNSManager2 as main;
- /**
- * Description of abstractController
- *
- * @author Michal Czech <michael@modulesgarden.com>
- */
- abstract class abstractController {
- public $mgToken = null;
- private $registredValidationErros = array();
-
- function __construct($input) {
- if(isset($input['mg-token']))
- {
- $this->mgToken = $input['mg-token'];
- }
- }
-
- /**
- * Generate Token For Form
- *
- * @author Michal Czech <michael@modulesgarden.com>
- * @return string
- */
- function genToken(){
- return md5(time());
- }
-
- /**
- * Validate Token With previous checked
- *
- * @author Michal Czech <michael@modulesgarden.com>
- * @param string $token
- * @return boolean
- */
- function checkToken($token = null){
- if($token === null)
- {
- $token = $this->mgToken;
- }
-
- if($_SESSION['mg-token'] === $token)
- {
- return false;
- }
-
- $_SESSION['mg-token'] = $token;
-
- return true;
- }
-
- function dataTablesParseRow($template,$data){
- $row = main\mgLibs\smarty::I()->view($template,$data);
- $output = array();
-
- if(preg_match_all('/\<td\>(?P<col>.*?)\<\/td\>/s', $row, $result))
- {
- foreach($result['col'] as $col)
- {
- $output[] = $col;
- }
- }
-
- return $output;
- }
-
- function registerErrors($errors){
- $this->registredValidationErros = $errors;
- }
-
- function getFieldError($field,$langspace='validationErrors'){
- if(!isset($this->registredValidationErros[$field]))
- {
- return false;
- }
-
- $message = array();
- foreach($this->registredValidationErros[$field] as $type)
- {
- $message[] = main\mgLibs\lang::absoluteT($langspace,$type);
- }
-
- return implode(',',$message);
- }
- }
|