Beispiel #1
0
 /**
  * @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];
 }
 /**
  * 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');
 }
Beispiel #3
0
/**
 * 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);
}
Beispiel #4
0
 /**
  * __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']);
 }
Beispiel #5
0
 /**
  * @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];
 }
 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');
 }
Beispiel #7
0
 /**
  * @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('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . _AM_MAINTENANCE_OR . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', '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"));
 }
Beispiel #8
0
 /**
  * @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('', '&nbsp;');
     $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);
 }
Beispiel #9
0
 public function test_loadMailerLocale()
 {
     $class = $this->myClass;
     $x = $class::loadMailerLocale();
     $this->assertSame(true, $x);
     $map = XoopsLoad::getMap();
     $this->assertTrue(isset($map['xoopsmailerlocale']));
 }
Beispiel #10
0
 /**
  * @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;
 }
Beispiel #11
0
 /**
  * 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');
 }
 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);
 }
Beispiel #13
0
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;
}
Beispiel #14
0
 /**
  * @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;
 }
/**
 * 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) . "';";
}
Beispiel #16
0
 public function test_translateTheme()
 {
     $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'));
     }
     $class = $this->myClass;
     $key = 'key';
     $x = $class::translateTheme($key);
     $this->assertSame($key, $x);
 }
Beispiel #17
0
 function XoopsGTicket()
 {
     $xoops = Xoops::getInstance();
     $language = $xoops->getConfig('language');
     // language file
     if ($language && !strstr($language, '/')) {
         if (XoopsLoad::fileExists(dirname(__DIR__) . '/language/' . $language . '/gticket_messages.phtml')) {
             include dirname(__DIR__) . '/language/' . $language . '/gticket_messages.phtml';
         }
     }
     // default messages
     if (empty($this->messages)) {
         $this->messages = array('err_general' => 'GTicket Error', 'err_nostubs' => 'No stubs found', 'err_noticket' => 'No ticket found', 'err_nopair' => 'No valid ticket-stub pair found', 'err_timeout' => 'Time out', 'err_areaorref' => 'Invalid area or referer', 'fmt_prompt4repost' => 'error(s) found:<br /><span style="background-color:red;font-weight:bold;color:white;">%s</span><br />Confirm it.<br />And do you want to post again?', 'btn_repost' => 'repost');
     }
 }
/**
 * xoModuleIcons16 Smarty compiler plug-in
 *
 * @copyright   XOOPS Project (http://xoops.org)
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
 * @author        Andricq Nicolas (AKA MusS)
 * @since       2.5.2
 * @version        $Id$
 */
function smarty_compiler_xoModuleIcons16($params, Smarty $smarty)
{
    $xoops = Xoops::getInstance();
    $arg = reset($params);
    $ico = trim($arg, " '\"\t\n\r\v");
    if (XoopsLoad::fileExists($xoops->path('media/xoops/images/icons/16/index.html'))) {
        $url = $xoops->url('media/xoops/images/icons/16/' . $ico);
    } else {
        if (XoopsLoad::fileExists($xoops->path('modules/system/images/icons/default/' . $ico))) {
            $url = $xoops->url('modules/system/images/icons/default/' . $ico);
        } else {
            $url = $xoops->url('modules/system/images/icons/default/xoops/xoops2.png');
        }
    }
    return "<?php echo '" . addslashes($url) . "'; ?>";
}
/**
 * xoAdminNav Smarty compiler plug-in
 *
 * @copyright   XOOPS Project (http://xoops.org)
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
 * @author        Andricq Nicolas (AKA MusS)
 * @since       2.5
 * @version        $Id$
 */
function smarty_compiler_xoAdminNav($argStr, &$smarty)
{
    $xoops = Xoops::getInstance();
    $icons = $xoops->getModuleConfig('typebreadcrumb', 'system');
    if ($icons == '') {
        $icons = 'default';
    }
    $url = '';
    if (XoopsLoad::fileExists($xoops->path('modules/system/images/breadcrumb/' . $icons . '/index.html'))) {
        $url = $xoops->url('modules/system/images/breadcrumb/' . $icons . '/' . $argStr);
    } else {
        if (XoopsLoad::fileExists($xoops->path('modules/system/images/breadcrumb/default/' . $argStr))) {
            $url = $xoops->url('modules/system/images/icons/default/' . $argStr);
        }
    }
    return "\necho '" . addslashes($url) . "';";
}
Beispiel #20
0
 /**
  * build a module handler for legacy module
  *
  * @param FactorySpec $spec specification for requested handler
  *
  * @return XoopsObjectHandler|null
  */
 public function build(FactorySpec $spec)
 {
     $handler = null;
     $name = strtolower($spec->getName());
     $dirname = strtolower($spec->getDirname());
     $handlerFile = \XoopsBaseConfig::get('root-path') . "/modules/{$dirname}/class/{$name}.php";
     if (\XoopsLoad::fileExists($handlerFile)) {
         include_once $handlerFile;
     }
     $class = ucfirst($dirname) . ucfirst($name) . 'Handler';
     if (class_exists($class, false)) {
         $handler = new $class($spec->getFactory()->db());
     }
     if ($handler === null) {
         if (false === $spec->getOptional()) {
             throw new NoHandlerException(sprintf('Class not found %s', $class));
         }
     }
     return $handler;
 }
/**
 * xoAdminIcons Smarty compiler plug-in
 *
 * @copyright   XOOPS Project (http://xoops.org)
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
 * @author        Andricq Nicolas (AKA MusS)
 * @since       2.5
 * @version        $Id$
 */
function smarty_compiler_xoAdminIcons($params, Smarty $smarty)
{
    $xoops = Xoops::getInstance();
    $arg = reset($params);
    $ico = trim($arg, " '\"\t\n\r\v");
    $icons = $xoops->getModuleConfig('typeicons', 'system');
    if ($icons == '') {
        $icons = 'default';
    }
    if (XoopsLoad::fileExists($xoops->path('modules/system/images/icons/' . $icons . '/index.html'))) {
        $url = $xoops->url('modules/system/images/icons/' . $icons . '/' . $ico);
    } else {
        if (XoopsLoad::fileExists($xoops->path('modules/system/images/icons/default/' . $ico))) {
            $url = $xoops->url('modules/system/images/icons/default/' . $ico);
        } else {
            $url = $xoops->url('modules/system/images/icons/default/xoops/xoops.png');
        }
    }
    return "<?php echo '" . addslashes($url) . "'; ?>";
}
Beispiel #22
0
/**
 * Blocks functions
 *
 * @copyright   XOOPS Project (http://xoops.org)
 * @license     GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @author      Kazumi Ono (AKA onokazu)
 * @package     system
 * @version     $Id$
 */
function b_system_main_show()
{
    $xoops = Xoops::getInstance();
    $block = array();
    $block['lang_home'] = XoopsLocale::HOME;
    $block['lang_close'] = XoopsLocale::A_CLOSE;
    $module_handler = $xoops->getHandlerModule();
    $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
    $criteria->add(new Criteria('isactive', 1));
    $criteria->add(new Criteria('weight', 0, '>'));
    $modules = $module_handler->getObjectsArray($criteria, true);
    $moduleperm_handler = $xoops->getHandlerGroupperm();
    $groups = $xoops->getUserGroups();
    $read_allowed = $moduleperm_handler->getItemIds('module_read', $groups);
    /* @var $module XoopsModule */
    foreach ($modules as $i => $module) {
        if (in_array($i, $read_allowed)) {
            $block['modules'][$i]['name'] = $module->getVar('name');
            $block['modules'][$i]['dirname'] = $module->getVar('dirname');
            if (XoopsLoad::fileExists($xoops->path('modules/' . $module->getVar('dirname') . '/icons/logo_small.png'))) {
                $block['modules'][$i]['image'] = $xoops->url('modules/' . $module->getVar('dirname') . '/icons/logo_small.png');
            }
            if ($xoops->isModule() && $i == $xoops->module->getVar('mid')) {
                $block['modules'][$i]['highlight'] = true;
                $block['nothome'] = true;
            }
            if ($xoops->module && $i == $xoops->module->getVar('mid')) {
                $block['modules'][$i]['highlight'] = true;
                $block['nothome'] = true;
            }
            /* @var $plugin MenusPluginInterface */
            if ($xoops->isModule() && $module->getVar('dirname') == $xoops->module->getVar('dirname') && ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'menus'))) {
                $sublinks = $plugin->subMenus();
                foreach ($sublinks as $sublink) {
                    $block['modules'][$i]['sublinks'][] = array('name' => $sublink['name'], 'url' => \XoopsBaseConfig::get('url') . '/modules/' . $module->getVar('dirname') . '/' . $sublink['url']);
                }
            }
        }
    }
    return $block;
}
 /**
  * execute the command
  *
  * @param InputInterface  $input  input handler
  * @param OutputInterface $output output handler
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // install the 'system' module
     $xoops = \Xoops::getInstance();
     $module = 'system';
     $output->writeln(sprintf('Installing %s', $module));
     if (false !== $xoops->getModuleByDirname($module)) {
         $output->writeln(sprintf('<error>%s module is alreay 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 module failed!</error>', $module));
     } else {
         $output->writeln(sprintf('<info>Install of %s module completed.</info>', $module));
     }
     $xoops->cache()->delete('system');
     // add an admin user
     $adminname = 'admin';
     $adminpass = password_hash($adminname, PASSWORD_DEFAULT);
     // user: admin pass: admin
     $regdate = time();
     $result = $xoops->db()->insertPrefix('system_user', array('uname' => $adminname, 'email' => 'nobody@localhost', 'user_regdate' => $regdate, 'user_viewemail' => 1, 'pass' => $adminpass, 'rank' => 7, 'level' => 5, 'last_login' => $regdate));
     $output->writeln(sprintf('<info>Inserted %d user.</info>', $result));
 }
Beispiel #24
0
 /**
  * system.preferences.save
  *
  * @param mixed $args arguments supplied to triggerEvent
  *
  * @return void
  */
 public static function eventSystemPreferencesSave($args)
 {
     XoopsLoad::addMap(array('legacylogger' => dirname(__DIR__) . '/class/legacylogger.php'));
 }
Beispiel #25
0
 /**
  * add any module specific class map entries
  *
  * @param mixed $args not used
  *
  * @return void
  */
 public static function eventCoreIncludeCommonClassmaps($args)
 {
     $path = dirname(__DIR__);
     XoopsLoad::addMap(array('userconfigs' => $path . '/class/helper.php'));
 }
Beispiel #26
0
 /**
  * Render navigation to admin page
  *
  * @param string $menu current menu
  *
  * @return array
  */
 public function renderNavigation($menu = '')
 {
     $xoops = \Xoops::getInstance();
     $ret = array();
     $this->module->loadAdminMenu();
     foreach (array_keys($this->module->adminmenu) as $i) {
         if ($this->module->adminmenu[$i]['link'] == "admin/" . $menu) {
             if (\XoopsLoad::fileExists($xoops->path("/media/xoops/images/icons/32/" . $this->module->adminmenu[$i]['icon']))) {
                 $this->module->adminmenu[$i]['icon'] = $xoops->url("/media/xoops/images/icons/32/" . $this->module->adminmenu[$i]['icon']);
             } else {
                 $this->module->adminmenu[$i]['icon'] = $xoops->url("/modules/" . $xoops->module->dirname() . "/icons/32/" . $this->module->adminmenu[$i]['icon']);
             }
             $xoops->tpl()->assign('xo_sys_navigation', $this->module->adminmenu[$i]);
             $ret[] = $xoops->tpl()->fetch($this->getTplPath('nav'));
         }
     }
     return $ret;
 }
Beispiel #27
0
 /**
  * Clean up an input variable.
  *
  * @param mixed  $var  The input variable.
  * @param int    $mask Filter bit mask.
  *  - 1=no trim: If this flag is cleared and the input is a string,
  *    the string will have leading and trailing whitespace trimmed.
  *  - 2=allow_raw: If set, no more filtering is performed, higher bits are ignored.
  *  - 4=allow_html: HTML is allowed, but passed through a safe HTML filter first.
  *    If set, no more filtering is performed.
  *  - If no bits other than the 1 bit is set, a strict filter is applied.
  * @param string $type The variable type. See {@link XoopsFilterInput::clean()}.
  *
  * @return string
  */
 private static function cleanVar($var, $mask = 0, $type = null)
 {
     // Static input filters for specific settings
     static $noHtmlFilter = null;
     static $safeHtmlFilter = null;
     // If the no trim flag is not set, trim the variable
     if (!($mask & 1) && is_string($var)) {
         $var = trim($var);
     }
     // Now we handle input filtering
     if ($mask & 2) {
         // If the allow raw flag is set, do not modify the variable
     } else {
         XoopsLoad::load('xoopsfilterinput');
         if ($mask & 4) {
             // If the allow html flag is set, apply a safe html filter to the variable
             if (is_null($safeHtmlFilter)) {
                 $safeHtmlFilter = XoopsFilterInput::getInstance(null, null, 1, 1);
             }
             $var = $safeHtmlFilter->clean($var, $type);
         } else {
             // Since no allow flags were set, we will apply the most strict filter to the variable
             if (is_null($noHtmlFilter)) {
                 $noHtmlFilter = XoopsFilterInput::getInstance();
             }
             $var = $noHtmlFilter->clean($var, $type);
         }
     }
     return $var;
 }
Beispiel #28
0
 function loadConfig($data = null)
 {
     if (is_array($data)) {
         $configs = $data;
     } else {
         if (!empty($data)) {
             $dirname = $data;
         } elseif (is_object($GLOBALS['xoopsModule'])) {
             $dirname = $GLOBALS['xoopsModule']->getVar('dirname', 'n');
         } else {
             return false;
         }
         if (!($configs = @(include XOOPS_ROOT_PATH . "/modules/" . $dirname . "/include/autoload.php"))) {
             return false;
         }
     }
     return $configs = array_merge(XoopsLoad::loadCoreConfig(), $configs);
 }
Beispiel #29
0
function menus_block_edit($options)
{
    //Unique ID
    if (!$options[4] || isset($_GET['op']) && $_GET['op'] == 'clone') {
        $options[4] = uniqid();
    }
    $helper = Xoops::getModuleHelper('menus');
    $helper->loadLanguage('admin');
    $criteria = new CriteriaCompo();
    $criteria->setSort('title');
    $criteria->setOrder('ASC');
    $menus = $helper->getHandlerMenus()->getList($criteria);
    unset($criteria);
    if (count($menus) == 0) {
        $form = "<a href='" . $helper->url('admin/admin_menus.php') . "'>" . _AM_MENUS_MSG_NOMENUS . "</a>";
        return $form;
    }
    //Menu
    $form = new Xoops\Form\BlockForm();
    $element = new Xoops\Form\Select(_MB_MENUS_SELECT_MENU, 'options[0]', $options[0], 1);
    $element->addOptionArray($menus);
    $element->setDescription(_MB_MENUS_SELECT_MENU_DSC);
    $form->addElement($element);
    //Skin
    $temp_skins = XoopsLists::getDirListAsArray(\XoopsBaseConfig::get('root-path') . "/modules/menus/skins/", "");
    $skins_options = array();
    foreach ($temp_skins as $skin) {
        if (XoopsLoad::fileExists($helper->path('skins/' . $skin . '/skin_version.php'))) {
            $skins_options[$skin] = $skin;
        }
    }
    $element = new Xoops\Form\Select(_MB_MENUS_SELECT_SKIN, 'options[1]', $options[1], 1);
    $element->addOptionArray($skins_options);
    $element->setDescription(_MB_MENUS_SELECT_SKIN_DSC);
    $form->addElement($element);
    //Use skin from,theme
    $element = new Xoops\Form\RadioYesNo(_MB_MENUS_USE_THEME_SKIN, 'options[2]', $options[2]);
    $element->setDescription(_MB_MENUS_USE_THEME_SKIN_DSC);
    $form->addElement($element);
    //Display method
    $display_options = array('block' => _MB_MENUS_DISPLAY_METHOD_BLOCK, 'template' => _MB_MENUS_DISPLAY_METHOD_TEMPLATE);
    $element = new Xoops\Form\Select(_MB_MENUS_DISPLAY_METHOD, 'options[3]', $options[3], 1);
    $element->addOptionArray($display_options);
    $element->setDescription(sprintf(_MB_MENUS_DISPLAY_METHOD_DSC, $options[4]));
    $form->addElement($element);
    //Unique ID
    $element = new Xoops\Form\Text(_MB_MENUS_UNIQUEID, 'options[4]', 2, 20, $options[4]);
    $element->setDescription(_MB_MENUS_UNIQUEID_DSC);
    $form->addElement($element);
    return $form->render();
}
Beispiel #30
0
 $xoops->tpl()->assign('ignored_queries', $ignored_queries);
 $modules_result = array();
 foreach ($mids as $mid) {
     $mid = (int) $mid;
     /* @var $module XoopsModule */
     $module = $modules[$mid];
     /* @var $plugin SearchPluginInterface */
     $plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'search');
     $results = $plugin->search($queries, $andor, 5, 0, null);
     $count = count($results);
     $mid = $module->getVar('mid');
     $res = array();
     if (is_array($results) && $count > 0) {
         $nomatch = false;
         $modules_result[$mid]['name'] = $module->getVar('name');
         if (XoopsLoad::fileExists($image = $xoops->path('modules/' . $module->getVar('dirname') . '/icons/logo_large.png'))) {
             $modules_result[$mid]['image'] = $xoops->url($image);
         } else {
             $modules_result[$mid]['image'] = $xoops->url('images/icons/posticon2.gif');
         }
         $res = array();
         for ($i = 0; $i < $count; ++$i) {
             if (!preg_match("/^http[s]*:\\/\\//i", $results[$i]['link'])) {
                 $res[$i]['link'] = $xoops->url('modules/' . $module->getVar('dirname') . '/' . $results[$i]['link']);
             } else {
                 $res[$i]['link'] = $results[$i]['link'];
             }
             $res[$i]['title'] = $myts->htmlSpecialChars($results[$i]['title']);
             $res[$i]['title_highligh'] = preg_replace($queries_pattern, "<span class='searchHighlight'>\$1</span>", $myts->htmlSpecialChars($results[$i]['title']));
             if (!empty($results[$i]['uid'])) {
                 $res[$i]['uid'] = (int) $results[$i]['uid'];