本文整理汇总了PHP中Solar类的典型用法代码示例。如果您正苦于以下问题:PHP Solar类的具体用法?PHP Solar怎么用?PHP Solar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Solar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: typekeyLink
/**
*
* Generates a link to the TypeKey login site.
*
* @param string $text The text to display for the link.
*
* @param array $attribs Attributes for the anchor.
*
* @return string
*
*/
public function typekeyLink($text = null, $attribs = null)
{
// get a URI processor; defaults to the current URI.
$uri = Solar::factory('Solar_Uri');
// do not retain the GET 'process' value on the current URI.
// this prevents double-processing of actions submitted via GET.
$key = $this->_config['process_key'];
if (!empty($uri->query[$key])) {
unset($uri->query[$key]);
}
// save the current URI as the return location after typekey.
$return = $uri->get(true);
// now reset the URI to point to the typekey service
$uri->set($this->_config['href']);
// add the typekey token
if (empty($this->_config['token'])) {
$uri->query['t'] = Solar_Config::get('Solar_Auth_Adapter_Typekey', 'token');
} else {
$uri->query['t'] = $this->_config['token'];
}
// convert need_email from true/false to 1/0 and add
$uri->query['need_email'] = (int) $this->_config['need_email'];
// add the return location
$uri->query['_return'] = $return;
if (empty($text)) {
// Preserve behavior of returning only the link if no text is passed.
return $uri->get(true);
}
// done!
return $this->_view->anchor($uri->get(true), $text, $attribs);
}
示例2: validateCredentials
/**
*
* Verifies set of credentials.
*
* @param array $credentials A list of credentials to verify
*
* @return mixed An array of verified user information, or boolean false
* if verification failed.
*
*/
public function validateCredentials($credentials)
{
if (empty($credentials['handle'])) {
return false;
}
if (empty($credentials['passwd'])) {
return false;
}
$handle = $credentials['handle'];
$passwd = $credentials['passwd'];
// create an array of POST data
$content = array($this->_config['handle'] => $handle, $this->_config['passwd'] => $passwd);
// build the base request
$request = Solar::factory('Solar_Http_Request');
$request->setUri($this->_config['uri'])->setMethod('post')->setContent($content);
// add custom headers
foreach ((array) $this->_config['headers'] as $label => $value) {
$request->setHeader($label, $value);
}
// fetch the response body content
$response = $request->fetch();
$reply = trim($response->content);
// is the reply string a known reply, and set to true?
$ok = array_key_exists($reply, $this->_config['replies']) && (bool) $this->_config['replies'][$reply];
if ($ok) {
return array('handle' => $handle);
} else {
return false;
}
}
示例3: setup
/**
*
* Tidy extension must be loaded. This allows us to ignore
* tag-level whitepspace differences.
*
*/
public function setup()
{
if (!extension_loaded('tidy')) {
$this->markTestSkipped("Tidy extension not loaded");
}
$this->_markdown = Solar::factory('Solar_Markdown_Wiki');
}
示例4: _displayCommandHelp
/**
*
* Displays a list of help options for a command, or the list of commands
* if no command was requested.
*
* @param string $cmd The requested command.
*
* @return void
*
*/
protected function _displayCommandHelp($cmd = null)
{
$this->_outln();
// the list of known command-to-class mappings
$list = $this->_console->getCommandList();
// is this a known command?
if (empty($list[$cmd])) {
$this->_outln('ERR_UNKNOWN_COMMAND', 1, array('cmd' => $cmd));
return;
}
$class = $list[$cmd];
$obj = Solar::factory($class);
$help = $obj->getInfoHelp();
if ($help) {
$this->_outln($help);
} else {
$this->_outln('ERR_NO_HELP');
}
$this->_outln();
$opts = $obj->getInfoOptions();
if ($opts) {
$this->_outln('HELP_VALID_OPTIONS');
$this->_outln();
foreach ($opts as $key => $val) {
$this->_outln($key);
$val = str_replace("\n", "\n ", wordwrap(": {$val}"));
$this->_outln($val);
$this->_outln();
}
}
}
示例5: _exec
/**
*
* Runs the tests for a class, descending into subdirectories unless
* otherwise specified.
*
* @param string $spec The Test_Class or Test_Class::testMethod to run.
*
* @return void
*
*/
protected function _exec($spec = null)
{
if (!$spec) {
throw $this->_exception('ERR_NO_TEST_SPEC');
}
// look for a :: in the class name; if it's there, split into class
// and method
$pos = strpos($spec, '::');
if ($pos) {
$class = substr($spec, 0, $pos);
$method = substr($spec, $pos + 2);
} else {
$class = $spec;
$method = null;
}
// run just the one test?
$only = (bool) $this->_options['only'];
// look for a test-config file?
$test_config = null;
if ($this->_options['test_config']) {
// find the real path to the test_config file
$test_config = realpath($this->_options['test_config']);
if ($test_config === false) {
throw $this->_exception('ERR_TEST_CONFIG_REALPATH', array('file' => $this->_options['test_config']));
}
}
// set up a test suite object
$suite = Solar::factory('Solar_Test_Suite', array('verbose' => $this->_options['verbose'], 'test_config' => $test_config, 'stop_on_fail' => $this->_options['stop_on_fail']));
// run the suite
$suite->run($class, $method, $only);
}
示例6: setup
/**
*
* Setup; runs before each test method.
*
*/
public function setup()
{
$this->_sql = Solar::factory('Solar_Sql', array('adapter' => 'Solar_Sql_Adapter_Sqlite', 'name' => ':memory:'));
// forcibly add sql to registry
Solar_Registry::set('sql', $this->_sql);
$cmd = "CREATE TABLE acl (" . " flag VARCHAR(10)," . " type CHAR(100)," . " name VARCHAR(255)," . " class_name VARCHAR(255)," . " action_name VARCHAR(255)," . " position VARCHAR(255)" . ")";
$this->_sql->query($cmd);
$dir = Solar_Class::dir('Test_Solar_Access_Adapter', '_support');
$lines = file_get_contents($dir . 'access.txt');
$rows = explode("\n", $lines);
$pos = 0;
foreach ($rows as $row) {
$row = trim($row);
// skip empty lines and comments
if (empty($row) || substr($row, 0, 1) == '#') {
continue;
}
$row = preg_replace('/[ \\t]{2,}/', ' ', $row);
$row = explode(' ', $row);
$data['flag'] = trim($row[0]);
$data['type'] = trim($row[1]);
$data['name'] = trim($row[2]);
$data['class_name'] = trim($row[3]);
$data['action_name'] = trim($row[4]);
$data['position'] = $pos;
$this->_sql->insert('acl', $data);
$pos++;
}
parent::setup();
}
示例7: _exec
/**
*
* Write out a series of dirs and symlinks for a new Vendor source.
*
* @param string $vendor The Vendor name.
*
* @return void
*
*/
protected function _exec($vendor = null)
{
// we need a vendor name, at least
if (!$vendor) {
throw $this->_exception('ERR_NO_VENDOR');
}
$this->_outln("Making links for vendor '{$vendor}' ...");
// build "foo-bar" and "FooBar" versions of the vendor name.
$this->_inflect = Solar_Registry::get('inflect');
$this->_dashes = $this->_inflect->camelToDashes($vendor);
$this->_studly = $this->_inflect->dashesToStudly($this->_dashes);
$links = array(array('dir' => "include", 'tgt' => $this->_studly, 'src' => "../source/{$this->_dashes}/{$this->_studly}"), array('dir' => "include/Test", 'tgt' => $this->_studly, 'src' => "../../source/{$this->_dashes}/tests/Test/{$this->_studly}"), array('dir' => "include/Mock", 'tgt' => $this->_studly, 'src' => "../../source/{$this->_dashes}/tests/Mock/{$this->_studly}"), array('dir' => "include/Fixture", 'tgt' => $this->_studly, 'src' => "../../source/{$this->_dashes}/tests/Fixture/{$this->_studly}"), array('dir' => "script", 'tgt' => $this->_dashes, 'src' => "../source/solar/script/solar"));
$system = Solar::$system;
foreach ($links as $link) {
// $dir, $src, $tgt
extract($link);
// make it
$this->_out(" Making link '{$dir}/{$tgt}' ... ");
try {
Solar_Symlink::make($src, $tgt, "{$system}/{$dir}");
$this->_outln("done.");
} catch (Exception $e) {
$this->_out($e->getMessage());
$this->_outln(" ... failed.");
}
}
// done with this part
$this->_outln("... done.");
// make public links
$link_public = Solar::factory('Solar_Cli_LinkPublic');
$link_public->exec($vendor);
// done for real
$this->_outln("Remember to add '{$this->_studly}_App' to the " . "['Solar_Controller_Front']['classes'] element " . "in your config file so that it finds your apps.");
$this->_outln("Remember to add '{$this->_studly}_Model' to the " . "['Solar_Sql_Model_Catalog']['classes'] element " . "in your config file so that it finds your models.");
}
示例8: preTest
public function preTest()
{
parent::preTest();
$this->_filter = Solar::factory('Solar_Filter');
$this->_plugin = $this->_filter->getFilter($this->_plugin_name);
$this->_filter->setRequire(true);
}
示例9: loop
/**
*
* Runs each benchmark method for a certain number of loops.
*
* @param int $loops Loop benchmark methods this number of times.
*
* @return string The Solar_Debug_Timer profile table; smaller diffs
* are better.
*
*/
public function loop($loops = null)
{
if (empty($loops)) {
$loops = $this->_config['loop'];
}
// get the list of bench*() methods
$bench = $this->_getMethods();
// get a timer object
$timer = Solar::factory('Solar_Debug_Timer', array('auto_start' => false));
// pre-run
$this->setup();
// start timing
$timer->start();
// run each benchmark method...
foreach ($bench as $method) {
// ... multiple times.
for ($i = 0; $i < $loops; ++$i) {
$this->{$method}();
}
// how long did the method run take?
$timer->mark($method);
}
// stop timing
$timer->stop();
// post-run
$this->teardown();
// done!
return $timer->fetch();
}
示例10: test__construct
/**
*
* Test -- Constructor.
*
*/
public function test__construct()
{
$view = Solar::factory('Solar_View');
$class = substr(get_class($this), 5);
$obj = Solar::factory($class, array('_view' => $view));
$this->assertInstance($obj, $class);
}
示例11: insertPostTags
/**
* insertPostTags
*
* @param $post_id
* @param $post_data
*/
public function insertPostTags($post_id, $tags)
{
$post_id = (int) $post_id;
$tag_map = array();
$tags_table = Solar::factory('Foresmo_Model_Tags');
$existing_tags = $tags_table->fetchAllAsArray();
foreach ($existing_tags as $existing_tag) {
foreach ($tags as $tag) {
if (strtolower($tag) == strtolower($existing_tag['tag'])) {
$tag_map[$tag] = $existing_tag['id'];
}
}
}
foreach ($tags as $tag) {
if (array_key_exists($tag, $tag_map)) {
$data = array('post_id' => $post_id, 'tag_id' => $tag_map[$tag]);
$this->insert($data);
} else {
$data = array('tag' => $tag, 'tag_slug' => Foresmo::makeSlug($tag));
$last_insert_id = $tags_table->insert($data);
$data = array('post_id' => $post_id, 'tag_id' => $last_insert_id);
$this->insert($data);
}
}
}
示例12: testGetTextRaw_badLocaleKey
public function testGetTextRaw_badLocaleKey()
{
Solar::start(false);
$actual = $this->_view->getTextRaw('no such "locale" key');
$expect = 'no such "locale" key';
$this->assertSame($actual, $expect);
}
示例13: _postConstruct
/**
* _postConstruct
*
* @param $model
*/
protected function _postConstruct()
{
parent::_postConstruct();
$this->_model = $this->_config['model'];
$this->_view_path = Solar_Class::dir($this, 'View');
$this->_view_file = 'index.php';
$this->_view = Solar::factory('Solar_View', array('template_path' => $this->_view_path));
}
示例14: _postConstruct
/**
*
* Post-construction tasks to complete object construction.
*
* @return void
*
*/
protected function _postConstruct()
{
parent::_postConstruct();
// only set up the handler if it doesn't exist yet.
if (!self::$_handler) {
self::$_handler = Solar::dependency('Solar_Session_Handler', $this->_config['handler']);
}
$this->_request = Solar_Registry::get('request');
}
示例15: _postConstruct
protected function _postConstruct()
{
parent::_postConstruct();
// "Test_Solar_View_Helper_" = 23
$this->_helper_name = substr(get_class($this), 23);
$this->_helper_class = substr(get_class($this), 5);
$this->_request = Solar_Registry::get('request');
$this->_view = Solar::factory('Solar_View');
}