function moduleversions() { $active = Config::getActiveModules(); $versions = array(); foreach ($active as $module) { $cur = Module::factory($module['module']); $versions[] = array('name' => $module['module'], 'version' => $cur->version); unset($cur); } return $versions; }
function adminMenu($params, &$smarty) { // Query for the items in reverse order to make it easier to build the menu string, since the last element // is not CSS classed. It is impossible to determine if the current element will be the last active module // providing an admin interface, so this is the best way to do it. //$activeModules = array_reverse(Config::getActiveModules()); $activeModules = Config::getActiveModules(); $adminItems = array('<li class="borderRight"><a href="/admin/">DASHBOARD</a></li>'); $i = 0; $thisUser = new User($_SESSION['authenticated_user']->getId()); foreach ($activeModules as $module) { if ($thisUser->hasPerm('admin') || $module['module'] == 'Campaigns') { $i++; // Use object reflection to reverse engineer the class functions $modulename = 'Module_' . $module['module']; include_once SITE_ROOT . '/modules/' . $module['module'] . '/' . $module['module'] . '.php'; $blah = new $modulename(); $test = new ReflectionClass($blah); // Determine if the current object provides and admin interface. Some modules may provide functionality // but not require a main admin interface, and instead accomplish their tasks with hooks or no interface // at all. if ($test->hasMethod('getAdminInterface')) { // If the array is empty push an un-classed array item onto the stack. If not, then push successive // array items with the required 'borderRight' class onto the stack. //if (count($adminItems) == 0) { // $adminItems = array('<li><a href="/admin/?module=' . $module['module'] . '">' . strtolower($module['module']) . '</a></li>'); //} else { // array_unshift($adminItems, '<li><a href="/admin/?module=' . $module['module'] . '">' . strtolower($module['module']) . '</a></li>'); //} if ($i != count($activeModules) && $module['module'] != 'Campaigns' || $module['module'] == 'Campaigns' && $i < 1) { $liClass = ' class="borderRight"'; } else { unset($liClass); } $adminItems[] = '<li' . $liClass . '><a href="/admin/' . $module['module'] . '">' . strtoupper($module['display_name']) . '</a></li>'; } } } $menuString = '<ul>'; $menuString .= implode(null, $adminItems); $menuString .= '</ul>'; return $menuString; }
/** * Load a set of language files * @param string * @param boolean * @param boolean */ protected function loadLanguageFile($strName, $strLanguage = false, $blnNoCache = false) { if (!$strLanguage) { $strLanguage = $GLOBALS['TL_LANGUAGE']; } // Return if the data has been loaded already if (!$blnNoCache && isset($GLOBALS['loadLanguageFile'][$strName][$strLanguage])) { return; } // Use a global cache variable to support nested calls $GLOBALS['loadLanguageFile'][$strName][$strLanguage] = true; // Parse all active modules foreach ($this->Config->getActiveModules() as $strModule) { $strFallback = sprintf('%s/system/modules/%s/languages/en/%s.php', TL_ROOT, $strModule, $strName); if (file_exists($strFallback)) { include $strFallback; } if ($strLanguage == 'en') { continue; } $strFile = sprintf('%s/system/modules/%s/languages/%s/%s.php', TL_ROOT, $strModule, $strLanguage, $strName); if (file_exists($strFile)) { include $strFile; } } // HOOK: allow to load custom labels if (isset($GLOBALS['TL_HOOKS']['loadLanguageFile']) && is_array($GLOBALS['TL_HOOKS']['loadLanguageFile'])) { foreach ($GLOBALS['TL_HOOKS']['loadLanguageFile'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($strName, $strLanguage); } } // Handle single quotes in the deleteConfirm message if ($strName == 'default') { $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] = str_replace("'", "\\'", $GLOBALS['TL_LANG']['MSC']['deleteConfirm']); } // Local configuration file if (file_exists(TL_ROOT . '/system/config/langconfig.php')) { include TL_ROOT . '/system/config/langconfig.php'; } }
public function getAddEditForm($target = '/admin/Menu') { require_once 'Menu.php'; if (isset($_REQUEST['id'])) { $item = new MenuItem($_REQUEST['id']); } $status = array('active' => 'Active', 'disabled' => 'Disabled'); $defaultValues['status'] = @array($item->status); $menu = new Menu(); $parent = $menu->toArray(); $defaultValues['parent'] = @array($item->parent); $form = new Form('menu_addedit', 'POST', $target, '', array('class' => 'admin')); if (@$item) { $form->setConstants(array('id' => $item->getId(), 'section' => 'addedit')); $form->addElement('hidden', 'id'); $links = $menu->getLinkables($item->module_id); } else { $form->setConstants(array('section' => 'addedit')); } $form->addElement('hidden', 'section'); $form->addElement('text', 'display', 'Display Name', array('value' => @$item->display)); $active = Config::getActiveModules(); $linkableType = array(); foreach ($active as $module) { $modulename = 'Module_' . $module['module']; include_once SITE_ROOT . '/modules/' . $module['module'] . '/' . $module['module'] . '.php'; $obj = new $modulename(); $test = new ReflectionClass($modulename); if ($test->hasMethod('getValidLinks')) { $linkableType[$module['id']] = $obj->linkType(); } } if (@(!$item)) { $keys = array_keys($linkableType); $links = $menu->getLinkables($keys[0]); } $defaultValues['link'] = @array($item->link_id); $defaultValues['linktype'] = @array($item->module_id); $defaultValues['target'] = @array($item->target); $form->addElement('select', 'status', 'Status', $status); $form->addElement('select', 'linktype', 'Link Type', $linkableType); $form->addElement('select', 'link', 'Link To', $links); $form->addElement('select', 'target', 'Open In', array('same' => 'Same Window', 'new' => 'New Window')); $form->addElement('select', 'parent', 'Parent Item', $parent); $form->addElement('submit', 'submit', 'Save'); $form->applyFilter('display', 'trim'); $form->addRule('display', 'Please enter a display name', 'required', null, 'client'); $form->addRule('parent', 'Please choose a parent', 'required', null, 'client'); $form->addRule('linktype', 'Please choose a link type', 'required', null, 'client'); $form->addRule('link', 'Please choose a link page', 'required', null, 'client'); $form->addRule('target', 'Please choose a target', 'required', null, 'client'); $form->addRule('status', 'Please choose a status', 'required', null, 'client'); $form->setDefaults($defaultValues); if (isset($_REQUEST['submit']) && $form->validate()) { $this->template = 'admin/menu.tpl'; $this->doMenuSubmit(); return false; } else { if (isset($_REQUEST['submit'])) { $formArray['errors'] = $form->_errors; } } return $form; }
/** * Add listeners, defined in each modules ../config/event_listeners.php file. * * @param EventDispatcherInterface $eventDispatcher The event dispatcher. * @param \Config $config The configuration object. * * @return static */ public function addSubscribersByModules(EventDispatcherInterface $eventDispatcher, \Config $config) { // include the module services configurations foreach ($config->getActiveModules() as $module) { $file = TL_ROOT . '/system/modules/' . $module . '/config/event_subscribers.php'; if (file_exists($file)) { $subscribers = (array) (include $file); $this->addSubscribers($eventDispatcher, $subscribers); } } // include the local services configuration $file = TL_ROOT . '/system/config/event_subscribers.php'; if (file_exists($file)) { $subscribers = (array) (include $file); $this->addSubscribers($eventDispatcher, $subscribers); } return $this; }