コード例 #1
0
<?php

$form = new XoopsThemeForm(_AM_SCLONE_CLONE_A_MODULE, "form", xoops_getenv('PHP_SELF'));
$form->setExtra("enctype='multipart/form-data'");
$module_select = new XoopsFormSelect('', 'module', '', 1, false);
$plugins_handler = new SmartclonePlugins();
$module_select->addOptionArray($plugins_handler->getPluginsArray());
$plugins_tray = new XoopsFormElementTray(_AM_SCLONE_MODULE_SELECT, '');
$plugins_tray->setDescription(_AM_SCLONE_MODULE_SELECT_DSC);
$plugins_tray->addElement($module_select, true);
include_once SMARTOBJECT_ROOT_PATH . 'class/smarttip.php';
$oTip = new SmartTip('smartclone_info1', _AM_SCLONE_WHERE_OTHER_MODULE, _AM_SCLONE_WHERE_OTHER_MODULE_EXP);
$module_selec_tip = new XoopsFormLabel('', $oTip->render(false));
$plugins_tray->addElement($module_selec_tip);
$form->addElement($plugins_tray);
$newname_text = new XoopsFormText(_AM_SCLONE_NEWNAME, 'newname', 50, 255, '');
$newname_text->setDescription(_AM_SCLONE_NEWNAME_DSC);
$form->addElement($newname_text, true);
$install_check = new XoopsFormRadioYN(_AM_SCLONE_INSTALL_CHECK, 'install', true);
$form->addElement($install_check);
$form_button_tray = new XoopsFormElementTray('', '');
$form_hidden = new XoopsFormHidden('op', '');
$form_button_tray->addElement($form_hidden);
$form_butt_create = new XoopsFormButton('', '', _GO, 'submit');
$form_butt_create->setExtra('onclick="this.form.elements.op.value=\'doclone\'"');
$form_button_tray->addElement($form_butt_create);
$butt_cancel = new XoopsFormButton('', '', _CANCEL, 'button');
$butt_cancel->setExtra('onclick="history.go(-1)"');
$form_button_tray->addElement($butt_cancel);
$form->addElement($form_button_tray);
$form->display();
コード例 #2
0
ファイル: smartclone.php プロジェクト: trabisdementia/xuups
 function execute()
 {
     if (function_exists('mb_convert_encoding')) {
         $this->_toModule = mb_convert_encoding($this->_toModule, "", "auto");
     }
     $this->_toModule = str_replace('-', 'xyz', $this->_toModule);
     $this->_toModule = eregi_replace("[[:punct:]]", "", $this->_toModule);
     $this->_toModule = str_replace('xyz', '-', $this->_toModule);
     $this->_toModule = ereg_replace(' ', '_', $this->_toModule);
     $this->addLog('ToModule name, once it has been sanitized : ' . $this->_toModule);
     // Check wether the new module to be created already exists
     if (is_dir(XOOPS_ROOT_PATH . '/modules/' . $this->_toModule)) {
         $this->setError(sprintf(_AM_SCLONE_NEW_MODULE_ALREADY_EXISTS, $this->_toModule));
         return false;
     }
     $this->_sCloNe = $this->_toModule;
     $this->addLog('ToModule : ' . $this->_sCloNe);
     $this->_sCLONE = strtoupper(eregi_replace("-", "_", $this->_toModule));
     $this->addLog('TOMODULE : ' . $this->_sCLONE);
     $this->_sclone = strtolower(eregi_replace("-", "_", $this->_toModule));
     $this->addLog('tomodule : ' . $this->_sclone);
     $this->_sClone = ucfirst(strtolower($this->_toModule));
     $this->addLog('Tomodule : ' . $this->_sClone);
     $this->_sMODULE = strtoupper($this->_fromModule);
     $this->addLog('FROMMODULE : ' . $this->_sMODULE);
     $this->_sModule = ucfirst($this->_fromModule);
     $this->addLog('Frommodule : ' . $this->_sModule);
     // first one must be module directory name
     $this->_patterns = array($this->_fromModule => $this->_sclone, $this->_sMODULE => $this->_sCLONE, $this->_sModule => $this->_sClone);
     // Look for a plugin for this fromModule
     $plugins_handler = new SmartclonePlugins();
     if ($plugins_handler->getPlugin($this->_fromModule) && $plugins_handler->pluginPatterns) {
         foreach ($plugins_handler->pluginPatterns as $aPattern) {
             switch ($aPattern['replacement']) {
                 case 'ModuleName':
                     $this->_patterns[$aPattern['key']] = $this->prefixSuffix($this->_sCloNe, $aPattern);
                     break;
                 case 'Modulename':
                     $this->_patterns[$aPattern['key']] = $this->prefixSuffix($this->_sClone, $aPattern);
                     break;
                 case 'modulename':
                     $this->_patterns[$aPattern['key']] = $this->prefixSuffix($this->_sclone, $aPattern);
                     break;
                 case 'MODULENAME':
                     $this->_patterns[$aPattern['key']] = $this->prefixSuffix($this->_SCLONE, $aPattern);
                     break;
                 case 'CONSTANT':
                     $this->_patterns[$aPattern['key']] = $this->getConstantPattern($aPattern, $aPattern);
                     break;
                 case 'CUSTOM':
                     if (function_exists($aPattern['function'])) {
                         $function = $aPattern['function'];
                         $this->_patterns[$aPattern['key']] = $this->prefixSuffix($function($this->_sCloNe), $aPattern);
                     }
                     break;
             }
         }
     }
     $this->_patKeys = array_keys($this->_patterns);
     $this->_patValues = array_values($this->_patterns);
     // Create clone
     $module_dir = XOOPS_ROOT_PATH . '/modules';
     $fileperm = fileperms($module_dir);
     $this->addLog('Original permissions of folder "' . XOOPS_ROOT_PATH . '/modules' . '" : ' . $fileperm);
     if (chmod($module_dir, 0777)) {
         $this->cloneFileFolder($module_dir . "/" . $this->_fromModule);
     } else {
         $this->setError(_AM_SCLONE_CHANGE_PERMISSION_FAILED);
         return false;
     }
     $this->storeLogsToFile();
     chmod($module_dir, $fileperm);
     return true;
 }