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'); } }
function uninstall() { if ($sec = ap::getClientSection($this->getSection()->getId())) { $modules = $sec->getModules(); if ($modules->remove($this->getId())) { $modules->getXML()->save(); } return true; } }
function setAdditionalParams($arParams) { $ar = array(); if (is_array($arParams)) { foreach ($arParams as $name => $value) { $ar[] = urlencode($name) . '=' . urlencode($value); } $this->getRootElement()->setAttribute('additionalParams', implode('&', $ar)); $this->setFormAction(ap::getUrl($arParams)); } }
function run() { global $_out, $_sec; if (ap::isCurrentModule($this)) { if ($e = $_sec->getXML()->query('//form[@id="common_form"]')->item(0)) { $form = new form($e); if (param('action') == 'save') { $form->save($_REQUEST); } $form->load(); $_out->elementIncludeTo($form->getRootElement(), '/page/section'); } } }
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(); }
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); } }
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; } } }
function run() { global $_struct; header('Location: ' . ap::getUrl(array('id' => $_struct->getDefaultSectionId()))); die; }
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(); } }
static function addSection($id, $title, $section = null, $save = true) { global $_struct; if ($s = ap::getClientstructure()->addSection($id, $title, $section)) { if ($section instanceof section) { $section = $_struct->getElementById($section->getId()); } $_struct->addSection($id, $title, $section); } if ($save) { ap::getClientstructure()->save(); } return $s; }
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 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'); } } } }
function getTemplate() { $sec = ap::getClientSection($this->getIdSection()); return $sec->getTemplateList(); }
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()); } }
function getIdSection() { return ap::id($this->getSection()->getId()); }
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 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 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; } }
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(); } } } } }