Beispiel #1
0
 function importClassGmp($class, $path = '')
 {
     if (!class_exists($class)) {
         if (!$path) {
             $classFile = $class;
             if (strpos(strtolower($classFile), GMP_CODE) !== false) {
                 $classFile = preg_replace('/' . GMP_CODE . '/i', '', $classFile);
             }
             $path = GMP_CLASSES_DIR . $classFile . '.php';
         }
         return importGmp($path);
     } else {
         //If such class already exist - let's check does this is our plugin class or someone else
         /*if(class_exists('ReflectionClass')) {   //ReflectionClass supported begining from php5
               $reflection = new ReflectionClass($class);
               $classFile = $reflection->getFileName();
               if(strpos($classFile, GMP_DIR) === false) {   //Class is not in our plugin directory
                   $conflictWith = substr($classFile, strpos($classFile, 'plugins') + strlen('plugins'. DS));
                   $conflictWith = substr($conflictWith, 0, strpos($conflictWith, DS));
                   $plugins = get_option('active_plugins');
                   if(!empty($plugins)) {
                       for($i = 0; $i < count($plugins); $i++) {
                           if(strpos($plugins[$i], GMP_PLUG_NAME) !== false) {   //Let's remove our plugin from list of active plugins
                               unset($plugins[$i]);
                           }
                       }
                       update_option( 'active_plugins', $plugins );
                   }
                   exit('Sorry, but we have conflict with class name <b style="color: red;">'. $class. '</b> in one of your already installed plugins <b style="color: red;">'. $conflictWith. '</b> located at '. $classFile. '. This means that you can not have both two plugins at one time.');
               }
           }*/
     }
     return false;
 }
Beispiel #2
0
 protected function _createView($name = '')
 {
     if (empty($name)) {
         $name = $this->getCode();
     }
     $parentModule = frameGmp::_()->getModule($this->getCode());
     $className = '';
     if (importGmp($parentModule->getModDir() . 'views' . DS . $name . '.php')) {
         $className = toeGetClassNameGmp($name . 'View');
     }
     if ($className) {
         $view = new $className();
         $view->setCode($this->getCode());
         return $view;
     }
     return NULL;
 }
Beispiel #3
0
 protected function _createController()
 {
     if (!file_exists($this->getModDir() . 'controller.php')) {
         return false;
         // EXCEPTION!!!
     }
     if ($this->_controller) {
         return true;
     }
     if (file_exists($this->getModDir() . 'controller.php')) {
         $className = '';
         if (importGmp($this->getModDir() . 'controller.php')) {
             $className = toeGetClassNameGmp($this->getCode() . 'Controller');
         }
         if (!empty($className)) {
             $this->_controller = new $className($this->getCode());
             $this->_controller->init();
             return true;
         }
     }
     return false;
 }