當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。