本文整理汇总了PHP中XoopsLoad类的典型用法代码示例。如果您正苦于以下问题:PHP XoopsLoad类的具体用法?PHP XoopsLoad怎么用?PHP XoopsLoad使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XoopsLoad类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHelper
/**
* @param string $dirname
*
* @return bool|Xoops\Module\Helper\HelperAbstract
*/
public static function getHelper($dirname = 'system')
{
static $modules = array();
$dirname = strtolower($dirname);
if (!isset($modules[$dirname])) {
$modules[$dirname] = false;
$xoops = \Xoops::getInstance();
if ($xoops->isActiveModule($dirname)) {
//Load Module helper if available
if (\XoopsLoad::loadFile($xoops->path("modules/{$dirname}/class/helper.php"))) {
$className = '\\' . ucfirst($dirname);
if (class_exists($className)) {
$class = new $className();
if ($class instanceof \Xoops\Module\Helper\HelperAbstract) {
$modules[$dirname] = $class::getInstance();
}
}
} else {
//Create Module Helper
$xoops->registry()->set('module_helper_id', $dirname);
$class = \Xoops\Module\Helper\Dummy::getInstance();
$class->setDirname($dirname);
$modules[$dirname] = $class;
}
}
}
return $modules[$dirname];
}
示例2: execute
/**
* execute the command
*
* @param InputInterface $input input handler
* @param OutputInterface $output output handler
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$xoops = \Xoops::getInstance();
$module = $input->getArgument('module');
if (false === \XoopsLoad::fileExists($xoops->path("modules/{$module}/xoops_version.php"))) {
$output->writeln(sprintf('<error>No module named %s found!</error>', $module));
return;
}
$output->writeln(sprintf('Installing %s', $module));
if (false !== $xoops->getModuleByDirname($module)) {
$output->writeln(sprintf('<error>%s module is already installed!</error>', $module));
return;
}
$xoops->setTpl(new XoopsTpl());
\XoopsLoad::load('module', 'system');
$sysmod = new \SystemModule();
$result = $sysmod->install($module);
foreach ($sysmod->trace as $message) {
if (is_array($message)) {
foreach ($message as $subMessage) {
if (!is_array($subMessage)) {
$output->writeln(strip_tags($subMessage));
}
}
} else {
$output->writeln(strip_tags($message));
}
}
if ($result === false) {
$output->writeln(sprintf('<error>Install of %s failed!</error>', $module));
} else {
$output->writeln(sprintf('<info>Install of %s completed.</info>', $module));
}
$xoops->cache()->delete('system');
}
示例3: xoops_load
/**
* XOOPS class loader wrapper
*
* Temporay solution for XOOPS 2.3
*
* @param string $name Name of class to be loaded
* @param string $type domain of the class, potential values: core - locaded in /class/; framework - located in /Frameworks/; other - module class, located in /modules/[$type]/class/
* @return boolean
*/
function xoops_load($name, $type = "core")
{
if (!class_exists('XoopsLoad')) {
require_once XOOPS_ROOT_PATH . "/class/xoopsload.php";
}
return XoopsLoad::load($name, $type);
}
示例4: __construct
/**
* __construct
* @param string|string[] $config fully qualified name of configuration file
* or configuration array
* @throws Exception
*/
private final function __construct($config)
{
if (!class_exists('XoopsLoad', false)) {
include __DIR__ . '/xoopsload.php';
}
if (is_string($config)) {
$yamlString = file_get_contents($config);
if ($yamlString === false) {
throw new \Exception('XoopsBaseConfig failed to load configuration.');
}
$loaderPath = $this->extractLibPath($yamlString) . '/vendor/autoload.php';
if (file_exists($loaderPath)) {
include_once $loaderPath;
}
self::$configs = Yaml::loadWrapped($yamlString);
\XoopsLoad::startAutoloader(self::$configs['lib-path']);
} elseif (is_array($config)) {
self::$configs = $config;
\XoopsLoad::startAutoloader(self::$configs['lib-path']);
}
if (!isset(self::$configs['lib-path'])) {
throw new \Exception('XoopsBaseConfig lib-path not defined.');
return;
}
\XoopsLoad::startAutoloader(self::$configs['lib-path']);
}
示例5: getPlugins
/**
* @param string $pluginName
* @param array|bool $inactiveModules
*
* @return mixed
*/
public static function getPlugins($pluginName = 'system', $inactiveModules = false)
{
static $plugins = array();
if (!isset($plugins[$pluginName])) {
$plugins[$pluginName] = array();
$xoops = \Xoops::getInstance();
//Load interface for this plugin
if (!\XoopsLoad::loadFile($xoops->path("modules/{$pluginName}/class/plugin/interface.php"))) {
return $plugins[$pluginName];
}
$dirnames = $xoops->getActiveModules();
if (is_array($inactiveModules)) {
$dirnames = array_merge($dirnames, $inactiveModules);
}
foreach ($dirnames as $dirname) {
if (\XoopsLoad::loadFile($xoops->path("modules/{$dirname}/class/plugin/{$pluginName}.php"))) {
$className = '\\' . ucfirst($dirname) . ucfirst($pluginName) . 'Plugin';
$interface = '\\' . ucfirst($pluginName) . 'PluginInterface';
$class = new $className($dirname);
if ($class instanceof \Xoops\Module\Plugin\PluginAbstract && $class instanceof $interface) {
$plugins[$pluginName][$dirname] = $class;
}
}
}
}
return $plugins[$pluginName];
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$module = $input->getArgument('module');
$output->writeln(sprintf('Uninstalling %s', $module));
$xoops = \Xoops::getInstance();
if (false === $xoops->getModuleByDirname($module)) {
$output->writeln(sprintf('<error>%s is not an installed module!</error>', $module));
return;
}
$xoops->setTpl(new \XoopsTpl());
\XoopsLoad::load('module', 'system');
$sysmod = new \SystemModule();
$result = $sysmod->uninstall($module);
foreach ($sysmod->trace as $message) {
if (is_array($message)) {
foreach ($message as $subMessage) {
if (!is_array($subMessage)) {
$output->writeln(strip_tags($subMessage));
}
}
} else {
$output->writeln(strip_tags($message));
}
}
if ($result === false) {
$output->writeln(sprintf('<error>Uninstall of %s failed!</error>', $module));
} else {
$output->writeln(sprintf('<info>Uninstall of %s completed.</info>', $module));
}
$xoops->cache()->delete('system');
}
示例7: getDump
/**
* @return void
*/
public function getDump()
{
$xoops = Xoops::getInstance();
$maintenance = new Maintenance();
parent::__construct('', "form_dump", "dump.php", 'post', true);
$dump_tray = new Xoops\Form\ElementTray(_AM_MAINTENANCE_DUMP_TABLES_OR_MODULES, '');
$select_tables1 = new Xoops\Form\Select('', "dump_tables", '', 7, true);
$select_tables1->addOptionArray($maintenance->displayTables(true));
$dump_tray->addElement($select_tables1, false);
$ele = new Xoops\Form\Select(' ' . _AM_MAINTENANCE_OR . ' ', 'dump_modules', '', 7, true);
$module_list = XoopsLists::getModulesList();
$module_handler = $xoops->getHandlerModule();
foreach ($module_list as $file) {
if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $file . '/xoops_version.php')) {
clearstatcache();
$file = trim($file);
$module = $module_handler->create();
$module->loadInfo($file);
if ($module->getInfo('tables') && $xoops->isActiveModule($file)) {
$ele->addOption($module->getInfo('dirname'), $module->getInfo('name'));
}
unset($module);
}
}
$dump_tray->addElement($ele);
$this->addElement($dump_tray);
$this->addElement(new Xoops\Form\RadioYesNo(_AM_MAINTENANCE_DUMP_DROP, 'drop', 1));
$this->addElement(new Xoops\Form\Hidden("op", "dump_save"));
$this->addElement(new Xoops\Form\Button("", "dump_save", XoopsLocale::A_SUBMIT, "submit"));
}
示例8: __construct
/**
* @param null $obj
*/
public function __construct($obj = null)
{
$xoops = Xoops::getInstance();
parent::__construct('', 'xlanguage_form', $xoops->getEnv('PHP_SELF'), 'post', true, 'horizontal');
// language name
$xlanguage_select = new Xoops\Form\Select(_AM_XLANGUAGE_NAME, 'xlanguage_name', $obj->getVar('xlanguage_name'));
$xlanguage_select->addOptionArray(XoopsLists::getLocaleList());
$this->addElement($xlanguage_select, true);
// language description
$this->addElement(new Xoops\Form\Text(_AM_XLANGUAGE_DESCRIPTION, 'xlanguage_description', 5, 30, $obj->getVar('xlanguage_description')), true);
// language charset
$autoload = XoopsLoad::loadConfig('xlanguage');
$charset_select = new Xoops\Form\Select(_AM_XLANGUAGE_CHARSET, 'xlanguage_charset', $obj->getVar('xlanguage_charset'));
$charset_select->addOptionArray($autoload['charset']);
$this->addElement($charset_select);
// language code
$this->addElement(new Xoops\Form\Text(_AM_XLANGUAGE_CODE, 'xlanguage_code', 5, 10, $obj->getVar('xlanguage_code')), true);
// language weight
$this->addElement(new Xoops\Form\Text(_AM_XLANGUAGE_WEIGHT, 'xlanguage_weight', 1, 4, $obj->getVar('xlanguage_weight')));
// language image
$image_option_tray = new Xoops\Form\ElementTray(_AM_XLANGUAGE_IMAGE, '');
$image_array = XoopsLists::getImgListAsArray(\XoopsBaseConfig::get('root-path') . '/media/xoops/images/flags/' . \Xoops\Module\Helper::getHelper('xlanguage')->getConfig('theme') . '/');
$image_select = new Xoops\Form\Select('', 'xlanguage_image', $obj->getVar('xlanguage_image'));
$image_select->addOptionArray($image_array);
$image_select->setExtra("onchange='showImgSelected(\"image\", \"xlanguage_image\", \"/media/xoops/images/flags/" . \Xoops\Module\Helper::getHelper('xlanguage')->getConfig('theme') . "/\", \"\", \"" . \XoopsBaseConfig::get('url') . "\")'");
$image_tray = new Xoops\Form\ElementTray('', ' ');
$image_tray->addElement($image_select);
$image_tray->addElement(new Xoops\Form\Label('', "<div style='padding: 8px;'><img style='width:24px; height:24px; ' src='" . \XoopsBaseConfig::get('url') . "/media/xoops/images/flags/" . \Xoops\Module\Helper::getHelper('xlanguage')->getConfig('theme') . "/" . $obj->getVar("xlanguage_image") . "' name='image' id='image' alt='' /></div>"));
$image_option_tray->addElement($image_tray);
$this->addElement($image_option_tray);
$this->addElement(new Xoops\Form\Hidden('xlanguage_id', $obj->getVar('xlanguage_id')));
/**
* Buttons
*/
$button_tray = new Xoops\Form\ElementTray('', '');
$button_tray->addElement(new Xoops\Form\Hidden('op', 'save'));
$button = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
$button->setClass('btn btn-success');
$button_tray->addElement($button);
$button_2 = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
$button_2->setClass('btn btn-warning');
$button_tray->addElement($button_2);
switch (basename($xoops->getEnv('PHP_SELF'), '.php')) {
case 'xoops_xlanguage':
$button_3 = new Xoops\Form\Button('', 'button', XoopsLocale::A_CLOSE, 'button');
$button_3->setExtra('onclick="tinyMCEPopup.close();"');
$button_3->setClass('btn btn-danger');
$button_tray->addElement($button_3);
break;
case 'index':
default:
$button_3 = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
$button_3->setExtra("onclick='javascript:history.go(-1);'");
$button_3->setClass('btn btn-danger');
$button_tray->addElement($button_3);
break;
}
$this->addElement($button_tray);
}
示例9: test_loadMailerLocale
public function test_loadMailerLocale()
{
$class = $this->myClass;
$x = $class::loadMailerLocale();
$this->assertSame(true, $x);
$map = XoopsLoad::getMap();
$this->assertTrue(isset($map['xoopsmailerlocale']));
}
示例10: loadLanguage
/**
* @param string $name
*/
public function loadLanguage($name)
{
$helper = Menus::getInstance();
$language = XoopsLocale::getLegacyLanguage();
$path = $helper->path("decorators/{$name}/language");
if (!($ret = XoopsLoad::loadFile("{$path}/{$language}/decorator.php"))) {
$ret = XoopsLoad::loadFile("{$path}/english/decorator.php");
}
return $ret;
}
示例11: init
/**
* Init the module
*
* @return null|void
*/
public function init()
{
if (XoopsLoad::fileExists($hnd_file = \XoopsBaseConfig::get('root-path') . '/modules/xlanguage/include/vars.php')) {
include_once $hnd_file;
}
if (XoopsLoad::fileExists($hnd_file = \XoopsBaseConfig::get('root-path') . '/modules/xlanguage/include/functions.php')) {
include_once $hnd_file;
}
$this->setDirname('xlanguage');
}
示例12: test_xoopsCodeDecode
public function test_xoopsCodeDecode()
{
$this->markTestSkipped('now protected - move to extension test');
$path = \XoopsBaseConfig::get('root-path');
if (!class_exists('Comments', false)) {
\XoopsLoad::addMap(array('comments' => $path . '/modules/comments/class/helper.php'));
}
if (!class_exists('MenusDecorator', false)) {
\XoopsLoad::addMap(array('menusdecorator' => $path . '/modules/menus/class/decorator.php'));
}
if (!class_exists('MenusBuilder', false)) {
\XoopsLoad::addMap(array('menusbuilder' => $path . '/modules/menus/class/builder.php'));
}
$class = $this->myClass;
$sanitizer = $class::getInstance();
$host = 'monhost.fr';
$site = 'MonSite';
$text = '[siteurl="' . $host . '"]' . $site . '[/siteurl]';
$message = $this->decode_check_level($sanitizer, $text);
$xoops_url = \XoopsBaseConfig::get('url');
$this->assertEquals('<a href="' . $xoops_url . '/' . $host . '" title="">' . $site . '</a>', $message);
$text = '[siteurl=\'' . $host . '\']' . $site . '[/siteurl]';
$message = $this->decode_check_level($sanitizer, $text);
$this->assertEquals('<a href="' . $xoops_url . '/' . $host . '" title="">' . $site . '</a>', $message);
$text = '[url="http://' . $host . '"]' . $site . '[/url]';
$message = $this->decode_check_level($sanitizer, $text);
$this->assertEquals('<a href="http://' . $host . '" rel="external" title="">' . $site . '</a>', $message);
$text = '[url=\'http://' . $host . '\']' . $site . '[/url]';
$message = $this->decode_check_level($sanitizer, $text);
$this->assertEquals('<a href="http://' . $host . '" rel="external" title="">' . $site . '</a>', $message);
$text = '[url="https://' . $host . '"]' . $site . '[/url]';
$message = $this->decode_check_level($sanitizer, $text);
$this->assertEquals('<a href="https://' . $host . '" rel="external" title="">' . $site . '</a>', $message);
$text = '[url=\'https://' . $host . '\']' . $site . '[/url]';
$message = $this->decode_check_level($sanitizer, $text);
$this->assertEquals('<a href="https://' . $host . '" rel="external" title="">' . $site . '</a>', $message);
$text = '[url="ftp://' . $host . '"]' . $site . '[/url]';
$message = $this->decode_check_level($sanitizer, $text);
$this->assertEquals('<a href="ftp://' . $host . '" rel="external" title="">' . $site . '</a>', $message);
$text = '[url=\'ftp://' . $host . '\']' . $site . '[/url]';
$message = $this->decode_check_level($sanitizer, $text);
$this->assertEquals('<a href="ftp://' . $host . '" rel="external" title="">' . $site . '</a>', $message);
$text = '[url="ftps://' . $host . '"]' . $site . '[/url]';
$message = $this->decode_check_level($sanitizer, $text);
$this->assertEquals('<a href="ftps://' . $host . '" rel="external" title="">' . $site . '</a>', $message);
$text = '[url=\'ftps://' . $host . '\']' . $site . '[/url]';
$message = $this->decode_check_level($sanitizer, $text);
$this->assertEquals('<a href="ftps://' . $host . '" rel="external" title="">' . $site . '</a>', $message);
$text = '[url="' . $host . '"]' . $site . '[/url]';
$message = $this->decode_check_level($sanitizer, $text);
$this->assertEquals('<a href="http://' . $host . '" rel="external" title="">' . $site . '</a>', $message);
$text = '[url=\'' . $host . '\']' . $site . '[/url]';
$message = $this->decode_check_level($sanitizer, $text);
$this->assertEquals('<a href="http://' . $host . '" rel="external" title="">' . $site . '</a>', $message);
}
示例13: xoops_module_pre_uninstall_notifications
function xoops_module_pre_uninstall_notifications(&$module)
{
$xoops = Xoops::getInstance();
XoopsLoad::loadFile($xoops->path('modules/notifications/class/helper.php'));
$helper = Notifications::getInstance();
$plugins = \Xoops\Module\Plugin::getPlugins('notifications');
foreach (array_keys($plugins) as $dirname) {
$helper->deleteModuleRelations($xoops->getModuleByDirname($dirname));
}
return true;
}
示例14: load
/**
* @param MyTextSanitizer $ts
* @param string $text
* @param bool $force
* @return mixed
*/
public function load(MyTextSanitizer &$ts, $text, $force = false)
{
$xoops = Xoops::getInstance();
if (empty($force) && $xoops->userIsAdmin) {
return $text;
}
// Built-in fitlers for XSS scripts
// To be improved
$text = $ts->filterXss($text);
if (XoopsLoad::load("purifier", "framework")) {
$text = XoopsPurifier::purify($text);
return $text;
}
$tags = array();
$search = array();
$replace = array();
$config = parent::loadConfig(__DIR__);
if (!empty($config["patterns"])) {
foreach ($config["patterns"] as $pattern) {
if (empty($pattern['search'])) {
continue;
}
$search[] = $pattern['search'];
$replace[] = $pattern['replace'];
}
}
if (!empty($config["tags"])) {
$tags = array_map("trim", $config["tags"]);
}
// Set embedded tags
$tags[] = "SCRIPT";
$tags[] = "VBSCRIPT";
$tags[] = "JAVASCRIPT";
foreach ($tags as $tag) {
$search[] = "/<" . $tag . "[^>]*?>.*?<\\/" . $tag . ">/si";
$replace[] = " [!" . strtoupper($tag) . " FILTERED!] ";
}
// Set meta refresh tag
$search[] = "/<META[^>\\/]*HTTP-EQUIV=(['\"])?REFRESH(\\1)[^>\\/]*?\\/>/si";
$replace[] = "";
// Sanitizing scripts in IMG tag
//$search[]= "/(<IMG[\s]+[^>\/]*SOURCE=)(['\"])?(.*)(\\2)([^>\/]*?\/>)/si";
//$replace[]="";
// Set iframe tag
$search[] = "/<IFRAME[^>\\/]*SRC=(['\"])?([^>\\/]*)(\\1)[^>\\/]*?\\/>/si";
$replace[] = " [!IFRAME FILTERED! \\2] ";
$search[] = "/<IFRAME[^>]*?>([^<]*)<\\/IFRAME>/si";
$replace[] = " [!IFRAME FILTERED! \\1] ";
// action
$text = preg_replace($search, $replace, $text);
return $text;
}
示例15: smarty_compiler_xoModuleIconsBookmarks
/**
* xoModuleIcons16 Smarty compiler plug-in
*
* @copyright XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @author Andricq Nicolas (AKA MusS)
* @since 2.5.2
*/
function smarty_compiler_xoModuleIconsBookmarks($argStr, &$smarty)
{
$xoops = Xoops::getInstance();
if (XoopsLoad::fileExists($xoops->path('media/xoops/images/icons/bookmarks/index.html'))) {
$url = $xoops->url('media/xoops/images/icons/bookmarks/' . $argStr);
} else {
if (XoopsLoad::fileExists($xoops->path('modules/system/images/icons/default/' . $argStr))) {
$url = $xoops->url('modules/system/images/icons/default/' . $argStr);
} else {
$url = $xoops->url('modules/system/images/icons/default/xoops/xoops.png');
}
}
return "\necho '" . addslashes($url) . "';";
}