public function showSettings() { if ($this->_block !== null) { echo '<h1>Настройки</h1>'; echo '<form method="post" action="' . $this->arel() . '" success="' . $this->rel('') . '">'; echo '<div class="content">'; echo '<table>'; foreach ($this->_defaultSettings as $name => $a) { $title = $a['title']; $default = $a['default']; $width = isset($a['width']) ? $a['width'] : '40px'; echo '<tr><td style="padding-right: 10px;text-align: right;">'; echo '<label for="s-' . $name . '">' . $title . '</label> '; echo '</td><td>'; echo '<input id="s-' . $name . '" type="text" name="' . $name . '" style="width: ' . $width . '" value="' . $this->_block->getOption($name, $default) . '" />'; echo '</td></tr>'; } echo '</table>'; echo '</div>'; echo '<div class="footer"><input type="submit" class="button submit" value="Сохранить" />'; if (request::isAjax()) { echo '<a href="' . $this->rel() . '" class="button close">Отменить</a>'; } echo '</div>'; echo '</form>'; } }
/** * Redirect to previous page */ function back() { if (request::isAjax()) { exit; } response::back(); }
/** * Used by the send function to replace place holders set by getHtmlelt * by actual content * * @param string $content * @return string */ protected function setHtmlEltIntern($content) { $ln = "\n"; $jsBlocks = $this->getHtmlBlocks('js', $ln); $addJsBlocks = request::isAjax() && strpos($content, '[{[JS]}]') === false; return str_replace( array('[{[TITLE]}]', '[{[META]}]', '[{[CSS]}]', '[{[JS]}]'), array( '<title>'.utils::htmlOut($this->getMeta('title')).'</title>', $this->getHtmlMeta(), $this->getHtmlIncFiles('css', $ln).$ln.$this->getHtmlBlocks('css', $ln), $this->getHtmlIncFiles('js', $ln).$ln.$jsBlocks ), $content).($addJsBlocks ? $jsBlocks : null); }
/** * Send The response * * @param bool $headerOnly Send only the header and exit */ public function send($headerOnly = false) { if (!headers_sent()) { $this->sendHeaders(); $this->beforeOut(); if ($headerOnly) exit(0); } $layout = request::isAjax()? $this->cfg->ajaxLayout : $this->cfg->layout; $ret = null; if (!$layout) { $ret = $this->content; } else { $tpl = factory::get('tpl', array( 'module'=>'out', 'action'=>$layout, 'default'=>'layout', 'layout'=>false, 'cache'=>array('auto'=>false) )); $tpl->set('content', $this->content); $ret = $tpl->fetch(); } //if ($ret) $this->addHeader('Content-Length', strlen($ret), true); return $ret; }
/** * Website main */ public static function main() { define('NYROVERSION', '0.2'); $globalContent = null; $globalVars = null; $cacheInst = null; $cacheInstVars = null; try { self::init(); $resp = response::getInstance(); self::$cfg->overload(__CLASS__.'Response'); if (self::$cfg->globalCache && !request::isPost() && count($_GET) == 0 && $resp->canGlobalCache()) { $prm = is_array(self::$cfg->globalCache) ? self::$cfg->globalCache : array(); $cacheInst = cache::getInstance(array_merge(array('serialize'=>false), $prm)); $id = str_replace('/', '._.', '/'.request::get('request')).(request::isAjax() ? '-ajax' : ''); $cacheInst->get($globalContent, array( 'id'=>$id )); $cacheInstVars = cache::getInstance(array_merge(array('serialize'=>true), $prm)); $cacheInstVars->get($globalVars, array( 'id'=>$id.'-vars' )); } if (is_null($globalContent)) { request::execModule(); if (DEV) { debug::timer('nyroProcess'); debug::timer('nyroRender'); } $resp->setContent(request::publishModule()); } } catch (module_exception $e) { session::setFlash('nyroError', 'MODULE or ACTION NOT FOUND<br />'.self::handleError($e)); $resp->error(null, 404); } catch (nException $e) { session::setFlash('nyroError', self::handleError($e)); $resp->error(null, 500); } catch (PDOException $e) { session::setFlash('nyroError', self::handleError($e)); $resp->error(null, 500); } catch (Exception $e) { session::setFlash('nyroError', self::handleError($e)); $resp->error(null, 500); } try { factory::saveCache(); if ($cacheInst) { if ($globalContent) { $resp->setVarsFromGlobalCache($globalVars); echo $globalContent; } else { $globalVars = $resp->getVarsForGlobalCache(); $globalContent = $resp->send(); $cacheInst->save(); $cacheInstVars->save(); echo $globalContent; } } else { echo $resp->send(); } } catch (Exception $e) { echo debug::trace($e); } }