/** * 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; } }
/** * 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; }
/** * 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); } }
/** * 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; }
/** * 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); }
/** * 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', '*****@*****.**'); $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 = "*****@*****.**"; $subject = "test"; $body = "test!!!"; echo "to:" . $to . eol(); $qdmail->sendMail($from, $to, $subject, $body); break; } }
/** * 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; }
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; }
/** * 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; }
/** * 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)); } } }
/** * テスト */ 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; }
/** * イベントを処理する * * @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); }
/** * 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); }
/** * 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; }
/** * 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); }
/** * execute tests */ public function test($action, $context) { $action = us($action); // create token generator object $generator = $context->createObject('simple', 'token_generator'); switch ($action) { case "simple_default": // create token generator object $token = $generator->generateToken(); $this->assertEquals(strlen($token), 40); $this->assertEquals(preg_match("/[^0-9a-zA-Z]+/", $token), false); echo "default token: {$token}"; break; case "simple_sha1": $config = new Charcoal_Config($this->getSandbox()->getEnvironment()); $config->set(s('algorithm'), 'sha1'); $generator->configure($config); $token = $generator->generateToken(); $this->assertEquals(strlen($token), 40); $this->assertEquals(preg_match("/[^0-9a-zA-Z]+/", $token), false); echo "sha1 token: {$token}"; break; case "simple_md5": $config = new Charcoal_Config($this->getSandbox()->getEnvironment()); $config->set(s('algorithm'), 'md5'); $generator->configure($config); $token = $generator->generateToken(); $this->assertEquals(strlen($token), 32); $this->assertEquals(preg_match("/[^0-9a-zA-Z]+/", $token), false); echo "md5 token: {$token}"; break; } }
/** * Format message */ public function formatMessage(Charcoal_LogMessage $msg) { // Charcoal_ParamTrait::validateIsA( 1, 'Charcoal_LogMessage', $msg ); $level = $msg->getLevel(); $tag = $msg->getTag(); $message = $msg->getMessage(); $file = $msg->getFile(); $line = $msg->getLine(); $time = date("y/m/d H:i:s"); // Convert encoding $message = $this->convertEncoding(s($message)); // Get now time $now_time = time(); // set log format string as initial value $out = $this->log_format; // logging context specific values $now_time = time(); $log_values = array('%Y4%' => date("Y", $now_time), '%Y2%' => date("y", $now_time), '%M2%' => date("m", $now_time), '%M1%' => date("n", $now_time), '%D2%' => date("d", $now_time), '%D1%' => date("j", $now_time), '%H2%' => date("H", $now_time), '%H1%' => date("G", $now_time), '%h2%' => date("h", $now_time), '%h1%' => date("g", $now_time), '%M%' => date("i", $now_time), '%S%' => date("s", $now_time), '%LEVEL%' => $level, '%TAG%' => $tag, '%MESSAGE%' => $message, '%FILE%' => $file, '%FILENAME%' => $file, '%LINE%' => $line); // replace keyword foreach ($log_values as $key => $value) { $out = str_replace($key, $value, us($out)); } // replace environment values $out = $this->getSandbox()->getEnvironment()->fill($out); return $out; }
/** * Constructor * * @param string|Charcoal_String $section * @param string|Charcoal_String $action * @param boolean|Charcoal_Boolean $success If TRUE, the test succeeded */ public function __construct($section, $action, $success) { parent::__construct(); $this->section = us($section); $this->action = us($action); $this->success = ub($success); }
public function loadClass($class_name) { $debug = $this->getSandbox()->isDebug(); $class_name = us($class_name); $class_paths = self::$class_paths; // フレームワークのクラスではない場合はFALSEを返却 if (!isset($class_paths[$class_name])) { // log_info( "system,debug,class_loader", "class_loader", "[FrameworkClassLoader] Can not load class: [$class_name]" ); if ($debug) { echo "Class NOT found in framework class loader: {$class_name}" . eol(); } return FALSE; } // クラス名からクラスパスを取得 $file_name = $class_name . '.class.php'; $pos = strpos($file_name, 'Charcoal_'); if ($pos !== FALSE) { $file_name = substr($file_name, $pos + 9); } $class_path = CHARCOAL_HOME . '/src/' . $class_paths[$class_name] . '/' . $file_name; // log_info( "system,debug,class_loader", "class_loader", "[FrameworkClassLoader] class_path=[$class_path] class_name=[$class_name]" ); // ソース読み込み Charcoal_Framework::loadSourceFile($class_path); if ($debug) { echo "Class found in framework class loader: {$class_name}" . eol(); } return TRUE; }
/** * find elements * * @param Charcoal_String|string $selector * @param Charcoal_Integer|integer $index */ public function find($selector, $index = NULL) { Charcoal_ParamTrait::validateString(1, $selector); Charcoal_ParamTrait::validateInteger(2, $index, TRUE); if (!$this->simple_html_dom) { _throw(new SimpleHtmlDomComponentException("SimpleHtmlDom object is not created")); } $selector = us($selector); log_debug("debug", "index:{$index}"); if ($index !== NULL) { // returns single element $index = ui($index); log_debug("debug", "returns single element"); $result = $this->simple_html_dom->find($selector, $index); log_debug("debug", "result: " . print_r($result, true)); return $result ? new Charcoal_SimpleHtmlDomElement($result) : NULL; } // returns all elements log_debug("debug", "selector:" . print_r($selector, true)); $result = $this->simple_html_dom->find($selector); log_debug("debug", "result: " . print_r($result, true)); $elements = array(); foreach ($result as $e) { $elements[] = new Charcoal_SimpleHtmlDomElement($e); } return $result ? $elements : array(); }
public static function processMacro($env, $value) { Charcoal_ParamTrait::validateIsA(1, 'Charcoal_IEnvironment', $env); if (is_array($value) || $value instanceof Traversable) { $new_array = array(); foreach ($value as $key => $value) { $value = is_string($value) ? self::processMacro($env, $value) : $value; $new_array[$key] = $value; } return $new_array; } $value = us($value); if (!is_string($value)) { return $value; } if (strpos($value, '%') === FALSE) { return $value; } if (!self::$static_macro_defs) { self::$static_macro_defs = array('%APPLICATION_DIR%' => CHARCOAL_WEBAPP_DIR . '/' . CHARCOAL_PROJECT . '/app/' . CHARCOAL_APPLICATION, '%PROJECT_DIR%' => CHARCOAL_WEBAPP_DIR . '/' . CHARCOAL_PROJECT, '%WEBAPP_DIR%' => CHARCOAL_WEBAPP_DIR, '%CHARCOAL_HOME%' => CHARCOAL_HOME, '%PROJECT%' => CHARCOAL_PROJECT, '%APPLICATION%' => CHARCOAL_APPLICATION, '%BASE_DIR%' => CHARCOAL_BASE_DIR, '%CACHE_DIR%' => CHARCOAL_CACHE_DIR, '%TMP_DIR%' => CHARCOAL_TMP_DIR); } // fill static values $value = strtr($value, self::$static_macro_defs); // set runtime values $request_path = $env->get('%REQUEST_PATH%'); $runtime_macro_defs = array('%REQUEST_PATH_REAL%' => str_replace(':', '/', substr($request_path, 2))); // fill runtime values $value = strtr($value, $runtime_macro_defs); return $value; }
/** * execute tests */ public function test($action, $context) { $action = us($action); $simple_router = $context->createObject('simple_router', 'router', 'Charcoal_IRouter'); $routing_rule = $context->createObject('array', 'routing_rule', 'Charcoal_IRoutingRule'); $config = new Charcoal_Config($context->getEnvironment(), array('routing rules' => array('/path/to/check/' => '@:path:to:check', '/path/to/check/:param' => '@:path:to:check'))); $routing_rule->configure($config); $proc_key = $context->getProfile()->getString('PROC_KEY', 'proc'); switch ($action) { case "no_param": $request = $context->getRequest(); $_SERVER["REQUEST_URI"] = '/path/to/check/'; $_SERVER["SCRIPT_NAME"] = ''; $result = $simple_router->route($request, $routing_rule); $proc = $request->get($proc_key); $this->assertEquals("@:path:to:check", $proc); break; case "one_param": $request = $context->getRequest(); $_SERVER["REQUEST_URI"] = '/path/to/check/1'; $_SERVER["SCRIPT_NAME"] = ''; $result = $simple_router->route($request, $routing_rule); $proc = $request->get($proc_key); ad($result); $this->assertEquals("@:path:to:check", $proc); break; } }
public static function splitParams($args) { Charcoal_ParamTrait::validateString(1, $args); $args = us($args); $pos = 0; $dq = FALSE; $sq = FALSE; $max_pos = strlen($args); $args_array = array(); $arg_tmp = ''; $escape = FALSE; while ($pos < $max_pos) { $ch = substr($args, $pos, 1); $escape_now = FALSE; if ($escape) { $arg_tmp .= $ch; } elseif ($dq) { if ($ch == '\\') { $escape = TRUE; $escape_now = TRUE; } elseif ($ch == '"') { $dq = FALSE; } else { $arg_tmp .= $ch; } } elseif ($sq) { if ($ch == '\\') { $escape = TRUE; $escape_now = TRUE; } elseif ($ch == "'") { $sq = FALSE; } else { $arg_tmp .= $ch; } } else { if ($ch == ' ') { $args_array[] = $arg_tmp; $arg_tmp = ''; } elseif ($ch == '\\') { $escape = TRUE; $escape_now = TRUE; } elseif ($ch == '"') { $dq = TRUE; } elseif ($ch == "'") { $sq = TRUE; } else { $arg_tmp .= $ch; } } if (!$escape_now && $escape) { $escape = FALSE; } $pos++; } if (strlen($arg_tmp) > 0) { $args_array[] = $arg_tmp; } return $args_array; }
/** * Construct */ public function __construct($message, $prev = NULL) { Charcoal_ParamTrait::validateString(1, $message); Charcoal_ParamTrait::validateException(2, $prev, TRUE); parent::__construct(us($message), 0, $prev); $this->backtrace = debug_backtrace(); $this->previous = $prev; }
/** * render buffer * * @param Charcoal_String|string $buffer rendering data */ public function render($buffer) { Charcoal_ParamTrait::validateString(1, $buffer); $buffer = us($buffer); if (is_string($buffer)) { echo $buffer; } }
/** * Save a value to cache * * @param string $key The key under which to store the value. * @param Charcoal_Object $value value to save * @param int $duration specify expiration span which the cache will be removed. */ public function set($key, $value, $duration = NULL) { // Charcoal_ParamTrait::validateString( 1, $key ); // Charcoal_ParamTrait::validateInteger( 3, $duration, TRUE ); $key = us($key); $duration = $duration ? ui($duration) : ui($this->_default_duration); $value = serialize($value); $res = $this->_memcache->set($key, $value); }
public function __construct($name, $value, $params) { Charcoal_ParamTrait::validateString(1, $name); Charcoal_ParamTrait::validateString(2, $value); Charcoal_ParamTrait::validateVector(3, $params); $this->name = us($name); $this->value = us($value); $this->params = uv($params); }
/** * constructor * * @param string|Charcoal_String $task_name task name * @param string|Charcoal_String $module_name module path * @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($task_name, $module_path, $app_name, $project_name, $target_dir) { parent::__construct(); $this->task_name = us($task_name); $this->module_path = us($module_path); $this->app_name = us($app_name); $this->project_name = us($project_name); $this->target_dir = us($target_dir); }
public function __construct($class_name) { // Charcoal_ParamTrait::validateString( 1, $class_name ); $class_name = us($class_name); parent::__construct(); if (!class_exists($class_name)) { _throw(new Charcoal_ClassNotFoundException($class_name)); } $this->class_name = us($class_name); }
private function EscapeQuote(Charcoal_String $str) { $str = us($str); $str = str_replace(",", "_", $str); $str = str_replace(self::DQ, "'", $str); if ($this->_double_quoted) { $str = self::DQ . $str . self::DQ; } return $str; }