예제 #1
0
 public function checkToShowTutorial(Rsc_Http_Parameters $query)
 {
     $this->_pluginSlug = $this->environment->getConfig()->get('plugin_slug');
     $page = $query->get('page');
     $module = $query->get('module');
     $action = $query->get('action');
     $disableTutorial = $query->get($this->_pluginSlug . '-ignore-tour');
     if ($disableTutorial !== null) {
         update_user_meta(get_current_user_id(), $this->_pluginSlug . '-ignore-tour', $disableTutorial);
     }
     $showTour = (int) get_user_meta(get_current_user_id(), $this->_pluginSlug . '-ignore-tour', true) ? false : true;
     if ($showTour) {
         switch (true) {
             case $page == $this->_pluginSlug && $module == 'projects' && $action == 'add':
                 $this->createProjectDesignTour();
                 break;
             case $page == $this->_pluginSlug && $module == 'projects' && $action == 'view':
                 $this->projectMainSettingTour();
                 break;
             default:
                 $this->startTutorialTourPointer();
         }
     }
 }
예제 #2
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;
 }
 /**
  * Do validation
  * @param Rsc_Http_Parameters $method
  */
 protected function doValidation(Rsc_Http_Parameters $method)
 {
     if (empty($this->rules)) {
         return;
     }
     /** @var Rsc_Form_Rule_Interface $rule */
     foreach ($this->rules as $field => $rules) {
         if (!is_array($this->rules[$field])) {
             $rules = array($rules);
         }
         foreach ($rules as $rule) {
             if ($method->has($field)) {
                 if (!$rule->validate($method->get($field))) {
                     if (!is_array($this->errors)) {
                         $this->errors = array();
                     }
                     $this->errors[$field][] = $rule->getMessage();
                 }
             }
         }
     }
 }
예제 #4
0
 /**
  * Returns the name of the user operating system
  * @return string|null
  */
 public function getUserOs()
 {
     $userAgent = $this->headers->get('USER_AGENT');
     preg_match_all('/windows|macintosh|linux|freebsd|unix|iphone/i', $userAgent, $os);
     return isset($os[0]) ? reset($os[0]) : null;
 }