/** * Triggers the services for the specified $transition. Can be called * as a static method. Returns a string of the concatenated output * from all of the services. * * @access public * @param string * @param array hash * @return string * */ function trigger($transition = 'global', $data = array()) { if (@file_exists('inc/app/cms/conf/services/' . $transition . '.php')) { $services = ini_parse('inc/app/cms/conf/services/' . $transition . '.php'); if (!is_array($services)) { $services = array(); } } else { $services = array(); } if ($transition != 'global' && $transition != 'error' && @file_exists('inc/app/cms/conf/services/global.php')) { $s2 = ini_parse('inc/app/cms/conf/services/global.php'); if (is_array($s2)) { $services = array_merge($services, $s2); } } $out = ''; $data['transition'] = $transition; foreach ($services as $service => $info) { if (strpos($info['handler'], 'box:') === 0) { $out .= loader_box(trim(substr($info['handler'], 4)), $data, 'service'); } elseif (strpos($info['handler'], 'form:') === 0) { $out .= loader_form(trim(substr($info['handler'], 5)), 'service'); } } return $out; }
/** * Executes the specified form using the Sitellite form API, * which is essentially just an include of a file that defines a * subclass of saf.MailForm. Note: This is now an alias * for the loader_form() function. * * @access public * @param string $name * @return string * */ function form($name) { $out = loader_form($name); if (empty($out)) { return html_marker('Empty Form: ' . $name); } return html_marker('Form: ' . $name) . $out; }
if (!session_allowed('add', 'rw', 'resource')) { header('Location: ' . site_prefix() . '/index/cms-cpanel-action'); exit; } if (session_is_resource($cgi->collection) && !session_allowed($cgi->collection, 'r', 'resource')) { header('Location: ' . site_prefix() . '/index/cms-cpanel-action'); exit; } if (isset($rex->info['Collection']['add'])) { list($call, $name) = explode(':', $rex->info['Collection']['add']); if ($call == 'box') { echo loader_box($name); } elseif ($call == 'form') { echo loader_form($name); } else { echo loader_form($call); } return; } else { class CmsAddForm extends MailForm { function CmsAddForm() { parent::MailForm(); $w =& $this->addWidget('hidden', 'collection'); $w =& $this->addWidget('hidden', '_return'); global $cgi; loader_import('cms.Versioning.Rex'); $rex = new Rex($cgi->collection); $widgets = $rex->getStruct(); if (!$widgets) {
if (!isset($parameters['show'])) { $parameters['show'] = appconf('default_page'); } $level = 0; if (session_valid()) { $level++; } if (session_admin()) { $level++; } $res = db_single('select * from sitewiki_page where id = ?', $parameters['show']); if (!$res) { if ($level >= appconf('default_edit_level')) { global $cgi; $cgi->page = $parameters['show']; echo loader_form('sitewiki/edit'); } else { echo template_simple('not_found.spt'); } return; } if ($res->view_level > $level && $res->owner != session_username()) { page_title(substr(preg_replace('/([A-Z])/', ' \\1', $parameters['show']), 1)); echo template_simple('not_visible.spt', $res); return; } if (isset($parameters['rev'])) { $rev = db_single('select * from sitewiki_page_sv where id = ? and sv_autoid = ?', $parameters['show'], $parameters['rev']); $res->body = $rev->body; $res->updated_on = $rev->sv_revision; $res->revision = $parameters['rev'];
function _fill($tpl, $obj) { global $simple_template_register, $simple_template_functions; if (empty($tpl)) { return ''; } if (isset($this->cache[$tpl])) { $use = $this->cache[$tpl]; } elseif (@is_file($this->getPath() . '/' . $tpl)) { $this->cache[$tpl] = @join('', @file($this->getPath() . '/' . $tpl)); $use = $this->cache[$tpl]; } else { $use = $tpl; } // Determine Delimiter if (preg_match('/^<\\!-- SIMPLE_TEMPLATE_DELIM_([A-Z0-9_]+) -->/', $use, $regs)) { $old_delim = $this->use_delim; $this->use_delim = constant('SIMPLE_TEMPLATE_DELIM_' . $regs[1]); $use = str_replace($regs[0], '', $use); } // Eval Inline PHP ob_start(); eval(CLOSE_TAG . $use); $use = ob_get_contents(); ob_end_clean(); //$out = preg_replace ("/" . $this->delim[$this->use_delim][0] . "([a-zA-Z0-9\.:\/_-]+)" . $this->delim[$this->use_delim][1] . "/e", "\$this->determine ('$1', \$obj)", $use); $tokens = preg_split('/(' . $this->delim[$this->use_delim][0] . '[\\[\\]\\(\\)a-zA-Z0-9\\.,=<>\\?&#$\'":;\\!\\=\\/\\| _-]+' . $this->delim[$this->use_delim][1] . ')/s', $use, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $out = ''; foreach ($tokens as $tok) { $_tok = substr($tok, strlen($this->delim_literal[$this->use_delim][0]), -strlen($this->delim_literal[$this->use_delim][1])); if (!empty($_tok) && strpos($tok, $this->delim_literal[$this->use_delim][0]) === 0 && strrpos($tok, $this->delim_literal[$this->use_delim][1]) === strlen($tok) - strlen($this->delim_literal[$this->use_delim][1])) { $_is_tag = true; } else { $_is_tag = false; } // HANDLE END-LOOP if ($this->_ignoreUntilEndLoop) { if (strpos($_tok, 'loop ') === 0) { $this->_structCount++; } elseif ($_tok == 'end loop' && $this->_structCount > 0) { $this->_structCount--; continue; } if ($_tok == 'end loop') { $this->_ignoreUntilEndLoop = false; $this->_bufferUntilEndLoop = false; } } elseif ($this->_bufferUntilEndLoop) { if (strpos($_tok, 'loop ') === 0) { $this->_structCount++; $this->_loopBuffer .= $tok; continue; } elseif ($_tok == 'end loop' && $this->_structCount > 0) { $this->_structCount--; $this->_loopBuffer .= $tok; continue; } if ($_tok == 'end loop') { $this->_bufferUntilEndLoop = false; $tmp = isset($simple_template_register['loop']) ? $simple_template_register['loop'] : null; $parent = isset($simple_template_register['parent']) ? $simple_template_register['parent'] : null; $simple_template_register['parent'] = $tmp; $index = 1; $total = count($this->_loopList); foreach ($this->_loopList as $key => $item) { if (in_array($key, array('_properties', '_index', '_key', '_total'), true)) { continue; } $simple_template_register['loop'] = $item; if (is_object($item)) { $simple_template_register['loop']->_properties = get_object_vars($simple_template_register['loop']); $simple_template_register['loop']->_index = $index; $simple_template_register['loop']->_key = $key; $simple_template_register['loop']->_total = $total; } elseif (is_array($item)) { $simple_template_register['loop']['_properties'] = $simple_template_register['loop']; $simple_template_register['loop']['_index'] = $index; $simple_template_register['loop']['_key'] = $key; $simple_template_register['loop']['_total'] = $total; } else { $simple_template_register['loop'] = (object) array('_value' => $item, '_index' => $index, '_key' => $key, '_total' => $total); } $out .= $this->fill($this->_loopBuffer, $obj); $index++; } $simple_template_register['loop'] = $tmp; $simple_template_register['parent'] = $parent; } else { $this->_loopBuffer .= $tok; } // HANDLE END-IF } elseif ($this->_ignoreUntilEndIf) { if (strpos($_tok, 'if ') === 0) { $this->_structCount++; } elseif ($_tok == 'end if' && $this->_structCount > 0) { $this->_structCount--; continue; } if ($_tok == 'end if') { $this->_ignoreUntilEndIf = false; } // HANDLE INC AND SPT } elseif (strpos($_tok, 'inc ') === 0) { // include $file = substr($_tok, 4); if (@file_exists($this->getPath() . '/' . $file)) { $out .= @join('', @file($this->getPath() . '/' . $file)); continue; } $val = $this->determine($file, $obj); if (@file_exists($this->getPath() . '/' . $val)) { $out .= @join('', @file($this->getPath() . '/' . $val)); continue; } elseif (!empty($val)) { $out .= $val; continue; } $out .= $file; continue; } elseif (strpos($_tok, 'spt ') === 0) { // include another template $file = substr($_tok, 4); list($file, $param) = explode(' ', $file); if (!empty($param)) { $param = $this->determine($param, $obj); } else { $param = $obj; } if (@file_exists($this->getPath() . '/' . $file)) { $out .= $this->fill(@join('', @file($this->getPath() . '/' . $file)), $param); continue; } $val = $this->determine($file, $obj); if (@file_exists($this->getPath() . '/' . $val)) { $out .= $this->fill(@join('', @file($this->getPath() . '/' . $val)), $param); continue; } elseif (!empty($val)) { $out .= $this->fill($val, $param); continue; } $out .= $this->fill($file, $param); continue; } elseif ($_is_tag && strpos($_tok, 'form ') === 0) { // call loader_form () $form = substr($_tok, 5); $out .= loader_form($form); continue; } elseif ($_is_tag && strpos($_tok, 'box ') === 0) { // call loader_box () $box = substr($_tok, 4); if (strstr($box, '?')) { $u = parse_url($box); $box = $u['path']; $param = array(); foreach (explode('&', $u['query']) as $pair) { list($k, $v) = explode('=', $pair); if ($v[0] == '[' && $v[strlen($v) - 1] == ']') { $v = $this->determine(substr($v, 1, strlen($v) - 2), $obj); } $param[$k] = $v; } } else { $param = array(); } $out .= loader_box($box, $param); continue; } elseif (strpos($_tok, 'info ') === 0) { ob_start(); info($this->determine(substr($_tok, 5), $obj)); $out .= ob_get_contents(); ob_end_clean(); } elseif ($_tok == 'end filter') { // return filter to default $this->filter = 'htmlentities_compat'; // STANDARD TAG INTERPRETATION } elseif ($_is_tag) { if (strpos($_tok, '|') !== false) { $_filters = explode('|', $_tok); $_tok = array_shift($_filters); $_prev_filter = $this->filter; $this->filter = join('/', $_filters); } if ($this->filter == 'none') { $out .= $this->determine($_tok, $obj); } else { if (isset($simple_template_register['loop']) && is_object($simple_template_register['loop'])) { $_name = $simple_template_register['loop']->_key; } elseif (isset($simple_template_register['loop']) && is_array($simple_template_register['loop'])) { $_name = $simple_template_register['loop']['_key']; } else { $_name = false; } $GLOBALS['simple_template_token_name'] = $_name; if (strpos($this->filter, '/') !== false) { $filters = explode('/', $this->filter); $res = $this->determine($_tok, $obj); foreach (array_reverse($filters) as $filter) { $res = @call_user_func($filter, $res); } $out .= $res; } else { $out .= @call_user_func($this->filter, $this->determine($_tok, $obj)); } } if (isset($_filters)) { $this->filter = $_prev_filter; unset($_prev_filter); unset($_filters); } // IN-BETWEEN TEXT } else { $out .= $tok; } } // Reset Delimiter if (isset($old_delim)) { $this->use_delim = $old_delim; } return $out; }
foreach (get_object_vars($res) as $key => $value) { $_document->{$key} = $value; } echo loader_form('cms/edit'); ?> </div> <div id="cms-grey"> </div> <div id="cms-properties"><?php echo loader_form('cms/properties'); ?> </div> <div id="cms-state"><?php echo loader_form('cms/state'); ?> </div> <div id="spacer"> </div> <div align="center" style="width: 650px"> <form method="post" action="/index/cms-edit-save-action"> <input type="hidden" name="id" /> <input type="hidden" name="title" /> <input type="hidden" name="body" /> <input type="hidden" name="sitellite_status" /> <input type="hidden" name="sitellite_access" /> <input type="hidden" name="template" /> <input type="hidden" name="below_page" /> <input type="hidden" name="is_section" />
<?php /** * This box is simply going to output some of the other example boxes * via the loader_box() function. */ // call the example/helloworld box echo loader_box('example/helloworld'); // call the example/contact form echo loader_form('example/contact'); // set the page title page_title(intl_get('Box in a Box'));