示例#1
0
文件: AdminBar.php 项目: ssrsfs/blg
 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);
 }
示例#2
0
文件: Socket.php 项目: ssrsfs/blg
 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     $for = $data->parseVariables($this->getAttribute('for'));
     if (!$for) {
         throw new Exception("Socket tag requires 'for' attribute");
     }
     $plugin = null;
     $detachable = true;
     if (count($this->children())) {
         $detachable = false;
         $found = $this->_findEmptyPluginTags();
         if (count($found) == 0) {
             throw new Exception('Socket tag with content requires an empty plugin (no attributes)');
         } else {
             if (count($found) > 1) {
                 throw new Exception('Socket tag should not contain more than one empty plugin');
             }
         }
         $plugin = $found[0];
     } else {
         $plugin = new Typeframe_Tag_Plugin('plugin', array(), $this);
         $this->appendChild($plugin);
     }
     $plugins = self::_GetPluginsFor($for);
     foreach ($plugins as $p) {
         $signature = Typeframe::Registry()->getPluginSignature($p['plug']);
         $plugin->className = $signature->className();
         $plugin->settings = $p['settings'];
         $plugin->attributes['plugid'] = $p['plugid'];
         parent::output($data, $stream);
     }
     if ($detachable) {
         $plugin->detach();
     }
 }
示例#3
0
文件: Sitemap.php 项目: ssrsfs/blg
 public function load()
 {
     $this->_data = array();
     $host = 'http://' . $_SERVER['SERVER_NAME'];
     // This will retrieve all the content pages.
     if (Typeframe::Registry()->application('Content')) {
         $query = "SELECT uri, nickname,\tapplication FROM #__page";
         $rs = Typeframe::Database()->prepare($query);
         $rs->execute();
         while ($data = $rs->fetch_array()) {
             $this->_data[] = array('page' => $host . TYPEF_WEB_DIR . $data['uri'], 'uri' => $data['uri'], 'name' => $data['nickname'] != '' ? $data['nickname'] : $data['uri'], 'application' => $data['application']);
         }
     }
     // And the news pages.
     if (Typeframe::Registry()->application('News')) {
         $select = new BuildSql_Select();
         $select->table('#__news n');
         $select->leftJoin('#__news_category ncat', 'ncat.categoryid = n.categoryid');
         $select->field('n.*');
         $select->field('ncat.categoryname');
         $select->group('n.newsid');
         $select->order('n.pubdate DESC');
         $select->where('n.pubdate <= ?', Typeframe::Now());
         $rs = $this->db()->prepare($select->query());
         $rs->execute();
         while ($row = $rs->fetch_array()) {
             $uri = News::GetCategoryUri($row['categoryid']) . '/' . ($row['encodedtitle'] ? $row['encodedtitle'] : $row['newsid']);
             $this->_data[] = array('page' => $host . TYPEF_WEB_DIR . $uri, 'uri' => $uri, 'name' => $row['title'], 'application' => $row['categoryname']);
         }
     }
 }
示例#4
0
文件: Skin.php 项目: ssrsfs/blg
 public static function At($uri)
 {
     $response = Typeframe::Registry()->responseAt($uri);
     if ($response) {
         return self::_AtResponse($response);
     }
     return TYPEF_SITE_SKIN ? TYPEF_SITE_SKIN : 'default';
 }
示例#5
0
文件: Plugin.php 项目: ssrsfs/blg
 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     $db = Typeframe::Database();
     if ($this->hasAttribute('rules') && !Typeframe_Tag_Socket::ProcessRules($this->getAttribute('rules'))) {
         return '';
     }
     /*
      * Rules for loading the plugin:
      * 1. The plugid overrides other load settings.
      * 2. Load a plugin from the table if the name attribute matches an
      *    an admin-specified name.
      * 3. Create a generic plugin from a signature.
      * 4. If the plugin was loaded from the database, attribute settings
      *    override database settings.
      */
     $p = null;
     if ($this->getAttribute('plugid')) {
         $plugin = Model_Plug::Get($data->parseVariables($this->getAttribute('plugid')));
         if ($plugin->exists()) {
             $p = Typeframe::Registry()->getPluginSignature($plugin['plug']);
         }
     } else {
         if ($this->getAttribute('name')) {
             $plugins = new Model_Plug();
             $plugins->where('name = ?', $data->parseVariables($this->getAttribute('name')));
             $plugin = $plugins->getFirst();
             if ($plugin->exists()) {
                 $p = Typeframe::Registry()->getPluginSignature($plugin['plug']);
             } else {
                 $p = Typeframe::Registry()->getPluginSignature($this->getAttribute('name'));
             }
         }
     }
     if ($p) {
         $cls = $p->className();
         if (class_exists($cls)) {
             $settings = $this->settings;
             foreach ($this->attributes() as $k => $v) {
                 $settings[$k] = $data->parseVariables($v);
             }
             //$obj = new $cls($settings);
             $obj = new $cls('plugin', $settings, null);
             foreach ($this->children() as $child) {
                 $obj->appendChild($child);
             }
             $obj->process($data, $stream);
             foreach ($obj->children() as $child) {
                 $this->appendChild($child);
             }
             $obj->detach();
         } else {
             throw new Exception("Class '{$cls}' does not exist");
         }
     } else {
         throw new Exception("Plugin does not have a signature");
     }
 }
示例#6
0
 public function testContentPages()
 {
     /* Assertions:
      * All content pages return a 200 or 403 response code
      */
     $contentPages = Typeframe::Registry()->applicationUrls('Content');
     $this->assertTrue($contentPages, "No content pages to test.");
     foreach ($contentPages as $page) {
         $this->get($page);
         $this->assertTrue(in_array($this->responseCode(), array(200, 403)), "{$this->currentUrl()} returned response code {$this->responseCode()}");
     }
 }
示例#7
0
文件: Page.php 项目: ssrsfs/blg
function _pageMeta($record)
{
    // Do not try to load the admin path from the registry until the registry
    // has been loaded. This is necessary to avoid causing infinite loops when
    // the registry uses Model_Page to load page data.
    if (Typeframe::RegistryLoaded()) {
        $response = Typeframe::Registry()->applicationAt(TYPEF_WEB_DIR . $record['uri']);
        if ($response) {
            $record['fullpath'] = $response->uri();
            if ($response->application()->admin()) {
                $record['admin'] = TYPEF_WEB_DIR . ($record['site']['directory'] ? '/' . $record['site']['directory'] : '') . $response->application()->admin();
            } else {
                $record['admin'] = '';
            }
        }
    }
}
示例#8
0
 public function output(\Pagemill_Data $data, \Pagemill_Stream $stream)
 {
     $data = $data->fork();
     $url = Typeframe::CurrentPage()->uri();
     if (substr($url, -1) == '/') {
         $url = substr($url, 0, -1);
     }
     $dirs = explode('/', substr($url, strlen(TYPEF_WEB_DIR)));
     $this->pluginTemplate = '/breadcrumbs/breadcrumbs.plug.html';
     $data['breadcrumbs'] = array();
     $currentUrl = TYPEF_WEB_DIR;
     $start = $data->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($this->getAttribute('start')));
     while (count($dirs) > 0) {
         $currentUrl .= '/' . array_shift($dirs);
         $currentUrl = preg_replace('/\\/+/', '/', $currentUrl);
         if ($start && strpos($currentUrl, $start) === false) {
             continue;
         }
         if (isset($_SESSION['breadcrumbs'][$currentUrl])) {
             $bc = $_SESSION['breadcrumbs'][$currentUrl];
             $bc['url'] = $currentUrl . ($bc['query'] ? '?' . $bc['query'] : '');
             $data['breadcrumbs'][] = $bc;
         } else {
             $response = Typeframe::Registry()->responseAt($currentUrl);
             if ($currentUrl == $response->page()->uri()) {
                 if ($response->application()->name() != '403' && $response->application()->name() != '404') {
                     $settings = $response->page()->settings();
                     if (!empty($settings['nickname'])) {
                         $title = $settings['nickname'];
                     } else {
                         $title = $response->page()->title();
                     }
                     $bc = array('title' => $title, 'query' => '');
                     $_SESSION['breadcrumbs'][$currentUrl] = $bc;
                     $bc['url'] = $currentUrl;
                     $data['breadcrumbs'][] = $bc;
                 }
             }
         }
     }
     parent::output($data, $stream);
     return;
 }
示例#9
0
 public function output(\Pagemill_Data $data, \Pagemill_Stream $stream)
 {
     $plugid = $data->parseVariables($this->getAttribute('plugid'));
     $plug = Model_Plug::Get($plugid);
     if ($plug->exists()) {
         $name = $plug['plug'];
         $sig = Typeframe::Registry()->getPluginSignature($name);
         $cls = $sig->className();
         if (is_subclass_of($cls, 'Plugin')) {
             $plug['settings']['plugid'] = $plugid;
             $plug = new $cls('', $plug['settings'], $this);
             $plug->admin($data, $stream);
         } else {
             throw new Exception("Invalid plugin type specified");
         }
     } else {
         throw new Exception("Invalid plugin specified");
     }
 }
示例#10
0
 public function testNewsIndex()
 {
     /* Assertions:
      * Site has at least one news page (required for tests).
      * All pages return 200 (public) or 403 (login required).
      * At least one news page is public (required for tests).
      */
     $newsPages = Typeframe::Registry()->applicationUrls('News');
     $this->assertTrue(count($newsPages), "No news pages to test.");
     foreach ($newsPages as $page) {
         $this->get($page);
         if (Typeframe::Allow($page)) {
             $validResponse = 200;
             $this->availablePage = $page;
         } else {
             $validResponse = 403;
         }
         $this->assertTrue($this->responseCode() == $validResponse, "{$page} returned {$this->responseCode()} (expected {$validResponse})");
     }
     $this->assertTrue(count($newsPages) == 0 || $this->availablePage, "No public news pages available for tests.");
 }
示例#11
0
文件: AdminTree.php 项目: ssrsfs/blg
 public function output(\Pagemill_Data $data, \Pagemill_Stream $stream)
 {
     $this->pluginTemplate = '/admin/admintree.plug.html';
     $data = $data->fork();
     $apps = array();
     foreach (Typeframe::Registry()->pages() as $page) {
         if (strpos($page->uri(), TYPEF_WEB_DIR . '/admin/') === 0) {
             $category = $page->application()->category() ? $page->application()->category() : 'Other';
             if (!isset($apps[$category])) {
                 $apps[$category] = array();
             }
             $apps[$category][] = array('title' => $page->title(), 'icon' => $page->icon(), 'uri' => $page->uri());
         }
     }
     ksort($apps);
     $categories = array();
     foreach ($apps as $category => $applications) {
         $categories[] = array('name' => $category, 'applications' => $applications);
     }
     $data['categories'] = $categories;
     parent::output($data, $stream);
 }
示例#12
0
文件: Doctype.php 项目: ssrsfs/blg
 public function __construct($nsPrefix)
 {
     $this->nsUri = 'http://typeframe.com/pagemill';
     parent::__construct($nsPrefix);
     $this->registerTag('socket', 'Typeframe_Tag_Socket');
     $this->registerTag('plugin', 'Typeframe_Tag_Plugin');
     $this->registerTag('pluginadmin', 'Typeframe_Tag_PluginAdmin');
     $this->registerTag('html', 'Typeframe_Tag_Html');
     $this->registerTag('head', 'Typeframe_Tag_Head');
     $this->registerTag('body', 'Typeframe_Tag_Body');
     $this->registerTag('import', 'Typeframe_Tag_Import');
     $this->registerTag('include', 'Typeframe_Tag_Include');
     $this->registerTag('editor', 'Typeframe_Tag_Editor');
     $this->registerTag('calendar', 'Typeframe_Tag_Calendar');
     $this->registerTag('select', 'Typeframe_Tag_Select');
     // TODO: Deprecate
     $this->registerTag('insert', 'Typeframe_Tag_Insert');
     $this->registerTag('group', 'Typeframe_Tag_Group');
     $this->registerTag('scriptonce', 'Typeframe_Tag_Scriptonce');
     $this->registerTag('codeblock', 'Typeframe_Tag_Codeblock');
     $this->registerTag('debug', 'Typeframe_Tag_Debug');
     $this->registerTag('timg', 'Typeframe_Tag_Timg');
     // TODO: Deprecate
     $this->registerTag('/body', 'Typeframe_Tag_Html_Body');
     $this->registerTag('fileupload', 'Typeframe_Tag_FileUpload');
     $this->registerTag('imageupload', 'Typeframe_Tag_ImageUpload');
     $this->registerTag('postlink', 'Typeframe_Tag_Postlink');
     $this->registerTag('checkbox', 'Typeframe_Tag_Checkbox');
     foreach (Typeframe::Registry()->tags() as $tag) {
         $this->registerTag($tag['name'], $tag['class']);
     }
     $this->registerAttribute('/href', 'Typeframe_Attribute_Url');
     $this->registerAttribute('/src', 'Typeframe_Attribute_Url');
     $this->registerAttribute('/action', 'Typeframe_Attribute_Url');
     $this->registerAttribute('method', 'Typeframe_Attribute_Method');
     $this->registerAttribute('confirm', 'Typeframe_Attribute_Confirm');
 }
示例#13
0
文件: Typeframe.php 项目: ssrsfs/blg
 /**
  * Return true if the current user is allowed to access the specified URI.
  * @param string $uri The complete path to the page (e.g., "/foo/bar").
  * @return bool
  */
 public static function Allow($uri)
 {
     if (substr($uri, 0, 2) == '~/') {
         $uri = TYPEF_WEB_DIR . substr($uri, 1);
     }
     if (substr($uri, 0, strlen(TYPEF_WEB_DIR)) != TYPEF_WEB_DIR) {
         return null;
     }
     $response = Typeframe::Registry()->responseAt($uri);
     if ($response) {
         return $response->page()->allow();
     }
     trigger_error("{$uri} is not part of a registered application.");
     return null;
 }
示例#14
0
文件: index.php 项目: ssrsfs/blg
<?php

$db = Typeframe::Database();
$pm = Typeframe::Pagemill();
Typeframe::SetPageTemplate('/admin/applications/index.html');
foreach (Typeframe::Registry()->applications() as $a) {
    $app = array('name' => $a->name(), 'title' => $a->title(), 'map' => $a->map());
    $pm->addLoop('applications', $app);
    if ($a->map() == 'hard') {
        $pm->addLoop('applications', 'pages', array('uri' => TYPEF_WEB_DIR . $a->base()));
    } else {
        // TODO: Figure out what to do about soft-mapped pages
        /*
        foreach (Typeframe::Registry()->getApplicationPagesByName($a->name()) as $p) {
        	$pm->addLoop('applications', 'pages', array('uri' => $p->uri()));
        }
        */
    }
}
$pm->sortLoop('applications', 'name');
示例#15
0
文件: urls.php 项目: ssrsfs/blg
<?php

header('Content-Type: text/plain');
if (empty($_REQUEST['q'])) {
    echo '';
} else {
    $results = array();
    foreach (Typeframe::Registry()->pages() as $app) {
        if (strpos($app->uri(), $_REQUEST['q']) !== false) {
            if (strpos($app->uri(), TYPEF_WEB_DIR . '/admin') !== 0) {
                $results[] = $app->uri;
            }
        }
    }
    sort($results);
    $results = array_unique($results);
    echo implode("\n", $results);
}
exit;
示例#16
0
文件: update.inc.php 项目: ssrsfs/blg
<?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();
示例#17
0
文件: news.php 项目: ssrsfs/blg
<?php

/**
 * This script was automatically generated. Instead of modifying it directly,
 * the best practice is to modify the corresponding <config> element in the
 * Typeframe registry and regenerate this script with the tfadmin.php tool.
 *
 * The primary purpose of this script is to document the constants defined in
 * the application registry so they are discoverable in IDEs.
 */
/**
 * Permanently redirect to friendly article URLs (default: '1')
 */
define('TYPEF_NEWS_ARTICLE_REDIRECT', Typeframe::Registry()->getConfigValue('TYPEF_NEWS_ARTICLE_REDIRECT'));
/**
 * Permanently redirect to friendly category URLs (default: '1')
 */
define('TYPEF_NEWS_CATEGORY_REDIRECT', Typeframe::Registry()->getConfigValue('TYPEF_NEWS_CATEGORY_REDIRECT'));
/**
 * Alert administrators when # days pass without a new article (0 for never) (default: '7')
 */
define('TYPEF_NEWS_OVERDUE_ALERT', Typeframe::Registry()->getConfigValue('TYPEF_NEWS_OVERDUE_ALERT'));
/**
 * Keep original URL when updating published articles (default: '1')
 */
define('TYPEF_NEWS_RETAIN_URL', Typeframe::Registry()->getConfigValue('TYPEF_NEWS_RETAIN_URL'));
/**
 * Permitted file extensions for files attached to articles (blank for any) (default: 'pdf,txt')
 */
define('NEWS_FILE_EXTENSIONS', Typeframe::Registry()->getConfigValue('NEWS_FILE_EXTENSIONS'));
示例#18
0
文件: comments.php 项目: ssrsfs/blg
 * the application registry so they are discoverable in IDEs.
 */
/**
 * Disable all comments (default: '0')
 */
define('COMMENTS_DISABLED', Typeframe::Registry()->getConfigValue('COMMENTS_DISABLED'));
/**
 * Require approval for comments (default: '1')
 */
define('COMMENTS_REQUIRE_APPROVAL', Typeframe::Registry()->getConfigValue('COMMENTS_REQUIRE_APPROVAL'));
/**
 * Require login for comments (default: '0')
 */
define('COMMENTS_REQUIRE_LOGIN', Typeframe::Registry()->getConfigValue('COMMENTS_REQUIRE_LOGIN'));
/**
 * Require captcha for guest comments (default: '1')
 */
define('COMMENTS_REQUIRE_CAPTCHA', Typeframe::Registry()->getConfigValue('COMMENTS_REQUIRE_CAPTCHA'));
/**
 * Spam honeypot field (default: 'website')
 */
define('COMMENTS_SPAM_HONEYPOT', Typeframe::Registry()->getConfigValue('COMMENTS_SPAM_HONEYPOT'));
/**
 * Notify commenters of rejection by email (default: '0')
 */
define('COMMENTS_EMAIL_REJECTION', Typeframe::Registry()->getConfigValue('COMMENTS_EMAIL_REJECTION'));
/**
 * Notify commenters of approval by email (default: '0')
 */
define('COMMENTS_EMAIL_APPROVAL', Typeframe::Registry()->getConfigValue('COMMENTS_EMAIL_APPROVAL'));
示例#19
0
文件: index.php 项目: ssrsfs/blg
<?php

/**
 * Typeframe Config application
 *
 * admin index controller
 */
foreach (Typeframe::Registry()->configs() as $config) {
    $pm->addLoop('configs', array('name' => $config->name()));
}
$pm->sortLoop('configs', 'name');
示例#20
0
文件: Response.php 项目: ssrsfs/blg
 /**
  * Get the Typeframe_Response object for the specified URL.
  * @param string $url
  * @return \Typeframe_Response
  */
 public static function At($url)
 {
     $response = new Typeframe_Response();
     if ($url == '') {
         $url = '/';
     }
     if (substr($url, 0, 1) == '/') {
         if (isset($_SERVER['HTTP_HOST']) && defined('TYPEF_HOST')) {
             $url = $_SERVER['HTTP_HOST'] . $url;
         } else {
             $url = (defined('TYPEF_HOST') ? TYPEF_HOST : '') . $url;
         }
     } else {
         if (substr($url, 0, 7) == 'http://' || substr($url, 0, 8) == 'https://') {
             $parts = parse_url($url);
             $url = $parts['domain'] . $parts['path'] . (!empty($parts['query']) ? '?' . $parts['query'] : '');
         }
     }
     if ($url != '/' && substr($url, -1, 1) == '/') {
         $url = substr($url, 0, -1);
     }
     $response->_url = $url;
     if (substr($response->_url, -1) == '/') {
         $response->_url = substr($response->_url, 0, -1);
     }
     $pages = Typeframe::Registry()->pages();
     /*if (substr($url, 0, 1) != '/') {
     			$host = substr($url, 0, strpos($url, '/'));
     		} else {
     			$host = '';
     		}*/
     $host = defined('TYPEF_HOST') ? @$_SERVER['HTTP_HOST'] : '';
     $uri = strpos($url, '?') !== false ? substr($url, 0, strlen(strpos($url, '?'))) : $url;
     $uri = preg_replace('/\\/+/', '/', $uri);
     if (substr($uri, 0, -1) == '/') {
         $uri = substr($uri, 0, -1);
     }
     $relativeUri = substr($uri, strlen(TYPEF_WEB_DIR) + (defined('TYPEF_HOST') ? strlen($host ? $host : TYPEF_HOST) : 0));
     $dirs = explode('/', $relativeUri);
     while (count($dirs)) {
         $uri = strpos($url, '?') !== false ? substr($url, 0, strlen(strpos($url, '?'))) : $url;
         $uri = preg_replace('/\\/+/', '/', $uri);
         if (substr($uri, 0, -1) == '/') {
             $uri = substr($uri, 0, -1);
         }
         $relativeUri = substr($uri, strpos($uri, '/') + strlen(TYPEF_WEB_DIR));
         $currentPath = $host . TYPEF_WEB_DIR . '/' . implode('/', $dirs);
         $currentPath = preg_replace('/\\/+/', '/', $currentPath);
         if (substr($currentPath, -1) == '/') {
             $currentPath = substr($currentPath, 0, -1);
         }
         if (!isset($pages[$currentPath]) && substr($currentPath, 0, strlen($host)) == $host) {
             $currentPath = substr($currentPath, strlen($host));
             $uri = substr($uri, strlen($host));
         }
         if (isset($pages[$currentPath])) {
             $currentPage = $pages[$currentPath];
             $uriWithoutDomain = substr($uri, 0, 1) == '/' ? $uri : substr($uri, strlen($host));
             $controllerPath = null;
             if ($currentPath && strlen($uri) > strlen($currentPath) && strpos($uri, $currentPath) === 0) {
                 $controllerPath = TYPEF_SOURCE_DIR . '/controllers' . $currentPage->application()->base() . substr($uriWithoutDomain, strlen($currentPage->uri()));
                 if (file_exists($controllerPath . '.php') && is_file($controllerPath . '.php')) {
                     $response->_controller = $controllerPath . '.php';
                     $response->_page = $currentPage;
                     break;
                 } else {
                     if (file_exists($controllerPath . '/index.php') && is_file($controllerPath . '/index.php')) {
                         $response->_controller = $controllerPath . '/index.php';
                         $response->_page = $currentPage;
                         break;
                     } else {
                         $controllerPath = null;
                         foreach ($currentPage->extenders() as $extender) {
                             if (defined('TYPEF_HOST') && substr($uri, 0, strlen($host)) == $host) {
                                 $pathinfo = substr($uri, strlen($host) + strlen($extender->path()));
                             } else {
                                 $pathinfo = substr($uri, strlen($extender->path()));
                             }
                             //if (substr($uri, strlen($host), strlen($extender->path())) == $extender->path()) {
                             //$extended = substr($uri, strlen($host) + strlen($extender->path()));
                             //if (preg_match($extender->preg(), $extended)) {
                             if (preg_match($extender->preg(), $pathinfo)) {
                                 $response->_pathInfo = substr($pathinfo, 1);
                                 if ($extender->redirect()) {
                                     $controllerPath = TYPEF_SOURCE_DIR . '/controllers' . $extender->redirect();
                                 } else {
                                     $controllerPath = TYPEF_SOURCE_DIR . '/controllers' . $currentPage->application()->base();
                                 }
                                 break;
                             }
                             //}
                         }
                     }
                 }
             } else {
                 if ($currentPath == $uri) {
                     $controllerPath = TYPEF_SOURCE_DIR . '/controllers' . $currentPage->application()->base();
                     if (file_exists($controllerPath . '.php') && is_file($controllerPath . '.php')) {
                         $response->_controller = $controllerPath . '.php';
                         $response->_page = $currentPage;
                         break;
                     } else {
                         if (file_exists($controllerPath . '/index.php') && is_file($controllerPath . '/index.php')) {
                             $response->_controller = $controllerPath . '/index.php';
                             $response->_page = $currentPage;
                             break;
                         }
                     }
                 } else {
                     $controllerPath = TYPEF_SOURCE_DIR . '/controllers' . $currentPage->application()->base();
                     $response->_pathInfo = substr($uri, strlen($currentPath) + 1);
                 }
             }
             if (!is_null($controllerPath)) {
                 if (file_exists($controllerPath . '.php') && is_file($controllerPath . '.php')) {
                     $response->_controller = $controllerPath . '.php';
                 } else {
                     if (file_exists($controllerPath . '/index.php') && is_file($controllerPath . '/index.php')) {
                         $response->_controller = $controllerPath . '/index.php';
                     }
                 }
             }
             if ($response->_controller) {
                 $response->_page = $currentPage;
                 break;
             }
         }
         array_pop($dirs);
     }
     if ($response->_controller && $response->_page) {
         $response->_controller = preg_replace('/\\/+/', '/', $response->_controller);
         if (!$response->_page->allow()) {
             $response->_return403();
         }
     } else {
         $response->_return404();
     }
     return $response;
 }
示例#21
0
文件: kernel.php 项目: ssrsfs/blg
 */
define('TYPEF_MAILER_PASSWORD', Typeframe::Registry()->getConfigValue('TYPEF_MAILER_PASSWORD'));
/**
 * Security (for SMTP authentication) (default: '')
 */
define('TYPEF_MAILER_SECURE', Typeframe::Registry()->getConfigValue('TYPEF_MAILER_SECURE'));
/**
 * Site skin (default: 'default')
 */
define('TYPEF_SITE_SKIN', Typeframe::Registry()->getConfigValue('TYPEF_SITE_SKIN'));
/**
 * Admin skin (default: 'default')
 */
define('TYPEF_ADMIN_SKIN', Typeframe::Registry()->getConfigValue('TYPEF_ADMIN_SKIN'));
/**
 * Enable mobile skins (default: '0')
 */
define('TYPEF_USE_MOBILE_SKINS', Typeframe::Registry()->getConfigValue('TYPEF_USE_MOBILE_SKINS'));
/**
 * Mobile site skin (default: 'default')
 */
define('TYPEF_MOBILE_SITE_SKIN', Typeframe::Registry()->getConfigValue('TYPEF_MOBILE_SITE_SKIN'));
/**
 * Mobile admin skin (default: 'default')
 */
define('TYPEF_MOBILE_ADMIN_SKIN', Typeframe::Registry()->getConfigValue('TYPEF_MOBILE_ADMIN_SKIN'));
/**
 * Try to use LESS versions of registered stylesheets (default: '1')
 */
define('TYPEF_LESS', Typeframe::Registry()->getConfigValue('TYPEF_LESS'));
示例#22
0
文件: user.php 项目: ssrsfs/blg
 */
define('TYPEF_ALLOW_LOGIN_COOKIE', Typeframe::Registry()->getConfigValue('TYPEF_ALLOW_LOGIN_COOKIE'));
/**
 * # days to store login cookies (default: '90')
 */
define('TYPEF_LOGIN_COOKIE_EXPIRE', Typeframe::Registry()->getConfigValue('TYPEF_LOGIN_COOKIE_EXPIRE'));
/**
 * Require email confirmation (default: '1')
 */
define('TYPEF_REQUIRE_CONFIRMATION', Typeframe::Registry()->getConfigValue('TYPEF_REQUIRE_CONFIRMATION'));
/**
 * Allow temp login without confirmation (default: '0')
 */
define('TYPEF_TEMP_AFTER_REG', Typeframe::Registry()->getConfigValue('TYPEF_TEMP_AFTER_REG'));
/**
 * Require admin approval to activate accounts (default: '0')
 */
define('TYPEF_REQUIRE_APPROVAL', Typeframe::Registry()->getConfigValue('TYPEF_REQUIRE_APPROVAL'));
/**
 * Email users when admin approval is required (default: '0')
 */
define('TYPEF_REQUIRE_APPROVAL_NOTIFICATION', Typeframe::Registry()->getConfigValue('TYPEF_REQUIRE_APPROVAL_NOTIFICATION'));
/**
 * Email these addresses when a user registers (default: '')
 */
define('TYPEF_REGISTRATION_NOTIFICATION', Typeframe::Registry()->getConfigValue('TYPEF_REGISTRATION_NOTIFICATION'));
/**
 * Authentication mechanism to use by default (default: 'Hash')
 */
define('TYPEF_AUTH_DEFAULT', Typeframe::Registry()->getConfigValue('TYPEF_AUTH_DEFAULT'));
示例#23
0
文件: Page.dep.php 项目: ssrsfs/blg
 private function _executeTriggers($when)
 {
     if ($this->stopped()) {
         return;
     }
     $currentPath = $this->path();
     foreach (Typeframe::Registry()->getTriggersWhen($when) as $trigger) {
         $triggerOnPath = false;
         if ($trigger->path() == $currentPath) {
             $triggerOnPath = true;
         } else {
             if (substr($trigger->path(), 0, 1) == '*') {
                 $triggerOnPath = true;
             } else {
                 $asterisk = strpos($trigger->path(), '*');
                 if ($asterisk !== false) {
                     $path = substr($trigger->path(), 0, $asterisk);
                     if ($currentPath == $path) {
                         $triggerOnPath = true;
                     } else {
                         if (substr($currentPath, 0, strlen($path)) == $path) {
                             if (substr($trigger->path(), $asterisk - 1, 1) == '/') {
                                 $triggerOnPath = true;
                             } else {
                                 if (substr($currentPath, $asterisk, 1) == '/') {
                                     $triggerOnPath = true;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($triggerOnPath) {
             Typeframe::IncludeScript($trigger->script());
         }
         if (Typeframe::CurrentPage()->stopped()) {
             return;
         }
     }
 }
示例#24
0
文件: unit.php 项目: ssrsfs/blg
 public function testConfigItemsAreDefined()
 {
     $configs = Typeframe::Registry()->configs();
     foreach ($configs as $config) {
         foreach ($config->items() as $item) {
             $this->assertTrue(defined($item->name()), "Config item '{$item->name()}' is not defined");
         }
     }
 }
示例#25
0
文件: admin.php 项目: ssrsfs/blg
<?php

/**
 * This script was automatically generated. Instead of modifying it directly,
 * the best practice is to modify the corresponding <config> element in the
 * Typeframe registry and regenerate this script with the tfadmin.php tool.
 *
 * The primary purpose of this script is to document the constants defined in
 * the application registry so they are discoverable in IDEs.
 */
/**
 * Default Page Application (default: '')
 */
define('PAGES_DEFAULT_APPLICATION', Typeframe::Registry()->getConfigValue('PAGES_DEFAULT_APPLICATION'));
示例#26
0
文件: add.php 项目: ssrsfs/blg
<?php

/**
 * Create a new plugin.
 */
Plugin_Breadcrumbs::Add('Add');
// save typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// process form
if ('POST' == $_SERVER['REQUEST_METHOD']) {
    $plug = Model_Plug::Create();
    $plug->set('plug', $_POST['plug']);
    //$plug->set('settings', json_encode((isset($_POST['settings']) && is_array($_POST['settings'])) ? $_POST['settings'] : array()));
    $plug->set('settings', isset($_POST['settings']) && is_array($_POST['settings']) ? $_POST['settings'] : array());
    $plug['siteid'] = Typeframe::CurrentPage()->siteid();
    $plug->save();
    // done
    $skin = isset($_REQUEST['skin']) ? "&skin={$_REQUEST['skin']}" : '';
    Typeframe::Redirect('Plugin created.', "{$typef_app_dir}/edit?plugid=" . $plug->get('plugid') . $skin);
    return;
}
// load plugins; add to template; sort by name
foreach (Typeframe::Registry()->plugins() as $plugin) {
    $pm->addLoop('plugins', array('name' => $plugin->name()));
}
$pm->sortLoop('plugins', 'name');
示例#27
0
文件: content.php 项目: ssrsfs/blg
<?php

/**
 * This script was automatically generated. Instead of modifying it directly,
 * the best practice is to modify the corresponding <config> element in the
 * Typeframe registry and regenerate this script with the tfadmin.php tool.
 *
 * The primary purpose of this script is to document the constants defined in
 * the application registry so they are discoverable in IDEs.
 */
/**
 * Default Template (default: 'generic.html')
 */
define('CONTENT_DEFAULT_TEMPLATE', Typeframe::Registry()->getConfigValue('CONTENT_DEFAULT_TEMPLATE'));
/**
 * Use the page's CSS to style WYSIWYG editors (default: '1')
 */
define('CONTENT_USE_PAGE_STYLE', Typeframe::Registry()->getConfigValue('CONTENT_USE_PAGE_STYLE'));
示例#28
0
文件: urlmeta.php 项目: ssrsfs/blg
<?php

/**
 * This script was automatically generated. Instead of modifying it directly,
 * the best practice is to modify the corresponding <config> element in the
 * Typeframe registry and regenerate this script with the tfadmin.php tool.
 *
 * The primary purpose of this script is to document the constants defined in
 * the application registry so they are discoverable in IDEs.
 */
/**
 * CSS Selector for Labels (default: 'title')
 */
define('URLMETA_LABEL_SELECTOR', Typeframe::Registry()->getConfigValue('URLMETA_LABEL_SELECTOR'));
示例#29
0
}
$pm->addLoop('usergroups', array('usergroupid' => '0', 'usergroupname' => 'Everyone', 'selected' => in_array(0, $selected) ? true : false));
foreach ($usergroups->getAll() as $usergroup) {
    if (in_array($usergroup['usergroupid'], $selected)) {
        $usergroup['selected'] = true;
    }
    $pm->addLoop('usergroups', $usergroup);
}
foreach (Typeframe::Registry()->applications() as $app) {
    //if ('soft' == $app->map())
    $pm->addLoop('applications', array('application' => $app->name()));
}
$pm->sortLoop('applications', 'application');
if (PAGES_DEFAULT_APPLICATION) {
    $app = Typeframe::Registry()->application(PAGES_DEFAULT_APPLICATION);
    //if ($app && ('soft' == $app->map()))
    if ($app) {
        $pm->setVariable('application', PAGES_DEFAULT_APPLICATION);
    }
}
// add skins to template
foreach (Typeframe::GetSkins() as $skin) {
    $pm->addLoop('skins', array('skin' => $skin));
}
$pm->setVariable('typef_site_skin', TYPEF_SITE_SKIN);
$application = Typeframe::Registry()->application($page['application']);
if ($application && $application->admin()) {
    if (file_exists(TYPEF_SOURCE_DIR . '/scripts' . $application->admin() . '/settings.php')) {
        Typeframe::IncludeScript($application->admin() . '/settings.php');
    }
}
示例#30
0
文件: UrlMeta.php 项目: ssrsfs/blg
 /**
  * Get URL metadata for a URL.
  * @param string $url The URL. If null, use the current page.
  * @param boolean $create Create a new record if the URL is valid.
  * @param string $newLabel The label for the URL if it doesn't exist.
  * @return Dbi_Record The URL metadata record.
  */
 public static function GetUrl($url = null, $create = true, $newLabel = '')
 {
     if (is_null($url)) {
         //$url = Typeframe::CurrentPage()->uri();
         //$app = Typeframe::CurrentPage()->application();
         $url = Typeframe::CurrentPage()->uri();
         if (substr($url, 0, -1) == '/') {
             $url = substr($url, -1);
         }
         $response = Typeframe::CurrentPage();
     } else {
         $url = parse_url($url, PHP_URL_PATH);
         if (substr($url, 0, -1) == '/') {
             $url = substr($url, -1);
         }
         $url = preg_replace('/\\/+/', '/', $url);
         //$app = Typeframe::Registry()->applicationAt($url);
         $response = Typeframe::Registry()->responseAt($url);
     }
     $app = $response->application();
     // Return a blank (nonexistent) Dbi_Record for invalid URLs
     if (!$app) {
         return Model_UrlMeta::Create();
     }
     $model = new Model_UrlMeta();
     $model->where('pageid = ?', $response->pageid());
     if ($response->pageid()) {
         $pathinfo = substr($url, strlen($response->applicationUri()));
     } else {
         $pathinfo = substr($response->applicationUri(), strlen(TYPEF_WEB_DIR));
     }
     if ($pathinfo == '/') {
         $pathinfo = '';
     }
     $model->where('pathinfo = ?', $pathinfo);
     $urlmeta = $model->getFirst();
     if (!$urlmeta->exists() && $create) {
         // Record does not exist. Generate a label and save it.
         $urlmeta['pageid'] = $response->pageid();
         $urlmeta['pathinfo'] = $pathinfo;
         if (!$newLabel) {
             // We need to save the metadata before we request the URL by proxy. Otherwise it's hammers all the way down.
             $urlmeta->save();
             // Create a label for the URL metadata
             $html = Typeframe::GetByProxy($url);
             if (!$html) {
                 return Model_UrlMeta::Create();
             } else {
                 $xml = @Pagemill_SimpleXmlElement::LoadString($html);
                 if ($xml) {
                     $selector = URLMETA_LABEL_SELECTOR ? URLMETA_LABEL_SELECTOR : 'title';
                     $parts = explode(',', $selector);
                     foreach ($parts as $part) {
                         if (trim($part)) {
                             $elements = $xml->select(trim($part));
                             if ($elements) {
                                 $urlmeta['label'] = trim($elements[0]->innerXml());
                                 break;
                             }
                         }
                     }
                 }
             }
             if (!$urlmeta['label']) {
                 $urlmeta['label'] = $app->title();
             }
         } else {
             $urlmeta['label'] = $newLabel;
         }
         $urlmeta->save();
     }
     return $urlmeta;
 }