function install() { if (!$this->getForm()) { $data_xml = new xml(PATH_MODULE . __CLASS__ . '/data.xml'); $this->getSection()->getXML()->elementIncludeTo($data_xml->getElementById('meta_form'), '//modules/module[@id="' . $this->getId() . '"]'); if ($form = $this->getForm()) { $form->getXML()->save(); } } if ($sec = ap::getClientSection($this->getSection()->getId())) { $modules = $sec->getModules(); if (!$modules->getById($this->getId())) { $moduleName = $this->getName(); if (preg_match('/ap([A-Z].*)/', $moduleName, $m)) { $moduleName = strtolower($m[1]); } $modules->add($moduleName, $this->getTitle(), $this->getId()); $modules->getXML()->save(); } return true; } }
function settings($action) { global $_out, $_site; $xml = new xml(PATH_MODULE . get_class($this) . '/data.xml'); if ($e = $xml->getElementById('feedback_form_settings')) { $form = new form($e); $form->replaceURI(array('MD' => $this->getId(), 'ID' => $this->getSection()->getId())); switch ($action) { case 'update': case 'apply_update': $form->save($_REQUEST); return; } //fill select from connect $select_connects = $form->getField('form__db_name_connect'); $mysqlConnects = $_site->query('//mysql/con'); foreach ($mysqlConnects as $con) { $select_connects->addOption($con->getAttribute('id'), $con->getAttribute('id')); } //fill selects from mail templates $tpls = apTemplateManager::getAllTemplates(); $select_tpl = $form->getField('form_email_tpl'); $select_uTpl = $form->getField('form_email_tpl_user'); foreach ($tpls as $item) { $select_tpl->addOption($item, $item); $select_uTpl->addOption($item, $item); } #fill tables $form->load(); //for database connection $con = $select_connects->getValue(); $mysql = new mysql($con ? $con : null); $rs = $mysql->query('SHOW TABLES'); $select_tb = $form->getField('form_db_name_table'); while ($res = mysql_fetch_array($rs)) { $select_tb->addOption($res[0], $res[0]); } $form->load(); $_out->addSectionContent($form->getRootElement()); } }
function settings($action) { global $_out; $xml = new xml(PATH_MODULE . __CLASS__ . '/data.xml'); if ($e = $xml->getElementById('settings')) { $form = new form($e); if (($ff = $form->getField('section_template')) && ($tl = apSectionTemplate::getPackages())) { $val = $ff->getValue(); foreach ($tl as $e) { $ff->addOption($e->getAttribute('id'), $e->getAttribute('title')); if ($val == $e->getAttribute('id')) { $ff->setValue($val); } } } $form->replaceURI(array('MD' => $this->getId(), 'ID' => $this->getSection()->getId())); switch ($action) { case 'update': case 'apply_update': $form->save($_REQUEST); return; } $form->load(); $_out->addSectionContent($form->getRootElement()); } }