function announce($tagname, $sort = null, $size = null, $parent = null) { global $_out; $xml = new xml(null, $tagname, false); $ns = $this->query('.//img'); if ($ns->length) { if ($sort == 'desc') { $c = 0; for ($i = $ns->length - 1; $i >= 0; $i--) { $xml->de()->appendChild($xml->importNode($ns->item($i))); $c++; if ($size && $c == $size) { break; } } } else { foreach ($ns as $i => $e) { if ($i == $size) { break; } $xml->de()->appendChild($xml->importNode($e)); } } $_out->xmlIncludeTo($xml, $parent); } }
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 getFormElement($id) { if ($e = $this->query('form' . ($id ? '[@id="' . $id . '"]' : null))->item(0)) { $xml = new xml(null, null, false); return $xml->appendChild($xml->importNode($e)); } }
function getSiteInfo() { $xml = new xml(); $xml->dd()->appendChild($xml->importNode($this->de())); $ns = $xml->query('/site/mysql | /site/users'); foreach ($ns as $n) { $n->parentNode->removeChild($n); } return $xml; }
function getForm($id, $isSettingsForm = false) { if (($xml = $this->getDataXML()) && ($e = $xml->query('//form[@id="' . $id . '"]')->item(0))) { $xml = new xml(null, null, false); $form = new form($xml->appendChild($xml->importNode($e))); $mysql = new mysql(); $sec = $this->getSection(); $form->replaceURI(array('TABLE' => $mysql->getTableName($this->table), 'MODULE' => $this->getId(), 'CONFIG_MODULE' => $this->getConf('module'), 'SECTION' => $sec->getId(), 'ROW' => $isSettingsForm ? null : $this->getRow(), 'PATH_DATA_FILE_CLIENT' => ABS_PATH_DATA_CLIENT . ap::id($sec->getId()) . '.xml', 'PATH_DATA_FILE_AP' => ABS_PATH_DATA_AP . ap::id($sec->getId()) . '.xml', 'PATH_SITE' => ABS_PATH_SITE)); return $form; } }
function deleteRow($row) { if ($row && ($rl = $this->getList())) { if (!is_array($row)) { $row = array($row); } $form = $this->getForm('edit'); foreach ($row as $id) { $xml = new xml(); $f = new formGallery($xml->appendChild($xml->importNode($form->getRootElement()->cloneNode(true)))); $f->replaceURI(array('ID' => $id, 'TABLE' => $rl->getTableName(), 'SECTION' => $this->getSection()->getId())); $f->deleteImages($id); $rl->deleteRow($id); } return true; } }
static function setImages($e, $img, $singleOnly = false) { if ($e && is_array($img) && ($id = $e->getAttribute('id')) && isset($img[$id]) && is_array($img[$id])) { $xml = new xml($e); foreach ($img[$id] as $i) { if (isset($i['img'])) { $pic = $e->appendChild($xml->importNode($i['img'], true)); if (isset($i['prv'])) { $pic->appendChild($xml->importNode($i['prv'], true)); } } elseif (isset($i['prv'])) { $e->appendChild($xml->importNode($i['prv'], true)); } if ($singleOnly) { break; } } } }
function elementIncludeTo($elem, $cont) { if (is_string($cont)) { $cont = $this->query($cont)->item(0); } if (is_object($elem) && is_object($cont) && $elem instanceof DOMElement && $cont instanceof DOMElement) { $xml = new xml($cont); return $cont->appendChild($xml->importNode($elem, true)); } throw new Exception('XML->elementIncludeTo() wrong element type', EXCEPTION_XML); }
static function ajaxResponse($val, $message = null) { if ($val instanceof xml) { $xml = $val; } elseif ($val instanceof DOMElement) { $xml = new xml(); $xml->appendChild($xml->importNode($val)); } else { $xml = new xml(null, 'response', false); $xml->de()->appendChild($xml->createElement('value', null, $val)); if ($message) { $xml->de()->appendChild($xml->createElement('message', null, $message)); } } if ($xml) { header('Content-Type: text/xml; charset=utf-8'); echo $xml; } die; }