Пример #1
0
 public static function update($data)
 {
     //CHECK
     $checks = array('defaultLanguage' => 'is_string-!is_empty', 'availableLanguages' => 'is_array-!is_empty', 'defaultBaseUrl' => 'is_string-!is_empty', 'availableBaseUrl' => 'is_array-!is_empty');
     if (!KLib\Validator::arrayCheck($data, $checks)) {
         throw new Exception('INVALID CONFIG DATA', 500);
     }
     if (!array_key_exists($data['defaultLanguage'], C::g('LIST_LANGUAGE'))) {
         throw new Exception('INVALID CONFIG DATA', 500);
     }
     foreach ($data['availableLanguages'] as $id) {
         if (!array_key_exists(strtoupper($id), C::g('LIST_LANGUAGE'))) {
             throw new Exception('INVALID CONFIG DATA', 500);
         }
         $availableLanguages[] = "'" . strtoupper($id) . "'";
     }
     if (!filter_var('http://' . $data['defaultBaseUrl'], FILTER_VALIDATE_URL)) {
         throw new Exception('INVALID CONFIG DATA', 500);
     }
     foreach ($data['availableBaseUrl'] as $id) {
         if (!filter_var('http://' . $id, FILTER_VALIDATE_URL)) {
             throw new Exception('INVALID CONFIG DATA', 500);
         }
         $availableBaseUrls[] = "'" . $id . "'";
     }
     $raw = "<?php\n### Default language\n### Index of LIST_LANGUAGE\nC::s('DEFAULT_LANG', '" . $data['defaultLanguage'] . "');\n### Language available\n### List of index of LIST_LANGUAGE\nC::s('DEFAULT_AVAILABLE_LANG', array(" . implode(', ', $availableLanguages) . "));\n###  Default baseUrl\n### eg. 'www.korona.io'\nC::s('DEFAULT_BASEURL', '" . $data['defaultBaseUrl'] . "');\n###  List of available baseUrl\n### eg. 'www.korona.io'\nC::s('DEFAULT_AVAILABLE_BASEURL', array(" . implode(', ', $availableBaseUrls) . "));";
     return file_put_contents(self::$configPath, $raw);
 }
Пример #2
0
 public function __construct($data = null)
 {
     parent::__construct($data);
     if (is_array($data)) {
         $checks = array('pageId' => 'is_mongoid');
         if (!KLib\Validator::arrayCheck($data, $checks)) {
             throw new Exception('INVALID PARAMETER MENUITEMINTERNAL', 500);
         }
         $this->setPageId($data['pageId']);
     }
 }
Пример #3
0
 public function __construct($id = null)
 {
     $data = array();
     if (MongoId::isValid($id)) {
         $data = KLib\MongoDB::findOne(array('_id' => (string) $id), 'kn_page');
         if (!is_array($data) || empty($data)) {
             throw new Exception('INVALID PAGE DATA', 500);
         }
         if (array_key_exists('_id', $data) && !array_key_exists('id', $data)) {
             $data['id'] = $data['_id'];
             unset($data['_id']);
         }
     } elseif (is_array($id)) {
         if (array_key_exists('_id', $id) && !array_key_exists('id', $id)) {
             $id['id'] = $id['_id'];
             unset($id['_id']);
         }
         $checks = array('id' => 'is_mongoid', 'baseUrl' => 'is_string-!is_empty', 'uri' => 'is_string-!is_empty', 'language' => 'is_string-!is_empty', 'languageParentId' => 'is_mongoid|is_null', 'ajax' => 'isBool', 'published' => 'isBool', 'metas' => 'is_array', 'css' => 'is_array', 'js' => 'is_array', 'content' => 'is_string', 'action' => 'is_string-!is_empty', 'method' => 'is_string-!is_empty', 'modele' => 'is_string-!is_empty', 'title' => 'is_string-!is_empty', '#blockIds' => 'is_array', 'datas' => 'is_array', 'priority' => 'is_float', 'dateModify' => 'is_timestamp|is_null', 'dateCreate' => 'is_timestamp|!is_empty');
         if (!KLib\Validator::arrayCheck($id, $checks)) {
             throw new Exception('INVALID PAGE DATA', 500);
         }
         $data = $id;
     } elseif (!is_null($id)) {
         throw new Exception('INVALID PAGE DATA', 500);
     }
     if (is_array($data) && !empty($data)) {
         $this->id = (string) $data['id'];
         $this->setBaseUrl($data['baseUrl']);
         $this->setUri($data['uri']);
         $this->setLanguage($data['language']);
         $this->setLanguageParentId($data['languageParentId']);
         $this->setAjax($data['ajax']);
         $this->setPublished($data['published']);
         $this->setMetas($data['metas']);
         $this->setCss($data['css']);
         $this->setJs($data['js']);
         $this->setContent($data['content']);
         $this->setAction($data['action']);
         $this->setMethod($data['method']);
         $this->setModele($data['modele']);
         $this->setTitle($data['title']);
         $this->setBlockIds(array_key_exists('blockIds', $data) ? $data['blockIds'] : array());
         $this->setDatas($data['datas']);
         $this->setPriority($data['priority']);
         $this->dateModify = is_null($data['dateModify']) ? null : intval($data['dateModify']);
         $this->dateCreate = is_null($data['dateCreate']) ? null : intval($data['dateCreate']);
     }
 }
Пример #4
0
 public function __construct($id = null)
 {
     if (is_array($id) && !empty($id)) {
         $checks = array('id' => 'is_string-!is_empty', 'password' => 'is_string-!is_empty', 'displayName' => 'is_string-!is_empty', 'type' => 'is_string-!is_empty', '#mail' => 'is_mail');
         if (!KLib\Validator::arrayCheck($id, $checks)) {
             throw new Exception('INVALID KADMIN FORMAT', 500);
         }
     } elseif (!is_null($id)) {
         throw new Exception('KADMIN NOT FOUND', 500);
     }
     $this->id = (string) $id['id'];
     $this->password = (string) $id['password'];
     $this->displayName = (string) $id['displayName'];
     $this->type = (string) $id['type'];
     $this->mail = $id['mail'];
 }
Пример #5
0
 public function __construct($item = null)
 {
     if (!is_null($item)) {
         if (!is_array($item)) {
             throw new Exception('INVALID PARAMETER MENUITEM', 500);
         }
         $checks = array('#id' => 'is_mongoid|null', 'type' => 'is_string-!is_empty', 'label' => 'is_string', 'url' => 'is_string|is_null', 'target' => 'is_string|is_null');
         if (!KLib\Validator::arrayCheck($item, $checks)) {
             throw new Exception('INVALID PARAMETER MENUITEM', 500);
         }
         if (array_key_exists('id', $item)) {
             $this->id = (string) $item['id'];
         }
         $this->setLabel((string) $item['label']);
         $this->setType((string) $item['type']);
         $this->setUrl($item['url']);
         $this->setTarget($item['target']);
     }
 }
Пример #6
0
 public function __construct($id = null)
 {
     $data = array();
     if (MongoId::isValid($id)) {
         $data = KLib\MongoDB::findOne(array('_id' => $id), 'kn_menu');
         if (!is_array($data) || empty($data)) {
             throw new Exception('INVALID PAGE DATA', 500);
         }
         if (array_key_exists('_id', $data) && !array_key_exists('id', $data)) {
             $data['id'] = $data['_id'];
             unset($data['_id']);
         }
     } elseif (is_array($id)) {
         if (array_key_exists('_id', $id) && !array_key_exists('id', $id)) {
             $id['id'] = $id['_id'];
             unset($id['_id']);
         }
         $checks = array('id' => 'is_mongoid', 'menuId' => 'is_string-!is_empty', 'label' => 'is_string-!is_empty', 'language' => 'is_string-!is_empty', 'languageParentId' => 'is_mongoid|is_null', 'items' => 'is_array', 'modele' => 'is_string-!is_empty', 'dateModify' => 'is_timestamp|is_null', 'dateCreate' => 'is_timestamp|!is_empty');
         if (!KLib\Validator::arrayCheck($id, $checks)) {
             throw new Exception('INVALID PAGE DATA', 500);
         }
         $data = $id;
     } elseif (!is_null($id)) {
         throw new Exception('INVALID PAGE DATA', 500);
     }
     if (is_array($data) && !empty($data)) {
         $this->id = (string) $data['id'];
         $this->setMenuId($data['menuId']);
         $this->setLabel($data['label']);
         $this->setLanguage($data['language']);
         $this->setLanguageParentId($data['languageParentId']);
         $this->setModele($data['modele']);
         $this->setItems($data['items']);
         $this->dateModify = is_null($data['dateModify']) ? null : intval($data['dateModify']);
         $this->dateCreate = is_null($data['dateCreate']) ? null : intval($data['dateCreate']);
     }
 }
Пример #7
0
 public function __construct($id = null)
 {
     $this->language = C::g('DEFAULT_LANG');
     $data = array();
     if (MongoId::isValid($id)) {
         $data = KLib\MongoDB::findOne(array('_id' => (string) $id), 'kn_block');
         if (!is_array($data) || empty($data)) {
             throw new Exception('INVALID BLOCK DATA', 500);
         }
         if (array_key_exists('_id', $data) && !array_key_exists('id', $data)) {
             $data['id'] = $data['_id'];
             unset($data['_id']);
         }
     } elseif (is_array($id)) {
         if (array_key_exists('_id', $id) && !array_key_exists('id', $id)) {
             $id['id'] = $id['_id'];
             unset($id['_id']);
         }
         $checks = array('id' => 'is_mongoid', 'type' => 'is_string-!is_empty', 'key' => 'is_string-!is_empty', 'label' => 'is_string-!is_empty', 'language' => 'is_string-!is_empty', 'action' => 'is_string-!is_empty', 'datas' => 'is_array');
         if (!KLib\Validator::arrayCheck($id, $checks)) {
             throw new Exception('INVALID BLOCK DATA', 500);
         }
         $data = $id;
     } elseif (!is_null($id)) {
         throw new Exception('INVALID BLOCK DATA', 500);
     }
     if (is_array($data) && !empty($data)) {
         $this->id = (string) $data['id'];
         $this->setType($data['type']);
         $this->setKey($data['key']);
         $this->setLabel($data['label']);
         $this->setLanguage($data['language']);
         $this->setAction($data['action']);
         $this->setDatas($data['datas']);
     }
 }
Пример #8
0
 public static function translateUpdatePo()
 {
     $checks = array('file' => 'is_fileUploaded');
     return KLib\Validator::arrayCheck($_FILES, $checks);
 }