public static function Initialise() { utopia::AddTemplateParser('login_user', 'uUserLogin::GetLoginUserBox', ''); utopia::AddTemplateParser('login_pass', 'uUserLogin::GetLoginPassBox', ''); utopia::AddTemplateParser('login_status', 'uUserLogin::GetLoginStatus', ''); utopia::AddTemplateParser('login', 'uUserLogin::LoginForm', '', true); uEvents::AddCallback('BeforeRunModule', 'uUserLogin::checkLogin'); uCSS::IncludeFile(dirname(__FILE__) . '/login.css'); uEvents::AddCallback('AfterInit', 'uUserLogin::CheckSession'); }
define('TEMPLATE_BLANK', '__blank__'); define('TEMPLATE_DEFAULT', '__default__'); utopia::AddTemplateParser('utopia', 'utopia::parseVars'); utopia::AddTemplateParser('list', 'utopia::DrawList'); utopia::AddTemplateParser('get', 'utopia::parseGet'); utopia::AddTemplateParser('post', 'utopia::parsePost'); utopia::AddTemplateParser('request', 'utopia::parseRequest'); utopia::AddTemplateParser('session', 'utopia::parseSession'); utopia::AddTemplateParser('const', 'utopia::parseConst'); utopia::AddTemplateParser('domain', 'utopia::GetDomainName', ''); utopia::AddTemplateParser('home_url', PATH_REL_ROOT, ''); utopia::AddTemplateParser('home_url_abs', 'utopia::GetSiteURL', ''); utopia::AddTemplateParser('inline', 'inline=0', ''); utopia::SetVar('tp', PATH_REL_CORE . 'images/tp.gif'); utopia::AddTemplateParser('setrequest', 'utopia::setRequest'); utopia::AddTemplateParser('setget', 'utopia::setGet'); final class utopia { private static $children = array(); private static $parents = array(); static function AddChild($parent, $child, $info) { $info['parent'] = $parent; $info['child'] = $child; self::$children[$parent][$child][] = $info; self::$parents[$child][$parent][] = $info; } static function GetChildren($parent) { $specific = isset(self::$children[$parent]) ? self::$children[$parent] : array(); $currentModule = $parent == utopia::GetCurrentModule() && isset(self::$children['/']) ? self::$children['/'] : array();
<?php utopia::AddTemplateParser('gravatar', 'uGravatar::GetImage'); class uGravatar { public static function GetImageField($originalValue, $pkVal, $value, $rec, $fieldName) { if (!$originalValue) { return ''; } $o = utopia::GetInstance($rec['_module']); $size = $o->GetFieldProperty($fieldName, 'size'); return self::GetImage($originalValue, $size); } public static function GetImage($email, $size = null) { if (!$email) { return ''; } if ($size === null) { $size = 40; } return '<img src="http://www.gravatar.com/avatar/' . self::GetHash($email) . '?d=mm&s=' . $size . '" />'; } public static function GetProfile($email) { try { $profile = unserialize(curl_get_contents('http://www.gravatar.com/' . self::GetHash($email) . '.php')); } catch (Exception $e) { return FALSE; }
class tabledef_ModOpts extends uTableDef { public $tablename = 'internal_modopts'; public function SetupFields() { // add all the fields in here // AddField($name, $type, $length, $collation='', $attributes='', $null='not null', $default='', $extra='', $comments='') // SetPrimaryKey($name); $this->AddField('ident', ftVARCHAR, 100); $this->AddField('group', ftVARCHAR, 100); $this->AddField('name', ftVARCHAR, 100); $this->AddField('value', ftTEXT); $this->SetPrimaryKey('ident'); } } utopia::AddTemplateParser('option', 'modOpts::GetOption', '.+'); class modOpts extends uListDataModule implements iAdminModule { public function GetTitle() { $f =& $this->FindFilter('group'); if ($f['value']) { return $f['value']; } return 'Options'; } public function GetSortOrder() { return 10000 - 2; } public function GetOptions()
header('Content-Type: application/json'); echo json_encode($rows); } public function RunModule() { $this->ShowData(); // show conclicts between static block ids and custom ids $rows = $this->GetDataset()->fetchAll(); foreach ($rows as $row) { if (uWidgets::StaticWidgetExists($row['block_id'])) { echo "Conflict: Widget ({$row['block_id']}) already exists as a static Widget. Please rename it."; } } } } utopia::AddTemplateParser('widget', 'uWidgets::DrawWidget'); class uWidgets extends uSingleDataModule implements iAdminModule { public function GetTitle() { return 'Edit Widget'; } public function GetOptions() { return ALLOW_DELETE | ALLOW_FILTER | ALLOW_EDIT | ALLOW_ADD; } public function GetTabledef() { return 'tabledef_Widgets'; } public function SetupFields()
public static function Initialise() { utopia::RegisterAjax('getWidgetPlaceholder', 'uCMS_Edit::getWidgetPlaceholder'); utopia::AddTemplateParser('content', 'uCMS_Edit::getEditor', '.*'); uEvents::AddCallback('BeforeRunModule', 'uCMS_Edit::editPageCallback', null, -9999); self::AddParent('uCMS_List', 'cms_id'); }
<?php utopia::AddTemplateParser('breadcrumb', 'uBreadcrumb::GetTrail', '.*'); class uBreadcrumb { private static $extras = array(); static function AddCrumb($name, $url) { self::$extras[] = array($name, $url); } static function GetTrail($start = null) { $obj = utopia::GetInstance('uCMS_List'); $arr = $obj->GetNestedArray(); $out = array(); //TODO: add (Search Results) to end of title if current page is filtered. $out[$_SERVER['REQUEST_URI']] = '{utopia.title}'; // '<a href="'.$_SERVER['REQUEST_URI'].'">{utopia.title}</a>'; foreach (self::$extras as $a) { $out[$a[1]] = $a[0]; //'<a href="'.$a[1].'">'.$a[0].'</a>'; } $obj = utopia::GetInstance('uCMS_View'); $row = uCMS_View::findPage(); do { if (!$row) { break; } $url = $obj->GetURL($row['cms_id']); $title = $row['nav_text'] ? $row['nav_text'] : $row['title']; $out[$url] = $title;
public static function Initialise() { utopia::AddTemplateParser('menu1', 'uMenu::GetMenu', '.*'); utopia::AddTemplateParser('menu', 'uMenu::GetNestedMenu', '.*'); utopia::AddTemplateParser('sitemap', 'uMenu::DrawNestedMenu', ''); }