示例#1
0
 function settings($action)
 {
     global $_out, $_struct;
     if (($xml = $this->getDataXML()) && ($e = $xml->getElementById('settings'))) {
         $form = new form($e);
         $form->replaceURI(array('MODULE' => $this->getId(), 'SECTION' => $this->getSection()->getId(), 'PATH_DATA_FILE_CLIENT' => ABS_PATH_DATA_CLIENT . ap::id($this->getSection()->getId()) . '.xml', 'PATH_DATA_FILE_AP' => ABS_PATH_DATA_AP . ap::id($this->getSection()->getId()) . '.xml'));
         if ($ff = $form->getField('section')) {
             apSectionEdit::seclist(ap::getClientstructure()->de(), $ff, $ar = array());
         }
         switch ($action) {
             case 'update':
             case 'apply_update':
                 $form->save($_REQUEST);
                 break;
             case 'edit':
                 if (($id = param('section')) && ($sec = $_struct->getSection($id)) && ($modules = $sec->getModules())) {
                     $xml = new xml(null, 'modules', false);
                     foreach ($modules as $m) {
                         $xml->de()->appendChild($xml->importNode($m->getRootElement(), false));
                     }
                     ap::ajaxResponse($xml);
                 }
                 break;
         }
         $form->load();
         $_out->addSectionContent($form->getRootElement());
         $this->addTemplate('tpl.xsl');
     }
 }
示例#2
0
 function run()
 {
     global $_out, $_sec;
     if (ap::isCurrentModule($this)) {
         ap::addMessage($this->getMessage());
         if ($form = $this->getForm()) {
             $form->replaceURI(array('ID' => $_sec->getId(), 'MD' => $this->getId(), 'PARENT' => $this->getSection()->GetParent()->getId()));
             switch ($action = param('action')) {
                 case 'save':
                     $values = $this->initImages($form, true);
                     $values = array_merge($_REQUEST, $values);
                     $form->save($values);
                     $this->updateImagesSize($form);
                     $this->redirect('save_ok');
                     break;
                 case 'fileinfo':
                     if (($path = urldecode(param('path'))) && ($f = ap::getFileInfo($_SERVER['DOCUMENT_ROOT'] . $path))) {
                         $f['path'] = $path;
                         $xml = new xml(null, 'file', false);
                         foreach ($f as $tagName => $value) {
                             $xml->de()->appendChild($xml->createElement($tagName, null, $value));
                         }
                         ap::ajaxResponse($xml);
                     }
                     vdump('Error file not found ' . $path);
                     break;
             }
             $this->initImages($form, false);
             $form->load();
             $_out->elementIncludeTo($form->getRootElement(), '/page/section');
         } else {
             throw new Exception('Form not found', EXCEPTION_XML);
         }
     }
 }
示例#3
0
 function run()
 {
     if (ap::isCurrentModule($this)) {
         switch ($this->getAction()) {
             case 'bannersize':
                 if (($path = urldecode(param('path'))) && is_file($path)) {
                     list($width, $height) = getimagesize($path);
                     $xml = new xml(null, 'size', false);
                     $xml->de()->setAttribute('width', $width);
                     $xml->de()->setAttribute('height', $height);
                     ap::ajaxResponse($xml);
                 }
                 vdump('Error file not found ' . $path);
                 break;
         }
     }
     parent::run();
 }
示例#4
0
 function run()
 {
     global $_out;
     if (ap::isCurrentModule($this)) {
         switch ($action = param('action')) {
             case 'fileinfo':
                 if (($path = urldecode(param('path'))) && ($f = $this->getFileInfo($_SERVER['DOCUMENT_ROOT'] . $path))) {
                     $f['path'] = $path;
                     $xml = new xml(null, 'file', false);
                     foreach ($f as $tagName => $value) {
                         $xml->de()->appendChild($xml->createElement($tagName, null, $value));
                     }
                     ap::ajaxResponse($xml);
                 }
                 vdump('Error file not found ' . $path);
                 break;
         }
         parent::run();
     }
 }
示例#5
0
 function run()
 {
     global $_out;
     if (ap::isCurrentModule($this)) {
         ap::addMessage($this->getMessage());
         switch ($action = param('action')) {
             case 'active':
                 if ($row = $this->getRow()) {
                     $mysql = new mysql();
                     $state = !(param('active') == 'on');
                     $res = $mysql->update($this->table, array('active' => $state ? '1' : '0'), '`id`=' . $row);
                     if (!$res) {
                         $state = !$state;
                     }
                     if (param('ajax')) {
                         ap::ajaxResponse($state ? 'on' : 'off');
                     } else {
                         $this->redirect('active_' . ($res ? 'ok' : 'fail'));
                     }
                 }
                 break;
             case 'move':
                 if (($row = $this->getRow()) && ($pos = param('pos')) && ($rl = $this->getList()) && $rl->moveRow($row, $pos)) {
                     $this->redirect('move_ok');
                 } else {
                     $this->redirect('move_fail');
                 }
                 break;
             case 'delete':
                 if ($this->onDelete($action)) {
                     $this->redirect('delete_ok');
                 } else {
                     $this->redirect('delete_fail');
                 }
                 break;
             case 'update':
             case 'apply_update':
                 if ($this->onUpdate($action)) {
                     $this->redirect('update_ok');
                 } else {
                     $this->redirect('update_fail');
                 }
                 break;
             case 'add':
             case 'apply_add':
                 if ($this->onAdd($action)) {
                     $this->redirect('add_ok');
                 } else {
                     $this->redirect('add_fail');
                 }
                 break;
             case 'edit':
                 if ($this->onEdit($action)) {
                     $_out->addSectionContent($this->getForm($action)->getRootElement());
                 }
                 break;
             case 'new':
                 if ($this->onNew($action)) {
                     $_out->addSectionContent($this->getForm($action)->getRootElement());
                 }
                 break;
             default:
                 if ($rl = $this->getList()) {
                     $rl->build();
                     $_out->addSectionContent($rl->getRootElement());
                 }
         }
     }
 }
示例#6
0
 function run()
 {
     global $_out;
     if (ap::isCurrentModule($this)) {
         $action = param('action');
         // управление текущими модулями
         $modules = $this->getModules();
         // все модули доступные для подключения
         $all_modules = $this->getModuleList();
         $form = $this->getForm($action);
         switch ($action) {
             case 'active':
                 if (($row = param('row')) && ($sec = $this->getDataSection()) && ($modules = $sec->getModules()) && ($module = $modules->getById($row)) && ($e = $module->getRootElement())) {
                     if (param('active') == 'on') {
                         $e->setAttribute('readonly', 'readonly');
                     } elseif ($e->hasAttribute('readonly')) {
                         $e->removeAttribute('readonly');
                     }
                     $modules->getXML()->save();
                     $state = !(param('active') == 'on');
                     if (param('ajax')) {
                         ap::ajaxResponse($state ? 'on' : 'off');
                     }
                 }
                 break;
             case 'move':
                 if (($row = param('row')) && ($pos = param('pos'))) {
                     $modules->move($row, $pos);
                     $modules->getXML()->save();
                 }
                 $this->redirect($action);
                 break;
             case 'delete':
                 if ($row = param('row')) {
                     apModuleManager::removeModule($this->getIdSection(), $row);
                 }
                 $this->redirect($action);
                 break;
             case 'add':
             case 'apply_add':
                 if ($m = apModuleManager::addModule($this->getIdSection(), param('name'), param('title'), param('readonly'))) {
                     $this->redirect($action, $m->getId());
                 } else {
                     throw new Exception('Error add module "' . $_REQUEST['name'] . '"');
                 }
                 break;
             case 'update':
             case 'apply_update':
             case 'edit':
                 if (($row = param('row')) && ($sec = $this->getDataSection()) && ($modules = $sec->getModules()) && ($module = $modules->getById($row)) && method_exists($module, 'settings')) {
                     $module->settings($action);
                 }
                 $this->redirect($action, $row);
                 break;
             case 'new':
                 $m = $modules->add('tests_module');
                 $form->replaceURI(array('ID' => $this->getIdSection(), 'MODULEID' => $m->getId(), 'PATH_DATA_FILE_CLIENT' => ABS_PATH_DATA_CLIENT . ap::id($this->getSection()->getId()) . '.xml', 'PATH_DATA_FILE_AP' => ABS_PATH_DATA_AP . ap::id($this->getSection()->getId()) . '.xml'));
                 $select = $form->getField('name');
                 foreach ($all_modules as $key => $module) {
                     $select->addOption($key, $module['name']);
                 }
                 $_out->elementIncludeTo($form->getRootElement(), '/page/section');
                 break;
             default:
                 if ($res = $this->getList()) {
                     $_out->addSectionContent($res);
                 }
         }
     }
 }
示例#7
0
 function onActive()
 {
     if (($row = $this->getRow()) && ($tl = $this->getTagList()) && ($e = $tl->get($row))) {
         if (param('active') == 'on') {
             $e->setAttribute('disabled', 'disabled');
         } elseif ($e->hasAttribute('disabled')) {
             $e->removeAttribute('disabled');
         }
         $tl->getXML()->save();
         if (param('ajax')) {
             ap::ajaxResponse($e->hasAttribute('disabled') ? 'off' : 'on');
         } else {
             return true;
         }
     }
 }
示例#8
0
 function run()
 {
     global $_out;
     if (ap::isCurrentModule($this)) {
         ap::addMessage($this->getMessage());
         $action = param('action');
         $users = new users();
         $form = $this->getForm($action);
         $row = $this->getRow();
         switch ($action) {
             case 'active':
                 if ($row && $users->userExists($row)) {
                     $usr = $users->getUser($row);
                     $usr->disable(param('active') == 'on');
                     if (param('ajax')) {
                         ap::ajaxResponse($usr->getDisabled() ? 'off' : 'on');
                     } else {
                         $this->redirect('active_ok');
                     }
                 }
                 break;
             case 'move':
                 if ($row && $users->userExists($row) && ($pos = param('pos')) > 0) {
                     $users->moveUser($users->getUser($row), $pos);
                     $this->redirect('move_ok');
                 } else {
                     $this->redirect('move_fail');
                 }
                 break;
             case 'delete':
                 if ($row && $users->userExists($row)) {
                     $users->removeUser(param('row'));
                     $this->redirect('delete_ok');
                 } else {
                     $this->redirect('delete_fail');
                 }
                 break;
             case 'update':
             case 'apply_update':
                 if ($row && $users->userExists($row)) {
                     $pos = $users->getPos($users->getUser($row)) + 1;
                     $form->replaceURI(array('POSITION' => $pos));
                     $form->save($_REQUEST);
                     $this->redirect('update_ok');
                 } else {
                     $this->redirect('update_fail');
                 }
                 break;
             case 'add':
             case 'apply_add':
                 if ($row && !$users->userExists($row)) {
                     $form->save($_REQUEST);
                     $this->redirect('add_ok');
                 } else {
                     $this->redirect('add_fail');
                 }
                 break;
             case 'edit':
                 $pos = $users->getPos($users->getUser($row)) + 1;
                 $form->replaceURI(array('POSITION' => $pos));
                 $form->load();
             case 'new':
                 $_out->elementIncludeTo($form->getRootElement(), '/page/section');
                 break;
             default:
                 if ($rl = $this->getList($users)) {
                     $_out->elementIncludeTo($rl->getRootElement(), '/page/section');
                 }
         }
     }
 }