Fork me on GitHub

Rapport de message :*
 

Re: Clonage d'un module

Titre du sujet : Re: Clonage d'un module
par Kris sur 12/11/2011 13:19:34

essayes avec ce script de clonage
<?php   
/*   
Usage:   
    Copy clone.php in <xoops_root>   
    Change current working directory to <xoops_root>   
    Update mappings as per new modulename.   
    php -q clone.php   
*/   
// ##########################################################   
//    Define your mapping here   
// ##########################################################   
$patterns = array(   
  
// first one must be module directory name   
  
'mytube'  => 'video',   
  
'MYTUBE'  => 'VIDEO',   
  
'Mytube' => 'Video',   
  
'MyTube' => 'ViDeo',   
  
'xoopstube' => 'videos',  
);   
$patKeys array_keys($patterns);   
$patValues array_values($patterns);   
// work around for PHP < 5.0.x   
if(!function_exists('file_put_contents')) {   
  function 
file_put_contents($filename$data$file_append false) {   
    
$fp fopen($filename, (!$file_append 'w+' 'a+'));   
    if(!
$fp) {   
      
trigger_error('file_put_contents cannot write in file.'E_USER_ERROR);   
      return;   
    }   
    
fputs($fp$data);   
    
fclose($fp);   
  }   
}   
// recursive clonning script   
function cloneFileFolder($path)   
{   
  global 
$patKeys;   
  global 
$patValues;   
  
$newPath str_replace($patKeys[0], $patValues[0], $path);   
  if (
is_dir($path))   
  {   
    
// create new dir   
    
mkdir($newPath);   
    
// check all files in dir, and process it   
    
if ($handle opendir($path))   
    {   
      while (
$file readdir($handle))   
      {   
        if (
$file != '.' && $file != '..')   
        {   
          
cloneFileFolder("$path/$file");   
        }   
      }   
      
closedir($handle);   
    }   
  }   
  else   
  {   
    if(
preg_match('/(.jpg|.gif|.png|.zip)$/i'$path))   
    {   
      
copy($path$newPath);   
    }   
    else   
    {   
      
$content file_get_contents($path);   
      
$content str_replace($patKeys$patValues$content);   
      
file_put_contents($newPath$content);   
    }   
  }   
}   
cloneFileFolder('modules/mytube');   
echo 
"Happy cloning...n";   
echo 
"check directory modules/" $patterns['mytube'] . " for cloned module n";   
echo 
"Consider modifying new module by editing language/english/modinfo.php and images/" $patterns['mytube'] . "_slogo.png manually (if you care)n";   
?>

Propulsé avec XOOPS | Graphisme adapté par Tatane, Grosdunord, Montuy337513

33 Personne(s) en ligne (25 Personne(s) connectée(s) sur Forum) | Utilisateur(s): 0 | Invité(s): 33 | Plus ...