Ejemplo n.º 1
0
 public static function DrawDashboard()
 {
     // get large widget area
     ob_start();
     uEvents::TriggerEvent('ShowDashboard');
     $largeContent = ob_get_clean();
     if ($largeContent) {
         echo '<div class="dash-large">' . $largeContent . '</div>';
     }
     // get small widget area
     $smallContent = '';
     $w = utopia::GetModulesOf('uDashboardWidget');
     foreach ($w as $wid) {
         $wid = $wid['module_name'];
         $ref = new ReflectionClass($wid);
         ob_start();
         if ($ref->hasMethod('Draw100')) {
             $wid::Draw100();
         } elseif ($ref->hasMethod('Draw50')) {
             $wid::Draw50();
         } elseif ($ref->hasMethod('Draw25')) {
             $wid::Draw25();
         }
         $content = ob_get_clean();
         if (!$content) {
             continue;
         }
         $smallContent .= '<div class="widget-container ' . $wid . '"><h1>' . $wid::GetTitle() . '</h1><div class="module-content">' . $content . '</div></div>';
     }
     if ($smallContent) {
         echo '<div class="dash-small">' . $smallContent . '</div>';
     }
 }
Ejemplo n.º 2
0
 public static function CreateLinkMenu($module = null)
 {
     $cm = utopia::GetCurrentModule();
     if ($module === null) {
         $module = $cm;
     }
     if (isset(self::$done[$module])) {
         return;
     }
     self::$done[$module] = true;
     $cmAdmin = is_subclass_of($cm, 'iAdminModule');
     $modules = utopia::GetChildren($module);
     $highestpos = 0;
     foreach ($modules as $mid => $children) {
         if ($cmAdmin && !is_subclass_of($mid, 'iAdminModule')) {
             continue;
         }
         if (!$cmAdmin && is_subclass_of($mid, 'iAdminModule')) {
             continue;
         }
         foreach ($children as $child) {
             if (isset($child['callback'])) {
                 continue;
             }
             if (isset($child['fieldLinks']) && $mid !== $cm) {
                 continue;
             }
             if (uEvents::TriggerEvent('CanAccessModule', $mid) === FALSE) {
                 continue;
             }
             if ($module !== $cm && $child['parent'] === '/') {
                 continue;
             }
             $parent = '_modlinks_';
             if (isset($child['parent']) && $child['parent'] !== '/') {
                 $parent .= $child['parent'];
             }
             $obj = utopia::GetInstance($mid);
             $position = $obj->GetSortOrder();
             if (isset($child['fieldLinks']) && $mid === $cm) {
                 $position = 0;
             }
             if ($position > $highestpos) {
                 $highestpos = $position;
             }
             uMenu::AddItem($parent . $mid, $obj->GetTitle(), $obj->GetURL(), $parent, null, $position);
         }
         self::CreateLinkMenu($mid);
     }
     if ($module === $cm) {
         // add separators
         $i = -10001;
         while ($i < $highestpos) {
             uMenu::AddItem('_sep_' . $i, '', '', '_modlinks_', null, $i);
             $i = $i + 1000;
         }
     }
 }
Ejemplo n.º 3
0
 static function RunPopup()
 {
     utopia::SetTitle('Browse Media');
     uEvents::RemoveCallback('ProcessDomDocument', 'uAdminBar::ProcessDomDocument');
     utopia::UseTemplate(TEMPLATE_BLANK);
     utopia::$noSnip = true;
     $o = utopia::GetInstance('fileManager');
     $o->_RunModule();
 }
Ejemplo n.º 4
0
 public static function Initialise()
 {
     uEvents::AddCallback('ProcessDomDocument', 'uJavascript::LinkToDocument');
     uEvents::AddCallback('ProcessDomDocument', 'uJavascript::ProcessDomDocument', null, MAX_ORDER);
     self::LinkFile(PATH_REL_ROOT . 'javascript.js', -10);
     self::LinkFile(dirname(__FILE__) . '/jQuery/jquery-1.10.2.min.js', -100);
     self::LinkFile(dirname(__FILE__) . '/jQuery/jquery-ui-1.10.3.min.js', -99);
     self::IncludeFile(dirname(__FILE__) . '/javascript.js', -999);
     module_Offline::IgnoreClass(__CLASS__);
 }
Ejemplo n.º 5
0
 static function Initialise()
 {
     uJavascript::IncludeFile(dirname(__FILE__) . '/static_ajax.js');
     // register ajax
     utopia::RegisterAjax('updateField', 'uStaticAjax::UpdateField');
     utopia::RegisterAjax('getValues', 'uStaticAjax::getValues');
     utopia::RegisterAjax('getUpload', 'uStaticAjax::getUpload');
     utopia::RegisterAjax('getCompressed', 'uStaticAjax::getCompressed');
     utopia::RegisterAjax('getParserContent', 'uStaticAjax::getParserContent');
     uEvents::AddCallback('AfterInit', 'uStaticAjax::RunAjax', null, MAX_ORDER + MAX_ORDER);
 }
Ejemplo n.º 6
0
    public static function Initialise()
    {
        utopia::AddInputType(itRICHTEXT, 'module_CKEditor::drti_func');
        utopia::AddInputType(itHTML, 'module_CKEditor::drti_func');
        uJavascript::IncludeFile(dirname(__FILE__) . '/lib/ckeditor.js', 1000);
        uJavascript::IncludeFile(dirname(__FILE__) . '/ckeditor.js', 1005);
        uCSS::IncludeFile(dirname(__FILE__) . '/ckeditor.css');
        uEvents::AddCallback('AfterRunModule', 'module_CKEditor::MediaScript', 'fileManager');
        $basepath = utopia::GetRelativePath(dirname(__FILE__) . '/lib/');
        uJavascript::IncludeText(<<<FIN
var CKEDITOR_BASEPATH = '{$basepath}/';
var FILE_BROWSE_URL = PATH_REL_CORE+'index.php?__ajax=media';
FIN
);
    }
Ejemplo n.º 7
0
 public function RunModule()
 {
     uEvents::TriggerEvent('InitSitemap');
     $grp = isset($_GET['group']) ? $_GET['group'] : '';
     if (!isset(self::$items[$grp])) {
         utopia::PageNotFound();
     }
     utopia::CancelTemplate();
     header('Content-Type: application/xml', true);
     echo '<?xml version="1.0" encoding="UTF-8"?>';
     echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     foreach (self::$items[$grp] as $entry) {
         echo '<url>';
         foreach ($entry as $k => $v) {
             echo "\t<{$k}>{$v}</{$k}>";
         }
         echo '</url>';
     }
     echo '</urlset>';
     die;
 }
Ejemplo n.º 8
0
 public static function OutputTemplate()
 {
     uEvents::TriggerEvent('BeforeOutputTemplate');
     if (!self::UsingTemplate()) {
         ob_end_clean();
         echo utopia::GetVar('content');
         return;
     }
     if (isset($_GET['inline']) && !is_numeric($_GET['inline'])) {
         $_GET['inline'] = 0;
     }
     if (self::UsingTemplate(TEMPLATE_BLANK) || isset($_GET['inline']) && $_GET['inline'] == 0) {
         $template = utopia::GetVar('content');
     } else {
         $tCount = -1;
         // do all by default
         if (isset($_GET['inline'])) {
             $tCount = $_GET['inline'] - 1;
         }
         $template = '';
         $css = self::GetTemplateCSS();
         foreach ($css as $cssfile) {
             uCSS::LinkFile($cssfile);
         }
         // first get list of parents
         $templates = array();
         $templateDir = utopia::GetTemplateDir(true);
         if (!file_exists($templateDir)) {
             $templateDir = utopia::GetAbsolutePath($templateDir);
         }
         if (file_exists($templateDir)) {
             $templates[] = $templateDir;
         }
         while ($tCount-- && file_exists($templateDir . '/template.ini')) {
             $inifile = parse_ini_file($templateDir . '/template.ini');
             if (!isset($inifile['parent'])) {
                 break;
             }
             if (file_exists(PATH_ABS_ROOT . $inifile['parent'])) {
                 $templateDir = PATH_ABS_ROOT . $inifile['parent'];
             } else {
                 $templateDir = dirname($templateDir) . '/' . $inifile['parent'];
             }
             $templates[] = $templateDir;
         }
         foreach ($templates as $templateDir) {
             // set templatedir
             self::SetVar('templatedir', self::GetRelativePath($templateDir));
             $templatePath = $templateDir . '/template.php';
             $template = get_include_contents($templatePath);
             // mergevars
             while (self::MergeVars($template)) {
             }
             // setvar
             self::SetVar('content', $template);
         }
         if (!$template) {
             $template = '{utopia.content}';
         }
     }
     ob_end_clean();
     while (self::MergeVars($template)) {
     }
     $template = str_replace('<head>', '<head>' . '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>', $template);
     // Make all resources secure
     if (self::IsRequestSecure()) {
         $template = str_replace('http://' . self::GetDomainName(), 'https://' . self::GetDomainName(), $template);
     }
     do {
         if (self::UsingTemplate() && class_exists('DOMDocument')) {
             libxml_use_internal_errors(true);
             $doc = new DOMDocument();
             $doc->formatOutput = false;
             $doc->preserveWhiteSpace = true;
             $doc->validateOnParse = true;
             if (!$doc->loadHTML('<?xml encoding="UTF-8">' . utf8_decode($template))) {
                 break;
             }
             $isSnip = stripos($template, '<html') === false;
             $doc->encoding = 'UTF-8';
             // no html tag?  break out.
             if (!$doc->getElementsByTagName('html')->length) {
                 break;
             }
             // remove multiple xmlns attributes
             $doc->documentElement->removeAttributeNS(NULL, 'xmlns');
             // assert BODY tag
             if (!$doc->getElementsByTagName('body')->length) {
                 $node = $doc->createElement("body");
                 $doc->getElementsByTagName('html')->item(0)->appendChild($node);
             }
             // assert HEAD tag
             if (!$doc->getElementsByTagName('head')->length) {
                 // create head node
                 $node = $doc->createElement("head");
                 $body = $doc->getElementsByTagName('body')->item(0);
                 $newnode = $body->parentNode->insertBefore($node, $body);
             }
             // add HEAD children
             $head = $doc->getElementsByTagName('head')->item(0);
             // set title
             if (!$head->getElementsByTagName('title')->length) {
                 $node = $doc->createElement('title');
                 $node->appendChild($doc->createTextNode(utopia::GetTitle(true)));
                 $head->appendChild($node);
             }
             if (utopia::GetDescription(true)) {
                 $node = $doc->createElement('meta');
                 $node->setAttribute('name', 'description');
                 $node->setAttribute('content', utopia::GetDescription(true));
                 $head->appendChild($node);
             }
             if (utopia::GetKeywords(true)) {
                 $node = $doc->createElement('meta');
                 $node->setAttribute('name', 'keywords');
                 $node->setAttribute('content', utopia::GetKeywords(true));
                 $head->appendChild($node);
             }
             $node = $doc->createElement('meta');
             $node->setAttribute('name', 'generator');
             $node->setAttribute('content', 'uCore PHP Framework');
             $head->appendChild($node);
             // template is all done, now lets run a post process event
             try {
                 uEvents::TriggerEvent('ProcessDomDocument', null, array(&$doc));
             } catch (Exception $e) {
                 uErrorHandler::EchoException($e);
             }
             $ctNode = null;
             foreach ($head->getElementsByTagName('meta') as $meta) {
                 if ($meta->hasAttribute('http-equiv') && strtolower($meta->getAttribute('http-equiv')) == 'content-type') {
                     $ctNode = $meta;
                     break;
                 }
             }
             if (!$ctNode) {
                 $ctNode = $doc->createElement('meta');
                 $head->appendChild($ctNode);
             }
             $ctNode->setAttribute('http-equiv', 'content-type');
             $ctNode->setAttribute('content', 'text/html;charset=' . CHARSET_ENCODING);
             if ($ctNode !== $head->firstChild) {
                 $head->insertBefore($ctNode, $head->firstChild);
             }
             $doc->normalizeDocument();
             if (strpos(strtolower($doc->doctype->publicId), ' xhtml ')) {
                 $template = $doc->saveXML();
             } else {
                 $template = $doc->saveHTML();
             }
             $template = preg_replace('/<\\?xml encoding="UTF-8"\\??>\\n?/i', '', $template);
             if ($isSnip && !self::$noSnip) {
                 $template = preg_replace('/.*<body[^>]*>\\s*/ims', '', $template);
                 // remove everything up to and including the body open tag
                 $template = preg_replace('/\\s*<\\/body>.*/ims', '', $template);
                 // remove everything after and including the body close tag
             }
         }
     } while (false);
     while (self::MergeVars($template)) {
     }
     if (isset($_GET['callback'])) {
         $output = json_encode(array('title' => self::GetTitle(true), 'content' => $template));
         header('Content-Type: application/javascript');
         echo $_GET['callback'] . '(' . $output . ')';
         return;
     }
     echo $template;
 }
Ejemplo n.º 9
0
 public function SetupParents()
 {
     $this->SetRewrite(array('{c}'));
     uEvents::AddCallback('AfterUpdateField', array($this, 'UpdatedEmail'), 'uUserProfile');
 }
Ejemplo n.º 10
0
            return $key;
        }
        return $this->localisations[$key];
    }
    public function offsetSet($key, $val)
    {
        if ($val === TRUE) {
            $val = $key;
        }
        $key = strtolower($key);
        $this->localisations[$key] = $val;
    }
    public function offsetExists($key)
    {
        return array_key_exists($key, $this->localisations);
    }
    public function offsetUnset($key)
    {
        unset($this->localisations[$key]);
    }
    public static function InitLocale()
    {
        uLocale::ResetLocale();
        if (self::$locale_limit === NULL) {
            uLocale::LimitLocale(array(DEFAULT_LOCALE));
        }
    }
}
uConfig::AddConfigVar('DEFAULT_LOCALE', 'Default Locale', 'en_GB', uLocale::ListLocale('%t, %l'));
uEvents::AddCallback('ConfigDefined', 'uLocale::InitLocale');
Ejemplo n.º 11
0
            if ($img->hasAttribute('width')) {
                $qs['w'] = $img->getAttribute('width');
            }
            if ($img->hasAttribute('height')) {
                $qs['h'] = $img->getAttribute('height');
            }
            // inline styles second as they have priority over attributes
            if ($img->hasAttribute('style')) {
                $s = $img->getAttribute('style');
                $s = explode(';', $s);
                foreach ($s as $prop) {
                    if (preg_match('/\\s*(width|height)\\s*:\\s*([0-9]+)px/', $prop, $matches)) {
                        $qs[$matches[1][0]] = intval($matches[2]);
                    }
                }
            }
            $qs = http_build_query($qs);
            if (!$qs) {
                continue;
            }
            if (strpos('?', $src) !== false) {
                $src .= '&' . $qs;
            } else {
                $src .= '?' . $qs;
            }
            $img->setAttribute('src', $src);
        }
    }
}
uEvents::AddCallback('ProcessDomDocument', 'uUploads::ProcessDomDocument', '', MAX_ORDER);
Ejemplo n.º 12
0
 public function UpdateField($fieldName, $newValue, &$pkVal = NULL, $fieldType = NULL)
 {
     $this->AssertTable();
     uEvents::TriggerEvent('BeforeUpdateField', $this, array($fieldName, $newValue, &$pkVal, $fieldType));
     //AjaxEcho('//'.str_replace("\n",'',get_class($this)."@UpdateField($fieldName,,$pkVal)\n"));
     if ($fieldType === NULL) {
         $fieldType = $this->fields[$fieldName]['type'];
     }
     if (is_array($newValue)) {
         $newValue = json_encode($newValue);
     }
     if ($newValue) {
         switch ($fieldType) {
             case ftRAW:
                 break;
             case ftDATE:
             case ftTIME:
             case ftDATETIME:
                 // datetime
             // datetime
             case ftTIMESTAMP:
                 $parsed = utopia::strtotime($newValue);
                 $newValue = $newValue == '' ? 'NULL' : date('Y-m-d H:i:s', $parsed);
                 break;
             case ftFLOAT:
                 // float
             // float
             case ftDECIMAL:
                 $l = setlocale(LC_ALL, 'en_US');
                 $newValue = floatval($newValue);
                 setlocale(LC_ALL, $l);
                 break;
             case ftBOOL:
                 // bool
             // bool
             case ftPERCENT:
                 // percent
             // percent
             case ftCURRENCY:
                 // currency
             // currency
             case ftNUMBER:
                 $newValue = $newValue === '' ? '' : preg_replace('/[^0-9\\.-]/', '', $newValue);
                 break;
         }
     }
     if (($newValue === '' || $newValue === NULL) && $this->GetFieldProperty($fieldName, 'null') !== SQL_NOT_NULL) {
         $newValue = NULL;
     }
     $updateQry = array();
     $raw = $fieldType == ftRAW;
     $args = array();
     if ($pkVal === NULL) {
         $query = 'INSERT INTO ' . $this->tablename . ' (`' . $fieldName . '`) VALUES (' . ($raw ? $newValue : '?') . ')';
         if (!$raw) {
             $args[] = $newValue;
         }
     } else {
         $query = 'UPDATE ' . $this->tablename . ' SET `' . $fieldName . '` = ' . ($raw ? $newValue : '?') . ' WHERE `' . $this->GetPrimaryKey() . '` = ?';
         if (!$raw) {
             $args[] = $newValue;
         }
         $args[] = $pkVal;
     }
     database::query($query, $args);
     if ($fieldName == $this->GetPrimaryKey() && $newValue !== NULL) {
         // this allows us to get the real evaluated value of the new primary key
         $stm = database::query('SELECT ? AS new_pk', array($newValue));
         $row = $stm->fetch();
         $pkVal = $row['new_pk'];
     } elseif ($pkVal === NULL) {
         $pkVal = database::connect()->lastInsertId();
     }
     uEvents::TriggerEvent('AfterUpdateField', $this, array($fieldName, $newValue, &$pkVal, $fieldType));
 }
Ejemplo n.º 13
0
 public static function Initialise()
 {
     uEvents::AddCallback('AfterInit', 'cms_publish_update::uCMS_publish_update');
 }
Ejemplo n.º 14
0
            $ret = '<li ' . $attrs . '>';
            if (!empty($item['url'])) {
                $ret .= '<a href="' . $item['url'] . '" title="' . $item['text'] . '">' . $item['text'] . '</a>';
            } else {
                $ret .= '&nbsp;';
            }
            if ($level !== 0) {
                $ret .= self::GetMenu($item['id'], $level);
            }
            $ret .= '</li>';
            $items[] = $ret;
            $lastWasBlank = empty($item['url']);
        }
        if (!$items) {
            return '';
        }
        $ret = '<ul class="u-menu ' . $group . '">' . implode('', $items) . '</ul>';
        return $ret;
    }
    static function GetNestedMenu($group = '')
    {
        return self::GetMenu($group, -1);
    }
    static function AddStyles()
    {
        uCSS::IncludeFile(dirname(__FILE__) . '/menu.css');
        uJavascript::IncludeFile(dirname(__FILE__) . '/menu.js');
    }
}
uEvents::AddCallback('AfterInit', 'uMenu::AddStyles');
Ejemplo n.º 15
0
 public static function Initialise()
 {
     uEvents::AddCallback('AfterInit', 'uMigrateMetadata::remove_metadata_field');
 }
Ejemplo n.º 16
0
 public static function Initialise()
 {
     modOpts::AddOption('site_online', 'Site Online', NULL, 0, itYESNO);
     uEvents::AddCallback('BeforeRunModule', 'module_Offline::siteOffline');
 }
Ejemplo n.º 17
0
 public function RunModule()
 {
     uEvents::AddCallback('ProcessDomDocument', array($this, 'ProcessDomDocument'));
     if (isset($_GET['news_id'])) {
         $rec = $this->LookupRecord($_GET['news_id']);
         if (!$rec) {
             utopia::PageNotFound();
         }
         utopia::SetTitle($rec['heading']);
         utopia::SetDescription($rec['description']);
         $n = array();
         if ($rec['noindex']) {
             $n[] = 'noindex';
         }
         if ($rec['nofollow']) {
             $n[] = 'nofollow';
         }
         if ($n) {
             utopia::AddMetaTag('robots', implode(',', $n));
         }
         echo '{widget.' . modOpts::GetOption('news_widget_article') . '}';
         return;
     }
     if (isset($_GET['tags'])) {
         utopia::SetTitle('Latest ' . ucwords($_GET['tags']) . ' News');
     }
     echo '{widget.' . modOpts::GetOption('news_widget_archive') . '}';
 }
Ejemplo n.º 18
0
 public static function Initialise()
 {
     self::AddParent('uUsersList', 'user_id', '*');
     uEvents::AddCallback('AfterRunModule', 'UserProfileDetail::RunChild', 'uUserProfile', 101);
 }
Ejemplo n.º 19
0
<?php

function initialiseTreesort()
{
    uJavascript::IncludeFile(utopia::GetRelativePath(dirname(__FILE__) . '/jquery.treeSort.js'));
    uCSS::IncludeFile(utopia::GetRelativePath(dirname(__FILE__) . '/jquery.treeSort.css'));
}
uEvents::AddCallback('AfterInit', 'initialiseTreesort');
Ejemplo n.º 20
0
 public static function Initialise()
 {
     uEvents::AddCallback('ProcessDomDocument', 'uCSS::LinkToDocument');
     uEvents::AddCallback('ProcessDomDocument', 'uCSS::ProcessDomDocument', null, MAX_ORDER);
     uEvents::AddCallback('AfterInit', 'uCSS::LinkGlobal');
     self::LinkFile(PATH_REL_ROOT . 'styles.css', -10);
     self::LinkFile(dirname(__FILE__) . '/jQuery/jquery-ui.min.css', -99);
     self::IncludeFile(PATH_REL_CORE . 'default.css');
     module_Offline::IgnoreClass(__CLASS__);
 }
Ejemplo n.º 21
0
 public function GetTitle()
 {
     $rec = self::findPage();
     if (!$rec) {
         $rec = self::GetHomepage();
     }
     if (!$rec) {
         $rec = $this->LookupRecord();
     }
     if (isset($_GET['preview']) && uEvents::TriggerEvent('CanAccessModule', 'uCMS_Edit') !== FALSE) {
         return $rec['title'] . ' (Preview)';
     }
     return $rec['title'];
 }
Ejemplo n.º 22
0
 public static function Initialise()
 {
     uEvents::AddCallback('AfterInit', 'uUserRoles::AssertAdminRole');
     self::AddParent('uUsersList');
 }
Ejemplo n.º 23
0
        return '<div class="uNotice uNotice-' . $type . '">' . $message . '</div>';
    }
    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 . '});');
        }
    }
    public static function Init()
    {
        uCSS::IncludeFile(dirname(__FILE__) . '/notices.css');
        uJavascript::IncludeFile(dirname(__FILE__) . '/notices.js');
    }
}
uEvents::AddCallback('AfterInit', 'uNotices::Init');
uEvents::AddCallback('BeforeOutputTemplate', 'uNotices::ShowNotices');
utopia::RegisterAjax('getNotices', 'uNotices::ShowNotices');
Ejemplo n.º 24
0
<?php

utopia::RegisterAjax('dataonly', 'uDataOnly::process');
uDataOnly::RegisterType('csv', 'uDataOnly::csv');
uDataOnly::RegisterType('json', 'uDataOnly::json');
uEvents::AddCallback('AfterInit', 'uDataOnly::processInjectionQueue', null, MAX_ORDER);
class uDataOnly
{
    private static $types = array();
    public static function RegisterType($type, $callback)
    {
        self::$types[$type] = $callback;
    }
    private static $queue = array();
    public static function inject($module)
    {
        self::$queue[] = $module;
    }
    public static function processInjectionQueue()
    {
        foreach (self::$queue as $module) {
            self::doInject($module);
        }
    }
    private static function doInject($obj)
    {
        if (is_string($obj)) {
            $parent = $obj;
            $obj = utopia::GetInstance($parent);
        } else {
            $parent = get_class($obj);
Ejemplo n.º 25
0
 public static function Initialise()
 {
     uEvents::AddCallback('ProcessDomDocument', 'uAdminBar::ProcessDomDocument');
 }
Ejemplo n.º 26
0
 public function ShowData()
 {
     //check pk and ptable are set up
     if (is_empty($this->GetTabledef())) {
         ErrorLog('Primary table not set up for ' . get_class($this));
         return;
     }
     echo '<h1>' . $this->GetTitle() . '</h1>';
     echo '{list.' . get_class($this) . '}';
     $row = null;
     $num_rows = 0;
     if (!isset($_GET['_n_' . $this->GetModuleId()])) {
         $this->GetLimit($limit, $page);
         $dataset = $this->GetDataset();
         $num_rows = $dataset->CountRecords();
         $row = $dataset->GetPage($page, $limit)->fetch();
     }
     $pagination = '';
     $this->GetLimit($limit);
     if ($limit) {
         $pages = max(ceil($num_rows / $limit), 1);
         ob_start();
         utopia::OutputPagination($pages, '_p_' . $this->GetModuleId());
         $pagination = ob_get_clean();
     }
     $records = $num_rows == 0 ? "There are no records to display." : 'Total Rows: ' . $num_rows;
     $pager = '<div class="right">' . $pagination . '</div>';
     uEvents::TriggerEvent('OnShowDataDetail', $this);
     if ($this->flag_is_set(ALLOW_DELETE) && $row) {
         $fltr =& $this->FindFilter($this->GetPrimaryKey(), ctEQ, itNONE);
         $delbtn = $this->GetDeleteButton($this->GetFilterValue($fltr['uid']), 'Delete Record');
         utopia::AppendVar('footer_left', $delbtn);
     }
     //		if (!$this->IsNewRecord()) { // records exist, lets get the first.
     // pagination?
     //			if (mysql_num_rows($result) > 1) {
     // multiple records exist in this set, sort out pagination
     //			}
     //		}
     $order = $this->GetSortOrder();
     $extraCount = 1;
     $secCount = count($this->layoutSections);
     foreach ($this->layoutSections as $sectionID => $sectionInfo) {
         $out = '';
         if ($secCount > 1) {
             $sectionName = $sectionInfo['title'];
             if ($sectionName === '') {
                 if ($sectionID === 0) {
                     $SN = 'General';
                 } else {
                     $SN = "Extra ({$extraCount})";
                     $extraCount++;
                 }
             } else {
                 $SN = ucwords($sectionName);
             }
             $out .= '<h2>' . $SN . '</h2>';
         }
         if (!$this->isAjax) {
             $out .= '<form class="uf" action="" onsubmit="this.action = window.location" method="post">';
         }
         $out .= "<div class=\"table-wrapper\"><table class=\"module-content layoutDetailSection\">";
         $fields = $this->GetFields(true, $sectionID);
         $hasFieldHeaders = false;
         foreach ($fields as $fieldName => $fieldData) {
             $hasFieldHeaders = $hasFieldHeaders || !empty($fieldData['visiblename']);
         }
         $fieldCount = count($fields);
         foreach ($fields as $fieldName => $fieldData) {
             $targetUrl = $this->GetTargetUrl($fieldName, $row);
             $out .= "<tr>";
             if ($hasFieldHeaders) {
                 $out .= "<td class=\"fld\">" . $fieldData['visiblename'] . "</td>";
             }
             $out .= '<td>' . $this->GetCell($fieldName, $row, $targetUrl) . '</td>';
             $out .= "</tr>";
         }
         $out .= "</table></div>";
         if (!$this->isAjax) {
             $out .= '</form>';
         }
         echo $out;
     }
     if ($num_rows > 1) {
         echo '<div class="oh"><b>' . $records . '</b>' . $pager . '</div>';
     }
 }
Ejemplo n.º 27
0
    public static function LoginForm()
    {
        if (self::IsLoggedIn()) {
            return;
        }
        ?>
<div class="login-wrap widget-container">
			<h1>Log In</h1>
			<form class="module-content" action="<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
" method="POST">
			<div class="form-field">
			<label for="__login_u">Email/Username</label>{login_user}
			</div>
			<div class="form-field">
			<label for="__login_p">Password</label>{login_pass}
			</div>
			<label><input type="checkbox" value="1" name="remember_me" /> Remember Me</label><?php 
        $o = utopia::GetInstance('uResetPassword');
        echo utopia::DrawInput('', itSUBMIT, 'Log In', null, array('class' => 'right'));
        echo '<a href="' . $o->GetURL(null) . '" class="forgotten-password">Forgotten Password?</a>';
        echo '</form><script type="text/javascript">$(function (){$(\'#__login_u\').focus()})</script>';
        uEvents::TriggerEvent('LoginButtons');
        echo '</div>';
        // register
        uEvents::TriggerEvent('AfterShowLogin');
    }
Ejemplo n.º 28
0
<?php

uEvents::AddCallback('ProcessDomDocument', 'uFavicon::LinkFavicon');
class uFavicon
{
    public static function LinkFavicon($obj, $event, $templateDoc)
    {
        // first check template, then check root.
        $iconPaths = array();
        $iconPaths[] = utopia::GetTemplateDir(false) . 'favicon.ico';
        $iconPaths[] = PATH_ABS_ROOT . 'favicon.ico';
        $iconPaths[] = PATH_ABS_CORE . 'favicon.ico';
        $head = $templateDoc->getElementsByTagName('head')->item(0);
        foreach ($iconPaths as $iconPath) {
            if (file_exists($iconPath)) {
                $node = $templateDoc->createElement('link');
                $node->setAttribute('rel', 'shortcut icon');
                $node->setAttribute('href', utopia::GetRelativePath($iconPath));
                $head->appendChild($node);
                return;
            }
        }
    }
}
Ejemplo n.º 29
0
    $row['module_name']::Initialise();
    timer_end('Init: ' . $row['module_name']);
}
timer_end('Static Initialise');
uConfig::DefineConfig();
uConfig::ValidateConfig();
uEvents::TriggerEvent('ConfigDefined');
timer_start('Before Init');
uEvents::TriggerEvent('BeforeInit');
timer_end('Before Init');
timer_start('Table Initialise');
uTableDef::TableExists(null);
// cache table exists
$allmodules = utopia::GetModulesOf('uTableDef');
foreach ($allmodules as $row) {
    // must run second due to requiring GLOB_MOD to be setup fully
    timer_start('Init: ' . $row['module_name']);
    $obj = utopia::GetInstance($row['module_name']);
    $obj->AssertTable();
    // setup Parents
    timer_end('Init: ' . $row['module_name']);
}
timer_end('Table Initialise');
define('INIT_COMPLETE', TRUE);
timer_start('After Init');
uEvents::TriggerEvent('InitComplete');
uEvents::TriggerEvent('AfterInit');
timer_end('After Init');
if ($_SERVER['HTTP_HOST'] !== 'cli') {
    utopia::UseTemplate(TEMPLATE_DEFAULT);
}