public static function ShowNotices() { // is redirect issued? If so, don't draw now. foreach (headers_list() as $h) { if (preg_match('/^location:/i', $h)) { return; } } if (!utopia::UsingTemplate() && !AjaxEcho()) { return; } if (!isset($_SESSION['notices'])) { return; } $scripts = implode(PHP_EOL, $_SESSION['notices']); $_SESSION['notices'] = array(); if (!AjaxEcho($scripts)) { uJavascript::AddText('$(function(){' . $scripts . '});'); } }
function ErrorLog($text) { return; AjaxEcho('ErrorLog("' . addcslashes(str_replace("\n", '', $text), '"') . '")'); if (utopia::UsingTemplate()) { echo $text; } $cLog = utopia::GetVar('error_log'); if (array_key_exists('__ajax', $_REQUEST)) { if (!empty($cLog)) { utopia::AppendVar('error_log', "\n"); } utopia::AppendVar('error_log', 'ErrorLog("' . $text . '");'); } else { if (!empty($cLog)) { utopia::AppendVar('error_log', '<br/>'); } utopia::AppendVar('error_log', '<span><b>*</b> ' . $text . '</span>'); // utopia::AppendVar('error_log','<span style="color:#EE3333; border-style:solid; border-width:1px; background-color:#DDDDDD; padding:3px">'.$text.'</span>'); } }
public function _RunModule() { $this->AssertURL(); if ($this->isDisabled) { echo $this->isDisabled; return; } // build linklist of children $children = utopia::GetChildren(get_class($this)); foreach ($children as $child => $links) { $obj = utopia::GetInstance($child); foreach ($links as $info) { if ($obj->flag_is_set(ALLOW_ADD) && !$this->flag_is_set(ALLOW_ADD) && is_subclass_of($child, 'uSingleDataModule') && ($info['parentField'] === NULL || $info['parentField'] === '*')) { $url = $obj->GetURL(array('_n_' . $obj->GetModuleId() => '1')); utopia::LinkList_Add('list_functions:' . get_class($this), null, CreateNavButton('New ' . $obj->itemName, $url, array('class' => 'new-item')), 1); } } } // BEFORE ob_start(); $beforeResult = uEvents::TriggerEvent('BeforeRunModule', $this); $beforeContent = ob_get_clean(); if (utopia::UsingTemplate() && $beforeContent) { $beforeContent = '<div class="module-container ' . get_class($this) . ' BeforeRunModule">' . $beforeContent . '</div>'; } echo $beforeContent; if ($beforeResult === FALSE) { return FALSE; } // RUN ob_start(); $result = $this->RunModule(); $runContent = ob_get_clean(); if (utopia::UsingTemplate() && $runContent) { $runContent = '<div class="module-container ' . get_class($this) . ' RunModule">' . $runContent . '</div>'; } echo $runContent; if ($result === FALSE) { return false; } $this->hasRun = true; // AFTER ob_start(); $afterResult = uEvents::TriggerEvent('AfterRunModule', $this); $afterContent = ob_get_clean(); if (utopia::UsingTemplate() && $afterContent) { $afterContent = '<div class="module-container ' . get_class($this) . ' AfterRunModule">' . $afterContent . '</div>'; } echo $afterContent; if ($afterResult === FALSE) { return FALSE; } }
public static function assertContent() { $o = utopia::GetInstance(__CLASS__); if (self::$asserted) { return; } self::$asserted = true; $rec = self::findPage(); if (!$rec) { if (utopia::GetCurrentModule() == __CLASS__) { utopia::PageNotFound(); } return; } $canEdit = uEvents::TriggerEvent('CanAccessModule', 'uCMS_Edit') !== FALSE; if (!$canEdit && !$rec['is_published']) { utopia::PageNotFound(); } if (!isset($_GET['preview']) && !isset($_GET['edit']) && !$rec['is_published']) { utopia::PageNotFound(); } echo '<div class="cms-' . $rec['cms_id'] . '">{content}</div>'; utopia::SetVar('cms_id', $rec['cms_id']); utopia::SetVar('cms_parent_id', $rec['parent']); $path = $o->GetCmsParents($rec['cms_id']); utopia::SetVar('cms_parents', $path); utopia::SetVar('cms_root_id', reset($path)); utopia::SetDescription($rec['description']); if (!utopia::UsingTemplate() || utopia::UsingTemplate(TEMPLATE_BLANK)) { return; } utopia::UseTemplate(self::GetTemplate($rec['cms_id'])); }