当前位置: 首页>>代码示例>>PHP>>正文


PHP Context::setContent方法代码示例

本文整理汇总了PHP中Context::setContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::setContent方法的具体用法?PHP Context::setContent怎么用?PHP Context::setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Context的用法示例。


在下文中一共展示了Context::setContent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testPlacementPrepend

 public function testPlacementPrepend()
 {
     $context = new Context();
     $context->add('content', array('name' => 'one', 'placement' => 'prepend'));
     $context->add('content', array('name' => 'two'));
     $context->setContent('one', 'outer');
     $context->setContent('two', 'inner');
     $expected = 'outerinner';
     $actual = $context->render();
     $this->assertEquals($expected, $actual);
 }
开发者ID:urbanetter,项目名称:muentschi,代码行数:11,代码来源:DecoratorTest.php

示例2: createContext

 /**
  * Creates a sub context of the given name
  * @param string $name the context name
  * @param string $id the id of the new context
  * @return Context The created context
  */
 public function createContext($name, $id = null)
 {
     $context = new Context($name, $id);
     $id = $context->id();
     // add selectors
     foreach ($this->_selectors as $key => $selector) {
         $parts = explode(' ', $key);
         // handle nested selectors
         $first = array_shift($parts);
         if (count($parts) > 0 && $context->applies($first)) {
             $key = implode(' ', $parts);
         }
         $context->_selectors[$key] = $selector;
     }
     // add tags and ids
     $context->_tags = $this->_tags;
     $context->_ids = $this->_ids;
     // add content
     $context->_content = $this->_content;
     $content = $this->getContent();
     if (is_array($content) && isset($content[$id])) {
         $content = $content[$id];
     }
     $context->setContent($name, $content);
     self::$_log[] = '[Context] Creating context ' . $name . ' with id ' . $id;
     return $context;
 }
开发者ID:urbanetter,项目名称:muentschi,代码行数:33,代码来源:Context.php

示例3: testTableWithIds

 public function testTableWithIds()
 {
     $context = new Context('table');
     $context->add('table');
     $context->add('contexts', 'row');
     $context->select('row')->add('tr')->add('contexts', 'column');
     $context->select('column')->add('td')->add('content');
     $context->ids('column', 'name,email');
     $data = array(array('id' => 23, 'name' => 'Peter', 'email' => 'peter@alps.ch'), array('id' => 17, 'name' => 'Heidi', 'email' => 'heidi@alps.ch'));
     $context->setContent($data);
     $expected = '<table><tr><td>Peter</td><td>peter@alps.ch</td></tr><tr><td>Heidi</td><td>heidi@alps.ch</td></tr></table>';
     $actual = $context->render();
     $this->assertEquals($expected, $actual);
 }
开发者ID:urbanetter,项目名称:muentschi,代码行数:14,代码来源:ContextFunctionalTest.php

示例4: testSettingEmptyContentIfParamMatchesName

 public function testSettingEmptyContentIfParamMatchesName()
 {
     $context = new Context('test');
     $content = array();
     $context->setContent('test', $content);
     $actual = $context->getContent('test');
     $this->assertEquals(array(), $actual);
 }
开发者ID:urbanetter,项目名称:muentschi,代码行数:8,代码来源:ContextTest.php

示例5: Context

$ctx = new Context($_GET, $_POST, $_SERVER);
if ($ctx->isFile()) {
    readfile('.' . $ctx->getPath());
    exit;
} else {
    if (preg_match('/\\.php$/', $ctx->getPath())) {
        include '.' . $ctx->getPath();
        exit;
    } else {
        ob_start();
        try {
            $r = $ctx->loadComponent();
        } catch (ContextException $ce) {
            if ($ce->getCode() == 404) {
                $ctx->setHTTPStatus(404, "Not found");
                $ctx->setContent($ce->getMessage());
            } else {
                $ctx->setHTTPStatus(500, "Internal error in PHP software");
                $ctx->setContent($ce->getMessage());
            }
        }
        $output = ob_get_clean();
        if (!empty($output)) {
            $ctx->appendContent($output);
        }
        if (!empty($r)) {
            $ctx->appendContent($r);
        }
    }
}
$ctx->flushHeaders();
开发者ID:ryochiji,项目名称:YAFF-PHP,代码行数:31,代码来源:index.php


注:本文中的Context::setContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。