Example #1
0
 function onLoad()
 {
     $this->onCreate();
     if (count(CurrentManifest::getViewIndex()) > 0) {
         $viewIndex = CurrentManifest::getViewIndex();
         $pathIndex = NativeUrl::pathResolver();
         $pathCount = count($pathIndex);
         $leftPath = [];
         $currentView = $viewIndex[self::VIEW_DEFAULT];
         for ($wayNumber = $pathCount; $wayNumber > 0; $wayNumber--) {
             $try = implode("/", $pathIndex);
             if (isset($viewIndex[$try]) && class_exists($viewIndex[$try])) {
                 $currentView = $viewIndex[$try];
                 $leftPath = array_splice(NativeUrl::pathResolver(), $wayNumber);
             } else {
                 array_pop($pathIndex);
             }
         }
         if (class_exists($currentView)) {
             $this->getLogger()->d("{$currentView} view is loaded");
             $class = new $currentView();
             if (!$class instanceof ViewSkeleton) {
                 throw new \InvalidArgumentException("{$currentView} isn't instance of ViewSkeleton");
             }
             EnvironmentVariables::define("currentSkeleton", $currentView);
             $class->onCreate($leftPath);
             $this->onSkeletonLoaded($class);
         } else {
             throw new \InvalidArgumentException("System couldn't find any view handling definition");
         }
     } else {
         throw new \InvalidArgumentException("No view was defined");
     }
     $this->onDestroy();
 }
Example #2
0
 public function onCreate(array $methods)
 {
     $log = new Log(self::TAG);
     $res = ResourceManager::getResource(MainConfig::DB_INDEX_NAME);
     $listPattern = new LogList($this);
     $queuedString = new \genonbeta\util\QueuedString();
     $queuedString->put("my");
     $queuedString->put("name");
     $queuedString->put("is");
     $queuedString->put("veli");
     $queuedString->useSeperator(" ");
     $log->d($queuedString->getString());
     try {
         $sdbLoader = new SQLite3Loader($res->findByName("tr_en"));
         $sdb = $sdbLoader->getDbInstance();
         $result = $sdb->query("SELECT * FROM `tr_en`");
         $cursor = $result->getCursor();
         $log->i("Veritabanında " . $cursor->getCount() . " adet kelime bulunuyor");
     } catch (\Exception $e) {
     }
     $this->loadLanguage(new Turkish());
     $this->setUrlResolver(new UrlResolver(EnvironmentVariables::get("workerAddress"), CurrentManifest::getViewIndex()));
     $log->d($this->getString("t", ["naber lan"]));
     $dbLoader = new MySQLLoader();
     $db = $dbLoader->getDbInstance();
     $log->i("<a href=\"" . $this->getUri("about", "?isOkay=true") . "\">Goto about page</a>");
     $this->drawPattern(new GBasicSkeleton($this), "system_html", array(GBasicSkeleton::TITLE => "Home", GBasicSkeleton::BODY => $listPattern->drawAsAdapter(Log::getLogs())));
 }
Example #3
0
 protected function onCreate()
 {
     $fwConf = CurrentManifest::getConfiguration();
     $req = new RequiredFiles(self::TAG);
     $req->request(Configuration::DATA_PATH . "/" . $fwConf['data_path'], RequiredFiles::TYPE_DIRECTORY);
     $req->request(Configuration::DATA_PATH . "/" . $fwConf['language_path'], RequiredFiles::TYPE_DIRECTORY);
     $req->request(Configuration::DATA_PATH . "/" . $fwConf['html_path'], RequiredFiles::TYPE_DIRECTORY);
     $req->request(Configuration::DATA_PATH . "/" . $fwConf['database_path'], RequiredFiles::TYPE_DIRECTORY);
     ResourceManager::addResource(MainConfig::LANGUAGE_INDEX_NAME, Configuration::DATA_PATH . "/" . $fwConf['language_path'], "json");
     ResourceManager::addResource(MainConfig::PATTERN_INDEX_NAME, Configuration::DATA_PATH . "/" . $fwConf['html_path'], "html");
     ResourceManager::addResource(MainConfig::DB_INDEX_NAME, Configuration::DATA_PATH . "/" . $fwConf['database_path'], "db");
 }