예제 #1
0
 /**
  * Returns both database and plugin prefixes.
  * @return string
  */
 public function getPrefix()
 {
     if (!$this->environment) {
         throw new RuntimeException('Can\'t get prefix without app environment.');
     }
     $database = $this->db->prefix;
     $plugin = $this->environment->getConfig()->get('db_prefix');
     return $database . $plugin;
 }
예제 #2
0
 /**
  * Builds the model name.
  * @param string $model
  * @param string|Rsc_Mvc_Module $module
  * @return string
  */
 protected function getClassName($model, $module)
 {
     if (!$module) {
         $module = $model;
     }
     if ($module instanceof Rsc_Mvc_Module) {
         $module = $module->getModuleName();
     }
     $prefix = $this->environment->getConfig()->get('plugin_prefix');
     $className = $prefix . '_' . ucfirst($module) . '_Model_' . ucfirst($model);
     return $className;
 }
예제 #3
0
 /**
  * Builds the model name.
  * @param string $model
  * @param string|Rsc_Mvc_Module $module
  * @param string $prefix
  * @return string
  */
 protected function getClassName($model, $module, $prefix = null)
 {
     if (null === $prefix) {
         $prefix = $this->environment->getConfig()->get('plugin_prefix');
     }
     if (!$module) {
         $module = $model;
     }
     if (is_object($module) && $module instanceof Rsc_Mvc_Module) {
         $e = explode('_', get_class($module));
         $prefix = array_shift($e);
         $module = $module->getModuleName();
     }
     $className = $prefix . '_' . ucfirst($module) . '_Model_' . ucfirst($model);
     return $className;
 }
예제 #4
0
 /**
  * @param Rsc_Http_Parameters $method
  * @return bool
  */
 public function handleRequest(Rsc_Http_Parameters $method)
 {
     /** @var Rsc_Mvc_Module $module */
     if (!$method->has('route')) {
         return false;
     }
     $route = $method->get('route');
     $module = isset($route['module']) ? $route['module'] : $this->environment->getConfig()->get('default_module');
     $action = isset($route['action']) ? $route['action'] : 'index';
     if (null !== ($module = $this->environment->getModule(strtolower($module)))) {
         $controller = $module->getController();
         if ($controller !== null && method_exists($controller, $action = sprintf('%sAction', $action))) {
             return call_user_func_array(array($controller, $action), array($controller->getRequest()));
         }
     }
     return false;
 }
 /**
  * Creates plugin's directories.
  */
 protected function initFilesystem()
 {
     $directories = array('tmp' => '/supsystic-slider', 'log' => '/supsystic-slider/log', 'cache' => '/supsystic-slider/cache', 'twig_cache' => '/supsystic-slider/cache/twig');
     foreach ($directories as $key => $dir) {
         if (false !== ($fullPath = $this->makeDirectory($dir))) {
             $this->environment->getConfig()->add('plugin_' . $key, $fullPath);
         }
     }
 }
예제 #6
0
 /**
  * Constructor
  * @param bool $debugEnabled
  */
 public function __construct($debugEnabled, Rsc_Environment $environment)
 {
     parent::__construct((bool) $debugEnabled);
     $config = $environment->getConfig();
     $vendor = $config->get('db_prefix');
     $this->table = $this->db->prefix . $vendor . 'stats';
     $this->maxVisits = 10;
     $this->environment = $environment;
 }
 /**
  * Creates plugin's directories.
  */
 protected function initFilesystem()
 {
     $directories = array('tmp' => '/grid-gallery', 'log' => '/grid-gallery/log', 'cache' => '/grid-gallery/cache', 'cache_galleries' => '/grid-gallery/cache/galleries', 'cache_twig' => '/grid-gallery/cache/twig');
     foreach ($directories as $key => $dir) {
         if (false !== ($fullPath = $this->makeDirectory($dir))) {
             $this->environment->getConfig()->add('plugin_' . $key, $fullPath);
         }
     }
 }
예제 #8
0
 public function handle()
 {
     $action = $this->request->query->get('action', 'index') . 'Action';
     $welcomePageShowed = $this->environment->getConfig()->get('welcome_page_was_showed');
     $promoController = $this->environment->getConfig()->get('promo_controller');
     if ($promoController && class_exists($promoController) && !$welcomePageShowed) {
         $promoController = new $promoController($this->environment, $this->request);
         if (method_exists($promoController, 'indexAction')) {
             return call_user_func_array(array($promoController, 'indexAction'), array($this->request));
         }
     } else {
         if (method_exists($this->getController(), $action)) {
             return call_user_func_array(array($this->getController(), $action), array($this->request));
         }
     }
     $twig = $this->environment->getTwig();
     return Rsc_Http_Response::create()->setContent($twig->render('404.twig'));
 }
예제 #9
0
 /**
  * Returns an array of found modules or NULL if at least one module did not found
  * @return array|null
  */
 public function getModulesList()
 {
     if (!$this->modulesList) {
         $modulesList = array();
         $modulesLocation = array(array(dirname(dirname(__FILE__)), 'Rsc'), array($this->environment->getConfig()->get('plugin_source'), $this->environment->getConfig()->get('plugin_prefix')));
         foreach ($modulesLocation as $locationData) {
             if (!in_array(null, $locationData) && count($locationData) == 2) {
                 list($path, $prefix) = $locationData;
                 $modules = $this->findModules($path, $prefix);
                 if (is_array($modules) && count($modules) > 0) {
                     $modulesList = array_merge($modulesList, $modules);
                 }
             }
         }
         $this->modulesList = new Rsc_Common_Collection($modulesList);
     }
     return $this->modulesList;
 }