Example #1
0
 /**
  * Get a reference to the only instance of database class and connects to DB
  *
  * if the class has not been instantiated yet, this will also take
  * care of that
  *
  * Doctrine connection function
  *
  * NOTE: Persistance connection is not included. XOOPS_DB_PCONNECT is ignored.
  *       allowWebChanges also needs to be addressed
  *
  * @param array $options driverOptions for Doctrine
  *
  * @return Connection|null Reference to the only instance of database class
  *
  * @todo change driver to support other databases and support for port, unix_socket and driver options.
  */
 public static function getConnection($options = null)
 {
     static $instance;
     if (!isset($instance)) {
         $xoops = \Xoops::getInstance();
         $config = new \Doctrine\DBAL\Configuration();
         $config->setSQLLogger(new XoopsDebugStack());
         $parameters = \XoopsBaseConfig::get('db-parameters');
         if (!empty($parameters) && is_array($parameters)) {
             $connectionParams = $parameters;
             $connectionParams['wrapperClass'] = '\\Xoops\\Core\\Database\\Connection';
         } else {
             $driver = 'pdo_' . \XoopsBaseConfig::get('db-type');
             $connectionParams = array('dbname' => \XoopsBaseConfig::get('db-name'), 'user' => \XoopsBaseConfig::get('db-user'), 'password' => \XoopsBaseConfig::get('db-pass'), 'host' => \XoopsBaseConfig::get('db-host'), 'charset' => \XoopsBaseConfig::get('db-charset'), 'driver' => $driver, 'wrapperClass' => '\\Xoops\\Core\\Database\\Connection');
             // Support for other doctrine databases
             $xoops_db_port = \XoopsBaseConfig::get('db-port');
             if (!empty($xoops_db_port)) {
                 $connectionParams['port'] = $xoops_db_port;
             }
             $xoops_db_socket = \XoopsBaseConfig::get('db-socket');
             if (!empty($xoops_db_socket)) {
                 $connectionParams['unix_socket'] = $xoops_db_socket;
             }
             if (!is_null($options) && is_array($options)) {
                 $connectionParams['driverOptions'] = $options;
             }
         }
         $instance = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
     }
     return $instance;
 }
Example #2
0
 public function test_100()
 {
     global $config;
     $xoops_root_path = \XoopsBaseConfig::get('root-path');
     ob_start();
     require $xoops_root_path . '/class/textsanitizer/config.php';
     $x = ob_get_clean();
     $this->assertTrue(is_array($config));
     $this->assertTrue(isset($config['extensions']));
     if (isset($config['extensions'])) {
         $ext = $config['extensions'];
         $this->assertTrue(isset($ext['iframe']));
         $this->assertTrue(isset($ext['image']));
         $this->assertTrue(isset($ext['flash']));
         $this->assertTrue(isset($ext['youtube']));
         $this->assertTrue(isset($ext['mp3']));
         $this->assertTrue(isset($ext['wmp']));
         $this->assertTrue(isset($ext['wiki']));
         $this->assertTrue(isset($ext['mms']));
         $this->assertTrue(isset($ext['rtsp']));
         $this->assertTrue(isset($ext['soundcloud']));
         $this->assertTrue(isset($ext['ul']));
         $this->assertTrue(isset($ext['li']));
     }
     $this->assertTrue(isset($config['truncate_length']));
     $this->assertTrue(isset($config['filterxss_on_display']));
 }
 /**
  * @param integer $time
  */
 function getMd5($time = null)
 {
     if (empty($time)) {
         $time = time();
     }
     return md5(gmdate('YmdH', $time) . \XoopsBaseConfig::get('db-prefix') . \XoopsBaseConfig::get('db-name'));
 }
Example #4
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_topposters_show($options)
{
    $xoops = Xoops::getInstance();
    $block = array();
    $criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
    $limit = !empty($options[0]) ? $options[0] : 10;
    $size = count($options);
    for ($i = 2; $i < $size; ++$i) {
        $criteria->add(new Criteria('rank', $options[$i], '<>'));
    }
    $criteria->setOrder('DESC');
    $criteria->setSort('posts');
    $criteria->setLimit($limit);
    $member_handler = $xoops->getHandlerMember();
    $topposters = $member_handler->getUsers($criteria);
    $count = count($topposters);
    for ($i = 0; $i < $count; ++$i) {
        $block['users'][$i]['rank'] = $i + 1;
        if ($options[1] == 1) {
            $block['users'][$i]['avatar'] = $topposters[$i]->getVar('user_avatar') !== 'blank.gif' ? \XoopsBaseConfig::get('uploads-url') . '/' . $topposters[$i]->getVar('user_avatar') : '';
        } else {
            $block['users'][$i]['avatar'] = '';
        }
        $block['users'][$i]['id'] = $topposters[$i]->getVar('uid');
        $block['users'][$i]['name'] = $topposters[$i]->getVar('uname');
        $block['users'][$i]['posts'] = $topposters[$i]->getVar('posts');
    }
    return $block;
}
 public function test___construct()
 {
     $extension = new $this->myClass($this->ts);
     $this->assertInstanceOf($this->myClass, $extension);
     $this->assertEquals($this->ts, $extension->ts);
     $this->assertEquals(\XoopsBaseConfig::get('url') . '/images/form', $extension->image_path);
 }
Example #6
0
/**
 * page module
 *
 * @copyright       XOOPS Project (http://xoops.org)
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package         page
 * @since           2.6.0
 * @author          Mage Grégory (AKA Mage)
 * @version         $Id$
 */
function page_blocks_show($options)
{
    $xoops = \Xoops::getInstance();
    $page = $xoops->getModuleHelper('page');
    $xoops->theme()->addStylesheet($page->url('css/styles.css'));
    $xoops->theme()->addStylesheet($page->url('css/rating.css'));
    $block = '';
    if ($options[0] == 'id') {
        $view_content = $page->getContentHandler()->get($options[1]);
        // content
        $content = $view_content->getValues();
        foreach ($content as $k => $v) {
            $block[$k] = $v;
        }
        // related
        $block['related'] = $page->getLinkHandler()->menu_related($options[1]);
        // get vote by user
        $block['yourvote'] = $page->getRatingHandler()->getVotebyUser($options[1]);
        // get token for rating
        $block['security'] = $xoops->security()->createToken();
    } else {
        $block['text'] = $options[4];
        $block['mode'] = $options[0];
        if ($options[0] == 'random') {
            $sort = 'sqlite' == \XoopsBaseConfig::get('db-type') ? 'RANDOM()' : 'RAND()';
            $content = $page->getContentHandler()->getPagePublished(0, $options[3], $sort);
        } else {
            $content = $page->getContentHandler()->getPagePublished(0, $options[3], 'content_' . $options[1], $options[2]);
        }
        foreach (array_keys($content) as $i) {
            $block['content'][$i] = $content[$i]->getValues();
        }
    }
    return $block;
}
Example #7
0
 /**
  * Constructor
  *
  * @param string $caption      caption
  * @param string $name         element name
  * @param bool   $include_anon Include user "anonymous"?
  * @param mixed  $value        Pre-selected value (or array of them).
  *                             For an item with massive members, such as "Registered Users",
  *                             "$value" should be used to store selected temporary users only
  *                             instead of all members of that item
  * @param int    $size         Number or rows. "1" makes a drop-down-list.
  * @param bool   $multiple     Allow multiple selections?
  */
 public function __construct($caption, $name, $include_anon = false, $value = null, $size = 1, $multiple = false)
 {
     $xoops = \Xoops::getInstance();
     $limit = 200;
     $select_element = new Select('', $name, $value, $size, $multiple);
     if ($include_anon) {
         $select_element->addOption(0, $xoops->getConfig('anonymous'));
     }
     $member_handler = $xoops->getHandlerMember();
     $user_count = $member_handler->getUserCount();
     $value = is_array($value) ? $value : (empty($value) ? array() : array($value));
     if ($user_count > $limit && count($value) > 0) {
         $criteria = new CriteriaCompo(new Criteria('uid', '(' . implode(',', $value) . ')', 'IN'));
     } else {
         $criteria = new CriteriaCompo();
         $criteria->setLimit($limit);
     }
     $criteria->setSort('uname');
     $criteria->setOrder('ASC');
     $users = $member_handler->getUserList($criteria);
     $select_element->addOptionArray($users);
     if ($user_count <= $limit) {
         parent::__construct($caption, "", $name);
         $this->addElement($select_element);
         return;
     }
     $js_addusers = "<script type='text/javascript'>\n            function addusers(opts){\n                var num = opts.substring(0, opts.indexOf(':'));\n                opts = opts.substring(opts.indexOf(':')+1, opts.length);\n                var sel = xoopsGetElementById('" . $name . "');\n                var arr = new Array(num);\n                for (var n=0; n < num; n++) {\n                    var nm = opts.substring(0, opts.indexOf(':'));\n                    opts = opts.substring(opts.indexOf(':')+1, opts.length);\n                    var val = opts.substring(0, opts.indexOf(':'));\n                    opts = opts.substring(opts.indexOf(':')+1, opts.length);\n                    var txt = opts.substring(0, nm - val.length);\n                    opts = opts.substring(nm - val.length, opts.length);\n                    var added = false;\n                    for (var k = 0; k < sel.options.length; k++) {\n                        if(sel.options[k].value == val){\n                            added = true;\n                            break;\n                        }\n                    }\n                    if (added == false) {\n                        sel.options[k] = new Option(txt, val);\n                        sel.options[k].selected = true;\n                    }\n                }\n                return true;\n            }\n            </script>";
     $token = $xoops->security()->createToken();
     $action_tray = new ElementTray("", " | ");
     $action_tray->addElement(new Label('', '<a href="#" onclick="var sel = xoopsGetElementById(\'' . $name . '\');for (var i = sel.options.length-1; i >= 0; i--) {if (!sel.options[i].selected) ' . '{sel.options[i] = null;}}; return false;">' . \XoopsLocale::REMOVE_UNSELECTED_USERS . "</a>"));
     $action_tray->addElement(new Label('', '<a href="#" onclick="openWithSelfMain(\'' . \XoopsBaseConfig::get('url') . '/include/findusers.php?target=' . $name . '&amp;multiple=' . $multiple . '&amp;token=' . $token . '\', \'userselect\', 800, 600, null); return false;" >' . \XoopsLocale::SEARCH_USERS . "</a>" . $js_addusers));
     parent::__construct($caption, '<br /><br />', $name);
     $this->addElement($select_element);
     $this->addElement($action_tray);
 }
 public function test___construct()
 {
     $xoops_root_path = \XoopsBaseConfig::get('root-path');
     $dir = $xoops_root_path . '/modules/avatar';
     $instance = new $this->myClass($dir);
     $this->assertInstanceOf($this->myClass, $instance);
 }
Example #9
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"));
 }
Example #10
0
 /**
  * getUserRank - given user info return array of rank information for the user
  *
  * @param Response $response \Xoops\Core\Service\Response object
  * @param mixed    $userinfo Xoops\Core\Kernel\Handlers\XoopsUser object for user (preferred) or
  *                            array of user info,
  *                               'uid'   => (int) id of system user
  *                               'posts' => (int) contribution count associated with the user
  *                               'rank'  => (int) id of manually assigned rank, 0 if none assigned
  *
  * @return void - $response->value set to array of rank information
  *                    'title' => string that describes the rank
  *                    'image' => url of image associated with the rank
  */
 public function getUserRank(Response $response, $userinfo)
 {
     $uid = isset($userinfo['uid']) ? (int) $userinfo['uid'] : null;
     $posts = isset($userinfo['posts']) ? (int) $userinfo['posts'] : null;
     $rank = isset($userinfo['rank']) ? (int) $userinfo['rank'] : null;
     if ($uid === null || $posts === null || $rank === null) {
         $response->setSuccess(false)->addErrorMessage('User info is invalid');
         return;
     }
     $myts = \MyTextSanitizer::getInstance();
     $db = \Xoops::getInstance()->db();
     $qb = $db->createXoopsQueryBuilder();
     $eb = $qb->expr();
     $qb->select('r.rank_title AS title')->addSelect('r.rank_image AS image')->fromPrefix('userrank_rank', 'r');
     if ($rank != 0) {
         $qb->where($eb->eq('r.rank_id', ':rank'))->setParameter(':rank', $rank, \PDO::PARAM_INT);
     } else {
         $qb->where($eb->lte('r.rank_min', ':posts'))->andWhere($eb->gte('r.rank_max', ':posts'))->andWhere($eb->eq('r.rank_special', 0))->setParameter(':posts', $posts, \PDO::PARAM_INT);
     }
     $result = $qb->execute();
     $rank = $result->fetch(\PDO::FETCH_ASSOC);
     $rank['title'] = isset($rank['title']) ? $myts->htmlSpecialChars($rank['title']) : '';
     $rank['image'] = \XoopsBaseConfig::get('uploads-url') . (isset($rank['image']) ? '/' . $rank['image'] : '/blank.gif');
     $response->setValue($rank);
 }
Example #11
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']);
 }
Example #12
0
 /**
  * Instantiate the specified theme
  *
  * @param array $options options array
  *
  * @return XoopsTheme
  */
 public function createInstance($options = array())
 {
     $xoops = \Xoops::getInstance();
     // Grab the theme folder from request vars if present
     if (empty($options['folderName'])) {
         if (($req = @$_REQUEST['xoops_theme_select']) && $this->isThemeAllowed($req)) {
             $options['folderName'] = $req;
             if (isset($_SESSION) && $this->allowUserSelection) {
                 $_SESSION[$this->xoBundleIdentifier]['defaultTheme'] = $req;
             }
         } else {
             if (isset($_SESSION[$this->xoBundleIdentifier]['defaultTheme'])) {
                 $options['folderName'] = $_SESSION[$this->xoBundleIdentifier]['defaultTheme'];
             } else {
                 if (empty($options['folderName']) || !$this->isThemeAllowed($options['folderName'])) {
                     $options['folderName'] = $this->defaultTheme;
                 }
             }
         }
         $xoops->setConfig('theme_set', $options['folderName']);
     }
     $options['path'] = \XoopsBaseConfig::get('themes-path') . '/' . $options['folderName'];
     $inst = new XoopsTheme();
     foreach ($options as $k => $v) {
         $inst->{$k} = $v;
     }
     $inst->xoInit();
     return $inst;
 }
Example #13
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);
 }
Example #14
0
 public function test_100()
 {
     global $config;
     $xoops_root_path = \XoopsBaseConfig::get('root-path');
     require $xoops_root_path . '/class/captcha/config.text.php';
     $this->assertTrue(is_array($config));
     $this->assertTrue(isset($config['num_chars']));
 }
Example #15
0
 static function eventCoreClassModuleTextsanitizerSmiley($args)
 {
     $smileys = MyTextSanitizer::getInstance()->getSmileys();
     $message =& $args[0];
     foreach ($smileys as $smile) {
         $message = str_replace($smile['smiley_code'], '<img class="imgsmile" src="' . \XoopsBaseConfig::get('uploads-url') . '/' . htmlspecialchars($smile['smiley_url']) . '" alt="' . $smile['smiley_emotion'] . '" />', $message);
     }
 }
Example #16
0
 public function test_100()
 {
     $xoops_root_path = \XoopsBaseConfig::get('root-path');
     ob_start(array($this, 'output_callback'));
     // to catch output after ob_end_flush in Xoops::simpleFooter
     require_once $xoops_root_path . '/class/xoopseditor/tinymce/tiny_mce/plugins/xoops_quote/xoops_quote.php';
     $this->assertTrue(is_string($this->buffer));
 }
Example #17
0
 public function __construct()
 {
     $this->captchaHandler = XoopsCaptcha::getInstance();
     $this->config = $this->loadConfig();
     $this->plugin_List = $this->getPluginList();
     $this->plugin_config = $this->loadConfigPlugin();
     $this->xcaptcha_path_plugin = \XoopsBaseConfig::get('root-path') . '/modules/xcaptcha/plugins';
 }
 public function test_100()
 {
     $xoops_root_path = \XoopsBaseConfig::get('root-path');
     ob_start();
     require_once $xoops_root_path . '/class/xoopseditor/tinymce/include/xoops_xlanguage.php';
     $x = ob_end_clean();
     $this->assertTrue((bool) $x);
 }
Example #19
0
 /**
  * @param int $currentoption
  * @param string $breadcrumb
  * @return bool
  */
 function loadModuleAdminMenu($currentoption = -1, $breadcrumb = "")
 {
     $xoops = Xoops::getInstance();
     if (!($adminmenu = $xoops->module->getAdminMenu())) {
         return false;
     }
     $breadcrumb = empty($breadcrumb) ? $adminmenu[$currentoption]["title"] : $breadcrumb;
     $xoops_url = \XoopsBaseConfig::get('url');
     $module_link = $xoops_url . "/modules/" . $xoops->module->getVar("dirname") . "/";
     $image_link = $xoops_url . "/Frameworks/compat/include";
     $adminmenu_text = '
         <style type="text/css">
         <!--
         #buttontop { float: left; width: 100%; background: #e7e7e7; font-size: 93%; line-height: normal; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; margin: 0;}
         #buttonbar { float: left; width: 100%; background: #e7e7e7 url("' . $image_link . '/modadminbg.gif") repeat-x left bottom; font-size: 93%; line-height: normal; border-left: 1px solid black; border-right: 1px solid black; margin-bottom: 12px;}
         #buttonbar ul { margin: 0; margin-top: 15px; padding: 10px 10px 0; list-style: none; }
         #buttonbar li { display: inline; margin: 0; padding: 0; }
         #buttonbar a { float: left; background: url("' . $image_link . '/left_both.gif") no-repeat left top; margin: 0; padding: 0 0 0 9px; border-bottom: 1px solid #000; text-decoration: none; }
         #buttonbar a span { float: left; display: block; background: url("' . $image_link . '/right_both.gif") no-repeat right top; padding: 5px 15px 4px 6px; font-weight: bold; color: #765; }
         /* Commented Backslash Hack hides rule from IE5-Mac \\*/
         #buttonbar a span {float: none;}
         /* End IE5-Mac hack */
         #buttonbar a:hover span { color:#333; }
         #buttonbar .current a { background-position: 0 -150px; border-width: 0; }
         #buttonbar .current a span { background-position: 100% -150px; padding-bottom: 5px; color: #333; }
         #buttonbar a:hover { background-position: 0% -150px; }
         #buttonbar a:hover span { background-position: 100% -150px; }
         //-->
         </style>
         <div id="buttontop">
          <table style="width: 100%; padding: 0; " cellspacing="0">
              <tr>
                  <td style="width: 70%; font-size: 10px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;">
                      <a href="../index.php">' . $xoops->module->getVar("name") . '</a>
                  </td>
                  <td style="width: 30%; font-size: 10px; text-align: right; color: #2F5376; padding: 0 6px; line-height: 18px;">
                      <strong>' . $xoops->module->getVar("name") . '</strong>&nbsp;' . $breadcrumb . '
                  </td>
              </tr>
          </table>
         </div>
         <div id="buttonbar">
          <ul>
         ';
     foreach (array_keys($adminmenu) as $key) {
         $adminmenu_text .= ($currentoption == $key ? '<li class="current">' : '<li>') . '<a href="' . $module_link . $adminmenu[$key]["link"] . '"><span>' . $adminmenu[$key]["title"] . '</span></a></li>';
     }
     //todo, check this dependencies
     if ($xoops->module->getVar("hasconfig") || $xoops->module->getVar("hascomments") || $xoops->module->getVar("hasnotification")) {
         $adminmenu_text .= '<li><a href="' . $xoops_url . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $xoops->module->getVar("mid") . '"><span>' . XoopsLocale::PREFERENCES . '</span></a></li>';
     }
     $adminmenu_text .= '
  </ul>
 </div>
 <br style="clear:both;" />';
     echo $adminmenu_text;
     return true;
 }
Example #20
0
function b_system_info_edit($options)
{
    $block_form = new Xoops\Form\BlockForm();
    $block_form->addElement(new Xoops\Form\Text(SystemLocale::POPUP_WINDOW_WIDTH, 'options[0]', 1, 3, $options[0]), true);
    $block_form->addElement(new Xoops\Form\Text(SystemLocale::POPUP_WINDOW_HEIGHT, 'options[1]', 1, 3, $options[1]), true);
    $block_form->addElement(new Xoops\Form\Text(sprintf(SystemLocale::F_LOGO_IMAGE_FILE_IS_LOCATED_UNDER, \XoopsBaseConfig::get('url') . "/images/"), 'options[2]', 5, 100, $options[2]), true);
    $block_form->addElement(new Xoops\Form\RadioYesNo(SystemLocale::SHOW_ADMIN_GROUPS, 'options[3]', $options[3]));
    return $block_form->render();
}
Example #21
0
 public function test__construct()
 {
     if (!class_exists('XoopsCache', false)) {
         $xoops_root_path = \XoopsBaseConfig::get('root-path');
         require_once $xoops_root_path . '/class/cache/xoopscache.php';
     }
     $instance = new $this->myclass(null);
     $this->assertInstanceOf('\\Xoops\\Core\\Cache\\Legacy', $instance);
 }
Example #22
0
 /**
  * @param SmiliesSmiley|XoopsObject $obj
  */
 public function __construct(SmiliesSmiley $obj)
 {
     $xoops = Xoops::getInstance();
     if ($obj->isNew()) {
         $blank_img = 'blank.gif';
     } else {
         $blank_img = str_replace('smilies/', '', $obj->getVar('smiley_url', 'e'));
     }
     $title = $obj->isNew() ? sprintf(_AM_SMILIES_ADD) : sprintf(_AM_SMILIES_EDIT);
     parent::__construct($title, 'form', $xoops->getEnv('PHP_SELF'), 'post', true);
     $this->setExtra('enctype="multipart/form-data"');
     $this->addElement(new Xoops\Form\Text(_AM_SMILIES_CODE, 'smiley_code', 2, 25, $obj->getVar('smiley_code')), true);
     $this->addElement(new Xoops\Form\Text(_AM_SMILIES_DESCRIPTION, 'smiley_emotion', 4, 50, $obj->getVar('smiley_emotion')), true);
     $imgtray_img = new Xoops\Form\ElementTray(_AM_SMILIES_FILE, '<br />');
     $imgpath_img = sprintf(_AM_SMILIES_IMAGE_PATH, \XoopsBaseConfig::get('uploads-url') . '/smilies/');
     $imageselect_img = new Xoops\Form\Select($imgpath_img, 'smiley_url', $blank_img);
     $image_array_img = XoopsLists::getImgListAsArray(\XoopsBaseConfig::get('uploads-url') . '/smilies');
     $imageselect_img->addOptionArray($image_array_img);
     $imageselect_img->setExtra('onchange="showImgSelected(\'xo-smilies-img\', \'smiley_url\', \'smilies\', \'\', \'' . \XoopsBaseConfig::get('uploads-url') . '\' )"');
     $imgtray_img->addElement($imageselect_img, false);
     $imgtray_img->addElement(new Xoops\Form\Label('', "<br /><img src='" . \XoopsBaseConfig::get('uploads-url') . "/smilies/" . $blank_img . "' name='image_img' id='xo-smilies-img' alt=''>"));
     $fileseltray_img = new Xoops\Form\ElementTray('<br />', '<br /><br />');
     $fileseltray_img->addElement(new Xoops\Form\File(_AM_SMILIES_UPLOADS, 'smiley_url'), false);
     $fileseltray_img->addElement(new Xoops\Form\Label(''), false);
     $imgtray_img->addElement($fileseltray_img);
     $this->addElement($imgtray_img);
     $this->addElement(new Xoops\Form\RadioYesNo(_AM_SMILIES_OFF, 'smiley_display', $obj->getVar('smiley_display')));
     $this->addElement(new Xoops\Form\Hidden('smiley_id', $obj->getVar('smiley_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_smilies':
             $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 'smilies':
         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);
 }
Example #23
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_user_show()
{
    $xoops = Xoops::getInstance();
    if (!$xoops->isUser()) {
        return false;
    }
    $block = array();
    $block['modules'] = array();
    $plugins = \Xoops\Module\Plugin::getPlugins('system');
    $i = 0;
    /* @var $plugin SystemPluginInterface */
    foreach ($plugins as $dirname => $plugin) {
        $menu = $plugin->userMenus();
        if (is_array($menu) && !empty($menu)) {
            $block['modules'][$i]['name'] = $menu['name'];
            $block['modules'][$i]['link'] = $xoops->url('modules/' . $dirname . '/' . $menu['link']);
            $block['modules'][$i]['image'] = $menu['image'];
            $block['modules'][$i]['icon'] = 'icon-tags';
            $block['modules'][$i]['dirname'] = $dirname;
            //todo, remove this hardcoded call
            if ($xoops->isModule() && $xoops->module->getVar('dirname') == $dirname && ($plugin = \Xoops\Module\Plugin::getPlugin($dirname, 'menus'))) {
                if (method_exists($plugin, 'subMenus')) {
                    $sublinks = $plugin->subMenus();
                    foreach ($sublinks as $sublink) {
                        $block['modules'][$i]['sublinks'][] = array('name' => $sublink['name'], 'url' => \XoopsBaseConfig::get('url') . '/modules/' . $dirname . '/' . $sublink['url']);
                    }
                }
            }
            ++$i;
        }
    }
    // View Account
    array_unshift($block['modules'], array('name' => XoopsLocale::VIEW_ACCOUNT, 'link' => $xoops->url('userinfo.php?uid=' . $xoops->user->getVar('uid')), 'icon' => 'icon-user'));
    // Edit Account
    array_unshift($block['modules'], array('name' => XoopsLocale::EDIT_ACCOUNT, 'link' => $xoops->url('edituser.php'), 'icon' => 'icon-user'));
    // Administration Menu
    if ($xoops->isAdmin()) {
        array_unshift($block['modules'], array('name' => SystemLocale::ADMINISTRATION_MENU, 'link' => $xoops->url('admin.php'), 'rel' => 'external', 'icon' => 'icon-wrench'));
    }
    // Inbox
    $criteria = new CriteriaCompo(new Criteria('read_msg', 0));
    $criteria->add(new Criteria('to_userid', $xoops->user->getVar('uid')));
    $pm_handler = $xoops->getHandlerPrivateMessage();
    $xoops->preload()->triggerEvent('system.blocks.system_blocks.usershow', array(&$pm_handler));
    $name = XoopsLocale::INBOX;
    $class = '';
    if ($pm_count = $pm_handler->getCount($criteria)) {
        $name = XoopsLocale::INBOX . ' <strong>' . $pm_count . '</strong>';
        $class = 'highlight';
    }
    array_push($block['modules'], array('name' => $name, 'link' => $xoops->url('viewpmsg.php'), 'icon' => 'icon-envelope', 'class' => $class));
    // Logout
    array_push($block['modules'], array('name' => XoopsLocale::A_LOGOUT, 'link' => $xoops->url('user.php?op=logout'), 'icon' => 'icon-off'));
    $block['active_url'] = \Xoops\Core\HttpRequest::getInstance()->getUrl();
    return $block;
}
Example #24
0
 public function test_100()
 {
     global $config;
     $xoops_root_path = \XoopsBaseConfig::get('root-path');
     ob_start();
     require $xoops_root_path . '/class/textsanitizer/config.custom.php';
     $x = ob_get_clean();
     $this->assertTrue(is_array($config));
     $this->assertTrue(isset($config['filterxss_on_display']));
 }
Example #25
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');
 }
Example #26
0
 /**
  * Create an admin theme instance
  *
  * @param array $options theme options
  *
  * @return XoopsTheme
  */
 public function createInstance($options = array())
 {
     $options["plugins"] = array();
     $options['renderBanner'] = false;
     $inst = parent::createInstance($options);
     $inst->path = \XoopsBaseConfig::get('adminthemes-path') . '/' . $inst->folderName;
     $inst->url = \XoopsBaseConfig::get('adminthemes-url') . '/' . $inst->folderName;
     $inst->template->assign(array('theme_path' => $inst->path, 'theme_tpl' => $inst->path . '/xotpl', 'theme_url' => $inst->url, 'theme_img' => $inst->url . '/img', 'theme_icons' => $inst->url . '/icons', 'theme_css' => $inst->url . '/css', 'theme_js' => $inst->url . '/js', 'theme_lang' => $inst->url . '/language'));
     return $inst;
 }
Example #27
0
 public function test_prefix()
 {
     $class = $this->myclass;
     $x = $class::prefix('');
     $db_prefix = \XoopsBaseConfig::get('db-prefix');
     $this->assertSame($db_prefix, $x);
     $table = 'toto';
     $x = $class::prefix($table);
     $this->assertSame($db_prefix . '_' . $table, $x);
 }
Example #28
0
 public function test_100()
 {
     global $config;
     $xoops_root_path = \XoopsBaseConfig::get('root-path');
     ob_start();
     require $xoops_root_path . '/class/textsanitizer/flash/config.php';
     $x = ob_get_clean();
     $this->assertTrue(is_array($config));
     $this->assertTrue(isset($config['detect_dimension']));
 }
Example #29
0
/**
 * xoops_module_install_avatars - install supplement for avatars module
 *
 * @param object &$module module object
 *
 * @return boolean true on success
 */
function xoops_module_install_avatars(&$module)
{
    /* This is all upgrade related, not install.
           TODO: Add to upgrade script and remove from here
    
        global $xoopsDB;
        // delete avatar_allow_upload, avatar_width, avatar_height, avatar_maxsize and avatar_minposts
        $xoops = Xoops::getInstance();
        $sql = "DELETE FROM " . $xoopsDB->prefix("config") . " WHERE `conf_name` IN "
        . " ('avatar_allow_upload', 'avatar_width', 'avatar_height', 'avatar_maxsize', 'avatar_minposts') ";
        $xoopsDB->queryF($sql);
    
        $dbManager = new XoopsDatabaseManager();
        $map = array(
            'avatar_id'       => 'avatar_id',
            'avatar_file'     => 'avatar_file',
            'avatar_name'     => 'avatar_name',
            'avatar_mimetype' => 'avatar_mimetype',
            'avatar_created'  => 'avatar_created',
            'avatar_display'  => 'avatar_display',
            'avatar_weight'   => 'avatar_weight',
            'avatar_type'     => 'avatar_type',
        );
        $dbManager->copyFields($map, 'avatar', 'avatars_avatar', false);
    
        $map = array(
            'avatar_id' => 'avatar_id',
            'user_id'   => 'user_id',
        );
        $dbManager->copyFields($map, 'avatar_user_link', 'avatars_user_link', false);
        */
    $xoops_root_path = \XoopsBaseConfig::get('root-path');
    // create folder "avatars"
    $dir = $xoops_root_path . "/uploads/avatars";
    if (!is_dir($dir)) {
        mkdir($dir, 0777);
        chmod($dir, 0777);
    }
    //Copy index.html
    $file = $xoops_root_path . "/uploads/avatars/index.html";
    if (!is_file($file)) {
        copy($xoops_root_path . "/modules/avatars/images/index.html", $file);
    }
    //Copy blank.gif
    $file = $xoops_root_path . "/uploads/avatars/blank.gif";
    if (!is_file($file)) {
        copy($xoops_root_path . "/modules/avatars/images/blank.gif", $file);
    }
    //Copy .htaccess
    $file = $xoops_root_path . "/uploads/avatars/.htaccess";
    if (!is_file($file)) {
        copy($xoops_root_path . "/uploads/.htaccess", $file);
    }
    return true;
}
 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);
 }