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']; } } } }
<?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();
private function _parseRegistry($xml) { // TODO: This is a clearly inefficient way of registering site pages // for hard-mapped applications. On the other hand, it might be efficient // enough after the registry is cached. static $sites = null; if (is_null($sites) && class_exists('Model_Site')) { $sites = array(); $model = new Model_Site(); foreach ($model->select() as $site) { $sites[] = $site->getArray(); } } foreach ($xml->application as $app) { if ($app['map'] == 'hard') { // Load application as page $tmpApp = $this->_loadApplication($app); $fullPath = TYPEF_WEB_DIR . ($app['base'] != '/' ? $app['base'] : ''); if ($fullPath == '') { $fullPath = '/'; } $this->_pages[$fullPath] = new Typeframe_Page($tmpApp, $fullPath, array('siteid' => 0)); if (!is_null($sites)) { foreach ($sites as $site) { $fullPath = TYPEF_WEB_DIR . ($site['directory'] ? "/{$site['directory']}" : '') . ($app['base'] != '/' ? $app['base'] : ''); if ($fullPath == '') { $fullPath = '/'; } $this->_pages[$site['domain'] . $fullPath] = new Typeframe_Page($tmpApp, $fullPath, array('siteid' => $site['id'])); } } } else { // Load soft application $this->_applications["{$app['name']}"] = $this->_loadApplication($app); } } }