Example #1
0
File: db.php Project: demental/m
 public function postProcessForm(&$v, &$fb, &$obj)
 {
     $defs = $obj->_getPluginsDef();
     $field = $obj->fb_elementNamePrefix . 'filename' . $obj->fb_elementNamePostfix;
     if (!$_FILES[$field]['tmp_name']) {
         return;
     }
     $filename = $obj->getImageName();
     if (!$filename) {
         $filename = $obj->getOwner()->tableName() . '_' . substr(md5(time() + rand(0, 100)), 0, 10);
     }
     $obj->filename = $this->_upFile($obj, $obj->fb_elementNamePrefix . 'filename' . $obj->fb_elementNamePostfix, $defs['otfimage']['path'], $filename);
     $obj->update();
     /**
      * Clearing cache for this image
      **/
     $filename = eregi_replace('(\\.[^\\.]+)$', '', basename($obj->filename));
     $cachefolder = APP_ROOT . 'public/' . $defs['otfimage']['cache'] . '/' . $filename . '/';
     foreach (FileUtils::getAllFiles($cachefolder) as $file) {
         @unlink($file);
     }
     /**
      * Setting as main if none exist
      */
     $main = $obj->getOwner();
     $mainImg = $main->getMainImage();
     if (!$obj->ismain && !$mainImg->pk()) {
         $obj->setAsMain();
     }
 }
Example #2
0
 public function longHelp($params)
 {
     if (count($params) == 0) {
         $this->line('Invoques a plugin subcommand');
         $this->line('Usage:');
         $this->line('plugin [PLUGIN_NAME] [COMMAND_NAME] [[COMMAND_PARAMETERS]]');
         $this->line('');
         $this->line('You can get a description of the plugin and list the available subcommands using:');
         $this->line('help plugin [PLUGIN_NAME]');
         $this->line('You can also get help from subcommands if provided using:');
         $this->line('help plugin [PLUGIN_NAME] [COMMAND_NAME]');
         $this->line('============');
         $this->line('Here is a list of available plugins:');
         $dir = dirname(realpath(__FILE__));
         $pluginsPath = realpath($dir . '/../plugins/');
         foreach (FileUtils::getFolders($pluginsPath) as $adir) {
             if (ereg('^\\.', basename($adir))) {
                 continue;
             }
             $this->line(basename($adir));
         }
     } elseif (count($params) == 1) {
         $plugin = $params[0];
         $pluginPath = 'M/plugins/' . $plugin . '/';
         if (!FileUtils::file_exists_incpath($pluginPath . 'commands/help.php')) {
             if (!FileUtils::file_exists_incpath('M/plugins/' . $plugin)) {
                 throw new Exception($plugin . ' plugin does not exist');
             } else {
                 $this->line('no description for ' . $plugin . ' plugin');
             }
         } else {
             require_once 'M/plugins/' . $plugin . '/commands/help.php';
             $className = $plugin . '_Command_help';
             $h = new $className();
             $h->execute();
         }
         $this->line('============');
         $this->line('Here is a list of available commands for this plugin:');
         $dir = dirname(realpath(__FILE__));
         $commandsPath = realpath($dir . '/../../' . $pluginPath . 'commands/');
         foreach (FileUtils::getAllFiles($commandsPath) as $file) {
             $commandname = basename($file, '.php');
             if ($commandname == 'help') {
                 continue;
             }
             $className = $plugin . '_Command_' . $commandname;
             require_once $file;
             $newcommand = new $className();
             $this->line('');
             $this->line($commandname);
             $newcommand->shortHelp();
         }
     } else {
         $plugin = array_shift($params);
         $command = array_shift($params);
         $this->getPluginCommand($plugin, $command, $params)->longHelp();
     }
 }
Example #3
0
File: M.php Project: demental/m
 public static function tablesWithPlugin($pluginName)
 {
     foreach (FileUtils::getAllFiles(APP_ROOT . 'app/models/', 'php') as $file) {
         $t = DB_DataObject::factory(strtolower(basename($file, '.php')));
         if (PEAR::isError($t)) {
             continue;
         }
         $plugs = $t->_getPluginsDef();
         if ($plugs[$pluginName]) {
             $ret[] = $t->tableName();
         }
     }
     return $ret;
 }
 public function setup()
 {
     $options =& PEAR::getStaticProperty('DB_DataObject', 'options');
     $options['class_location'] = PEAR_FOLDER . 'M/tests/DO/';
     $options['schema_location'] = PEAR_FOLDER . 'M/tests/DO/';
     $options['class_prefix'] = 'DataObjects_';
     foreach (FileUtils::getAllFiles(PEAR_FOLDER . 'M/tests/DO/') as $file) {
         unlink($file);
     }
     foreach (FileUtils::getAllFiles(PEAR_FOLDER . 'M/tests/DO_dist/') as $file) {
         copy($file, str_replace('DO_dist', 'DO', $file));
     }
     $this->setUpDatabase('Mfixture.sql', 1);
 }
Example #5
0
 protected function _checkForCustomLinks()
 {
     $data = PEAR::getStaticProperty('DB_DataObject', 'options');
     $folder = $data['class_location'];
     $files = FileUtils::getAllFiles($folder, 'php');
     foreach ($files as $file) {
         $content = file_get_contents($file);
         $classname = strtolower(basename($file, '.php'));
         if (DB_DataObject_Advgenerator::hasCustomLinksMethod($content)) {
             if ($this->confirm($classname . ' class seems to have dynamic/conditional links.' . "\n" . 'Do you wish to scan all table for link fix (long but recommended) ?', 'y')) {
                 $this->toScan[] = $classname;
             }
         }
     }
 }
Example #6
0
 public function longHelp($params)
 {
     if (count($params) == 0) {
         $this->line('Invoques a module subcommand');
         $this->line('Usage:');
         $this->line('module [MODULE_NAME] [COMMAND_NAME] [[COMMAND_PARAMETERS]]');
         $this->line('');
         $this->line('You can get a description of the module and list the available subcommands using:');
         $this->line('help module [MODULE_NAME]');
         $this->line('You can also get help from subcommands if provided using:');
         $this->line('help module [MODULE_NAME] [COMMAND_NAME]');
         $this->line('============');
     } elseif (count($params) == 1) {
         $module = $params[0];
         $modulePath = APP_ROOT . 'app/' . APP_NAME . '/modules/' . $module . '/';
         if (!file_exists($modulePath . 'commands/help.php')) {
             if (!file_exists($modulePath)) {
                 throw new Exception($module . ' module does not exist while processing help');
             } else {
                 $this->line('no description for ' . $module . ' module');
             }
         } else {
             require_once $modulePath . '/commands/help.php';
             $className = $module . '_Command_help';
             $h = new $className();
             $h->execute();
         }
         $this->line('============');
         $this->line('Here is a list of available commands for this module:');
         $commandsPath = realpath($modulePath . 'commands/');
         foreach (FileUtils::getAllFiles($commandsPath) as $file) {
             $commandname = basename($file, '.php');
             if ($commandname == 'help') {
                 continue;
             }
             $className = $module . '_Command_' . $commandname;
             require_once $file;
             $newcommand = new $className();
             $this->line('');
             $this->line($commandname);
             $newcommand->shortHelp();
         }
     } else {
         $module = array_shift($params);
         $command = array_shift($params);
         $this->getModuleCommand($module, $command, $params)->longHelp();
     }
 }
Example #7
0
 public function execute($params)
 {
     $lang = $params[0];
     if (!in_array($lang, Config::getAllLangs())) {
         throw new Exception('Specified lang is not part of this project handled languages');
     }
     foreach (FileUtils::getAllFiles(APP_ROOT . 'app/' . APP_NAME) as $file) {
         $result = preg_match_all('`(?:__|_e)\\(\'(.+)\'(?:,array\\(.+\\))?\\)`sU', file_get_contents($file), $matches);
         foreach ($matches[1] as $elem) {
             $nbfound++;
             __(str_replace("\\'", "'", $elem));
         }
     }
     $arr = T::getInstance($lang)->getStrings();
     T::getInstance($lang)->save(true);
 }
Example #8
0
 public function setup()
 {
     ini_set('display_errors', 1);
     $options =& PEAR::getStaticProperty('DB_DataObject', 'options');
     $options['class_location'] = PEAR_FOLDER . 'M/tests/DO/';
     $options['schema_location'] = PEAR_FOLDER . 'M/tests/DO/';
     $options['class_prefix'] = 'DataObjects_';
     $this->setUpDatabase('Mfixture.sql', 1);
     // Setup 3 langs : fr en es and fr as default
     Config::set('defautLang', 'es');
     Config::set('installedLangs', array('en', 'fr', 'es'));
     // Copy original test DO's
     foreach (FileUtils::getAllFiles(PEAR_FOLDER . 'M/tests/DO/') as $file) {
         unlink($file);
     }
     foreach (FileUtils::getAllFiles(PEAR_FOLDER . 'M/tests/DO_dist/') as $file) {
         copy($file, str_replace('DO_dist', 'DO', $file));
     }
 }
Example #9
0
File: T.php Project: demental/m
 public function files_to_load($lang)
 {
     foreach (T::paths() as $path) {
         foreach (FileUtils::getAllFiles($path) as $file) {
             if (substr($file, -6, 3) == $lang . '.') {
                 $files_to_load[] = $file;
             }
         }
     }
     return $files_to_load;
 }
Example #10
0
 protected function _regenerateAssets()
 {
     $this->header('Regenerating assets');
     $version_file = APP_ROOT . 'app/ASSETSVERSION';
     $assetsversion = (int) file_get_contents($version_file);
     $assetsversion++;
     file_put_contents($version_file, $assetsversion);
     $assetsfolder = APP_ROOT . 'public/assets/';
     $jsfolder = $assetsfolder . 'js/';
     foreach (FileUtils::getFolders($jsfolder) as $folder) {
         if (preg_match('`^\\.`', $folder)) {
             continue;
         }
         $this->line('Regenerating ' . $folder . ' javascript asset');
         $out = '';
         foreach (FileUtils::getAllFiles($jsfolder . $folder) as $file) {
             $out .= file_get_contents($file) . "\n";
         }
         if (MODE == 'production') {
             $out = JSmin::minify($out);
         }
         $version = self::getOption('assetsurlrewriting') ? '' : $assetsversion;
         file_put_contents(APP_ROOT . 'public/cache/' . $folder . $version . '.js', $out);
     }
     // css
     $cssfolder = $assetsfolder . 'css/';
     foreach (FileUtils::getFolders($cssfolder) as $folder) {
         if (preg_match('`^\\.`', $folder)) {
             continue;
         }
         $this->line('Regenerating ' . $folder . ' CSS asset');
         $out = '';
         foreach (FileUtils::getAllFiles($cssfolder . $folder) as $file) {
             $out .= file_get_contents($file) . "\n";
         }
         if (MODE == 'production') {
             $out = CSSmin::minify($out);
         }
         $version = self::getOption('assetsurlrewriting') ? '' : $assetsversion;
         file_put_contents(APP_ROOT . 'public/cache/' . $folder . $version . '.css', $out);
     }
 }
Example #11
-4
File: help.php Project: demental/m
 public function execute($params)
 {
     if (is_array($params) && count($params) > 0) {
         $command = array_shift($params);
         $exec = Command::factory($command);
         $exec->longHelp($params);
     } else {
         $this->line('This command displays global help text or specific help text for a command if provided');
         $this->line('Usage:');
         $this->line('help');
         $this->line('  Displays this help');
         $this->line('help [COMMAND_NAME]');
         $this->line('  Displays specific and longer help for [COMMAND_NAME]');
         $this->line('help [COMMAND_NAME] [SUBCOMMAND_NAME] and so on....');
         $this->line('  Displays specific and longer help for [SUBCOMMAND_NAME] if [COMMAND_NAME] contains some subcommands (e.g. the plugin command)');
         $this->line('==========');
         $this->line('Here is the list of available root commands:');
         $dir = dirname(realpath(__FILE__));
         foreach (FileUtils::getAllFiles($dir, 'php') as $afile) {
             $subcname = basename($afile, '.php');
             $subc = Command::factory($subcname);
             $this->line('====== ' . $subcname . ' ======');
             $subc->shortHelp();
         }
     }
 }