Esempio n. 1
0
 public static function getProgressiveCode()
 {
     $engine = Engine::getInstance();
     $dbname = $engine->getDbName();
     $result = $engine->db->fetchOne("SELECT `AUTO_INCREMENT`\n\t\t\t\tFROM  INFORMATION_SCHEMA.TABLES\n\t\t\t\tWHERE TABLE_SCHEMA = '{$dbname}'\n\t\t\t\tAND   TABLE_NAME   = 'customers_groups'");
     return str_pad($result['AUTO_INCREMENT'], 4, 0, STR_PAD_LEFT);
 }
Esempio n. 2
0
 public function __construct()
 {
     if (self::$_alreadyInit) {
         return;
     }
     define('THUNDERHAWK', 'Thunderhawk');
     define('TH', THUNDERHAWK);
     define('TH_VERSION', Engine::getVersion());
     define('TH_PREFIX', 'th');
     define('TH_DB_PREFIX', Engine::getInstance()->getDbPrefix() . '_');
     define('TH_BASE_DIR', $_SERVER['DOCUMENT_ROOT'] . Engine::getInstance()->getBaseUri());
     self::$_alreadyInit = true;
 }
Esempio n. 3
0
 public static function checkPermission($moduleName, $serviceName)
 {
     $registeredPermissions = self::getPermissions($moduleName);
     $declaredPermissions = Engine::getInstance()->getModuleDefinition($moduleName)['permissions'];
     foreach ($declaredPermissions as $declaredPermission) {
         foreach ($registeredPermissions as $registerdPermission) {
             if ($declaredPermission == $registerdPermission && $declaredPermission->getServiceName() === $serviceName) {
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 4
0
 private function checkPermission($name)
 {
     $moduleName = $this->router->getModuleName();
     if (trim($moduleName) == false) {
         return;
     }
     $permission = Permission\Manager::checkPermission($moduleName, $name);
     $className = $this->router->getNamespaceName();
     dump('module ' . $moduleName . ' in namespace ' . $className . ' wanna get  ' . $name);
     if (Service::isService($name) && Engine::getInstance()->isRegisteredModule($moduleName) && !$permission) {
         //dump ( 'doesn\'t have permission for ' . $name . ' ' . $moduleName . ' ' . ( int ) $permission );
         Engine::throwException($name, 300);
     }
     return true;
 }
Esempio n. 5
0
 public function initialize()
 {
     $this->session->start();
     $this->engine = Engine::getInstance();
     $this->tag->setDoctype(\Phalcon\Tag::HTML5);
     $this->tag->setTitleSeparator($this->config->app->titleSeparator);
     $this->tag->setTitle($this->config->app->title);
     $this->settings = Settings::findFirst(array('namespace = ?0 AND controller = ?1', 'bind' => array($this->dispatcher->getNamespaceName(), $this->dispatcher->getControllerName())));
     if ($this->settings === false) {
         $this->settings = new Settings();
     }
     $this->cssPlugins = $this->assets->collection('cssPlugins');
     $this->jsPlugins = $this->assets->collection('jsPlugins');
     $this->jsComponents = $this->assets->collection('jsComponents');
     $this->jsControllers = $this->assets->collection('jsControllers');
     $this->view->body_class = '';
     $this->onInitialize();
 }
Esempio n. 6
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     if (array_key_exists('moduleUri', $this->getOptions())) {
         $this->moduleUri = $this->getOptions()['moduleUri'];
     }
     $this->dirs = Engine::getInstance()->getConfigDirs();
     $this->customRequireFunction = function ($name) {
         if (!array_key_exists($name, $this->loadedLibraries)) {
             $this->loadedLibraries[$name] = $this->customLibraries[$name];
             $collectionBase = $this->loadedLibraries[$name]['collection'];
             foreach ($this->loadedLibraries[$name]['resources'] as $type => $resource) {
                 $calledFunction = 'add' . ucfirst($type);
                 $path = $this->dirs['assets']->lib . $resource['path'];
                 $this->collection($collectionBase . '-' . $type)->{$calledFunction}($path, $resource['local'], $resource['filter'], $resource['attributes']);
             }
         }
     };
     $this->customOutputFunction = function ($name) {
         if (!array_key_exists($name, $this->loadedLibraries)) {
             return;
         }
         foreach ($this->loadedLibraries[$name]['resources'] as $type => $resource) {
             $collection = $this->loadedLibraries[$name]['collection'] . '-' . $type;
             $calledFunction = 'output' . ucfirst($type);
             $this->{$calledFunction}($collection);
         }
     };
     $this->initializeCustomMethods();
     $this->siteBaseUri = Service::get(Service::URL)->getBaseUri();
     $this->assetsUri = $this->dirs['public']->assets;
     $this->standardUri = $this->dirs['assets']->standard;
     $this->themesUri = $this->dirs['assets']->themes;
     $this->libUri = $this->dirs['assets']->lib;
     $this->collection('customjs');
     $this->collection('customcss');
 }
Esempio n. 7
0
 public static function isService($serviceName)
 {
     return Engine::getInstance()->isService($serviceName);
 }
Esempio n. 8
0
 public static function isService($value)
 {
     return self::isEnumValue($value) || Engine::getInstance()->getDI()->has($value);
 }
Esempio n. 9
0
 protected function onRegisterAssets($di, $assets)
 {
     $baseDir = $this->baseDir;
     $di->set('assets', function () use($baseDir) {
         $dirs = Engine::getInstance()->getConfigDirs();
         $assets = new AssetsManager(['moduleUri' => $dirs['assets']->modules . $baseDir . '/']);
         return $assets;
     });
     $this->copyAssets(true);
 }
Esempio n. 10
0
 public function outputRenderInlineJs()
 {
     foreach ($this->_renderJs as $file => $content) {
         $js = Engine::getInstance()->getService(ServiceManager::VIEW_JS);
         echo '<script>';
         echo $js->render($file, $content['parameters']);
         echo '</script>';
     }
 }
Esempio n. 11
0
 public function __construct()
 {
     $this->_engine = Engine::getInstance();
     $this->_namespace = $this->_engine->getModules()[$this->getModuleName()]['namespace'];
 }