BEdita API doc | 4-cactus
  • Class
  • Tree
  • Deprecated
  • Download

Classes

  • Addon
  • AddressbookController
  • AddressbookShell
  • AdminController
  • Alias
  • Annotation
  • ApiAuthComponent
  • ApiBaseController
  • ApiFormatterComponent
  • ApiUploadComponent
  • ApiValidatorComponent
  • AppController
  • AppError
  • AppHelper
  • Application
  • AppModel
  • Area
  • AreasController
  • Audio
  • AuthenticationsController
  • BannedIp
  • BEAppModel
  • BEAppObjectModel
  • BeAuthComponent
  • BeAuthFacebookComponent
  • BeAuthGoogleComponent
  • BeAuthTwitterComponent
  • BeCallbackManager
  • BeConfigure
  • BeCustomPropertyComponent
  • BeditaAnnotationModel
  • BeditaBaseShell
  • BeditaCollectionModel
  • BeditaContentModel
  • BeditaExportFilter
  • BeditaImportFilter
  • BeditaObjectModel
  • BeditaProductModel
  • BeditaShell
  • BeditaSimpleObjectModel
  • BeditaSimpleStreamModel
  • BeditaStreamModel
  • BeEmbedFlashHelper
  • BeEmbedHtml5Helper
  • BeEmbedMediaHelper
  • BeErrorCode
  • BeExceptionHandler
  • BEFile
  • BeFileHandlerComponent
  • BeFormHelper
  • BeFrontHelper
  • BeHashComponent
  • BeHtmlHelper
  • BeLangTextComponent
  • BeLib
  • BeMailComponent
  • BEObject
  • BeObjectCache
  • BePaginatorToolbarHelper
  • BeSchema
  • BeSecurityComponent
  • BeSystem
  • BeSystemComponent
  • BeThumb
  • BeTimeHelper
  • BeToolbarHelper
  • BeTreeComponent
  • BeTreeHelper
  • BeUploadToObjComponent
  • BeurlHelper
  • BeVimeoComponent
  • BeYoutubeComponent
  • BuildFilterBehavior
  • CacheableBehavior
  • CacheShell
  • CallbackBehavior
  • CaptchaComponent
  • Caption
  • CaptionsBehavior
  • Card
  • CardsImportFilter
  • Category
  • CleanupDataTask
  • CleanupTask
  • Comment
  • CommentsController
  • CompactResultBehavior
  • Content
  • CreateIndexFieldsBehavior
  • DataShell
  • DataTransfer
  • DateItem
  • DbadminShell
  • DeleteDependentObjectBehavior
  • DeleteObjectBehavior
  • DeployShell
  • Document
  • DocumentsController
  • DumpModel
  • EditorialContentsShell
  • EditorNote
  • Event
  • EventLog
  • EventsController
  • FilesController
  • ForeignDependenceSaveBehavior
  • FrontendController
  • FrontendShell
  • GalleriesController
  • Gallery
  • GeoTag
  • GettextShell
  • Git
  • GravatarHelper
  • Group
  • HashJob
  • History
  • HomeController
  • Image
  • ImageInfoHelper
  • JsonExportFilter
  • JsonImportFilter
  • JsonView
  • LangText
  • Link
  • MailGroup
  • MailGroupCard
  • MailJob
  • MailLog
  • MailMessage
  • MailShell
  • MailTemplate
  • Mask
  • MediaShell
  • MigrateDumpModel
  • MigrateShell
  • Migration
  • MigrationBase
  • MigrationDateItemsShell
  • Module
  • ModulesController
  • ModuleShell
  • MultimediaController
  • NewsController
  • NewsletterController
  • NewsletterShell
  • NotifyBehavior
  • ObjectEditor
  • ObjectProperty
  • ObjectRelation
  • ObjectType
  • ObjectUser
  • PagesController
  • Permission
  • PermissionModule
  • PermsHelper
  • Product
  • Property
  • PropertyOption
  • PublicationShell
  • RedisShell
  • RelationCheck
  • RelationRepair
  • RelationShell
  • RelationStats
  • RemoveDummyNameBehavior
  • ResponseHandlerComponent
  • RestClientModel
  • Revision
  • RevisionObjectBehavior
  • SearchText
  • SearchTextSaveBehavior
  • Section
  • SectionDummy
  • SessionFilterComponent
  • SessionFilterHelper
  • ShortNews
  • SmartyView
  • SoapClientModel
  • SplitterSql
  • StatisticsController
  • Stream
  • StreamLog
  • StreamsController
  • Svn
  • TagsController
  • ThemeSmartyView
  • ThumbnailHelper
  • ThumbShell
  • TransactionComponent
  • TransactionFS
  • TranslationsController
  • Tree
  • TrHelper
  • User
  • UserProperty
  • UsersController
  • Utility
  • Version
  • Video
  • VimeoHelper
  • WebmarksController
  • XmlExportFilter
  • XmlImportFilter
  • XmlJsonConverter
  • XmlView
  • YoutubeHelper

Interfaces

  • ApiAuthInterface
  • MediaProviderInterface
  • UploadableInterface

Exceptions

  • BeditaAjaxException
  • BEditaAllowURLException
  • BeditaBadRequestException
  • BeditaConflictException
  • BEditaDeleteStreamObjException
  • BeditaException
  • BEditaFileExistException
  • BeditaForbiddenException
  • BeditaFrontAccessException
  • BeditaHashException
  • BEditaInfoException
  • BeditaInternalErrorException
  • BEditaIOException
  • BeditaLengthRequiredException
  • BeditaMailException
  • BEditaMediaProviderException
  • BeditaMethodNotAllowedException
  • BEditaMIMEException
  • BeditaNotFoundException
  • BeditaNotImplementedException
  • BeditaPublicationException
  • BeditaRuntimeException
  • BEditaSaveStreamObjException
  • BeditaServiceUnavailableException
  • BeditaUnauthorizedException
  • BEditaUploadPHPException
  • BEditaURLException
   1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99  100  101  102  103  104  105  106  107  108  109  110  111  112  113  114  115  116  117  118  119  120  121  122  123  124  125  126  127  128  129  130  131  132  133  134  135  136  137  138  139  140  141  142  143  144  145  146  147  148  149  150  151  152  153  154  155  156  157  158  159  160  161  162  163  164  165  166  167  168  169  170  171  172  173  174  175  176  177  178  179  180  181  182  183  184  185  186  187  188  189  190  191  192  193  194  195  196  197  198  199  200  201  202  203  204  205  206  207  208  209  210  211  212  213  214  215  216  217  218  219  220  221  222  223  224  225  226  227  228  229  230  231  232  233  234  235  236  237  238  239  240  241  242  243  244  245  246  247  248  249  250  251  252  253  254  255  256  257  258  259  260  261  262  263  264  265  266  267  268  269  270  271  272  273  274  275  276  277  278  279  280  281  282  283  284  285  286  287  288  289  290  291  292  293  294  295  296  297  298  299  300  301  302  303  304  305  306  307  308  309  310  311  312  313  314  315  316  317  318  319  320  321  322  323  324  325  326  327  328  329  330  331  332  333  334  335  336  337  338  339  340  341  342  343  344  345  346  347  348  349  350  351  352  353  354  355  356  357  358  359  360  361  362  363  364  365  366  367  368  369  370  371  372  373  374  375  376  377  378  379  380  381  382  383  384  385  386  387  388  389  390  391  392  393  394  395  396  397  398  399  400  401  402  403  404  405  406  407  408  409  410  411  412  413  414  415  416  417  418  419  420  421  422  423  424  425  426  427  428  429  430  431  432  433  434  435  436  437  438  439  440  441  442  443  444  445  446  447  448  449  450  451  452  453  454  455  456  457  458  459  460  461  462  463  464  465  466  467  468  469  470  471  472  473  474  475  476  477  478  479  480  481  482  483  484  485  486  487  488  489  490  491  492  493  494  495  496  497  498  499  500  501  502  503  504  505  506  507  508  509  510  511  512  513  514  515  516  517  518  519  520  521  522  523  524  525  526  527  528  529  530  531  532  533  534  535  536  537  538  539  540  541  542  543  544  545  546  547  548  549  550  551  552  553  554  555  556  557  558  559  560  561  562  563  564  565  566  567  568  569  570  571  572  573  574  575  576  577  578  579  580  581  582  583  584  585  586  587  588  589  590  591  592  593  594  595  596  597  598  599  600  601  602  603  604  605  606  607  608  609  610  611  612  613  614  615  616  617  618  619  620  621  622  623  624  625  626  627  628  629  630  631  632  633  634  635  636  637  638  639  640  641  642  643  644  645  646  647  648  649  650  651  652  653  654  655  656  657  658  659  660  661  662  663  664  665  666  667  668  669  670  671  672  673  674  675  676  677  678  679  680  681  682  683  684  685  686  687  688  689  690  691  692  693  694  695  696  697  698  699  700  701  702  703  704  705  706  707  708  709  710  711  712  713  714  715  716  717  718  719  720  721  722  723  724  725  726  727  728  729  730  731  732  733  734  735  736  737  738  739  740  741  742  743  744  745  746  747  748  749  750  751  752  753  754  755  756  757  758  759  760  761  762  763  764  765  766  767  768  769  770  771  772  773  774  775  776  777  778  779  780  781  782  783  784  785  786  787  788  789  790  791  792  793  794  795  796  797  798  799  800  801  802  803  804  805  806  807  808  809  810  811  812  813  814  815  816  817  818  819  820  821  822  823  824  825  826  827  828  829  830  831  832  833  834  835  836  837  838  839  840  841  842  843  844  845  846  847  848  849  850  851  852  853  854  855  856  857  858  859  860  861  862  863  864  865  866  867  868  869  870  871  872  873  874  875  876  877  878  879  880  881  882  883  884  885  886  887  888  889  890  891  892  893  894  895  896  897  898  899  900  901  902  903  904  905  906  907  908  909  910  911  912  913  914  915  916  917  918  919  920  921  922  923  924  925  926  927  928  929  930  931  932  933  934  935  936  937  938  939  940  941  942  943  944  945  946  947  948  949  950  951  952  953  954  955  956  957  958  959  960  961  962  963  964  965  966  967  968  969  970  971  972  973  974  975  976  977  978  979  980  981  982  983  984  985  986  987  988  989  990  991  992  993  994  995  996  997  998  999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 
<?php 
/*-----8<--------------------------------------------------------------------
 * 
 * BEdita - a semantic content management framework
 * 
 * Copyright 2008, 2010 ChannelWeb Srl, Chialab Srl
 * 
 * This file is part of BEdita: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published 
 * by the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version.
 * BEdita is distributed WITHOUT ANY WARRANTY; without even the implied 
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License 
 * version 3 along with BEdita (see LICENSE.LGPL).
 * If not, see <http://gnu.org/licenses/lgpl-3.0.html>.
 * 
 *------------------------------------------------------------------->8-----
 */

App::import('Model', 'BeSchema');
App::import('Model', 'Stream');
App::import('Component', 'Transaction');
require_once 'bedita_base.php';

/**
 * @version         $Revision$
 * @modifiedby      $LastChangedBy$
 * @lastmodified    $LastChangedDate$
 * 
 * $Id$
 */
/*

/**
 * Main bedita shell script: basic methods services, including
 * - import/export of complete instances
 * - fresh init/install
 * - cache, compiled templates cleanups
 * - application and media files consistency check
 *
 */
class BeditaShell extends BeditaBaseShell {

    const DEFAULT_TAR_FILE  = 'bedita-export.tar' ;
    const DEFAULT_ARCHIVE_FILE  = 'bedita-export.tar.gz' ;

    var $tasks = array('Cleanup', 'CleanupData');
    
    /**
     * Overrides base startup(), don't call initConfig...
     * @see BeditaBaseShell::startup()
     */
    function startup() {
        Configure::write('debug', 1);
    }
    
    /**
     * initialize BEdita
     *
     */
    function init() {
        $this->loadTasks();
        $this->out("BEdita CLEANUP");
        $this->Cleanup->execute();
        $this->hr();
        $this->out("CHECKING DATABASE CONNECTION");
        $res = $this->checkAppDbConnection();
        $this->hr();
        if(!$res) {
            $this->out("HINT: check database existence/setup and edit \$default array in bedita-app/config/database.php, have a look to CakePHP documentation.");
            $this->out("");
            return;
        }
        $this->out("");
        $this->hr();
        $this->out("CHECKING MEDIA ROOT");
        $mediaRoot = Configure::read("mediaRoot");
        $res = @$this->checkAppDirPerms($mediaRoot);
        $this->hr();
        if(!$res) {
            $this->out("HINT: edit \$config['mediaRoot'] in bedita-app/config/bedita.cfg.php, if necessary uncomment it.");
            $ans = $this->in("Proceed anyway? [y/n]");
            if($ans != "y") {
                $this->out("Bye");
                return;
            }               
        }

        $this->out("CHECKING MEDIA URLs");
        $mediaUrl = Configure::read("mediaUrl");
        $res = $this->checkAppUrl($mediaUrl);
        $this->hr();
        if(!$res) {
            $this->out("HINT: edit \$config['mediaUrl'] in bedita-app/config/bedita.cfg.php, if necessary uncomment it.");
            $ans = $this->in("Proceed anyway? [y/n]");
            if($ans != "y") {
                $this->out("Bye");
                return;
            }               
        }
                
        $this->out("");
        $this->hr();
        $this->out("INITIALIZE DATABASE");
        $this->initDb();
        $this->out("");
        $res = $this->in("Do you want to check BEdita status? [y/n]");
        if($res != "y") {
            $this->out("Bye");
            return;
        }
        $this->hr();
        $this->out("BEdita STATUS");
        $this->hr();
        $this->checkApp();
    }
    
    function initDb() {
        $dbCfg = 'default';
        if (isset($this->params['db'])) {
            $dbCfg = $this->params['db'];
        }
        
        $sqlScriptPath = APP ."config" . DS . "sql" . DS;
        $sqlDataDump = $sqlScriptPath . 'bedita_init_data.sql';
        if (isset($this->params['data'])) {
            if(file_exists($sqlScriptPath . $this->params['data'])) {
                $sqlDataDump = $sqlScriptPath .$this->params['data'];
            } else {
                $sqlDataDump = $this->params['data'];
                if(!file_exists($sqlDataDump)) {
                    $this->out("data file $sqlDataDump not found");
                    return;
                }
            }
        }
        
        $db = ConnectionManager::getDataSource($dbCfg);
        $hostName = $db->config['host'];
        $dbName = $db->config['database'];
        $driver = $db->config['driver'];
        $this->out("Updating bedita db config: $dbCfg - $driver [host=".$hostName.", database=".$dbName."]");
        $res = $this->in("ACHTUNG! Database $dbName will be replaced, proceed? [y/n]");
        if($res != "y") {
            $this->out("Bye");
            return;
        }
        $this->hr();

        $transaction = new TransactionComponent($dbCfg);
        $transaction->begin();
        
        $beSchema = new BeSchema();
        $script = $sqlScriptPath . "bedita_" . $driver . "_schema.sql";
        $this->out("Update schema from $script");
        $beSchema->executeQuery($db, $script);
        
        if (isset($this->params['nodata'])) {
            $this->out("No data inserted");
        } else {
            $this->out("Load data from $sqlDataDump");
            $beSchema->executeInsert($db, $sqlDataDump);
        }
        $beSchema->checkSequences($db);
        $this->out("$dbCfg database updated");
        $transaction->commit();
        
        BeLib::getObject("BeConfigure")->cacheConfig();
        
        if (isset($this->params['media'])) {
            $this->extractMediaZip($this->params['media']);
        }

        $this->out("checking media files");
        $this->checkMedia();
        $this->out("bye");       
    }

    function import() {

        if(!class_exists("PharData")) {
            $this->out("Phar module needed for this operation. Exiting.");
            return;         
        }
        
        $dbCfg = 'default';
        if (isset($this->params['db'])) {
            $dbCfg = $this->params['db'];
        }

        $answerYes = false;
        if (isset($this->params['y'])) {
            $answerYes = true;
        }
        
        $this->check_sys_get_temp_dir();
        $tmpBasePath = $this->setupTempDir();
        $this->out("Using temp dir: $tmpBasePath");
        
        $archFile = self::DEFAULT_ARCHIVE_FILE;
        if (isset($this->params['f'])) {
            $archFile = $this->params['f'];
        }

        if(!file_exists($archFile)) {
            $this->out("$archFile not found, bye");
            return;
        }
        $this->out("Importing file $archFile");

        $phar = new PharData($archFile);
        $phar->extractTo($tmpBasePath);
        
        // check if media files are present
        $tmpMediaDir = $tmpBasePath."media";
        if(!file_exists($tmpMediaDir) && !$answerYes) {
            $res = $this->in("ACHTUNG! Media files not present in import file, proceed? [y/n]");
            if($res != "y") {
                $this->out("Bye");
                return;
            }
        }
        
        // TODO: check version.txt compatibility
        
        // check plugins 
        $currentPlugins = $this->currentPluginModules();
        $plugins = array();
        if(file_exists($tmpBasePath."plugins.php")) {
            include $tmpBasePath."plugins.php"; 
        }
        $missingPlugins = array_diff($plugins, $currentPlugins);
        if(!empty($missingPlugins)) {
            $this->out("Some plugins are needed to proceed with import: " . implode(", ", $missingPlugins));
            $this->out("Load them and try again.");
            return;
        }
    
        $sqlFileName = $tmpBasePath."bedita-data.sql";
        
        $this->hr();
        $db = ConnectionManager::getDataSource($dbCfg);
        $hostName = $db->config['host'];
        $driver = $db->config['driver'];
        $dbName = $db->config['database'];
        $this->out("Importing data using bedita db config: $dbCfg - $driver [host=".$hostName.", database=".$dbName."]");
        if(!$answerYes) {
            $res = $this->in("ACHTUNG! Database $dbName will be replaced, proceed? [y/n]");
            if($res != "y") {
                $this->out("Bye");
                return;
            }
        }
        $this->hr();
                
        $transaction = new TransactionComponent($dbCfg);
        $transaction->begin();
        
        $sqlScriptPath = APP ."config" . DS . "sql" . DS;
        $beSchema = new BeSchema();
        $script = $sqlScriptPath . "bedita_" . $db->config['driver'] . "_schema.sql";
        $this->out("Update schema from $script");
        $beSchema->executeQuery($db, $script);
        
        $this->out("Load data from $sqlFileName");
        $beSchema->simpleInsert($db, $sqlFileName);
        unlink($sqlFileName);
        $beSchema->checkSequences($db);
        $this->out("$dbCfg database updated");

        BeLib::getObject("BeConfigure")->cacheConfig();

        $this->hr();
        // import new configuration file, if present
        $newCfgFileName = $tmpBasePath."bedita.cfg.php";
        if (file_exists($newCfgFileName)) {
            // overwrite current cfg file
            $cfgFileName = APP ."config".DS."bedita.cfg.php";
            if (file_exists($cfgFileName) && !$answerYes) {
                $res = $this->in($cfgFileName. " already exists, overwrite with new configuration? [y/n]");
                if($res == "y") {
                    $this->importCfg($newCfgFileName, $cfgFileName);
                } else {
                    $this->out("Configuration not updated!");
                }
            } else {
                $this->importCfg($newCfgFileName,$cfgFileName);
            }
        } else {
            $this->out("Configuration 'bedita.cfg.php' not present in .tar file");
        }
        $this->hr();
        
        $mediaRoot = Configure::read("mediaRoot");
        
        // update media root dir
        $folder = new Folder($mediaRoot);
        $ls = $folder->read();
        if(count($ls[0]) > 0 || count($ls[1]) > 0) {
            if($answerYes) {
                $this->removeMediaFiles();
            } else {
                $res = $this->in($mediaRoot. " is not empty, remove files and folders? [y/n]");
                if($res == "y") {
                    $this->removeMediaFiles();
                } else {
                    $this->out($mediaRoot. " not clean!");
                }
            }
        }
        
        // copy files from tmp dir to media_root
        $copts=array('to'=>$mediaRoot,'from'=>$tmpBasePath.'media','mode'=>0777);
        $this->out("copying from " . $copts['from'] . " to " . $copts['to']);
        $res = $folder->copy($copts);
        $this->out("Cleaning temp dir $tmpBasePath");
        $this->cleanTempDir();
        $this->out("done");
        
        $transaction->commit();     
        $this->out("bye");
    }

    
    public function export() {

        if(!class_exists("PharData")) {
            $this->out("Phar module needed for this operation. Exiting.");
            return;         
        }
        $this->initConfig();
        $expFile = self::DEFAULT_ARCHIVE_FILE;
        if (isset($this->params['f'])) {
            $expFile = $this->params['f'];
        } else if(isset($this->params['nocompress'])) {
            $expFile = self::DEFAULT_TAR_FILE;
        }
        
        $this->checkExportFile($expFile);

        $beSchema = new BeSchema();
        $tables = $beSchema->tableListOrdered();
        $this->check_sys_get_temp_dir();
        $tmpBasePath = $this->setupTempDir();
        $sqlFileName = $tmpBasePath . "bedita-data.sql";
        $this->out("Creating SQL dump....");
        $handle = fopen($sqlFileName, "w");
        if($handle === FALSE) 
            throw new Exception("Error opening file: ".$sqlFileName);
        $beSchema->tableDetails($tables, $handle);
        fclose($handle);
        
        $this->out("Creating metadata....");
        file_put_contents($tmpBasePath."version.txt", Configure::read('version'));
        if(!copy(APP."config".DS."bedita.cfg.php", $tmpBasePath . "bedita.cfg.php")) {
            throw new Exception("Error copying bedita.cfg.php file");
        }
        
        $plugins = $this->currentPluginModules();
        $pl = "<?php\n\$plugins = " . var_export($plugins, true) . ";\n?>";
        file_put_contents($tmpBasePath."plugins.php", $pl);
        
        if (isset($this->params['nomedia'])) { // exclude media files
            
            $this->out("Media files not exported!");
            
        } else {
        
            $this->out("Exporting media files....");
            // copy media files
            if(!mkdir($tmpBasePath . "media")) {
                throw new Exception("Error creating media directory");
            }

            $folder = new Folder();
            $allStream = ClassRegistry::init("Stream")->find("all");
            $mediaRoot = Configure::read("mediaRoot");
            foreach ($allStream as $v) {
                $p = $v['Stream']['uri'];
                if((stripos($p, "/") === 0) && file_exists($mediaRoot.$p)) {
                    $dirPath = $tmpBasePath . "media" . substr($p, 0, strrpos($p, "/"));
                    $folder->create($dirPath);
                    if(!copy($mediaRoot.$p, $tmpBasePath . "media" . $p)) {
                        throw new Exception("Error copying bedita.cfg.php file");
                    }
                }
            }
            unset($allStream);
        }

        $this->out("Creating archive....");

        $compress = isset($this->params['compress']);
        $tarFile = $expFile;
        if(substr($expFile, strlen($expFile)-3) == ".gz") {
            $tarFile = substr($expFile, 0, strlen($expFile)-3);
            $compress = true;
        }
        $phar = new PharData($tarFile);
        $phar->buildFromDirectory($tmpBasePath);
        if ($compress) {
            $this->out("Compressing archive....");
            $phar->compress(Phar::GZ);
            if($expFile !== $tarFile) {
                unlink($tarFile);
            }
        }
        $this->cleanTempDir();
        $this->out("$expFile created");
    }

    
    private function currentPluginModules() {
        // list plugins
        $module = ClassRegistry::init("Module");
        $mods = $module->find('all', array("conditions" => array("status" =>"on", 
            "module_type" => "plugin")));
        $plugins = array();
        foreach ($mods as $m) {
            $plugins[] = $m["Module"]["name"];
        }
        return $plugins;
    }
    
    private function extractMediaZip($zipFile) {
        $zip = new ZipArchive;
        if ($zip->open($zipFile) === TRUE) {
            $zip->extractTo(Configure::read("mediaRoot"));
            $zip->close();
            $this->out("Media files extracted");
        } else {
            $this->out("Error media file $zipFile not found!!");
        }
    }
    
    private function importCfg($source,$destination) {
        if (!copy($source, $destination)) {
            throw new Exception("Error copying " . $source . " to " . $destination);
        } else {
            $this->out("Configuration file " . $destination . " updated.");
        }
    }
    
    public function checkMedia() {

        $this->initConfig();
        $this->hr();
        $this->out("checkMedia - checking filesystem");
        $this->hr();
        $mediaNotPresent = array();
        $mediaRoot = Configure::read("mediaRoot");
        if (!file_exists($mediaRoot) || !is_dir($mediaRoot) || !is_readable($mediaRoot)) {
            $this->out('Error reading media root: media root does not exist or is not readable by this user');
            return;
        }

        $maxDepthLevel = 2;
        if (isset($this->params["level"])) {
            $maxDepthLevel = $this->params["level"];
            $this->out("Using max depth level: " . $maxDepthLevel);
        }
        $excludeDir = array();
        if (isset($this->params['exclude'])) {
            $exclude = $this->params['exclude'];
            $this->out('Excluding dirs: ' . $exclude);
            $excludeDir = explode(',', $exclude);
        }
        $this->streamsCheck($mediaRoot, 0, $maxDepthLevel, $mediaNotPresent, 
                isset($this->params['-remove-files']), isset($this->params['-force-remove']), $excludeDir);
        $this->hr();
        $this->out("Media files not in BEdita - " . count($mediaNotPresent));
        $stream = ClassRegistry::init("Stream");
        if (isset($this->params["create"])) {
            foreach ($mediaNotPresent as $m) {
                $mimeType = $stream->getMimeType($mediaRoot . DS . $m);
                $modelType = BeLib::getTypeFromMIME($mimeType);
                $model = ClassRegistry::init($modelType["name"]);
                $p1 = strrpos($m, "/") + 1;
                $p2 = strrpos($m, ".");
                if(!$p2 || $p2 <= $p1){
                    $p2 = strlen($m);
                } 
                $data = array("status" => "on", 
                        "title" => substr($m, $p1, $p2-$p1), 
                        "uri" => $m, 
                        "name" => substr($m, $p1),
                        "original_name" => substr($m, $p1),
                        "mime_type" => $mimeType);
                $data['Category'] = $stream->getCategoryMediaType($mimeType, $modelType["name"]);
                $model->create();
                if(!$model->save($data)) {
                    throw new BEditaSaveStreamObjException(__("Error saving stream object",true), $model->validationErrors) ;
                }
                $id = $model->id;
                $stream->updateStreamFields($id);
            }
        }

        // check db
        $this->hr();
        $this->out("checkMedia - checking database");
        $this->hr();
        $allStream = $stream->find("all");
        $mediaOk = true;
        $dbCount = 0;
        $beUrl = Configure::read('beditaUrl');
        foreach ($allStream as $v) {
            $p = $v['Stream']['uri'];
            // if $p is a local path check existence
            if((stripos($p, "/") === 0) && !file_exists($mediaRoot.$p)) {
                    $this->out("File $p not found on filesystem!! - " . $beUrl . '/view/' . $v['Stream']['id']);
                    $mediaOk = false;
                    $dbCount++;
            }
        }
        $this->hr();
        if($mediaOk) {
            $this->out("checkMedia - database OK");
        } else {
            $this->out("checkMedia - some files are missing");
            $this->out("Media objects with missing local file: " . $dbCount);
        }
        $this->hr();
    }    


    private function streamsCheck($mediaPath, $level, $maxLevel, 
            array &$mediaFiles, $removeFiles = false, $forceRemove = false, $excludeDir = array()) {
        if ($level > $maxLevel) {
            return;
        }

        $stream = ClassRegistry::init('Stream');
        $mediaRoot = Configure::read('mediaRoot');
        $folder = new Folder($mediaPath);
        $ls = $folder->read();
        foreach ($ls[1] as $f) {
            if ($f[0] !== '.') {
                $filePath = $mediaPath . DS . $f;
                $p = substr($filePath, strlen($mediaRoot));
                $s = $stream->findByUri($p);
                if ($s === false) {
                    $this->out("File $p not found on db!!");
                    $remove = $forceRemove;
                    if ($removeFiles && !$forceRemove) {
                        $res = $this->in("Remove file ${filePath} ? [y/n]");
                        if ($res == 'y') {
                            $remove = true;
                        }
                    }
                    if ($remove) {
                        $this->out("Removing file : ${filePath}");
                        if (!unlink($filePath)) {
                            $this->out("Error removing: ${filePath}");
                        }
                    }
                    $mediaFiles[] = $p;
                }
            }
        }

        if ($level == 0) {
            $excludeDir[] = 'cache'; // exclude cache in check
        } else {
            $excludeDir = array(); // exclude only 0 level dirs
        }
        foreach ($ls[0] as $dir) {
            if ($dir[0] !== '.' && !in_array($dir, $excludeDir)) {
                $this->streamsCheck($mediaPath . DS . $dir, $level+1, $maxLevel, 
                    $mediaFiles, $removeFiles, $forceRemove);               
            }
        }
    }

    private function removeMediaFiles() {
        $mediaRoot = Configure::read("mediaRoot");
        $folder= new Folder($mediaRoot);
        $dirs = $folder->read();
        foreach ($dirs[0] as $d) {
            $folder->delete($mediaRoot . DS. $d);
        }
        $this->out('Media files cleaned.');
        
    }

    private function checkAppFiles($appPath, $frontend = false) {
        // config/core.php
        $this->checkAppFile($appPath.DS."config".DS."core.php");
        // config/database.php
        $this->checkAppFile($appPath.DS."config".DS."database.php");
        if (!$frontend) {
            // config/bedita.cfg.php
            $this->checkAppFile($appPath.DS."config".DS."bedita.cfg.php");
        } else {
            // config/frontend.cfg.php
            $this->checkAppFile($appPath . DS . 'config' . DS . 'frontend.cfg.php');
            if (file_exists($appPath . DS . 'config' . DS . 'paths.php.sample')) {
                // config/paths.php
                $this->checkAppFile($appPath . DS . 'config' . DS . 'paths.php');
            }
        }
        // index.php
        $this->checkAppFile($appPath.DS."index.php");
        // webroot/index.php
        $this->checkAppFile($appPath.DS."webroot".DS."index.php");
        if (!$frontend) {
            // webroot/test.php
            $this->checkAppFile($appPath.DS."webroot".DS."test.php");
        }
        // tmp/cache
        $this->checkAppDirPerms($appPath.DS."tmp".DS."cache");
        // tmp/smarty/compile
        $this->checkAppDirPerms($appPath.DS."tmp".DS."smarty".DS."compile");
        // tmp/logs
        $this->checkAppDirPerms($appPath.DS."tmp".DS."logs");
    }
    
    public function checkApp() {
        $frontend = false;
        $appPath = $this->params['app'];
        if (isset($this->params['frontend'])) {
            $appPath = $this->params['frontend'];
            $frontend = true;
        }
        if($frontend) {
            $this->out('Checking frontend app dir: '.$appPath);
            $this->hr();
            $this->checkAppFiles($appPath, true);
        } else {
            $this->out('Checking backend app dir: '.$appPath);
            $this->hr();
            $this->checkAppFiles($appPath);
            if(!file_exists(BEDITA_FRONTENDS_PATH)) {
                $this->hr();
                $this->out("WARNING: frontend path " . BEDITA_FRONTENDS_PATH . " is missing");
            } else {
                $folder = new Folder(BEDITA_FRONTENDS_PATH);
                $ls = $folder->read();
                $count = 0;
                foreach ($ls[0] as $dir) {
                    if($dir[0] !== '.' ) {
                        $count++;
                        $this->hr();
                        $this->out('Checking frontend app dir: '. BEDITA_FRONTENDS_PATH. DS .$dir);
                        $this->hr();
                        $this->checkAppFiles(BEDITA_FRONTENDS_PATH. DS .$dir, true);
                    }
                }
                if($count === 0 ) {
                    $this->hr();
                    $this->out("WARNING: no frontends found in " . BEDITA_FRONTENDS_PATH);
                }
            }
        }
        // mediaRoot, mediaUrl, beditaUrl
        $this->hr();
        $this->out("Checking media dir and url");
        $this->hr();
        $mediaRoot = Configure::read("mediaRoot");
        if(empty($mediaRoot)) {
            $this->out("WARNING: empty 'mediaRoot' in config/bedita.cfg.php");
        }
        @$this->checkAppDirPerms($mediaRoot, "mediaRoot: ");
        
        $mediaUrl = Configure::read("mediaUrl");
        if(empty($mediaUrl)) {
            $this->out("WARNING: empty 'mediaUrl' in config/bedita.cfg.php");
        }
        @$this->checkAppUrl($mediaUrl, "mediaUrl: ");
        
        $beUrl = Configure::read("beditaUrl");
        if(empty($beUrl)) {
            $this->out("WARNING: empty 'beditaUrl' in config/bedita.cfg.php");
        }
        @$this->checkAppUrl($beUrl, "beditaUrl: ");
        
        // database connection
        @$this->checkAppDbConnection();
        
        $debugLevel = Configure::read("debug");
        $this->out("Cake debug level: $debugLevel");
        $saveSess = Configure::read("Session.save");
        $this->out("Cake session handling: " .$saveSess);
        if($saveSess !== "database") {
            $this->out("WARNING: use 'database' as session handler in config/core.php - 'Session.save'");
        }
        $appBaseUrl = Configure::read('App.baseUrl');
        if(empty($appBaseUrl)) {
            $this->out("Using mod_rewrite");
        } else {
            $this->out("NOT USING mod_rewrite");
        }
        
    }

    private function checkAppDirPerms($dirPath, $msg = "") {
        if (is_dir($dirPath)) {
            $this->out($msg . $dirPath. " - perms: ".sprintf("%o",(fileperms($dirPath) & 511)));
            return true;
        } else {
            $this->out($msg. $dirPath . " doesn't exist or it isn't a directory!");
            return false;
        }
    }

    private function checkAppDbConnection() {
        $dbCfg = 'default';
        if (isset($this->params['db'])) {
            $dbCfg = $this->params['db'];
        }
        $db1 = @ConnectionManager::getDataSource($dbCfg);
        $hostName = $db1->config['host'];
        $driver = $db1->config['driver'];
        $dbName = $db1->config['database'];
        $this->out("Checking database connection: $dbCfg - $driver [host=".$hostName.", database=".$dbName."]");
        $db = ConnectionManager::getInstance();
        $connected = $db->getDataSource($dbCfg); 
        if ($connected->isConnected()) {
            $this->out("Database connection: ok");
            return true;
        } else {
            $this->out("Database connection: unable to connect");
            return false;
        }
    }

    private function checkAppUrl($url, $msg = "") {
        $headers = get_headers($url); 
        if($headers && !strstr($headers[0], "404")) {
            $this->out($msg . $url . ": ok.");
            return true;
        } else {
            $this->out($msg . $url . ": unreachable.");
            return false;
        }
    }

    private function checkAppFile($filePath, $msg = "") {
        if(!file_exists($filePath)) {
            $this->out($msg . $filePath . ": NOT FOUND!");
            $sampleFile = $filePath.".sample";
            if(file_exists($sampleFile)) {
                $res = $this->in("$sampleFile found, create copy? [y/n]");
                if($res == "y") {
                    if(!copy($sampleFile, $filePath)) {
                        throw new Exception("Unable to copy $sampleFile to $filePath");
                    }                   
                }
            }
        } else {
            $this->out($msg . $filePath . ": ok.");
        }
    }
    
    
    public function modules() {
        $this->initConfig();
        if(!array_key_exists("enable", $this->params) && 
            !array_key_exists("disable", $this->params)) {
            $this->params['list'] = ""; // add default -list option
        }
        $module = ClassRegistry::init("Module");
        if (isset($this->params['list'])) {
            $mods = $module->find('all', array("conditions" => array("status" =>"on")));
            $modNames = array();
            foreach ($mods as $m) {
                $modNames[$m["Module"]["id"]] = $m["Module"]["name"];
            }
            $this->hr();
            $this->out("Current modules on istance " . Configure::read("projectName") . ":");
            $this->hr();    
            print_r($modNames);
            $modsAvailable = Configure::read("modules");
            $modsNot = array();
            foreach ($modsAvailable as $k => $v) {
                if(!in_array($k, $modNames))
                    $modsNot[$v['id']] = $k;
            }
            if(empty($modsNot)) {
                $this->out("\nAll Modules present");
            } else {
                $this->hr();
                $this->out("Modules disabled in " . Configure::read("projectName") . ":");
                $this->hr();
                print_r($modsNot);
            }
        }
        if (isset($this->params['enable'])) {
            $modName = $this->params['enable'];
            if (empty($modName) || $modName == 1) {
                $this->out("module name is mandatory");
                return;
            }
            $modsAvailable = Configure::read("modules");
            if(!array_key_exists($modName,$modsAvailable)) {
                $this->out("Unknown module name: " . $modName);
                return;
            }
            $data = $modsAvailable[$modName];
            if(!isset($data['url']))
                $data['url'] = $modName;
            if(!isset($data['label']))
                $data['label'] = $modName;
            $data['name'] = $modName;
            $data['status'] = "on";
            $namePresent = $module->field("name", array("name" => $modName));
            if(!empty($namePresent)) {
                $data['id'] = $module->field("id", array("name" => $modName));
            } else {
                $idPresent = $module->field("id", array("id" => $data['id']));
                if(!empty($idPresent)) {
                    $this->out("id " . $idPresent . " already present");
                    unset($data['id']); 
                }
            }
            if(!$module->save($data)) {
                $this->out("error saving module " . $modName);
                return;
            }
            $bePermsMod = ClassRegistry::init("PermissionModule");
            $perms =  array(
                array(
                    "name" => "administrator",
                    "switch" => PermissionModule::SWITCH_GROUP,
                    "flag" => BEDITA_PERMS_READ_MODIFY
                )
            );
            $bePermsMod->add($modName, $perms);
            $this->out("Module " . $modName . " added/enabled");
        }
        if (isset($this->params['disable'])) {
            $modName = $this->params['disable'];
            if (empty($modName) || $modName == 1) {
                $this->out("module name is mandatory");
                return;
            }
            $id = $module->field("id", array("name" => $modName));
            if(empty($id)) {
                $this->out("Module " . $modName . " not present");
                return;
            }
            $module->id = $id;
            if(!$module->saveField("status", "off")) {
                $this->out("Error removing module");
                return;
            }
            $this->out("Module " . $modName . " disabled");
        }           
    }
    
    public function mimeTypes() {
        $mimeFile = null;
        if (isset($this->params['f'])) {
            $mimeFile = $this->params['f'];
        } else {
            $this->out("mime.types file is mandatory, bye");
        }
        if(!file_exists($mimeFile)) {
            $this->out("$mimeFile not found, bye");
            return;
        }
        $mimeArray = array();
        $lines = file($mimeFile);
        foreach ($lines as $l) {
            $l = trim($l);
            if(!empty($l) && $l[0] !== "#") {
                $fields = split(' ', $l);
                if(count($fields) > 1) {
                    for ($i = 1 ; $i < count($fields); $i++) {
                        $k = strtolower($fields[$i]);
                        if(!empty($k)) {
                            $mimeArray[$k] = $fields[0];
                        }
                    }
                }
            }
        }
        $beditaMimeFile = APP . 'config' . DS . 'mime.types.php';
        $handle = fopen($beditaMimeFile, 'w');
        fwrite($handle, "<?php\n\$config['mimeTypes'] = array(\n");
        ksort($mimeArray);
        foreach ($mimeArray as $k => $v) {
            fwrite($handle, "  \"$k\" => \"$v\",\n");
        }
        fwrite($handle, ");\n?>");
        fclose($handle);
        $this->out("Mime types updated to: $beditaMimeFile");
    }

    public function updateObjectTypes() {
        $this->initConfig();
        $objType = ClassRegistry::init("ObjectType");
        // from 1 to 999 - core models
        if(!$objType->deleteAll("id < 1000")){ 
            throw new BeditaException(__("Error removing object types", true));
        }
        
        $types = Configure::read("objectTypes");
        foreach ($types as $k => $v) {
            if(is_numeric($k)) {
                $objType->create();
                if(!$objType->save($v)) {
                    throw new BeditaException(__("Error saving object type", true) . " id: $k");
                }
                $this->out("updated type: " . $v["name"]);
            }
        }
        $this->out("done");
    }
    
    
    public function cleanphp() {
        if (!isset($this->params["f"])) {
            $this->out("Missing -f parameter");
            return;
        }
        $recursive = (isset($this->params["r"]))? true : false;
        $this->hr();
        $this->out("Clean PHP files from leading and trailing spaces");
        $this->hr();
        $this->Cleanup->cleanPHPFiles($this->params["f"], $recursive);
        $this->out("done");
    }
    
    public function exportFilter() {
        $this->initConfig();
        $this->readInputArgs();
        if (!isset($this->params["f"])) {
            $this->out("Missing -f parameter");
            return;
        }
        $expFile = $this->params['f'];
        $this->checkExportFile($expFile);
        if (!isset($this->params["id"])) {
            $this->out("Missing -id parameter");
            return;
        }
        $modelType = ClassRegistry::init("BEObject")->getType($this->params["id"]);
        $model = ClassRegistry::init($modelType);
        $data = array($model->findbyId($this->params["id"]));
                
        if (!isset($this->params["filter"])) {
            $this->out("Missing -filter parameter");
            return;
        }

        $defaultParams = array('app' => '', 'root' => '', 'working' => '', 'f' => '', 
            'id' => '', 'filter' => '', 'webroot' => '');
        $filterOptions = array_diff_key($this->params, $defaultParams);

        $this->out("Creating file : " . $expFile . " from object: " . $this->params["id"] 
        . " using filter: " . $this->params["filter"]);
        $this->out('Filter options : ' . print_r($filterOptions, true));

        $filterClass = Configure::read("filters.export." . $this->params["filter"]);
        if (empty($filterClass)) {
            $this->out('Export filter class not found for: ' . $this->params['filter']);
            return;
        }
        $filterModel = ClassRegistry::init($filterClass);
        
        $result = $filterModel->export($data, $filterOptions);
        file_put_contents($expFile, $result["content"]);
        $this->out("File created: " . $expFile . " - content type: " . $result["contentType"] 
            . " size: " . $result["size"]);
            
        if (isset($this->params["validate"])) {
            $result = $filterModel->validate($expFile);
            $this->out("Validation result: \n" . $result);  
        }   
    }

    public function importFilter() {
        $this->initConfig();
        $this->readInputArgs();
        if (!isset($this->params["f"])) {
            $this->out("Missing -f parameter");
            return;
        }
        $impFile = $this->params['f'];
        if (!file_exists($impFile) ) {
            $this->out("Import file not found: " . $impFile);
            return;
        }
        if (!isset($this->params["filter"])) {
            $this->out("Missing -filter parameter");
            return;
        }
    
        $options = array();
        if (isset($this->params["id"])) {
            $options["sectionId"] = $this->params["id"];
        }
        
        // pass other options to filter
        foreach ($this->params as $k => $v) {
            if(!in_array($k, array("f", "id", "filter", "working", 
                    "app", "root", "webroot"))) {
                 $options[$k] = $v;
            }
        }
        
        $this->out("Importing file : " . $impFile . (empty($options["sectionId"]) ? 
                "":  " into section: " . $options["sectionId"])
                . " using filter: " . $this->params["filter"]);
    
        $filterClass = Configure::read("filters.import." . $this->params["filter"]);
        if (empty($filterClass)) {
            $this->out("No import filter found for: " . $this->params["filter"]);
            return;
        }
        
        $filterModel = ClassRegistry::init($filterClass);
        $result = $filterModel->import($impFile, $options);
        $this->out($result["objects"] . " objects created in import ");
    }

    public function filters() {
        $this->initConfig();
        $filters = Configure::read('filters');
        $filtername = "\n" . '(import) <filtername> available: ';
        foreach ($filters['import'] as $k => $v) {
            $filtername.= ' ' . $k;
        }
        $this->out($filtername);
        $this->out('(import) Usage: importFilter -f <file-to-import-path> -filter <filtername> [-id <dest-section-id>] [....]');
        $filtername = "\n" . '(import) <filtername> available: ';
        foreach ($filters['export'] as $k => $v) {
            $filtername.= ' ' . $k;
        }
        $this->out($filtername);
        $this->out('(export) Usage: exportFilter -f <filename> -filter <filtername> -id <object-id>');
    }

    function help() {
        $this->out('Available functions:');
        $this->out(' ');
        $this->out('0. init: initialize a new BEdita instance from scratch');
        $this->out(' ');
        $this->out('1. initDb: initialize database with bedita-db sql scripts');
        $this->out(' ');
        $this->out('    Usage: initDb [-db <dbname>] [-data <sql>] [-nodata] [-media <zipfile>]');
        $this->out(' ');
        $this->out("    -db <dbname>\t use db configuration <dbname> specified in config/database.php");
        $this->out("    -nodata <sql>   \t don't insert data");
        $this->out("    -data <sql>     \t use <sql> data dump, use absolute path if not in bedita-db/");
        $this->out("    -media <zipfile> \t restore media files in <zipfile>");
        $this->out(' ');
        $this->out('2. cleanup: cleanup cache, compile, log files');
        $this->out(' ');
        $this->out('    Usage: cleanup [-frontend <frontend path>] [-logs] [-all]');
        $this->out(' ');
        $this->out("    -frontend \t clean files in <frontend path> [use frontend /app path]");
        $this->out("    -logs \t clean log files");
        $this->out("    -all  \t clean all dirs in tmp/cache dir, not just 'models', 'persistent' and 'views' (default no)");
        $this->out(' ');
        $this->out('3. checkMedia: check media files on db and filesystem');
        $this->out(' ');
        $this->out('    Usage: checkMedia [-create] [--remove-files] [--force-remove][-level <max-depth-level>] [-exclude <dirs>]');
        $this->out(' ');
        $this->out("    -create \t create media objects from files in media root not in DB");
        $this->out("    --remove-files \t remove files not referenced in media objects, ask user confirm");
        $this->out("    --force-remove \t remove files not referenced in media objects, don't ask user confirm");
        $this->out("    -level <max-depth-level> \t max depth level checking filesystem, default 2");
        $this->out("    -exclude <dirs> \t exclude from filesystem check list of comma separated dirs in media root, -exclude dir1,dir2");
        $this->out(' ');
        $this->out('4. export: export media files and data dump');
        $this->out(' ');
        $this->out('    Usage: export [-f <tar-gz-filename>] [-compress]');
        $this->out(' ');
        $this->out("    -f <tar-gz-filename>\t file to export, default ".self::DEFAULT_ARCHIVE_FILE);
        $this->out("    -compress \t gz compression (automagically applied if file extension is .gz)");
        $this->out("    -nomedia  \t don't export media files in tar");
        $this->out(' ');
        $this->out('5. import: import media files and data dump');
        $this->out(' ');
        $this->out('    Usage: import [-f <tar-gz-filename>] [-db <dbname>] [-y]');
        $this->out(' ');
        $this->out("    -f <tar-gz-filename>\t file to import, default ".self::DEFAULT_ARCHIVE_FILE);
        $this->out("    -db <dbname>\t use db configuration <dbname> specified in config/database.php");
        $this->out("    -y  answer always 'yes' to questions...");
        $this->out(' ');
        $this->out('6. checkApp: check app files ... (core.php/database.php/index.php...)');
        $this->out(' ');
        $this->out('    Usage: checkApp [-frontend <app-path>]');
        $this->out(' ');
        $this->out("    -frontend \t check files in <frontend path> [use frontend /app path]");
        $this->out(' ');
        $this->out('7. modules: simple operations on BEdita modules list/enable/disable');
        $this->out(' ');
        $this->out('   Usage: modules [-list] [-enable <module-name>] [-disable <module-name>]');
        $this->out(' ');
        $this->out('8. mimeTypes: update config/mime.types.php from standard mime.types file');
        $this->out(' ');
        $this->out('   Usage: mimeTypes -f <mime.types-file>');
        $this->out(' ');
        $this->out('9. updateObjectTypes: update object_types table');
        $this->out(' ');
        $this->out('10. cleanphp: clean php files from leading and trailing spaces');
        $this->out(' ');
        $this->out('   Usage: cleanuphp [-f <file/dir-path>] [-r]');
        $this->out(' ');
        $this->out("    -f <file-or-directory-path>");
        $this->out("    -r recusrion on directory");
        $this->out(' ');
        $this->out('11. exportFilter: export object using an export filter');
        $this->out(' ');
        $this->out('   Usage: exportFilter -f <filename> -filter <filtername> -id <object-id>');
        $this->out(' ');
        $this->out("    -f <filename>\t actual file name to create");
        $this->out("    -filter <filtername>\t logical name of filter");
        $this->out("    -id <object-id>\t object id to export");
        $this->out(' ');
        $this->out('12. importFilter: import objects using an import filter');
        $this->out(' ');
        $this->out('   Usage: importFilter -f <file-to-import-path> -filter <filtername> [-id <dest-section-id>] [....]');
        $this->out(' ');
        $this->out("    -f <file-to-import-path>\t import file path");
        $this->out("    -filter <filtername>\t logical name of filter");
        $this->out("    -id <dest-section-id>\t optional section/area id destination of imported objects");
        $this->out("    - ... - specific filter params may be passed to filter");
        $this->out(' ');
        $this->out('13. filters: list import/export filters');
        $this->out(' ');
        $this->out('   Usage: filters');
    }
}

?>
BEdita API doc | 4-cactus API documentation generated by ApiGen