Ejemplo n.º 1
0
 static function removeSection($id)
 {
     global $_struct;
     if ($sec = $_struct->getSection(ap::id($id))) {
         $modules = $sec->getModules();
         foreach ($modules as $m) {
             apModuleManager::removeModule($sec->getId(), $m->getId());
         }
         ap::getClientstructure()->removeSection($sec->getId(), true);
         ap::getClientstructure()->save();
         $sec->remove(true);
     }
 }
Ejemplo n.º 2
0
 static function addModule($sec_id, $module = null, $title = "", $readonly = false)
 {
     global $_struct;
     if (!$module) {
         $module = 'apContent';
     }
     $sec_id = ap::id($sec_id);
     if (($info = apModuleManager::getModuleInfo($module)) && ($sec = $_struct->getSection($sec_id)) && ($modules = $sec->getModules()) && ($m = $modules->add($module, $title ? $title : @$info['name']))) {
         if ($readonly) {
             $m->getRootElement()->setAttribute('readonly', 'readonly');
         }
         if (method_exists($m, 'install')) {
             if (!$m->install()) {
                 apModuleManager::removeModule($sec_id, $m->getId());
             }
         }
         $modules->getXML()->save();
         return $m;
     }
     return false;
 }
Ejemplo n.º 3
0
 function onSectionReady($params = null)
 {
     global $_sec, $_out;
     $modules = $_sec->getModules();
     if (!$modules->getNum() && $_sec->isChildOf('apData')) {
         if (apModuleManager::addModule($_sec->getId(), 'apContent', $_sec->getTitle())) {
             header('Location: ' . $_SERVER['REQUEST_URI']);
             die;
         } else {
             throw new Exception('apContent install error', EXCEPTION_XML);
         }
     }
     if ($_sec->getId() == 'apStruct') {
         if (!$modules->hasModule('apSectionAdd')) {
             $modules->add('apSectionAdd', t('Add section'));
         }
     }
     if ($_sec->isChildOf('apStruct')) {
         if (!$modules->hasModule('apSectionEdit')) {
             $modules->add('apSectionEdit', t('Properties'));
         }
         if (!$modules->hasModule('apModuleManager')) {
             $modules->add('apModuleManager', t('Modules'));
         }
         if (!$modules->hasModule('apTemplateManager')) {
             $modules->add('apTemplateManager', t('Templates'));
         }
         if (!$modules->hasModule('apSectionAdd')) {
             $modules->add('apSectionAdd', t('Add section'));
         }
     }
     foreach ($modules as $id => $m) {
         $title = $m->getTitle();
         if (!$title) {
             continue;
         }
         ap::addTab($m->getId(), $title, ap::isCurrentModule($m->getId()));
     }
     if ($e = $_out->query('/page/section')->item(0)) {
         $e->setAttribute('module', ap::getCurrentModule()->getId());
     }
 }