public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $data = $data->fork(); $apps = array(); foreach (Typeframe::Registry()->pages() as $page) { if ($page->siteid() == Typeframe::CurrentPage()->siteid()) { if (strpos($page->uri(), '/admin/') !== false) { if ($page->allow()) { $apps[] = array('title' => $page->title(), 'icon' => $page->icon(), 'uri' => $page->uri()); } } } } $data['applications'] = $apps; if (class_exists('Model_Site')) { $sites = new Model_Site(); if (Typeframe::User()->get('usergroupid') != TYPEF_ADMIN_USERGROUPID) { $sites->innerJoin('perm', 'Model_User_Site', 'id = perm.siteid'); $sites->where('perm.userid = ?', Typeframe::User()->get('userid')); $primary = new Model_User_Site(); $primary->where('userid = ?', Typeframe::User()->get('userid')); $primary->where('siteid = ?', 0); $data['admin_primary'] = $primary->count() > 0; } else { $data['admin_primary'] = 1; } $data['sites'] = $sites; } $data->sortNodes(array('applications', 'title')); if (defined('TYPEF_HOST')) { $data['primary_host'] = TYPEF_HOST; } parent::output($data, $stream); }
<?php if ($page->exists() && $_POST['uri'] != $page['uri']) { $realPages = new Model_Page(); $realPages->where('site.masterid = ?', $page['masterid']); $realPages->where('uri = ?', $page['uri']); //$realPages->updateQuery(array('uri' => $_POST['uri'])); foreach ($realPages->select() as $rp) { $tmp = Model_Page::Get($rp['pageid']); $tmp['uri'] = $_POST['uri']; $tmp->save(); } } $page->setArray($_POST, false); $page->save(); $sites = new Model_Site(); $sites->where('masterid = ?', $master['id']); foreach ($sites->select() as $site) { $realPages = new Model_Page(); $realPages->where('siteid = ?', $site['id']); $realPages->where('uri = ?', $page['uri']); $realPage = $realPages->getFirst(); if (!$realPage->exists()) { $realPage = Model_Page::Create(); $realPage['siteid'] = $site['id']; } $realPage->setArray($page->getArray(), false); $realPage->save(); } Typeframe::Registry()->purgeRegistryCache();
public function siteid() { if (!is_null($this->_page->siteid())) { return $this->_page->siteid(); } else { if (!defined('TYPEF_HOST')) { return 0; } if ($_SERVER['HTTP_HOST'] == TYPEF_HOST) { return 0; } $sites = new Model_Site(); $sites->where('domain = ?', $_SERVER['HTTP_HOST']); foreach ($sites->select() as $site) { if ($site['directory'] == '' || strpos($this->uri(), $site['directory']) === 0) { return $site['id']; } } } }