当前位置: 首页>>代码示例>>PHP>>正文


PHP Module::getModulesDirOnDisk方法代码示例

本文整理汇总了PHP中Module::getModulesDirOnDisk方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::getModulesDirOnDisk方法的具体用法?PHP Module::getModulesDirOnDisk怎么用?PHP Module::getModulesDirOnDisk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Module的用法示例。


在下文中一共展示了Module::getModulesDirOnDisk方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: desactivate_custom_modules

function desactivate_custom_modules()
{
    $db = Db::getInstance();
    $modulesDirOnDisk = Module::getModulesDirOnDisk();
    $module_list_xml = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'modules_list.xml';
    $nativeModules = simplexml_load_file($module_list_xml);
    $nativeModules = $nativeModules->modules;
    foreach ($nativeModules as $nativeModulesType) {
        if (in_array($nativeModulesType['type'], array('native', 'partner'))) {
            $arrNativeModules[] = '""';
            foreach ($nativeModulesType->module as $module) {
                $arrNativeModules[] = '"' . pSQL($module['name']) . '"';
            }
        }
    }
    $arrNonNative = $db->ExecuteS('
		SELECT *
		FROM `' . _DB_PREFIX_ . 'module` m
		WHERE name NOT IN (' . implode(',', $arrNativeModules) . ') ');
    $uninstallMe = array("undefined-modules");
    if (is_array($arrNonNative)) {
        foreach ($arrNonNative as $aModule) {
            $uninstallMe[] = $aModule['name'];
        }
    }
    if (!is_array($uninstallMe)) {
        $uninstallMe = array($uninstallMe);
    }
    foreach ($uninstallMe as $k => $v) {
        $uninstallMe[$k] = '"' . pSQL($v) . '"';
    }
    return Db::getInstance()->Execute('
	UPDATE `' . _DB_PREFIX_ . 'module`
	SET `active`= 0
	WHERE `name` IN (' . implode(',', $uninstallMe) . ')');
}
开发者ID:srikanthash09,项目名称:codetestdatld,代码行数:36,代码来源:desactivatecustommodules.php

示例2: getFilesList

 public static function getFilesList($iso_from, $theme_from, $iso_to = false, $theme_to = false, $select = false, $check = false, $modules = false)
 {
     if (empty($iso_from)) {
         die(Tools::displayError());
     }
     $copy = ($iso_to and $theme_to) ? true : false;
     $lPath_from = _PS_TRANSLATIONS_DIR_ . (string) $iso_from . '/';
     $tPath_from = _PS_ROOT_DIR_ . '/themes/' . (string) $theme_from . '/';
     $mPath_from = _PS_MAIL_DIR_ . (string) $iso_from . '/';
     if ($copy) {
         $lPath_to = _PS_TRANSLATIONS_DIR_ . (string) $iso_to . '/';
         $tPath_to = _PS_ROOT_DIR_ . '/themes/' . (string) $theme_to . '/';
         $mPath_to = _PS_MAIL_DIR_ . (string) $iso_to . '/';
     }
     $lFiles = array('admin' . '.php', 'errors' . '.php', 'fields' . '.php', 'pdf' . '.php');
     $mFiles = array('account.html', 'account.txt', 'bankwire.html', 'bankwire.txt', 'cheque.html', 'cheque.txt', 'contact.html', 'contact.txt', 'contact_form.html', 'contact_form.txt', 'credit_slip.html', 'credit_slip.txt', 'download_product.html', 'download_product.txt', 'download-product.tpl', 'employee_password.html', 'employee_password.txt', 'forward_msg.html', 'forward_msg.txt', 'guest_to_customer.html', 'guest_to_customer.txt', 'in_transit.html', 'in_transit.txt', 'newsletter.html', 'newsletter.txt', 'order_canceled.html', 'order_canceled.txt', 'order_conf.html', 'order_conf.txt', 'order_customer_comment.html', 'order_customer_comment.txt', 'order_merchant_comment.html', 'order_merchant_comment.txt', 'order_return_state.html', 'order_return_state.txt', 'outofstock.html', 'outofstock.txt', 'password.html', 'password.txt', 'password_query.html', 'password_query.txt', 'payment.html', 'payment.txt', 'payment_error.html', 'payment_error.txt', 'preparation.html', 'preparation.txt', 'refund.html', 'refund.txt', 'reply_msg.html', 'reply_msg.txt', 'shipped.html', 'shipped.txt', 'test.html', 'test.txt', 'voucher.html', 'voucher.txt');
     $number = -1;
     $files = array();
     $files_tr = array();
     $files_theme = array();
     $files_mail = array();
     $files_modules = array();
     // When a copy is made from a theme in specific language
     // to an other theme for the same language,
     // it's avoid to copy Translations, Mails files
     // and modules files which are not override by theme.
     if (!$copy or $iso_from != $iso_to) {
         // Translations files
         if (!$check or $check and (string) $iso_from != 'en') {
             foreach ($lFiles as $file) {
                 $files_tr[$lPath_from . $file] = $copy ? $lPath_to . $file : ++$number;
             }
         }
         if ($select == 'tr') {
             return $files_tr;
         }
         $files = array_merge($files, $files_tr);
         // Mail files
         if (!$check or $check and (string) $iso_from != 'en') {
             $files_mail[$mPath_from . 'lang.php'] = $copy ? $mPath_to . 'lang.php' : ++$number;
         }
         foreach ($mFiles as $file) {
             $files_mail[$mPath_from . $file] = $copy ? $mPath_to . $file : ++$number;
         }
         if ($select == 'mail') {
             return $files_mail;
         }
         $files = array_merge($files, $files_mail);
         // Modules
         if ($modules) {
             $modList = Module::getModulesDirOnDisk();
             foreach ($modList as $k => $mod) {
                 $modDir = _PS_MODULE_DIR_ . $mod;
                 // Lang file
                 if (file_exists($modDir . '/' . (string) $iso_from . '.php')) {
                     $files_modules[$modDir . '/' . (string) $iso_from . '.php'] = $copy ? $modDir . '/' . (string) $iso_to . '.php' : ++$number;
                 }
                 // Mails files
                 $modMailDirFrom = $modDir . '/mails/' . (string) $iso_from;
                 $modMailDirTo = $modDir . '/mails/' . (string) $iso_to;
                 if (file_exists($modMailDirFrom)) {
                     $dirFiles = scandir($modMailDirFrom);
                     foreach ($dirFiles as $file) {
                         if (file_exists($modMailDirFrom . '/' . $file) and $file != '.' and $file != '..' and $file != '.svn') {
                             $files_modules[$modMailDirFrom . '/' . $file] = $copy ? $modMailDirTo . '/' . $file : ++$number;
                         }
                     }
                 }
             }
             if ($select == 'modules') {
                 return $files_modules;
             }
             $files = array_merge($files, $files_modules);
         }
     } else {
         if ($select == 'mail' or $select == 'tr') {
             return $files;
         }
     }
     // Theme files
     if (!$check or $check and (string) $iso_from != 'en') {
         $files_theme[$tPath_from . 'lang/' . (string) $iso_from . '.php'] = $copy ? $tPath_to . 'lang/' . (string) $iso_to . '.php' : ++$number;
         $module_theme_files = file_exists($tPath_from . 'modules/') ? scandir($tPath_from . 'modules/') : array();
         foreach ($module_theme_files as $module) {
             if ($module !== '.' and $module != '..' and $module !== '.svn' and file_exists($tPath_from . 'modules/' . $module . '/' . (string) $iso_from . '.php')) {
                 $files_theme[$tPath_from . 'modules/' . $module . '/' . (string) $iso_from . '.php'] = $copy ? $tPath_to . 'modules/' . $module . '/' . (string) $iso_to . '.php' : ++$number;
             }
         }
     }
     if ($select == 'theme') {
         return $files_theme;
     }
     $files = array_merge($files, $files_theme);
     // Return
     return $files;
 }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:96,代码来源:Language.php

示例3: getFilesList

 public static function getFilesList($iso_from, $theme_from, $iso_to = false, $theme_to = false, $select = false, $check = false, $modules = false)
 {
     $copy = ($iso_to and $theme_to) ? true : false;
     $lPath_from = _PS_TRANSLATIONS_DIR_ . strval($iso_from) . '/';
     $tPath_from = _PS_ROOT_DIR_ . '/themes/' . strval($theme_from) . '/lang/';
     $mPath_from = _PS_MAIL_DIR_ . strval($iso_from) . '/';
     if ($copy) {
         $lPath_to = _PS_TRANSLATIONS_DIR_ . strval($iso_to) . '/';
         $tPath_to = _PS_ROOT_DIR_ . '/themes/' . strval($theme_to) . '/lang/';
         $mPath_to = _PS_MAIL_DIR_ . strval($iso_to) . '/';
     }
     $lFiles = array('admin' . '.php', 'errors' . '.php', 'fields' . '.php', 'pdf' . '.php');
     $mFiles = array('account.html', 'account.txt', 'bankwire.html', 'bankwire.txt', 'cheque.html', 'cheque.txt', 'contact.html', 'contact.txt', 'credit_slip.html', 'credit_slip.txt', 'download_product.html', 'download_product.txt', 'download-product.tpl', 'employee_password.html', 'employee_password.txt', 'newsletter.html', 'newsletter.txt', 'order_canceled.html', 'order_canceled.txt', 'order_conf.html', 'order_conf.txt', 'order_customer_comment.html', 'order_customer_comment.txt', 'order_merchant_comment.html', 'order_merchant_comment.txt', 'order_return_state.html', 'order_return_state.txt', 'outofstock.html', 'outofstock.txt', 'password.html', 'password.txt', 'payment.html', 'payment.txt', 'payment_error.html', 'payment_error.txt', 'preparation.html', 'preparation.txt', 'refund.html', 'refund.txt', 'shipped.html', 'shipped.txt', 'in_transit.txt', 'in_transit.html', 'test.html', 'test.txt', 'voucher.html', 'voucher.txt');
     $number = -1;
     $files = array();
     $files_tr = array();
     $files_theme = array();
     $files_mail = array();
     $files_modules = array();
     // Translations files
     if (!$check or $check and strval($iso_from) != 'en') {
         foreach ($lFiles as $file) {
             $files_tr[$lPath_from . $file] = $copy ? $lPath_to . $file : ++$number;
         }
     }
     if ($select == 'tr') {
         return $files_tr;
     }
     $files = array_merge($files, $files_tr);
     // Theme files
     if (!$check or $check and strval($iso_from) != 'en') {
         $files_theme[$tPath_from . strval($iso_from) . '.php'] = $copy ? $tPath_to . strval($iso_to) . '.php' : ++$number;
     }
     if ($select == 'theme') {
         return $files_theme;
     }
     $files = array_merge($files, $files_theme);
     // Mail files
     if (!$check or $check and strval($iso_from) != 'en') {
         $files_mail[$mPath_from . 'lang.php'] = $copy ? $mPath_to . 'lang.php' : ++$number;
     }
     foreach ($mFiles as $file) {
         $files_mail[$mPath_from . $file] = $copy ? $mPath_to . $file : ++$number;
     }
     if ($select == 'mail') {
         return $files_mail;
     }
     $files = array_merge($files, $files_mail);
     // Modules
     if ($modules) {
         $modList = Module::getModulesDirOnDisk();
         foreach ($modList as $k => $mod) {
             // Lang file
             $modDir = _PS_MODULE_DIR_ . $mod;
             if (file_exists($modDir . '/' . strval($iso_from) . '.php')) {
                 $files_modules[$modDir . '/' . strval($iso_from) . '.php'] = $copy ? $modDir . '/' . strval($iso_to) . '.php' : ++$number;
             }
             // Mails files
             $modMailDirFrom = $modDir . '/mails/' . strval($iso_from);
             $modMailDirTo = $modDir . '/mails/' . strval($iso_to);
             if (file_exists($modMailDirFrom)) {
                 $dirFiles = scandir($modMailDirFrom);
                 foreach ($dirFiles as $file) {
                     if (file_exists($modMailDirFrom . '/' . $file) and $file != '.' and $file != '..' and $file != '.svn') {
                         $files_modules[$modMailDirFrom . '/' . $file] = $copy ? $modMailDirTo . '/' . $file : ++$number;
                     }
                 }
             }
         }
         if ($select == 'modules') {
             return $files_modules;
         }
         $files = array_merge($files, $files_modules);
     }
     // Return
     return $files;
 }
开发者ID:vincent,项目名称:theinvertebrates,代码行数:77,代码来源:Language.php

示例4: getModulesList

 public function getModulesList()
 {
     $results = array();
     $modules = Module::getModulesDirOnDisk();
     foreach ($modules as $module) {
         $backward_directory = _PS_MODULE_DIR_ . $module . '/backward_compatibility/';
         $module = Module::getInstanceByName($module);
         if (is_dir($backward_directory) && strcmp($module->name, 'backwardcompatibility') != 0) {
             $ini_file = $backward_directory . 'backward.ini';
             $version = $this->getVersion($ini_file);
             if (($handle = @fopen($ini_file, 'a+')) && is_writable($backward_directory)) {
                 @fclose($handle);
                 $writable = true;
             } else {
                 $writable = false;
             }
             $results[] = array('name' => $module->name, 'display_name' => $module->displayName, 'version' => $version, 'writable' => $writable);
         }
     }
     return $results;
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:21,代码来源:backwardcompatibility.php

示例5: getModulesOnDisk

    /**
     * Return available modules
     *
     * @param boolean $useConfig in order to use config.xml file in module dir
     * @return array Modules
     */
    public static function getModulesOnDisk($useConfig = false, $loggedOnAddons = false, $id_employee = false)
    {
        global $_MODULES;
        // Init var
        $module_list = array();
        $module_name_list = array();
        $modulesNameToCursor = array();
        $errors = array();
        // Get modules directory list and memory limit
        $modules_dir = Module::getModulesDirOnDisk();
        $memory_limit = Tools::getMemoryLimit();
        $modules_installed = array();
        $result = Db::getInstance()->executeS('
		SELECT m.name, m.version, mp.interest
		FROM `' . _DB_PREFIX_ . 'module` m
		' . Shop::addSqlAssociation('module', 'm') . '
		LEFT JOIN `' . _DB_PREFIX_ . 'module_preference` mp ON (mp.`module` = m.`name` AND mp.`id_employee` = ' . (int) $id_employee . ')');
        foreach ($result as $row) {
            $modules_installed[$row['name']] = $row;
        }
        foreach ($modules_dir as $module) {
            // Memory usage checking
            if (function_exists('memory_get_usage') && $memory_limit != '-1') {
                $current_memory = memory_get_usage(true);
                // memory_threshold in MB
                $memory_threshold = Tools::isX86_64arch() ? 3 : 1.5;
                if ($memory_limit - $current_memory <= $memory_threshold * 1024 * 1024) {
                    $errors[] = Tools::displayError('All modules cannot be loaded due to memory limit restrictions, please increase your memory_limit value on your server configuration');
                    break;
                }
            }
            // Check if config.xml module file exists and if it's not outdated
            $configFile = _PS_MODULE_DIR_ . $module . '/config.xml';
            $xml_exist = file_exists($configFile);
            if ($xml_exist) {
                $needNewConfigFile = filemtime($configFile) < filemtime(_PS_MODULE_DIR_ . $module . '/' . $module . '.php');
            } else {
                $needNewConfigFile = true;
            }
            // If config.xml exists and that the use config flag is at true
            if ($useConfig && $xml_exist) {
                // Load config.xml
                libxml_use_internal_errors(true);
                $xml_module = simplexml_load_file($configFile);
                foreach (libxml_get_errors() as $error) {
                    $errors[] = '[' . $module . '] ' . Tools::displayError('Error found in config file:') . ' ' . htmlentities($error->message);
                }
                libxml_clear_errors();
                // If no errors in Xml, no need instand and no need new config.xml file, we load only translations
                if (!count($errors) && (int) $xml_module->need_instance == 0 && !$needNewConfigFile) {
                    $file = _PS_MODULE_DIR_ . $module . '/' . Context::getContext()->language->iso_code . '.php';
                    if (Tools::file_exists_cache($file) && (include_once $file)) {
                        if (isset($_MODULE) && is_array($_MODULE)) {
                            $_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE;
                        }
                    }
                    $item = new stdClass();
                    $item->id = 0;
                    $item->warning = '';
                    foreach ($xml_module as $k => $v) {
                        $item->{$k} = (string) $v;
                    }
                    $item->displayName = stripslashes(Translate::getModuleTranslation((string) $xml_module->name, Module::configXmlStringFormat($xml_module->displayName), (string) $xml_module->name));
                    $item->description = stripslashes(Translate::getModuleTranslation((string) $xml_module->name, Module::configXmlStringFormat($xml_module->description), (string) $xml_module->name));
                    $item->author = stripslashes(Translate::getModuleTranslation((string) $xml_module->name, Module::configXmlStringFormat($xml_module->author), (string) $xml_module->name));
                    if (isset($xml_module->confirmUninstall)) {
                        $item->confirmUninstall = Translate::getModuleTranslation((string) $xml_module->name, Module::configXmlStringFormat($xml_module->confirmUninstall), (string) $xml_module->name);
                    }
                    $item->active = 0;
                    $item->onclick_option = false;
                    $module_list[] = $item;
                    $module_name_list[] = '\'' . pSQL($item->name) . '\'';
                    $modulesNameToCursor[strval($item->name)] = $item;
                }
            }
            // If use config flag is at false or config.xml does not exist OR need instance OR need a new config.xml file
            if (!$useConfig || !$xml_exist || isset($xml_module->need_instance) && (int) $xml_module->need_instance == 1 || $needNewConfigFile) {
                // If class does not exists, we include the file
                if (!class_exists($module, false)) {
                    // Get content from php file
                    $filepath = _PS_MODULE_DIR_ . $module . '/' . $module . '.php';
                    $file = trim(file_get_contents(_PS_MODULE_DIR_ . $module . '/' . $module . '.php'));
                    if (substr($file, 0, 5) == '<?php') {
                        $file = substr($file, 5);
                    }
                    if (substr($file, -2) == '?>') {
                        $file = substr($file, 0, -2);
                    }
                    // If (false) is a trick to not load the class with "eval".
                    // This way require_once will works correctly
                    if (eval('if (false){	' . $file . ' }') !== false) {
                        require_once _PS_MODULE_DIR_ . $module . '/' . $module . '.php';
                    } else {
                        $errors[] = sprintf(Tools::displayError('%1$s (parse error in %2$s)'), $module, substr($filepath, strlen(_PS_ROOT_DIR_)));
//.........这里部分代码省略.........
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:101,代码来源:Module.php

示例6: generateTrustedXml

 /**
  * Generate XML files for trusted and untrusted modules
  *
  */
 public static final function generateTrustedXml()
 {
     $modules_on_disk = Module::getModulesDirOnDisk();
     $trusted = array();
     $untrusted = array();
     $trusted_modules_xml = array(_PS_ROOT_DIR_ . self::CACHE_FILE_ALL_COUNTRY_MODULES_LIST, _PS_ROOT_DIR_ . self::CACHE_FILE_MUST_HAVE_MODULES_LIST);
     if (file_exists(_PS_ROOT_DIR_ . self::CACHE_FILE_CUSTOMER_MODULES_LIST)) {
         $trusted_modules_xml[] = _PS_ROOT_DIR_ . self::CACHE_FILE_CUSTOMER_MODULES_LIST;
     }
     // Create 2 arrays with trusted and untrusted modules
     foreach ($trusted_modules_xml as $file) {
         $content = Tools::file_get_contents($file);
         $xml = @simplexml_load_string($content, null, LIBXML_NOCDATA);
         if ($xml && isset($xml->module)) {
             foreach ($xml->module as $modaddons) {
                 $trusted[] = Tools::strtolower((string) $modaddons->name);
             }
         }
     }
     foreach (glob(_PS_ROOT_DIR_ . '/config/xml/themes/*.xml') as $theme_xml) {
         if (file_exists($theme_xml)) {
             $content = Tools::file_get_contents($theme_xml);
             $xml = @simplexml_load_string($content, null, LIBXML_NOCDATA);
             foreach ($xml->modules->module as $modaddons) {
                 if ((string) $modaddons['action'] == 'install') {
                     $trusted[] = Tools::strtolower((string) $modaddons['name']);
                 }
             }
         }
     }
     foreach ($modules_on_disk as $name) {
         if (!in_array($name, $trusted)) {
             if (Module::checkModuleFromAddonsApi($name)) {
                 $trusted[] = Tools::strtolower($name);
             } else {
                 $untrusted[] = Tools::strtolower($name);
             }
         }
     }
     $context = Context::getContext();
     $theme = new Theme($context->shop->id_theme);
     // Save the 2 arrays into XML files
     $trusted_xml = new SimpleXMLElement('<modules_list/>');
     $trusted_xml->addAttribute('theme', $theme->name);
     $modules = $trusted_xml->addChild('modules');
     $modules->addAttribute('type', 'trusted');
     foreach ($trusted as $key => $name) {
         $module = $modules->addChild('module');
         $module->addAttribute('name', $name);
     }
     $success = file_put_contents(_PS_ROOT_DIR_ . self::CACHE_FILE_TRUSTED_MODULES_LIST, $trusted_xml->asXML());
     $untrusted_xml = new SimpleXMLElement('<modules_list/>');
     $modules = $untrusted_xml->addChild('modules');
     $modules->addAttribute('type', 'untrusted');
     foreach ($untrusted as $key => $name) {
         $module = $modules->addChild('module');
         $module->addAttribute('name', $name);
     }
     $success &= file_put_contents(_PS_ROOT_DIR_ . self::CACHE_FILE_UNTRUSTED_MODULES_LIST, $untrusted_xml->asXML());
     if ($success) {
         return true;
     } else {
         Tools::displayError('Trusted and Untrusted XML have not been generated properly');
     }
 }
开发者ID:evgrishin,项目名称:mh16014,代码行数:69,代码来源:Module.php

示例7: getNonNativeModuleList

    /**
     * Return non native module
     *
     * @param int $position Take only positionnables modules
     * @return array Modules
     */
    public static function getNonNativeModuleList()
    {
        $db = Db::getInstance();
        $modulesDirOnDisk = Module::getModulesDirOnDisk();
        $module_list_xml = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'modules_list.xml';
        $nativeModules = simplexml_load_file($module_list_xml);
        $nativeModules = $nativeModules->modules;
        foreach ($nativeModules as $nativeModulesType) {
            if (in_array($nativeModulesType['type'], array('native', 'partner'))) {
                $arrNativeModules[] = '""';
                foreach ($nativeModulesType->module as $module) {
                    $arrNativeModules[] = '"' . pSQL($module['name']) . '"';
                }
            }
        }
        return $db->ExecuteS('
			SELECT *
			FROM `' . _DB_PREFIX_ . 'module` m
			WHERE name NOT IN (' . implode(',', $arrNativeModules) . ') ');
    }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:26,代码来源:Module.php


注:本文中的Module::getModulesDirOnDisk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。