Example #1
0
 /**
  * Adds a setting to the databse
  * @param string $setting
  */
 public function addSetting($setting)
 {
     $data = array('setting_key' => $setting);
     if (in_array($setting, $this->getSerialized())) {
         $data['serialized'] = '1';
     }
     return $this->db->insert($this->getTable(), $data);
 }
Example #2
0
 /**
  * Sets up and returns all the objects we'll use
  * @return \mithra62\Language|\Pimple\Container
  */
 public function getServices()
 {
     $this->container['db'] = function ($c) {
         $db = new Db();
         $db->setCredentials($this->getDbConfig());
         return $db;
     };
     $this->container['encrypt'] = function ($c) {
         $encrypt = new Encrypt();
         $new_key = $c['platform']->getEncryptionKey();
         $encrypt->setKey($new_key);
         return $encrypt;
     };
     $this->container['lang'] = function ($c) {
         $lang = new Language();
         if (is_array($this->getLangPath())) {
             foreach ($this->getLangPath() as $path) {
                 $lang->init($path);
             }
         } elseif ($this->getLangPath() != '') {
             $lang->init($this->getLangPath());
         }
         return $lang;
     };
     $this->container['validate'] = function ($c) {
         $validate = new Validate();
         $validate->setRegex($this->container['regex']);
         return $validate;
     };
     $this->container['files'] = function ($c) {
         $file = new Files();
         return $file;
     };
     $this->container['errors'] = function ($c) {
         $errors = new Errors();
         $errors->setValidation($c['validate']);
         return $errors;
     };
     $this->container['license'] = function ($c) {
         $license = new License();
         return $license;
     };
     $this->container['email'] = function ($c) {
         $email = new Email();
         $email->setView($c['view']);
         $email->setLang($c['lang']);
         return $email;
     };
     $this->container['view'] = function ($c) {
         $view = new View();
         $helpers = array('file_size' => function ($text) {
             return $this->container['view_helpers']->m62FileSize($text);
         }, 'lang' => function ($text) {
             return $this->container['view_helpers']->m62Lang($text);
         }, 'date_time' => function ($text, $html = true) {
             return $this->container['view_helpers']->m62DateTime($text, $html = true);
         }, 'encode' => function ($text) {
             return $this->container['view_helpers']->m62Encode($text);
         }, 'decode' => function ($text) {
             return $this->container['view_helpers']->m62Decode($text);
         });
         $view->addHelper('m62', $helpers);
         return $view;
     };
     $this->container['regex'] = function ($c) {
         $regex = new Regex();
         return $regex;
     };
     $this->container['shell'] = function ($c) {
         $shell = new Shell();
         return $shell;
     };
     return $this->container;
 }