exponent_forms_initialize();
 $form = new form();
 $policies = array();
 $_GET['m'] = preg_replace('/[^A-Za-z0-9_]/', '', $_GET['m']);
 $_GET['s'] = preg_replace('/[^A-Za-z0-9_]/', '', $_GET['s']);
 $assoc = $db->selectObject('approvalpolicyassociation', "module='" . $_GET['m'] . "' AND source='" . $_GET['s'] . "'");
 if (!$assoc) {
     $assoc = $db->selectObject('approvalpolicyassociation', "module='" . $_GET['m'] . "' AND is_global='1'");
 }
 if (!$assoc) {
     $assoc->policy_id = 0;
 }
 if (!defined('SYS_WORKFLOW')) {
     include_once BASE . 'subsystems/workflow.php';
 }
 if (exponent_workflow_moduleUsesDefaultPolicy($_GET['m'], $_GET['s'])) {
     $assoc->policy_id = 0;
 }
 foreach ($db->selectObjects('approvalpolicy') as $pol) {
     $policies[$pol->id] = $pol->name;
 }
 uasort($policies, 'strnatcasecmp');
 $realpol = array();
 $defaultpol = exponent_workflow_getDefaultPolicy($_GET['m']);
 if ($defaultpol) {
     $realpol = array(-1 => $i18n['no_policy'], 0 => sprintf($i18n['default_policy'], $defaultpol->name));
 } else {
     $realpol = array(-1 => $i18n['no_policy'], 0 => sprintf($i18n['default_policy'], $i18n['no_policy']));
 }
 foreach ($policies as $key => $name) {
     $realpol[$key] = $name;
 function show($view, $loc = null, $title = '')
 {
     $i18n = exponent_lang_loadFile('modules/ContainerModule/class.php');
     $source_select = array();
     $clickable_mods = null;
     // Show all
     $dest = null;
     $singleview = '_container';
     $singlemodule = 'ContainerModule';
     if (exponent_sessions_isset('source_select') && defined('SELECTOR')) {
         $source_select = exponent_sessions_get('source_select');
         $singleview = $source_select['view'];
         $singlemodule = $source_select['module'];
         $clickable_mods = $source_select['showmodules'];
         if (!is_array($clickable_mods)) {
             $clickable_mods = null;
         }
         $dest = $source_select['dest'];
     }
     global $db;
     $container = null;
     if (!isset($this) || !isset($this->_hasParent) || $this->_hasParent == 0) {
         // Top level container.
         $container = $db->selectObject('container', "external='" . serialize(null) . "' AND internal='" . serialize($loc) . "'");
         if ($container == null) {
             $container->external = serialize(null);
             $container->internal = serialize($loc);
             $container->view = $view;
             $container->title = $title;
             $container->id = $db->insertObject($container, 'container');
         }
         if (!defined('PREVIEW_READONLY') || defined('SELECTOR')) {
             $view = $container->view;
         }
         $title = $container->title;
     }
     $template = new template('ContainerModule', $view, $loc);
     if ($dest) {
         $template->assign('dest', $dest);
     }
     $template->assign('singleview', $singleview);
     $template->assign('singlemodule', $singlemodule);
     $template->assign('top', $container);
     $containers = array();
     $container_key = serialize($loc);
     if (!isset($_SESSION['containers_cache'][$container_key])) {
         foreach ($db->selectObjects('container', "external='" . serialize($loc) . "'") as $c) {
             if ($c->is_private == 0 || exponent_permissions_check('view', exponent_core_makeLocation($loc->mod, $loc->src, $c->id))) {
                 $containers[$c->rank] = $c;
             }
         }
         $_SESSION['containers_cache'][$container_key] = serialize($containers);
     } else {
         $containers = unserialize($_SESSION['containers_cache'][$container_key]);
     }
     if (!defined('SYS_WORKFLOW')) {
         include_once BASE . 'subsystems/workflow.php';
     }
     ksort($containers);
     foreach (array_keys($containers) as $i) {
         $location = unserialize($containers[$i]->internal);
         $modclass = $location->mod;
         if (class_exists($modclass)) {
             $mod = new $modclass();
             ob_start();
             $mod->_hasParent = 1;
             $mod->show($containers[$i]->view, $location, $containers[$i]->title);
             $containers[$i]->output = trim(ob_get_contents());
             ob_end_clean();
             $policy = exponent_workflow_getPolicy($modclass, $location->src);
             $containers[$i]->info = array('module' => $mod->name(), 'source' => $location->src, 'hasContent' => $mod->hasContent(), 'hasSources' => $mod->hasSources(), 'hasViews' => $mod->hasViews(), 'class' => $modclass, 'supportsWorkflow' => $mod->supportsWorkflow() ? 1 : 0, 'workflowPolicy' => $policy ? $policy->name : '', 'workflowUsesDefault' => exponent_workflow_moduleUsesDefaultPolicy($location->mod, $location->src) ? 1 : 0, 'clickable' => $clickable_mods == null || in_array($modclass, $clickable_mods));
         } else {
             $containers[$i]->output = sprintf($i18n['mod_not_found'], $location->mod);
             $containers[$i]->info = array('module' => sprintf($i18n['unknown'], $location->mod), 'source' => $location->src, 'hasContent' => 0, 'hasSources' => 0, 'hasViews' => 0, 'class' => $modclass, 'supportsWorkflow' => 0, 'workflowPolicy' => '', 'workflowUsesDefault' => 0, 'clickable' => 0);
         }
         $containers[$i]->moduleLocation = $location;
         $cloc = null;
         $cloc->mod = $loc->mod;
         $cloc->src = $loc->src;
         $cloc->int = $containers[$i]->id;
         $containers[$i]->permissions = array('administrate' => exponent_permissions_check('administrate', $location) ? 1 : 0, 'configure' => exponent_permissions_check('configure', $location) ? 1 : 0);
     }
     $template->assign('containers', $containers);
     $template->assign('hasParent', isset($this) && isset($this->_hasParent) ? 1 : 0);
     $template->register_permissions(array('administrate', 'add_module', 'edit_module', 'delete_module', 'order_modules'), $loc);
     $template->output();
 }