Esempio n. 1
0
 /**
  *
  */
 public function __construct()
 {
     if (array_key_exists('action', $_REQUEST) && $_REQUEST['type'] === 'ajax' && $_REQUEST['action'] != 'prepareDatabase') {
         \Cunity\Core\Cunity::init();
     } elseif (array_key_exists('action', $_REQUEST) && $_REQUEST['type'] != 'ajax') {
         $this->init();
     }
     $this->initTranslator();
     $this->handleRequest();
 }
Esempio n. 2
0
 /**
  * @throws \Exception
  */
 public function __construct()
 {
     View::initTranslator();
     array_walk_recursive($_GET, [$this, 'trimhtml']);
     array_walk_recursive($_POST, [$this, 'trimhtml']);
     Cunity::init();
     //use the filesdir hash as unique session name
     session_name("cunity-" . Cunity::get("settings")->getSetting("core.filesdir"));
     session_start();
     if (Models\Request::isAjaxRequest()) {
         set_exception_handler([$this, 'handleAjaxException']);
     } else {
         set_exception_handler([$this, 'handleException']);
     }
     $this->handleQuery();
 }
Esempio n. 3
0
 /**
  *
  */
 public static function initTranslator()
 {
     Cunity::init();
     $locale = new Zend_Locale(Cunity::get('settings')->getSetting('core.language'));
     if (null === self::$zt) {
         self::$zt = new Zend_Translate(['adapter' => 'csv', 'content' => __DIR__ . '/../languages/' . $locale->getLanguage() . '.csv', 'scan' => Zend_Translate::LOCALE_FILENAME, 'locale' => $locale->getLanguage()]);
         /** @noinspection PhpUndefinedMethodInspection */
         self::$zt->addTranslation(array('content' => __DIR__ . '/../languages/' . $locale->getLanguage() . '.csv', 'locale' => $locale->getLanguage()));
         /** @noinspection PhpUndefinedMethodInspection */
         $missingTranslationLog = __DIR__ . '/../../../../resources/log/missing-translations.log';
         if (is_writeable($missingTranslationLog)) {
             self::$zt->setOptions(['log' => new Zend_Log(new Zend_Log_Writer_Stream($missingTranslationLog)), 'logUntranslated' => true]);
         }
         /** @noinspection PhpUndefinedMethodInspection */
         if (!self::$zt->isAvailable($locale->getLanguage())) {
             /** @noinspection PhpUndefinedMethodInspection */
             self::$zt->setLocale(self::$defaultLanguage);
         }
         /** @noinspection PhpUndefinedMethodInspection */
         self::$zt->getLocale();
     }
 }