Changeset 156

Show
Ignore:
Timestamp:
05/04/06 09:33:50 (3 years ago)
Author:
bballizlife
Message:

Nombreuses modifications afin d'ajouter la gestion des scripts en ligne de commande

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/manifests/jelix-dev.mn

    r150 r156  
    126126  dbprofils.ini.php.tpl 
    127127  config.classic.ini.php.tpl 
     128  config.cmdline.ini.php.tpl 
     129  controller.cmdline.tpl 
    128130cd lib/jelix-scripts/templates/www 
    129131  xmlrpc.php.tpl 
    130132  index.php.tpl 
    131133  jsonrpc.php.tpl 
     134cd lib/jelix-scripts/templates/scripts 
     135  cmdline.php.tpl 
    132136cd lib/jelix/docs/ns 
    133137  dao.rng 
  • trunk/build/manifests/jelix-lib.mn

    r150 r156  
    2222  jAclUserGroup.class.php 
    2323  jAclManager.class.php 
     24   
     25cd lib/jelix/controllers 
     26  jControllerCmdLine.class.php 
    2427 
    2528cd lib/jelix/core 
     
    149152  jZone.class.php 
    150153  jDatatype.class.php 
     154  jCmdUtils.class.php 
    151155 
    152156cd lib/json 
  • trunk/lib/jelix-scripts/commands/createapp.cmd.php

    r153 r156  
    55* @version     $Id$ 
    66* @author      Jouanneau Laurent 
    7 * @contributor 
     7* @contributor Loic Mathaud 
    88* @copyright   2005-2006 Jouanneau laurent 
    99* @link        http://www.jelix.org 
     
    1414 
    1515    public  $name = 'createapp'; 
    16     public  $allowed_options=array('-withdefaultmodule'=>false); 
     16    public  $allowed_options=array('-withdefaultmodule'=>false, '-withcmdline'=>false); 
    1717    public  $allowed_parameters=array(); 
    1818 
    19     public  $syntaxhelp = "[-withdefaultmodule]"; 
     19    public  $syntaxhelp = "[-withdefaultmodule] [-withcmdline]"; 
    2020    public  $help=" 
    2121    Cr� une nouvelle application avec tous les r�rtoires n�ssaires. 
     
    2323    Si l'option -withdefaultmodule est pr�nte, cr� �lement un module du 
    2424    m� nom que l'application. 
     25     
     26    Si l'option -withcmdline est pr�nte, cr� un point d'entr�afin de d�lopper des 
     27    scripts en ligne de commande. 
    2528 
    2629    Le nom de l'application doit �e indiqu�   1) soit en premier param�e du script jelix.php 
     
    7881            $cmd->run(); 
    7982       } 
     83        
     84       if ($this->getOption('-withcmdline')) { 
     85            $this->createDir(JELIX_APP_CMD_PATH); 
     86            $this->createFile(JELIX_APP_CONFIG_PATH.'config.cmdline.ini.php','config.cmdline.ini.php.tpl',$param); 
     87            $param['rp_cmd'] =jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CMD_PATH); 
     88            $this->createFile(JELIX_APP_CMD_PATH.'cmdline.php','scripts/cmdline.php.tpl',$param); 
     89       } 
    8090 
    8191    } 
  • trunk/lib/jelix-scripts/commands/createctrl.cmd.php

    r153 r156  
    55* @version     $Id$ 
    66* @author      Jouanneau Laurent 
    7 * @contributor 
     7* @contributor Loic Mathaud 
    88* @copyright   2005-2006 Jouanneau laurent 
    99* @link        http://www.jelix.org 
     
    1414 
    1515    public  $name = 'createctrl'; 
    16     public  $allowed_options=array(); 
     16    public  $allowed_options=array('-cmdline'=>false); 
    1717    public  $allowed_parameters=array('module'=>true,'name'=>true, 'method'=>false); 
    1818 
    19     public  $syntaxhelp = "MODULE NOM_CONTROLEUR [NOM_METHOD]"; 
     19    public  $syntaxhelp = "[-cmdline] MODULE NOM_CONTROLEUR [NOM_METHOD]"; 
    2020    public  $help=" 
    21     Permet de cr� un nouveau fichier d'une classe jController 
     21    Permet de cr� un nouveau fichier d'une classe jController ou jControllerCmdLine 
    2222 
     23    Si l'option -cmdline est pr�nte, cr�un controller de type jControllerCmdLine, 
     24    pour d�lopper des scripts en ligne de commande. Sinon, le controller cr�est 
     25    de type jController. 
     26     
    2327    MODULE : le nom du module concern�    NOM_CONTROLEUR :  nom du controleur que vous voulez cr�. 
    2428    NOM_METHOD (facultatif) : nom de la premi� m�ode. Par d�ut, elle a 
    2529                              le nom index."; 
    26  
     30     
    2731 
    2832    public function run(){ 
     
    3135       $agfilename= $path.'controllers/'; 
    3236       $this->createDir($agfilename); 
    33  
    34        $agfilename.=strtolower($this->_parameters['name']).'.classic.php'; 
     37        
     38       if ($this->getOption('-cmdline')) {  
     39            $type = 'cmdline'; 
     40       } else { 
     41            $type = 'classic'; 
     42       } 
     43        
     44       $agfilename.=strtolower($this->_parameters['name']).'.'. $type .'.php'; 
    3545 
    3646       $method = $this->getParam('method','index'); 
     
    3848       $param= array('name'=>$this->_parameters['name'] , 'method'=>$method); 
    3949 
    40        $this->createFile($agfilename,'controller.tpl',$param); 
     50       if ($this->getOption('-cmdline')) { 
     51            $tplname = 'controller.cmdline.tpl'; 
     52       } else { 
     53            $tplname = 'controller.tpl'; 
     54       } 
     55       $this->createFile($agfilename,$tplname,$param); 
    4156 
    4257    } 
  • trunk/lib/jelix-scripts/jelix.php

    r153 r156  
    44* @version     $Id$ 
    55* @author      Jouanneau Laurent 
    6 * @contributor 
     6* @contributor Loic Mathaud 
    77* @copyright   2005-2006 Jouanneau laurent 
    88* @link        http://www.jelix.org 
     
    8080   define ('JELIX_APP_CONFIG_PATH',  JELIXS_APPTPL_CONFIG_PATH); 
    8181   define ('JELIX_APP_WWW_PATH',     JELIXS_APPTPL_WWW_PATH); 
     82   define ('JELIX_APP_CMD_PATH',     JELIXS_APPTPL_CMD_PATH); 
    8283} 
    8384 
  • trunk/lib/jelix-scripts/scripts.conf.php

    r120 r156  
    44* @version     $Id$ 
    55* @author      Jouanneau Laurent 
    6 * @contributor 
     6* @contributor Loic Mathaud 
    77* @copyright   2005-2006 Jouanneau laurent 
    88* @link        http://www.jelix.org 
     
    1919define ('JELIXS_APPTPL_LOG_PATH'    , JELIXS_APPS_BASEPATH."/$APPNAME/var/log/"); 
    2020define ('JELIXS_APPTPL_CONFIG_PATH' , JELIXS_APPS_BASEPATH."/$APPNAME/var/config/"); 
     21define ('JELIXS_APPTPL_CMD_PATH'    , JELIXS_APPS_BASEPATH."/$APPNAME/scripts/"); 
    2122define ('JELIXS_INIT_PATH'          , JELIXS_APPS_BASEPATH.'/lib/jelix/init.php'); 
    2223 
  • trunk/lib/jelix-scripts/templates/application.init.php.tpl

    r9 r156  
    1818define ('JELIX_APP_CONFIG_PATH',  realpath(JELIX_APP_PATH.'{$rp_conf}').'/'); 
    1919define ('JELIX_APP_WWW_PATH',     realpath(JELIX_APP_PATH.'{$rp_www}').'/'); 
    20  
     20define ('JELIX_APP_CMD_PATH',     realpath(JELIX_APP_PATH.'{$rp_cmd}').'/'); 
    2121 
    2222?> 
  • trunk/lib/jelix/core/jController.class.php

    r138 r156  
    55* @version    $Id:$ 
    66* @author     Laurent Jouanneau 
    7 * @contributor 
     7* @contributor Loic Mathaud 
    88* @copyright  2001-2005 CopixTeam, 2005-2006 Laurent Jouanneau 
    99* @link        http://www.jelix.org 
     
    2626 
    2727    public $pluginParams=array(); 
    28     private $request; 
     28    protected $request; 
    2929 
    3030    /** 
  • trunk/lib/jelix/core/request/jCmdLineRequest.class.php

    r51 r156  
    55* @version     $Id$ 
    66* @author      Jouanneau Laurent 
    7 * @contributor 
     7* @contributor Loic Mathaud 
    88* @copyright   2005-2006 Jouanneau laurent 
    99* @link        http://www.jelix.org 
     
    1919 
    2020    protected function _initParams(){ 
     21        if($_SERVER['argc'] < 2){ 
     22            die("Error: selector is missing\n"); 
     23        } 
     24        $argv = $_SERVER['argv']; 
    2125 
    22         $this->url  = jUrl::parse($_SERVER['SCRIPT_NAME']); 
    23         $this->params = $_SERVER['argv']; 
     26        $scriptName = array_shift($argv); // shift the script name 
     27        $argsel = array_shift($argv); // get the module~action selector 
     28        $selector = new jSelectorAct($argsel); 
     29 
     30        $this->params = $argv; 
     31        $this->params['module'] = $selector->module; 
     32        $this->params['action'] = $selector->controller .'_'. $selector->method; 
     33        $this->url  = null; // no URL in command line mode 
    2434    } 
    2535} 
  • trunk/lib/jelix/init.php

    r150 r156  
    55* @version  $Id$ 
    66* @author   Jouanneau Laurent 
    7 * @contributor 
     7* @contributor Loic Mathaud 
    88* @copyright 2005-2006 Jouanneau laurent 
    99* @link     http://www.jelix.org 
     
    2727define ('JELIX_LIB_RESPONSE_PATH',JELIX_LIB_PATH.'core/response/'); 
    2828define ('JELIX_LIB_TPL_PATH',      JELIX_LIB_PATH.'tpl/'); 
     29define ('JELIX_LIB_CTRL_PATH',      JELIX_LIB_PATH.'controllers/'); 
    2930 
    3031// all path of libs 
     
    5657$gLibPath=array('Db'=>JELIX_LIB_DB_PATH, 'DAO'=>JELIX_LIB_DAO_PATH, 
    5758 'Forms'=>JELIX_LIB_FORMS_PATH, 'Event'=>JELIX_LIB_EVENTS_PATH, 'Auth'=>JELIX_LIB_AUTH_PATH, 
    58  'Tpl'=>JELIX_LIB_TPL_PATH, 'Acl'=>JELIX_LIB_ACL_PATH); 
     59 'Tpl'=>JELIX_LIB_TPL_PATH, 'Acl'=>JELIX_LIB_ACL_PATH, 'Controller'=>JELIX_LIB_CTRL_PATH); 
    5960 
    6061 
    6162function __autoload($class){ 
    62    if(preg_match('/^j(Acl|DAO|Db|Forms|Event|Auth|Tpl).*$/', $class, $m)){ 
     63   if(preg_match('/^j(Acl|Controller|DAO|Db|Forms|Event|Auth|Tpl).*$/', $class, $m)){ 
    6364       $f=$GLOBALS['gLibPath'][$m[1]].$class.'.class.php'; 
    6465   }elseif(preg_match('/^cDAO(?:Record)?_(.*)_(.*)_(.*)$/', $class, $m)){ 
Download in other formats: Unified Diff Zip Archive