Exemplo n.º 1
0
 /**
  * tries to include the requested plugin and returns the plugin class name, or false if plugin not found.
  * @param string $pluginName name of the plugin
  * @return string class name or false if not found
  */
 protected function _load($pluginName, $section)
 {
     $cleanName = FileUtils::sanitize($pluginName);
     $className = strtolower("Plugins_{$cleanName}_{$section}");
     if (M::resolve_class($className, 'plugins', function () use($cleanName) {
         PluginRegistry::initPlugin($cleanName);
     })) {
         return $className;
     }
 }
Exemplo n.º 2
0
 public function generate_migration($name, $format = 'php', $pluginName = '')
 {
     if (!empty($pluginName)) {
         $basepath = PluginRegistry::initPlugin($pluginName);
     } else {
         $basepath = APP_ROOT;
     }
     $file = $basepath . 'db/migrations/' . date('YmdHi') . '_' . Strings::snake($name) . '.' . $format;
     $classname = Strings::camel($name);
     $source = file_get_contents(dirname(__FILE__) . '/generate/migration/' . $format . '.tpl');
     $source = str_replace('[MIGRATION_NAME]', $classname, $source);
     file_put_contents($file, $source);
     $this->line($file . ' created');
 }
Exemplo n.º 3
0
Arquivo: Mtpl.php Projeto: demental/m
 public function fetch($tplfile)
 {
     if (!is_array($tplfile)) {
         $tplfile = array($tplfile);
     }
     $buffer = ob_get_contents();
     ob_clean();
     extract($this->_assignvars);
     $included = false;
     foreach ($tplfile as $file) {
         $pluginfile = explode(':', $file);
         if (count($pluginfile) == 2) {
             PluginRegistry::initPlugin($pluginfile[0]);
             $file = $pluginfile[1];
             $this->_config['tplfolders'] = array('M/plugins/' . $pluginfile[0] . '/templates/', APP_ROOT . 'app/plugins/' . $pluginfile[0] . '/templates/');
         }
         $this->_tplfile = $file;
         if ($tpl = $this->getTemplatePath()) {
             ob_start();
             $bf = trim($buffer);
             if (!empty($bf)) {
                 echo $this->comment('Start include ' . $file);
             }
             include $tpl;
             if (!empty($bf)) {
                 echo $this->comment('End include ' . $file);
             }
             $included = true;
             $ret = ob_get_contents();
             ob_clean();
             echo $buffer;
             foreach ($this->_postFilters as $filter) {
                 $filter->execute($ret);
             }
             return $ret;
             break;
         }
     }
     echo $buffer;
     ob_clean();
     throw new Exception('Fichier ' . print_r($tplfile, true) . ' introuvable dans dossier(s) ' . print_r($this->_config['tplfolders'], true));
 }
Exemplo n.º 4
0
 /**
  *
  * description
  *
  * @param $modulename
  * @param $path
  * @param $params
  * @return unknown_type
  */
 public static function &factory($modulename, $path = null, $params = null)
 {
     if (empty($path)) {
         $path = array('modules');
     }
     if (!is_array($path)) {
         $path = array($path);
     }
     Log::info('Module::factory ' . $modulename);
     $plugmod = explode(':', $modulename);
     $moduleOpt = PEAR::getStaticProperty('Module', 'global');
     $optionsGroup = PEAR::getStaticProperty('Options', 'group');
     if ($plugmod[1]) {
         Log::info('Calling plugin module ' . $modulename);
         PluginRegistry::initPlugin($plugmod[0]);
         $path = array(APP_ROOT . 'app/plugins/' . $plugmod[0] . '/modules/', 'plugins/' . $plugmod[0] . '/modules/');
         $moduleOpt['template_dir'][] = 'plugins/' . $plugmod[0] . '/templates/';
         $moduleOpt['template_dir'][] = APP_ROOT . 'app/plugins/' . $plugmod[0] . '/templates/';
         $modulename = $plugmod[1];
         $className = $plugmod[0] . '_Module_' . $modulename;
     } else {
         $className = 'Module_' . $modulename;
     }
     $i = false;
     foreach ($path as $aPath) {
         if (@(include_once $aPath . '/' . $modulename . '.php')) {
             $i = true;
             break;
         }
     }
     if (!$i) {
         Log::info('Module::factory ' . $modulename . ' not found in path ' . implode(',', $path));
         throw new Error404Exception("No {$modulename} module in path " . implode(',', $path));
     }
     Log::info('Module::factory ' . $modulename . ' OK');
     $module = new $className($modulename);
     $module->_path = $path;
     Log::info('Generating options');
     $options = $module->generateOptions($moduleOpt, $optionsGroup);
     $module->setConfig($options);
     $module->setParams($params);
     $module->startView();
     Log::info('Module::factory ' . $className . ' configured');
     return $module;
 }