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


PHP us函数代码示例

本文整理汇总了PHP中us函数的典型用法代码示例。如果您正苦于以下问题:PHP us函数的具体用法?PHP us怎么用?PHP us使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test

 /**
  * execute tests
  */
 public function test($action, $context)
 {
     $action = us($action);
     $sequence = new Charcoal_SequenceHolder(new Charcoal_Sequence(), new Charcoal_Sequence());
     // form token component
     $form_token = $context->getComponent('form_token@:charcoal:form');
     $config = new Charcoal_Config($this->getSandbox()->getEnvironment());
     $config->set('token_key', 'foo');
     $form_token->configure($config);
     switch ($action) {
         case "form_token1":
             $token = $form_token->generate($sequence);
             echo "token: {$token}" . PHP_EOL;
             $this->assertNotNull($token);
             $this->assertNotEmpty($token);
             break;
         case "form_token2":
             // save my ticket into sequence
             $token_list = $sequence->get('token_key');
             $token_list[] = 'my-ticket';
             $sequence->set('foo', $token_list);
             // validation token will success
             $form_token->validate($sequence, 'my-ticket');
             break;
         case "form_token3":
             // save my ticket into sequence
             $token_list = $sequence->get('token_key');
             $token_list[] = 'my-ticket';
             $sequence->set('foo', $token_list);
             // validation token will fail
             $this->setExpectedException('Charcoal_FormTokenValidationException');
             $form_token->validate($sequence, 'another-ticket');
             break;
     }
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:38,代码来源:FormTokenTestTask.class.php

示例2: test

 /**
  * execute tests
  */
 public function test($action, $context)
 {
     $action = us($action);
     switch ($action) {
         case "split_params1":
             $args_commandline = "foo bar baz";
             $actual = Charcoal_CommandLineUtil::splitParams(s($args_commandline));
             $extected = array("foo", "bar", "baz");
             $this->assertEquals($extected, $actual);
             return TRUE;
         case "split_params2":
             $args_commandline = "foo\\'s bar\\'s 'baz'";
             $actual = Charcoal_CommandLineUtil::splitParams(s($args_commandline));
             $extected = array("foo's", "bar's", "baz");
             $this->assertEquals($extected, $actual);
             return TRUE;
         case "split_params3":
             $args_commandline = "'Teacher\\'s Voice' \"Teacher\\'s Voice\" 'Teacher\\\"s Voice'";
             $actual = Charcoal_CommandLineUtil::splitParams(s($args_commandline));
             print_r($actual);
             $extected = array("Teacher's Voice", "Teacher's Voice", "Teacher\"s Voice");
             $this->assertEquals($extected, $actual);
             return TRUE;
     }
     return FALSE;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:29,代码来源:CommandLineUtilTestTask.class.php

示例3: configure

 /**
  * Initialize instance
  *
  * @param Charcoal_Config $config   configuration data
  */
 public function configure($config)
 {
     parent::configure($config);
     $this->task_manager = us($config->getString('task_manager', ''));
     $this->forward_target = us($config->getString('forward_target', ''));
     $this->modules = uv($config->getArray('modules', array()));
     $this->events = uv($config->getArray('events', array()));
     $this->debug_mode = ub($config->getBoolean('debug_mode', FALSE));
     $this->log_enabled = ub($config->getBoolean('log_enabled'));
     $this->log_level = us($config->getString('log_level'));
     $this->log_loggers = uv($config->getArray('log_loggers'));
     // eventsに記載しているイベントのモジュールも読み込む
     if (is_array($this->events)) {
         foreach ($this->events as $event) {
             $pos = strpos($event, "@");
             if ($pos !== FALSE) {
                 $this->modules[] = substr($event, $pos);
             }
         }
     }
     if ($this->getSandbox()->isDebug()) {
         log_info("system, debug, config", "task_manager:" . $this->task_manager, self::TAG);
         log_info("system, debug, config", "forward_target:" . $this->forward_target, self::TAG);
         log_info("system, debug, config", "modules:" . print_r($this->modules, true), self::TAG);
         log_info("system, debug, config", "events:" . print_r($this->events, true), self::TAG);
         log_info("system, debug, config", "debug_mode" . $this->debug_mode, self::TAG);
         log_info("system, debug, config", "log_enabled" . $this->log_enabled, self::TAG);
         log_info("system, debug, config", "log_level" . $this->log_level, self::TAG);
         log_info("system, debug, config", "log_loggers" . print_r($this->log_loggers, true), self::TAG);
     }
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:36,代码来源:AbstractProcedure.class.php

示例4: test

 /**
  * execute tests
  */
 public function test($action, $context)
 {
     $action = us($action);
     $test_data_dir = $context->getFile(s('%APPLICATION_DIR%/test_data/class/io'));
     switch ($action) {
         case "combined_regex":
             $filter1 = new Charcoal_RegExFileFilter(s('/sample_file1\\.txt/'));
             $filter2 = new Charcoal_RegExFileFilter(s('/sample_file[23]\\.txt/'));
             $filter = new Charcoal_CombinedFileFilter(v(array($filter1, $filter2)));
             $files = $test_data_dir->listFiles($filter);
             $files_found = array();
             foreach ($files as $file) {
                 $files_found[] = $file->getName();
             }
             $expected = array('sample_file1.txt', 'sample_file2.txt', 'sample_file3.txt');
             $this->assertEquals('array', gettype($files));
             $this->assertEquals(3, count($files));
             $this->assertEquals(array(), array_diff($files_found, $expected));
             return TRUE;
         case "combined_wildcard":
             return TRUE;
         case "combined_complexed":
             return TRUE;
     }
     return FALSE;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:29,代码来源:CombinedFileFilterTestTask.class.php

示例5: __construct

 /**
  *    constructor
  *
  *    @param string|Charcoal_String $database         database name
  *    @param string|Charcoal_String $table          table name
  *    @param string|Charcoal_String $target_dir     target directory
  */
 public function __construct($database, $table, $target_dir)
 {
     parent::__construct();
     $this->database = us($database);
     $this->table = us($table);
     $this->target_dir = us($target_dir);
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:14,代码来源:GenerateModelEvent.class.php

示例6: test

 /**
  * execute tests
  */
 public function test($action, $context)
 {
     $request = $context->getRequest();
     $action = us($action);
     // Qdmail
     $qdmail = $context->getComponent('qdmail@:qdmail');
     $config = new Charcoal_Config($this->getSandbox()->getEnvironment());
     $config->set('qdsmtp.host', 'localhost');
     $config->set('qdsmtp.port', '25');
     $config->set('qdsmtp.from', 'stk2k@sazysoft.com');
     $config->set('qdsmtp.protocol', 'SMTP');
     $config->set('qdsmtp.user', '');
     $config->set('qdsmtp.pass', '');
     $qdmail->configure($config);
     switch ($action) {
         // Send mail
         case "send_mail":
             $to = $request->get("to");
             $from = "stk2k@sazysoft.com";
             $subject = "test";
             $body = "test!!!";
             echo "to:" . $to . eol();
             $qdmail->sendMail($from, $to, $subject, $body);
             break;
     }
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:29,代码来源:QdmailTestTask.class.php

示例7: test

 /**
  * execute tests
  *
  * @param string $action
  * @param Charcoal_IEventContext $context
  *
  * @return boolean
  */
 public function test($action, $context)
 {
     $action = us($action);
     // temp file component
     /** @var Charcoal_TempFileComponent $tf */
     $tf = $context->getComponent('temp_file@:charcoal:file');
     switch ($action) {
         case "create":
             $file = $tf->create("test");
             $this->assertTrue($file->exists());
             $this->assertTrue($file->canRead());
             $this->assertEquals("test", $file->getContents());
             return TRUE;
         case "get_contents":
             $temp_file = new Charcoal_File(CHARCOAL_TMP_DIR . '/tmpfile.txt');
             $temp_file->putContents("test");
             $tf->setFile($temp_file);
             $this->assertEquals("test", $tf->getContents());
             return TRUE;
         case "put_contents":
             $temp_file = new Charcoal_File(CHARCOAL_TMP_DIR . '/tmpfile.txt');
             $tf->setFile($temp_file);
             $tf->putContents("cat");
             $this->assertTrue($temp_file->exists());
             $this->assertTrue($temp_file->canRead());
             $this->assertEquals("cat", $temp_file->getContents());
             return TRUE;
     }
     return FALSE;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:38,代码来源:TempFileTestTask.class.php

示例8: __construct

 public function __construct(Charcoal_String $file, Charcoal_Integer $line, Charcoal_Integer $range = NULL)
 {
     parent::__construct();
     $this->_file = us($file);
     $this->_line = ui($line);
     $this->_range = $range ? ui($range) : self::DEFAULT_RANGE;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:7,代码来源:PhpSourceInfo.class.php

示例9: test

    /**
     * execute tests
     */
    public function test($action, $context)
    {
        echo "action:{$action}" . PHP_EOL;
        $request = $context->getRequest();
        $action = us($action);
        // Tidy
        $tidy = $context->getComponent('tidy@:html:repair:tidy');
        $config = new Charcoal_Config();
        $config->set('encoding', 'utf8');
        $tidy->configure($config);
        switch ($action) {
            case "parse_string":
                $html1 = <<<HTMLDATA1
<html>
  <head>
    <title>My Title</name>
  </head>
<BODY>

  <h1>Test Header</hh1>
    <form>Google</textarea>
    <textarea>http://google.com/</textarea></form>
  </company>
HTMLDATA1;
                $tidy->parseString($html1);
                show_with_children($tidy->root());
                return TRUE;
        }
        return FALSE;
    }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:33,代码来源:TidyTestTask.class.php

示例10: configure

 /**
  * Initialize instance
  *
  * @param Charcoal_Config $config   configuration data
  */
 public function configure($config)
 {
     parent::configure($config);
     $this->debug_mode = ub($config->getBoolean('debug_mode', FALSE));
     $this->smarty->caching = 0;
     //$config->getBoolean( 'caching' )->unbox();
     $this->smarty->compile_check = ub($config->getBoolean('compile_check', FALSE));
     $this->smarty->template_dir = us($config->getString('template_dir', '', TRUE));
     $this->smarty->compile_dir = us($config->getString('compile_dir', '', TRUE));
     $this->smarty->config_dir = us($config->getString('config_dir', '', TRUE));
     $this->smarty->cache_dir = us($config->getString('cache_dir', '', TRUE));
     $this->smarty->left_delimiter = us($config->getString('left_delimiter', '{', FALSE));
     $this->smarty->right_delimiter = us($config->getString('right_delimiter', '}', FALSE));
     //        $this->smarty->default_modifiers     = $config->getArray( 'default_modifiers', array() )->unbox();
     $plugins_dir = uv($config->getArray('plugins_dir', array(), TRUE));
     // add default plugins_dir: Smarty/Smarty/plugins
     $reflector = new ReflectionClass($this->smarty);
     $plugins_dir[] = dirname($reflector->getFileName()) . '/plugins';
     $this->smarty->plugins_dir = $plugins_dir;
     log_debug("smarty", "smarty->plugins_dir=" . print_r($this->smarty->plugins_dir, true), self::TAG);
     log_debug("smarty", "smarty=" . spl_object_hash($this->smarty), self::TAG);
     if ($this->debug_mode) {
         $smarty_options = array('caching' => $this->smarty->caching, 'compile_check' => $this->smarty->compile_check, 'template_dir' => $this->smarty->template_dir, 'compile_dir' => $this->smarty->compile_dir, 'config_dir' => $this->smarty->config_dir, 'cache_dir' => $this->smarty->cache_dir, 'default_modifiers' => $this->smarty->default_modifiers, 'plugins_dir' => $this->smarty->plugins_dir, 'left_delimiter' => $this->smarty->left_delimiter, 'right_delimiter' => $this->smarty->right_delimiter);
         ad($smarty_options);
         foreach ($smarty_options as $key => $value) {
             log_debug('system, debug, smarty', "smarty option: [{$key}]=" . Charcoal_System::toString($value));
         }
     }
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:34,代码来源:SmartyRendererTask.class.php

示例11: test

 /**
  * テスト
  */
 public function test($action, $context)
 {
     $action = us($action);
     switch ($action) {
         case "open":
             $this->handler->open('/foo/bar', 'test');
             $save_path = Charcoal_System::getObjectVar($this->handler, 'save_path');
             $session_name = Charcoal_System::getObjectVar($this->handler, 'session_name');
             $this->assertEquals('/foo/bar', $save_path);
             $this->assertEquals('test', $session_name);
             return TRUE;
         case "close":
             return TRUE;
         case "read":
             return TRUE;
         case "write":
             $id = Charcoal_System::hash();
             $sess_data = 'test session data';
             $this->handler->open('/foo/bar', 'test');
             $this->handler->write($id, $sess_data);
             $criteria = new Charcoal_SQLCriteria(s('session_id = ?'), v(array($id)));
             $dto = $this->gw->findFirst(qt('session'), $criteria);
             $this->assertEquals($sess_data, $dto->session_data);
             $this->assertEquals('test', $dto->session_name);
             return TRUE;
         case "destroy":
             return TRUE;
         case "gc":
             return TRUE;
     }
     return FALSE;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:35,代码来源:SmartGatewaySessionHandlerTestTask.class.php

示例12: processEvent

 /**
  * イベントを処理する
  *
  * @param Charcoal_IEventContext $context
  *
  * @return boolean
  */
 public function processEvent($context)
 {
     $request = $context->getRequest();
     // パラメータを取得
     $database = us($request->getString('p2'));
     $table = us($request->getString('p3'));
     //=======================================
     // Confirm input parameters
     //=======================================
     if (!empty($database) && !preg_match('/^[0-9a-zA-Z_\\-]*$/', $database)) {
         print "Parameter 2(database name) is wrong: {$database}" . PHP_EOL;
         return b(true);
     }
     if (!empty($table) && !preg_match('/^[0-9a-zA-Z_\\-]*$/', $table)) {
         print "Parameter 3(table name) is wrong: {$table}" . PHP_EOL;
         return b(true);
     }
     //=======================================
     // Send new project event
     //=======================================
     /** @var Charcoal_IEvent $event */
     $event_path = 'show_table_event@:charcoal:db:show:table';
     $event = $context->createEvent($event_path, array($database, $table));
     $context->pushEvent($event);
     return b(true);
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:33,代码来源:ShowTableCommandTask.class.php

示例13: __construct

 /**
  *    constructor
  *
  *    @param string|Charcoal_String $app_name       application name
  *    @param string|Charcoal_String $project_name   project name
  *    @param string|Charcoal_String $target_dir     target directory
  */
 public function __construct($app_name, $project_name, $target_dir)
 {
     parent::__construct();
     $this->app_name = us($app_name);
     $this->project_name = us($project_name);
     $this->target_dir = us($target_dir);
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:14,代码来源:NewAppEvent.class.php

示例14: configure

 /**
  * Initialize instance
  *
  * @param Charcoal_Config $config   configuration data
  */
 public function configure($config)
 {
     parent::configure($config);
     $session_name = $config->getString('session_name', '');
     $save_path = $config->getString('save_path', '', TRUE);
     $lifetime = $config->getInteger('lifetime', 0);
     $valid_path = $config->getString('valid_path', '');
     $valid_domain = $config->getString('valid_domain', '');
     $ssl_only = $config->getBoolean('ssl_only', FALSE);
     $save_path = us($save_path);
     $lifetime = ui($lifetime);
     $ssl_only = ub($ssl_only);
     $session_name = us($session_name);
     // デフォルトのセッション保存先
     if (!$save_path || !is_dir($save_path)) {
         $save_path = Charcoal_ResourceLocator::getApplicationPath('sessions');
     }
     // セッション初期化処理
     //        session_set_cookie_params( $lifetime, "$valid_path", "$valid_domain", $ssl_only );
     session_save_path($save_path);
     //        $session_name = session_name( $session_name ? $session_name : APPLICATION );
     session_name("PHPSESSID");
     //session_regenerate_id( TRUE );
     if ($this->getSandbox()->isDebug()) {
         log_debug("session", "session_name:{$session_name}", self::TAG);
         log_debug("session", "save_path:{$save_path}", self::TAG);
         log_debug("session", "lifetime:{$lifetime}", self::TAG);
         log_debug("session", "valid_path:{$valid_path}", self::TAG);
         log_debug("session", "valid_domain:{$valid_domain}", self::TAG);
         log_debug("session", "ssl_only:{$ssl_only}", self::TAG);
     }
     // メンバーに保存
     $this->save_path = $save_path;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:39,代码来源:DefaultSessionHandler.class.php

示例15: processEvent

 /**
  * process event
  *
  * @param Charcoal_IEventContext $context   event context
  *
  * @return boolean
  */
 public function processEvent($context)
 {
     $request = $context->getRequest();
     // get command line options
     $cmd_path = us($request->getString('p2'));
     $options = array('@:help' => '[command_path]', '@:version' => '', '@:db:generate:model' => 'databse table [target directory]', '@:db:show:table' => 'databse table');
     $examples1 = array('@:help' => '@:version => show "@:version" command help', '@:db:generate:model' => 'charcoal blog => generate "blog" table\'s model files in "charcoal" database' . '(model files are generated into current directory).', '@:db:show:table' => 'charcoal blog => show description about "blog" table in "charcoal" database.');
     $examples2 = array('@:help' => 'list => show all supported commands("list" can be omitted)');
     $descriptions = array('@:help' => 'show command help or list all command paths', '@:version' => 'show framework version.', '@:db:generate:model' => 'create model files into [target directory].', '@:db:show:table' => 'show table description');
     if (empty($cmd_path) || $cmd_path == 'list') {
         // show all commands
         echo "Supported command list: ";
         foreach ($options as $path => $opt) {
             echo "\n  " . $path;
         }
     } elseif (isset($options[$cmd_path])) {
         echo "How to use: ";
         echo "\n  charcoal " . $cmd_path . ' ' . $options[$cmd_path];
         if (isset($examples1[$cmd_path])) {
             echo "\nExample:";
             echo "\n  charcoal " . $cmd_path . ' ' . $examples1[$cmd_path];
             if (isset($examples2[$cmd_path])) {
                 echo "\n  charcoal " . $cmd_path . ' ' . $examples2[$cmd_path];
             }
         }
         if (isset($descriptions[$cmd_path])) {
             echo "\n\nThis command " . $descriptions[$cmd_path];
         }
     } else {
         echo "Command not found: {$cmd_path}";
     }
     echo "\n";
     return b(true);
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:41,代码来源:HelpTask.class.php


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