本文整理汇总了PHP中Typeframe::Registry方法的典型用法代码示例。如果您正苦于以下问题:PHP Typeframe::Registry方法的具体用法?PHP Typeframe::Registry怎么用?PHP Typeframe::Registry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Typeframe
的用法示例。
在下文中一共展示了Typeframe::Registry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output
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: output
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: load
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: At
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: output
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: testContentPages
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: _pageMeta
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: output
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: output
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: testNewsIndex
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: output
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: __construct
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: Allow
/**
* 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: foreach
<?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: header
<?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;