function uninstall() { if ($sec = ap::getClientSection($this->getSection()->getId())) { $modules = $sec->getModules(); if ($modules->remove($this->getId())) { $modules->getXML()->save(); } return true; } }
function uninstall() { $mysql = new mysql(); if ($md = $this->getConf('module')) { $mysql->query('delete from `' . $mysql->getTableName($this->table) . '` where `section`="' . $this->getSection()->getID() . '" AND `module`="' . $md . '"'); } if ($sec = ap::getClientSection($this->getSection()->getId())) { $modules = $sec->getModules(); if ($modules->remove($this->getId())) { $modules->getXML()->save(); } return true; } }
function uninstall() { $mysql = new mysql(); $table = $this->table; if ($rs = $mysql->query('select * from `' . $mysql->getTableName($table) . '` where `section`="' . $this->getSection()->getID() . '" AND `module`="' . $this->getId() . '"')) { while ($r = mysql_fetch_array($rs)) { $this->deleteRow($r['id']); } } if ($sec = ap::getClientSection($this->getSection()->getId())) { $modules = $sec->getModules(); if ($modules->remove($this->getId())) { $modules->getXML()->save(); } return true; } }
function run() { global $_out, $_sec; if (ap::isCurrentModule($this)) { ap::addMessage($this->getMessage()); $action = param('action'); $nowId = $this->getSection()->getId(); $path = "//sec[@id='" . substr($nowId, 3) . "']"; $form = $this->getForm(); // если это корневой раздел то показываем форму по добавлению нового раздела switch ($action) { case 'ajax': if ($parent = param('parent')) { if (($sec_parent = ap::getClientSection($parent)) || $parent == 'apStruct') { header('Content-type: text/xml'); $xml = new xml(null, 'seclist', false); $res = ap::getClientstructure()->query($parent == 'apStruct' ? '/structure/sec' : '//sec[@id="' . $sec_parent->getId() . '"]/sec'); foreach ($res as $sec) { $xml->de()->appendChild($xml->createElement('sec', array('id' => $sec->getAttribute('id'), 'title' => $sec->getAttribute('title')))); } echo $xml; } die; } break; case 'remove': $struct = ap::getClientstructure(); $id = $this->getSection()->getParent()->getId(); apSectionEdit::removeSection($nowId); $this->redirect($action, $id); break; case 'save': $form->replaceURI(array('PATH' => $this->getQueryPath(), 'PATH_STRUCT_CLIENT' => ABS_PATH_STRUCT_CLIENT)); // сохранение атрибутов $form->save($_REQUEST); // перенос элемента со сменой родителя и порядка $struct = ap::getClientstructure(false); if ($id = ap::getClientSection(param('id_sec'))->getId()) { if (!($parent = $struct->query('/structure//sec[@id="' . param('parent') . '"]')->item(0))) { $parent = $struct->query('/structure')->item(0); } if ($parent) { $sec = $struct->query('/structure//sec[@id="' . $id . '"]')->item(0); $sec = $sec->parentNode->removeChild($sec); if (($pos = param('position')) && ($before = $struct->query('/structure//sec[@id="' . $pos . '"]')->item(0))) { $parent->insertBefore($sec, $before); } else { $parent->appendChild($sec); } $struct->save(); } } $this->redirect($action, param('id_sec')); break; case 'newtpl': if (apSectionTemplate::createPackage(ap::id($this->getSection()->getId()), param('title'))) { $this->redirect('newtpl_ok'); } else { $this->redirect('newtpl_fail'); } break; default: $form->replaceURI(array('PATH' => $path, 'PATH_STRUCT_CLIENT' => ABS_PATH_STRUCT_CLIENT)); $form->getRootElement()->setAttribute('title', str_replace("%TITLE%", $_sec->getTitle(), $form->getRootElement()->getAttribute('title'))); //список разделов if (($ff = $form->getField('parent')) && ($s = ap::getClientstructure()->getSection(ap::id($nowId)))) { $ff->addOption('apStruct', 'Root'); $ar = array($s->getId()); $p = $s->getParent(); $this->seclist(ap::getClientstructure()->de(), $ff, $ar); $ff->setValue($p ? $p->getId() : 'apStruct'); } if ($ff = $form->getField('position')) { $ff->setValue(ap::id($nowId)); } if (!($nowId == 'apStruct')) { $form->load(); } $_sec->getTemplate()->addTemplate('../../modules/' . $this->getName() . '/template/sectionedit.xsl'); $_out->elementIncludeTo($form->getRootElement(), '/page/section'); break; } } }
function onAdd() { if (($id = param('alias')) && ($title = param('title')) && ($tpl = $this->evaluate('string(template/@id)')) && ($sec = apSectionAdd::addSection($id, $title, ap::getClientSection($this->getSection()->getId())))) { apSectionTemplate::applyTemplate($id, $tpl); param('row', $sec->getId()); return true; } }
function run() { global $_out, $_struct, $_sec; if (ap::isCurrentModule($this)) { ap::addMessage($this->getMessage()); $action = param('action'); $nowId = $this->getSection()->getId(); $form = $this->getForm(); //если это корневой раздел то показываем форму по добавлению нового раздела switch ($action) { case 'ajax': if ($parent = param('parent')) { if (($sec_parent = ap::getClientSection($parent)) || $parent == 'apStruct') { header('Content-type: text/xml'); $xml = new xml(null, 'seclist', false); $res = ap::getClientstructure()->query($parent == 'apStruct' ? '/structure/sec' : '//sec[@id="' . $sec_parent->getId() . '"]/sec'); foreach ($res as $sec) { $xml->de()->appendChild($xml->createElement('sec', array('id' => $sec->getAttribute('id'), 'title' => $sec->getAttribute('title')))); } echo $xml; } die; } if ($issetid = param('isset')) { echo ap::getClientSection($issetid) ? '0' : '1'; die; } break; case 'add': case 'apply': if (is_array($sec = param('sec')) && $sec['id']) { $form->replaceURI(array('PATH' => $this->getQueryPath(param('parent')), 'PATH_STRUCT_CLIENT' => ABS_PATH_STRUCT_CLIENT)); $form->save($_REQUEST); $_struct->addSection($sec['id'], $sec['title']); /* позиция */ if (($id_pos = param('position')) && ($struct = ap::getClientstructure(false))) { if (($sec_new = $struct->getSection($sec['id'])) && ($sec_pos = $struct->getSection($id_pos))) { $sec_pos->getElement()->parentNode->insertBefore($sec_new->getElement(), $sec_pos->getElement()); $struct->save(); } } /* установить выбранный шаблон раздела */ if ($tpl_id = param('template')) { apSectionTemplate::applyTemplate(ap::id($sec['id']), $tpl_id); } $this->redirect($action, $sec["id"]); } else { $this->redirect('fail'); } break; default: $form->replaceURI(array('PATH' => '', 'PATH_STRUCT_CLIENT' => ABS_PATH_STRUCT_CLIENT)); //список разделов if ($ff = $form->getField('parent')) { $s = ap::getClientstructure()->getSection(ap::id($nowId)); $ff->addOption('apStruct', 'Root'); $ar = array(); if ($s) { $p = $s->getParent(); } $this->seclist(ap::getClientstructure()->de(), $ff, $ar); $ff->setValue($p ? $p->getId() : 'apStruct'); } // список разделов шаблонов if (($ff = $form->getField('template')) && ($tl = apSectionTemplate::getPackages())) { if ($tl->getNum()) { foreach ($tl as $e) { $ff->addOption($e->getAttribute('id'), $e->getAttribute('title')); } } else { $ff->remove(); } } $_sec->getTemplate()->addTemplate('../../modules/' . $this->getName() . '/template/sectionadd.xsl'); $_out->elementIncludeTo($form->getRootElement(), '/page/section'); break; } } }
function uninstall() { if ($form = $this->getForm()) { //удаляем галерею $formFields = $form->getFields('@type="image"'); foreach ($formFields as $ff) { $formats = array(); $res = $ff->query('param'); foreach ($res as $param) { $formats[] = $param->parentNode->removeChild($param); } $scheme = new xmlScheme(); if (($n = $scheme->getNode($ff->getURI())) && $n instanceof DOMElement) { $tl = new taglist($n, 'img'); foreach ($tl as $img) { $fieldName = $ff->getName() . '_IMAGE_ID_' . $img->getAttribute('id'); foreach ($formats as $param) { $e = $ff->getRootElement()->appendChild($param->cloneNode(true)); $e->setAttribute('name', $fieldName); $e->setAttribute('uri', str_replace('%IMG_NAME%', $this->getGalleryImageName($img->getAttribute('id')), $e->getAttribute('uri'))); } } $ff->removeImageFiles(); $n->parentNode->removeChild($n); $tl->getXML()->save(); } } } if ($sec = ap::getClientSection($this->getSection()->getId())) { $modules = $sec->getModules(); if ($modules->remove($this->getId())) { $modules->getXML()->save(); } return true; } }
function getTemplate() { $sec = ap::getClientSection($this->getIdSection()); return $sec->getTemplateList(); }
static function applyTemplate($id_sec, $id_pckg) { global $_struct; $tl = apSectionTemplate::getPackages(); if (($tl = apSectionTemplate::getPackages()) && ($pckg = $tl->getById($id_pckg)) && ($apsec = $_struct->getSection($id_sec)) && ($clsec = ap::getClientSection($id_sec))) { if ($v = $pckg->getAttribute('class')) { $apsec->setClass($v); $clsec->setClass($v); $struct = new xml($clsec->getElement()); $struct->save(); } $ar = array('_ap' => $apsec->getXML(false), '_cl' => $clsec->getXML()); foreach ($ar as $attr => $xml) { if ($e = $tl->getXML()->query('section[@' . $attr . ']', $pckg)->item(0)) { $xml->removeChild(); if ($e = $xml->appendChild($xml->importNode($e))) { $e->removeAttribute($attr); $xml->save(); } } } } }