Exemplo n.º 1
0
 function __construct()
 {
     $this->_plugins = array();
     $this->_events = array();
     $this->_registry =& MymenusRegistry::getInstance();
     $this->setPlugins();
     $this->setEvents();
 }
Exemplo n.º 2
0
 function _doDecoration($string)
 {
     $registry =& MymenusRegistry::getInstance();
     if (!preg_match('/{(.*\\|.*)}/i', $string, $reg)) {
         return $string;
     }
     $expression = $reg[0];
     list($validator, $value) = array_map('strtolower', explode('|', $reg[1]));
     if ($validator == 'smarty') {
         if (isset($GLOBALS['xoopsTpl']->_tpl_vars[$value])) {
             $string = str_replace($expression, $GLOBALS['xoopsTpl']->_tpl_vars[$value], $string);
         }
     }
     return $string;
 }
Exemplo n.º 3
0
 function _doDecoration($string)
 {
     $registry =& MymenusRegistry::getInstance();
     if (!preg_match('/{(.*\\|.*)}/i', $string, $reg)) {
         return $string;
     }
     $expression = $reg[0];
     list($validator, $value) = array_map('strtoupper', explode('|', $reg[1]));
     if ($validator == 'CONSTANT') {
         if (defined($value)) {
             $string = str_replace($expression, constant($value), $string);
         }
     }
     return $string;
 }
Exemplo n.º 4
0
 function eventEnd()
 {
     $registry =& MymenusRegistry::getInstance();
     $menus = $registry->getEntry('menus');
     foreach ($menus as $menu) {
         if (!preg_match('/{(MODULE\\|.*)}/i', $menu['title'], $reg)) {
             $newmenus[] = $menu;
             continue;
         }
         $result = array_map('strtolower', explode('|', $reg[1]));
         $moduleMenus = self::_getModuleMenus($result[1], $menu['pid']);
         foreach ($moduleMenus as $mMenu) {
             $newmenus[] = $mMenu;
         }
     }
     $registry->setEntry('menus', $newmenus);
 }
Exemplo n.º 5
0
function mymenus_admin_form($id = null, $pid = null)
{
    global $menu_id;
    $registry =& MymenusRegistry::getInstance();
    $plugin =& MymenusPlugin::getInstance();
    $this_handler =& xoops_getModuleHandler('menu', 'mymenus');
    $objArray = array();
    if (isset($id)) {
        $ftitle = _EDIT;
        $obj = $this_handler->get($id);
        $objArray = $obj->getValues();
    } else {
        $ftitle = _ADD;
        $obj = $this_handler->create();
        $objArray = $obj->getValues();
        if (isset($pid)) {
            $objArray['pid'] = $pid;
        }
    }
    $form = new XoopsThemeForm($ftitle, 'admin_form', $GLOBALS['mymenus_adminpage'], "post", true);
    $formtitle = new XoopsFormText(_AM_MYMENUS_MENU_TITLE, 'title', 50, 255, $objArray['title']);
    $formalttitle = new XoopsFormText(_AM_MYMENUS_MENU_ALTTITLE, 'alt_title', 50, 255, $objArray['alt_title']);
    $formlink = new XoopsFormText(_AM_MYMENUS_MENU_LINK, 'link', 50, 255, $objArray['link']);
    /*$plugin->triggerEvent('FormLinkDescription');
      $formlink->setDescription($registry->getEntry('form_link_description'));  */
    $formimage = new XoopsFormText(_AM_MYMENUS_MENU_IMAGE, 'image', 50, 255, $objArray['image']);
    $criteria = new CriteriaCompo(new Criteria('mid', $menu_id));
    $criteria->add(new Criteria('id', $id, '<>'));
    // $criteria->add(new Criteria('pid', 0));
    $criteria->setSort('weight');
    $criteria->setOrder('ASC');
    $results = $this_handler->getAll($criteria, array('title', 'id', 'pid'));
    include_once $GLOBALS['xoops']->path('class/tree.php');
    $parent_tree = new XoopsObjectTree($results, 'id', 'pid');
    $parent_select = $parent_tree->makeSelBox('pid', 'title', '-- ', $objArray['pid'], true);
    $formparent = new XoopsFormLabel(_AM_MYMENUS_MENU_PARENT, $parent_select);
    $formvis = new XoopsFormSelect(_AM_MYMENUS_MENU_VISIBLE, "visible", $objArray['visible']);
    $formvis->addOption("0", _NO);
    $formvis->addOption("1", _YES);
    $formtarget = new XoopsFormSelect(_AM_MYMENUS_MENU_TARGET, "target", $objArray['target']);
    $formtarget->addOption("_self", _AM_MYMENUS_MENU_TARG_SELF);
    $formtarget->addOption("_blank", _AM_MYMENUS_MENU_TARG_BLANK);
    $formtarget->addOption("_parent", _AM_MYMENUS_MENU_TARG_PARENT);
    $formtarget->addOption("_top", _AM_MYMENUS_MENU_TARG_TOP);
    $formgroups = new XoopsFormSelectGroup(_AM_MYMENUS_MENU_GROUPS, "groups", true, $objArray['groups'], 5, true);
    $formgroups->setDescription(_AM_MYMENUS_MENU_GROUPS_HELP);
    //$formhooks = new XoopsFormTextArea(_AM_MYMENUS_MENU_HOOKS, "hooks", $objArray['hooks'], 7, 60);
    $formhooks = new XoopsFormSelect(_AM_MYMENUS_MENU_ACCESS_FILTER, "hooks", $objArray['hooks'], 5, true);
    $plugin->triggerEvent('AccessFilter');
    $results = $registry->getEntry('access_filter');
    if ($results) {
        foreach ($results as $result) {
            $formhooks->addOption($result['method'], $result['name']);
        }
    }
    $formcss = new XoopsFormText(_AM_MYMENUS_MENU_CSS, 'css', 50, 255, $objArray['css']);
    $form->addElement($formtitle, true);
    $form->addElement($formalttitle);
    $form->addElement($formlink);
    $form->addElement($formimage);
    $form->addElement($formparent);
    $form->addElement($formvis);
    $form->addElement($formtarget);
    $form->addElement($formgroups);
    $form->addElement($formhooks);
    $form->addElement($formcss);
    //$form->addElement($formhooks2);
    $tray = new XoopsFormElementTray('', '');
    $tray->addElement(new XoopsFormButton('', 'submit_button', _SUBMIT, 'submit'));
    $btn = new XoopsFormButton('', 'reset', _CANCEL, 'button');
    if (isset($id)) {
        $btn->setExtra('onclick="document.location.href=\'' . $GLOBALS['mymenus_adminpage'] . '?op=list&amp;menu_id=' . $menu_id . ' \'"');
    } else {
        $btn->setExtra('onclick="document.getElementById(\'addform\').style.display = \'none\'; return false;"');
    }
    $tray->addElement($btn);
    $form->addElement($tray);
    if (isset($id)) {
        $form->addElement(new XoopsFormHidden('op', 'editok'));
        $form->addElement(new XoopsFormHidden('id', $id));
    } else {
        $form->addElement(new XoopsFormHidden('op', 'add'));
    }
    $form->addElement(new XoopsFormHidden('mid', $menu_id));
    return $form->render();
}
Exemplo n.º 6
0
 function getExtraValue($type = 'user', $value)
 {
     $registry =& MymenusRegistry::getInstance();
     $ret = 0;
     $values = array('pm_new', 'pm_readed', 'pm_total');
     if (!in_array($value, $values)) {
         return $ret;
     }
     $entry = $registry->getEntry($type);
     if (empty($entry)) {
         return $ret;
     }
     $pm_handler =& xoops_gethandler('privmessage');
     if ($value == 'pm_new') {
         $criteria = new CriteriaCompo(new Criteria('read_msg', 0));
         $criteria->add(new Criteria('to_userid', $entry['uid']));
     }
     if ($value == 'pm_readed') {
         $criteria = new CriteriaCompo(new Criteria('read_msg', 1));
         $criteria->add(new Criteria('to_userid', $entry['uid']));
     }
     if ($value == 'pm_total') {
         $criteria = new Criteria('to_userid', $entry['uid']);
     }
     $entry[$value] = $pm_handler->getCount($criteria);
     $registry->setEntry($type, $entry);
     unset($criteria);
     return $entry[$value];
 }
Exemplo n.º 7
0
function mymenus_block_show($options)
{
    $block = array();
    global $xoopsTpl, $xoTheme, $xoopsUser, $xoopsConfig, $xoopsLogger;
    $xoopsLogger->startTime('My Menus Block');
    $myts =& MyTextSanitizer::getInstance();
    include_once $GLOBALS['xoops']->path('modules/mymenus/include/functions.php');
    include_once $GLOBALS['xoops']->path('modules/mymenus/class/registry.php');
    include_once $GLOBALS['xoops']->path('modules/mymenus/class/plugin.php');
    include_once $GLOBALS['xoops']->path('modules/mymenus/class/builder.php');
    $registry =& MymenusRegistry::getInstance();
    $plugin =& MymenusPlugin::getInstance();
    $plugin->triggerEvent('Boot');
    $menu_id = $options[0];
    $this_handler =& xoops_getModuleHandler('menu', 'mymenus');
    $criteria = new CriteriaCompo(new Criteria('mid', $menu_id));
    $criteria->setSort('weight');
    $criteria->setOrder('ASC');
    //get menus as an array with ids as keys
    $menus = $this_handler->getAll($criteria, null, false, false);
    unset($criteria);
    foreach ($menus as $key => $menu) {
        $registry->setEntry('menu', $menu);
        $registry->setEntry('has_access', 'yes');
        $plugin->triggerEvent('HasAccess');
        if ($registry->getEntry('has_access') == 'no') {
            unset($menus[$key]);
        }
    }
    $count = count($menus);
    if ($count == 0) {
        return $block;
    }
    foreach ($menus as $key => $menu) {
        $registry->setEntry('link_array', $menu);
        $plugin->triggerEvent('TitleDecoration');
        $plugin->triggerEvent('AlttitleDecoration');
        $plugin->triggerEvent('LinkDecoration');
        $plugin->triggerEvent('ImageDecoration');
        $menus[$key] = $registry->getEntry('link_array');
    }
    $registry->setEntry('menus', $menus);
    $plugin->triggerEvent('End');
    $menus = $registry->getEntry('menus');
    $builder = new MymenusBuilder($menus);
    $block = $builder->render();
    /*--------------------------------------------------------------*/
    //default files to load
    $css = array();
    $js = array();
    //get extra files from skins
    $skin = $options[1];
    $skin_info = mymenus_getSkinInfo($skin, $options[2]);
    if (isset($skin_info['css'])) {
        $css = array_merge($css, $skin_info['css']);
    }
    if (isset($skin_info['js'])) {
        $js = array_merge($js, $skin_info['js']);
    }
    $config = mymenus_getModuleConfig();
    if ($config['assign_method'] == 'xoopstpl') {
        $tpl_vars = '';
        foreach ($css as $file) {
            $tpl_vars .= "\n" . '<link rel="stylesheet" type="text/css" media="all" href="' . $file . '" />';
        }
        foreach ($js as $file) {
            $tpl_vars .= "\n" . '<script type="text/javascript" src="' . $file . '"></script>';
        }
        if (isset($skin_info['header'])) {
            $tpl_vars .= "\n" . $skin_info['header'];
        }
        $xoopsTpl->assign('xoops_module_header', $tpl_vars . @$xoopsTpl->get_template_vars("xoops_module_header"));
    } else {
        foreach ($css as $file) {
            $xoTheme->addStylesheet($file);
        }
        foreach ($js as $file) {
            $xoTheme->addScript($file);
        }
        if (isset($skin_info['header'])) {
            $xoopsTpl->assign('xoops_footer', @$xoopsTpl->get_template_vars("xoops_footer") . "\n" . $skin_info['header']);
        }
    }
    $blockTpl = new XoopsTpl();
    $blockTpl->assign('block', $block);
    $blockTpl->assign('config', $skin_info['config']);
    $blockTpl->assign('skinurl', $skin_info['url']);
    $blockTpl->assign('skinpath', $skin_info['path']);
    $block['content'] = $blockTpl->fetch($skin_info['template']);
    if ($options[3] == 'template') {
        $xoopsTpl->assign('xoops_menu_' . $options[4], $block['content']);
        $block = array();
    }
    $registry->unsetAll();
    unset($registry, $plugin);
    $xoopsLogger->stopTime('My Menus Block');
    return $block;
}