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


PHP Context::add方法代码示例

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


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

示例1: init

 /**
  * Iniciamos la sesión
  * @return nothing
  */
 public static final function init()
 {
     // Configuramos...
     self::$configuration = get_config(str_replace('Framework\\', '', get_called_class()));
     // Obtenemos una instancia de LDB para utilizar...
     self::$db = LittleDB::get_instance();
     if (!isset($_SESSION) or session_id() == '') {
         session_start();
     }
     // Iniciamos datos predeterminados para la sesión
     if (!isset($_SESSION['hash'])) {
         if (isset($_COOKIE[self::$configuration['cookie_name']])) {
             $_SESSION['hash'] = $_COOKIE[self::$configuration['cookie_name']];
             $_SESSION['use_cookies'] = true;
         } else {
             $_SESSION['hash'] = null;
             $_SESSION['use_cookies'] = false;
         }
         $_SESSION['ip'] = ip2long($_SERVER['REMOTE_ADDR']);
     }
     $_SESSION['datetime'] = time();
     if ($_SESSION['hash'] !== null) {
         self::set_id();
     }
     Context::add('is_logged', array('Framework\\Session', 'is_session'));
 }
开发者ID:areslepra,项目名称:Framework,代码行数:30,代码来源:class.session.php

示例2: recursiveExport

 /**
  * Recursive implementation of export
  *
  * @param  mixed $value The value to export
  * @param  integer $indentation The indentation level of the 2nd+ line
  * @param  SebastianBergmann\Exporter\Context $processed Contains all objects and arrays that have previously been rendered
  * @return string
  * @see    SebastianBergmann\Exporter\Exporter::export
  */
 protected function recursiveExport(&$value, $indentation, $processed = NULL)
 {
     if ($value === NULL) {
         return 'null';
     }
     if ($value === TRUE) {
         return 'true';
     }
     if ($value === FALSE) {
         return 'false';
     }
     if (is_float($value) && floatval(intval($value)) === $value) {
         return "{$value}.0";
     }
     if (is_resource($value)) {
         return sprintf('resource(%d) of type (%s)', $value, get_resource_type($value));
     }
     if (is_string($value)) {
         // Match for most non printable chars somewhat taking multibyte chars into account
         if (preg_match('/[^\\x09-\\x0d\\x20-\\xff]/', $value)) {
             return 'Binary String: 0x' . bin2hex($value);
         }
         return "'" . str_replace(array("\r\n", "\n\r", "\r"), array("\n", "\n", "\n"), $value) . "'";
     }
     $whitespace = str_repeat(' ', 4 * $indentation);
     if (!$processed) {
         $processed = new Context();
     }
     if (is_array($value)) {
         if (($key = $processed->contains($value)) !== FALSE) {
             return 'Array &' . $key;
         }
         $key = $processed->add($value);
         $values = '';
         if (count($value) > 0) {
             foreach ($value as $k => $v) {
                 $values .= sprintf('%s    %s => %s' . "\n", $whitespace, $this->recursiveExport($k, $indentation), $this->recursiveExport($value[$k], $indentation + 1, $processed));
             }
             $values = "\n" . $values . $whitespace;
         }
         return sprintf('Array &%s (%s)', $key, $values);
     }
     if (is_object($value)) {
         $class = get_class($value);
         if ($hash = $processed->contains($value)) {
             return sprintf('%s Object &%s', $class, $hash);
         }
         $hash = $processed->add($value);
         $values = '';
         $array = $this->toArray($value);
         if (count($array) > 0) {
             foreach ($array as $k => $v) {
                 $values .= sprintf('%s    %s => %s' . "\n", $whitespace, $this->recursiveExport($k, $indentation), $this->recursiveExport($v, $indentation + 1, $processed));
             }
             $values = "\n" . $values . $whitespace;
         }
         return sprintf('%s Object &%s (%s)', $class, $hash, $values);
     }
     return var_export($value, TRUE);
 }
开发者ID:ppwalks33,项目名称:cleansure,代码行数:69,代码来源:Exporter.php

示例3: 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

示例4: testLog

    public function testLog()
    {
        $context = new Context('dialog');
        $context->add('div', array('class' => 'dialog'));
        $context->add('context', 'title');
        $context->add('context', 'body');
        $context->select('title')->add('div', array('class' => 'title'));
        $context->select('title')->add('content');
        $body = $context->select('body');
        $body->add('div', array('class' => 'body'));
        $body->add('content');
        $content = array('title' => 'My title', 'body' => 'My first contextual view');
        Context::clearLog();
        $context->render($content);
        $actual = implode("\n", Context::getLog());
        $expected = <<<END
[Render] Rendering dialog#dialog
[Selector] Selector dialog applies
[Decorator] Rendering decorator Context with name body
[Context] Creating context body with id body
[Render] Rendering body#body
[Selector] Selector body applies
[Decorator] Rendering decorator Content with name content
[Decorator] Rendering decorator HtmlTag with name div
[Decorator] Rendering decorator Context with name title
[Context] Creating context title with id title
[Render] Rendering title#title
[Selector] Selector title applies
[Decorator] Rendering decorator Content with name content
[Decorator] Rendering decorator HtmlTag with name div
[Decorator] Rendering decorator HtmlTag with name div
END;
        // Normalize line endings
        $expected = str_replace("\r\n", "\n", $expected);
        $actual = str_replace("\r\n", "\n", $actual);
        $this->assertEquals($expected, $actual);
    }
开发者ID:urbanetter,项目名称:muentschi,代码行数:37,代码来源:ContextTest.php

示例5: 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


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