code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231 values | license stringclasses 13 values | size int64 1 2.01M |
|---|---|---|---|---|---|
<?php
require_once(dirname(__FILE__) . '/../../autorun.php');
class FailingTest extends UnitTestCase {
function test_fail() {
$this->assertEqual(1,2);
}
}
?> | 10npsite | trunk/simpletest/test/support/failing_test.php | PHP | asf20 | 174 |
<?php
class test1 extends UnitTestCase {
function test_pass(){
$this->assertEqual(3,1+2, "pass1");
}
}
?>
| 10npsite | trunk/simpletest/test/support/test1.php | PHP | asf20 | 110 |
<?php
require_once(dirname(__FILE__) . '/../../autorun.php');
class PassingTest extends UnitTestCase {
function test_pass() {
$this->assertEqual(2,2);
}
}
?> | 10npsite | trunk/simpletest/test/support/passing_test.php | PHP | asf20 | 174 |
<?php
require_once(dirname(__FILE__) . '/../../autorun.php');
?> | 10npsite | trunk/simpletest/test/support/empty_test_file.php | PHP | asf20 | 64 |
<?php
// $Id: sample_test.php 1500 2007-04-29 14:33:31Z pp11 $
require_once dirname(__FILE__) . '/../../autorun.php';
class SampleTestForRecorder extends UnitTestCase {
function testTrueIsTrue() {
$this->assertTrue(true);
}
function testFalseIsTrue() {
$this->assertFalse(true);
}
}
?> | 10npsite | trunk/simpletest/test/support/recorder_sample.php | PHP | asf20 | 319 |
<?php
// $Id: spl_examples.php 1262 2006-02-05 19:35:31Z lastcraft $
class IteratorImplementation implements Iterator {
function current() { }
function next() { }
function key() { }
function valid() { }
function rewind() { }
}
class IteratorAggregateImplementation implements IteratorAggregate {
function getIterator() { }
}
?> | 10npsite | trunk/simpletest/test/support/spl_examples.php | PHP | asf20 | 397 |
<?php
// $Id: browser_test.php 1964 2009-10-13 15:27:31Z maetl_ $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../browser.php');
require_once(dirname(__FILE__) . '/../user_agent.php');
require_once(dirname(__FILE__) . '/../http.php');
require_once(dirname(__FILE__) . '/../page.php');
require_once(dirname(__FILE__) . '/../encoding.php');
Mock::generate('SimpleHttpResponse');
Mock::generate('SimplePage');
Mock::generate('SimpleForm');
Mock::generate('SimpleUserAgent');
Mock::generatePartial(
'SimpleBrowser',
'MockParseSimpleBrowser',
array('createUserAgent', 'parse'));
Mock::generatePartial(
'SimpleBrowser',
'MockUserAgentSimpleBrowser',
array('createUserAgent'));
class TestOfHistory extends UnitTestCase {
function testEmptyHistoryHasFalseContents() {
$history = new SimpleBrowserHistory();
$this->assertIdentical($history->getUrl(), false);
$this->assertIdentical($history->getParameters(), false);
}
function testCannotMoveInEmptyHistory() {
$history = new SimpleBrowserHistory();
$this->assertFalse($history->back());
$this->assertFalse($history->forward());
}
function testCurrentTargetAccessors() {
$history = new SimpleBrowserHistory();
$history->recordEntry(
new SimpleUrl('http://www.here.com/'),
new SimpleGetEncoding());
$this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.here.com/'));
$this->assertIdentical($history->getParameters(), new SimpleGetEncoding());
}
function testSecondEntryAccessors() {
$history = new SimpleBrowserHistory();
$history->recordEntry(
new SimpleUrl('http://www.first.com/'),
new SimpleGetEncoding());
$history->recordEntry(
new SimpleUrl('http://www.second.com/'),
new SimplePostEncoding(array('a' => 1)));
$this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.second.com/'));
$this->assertIdentical(
$history->getParameters(),
new SimplePostEncoding(array('a' => 1)));
}
function testGoingBackwards() {
$history = new SimpleBrowserHistory();
$history->recordEntry(
new SimpleUrl('http://www.first.com/'),
new SimpleGetEncoding());
$history->recordEntry(
new SimpleUrl('http://www.second.com/'),
new SimplePostEncoding(array('a' => 1)));
$this->assertTrue($history->back());
$this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.first.com/'));
$this->assertIdentical($history->getParameters(), new SimpleGetEncoding());
}
function testGoingBackwardsOffBeginning() {
$history = new SimpleBrowserHistory();
$history->recordEntry(
new SimpleUrl('http://www.first.com/'),
new SimpleGetEncoding());
$this->assertFalse($history->back());
$this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.first.com/'));
$this->assertIdentical($history->getParameters(), new SimpleGetEncoding());
}
function testGoingForwardsOffEnd() {
$history = new SimpleBrowserHistory();
$history->recordEntry(
new SimpleUrl('http://www.first.com/'),
new SimpleGetEncoding());
$this->assertFalse($history->forward());
$this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.first.com/'));
$this->assertIdentical($history->getParameters(), new SimpleGetEncoding());
}
function testGoingBackwardsAndForwards() {
$history = new SimpleBrowserHistory();
$history->recordEntry(
new SimpleUrl('http://www.first.com/'),
new SimpleGetEncoding());
$history->recordEntry(
new SimpleUrl('http://www.second.com/'),
new SimplePostEncoding(array('a' => 1)));
$this->assertTrue($history->back());
$this->assertTrue($history->forward());
$this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.second.com/'));
$this->assertIdentical(
$history->getParameters(),
new SimplePostEncoding(array('a' => 1)));
}
function testNewEntryReplacesNextOne() {
$history = new SimpleBrowserHistory();
$history->recordEntry(
new SimpleUrl('http://www.first.com/'),
new SimpleGetEncoding());
$history->recordEntry(
new SimpleUrl('http://www.second.com/'),
new SimplePostEncoding(array('a' => 1)));
$history->back();
$history->recordEntry(
new SimpleUrl('http://www.third.com/'),
new SimpleGetEncoding());
$this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.third.com/'));
$this->assertIdentical($history->getParameters(), new SimpleGetEncoding());
}
function testNewEntryDropsFutureEntries() {
$history = new SimpleBrowserHistory();
$history->recordEntry(
new SimpleUrl('http://www.first.com/'),
new SimpleGetEncoding());
$history->recordEntry(
new SimpleUrl('http://www.second.com/'),
new SimpleGetEncoding());
$history->recordEntry(
new SimpleUrl('http://www.third.com/'),
new SimpleGetEncoding());
$history->back();
$history->back();
$history->recordEntry(
new SimpleUrl('http://www.fourth.com/'),
new SimpleGetEncoding());
$this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.fourth.com/'));
$this->assertFalse($history->forward());
$history->back();
$this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.first.com/'));
$this->assertFalse($history->back());
}
}
class TestOfParsedPageAccess extends UnitTestCase {
function loadPage(&$page) {
$response = new MockSimpleHttpResponse($this);
$agent = new MockSimpleUserAgent($this);
$agent->returns('fetchResponse', $response);
$browser = new MockParseSimpleBrowser($this);
$browser->returns('createUserAgent', $agent);
$browser->returns('parse', $page);
$browser->__construct();
$browser->get('http://this.com/page.html');
return $browser;
}
function testAccessorsWhenNoPage() {
$agent = new MockSimpleUserAgent($this);
$browser = new MockParseSimpleBrowser($this);
$browser->returns('createUserAgent', $agent);
$browser->__construct();
$this->assertEqual($browser->getContent(), '');
}
function testParse() {
$page = new MockSimplePage();
$page->setReturnValue('getRequest', "GET here.html\r\n\r\n");
$page->setReturnValue('getRaw', 'Raw HTML');
$page->setReturnValue('getTitle', 'Here');
$page->setReturnValue('getFrameFocus', 'Frame');
$page->setReturnValue('getMimeType', 'text/html');
$page->setReturnValue('getResponseCode', 200);
$page->setReturnValue('getAuthentication', 'Basic');
$page->setReturnValue('getRealm', 'Somewhere');
$page->setReturnValue('getTransportError', 'Ouch!');
$browser = $this->loadPage($page);
$this->assertEqual($browser->getRequest(), "GET here.html\r\n\r\n");
$this->assertEqual($browser->getContent(), 'Raw HTML');
$this->assertEqual($browser->getTitle(), 'Here');
$this->assertEqual($browser->getFrameFocus(), 'Frame');
$this->assertIdentical($browser->getResponseCode(), 200);
$this->assertEqual($browser->getMimeType(), 'text/html');
$this->assertEqual($browser->getAuthentication(), 'Basic');
$this->assertEqual($browser->getRealm(), 'Somewhere');
$this->assertEqual($browser->getTransportError(), 'Ouch!');
}
function testLinkAffirmationWhenPresent() {
$page = new MockSimplePage();
$page->setReturnValue('getUrlsByLabel', array('http://www.nowhere.com'));
$page->expectOnce('getUrlsByLabel', array('a link label'));
$browser = $this->loadPage($page);
$this->assertIdentical($browser->getLink('a link label'), 'http://www.nowhere.com');
}
function testLinkAffirmationByIdWhenPresent() {
$page = new MockSimplePage();
$page->setReturnValue('getUrlById', 'a_page.com', array(99));
$page->setReturnValue('getUrlById', false, array('*'));
$browser = $this->loadPage($page);
$this->assertIdentical($browser->getLinkById(99), 'a_page.com');
$this->assertFalse($browser->getLinkById(98));
}
function testSettingFieldIsPassedToPage() {
$page = new MockSimplePage();
$page->expectOnce('setField', array(new SimpleByLabelOrName('key'), 'Value', false));
$page->setReturnValue('getField', 'Value');
$browser = $this->loadPage($page);
$this->assertEqual($browser->getField('key'), 'Value');
$browser->setField('key', 'Value');
}
}
class TestOfBrowserNavigation extends UnitTestCase {
function createBrowser($agent, $page) {
$browser = new MockParseSimpleBrowser();
$browser->returns('createUserAgent', $agent);
$browser->returns('parse', $page);
$browser->__construct();
return $browser;
}
function testBrowserRequestMethods() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$agent->expectAt(
0,
'fetchResponse',
array(new SimpleUrl('http://this.com/get.req'), new SimpleGetEncoding()));
$agent->expectAt(
1,
'fetchResponse',
array(new SimpleUrl('http://this.com/post.req'), new SimplePostEncoding()));
$agent->expectAt(
2,
'fetchResponse',
array(new SimpleUrl('http://this.com/put.req'), new SimplePutEncoding()));
$agent->expectAt(
3,
'fetchResponse',
array(new SimpleUrl('http://this.com/delete.req'), new SimpleDeleteEncoding()));
$agent->expectAt(
4,
'fetchResponse',
array(new SimpleUrl('http://this.com/head.req'), new SimpleHeadEncoding()));
$agent->expectCallCount('fetchResponse', 5);
$page = new MockSimplePage();
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/get.req');
$browser->post('http://this.com/post.req');
$browser->put('http://this.com/put.req');
$browser->delete('http://this.com/delete.req');
$browser->head('http://this.com/head.req');
}
function testClickLinkRequestsPage() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$agent->expectAt(
0,
'fetchResponse',
array(new SimpleUrl('http://this.com/page.html'), new SimpleGetEncoding()));
$agent->expectAt(
1,
'fetchResponse',
array(new SimpleUrl('http://this.com/new.html'), new SimpleGetEncoding()));
$agent->expectCallCount('fetchResponse', 2);
$page = new MockSimplePage();
$page->setReturnValue('getUrlsByLabel', array(new SimpleUrl('http://this.com/new.html')));
$page->expectOnce('getUrlsByLabel', array('New'));
$page->setReturnValue('getRaw', 'A page');
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertTrue($browser->clickLink('New'));
}
function testClickLinkWithUnknownFrameStillRequestsWholePage() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$agent->expectAt(
0,
'fetchResponse',
array(new SimpleUrl('http://this.com/page.html'), new SimpleGetEncoding()));
$target = new SimpleUrl('http://this.com/new.html');
$target->setTarget('missing');
$agent->expectAt(
1,
'fetchResponse',
array($target, new SimpleGetEncoding()));
$agent->expectCallCount('fetchResponse', 2);
$parsed_url = new SimpleUrl('http://this.com/new.html');
$parsed_url->setTarget('missing');
$page = new MockSimplePage();
$page->setReturnValue('getUrlsByLabel', array($parsed_url));
$page->setReturnValue('hasFrames', false);
$page->expectOnce('getUrlsByLabel', array('New'));
$page->setReturnValue('getRaw', 'A page');
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertTrue($browser->clickLink('New'));
}
function testClickingMissingLinkFails() {
$agent = new MockSimpleUserAgent($this);
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$page = new MockSimplePage();
$page->setReturnValue('getUrlsByLabel', array());
$page->setReturnValue('getRaw', 'stuff');
$browser = $this->createBrowser($agent, $page);
$this->assertTrue($browser->get('http://this.com/page.html'));
$this->assertFalse($browser->clickLink('New'));
}
function testClickIndexedLink() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$agent->expectAt(
1,
'fetchResponse',
array(new SimpleUrl('1.html'), new SimpleGetEncoding()));
$agent->expectCallCount('fetchResponse', 2);
$page = new MockSimplePage();
$page->setReturnValue(
'getUrlsByLabel',
array(new SimpleUrl('0.html'), new SimpleUrl('1.html')));
$page->setReturnValue('getRaw', 'A page');
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertTrue($browser->clickLink('New', 1));
}
function testClinkLinkById() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$agent->expectAt(1, 'fetchResponse', array(
new SimpleUrl('http://this.com/link.html'),
new SimpleGetEncoding()));
$agent->expectCallCount('fetchResponse', 2);
$page = new MockSimplePage();
$page->setReturnValue('getUrlById', new SimpleUrl('http://this.com/link.html'));
$page->expectOnce('getUrlById', array(2));
$page->setReturnValue('getRaw', 'A page');
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertTrue($browser->clickLinkById(2));
}
function testClickingMissingLinkIdFails() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$page = new MockSimplePage();
$page->setReturnValue('getUrlById', false);
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertFalse($browser->clickLink(0));
}
function testSubmitFormByLabel() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$agent->expectAt(1, 'fetchResponse', array(
new SimpleUrl('http://this.com/handler.html'),
new SimplePostEncoding(array('a' => 'A'))));
$agent->expectCallCount('fetchResponse', 2);
$form = new MockSimpleForm();
$form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
$form->setReturnValue('getMethod', 'post');
$form->setReturnValue('submitButton', new SimplePostEncoding(array('a' => 'A')));
$form->expectOnce('submitButton', array(new SimpleByLabel('Go'), false));
$page = new MockSimplePage();
$page->returns('getFormBySubmit', $form);
$page->expectOnce('getFormBySubmit', array(new SimpleByLabel('Go')));
$page->setReturnValue('getRaw', 'stuff');
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertTrue($browser->clickSubmit('Go'));
}
function testDefaultSubmitFormByLabel() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$agent->expectAt(1, 'fetchResponse', array(
new SimpleUrl('http://this.com/page.html'),
new SimpleGetEncoding(array('a' => 'A'))));
$agent->expectCallCount('fetchResponse', 2);
$form = new MockSimpleForm();
$form->setReturnValue('getAction', new SimpleUrl('http://this.com/page.html'));
$form->setReturnValue('getMethod', 'get');
$form->setReturnValue('submitButton', new SimpleGetEncoding(array('a' => 'A')));
$page = new MockSimplePage();
$page->returns('getFormBySubmit', $form);
$page->expectOnce('getFormBySubmit', array(new SimpleByLabel('Submit')));
$page->setReturnValue('getRaw', 'stuff');
$page->setReturnValue('getUrl', new SimpleUrl('http://this.com/page.html'));
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertTrue($browser->clickSubmit());
}
function testSubmitFormByName() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$form = new MockSimpleForm();
$form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
$form->setReturnValue('getMethod', 'post');
$form->setReturnValue('submitButton', new SimplePostEncoding(array('a' => 'A')));
$page = new MockSimplePage();
$page->returns('getFormBySubmit', $form);
$page->expectOnce('getFormBySubmit', array(new SimpleByName('me')));
$page->setReturnValue('getRaw', 'stuff');
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertTrue($browser->clickSubmitByName('me'));
}
function testSubmitFormById() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$form = new MockSimpleForm();
$form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
$form->setReturnValue('getMethod', 'post');
$form->setReturnValue('submitButton', new SimplePostEncoding(array('a' => 'A')));
$form->expectOnce('submitButton', array(new SimpleById(99), false));
$page = new MockSimplePage();
$page->returns('getFormBySubmit', $form);
$page->expectOnce('getFormBySubmit', array(new SimpleById(99)));
$page->setReturnValue('getRaw', 'stuff');
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertTrue($browser->clickSubmitById(99));
}
function testSubmitFormByImageLabel() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$form = new MockSimpleForm();
$form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
$form->setReturnValue('getMethod', 'post');
$form->setReturnValue('submitImage', new SimplePostEncoding(array('a' => 'A')));
$form->expectOnce('submitImage', array(new SimpleByLabel('Go!'), 10, 11, false));
$page = new MockSimplePage();
$page->returns('getFormByImage', $form);
$page->expectOnce('getFormByImage', array(new SimpleByLabel('Go!')));
$page->setReturnValue('getRaw', 'stuff');
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertTrue($browser->clickImage('Go!', 10, 11));
}
function testSubmitFormByImageName() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$form = new MockSimpleForm();
$form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
$form->setReturnValue('getMethod', 'post');
$form->setReturnValue('submitImage', new SimplePostEncoding(array('a' => 'A')));
$form->expectOnce('submitImage', array(new SimpleByName('a'), 10, 11, false));
$page = new MockSimplePage();
$page->returns('getFormByImage', $form);
$page->expectOnce('getFormByImage', array(new SimpleByName('a')));
$page->setReturnValue('getRaw', 'stuff');
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertTrue($browser->clickImageByName('a', 10, 11));
}
function testSubmitFormByImageId() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$form = new MockSimpleForm();
$form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
$form->setReturnValue('getMethod', 'post');
$form->setReturnValue('submitImage', new SimplePostEncoding(array('a' => 'A')));
$form->expectOnce('submitImage', array(new SimpleById(99), 10, 11, false));
$page = new MockSimplePage();
$page->returns('getFormByImage', $form);
$page->expectOnce('getFormByImage', array(new SimpleById(99)));
$page->setReturnValue('getRaw', 'stuff');
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertTrue($browser->clickImageById(99, 10, 11));
}
function testSubmitFormByFormId() {
$agent = new MockSimpleUserAgent();
$agent->returns('fetchResponse', new MockSimpleHttpResponse());
$agent->expectAt(1, 'fetchResponse', array(
new SimpleUrl('http://this.com/handler.html'),
new SimplePostEncoding(array('a' => 'A'))));
$agent->expectCallCount('fetchResponse', 2);
$form = new MockSimpleForm();
$form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
$form->setReturnValue('getMethod', 'post');
$form->setReturnValue('submit', new SimplePostEncoding(array('a' => 'A')));
$page = new MockSimplePage();
$page->returns('getFormById', $form);
$page->expectOnce('getFormById', array(33));
$page->setReturnValue('getRaw', 'stuff');
$browser = $this->createBrowser($agent, $page);
$browser->get('http://this.com/page.html');
$this->assertTrue($browser->submitFormById(33));
}
}
class TestOfBrowserFrames extends UnitTestCase {
function createBrowser($agent) {
$browser = new MockUserAgentSimpleBrowser();
$browser->returns('createUserAgent', $agent);
$browser->__construct();
return $browser;
}
function createUserAgent($pages) {
$agent = new MockSimpleUserAgent();
foreach ($pages as $url => $raw) {
$url = new SimpleUrl($url);
$response = new MockSimpleHttpResponse();
$response->setReturnValue('getUrl', $url);
$response->setReturnValue('getContent', $raw);
$agent->returns('fetchResponse', $response, array($url, '*'));
}
return $agent;
}
function testSimplePageHasNoFrames() {
$browser = $this->createBrowser($this->createUserAgent(
array('http://site.with.no.frames/' => 'A non-framed page')));
$this->assertEqual(
$browser->get('http://site.with.no.frames/'),
'A non-framed page');
$this->assertIdentical($browser->getFrames(), 'http://site.with.no.frames/');
}
function testFramesetWithSingleFrame() {
$frameset = '<frameset><frame name="a" src="frame.html"></frameset>';
$browser = $this->createBrowser($this->createUserAgent(array(
'http://site.with.one.frame/' => $frameset,
'http://site.with.one.frame/frame.html' => 'A frame')));
$this->assertEqual($browser->get('http://site.with.one.frame/'), 'A frame');
$this->assertIdentical(
$browser->getFrames(),
array('a' => 'http://site.with.one.frame/frame.html'));
}
function testTitleTakenFromFramesetPage() {
$frameset = '<title>Frameset title</title>' .
'<frameset><frame name="a" src="frame.html"></frameset>';
$browser = $this->createBrowser($this->createUserAgent(array(
'http://site.with.one.frame/' => $frameset,
'http://site.with.one.frame/frame.html' => '<title>Page title</title>')));
$browser->get('http://site.with.one.frame/');
$this->assertEqual($browser->getTitle(), 'Frameset title');
}
function testFramesetWithSingleUnnamedFrame() {
$frameset = '<frameset><frame src="frame.html"></frameset>';
$browser = $this->createBrowser($this->createUserAgent(array(
'http://site.with.one.frame/' => $frameset,
'http://site.with.one.frame/frame.html' => 'One frame')));
$this->assertEqual(
$browser->get('http://site.with.one.frame/'),
'One frame');
$this->assertIdentical(
$browser->getFrames(),
array(1 => 'http://site.with.one.frame/frame.html'));
}
function testFramesetWithMultipleFrames() {
$frameset = '<frameset>' .
'<frame name="a" src="frame_a.html">' .
'<frame name="b" src="frame_b.html">' .
'<frame name="c" src="frame_c.html">' .
'</frameset>';
$browser = $this->createBrowser($this->createUserAgent(array(
'http://site.with.frames/' => $frameset,
'http://site.with.frames/frame_a.html' => 'A frame',
'http://site.with.frames/frame_b.html' => 'B frame',
'http://site.with.frames/frame_c.html' => 'C frame')));
$this->assertEqual(
$browser->get('http://site.with.frames/'),
'A frameB frameC frame');
$this->assertIdentical($browser->getFrames(), array(
'a' => 'http://site.with.frames/frame_a.html',
'b' => 'http://site.with.frames/frame_b.html',
'c' => 'http://site.with.frames/frame_c.html'));
}
function testFrameFocusByName() {
$frameset = '<frameset>' .
'<frame name="a" src="frame_a.html">' .
'<frame name="b" src="frame_b.html">' .
'<frame name="c" src="frame_c.html">' .
'</frameset>';
$browser = $this->createBrowser($this->createUserAgent(array(
'http://site.with.frames/' => $frameset,
'http://site.with.frames/frame_a.html' => 'A frame',
'http://site.with.frames/frame_b.html' => 'B frame',
'http://site.with.frames/frame_c.html' => 'C frame')));
$browser->get('http://site.with.frames/');
$browser->setFrameFocus('a');
$this->assertEqual($browser->getContent(), 'A frame');
$browser->setFrameFocus('b');
$this->assertEqual($browser->getContent(), 'B frame');
$browser->setFrameFocus('c');
$this->assertEqual($browser->getContent(), 'C frame');
}
function testFramesetWithSomeNamedFrames() {
$frameset = '<frameset>' .
'<frame name="a" src="frame_a.html">' .
'<frame src="frame_b.html">' .
'<frame name="c" src="frame_c.html">' .
'<frame src="frame_d.html">' .
'</frameset>';
$browser = $this->createBrowser($this->createUserAgent(array(
'http://site.with.frames/' => $frameset,
'http://site.with.frames/frame_a.html' => 'A frame',
'http://site.with.frames/frame_b.html' => 'B frame',
'http://site.with.frames/frame_c.html' => 'C frame',
'http://site.with.frames/frame_d.html' => 'D frame')));
$this->assertEqual(
$browser->get('http://site.with.frames/'),
'A frameB frameC frameD frame');
$this->assertIdentical($browser->getFrames(), array(
'a' => 'http://site.with.frames/frame_a.html',
2 => 'http://site.with.frames/frame_b.html',
'c' => 'http://site.with.frames/frame_c.html',
4 => 'http://site.with.frames/frame_d.html'));
}
function testFrameFocusWithMixedNamesAndIndexes() {
$frameset = '<frameset>' .
'<frame name="a" src="frame_a.html">' .
'<frame src="frame_b.html">' .
'<frame name="c" src="frame_c.html">' .
'<frame src="frame_d.html">' .
'</frameset>';
$browser = $this->createBrowser($this->createUserAgent(array(
'http://site.with.frames/' => $frameset,
'http://site.with.frames/frame_a.html' => 'A frame',
'http://site.with.frames/frame_b.html' => 'B frame',
'http://site.with.frames/frame_c.html' => 'C frame',
'http://site.with.frames/frame_d.html' => 'D frame')));
$browser->get('http://site.with.frames/');
$browser->setFrameFocus('a');
$this->assertEqual($browser->getContent(), 'A frame');
$browser->setFrameFocus(2);
$this->assertEqual($browser->getContent(), 'B frame');
$browser->setFrameFocus('c');
$this->assertEqual($browser->getContent(), 'C frame');
$browser->setFrameFocus(4);
$this->assertEqual($browser->getContent(), 'D frame');
$browser->clearFrameFocus();
$this->assertEqual($browser->getContent(), 'A frameB frameC frameD frame');
}
function testNestedFrameset() {
$inner = '<frameset>' .
'<frame name="page" src="page.html">' .
'</frameset>';
$outer = '<frameset>' .
'<frame name="inner" src="inner.html">' .
'</frameset>';
$browser = $this->createBrowser($this->createUserAgent(array(
'http://site.with.nested.frame/' => $outer,
'http://site.with.nested.frame/inner.html' => $inner,
'http://site.with.nested.frame/page.html' => 'The page')));
$this->assertEqual(
$browser->get('http://site.with.nested.frame/'),
'The page');
$this->assertIdentical($browser->getFrames(), array(
'inner' => array(
'page' => 'http://site.with.nested.frame/page.html')));
}
function testCanNavigateToNestedFrame() {
$inner = '<frameset>' .
'<frame name="one" src="one.html">' .
'<frame name="two" src="two.html">' .
'</frameset>';
$outer = '<frameset>' .
'<frame name="inner" src="inner.html">' .
'<frame name="three" src="three.html">' .
'</frameset>';
$browser = $this->createBrowser($this->createUserAgent(array(
'http://site.with.nested.frames/' => $outer,
'http://site.with.nested.frames/inner.html' => $inner,
'http://site.with.nested.frames/one.html' => 'Page one',
'http://site.with.nested.frames/two.html' => 'Page two',
'http://site.with.nested.frames/three.html' => 'Page three')));
$browser->get('http://site.with.nested.frames/');
$this->assertEqual($browser->getContent(), 'Page onePage twoPage three');
$this->assertTrue($browser->setFrameFocus('inner'));
$this->assertEqual($browser->getFrameFocus(), array('inner'));
$this->assertTrue($browser->setFrameFocus('one'));
$this->assertEqual($browser->getFrameFocus(), array('inner', 'one'));
$this->assertEqual($browser->getContent(), 'Page one');
$this->assertTrue($browser->setFrameFocus('two'));
$this->assertEqual($browser->getFrameFocus(), array('inner', 'two'));
$this->assertEqual($browser->getContent(), 'Page two');
$browser->clearFrameFocus();
$this->assertTrue($browser->setFrameFocus('three'));
$this->assertEqual($browser->getFrameFocus(), array('three'));
$this->assertEqual($browser->getContent(), 'Page three');
$this->assertTrue($browser->setFrameFocus('inner'));
$this->assertEqual($browser->getContent(), 'Page onePage two');
}
function testCanNavigateToNestedFrameByIndex() {
$inner = '<frameset>' .
'<frame src="one.html">' .
'<frame src="two.html">' .
'</frameset>';
$outer = '<frameset>' .
'<frame src="inner.html">' .
'<frame src="three.html">' .
'</frameset>';
$browser = $this->createBrowser($this->createUserAgent(array(
'http://site.with.nested.frames/' => $outer,
'http://site.with.nested.frames/inner.html' => $inner,
'http://site.with.nested.frames/one.html' => 'Page one',
'http://site.with.nested.frames/two.html' => 'Page two',
'http://site.with.nested.frames/three.html' => 'Page three')));
$browser->get('http://site.with.nested.frames/');
$this->assertEqual($browser->getContent(), 'Page onePage twoPage three');
$this->assertTrue($browser->setFrameFocusByIndex(1));
$this->assertEqual($browser->getFrameFocus(), array(1));
$this->assertTrue($browser->setFrameFocusByIndex(1));
$this->assertEqual($browser->getFrameFocus(), array(1, 1));
$this->assertEqual($browser->getContent(), 'Page one');
$this->assertTrue($browser->setFrameFocusByIndex(2));
$this->assertEqual($browser->getFrameFocus(), array(1, 2));
$this->assertEqual($browser->getContent(), 'Page two');
$browser->clearFrameFocus();
$this->assertTrue($browser->setFrameFocusByIndex(2));
$this->assertEqual($browser->getFrameFocus(), array(2));
$this->assertEqual($browser->getContent(), 'Page three');
$this->assertTrue($browser->setFrameFocusByIndex(1));
$this->assertEqual($browser->getContent(), 'Page onePage two');
}
}
?> | 10npsite | trunk/simpletest/test/browser_test.php | PHP | asf20 | 35,230 |
<?php
// $Id: frames_test.php 1899 2009-07-28 19:33:42Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../tag.php');
require_once(dirname(__FILE__) . '/../page.php');
require_once(dirname(__FILE__) . '/../frames.php');
Mock::generate('SimplePage');
Mock::generate('SimpleForm');
class TestOfFrameset extends UnitTestCase {
function testTitleReadFromFramesetPage() {
$page = new MockSimplePage();
$page->setReturnValue('getTitle', 'This page');
$frameset = new SimpleFrameset($page);
$this->assertEqual($frameset->getTitle(), 'This page');
}
function TestHeadersReadFromFramesetByDefault() {
$page = new MockSimplePage();
$page->setReturnValue('getHeaders', 'Header: content');
$page->setReturnValue('getMimeType', 'text/xml');
$page->setReturnValue('getResponseCode', 401);
$page->setReturnValue('getTransportError', 'Could not parse headers');
$page->setReturnValue('getAuthentication', 'Basic');
$page->setReturnValue('getRealm', 'Safe place');
$frameset = new SimpleFrameset($page);
$this->assertIdentical($frameset->getHeaders(), 'Header: content');
$this->assertIdentical($frameset->getMimeType(), 'text/xml');
$this->assertIdentical($frameset->getResponseCode(), 401);
$this->assertIdentical($frameset->getTransportError(), 'Could not parse headers');
$this->assertIdentical($frameset->getAuthentication(), 'Basic');
$this->assertIdentical($frameset->getRealm(), 'Safe place');
}
function testEmptyFramesetHasNoContent() {
$page = new MockSimplePage();
$page->setReturnValue('getRaw', 'This content');
$frameset = new SimpleFrameset($page);
$this->assertEqual($frameset->getRaw(), '');
}
function testRawContentIsFromOnlyFrame() {
$page = new MockSimplePage();
$page->expectNever('getRaw');
$frame = new MockSimplePage();
$frame->setReturnValue('getRaw', 'Stuff');
$frameset = new SimpleFrameset($page);
$frameset->addFrame($frame);
$this->assertEqual($frameset->getRaw(), 'Stuff');
}
function testRawContentIsFromAllFrames() {
$page = new MockSimplePage();
$page->expectNever('getRaw');
$frame1 = new MockSimplePage();
$frame1->setReturnValue('getRaw', 'Stuff1');
$frame2 = new MockSimplePage();
$frame2->setReturnValue('getRaw', 'Stuff2');
$frameset = new SimpleFrameset($page);
$frameset->addFrame($frame1);
$frameset->addFrame($frame2);
$this->assertEqual($frameset->getRaw(), 'Stuff1Stuff2');
}
function testTextContentIsFromOnlyFrame() {
$page = new MockSimplePage();
$page->expectNever('getText');
$frame = new MockSimplePage();
$frame->setReturnValue('getText', 'Stuff');
$frameset = new SimpleFrameset($page);
$frameset->addFrame($frame);
$this->assertEqual($frameset->getText(), 'Stuff');
}
function testTextContentIsFromAllFrames() {
$page = new MockSimplePage();
$page->expectNever('getText');
$frame1 = new MockSimplePage();
$frame1->setReturnValue('getText', 'Stuff1');
$frame2 = new MockSimplePage();
$frame2->setReturnValue('getText', 'Stuff2');
$frameset = new SimpleFrameset($page);
$frameset->addFrame($frame1);
$frameset->addFrame($frame2);
$this->assertEqual($frameset->getText(), 'Stuff1 Stuff2');
}
function testFieldFoundIsFirstInFramelist() {
$frame1 = new MockSimplePage();
$frame1->setReturnValue('getField', null);
$frame1->expectOnce('getField', array(new SimpleByName('a')));
$frame2 = new MockSimplePage();
$frame2->setReturnValue('getField', 'A');
$frame2->expectOnce('getField', array(new SimpleByName('a')));
$frame3 = new MockSimplePage();
$frame3->expectNever('getField');
$page = new MockSimplePage();
$frameset = new SimpleFrameset($page);
$frameset->addFrame($frame1);
$frameset->addFrame($frame2);
$frameset->addFrame($frame3);
$this->assertIdentical($frameset->getField(new SimpleByName('a')), 'A');
}
function testFrameReplacementByIndex() {
$page = new MockSimplePage();
$page->expectNever('getRaw');
$frame1 = new MockSimplePage();
$frame1->setReturnValue('getRaw', 'Stuff1');
$frame2 = new MockSimplePage();
$frame2->setReturnValue('getRaw', 'Stuff2');
$frameset = new SimpleFrameset($page);
$frameset->addFrame($frame1);
$frameset->setFrame(array(1), $frame2);
$this->assertEqual($frameset->getRaw(), 'Stuff2');
}
function testFrameReplacementByName() {
$page = new MockSimplePage();
$page->expectNever('getRaw');
$frame1 = new MockSimplePage();
$frame1->setReturnValue('getRaw', 'Stuff1');
$frame2 = new MockSimplePage();
$frame2->setReturnValue('getRaw', 'Stuff2');
$frameset = new SimpleFrameset($page);
$frameset->addFrame($frame1, 'a');
$frameset->setFrame(array('a'), $frame2);
$this->assertEqual($frameset->getRaw(), 'Stuff2');
}
}
class TestOfFrameNavigation extends UnitTestCase {
function testStartsWithoutFrameFocus() {
$page = new MockSimplePage();
$frameset = new SimpleFrameset($page);
$frameset->addFrame(new MockSimplePage());
$this->assertFalse($frameset->getFrameFocus());
}
function testCanFocusOnSingleFrame() {
$page = new MockSimplePage();
$page->expectNever('getRaw');
$frame = new MockSimplePage();
$frame->setReturnValue('getFrameFocus', array());
$frame->setReturnValue('getRaw', 'Stuff');
$frameset = new SimpleFrameset($page);
$frameset->addFrame($frame);
$this->assertFalse($frameset->setFrameFocusByIndex(0));
$this->assertTrue($frameset->setFrameFocusByIndex(1));
$this->assertEqual($frameset->getRaw(), 'Stuff');
$this->assertFalse($frameset->setFrameFocusByIndex(2));
$this->assertIdentical($frameset->getFrameFocus(), array(1));
}
function testContentComesFromFrameInFocus() {
$page = new MockSimplePage();
$frame1 = new MockSimplePage();
$frame1->setReturnValue('getRaw', 'Stuff1');
$frame1->setReturnValue('getFrameFocus', array());
$frame2 = new MockSimplePage();
$frame2->setReturnValue('getRaw', 'Stuff2');
$frame2->setReturnValue('getFrameFocus', array());
$frameset = new SimpleFrameset($page);
$frameset->addFrame($frame1);
$frameset->addFrame($frame2);
$this->assertTrue($frameset->setFrameFocusByIndex(1));
$this->assertEqual($frameset->getFrameFocus(), array(1));
$this->assertEqual($frameset->getRaw(), 'Stuff1');
$this->assertTrue($frameset->setFrameFocusByIndex(2));
$this->assertEqual($frameset->getFrameFocus(), array(2));
$this->assertEqual($frameset->getRaw(), 'Stuff2');
$this->assertFalse($frameset->setFrameFocusByIndex(3));
$this->assertEqual($frameset->getFrameFocus(), array(2));
$frameset->clearFrameFocus();
$this->assertEqual($frameset->getRaw(), 'Stuff1Stuff2');
}
function testCanFocusByName() {
$page = new MockSimplePage();
$frame1 = new MockSimplePage();
$frame1->setReturnValue('getRaw', 'Stuff1');
$frame1->setReturnValue('getFrameFocus', array());
$frame2 = new MockSimplePage();
$frame2->setReturnValue('getRaw', 'Stuff2');
$frame2->setReturnValue('getFrameFocus', array());
$frameset = new SimpleFrameset($page);
$frameset->addFrame($frame1, 'A');
$frameset->addFrame($frame2, 'B');
$this->assertTrue($frameset->setFrameFocus('A'));
$this->assertEqual($frameset->getFrameFocus(), array('A'));
$this->assertEqual($frameset->getRaw(), 'Stuff1');
$this->assertTrue($frameset->setFrameFocusByIndex(2));
$this->assertEqual($frameset->getFrameFocus(), array('B'));
$this->assertEqual($frameset->getRaw(), 'Stuff2');
$this->assertFalse($frameset->setFrameFocus('z'));
$frameset->clearFrameFocus();
$this->assertEqual($frameset->getRaw(), 'Stuff1Stuff2');
}
}
class TestOfFramesetPageInterface extends UnitTestCase {
private $page_interface;
private $frameset_interface;
function __construct() {
parent::__construct();
$this->page_interface = $this->getPageMethods();
$this->frameset_interface = $this->getFramesetMethods();
}
function assertListInAnyOrder($list, $expected) {
sort($list);
sort($expected);
$this->assertEqual($list, $expected);
}
private function getPageMethods() {
$methods = array();
foreach (get_class_methods('SimplePage') as $method) {
if (strtolower($method) == strtolower('SimplePage')) {
continue;
}
if (strtolower($method) == strtolower('getFrameset')) {
continue;
}
if (strncmp($method, '_', 1) == 0) {
continue;
}
if (in_array($method, array('setTitle', 'setBase', 'setForms', 'normalise', 'setFrames', 'addLink'))) {
continue;
}
$methods[] = $method;
}
return $methods;
}
private function getFramesetMethods() {
$methods = array();
foreach (get_class_methods('SimpleFrameset') as $method) {
if (strtolower($method) == strtolower('SimpleFrameset')) {
continue;
}
if (strncmp($method, '_', 1) == 0) {
continue;
}
if (strncmp($method, 'add', 3) == 0) {
continue;
}
$methods[] = $method;
}
return $methods;
}
function testFramsetHasPageInterface() {
$difference = array();
foreach ($this->page_interface as $method) {
if (! in_array($method, $this->frameset_interface)) {
$this->fail("No [$method] in Frameset class");
return;
}
}
$this->pass('Frameset covers Page interface');
}
function testHeadersReadFromFrameIfInFocus() {
$frame = new MockSimplePage();
$frame->setReturnValue('getUrl', new SimpleUrl('http://localhost/stuff'));
$frame->setReturnValue('getRequest', 'POST stuff');
$frame->setReturnValue('getMethod', 'POST');
$frame->setReturnValue('getRequestData', array('a' => 'A'));
$frame->setReturnValue('getHeaders', 'Header: content');
$frame->setReturnValue('getMimeType', 'text/xml');
$frame->setReturnValue('getResponseCode', 401);
$frame->setReturnValue('getTransportError', 'Could not parse headers');
$frame->setReturnValue('getAuthentication', 'Basic');
$frame->setReturnValue('getRealm', 'Safe place');
$frameset = new SimpleFrameset(new MockSimplePage());
$frameset->addFrame($frame);
$frameset->setFrameFocusByIndex(1);
$url = new SimpleUrl('http://localhost/stuff');
$url->setTarget(1);
$this->assertIdentical($frameset->getUrl(), $url);
$this->assertIdentical($frameset->getRequest(), 'POST stuff');
$this->assertIdentical($frameset->getMethod(), 'POST');
$this->assertIdentical($frameset->getRequestData(), array('a' => 'A'));
$this->assertIdentical($frameset->getHeaders(), 'Header: content');
$this->assertIdentical($frameset->getMimeType(), 'text/xml');
$this->assertIdentical($frameset->getResponseCode(), 401);
$this->assertIdentical($frameset->getTransportError(), 'Could not parse headers');
$this->assertIdentical($frameset->getAuthentication(), 'Basic');
$this->assertIdentical($frameset->getRealm(), 'Safe place');
}
function testUrlsComeFromBothFrames() {
$page = new MockSimplePage();
$page->expectNever('getUrls');
$frame1 = new MockSimplePage();
$frame1->setReturnValue(
'getUrls',
array('http://www.lastcraft.com/', 'http://myserver/'));
$frame2 = new MockSimplePage();
$frame2->setReturnValue(
'getUrls',
array('http://www.lastcraft.com/', 'http://test/'));
$frameset = new SimpleFrameset($page);
$frameset->addFrame($frame1);
$frameset->addFrame($frame2);
$this->assertListInAnyOrder(
$frameset->getUrls(),
array('http://www.lastcraft.com/', 'http://myserver/', 'http://test/'));
}
function testLabelledUrlsComeFromBothFrames() {
$frame1 = new MockSimplePage();
$frame1->setReturnValue(
'getUrlsByLabel',
array(new SimpleUrl('goodbye.php')),
array('a'));
$frame2 = new MockSimplePage();
$frame2->setReturnValue(
'getUrlsByLabel',
array(new SimpleUrl('hello.php')),
array('a'));
$frameset = new SimpleFrameset(new MockSimplePage());
$frameset->addFrame($frame1);
$frameset->addFrame($frame2, 'Two');
$expected1 = new SimpleUrl('goodbye.php');
$expected1->setTarget(1);
$expected2 = new SimpleUrl('hello.php');
$expected2->setTarget('Two');
$this->assertEqual(
$frameset->getUrlsByLabel('a'),
array($expected1, $expected2));
}
function testUrlByIdComesFromFirstFrameToRespond() {
$frame1 = new MockSimplePage();
$frame1->setReturnValue('getUrlById', new SimpleUrl('four.php'), array(4));
$frame1->setReturnValue('getUrlById', false, array(5));
$frame2 = new MockSimplePage();
$frame2->setReturnValue('getUrlById', false, array(4));
$frame2->setReturnValue('getUrlById', new SimpleUrl('five.php'), array(5));
$frameset = new SimpleFrameset(new MockSimplePage());
$frameset->addFrame($frame1);
$frameset->addFrame($frame2);
$four = new SimpleUrl('four.php');
$four->setTarget(1);
$this->assertEqual($frameset->getUrlById(4), $four);
$five = new SimpleUrl('five.php');
$five->setTarget(2);
$this->assertEqual($frameset->getUrlById(5), $five);
}
function testReadUrlsFromFrameInFocus() {
$frame1 = new MockSimplePage();
$frame1->setReturnValue('getUrls', array('a'));
$frame1->setReturnValue('getUrlsByLabel', array(new SimpleUrl('l')));
$frame1->setReturnValue('getUrlById', new SimpleUrl('i'));
$frame2 = new MockSimplePage();
$frame2->expectNever('getUrls');
$frame2->expectNever('getUrlsByLabel');
$frame2->expectNever('getUrlById');
$frameset = new SimpleFrameset(new MockSimplePage());
$frameset->addFrame($frame1, 'A');
$frameset->addFrame($frame2, 'B');
$frameset->setFrameFocus('A');
$this->assertIdentical($frameset->getUrls(), array('a'));
$expected = new SimpleUrl('l');
$expected->setTarget('A');
$this->assertIdentical($frameset->getUrlsByLabel('label'), array($expected));
$expected = new SimpleUrl('i');
$expected->setTarget('A');
$this->assertIdentical($frameset->getUrlById(99), $expected);
}
function testReadFrameTaggedUrlsFromFrameInFocus() {
$frame = new MockSimplePage();
$by_label = new SimpleUrl('l');
$by_label->setTarget('L');
$frame->setReturnValue('getUrlsByLabel', array($by_label));
$by_id = new SimpleUrl('i');
$by_id->setTarget('I');
$frame->setReturnValue('getUrlById', $by_id);
$frameset = new SimpleFrameset(new MockSimplePage());
$frameset->addFrame($frame, 'A');
$frameset->setFrameFocus('A');
$this->assertIdentical($frameset->getUrlsByLabel('label'), array($by_label));
$this->assertIdentical($frameset->getUrlById(99), $by_id);
}
function testFindingFormsById() {
$frame = new MockSimplePage();
$form = new MockSimpleForm();
$frame->returns('getFormById', $form, array('a'));
$frameset = new SimpleFrameset(new MockSimplePage());
$frameset->addFrame(new MockSimplePage(), 'A');
$frameset->addFrame($frame, 'B');
$this->assertSame($frameset->getFormById('a'), $form);
$frameset->setFrameFocus('A');
$this->assertNull($frameset->getFormById('a'));
$frameset->setFrameFocus('B');
$this->assertSame($frameset->getFormById('a'), $form);
}
function testFindingFormsBySubmit() {
$frame = new MockSimplePage();
$form = new MockSimpleForm();
$frame->returns(
'getFormBySubmit',
$form,
array(new SimpleByLabel('a')));
$frameset = new SimpleFrameset(new MockSimplePage());
$frameset->addFrame(new MockSimplePage(), 'A');
$frameset->addFrame($frame, 'B');
$this->assertSame($frameset->getFormBySubmit(new SimpleByLabel('a')), $form);
$frameset->setFrameFocus('A');
$this->assertNull($frameset->getFormBySubmit(new SimpleByLabel('a')));
$frameset->setFrameFocus('B');
$this->assertSame($frameset->getFormBySubmit(new SimpleByLabel('a')), $form);
}
function testFindingFormsByImage() {
$frame = new MockSimplePage();
$form = new MockSimpleForm();
$frame->returns(
'getFormByImage',
$form,
array(new SimpleByLabel('a')));
$frameset = new SimpleFrameset(new MockSimplePage());
$frameset->addFrame(new MockSimplePage(), 'A');
$frameset->addFrame($frame, 'B');
$this->assertSame($frameset->getFormByImage(new SimpleByLabel('a')), $form);
$frameset->setFrameFocus('A');
$this->assertNull($frameset->getFormByImage(new SimpleByLabel('a')));
$frameset->setFrameFocus('B');
$this->assertSame($frameset->getFormByImage(new SimpleByLabel('a')), $form);
}
function testSettingAllFrameFieldsWhenNoFrameFocus() {
$frame1 = new MockSimplePage();
$frame1->expectOnce('setField', array(new SimpleById(22), 'A'));
$frame2 = new MockSimplePage();
$frame2->expectOnce('setField', array(new SimpleById(22), 'A'));
$frameset = new SimpleFrameset(new MockSimplePage());
$frameset->addFrame($frame1, 'A');
$frameset->addFrame($frame2, 'B');
$frameset->setField(new SimpleById(22), 'A');
}
function testOnlySettingFieldFromFocusedFrame() {
$frame1 = new MockSimplePage();
$frame1->expectOnce('setField', array(new SimpleByLabelOrName('a'), 'A'));
$frame2 = new MockSimplePage();
$frame2->expectNever('setField');
$frameset = new SimpleFrameset(new MockSimplePage());
$frameset->addFrame($frame1, 'A');
$frameset->addFrame($frame2, 'B');
$frameset->setFrameFocus('A');
$frameset->setField(new SimpleByLabelOrName('a'), 'A');
}
function testOnlyGettingFieldFromFocusedFrame() {
$frame1 = new MockSimplePage();
$frame1->setReturnValue('getField', 'f', array(new SimpleByName('a')));
$frame2 = new MockSimplePage();
$frame2->expectNever('getField');
$frameset = new SimpleFrameset(new MockSimplePage());
$frameset->addFrame($frame1, 'A');
$frameset->addFrame($frame2, 'B');
$frameset->setFrameFocus('A');
$this->assertIdentical($frameset->getField(new SimpleByName('a')), 'f');
}
}
?> | 10npsite | trunk/simpletest/test/frames_test.php | PHP | asf20 | 20,083 |
<?php
interface SampleInterfaceWithHintInSignature {
function method(array $hinted);
}
class TestOfInterfaceMocksWithHintInSignature extends UnitTestCase {
function testBasicConstructOfAnInterfaceWithHintInSignature() {
Mock::generate('SampleInterfaceWithHintInSignature');
$mock = new MockSampleInterfaceWithHintInSignature();
$this->assertIsA($mock, 'SampleInterfaceWithHintInSignature');
}
}
| 10npsite | trunk/simpletest/test/interfaces_test_php5_1.php | PHP | asf20 | 434 |
<?php
// $Id: adapter_test.php 1748 2008-04-14 01:50:41Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../extensions/pear_test_case.php');
class SameTestClass {
}
class TestOfPearAdapter extends PHPUnit_TestCase {
function testBoolean() {
$this->assertTrue(true, "PEAR true");
$this->assertFalse(false, "PEAR false");
}
function testName() {
$this->assertTrue($this->getName() == get_class($this));
}
function testPass() {
$this->pass("PEAR pass");
}
function testNulls() {
$value = null;
$this->assertNull($value, "PEAR null");
$value = 0;
$this->assertNotNull($value, "PEAR not null");
}
function testType() {
$this->assertType("Hello", "string", "PEAR type");
}
function testEquals() {
$this->assertEquals(12, 12, "PEAR identity");
$this->setLooselyTyped(true);
$this->assertEquals("12", 12, "PEAR equality");
}
function testSame() {
$same = new SameTestClass();
$this->assertSame($same, $same, "PEAR same");
}
function testRegExp() {
$this->assertRegExp('/hello/', "A big hello from me", "PEAR regex");
}
}
?> | 10npsite | trunk/simpletest/test/adapter_test.php | PHP | asf20 | 1,293 |
<?php
// $Id: visual_test.php 1884 2009-07-01 16:30:40Z lastcraft $
// NOTE:
// Some of these tests are designed to fail! Do not be alarmed.
// ----------------
// The following tests are a bit hacky. Whilst Kent Beck tried to
// build a unit tester with a unit tester, I am not that brave.
// Instead I have just hacked together odd test scripts until
// I have enough of a tester to procede more formally.
//
// The proper tests start in all_tests.php
require_once('../unit_tester.php');
require_once('../shell_tester.php');
require_once('../mock_objects.php');
require_once('../reporter.php');
require_once('../xml.php');
class TestDisplayClass {
private $a;
function TestDisplayClass($a) {
$this->a = $a;
}
}
class PassingUnitTestCaseOutput extends UnitTestCase {
function testOfResults() {
$this->pass('Pass');
}
function testTrue() {
$this->assertTrue(true);
}
function testFalse() {
$this->assertFalse(false);
}
function testExpectation() {
$expectation = &new EqualExpectation(25, 'My expectation message: %s');
$this->assert($expectation, 25, 'My assert message : %s');
}
function testNull() {
$this->assertNull(null, "%s -> Pass");
$this->assertNotNull(false, "%s -> Pass");
}
function testType() {
$this->assertIsA("hello", "string", "%s -> Pass");
$this->assertIsA($this, "PassingUnitTestCaseOutput", "%s -> Pass");
$this->assertIsA($this, "UnitTestCase", "%s -> Pass");
}
function testTypeEquality() {
$this->assertEqual("0", 0, "%s -> Pass");
}
function testNullEquality() {
$this->assertNotEqual(null, 1, "%s -> Pass");
$this->assertNotEqual(1, null, "%s -> Pass");
}
function testIntegerEquality() {
$this->assertNotEqual(1, 2, "%s -> Pass");
}
function testStringEquality() {
$this->assertEqual("a", "a", "%s -> Pass");
$this->assertNotEqual("aa", "ab", "%s -> Pass");
}
function testHashEquality() {
$this->assertEqual(array("a" => "A", "b" => "B"), array("b" => "B", "a" => "A"), "%s -> Pass");
}
function testWithin() {
$this->assertWithinMargin(5, 5.4, 0.5, "%s -> Pass");
}
function testOutside() {
$this->assertOutsideMargin(5, 5.6, 0.5, "%s -> Pass");
}
function testStringIdentity() {
$a = "fred";
$b = $a;
$this->assertIdentical($a, $b, "%s -> Pass");
}
function testTypeIdentity() {
$a = "0";
$b = 0;
$this->assertNotIdentical($a, $b, "%s -> Pass");
}
function testNullIdentity() {
$this->assertNotIdentical(null, 1, "%s -> Pass");
$this->assertNotIdentical(1, null, "%s -> Pass");
}
function testHashIdentity() {
}
function testObjectEquality() {
$this->assertEqual(new TestDisplayClass(4), new TestDisplayClass(4), "%s -> Pass");
$this->assertNotEqual(new TestDisplayClass(4), new TestDisplayClass(5), "%s -> Pass");
}
function testObjectIndentity() {
$this->assertIdentical(new TestDisplayClass(false), new TestDisplayClass(false), "%s -> Pass");
$this->assertNotIdentical(new TestDisplayClass(false), new TestDisplayClass(0), "%s -> Pass");
}
function testReference() {
$a = "fred";
$b = &$a;
$this->assertReference($a, $b, "%s -> Pass");
}
function testCloneOnDifferentObjects() {
$a = "fred";
$b = $a;
$c = "Hello";
$this->assertClone($a, $b, "%s -> Pass");
}
function testPatterns() {
$this->assertPattern('/hello/i', "Hello there", "%s -> Pass");
$this->assertNoPattern('/hello/', "Hello there", "%s -> Pass");
}
function testLongStrings() {
$text = "";
for ($i = 0; $i < 10; $i++) {
$text .= "0123456789";
}
$this->assertEqual($text, $text);
}
}
class FailingUnitTestCaseOutput extends UnitTestCase {
function testOfResults() {
$this->fail('Fail'); // Fail.
}
function testTrue() {
$this->assertTrue(false); // Fail.
}
function testFalse() {
$this->assertFalse(true); // Fail.
}
function testExpectation() {
$expectation = &new EqualExpectation(25, 'My expectation message: %s');
$this->assert($expectation, 24, 'My assert message : %s'); // Fail.
}
function testNull() {
$this->assertNull(false, "%s -> Fail"); // Fail.
$this->assertNotNull(null, "%s -> Fail"); // Fail.
}
function testType() {
$this->assertIsA(14, "string", "%s -> Fail"); // Fail.
$this->assertIsA(14, "TestOfUnitTestCaseOutput", "%s -> Fail"); // Fail.
$this->assertIsA($this, "TestReporter", "%s -> Fail"); // Fail.
}
function testTypeEquality() {
$this->assertNotEqual("0", 0, "%s -> Fail"); // Fail.
}
function testNullEquality() {
$this->assertEqual(null, 1, "%s -> Fail"); // Fail.
$this->assertEqual(1, null, "%s -> Fail"); // Fail.
}
function testIntegerEquality() {
$this->assertEqual(1, 2, "%s -> Fail"); // Fail.
}
function testStringEquality() {
$this->assertNotEqual("a", "a", "%s -> Fail"); // Fail.
$this->assertEqual("aa", "ab", "%s -> Fail"); // Fail.
}
function testHashEquality() {
$this->assertEqual(array("a" => "A", "b" => "B"), array("b" => "B", "a" => "Z"), "%s -> Fail");
}
function testWithin() {
$this->assertWithinMargin(5, 5.6, 0.5, "%s -> Fail"); // Fail.
}
function testOutside() {
$this->assertOutsideMargin(5, 5.4, 0.5, "%s -> Fail"); // Fail.
}
function testStringIdentity() {
$a = "fred";
$b = $a;
$this->assertNotIdentical($a, $b, "%s -> Fail"); // Fail.
}
function testTypeIdentity() {
$a = "0";
$b = 0;
$this->assertIdentical($a, $b, "%s -> Fail"); // Fail.
}
function testNullIdentity() {
$this->assertIdentical(null, 1, "%s -> Fail"); // Fail.
$this->assertIdentical(1, null, "%s -> Fail"); // Fail.
}
function testHashIdentity() {
$this->assertIdentical(array("a" => "A", "b" => "B"), array("b" => "B", "a" => "A"), "%s -> fail"); // Fail.
}
function testObjectEquality() {
$this->assertNotEqual(new TestDisplayClass(4), new TestDisplayClass(4), "%s -> Fail"); // Fail.
$this->assertEqual(new TestDisplayClass(4), new TestDisplayClass(5), "%s -> Fail"); // Fail.
}
function testObjectIndentity() {
$this->assertNotIdentical(new TestDisplayClass(false), new TestDisplayClass(false), "%s -> Fail"); // Fail.
$this->assertIdentical(new TestDisplayClass(false), new TestDisplayClass(0), "%s -> Fail"); // Fail.
}
function testReference() {
$a = "fred";
$b = &$a;
$this->assertClone($a, $b, "%s -> Fail"); // Fail.
}
function testCloneOnDifferentObjects() {
$a = "fred";
$b = $a;
$c = "Hello";
$this->assertClone($a, $c, "%s -> Fail"); // Fail.
}
function testPatterns() {
$this->assertPattern('/hello/', "Hello there", "%s -> Fail"); // Fail.
$this->assertNoPattern('/hello/i', "Hello there", "%s -> Fail"); // Fail.
}
function testLongStrings() {
$text = "";
for ($i = 0; $i < 10; $i++) {
$text .= "0123456789";
}
$this->assertEqual($text . $text, $text . "a" . $text); // Fail.
}
}
class Dummy {
function Dummy() {
}
function a() {
}
}
Mock::generate('Dummy');
class TestOfMockObjectsOutput extends UnitTestCase {
function testCallCounts() {
$dummy = &new MockDummy();
$dummy->expectCallCount('a', 1, 'My message: %s');
$dummy->a();
$dummy->a();
}
function testMinimumCallCounts() {
$dummy = &new MockDummy();
$dummy->expectMinimumCallCount('a', 2, 'My message: %s');
$dummy->a();
$dummy->a();
}
function testEmptyMatching() {
$dummy = &new MockDummy();
$dummy->expect('a', array());
$dummy->a();
$dummy->a(null); // Fail.
}
function testEmptyMatchingWithCustomMessage() {
$dummy = &new MockDummy();
$dummy->expect('a', array(), 'My expectation message: %s');
$dummy->a();
$dummy->a(null); // Fail.
}
function testNullMatching() {
$dummy = &new MockDummy();
$dummy->expect('a', array(null));
$dummy->a(null);
$dummy->a(); // Fail.
}
function testBooleanMatching() {
$dummy = &new MockDummy();
$dummy->expect('a', array(true, false));
$dummy->a(true, false);
$dummy->a(true, true); // Fail.
}
function testIntegerMatching() {
$dummy = &new MockDummy();
$dummy->expect('a', array(32, 33));
$dummy->a(32, 33);
$dummy->a(32, 34); // Fail.
}
function testFloatMatching() {
$dummy = &new MockDummy();
$dummy->expect('a', array(3.2, 3.3));
$dummy->a(3.2, 3.3);
$dummy->a(3.2, 3.4); // Fail.
}
function testStringMatching() {
$dummy = &new MockDummy();
$dummy->expect('a', array('32', '33'));
$dummy->a('32', '33');
$dummy->a('32', '34'); // Fail.
}
function testEmptyMatchingWithCustomExpectationMessage() {
$dummy = &new MockDummy();
$dummy->expect(
'a',
array(new EqualExpectation('A', 'My part expectation message: %s')),
'My expectation message: %s');
$dummy->a('A');
$dummy->a('B'); // Fail.
}
function testArrayMatching() {
$dummy = &new MockDummy();
$dummy->expect('a', array(array(32), array(33)));
$dummy->a(array(32), array(33));
$dummy->a(array(32), array('33')); // Fail.
}
function testObjectMatching() {
$a = new Dummy();
$a->a = 'a';
$b = new Dummy();
$b->b = 'b';
$dummy = &new MockDummy();
$dummy->expect('a', array($a, $b));
$dummy->a($a, $b);
$dummy->a($a, $a); // Fail.
}
function testBigList() {
$dummy = &new MockDummy();
$dummy->expect('a', array(false, 0, 1, 1.0));
$dummy->a(false, 0, 1, 1.0);
$dummy->a(true, false, 2, 2.0); // Fail.
}
}
class TestOfPastBugs extends UnitTestCase {
function testMixedTypes() {
$this->assertEqual(array(), null, "%s -> Pass");
$this->assertIdentical(array(), null, "%s -> Fail"); // Fail.
}
function testMockWildcards() {
$dummy = &new MockDummy();
$dummy->expect('a', array('*', array(33)));
$dummy->a(array(32), array(33));
$dummy->a(array(32), array('33')); // Fail.
}
}
class TestOfVisualShell extends ShellTestCase {
function testDump() {
$this->execute('ls');
$this->dumpOutput();
$this->execute('dir');
$this->dumpOutput();
}
function testDumpOfList() {
$this->execute('ls');
$this->dump($this->getOutputAsList());
}
}
class PassesAsWellReporter extends HtmlReporter {
protected function getCss() {
return parent::getCss() . ' .pass { color: darkgreen; }';
}
function paintPass($message) {
parent::paintPass($message);
print "<span class=\"pass\">Pass</span>: ";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
print implode(" -> ", $breadcrumb);
print " -> " . htmlentities($message) . "<br />\n";
}
function paintSignal($type, &$payload) {
print "<span class=\"fail\">$type</span>: ";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
print implode(" -> ", $breadcrumb);
print " -> " . htmlentities(serialize($payload)) . "<br />\n";
}
}
class TestOfSkippingNoMatterWhat extends UnitTestCase {
function skip() {
$this->skipIf(true, 'Always skipped -> %s');
}
function testFail() {
$this->fail('This really shouldn\'t have happened');
}
}
class TestOfSkippingOrElse extends UnitTestCase {
function skip() {
$this->skipUnless(false, 'Always skipped -> %s');
}
function testFail() {
$this->fail('This really shouldn\'t have happened');
}
}
class TestOfSkippingTwiceOver extends UnitTestCase {
function skip() {
$this->skipIf(true, 'First reason -> %s');
$this->skipIf(true, 'Second reason -> %s');
}
function testFail() {
$this->fail('This really shouldn\'t have happened');
}
}
class TestThatShouldNotBeSkipped extends UnitTestCase {
function skip() {
$this->skipIf(false);
$this->skipUnless(true);
}
function testFail() {
$this->fail('We should see this message');
}
function testPass() {
$this->pass('We should see this message');
}
}
$test = &new TestSuite('Visual test with 46 passes, 47 fails and 0 exceptions');
$test->add(new PassingUnitTestCaseOutput());
$test->add(new FailingUnitTestCaseOutput());
$test->add(new TestOfMockObjectsOutput());
$test->add(new TestOfPastBugs());
$test->add(new TestOfVisualShell());
$test->add(new TestOfSkippingNoMatterWhat());
$test->add(new TestOfSkippingOrElse());
$test->add(new TestOfSkippingTwiceOver());
$test->add(new TestThatShouldNotBeSkipped());
if (isset($_GET['xml']) || in_array('xml', (isset($argv) ? $argv : array()))) {
$reporter = new XmlReporter();
} elseif (TextReporter::inCli()) {
$reporter = new TextReporter();
} else {
$reporter = new PassesAsWellReporter();
}
if (isset($_GET['dry']) || in_array('dry', (isset($argv) ? $argv : array()))) {
$reporter->makeDry();
}
exit ($test->run($reporter) ? 0 : 1);
?> | 10npsite | trunk/simpletest/test/visual_test.php | PHP | asf20 | 14,271 |
<?php
// $Id: user_agent_test.php 1788 2008-04-27 11:01:59Z pp11 $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../user_agent.php');
require_once(dirname(__FILE__) . '/../authentication.php');
require_once(dirname(__FILE__) . '/../http.php');
require_once(dirname(__FILE__) . '/../encoding.php');
Mock::generate('SimpleHttpRequest');
Mock::generate('SimpleHttpResponse');
Mock::generate('SimpleHttpHeaders');
Mock::generatePartial('SimpleUserAgent', 'MockRequestUserAgent', array('createHttpRequest'));
class TestOfFetchingUrlParameters extends UnitTestCase {
function setUp() {
$this->headers = new MockSimpleHttpHeaders();
$this->response = new MockSimpleHttpResponse();
$this->response->setReturnValue('isError', false);
$this->response->returns('getHeaders', new MockSimpleHttpHeaders());
$this->request = new MockSimpleHttpRequest();
$this->request->returns('fetch', $this->response);
}
function testGetRequestWithoutIncidentGivesNoErrors() {
$url = new SimpleUrl('http://test:secret@this.com/page.html');
$url->addRequestParameters(array('a' => 'A', 'b' => 'B'));
$agent = new MockRequestUserAgent();
$agent->returns('createHttpRequest', $this->request);
$agent->__construct();
$response = $agent->fetchResponse(
new SimpleUrl('http://test:secret@this.com/page.html'),
new SimpleGetEncoding(array('a' => 'A', 'b' => 'B')));
$this->assertFalse($response->isError());
}
}
class TestOfAdditionalHeaders extends UnitTestCase {
function testAdditionalHeaderAddedToRequest() {
$response = new MockSimpleHttpResponse();
$response->setReturnReference('getHeaders', new MockSimpleHttpHeaders());
$request = new MockSimpleHttpRequest();
$request->setReturnReference('fetch', $response);
$request->expectOnce(
'addHeaderLine',
array('User-Agent: SimpleTest'));
$agent = new MockRequestUserAgent();
$agent->setReturnReference('createHttpRequest', $request);
$agent->__construct();
$agent->addHeader('User-Agent: SimpleTest');
$response = $agent->fetchResponse(new SimpleUrl('http://this.host/'), new SimpleGetEncoding());
}
}
class TestOfBrowserCookies extends UnitTestCase {
private function createStandardResponse() {
$response = new MockSimpleHttpResponse();
$response->setReturnValue("isError", false);
$response->setReturnValue("getContent", "stuff");
$response->setReturnReference("getHeaders", new MockSimpleHttpHeaders());
return $response;
}
private function createCookieSite($header_lines) {
$headers = new SimpleHttpHeaders($header_lines);
$response = new MockSimpleHttpResponse();
$response->setReturnValue("isError", false);
$response->setReturnReference("getHeaders", $headers);
$response->setReturnValue("getContent", "stuff");
$request = new MockSimpleHttpRequest();
$request->setReturnReference("fetch", $response);
return $request;
}
private function createMockedRequestUserAgent(&$request) {
$agent = new MockRequestUserAgent();
$agent->setReturnReference('createHttpRequest', $request);
$agent->__construct();
return $agent;
}
function testCookieJarIsSentToRequest() {
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'A');
$request = new MockSimpleHttpRequest();
$request->returns('fetch', $this->createStandardResponse());
$request->expectOnce('readCookiesFromJar', array($jar, '*'));
$agent = $this->createMockedRequestUserAgent($request);
$agent->setCookie('a', 'A');
$agent->fetchResponse(
new SimpleUrl('http://this.com/this/path/page.html'),
new SimpleGetEncoding());
}
function testNoCookieJarIsSentToRequestWhenCookiesAreDisabled() {
$request = new MockSimpleHttpRequest();
$request->returns('fetch', $this->createStandardResponse());
$request->expectNever('readCookiesFromJar');
$agent = $this->createMockedRequestUserAgent($request);
$agent->setCookie('a', 'A');
$agent->ignoreCookies();
$agent->fetchResponse(
new SimpleUrl('http://this.com/this/path/page.html'),
new SimpleGetEncoding());
}
function testReadingNewCookie() {
$request = $this->createCookieSite('Set-cookie: a=AAAA');
$agent = $this->createMockedRequestUserAgent($request);
$agent->fetchResponse(
new SimpleUrl('http://this.com/this/path/page.html'),
new SimpleGetEncoding());
$this->assertEqual($agent->getCookieValue("this.com", "this/path/", "a"), "AAAA");
}
function testIgnoringNewCookieWhenCookiesDisabled() {
$request = $this->createCookieSite('Set-cookie: a=AAAA');
$agent = $this->createMockedRequestUserAgent($request);
$agent->ignoreCookies();
$agent->fetchResponse(
new SimpleUrl('http://this.com/this/path/page.html'),
new SimpleGetEncoding());
$this->assertIdentical($agent->getCookieValue("this.com", "this/path/", "a"), false);
}
function testOverwriteCookieThatAlreadyExists() {
$request = $this->createCookieSite('Set-cookie: a=AAAA');
$agent = $this->createMockedRequestUserAgent($request);
$agent->setCookie('a', 'A');
$agent->fetchResponse(
new SimpleUrl('http://this.com/this/path/page.html'),
new SimpleGetEncoding());
$this->assertEqual($agent->getCookieValue("this.com", "this/path/", "a"), "AAAA");
}
function testClearCookieBySettingExpiry() {
$request = $this->createCookieSite('Set-cookie: a=b');
$agent = $this->createMockedRequestUserAgent($request);
$agent->setCookie("a", "A", "this/path/", "Wed, 25-Dec-02 04:24:21 GMT");
$agent->fetchResponse(
new SimpleUrl('http://this.com/this/path/page.html'),
new SimpleGetEncoding());
$this->assertIdentical(
$agent->getCookieValue("this.com", "this/path/", "a"),
"b");
$agent->restart("Wed, 25-Dec-02 04:24:20 GMT");
$this->assertIdentical(
$agent->getCookieValue("this.com", "this/path/", "a"),
false);
}
function testAgeingAndClearing() {
$request = $this->createCookieSite('Set-cookie: a=A; expires=Wed, 25-Dec-02 04:24:21 GMT; path=/this/path');
$agent = $this->createMockedRequestUserAgent($request);
$agent->fetchResponse(
new SimpleUrl('http://this.com/this/path/page.html'),
new SimpleGetEncoding());
$agent->restart("Wed, 25-Dec-02 04:24:20 GMT");
$this->assertIdentical(
$agent->getCookieValue("this.com", "this/path/", "a"),
"A");
$agent->ageCookies(2);
$agent->restart("Wed, 25-Dec-02 04:24:20 GMT");
$this->assertIdentical(
$agent->getCookieValue("this.com", "this/path/", "a"),
false);
}
function testReadingIncomingAndSettingNewCookies() {
$request = $this->createCookieSite('Set-cookie: a=AAA');
$agent = $this->createMockedRequestUserAgent($request);
$this->assertNull($agent->getBaseCookieValue("a", false));
$agent->fetchResponse(
new SimpleUrl('http://this.com/this/path/page.html'),
new SimpleGetEncoding());
$agent->setCookie("b", "BBB", "this.com", "this/path/");
$this->assertEqual(
$agent->getBaseCookieValue("a", new SimpleUrl('http://this.com/this/path/page.html')),
"AAA");
$this->assertEqual(
$agent->getBaseCookieValue("b", new SimpleUrl('http://this.com/this/path/page.html')),
"BBB");
}
}
class TestOfHttpRedirects extends UnitTestCase {
function createRedirect($content, $redirect) {
$headers = new MockSimpleHttpHeaders();
$headers->setReturnValue('isRedirect', (boolean)$redirect);
$headers->setReturnValue('getLocation', $redirect);
$response = new MockSimpleHttpResponse();
$response->setReturnValue('getContent', $content);
$response->setReturnReference('getHeaders', $headers);
$request = new MockSimpleHttpRequest();
$request->setReturnReference('fetch', $response);
return $request;
}
function testDisabledRedirects() {
$agent = new MockRequestUserAgent();
$agent->returns(
'createHttpRequest',
$this->createRedirect('stuff', 'there.html'));
$agent->expectOnce('createHttpRequest');
$agent->__construct();
$agent->setMaximumRedirects(0);
$response = $agent->fetchResponse(new SimpleUrl('here.html'), new SimpleGetEncoding());
$this->assertEqual($response->getContent(), 'stuff');
}
function testSingleRedirect() {
$agent = new MockRequestUserAgent();
$agent->returnsAt(
0,
'createHttpRequest',
$this->createRedirect('first', 'two.html'));
$agent->returnsAt(
1,
'createHttpRequest',
$this->createRedirect('second', 'three.html'));
$agent->expectCallCount('createHttpRequest', 2);
$agent->__construct();
$agent->setMaximumRedirects(1);
$response = $agent->fetchResponse(new SimpleUrl('one.html'), new SimpleGetEncoding());
$this->assertEqual($response->getContent(), 'second');
}
function testDoubleRedirect() {
$agent = new MockRequestUserAgent();
$agent->returnsAt(
0,
'createHttpRequest',
$this->createRedirect('first', 'two.html'));
$agent->returnsAt(
1,
'createHttpRequest',
$this->createRedirect('second', 'three.html'));
$agent->returnsAt(
2,
'createHttpRequest',
$this->createRedirect('third', 'four.html'));
$agent->expectCallCount('createHttpRequest', 3);
$agent->__construct();
$agent->setMaximumRedirects(2);
$response = $agent->fetchResponse(new SimpleUrl('one.html'), new SimpleGetEncoding());
$this->assertEqual($response->getContent(), 'third');
}
function testSuccessAfterRedirect() {
$agent = new MockRequestUserAgent();
$agent->returnsAt(
0,
'createHttpRequest',
$this->createRedirect('first', 'two.html'));
$agent->returnsAt(
1,
'createHttpRequest',
$this->createRedirect('second', false));
$agent->returnsAt(
2,
'createHttpRequest',
$this->createRedirect('third', 'four.html'));
$agent->expectCallCount('createHttpRequest', 2);
$agent->__construct();
$agent->setMaximumRedirects(2);
$response = $agent->fetchResponse(new SimpleUrl('one.html'), new SimpleGetEncoding());
$this->assertEqual($response->getContent(), 'second');
}
function testRedirectChangesPostToGet() {
$agent = new MockRequestUserAgent();
$agent->returnsAt(
0,
'createHttpRequest',
$this->createRedirect('first', 'two.html'));
$agent->expectAt(0, 'createHttpRequest', array('*', new IsAExpectation('SimplePostEncoding')));
$agent->returnsAt(
1,
'createHttpRequest',
$this->createRedirect('second', 'three.html'));
$agent->expectAt(1, 'createHttpRequest', array('*', new IsAExpectation('SimpleGetEncoding')));
$agent->expectCallCount('createHttpRequest', 2);
$agent->__construct();
$agent->setMaximumRedirects(1);
$response = $agent->fetchResponse(new SimpleUrl('one.html'), new SimplePostEncoding());
}
}
class TestOfBadHosts extends UnitTestCase {
private function createSimulatedBadHost() {
$response = new MockSimpleHttpResponse();
$response->setReturnValue('isError', true);
$response->setReturnValue('getError', 'Bad socket');
$response->setReturnValue('getContent', false);
$request = new MockSimpleHttpRequest();
$request->setReturnReference('fetch', $response);
return $request;
}
function testUntestedHost() {
$request = $this->createSimulatedBadHost();
$agent = new MockRequestUserAgent();
$agent->setReturnReference('createHttpRequest', $request);
$agent->__construct();
$response = $agent->fetchResponse(
new SimpleUrl('http://this.host/this/path/page.html'),
new SimpleGetEncoding());
$this->assertTrue($response->isError());
}
}
class TestOfAuthorisation extends UnitTestCase {
function testAuthenticateHeaderAdded() {
$response = new MockSimpleHttpResponse();
$response->setReturnReference('getHeaders', new MockSimpleHttpHeaders());
$request = new MockSimpleHttpRequest();
$request->returns('fetch', $response);
$request->expectOnce(
'addHeaderLine',
array('Authorization: Basic ' . base64_encode('test:secret')));
$agent = new MockRequestUserAgent();
$agent->returns('createHttpRequest', $request);
$agent->__construct();
$response = $agent->fetchResponse(
new SimpleUrl('http://test:secret@this.host'),
new SimpleGetEncoding());
}
}
?> | 10npsite | trunk/simpletest/test/user_agent_test.php | PHP | asf20 | 14,156 |
<?php
// $Id: http_test.php 1964 2009-10-13 15:27:31Z maetl_ $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../encoding.php');
require_once(dirname(__FILE__) . '/../http.php');
require_once(dirname(__FILE__) . '/../socket.php');
require_once(dirname(__FILE__) . '/../cookies.php');
Mock::generate('SimpleSocket');
Mock::generate('SimpleCookieJar');
Mock::generate('SimpleRoute');
Mock::generatePartial(
'SimpleRoute',
'PartialSimpleRoute',
array('createSocket'));
Mock::generatePartial(
'SimpleProxyRoute',
'PartialSimpleProxyRoute',
array('createSocket'));
class TestOfDirectRoute extends UnitTestCase {
function testDefaultGetRequest() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("GET /here.html HTTP/1.0\r\n"));
$socket->expectAt(1, 'write', array("Host: a.valid.host\r\n"));
$socket->expectAt(2, 'write', array("Connection: close\r\n"));
$socket->expectCallCount('write', 3);
$route = new PartialSimpleRoute();
$route->setReturnReference('createSocket', $socket);
$route->__construct(new SimpleUrl('http://a.valid.host/here.html'));
$this->assertSame($route->createConnection('GET', 15), $socket);
}
function testDefaultPostRequest() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("POST /here.html HTTP/1.0\r\n"));
$socket->expectAt(1, 'write', array("Host: a.valid.host\r\n"));
$socket->expectAt(2, 'write', array("Connection: close\r\n"));
$socket->expectCallCount('write', 3);
$route = new PartialSimpleRoute();
$route->setReturnReference('createSocket', $socket);
$route->__construct(new SimpleUrl('http://a.valid.host/here.html'));
$route->createConnection('POST', 15);
}
function testDefaultDeleteRequest() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("DELETE /here.html HTTP/1.0\r\n"));
$socket->expectAt(1, 'write', array("Host: a.valid.host\r\n"));
$socket->expectAt(2, 'write', array("Connection: close\r\n"));
$socket->expectCallCount('write', 3);
$route = new PartialSimpleRoute();
$route->setReturnReference('createSocket', $socket);
$route->__construct(new SimpleUrl('http://a.valid.host/here.html'));
$this->assertSame($route->createConnection('DELETE', 15), $socket);
}
function testDefaultHeadRequest() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("HEAD /here.html HTTP/1.0\r\n"));
$socket->expectAt(1, 'write', array("Host: a.valid.host\r\n"));
$socket->expectAt(2, 'write', array("Connection: close\r\n"));
$socket->expectCallCount('write', 3);
$route = new PartialSimpleRoute();
$route->setReturnReference('createSocket', $socket);
$route->__construct(new SimpleUrl('http://a.valid.host/here.html'));
$this->assertSame($route->createConnection('HEAD', 15), $socket);
}
function testGetWithPort() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("GET /here.html HTTP/1.0\r\n"));
$socket->expectAt(1, 'write', array("Host: a.valid.host:81\r\n"));
$socket->expectAt(2, 'write', array("Connection: close\r\n"));
$socket->expectCallCount('write', 3);
$route = new PartialSimpleRoute();
$route->setReturnReference('createSocket', $socket);
$route->__construct(new SimpleUrl('http://a.valid.host:81/here.html'));
$route->createConnection('GET', 15);
}
function testGetWithParameters() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("GET /here.html?a=1&b=2 HTTP/1.0\r\n"));
$socket->expectAt(1, 'write', array("Host: a.valid.host\r\n"));
$socket->expectAt(2, 'write', array("Connection: close\r\n"));
$socket->expectCallCount('write', 3);
$route = new PartialSimpleRoute();
$route->setReturnReference('createSocket', $socket);
$route->__construct(new SimpleUrl('http://a.valid.host/here.html?a=1&b=2'));
$route->createConnection('GET', 15);
}
}
class TestOfProxyRoute extends UnitTestCase {
function testDefaultGet() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("GET http://a.valid.host/here.html HTTP/1.0\r\n"));
$socket->expectAt(1, 'write', array("Host: my-proxy:8080\r\n"));
$socket->expectAt(2, 'write', array("Connection: close\r\n"));
$socket->expectCallCount('write', 3);
$route = new PartialSimpleProxyRoute();
$route->setReturnReference('createSocket', $socket);
$route->__construct(
new SimpleUrl('http://a.valid.host/here.html'),
new SimpleUrl('http://my-proxy'));
$route->createConnection('GET', 15);
}
function testDefaultPost() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("POST http://a.valid.host/here.html HTTP/1.0\r\n"));
$socket->expectAt(1, 'write', array("Host: my-proxy:8080\r\n"));
$socket->expectAt(2, 'write', array("Connection: close\r\n"));
$socket->expectCallCount('write', 3);
$route = new PartialSimpleProxyRoute();
$route->setReturnReference('createSocket', $socket);
$route->__construct(
new SimpleUrl('http://a.valid.host/here.html'),
new SimpleUrl('http://my-proxy'));
$route->createConnection('POST', 15);
}
function testGetWithPort() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("GET http://a.valid.host:81/here.html HTTP/1.0\r\n"));
$socket->expectAt(1, 'write', array("Host: my-proxy:8081\r\n"));
$socket->expectAt(2, 'write', array("Connection: close\r\n"));
$socket->expectCallCount('write', 3);
$route = new PartialSimpleProxyRoute();
$route->setReturnReference('createSocket', $socket);
$route->__construct(
new SimpleUrl('http://a.valid.host:81/here.html'),
new SimpleUrl('http://my-proxy:8081'));
$route->createConnection('GET', 15);
}
function testGetWithParameters() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("GET http://a.valid.host/here.html?a=1&b=2 HTTP/1.0\r\n"));
$socket->expectAt(1, 'write', array("Host: my-proxy:8080\r\n"));
$socket->expectAt(2, 'write', array("Connection: close\r\n"));
$socket->expectCallCount('write', 3);
$route = new PartialSimpleProxyRoute();
$route->setReturnReference('createSocket', $socket);
$route->__construct(
new SimpleUrl('http://a.valid.host/here.html?a=1&b=2'),
new SimpleUrl('http://my-proxy'));
$route->createConnection('GET', 15);
}
function testGetWithAuthentication() {
$encoded = base64_encode('Me:Secret');
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("GET http://a.valid.host/here.html HTTP/1.0\r\n"));
$socket->expectAt(1, 'write', array("Host: my-proxy:8080\r\n"));
$socket->expectAt(2, 'write', array("Proxy-Authorization: Basic $encoded\r\n"));
$socket->expectAt(3, 'write', array("Connection: close\r\n"));
$socket->expectCallCount('write', 4);
$route = new PartialSimpleProxyRoute();
$route->setReturnReference('createSocket', $socket);
$route->__construct(
new SimpleUrl('http://a.valid.host/here.html'),
new SimpleUrl('http://my-proxy'),
'Me',
'Secret');
$route->createConnection('GET', 15);
}
}
class TestOfHttpRequest extends UnitTestCase {
function testReadingBadConnection() {
$socket = new MockSimpleSocket();
$route = new MockSimpleRoute();
$route->setReturnReference('createConnection', $socket);
$request = new SimpleHttpRequest($route, new SimpleGetEncoding());
$reponse = $request->fetch(15);
$this->assertTrue($reponse->isError());
}
function testReadingGoodConnection() {
$socket = new MockSimpleSocket();
$socket->expectOnce('write', array("\r\n"));
$route = new MockSimpleRoute();
$route->setReturnReference('createConnection', $socket);
$route->expect('createConnection', array('GET', 15));
$request = new SimpleHttpRequest($route, new SimpleGetEncoding());
$this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
}
function testWritingAdditionalHeaders() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("My: stuff\r\n"));
$socket->expectAt(1, 'write', array("\r\n"));
$socket->expectCallCount('write', 2);
$route = new MockSimpleRoute();
$route->setReturnReference('createConnection', $socket);
$request = new SimpleHttpRequest($route, new SimpleGetEncoding());
$request->addHeaderLine('My: stuff');
$request->fetch(15);
}
function testCookieWriting() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("Cookie: a=A\r\n"));
$socket->expectAt(1, 'write', array("\r\n"));
$socket->expectCallCount('write', 2);
$route = new MockSimpleRoute();
$route->setReturnReference('createConnection', $socket);
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'A');
$request = new SimpleHttpRequest($route, new SimpleGetEncoding());
$request->readCookiesFromJar($jar, new SimpleUrl('/'));
$this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
}
function testMultipleCookieWriting() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("Cookie: a=A;b=B\r\n"));
$route = new MockSimpleRoute();
$route->setReturnReference('createConnection', $socket);
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'A');
$jar->setCookie('b', 'B');
$request = new SimpleHttpRequest($route, new SimpleGetEncoding());
$request->readCookiesFromJar($jar, new SimpleUrl('/'));
$request->fetch(15);
}
function testReadingDeleteConnection() {
$socket = new MockSimpleSocket();
$route = new MockSimpleRoute();
$route->setReturnReference('createConnection', $socket);
$route->expect('createConnection', array('DELETE', 15));
$request = new SimpleHttpRequest($route, new SimpleDeleteEncoding());
$this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
}
}
class TestOfHttpPostRequest extends UnitTestCase {
function testReadingBadConnectionCausesErrorBecauseOfDeadSocket() {
$socket = new MockSimpleSocket();
$route = new MockSimpleRoute();
$route->setReturnReference('createConnection', $socket);
$request = new SimpleHttpRequest($route, new SimplePostEncoding());
$reponse = $request->fetch(15);
$this->assertTrue($reponse->isError());
}
function testReadingGoodConnection() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("Content-Length: 0\r\n"));
$socket->expectAt(1, 'write', array("Content-Type: application/x-www-form-urlencoded\r\n"));
$socket->expectAt(2, 'write', array("\r\n"));
$socket->expectAt(3, 'write', array(""));
$route = new MockSimpleRoute();
$route->setReturnReference('createConnection', $socket);
$route->expect('createConnection', array('POST', 15));
$request = new SimpleHttpRequest($route, new SimplePostEncoding());
$this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
}
function testContentHeadersCalculatedWithUrlEncodedParams() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("Content-Length: 3\r\n"));
$socket->expectAt(1, 'write', array("Content-Type: application/x-www-form-urlencoded\r\n"));
$socket->expectAt(2, 'write', array("\r\n"));
$socket->expectAt(3, 'write', array("a=A"));
$route = new MockSimpleRoute();
$route->setReturnReference('createConnection', $socket);
$route->expect('createConnection', array('POST', 15));
$request = new SimpleHttpRequest(
$route,
new SimplePostEncoding(array('a' => 'A')));
$this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
}
function testContentHeadersCalculatedWithRawEntityBody() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("Content-Length: 8\r\n"));
$socket->expectAt(1, 'write', array("Content-Type: text/plain\r\n"));
$socket->expectAt(2, 'write', array("\r\n"));
$socket->expectAt(3, 'write', array("raw body"));
$route = new MockSimpleRoute();
$route->setReturnReference('createConnection', $socket);
$route->expect('createConnection', array('POST', 15));
$request = new SimpleHttpRequest(
$route,
new SimplePostEncoding('raw body'));
$this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
}
function testContentHeadersCalculatedWithXmlEntityBody() {
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("Content-Length: 27\r\n"));
$socket->expectAt(1, 'write', array("Content-Type: text/xml\r\n"));
$socket->expectAt(2, 'write', array("\r\n"));
$socket->expectAt(3, 'write', array("<a><b>one</b><c>two</c></a>"));
$route = new MockSimpleRoute();
$route->setReturnReference('createConnection', $socket);
$route->expect('createConnection', array('POST', 15));
$request = new SimpleHttpRequest(
$route,
new SimplePostEncoding('<a><b>one</b><c>two</c></a>', 'text/xml'));
$this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
}
}
class TestOfHttpHeaders extends UnitTestCase {
function testParseBasicHeaders() {
$headers = new SimpleHttpHeaders(
"HTTP/1.1 200 OK\r\n" .
"Date: Mon, 18 Nov 2002 15:50:29 GMT\r\n" .
"Content-Type: text/plain\r\n" .
"Server: Apache/1.3.24 (Win32) PHP/4.2.3\r\n" .
"Connection: close");
$this->assertIdentical($headers->getHttpVersion(), "1.1");
$this->assertIdentical($headers->getResponseCode(), 200);
$this->assertEqual($headers->getMimeType(), "text/plain");
}
function testNonStandardResponseHeader() {
$headers = new SimpleHttpHeaders(
"HTTP/1.1 302 (HTTP-Version SP Status-Code CRLF)\r\n" .
"Connection: close");
$this->assertIdentical($headers->getResponseCode(), 302);
}
function testCanParseMultipleCookies() {
$jar = new MockSimpleCookieJar();
$jar->expectAt(0, 'setCookie', array('a', 'aaa', 'host', '/here/', 'Wed, 25 Dec 2002 04:24:20 GMT'));
$jar->expectAt(1, 'setCookie', array('b', 'bbb', 'host', '/', false));
$headers = new SimpleHttpHeaders(
"HTTP/1.1 200 OK\r\n" .
"Date: Mon, 18 Nov 2002 15:50:29 GMT\r\n" .
"Content-Type: text/plain\r\n" .
"Server: Apache/1.3.24 (Win32) PHP/4.2.3\r\n" .
"Set-Cookie: a=aaa; expires=Wed, 25-Dec-02 04:24:20 GMT; path=/here/\r\n" .
"Set-Cookie: b=bbb\r\n" .
"Connection: close");
$headers->writeCookiesToJar($jar, new SimpleUrl('http://host'));
}
function testCanRecogniseRedirect() {
$headers = new SimpleHttpHeaders("HTTP/1.1 301 OK\r\n" .
"Content-Type: text/plain\r\n" .
"Content-Length: 0\r\n" .
"Location: http://www.somewhere-else.com/\r\n" .
"Connection: close");
$this->assertIdentical($headers->getResponseCode(), 301);
$this->assertEqual($headers->getLocation(), "http://www.somewhere-else.com/");
$this->assertTrue($headers->isRedirect());
}
function testCanParseChallenge() {
$headers = new SimpleHttpHeaders("HTTP/1.1 401 Authorization required\r\n" .
"Content-Type: text/plain\r\n" .
"Connection: close\r\n" .
"WWW-Authenticate: Basic realm=\"Somewhere\"");
$this->assertEqual($headers->getAuthentication(), 'Basic');
$this->assertEqual($headers->getRealm(), 'Somewhere');
$this->assertTrue($headers->isChallenge());
}
}
class TestOfHttpResponse extends UnitTestCase {
function testBadRequest() {
$socket = new MockSimpleSocket();
$socket->setReturnValue('getSent', '');
$response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding());
$this->assertTrue($response->isError());
$this->assertPattern('/Nothing fetched/', $response->getError());
$this->assertIdentical($response->getContent(), false);
$this->assertIdentical($response->getSent(), '');
}
function testBadSocketDuringResponse() {
$socket = new MockSimpleSocket();
$socket->setReturnValueAt(0, "read", "HTTP/1.1 200 OK\r\n");
$socket->setReturnValueAt(1, "read", "Date: Mon, 18 Nov 2002 15:50:29 GMT\r\n");
$socket->setReturnValue("read", "");
$socket->setReturnValue('getSent', 'HTTP/1.1 ...');
$response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding());
$this->assertTrue($response->isError());
$this->assertEqual($response->getContent(), '');
$this->assertEqual($response->getSent(), 'HTTP/1.1 ...');
}
function testIncompleteHeader() {
$socket = new MockSimpleSocket();
$socket->setReturnValueAt(0, "read", "HTTP/1.1 200 OK\r\n");
$socket->setReturnValueAt(1, "read", "Date: Mon, 18 Nov 2002 15:50:29 GMT\r\n");
$socket->setReturnValueAt(2, "read", "Content-Type: text/plain\r\n");
$socket->setReturnValue("read", "");
$response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding());
$this->assertTrue($response->isError());
$this->assertEqual($response->getContent(), "");
}
function testParseOfResponseHeadersWhenChunked() {
$socket = new MockSimpleSocket();
$socket->setReturnValueAt(0, "read", "HTTP/1.1 200 OK\r\nDate: Mon, 18 Nov 2002 15:50:29 GMT\r\n");
$socket->setReturnValueAt(1, "read", "Content-Type: text/plain\r\n");
$socket->setReturnValueAt(2, "read", "Server: Apache/1.3.24 (Win32) PHP/4.2.3\r\nConne");
$socket->setReturnValueAt(3, "read", "ction: close\r\n\r\nthis is a test file\n");
$socket->setReturnValueAt(4, "read", "with two lines in it\n");
$socket->setReturnValue("read", "");
$response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding());
$this->assertFalse($response->isError());
$this->assertEqual(
$response->getContent(),
"this is a test file\nwith two lines in it\n");
$headers = $response->getHeaders();
$this->assertIdentical($headers->getHttpVersion(), "1.1");
$this->assertIdentical($headers->getResponseCode(), 200);
$this->assertEqual($headers->getMimeType(), "text/plain");
$this->assertFalse($headers->isRedirect());
$this->assertFalse($headers->getLocation());
}
function testRedirect() {
$socket = new MockSimpleSocket();
$socket->setReturnValueAt(0, "read", "HTTP/1.1 301 OK\r\n");
$socket->setReturnValueAt(1, "read", "Content-Type: text/plain\r\n");
$socket->setReturnValueAt(2, "read", "Location: http://www.somewhere-else.com/\r\n");
$socket->setReturnValueAt(3, "read", "Connection: close\r\n");
$socket->setReturnValueAt(4, "read", "\r\n");
$socket->setReturnValue("read", "");
$response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding());
$headers = $response->getHeaders();
$this->assertTrue($headers->isRedirect());
$this->assertEqual($headers->getLocation(), "http://www.somewhere-else.com/");
}
function testRedirectWithPort() {
$socket = new MockSimpleSocket();
$socket->setReturnValueAt(0, "read", "HTTP/1.1 301 OK\r\n");
$socket->setReturnValueAt(1, "read", "Content-Type: text/plain\r\n");
$socket->setReturnValueAt(2, "read", "Location: http://www.somewhere-else.com:80/\r\n");
$socket->setReturnValueAt(3, "read", "Connection: close\r\n");
$socket->setReturnValueAt(4, "read", "\r\n");
$socket->setReturnValue("read", "");
$response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding());
$headers = $response->getHeaders();
$this->assertTrue($headers->isRedirect());
$this->assertEqual($headers->getLocation(), "http://www.somewhere-else.com:80/");
}
}
?> | 10npsite | trunk/simpletest/test/http_test.php | PHP | asf20 | 19,329 |
<?php
require_once(dirname(__FILE__) . '/../autorun.php');
class BadTestCases extends TestSuite {
function BadTestCases() {
$this->TestSuite('Two bad test cases');
$this->addFile(dirname(__FILE__) . '/support/empty_test_file.php');
}
}
?> | 10npsite | trunk/simpletest/test/bad_test_suite.php | PHP | asf20 | 263 |
<?php
// $Id: cookies_test.php 1506 2007-05-07 00:58:03Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../arguments.php');
class TestOfCommandLineArgumentParsing extends UnitTestCase {
function testArgumentListWithJustProgramNameGivesFalseToEveryName() {
$arguments = new SimpleArguments(array('me'));
$this->assertIdentical($arguments->a, false);
$this->assertIdentical($arguments->all(), array());
}
function testSingleArgumentNameRecordedAsTrue() {
$arguments = new SimpleArguments(array('me', '-a'));
$this->assertIdentical($arguments->a, true);
}
function testSingleArgumentCanBeGivenAValue() {
$arguments = new SimpleArguments(array('me', '-a=AAA'));
$this->assertIdentical($arguments->a, 'AAA');
}
function testSingleArgumentCanBeGivenSpaceSeparatedValue() {
$arguments = new SimpleArguments(array('me', '-a', 'AAA'));
$this->assertIdentical($arguments->a, 'AAA');
}
function testWillBuildArrayFromRepeatedValue() {
$arguments = new SimpleArguments(array('me', '-a', 'A', '-a', 'AA'));
$this->assertIdentical($arguments->a, array('A', 'AA'));
}
function testWillBuildArrayFromMultiplyRepeatedValues() {
$arguments = new SimpleArguments(array('me', '-a', 'A', '-a', 'AA', '-a', 'AAA'));
$this->assertIdentical($arguments->a, array('A', 'AA', 'AAA'));
}
function testCanParseLongFormArguments() {
$arguments = new SimpleArguments(array('me', '--aa=AA', '--bb', 'BB'));
$this->assertIdentical($arguments->aa, 'AA');
$this->assertIdentical($arguments->bb, 'BB');
}
function testGetsFullSetOfResultsAsHash() {
$arguments = new SimpleArguments(array('me', '-a', '-b=1', '-b', '2', '--aa=AA', '--bb', 'BB', '-c'));
$this->assertEqual($arguments->all(),
array('a' => true, 'b' => array('1', '2'), 'aa' => 'AA', 'bb' => 'BB', 'c' => true));
}
}
class TestOfHelpOutput extends UnitTestCase {
function testDisplaysGeneralHelpBanner() {
$help = new SimpleHelp('Cool program');
$this->assertEqual($help->render(), "Cool program\n");
}
function testDisplaysOnlySingleLineEndings() {
$help = new SimpleHelp("Cool program\n");
$this->assertEqual($help->render(), "Cool program\n");
}
function testDisplaysHelpOnShortFlag() {
$help = new SimpleHelp('Cool program');
$help->explainFlag('a', 'Enables A');
$this->assertEqual($help->render(), "Cool program\n-a Enables A\n");
}
function testHasAtleastFourSpacesAfterLongestFlag() {
$help = new SimpleHelp('Cool program');
$help->explainFlag('a', 'Enables A');
$help->explainFlag('long', 'Enables Long');
$this->assertEqual($help->render(),
"Cool program\n-a Enables A\n--long Enables Long\n");
}
function testCanDisplaysMultipleFlagsForEachOption() {
$help = new SimpleHelp('Cool program');
$help->explainFlag(array('a', 'aa'), 'Enables A');
$this->assertEqual($help->render(), "Cool program\n-a Enables A\n --aa\n");
}
}
?> | 10npsite | trunk/simpletest/test/arguments_test.php | PHP | asf20 | 3,305 |
<?php
// $Id: authentication_test.php 1748 2008-04-14 01:50:41Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../authentication.php');
require_once(dirname(__FILE__) . '/../http.php');
Mock::generate('SimpleHttpRequest');
class TestOfRealm extends UnitTestCase {
function testWithinSameUrl() {
$realm = new SimpleRealm(
'Basic',
new SimpleUrl('http://www.here.com/path/hello.html'));
$this->assertTrue($realm->isWithin(
new SimpleUrl('http://www.here.com/path/hello.html')));
}
function testInsideWithLongerUrl() {
$realm = new SimpleRealm(
'Basic',
new SimpleUrl('http://www.here.com/path/'));
$this->assertTrue($realm->isWithin(
new SimpleUrl('http://www.here.com/path/hello.html')));
}
function testBelowRootIsOutside() {
$realm = new SimpleRealm(
'Basic',
new SimpleUrl('http://www.here.com/path/'));
$this->assertTrue($realm->isWithin(
new SimpleUrl('http://www.here.com/path/more/hello.html')));
}
function testOldNetscapeDefinitionIsOutside() {
$realm = new SimpleRealm(
'Basic',
new SimpleUrl('http://www.here.com/path/'));
$this->assertFalse($realm->isWithin(
new SimpleUrl('http://www.here.com/pathmore/hello.html')));
}
function testInsideWithMissingTrailingSlash() {
$realm = new SimpleRealm(
'Basic',
new SimpleUrl('http://www.here.com/path/'));
$this->assertTrue($realm->isWithin(
new SimpleUrl('http://www.here.com/path')));
}
function testDifferentPageNameStillInside() {
$realm = new SimpleRealm(
'Basic',
new SimpleUrl('http://www.here.com/path/hello.html'));
$this->assertTrue($realm->isWithin(
new SimpleUrl('http://www.here.com/path/goodbye.html')));
}
function testNewUrlInSameDirectoryDoesNotChangeRealm() {
$realm = new SimpleRealm(
'Basic',
new SimpleUrl('http://www.here.com/path/hello.html'));
$realm->stretch(new SimpleUrl('http://www.here.com/path/goodbye.html'));
$this->assertTrue($realm->isWithin(
new SimpleUrl('http://www.here.com/path/index.html')));
$this->assertFalse($realm->isWithin(
new SimpleUrl('http://www.here.com/index.html')));
}
function testNewUrlMakesRealmTheCommonPath() {
$realm = new SimpleRealm(
'Basic',
new SimpleUrl('http://www.here.com/path/here/hello.html'));
$realm->stretch(new SimpleUrl('http://www.here.com/path/there/goodbye.html'));
$this->assertTrue($realm->isWithin(
new SimpleUrl('http://www.here.com/path/here/index.html')));
$this->assertTrue($realm->isWithin(
new SimpleUrl('http://www.here.com/path/there/index.html')));
$this->assertTrue($realm->isWithin(
new SimpleUrl('http://www.here.com/path/index.html')));
$this->assertFalse($realm->isWithin(
new SimpleUrl('http://www.here.com/index.html')));
$this->assertFalse($realm->isWithin(
new SimpleUrl('http://www.here.com/paths/index.html')));
$this->assertFalse($realm->isWithin(
new SimpleUrl('http://www.here.com/pathindex.html')));
}
}
class TestOfAuthenticator extends UnitTestCase {
function testNoRealms() {
$request = new MockSimpleHttpRequest();
$request->expectNever('addHeaderLine');
$authenticator = new SimpleAuthenticator();
$authenticator->addHeaders($request, new SimpleUrl('http://here.com/'));
}
function &createSingleRealm() {
$authenticator = new SimpleAuthenticator();
$authenticator->addRealm(
new SimpleUrl('http://www.here.com/path/hello.html'),
'Basic',
'Sanctuary');
$authenticator->setIdentityForRealm('www.here.com', 'Sanctuary', 'test', 'secret');
return $authenticator;
}
function testOutsideRealm() {
$request = new MockSimpleHttpRequest();
$request->expectNever('addHeaderLine');
$authenticator = &$this->createSingleRealm();
$authenticator->addHeaders(
$request,
new SimpleUrl('http://www.here.com/hello.html'));
}
function testWithinRealm() {
$request = new MockSimpleHttpRequest();
$request->expectOnce('addHeaderLine');
$authenticator = &$this->createSingleRealm();
$authenticator->addHeaders(
$request,
new SimpleUrl('http://www.here.com/path/more/hello.html'));
}
function testRestartingClearsRealm() {
$request = new MockSimpleHttpRequest();
$request->expectNever('addHeaderLine');
$authenticator = &$this->createSingleRealm();
$authenticator->restartSession();
$authenticator->addHeaders(
$request,
new SimpleUrl('http://www.here.com/hello.html'));
}
function testDifferentHostIsOutsideRealm() {
$request = new MockSimpleHttpRequest();
$request->expectNever('addHeaderLine');
$authenticator = &$this->createSingleRealm();
$authenticator->addHeaders(
$request,
new SimpleUrl('http://here.com/path/hello.html'));
}
}
?> | 10npsite | trunk/simpletest/test/authentication_test.php | PHP | asf20 | 5,665 |
<?php
// $Id: xml_test.php 1787 2008-04-26 20:35:39Z pp11 $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../xml.php');
Mock::generate('SimpleScorer');
if (! function_exists('xml_parser_create')) {
SimpleTest::ignore('TestOfXmlStructureParsing');
SimpleTest::ignore('TestOfXmlResultsParsing');
}
class TestOfNestingTags extends UnitTestCase {
function testGroupSize() {
$nesting = new NestingGroupTag(array('SIZE' => 2));
$this->assertEqual($nesting->getSize(), 2);
}
}
class TestOfXmlStructureParsing extends UnitTestCase {
function testValidXml() {
$listener = new MockSimpleScorer();
$listener->expectNever('paintGroupStart');
$listener->expectNever('paintGroupEnd');
$listener->expectNever('paintCaseStart');
$listener->expectNever('paintCaseEnd');
$parser = new SimpleTestXmlParser($listener);
$this->assertTrue($parser->parse("<?xml version=\"1.0\"?>\n"));
$this->assertTrue($parser->parse("<run>\n"));
$this->assertTrue($parser->parse("</run>\n"));
}
function testEmptyGroup() {
$listener = new MockSimpleScorer();
$listener->expectOnce('paintGroupStart', array('a_group', 7));
$listener->expectOnce('paintGroupEnd', array('a_group'));
$parser = new SimpleTestXmlParser($listener);
$parser->parse("<?xml version=\"1.0\"?>\n");
$parser->parse("<run>\n");
$this->assertTrue($parser->parse("<group size=\"7\">\n"));
$this->assertTrue($parser->parse("<name>a_group</name>\n"));
$this->assertTrue($parser->parse("</group>\n"));
$parser->parse("</run>\n");
}
function testEmptyCase() {
$listener = new MockSimpleScorer();
$listener->expectOnce('paintCaseStart', array('a_case'));
$listener->expectOnce('paintCaseEnd', array('a_case'));
$parser = new SimpleTestXmlParser($listener);
$parser->parse("<?xml version=\"1.0\"?>\n");
$parser->parse("<run>\n");
$this->assertTrue($parser->parse("<case>\n"));
$this->assertTrue($parser->parse("<name>a_case</name>\n"));
$this->assertTrue($parser->parse("</case>\n"));
$parser->parse("</run>\n");
}
function testEmptyMethod() {
$listener = new MockSimpleScorer();
$listener->expectOnce('paintCaseStart', array('a_case'));
$listener->expectOnce('paintCaseEnd', array('a_case'));
$listener->expectOnce('paintMethodStart', array('a_method'));
$listener->expectOnce('paintMethodEnd', array('a_method'));
$parser = new SimpleTestXmlParser($listener);
$parser->parse("<?xml version=\"1.0\"?>\n");
$parser->parse("<run>\n");
$parser->parse("<case>\n");
$parser->parse("<name>a_case</name>\n");
$this->assertTrue($parser->parse("<test>\n"));
$this->assertTrue($parser->parse("<name>a_method</name>\n"));
$this->assertTrue($parser->parse("</test>\n"));
$parser->parse("</case>\n");
$parser->parse("</run>\n");
}
function testNestedGroup() {
$listener = new MockSimpleScorer();
$listener->expectAt(0, 'paintGroupStart', array('a_group', 7));
$listener->expectAt(1, 'paintGroupStart', array('b_group', 3));
$listener->expectCallCount('paintGroupStart', 2);
$listener->expectAt(0, 'paintGroupEnd', array('b_group'));
$listener->expectAt(1, 'paintGroupEnd', array('a_group'));
$listener->expectCallCount('paintGroupEnd', 2);
$parser = new SimpleTestXmlParser($listener);
$parser->parse("<?xml version=\"1.0\"?>\n");
$parser->parse("<run>\n");
$this->assertTrue($parser->parse("<group size=\"7\">\n"));
$this->assertTrue($parser->parse("<name>a_group</name>\n"));
$this->assertTrue($parser->parse("<group size=\"3\">\n"));
$this->assertTrue($parser->parse("<name>b_group</name>\n"));
$this->assertTrue($parser->parse("</group>\n"));
$this->assertTrue($parser->parse("</group>\n"));
$parser->parse("</run>\n");
}
}
class AnyOldSignal {
public $stuff = true;
}
class TestOfXmlResultsParsing extends UnitTestCase {
function sendValidStart(&$parser) {
$parser->parse("<?xml version=\"1.0\"?>\n");
$parser->parse("<run>\n");
$parser->parse("<case>\n");
$parser->parse("<name>a_case</name>\n");
$parser->parse("<test>\n");
$parser->parse("<name>a_method</name>\n");
}
function sendValidEnd(&$parser) {
$parser->parse("</test>\n");
$parser->parse("</case>\n");
$parser->parse("</run>\n");
}
function testPass() {
$listener = new MockSimpleScorer();
$listener->expectOnce('paintPass', array('a_message'));
$parser = new SimpleTestXmlParser($listener);
$this->sendValidStart($parser);
$this->assertTrue($parser->parse("<pass>a_message</pass>\n"));
$this->sendValidEnd($parser);
}
function testFail() {
$listener = new MockSimpleScorer();
$listener->expectOnce('paintFail', array('a_message'));
$parser = new SimpleTestXmlParser($listener);
$this->sendValidStart($parser);
$this->assertTrue($parser->parse("<fail>a_message</fail>\n"));
$this->sendValidEnd($parser);
}
function testException() {
$listener = new MockSimpleScorer();
$listener->expectOnce('paintError', array('a_message'));
$parser = new SimpleTestXmlParser($listener);
$this->sendValidStart($parser);
$this->assertTrue($parser->parse("<exception>a_message</exception>\n"));
$this->sendValidEnd($parser);
}
function testSkip() {
$listener = new MockSimpleScorer();
$listener->expectOnce('paintSkip', array('a_message'));
$parser = new SimpleTestXmlParser($listener);
$this->sendValidStart($parser);
$this->assertTrue($parser->parse("<skip>a_message</skip>\n"));
$this->sendValidEnd($parser);
}
function testSignal() {
$signal = new AnyOldSignal();
$signal->stuff = "Hello";
$listener = new MockSimpleScorer();
$listener->expectOnce('paintSignal', array('a_signal', $signal));
$parser = new SimpleTestXmlParser($listener);
$this->sendValidStart($parser);
$this->assertTrue($parser->parse(
"<signal type=\"a_signal\"><![CDATA[" .
serialize($signal) . "]]></signal>\n"));
$this->sendValidEnd($parser);
}
function testMessage() {
$listener = new MockSimpleScorer();
$listener->expectOnce('paintMessage', array('a_message'));
$parser = new SimpleTestXmlParser($listener);
$this->sendValidStart($parser);
$this->assertTrue($parser->parse("<message>a_message</message>\n"));
$this->sendValidEnd($parser);
}
function testFormattedMessage() {
$listener = new MockSimpleScorer();
$listener->expectOnce('paintFormattedMessage', array("\na\tmessage\n"));
$parser = new SimpleTestXmlParser($listener);
$this->sendValidStart($parser);
$this->assertTrue($parser->parse("<formatted><![CDATA[\na\tmessage\n]]></formatted>\n"));
$this->sendValidEnd($parser);
}
}
?> | 10npsite | trunk/simpletest/test/xml_test.php | PHP | asf20 | 7,382 |
<?php
// $Id: shell_test.php 1748 2008-04-14 01:50:41Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../shell_tester.php');
class TestOfShell extends UnitTestCase {
function testEcho() {
$shell = new SimpleShell();
$this->assertIdentical($shell->execute('echo Hello'), 0);
$this->assertPattern('/Hello/', $shell->getOutput());
}
function testBadCommand() {
$shell = new SimpleShell();
$this->assertNotEqual($ret = $shell->execute('blurgh! 2>&1'), 0);
}
}
class TestOfShellTesterAndShell extends ShellTestCase {
function testEcho() {
$this->assertTrue($this->execute('echo Hello'));
$this->assertExitCode(0);
$this->assertoutput('Hello');
}
function testFileExistence() {
$this->assertFileExists(dirname(__FILE__) . '/all_tests.php');
$this->assertFileNotExists('wibble');
}
function testFilePatterns() {
$this->assertFilePattern('/all[_ ]tests/i', dirname(__FILE__) . '/all_tests.php');
$this->assertNoFilePattern('/sputnik/i', dirname(__FILE__) . '/all_tests.php');
}
}
?> | 10npsite | trunk/simpletest/test/shell_test.php | PHP | asf20 | 1,190 |
<?php
// $Id: compatibility_test.php 1748 2008-04-14 01:50:41Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../compatibility.php');
class ComparisonClass { }
class ComparisonSubclass extends ComparisonClass { }
interface ComparisonInterface { }
class ComparisonClassWithInterface implements ComparisonInterface { }
class TestOfCompatibility extends UnitTestCase {
function testIsA() {
$this->assertTrue(SimpleTestCompatibility::isA(
new ComparisonClass(),
'ComparisonClass'));
$this->assertFalse(SimpleTestCompatibility::isA(
new ComparisonClass(),
'ComparisonSubclass'));
$this->assertTrue(SimpleTestCompatibility::isA(
new ComparisonSubclass(),
'ComparisonClass'));
}
function testIdentityOfNumericStrings() {
$numericString1 = "123";
$numericString2 = "00123";
$this->assertNotIdentical($numericString1, $numericString2);
}
function testIdentityOfObjects() {
$object1 = new ComparisonClass();
$object2 = new ComparisonClass();
$this->assertIdentical($object1, $object2);
}
function testReferences () {
$thing = "Hello";
$thing_reference = &$thing;
$thing_copy = $thing;
$this->assertTrue(SimpleTestCompatibility::isReference(
$thing,
$thing));
$this->assertTrue(SimpleTestCompatibility::isReference(
$thing,
$thing_reference));
$this->assertFalse(SimpleTestCompatibility::isReference(
$thing,
$thing_copy));
}
function testObjectReferences () {
$object = new ComparisonClass();
$object_reference = $object;
$object_copy = new ComparisonClass();
$object_assignment = $object;
$this->assertTrue(SimpleTestCompatibility::isReference(
$object,
$object));
$this->assertTrue(SimpleTestCompatibility::isReference(
$object,
$object_reference));
$this->assertFalse(SimpleTestCompatibility::isReference(
$object,
$object_copy));
if (version_compare(phpversion(), '5', '>=')) {
$this->assertTrue(SimpleTestCompatibility::isReference(
$object,
$object_assignment));
} else {
$this->assertFalse(SimpleTestCompatibility::isReference(
$object,
$object_assignment));
}
}
function testInteraceComparison() {
$object = new ComparisonClassWithInterface();
$this->assertFalse(SimpleTestCompatibility::isA(
new ComparisonClass(),
'ComparisonInterface'));
$this->assertTrue(SimpleTestCompatibility::isA(
new ComparisonClassWithInterface(),
'ComparisonInterface'));
}
}
?> | 10npsite | trunk/simpletest/test/compatibility_test.php | PHP | asf20 | 3,067 |
<?php
// $Id: test.php 1500 2007-04-29 14:33:31Z pp11 $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../recorder.php');
class TestOfRecorder extends UnitTestCase {
function testContentOfRecorderWithOnePassAndOneFailure() {
$test = new TestSuite();
$test->addFile(dirname(__FILE__) . '/support/recorder_sample.php');
$recorder = new Recorder(new SimpleReporter());
$test->run($recorder);
$this->assertEqual(count($recorder->results), 2);
$this->assertIsA($recorder->results[0], 'SimpleResultOfPass');
$this->assertEqual('testTrueIsTrue', array_pop($recorder->results[0]->breadcrumb));
$this->assertPattern('/ at \[.*\Wrecorder_sample\.php line 7\]/', $recorder->results[0]->message);
$this->assertIsA($recorder->results[1], 'SimpleResultOfFail');
$this->assertEqual('testFalseIsTrue', array_pop($recorder->results[1]->breadcrumb));
$this->assertPattern("/Expected false, got \[Boolean: true\] at \[.*\Wrecorder_sample\.php line 11\]/",
$recorder->results[1]->message);
}
}
?> | 10npsite | trunk/simpletest/test/recorder_test.php | PHP | asf20 | 1,148 |
<?php
// $Id: dumper_test.php 1505 2007-04-30 23:39:59Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
class DumperDummy {
}
class TestOfTextFormatting extends UnitTestCase {
function testClipping() {
$dumper = new SimpleDumper();
$this->assertEqual(
$dumper->clipString("Hello", 6),
"Hello",
"Hello, 6->%s");
$this->assertEqual(
$dumper->clipString("Hello", 5),
"Hello",
"Hello, 5->%s");
$this->assertEqual(
$dumper->clipString("Hello world", 3),
"Hel...",
"Hello world, 3->%s");
$this->assertEqual(
$dumper->clipString("Hello world", 6, 3),
"Hello ...",
"Hello world, 6, 3->%s");
$this->assertEqual(
$dumper->clipString("Hello world", 3, 6),
"...o w...",
"Hello world, 3, 6->%s");
$this->assertEqual(
$dumper->clipString("Hello world", 4, 11),
"...orld",
"Hello world, 4, 11->%s");
$this->assertEqual(
$dumper->clipString("Hello world", 4, 12),
"...orld",
"Hello world, 4, 12->%s");
}
function testDescribeNull() {
$dumper = new SimpleDumper();
$this->assertPattern('/null/i', $dumper->describeValue(null));
}
function testDescribeBoolean() {
$dumper = new SimpleDumper();
$this->assertPattern('/boolean/i', $dumper->describeValue(true));
$this->assertPattern('/true/i', $dumper->describeValue(true));
$this->assertPattern('/false/i', $dumper->describeValue(false));
}
function testDescribeString() {
$dumper = new SimpleDumper();
$this->assertPattern('/string/i', $dumper->describeValue('Hello'));
$this->assertPattern('/Hello/', $dumper->describeValue('Hello'));
}
function testDescribeInteger() {
$dumper = new SimpleDumper();
$this->assertPattern('/integer/i', $dumper->describeValue(35));
$this->assertPattern('/35/', $dumper->describeValue(35));
}
function testDescribeFloat() {
$dumper = new SimpleDumper();
$this->assertPattern('/float/i', $dumper->describeValue(0.99));
$this->assertPattern('/0\.99/', $dumper->describeValue(0.99));
}
function testDescribeArray() {
$dumper = new SimpleDumper();
$this->assertPattern('/array/i', $dumper->describeValue(array(1, 4)));
$this->assertPattern('/2/i', $dumper->describeValue(array(1, 4)));
}
function testDescribeObject() {
$dumper = new SimpleDumper();
$this->assertPattern(
'/object/i',
$dumper->describeValue(new DumperDummy()));
$this->assertPattern(
'/DumperDummy/i',
$dumper->describeValue(new DumperDummy()));
}
}
?> | 10npsite | trunk/simpletest/test/dumper_test.php | PHP | asf20 | 3,034 |
<?php
// $Id: test_with_parse_error.php 901 2005-01-24 00:32:14Z lastcraft $
class TestCaseWithParseError extends UnitTestCase {
wibble
}
?> | 10npsite | trunk/simpletest/test/test_with_parse_error.php | PHP | asf20 | 170 |
<?php
// $Id: exceptions_test.php 1882 2009-07-01 14:30:05Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../exceptions.php');
require_once(dirname(__FILE__) . '/../expectation.php');
require_once(dirname(__FILE__) . '/../test_case.php');
Mock::generate('SimpleTestCase');
Mock::generate('SimpleExpectation');
class MyTestException extends Exception {}
class HigherTestException extends MyTestException {}
class OtherTestException extends Exception {}
class TestOfExceptionExpectation extends UnitTestCase {
function testExceptionClassAsStringWillMatchExceptionsRootedOnThatClass() {
$expectation = new ExceptionExpectation('MyTestException');
$this->assertTrue($expectation->test(new MyTestException()));
$this->assertTrue($expectation->test(new HigherTestException()));
$this->assertFalse($expectation->test(new OtherTestException()));
}
function testMatchesClassAndMessageWhenExceptionExpected() {
$expectation = new ExceptionExpectation(new MyTestException('Hello'));
$this->assertTrue($expectation->test(new MyTestException('Hello')));
$this->assertFalse($expectation->test(new HigherTestException('Hello')));
$this->assertFalse($expectation->test(new OtherTestException('Hello')));
$this->assertFalse($expectation->test(new MyTestException('Goodbye')));
$this->assertFalse($expectation->test(new MyTestException()));
}
function testMessagelessExceptionMatchesOnlyOnClass() {
$expectation = new ExceptionExpectation(new MyTestException());
$this->assertTrue($expectation->test(new MyTestException()));
$this->assertFalse($expectation->test(new HigherTestException()));
}
}
class TestOfExceptionTrap extends UnitTestCase {
function testNoExceptionsInQueueMeansNoTestMessages() {
$test = new MockSimpleTestCase();
$test->expectNever('assert');
$queue = new SimpleExceptionTrap();
$this->assertFalse($queue->isExpected($test, new Exception()));
}
function testMatchingExceptionGivesTrue() {
$expectation = new MockSimpleExpectation();
$expectation->setReturnValue('test', true);
$test = new MockSimpleTestCase();
$test->setReturnValue('assert', true);
$queue = new SimpleExceptionTrap();
$queue->expectException($expectation, 'message');
$this->assertTrue($queue->isExpected($test, new Exception()));
}
function testMatchingExceptionTriggersAssertion() {
$test = new MockSimpleTestCase();
$test->expectOnce('assert', array(
'*',
new ExceptionExpectation(new Exception()),
'message'));
$queue = new SimpleExceptionTrap();
$queue->expectException(new ExceptionExpectation(new Exception()), 'message');
$queue->isExpected($test, new Exception());
}
}
class TestOfCatchingExceptions extends UnitTestCase {
function testCanCatchAnyExpectedException() {
$this->expectException();
throw new Exception();
}
function testCanMatchExceptionByClass() {
$this->expectException('MyTestException');
throw new HigherTestException();
}
function testCanMatchExceptionExactly() {
$this->expectException(new Exception('Ouch'));
throw new Exception('Ouch');
}
function testLastListedExceptionIsTheOneThatCounts() {
$this->expectException('OtherTestException');
$this->expectException('MyTestException');
throw new HigherTestException();
}
}
class TestOfIgnoringExceptions extends UnitTestCase {
function testCanIgnoreAnyException() {
$this->ignoreException();
throw new Exception();
}
function testCanIgnoreSpecificException() {
$this->ignoreException('MyTestException');
throw new MyTestException();
}
function testCanIgnoreExceptionExactly() {
$this->ignoreException(new Exception('Ouch'));
throw new Exception('Ouch');
}
function testIgnoredExceptionsDoNotMaskExpectedExceptions() {
$this->ignoreException('Exception');
$this->expectException('MyTestException');
throw new MyTestException();
}
function testCanIgnoreMultipleExceptions() {
$this->ignoreException('MyTestException');
$this->ignoreException('OtherTestException');
throw new OtherTestException();
}
}
class TestOfCallingTearDownAfterExceptions extends UnitTestCase {
private $debri = 0;
function tearDown() {
$this->debri--;
}
function testLeaveSomeDebri() {
$this->debri++;
$this->expectException();
throw new Exception(__FUNCTION__);
}
function testDebriWasRemovedOnce() {
$this->assertEqual($this->debri, 0);
}
}
class TestOfExceptionThrownInSetUpDoesNotRunTestBody extends UnitTestCase {
function setUp() {
$this->expectException();
throw new Exception();
}
function testShouldNotBeRun() {
$this->fail('This test body should not be run');
}
function testShouldNotBeRunEither() {
$this->fail('This test body should not be run either');
}
}
class TestOfExpectExceptionWithSetUp extends UnitTestCase {
function setUp() {
$this->expectException();
}
function testThisExceptionShouldBeCaught() {
throw new Exception();
}
function testJustThrowingMyTestException() {
throw new MyTestException();
}
}
class TestOfThrowingExceptionsInTearDown extends UnitTestCase {
function tearDown() {
throw new Exception();
}
function testDoesntFatal() {
$this->expectException();
}
}
?> | 10npsite | trunk/simpletest/test/exceptions_test.php | PHP | asf20 | 5,736 |
<?php
// $Id: tag_test.php 1748 2008-04-14 01:50:41Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../tag.php');
require_once(dirname(__FILE__) . '/../encoding.php');
Mock::generate('SimpleMultipartEncoding');
class TestOfTag extends UnitTestCase {
function testStartValuesWithoutAdditionalContent() {
$tag = new SimpleTitleTag(array('a' => '1', 'b' => ''));
$this->assertEqual($tag->getTagName(), 'title');
$this->assertIdentical($tag->getAttribute('a'), '1');
$this->assertIdentical($tag->getAttribute('b'), '');
$this->assertIdentical($tag->getAttribute('c'), false);
$this->assertIdentical($tag->getContent(), '');
}
function testTitleContent() {
$tag = new SimpleTitleTag(array());
$this->assertTrue($tag->expectEndTag());
$tag->addContent('Hello');
$tag->addContent('World');
$this->assertEqual($tag->getText(), 'HelloWorld');
}
function testMessyTitleContent() {
$tag = new SimpleTitleTag(array());
$this->assertTrue($tag->expectEndTag());
$tag->addContent('<b>Hello</b>');
$tag->addContent('<em>World</em>');
$this->assertEqual($tag->getText(), 'HelloWorld');
}
function testTagWithNoEnd() {
$tag = new SimpleTextTag(array());
$this->assertFalse($tag->expectEndTag());
}
function testAnchorHref() {
$tag = new SimpleAnchorTag(array('href' => 'http://here/'));
$this->assertEqual($tag->getHref(), 'http://here/');
$tag = new SimpleAnchorTag(array('href' => ''));
$this->assertIdentical($tag->getAttribute('href'), '');
$this->assertIdentical($tag->getHref(), '');
$tag = new SimpleAnchorTag(array());
$this->assertIdentical($tag->getAttribute('href'), false);
$this->assertIdentical($tag->getHref(), '');
}
function testIsIdMatchesIdAttribute() {
$tag = new SimpleAnchorTag(array('href' => 'http://here/', 'id' => 7));
$this->assertIdentical($tag->getAttribute('id'), '7');
$this->assertTrue($tag->isId(7));
}
}
class TestOfWidget extends UnitTestCase {
function testTextEmptyDefault() {
$tag = new SimpleTextTag(array('type' => 'text'));
$this->assertIdentical($tag->getDefault(), '');
$this->assertIdentical($tag->getValue(), '');
}
function testSettingOfExternalLabel() {
$tag = new SimpleTextTag(array('type' => 'text'));
$tag->setLabel('it');
$this->assertTrue($tag->isLabel('it'));
}
function testTextDefault() {
$tag = new SimpleTextTag(array('value' => 'aaa'));
$this->assertEqual($tag->getDefault(), 'aaa');
$this->assertEqual($tag->getValue(), 'aaa');
}
function testSettingTextValue() {
$tag = new SimpleTextTag(array('value' => 'aaa'));
$tag->setValue('bbb');
$this->assertEqual($tag->getValue(), 'bbb');
$tag->resetValue();
$this->assertEqual($tag->getValue(), 'aaa');
}
function testFailToSetHiddenValue() {
$tag = new SimpleTextTag(array('value' => 'aaa', 'type' => 'hidden'));
$this->assertFalse($tag->setValue('bbb'));
$this->assertEqual($tag->getValue(), 'aaa');
}
function testSubmitDefaults() {
$tag = new SimpleSubmitTag(array('type' => 'submit'));
$this->assertIdentical($tag->getName(), false);
$this->assertEqual($tag->getValue(), 'Submit');
$this->assertFalse($tag->setValue('Cannot set this'));
$this->assertEqual($tag->getValue(), 'Submit');
$this->assertEqual($tag->getLabel(), 'Submit');
$encoding = new MockSimpleMultipartEncoding();
$encoding->expectNever('add');
$tag->write($encoding);
}
function testPopulatedSubmit() {
$tag = new SimpleSubmitTag(
array('type' => 'submit', 'name' => 's', 'value' => 'Ok!'));
$this->assertEqual($tag->getName(), 's');
$this->assertEqual($tag->getValue(), 'Ok!');
$this->assertEqual($tag->getLabel(), 'Ok!');
$encoding = new MockSimpleMultipartEncoding();
$encoding->expectOnce('add', array('s', 'Ok!'));
$tag->write($encoding);
}
function testImageSubmit() {
$tag = new SimpleImageSubmitTag(
array('type' => 'image', 'name' => 's', 'alt' => 'Label'));
$this->assertEqual($tag->getName(), 's');
$this->assertEqual($tag->getLabel(), 'Label');
$encoding = new MockSimpleMultipartEncoding();
$encoding->expectAt(0, 'add', array('s.x', 20));
$encoding->expectAt(1, 'add', array('s.y', 30));
$tag->write($encoding, 20, 30);
}
function testImageSubmitTitlePreferredOverAltForLabel() {
$tag = new SimpleImageSubmitTag(
array('type' => 'image', 'name' => 's', 'alt' => 'Label', 'title' => 'Title'));
$this->assertEqual($tag->getLabel(), 'Title');
}
function testButton() {
$tag = new SimpleButtonTag(
array('type' => 'submit', 'name' => 's', 'value' => 'do'));
$tag->addContent('I am a button');
$this->assertEqual($tag->getName(), 's');
$this->assertEqual($tag->getValue(), 'do');
$this->assertEqual($tag->getLabel(), 'I am a button');
$encoding = new MockSimpleMultipartEncoding();
$encoding->expectOnce('add', array('s', 'do'));
$tag->write($encoding);
}
}
class TestOfTextArea extends UnitTestCase {
function testDefault() {
$tag = new SimpleTextAreaTag(array('name' => 'a'));
$tag->addContent('Some text');
$this->assertEqual($tag->getName(), 'a');
$this->assertEqual($tag->getDefault(), 'Some text');
}
function testWrapping() {
$tag = new SimpleTextAreaTag(array('cols' => '10', 'wrap' => 'physical'));
$tag->addContent("Lot's of text that should be wrapped");
$this->assertEqual(
$tag->getDefault(),
"Lot's of\r\ntext that\r\nshould be\r\nwrapped");
$tag->setValue("New long text\r\nwith two lines");
$this->assertEqual(
$tag->getValue(),
"New long\r\ntext\r\nwith two\r\nlines");
}
function testWrappingRemovesLeadingcariageReturn() {
$tag = new SimpleTextAreaTag(array('cols' => '20', 'wrap' => 'physical'));
$tag->addContent("\rStuff");
$this->assertEqual($tag->getDefault(), 'Stuff');
$tag->setValue("\nNew stuff\n");
$this->assertEqual($tag->getValue(), "New stuff\r\n");
}
function testBreaksAreNewlineAndCarriageReturn() {
$tag = new SimpleTextAreaTag(array('cols' => '10'));
$tag->addContent("Some\nText\rwith\r\nbreaks");
$this->assertEqual($tag->getValue(), "Some\r\nText\r\nwith\r\nbreaks");
}
}
class TestOfCheckbox extends UnitTestCase {
function testCanSetCheckboxToNamedValueWithBooleanTrue() {
$tag = new SimpleCheckboxTag(array('name' => 'a', 'value' => 'A'));
$this->assertEqual($tag->getValue(), false);
$tag->setValue(true);
$this->assertIdentical($tag->getValue(), 'A');
}
}
class TestOfSelection extends UnitTestCase {
function testEmpty() {
$tag = new SimpleSelectionTag(array('name' => 'a'));
$this->assertIdentical($tag->getValue(), '');
}
function testSingle() {
$tag = new SimpleSelectionTag(array('name' => 'a'));
$option = new SimpleOptionTag(array());
$option->addContent('AAA');
$tag->addTag($option);
$this->assertEqual($tag->getValue(), 'AAA');
}
function testSingleDefault() {
$tag = new SimpleSelectionTag(array('name' => 'a'));
$option = new SimpleOptionTag(array('selected' => ''));
$option->addContent('AAA');
$tag->addTag($option);
$this->assertEqual($tag->getValue(), 'AAA');
}
function testSingleMappedDefault() {
$tag = new SimpleSelectionTag(array('name' => 'a'));
$option = new SimpleOptionTag(array('selected' => '', 'value' => 'aaa'));
$option->addContent('AAA');
$tag->addTag($option);
$this->assertEqual($tag->getValue(), 'aaa');
}
function testStartsWithDefault() {
$tag = new SimpleSelectionTag(array('name' => 'a'));
$a = new SimpleOptionTag(array());
$a->addContent('AAA');
$tag->addTag($a);
$b = new SimpleOptionTag(array('selected' => ''));
$b->addContent('BBB');
$tag->addTag($b);
$c = new SimpleOptionTag(array());
$c->addContent('CCC');
$tag->addTag($c);
$this->assertEqual($tag->getValue(), 'BBB');
}
function testSettingOption() {
$tag = new SimpleSelectionTag(array('name' => 'a'));
$a = new SimpleOptionTag(array());
$a->addContent('AAA');
$tag->addTag($a);
$b = new SimpleOptionTag(array('selected' => ''));
$b->addContent('BBB');
$tag->addTag($b);
$c = new SimpleOptionTag(array());
$c->addContent('CCC');
$tag->setValue('AAA');
$this->assertEqual($tag->getValue(), 'AAA');
}
function testSettingMappedOption() {
$tag = new SimpleSelectionTag(array('name' => 'a'));
$a = new SimpleOptionTag(array('value' => 'aaa'));
$a->addContent('AAA');
$tag->addTag($a);
$b = new SimpleOptionTag(array('value' => 'bbb', 'selected' => ''));
$b->addContent('BBB');
$tag->addTag($b);
$c = new SimpleOptionTag(array('value' => 'ccc'));
$c->addContent('CCC');
$tag->addTag($c);
$tag->setValue('AAA');
$this->assertEqual($tag->getValue(), 'aaa');
$tag->setValue('ccc');
$this->assertEqual($tag->getValue(), 'ccc');
}
function testSelectionDespiteSpuriousWhitespace() {
$tag = new SimpleSelectionTag(array('name' => 'a'));
$a = new SimpleOptionTag(array());
$a->addContent(' AAA ');
$tag->addTag($a);
$b = new SimpleOptionTag(array('selected' => ''));
$b->addContent(' BBB ');
$tag->addTag($b);
$c = new SimpleOptionTag(array());
$c->addContent(' CCC ');
$tag->addTag($c);
$this->assertEqual($tag->getValue(), ' BBB ');
$tag->setValue('AAA');
$this->assertEqual($tag->getValue(), ' AAA ');
}
function testFailToSetIllegalOption() {
$tag = new SimpleSelectionTag(array('name' => 'a'));
$a = new SimpleOptionTag(array());
$a->addContent('AAA');
$tag->addTag($a);
$b = new SimpleOptionTag(array('selected' => ''));
$b->addContent('BBB');
$tag->addTag($b);
$c = new SimpleOptionTag(array());
$c->addContent('CCC');
$tag->addTag($c);
$this->assertFalse($tag->setValue('Not present'));
$this->assertEqual($tag->getValue(), 'BBB');
}
function testNastyOptionValuesThatLookLikeFalse() {
$tag = new SimpleSelectionTag(array('name' => 'a'));
$a = new SimpleOptionTag(array('value' => '1'));
$a->addContent('One');
$tag->addTag($a);
$b = new SimpleOptionTag(array('value' => '0'));
$b->addContent('Zero');
$tag->addTag($b);
$this->assertIdentical($tag->getValue(), '1');
$tag->setValue('Zero');
$this->assertIdentical($tag->getValue(), '0');
}
function testBlankOption() {
$tag = new SimpleSelectionTag(array('name' => 'A'));
$a = new SimpleOptionTag(array());
$tag->addTag($a);
$b = new SimpleOptionTag(array());
$b->addContent('b');
$tag->addTag($b);
$this->assertIdentical($tag->getValue(), '');
$tag->setValue('b');
$this->assertIdentical($tag->getValue(), 'b');
$tag->setValue('');
$this->assertIdentical($tag->getValue(), '');
}
function testMultipleDefaultWithNoSelections() {
$tag = new MultipleSelectionTag(array('name' => 'a', 'multiple' => ''));
$a = new SimpleOptionTag(array());
$a->addContent('AAA');
$tag->addTag($a);
$b = new SimpleOptionTag(array());
$b->addContent('BBB');
$tag->addTag($b);
$this->assertIdentical($tag->getDefault(), array());
$this->assertIdentical($tag->getValue(), array());
}
function testMultipleDefaultWithSelections() {
$tag = new MultipleSelectionTag(array('name' => 'a', 'multiple' => ''));
$a = new SimpleOptionTag(array('selected' => ''));
$a->addContent('AAA');
$tag->addTag($a);
$b = new SimpleOptionTag(array('selected' => ''));
$b->addContent('BBB');
$tag->addTag($b);
$this->assertIdentical($tag->getDefault(), array('AAA', 'BBB'));
$this->assertIdentical($tag->getValue(), array('AAA', 'BBB'));
}
function testSettingMultiple() {
$tag = new MultipleSelectionTag(array('name' => 'a', 'multiple' => ''));
$a = new SimpleOptionTag(array('selected' => ''));
$a->addContent('AAA');
$tag->addTag($a);
$b = new SimpleOptionTag(array());
$b->addContent('BBB');
$tag->addTag($b);
$c = new SimpleOptionTag(array('selected' => '', 'value' => 'ccc'));
$c->addContent('CCC');
$tag->addTag($c);
$this->assertIdentical($tag->getDefault(), array('AAA', 'ccc'));
$this->assertTrue($tag->setValue(array('BBB', 'ccc')));
$this->assertIdentical($tag->getValue(), array('BBB', 'ccc'));
$this->assertTrue($tag->setValue(array()));
$this->assertIdentical($tag->getValue(), array());
}
function testFailToSetIllegalOptionsInMultiple() {
$tag = new MultipleSelectionTag(array('name' => 'a', 'multiple' => ''));
$a = new SimpleOptionTag(array('selected' => ''));
$a->addContent('AAA');
$tag->addTag($a);
$b = new SimpleOptionTag(array());
$b->addContent('BBB');
$tag->addTag($b);
$this->assertFalse($tag->setValue(array('CCC')));
$this->assertTrue($tag->setValue(array('AAA', 'BBB')));
$this->assertFalse($tag->setValue(array('AAA', 'CCC')));
}
}
class TestOfRadioGroup extends UnitTestCase {
function testEmptyGroup() {
$group = new SimpleRadioGroup();
$this->assertIdentical($group->getDefault(), false);
$this->assertIdentical($group->getValue(), false);
$this->assertFalse($group->setValue('a'));
}
function testReadingSingleButtonGroup() {
$group = new SimpleRadioGroup();
$group->addWidget(new SimpleRadioButtonTag(
array('value' => 'A', 'checked' => '')));
$this->assertIdentical($group->getDefault(), 'A');
$this->assertIdentical($group->getValue(), 'A');
}
function testReadingMultipleButtonGroup() {
$group = new SimpleRadioGroup();
$group->addWidget(new SimpleRadioButtonTag(
array('value' => 'A')));
$group->addWidget(new SimpleRadioButtonTag(
array('value' => 'B', 'checked' => '')));
$this->assertIdentical($group->getDefault(), 'B');
$this->assertIdentical($group->getValue(), 'B');
}
function testFailToSetUnlistedValue() {
$group = new SimpleRadioGroup();
$group->addWidget(new SimpleRadioButtonTag(array('value' => 'z')));
$this->assertFalse($group->setValue('a'));
$this->assertIdentical($group->getValue(), false);
}
function testSettingNewValueClearsTheOldOne() {
$group = new SimpleRadioGroup();
$group->addWidget(new SimpleRadioButtonTag(
array('value' => 'A')));
$group->addWidget(new SimpleRadioButtonTag(
array('value' => 'B', 'checked' => '')));
$this->assertTrue($group->setValue('A'));
$this->assertIdentical($group->getValue(), 'A');
}
function testIsIdMatchesAnyWidgetInSet() {
$group = new SimpleRadioGroup();
$group->addWidget(new SimpleRadioButtonTag(
array('value' => 'A', 'id' => 'i1')));
$group->addWidget(new SimpleRadioButtonTag(
array('value' => 'B', 'id' => 'i2')));
$this->assertFalse($group->isId('i0'));
$this->assertTrue($group->isId('i1'));
$this->assertTrue($group->isId('i2'));
}
function testIsLabelMatchesAnyWidgetInSet() {
$group = new SimpleRadioGroup();
$button1 = new SimpleRadioButtonTag(array('value' => 'A'));
$button1->setLabel('one');
$group->addWidget($button1);
$button2 = new SimpleRadioButtonTag(array('value' => 'B'));
$button2->setLabel('two');
$group->addWidget($button2);
$this->assertFalse($group->isLabel('three'));
$this->assertTrue($group->isLabel('one'));
$this->assertTrue($group->isLabel('two'));
}
}
class TestOfTagGroup extends UnitTestCase {
function testReadingMultipleCheckboxGroup() {
$group = new SimpleCheckboxGroup();
$group->addWidget(new SimpleCheckboxTag(array('value' => 'A')));
$group->addWidget(new SimpleCheckboxTag(
array('value' => 'B', 'checked' => '')));
$this->assertIdentical($group->getDefault(), 'B');
$this->assertIdentical($group->getValue(), 'B');
}
function testReadingMultipleUncheckedItems() {
$group = new SimpleCheckboxGroup();
$group->addWidget(new SimpleCheckboxTag(array('value' => 'A')));
$group->addWidget(new SimpleCheckboxTag(array('value' => 'B')));
$this->assertIdentical($group->getDefault(), false);
$this->assertIdentical($group->getValue(), false);
}
function testReadingMultipleCheckedItems() {
$group = new SimpleCheckboxGroup();
$group->addWidget(new SimpleCheckboxTag(
array('value' => 'A', 'checked' => '')));
$group->addWidget(new SimpleCheckboxTag(
array('value' => 'B', 'checked' => '')));
$this->assertIdentical($group->getDefault(), array('A', 'B'));
$this->assertIdentical($group->getValue(), array('A', 'B'));
}
function testSettingSingleValue() {
$group = new SimpleCheckboxGroup();
$group->addWidget(new SimpleCheckboxTag(array('value' => 'A')));
$group->addWidget(new SimpleCheckboxTag(array('value' => 'B')));
$this->assertTrue($group->setValue('A'));
$this->assertIdentical($group->getValue(), 'A');
$this->assertTrue($group->setValue('B'));
$this->assertIdentical($group->getValue(), 'B');
}
function testSettingMultipleValues() {
$group = new SimpleCheckboxGroup();
$group->addWidget(new SimpleCheckboxTag(array('value' => 'A')));
$group->addWidget(new SimpleCheckboxTag(array('value' => 'B')));
$this->assertTrue($group->setValue(array('A', 'B')));
$this->assertIdentical($group->getValue(), array('A', 'B'));
}
function testSettingNoValue() {
$group = new SimpleCheckboxGroup();
$group->addWidget(new SimpleCheckboxTag(array('value' => 'A')));
$group->addWidget(new SimpleCheckboxTag(array('value' => 'B')));
$this->assertTrue($group->setValue(false));
$this->assertIdentical($group->getValue(), false);
}
function testIsIdMatchesAnyIdInSet() {
$group = new SimpleCheckboxGroup();
$group->addWidget(new SimpleCheckboxTag(array('id' => 1, 'value' => 'A')));
$group->addWidget(new SimpleCheckboxTag(array('id' => 2, 'value' => 'B')));
$this->assertFalse($group->isId(0));
$this->assertTrue($group->isId(1));
$this->assertTrue($group->isId(2));
}
}
class TestOfUploadWidget extends UnitTestCase {
function testValueIsFilePath() {
$upload = new SimpleUploadTag(array('name' => 'a'));
$upload->setValue(dirname(__FILE__) . '/support/upload_sample.txt');
$this->assertEqual($upload->getValue(), dirname(__FILE__) . '/support/upload_sample.txt');
}
function testSubmitsFileContents() {
$encoding = new MockSimpleMultipartEncoding();
$encoding->expectOnce('attach', array(
'a',
'Sample for testing file upload',
'upload_sample.txt'));
$upload = new SimpleUploadTag(array('name' => 'a'));
$upload->setValue(dirname(__FILE__) . '/support/upload_sample.txt');
$upload->write($encoding);
}
}
class TestOfLabelTag extends UnitTestCase {
function testLabelShouldHaveAnEndTag() {
$label = new SimpleLabelTag(array());
$this->assertTrue($label->expectEndTag());
}
function testContentIsTextOnly() {
$label = new SimpleLabelTag(array());
$label->addContent('Here <tag>are</tag> words');
$this->assertEqual($label->getText(), 'Here are words');
}
}
?> | 10npsite | trunk/simpletest/test/tag_test.php | PHP | asf20 | 21,311 |
<?php
// $Id: cookies_test.php 1506 2007-05-07 00:58:03Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../cookies.php');
class TestOfCookie extends UnitTestCase {
function testCookieDefaults() {
$cookie = new SimpleCookie("name");
$this->assertFalse($cookie->getValue());
$this->assertEqual($cookie->getPath(), "/");
$this->assertIdentical($cookie->getHost(), false);
$this->assertFalse($cookie->getExpiry());
$this->assertFalse($cookie->isSecure());
}
function testCookieAccessors() {
$cookie = new SimpleCookie(
"name",
"value",
"/path",
"Mon, 18 Nov 2002 15:50:29 GMT",
true);
$this->assertEqual($cookie->getName(), "name");
$this->assertEqual($cookie->getValue(), "value");
$this->assertEqual($cookie->getPath(), "/path/");
$this->assertEqual($cookie->getExpiry(), "Mon, 18 Nov 2002 15:50:29 GMT");
$this->assertTrue($cookie->isSecure());
}
function testFullHostname() {
$cookie = new SimpleCookie("name");
$this->assertTrue($cookie->setHost("host.name.here"));
$this->assertEqual($cookie->getHost(), "host.name.here");
$this->assertTrue($cookie->setHost("host.com"));
$this->assertEqual($cookie->getHost(), "host.com");
}
function testHostTruncation() {
$cookie = new SimpleCookie("name");
$cookie->setHost("this.host.name.here");
$this->assertEqual($cookie->getHost(), "host.name.here");
$cookie->setHost("this.host.com");
$this->assertEqual($cookie->getHost(), "host.com");
$this->assertTrue($cookie->setHost("dashes.in-host.com"));
$this->assertEqual($cookie->getHost(), "in-host.com");
}
function testBadHosts() {
$cookie = new SimpleCookie("name");
$this->assertFalse($cookie->setHost("gibberish"));
$this->assertFalse($cookie->setHost("host.here"));
$this->assertFalse($cookie->setHost("host..com"));
$this->assertFalse($cookie->setHost("..."));
$this->assertFalse($cookie->setHost("host.com."));
}
function testHostValidity() {
$cookie = new SimpleCookie("name");
$cookie->setHost("this.host.name.here");
$this->assertTrue($cookie->isValidHost("host.name.here"));
$this->assertTrue($cookie->isValidHost("that.host.name.here"));
$this->assertFalse($cookie->isValidHost("bad.host"));
$this->assertFalse($cookie->isValidHost("nearly.name.here"));
}
function testPathValidity() {
$cookie = new SimpleCookie("name", "value", "/path");
$this->assertFalse($cookie->isValidPath("/"));
$this->assertTrue($cookie->isValidPath("/path/"));
$this->assertTrue($cookie->isValidPath("/path/more"));
}
function testSessionExpiring() {
$cookie = new SimpleCookie("name", "value", "/path");
$this->assertTrue($cookie->isExpired(0));
}
function testTimestampExpiry() {
$cookie = new SimpleCookie("name", "value", "/path", 456);
$this->assertFalse($cookie->isExpired(0));
$this->assertTrue($cookie->isExpired(457));
$this->assertFalse($cookie->isExpired(455));
}
function testDateExpiry() {
$cookie = new SimpleCookie(
"name",
"value",
"/path",
"Mon, 18 Nov 2002 15:50:29 GMT");
$this->assertTrue($cookie->isExpired("Mon, 18 Nov 2002 15:50:30 GMT"));
$this->assertFalse($cookie->isExpired("Mon, 18 Nov 2002 15:50:28 GMT"));
}
function testAging() {
$cookie = new SimpleCookie("name", "value", "/path", 200);
$cookie->agePrematurely(199);
$this->assertFalse($cookie->isExpired(0));
$cookie->agePrematurely(2);
$this->assertTrue($cookie->isExpired(0));
}
}
class TestOfCookieJar extends UnitTestCase {
function testAddCookie() {
$jar = new SimpleCookieJar();
$jar->setCookie("a", "A");
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a=A'));
}
function testHostFilter() {
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'A', 'my-host.com');
$jar->setCookie('b', 'B', 'another-host.com');
$jar->setCookie('c', 'C');
$this->assertEqual(
$jar->selectAsPairs(new SimpleUrl('my-host.com')),
array('a=A', 'c=C'));
$this->assertEqual(
$jar->selectAsPairs(new SimpleUrl('another-host.com')),
array('b=B', 'c=C'));
$this->assertEqual(
$jar->selectAsPairs(new SimpleUrl('www.another-host.com')),
array('b=B', 'c=C'));
$this->assertEqual(
$jar->selectAsPairs(new SimpleUrl('new-host.org')),
array('c=C'));
$this->assertEqual(
$jar->selectAsPairs(new SimpleUrl('/')),
array('a=A', 'b=B', 'c=C'));
}
function testPathFilter() {
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'A', false, '/path/');
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array());
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/elsewhere')), array());
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path/')), array('a=A'));
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path')), array('a=A'));
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/pa')), array());
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path/here')), array('a=A'));
}
function testPathFilterDeeply() {
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'A', false, '/path/more_path/');
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path/')), array());
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path')), array());
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/pa')), array());
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path/more_path/')), array('a=A'));
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path/more_path/and_more')), array('a=A'));
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path/not_here/')), array());
}
function testMultipleCookieWithDifferentPathsButSameName() {
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'abc', false, '/');
$jar->setCookie('a', '123', false, '/path/here/');
$this->assertEqual(
$jar->selectAsPairs(new SimpleUrl('/')),
array('a=abc'));
$this->assertEqual(
$jar->selectAsPairs(new SimpleUrl('my-host.com/')),
array('a=abc'));
$this->assertEqual(
$jar->selectAsPairs(new SimpleUrl('my-host.com/path/')),
array('a=abc'));
$this->assertEqual(
$jar->selectAsPairs(new SimpleUrl('my-host.com/path/here')),
array('a=abc', 'a=123'));
$this->assertEqual(
$jar->selectAsPairs(new SimpleUrl('my-host.com/path/here/there')),
array('a=abc', 'a=123'));
}
function testOverwrite() {
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'abc', false, '/');
$jar->setCookie('a', 'cde', false, '/');
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a=cde'));
}
function testClearSessionCookies() {
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'A', false, '/');
$jar->restartSession();
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array());
}
function testExpiryFilterByDate() {
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'A', false, '/', 'Wed, 25-Dec-02 04:24:20 GMT');
$jar->restartSession("Wed, 25-Dec-02 04:24:19 GMT");
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a=A'));
$jar->restartSession("Wed, 25-Dec-02 04:24:21 GMT");
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array());
}
function testExpiryFilterByAgeing() {
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'A', false, '/', 'Wed, 25-Dec-02 04:24:20 GMT');
$jar->restartSession("Wed, 25-Dec-02 04:24:19 GMT");
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a=A'));
$jar->agePrematurely(2);
$jar->restartSession("Wed, 25-Dec-02 04:24:19 GMT");
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array());
}
function testCookieClearing() {
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'abc', false, '/');
$jar->setCookie('a', '', false, '/');
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a='));
}
function testCookieClearByLoweringDate() {
$jar = new SimpleCookieJar();
$jar->setCookie('a', 'abc', false, '/', 'Wed, 25-Dec-02 04:24:21 GMT');
$jar->setCookie('a', 'def', false, '/', 'Wed, 25-Dec-02 04:24:19 GMT');
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a=def'));
$jar->restartSession('Wed, 25-Dec-02 04:24:20 GMT');
$this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array());
}
}
?> | 10npsite | trunk/simpletest/test/cookies_test.php | PHP | asf20 | 9,584 |
<?php
require_once(dirname(__FILE__) . '/../autorun.php');
class AllTests extends TestSuite {
function AllTests() {
$this->TestSuite('All tests for SimpleTest ' . SimpleTest::getVersion());
$this->addFile(dirname(__FILE__) . '/unit_tests.php');
$this->addFile(dirname(__FILE__) . '/shell_test.php');
$this->addFile(dirname(__FILE__) . '/live_test.php');
$this->addFile(dirname(__FILE__) . '/acceptance_test.php');
}
}
?> | 10npsite | trunk/simpletest/test/all_tests.php | PHP | asf20 | 469 |
<?php
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../default_reporter.php');
class TestOfCommandLineParsing extends UnitTestCase {
function testDefaultsToEmptyStringToMeanNullToTheSelectiveReporter() {
$parser = new SimpleCommandLineParser(array());
$this->assertIdentical($parser->getTest(), '');
$this->assertIdentical($parser->getTestCase(), '');
}
function testNotXmlByDefault() {
$parser = new SimpleCommandLineParser(array());
$this->assertFalse($parser->isXml());
}
function testCanDetectRequestForXml() {
$parser = new SimpleCommandLineParser(array('--xml'));
$this->assertTrue($parser->isXml());
}
function testCanReadAssignmentSyntax() {
$parser = new SimpleCommandLineParser(array('--test=myTest'));
$this->assertEqual($parser->getTest(), 'myTest');
}
function testCanReadFollowOnSyntax() {
$parser = new SimpleCommandLineParser(array('--test', 'myTest'));
$this->assertEqual($parser->getTest(), 'myTest');
}
function testCanReadShortForms() {
$parser = new SimpleCommandLineParser(array('-t', 'myTest', '-c', 'MyClass', '-x'));
$this->assertEqual($parser->getTest(), 'myTest');
$this->assertEqual($parser->getTestCase(), 'MyClass');
$this->assertTrue($parser->isXml());
}
}
?> | 10npsite | trunk/simpletest/test/command_line_test.php | PHP | asf20 | 1,431 |
<?php
// $Id: mock_objects_test.php 1900 2009-07-29 11:44:37Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../expectation.php');
require_once(dirname(__FILE__) . '/../mock_objects.php');
class TestOfAnythingExpectation extends UnitTestCase {
function testSimpleInteger() {
$expectation = new AnythingExpectation();
$this->assertTrue($expectation->test(33));
$this->assertTrue($expectation->test(false));
$this->assertTrue($expectation->test(null));
}
}
class TestOfParametersExpectation extends UnitTestCase {
function testEmptyMatch() {
$expectation = new ParametersExpectation(array());
$this->assertTrue($expectation->test(array()));
$this->assertFalse($expectation->test(array(33)));
}
function testSingleMatch() {
$expectation = new ParametersExpectation(array(0));
$this->assertFalse($expectation->test(array(1)));
$this->assertTrue($expectation->test(array(0)));
}
function testAnyMatch() {
$expectation = new ParametersExpectation(false);
$this->assertTrue($expectation->test(array()));
$this->assertTrue($expectation->test(array(1, 2)));
}
function testMissingParameter() {
$expectation = new ParametersExpectation(array(0));
$this->assertFalse($expectation->test(array()));
}
function testNullParameter() {
$expectation = new ParametersExpectation(array(null));
$this->assertTrue($expectation->test(array(null)));
$this->assertFalse($expectation->test(array()));
}
function testAnythingExpectations() {
$expectation = new ParametersExpectation(array(new AnythingExpectation()));
$this->assertFalse($expectation->test(array()));
$this->assertIdentical($expectation->test(array(null)), true);
$this->assertIdentical($expectation->test(array(13)), true);
}
function testOtherExpectations() {
$expectation = new ParametersExpectation(
array(new PatternExpectation('/hello/i')));
$this->assertFalse($expectation->test(array('Goodbye')));
$this->assertTrue($expectation->test(array('hello')));
$this->assertTrue($expectation->test(array('Hello')));
}
function testIdentityOnly() {
$expectation = new ParametersExpectation(array("0"));
$this->assertFalse($expectation->test(array(0)));
$this->assertTrue($expectation->test(array("0")));
}
function testLongList() {
$expectation = new ParametersExpectation(
array("0", 0, new AnythingExpectation(), false));
$this->assertTrue($expectation->test(array("0", 0, 37, false)));
$this->assertFalse($expectation->test(array("0", 0, 37, true)));
$this->assertFalse($expectation->test(array("0", 0, 37)));
}
}
class TestOfSimpleSignatureMap extends UnitTestCase {
function testEmpty() {
$map = new SimpleSignatureMap();
$this->assertFalse($map->isMatch("any", array()));
$this->assertNull($map->findFirstAction("any", array()));
}
function testDifferentCallSignaturesCanHaveDifferentReferences() {
$map = new SimpleSignatureMap();
$fred = 'Fred';
$jim = 'jim';
$map->add(array(0), $fred);
$map->add(array('0'), $jim);
$this->assertSame($fred, $map->findFirstAction(array(0)));
$this->assertSame($jim, $map->findFirstAction(array('0')));
}
function testWildcard() {
$fred = 'Fred';
$map = new SimpleSignatureMap();
$map->add(array(new AnythingExpectation(), 1, 3), $fred);
$this->assertTrue($map->isMatch(array(2, 1, 3)));
$this->assertSame($map->findFirstAction(array(2, 1, 3)), $fred);
}
function testAllWildcard() {
$fred = 'Fred';
$map = new SimpleSignatureMap();
$this->assertFalse($map->isMatch(array(2, 1, 3)));
$map->add('', $fred);
$this->assertTrue($map->isMatch(array(2, 1, 3)));
$this->assertSame($map->findFirstAction(array(2, 1, 3)), $fred);
}
function testOrdering() {
$map = new SimpleSignatureMap();
$map->add(array(1, 2), new SimpleByValue("1, 2"));
$map->add(array(1, 3), new SimpleByValue("1, 3"));
$map->add(array(1), new SimpleByValue("1"));
$map->add(array(1, 4), new SimpleByValue("1, 4"));
$map->add(array(new AnythingExpectation()), new SimpleByValue("Any"));
$map->add(array(2), new SimpleByValue("2"));
$map->add("", new SimpleByValue("Default"));
$map->add(array(), new SimpleByValue("None"));
$this->assertEqual($map->findFirstAction(array(1, 2)), new SimpleByValue("1, 2"));
$this->assertEqual($map->findFirstAction(array(1, 3)), new SimpleByValue("1, 3"));
$this->assertEqual($map->findFirstAction(array(1, 4)), new SimpleByValue("1, 4"));
$this->assertEqual($map->findFirstAction(array(1)), new SimpleByValue("1"));
$this->assertEqual($map->findFirstAction(array(2)), new SimpleByValue("Any"));
$this->assertEqual($map->findFirstAction(array(3)), new SimpleByValue("Any"));
$this->assertEqual($map->findFirstAction(array()), new SimpleByValue("Default"));
}
}
class TestOfCallSchedule extends UnitTestCase {
function testCanBeSetToAlwaysReturnTheSameReference() {
$a = 5;
$schedule = new SimpleCallSchedule();
$schedule->register('aMethod', false, new SimpleByReference($a));
$this->assertReference($schedule->respond(0, 'aMethod', array()), $a);
$this->assertReference($schedule->respond(1, 'aMethod', array()), $a);
}
function testSpecificSignaturesOverrideTheAlwaysCase() {
$any = 'any';
$one = 'two';
$schedule = new SimpleCallSchedule();
$schedule->register('aMethod', array(1), new SimpleByReference($one));
$schedule->register('aMethod', false, new SimpleByReference($any));
$this->assertReference($schedule->respond(0, 'aMethod', array(2)), $any);
$this->assertReference($schedule->respond(0, 'aMethod', array(1)), $one);
}
function testReturnsCanBeSetOverTime() {
$one = 'one';
$two = 'two';
$schedule = new SimpleCallSchedule();
$schedule->registerAt(0, 'aMethod', false, new SimpleByReference($one));
$schedule->registerAt(1, 'aMethod', false, new SimpleByReference($two));
$this->assertReference($schedule->respond(0, 'aMethod', array()), $one);
$this->assertReference($schedule->respond(1, 'aMethod', array()), $two);
}
function testReturnsOverTimecanBeAlteredByTheArguments() {
$one = '1';
$two = '2';
$two_a = '2a';
$schedule = new SimpleCallSchedule();
$schedule->registerAt(0, 'aMethod', false, new SimpleByReference($one));
$schedule->registerAt(1, 'aMethod', array('a'), new SimpleByReference($two_a));
$schedule->registerAt(1, 'aMethod', false, new SimpleByReference($two));
$this->assertReference($schedule->respond(0, 'aMethod', array()), $one);
$this->assertReference($schedule->respond(1, 'aMethod', array()), $two);
$this->assertReference($schedule->respond(1, 'aMethod', array('a')), $two_a);
}
function testCanReturnByValue() {
$a = 5;
$schedule = new SimpleCallSchedule();
$schedule->register('aMethod', false, new SimpleByValue($a));
$this->assertCopy($schedule->respond(0, 'aMethod', array()), $a);
}
function testCanThrowException() {
if (version_compare(phpversion(), '5', '>=')) {
$schedule = new SimpleCallSchedule();
$schedule->register('aMethod', false, new SimpleThrower(new Exception('Ouch')));
$this->expectException(new Exception('Ouch'));
$schedule->respond(0, 'aMethod', array());
}
}
function testCanEmitError() {
$schedule = new SimpleCallSchedule();
$schedule->register('aMethod', false, new SimpleErrorThrower('Ouch', E_USER_WARNING));
$this->expectError('Ouch');
$schedule->respond(0, 'aMethod', array());
}
}
class Dummy {
function Dummy() {
}
function aMethod() {
return true;
}
function &aReferenceMethod() {
return true;
}
function anotherMethod() {
return true;
}
}
Mock::generate('Dummy');
Mock::generate('Dummy', 'AnotherMockDummy');
Mock::generate('Dummy', 'MockDummyWithExtraMethods', array('extraMethod'));
class TestOfMockGeneration extends UnitTestCase {
function testCloning() {
$mock = new MockDummy();
$this->assertTrue(method_exists($mock, "aMethod"));
$this->assertNull($mock->aMethod());
}
function testCloningWithExtraMethod() {
$mock = new MockDummyWithExtraMethods();
$this->assertTrue(method_exists($mock, "extraMethod"));
}
function testCloningWithChosenClassName() {
$mock = new AnotherMockDummy();
$this->assertTrue(method_exists($mock, "aMethod"));
}
}
class TestOfMockReturns extends UnitTestCase {
function testDefaultReturn() {
$mock = new MockDummy();
$mock->returnsByValue("aMethod", "aaa");
$this->assertIdentical($mock->aMethod(), "aaa");
$this->assertIdentical($mock->aMethod(), "aaa");
}
function testParameteredReturn() {
$mock = new MockDummy();
$mock->returnsByValue('aMethod', 'aaa', array(1, 2, 3));
$this->assertNull($mock->aMethod());
$this->assertIdentical($mock->aMethod(1, 2, 3), 'aaa');
}
function testSetReturnGivesObjectReference() {
$mock = new MockDummy();
$object = new Dummy();
$mock->returns('aMethod', $object, array(1, 2, 3));
$this->assertSame($mock->aMethod(1, 2, 3), $object);
}
function testSetReturnReferenceGivesOriginalReference() {
$mock = new MockDummy();
$object = 1;
$mock->returnsByReference('aReferenceMethod', $object, array(1, 2, 3));
$this->assertReference($mock->aReferenceMethod(1, 2, 3), $object);
}
function testReturnValueCanBeChosenJustByPatternMatchingArguments() {
$mock = new MockDummy();
$mock->returnsByValue(
"aMethod",
"aaa",
array(new PatternExpectation('/hello/i')));
$this->assertIdentical($mock->aMethod('Hello'), 'aaa');
$this->assertNull($mock->aMethod('Goodbye'));
}
function testMultipleMethods() {
$mock = new MockDummy();
$mock->returnsByValue("aMethod", 100, array(1));
$mock->returnsByValue("aMethod", 200, array(2));
$mock->returnsByValue("anotherMethod", 10, array(1));
$mock->returnsByValue("anotherMethod", 20, array(2));
$this->assertIdentical($mock->aMethod(1), 100);
$this->assertIdentical($mock->anotherMethod(1), 10);
$this->assertIdentical($mock->aMethod(2), 200);
$this->assertIdentical($mock->anotherMethod(2), 20);
}
function testReturnSequence() {
$mock = new MockDummy();
$mock->returnsByValueAt(0, "aMethod", "aaa");
$mock->returnsByValueAt(1, "aMethod", "bbb");
$mock->returnsByValueAt(3, "aMethod", "ddd");
$this->assertIdentical($mock->aMethod(), "aaa");
$this->assertIdentical($mock->aMethod(), "bbb");
$this->assertNull($mock->aMethod());
$this->assertIdentical($mock->aMethod(), "ddd");
}
function testSetReturnReferenceAtGivesOriginal() {
$mock = new MockDummy();
$object = 100;
$mock->returnsByReferenceAt(1, "aReferenceMethod", $object);
$this->assertNull($mock->aReferenceMethod());
$this->assertReference($mock->aReferenceMethod(), $object);
$this->assertNull($mock->aReferenceMethod());
}
function testReturnsAtGivesOriginalObjectHandle() {
$mock = new MockDummy();
$object = new Dummy();
$mock->returnsAt(1, "aMethod", $object);
$this->assertNull($mock->aMethod());
$this->assertSame($mock->aMethod(), $object);
$this->assertNull($mock->aMethod());
}
function testComplicatedReturnSequence() {
$mock = new MockDummy();
$object = new Dummy();
$mock->returnsAt(1, "aMethod", "aaa", array("a"));
$mock->returnsAt(1, "aMethod", "bbb");
$mock->returnsAt(2, "aMethod", $object, array('*', 2));
$mock->returnsAt(2, "aMethod", "value", array('*', 3));
$mock->returns("aMethod", 3, array(3));
$this->assertNull($mock->aMethod());
$this->assertEqual($mock->aMethod("a"), "aaa");
$this->assertSame($mock->aMethod(1, 2), $object);
$this->assertEqual($mock->aMethod(3), 3);
$this->assertNull($mock->aMethod());
}
function testMultipleMethodSequences() {
$mock = new MockDummy();
$mock->returnsByValueAt(0, "aMethod", "aaa");
$mock->returnsByValueAt(1, "aMethod", "bbb");
$mock->returnsByValueAt(0, "anotherMethod", "ccc");
$mock->returnsByValueAt(1, "anotherMethod", "ddd");
$this->assertIdentical($mock->aMethod(), "aaa");
$this->assertIdentical($mock->anotherMethod(), "ccc");
$this->assertIdentical($mock->aMethod(), "bbb");
$this->assertIdentical($mock->anotherMethod(), "ddd");
}
function testSequenceFallback() {
$mock = new MockDummy();
$mock->returnsByValueAt(0, "aMethod", "aaa", array('a'));
$mock->returnsByValueAt(1, "aMethod", "bbb", array('a'));
$mock->returnsByValue("aMethod", "AAA");
$this->assertIdentical($mock->aMethod('a'), "aaa");
$this->assertIdentical($mock->aMethod('b'), "AAA");
}
function testMethodInterference() {
$mock = new MockDummy();
$mock->returnsByValueAt(0, "anotherMethod", "aaa");
$mock->returnsByValue("aMethod", "AAA");
$this->assertIdentical($mock->aMethod(), "AAA");
$this->assertIdentical($mock->anotherMethod(), "aaa");
}
}
class TestOfMockExpectationsThatPass extends UnitTestCase {
function testAnyArgument() {
$mock = new MockDummy();
$mock->expect('aMethod', array('*'));
$mock->aMethod(1);
$mock->aMethod('hello');
}
function testAnyTwoArguments() {
$mock = new MockDummy();
$mock->expect('aMethod', array('*', '*'));
$mock->aMethod(1, 2);
}
function testSpecificArgument() {
$mock = new MockDummy();
$mock->expect('aMethod', array(1));
$mock->aMethod(1);
}
function testExpectation() {
$mock = new MockDummy();
$mock->expect('aMethod', array(new IsAExpectation('Dummy')));
$mock->aMethod(new Dummy());
}
function testArgumentsInSequence() {
$mock = new MockDummy();
$mock->expectAt(0, 'aMethod', array(1, 2));
$mock->expectAt(1, 'aMethod', array(3, 4));
$mock->aMethod(1, 2);
$mock->aMethod(3, 4);
}
function testAtLeastOnceSatisfiedByOneCall() {
$mock = new MockDummy();
$mock->expectAtLeastOnce('aMethod');
$mock->aMethod();
}
function testAtLeastOnceSatisfiedByTwoCalls() {
$mock = new MockDummy();
$mock->expectAtLeastOnce('aMethod');
$mock->aMethod();
$mock->aMethod();
}
function testOnceSatisfiedByOneCall() {
$mock = new MockDummy();
$mock->expectOnce('aMethod');
$mock->aMethod();
}
function testMinimumCallsSatisfiedByEnoughCalls() {
$mock = new MockDummy();
$mock->expectMinimumCallCount('aMethod', 1);
$mock->aMethod();
}
function testMinimumCallsSatisfiedByTooManyCalls() {
$mock = new MockDummy();
$mock->expectMinimumCallCount('aMethod', 3);
$mock->aMethod();
$mock->aMethod();
$mock->aMethod();
$mock->aMethod();
}
function testMaximumCallsSatisfiedByEnoughCalls() {
$mock = new MockDummy();
$mock->expectMaximumCallCount('aMethod', 1);
$mock->aMethod();
}
function testMaximumCallsSatisfiedByNoCalls() {
$mock = new MockDummy();
$mock->expectMaximumCallCount('aMethod', 1);
}
}
class MockWithInjectedTestCase extends SimpleMock {
protected function getCurrentTestCase() {
return SimpleTest::getContext()->getTest()->getMockedTest();
}
}
SimpleTest::setMockBaseClass('MockWithInjectedTestCase');
Mock::generate('Dummy', 'MockDummyWithInjectedTestCase');
SimpleTest::setMockBaseClass('SimpleMock');
Mock::generate('SimpleTestCase');
class LikeExpectation extends IdenticalExpectation {
function __construct($expectation) {
$expectation->message = '';
parent::__construct($expectation);
}
function test($compare) {
$compare->message = '';
return parent::test($compare);
}
function testMessage($compare) {
$compare->message = '';
return parent::testMessage($compare);
}
}
class TestOfMockExpectations extends UnitTestCase {
private $test;
function setUp() {
$this->test = new MockSimpleTestCase();
}
function getMockedTest() {
return $this->test;
}
function testSettingExpectationOnNonMethodThrowsError() {
$mock = new MockDummyWithInjectedTestCase();
$this->expectError();
$mock->expectMaximumCallCount('aMissingMethod', 2);
}
function testMaxCallsDetectsOverrun() {
$this->test->expectOnce('assert', array(new MemberExpectation('count', 2), 3));
$mock = new MockDummyWithInjectedTestCase();
$mock->expectMaximumCallCount('aMethod', 2);
$mock->aMethod();
$mock->aMethod();
$mock->aMethod();
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testTallyOnMaxCallsSendsPassOnUnderrun() {
$this->test->expectOnce('assert', array(new MemberExpectation('count', 2), 2));
$mock = new MockDummyWithInjectedTestCase();
$mock->expectMaximumCallCount("aMethod", 2);
$mock->aMethod();
$mock->aMethod();
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testExpectNeverDetectsOverrun() {
$this->test->expectOnce('assert', array(new MemberExpectation('count', 0), 1));
$mock = new MockDummyWithInjectedTestCase();
$mock->expectNever('aMethod');
$mock->aMethod();
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testTallyOnExpectNeverStillSendsPassOnUnderrun() {
$this->test->expectOnce('assert', array(new MemberExpectation('count', 0), 0));
$mock = new MockDummyWithInjectedTestCase();
$mock->expectNever('aMethod');
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testMinCalls() {
$this->test->expectOnce('assert', array(new MemberExpectation('count', 2), 2));
$mock = new MockDummyWithInjectedTestCase();
$mock->expectMinimumCallCount('aMethod', 2);
$mock->aMethod();
$mock->aMethod();
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testFailedNever() {
$this->test->expectOnce('assert', array(new MemberExpectation('count', 0), 1));
$mock = new MockDummyWithInjectedTestCase();
$mock->expectNever('aMethod');
$mock->aMethod();
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testUnderOnce() {
$this->test->expectOnce('assert', array(new MemberExpectation('count', 1), 0));
$mock = new MockDummyWithInjectedTestCase();
$mock->expectOnce('aMethod');
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testOverOnce() {
$this->test->expectOnce('assert', array(new MemberExpectation('count', 1), 2));
$mock = new MockDummyWithInjectedTestCase();
$mock->expectOnce('aMethod');
$mock->aMethod();
$mock->aMethod();
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testUnderAtLeastOnce() {
$this->test->expectOnce('assert', array(new MemberExpectation('count', 1), 0));
$mock = new MockDummyWithInjectedTestCase();
$mock->expectAtLeastOnce("aMethod");
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testZeroArguments() {
$this->test->expectOnce('assert',
array(new MemberExpectation('expected', array()), array(), '*'));
$mock = new MockDummyWithInjectedTestCase();
$mock->expect('aMethod', array());
$mock->aMethod();
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testExpectedArguments() {
$this->test->expectOnce('assert',
array(new MemberExpectation('expected', array(1, 2, 3)), array(1, 2, 3), '*'));
$mock = new MockDummyWithInjectedTestCase();
$mock->expect('aMethod', array(1, 2, 3));
$mock->aMethod(1, 2, 3);
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testFailedArguments() {
$this->test->expectOnce('assert',
array(new MemberExpectation('expected', array('this')), array('that'), '*'));
$mock = new MockDummyWithInjectedTestCase();
$mock->expect('aMethod', array('this'));
$mock->aMethod('that');
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testWildcardsAreTranslatedToAnythingExpectations() {
$this->test->expectOnce('assert',
array(new MemberExpectation('expected',
array(new AnythingExpectation(),
123,
new AnythingExpectation())),
array(100, 123, 101), '*'));
$mock = new MockDummyWithInjectedTestCase($this);
$mock->expect("aMethod", array('*', 123, '*'));
$mock->aMethod(100, 123, 101);
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testSpecificPassingSequence() {
$this->test->expectAt(0, 'assert',
array(new MemberExpectation('expected', array(1, 2, 3)), array(1, 2, 3), '*'));
$this->test->expectAt(1, 'assert',
array(new MemberExpectation('expected', array('Hello')), array('Hello'), '*'));
$mock = new MockDummyWithInjectedTestCase();
$mock->expectAt(1, 'aMethod', array(1, 2, 3));
$mock->expectAt(2, 'aMethod', array('Hello'));
$mock->aMethod();
$mock->aMethod(1, 2, 3);
$mock->aMethod('Hello');
$mock->aMethod();
$mock->mock->atTestEnd('testSomething', $this->test);
}
function testNonArrayForExpectedParametersGivesError() {
$mock = new MockDummyWithInjectedTestCase();
$this->expectError(new PatternExpectation('/\$args.*not an array/i'));
$mock->expect("aMethod", "foo");
$mock->aMethod();
$mock->mock->atTestEnd('testSomething', $this->test);
}
}
class TestOfMockComparisons extends UnitTestCase {
function testEqualComparisonOfMocksDoesNotCrash() {
$expectation = new EqualExpectation(new MockDummy());
$this->assertTrue($expectation->test(new MockDummy(), true));
}
function testIdenticalComparisonOfMocksDoesNotCrash() {
$expectation = new IdenticalExpectation(new MockDummy());
$this->assertTrue($expectation->test(new MockDummy()));
}
}
class ClassWithSpecialMethods {
function __get($name) { }
function __set($name, $value) { }
function __isset($name) { }
function __unset($name) { }
function __call($method, $arguments) { }
function __toString() { }
}
Mock::generate('ClassWithSpecialMethods');
class TestOfSpecialMethodsAfterPHP51 extends UnitTestCase {
function skip() {
$this->skipIf(version_compare(phpversion(), '5.1', '<'), '__isset and __unset overloading not tested unless PHP 5.1+');
}
function testCanEmulateIsset() {
$mock = new MockClassWithSpecialMethods();
$mock->returnsByValue('__isset', true);
$this->assertIdentical(isset($mock->a), true);
}
function testCanExpectUnset() {
$mock = new MockClassWithSpecialMethods();
$mock->expectOnce('__unset', array('a'));
unset($mock->a);
}
}
class TestOfSpecialMethods extends UnitTestCase {
function skip() {
$this->skipIf(version_compare(phpversion(), '5', '<'), 'Overloading not tested unless PHP 5+');
}
function testCanMockTheThingAtAll() {
$mock = new MockClassWithSpecialMethods();
}
function testReturnFromSpecialAccessor() {
$mock = new MockClassWithSpecialMethods();
$mock->returnsByValue('__get', '1st Return', array('first'));
$mock->returnsByValue('__get', '2nd Return', array('second'));
$this->assertEqual($mock->first, '1st Return');
$this->assertEqual($mock->second, '2nd Return');
}
function testcanExpectTheSettingOfValue() {
$mock = new MockClassWithSpecialMethods();
$mock->expectOnce('__set', array('a', 'A'));
$mock->a = 'A';
}
function testCanSimulateAnOverloadmethod() {
$mock = new MockClassWithSpecialMethods();
$mock->expectOnce('__call', array('amOverloaded', array('A')));
$mock->returnsByValue('__call', 'aaa');
$this->assertIdentical($mock->amOverloaded('A'), 'aaa');
}
function testToStringMagic() {
$mock = new MockClassWithSpecialMethods();
$mock->expectOnce('__toString');
$mock->returnsByValue('__toString', 'AAA');
ob_start();
print $mock;
$output = ob_get_contents();
ob_end_clean();
$this->assertEqual($output, 'AAA');
}
}
class WithStaticMethod {
static function aStaticMethod() { }
}
Mock::generate('WithStaticMethod');
class TestOfMockingClassesWithStaticMethods extends UnitTestCase {
function testStaticMethodIsMockedAsStatic() {
$mock = new WithStaticMethod();
$reflection = new ReflectionClass($mock);
$method = $reflection->getMethod('aStaticMethod');
$this->assertTrue($method->isStatic());
}
}
class MockTestException extends Exception { }
class TestOfThrowingExceptionsFromMocks extends UnitTestCase {
function testCanThrowOnMethodCall() {
$mock = new MockDummy();
$mock->throwOn('aMethod');
$this->expectException();
$mock->aMethod();
}
function testCanThrowSpecificExceptionOnMethodCall() {
$mock = new MockDummy();
$mock->throwOn('aMethod', new MockTestException());
$this->expectException();
$mock->aMethod();
}
function testThrowsOnlyWhenCallSignatureMatches() {
$mock = new MockDummy();
$mock->throwOn('aMethod', new MockTestException(), array(3));
$mock->aMethod(1);
$mock->aMethod(2);
$this->expectException();
$mock->aMethod(3);
}
function testCanThrowOnParticularInvocation() {
$mock = new MockDummy();
$mock->throwAt(2, 'aMethod', new MockTestException());
$mock->aMethod();
$mock->aMethod();
$this->expectException();
$mock->aMethod();
}
}
class TestOfThrowingErrorsFromMocks extends UnitTestCase {
function testCanGenerateErrorFromMethodCall() {
$mock = new MockDummy();
$mock->errorOn('aMethod', 'Ouch!');
$this->expectError('Ouch!');
$mock->aMethod();
}
function testGeneratesErrorOnlyWhenCallSignatureMatches() {
$mock = new MockDummy();
$mock->errorOn('aMethod', 'Ouch!', array(3));
$mock->aMethod(1);
$mock->aMethod(2);
$this->expectError();
$mock->aMethod(3);
}
function testCanGenerateErrorOnParticularInvocation() {
$mock = new MockDummy();
$mock->errorAt(2, 'aMethod', 'Ouch!');
$mock->aMethod();
$mock->aMethod();
$this->expectError();
$mock->aMethod();
}
}
Mock::generatePartial('Dummy', 'TestDummy', array('anotherMethod', 'aReferenceMethod'));
class TestOfPartialMocks extends UnitTestCase {
function testMethodReplacementWithNoBehaviourReturnsNull() {
$mock = new TestDummy();
$this->assertEqual($mock->aMethod(99), 99);
$this->assertNull($mock->anotherMethod());
}
function testSettingReturns() {
$mock = new TestDummy();
$mock->returnsByValue('anotherMethod', 33, array(3));
$mock->returnsByValue('anotherMethod', 22);
$mock->returnsByValueAt(2, 'anotherMethod', 44, array(3));
$this->assertEqual($mock->anotherMethod(), 22);
$this->assertEqual($mock->anotherMethod(3), 33);
$this->assertEqual($mock->anotherMethod(3), 44);
}
function testSetReturnReferenceGivesOriginal() {
$mock = new TestDummy();
$object = 99;
$mock->returnsByReferenceAt(0, 'aReferenceMethod', $object, array(3));
$this->assertReference($mock->aReferenceMethod(3), $object);
}
function testReturnsAtGivesOriginalObjectHandle() {
$mock = new TestDummy();
$object = new Dummy();
$mock->returnsAt(0, 'anotherMethod', $object, array(3));
$this->assertSame($mock->anotherMethod(3), $object);
}
function testExpectations() {
$mock = new TestDummy();
$mock->expectCallCount('anotherMethod', 2);
$mock->expect('anotherMethod', array(77));
$mock->expectAt(1, 'anotherMethod', array(66));
$mock->anotherMethod(77);
$mock->anotherMethod(66);
}
function testSettingExpectationOnMissingMethodThrowsError() {
$mock = new TestDummy();
$this->expectError();
$mock->expectCallCount('aMissingMethod', 2);
}
}
class ConstructorSuperClass {
function ConstructorSuperClass() { }
}
class ConstructorSubClass extends ConstructorSuperClass { }
class TestOfPHP4StyleSuperClassConstruct extends UnitTestCase {
function testBasicConstruct() {
Mock::generate('ConstructorSubClass');
$mock = new MockConstructorSubClass();
$this->assertIsA($mock, 'ConstructorSubClass');
$this->assertTrue(method_exists($mock, 'ConstructorSuperClass'));
}
}
class TestOfPHP5StaticMethodMocking extends UnitTestCase {
function testCanCreateAMockObjectWithStaticMethodsWithoutError() {
eval('
class SimpleObjectContainingStaticMethod {
static function someStatic() { }
}
');
Mock::generate('SimpleObjectContainingStaticMethod');
}
}
class TestOfPHP5AbstractMethodMocking extends UnitTestCase {
function testCanCreateAMockObjectFromAnAbstractWithProperFunctionDeclarations() {
eval('
abstract class SimpleAbstractClassContainingAbstractMethods {
abstract function anAbstract();
abstract function anAbstractWithParameter($foo);
abstract function anAbstractWithMultipleParameters($foo, $bar);
}
');
Mock::generate('SimpleAbstractClassContainingAbstractMethods');
$this->assertTrue(
method_exists(
// Testing with class name alone does not work in PHP 5.0
new MockSimpleAbstractClassContainingAbstractMethods,
'anAbstract'
)
);
$this->assertTrue(
method_exists(
new MockSimpleAbstractClassContainingAbstractMethods,
'anAbstractWithParameter'
)
);
$this->assertTrue(
method_exists(
new MockSimpleAbstractClassContainingAbstractMethods,
'anAbstractWithMultipleParameters'
)
);
}
function testMethodsDefinedAsAbstractInParentShouldHaveFullSignature() {
eval('
abstract class SimpleParentAbstractClassContainingAbstractMethods {
abstract function anAbstract();
abstract function anAbstractWithParameter($foo);
abstract function anAbstractWithMultipleParameters($foo, $bar);
}
class SimpleChildAbstractClassContainingAbstractMethods extends SimpleParentAbstractClassContainingAbstractMethods {
function anAbstract(){}
function anAbstractWithParameter($foo){}
function anAbstractWithMultipleParameters($foo, $bar){}
}
class EvenDeeperEmptyChildClass extends SimpleChildAbstractClassContainingAbstractMethods {}
');
Mock::generate('SimpleChildAbstractClassContainingAbstractMethods');
$this->assertTrue(
method_exists(
new MockSimpleChildAbstractClassContainingAbstractMethods,
'anAbstract'
)
);
$this->assertTrue(
method_exists(
new MockSimpleChildAbstractClassContainingAbstractMethods,
'anAbstractWithParameter'
)
);
$this->assertTrue(
method_exists(
new MockSimpleChildAbstractClassContainingAbstractMethods,
'anAbstractWithMultipleParameters'
)
);
Mock::generate('EvenDeeperEmptyChildClass');
$this->assertTrue(
method_exists(
new MockEvenDeeperEmptyChildClass,
'anAbstract'
)
);
$this->assertTrue(
method_exists(
new MockEvenDeeperEmptyChildClass,
'anAbstractWithParameter'
)
);
$this->assertTrue(
method_exists(
new MockEvenDeeperEmptyChildClass,
'anAbstractWithMultipleParameters'
)
);
}
}
class DummyWithProtected
{
public function aMethodCallsProtected() { return $this->aProtectedMethod(); }
protected function aProtectedMethod() { return true; }
}
Mock::generatePartial('DummyWithProtected', 'TestDummyWithProtected', array('aProtectedMethod'));
class TestOfProtectedMethodPartialMocks extends UnitTestCase
{
function testProtectedMethodExists() {
$this->assertTrue(
method_exists(
new TestDummyWithProtected,
'aProtectedMethod'
)
);
}
function testProtectedMethodIsCalled() {
$object = new DummyWithProtected();
$this->assertTrue($object->aMethodCallsProtected(), 'ensure original was called');
}
function testMockedMethodIsCalled() {
$object = new TestDummyWithProtected();
$object->returnsByValue('aProtectedMethod', false);
$this->assertFalse($object->aMethodCallsProtected());
}
}
?>
| 10npsite | trunk/simpletest/test/mock_objects_test.php | PHP | asf20 | 35,273 |
<?php
// $Id: web_tester_test.php 1748 2008-04-14 01:50:41Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../web_tester.php');
class TestOfFieldExpectation extends UnitTestCase {
function testStringMatchingIsCaseSensitive() {
$expectation = new FieldExpectation('a');
$this->assertTrue($expectation->test('a'));
$this->assertTrue($expectation->test(array('a')));
$this->assertFalse($expectation->test('A'));
}
function testMatchesInteger() {
$expectation = new FieldExpectation('1');
$this->assertTrue($expectation->test('1'));
$this->assertTrue($expectation->test(1));
$this->assertTrue($expectation->test(array('1')));
$this->assertTrue($expectation->test(array(1)));
}
function testNonStringFailsExpectation() {
$expectation = new FieldExpectation('a');
$this->assertFalse($expectation->test(null));
}
function testUnsetFieldCanBeTestedFor() {
$expectation = new FieldExpectation(false);
$this->assertTrue($expectation->test(false));
}
function testMultipleValuesCanBeInAnyOrder() {
$expectation = new FieldExpectation(array('a', 'b'));
$this->assertTrue($expectation->test(array('a', 'b')));
$this->assertTrue($expectation->test(array('b', 'a')));
$this->assertFalse($expectation->test(array('a', 'a')));
$this->assertFalse($expectation->test('a'));
}
function testSingleItemCanBeArrayOrString() {
$expectation = new FieldExpectation(array('a'));
$this->assertTrue($expectation->test(array('a')));
$this->assertTrue($expectation->test('a'));
}
}
class TestOfHeaderExpectations extends UnitTestCase {
function testExpectingOnlyTheHeaderName() {
$expectation = new HttpHeaderExpectation('a');
$this->assertIdentical($expectation->test(false), false);
$this->assertIdentical($expectation->test('a: A'), true);
$this->assertIdentical($expectation->test('A: A'), true);
$this->assertIdentical($expectation->test('a: B'), true);
$this->assertIdentical($expectation->test(' a : A '), true);
}
function testHeaderValueAsWell() {
$expectation = new HttpHeaderExpectation('a', 'A');
$this->assertIdentical($expectation->test(false), false);
$this->assertIdentical($expectation->test('a: A'), true);
$this->assertIdentical($expectation->test('A: A'), true);
$this->assertIdentical($expectation->test('A: a'), false);
$this->assertIdentical($expectation->test('a: B'), false);
$this->assertIdentical($expectation->test(' a : A '), true);
$this->assertIdentical($expectation->test(' a : AB '), false);
}
function testHeaderValueWithColons() {
$expectation = new HttpHeaderExpectation('a', 'A:B:C');
$this->assertIdentical($expectation->test('a: A'), false);
$this->assertIdentical($expectation->test('a: A:B'), false);
$this->assertIdentical($expectation->test('a: A:B:C'), true);
$this->assertIdentical($expectation->test('a: A:B:C:D'), false);
}
function testMultilineSearch() {
$expectation = new HttpHeaderExpectation('a', 'A');
$this->assertIdentical($expectation->test("aa: A\r\nb: B\r\nc: C"), false);
$this->assertIdentical($expectation->test("aa: A\r\na: A\r\nb: B"), true);
}
function testMultilineSearchWithPadding() {
$expectation = new HttpHeaderExpectation('a', ' A ');
$this->assertIdentical($expectation->test("aa:A\r\nb:B\r\nc:C"), false);
$this->assertIdentical($expectation->test("aa:A\r\na:A\r\nb:B"), true);
}
function testPatternMatching() {
$expectation = new HttpHeaderExpectation('a', new PatternExpectation('/A/'));
$this->assertIdentical($expectation->test('a: A'), true);
$this->assertIdentical($expectation->test('A: A'), true);
$this->assertIdentical($expectation->test('A: a'), false);
$this->assertIdentical($expectation->test('a: B'), false);
$this->assertIdentical($expectation->test(' a : A '), true);
$this->assertIdentical($expectation->test(' a : AB '), true);
}
function testCaseInsensitivePatternMatching() {
$expectation = new HttpHeaderExpectation('a', new PatternExpectation('/A/i'));
$this->assertIdentical($expectation->test('a: a'), true);
$this->assertIdentical($expectation->test('a: B'), false);
$this->assertIdentical($expectation->test(' a : A '), true);
$this->assertIdentical($expectation->test(' a : BAB '), true);
$this->assertIdentical($expectation->test(' a : bab '), true);
}
function testUnwantedHeader() {
$expectation = new NoHttpHeaderExpectation('a');
$this->assertIdentical($expectation->test(''), true);
$this->assertIdentical($expectation->test('stuff'), true);
$this->assertIdentical($expectation->test('b: B'), true);
$this->assertIdentical($expectation->test('a: A'), false);
$this->assertIdentical($expectation->test('A: A'), false);
}
function testMultilineUnwantedSearch() {
$expectation = new NoHttpHeaderExpectation('a');
$this->assertIdentical($expectation->test("aa:A\r\nb:B\r\nc:C"), true);
$this->assertIdentical($expectation->test("aa:A\r\na:A\r\nb:B"), false);
}
function testLocationHeaderSplitsCorrectly() {
$expectation = new HttpHeaderExpectation('Location', 'http://here/');
$this->assertIdentical($expectation->test('Location: http://here/'), true);
}
}
class TestOfTextExpectations extends UnitTestCase {
function testMatchingSubString() {
$expectation = new TextExpectation('wanted');
$this->assertIdentical($expectation->test(''), false);
$this->assertIdentical($expectation->test('Wanted'), false);
$this->assertIdentical($expectation->test('wanted'), true);
$this->assertIdentical($expectation->test('the wanted text is here'), true);
}
function testNotMatchingSubString() {
$expectation = new NoTextExpectation('wanted');
$this->assertIdentical($expectation->test(''), true);
$this->assertIdentical($expectation->test('Wanted'), true);
$this->assertIdentical($expectation->test('wanted'), false);
$this->assertIdentical($expectation->test('the wanted text is here'), false);
}
}
class TestOfGenericAssertionsInWebTester extends WebTestCase {
function testEquality() {
$this->assertEqual('a', 'a');
$this->assertNotEqual('a', 'A');
}
}
?> | 10npsite | trunk/simpletest/test/web_tester_test.php | PHP | asf20 | 6,800 |
<?php
// $Id: unit_tests.php 1986 2010-04-02 10:02:42Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../unit_tester.php');
require_once(dirname(__FILE__) . '/../shell_tester.php');
require_once(dirname(__FILE__) . '/../mock_objects.php');
require_once(dirname(__FILE__) . '/../web_tester.php');
require_once(dirname(__FILE__) . '/../extensions/pear_test_case.php');
class UnitTests extends TestSuite {
function UnitTests() {
$this->TestSuite('Unit tests');
$path = dirname(__FILE__);
$this->addFile($path . '/errors_test.php');
$this->addFile($path . '/exceptions_test.php');
$this->addFile($path . '/arguments_test.php');
$this->addFile($path . '/autorun_test.php');
$this->addFile($path . '/compatibility_test.php');
$this->addFile($path . '/simpletest_test.php');
$this->addFile($path . '/dumper_test.php');
$this->addFile($path . '/expectation_test.php');
$this->addFile($path . '/unit_tester_test.php');
$this->addFile($path . '/reflection_php5_test.php');
$this->addFile($path . '/mock_objects_test.php');
$this->addFile($path . '/interfaces_test.php');
$this->addFile($path . '/collector_test.php');
$this->addFile($path . '/recorder_test.php');
$this->addFile($path . '/adapter_test.php');
$this->addFile($path . '/socket_test.php');
$this->addFile($path . '/encoding_test.php');
$this->addFile($path . '/url_test.php');
$this->addFile($path . '/cookies_test.php');
$this->addFile($path . '/http_test.php');
$this->addFile($path . '/authentication_test.php');
$this->addFile($path . '/user_agent_test.php');
$this->addFile($path . '/php_parser_test.php');
$this->addFile($path . '/parsing_test.php');
$this->addFile($path . '/tag_test.php');
$this->addFile($path . '/form_test.php');
$this->addFile($path . '/page_test.php');
$this->addFile($path . '/frames_test.php');
$this->addFile($path . '/browser_test.php');
$this->addFile($path . '/web_tester_test.php');
$this->addFile($path . '/shell_tester_test.php');
$this->addFile($path . '/xml_test.php');
$this->addFile($path . '/../extensions/testdox/test.php');
}
}
?> | 10npsite | trunk/simpletest/test/unit_tests.php | PHP | asf20 | 2,370 |
<?php
// $Id: collector_test.php 1769 2008-04-19 14:39:00Z pp11 $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../collector.php');
SimpleTest::ignore('MockTestSuite');
Mock::generate('TestSuite');
class PathEqualExpectation extends EqualExpectation {
function __construct($value, $message = '%s') {
parent::__construct(str_replace("\\", '/', $value), $message);
}
function test($compare) {
return parent::test(str_replace("\\", '/', $compare));
}
}
class TestOfCollector extends UnitTestCase {
function testCollectionIsAddedToGroup() {
$suite = new MockTestSuite();
$suite->expectMinimumCallCount('addFile', 2);
$suite->expect(
'addFile',
array(new PatternExpectation('/collectable\\.(1|2)$/')));
$collector = new SimpleCollector();
$collector->collect($suite, dirname(__FILE__) . '/support/collector/');
}
}
class TestOfPatternCollector extends UnitTestCase {
function testAddingEverythingToGroup() {
$suite = new MockTestSuite();
$suite->expectCallCount('addFile', 2);
$suite->expect(
'addFile',
array(new PatternExpectation('/collectable\\.(1|2)$/')));
$collector = new SimplePatternCollector('/.*/');
$collector->collect($suite, dirname(__FILE__) . '/support/collector/');
}
function testOnlyMatchedFilesAreAddedToGroup() {
$suite = new MockTestSuite();
$suite->expectOnce('addFile', array(new PathEqualExpectation(
dirname(__FILE__) . '/support/collector/collectable.1')));
$collector = new SimplePatternCollector('/1$/');
$collector->collect($suite, dirname(__FILE__) . '/support/collector/');
}
}
?> | 10npsite | trunk/simpletest/test/collector_test.php | PHP | asf20 | 1,788 |
<?php
// $Id: detached_test.php 1884 2009-07-01 16:30:40Z lastcraft $
require_once('../detached.php');
require_once('../reporter.php');
// The following URL will depend on your own installation.
$command = 'php ' . dirname(__FILE__) . '/visual_test.php xml';
$test = new TestSuite('Remote tests');
$test->add(new DetachedTestCase($command));
if (SimpleReporter::inCli()) {
exit ($test->run(new TextReporter()) ? 0 : 1);
}
$test->run(new HtmlReporter());
?> | 10npsite | trunk/simpletest/test/detached_test.php | PHP | asf20 | 462 |
<?php
// $Id: url_test.php 1998 2010-07-27 09:55:55Z pp11 $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../url.php');
class TestOfUrl extends UnitTestCase {
function testDefaultUrl() {
$url = new SimpleUrl('');
$this->assertEqual($url->getScheme(), '');
$this->assertEqual($url->getHost(), '');
$this->assertEqual($url->getScheme('http'), 'http');
$this->assertEqual($url->getHost('localhost'), 'localhost');
$this->assertEqual($url->getPath(), '');
}
function testBasicParsing() {
$url = new SimpleUrl('https://www.lastcraft.com/test/');
$this->assertEqual($url->getScheme(), 'https');
$this->assertEqual($url->getHost(), 'www.lastcraft.com');
$this->assertEqual($url->getPath(), '/test/');
}
function testRelativeUrls() {
$url = new SimpleUrl('../somewhere.php');
$this->assertEqual($url->getScheme(), false);
$this->assertEqual($url->getHost(), false);
$this->assertEqual($url->getPath(), '../somewhere.php');
}
function testParseBareParameter() {
$url = new SimpleUrl('?a');
$this->assertEqual($url->getPath(), '');
$this->assertEqual($url->getEncodedRequest(), '?a');
$url->addRequestParameter('x', 'X');
$this->assertEqual($url->getEncodedRequest(), '?a=&x=X');
}
function testParseEmptyParameter() {
$url = new SimpleUrl('?a=');
$this->assertEqual($url->getPath(), '');
$this->assertEqual($url->getEncodedRequest(), '?a=');
$url->addRequestParameter('x', 'X');
$this->assertEqual($url->getEncodedRequest(), '?a=&x=X');
}
function testParseParameterPair() {
$url = new SimpleUrl('?a=A');
$this->assertEqual($url->getPath(), '');
$this->assertEqual($url->getEncodedRequest(), '?a=A');
$url->addRequestParameter('x', 'X');
$this->assertEqual($url->getEncodedRequest(), '?a=A&x=X');
}
function testParseMultipleParameters() {
$url = new SimpleUrl('?a=A&b=B');
$this->assertEqual($url->getEncodedRequest(), '?a=A&b=B');
$url->addRequestParameter('x', 'X');
$this->assertEqual($url->getEncodedRequest(), '?a=A&b=B&x=X');
}
function testParsingParameterMixture() {
$url = new SimpleUrl('?a=A&b=&c');
$this->assertEqual($url->getEncodedRequest(), '?a=A&b=&c');
$url->addRequestParameter('x', 'X');
$this->assertEqual($url->getEncodedRequest(), '?a=A&b=&c=&x=X');
}
function testAddParametersFromScratch() {
$url = new SimpleUrl('');
$url->addRequestParameter('a', 'A');
$this->assertEqual($url->getEncodedRequest(), '?a=A');
$url->addRequestParameter('b', 'B');
$this->assertEqual($url->getEncodedRequest(), '?a=A&b=B');
$url->addRequestParameter('a', 'aaa');
$this->assertEqual($url->getEncodedRequest(), '?a=A&b=B&a=aaa');
}
function testClearingParameters() {
$url = new SimpleUrl('');
$url->addRequestParameter('a', 'A');
$url->clearRequest();
$this->assertIdentical($url->getEncodedRequest(), '');
}
function testEncodingParameters() {
$url = new SimpleUrl('');
$url->addRequestParameter('a', '?!"\'#~@[]{}:;<>,./|$%^&*()_+-=');
$this->assertIdentical(
$request = $url->getEncodedRequest(),
'?a=%3F%21%22%27%23%7E%40%5B%5D%7B%7D%3A%3B%3C%3E%2C.%2F%7C%24%25%5E%26%2A%28%29_%2B-%3D');
}
function testDecodingParameters() {
$url = new SimpleUrl('?a=%3F%21%22%27%23%7E%40%5B%5D%7B%7D%3A%3B%3C%3E%2C.%2F%7C%24%25%5E%26%2A%28%29_%2B-%3D');
$this->assertEqual(
$url->getEncodedRequest(),
'?a=' . urlencode('?!"\'#~@[]{}:;<>,./|$%^&*()_+-='));
}
function testUrlInQueryDoesNotConfuseParsing() {
$url = new SimpleUrl('wibble/login.php?url=http://www.google.com/moo/');
$this->assertFalse($url->getScheme());
$this->assertFalse($url->getHost());
$this->assertEqual($url->getPath(), 'wibble/login.php');
$this->assertEqual($url->getEncodedRequest(), '?url=http://www.google.com/moo/');
}
function testSettingCordinates() {
$url = new SimpleUrl('');
$url->setCoordinates('32', '45');
$this->assertIdentical($url->getX(), 32);
$this->assertIdentical($url->getY(), 45);
$this->assertEqual($url->getEncodedRequest(), '');
}
function testParseCordinates() {
$url = new SimpleUrl('?32,45');
$this->assertIdentical($url->getX(), 32);
$this->assertIdentical($url->getY(), 45);
}
function testClearingCordinates() {
$url = new SimpleUrl('?32,45');
$url->setCoordinates();
$this->assertIdentical($url->getX(), false);
$this->assertIdentical($url->getY(), false);
}
function testParsingParameterCordinateMixture() {
$url = new SimpleUrl('?a=A&b=&c?32,45');
$this->assertIdentical($url->getX(), 32);
$this->assertIdentical($url->getY(), 45);
$this->assertEqual($url->getEncodedRequest(), '?a=A&b=&c');
}
function testParsingParameterWithBadCordinates() {
$url = new SimpleUrl('?a=A&b=&c?32');
$this->assertIdentical($url->getX(), false);
$this->assertIdentical($url->getY(), false);
$this->assertEqual($url->getEncodedRequest(), '?a=A&b=&c?32');
}
function testPageSplitting() {
$url = new SimpleUrl('./here/../there/somewhere.php');
$this->assertEqual($url->getPath(), './here/../there/somewhere.php');
$this->assertEqual($url->getPage(), 'somewhere.php');
$this->assertEqual($url->getBasePath(), './here/../there/');
}
function testAbsolutePathPageSplitting() {
$url = new SimpleUrl("http://host.com/here/there/somewhere.php");
$this->assertEqual($url->getPath(), "/here/there/somewhere.php");
$this->assertEqual($url->getPage(), "somewhere.php");
$this->assertEqual($url->getBasePath(), "/here/there/");
}
function testSplittingUrlWithNoPageGivesEmptyPage() {
$url = new SimpleUrl('/here/there/');
$this->assertEqual($url->getPath(), '/here/there/');
$this->assertEqual($url->getPage(), '');
$this->assertEqual($url->getBasePath(), '/here/there/');
}
function testPathNormalisation() {
$url = new SimpleUrl();
$this->assertEqual(
$url->normalisePath('https://host.com/I/am/here/../there/somewhere.php'),
'https://host.com/I/am/there/somewhere.php');
}
// regression test for #1535407
function testPathNormalisationWithSinglePeriod() {
$url = new SimpleUrl();
$this->assertEqual(
$url->normalisePath('https://host.com/I/am/here/./../there/somewhere.php'),
'https://host.com/I/am/there/somewhere.php');
}
// regression test for #1852413
function testHostnameExtractedFromUContainingAtSign() {
$url = new SimpleUrl("http://localhost/name@example.com");
$this->assertEqual($url->getScheme(), "http");
$this->assertEqual($url->getUsername(), "");
$this->assertEqual($url->getPassword(), "");
$this->assertEqual($url->getHost(), "localhost");
$this->assertEqual($url->getPath(), "/name@example.com");
}
function testHostnameInLocalhost() {
$url = new SimpleUrl("http://localhost/name/example.com");
$this->assertEqual($url->getScheme(), "http");
$this->assertEqual($url->getUsername(), "");
$this->assertEqual($url->getPassword(), "");
$this->assertEqual($url->getHost(), "localhost");
$this->assertEqual($url->getPath(), "/name/example.com");
}
function testUsernameAndPasswordAreUrlDecoded() {
$url = new SimpleUrl('http://' . urlencode('test@test') .
':' . urlencode('$!�@*&%') . '@www.lastcraft.com');
$this->assertEqual($url->getUsername(), 'test@test');
$this->assertEqual($url->getPassword(), '$!�@*&%');
}
function testBlitz() {
$this->assertUrl(
"https://username:password@www.somewhere.com:243/this/that/here.php?a=1&b=2#anchor",
array("https", "username", "password", "www.somewhere.com", 243, "/this/that/here.php", "com", "?a=1&b=2", "anchor"),
array("a" => "1", "b" => "2"));
$this->assertUrl(
"username:password@www.somewhere.com/this/that/here.php?a=1",
array(false, "username", "password", "www.somewhere.com", false, "/this/that/here.php", "com", "?a=1", false),
array("a" => "1"));
$this->assertUrl(
"username:password@somewhere.com:243?1,2",
array(false, "username", "password", "somewhere.com", 243, "/", "com", "", false),
array(),
array(1, 2));
$this->assertUrl(
"https://www.somewhere.com",
array("https", false, false, "www.somewhere.com", false, "/", "com", "", false));
$this->assertUrl(
"username@www.somewhere.com:243#anchor",
array(false, "username", false, "www.somewhere.com", 243, "/", "com", "", "anchor"));
$this->assertUrl(
"/this/that/here.php?a=1&b=2?3,4",
array(false, false, false, false, false, "/this/that/here.php", false, "?a=1&b=2", false),
array("a" => "1", "b" => "2"),
array(3, 4));
$this->assertUrl(
"username@/here.php?a=1&b=2",
array(false, "username", false, false, false, "/here.php", false, "?a=1&b=2", false),
array("a" => "1", "b" => "2"));
}
function testAmbiguousHosts() {
$this->assertUrl(
"tigger",
array(false, false, false, false, false, "tigger", false, "", false));
$this->assertUrl(
"/tigger",
array(false, false, false, false, false, "/tigger", false, "", false));
$this->assertUrl(
"//tigger",
array(false, false, false, "tigger", false, "/", false, "", false));
$this->assertUrl(
"//tigger/",
array(false, false, false, "tigger", false, "/", false, "", false));
$this->assertUrl(
"tigger.com",
array(false, false, false, "tigger.com", false, "/", "com", "", false));
$this->assertUrl(
"me.net/tigger",
array(false, false, false, "me.net", false, "/tigger", "net", "", false));
}
function testAsString() {
$this->assertPreserved('https://www.here.com');
$this->assertPreserved('http://me:secret@www.here.com');
$this->assertPreserved('http://here/there');
$this->assertPreserved('http://here/there?a=A&b=B');
$this->assertPreserved('http://here/there?a=1&a=2');
$this->assertPreserved('http://here/there?a=1&a=2?9,8');
$this->assertPreserved('http://host?a=1&a=2');
$this->assertPreserved('http://host#stuff');
$this->assertPreserved('http://me:secret@www.here.com/a/b/c/here.html?a=A?7,6');
$this->assertPreserved('http://www.here.com/?a=A__b=B');
$this->assertPreserved('http://www.example.com:8080/');
}
function testUrlWithTwoSlashesInPath() {
$url = new SimpleUrl('/article/categoryedit/insert//');
$this->assertEqual($url->getPath(), '/article/categoryedit/insert//');
}
function testUrlWithRequestKeyEncoded() {
$url = new SimpleUrl('/?foo%5B1%5D=bar');
$this->assertEqual($url->getEncodedRequest(), '?foo%5B1%5D=bar');
$url->addRequestParameter('a[1]', 'b[]');
$this->assertEqual($url->getEncodedRequest(), '?foo%5B1%5D=bar&a%5B1%5D=b%5B%5D');
$url = new SimpleUrl('/');
$url->addRequestParameter('a[1]', 'b[]');
$this->assertEqual($url->getEncodedRequest(), '?a%5B1%5D=b%5B%5D');
}
function testUrlWithRequestKeyEncodedAndParamNamLookingLikePair() {
$url = new SimpleUrl('/');
$url->addRequestParameter('foo[]=bar', '');
$this->assertEqual($url->getEncodedRequest(), '?foo%5B%5D%3Dbar=');
$url = new SimpleUrl('/?foo%5B%5D%3Dbar=');
$this->assertEqual($url->getEncodedRequest(), '?foo%5B%5D%3Dbar=');
}
function assertUrl($raw, $parts, $params = false, $coords = false) {
if (! is_array($params)) {
$params = array();
}
$url = new SimpleUrl($raw);
$this->assertIdentical($url->getScheme(), $parts[0], "[$raw] scheme -> %s");
$this->assertIdentical($url->getUsername(), $parts[1], "[$raw] username -> %s");
$this->assertIdentical($url->getPassword(), $parts[2], "[$raw] password -> %s");
$this->assertIdentical($url->getHost(), $parts[3], "[$raw] host -> %s");
$this->assertIdentical($url->getPort(), $parts[4], "[$raw] port -> %s");
$this->assertIdentical($url->getPath(), $parts[5], "[$raw] path -> %s");
$this->assertIdentical($url->getTld(), $parts[6], "[$raw] tld -> %s");
$this->assertIdentical($url->getEncodedRequest(), $parts[7], "[$raw] encoded -> %s");
$this->assertIdentical($url->getFragment(), $parts[8], "[$raw] fragment -> %s");
if ($coords) {
$this->assertIdentical($url->getX(), $coords[0], "[$raw] x -> %s");
$this->assertIdentical($url->getY(), $coords[1], "[$raw] y -> %s");
}
}
function assertPreserved($string) {
$url = new SimpleUrl($string);
$this->assertEqual($url->asString(), $string);
}
}
class TestOfAbsoluteUrls extends UnitTestCase {
function testDirectoriesAfterFilename() {
$string = '../../index.php/foo/bar';
$url = new SimpleUrl($string);
$this->assertEqual($url->asString(), $string);
$absolute = $url->makeAbsolute('http://www.domain.com/some/path/');
$this->assertEqual($absolute->asString(), 'http://www.domain.com/index.php/foo/bar');
}
function testMakingAbsolute() {
$url = new SimpleUrl('../there/somewhere.php');
$this->assertEqual($url->getPath(), '../there/somewhere.php');
$absolute = $url->makeAbsolute('https://host.com:1234/I/am/here/');
$this->assertEqual($absolute->getScheme(), 'https');
$this->assertEqual($absolute->getHost(), 'host.com');
$this->assertEqual($absolute->getPort(), 1234);
$this->assertEqual($absolute->getPath(), '/I/am/there/somewhere.php');
}
function testMakingAnEmptyUrlAbsolute() {
$url = new SimpleUrl('');
$this->assertEqual($url->getPath(), '');
$absolute = $url->makeAbsolute('http://host.com/I/am/here/page.html');
$this->assertEqual($absolute->getScheme(), 'http');
$this->assertEqual($absolute->getHost(), 'host.com');
$this->assertEqual($absolute->getPath(), '/I/am/here/page.html');
}
function testMakingAnEmptyUrlAbsoluteWithMissingPageName() {
$url = new SimpleUrl('');
$this->assertEqual($url->getPath(), '');
$absolute = $url->makeAbsolute('http://host.com/I/am/here/');
$this->assertEqual($absolute->getScheme(), 'http');
$this->assertEqual($absolute->getHost(), 'host.com');
$this->assertEqual($absolute->getPath(), '/I/am/here/');
}
function testMakingAShortQueryUrlAbsolute() {
$url = new SimpleUrl('?a#b');
$this->assertEqual($url->getPath(), '');
$absolute = $url->makeAbsolute('http://host.com/I/am/here/');
$this->assertEqual($absolute->getScheme(), 'http');
$this->assertEqual($absolute->getHost(), 'host.com');
$this->assertEqual($absolute->getPath(), '/I/am/here/');
$this->assertEqual($absolute->getEncodedRequest(), '?a');
$this->assertEqual($absolute->getFragment(), 'b');
}
function testMakingADirectoryUrlAbsolute() {
$url = new SimpleUrl('hello/');
$this->assertEqual($url->getPath(), 'hello/');
$this->assertEqual($url->getBasePath(), 'hello/');
$this->assertEqual($url->getPage(), '');
$absolute = $url->makeAbsolute('http://host.com/I/am/here/page.html');
$this->assertEqual($absolute->getPath(), '/I/am/here/hello/');
}
function testMakingARootUrlAbsolute() {
$url = new SimpleUrl('/');
$this->assertEqual($url->getPath(), '/');
$absolute = $url->makeAbsolute('http://host.com/I/am/here/page.html');
$this->assertEqual($absolute->getPath(), '/');
}
function testMakingARootPageUrlAbsolute() {
$url = new SimpleUrl('/here.html');
$absolute = $url->makeAbsolute('http://host.com/I/am/here/page.html');
$this->assertEqual($absolute->getPath(), '/here.html');
}
function testCarryAuthenticationFromRootPage() {
$url = new SimpleUrl('here.html');
$absolute = $url->makeAbsolute('http://test:secret@host.com/');
$this->assertEqual($absolute->getPath(), '/here.html');
$this->assertEqual($absolute->getUsername(), 'test');
$this->assertEqual($absolute->getPassword(), 'secret');
}
function testMakingCoordinateUrlAbsolute() {
$url = new SimpleUrl('?1,2');
$this->assertEqual($url->getPath(), '');
$absolute = $url->makeAbsolute('http://host.com/I/am/here/');
$this->assertEqual($absolute->getScheme(), 'http');
$this->assertEqual($absolute->getHost(), 'host.com');
$this->assertEqual($absolute->getPath(), '/I/am/here/');
$this->assertEqual($absolute->getX(), 1);
$this->assertEqual($absolute->getY(), 2);
}
function testMakingAbsoluteAppendedPath() {
$url = new SimpleUrl('./there/somewhere.php');
$absolute = $url->makeAbsolute('https://host.com/here/');
$this->assertEqual($absolute->getPath(), '/here/there/somewhere.php');
}
function testMakingAbsoluteBadlyFormedAppendedPath() {
$url = new SimpleUrl('there/somewhere.php');
$absolute = $url->makeAbsolute('https://host.com/here/');
$this->assertEqual($absolute->getPath(), '/here/there/somewhere.php');
}
function testMakingAbsoluteHasNoEffectWhenAlreadyAbsolute() {
$url = new SimpleUrl('https://test:secret@www.lastcraft.com:321/stuff/?a=1#f');
$absolute = $url->makeAbsolute('http://host.com/here/');
$this->assertEqual($absolute->getScheme(), 'https');
$this->assertEqual($absolute->getUsername(), 'test');
$this->assertEqual($absolute->getPassword(), 'secret');
$this->assertEqual($absolute->getHost(), 'www.lastcraft.com');
$this->assertEqual($absolute->getPort(), 321);
$this->assertEqual($absolute->getPath(), '/stuff/');
$this->assertEqual($absolute->getEncodedRequest(), '?a=1');
$this->assertEqual($absolute->getFragment(), 'f');
}
function testMakingAbsoluteCarriesAuthenticationWhenAlreadyAbsolute() {
$url = new SimpleUrl('https://www.lastcraft.com');
$absolute = $url->makeAbsolute('http://test:secret@host.com/here/');
$this->assertEqual($absolute->getHost(), 'www.lastcraft.com');
$this->assertEqual($absolute->getUsername(), 'test');
$this->assertEqual($absolute->getPassword(), 'secret');
}
function testMakingHostOnlyAbsoluteDoesNotCarryAnyOtherInformation() {
$url = new SimpleUrl('http://www.lastcraft.com');
$absolute = $url->makeAbsolute('https://host.com:81/here/');
$this->assertEqual($absolute->getScheme(), 'http');
$this->assertEqual($absolute->getHost(), 'www.lastcraft.com');
$this->assertIdentical($absolute->getPort(), false);
$this->assertEqual($absolute->getPath(), '/');
}
}
class TestOfFrameUrl extends UnitTestCase {
function testTargetAttachment() {
$url = new SimpleUrl('http://www.site.com/home.html');
$this->assertIdentical($url->getTarget(), false);
$url->setTarget('A frame');
$this->assertIdentical($url->getTarget(), 'A frame');
}
}
/**
* @note Based off of http://www.mozilla.org/quality/networking/testing/filetests.html
*/
class TestOfFileUrl extends UnitTestCase {
function testMinimalUrl() {
$url = new SimpleUrl('file:///');
$this->assertEqual($url->getScheme(), 'file');
$this->assertIdentical($url->getHost(), false);
$this->assertEqual($url->getPath(), '/');
}
function testUnixUrl() {
$url = new SimpleUrl('file:///fileInRoot');
$this->assertEqual($url->getScheme(), 'file');
$this->assertIdentical($url->getHost(), false);
$this->assertEqual($url->getPath(), '/fileInRoot');
}
function testDOSVolumeUrl() {
$url = new SimpleUrl('file:///C:/config.sys');
$this->assertEqual($url->getScheme(), 'file');
$this->assertIdentical($url->getHost(), false);
$this->assertEqual($url->getPath(), '/C:/config.sys');
}
function testDOSVolumePromotion() {
$url = new SimpleUrl('file://C:/config.sys');
$this->assertEqual($url->getScheme(), 'file');
$this->assertIdentical($url->getHost(), false);
$this->assertEqual($url->getPath(), '/C:/config.sys');
}
function testDOSBackslashes() {
$url = new SimpleUrl('file:///C:\config.sys');
$this->assertEqual($url->getScheme(), 'file');
$this->assertIdentical($url->getHost(), false);
$this->assertEqual($url->getPath(), '/C:/config.sys');
}
function testDOSDirnameAfterFile() {
$url = new SimpleUrl('file://C:\config.sys');
$this->assertEqual($url->getScheme(), 'file');
$this->assertIdentical($url->getHost(), false);
$this->assertEqual($url->getPath(), '/C:/config.sys');
}
}
?> | 10npsite | trunk/simpletest/test/url_test.php | PHP | asf20 | 22,242 |
<?php
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/support/test1.php');
class TestOfAutorun extends UnitTestCase {
function testLoadIfIncluded() {
$tests = new TestSuite();
$tests->addFile(dirname(__FILE__) . '/support/test1.php');
$this->assertEqual($tests->getSize(), 1);
}
function testExitStatusOneIfTestsFail() {
exec('php ' . dirname(__FILE__) . '/support/failing_test.php', $output, $exit_status);
$this->assertEqual($exit_status, 1);
}
function testExitStatusZeroIfTestsPass() {
exec('php ' . dirname(__FILE__) . '/support/passing_test.php', $output, $exit_status);
$this->assertEqual($exit_status, 0);
}
}
?> | 10npsite | trunk/simpletest/test/autorun_test.php | PHP | asf20 | 766 |
<?php
// $Id: form_test.php 1996 2010-07-27 09:11:59Z pp11 $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../url.php');
require_once(dirname(__FILE__) . '/../form.php');
require_once(dirname(__FILE__) . '/../page.php');
require_once(dirname(__FILE__) . '/../encoding.php');
Mock::generate('SimplePage');
class TestOfForm extends UnitTestCase {
function page($url, $action = false) {
$page = new MockSimplePage();
$page->returns('getUrl', new SimpleUrl($url));
$page->returns('expandUrl', new SimpleUrl($url));
return $page;
}
function testFormAttributes() {
$tag = new SimpleFormTag(array('method' => 'GET', 'action' => 'here.php', 'id' => '33'));
$form = new SimpleForm($tag, $this->page('http://host/a/index.html'));
$this->assertEqual($form->getMethod(), 'get');
$this->assertIdentical($form->getId(), '33');
$this->assertNull($form->getValue(new SimpleByName('a')));
}
function testAction() {
$page = new MockSimplePage();
$page->expectOnce('expandUrl', array(new SimpleUrl('here.php')));
$page->setReturnValue('expandUrl', new SimpleUrl('http://host/here.php'));
$tag = new SimpleFormTag(array('method' => 'GET', 'action' => 'here.php'));
$form = new SimpleForm($tag, $page);
$this->assertEqual($form->getAction(), new SimpleUrl('http://host/here.php'));
}
function testEmptyAction() {
$tag = new SimpleFormTag(array('method' => 'GET', 'action' => '', 'id' => '33'));
$form = new SimpleForm($tag, $this->page('http://host/a/index.html'));
$this->assertEqual(
$form->getAction(),
new SimpleUrl('http://host/a/index.html'));
}
function testMissingAction() {
$tag = new SimpleFormTag(array('method' => 'GET'));
$form = new SimpleForm($tag, $this->page('http://host/a/index.html'));
$this->assertEqual(
$form->getAction(),
new SimpleUrl('http://host/a/index.html'));
}
function testRootAction() {
$page = new MockSimplePage();
$page->expectOnce('expandUrl', array(new SimpleUrl('/')));
$page->setReturnValue('expandUrl', new SimpleUrl('http://host/'));
$tag = new SimpleFormTag(array('method' => 'GET', 'action' => '/'));
$form = new SimpleForm($tag, $page);
$this->assertEqual(
$form->getAction(),
new SimpleUrl('http://host/'));
}
function testDefaultFrameTargetOnForm() {
$page = new MockSimplePage();
$page->expectOnce('expandUrl', array(new SimpleUrl('here.php')));
$page->setReturnValue('expandUrl', new SimpleUrl('http://host/here.php'));
$tag = new SimpleFormTag(array('method' => 'GET', 'action' => 'here.php'));
$form = new SimpleForm($tag, $page);
$form->setDefaultTarget('frame');
$expected = new SimpleUrl('http://host/here.php');
$expected->setTarget('frame');
$this->assertEqual($form->getAction(), $expected);
}
function testTextWidget() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$form->addWidget(new SimpleTextTag(
array('name' => 'me', 'type' => 'text', 'value' => 'Myself')));
$this->assertIdentical($form->getValue(new SimpleByName('me')), 'Myself');
$this->assertTrue($form->setField(new SimpleByName('me'), 'Not me'));
$this->assertFalse($form->setField(new SimpleByName('not_present'), 'Not me'));
$this->assertIdentical($form->getValue(new SimpleByName('me')), 'Not me');
$this->assertNull($form->getValue(new SimpleByName('not_present')));
}
function testTextWidgetById() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$form->addWidget(new SimpleTextTag(
array('name' => 'me', 'type' => 'text', 'value' => 'Myself', 'id' => 50)));
$this->assertIdentical($form->getValue(new SimpleById(50)), 'Myself');
$this->assertTrue($form->setField(new SimpleById(50), 'Not me'));
$this->assertIdentical($form->getValue(new SimpleById(50)), 'Not me');
}
function testTextWidgetByLabel() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$widget = new SimpleTextTag(array('name' => 'me', 'type' => 'text', 'value' => 'a'));
$form->addWidget($widget);
$widget->setLabel('thing');
$this->assertIdentical($form->getValue(new SimpleByLabel('thing')), 'a');
$this->assertTrue($form->setField(new SimpleByLabel('thing'), 'b'));
$this->assertIdentical($form->getValue(new SimpleByLabel('thing')), 'b');
}
function testSubmitEmpty() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$this->assertIdentical($form->submit(), new SimpleGetEncoding());
}
function testSubmitButton() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('http://host'));
$form->addWidget(new SimpleSubmitTag(
array('type' => 'submit', 'name' => 'go', 'value' => 'Go!', 'id' => '9')));
$this->assertTrue($form->hasSubmit(new SimpleByName('go')));
$this->assertEqual($form->getValue(new SimpleByName('go')), 'Go!');
$this->assertEqual($form->getValue(new SimpleById(9)), 'Go!');
$this->assertEqual(
$form->submitButton(new SimpleByName('go')),
new SimpleGetEncoding(array('go' => 'Go!')));
$this->assertEqual(
$form->submitButton(new SimpleByLabel('Go!')),
new SimpleGetEncoding(array('go' => 'Go!')));
$this->assertEqual(
$form->submitButton(new SimpleById(9)),
new SimpleGetEncoding(array('go' => 'Go!')));
}
function testSubmitWithAdditionalParameters() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('http://host'));
$form->addWidget(new SimpleSubmitTag(
array('type' => 'submit', 'name' => 'go', 'value' => 'Go!')));
$this->assertEqual(
$form->submitButton(new SimpleByLabel('Go!'), array('a' => 'A')),
new SimpleGetEncoding(array('go' => 'Go!', 'a' => 'A')));
}
function testSubmitButtonWithLabelOfSubmit() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('http://host'));
$form->addWidget(new SimpleSubmitTag(
array('type' => 'submit', 'name' => 'test', 'value' => 'Submit')));
$this->assertEqual(
$form->submitButton(new SimpleByName('test')),
new SimpleGetEncoding(array('test' => 'Submit')));
$this->assertEqual(
$form->submitButton(new SimpleByLabel('Submit')),
new SimpleGetEncoding(array('test' => 'Submit')));
}
function testSubmitButtonWithWhitespacePaddedLabelOfSubmit() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('http://host'));
$form->addWidget(new SimpleSubmitTag(
array('type' => 'submit', 'name' => 'test', 'value' => ' Submit ')));
$this->assertEqual(
$form->submitButton(new SimpleByLabel('Submit')),
new SimpleGetEncoding(array('test' => ' Submit ')));
}
function testImageSubmitButton() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$form->addWidget(new SimpleImageSubmitTag(array(
'type' => 'image',
'src' => 'source.jpg',
'name' => 'go',
'alt' => 'Go!',
'id' => '9')));
$this->assertTrue($form->hasImage(new SimpleByLabel('Go!')));
$this->assertEqual(
$form->submitImage(new SimpleByLabel('Go!'), 100, 101),
new SimpleGetEncoding(array('go.x' => 100, 'go.y' => 101)));
$this->assertTrue($form->hasImage(new SimpleByName('go')));
$this->assertEqual(
$form->submitImage(new SimpleByName('go'), 100, 101),
new SimpleGetEncoding(array('go.x' => 100, 'go.y' => 101)));
$this->assertTrue($form->hasImage(new SimpleById(9)));
$this->assertEqual(
$form->submitImage(new SimpleById(9), 100, 101),
new SimpleGetEncoding(array('go.x' => 100, 'go.y' => 101)));
}
function testImageSubmitButtonWithAdditionalData() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$form->addWidget(new SimpleImageSubmitTag(array(
'type' => 'image',
'src' => 'source.jpg',
'name' => 'go',
'alt' => 'Go!')));
$this->assertEqual(
$form->submitImage(new SimpleByLabel('Go!'), 100, 101, array('a' => 'A')),
new SimpleGetEncoding(array('go.x' => 100, 'go.y' => 101, 'a' => 'A')));
}
function testButtonTag() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('http://host'));
$widget = new SimpleButtonTag(
array('type' => 'submit', 'name' => 'go', 'value' => 'Go', 'id' => '9'));
$widget->addContent('Go!');
$form->addWidget($widget);
$this->assertTrue($form->hasSubmit(new SimpleByName('go')));
$this->assertTrue($form->hasSubmit(new SimpleByLabel('Go!')));
$this->assertEqual(
$form->submitButton(new SimpleByName('go')),
new SimpleGetEncoding(array('go' => 'Go')));
$this->assertEqual(
$form->submitButton(new SimpleByLabel('Go!')),
new SimpleGetEncoding(array('go' => 'Go')));
$this->assertEqual(
$form->submitButton(new SimpleById(9)),
new SimpleGetEncoding(array('go' => 'Go')));
}
function testMultipleFieldsWithSameNameSubmitted() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$input = new SimpleTextTag(array('name' => 'elements[]', 'value' => '1'));
$form->addWidget($input);
$input = new SimpleTextTag(array('name' => 'elements[]', 'value' => '2'));
$form->addWidget($input);
$form->setField(new SimpleByLabelOrName('elements[]'), '3', 1);
$form->setField(new SimpleByLabelOrName('elements[]'), '4', 2);
$submit = $form->submit();
$requests = $submit->getAll();
$this->assertEqual(count($requests), 2);
$this->assertIdentical($requests[0], new SimpleEncodedPair('elements[]', '3'));
$this->assertIdentical($requests[1], new SimpleEncodedPair('elements[]', '4'));
}
function testSingleSelectFieldSubmitted() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$select = new SimpleSelectionTag(array('name' => 'a'));
$select->addTag(new SimpleOptionTag(
array('value' => 'aaa', 'selected' => '')));
$form->addWidget($select);
$this->assertIdentical(
$form->submit(),
new SimpleGetEncoding(array('a' => 'aaa')));
}
function testSingleSelectFieldSubmittedWithPost() {
$form = new SimpleForm(new SimpleFormTag(array('method' => 'post')), $this->page('htp://host'));
$select = new SimpleSelectionTag(array('name' => 'a'));
$select->addTag(new SimpleOptionTag(
array('value' => 'aaa', 'selected' => '')));
$form->addWidget($select);
$this->assertIdentical(
$form->submit(),
new SimplePostEncoding(array('a' => 'aaa')));
}
function testUnchecked() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$form->addWidget(new SimpleCheckboxTag(
array('name' => 'me', 'type' => 'checkbox')));
$this->assertIdentical($form->getValue(new SimpleByName('me')), false);
$this->assertTrue($form->setField(new SimpleByName('me'), 'on'));
$this->assertEqual($form->getValue(new SimpleByName('me')), 'on');
$this->assertFalse($form->setField(new SimpleByName('me'), 'other'));
$this->assertEqual($form->getValue(new SimpleByName('me')), 'on');
}
function testChecked() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$form->addWidget(new SimpleCheckboxTag(
array('name' => 'me', 'value' => 'a', 'type' => 'checkbox', 'checked' => '')));
$this->assertIdentical($form->getValue(new SimpleByName('me')), 'a');
$this->assertTrue($form->setField(new SimpleByName('me'), 'a'));
$this->assertEqual($form->getValue(new SimpleByName('me')), 'a');
$this->assertTrue($form->setField(new SimpleByName('me'), false));
$this->assertEqual($form->getValue(new SimpleByName('me')), false);
}
function testSingleUncheckedRadioButton() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$form->addWidget(new SimpleRadioButtonTag(
array('name' => 'me', 'value' => 'a', 'type' => 'radio')));
$this->assertIdentical($form->getValue(new SimpleByName('me')), false);
$this->assertTrue($form->setField(new SimpleByName('me'), 'a'));
$this->assertEqual($form->getValue(new SimpleByName('me')), 'a');
}
function testSingleCheckedRadioButton() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$form->addWidget(new SimpleRadioButtonTag(
array('name' => 'me', 'value' => 'a', 'type' => 'radio', 'checked' => '')));
$this->assertIdentical($form->getValue(new SimpleByName('me')), 'a');
$this->assertFalse($form->setField(new SimpleByName('me'), 'other'));
}
function testUncheckedRadioButtons() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$form->addWidget(new SimpleRadioButtonTag(
array('name' => 'me', 'value' => 'a', 'type' => 'radio')));
$form->addWidget(new SimpleRadioButtonTag(
array('name' => 'me', 'value' => 'b', 'type' => 'radio')));
$this->assertIdentical($form->getValue(new SimpleByName('me')), false);
$this->assertTrue($form->setField(new SimpleByName('me'), 'a'));
$this->assertIdentical($form->getValue(new SimpleByName('me')), 'a');
$this->assertTrue($form->setField(new SimpleByName('me'), 'b'));
$this->assertIdentical($form->getValue(new SimpleByName('me')), 'b');
$this->assertFalse($form->setField(new SimpleByName('me'), 'c'));
$this->assertIdentical($form->getValue(new SimpleByName('me')), 'b');
}
function testCheckedRadioButtons() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$form->addWidget(new SimpleRadioButtonTag(
array('name' => 'me', 'value' => 'a', 'type' => 'radio')));
$form->addWidget(new SimpleRadioButtonTag(
array('name' => 'me', 'value' => 'b', 'type' => 'radio', 'checked' => '')));
$this->assertIdentical($form->getValue(new SimpleByName('me')), 'b');
$this->assertTrue($form->setField(new SimpleByName('me'), 'a'));
$this->assertIdentical($form->getValue(new SimpleByName('me')), 'a');
}
function testMultipleFieldsWithSameKey() {
$form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
$form->addWidget(new SimpleCheckboxTag(
array('name' => 'a', 'type' => 'checkbox', 'value' => 'me')));
$form->addWidget(new SimpleCheckboxTag(
array('name' => 'a', 'type' => 'checkbox', 'value' => 'you')));
$this->assertIdentical($form->getValue(new SimpleByName('a')), false);
$this->assertTrue($form->setField(new SimpleByName('a'), 'me'));
$this->assertIdentical($form->getValue(new SimpleByName('a')), 'me');
}
function testRemoveGetParamsFromAction() {
Mock::generatePartial('SimplePage', 'MockPartialSimplePage', array('getUrl'));
$page = new MockPartialSimplePage();
$page->returns('getUrl', new SimpleUrl('htp://host/'));
# Keep GET params in "action", if the form has no widgets
$form = new SimpleForm(new SimpleFormTag(array('action'=>'?test=1')), $page);
$this->assertEqual($form->getAction()->asString(), 'htp://host/');
$form = new SimpleForm(new SimpleFormTag(array('action'=>'?test=1')), $page);
$form->addWidget(new SimpleTextTag(array('name' => 'me', 'type' => 'text', 'value' => 'a')));
$this->assertEqual($form->getAction()->asString(), 'htp://host/');
$form = new SimpleForm(new SimpleFormTag(array('action'=>'')), $page);
$this->assertEqual($form->getAction()->asString(), 'htp://host/');
$form = new SimpleForm(new SimpleFormTag(array('action'=>'?test=1', 'method'=>'post')), $page);
$this->assertEqual($form->getAction()->asString(), 'htp://host/?test=1');
}
}
?> | 10npsite | trunk/simpletest/test/form_test.php | PHP | asf20 | 17,460 |
<?php
// $Id: page_test.php 1912 2009-07-29 16:39:17Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../page.php');
require_once(dirname(__FILE__) . '/../php_parser.php');
require_once(dirname(__FILE__) . '/../tidy_parser.php');
Mock::generate('SimpleHttpResponse');
abstract class TestOfParsing extends UnitTestCase {
function testRawAccessor() {
$page = $this->whenVisiting('http://host/', 'Raw HTML');
$this->assertEqual($page->getRaw(), 'Raw HTML');
}
function testTextAccessor() {
$page = $this->whenVisiting('http://host/', '<b>Some</b> "messy" HTML');
$this->assertEqual($page->getText(), 'Some "messy" HTML');
}
function testFramesetAbsence() {
$page = $this->whenVisiting('http://here/', '');
$this->assertFalse($page->hasFrames());
$this->assertIdentical($page->getFrameset(), false);
}
function testPageWithNoUrlsGivesEmptyArrayOfLinks() {
$page = $this->whenVisiting('http://here/', '<html><body><p>Stuff</p></body></html>');
$this->assertIdentical($page->getUrls(), array());
}
function testAddAbsoluteLink() {
$page = $this->whenVisiting('http://host',
'<html><a href="http://somewhere.com">Label</a></html>');
$this->assertEqual(
$page->getUrlsByLabel('Label'),
array(new SimpleUrl('http://somewhere.com')));
}
function testUrlLabelsHaveHtmlTagsStripped() {
$page = $this->whenVisiting('http://host',
'<html><a href="http://somewhere.com"><b>Label</b></a></html>');
$this->assertEqual(
$page->getUrlsByLabel('Label'),
array(new SimpleUrl('http://somewhere.com')));
}
function testAddStrictRelativeLink() {
$page = $this->whenVisiting('http://host',
'<html><a href="./somewhere.php">Label</a></html>');
$this->assertEqual(
$page->getUrlsByLabel('Label'),
array(new SimpleUrl('http://host/somewhere.php')));
}
function testAddBareRelativeLink() {
$page = $this->whenVisiting('http://host',
'<html><a href="somewhere.php">Label</a></html>');
$this->assertEqual(
$page->getUrlsByLabel('Label'),
array(new SimpleUrl('http://host/somewhere.php')));
}
function testAddRelativeLinkWithBaseTag() {
$raw = '<html><head><base href="http://www.lastcraft.com/stuff/"></head>' .
'<body><a href="somewhere.php">Label</a></body>' .
'</html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual(
$page->getUrlsByLabel('Label'),
array(new SimpleUrl('http://www.lastcraft.com/stuff/somewhere.php')));
}
function testAddAbsoluteLinkWithBaseTag() {
$raw = '<html><head><base href="http://www.lastcraft.com/stuff/"></head>' .
'<body><a href="http://here.com/somewhere.php">Label</a></body>' .
'</html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual(
$page->getUrlsByLabel('Label'),
array(new SimpleUrl('http://here.com/somewhere.php')));
}
function testCanFindLinkInsideForm() {
$raw = '<html><body><form><a href="./somewhere.php">Label</a></form></body></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual(
$page->getUrlsByLabel('Label'),
array(new SimpleUrl('http://host/somewhere.php')));
}
function testCanGetLinksByIdOrLabel() {
$raw = '<html><body><a href="./somewhere.php" id="33">Label</a></body></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual(
$page->getUrlsByLabel('Label'),
array(new SimpleUrl('http://host/somewhere.php')));
$this->assertFalse($page->getUrlById(0));
$this->assertEqual(
$page->getUrlById(33),
new SimpleUrl('http://host/somewhere.php'));
}
function testCanFindLinkByNormalisedLabel() {
$raw = '<html><body><a href="./somewhere.php" id="33"><em>Long & thin</em></a></body></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual(
$page->getUrlsByLabel('Long & thin'),
array(new SimpleUrl('http://host/somewhere.php')));
}
function testCanFindLinkByImageAltText() {
$raw = '<a href="./somewhere.php" id="33"><img src="pic.jpg" alt="<A picture>"></a>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual(
array_map(array($this, 'urlToString'), $page->getUrlsByLabel('<A picture>')),
array('http://host/somewhere.php'));
}
function testTitle() {
$page = $this->whenVisiting('http://host',
'<html><head><title>Me</title></head></html>');
$this->assertEqual($page->getTitle(), 'Me');
}
function testTitleWithEntityReference() {
$page = $this->whenVisiting('http://host',
'<html><head><Title>Me&Me</TITLE></head></html>');
$this->assertEqual($page->getTitle(), "Me&Me");
}
function testOnlyFramesInFramesetAreRecognised() {
$raw =
'<frameset>' .
' <frame src="2.html"></frame>' .
' <frame src="3.html"></frame>' .
'</frameset>' .
'<frame src="4.html"></frame>';
$page = $this->whenVisiting('http://here', $raw);
$this->assertTrue($page->hasFrames());
$this->assertSameFrameset($page->getFrameset(), array(
1 => new SimpleUrl('http://here/2.html'),
2 => new SimpleUrl('http://here/3.html')));
}
function testReadsNamesInFrames() {
$raw =
'<frameset>' .
' <frame src="1.html"></frame>' .
' <frame src="2.html" name="A"></frame>' .
' <frame src="3.html" name="B"></frame>' .
' <frame src="4.html"></frame>' .
'</frameset>';
$page = $this->whenVisiting('http://here', $raw);
$this->assertTrue($page->hasFrames());
$this->assertSameFrameset($page->getFrameset(), array(
1 => new SimpleUrl('http://here/1.html'),
'A' => new SimpleUrl('http://here/2.html'),
'B' => new SimpleUrl('http://here/3.html'),
4 => new SimpleUrl('http://here/4.html')));
}
function testRelativeFramesRespectBaseTag() {
$raw = '<base href="https://there.com/stuff/"><frameset><frame src="1.html"></frameset>';
$page = $this->whenVisiting('http://here', $raw);
$this->assertSameFrameset(
$page->getFrameset(),
array(1 => new SimpleUrl('https://there.com/stuff/1.html')));
}
function testSingleFrameInNestedFrameset() {
$raw = '<html><frameset><frameset>' .
'<frame src="a.html">' .
'</frameset></frameset></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertTrue($page->hasFrames());
$this->assertIdentical(
$page->getFrameset(),
array(1 => new SimpleUrl('http://host/a.html')));
}
function testFramesCollectedWithNestedFramesetTags() {
$raw = '<html><frameset>' .
'<frame src="a.html">' .
'<frameset><frame src="b.html"></frameset>' .
'<frame src="c.html">' .
'</frameset></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertTrue($page->hasFrames());
$this->assertIdentical($page->getFrameset(), array(
1 => new SimpleUrl('http://host/a.html'),
2 => new SimpleUrl('http://host/b.html'),
3 => new SimpleUrl('http://host/c.html')));
}
function testNamedFrames() {
$raw = '<html><frameset>' .
'<frame src="a.html">' .
'<frame name="_one" src="b.html">' .
'<frame src="c.html">' .
'<frame src="d.html" name="_two">' .
'</frameset></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertTrue($page->hasFrames());
$this->assertIdentical($page->getFrameset(), array(
1 => new SimpleUrl('http://host/a.html'),
'_one' => new SimpleUrl('http://host/b.html'),
3 => new SimpleUrl('http://host/c.html'),
'_two' => new SimpleUrl('http://host/d.html')));
}
function testCanReadElementOfCompleteForm() {
$raw = '<html><head><form>' .
'<input type="text" name="here" value="Hello">' .
'</form></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('here')), "Hello");
}
function testCanReadElementOfUnclosedForm() {
$raw = '<html><head><form>' .
'<input type="text" name="here" value="Hello">' .
'</head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('here')), "Hello");
}
function testCanReadElementByLabel() {
$raw = '<html><head><form>' .
'<label>Where<input type="text" name="here" value="Hello"></label>' .
'</head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByLabel('Where')), "Hello");
}
function testCanFindFormByLabel() {
$raw = '<html><head><form><input type="submit"></form></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertNull($page->getFormBySubmit(new SimpleByLabel('submit')));
$this->assertNull($page->getFormBySubmit(new SimpleByName('submit')));
$this->assertIsA(
$page->getFormBySubmit(new SimpleByLabel('Submit')),
'SimpleForm');
}
function testConfirmSubmitAttributesAreCaseSensitive() {
$raw = '<html><head><FORM><INPUT TYPE="SUBMIT" NAME="S" VALUE="S"></FORM></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertIsA(
$page->getFormBySubmit(new SimpleByName('S')),
'SimpleForm');
$this->assertIsA(
$page->getFormBySubmit(new SimpleByLabel('S')),
'SimpleForm');
}
function testCanFindFormByImage() {
$raw = '<html><head><form>' .
'<input type="image" id=100 alt="Label" name="me">' .
'</form></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertIsA(
$page->getFormByImage(new SimpleByLabel('Label')),
'SimpleForm');
$this->assertIsA(
$page->getFormByImage(new SimpleByName('me')),
'SimpleForm');
$this->assertIsA(
$page->getFormByImage(new SimpleById(100)),
'SimpleForm');
}
function testCanFindFormByButtonTag() {
$raw = '<html><head><form>' .
'<button type="submit" name="b" value="B">BBB</button>' .
'</form></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertNull($page->getFormBySubmit(new SimpleByLabel('b')));
$this->assertNull($page->getFormBySubmit(new SimpleByLabel('B')));
$this->assertIsA(
$page->getFormBySubmit(new SimpleByName('b')),
'SimpleForm');
$this->assertIsA(
$page->getFormBySubmit(new SimpleByLabel('BBB')),
'SimpleForm');
}
function testCanFindFormById() {
$raw = '<html><head><form id="55"><input type="submit"></form></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertNull($page->getFormById(54));
$this->assertIsA($page->getFormById(55), 'SimpleForm');
}
function testFormCanBeSubmitted() {
$raw = '<html><head><form method="GET" action="here.php">' .
'<input type="submit" name="s" value="Submit">' .
'</form></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$form = $page->getFormBySubmit(new SimpleByLabel('Submit'));
$this->assertEqual(
$form->submitButton(new SimpleByLabel('Submit')),
new SimpleGetEncoding(array('s' => 'Submit')));
}
function testUnparsedTagDoesNotCrash() {
$raw = '<form><input type="reset" name="Clear"></form>';
$this->whenVisiting('http://host', $raw);
}
function testReadingTextField() {
$raw = '<html><head><form>' .
'<input type="text" name="a">' .
'<input type="text" name="b" value="bbb" id=3>' .
'</form></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertNull($page->getField(new SimpleByName('missing')));
$this->assertIdentical($page->getField(new SimpleByName('a')), '');
$this->assertIdentical($page->getField(new SimpleByName('b')), 'bbb');
}
function testEntitiesAreDecodedInDefaultTextFieldValue() {
$raw = '<form><input type="text" name="a" value="&\'"<>"></form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('a')), '&\'"<>');
}
function testReadingTextFieldIsCaseInsensitive() {
$raw = '<html><head><FORM>' .
'<INPUT TYPE="TEXT" NAME="a">' .
'<INPUT TYPE="TEXT" NAME="b" VALUE="bbb" id=3>' .
'</FORM></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertNull($page->getField(new SimpleByName('missing')));
$this->assertIdentical($page->getField(new SimpleByName('a')), '');
$this->assertIdentical($page->getField(new SimpleByName('b')), 'bbb');
}
function testSettingTextField() {
$raw = '<html><head><form>' .
'<input type="text" name="a">' .
'<input type="text" name="b" id=3>' .
'<input type="submit">' .
'</form></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertTrue($page->setField(new SimpleByName('a'), 'aaa'));
$this->assertEqual($page->getField(new SimpleByName('a')), 'aaa');
$this->assertTrue($page->setField(new SimpleById(3), 'bbb'));
$this->assertEqual($page->getField(new SimpleBYId(3)), 'bbb');
$this->assertFalse($page->setField(new SimpleByName('z'), 'zzz'));
$this->assertNull($page->getField(new SimpleByName('z')));
}
function testSettingTextFieldByEnclosingLabel() {
$raw = '<html><head><form>' .
'<label>Stuff' .
'<input type="text" name="a" value="A">' .
'</label>' .
'</form></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('a')), 'A');
$this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'A');
$this->assertTrue($page->setField(new SimpleByLabel('Stuff'), 'aaa'));
$this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'aaa');
}
function testLabelsWithoutForDoNotAttachToInputsWithNoId() {
$raw = '<form action="network_confirm.php?x=X&y=Y" method="post">
<label>Text A <input type="text" name="a" value="one"></label>
<label>Text B <input type="text" name="b" value="two"></label>
</form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByLabelOrName('Text A')), 'one');
$this->assertEqual($page->getField(new SimpleByLabelOrName('Text B')), 'two');
$this->assertTrue($page->setField(new SimpleByLabelOrName('Text A'), '1'));
$this->assertTrue($page->setField(new SimpleByLabelOrName('Text B'), '2'));
$this->assertEqual($page->getField(new SimpleByLabelOrName('Text A')), '1');
$this->assertEqual($page->getField(new SimpleByLabelOrName('Text B')), '2');
}
function testGettingTextFieldByEnclosingLabelWithConflictingOtherFields() {
$raw = '<html><head><form>' .
'<label>Stuff' .
'<input type="text" name="a" value="A">' .
'</label>' .
'<input type="text" name="b" value="B">' .
'</form></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('a')), 'A');
$this->assertEqual($page->getField(new SimpleByName('b')), 'B');
$this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'A');
}
function testSettingTextFieldByExternalLabel() {
$raw = '<html><head><form>' .
'<label for="aaa">Stuff</label>' .
'<input id="aaa" type="text" name="a" value="A">' .
'</form></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'A');
$this->assertTrue($page->setField(new SimpleByLabel('Stuff'), 'aaa'));
$this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'aaa');
}
function testReadingTextArea() {
$raw = '<html><head><form>' .
'<textarea name="a">aaa</textarea>' .
'<input type="submit">' .
'</form></head></html>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('a')), 'aaa');
}
function testEntitiesAreDecodedInTextareaValue() {
$raw = '<form><textarea name="a">&\'"<></textarea></form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('a')), '&\'"<>');
}
function testNewlinesPreservedInTextArea() {
$raw = "<form><textarea name=\"a\">hello\r\nworld</textarea></form>";
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('a')), "hello\r\nworld");
}
function testWhitespacePreservedInTextArea() {
$raw = '<form><textarea name="a"> </textarea></form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('a')), ' ');
}
function testComplexWhitespaceInTextArea() {
$raw = "<html>\n" .
" <head><title></title></head>\n" .
" <body>\n" .
" <form>\n".
" <label>Text area C\n" .
" <textarea name='c'>\n" .
" </textarea>\n" .
" </label>\n" .
" </form>\n" .
" </body>\n" .
"</html>";
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('c')), " ");
}
function testSettingTextArea() {
$raw = '<form>' .
'<textarea name="a">aaa</textarea>' .
'<input type="submit">' .
'</form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertTrue($page->setField(new SimpleByName('a'), 'AAA'));
$this->assertEqual($page->getField(new SimpleByName('a')), 'AAA');
}
function testDontIncludeTextAreaContentInLabel() {
$raw = '<form><label>Text area C<textarea id=3 name="c">mouse</textarea></label></form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByLabel('Text area C')), 'mouse');
}
function testSettingSelectionField() {
$raw = '<form>' .
'<select name="a">' .
'<option>aaa</option>' .
'<option selected>bbb</option>' .
'</select>' .
'<input type="submit">' .
'</form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('a')), 'bbb');
$this->assertFalse($page->setField(new SimpleByName('a'), 'ccc'));
$this->assertTrue($page->setField(new SimpleByName('a'), 'aaa'));
$this->assertEqual($page->getField(new SimpleByName('a')), 'aaa');
}
function testSelectionOptionsAreNormalised() {
$raw = '<form>' .
'<select name="a">' .
'<option selected><b>Big</b> bold</option>' .
'<option>small <em>italic</em></option>' .
'</select>' .
'</form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('a')), 'Big bold');
$this->assertTrue($page->setField(new SimpleByName('a'), 'small italic'));
$this->assertEqual($page->getField(new SimpleByName('a')), 'small italic');
}
function testCanParseBlankOptions() {
$raw = '<form>
<select id=4 name="d">
<option value="d1">D1</option>
<option value="d2">D2</option>
<option></option>
</select>
</form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertTrue($page->setField(new SimpleByName('d'), ''));
}
function testTwoSelectionFieldsAreIndependent() {
$raw = '<form>
<select id=4 name="d">
<option value="d1" selected>D1</option>
<option value="d2">D2</option>
</select>
<select id=11 name="h">
<option value="h1">H1</option>
<option value="h2" selected>H2</option>
</select>
</form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertTrue($page->setField(new SimpleByName('d'), 'd2'));
$this->assertTrue($page->setField(new SimpleByName('h'), 'h1'));
$this->assertEqual($page->getField(new SimpleByName('d')), 'd2');
}
function testEmptyOptionDoesNotScrewUpTwoSelectionFields() {
$raw = '<form>
<select name="d">
<option value="d1" selected>D1</option>
<option value="d2">D2</option>
<option></option>
</select>
<select name="h">
<option value="h1">H1</option>
<option value="h2" selected>H2</option>
</select>
</form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertTrue($page->setField(new SimpleByName('d'), 'd2'));
$this->assertTrue($page->setField(new SimpleByName('h'), 'h1'));
$this->assertEqual($page->getField(new SimpleByName('d')), 'd2');
}
function testSettingSelectionFieldByEnclosingLabel() {
$raw = '<form>' .
'<label>Stuff' .
'<select name="a"><option selected>A</option><option>B</option></select>' .
'</label>' .
'</form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'A');
$this->assertTrue($page->setField(new SimpleByLabel('Stuff'), 'B'));
$this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'B');
}
function testTwoSelectionFieldsWithLabelsAreIndependent() {
$raw = '<form>
<label>Labelled D
<select id=4 name="d">
<option value="d1" selected>D1</option>
<option value="d2">D2</option>
</select>
</label>
<label>Labelled H
<select id=11 name="h">
<option value="h1">H1</option>
<option value="h2" selected>H2</option>
</select>
</label>
</form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertTrue($page->setField(new SimpleByLabel('Labelled D'), 'd2'));
$this->assertTrue($page->setField(new SimpleByLabel('Labelled H'), 'h1'));
$this->assertEqual($page->getField(new SimpleByLabel('Labelled D')), 'd2');
}
function testSettingRadioButtonByEnclosingLabel() {
$raw = '<form>' .
'<label>A<input type="radio" name="r" value="a" checked></label>' .
'<label>B<input type="radio" name="r" value="b"></label>' .
'</form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByLabel('A')), 'a');
$this->assertTrue($page->setField(new SimpleBylabel('B'), 'b'));
$this->assertEqual($page->getField(new SimpleByLabel('B')), 'b');
}
function testCanParseInputsWithAllKindsOfAttributeQuoting() {
$raw = '<form>' .
'<input type="checkbox" name=\'first\' value=one checked></input>' .
'<input type=checkbox name="second" value="two"></input>' .
'<input type=checkbox name="third" value=\'three\' checked="checked" />' .
'</form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByName('first')), 'one');
$this->assertEqual($page->getField(new SimpleByName('second')), false);
$this->assertEqual($page->getField(new SimpleByName('third')), 'three');
}
function urlToString($url) {
return $url->asString();
}
function assertSameFrameset($actual, $expected) {
$this->assertIdentical(array_map(array($this, 'urlToString'), $actual),
array_map(array($this, 'urlToString'), $expected));
}
}
class TestOfParsingUsingPhpParser extends TestOfParsing {
function whenVisiting($url, $content) {
$response = new MockSimpleHttpResponse();
$response->setReturnValue('getContent', $content);
$response->setReturnValue('getUrl', new SimpleUrl($url));
$builder = new SimplePhpPageBuilder();
return $builder->parse($response);
}
function testNastyTitle() {
$page = $this->whenVisiting('http://host',
'<html><head><Title> <b>Me&Me </TITLE></b></head></html>');
$this->assertEqual($page->getTitle(), "Me&Me");
}
function testLabelShouldStopAtClosingLabelTag() {
$raw = '<form><label>start<textarea id=3 name="c" wrap="hard">stuff</textarea>end</label>stuff</form>';
$page = $this->whenVisiting('http://host', $raw);
$this->assertEqual($page->getField(new SimpleByLabel('startend')), 'stuff');
}
}
class TestOfParsingUsingTidyParser extends TestOfParsing {
function skip() {
$this->skipUnless(extension_loaded('tidy'), 'Install \'tidy\' php extension to enable html tidy based parser');
}
function whenVisiting($url, $content) {
$response = new MockSimpleHttpResponse();
$response->setReturnValue('getContent', $content);
$response->setReturnValue('getUrl', new SimpleUrl($url));
$builder = new SimpleTidyPageBuilder();
return $builder->parse($response);
}
}
?> | 10npsite | trunk/simpletest/test/parsing_test.php | PHP | asf20 | 28,304 |
<?php
// $Id: page_test.php 1913 2009-07-29 16:50:56Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../expectation.php');
require_once(dirname(__FILE__) . '/../http.php');
require_once(dirname(__FILE__) . '/../page.php');
Mock::generate('SimpleHttpHeaders');
Mock::generate('SimpleHttpResponse');
class TestOfPageInterface extends UnitTestCase {
function testInterfaceOnEmptyPage() {
$page = new SimplePage();
$this->assertEqual($page->getTransportError(), 'No page fetched yet');
$this->assertIdentical($page->getRaw(), false);
$this->assertIdentical($page->getHeaders(), false);
$this->assertIdentical($page->getMimeType(), false);
$this->assertIdentical($page->getResponseCode(), false);
$this->assertIdentical($page->getAuthentication(), false);
$this->assertIdentical($page->getRealm(), false);
$this->assertFalse($page->hasFrames());
$this->assertIdentical($page->getUrls(), array());
$this->assertIdentical($page->getTitle(), false);
}
}
class TestOfPageHeaders extends UnitTestCase {
function testUrlAccessor() {
$headers = new MockSimpleHttpHeaders();
$response = new MockSimpleHttpResponse();
$response->setReturnValue('getHeaders', $headers);
$response->setReturnValue('getMethod', 'POST');
$response->setReturnValue('getUrl', new SimpleUrl('here'));
$response->setReturnValue('getRequestData', array('a' => 'A'));
$page = new SimplePage($response);
$this->assertEqual($page->getMethod(), 'POST');
$this->assertEqual($page->getUrl(), new SimpleUrl('here'));
$this->assertEqual($page->getRequestData(), array('a' => 'A'));
}
function testTransportError() {
$response = new MockSimpleHttpResponse();
$response->setReturnValue('getError', 'Ouch');
$page = new SimplePage($response);
$this->assertEqual($page->getTransportError(), 'Ouch');
}
function testHeadersAccessor() {
$headers = new MockSimpleHttpHeaders();
$headers->setReturnValue('getRaw', 'My: Headers');
$response = new MockSimpleHttpResponse();
$response->setReturnValue('getHeaders', $headers);
$page = new SimplePage($response);
$this->assertEqual($page->getHeaders(), 'My: Headers');
}
function testMimeAccessor() {
$headers = new MockSimpleHttpHeaders();
$headers->setReturnValue('getMimeType', 'text/html');
$response = new MockSimpleHttpResponse();
$response->setReturnValue('getHeaders', $headers);
$page = new SimplePage($response);
$this->assertEqual($page->getMimeType(), 'text/html');
}
function testResponseAccessor() {
$headers = new MockSimpleHttpHeaders();
$headers->setReturnValue('getResponseCode', 301);
$response = new MockSimpleHttpResponse();
$response->setReturnValue('getHeaders', $headers);
$page = new SimplePage($response);
$this->assertIdentical($page->getResponseCode(), 301);
}
function testAuthenticationAccessors() {
$headers = new MockSimpleHttpHeaders();
$headers->setReturnValue('getAuthentication', 'Basic');
$headers->setReturnValue('getRealm', 'Secret stuff');
$response = new MockSimpleHttpResponse();
$response->setReturnValue('getHeaders', $headers);
$page = new SimplePage($response);
$this->assertEqual($page->getAuthentication(), 'Basic');
$this->assertEqual($page->getRealm(), 'Secret stuff');
}
}
class TestOfHtmlStrippingAndNormalisation extends UnitTestCase {
function testImageSuppressionWhileKeepingParagraphsAndAltText() {
$this->assertEqual(
SimplePage::normalise('<img src="foo.png" /><p>some text</p><img src="bar.png" alt="bar" />'),
'some text bar');
}
function testSpaceNormalisation() {
$this->assertEqual(
SimplePage::normalise("\nOne\tTwo \nThree\t"),
'One Two Three');
}
function testMultilinesCommentSuppression() {
$this->assertEqual(
SimplePage::normalise('<!--\n Hello \n-->'),
'');
}
function testCommentSuppression() {
$this->assertEqual(
SimplePage::normalise('<!--Hello-->'),
'');
}
function testJavascriptSuppression() {
$this->assertEqual(
SimplePage::normalise('<script attribute="test">\nHello\n</script>'),
'');
$this->assertEqual(
SimplePage::normalise('<script attribute="test">Hello</script>'),
'');
$this->assertEqual(
SimplePage::normalise('<script>Hello</script>'),
'');
}
function testTagSuppression() {
$this->assertEqual(
SimplePage::normalise('<b>Hello</b>'),
'Hello');
}
function testAdjoiningTagSuppression() {
$this->assertEqual(
SimplePage::normalise('<b>Hello</b><em>Goodbye</em>'),
'HelloGoodbye');
}
function testExtractImageAltTextWithDifferentQuotes() {
$this->assertEqual(
SimplePage::normalise('<img alt="One"><img alt=\'Two\'><img alt=Three>'),
'One Two Three');
}
function testExtractImageAltTextMultipleTimes() {
$this->assertEqual(
SimplePage::normalise('<img alt="One"><img alt="Two"><img alt="Three">'),
'One Two Three');
}
function testHtmlEntityTranslation() {
$this->assertEqual(
SimplePage::normalise('<>"&''),
'<>"&\'');
}
}
?> | 10npsite | trunk/simpletest/test/page_test.php | PHP | asf20 | 5,826 |
<?php
// $Id: socket_test.php 1782 2008-04-25 17:09:06Z pp11 $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../socket.php');
Mock::generate('SimpleSocket');
class TestOfSimpleStickyError extends UnitTestCase {
function testSettingError() {
$error = new SimpleStickyError();
$this->assertFalse($error->isError());
$error->setError('Ouch');
$this->assertTrue($error->isError());
$this->assertEqual($error->getError(), 'Ouch');
}
function testClearingError() {
$error = new SimpleStickyError();
$error->setError('Ouch');
$this->assertTrue($error->isError());
$error->clearError();
$this->assertFalse($error->isError());
}
}
?> | 10npsite | trunk/simpletest/test/socket_test.php | PHP | asf20 | 773 |
<?php
// $Id: acceptance_test.php 2013 2011-04-29 09:29:45Z pp11 $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../compatibility.php');
require_once(dirname(__FILE__) . '/../browser.php');
require_once(dirname(__FILE__) . '/../web_tester.php');
require_once(dirname(__FILE__) . '/../unit_tester.php');
class SimpleTestAcceptanceTest extends WebTestCase {
static function samples() {
return 'http://www.lastcraft.com/test/';
}
}
class TestOfLiveBrowser extends UnitTestCase {
function samples() {
return SimpleTestAcceptanceTest::samples();
}
function testGet() {
$browser = new SimpleBrowser();
$browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
$this->assertTrue($browser->get($this->samples() . 'network_confirm.php'));
$this->assertPattern('/target for the SimpleTest/', $browser->getContent());
$this->assertPattern('/Request method.*?<dd>GET<\/dd>/', $browser->getContent());
$this->assertEqual($browser->getTitle(), 'Simple test target file');
$this->assertEqual($browser->getResponseCode(), 200);
$this->assertEqual($browser->getMimeType(), 'text/html');
}
function testPost() {
$browser = new SimpleBrowser();
$browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
$this->assertTrue($browser->post($this->samples() . 'network_confirm.php'));
$this->assertPattern('/target for the SimpleTest/', $browser->getContent());
$this->assertPattern('/Request method.*?<dd>POST<\/dd>/', $browser->getContent());
}
function testAbsoluteLinkFollowing() {
$browser = new SimpleBrowser();
$browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
$browser->get($this->samples() . 'link_confirm.php');
$this->assertTrue($browser->clickLink('Absolute'));
$this->assertPattern('/target for the SimpleTest/', $browser->getContent());
}
function testRelativeEncodedLinkFollowing() {
$browser = new SimpleBrowser();
$browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
$browser->get($this->samples() . 'link_confirm.php');
// Warning: the below data is ISO 8859-1 encoded
$this->assertTrue($browser->clickLink("m\xE4rc\xEAl kiek'eboe"));
$this->assertPattern('/target for the SimpleTest/', $browser->getContent());
}
function testRelativeLinkFollowing() {
$browser = new SimpleBrowser();
$browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
$browser->get($this->samples() . 'link_confirm.php');
$this->assertTrue($browser->clickLink('Relative'));
$this->assertPattern('/target for the SimpleTest/', $browser->getContent());
}
function testUnifiedClickLinkClicking() {
$browser = new SimpleBrowser();
$browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
$browser->get($this->samples() . 'link_confirm.php');
$this->assertTrue($browser->click('Relative'));
$this->assertPattern('/target for the SimpleTest/', $browser->getContent());
}
function testIdLinkFollowing() {
$browser = new SimpleBrowser();
$browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
$browser->get($this->samples() . 'link_confirm.php');
$this->assertTrue($browser->clickLinkById(1));
$this->assertPattern('/target for the SimpleTest/', $browser->getContent());
}
function testCookieReading() {
$browser = new SimpleBrowser();
$browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
$browser->get($this->samples() . 'set_cookies.php');
$this->assertEqual($browser->getCurrentCookieValue('session_cookie'), 'A');
$this->assertEqual($browser->getCurrentCookieValue('short_cookie'), 'B');
$this->assertEqual($browser->getCurrentCookieValue('day_cookie'), 'C');
}
function testSimpleSubmit() {
$browser = new SimpleBrowser();
$browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
$browser->get($this->samples() . 'form.html');
$this->assertTrue($browser->clickSubmit('Go!'));
$this->assertPattern('/Request method.*?<dd>POST<\/dd>/', $browser->getContent());
$this->assertPattern('/go=\[Go!\]/', $browser->getContent());
}
function testUnifiedClickCanSubmit() {
$browser = new SimpleBrowser();
$browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
$browser->get($this->samples() . 'form.html');
$this->assertTrue($browser->click('Go!'));
$this->assertPattern('/go=\[Go!\]/', $browser->getContent());
}
}
class TestOfLocalFileBrowser extends UnitTestCase {
function samples() {
return 'file://'.dirname(__FILE__).'/site/';
}
function testGet() {
$browser = new SimpleBrowser();
$browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
$this->assertTrue($browser->get($this->samples() . 'file.html'));
$this->assertPattern('/Link to SimpleTest/', $browser->getContent());
$this->assertEqual($browser->getTitle(), 'Link to SimpleTest');
$this->assertFalse($browser->getResponseCode());
$this->assertEqual($browser->getMimeType(), '');
}
}
class TestOfRequestMethods extends UnitTestCase {
function samples() {
return SimpleTestAcceptanceTest::samples();
}
function testHeadRequest() {
$browser = new SimpleBrowser();
$this->assertTrue($browser->head($this->samples() . 'request_methods.php'));
$this->assertEqual($browser->getResponseCode(), 202);
}
function testGetRequest() {
$browser = new SimpleBrowser();
$this->assertTrue($browser->get($this->samples() . 'request_methods.php'));
$this->assertEqual($browser->getResponseCode(), 405);
}
function testPostWithPlainEncoding() {
$browser = new SimpleBrowser();
$this->assertTrue($browser->post($this->samples() . 'request_methods.php', 'A content message'));
$this->assertEqual($browser->getResponseCode(), 406);
$this->assertPattern('/Please ensure content type is an XML format/', $browser->getContent());
}
function testPostWithXmlEncoding() {
$browser = new SimpleBrowser();
$this->assertTrue($browser->post($this->samples() . 'request_methods.php', '<a><b>c</b></a>', 'text/xml'));
$this->assertEqual($browser->getResponseCode(), 201);
$this->assertPattern('/c/', $browser->getContent());
}
function testPutWithPlainEncoding() {
$browser = new SimpleBrowser();
$this->assertTrue($browser->put($this->samples() . 'request_methods.php', 'A content message'));
$this->assertEqual($browser->getResponseCode(), 406);
$this->assertPattern('/Please ensure content type is an XML format/', $browser->getContent());
}
function testPutWithXmlEncoding() {
$browser = new SimpleBrowser();
$this->assertTrue($browser->put($this->samples() . 'request_methods.php', '<a><b>c</b></a>', 'application/xml'));
$this->assertEqual($browser->getResponseCode(), 201);
$this->assertPattern('/c/', $browser->getContent());
}
function testDeleteRequest() {
$browser = new SimpleBrowser();
$browser->delete($this->samples() . 'request_methods.php');
$this->assertEqual($browser->getResponseCode(), 202);
$this->assertPattern('/Your delete request was accepted/', $browser->getContent());
}
}
class TestRadioFields extends SimpleTestAcceptanceTest {
function testSetFieldAsInteger() {
$this->get($this->samples() . 'form_with_radio_buttons.html');
$this->assertTrue($this->setField('tested_field', 2));
$this->clickSubmitByName('send');
$this->assertEqual($this->getUrl(), $this->samples() . 'form_with_radio_buttons.html?tested_field=2&send=click+me');
}
function testSetFieldAsString() {
$this->get($this->samples() . 'form_with_radio_buttons.html');
$this->assertTrue($this->setField('tested_field', '2'));
$this->clickSubmitByName('send');
$this->assertEqual($this->getUrl(), $this->samples() . 'form_with_radio_buttons.html?tested_field=2&send=click+me');
}
}
class TestOfLiveFetching extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testFormWithArrayBasedInputs() {
$this->get($this->samples() . 'form_with_array_based_inputs.php');
$this->setField('value[]', '3', '1');
$this->setField('value[]', '4', '2');
$this->clickSubmit('Go');
$this->assertPattern('/QUERY_STRING : value%5B%5D=3&value%5B%5D=4&submit=Go/');
}
function testFormWithQuotedValues() {
$this->get($this->samples() . 'form_with_quoted_values.php');
$this->assertField('a', 'default');
$this->assertFieldById('text_field', 'default');
$this->clickSubmit('Go');
$this->assertPattern('/a=default&submit=Go/');
}
function testGet() {
$this->assertTrue($this->get($this->samples() . 'network_confirm.php'));
$this->assertEqual($this->getUrl(), $this->samples() . 'network_confirm.php');
$this->assertText('target for the SimpleTest');
$this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
$this->assertTitle('Simple test target file');
$this->assertTitle(new PatternExpectation('/target file/'));
$this->assertResponse(200);
$this->assertMime('text/html');
$this->assertHeader('connection', 'close');
$this->assertHeader('connection', new PatternExpectation('/los/'));
}
function testSlowGet() {
$this->assertTrue($this->get($this->samples() . 'slow_page.php'));
}
function testTimedOutGet() {
$this->setConnectionTimeout(1);
$this->ignoreErrors();
$this->assertFalse($this->get($this->samples() . 'slow_page.php'));
}
function testPost() {
$this->assertTrue($this->post($this->samples() . 'network_confirm.php'));
$this->assertText('target for the SimpleTest');
$this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
}
function testGetWithData() {
$this->get($this->samples() . 'network_confirm.php', array("a" => "aaa"));
$this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
$this->assertText('a=[aaa]');
}
function testPostWithData() {
$this->post($this->samples() . 'network_confirm.php', array("a" => "aaa"));
$this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
$this->assertText('a=[aaa]');
}
function testPostWithRecursiveData() {
$this->post($this->samples() . 'network_confirm.php', array("a" => "aaa"));
$this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
$this->assertText('a=[aaa]');
$this->post($this->samples() . 'network_confirm.php', array("a[aa]" => "aaa"));
$this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
$this->assertText('a=[aa=[aaa]]');
$this->post($this->samples() . 'network_confirm.php', array("a[aa][aaa]" => "aaaa"));
$this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
$this->assertText('a=[aa=[aaa=[aaaa]]]');
$this->post($this->samples() . 'network_confirm.php', array("a" => array("aa" => "aaa")));
$this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
$this->assertText('a=[aa=[aaa]]');
$this->post($this->samples() . 'network_confirm.php', array("a" => array("aa" => array("aaa" => "aaaa"))));
$this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
$this->assertText('a=[aa=[aaa=[aaaa]]]');
}
function testRelativeGet() {
$this->get($this->samples() . 'link_confirm.php');
$this->assertTrue($this->get('network_confirm.php'));
$this->assertText('target for the SimpleTest');
}
function testRelativePost() {
$this->post($this->samples() . 'link_confirm.php', array('a' => '123'));
$this->assertTrue($this->post('network_confirm.php'));
$this->assertText('target for the SimpleTest');
}
}
class TestOfLinkFollowing extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testLinkAssertions() {
$this->get($this->samples() . 'link_confirm.php');
$this->assertLink('Absolute', $this->samples() . 'network_confirm.php');
$this->assertLink('Absolute', new PatternExpectation('/confirm/'));
$this->assertClickable('Absolute');
}
function testAbsoluteLinkFollowing() {
$this->get($this->samples() . 'link_confirm.php');
$this->assertTrue($this->clickLink('Absolute'));
$this->assertText('target for the SimpleTest');
}
function testRelativeLinkFollowing() {
$this->get($this->samples() . 'link_confirm.php');
$this->assertTrue($this->clickLink('Relative'));
$this->assertText('target for the SimpleTest');
}
function testLinkIdFollowing() {
$this->get($this->samples() . 'link_confirm.php');
$this->assertLinkById(1);
$this->assertTrue($this->clickLinkById(1));
$this->assertText('target for the SimpleTest');
}
function testAbsoluteUrlBehavesAbsolutely() {
$this->get($this->samples() . 'link_confirm.php');
$this->get('http://www.lastcraft.com');
$this->assertText('No guarantee of quality is given or even intended');
}
function testRelativeUrlRespectsBaseTag() {
$this->get($this->samples() . 'base_tag/base_link.html');
$this->click('Back to test pages');
$this->assertTitle('Simple test target file');
}
}
class TestOfLivePageLinkingWithMinimalLinks extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testClickToExplicitelyNamedSelfReturns() {
$this->get($this->samples() . 'front_controller_style/a_page.php');
$this->assertEqual($this->getUrl(), $this->samples() . 'front_controller_style/a_page.php');
$this->assertTitle('Simple test page with links');
$this->assertLink('Self');
$this->clickLink('Self');
$this->assertTitle('Simple test page with links');
}
function testClickToMissingPageReturnsToSamePage() {
$this->get($this->samples() . 'front_controller_style/a_page.php');
$this->clickLink('No page');
$this->assertTitle('Simple test page with links');
$this->assertText('[action=no_page]');
}
function testClickToBareActionReturnsToSamePage() {
$this->get($this->samples() . 'front_controller_style/a_page.php');
$this->clickLink('Bare action');
$this->assertTitle('Simple test page with links');
$this->assertText('[action=]');
}
function testClickToSingleQuestionMarkReturnsToSamePage() {
$this->get($this->samples() . 'front_controller_style/a_page.php');
$this->clickLink('Empty query');
$this->assertTitle('Simple test page with links');
}
function testClickToEmptyStringReturnsToSamePage() {
$this->get($this->samples() . 'front_controller_style/a_page.php');
$this->clickLink('Empty link');
$this->assertTitle('Simple test page with links');
}
function testClickToSingleDotGoesToCurrentDirectory() {
$this->get($this->samples() . 'front_controller_style/a_page.php');
$this->clickLink('Current directory');
$this->assertTitle(
'Simple test front controller',
'%s -> index.php needs to be set as a default web server home page');
}
function testClickBackADirectoryLevel() {
$this->get($this->samples() . 'front_controller_style/');
$this->clickLink('Down one');
$this->assertPattern('|Index of .*?/test|i');
}
}
class TestOfLiveFrontControllerEmulation extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testJumpToNamedPage() {
$this->get($this->samples() . 'front_controller_style/');
$this->assertText('Simple test front controller');
$this->clickLink('Index');
$this->assertResponse(200);
$this->assertText('[action=index]');
}
function testJumpToUnnamedPage() {
$this->get($this->samples() . 'front_controller_style/');
$this->clickLink('No page');
$this->assertResponse(200);
$this->assertText('Simple test front controller');
$this->assertText('[action=no_page]');
}
function testJumpToUnnamedPageWithBareParameter() {
$this->get($this->samples() . 'front_controller_style/');
$this->clickLink('Bare action');
$this->assertResponse(200);
$this->assertText('Simple test front controller');
$this->assertText('[action=]');
}
function testJumpToUnnamedPageWithEmptyQuery() {
$this->get($this->samples() . 'front_controller_style/');
$this->clickLink('Empty query');
$this->assertResponse(200);
$this->assertPattern('/Simple test front controller/');
$this->assertPattern('/raw get data.*?\[\].*?get data/si');
}
function testJumpToUnnamedPageWithEmptyLink() {
$this->get($this->samples() . 'front_controller_style/');
$this->clickLink('Empty link');
$this->assertResponse(200);
$this->assertPattern('/Simple test front controller/');
$this->assertPattern('/raw get data.*?\[\].*?get data/si');
}
function testJumpBackADirectoryLevel() {
$this->get($this->samples() . 'front_controller_style/');
$this->clickLink('Down one');
$this->assertPattern('|Index of .*?/test|');
}
function testSubmitToNamedPage() {
$this->get($this->samples() . 'front_controller_style/');
$this->assertText('Simple test front controller');
$this->clickSubmit('Index');
$this->assertResponse(200);
$this->assertText('[action=Index]');
}
function testSubmitToSameDirectory() {
$this->get($this->samples() . 'front_controller_style/index.php');
$this->clickSubmit('Same directory');
$this->assertResponse(200);
$this->assertText('[action=Same+directory]');
}
function testSubmitToEmptyAction() {
$this->get($this->samples() . 'front_controller_style/index.php');
$this->clickSubmit('Empty action');
$this->assertResponse(200);
$this->assertText('[action=Empty+action]');
}
function testSubmitToNoAction() {
$this->get($this->samples() . 'front_controller_style/index.php');
$this->clickSubmit('No action');
$this->assertResponse(200);
$this->assertText('[action=No+action]');
}
function testSubmitBackADirectoryLevel() {
$this->get($this->samples() . 'front_controller_style/');
$this->clickSubmit('Down one');
$this->assertPattern('|Index of .*?/test|');
}
function testSubmitToNamedPageWithMixedPostAndGet() {
$this->get($this->samples() . 'front_controller_style/?a=A');
$this->assertText('Simple test front controller');
$this->clickSubmit('Index post');
$this->assertText('action=[Index post]');
$this->assertNoText('[a=A]');
}
function testSubmitToSameDirectoryMixedPostAndGet() {
$this->get($this->samples() . 'front_controller_style/index.php?a=A');
$this->clickSubmit('Same directory post');
$this->assertText('action=[Same directory post]');
$this->assertNoText('[a=A]');
}
function testSubmitToEmptyActionMixedPostAndGet() {
$this->get($this->samples() . 'front_controller_style/index.php?a=A');
$this->clickSubmit('Empty action post');
$this->assertText('action=[Empty action post]');
$this->assertText('[a=A]');
}
function testSubmitToNoActionMixedPostAndGet() {
$this->get($this->samples() . 'front_controller_style/index.php?a=A');
$this->clickSubmit('No action post');
$this->assertText('action=[No action post]');
$this->assertText('[a=A]');
}
}
class TestOfLiveHeaders extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testConfirmingHeaderExistence() {
$this->get('http://www.lastcraft.com/');
$this->assertHeader('content-type');
$this->assertHeader('content-type', 'text/html');
$this->assertHeader('content-type', new PatternExpectation('/HTML/i'));
$this->assertNoHeader('WWW-Authenticate');
}
}
class TestOfLiveRedirects extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testNoRedirects() {
$this->setMaximumRedirects(0);
$this->get($this->samples() . 'redirect.php');
$this->assertTitle('Redirection test');
}
function testRedirects() {
$this->setMaximumRedirects(1);
$this->get($this->samples() . 'redirect.php');
$this->assertTitle('Simple test target file');
}
function testRedirectLosesGetData() {
$this->get($this->samples() . 'redirect.php', array('a' => 'aaa'));
$this->assertNoText('a=[aaa]');
}
function testRedirectKeepsExtraRequestDataOfItsOwn() {
$this->get($this->samples() . 'redirect.php');
$this->assertText('r=[rrr]');
}
function testRedirectLosesPostData() {
$this->post($this->samples() . 'redirect.php', array('a' => 'aaa'));
$this->assertTitle('Simple test target file');
$this->assertNoText('a=[aaa]');
}
function testRedirectWithBaseUrlChange() {
$this->get($this->samples() . 'base_change_redirect.php');
$this->assertTitle('Simple test target file in folder');
$this->get($this->samples() . 'path/base_change_redirect.php');
$this->assertTitle('Simple test target file');
}
function testRedirectWithDoubleBaseUrlChange() {
$this->get($this->samples() . 'double_base_change_redirect.php');
$this->assertTitle('Simple test target file');
}
}
class TestOfLiveCookies extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function here() {
return new SimpleUrl($this->samples());
}
function thisHost() {
$here = $this->here();
return $here->getHost();
}
function thisPath() {
$here = $this->here();
return $here->getPath();
}
function testCookieSettingAndAssertions() {
$this->setCookie('a', 'Test cookie a');
$this->setCookie('b', 'Test cookie b', $this->thisHost());
$this->setCookie('c', 'Test cookie c', $this->thisHost(), $this->thisPath());
$this->get($this->samples() . 'network_confirm.php');
$this->assertText('Test cookie a');
$this->assertText('Test cookie b');
$this->assertText('Test cookie c');
$this->assertCookie('a');
$this->assertCookie('b', 'Test cookie b');
$this->assertTrue($this->getCookie('c') == 'Test cookie c');
}
function testNoCookieSetWhenCookiesDisabled() {
$this->setCookie('a', 'Test cookie a');
$this->ignoreCookies();
$this->get($this->samples() . 'network_confirm.php');
$this->assertNoText('Test cookie a');
}
function testCookieReading() {
$this->get($this->samples() . 'set_cookies.php');
$this->assertCookie('session_cookie', 'A');
$this->assertCookie('short_cookie', 'B');
$this->assertCookie('day_cookie', 'C');
}
function testNoCookie() {
$this->assertNoCookie('aRandomCookie');
}
function testNoCookieReadingWhenCookiesDisabled() {
$this->ignoreCookies();
$this->get($this->samples() . 'set_cookies.php');
$this->assertNoCookie('session_cookie');
$this->assertNoCookie('short_cookie');
$this->assertNoCookie('day_cookie');
}
function testCookiePatternAssertions() {
$this->get($this->samples() . 'set_cookies.php');
$this->assertCookie('session_cookie', new PatternExpectation('/a/i'));
}
function testTemporaryCookieExpiry() {
$this->get($this->samples() . 'set_cookies.php');
$this->restart();
$this->assertNoCookie('session_cookie');
$this->assertCookie('day_cookie', 'C');
}
function testTimedCookieExpiryWith100SecondMargin() {
$this->get($this->samples() . 'set_cookies.php');
$this->ageCookies(3600);
$this->restart(time() + 100);
$this->assertNoCookie('session_cookie');
$this->assertNoCookie('hour_cookie');
$this->assertCookie('day_cookie', 'C');
}
function testNoClockOverDriftBy100Seconds() {
$this->get($this->samples() . 'set_cookies.php');
$this->restart(time() + 200);
$this->assertNoCookie(
'short_cookie',
'%s -> Please check your computer clock setting if you are not using NTP');
}
function testNoClockUnderDriftBy100Seconds() {
$this->get($this->samples() . 'set_cookies.php');
$this->restart(time() + 0);
$this->assertCookie(
'short_cookie',
'B',
'%s -> Please check your computer clock setting if you are not using NTP');
}
function testCookiePath() {
$this->get($this->samples() . 'set_cookies.php');
$this->assertNoCookie('path_cookie', 'D');
$this->get('./path/show_cookies.php');
$this->assertPattern('/path_cookie/');
$this->assertCookie('path_cookie', 'D');
}
}
class LiveTestOfForms extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testSimpleSubmit() {
$this->get($this->samples() . 'form.html');
$this->assertTrue($this->clickSubmit('Go!'));
$this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
$this->assertText('go=[Go!]');
}
function testDefaultFormValues() {
$this->get($this->samples() . 'form.html');
$this->assertFieldByName('a', '');
$this->assertFieldByName('b', 'Default text');
$this->assertFieldByName('c', '');
$this->assertFieldByName('d', 'd1');
$this->assertFieldByName('e', false);
$this->assertFieldByName('f', 'on');
$this->assertFieldByName('g', 'g3');
$this->assertFieldByName('h', 2);
$this->assertFieldByName('go', 'Go!');
$this->assertClickable('Go!');
$this->assertSubmit('Go!');
$this->assertTrue($this->clickSubmit('Go!'));
$this->assertText('go=[Go!]');
$this->assertText('a=[]');
$this->assertText('b=[Default text]');
$this->assertText('c=[]');
$this->assertText('d=[d1]');
$this->assertNoText('e=[');
$this->assertText('f=[on]');
$this->assertText('g=[g3]');
}
function testFormSubmissionByButtonLabel() {
$this->get($this->samples() . 'form.html');
$this->setFieldByName('a', 'aaa');
$this->setFieldByName('b', 'bbb');
$this->setFieldByName('c', 'ccc');
$this->setFieldByName('d', 'D2');
$this->setFieldByName('e', 'on');
$this->setFieldByName('f', false);
$this->setFieldByName('g', 'g2');
$this->setFieldByName('h', 1);
$this->assertTrue($this->clickSubmit('Go!'));
$this->assertText('a=[aaa]');
$this->assertText('b=[bbb]');
$this->assertText('c=[ccc]');
$this->assertText('d=[d2]');
$this->assertText('e=[on]');
$this->assertNoText('f=[');
$this->assertText('g=[g2]');
}
function testAdditionalFormValues() {
$this->get($this->samples() . 'form.html');
$this->assertTrue($this->clickSubmit('Go!', array('add' => 'A')));
$this->assertText('go=[Go!]');
$this->assertText('add=[A]');
}
function testFormSubmissionByName() {
$this->get($this->samples() . 'form.html');
$this->setFieldByName('a', 'A');
$this->assertTrue($this->clickSubmitByName('go'));
$this->assertText('a=[A]');
}
function testFormSubmissionByNameAndAdditionalParameters() {
$this->get($this->samples() . 'form.html');
$this->assertTrue($this->clickSubmitByName('go', array('add' => 'A')));
$this->assertText('go=[Go!]');
$this->assertText('add=[A]');
}
function testFormSubmissionBySubmitButtonLabeledSubmit() {
$this->get($this->samples() . 'form.html');
$this->assertTrue($this->clickSubmitByName('test'));
$this->assertText('test=[Submit]');
}
function testFormSubmissionWithIds() {
$this->get($this->samples() . 'form.html');
$this->assertFieldById(1, '');
$this->assertFieldById(2, 'Default text');
$this->assertFieldById(3, '');
$this->assertFieldById(4, 'd1');
$this->assertFieldById(5, false);
$this->assertFieldById(6, 'on');
$this->assertFieldById(8, 'g3');
$this->assertFieldById(11, 2);
$this->setFieldById(1, 'aaa');
$this->setFieldById(2, 'bbb');
$this->setFieldById(3, 'ccc');
$this->setFieldById(4, 'D2');
$this->setFieldById(5, 'on');
$this->setFieldById(6, false);
$this->setFieldById(8, 'g2');
$this->setFieldById(11, 'H1');
$this->assertTrue($this->clickSubmitById(99));
$this->assertText('a=[aaa]');
$this->assertText('b=[bbb]');
$this->assertText('c=[ccc]');
$this->assertText('d=[d2]');
$this->assertText('e=[on]');
$this->assertNoText('f=[');
$this->assertText('g=[g2]');
$this->assertText('h=[1]');
$this->assertText('go=[Go!]');
}
function testFormSubmissionWithIdsAndAdditionnalData() {
$this->get($this->samples() . 'form.html');
$this->assertTrue($this->clickSubmitById(99, array('additionnal' => "data")));
$this->assertText('additionnal=[data]');
}
function testFormSubmissionWithLabels() {
$this->get($this->samples() . 'form.html');
$this->assertField('Text A', '');
$this->assertField('Text B', 'Default text');
$this->assertField('Text area C', '');
$this->assertField('Selection D', 'd1');
$this->assertField('Checkbox E', false);
$this->assertField('Checkbox F', 'on');
$this->assertField('3', 'g3');
$this->assertField('Selection H', 2);
$this->setField('Text A', 'aaa');
$this->setField('Text B', 'bbb');
$this->setField('Text area C', 'ccc');
$this->setField('Selection D', 'D2');
$this->setField('Checkbox E', 'on');
$this->setField('Checkbox F', false);
$this->setField('2', 'g2');
$this->setField('Selection H', 'H1');
$this->clickSubmit('Go!');
$this->assertText('a=[aaa]');
$this->assertText('b=[bbb]');
$this->assertText('c=[ccc]');
$this->assertText('d=[d2]');
$this->assertText('e=[on]');
$this->assertNoText('f=[');
$this->assertText('g=[g2]');
$this->assertText('h=[1]');
$this->assertText('go=[Go!]');
}
function testSettingCheckboxWithBooleanTrueSetsUnderlyingValue() {
$this->get($this->samples() . 'form.html');
$this->setField('Checkbox E', true);
$this->assertField('Checkbox E', 'on');
$this->clickSubmit('Go!');
$this->assertText('e=[on]');
}
function testFormSubmissionWithMixedPostAndGet() {
$this->get($this->samples() . 'form_with_mixed_post_and_get.html');
$this->setField('Text A', 'Hello');
$this->assertTrue($this->clickSubmit('Go!'));
$this->assertText('a=[Hello]');
$this->assertText('x=[X]');
$this->assertText('y=[Y]');
}
function testFormSubmissionWithMixedPostAndEncodedGet() {
$this->get($this->samples() . 'form_with_mixed_post_and_get.html');
$this->setField('Text B', 'Hello');
$this->assertTrue($this->clickSubmit('Go encoded!'));
$this->assertText('b=[Hello]');
$this->assertText('x=[X]');
$this->assertText('y=[Y]');
}
function testFormSubmissionWithoutAction() {
$this->get($this->samples() . 'form_without_action.php?test=test');
$this->assertText('_GET : [test]');
$this->assertTrue($this->clickSubmit('Submit Post With Empty Action'));
$this->assertText('_GET : [test]');
$this->assertText('_POST : [test]');
}
function testImageSubmissionByLabel() {
$this->get($this->samples() . 'form.html');
$this->assertImage('Image go!');
$this->assertTrue($this->clickImage('Image go!', 10, 12));
$this->assertText('go_x=[10]');
$this->assertText('go_y=[12]');
}
function testImageSubmissionByLabelWithAdditionalParameters() {
$this->get($this->samples() . 'form.html');
$this->assertTrue($this->clickImage('Image go!', 10, 12, array('add' => 'A')));
$this->assertText('add=[A]');
}
function testImageSubmissionByName() {
$this->get($this->samples() . 'form.html');
$this->assertTrue($this->clickImageByName('go', 10, 12));
$this->assertText('go_x=[10]');
$this->assertText('go_y=[12]');
}
function testImageSubmissionById() {
$this->get($this->samples() . 'form.html');
$this->assertTrue($this->clickImageById(97, 10, 12));
$this->assertText('go_x=[10]');
$this->assertText('go_y=[12]');
}
function testButtonSubmissionByLabel() {
$this->get($this->samples() . 'form.html');
$this->assertTrue($this->clickSubmit('Button go!', 10, 12));
$this->assertPattern('/go=\[ButtonGo\]/s');
}
function testNamelessSubmitSendsNoValue() {
$this->get($this->samples() . 'form_with_unnamed_submit.html');
$this->click('Go!');
$this->assertNoText('Go!');
$this->assertNoText('submit');
}
function testNamelessImageSendsXAndYValues() {
$this->get($this->samples() . 'form_with_unnamed_submit.html');
$this->clickImage('Image go!', 4, 5);
$this->assertNoText('ImageGo');
$this->assertText('x=[4]');
$this->assertText('y=[5]');
}
function testNamelessButtonSendsNoValue() {
$this->get($this->samples() . 'form_with_unnamed_submit.html');
$this->click('Button Go!');
$this->assertNoText('ButtonGo');
}
function testSelfSubmit() {
$this->get($this->samples() . 'self_form.php');
$this->assertNoText('[Submitted]');
$this->assertNoText('[Wrong form]');
$this->assertTrue($this->clickSubmit());
$this->assertText('[Submitted]');
$this->assertNoText('[Wrong form]');
$this->assertTitle('Test of form self submission');
}
function testSelfSubmitWithParameters() {
$this->get($this->samples() . 'self_form.php');
$this->setFieldByName('visible', 'Resent');
$this->assertTrue($this->clickSubmit());
$this->assertText('[Resent]');
}
function testSettingOfBlankOption() {
$this->get($this->samples() . 'form.html');
$this->assertTrue($this->setFieldByName('d', ''));
$this->clickSubmit('Go!');
$this->assertText('d=[]');
}
function testAssertingFieldValueWithPattern() {
$this->get($this->samples() . 'form.html');
$this->setField('c', 'A very long string');
$this->assertField('c', new PatternExpectation('/very long/'));
}
function testSendingMultipartFormDataEncodedForm() {
$this->get($this->samples() . 'form_data_encoded_form.html');
$this->assertField('Text A', '');
$this->assertField('Text B', 'Default text');
$this->assertField('Text area C', '');
$this->assertField('Selection D', 'd1');
$this->assertField('Checkbox E', false);
$this->assertField('Checkbox F', 'on');
$this->assertField('3', 'g3');
$this->assertField('Selection H', 2);
$this->setField('Text A', 'aaa');
$this->setField('Text B', 'bbb');
$this->setField('Text area C', 'ccc');
$this->setField('Selection D', 'D2');
$this->setField('Checkbox E', 'on');
$this->setField('Checkbox F', false);
$this->setField('2', 'g2');
$this->setField('Selection H', 'H1');
$this->assertTrue($this->clickSubmit('Go!'));
$this->assertText('a=[aaa]');
$this->assertText('b=[bbb]');
$this->assertText('c=[ccc]');
$this->assertText('d=[d2]');
$this->assertText('e=[on]');
$this->assertNoText('f=[');
$this->assertText('g=[g2]');
$this->assertText('h=[1]');
$this->assertText('go=[Go!]');
}
function testSettingVariousBlanksInFields() {
$this->get($this->samples() . 'form_with_false_defaults.html');
$this->assertField('Text A', '');
$this->setField('Text A', '0');
$this->assertField('Text A', '0');
$this->assertField('Text area B', '');
$this->setField('Text area B', '0');
$this->assertField('Text area B', '0');
$this->assertField('Selection D', '');
$this->setField('Selection D', 'D2');
$this->assertField('Selection D', 'D2');
$this->setField('Selection D', 'D3');
$this->assertField('Selection D', '0');
$this->setField('Selection D', 'D4');
$this->assertField('Selection D', '?');
$this->assertField('Checkbox E', '');
$this->assertField('Checkbox F', 'on');
$this->assertField('Checkbox G', '0');
$this->assertField('Checkbox H', '?');
$this->assertFieldByName('i', 'on');
$this->setFieldByName('i', '');
$this->assertFieldByName('i', '');
$this->setFieldByName('i', '0');
$this->assertFieldByName('i', '0');
$this->setFieldByName('i', '?');
$this->assertFieldByName('i', '?');
}
function testDefaultValueOfTextareaHasNewlinesAndWhitespacePreserved() {
$this->get($this->samples() . 'form_with_false_defaults.html');
$this->assertField('Text area C', ' ');
}
function chars($t) {
for ($i = 0; $i < strlen($t); $i++) {
print "[$t[$i]]";
}
}
function testSubmissionOfBlankFields() {
$this->get($this->samples() . 'form_with_false_defaults.html');
$this->setField('Text A', '');
$this->setField('Text area B', '');
$this->setFieldByName('i', '');
$this->click('Go!');
$this->assertText('a=[]');
$this->assertText('b=[]');
$this->assertText('d=[]');
$this->assertText('e=[]');
$this->assertText('i=[]');
}
function testDefaultValueOfTextareaHasNewlinesAndWhitespacePreservedOnSubmission() {
$this->get($this->samples() . 'form_with_false_defaults.html');
$this->click('Go!');
$this->assertPattern('/c=\[ \]/');
}
function testSubmissionOfEmptyValues() {
$this->get($this->samples() . 'form_with_false_defaults.html');
$this->setField('Selection D', 'D2');
$this->click('Go!');
$this->assertText('a=[]');
$this->assertText('b=[]');
$this->assertText('d=[D2]');
$this->assertText('f=[on]');
$this->assertText('i=[on]');
}
function testSubmissionOfZeroes() {
$this->get($this->samples() . 'form_with_false_defaults.html');
$this->setField('Text A', '0');
$this->setField('Text area B', '0');
$this->setField('Selection D', 'D3');
$this->setFieldByName('i', '0');
$this->click('Go!');
$this->assertText('a=[0]');
$this->assertText('b=[0]');
$this->assertText('d=[0]');
$this->assertText('g=[0]');
$this->assertText('i=[0]');
}
function testSubmissionOfQuestionMarks() {
$this->get($this->samples() . 'form_with_false_defaults.html');
$this->setField('Text A', '?');
$this->setField('Text area B', '?');
$this->setField('Selection D', 'D4');
$this->setFieldByName('i', '?');
$this->click('Go!');
$this->assertText('a=[?]');
$this->assertText('b=[?]');
$this->assertText('d=[?]');
$this->assertText('h=[?]');
$this->assertText('i=[?]');
}
function testSubmissionOfHtmlEncodedValues() {
$this->get($this->samples() . 'form_with_tricky_defaults.html');
$this->assertField('Text A', '&\'"<>');
$this->assertField('Text B', '"');
$this->assertField('Text area C', '&\'"<>');
$this->assertField('Selection D', "'");
$this->assertField('Checkbox E', '&\'"<>');
$this->assertField('Checkbox F', false);
$this->assertFieldByname('i', "'");
$this->click('Go!');
$this->assertText('a=[&\'"<>, "]');
$this->assertText('c=[&\'"<>]');
$this->assertText("d=[']");
$this->assertText('e=[&\'"<>]');
$this->assertText("i=[']");
}
function testFormActionRespectsBaseTag() {
$this->get($this->samples() . 'base_tag/form.html');
$this->assertTrue($this->clickSubmit('Go!'));
$this->assertText('go=[Go!]');
$this->assertText('a=[]');
}
}
class TestOfLiveMultiValueWidgets extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testDefaultFormValueSubmission() {
$this->get($this->samples() . 'multiple_widget_form.html');
$this->assertFieldByName('a', array('a2', 'a3'));
$this->assertFieldByName('b', array('b2', 'b3'));
$this->assertFieldByName('c[]', array('c2', 'c3'));
$this->assertFieldByName('d', array('2', '3'));
$this->assertFieldByName('e', array('2', '3'));
$this->assertTrue($this->clickSubmit('Go!'));
$this->assertText('a=[a2, a3]');
$this->assertText('b=[b2, b3]');
$this->assertText('c=[c2, c3]');
$this->assertText('d=[2, 3]');
$this->assertText('e=[2, 3]');
}
function testSubmittingMultipleValues() {
$this->get($this->samples() . 'multiple_widget_form.html');
$this->setFieldByName('a', array('a1', 'a4'));
$this->assertFieldByName('a', array('a1', 'a4'));
$this->assertFieldByName('a', array('a4', 'a1'));
$this->setFieldByName('b', array('b1', 'b4'));
$this->assertFieldByName('b', array('b1', 'b4'));
$this->setFieldByName('c[]', array('c1', 'c4'));
$this->assertField('c[]', array('c1', 'c4'));
$this->setFieldByName('d', array('1', '4'));
$this->assertField('d', array('1', '4'));
$this->setFieldByName('e', array('e1', 'e4'));
$this->assertField('e', array('1', '4'));
$this->assertTrue($this->clickSubmit('Go!'));
$this->assertText('a=[a1, a4]');
$this->assertText('b=[b1, b4]');
$this->assertText('c=[c1, c4]');
$this->assertText('d=[1, 4]');
$this->assertText('e=[1, 4]');
}
function testSettingByOptionValue() {
$this->get($this->samples() . 'multiple_widget_form.html');
$this->setFieldByName('d', array('1', '4'));
$this->assertField('d', array('1', '4'));
$this->assertTrue($this->clickSubmit('Go!'));
$this->assertText('d=[1, 4]');
}
function testSubmittingMultipleValuesByLabel() {
$this->get($this->samples() . 'multiple_widget_form.html');
$this->setField('Multiple selection A', array('a1', 'a4'));
$this->assertField('Multiple selection A', array('a1', 'a4'));
$this->assertField('Multiple selection A', array('a4', 'a1'));
$this->setField('multiple selection C', array('c1', 'c4'));
$this->assertField('multiple selection C', array('c1', 'c4'));
$this->assertTrue($this->clickSubmit('Go!'));
$this->assertText('a=[a1, a4]');
$this->assertText('c=[c1, c4]');
}
function testSavantStyleHiddenFieldDefaults() {
$this->get($this->samples() . 'savant_style_form.html');
$this->assertFieldByName('a', array('a0'));
$this->assertFieldByName('b', array('b0'));
$this->assertTrue($this->clickSubmit('Go!'));
$this->assertText('a=[a0]');
$this->assertText('b=[b0]');
}
function testSavantStyleHiddenDefaultsAreOverridden() {
$this->get($this->samples() . 'savant_style_form.html');
$this->assertTrue($this->setFieldByName('a', array('a1')));
$this->assertTrue($this->setFieldByName('b', 'b1'));
$this->assertTrue($this->clickSubmit('Go!'));
$this->assertText('a=[a1]');
$this->assertText('b=[b1]');
}
function testSavantStyleFormSettingById() {
$this->get($this->samples() . 'savant_style_form.html');
$this->assertFieldById(1, array('a0'));
$this->assertFieldById(4, array('b0'));
$this->assertTrue($this->setFieldById(2, 'a1'));
$this->assertTrue($this->setFieldById(5, 'b1'));
$this->assertTrue($this->clickSubmitById(99));
$this->assertText('a=[a1]');
$this->assertText('b=[b1]');
}
}
class TestOfFileUploads extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testSingleFileUpload() {
$this->get($this->samples() . 'upload_form.html');
$this->assertTrue($this->setField('Content:',
dirname(__FILE__) . '/support/upload_sample.txt'));
$this->assertField('Content:', dirname(__FILE__) . '/support/upload_sample.txt');
$this->click('Go!');
$this->assertText('Sample for testing file upload');
}
function testMultipleFileUpload() {
$this->get($this->samples() . 'upload_form.html');
$this->assertTrue($this->setField('Content:',
dirname(__FILE__) . '/support/upload_sample.txt'));
$this->assertTrue($this->setField('Supplemental:',
dirname(__FILE__) . '/support/supplementary_upload_sample.txt'));
$this->assertField('Supplemental:',
dirname(__FILE__) . '/support/supplementary_upload_sample.txt');
$this->click('Go!');
$this->assertText('Sample for testing file upload');
$this->assertText('Some more text content');
}
function testBinaryFileUpload() {
$this->get($this->samples() . 'upload_form.html');
$this->assertTrue($this->setField('Content:',
dirname(__FILE__) . '/support/latin1_sample'));
$this->click('Go!');
$this->assertText(
implode('', file(dirname(__FILE__) . '/support/latin1_sample')));
}
}
class TestOfLiveHistoryNavigation extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testRetry() {
$this->get($this->samples() . 'cookie_based_counter.php');
$this->assertPattern('/count: 1/i');
$this->retry();
$this->assertPattern('/count: 2/i');
$this->retry();
$this->assertPattern('/count: 3/i');
}
function testOfBackButton() {
$this->get($this->samples() . '1.html');
$this->clickLink('2');
$this->assertTitle('2');
$this->assertTrue($this->back());
$this->assertTitle('1');
$this->assertTrue($this->forward());
$this->assertTitle('2');
$this->assertFalse($this->forward());
}
function testGetRetryResubmitsData() {
$this->assertTrue($this->get(
$this->samples() . 'network_confirm.php?a=aaa'));
$this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
$this->assertText('a=[aaa]');
$this->retry();
$this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
$this->assertText('a=[aaa]');
}
function testGetRetryResubmitsExtraData() {
$this->assertTrue($this->get(
$this->samples() . 'network_confirm.php',
array('a' => 'aaa')));
$this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
$this->assertText('a=[aaa]');
$this->retry();
$this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
$this->assertText('a=[aaa]');
}
function testPostRetryResubmitsData() {
$this->assertTrue($this->post(
$this->samples() . 'network_confirm.php',
array('a' => 'aaa')));
$this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
$this->assertText('a=[aaa]');
$this->retry();
$this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
$this->assertText('a=[aaa]');
}
function testGetRetryResubmitsRepeatedData() {
$this->assertTrue($this->get(
$this->samples() . 'network_confirm.php?a=1&a=2'));
$this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
$this->assertText('a=[1, 2]');
$this->retry();
$this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
$this->assertText('a=[1, 2]');
}
}
class TestOfLiveAuthentication extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testChallengeFromProtectedPage() {
$this->get($this->samples() . 'protected/');
$this->assertResponse(401);
$this->assertAuthentication('Basic');
$this->assertRealm('SimpleTest basic authentication');
$this->assertRealm(new PatternExpectation('/simpletest/i'));
$this->authenticate('test', 'secret');
$this->assertResponse(200);
$this->retry();
$this->assertResponse(200);
}
function testTrailingSlashImpliedWithinRealm() {
$this->get($this->samples() . 'protected/');
$this->authenticate('test', 'secret');
$this->assertResponse(200);
$this->get($this->samples() . 'protected');
$this->assertResponse(200);
}
function testTrailingSlashImpliedSettingRealm() {
$this->get($this->samples() . 'protected');
$this->authenticate('test', 'secret');
$this->assertResponse(200);
$this->get($this->samples() . 'protected/');
$this->assertResponse(200);
}
function testEncodedAuthenticationFetchesPage() {
$this->get('http://test:secret@www.lastcraft.com/test/protected/');
$this->assertResponse(200);
}
function testEncodedAuthenticationFetchesPageAfterTrailingSlashRedirect() {
$this->get('http://test:secret@www.lastcraft.com/test/protected');
$this->assertResponse(200);
}
function testRealmExtendsToWholeDirectory() {
$this->get($this->samples() . 'protected/1.html');
$this->authenticate('test', 'secret');
$this->clickLink('2');
$this->assertResponse(200);
$this->clickLink('3');
$this->assertResponse(200);
}
function testRedirectKeepsAuthentication() {
$this->get($this->samples() . 'protected/local_redirect.php');
$this->authenticate('test', 'secret');
$this->assertTitle('Simple test target file');
}
function testRedirectKeepsEncodedAuthentication() {
$this->get('http://test:secret@www.lastcraft.com/test/protected/local_redirect.php');
$this->assertResponse(200);
$this->assertTitle('Simple test target file');
}
function testSessionRestartLosesAuthentication() {
$this->get($this->samples() . 'protected/');
$this->authenticate('test', 'secret');
$this->assertResponse(200);
$this->restart();
$this->get($this->samples() . 'protected/');
$this->assertResponse(401);
}
}
class TestOfLoadingFrames extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testNoFramesContentWhenFramesDisabled() {
$this->ignoreFrames();
$this->get($this->samples() . 'one_page_frameset.html');
$this->assertTitle('Frameset for testing of SimpleTest');
$this->assertText('This content is for no frames only');
}
function testPatternMatchCanReadTheOnlyFrame() {
$this->get($this->samples() . 'one_page_frameset.html');
$this->assertText('A target for the SimpleTest test suite');
$this->assertNoText('This content is for no frames only');
}
function testMessyFramesetResponsesByName() {
$this->assertTrue($this->get(
$this->samples() . 'messy_frameset.html'));
$this->assertTitle('Frameset for testing of SimpleTest');
$this->assertTrue($this->setFrameFocus('Front controller'));
$this->assertResponse(200);
$this->assertText('Simple test front controller');
$this->assertTrue($this->setFrameFocus('One'));
$this->assertResponse(200);
$this->assertLink('2');
$this->assertTrue($this->setFrameFocus('Frame links'));
$this->assertResponse(200);
$this->assertLink('Set one to 2');
$this->assertTrue($this->setFrameFocus('Counter'));
$this->assertResponse(200);
$this->assertText('Count: 1');
$this->assertTrue($this->setFrameFocus('Redirected'));
$this->assertResponse(200);
$this->assertText('r=rrr');
$this->assertTrue($this->setFrameFocus('Protected'));
$this->assertResponse(401);
$this->assertTrue($this->setFrameFocus('Protected redirect'));
$this->assertResponse(401);
$this->assertTrue($this->setFrameFocusByIndex(1));
$this->assertResponse(200);
$this->assertText('Simple test front controller');
$this->assertTrue($this->setFrameFocusByIndex(2));
$this->assertResponse(200);
$this->assertLink('2');
$this->assertTrue($this->setFrameFocusByIndex(3));
$this->assertResponse(200);
$this->assertLink('Set one to 2');
$this->assertTrue($this->setFrameFocusByIndex(4));
$this->assertResponse(200);
$this->assertText('Count: 1');
$this->assertTrue($this->setFrameFocusByIndex(5));
$this->assertResponse(200);
$this->assertText('r=rrr');
$this->assertTrue($this->setFrameFocusByIndex(6));
$this->assertResponse(401);
$this->assertTrue($this->setFrameFocusByIndex(7));
}
function testReloadingFramesetPage() {
$this->get($this->samples() . 'messy_frameset.html');
$this->assertText('Count: 1');
$this->retry();
$this->assertText('Count: 2');
$this->retry();
$this->assertText('Count: 3');
}
function testReloadingSingleFrameWithCookieCounter() {
$this->get($this->samples() . 'counting_frameset.html');
$this->setFrameFocus('a');
$this->assertText('Count: 1');
$this->setFrameFocus('b');
$this->assertText('Count: 2');
$this->setFrameFocus('a');
$this->retry();
$this->assertText('Count: 3');
$this->retry();
$this->assertText('Count: 4');
$this->setFrameFocus('b');
$this->assertText('Count: 2');
}
function testReloadingFrameWhenUnfocusedReloadsWholeFrameset() {
$this->get($this->samples() . 'counting_frameset.html');
$this->setFrameFocus('a');
$this->assertText('Count: 1');
$this->setFrameFocus('b');
$this->assertText('Count: 2');
$this->clearFrameFocus('a');
$this->retry();
$this->assertTitle('Frameset for testing of SimpleTest');
$this->setFrameFocus('a');
$this->assertText('Count: 3');
$this->setFrameFocus('b');
$this->assertText('Count: 4');
}
function testClickingNormalLinkReplacesJustThatFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->clickLink('2');
$this->assertLink('3');
$this->assertText('Simple test front controller');
}
function testJumpToNamedPageReplacesJustThatFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->assertPattern('/Simple test front controller/');
$this->clickLink('Index');
$this->assertResponse(200);
$this->assertText('[action=index]');
$this->assertText('Count: 1');
}
function testJumpToUnnamedPageReplacesJustThatFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->clickLink('No page');
$this->assertResponse(200);
$this->assertText('Simple test front controller');
$this->assertText('[action=no_page]');
$this->assertText('Count: 1');
}
function testJumpToUnnamedPageWithBareParameterReplacesJustThatFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->clickLink('Bare action');
$this->assertResponse(200);
$this->assertText('Simple test front controller');
$this->assertText('[action=]');
$this->assertText('Count: 1');
}
function testJumpToUnnamedPageWithEmptyQueryReplacesJustThatFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->clickLink('Empty query');
$this->assertResponse(200);
$this->assertPattern('/Simple test front controller/');
$this->assertPattern('/raw get data.*?\[\].*?get data/si');
$this->assertPattern('/Count: 1/');
}
function testJumpToUnnamedPageWithEmptyLinkReplacesJustThatFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->clickLink('Empty link');
$this->assertResponse(200);
$this->assertPattern('/Simple test front controller/');
$this->assertPattern('/raw get data.*?\[\].*?get data/si');
$this->assertPattern('/Count: 1/');
}
function testJumpBackADirectoryLevelReplacesJustThatFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->clickLink('Down one');
$this->assertPattern('/index of .*\/test/i');
$this->assertPattern('/Count: 1/');
}
function testSubmitToNamedPageReplacesJustThatFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->assertPattern('/Simple test front controller/');
$this->clickSubmit('Index');
$this->assertResponse(200);
$this->assertText('[action=Index]');
$this->assertText('Count: 1');
}
function testSubmitToSameDirectoryReplacesJustThatFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->clickSubmit('Same directory');
$this->assertResponse(200);
$this->assertText('[action=Same+directory]');
$this->assertText('Count: 1');
}
function testSubmitToEmptyActionReplacesJustThatFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->clickSubmit('Empty action');
$this->assertResponse(200);
$this->assertText('[action=Empty+action]');
$this->assertText('Count: 1');
}
function testSubmitToNoActionReplacesJustThatFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->clickSubmit('No action');
$this->assertResponse(200);
$this->assertText('[action=No+action]');
$this->assertText('Count: 1');
}
function testSubmitBackADirectoryLevelReplacesJustThatFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->clickSubmit('Down one');
$this->assertPattern('/index of .*\/test/i');
$this->assertPattern('/Count: 1/');
}
function testTopLinkExitsFrameset() {
$this->get($this->samples() . 'messy_frameset.html');
$this->clickLink('Exit the frameset');
$this->assertTitle('Simple test target file');
}
function testLinkInOnePageCanLoadAnother() {
$this->get($this->samples() . 'messy_frameset.html');
$this->assertNoLink('3');
$this->clickLink('Set one to 2');
$this->assertLink('3');
$this->assertNoLink('2');
$this->assertTitle('Frameset for testing of SimpleTest');
}
function testFrameWithRelativeLinksRespectsBaseTagForThatPage() {
$this->get($this->samples() . 'base_tag/frameset.html');
$this->click('Back to test pages');
$this->assertTitle('Frameset for testing of SimpleTest');
$this->assertText('A target for the SimpleTest test suite');
}
function testRelativeLinkInFrameIsNotAffectedByFramesetBaseTag() {
$this->get($this->samples() . 'base_tag/frameset_with_base_tag.html');
$this->assertText('This is page 1');
$this->click('To page 2');
$this->assertTitle('Frameset for testing of SimpleTest');
$this->assertText('This is page 2');
}
}
class TestOfFrameAuthentication extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testUnauthenticatedFrameSendsChallenge() {
$this->get($this->samples() . 'protected/');
$this->setFrameFocus('Protected');
$this->assertAuthentication('Basic');
$this->assertRealm('SimpleTest basic authentication');
$this->assertResponse(401);
}
function testCanReadFrameFromAlreadyAuthenticatedRealm() {
$this->get($this->samples() . 'protected/');
$this->authenticate('test', 'secret');
$this->get($this->samples() . 'messy_frameset.html');
$this->setFrameFocus('Protected');
$this->assertResponse(200);
$this->assertText('A target for the SimpleTest test suite');
}
function testCanAuthenticateFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->setFrameFocus('Protected');
$this->authenticate('test', 'secret');
$this->assertResponse(200);
$this->assertText('A target for the SimpleTest test suite');
$this->clearFrameFocus();
$this->assertText('Count: 1');
}
function testCanAuthenticateRedirectedFrame() {
$this->get($this->samples() . 'messy_frameset.html');
$this->setFrameFocus('Protected redirect');
$this->assertResponse(401);
$this->authenticate('test', 'secret');
$this->assertResponse(200);
$this->assertText('A target for the SimpleTest test suite');
$this->clearFrameFocus();
$this->assertText('Count: 1');
}
}
class TestOfNestedFrames extends SimpleTestAcceptanceTest {
function setUp() {
$this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
}
function testCanNavigateToSpecificContent() {
$this->get($this->samples() . 'nested_frameset.html');
$this->assertTitle('Nested frameset for testing of SimpleTest');
$this->assertPattern('/This is frame A/');
$this->assertPattern('/This is frame B/');
$this->assertPattern('/Simple test front controller/');
$this->assertLink('2');
$this->assertLink('Set one to 2');
$this->assertPattern('/Count: 1/');
$this->assertPattern('/r=rrr/');
$this->setFrameFocus('pair');
$this->assertPattern('/This is frame A/');
$this->assertPattern('/This is frame B/');
$this->assertNoPattern('/Simple test front controller/');
$this->assertNoLink('2');
$this->setFrameFocus('aaa');
$this->assertPattern('/This is frame A/');
$this->assertNoPattern('/This is frame B/');
$this->clearFrameFocus();
$this->assertResponse(200);
$this->setFrameFocus('messy');
$this->assertResponse(200);
$this->setFrameFocus('Front controller');
$this->assertResponse(200);
$this->assertPattern('/Simple test front controller/');
$this->assertNoLink('2');
}
function testReloadingFramesetPage() {
$this->get($this->samples() . 'nested_frameset.html');
$this->assertPattern('/Count: 1/');
$this->retry();
$this->assertPattern('/Count: 2/');
$this->retry();
$this->assertPattern('/Count: 3/');
}
function testRetryingNestedPageOnlyRetriesThatSet() {
$this->get($this->samples() . 'nested_frameset.html');
$this->assertPattern('/Count: 1/');
$this->setFrameFocus('messy');
$this->retry();
$this->assertPattern('/Count: 2/');
$this->setFrameFocus('Counter');
$this->retry();
$this->assertPattern('/Count: 3/');
$this->clearFrameFocus();
$this->setFrameFocus('messy');
$this->setFrameFocus('Front controller');
$this->retry();
$this->clearFrameFocus();
$this->assertPattern('/Count: 3/');
}
function testAuthenticatingNestedPage() {
$this->get($this->samples() . 'nested_frameset.html');
$this->setFrameFocus('messy');
$this->setFrameFocus('Protected');
$this->assertAuthentication('Basic');
$this->assertRealm('SimpleTest basic authentication');
$this->assertResponse(401);
$this->authenticate('test', 'secret');
$this->assertResponse(200);
$this->assertPattern('/A target for the SimpleTest test suite/');
}
}
?> | 10npsite | trunk/simpletest/test/acceptance_test.php | PHP | asf20 | 66,569 |
<?php
// $Id: reflection_php5_test.php 1778 2008-04-21 16:13:08Z edwardzyang $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../reflection_php5.php');
class AnyOldLeafClass {
function aMethod() { }
}
abstract class AnyOldClass {
function aMethod() { }
}
class AnyOldLeafClassWithAFinal {
final function aMethod() { }
}
interface AnyOldInterface {
function aMethod();
}
interface AnyOldArgumentInterface {
function aMethod(AnyOldInterface $argument);
}
interface AnyDescendentInterface extends AnyOldInterface {
}
class AnyOldImplementation implements AnyOldInterface {
function aMethod() { }
function extraMethod() { }
}
abstract class AnyAbstractImplementation implements AnyOldInterface {
}
abstract class AnotherOldAbstractClass {
protected abstract function aMethod(AnyOldInterface $argument);
}
class AnyOldSubclass extends AnyOldImplementation { }
class AnyOldArgumentClass {
function aMethod($argument) { }
}
class AnyOldArgumentImplementation implements AnyOldArgumentInterface {
function aMethod(AnyOldInterface $argument) { }
}
class AnyOldTypeHintedClass implements AnyOldArgumentInterface {
function aMethod(AnyOldInterface $argument) { }
}
class AnyDescendentImplementation implements AnyDescendentInterface {
function aMethod() { }
}
class AnyOldOverloadedClass {
function __isset($key) { }
function __unset($key) { }
}
class AnyOldClassWithStaticMethods {
static function aStatic() { }
static function aStaticWithParameters($arg1, $arg2) { }
}
abstract class AnyOldAbstractClassWithAbstractMethods {
abstract function anAbstract();
abstract function anAbstractWithParameter($foo);
abstract function anAbstractWithMultipleParameters($foo, $bar);
}
class TestOfReflection extends UnitTestCase {
function testClassExistence() {
$reflection = new SimpleReflection('AnyOldLeafClass');
$this->assertTrue($reflection->classOrInterfaceExists());
$this->assertTrue($reflection->classOrInterfaceExistsSansAutoload());
$this->assertFalse($reflection->isAbstract());
$this->assertFalse($reflection->isInterface());
}
function testClassNonExistence() {
$reflection = new SimpleReflection('UnknownThing');
$this->assertFalse($reflection->classOrInterfaceExists());
$this->assertFalse($reflection->classOrInterfaceExistsSansAutoload());
}
function testDetectionOfAbstractClass() {
$reflection = new SimpleReflection('AnyOldClass');
$this->assertTrue($reflection->isAbstract());
}
function testDetectionOfFinalMethods() {
$reflection = new SimpleReflection('AnyOldClass');
$this->assertFalse($reflection->hasFinal());
$reflection = new SimpleReflection('AnyOldLeafClassWithAFinal');
$this->assertTrue($reflection->hasFinal());
}
function testFindingParentClass() {
$reflection = new SimpleReflection('AnyOldSubclass');
$this->assertEqual($reflection->getParent(), 'AnyOldImplementation');
}
function testInterfaceExistence() {
$reflection = new SimpleReflection('AnyOldInterface');
$this->assertTrue($reflection->classOrInterfaceExists());
$this->assertTrue($reflection->classOrInterfaceExistsSansAutoload());
$this->assertTrue($reflection->isInterface());
}
function testMethodsListFromClass() {
$reflection = new SimpleReflection('AnyOldClass');
$this->assertIdentical($reflection->getMethods(), array('aMethod'));
}
function testMethodsListFromInterface() {
$reflection = new SimpleReflection('AnyOldInterface');
$this->assertIdentical($reflection->getMethods(), array('aMethod'));
$this->assertIdentical($reflection->getInterfaceMethods(), array('aMethod'));
}
function testMethodsComeFromDescendentInterfacesASWell() {
$reflection = new SimpleReflection('AnyDescendentInterface');
$this->assertIdentical($reflection->getMethods(), array('aMethod'));
}
function testCanSeparateInterfaceMethodsFromOthers() {
$reflection = new SimpleReflection('AnyOldImplementation');
$this->assertIdentical($reflection->getMethods(), array('aMethod', 'extraMethod'));
$this->assertIdentical($reflection->getInterfaceMethods(), array('aMethod'));
}
function testMethodsComeFromDescendentInterfacesInAbstractClass() {
$reflection = new SimpleReflection('AnyAbstractImplementation');
$this->assertIdentical($reflection->getMethods(), array('aMethod'));
}
function testInterfaceHasOnlyItselfToImplement() {
$reflection = new SimpleReflection('AnyOldInterface');
$this->assertEqual(
$reflection->getInterfaces(),
array('AnyOldInterface'));
}
function testInterfacesListedForClass() {
$reflection = new SimpleReflection('AnyOldImplementation');
$this->assertEqual(
$reflection->getInterfaces(),
array('AnyOldInterface'));
}
function testInterfacesListedForSubclass() {
$reflection = new SimpleReflection('AnyOldSubclass');
$this->assertEqual(
$reflection->getInterfaces(),
array('AnyOldInterface'));
}
function testNoParameterCreationWhenNoInterface() {
$reflection = new SimpleReflection('AnyOldArgumentClass');
$function = $reflection->getSignature('aMethod');
if (version_compare(phpversion(), '5.0.2', '<=')) {
$this->assertEqual('function amethod($argument)', strtolower($function));
} else {
$this->assertEqual('function aMethod($argument)', $function);
}
}
function testParameterCreationWithoutTypeHinting() {
$reflection = new SimpleReflection('AnyOldArgumentImplementation');
$function = $reflection->getSignature('aMethod');
if (version_compare(phpversion(), '5.0.2', '<=')) {
$this->assertEqual('function amethod(AnyOldInterface $argument)', $function);
} else {
$this->assertEqual('function aMethod(AnyOldInterface $argument)', $function);
}
}
function testParameterCreationForTypeHinting() {
$reflection = new SimpleReflection('AnyOldTypeHintedClass');
$function = $reflection->getSignature('aMethod');
if (version_compare(phpversion(), '5.0.2', '<=')) {
$this->assertEqual('function amethod(AnyOldInterface $argument)', $function);
} else {
$this->assertEqual('function aMethod(AnyOldInterface $argument)', $function);
}
}
function testIssetFunctionSignature() {
$reflection = new SimpleReflection('AnyOldOverloadedClass');
$function = $reflection->getSignature('__isset');
$this->assertEqual('function __isset($key)', $function);
}
function testUnsetFunctionSignature() {
$reflection = new SimpleReflection('AnyOldOverloadedClass');
$function = $reflection->getSignature('__unset');
$this->assertEqual('function __unset($key)', $function);
}
function testProperlyReflectsTheFinalInterfaceWhenObjectImplementsAnExtendedInterface() {
$reflection = new SimpleReflection('AnyDescendentImplementation');
$interfaces = $reflection->getInterfaces();
$this->assertEqual(1, count($interfaces));
$this->assertEqual('AnyDescendentInterface', array_shift($interfaces));
}
function testCreatingSignatureForAbstractMethod() {
$reflection = new SimpleReflection('AnotherOldAbstractClass');
$this->assertEqual($reflection->getSignature('aMethod'), 'function aMethod(AnyOldInterface $argument)');
}
function testCanProperlyGenerateStaticMethodSignatures() {
$reflection = new SimpleReflection('AnyOldClassWithStaticMethods');
$this->assertEqual('static function aStatic()', $reflection->getSignature('aStatic'));
$this->assertEqual(
'static function aStaticWithParameters($arg1, $arg2)',
$reflection->getSignature('aStaticWithParameters')
);
}
}
class TestOfReflectionWithTypeHints extends UnitTestCase {
function skip() {
$this->skipIf(version_compare(phpversion(), '5.1.0', '<'), 'Reflection with type hints only tested for PHP 5.1.0 and above');
}
function testParameterCreationForTypeHintingWithArray() {
eval('interface AnyOldArrayTypeHintedInterface {
function amethod(array $argument);
}
class AnyOldArrayTypeHintedClass implements AnyOldArrayTypeHintedInterface {
function amethod(array $argument) {}
}');
$reflection = new SimpleReflection('AnyOldArrayTypeHintedClass');
$function = $reflection->getSignature('amethod');
$this->assertEqual('function amethod(array $argument)', $function);
}
}
class TestOfAbstractsWithAbstractMethods extends UnitTestCase {
function testCanProperlyGenerateAbstractMethods() {
$reflection = new SimpleReflection('AnyOldAbstractClassWithAbstractMethods');
$this->assertEqual(
'function anAbstract()',
$reflection->getSignature('anAbstract')
);
$this->assertEqual(
'function anAbstractWithParameter($foo)',
$reflection->getSignature('anAbstractWithParameter')
);
$this->assertEqual(
'function anAbstractWithMultipleParameters($foo, $bar)',
$reflection->getSignature('anAbstractWithMultipleParameters')
);
}
}
?> | 10npsite | trunk/simpletest/test/reflection_php5_test.php | PHP | asf20 | 8,864 |
<?php
// $Id: expectation_test.php 2009 2011-04-28 08:57:25Z pp11 $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../expectation.php');
class TestOfEquality extends UnitTestCase {
function testBoolean() {
$is_true = new EqualExpectation(true);
$this->assertTrue($is_true->test(true));
$this->assertFalse($is_true->test(false));
}
function testStringMatch() {
$hello = new EqualExpectation("Hello");
$this->assertTrue($hello->test("Hello"));
$this->assertFalse($hello->test("Goodbye"));
}
function testInteger() {
$fifteen = new EqualExpectation(15);
$this->assertTrue($fifteen->test(15));
$this->assertFalse($fifteen->test(14));
}
function testFloat() {
$pi = new EqualExpectation(3.14);
$this->assertTrue($pi->test(3.14));
$this->assertFalse($pi->test(3.15));
}
function testArray() {
$colours = new EqualExpectation(array("r", "g", "b"));
$this->assertTrue($colours->test(array("r", "g", "b")));
$this->assertFalse($colours->test(array("g", "b", "r")));
}
function testHash() {
$is_blue = new EqualExpectation(array("r" => 0, "g" => 0, "b" => 255));
$this->assertTrue($is_blue->test(array("r" => 0, "g" => 0, "b" => 255)));
$this->assertFalse($is_blue->test(array("r" => 0, "g" => 255, "b" => 0)));
}
function testHashWithOutOfOrderKeysShouldStillMatch() {
$any_order = new EqualExpectation(array('a' => 1, 'b' => 2));
$this->assertTrue($any_order->test(array('b' => 2, 'a' => 1)));
}
}
class TestOfWithin extends UnitTestCase {
function testWithinFloatingPointMargin() {
$within = new WithinMarginExpectation(1.0, 0.2);
$this->assertFalse($within->test(0.7));
$this->assertTrue($within->test(0.8));
$this->assertTrue($within->test(0.9));
$this->assertTrue($within->test(1.1));
$this->assertTrue($within->test(1.2));
$this->assertFalse($within->test(1.3));
}
function testOutsideFloatingPointMargin() {
$within = new OutsideMarginExpectation(1.0, 0.2);
$this->assertTrue($within->test(0.7));
$this->assertFalse($within->test(0.8));
$this->assertFalse($within->test(1.2));
$this->assertTrue($within->test(1.3));
}
}
class TestOfInequality extends UnitTestCase {
function testStringMismatch() {
$not_hello = new NotEqualExpectation("Hello");
$this->assertTrue($not_hello->test("Goodbye"));
$this->assertFalse($not_hello->test("Hello"));
}
}
class RecursiveNasty {
private $me;
function RecursiveNasty() {
$this->me = $this;
}
}
class OpaqueContainer {
private $stuff;
private $value;
public function __construct($value) {
$this->value = $value;
}
}
class DerivedOpaqueContainer extends OpaqueContainer {
// Deliberately have a variable whose name with the same suffix as a later
// variable
private $new_value = 1;
// Deliberately obscures the variable of the same name in the base
// class.
private $value;
public function __construct($value, $base_value) {
parent::__construct($base_value);
$this->value = $value;
}
}
class TestOfIdentity extends UnitTestCase {
function testType() {
$string = new IdenticalExpectation("37");
$this->assertTrue($string->test("37"));
$this->assertFalse($string->test(37));
$this->assertFalse($string->test("38"));
}
function _testNastyPhp5Bug() {
$this->assertFalse(new RecursiveNasty() != new RecursiveNasty());
}
function _testReallyHorribleRecursiveStructure() {
$hopeful = new IdenticalExpectation(new RecursiveNasty());
$this->assertTrue($hopeful->test(new RecursiveNasty()));
}
function testCanComparePrivateMembers() {
$expectFive = new IdenticalExpectation(new OpaqueContainer(5));
$this->assertTrue($expectFive->test(new OpaqueContainer(5)));
$this->assertFalse($expectFive->test(new OpaqueContainer(6)));
}
function testCanComparePrivateMembersOfObjectsInArrays() {
$expectFive = new IdenticalExpectation(array(new OpaqueContainer(5)));
$this->assertTrue($expectFive->test(array(new OpaqueContainer(5))));
$this->assertFalse($expectFive->test(array(new OpaqueContainer(6))));
}
function testCanComparePrivateMembersOfObjectsWherePrivateMemberOfBaseClassIsObscured() {
$expectFive = new IdenticalExpectation(array(new DerivedOpaqueContainer(1,2)));
$this->assertTrue($expectFive->test(array(new DerivedOpaqueContainer(1,2))));
$this->assertFalse($expectFive->test(array(new DerivedOpaqueContainer(0,2))));
$this->assertFalse($expectFive->test(array(new DerivedOpaqueContainer(0,9))));
$this->assertFalse($expectFive->test(array(new DerivedOpaqueContainer(1,0))));
}
}
class TransparentContainer {
public $value;
public function __construct($value) {
$this->value = $value;
}
}
class TestOfMemberComparison extends UnitTestCase {
function testMemberExpectationCanMatchPublicMember() {
$expect_five = new MemberExpectation('value', 5);
$this->assertTrue($expect_five->test(new TransparentContainer(5)));
$this->assertFalse($expect_five->test(new TransparentContainer(8)));
}
function testMemberExpectationCanMatchPrivateMember() {
$expect_five = new MemberExpectation('value', 5);
$this->assertTrue($expect_five->test(new OpaqueContainer(5)));
$this->assertFalse($expect_five->test(new OpaqueContainer(8)));
}
function testMemberExpectationCanMatchPrivateMemberObscuredByDerivedClass() {
$expect_five = new MemberExpectation('value', 5);
$this->assertTrue($expect_five->test(new DerivedOpaqueContainer(5,8)));
$this->assertTrue($expect_five->test(new DerivedOpaqueContainer(5,5)));
$this->assertFalse($expect_five->test(new DerivedOpaqueContainer(8,8)));
$this->assertFalse($expect_five->test(new DerivedOpaqueContainer(8,5)));
}
}
class DummyReferencedObject{}
class TestOfReference extends UnitTestCase {
function testReference() {
$foo = "foo";
$ref = &$foo;
$not_ref = $foo;
$bar = "bar";
$expect = new ReferenceExpectation($foo);
$this->assertTrue($expect->test($ref));
$this->assertFalse($expect->test($not_ref));
$this->assertFalse($expect->test($bar));
}
}
class TestOfNonIdentity extends UnitTestCase {
function testType() {
$string = new NotIdenticalExpectation("37");
$this->assertTrue($string->test("38"));
$this->assertTrue($string->test(37));
$this->assertFalse($string->test("37"));
}
}
class TestOfPatterns extends UnitTestCase {
function testWanted() {
$pattern = new PatternExpectation('/hello/i');
$this->assertTrue($pattern->test("Hello world"));
$this->assertFalse($pattern->test("Goodbye world"));
}
function testUnwanted() {
$pattern = new NoPatternExpectation('/hello/i');
$this->assertFalse($pattern->test("Hello world"));
$this->assertTrue($pattern->test("Goodbye world"));
}
}
class ExpectedMethodTarget {
function hasThisMethod() {}
}
class TestOfMethodExistence extends UnitTestCase {
function testHasMethod() {
$instance = new ExpectedMethodTarget();
$expectation = new MethodExistsExpectation('hasThisMethod');
$this->assertTrue($expectation->test($instance));
$expectation = new MethodExistsExpectation('doesNotHaveThisMethod');
$this->assertFalse($expectation->test($instance));
}
}
class TestOfIsA extends UnitTestCase {
function testString() {
$expectation = new IsAExpectation('string');
$this->assertTrue($expectation->test('Hello'));
$this->assertFalse($expectation->test(5));
}
function testBoolean() {
$expectation = new IsAExpectation('boolean');
$this->assertTrue($expectation->test(true));
$this->assertFalse($expectation->test(1));
}
function testBool() {
$expectation = new IsAExpectation('bool');
$this->assertTrue($expectation->test(true));
$this->assertFalse($expectation->test(1));
}
function testDouble() {
$expectation = new IsAExpectation('double');
$this->assertTrue($expectation->test(5.0));
$this->assertFalse($expectation->test(5));
}
function testFloat() {
$expectation = new IsAExpectation('float');
$this->assertTrue($expectation->test(5.0));
$this->assertFalse($expectation->test(5));
}
function testReal() {
$expectation = new IsAExpectation('real');
$this->assertTrue($expectation->test(5.0));
$this->assertFalse($expectation->test(5));
}
function testInteger() {
$expectation = new IsAExpectation('integer');
$this->assertTrue($expectation->test(5));
$this->assertFalse($expectation->test(5.0));
}
function testInt() {
$expectation = new IsAExpectation('int');
$this->assertTrue($expectation->test(5));
$this->assertFalse($expectation->test(5.0));
}
function testScalar() {
$expectation = new IsAExpectation('scalar');
$this->assertTrue($expectation->test(5));
$this->assertFalse($expectation->test(array(5)));
}
function testNumeric() {
$expectation = new IsAExpectation('numeric');
$this->assertTrue($expectation->test(5));
$this->assertFalse($expectation->test('string'));
}
function testNull() {
$expectation = new IsAExpectation('null');
$this->assertTrue($expectation->test(null));
$this->assertFalse($expectation->test('string'));
}
}
class TestOfNotA extends UnitTestCase {
function testString() {
$expectation = new NotAExpectation('string');
$this->assertFalse($expectation->test('Hello'));
$this->assertTrue($expectation->test(5));
}
}
?> | 10npsite | trunk/simpletest/test/expectation_test.php | PHP | asf20 | 10,243 |
<?php
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../errors.php');
require_once(dirname(__FILE__) . '/../expectation.php');
require_once(dirname(__FILE__) . '/../test_case.php');
Mock::generate('SimpleTestCase');
Mock::generate('SimpleExpectation');
SimpleTest::ignore('MockSimpleTestCase');
class TestOfErrorQueue extends UnitTestCase {
function setUp() {
$context = SimpleTest::getContext();
$queue = $context->get('SimpleErrorQueue');
$queue->clear();
}
function tearDown() {
$context = SimpleTest::getContext();
$queue = $context->get('SimpleErrorQueue');
$queue->clear();
}
function testExpectationMatchCancelsIncomingError() {
$test = new MockSimpleTestCase();
$test->expectOnce('assert', array(
new IdenticalExpectation(new AnythingExpectation()),
'B',
'a message'));
$test->setReturnValue('assert', true);
$test->expectNever('error');
$queue = new SimpleErrorQueue();
$queue->setTestCase($test);
$queue->expectError(new AnythingExpectation(), 'a message');
$queue->add(1024, 'B', 'b.php', 100);
}
}
class TestOfErrorTrap extends UnitTestCase {
private $old;
function setUp() {
$this->old = error_reporting(E_ALL);
set_error_handler('SimpleTestErrorHandler');
}
function tearDown() {
restore_error_handler();
error_reporting($this->old);
}
function testQueueStartsEmpty() {
$context = SimpleTest::getContext();
$queue = $context->get('SimpleErrorQueue');
$this->assertFalse($queue->extract());
}
function testErrorsAreSwallowedByMatchingExpectation() {
$this->expectError('Ouch!');
trigger_error('Ouch!');
}
function testErrorsAreSwallowedInOrder() {
$this->expectError('a');
$this->expectError('b');
trigger_error('a');
trigger_error('b');
}
function testAnyErrorCanBeSwallowed() {
$this->expectError();
trigger_error('Ouch!');
}
function testErrorCanBeSwallowedByPatternMatching() {
$this->expectError(new PatternExpectation('/ouch/i'));
trigger_error('Ouch!');
}
function testErrorWithPercentsPassesWithNoSprintfError() {
$this->expectError("%");
trigger_error('%');
}
}
class TestOfErrors extends UnitTestCase {
private $old;
function setUp() {
$this->old = error_reporting(E_ALL);
}
function tearDown() {
error_reporting($this->old);
}
function testDefaultWhenAllReported() {
error_reporting(E_ALL);
$this->expectError('Ouch!');
trigger_error('Ouch!');
}
function testNoticeWhenReported() {
error_reporting(E_ALL);
$this->expectError('Ouch!');
trigger_error('Ouch!', E_USER_NOTICE);
}
function testWarningWhenReported() {
error_reporting(E_ALL);
$this->expectError('Ouch!');
trigger_error('Ouch!', E_USER_WARNING);
}
function testErrorWhenReported() {
error_reporting(E_ALL);
$this->expectError('Ouch!');
trigger_error('Ouch!', E_USER_ERROR);
}
function testNoNoticeWhenNotReported() {
error_reporting(0);
trigger_error('Ouch!', E_USER_NOTICE);
}
function testNoWarningWhenNotReported() {
error_reporting(0);
trigger_error('Ouch!', E_USER_WARNING);
}
function testNoticeSuppressedWhenReported() {
error_reporting(E_ALL);
@trigger_error('Ouch!', E_USER_NOTICE);
}
function testWarningSuppressedWhenReported() {
error_reporting(E_ALL);
@trigger_error('Ouch!', E_USER_WARNING);
}
function testErrorWithPercentsReportedWithNoSprintfError() {
$this->expectError('%');
trigger_error('%');
}
}
class TestOfPHP52RecoverableErrors extends UnitTestCase {
function skip() {
$this->skipIf(
version_compare(phpversion(), '5.2', '<'),
'E_RECOVERABLE_ERROR not tested for PHP below 5.2');
}
function testError() {
eval('
class RecoverableErrorTestingStub {
function ouch(RecoverableErrorTestingStub $obj) {
}
}
');
$stub = new RecoverableErrorTestingStub();
$this->expectError(new PatternExpectation('/must be an instance of RecoverableErrorTestingStub/i'));
$stub->ouch(new stdClass());
}
}
class TestOfErrorsExcludingPHP52AndAbove extends UnitTestCase {
function skip() {
$this->skipIf(
version_compare(phpversion(), '5.2', '>='),
'E_USER_ERROR not tested for PHP 5.2 and above');
}
function testNoErrorWhenNotReported() {
error_reporting(0);
trigger_error('Ouch!', E_USER_ERROR);
}
function testErrorSuppressedWhenReported() {
error_reporting(E_ALL);
@trigger_error('Ouch!', E_USER_ERROR);
}
}
SimpleTest::ignore('TestOfNotEnoughErrors');
/**
* This test is ignored as it is used by {@link TestRunnerForLeftOverAndNotEnoughErrors}
* to verify that it fails as expected.
*
* @ignore
*/
class TestOfNotEnoughErrors extends UnitTestCase {
function testExpectTwoErrorsThrowOne() {
$this->expectError('Error 1');
trigger_error('Error 1');
$this->expectError('Error 2');
}
}
SimpleTest::ignore('TestOfLeftOverErrors');
/**
* This test is ignored as it is used by {@link TestRunnerForLeftOverAndNotEnoughErrors}
* to verify that it fails as expected.
*
* @ignore
*/
class TestOfLeftOverErrors extends UnitTestCase {
function testExpectOneErrorGetTwo() {
$this->expectError('Error 1');
trigger_error('Error 1');
trigger_error('Error 2');
}
}
class TestRunnerForLeftOverAndNotEnoughErrors extends UnitTestCase {
function testRunLeftOverErrorsTestCase() {
$test = new TestOfLeftOverErrors();
$this->assertFalse($test->run(new SimpleReporter()));
}
function testRunNotEnoughErrors() {
$test = new TestOfNotEnoughErrors();
$this->assertFalse($test->run(new SimpleReporter()));
}
}
// TODO: Add stacked error handler test
?> | 10npsite | trunk/simpletest/test/errors_test.php | PHP | asf20 | 6,349 |
<?php
// $Id: simpletest_test.php 1748 2008-04-14 01:50:41Z lastcraft $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../simpletest.php');
SimpleTest::ignore('ShouldNeverBeRunEither');
class ShouldNeverBeRun extends UnitTestCase {
function testWithNoChanceOfSuccess() {
$this->fail('Should be ignored');
}
}
class ShouldNeverBeRunEither extends ShouldNeverBeRun { }
class TestOfStackTrace extends UnitTestCase {
function testCanFindAssertInTrace() {
$trace = new SimpleStackTrace(array('assert'));
$this->assertEqual(
$trace->traceMethod(array(array(
'file' => '/my_test.php',
'line' => 24,
'function' => 'assertSomething'))),
' at [/my_test.php line 24]');
}
}
class DummyResource { }
class TestOfContext extends UnitTestCase {
function testCurrentContextIsUnique() {
$this->assertSame(
SimpleTest::getContext(),
SimpleTest::getContext());
}
function testContextHoldsCurrentTestCase() {
$context = SimpleTest::getContext();
$this->assertSame($this, $context->getTest());
}
function testResourceIsSingleInstanceWithContext() {
$context = new SimpleTestContext();
$this->assertSame(
$context->get('DummyResource'),
$context->get('DummyResource'));
}
function testClearingContextResetsResources() {
$context = new SimpleTestContext();
$resource = $context->get('DummyResource');
$context->clear();
$this->assertClone($resource, $context->get('DummyResource'));
}
}
?> | 10npsite | trunk/simpletest/test/simpletest_test.php | PHP | asf20 | 1,730 |
<?php
// $Id: shell_tester_test.php 1787 2008-04-26 20:35:39Z pp11 $
require_once(dirname(__FILE__) . '/../autorun.php');
require_once(dirname(__FILE__) . '/../shell_tester.php');
Mock::generate('SimpleShell');
class TestOfShellTestCase extends ShellTestCase {
private $mock_shell = false;
function getShell() {
return $this->mock_shell;
}
function testGenericEquality() {
$this->assertEqual('a', 'a');
$this->assertNotEqual('a', 'A');
}
function testExitCode() {
$this->mock_shell = new MockSimpleShell();
$this->mock_shell->setReturnValue('execute', 0);
$this->mock_shell->expectOnce('execute', array('ls'));
$this->assertTrue($this->execute('ls'));
$this->assertExitCode(0);
}
function testOutput() {
$this->mock_shell = new MockSimpleShell();
$this->mock_shell->setReturnValue('execute', 0);
$this->mock_shell->setReturnValue('getOutput', "Line 1\nLine 2\n");
$this->assertOutput("Line 1\nLine 2\n");
}
function testOutputPatterns() {
$this->mock_shell = new MockSimpleShell();
$this->mock_shell->setReturnValue('execute', 0);
$this->mock_shell->setReturnValue('getOutput', "Line 1\nLine 2\n");
$this->assertOutputPattern('/line/i');
$this->assertNoOutputPattern('/line 2/');
}
}
?> | 10npsite | trunk/simpletest/test/shell_tester_test.php | PHP | asf20 | 1,392 |
<?php
/**
* Base include file for SimpleTest
* @package SimpleTest
* @subpackage WebTester
* @version $Id: user_agent.php 2039 2011-11-30 18:16:15Z pp11 $
*/
/**#@+
* include other SimpleTest class files
*/
require_once(dirname(__FILE__) . '/cookies.php');
require_once(dirname(__FILE__) . '/http.php');
require_once(dirname(__FILE__) . '/encoding.php');
require_once(dirname(__FILE__) . '/authentication.php');
/**#@-*/
if (! defined('DEFAULT_MAX_REDIRECTS')) {
define('DEFAULT_MAX_REDIRECTS', 3);
}
if (! defined('DEFAULT_CONNECTION_TIMEOUT')) {
define('DEFAULT_CONNECTION_TIMEOUT', 15);
}
/**
* Fetches web pages whilst keeping track of
* cookies and authentication.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleUserAgent {
private $cookie_jar;
private $cookies_enabled = true;
private $authenticator;
private $max_redirects = DEFAULT_MAX_REDIRECTS;
private $proxy = false;
private $proxy_username = false;
private $proxy_password = false;
private $connection_timeout = DEFAULT_CONNECTION_TIMEOUT;
private $additional_headers = array();
/**
* Starts with no cookies, realms or proxies.
* @access public
*/
function __construct() {
$this->cookie_jar = new SimpleCookieJar();
$this->authenticator = new SimpleAuthenticator();
}
/**
* Removes expired and temporary cookies as if
* the browser was closed and re-opened. Authorisation
* has to be obtained again as well.
* @param string/integer $date Time when session restarted.
* If omitted then all persistent
* cookies are kept.
* @access public
*/
function restart($date = false) {
$this->cookie_jar->restartSession($date);
$this->authenticator->restartSession();
}
/**
* Adds a header to every fetch.
* @param string $header Header line to add to every
* request until cleared.
* @access public
*/
function addHeader($header) {
$this->additional_headers[] = $header;
}
/**
* Ages the cookies by the specified time.
* @param integer $interval Amount in seconds.
* @access public
*/
function ageCookies($interval) {
$this->cookie_jar->agePrematurely($interval);
}
/**
* Sets an additional cookie. If a cookie has
* the same name and path it is replaced.
* @param string $name Cookie key.
* @param string $value Value of cookie.
* @param string $host Host upon which the cookie is valid.
* @param string $path Cookie path if not host wide.
* @param string $expiry Expiry date.
* @access public
*/
function setCookie($name, $value, $host = false, $path = '/', $expiry = false) {
$this->cookie_jar->setCookie($name, $value, $host, $path, $expiry);
}
/**
* Reads the most specific cookie value from the
* browser cookies.
* @param string $host Host to search.
* @param string $path Applicable path.
* @param string $name Name of cookie to read.
* @return string False if not present, else the
* value as a string.
* @access public
*/
function getCookieValue($host, $path, $name) {
return $this->cookie_jar->getCookieValue($host, $path, $name);
}
/**
* Reads the current cookies within the base URL.
* @param string $name Key of cookie to find.
* @param SimpleUrl $base Base URL to search from.
* @return string/boolean Null if there is no base URL, false
* if the cookie is not set.
* @access public
*/
function getBaseCookieValue($name, $base) {
if (! $base) {
return null;
}
return $this->getCookieValue($base->getHost(), $base->getPath(), $name);
}
/**
* Switches off cookie sending and recieving.
* @access public
*/
function ignoreCookies() {
$this->cookies_enabled = false;
}
/**
* Switches back on the cookie sending and recieving.
* @access public
*/
function useCookies() {
$this->cookies_enabled = true;
}
/**
* Sets the socket timeout for opening a connection.
* @param integer $timeout Maximum time in seconds.
* @access public
*/
function setConnectionTimeout($timeout) {
$this->connection_timeout = $timeout;
}
/**
* Sets the maximum number of redirects before
* a page will be loaded anyway.
* @param integer $max Most hops allowed.
* @access public
*/
function setMaximumRedirects($max) {
$this->max_redirects = $max;
}
/**
* Sets proxy to use on all requests for when
* testing from behind a firewall. Set URL
* to false to disable.
* @param string $proxy Proxy URL.
* @param string $username Proxy username for authentication.
* @param string $password Proxy password for authentication.
* @access public
*/
function useProxy($proxy, $username, $password) {
if (! $proxy) {
$this->proxy = false;
return;
}
if ((strncmp($proxy, 'http://', 7) != 0) && (strncmp($proxy, 'https://', 8) != 0)) {
$proxy = 'http://'. $proxy;
}
$this->proxy = new SimpleUrl($proxy);
$this->proxy_username = $username;
$this->proxy_password = $password;
}
/**
* Test to see if the redirect limit is passed.
* @param integer $redirects Count so far.
* @return boolean True if over.
* @access private
*/
protected function isTooManyRedirects($redirects) {
return ($redirects > $this->max_redirects);
}
/**
* Sets the identity for the current realm.
* @param string $host Host to which realm applies.
* @param string $realm Full name of realm.
* @param string $username Username for realm.
* @param string $password Password for realm.
* @access public
*/
function setIdentity($host, $realm, $username, $password) {
$this->authenticator->setIdentityForRealm($host, $realm, $username, $password);
}
/**
* Fetches a URL as a response object. Will keep trying if redirected.
* It will also collect authentication realm information.
* @param string/SimpleUrl $url Target to fetch.
* @param SimpleEncoding $encoding Additional parameters for request.
* @return SimpleHttpResponse Hopefully the target page.
* @access public
*/
function fetchResponse($url, $encoding) {
if ($encoding->getMethod() != 'POST') {
$url->addRequestParameters($encoding);
$encoding->clear();
}
$response = $this->fetchWhileRedirected($url, $encoding);
if ($headers = $response->getHeaders()) {
if ($headers->isChallenge()) {
$this->authenticator->addRealm(
$url,
$headers->getAuthentication(),
$headers->getRealm());
}
}
return $response;
}
/**
* Fetches the page until no longer redirected or
* until the redirect limit runs out.
* @param SimpleUrl $url Target to fetch.
* @param SimpelFormEncoding $encoding Additional parameters for request.
* @return SimpleHttpResponse Hopefully the target page.
* @access private
*/
protected function fetchWhileRedirected($url, $encoding) {
$redirects = 0;
do {
$response = $this->fetch($url, $encoding);
if ($response->isError()) {
return $response;
}
$headers = $response->getHeaders();
if ($this->cookies_enabled) {
$headers->writeCookiesToJar($this->cookie_jar, $url);
}
if (! $headers->isRedirect()) {
break;
}
$location = new SimpleUrl($headers->getLocation());
$url = $location->makeAbsolute($url);
$encoding = new SimpleGetEncoding();
} while (! $this->isTooManyRedirects(++$redirects));
return $response;
}
/**
* Actually make the web request.
* @param SimpleUrl $url Target to fetch.
* @param SimpleFormEncoding $encoding Additional parameters for request.
* @return SimpleHttpResponse Headers and hopefully content.
* @access protected
*/
protected function fetch($url, $encoding) {
$request = $this->createRequest($url, $encoding);
return $request->fetch($this->connection_timeout);
}
/**
* Creates a full page request.
* @param SimpleUrl $url Target to fetch as url object.
* @param SimpleFormEncoding $encoding POST/GET parameters.
* @return SimpleHttpRequest New request.
* @access private
*/
protected function createRequest($url, $encoding) {
$request = $this->createHttpRequest($url, $encoding);
$this->addAdditionalHeaders($request);
if ($this->cookies_enabled) {
$request->readCookiesFromJar($this->cookie_jar, $url);
}
$this->authenticator->addHeaders($request, $url);
return $request;
}
/**
* Builds the appropriate HTTP request object.
* @param SimpleUrl $url Target to fetch as url object.
* @param SimpleFormEncoding $parameters POST/GET parameters.
* @return SimpleHttpRequest New request object.
* @access protected
*/
protected function createHttpRequest($url, $encoding) {
return new SimpleHttpRequest($this->createRoute($url), $encoding);
}
/**
* Sets up either a direct route or via a proxy.
* @param SimpleUrl $url Target to fetch as url object.
* @return SimpleRoute Route to take to fetch URL.
* @access protected
*/
protected function createRoute($url) {
if ($this->proxy) {
return new SimpleProxyRoute(
$url,
$this->proxy,
$this->proxy_username,
$this->proxy_password);
}
return new SimpleRoute($url);
}
/**
* Adds additional manual headers.
* @param SimpleHttpRequest $request Outgoing request.
* @access private
*/
protected function addAdditionalHeaders(&$request) {
foreach ($this->additional_headers as $header) {
$request->addHeaderLine($header);
}
}
}
?> | 10npsite | trunk/simpletest/user_agent.php | PHP | asf20 | 11,248 |
<?php
//外网配置
session_start();
header('Content-Type: text/html; charset=utf-8');
//定义全局参数
//函数体要引用全局变量,即在函数体内申明如:global $a;
$SystemConest=array();
$SystemConest[0]=dirname(__FILE__);
$SystemConest[1]="guanli";//后台管理目录
$SystemConest[2]="admin";//超级帐号
$SystemConest[3]=1*1024*100;//充许文件上传的大小
$SystemConest[4]="/Public/upfiles/";//上传文件存放的路径
$SystemConest[5]=array('.zip','.rar','.jpg','.png','.gif','.wma','.rm','.wmv','.doc','.mpeg','.mp3','.avi');//充许文件上传类型
$SystemConest[6]="default";//风格样式名称 在/template 文件夹下
define("DQ","cd_");//主站数据表前缀
define("UHDQ","uchome_");//UCHOME数据表前缀
$SystemConest[7]=DQ;
$SystemConest[8]="法轮功,淫,日你,日她,我日,易勇斌";//非法字符串,用“,”分隔
$SystemConest[9]="127.0.0.1";//数据库IP地址
$SystemConest[10]="xdreams";//数据库名
$SystemConest[11]="root";//数据库用户
$SystemConest[12]="mzlsz$168_78R";//数据库密码 mzlsz$168_78R
$SystemConest[13]="7659";//数据库端口
$SystemConest["db_user"]=$SystemConest[11];//数据库用户
$SystemConest["tourxmlpath"]="xml";//生成线路xml的路径,以相对网站根目录的始
$SystemConest["sys_suoluetu"]["w"]=240;//生成缩略图的宽度
$SystemConest["sys_suoluetu"]["h"]=190;//生成缩略图的宽度
$SystemConest["KZURL"]="http://kezhan.haomzl.com";//客栈的二级域名
define("RootDir",$SystemConest[0]);//定义根目录为常量
define("Q","dsz");//定义入口文件的别名
define("FGF","/");//定义url地址分割符
define("TempDir",RootDir."/template/".$SystemConest[6]);//定义模板文件的路径为常量
define("Syshoutai",$SystemConest[1]);
define('HTML_DIR','Runtime/cachehtml');
define('DanxuangduofenC','|$#df&@|');//单项多分属性的内容分界符
define('DanxuangduofenT','|%@df&@|');//单项多分属性的内容再折分标题和内容时的分隔符
define("PICPATHsystem",(strstr($_SERVER['HTTP_HOST'],"127.0.0.1"))?"http://www.haomzl.com":"http://www.haomzl.com");
define("PICPATH",PICPATHsystem);//本站图片服务器地址
define('RUNTIME_ALLINONE', false); // 开启 ALLINONE 运行模式
define("SYS_SITENAME","梦之旅旅游网");//定义站点名称
define("SYS_UCHOMEURL",PICPATHsystem."/user");//定义社区的url地址
define("SYS_UCcenter",PICPATHsystem."/ducenter");//定义社区的url地址
//支付方式
//key值为标签的value值,值为标签的显示值
$PayType=array(
""=>"请选择",
"支付宝"=>"支付宝",
"环讯" =>"在线支付",
"paypal"=>"贝宝",
"网银"=>"网银",
"转帐"=>"转帐",
"财付通"=>"财付通"
);
$SYS_config=array(
"addYingx"=>6,//每个会员可以添加的线路印象条数
"pinglunmaxnum"=>5,//线路评论的最大数
"maxjifenduije"=>0.05,//积分在兑换金额时的最大比例这里为%5
"xfsjfnumdy1jenum"=>100,//在抵用时多少积分抵用1元人民币
"siteurl"=>"http://www.haomzl.com",//网站主域名
"Gettourxoldurl"=>"http://www.dreams-travel.com",//获取老网站线路的地址
"tiqianzftime"=>6,//订单定金支付的限期,从下订单后多少小时后可支付
"yukuanzfqixuan"=>33,//余款支付的期限,从下单时间开始算
"smsuser"=>"szgl00006",//凌凯短信帐号
"smspass"=>"sz168msm",//凌凯短信密码
"tiaoshi"=>false,//是否开启调试和显示页面Trace信息
"cookiedoman"=>".haomzl.com",//cookie的作用域
"hotelpingnum"=>"(select count(*) as tnum from ".DQ."pinglun where pinglun2=a.hotel0) as ctnum",//在调用酒店列表时,要统计总的评论记录条数时的sql语句,可以直接写入语句里
"hotelpingtotalfen"=>"(select sum(pinglun9+pinglun10+pinglun11+pinglun12+pinglun13+pinglun14)as onenum from ".DQ."pinglun where pinglun2=a.hotel0) as allfs",//某个酒店的所有评论条数加起来的分数总和
);
//系统级函数
/**
* 格式化url路由函数 要求把模块和操作和参数的分隔符分开
* @param $str url的字符串
* @param $pref 模块和操作的分隔符
* @param $can url参数的分隔符,?后面的
*
*/
function Sys_formaturl($str,$pref,$can)
{
$str1=str_replace($pref,$can,$str);
return preg_replace("/".$can."/","/",$str1,2);
}
?> | 10npsite | trunk/global2.php | PHP | asf20 | 4,406 |
<script language="javascript">
function show(title,msg)
{
alert("dffdfd");
/*
var d_mask=document.getElementById('mask');
var d_dialog =document.getElementById('dialog');
d_mask.style.width = document.body.clientWidth ;
d_mask.style.height=document.body.clientHeight;
d_dialog.style.top = document.body.clientHeight / 2 -260;
d_dialog.style.left =document.body.clientWidth / 2 -100;
var Inner = "<input type='button' value='Close' onclick='DialogClose()'/>"
var info = "<table cellspacing='0' width='100%' height='100%'>"+
"<tr class='dgtitle'><td>"
+title
+"</td><td align='right'><input type='button' value='Close' onclick='DialogClose()'class='formButton'/></td></tr>"
+"<tr><td colspan='2'>"
+msg
+"</td></tr>"
+"<tr class='dgfooter'><td></td><td>"
+"</td></tr>"
+"</table>";
d_dialog.innerHTML =info;
d_mask.style.visibility='visible';
d_dialog.style.visibility='visible';
}
function Icon_Close_Over(obj)
{
obj.src='close.gif';
}
function Icon_Close_Out(obj)
{
obj.src='close1.gif'
}
function DialogClose()
{
var d_mask=document.getElementById('mask');
var d_dialog = document.getElementById('dialog');
//parent.getifheight();//当记录没有时或很少时还原其框架在原来的页面中的高度
enableSelect()
d_mask.style.visibility='hidden';
d_dialog.style.visibility='hidden';
}
function disableSelect()
{
for(i=0;i<document.all.length;i++)
if(document.all(i).tagName=="SELECT")
document.all(i).disabled = true;
}
function enableSelect()
{
for(i=0;i<document.all.length;i++){
if(document.all(i).tagName=="SELECT")
{
document.all(i).disabled = false;
}
}
}
function divBlock_event_mousedown()
{
var e, obj, temp;
obj=document.getElementById('dialog');
e=window.event?window.event:e;
obj.startX=e.clientX-obj.offsetLeft;
obj.startY=e.clientY-obj.offsetTop;
document.onmousemove=document_event_mousemove;
temp=document.attachEvent?document.attachEvent('onmouseup',document_event_mouseup):document.addEventListener('mouseup',document_event_mouseup,'');
}
function document_event_mousemove(e)
{
var e, obj;
obj=document.getElementById('dialog');
e=window.event?window.event:e;
with(obj.style){
position='absolute';
left=e.clientX-obj.startX+'px';
top=e.clientY-obj.startY+'px';
}
}
function document_event_mouseup(e)
{
var temp;
document.onmousemove='';
temp=document.detachEvent?parent.detachEvent('onmouseup',document_event_mouseup):document.removeEventListener('mouseup',document_event_mouseup,'');
}
window.onresize = function()
{
var d_mask=document.getElementById('mask');
var d_dialog = document.getElementById('dialog');
d_mask.style.width = document.body.clientWidth ;
d_mask.style.height=document.body.clientHeight;
*/
}
</script>
| 10npsite | trunk/Public/jsLibrary/jsAlert.php | PHP | asf20 | 3,278 |
<!--
/**
* Calendar
* @param beginYear 1990
* @param endYear 2010
* @param language 0(zh_cn)|1(en_us)|2(en_en)|3(zh_tw)
* @param patternDelimiter "-"
* @param date2StringPattern "yyyy-MM-dd"
* @param string2DatePattern "ymd"
* @version 1.0 build 2006-04-01
* @version 1.1 build 2006-12-17
* @author KimSoft (jinqinghua [at] gmail.com)
* NOTE! you can use it free, but keep the copyright please
* IMPORTANT:you must include this script file inner html body elment
*/
function Calendar(beginYear, endYear, language, patternDelimiter, date2StringPattern, string2DatePattern) {
this.beginYear = beginYear || 1990;
this.endYear = endYear || 2020;
this.language = language || 0;
this.patternDelimiter = patternDelimiter || "-";
this.date2StringPattern = date2StringPattern || Calendar.language["date2StringPattern"][this.language].replace(/\-/g, this.patternDelimiter);
this.string2DatePattern = string2DatePattern || Calendar.language["string2DatePattern"][this.language];
this.dateControl = null;
this.panel = this.getElementById("__calendarPanel");
this.iframe = window.frames["__calendarIframe"];
this.form = null;
this.date = new Date();
this.year = this.date.getFullYear();
this.month = this.date.getMonth();
this.colors = {"bg_cur_day":"#00CC33","bg_over":"#EFEFEF","bg_out":"#FFCC00"}
};
Calendar.language = {
"year" : ["\u5e74", "", "", "\u5e74"],
"months" : [
["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"],
["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"],
["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"],
["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"]
],
"weeks" : [["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"],
["Sun","Mon","Tur","Wed","Thu","Fri","Sat"],
["Sun","Mon","Tur","Wed","Thu","Fri","Sat"],
["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"]
],
"clear" : ["\u6e05\u7a7a", "Clear", "Clear", "\u6e05\u7a7a"],
"today" : ["\u4eca\u5929", "Today", "Today", "\u4eca\u5929"],
"close" : ["\u5173\u95ed", "Close", "Close", "\u95dc\u9589"],
"date2StringPattern" : ["yyyy-MM-dd", "yyyy-MM-dd", "yyyy-MM-dd", "yyyy-MM-dd"],
"string2DatePattern" : ["ymd","ymd", "ymd", "ymd"]
};
Calendar.prototype.draw = function() {
calendar = this;
var _cs = [];
_cs[_cs.length] = '<form id="__calendarForm" name="__calendarForm" method="post">';
_cs[_cs.length] = '<table id="__calendarTable" width="100%" border="0" cellpadding="3" cellspacing="1" align="center">';
_cs[_cs.length] = ' <tr>';
_cs[_cs.length] = ' <th><input class="l" name="goPrevMonthButton" type="button" id="goPrevMonthButton" value="<" \/><\/th>';
_cs[_cs.length] = ' <th colspan="5"><select class="year" name="yearSelect" id="yearSelect"><\/select><select class="month" name="monthSelect" id="monthSelect"><\/select><\/th>';
_cs[_cs.length] = ' <th><input class="r" name="goNextMonthButton" type="button" id="goNextMonthButton" value=">" \/><\/th>';
_cs[_cs.length] = ' <\/tr>';
_cs[_cs.length] = ' <tr>';
for(var i = 0; i < 7; i++) {
_cs[_cs.length] = '<th class="theader">';
_cs[_cs.length] = Calendar.language["weeks"][this.language][i];
_cs[_cs.length] = '<\/th>';
}
_cs[_cs.length] = '<\/tr>';
for(var i = 0; i < 6; i++){
_cs[_cs.length] = '<tr align="center">';
for(var j = 0; j < 7; j++) {
switch (j) {
case 0: _cs[_cs.length] = '<td class="sun"> <\/td>'; break;
case 6: _cs[_cs.length] = '<td class="sat"> <\/td>'; break;
default:_cs[_cs.length] = '<td class="normal"> <\/td>'; break;
}
}
_cs[_cs.length] = '<\/tr>';
}
_cs[_cs.length] = ' <tr>';
_cs[_cs.length] = ' <th colspan="2"><input type="button" class="b" name="clearButton" id="clearButton" \/><\/th>';
_cs[_cs.length] = ' <th colspan="3"><input type="button" class="b" name="selectTodayButton" id="selectTodayButton" \/><\/th>';
_cs[_cs.length] = ' <th colspan="2"><input type="button" class="b" name="closeButton" id="closeButton" \/><\/th>';
_cs[_cs.length] = ' <\/tr>';
_cs[_cs.length] = '<\/table>';
_cs[_cs.length] = '<\/form>';
this.iframe.document.body.innerHTML = _cs.join("");
this.form = this.iframe.document.forms["__calendarForm"];
this.form.clearButton.value = Calendar.language["clear"][this.language];
this.form.selectTodayButton.value = Calendar.language["today"][this.language];
this.form.closeButton.value = Calendar.language["close"][this.language];
this.form.goPrevMonthButton.onclick = function () {calendar.goPrevMonth(this);}
this.form.goNextMonthButton.onclick = function () {calendar.goNextMonth(this);}
this.form.yearSelect.onchange = function () {calendar.update(this);}
this.form.monthSelect.onchange = function () {calendar.update(this);}
this.form.clearButton.onclick = function () {calendar.dateControl.value = "";calendar.hide();}
this.form.closeButton.onclick = function () {calendar.hide();}
this.form.selectTodayButton.onclick = function () {
var today = new Date();
calendar.date = today;
calendar.year = today.getFullYear();
calendar.month = today.getMonth();
calendar.dateControl.value = today.format(calendar.date2StringPattern);
calendar.hide();
}
};
Calendar.prototype.bindYear = function() {
var ys = this.form.yearSelect;
ys.length = 0;
for (var i = this.beginYear; i <= this.endYear; i++){
ys.options[ys.length] = new Option(i + Calendar.language["year"][this.language], i);
}
};
Calendar.prototype.bindMonth = function() {
var ms = this.form.monthSelect;
ms.length = 0;
for (var i = 0; i < 12; i++){
ms.options[ms.length] = new Option(Calendar.language["months"][this.language][i], i);
}
};
Calendar.prototype.goPrevMonth = function(e){
if (this.year == this.beginYear && this.month == 0){return;}
this.month--;
if (this.month == -1) {
this.year--;
this.month = 11;
}
this.date = new Date(this.year, this.month, 1);
this.changeSelect();
this.bindData();
};
Calendar.prototype.goNextMonth = function(e){
if (this.year == this.endYear && this.month == 11){return;}
this.month++;
if (this.month == 12) {
this.year++;
this.month = 0;
}
this.date = new Date(this.year, this.month, 1);
this.changeSelect();
this.bindData();
};
Calendar.prototype.changeSelect = function() {
var ys = this.form.yearSelect;
var ms = this.form.monthSelect;
for (var i= 0; i < ys.length; i++){
if (ys.options[i].value == this.date.getFullYear()){
ys[i].selected = true;
break;
}
}
for (var i= 0; i < ms.length; i++){
if (ms.options[i].value == this.date.getMonth()){
ms[i].selected = true;
break;
}
}
};
Calendar.prototype.update = function (e){
this.year = e.form.yearSelect.options[e.form.yearSelect.selectedIndex].value;
this.month = e.form.monthSelect.options[e.form.monthSelect.selectedIndex].value;
this.date = new Date(this.year, this.month, 1);
this.changeSelect();
this.bindData();
};
Calendar.prototype.bindData = function () {
var calendar = this;
var dateArray = this.getMonthViewDateArray(this.date.getFullYear(), this.date.getMonth());
var tds = this.getElementsByTagName("td", this.getElementById("__calendarTable", this.iframe.document));
for(var i = 0; i < tds.length; i++) {
tds[i].style.backgroundColor = calendar.colors["bg_over"];
tds[i].onclick = null;
tds[i].onmouseover = null;
tds[i].onmouseout = null;
tds[i].innerHTML = dateArray[i] || " ";
if (i > dateArray.length - 1) continue;
if (dateArray[i]){
tds[i].onclick = function () {
if (calendar.dateControl){
calendar.dateControl.value = new Date(calendar.date.getFullYear(),
calendar.date.getMonth(),
this.innerHTML).format(calendar.date2StringPattern);
}
calendar.hide();
}
tds[i].onmouseover = function () {this.style.backgroundColor = calendar.colors["bg_out"];}
tds[i].onmouseout = function () {this.style.backgroundColor = calendar.colors["bg_over"];}
var today = new Date();
if (today.getFullYear() == calendar.date.getFullYear()) {
if (today.getMonth() == calendar.date.getMonth()) {
if (today.getDate() == dateArray[i]) {
tds[i].style.backgroundColor = calendar.colors["bg_cur_day"];
tds[i].onmouseover = function () {this.style.backgroundColor = calendar.colors["bg_out"];}
tds[i].onmouseout = function () {this.style.backgroundColor = calendar.colors["bg_cur_day"];}
}
}
}
}//end if
}//end for
};
Calendar.prototype.getMonthViewDateArray = function (y, m) {
var dateArray = new Array(42);
var dayOfFirstDate = new Date(y, m, 1).getDay();
var dateCountOfMonth = new Date(y, m + 1, 0).getDate();
for (var i = 0; i < dateCountOfMonth; i++) {
dateArray[i + dayOfFirstDate] = i + 1;
}
return dateArray;
};
Calendar.prototype.show = function (dateControl, popuControl) {
if (this.panel.style.visibility == "visible") {
this.panel.style.visibility = "hidden";
}
if (!dateControl){
throw new Error("arguments[0] is necessary!")
}
this.dateControl = dateControl;
popuControl = popuControl || dateControl;
this.draw();
this.bindYear();
this.bindMonth();
if (dateControl.value.length > 0){
this.date = new Date(dateControl.value.toDate(this.patternDelimiter, this.string2DatePattern));
this.year = this.date.getFullYear();
this.month = this.date.getMonth();
}
this.changeSelect();
this.bindData();
var xy = this.getAbsPoint(popuControl);
this.panel.style.left = xy.x + "px";
this.panel.style.top = (xy.y + dateControl.offsetHeight) + "px";
this.panel.style.visibility = "visible";
};
Calendar.prototype.hide = function() {
this.panel.style.visibility = "hidden";
};
Calendar.prototype.getElementById = function(id, object){
object = object || document;
return document.getElementById ? object.getElementById(id) : document.all(id);
};
Calendar.prototype.getElementsByTagName = function(tagName, object){
object = object || document;
return document.getElementsByTagName ? object.getElementsByTagName(tagName) : document.all.tags(tagName);
};
Calendar.prototype.getAbsPoint = function (e){
var x = e.offsetLeft;
var y = e.offsetTop;
while(e = e.offsetParent){
x += e.offsetLeft;
y += e.offsetTop;
}
return {"x": x, "y": y};
};
/**
* @param d the delimiter
* @param p the pattern of your date
* @author meizz
* @author kimsoft add w+ pattern
*/
Date.prototype.format = function(style) {
var o = {
"M+" : this.getMonth() + 1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"w+" : "\u65e5\u4e00\u4e8c\u4e09\u56db\u4e94\u516d".charAt(this.getDay()), //week
"q+" : Math.floor((this.getMonth() + 3) / 3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if (/(y+)/.test(style)) {
style = style.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for(var k in o){
if (new RegExp("("+ k +")").test(style)){
style = style.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
}
}
return style;
};
/**
* @param d the delimiter
* @param p the pattern of your date
* @rebuilder kimsoft
* @version build 2006.12.15
*/
String.prototype.toDate = function(delimiter, pattern) {
delimiter = delimiter || "-";
pattern = pattern || "ymd";
var a = this.split(delimiter);
var y = parseInt(a[pattern.indexOf("y")], 10);
//remember to change this next century ;)
if(y.toString().length <= 2) y += 2000;
if(isNaN(y)) y = new Date().getFullYear();
var m = parseInt(a[pattern.indexOf("m")], 10) - 1;
var d = parseInt(a[pattern.indexOf("d")], 10);
if(isNaN(d)) d = 1;
return new Date(y, m, d);
};
document.writeln('<div id="__calendarPanel" style="position:absolute;visibility:hidden;z-index:9999;background-color:#FFFFFF;border:1px solid #666666;width:200px;height:216px;">');
document.writeln('<iframe name="__calendarIframe" id="__calendarIframe" width="100%" height="100%" scrolling="no" frameborder="0" style="margin:0px;"><\/iframe>');
var __ci = window.frames['__calendarIframe'];
__ci.document.writeln('<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd">');
__ci.document.writeln('<html xmlns="http:\/\/www.w3.org\/1999\/xhtml">');
__ci.document.writeln('<head>');
__ci.document.writeln('<meta http-equiv="Content-Type" content="text\/html; charset=utf-8" \/>');
__ci.document.writeln('<title>Web Calendar(UTF-8) Written By KimSoft<\/title>');
__ci.document.writeln('<style type="text\/css">');
__ci.document.writeln('<!--');
__ci.document.writeln('body {font-size:12px;margin:0px;text-align:center;}');
__ci.document.writeln('form {margin:0px;}');
__ci.document.writeln('select {font-size:12px;background-color:#EFEFEF;}');
__ci.document.writeln('table {border:0px solid #CCCCCC;background-color:#FFFFFF}');
__ci.document.writeln('th {font-size:12px;font-weight:normal;background-color:#FFFFFF;}');
__ci.document.writeln('th.theader {font-weight:normal;background-color:#666666;color:#FFFFFF;width:24px;}');
__ci.document.writeln('select.year {width:64px;}');
__ci.document.writeln('select.month {width:60px;}');
__ci.document.writeln('td {font-size:12px;text-align:center;}');
__ci.document.writeln('td.sat {color:#0000FF;background-color:#EFEFEF;}');
__ci.document.writeln('td.sun {color:#FF0000;background-color:#EFEFEF;}');
__ci.document.writeln('td.normal {background-color:#EFEFEF;}');
__ci.document.writeln('input.l {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
__ci.document.writeln('input.r {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
__ci.document.writeln('input.b {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:100%;height:20px;}');
__ci.document.writeln('-->');
__ci.document.writeln('<\/style>');
__ci.document.writeln('<\/head>');
__ci.document.writeln('<body>');
__ci.document.writeln('<\/body>');
__ci.document.writeln('<\/html>');
__ci.document.close();
document.writeln('<\/div>');
var calendar = new Calendar();
//--> | 10npsite | trunk/Public/jsLibrary/calendar.js | JavaScript | asf20 | 14,815 |
/* For the details, see:
http://flowplayer.org/tools/dateinput/index.html#skinning */
/* the input field */
.date {
border:1px solid #ccc;
font-size:18px;
padding:4px;
text-align:center;
width:194px;
-moz-box-shadow:0 0 10px #eee inset;
-webkit-box-shadow:0 0 10px #eee inset;
}
/* calendar root element */
#calroot {
/* place on top of other elements. set a higher value if nessessary */
z-index:10000;
margin-top:-1px;
width:198px;
padding:2px;
background-color:#fff;
font-size:11px;
border:1px solid #ccc;
-moz-border-radius:5px;
-webkit-border-radius:5px;
-moz-box-shadow: 0 0 15px #666;
-webkit-box-shadow: 0 0 15px #666;
}
/* head. contains title, prev/next month controls and possible month/year selectors */
#calhead {
padding:2px 0;
height:22px;
}
#caltitle {
font-size:14px;
color:#0150D1;
float:left;
text-align:center;
width:155px;
line-height:20px;
text-shadow:0 1px 0 #ddd;
}
#calnext, #calprev {
display:block;
width:20px;
height:20px;
background:transparent url(skin1/prev.gif) no-repeat scroll center center;
float:left;
cursor:pointer;
}
#calnext {
background-image:url(skin1/next.gif);
float:right;
}
#calprev.caldisabled, #calnext.caldisabled {
visibility:hidden;
}
/* year/month selector */
#caltitle select {
font-size:10px;
}
/* names of the days */
#caldays {
height:14px;
border-bottom:1px solid #ddd;
}
#caldays span {
display:block;
float:left;
width:28px;
text-align:center;
}
/* container for weeks */
#calweeks {
background-color:#fff;
margin-top:4px;
}
/* single week */
.calweek {
clear:left;
height:22px;
}
/* single day */
.calweek a {
display:block;
float:left;
width:27px;
height:20px;
text-decoration:none;
font-size:11px;
margin-left:1px;
text-align:center;
line-height:20px;
color:#666;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}
/* different states */
.calweek a:hover, .calfocus {
background-color:#ddd;
}
/* sunday */
a.calsun {
color:red;
}
/* offmonth day */
a.caloff {
color:#ccc;
}
a.caloff:hover {
background-color:rgb(245, 245, 250);
}
/* unselecteble day */
a.caldisabled {
background-color:#efefef !important;
color:#ccc !important;
cursor:default;
}
/* current day */
#calcurrent {
background-color:#498CE2;
color:#fff;
}
/* today */
#caltoday {
background-color:#333;
color:#fff;
} | 10npsite | trunk/Public/jsLibrary/jquerytools/dateinput/skin1.css | CSS | asf20 | 2,555 |
<?
header('Content-Type: text/html; charset=utf-8');
require_once "../../inc/Uifunction.php";
require_once "../../inc/Function.Libary.php";
///*----------------------------------------------------------------*/
///*获取当年是不是闰年*/
function M_2($Y)
{
if(date("L",strtotime($Y)))
{
return 29;
}
else
{
return 28;
}
/*
if(($Y %2 ==0 and $Y %100<>0) or ($Y % 400==0))
{
return 29;
}
else
{
return 28;
}
*/
}
/**
判断循环到的当前时间和今天的时间做比较
@param $d1大于或等于今天是时返回true 否则返回false
*/
function mydifftime($d1)
{
if(strtotime($d1)-strtotime(date("Y-m-d"))>=0)
{
return true;
}
else
{
return false;
}
}
///*获取当年是不是闰年 end*/
///*获取当月天数*/
///*函数 M_NUM*/
/**
* 获取每个月份有多少天数
* @param $Y 年
* @param $M 月
* @return 返回天数
*/
function M_NUM($Y,$M)
{
switch($M){
case 0: return 31;
case 1: return 31;
case 2: return M_2($Y);
case 3: return 31;
case 4: return 30;
case 5: return 31;
case 6: return 30;
case 7: return 31;
case 8: return 31;
case 9: return 30;
case 10: return 31;
case 11: return 30;
case 12: return 31;
case 13: return 31;
}
}
///*获取当月1号是星期几*/
///*函数 M_D_1*/ /*1=日 .. 7=六*/
/**
* 返回星期几
* @param $Y 年
* @param $M 月
*/
function M_D_1($Y,$M)
{
return date("w",strtotime($Y."-".$M."-1"))+1;
}
///*获取一共该显示多少个格子*/
///*变量 G*/
/**
* 获取一共该显示多少个格子
* @param $M_NUM
* @param $M_D_1
*/
function G($M_NUM,$M_D_1)
{
$TEMP=$M_NUM+$M_D_1 -1;
if($TEMP % 7 !=0)
{
$TEMP=$TEMP+(7-($TEMP %7));
}
return $TEMP;
}
///*显示函数*/
function XS($I,$Y,$M)
{
$TEMP="";
if($I==M_D_1($Y,$M)) $TEMP="1";//*1号*/
if($I > M_D_1($Y,$M) and $I<=(M_NUM($Y,$M)+ M_D_1($Y,$M)-1)) $TEMP=1+($I - M_D_1($Y,$M));//*1号之后*/
return $TEMP;
}
//*----------------------------------------------------------------*/
//*初始化数据*/
$DATE_ = $_GET["DATE_"];
if($DATE_=="") $DATE_=date("Y-m-d");
$DATE_ARR=explode("-",$DATE_);
$Y=$DATE_ARR[0];//年份值
$M=$DATE_ARR[1];//月份值
$D=$DATE_ARR[2];//日值
/*参数说明
// 当前日期 DATE_ 格式 2010-11-11
'/*选择方式 只能选一种 可和时间段任意搭配*/
/*' 选择每周几 week 格式 1=一,2=二,3=三,4=四,5=五,6=六,7=天
' 任意日期用 rydate 格式 1-1,1-2,2-5,6-5
' 每天发团 mtft 格式 1 1=每天发团
'/*时间段 可和上面三种任意搭配
时间段 sjd 格式 8-1->10-6
'/*测试参数
ydate = "8-1,8-2,8-7,8-10"
sjd = "2010-8-1->2010-9-15" /*时间段
*/
$zhouqi=$_REQUEST["zhouqi"];//发团周期 值为空时($indate)又为空时为每天发团 当为周三,周四时,表示每周发团 多个值用,号分隔
$rydate = $_GET["rydate"];
$sjd = $_GET["sjd"]; //*时间段*/
$tqts = $_GET["tqts"]; //*几天后开始选 空为不限制*/
$input_ID= $_GET["input_ID"]; //*标签ID*/
$rydate=$_GET["rydate"];//日期类型 为空时为时间段可选 anydate 为任意一天或任意多天
$guanli=$_GET["guanli"];//为后台管理时可选择多个日期
$otherhtml=gettypehtm($rydate);//当是anydate时,在每个日期值下加一个复选框
$indate=$_GET["indate"];//显示已经有的有效期 多个时间天数值时有 效 如2010-10-25,2010-10-27
$startdateArr=explode("->",$sjd);
$startdate=$startdateArr[0];
$enddate=$startdateArr[1];
$SY=date("Y",strtotime($startdate));//开始的年份
if($tqts=="") $tqts=1;//提前天数,当是提前天数时
//返回不同类型日期的不同值
function gettypehtm($rydate)
{
if($rydate=="anydate")
{
return "<br><input type='checkbox' name='anydate[]' value='' onclick='' ischeck>";
}
else
{
return "";
}
}
if($indate!="">0)
{
$indateArr=explode(",",$indate);
}
if($zhouqi!="")
{
$ZhouqidArr=explode(",",$zhouqi);
}
if($week == "") $mtft = "1";
?>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<script>
function up_m()
{
window.location.href='?DATE_=<? echo getpmodth($Y."-".$M."-1");?>&mtft=<? echo $mtft;?>&week=<? echo $week;?>&rydate=<? echo $rydate;?>&sjd=<? echo $sjd;?>&input_ID=<? echo $input_ID; ?>&tqts=<? echo $tqts;?>&indate=<? echo $indate;?>&guanli=<? echo $$guanli?>&zhouqi=<? echo $zhouqi;?>';
}
function down_m()
{
window.location.href='?DATE_=<? echo getnextmodth($Y."-".$M."-1");?>&mtft=<? echo $mtft;?>&week=<? echo $week;?>&rydate=<? echo $rydate;?>&sjd=<? echo $sjd;?>&input_ID=<? echo $input_ID;?>&tqts=<? echo $tqts;?>&indate=<? echo $indate;?>&guanli=<? echo $$guanli?>&zhouqi=<? echo $zhouqi;?>';
}
</script>
<table width="200" height="250" border="0" cellpadding="4" cellspacing="1" bgcolor="#000000">
<tr align="center">
<td colspan="7" bgcolor="#FFFFFF;"><a href="javascript:up_m();">上月</a> 【<? echo $Y."-".$M;?>】 <a href="javascript:down_m();">下月</a></td>
</tr>
<tr align="center" style="background:#0099CC">
<td>日</td>
<td>一</td>
<td>二</td>
<td>三</td>
<td>四</td>
<td>五</td>
<td>六</td>
</tr>
<?
//*日历显示*/
?>
<tr align=center>
<?
//*时间段*/'
//sjd_cz = py_z_count(sjd,"([\d]*?-[\d]*?-\>[\d]*?-[0-9]+)",20)/
if(preg_match("([\d]*?-[\d]*?-\>[\d]*?-[0-9]+)",$sjd,$tAt)>0)//*不存在时间段0*/
{
$sjd_cz=$tAt[0];
}
else
{
$sjd_cz=false;
}
//die($sjd_cz);
if($sjd_cz)
{
$sjd=$sjd_cz;
$sjd_arr=explode("->",$sjd);
$sjd_b=$sjd_arr[0];
$sjd_e=$sjd_arr[1];
$sjd_b_Arr=explode("-",$sjd_b);
$sjd_e_Arr=explode("-",$sjd_e);
$sjd_b_M=$sjd_b_Arr[0];//开始月
$sjd_b_D=$sjd_b_Arr[1];//开始日
$sjd_e_M=$sjd_e_Arr[0];//结束月
$sjd_e_D=$sjd_e_Arr[1];//结束日
}
$last_b_M=$sjd_b_M;//最终的开始月份
$last_b_D=$sjd_b_D;//最终的开始日
$last_tqts=$tqts*24*60*60;//转换成一天的秒数
$getdaysnum=getwogdays($sjd_e,$sjd_b);//获取这个时间段相差的天数
/*
计算两个时间之间相隔的天数
传入形式 10-11, 11-10
如果$enddat的月数比$startdate小,则表示是第二年的
*/
function getwogdays($startdate,$enddate)
{
$Y1= $Y2=date("Y");
$sjd_b_Arr=explode("-",$startdate);
$sjd_e_Arr=explode("-",$enddate);
$sjd_b_M=$sjd_b_Arr[0];//开始月
$sjd_e_M=$sjd_e_Arr[0];//结束月
if($sjd_e_M>$sjd_b_M)
{
$Y2=$Y2+1;
}
return difftime_i(strtotime($startdate),strtotime($enddate));
}
//*循环格子*/
$num=G(M_NUM($Y,$M),M_D_1($Y,$M));
/*
$num=$num+7;
if($num%7!=0)
{
for($i=1;$i<7;$i++)
{
$num=$num+$i;
if($num % 7==0) break;
}
}*/
$in=1;
$in2=1;
for($i=1;$i<=$num;$i++)
{
?>
<td bgcolor="#FFFFFF">
<?
//*每天都可以*/
if($mtft=="1") $click_=$i;
//*处理指定周*/
if($week!="")
{
$week_arr=explode(",",$week);
$week_len=count($week_arr);
for($week_i=0;$week_i<$week_len;$week_i++)
{
$t_w=(int)$week_arr($week_i) +1;
if($t_w==7) $t_w==0;
if($t_w==8) $t_w==1;
if($i=$t_w+(int)($i/7)*7) $click_=$i;
}
}
//*处理时间段*/
if($sjd_cz)
{
$di = XS($i,$Y,$M);
If($di == "") $di = 1;
$Y1=($sjd_b_M >$sjd_e_M)?(int)$Y+1:$Y;
$Y1=($sjd_b_M=$sjd_e_M and $sjd_b_D>$sjd_e_D)?$Y1=(int)$Y+1:$Y;
$Y2=(($Y>date("Y") and $sjd_b_M>$sjd_e_M) or ($Y>date("Y") and $sjd_b_M==$sjd_e_M and $sjd_b_D>$sjd_e_D) )?$Y:$Y;
$time1 = $Y2;
$time1=($sjd_b_M<10)?$time1."0".$sjd_b_M:$time1.$sjd_b_M;
$time1=($sjd_b_D<10)?$time."0".$sjd_b_D:$time1.$sjd_b_D;
$time2 = $Y1;
$time2=($sjd_e_M<10)?$time2."0".$sjd_e_M:$time2.$sjd_e_M;
$time2=($sjd_e_D<10)?$time2."0".$sjd_e_D:$time.$sjd_e_D;
$time_n = $Y;
$time_n=($M<10)?$time_n."0".$M:$time_n.$M;
$time_n=($di<10)?$time_n."0".$di:$time_n.$di;
$click_=($time1<=$time_n and $time_<=$time2)?$click_:0;
//*处理时间段 end*/
}
//*提前天数处理*/
if($tqts!="" )
{
$di=XS($i,$Y,$M);
if($di=="") $di=1;
$endtime=strtotime($SY."-$last_b_M"."-".$last_b_D)-$last_tqts;
$starttime=strtotime($Y."-".$M."-".$di);
$sdn=difftime_i($endtime,$starttime,"1");//两个时间相差的天数
//echo date("Y-m-d",$endtime)."||".date("Y-m-d".$starttime);
$click_=(difftime_i($starttime,$endtime,"1")>=0)?$click_:0;
}
//*提前天数处理 end*/
//echo $sdn."#$getdaysnum#";
$ervyfday=M_D_1($Y,$M);//每个月的第一天的星期
$ervyfday=date("w",strtotime(date("$Y-$M-1")));
if($rydate=="anydate" and $i>=$ervyfday)
{
$dnum=date("Y-M-d");
if($in<=M_NUM($Y,$M) and $i>$ervyfday)
{
if(strtotime($Y."-".$M."-".$in)>=strtotime($dnum))
{
$otherhtml=gettypehtm($rydate);
$otherhtml=str_replace("value=''","value='".$Y."-".$M."-".$in."'",$otherhtml);
$otherhtml=str_replace("onclick=''","onclick=changevalue('".$_REQUEST["input_ID"]."','".$Y."-".$M."-".$in."')",$otherhtml);
//初始化值,如果是已选择的值,则加上勾,大于今天的才勾上
if(count($indateArr)>0)
{
foreach($indateArr as $v)
{
if($v==$Y."-".$M."-".$in )
{
if(mydifftime($v)) $otherhtml=str_replace("ischeck","checked",$otherhtml);
}
}
}
echo "".$in."$otherhtml";
}
else
{
echo $in;
}
$in++;
}
}
else
{
//任意每一天的日期值格式 若数据个数没有时,则为时间段式的表现形式
if(count($indateArr)>0)
{
if($i>$ervyfday and $i<=M_NUM($Y,$M)+$ervyfday)
{
$letdate = date("Y-m-d",strtotime($Y."-".$M."-".$in2));
$temp1=0;
foreach($indateArr as $v)
{
if($v==$Y."-".$M."-".$in2 )
{
if(mydifftime($v) and difftime($enddate,$letdate)>=0 and difftime_i(strtotime($letdate),strtotime(date("Y-m-d"))+24*60*60*$tqts) >0)//当是大于今天的日期时才有效
{
echo "<a href=# style='color:red;' onclick=\"javascript:parent.let_Val('".$input_ID."','".$letdate."');\">".$in2."</a>";
}
else
{
echo $in2."";
}
$temp1=1;
}
}
if($temp1==0) echo $in2."";
$in2++;
}
}
else
{
//时间段时的处理
if( $sdn<=0 and abs($sdn)<=$getdaysnum+$tqts)
{
$D1 = XS($i,$Y,$M);
$M1=$M;
$letdate = $Y."-".$M1."-".$D1;
$tt=date("w",strtotime($Y."-".$M."-".$D1));
$tempc=0;
if($zhouqi!="")
{
if(count($ZhouqidArr)>0)
{
foreach($ZhouqidArr as $v)
{
if($tt==$v)
{
$tempc=1;
}
}
}
if(($tempc==1 or mydifftime(strtotime($letdate)-$last_tqts))and difftime($enddate,$letdate)>=0)
{
//判断的是每周发团形式的
if(difftime($letdate,$startdate)>=0 and difftime($enddate,$letdate)>=0 and difftime_i(strtotime($letdate),strtotime(date("Y-m-d"))+24*60*60*$tqts) >0 )//当是大于今天的日期时才有效
{
echo str_replace($D1,"<a href=# style='color:red;' onclick=\"javascript:parent.let_Val('".$input_ID."','".$letdate."');\">".$D1."</a>",$D1);
}
else
{
echo $D1;
}
}
else
{
echo $D1;
}
}
else
{
if(mydifftime($letdate) and difftime($enddate,$letdate)>=0 and difftime_i(strtotime($letdate),strtotime(date("Y-m-d"))+24*60*60*$tqts) >0)//当是大于今天的日期时才有效
{
echo str_replace($D1,"<a href=# style='color:red;' onclick=\"javascript:parent.let_Val('".$input_ID."','".$letdate."');\">".$D1."</a>",$D1);
}
else
{
echo $D1;
}
}
}
else
{
echo XS($i,$Y,$M);
}
}
}
?>
</td>
<?
if($i % 7 == 0) echo "</TR><TR align=center>";
}
//*循环格子 end*/
?>
</tr>
<?
//*日历显示 end*/
?>
<tr height="1">
<td colspan="7" bgcolor="#FFFFFF" align="center">【今天:<? echo date("Y-m-d")?>】<input type="button" value="关闭" onclick="javascript:parent.cdate_hide();"/></td>
</tr>
</table>
<?
//*----------------------------------------------------------------*/
//*css样式*/
?>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.*{font-size:14px;}
-->
</style>
<script language="javascript">
function changevalue(elename,v)
{
parent.addvalue(elename,v);
}
</script> | 10npsite | trunk/Public/jsLibrary/cdate_py_z_code.php | PHP | asf20 | 12,940 |
<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
// Define a destination
$targetFolder = '/uploads'; // Relative to the root
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo '1';
} else {
echo 'Invalid file type.';
}
}
?> | 10npsite | trunk/Public/jsLibrary/uploadify/uploadify.php | PHP | asf20 | 767 |
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
.uploadify {
position: relative;
margin-bottom: 1em;
}
.uploadify-button {
background-color: #505050;
background-image: linear-gradient(bottom, #505050 0%, #707070 100%);
background-image: -o-linear-gradient(bottom, #505050 0%, #707070 100%);
background-image: -moz-linear-gradient(bottom, #505050 0%, #707070 100%);
background-image: -webkit-linear-gradient(bottom, #505050 0%, #707070 100%);
background-image: -ms-linear-gradient(bottom, #505050 0%, #707070 100%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, #505050),
color-stop(1, #707070)
);
background-position: center top;
background-repeat: no-repeat;
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
border-radius: 30px;
border: 2px solid #808080;
color: #FFF;
font: bold 12px Arial, Helvetica, sans-serif;
text-align: center;
text-shadow: 0 -1px 0 rgba(0,0,0,0.25);
width: 100%;
}
.uploadify:hover .uploadify-button {
background-color: #606060;
background-image: linear-gradient(top, #606060 0%, #808080 100%);
background-image: -o-linear-gradient(top, #606060 0%, #808080 100%);
background-image: -moz-linear-gradient(top, #606060 0%, #808080 100%);
background-image: -webkit-linear-gradient(top, #606060 0%, #808080 100%);
background-image: -ms-linear-gradient(top, #606060 0%, #808080 100%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, #606060),
color-stop(1, #808080)
);
background-position: center bottom;
}
.uploadify-button.disabled {
background-color: #D0D0D0;
color: #808080;
}
.uploadify-queue {
margin-bottom: 1em;
}
.uploadify-queue-item {
background-color: #F5F5F5;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
font: 11px Verdana, Geneva, sans-serif;
margin-top: 5px;
max-width: 350px;
padding: 10px;
}
.uploadify-error {
background-color: #FDE5DD !important;
}
.uploadify-queue-item .cancel a {
background: url('../img/uploadify-cancel.png') 0 0 no-repeat;
float: right;
height: 16px;
text-indent: -9999px;
width: 16px;
}
.uploadify-queue-item.completed {
background-color: #E5E5E5;
}
.uploadify-progress {
background-color: #E5E5E5;
margin-top: 10px;
width: 100%;
}
.uploadify-progress-bar {
background-color: #0099FF;
height: 3px;
width: 1px;
} | 10npsite | trunk/Public/jsLibrary/uploadify/uploadify.css | CSS | asf20 | 2,543 |
/*
SWFObject v2.2 <http://code.google.com/p/swfobject/>
is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
;var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;
if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;
X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);
ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0;}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");
if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)];}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac};
}(),k=function(){if(!M.w3){return;}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f();
}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false);}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);
f();}});if(O==top){(function(){if(J){return;}try{j.documentElement.doScroll("left");}catch(X){setTimeout(arguments.callee,0);return;}f();})();}}if(M.wk){(function(){if(J){return;
}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return;}f();})();}s(f);}}();function f(){if(J){return;}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));
Z.parentNode.removeChild(Z);}catch(aa){return;}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]();}}function K(X){if(J){X();}else{U[U.length]=X;}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false);
}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false);}else{if(typeof O.attachEvent!=D){i(O,"onload",Y);}else{if(typeof O.onload=="function"){var X=O.onload;
O.onload=function(){X();Y();};}else{O.onload=Y;}}}}}function h(){if(T){V();}else{H();}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);
aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");
M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)];}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return;}}X.removeChild(aa);Z=null;H();
})();}else{H();}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);
if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa);}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;
ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class");}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align");
}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value");
}}P(ai,ah,Y,ab);}else{p(ae);if(ab){ab(aa);}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z;}ab(aa);}}}}}function z(aa){var X=null;
var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y;}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z;}}}return X;}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312);
}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null;}else{l=ae;Q=X;}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310";
}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137";}j.title=j.title.slice(0,47)+" - Flash Player Installation";
var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac;
}else{ab.flashvars=ac;}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";
(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae);}else{setTimeout(arguments.callee,10);}})();}u(aa,ab,X);}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");
Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y);}else{setTimeout(arguments.callee,10);
}})();}else{Y.parentNode.replaceChild(g(Y),Y);}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML;}else{var Y=ab.getElementsByTagName(r)[0];
if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true));
}}}}}return aa;}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X;}if(aa){if(typeof ai.id==D){ai.id=Y;}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae];
}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"';}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"';}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />';
}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id);}else{var Z=C(r);Z.setAttribute("type",q);
for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac]);}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac]);
}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab]);}}aa.parentNode.replaceChild(Z,aa);X=Z;}}return X;}function e(Z,X,Y){var aa=C("param");
aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa);}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";
(function(){if(X.readyState==4){b(Y);}else{setTimeout(arguments.callee,10);}})();}else{X.parentNode.removeChild(X);}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null;
}}Y.parentNode.removeChild(Y);}}function c(Z){var X=null;try{X=j.getElementById(Z);}catch(Y){}return X;}function C(X){return j.createElement(X);}function i(Z,X,Y){Z.attachEvent(X,Y);
I[I.length]=[Z,X,Y];}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false;
}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return;}var aa=j.getElementsByTagName("head")[0];if(!aa){return;}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;
G=null;}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1];
}G=X;}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y);}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"));
}}}function w(Z,X){if(!m){return;}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y;}else{v("#"+Z,"visibility:"+Y);}}function L(Y){var Z=/[\\\"<>\.;]/;
var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y;}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;
for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2]);}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa]);}for(var Y in M){M[Y]=null;}M=null;for(var X in swfobject){swfobject[X]=null;
}swfobject=null;});}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;
w(ab,false);}else{if(Z){Z({success:false,id:ab});}}},getObjectById:function(X){if(M.w3){return z(X);}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};
if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al];}}aj.data=ab;
aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak];}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai];
}else{am.flashvars=ai+"="+Z[ai];}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true);}X.success=true;X.ref=an;}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);
return;}else{w(ah,true);}}if(ac){ac(X);}});}else{if(ac){ac(X);}}},switchOffAutoHideShow:function(){m=false;},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]};
},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X);}else{return undefined;}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y);
}},removeSWF:function(X){if(M.w3){y(X);}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X);}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;
if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1];}if(aa==null){return L(Z);}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)));
}}}return"";},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block";
}}if(E){E(B);}}a=false;}}};}();
/*
SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/
SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License:
http://www.opensource.org/licenses/mit-license.php
SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
http://www.opensource.org/licenses/mit-license.php
*/
var SWFUpload;if(SWFUpload==undefined){SWFUpload=function(a){this.initSWFUpload(a)}}SWFUpload.prototype.initSWFUpload=function(b){try{this.customSettings={};this.settings=b;this.eventQueue=[];this.movieName="SWFUpload_"+SWFUpload.movieCount++;this.movieElement=null;SWFUpload.instances[this.movieName]=this;this.initSettings();this.loadFlash();this.displayDebugInfo()}catch(a){delete SWFUpload.instances[this.movieName];throw a}};SWFUpload.instances={};SWFUpload.movieCount=0;SWFUpload.version="2.2.0 2009-03-25";SWFUpload.QUEUE_ERROR={QUEUE_LIMIT_EXCEEDED:-100,FILE_EXCEEDS_SIZE_LIMIT:-110,ZERO_BYTE_FILE:-120,INVALID_FILETYPE:-130};SWFUpload.UPLOAD_ERROR={HTTP_ERROR:-200,MISSING_UPLOAD_URL:-210,IO_ERROR:-220,SECURITY_ERROR:-230,UPLOAD_LIMIT_EXCEEDED:-240,UPLOAD_FAILED:-250,SPECIFIED_FILE_ID_NOT_FOUND:-260,FILE_VALIDATION_FAILED:-270,FILE_CANCELLED:-280,UPLOAD_STOPPED:-290};SWFUpload.FILE_STATUS={QUEUED:-1,IN_PROGRESS:-2,ERROR:-3,COMPLETE:-4,CANCELLED:-5};SWFUpload.BUTTON_ACTION={SELECT_FILE:-100,SELECT_FILES:-110,START_UPLOAD:-120};SWFUpload.CURSOR={ARROW:-1,HAND:-2};SWFUpload.WINDOW_MODE={WINDOW:"window",TRANSPARENT:"transparent",OPAQUE:"opaque"};SWFUpload.completeURL=function(a){if(typeof(a)!=="string"||a.match(/^https?:\/\//i)||a.match(/^\//)){return a}var c=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"");var b=window.location.pathname.lastIndexOf("/");if(b<=0){path="/"}else{path=window.location.pathname.substr(0,b)+"/"}return path+a};SWFUpload.prototype.initSettings=function(){this.ensureDefault=function(b,a){this.settings[b]=(this.settings[b]==undefined)?a:this.settings[b]};this.ensureDefault("upload_url","");this.ensureDefault("preserve_relative_urls",false);this.ensureDefault("file_post_name","Filedata");this.ensureDefault("post_params",{});this.ensureDefault("use_query_string",false);this.ensureDefault("requeue_on_error",false);this.ensureDefault("http_success",[]);this.ensureDefault("assume_success_timeout",0);this.ensureDefault("file_types","*.*");this.ensureDefault("file_types_description","All Files");this.ensureDefault("file_size_limit",0);this.ensureDefault("file_upload_limit",0);this.ensureDefault("file_queue_limit",0);this.ensureDefault("flash_url","swfupload.swf");this.ensureDefault("prevent_swf_caching",true);this.ensureDefault("button_image_url","");this.ensureDefault("button_width",1);this.ensureDefault("button_height",1);this.ensureDefault("button_text","");this.ensureDefault("button_text_style","color: #000000; font-size: 16pt;");this.ensureDefault("button_text_top_padding",0);this.ensureDefault("button_text_left_padding",0);this.ensureDefault("button_action",SWFUpload.BUTTON_ACTION.SELECT_FILES);this.ensureDefault("button_disabled",false);this.ensureDefault("button_placeholder_id","");this.ensureDefault("button_placeholder",null);this.ensureDefault("button_cursor",SWFUpload.CURSOR.ARROW);this.ensureDefault("button_window_mode",SWFUpload.WINDOW_MODE.WINDOW);this.ensureDefault("debug",false);this.settings.debug_enabled=this.settings.debug;this.settings.return_upload_start_handler=this.returnUploadStart;this.ensureDefault("swfupload_loaded_handler",null);this.ensureDefault("file_dialog_start_handler",null);this.ensureDefault("file_queued_handler",null);this.ensureDefault("file_queue_error_handler",null);this.ensureDefault("file_dialog_complete_handler",null);this.ensureDefault("upload_start_handler",null);this.ensureDefault("upload_progress_handler",null);this.ensureDefault("upload_error_handler",null);this.ensureDefault("upload_success_handler",null);this.ensureDefault("upload_complete_handler",null);this.ensureDefault("debug_handler",this.debugMessage);this.ensureDefault("custom_settings",{});this.customSettings=this.settings.custom_settings;if(!!this.settings.prevent_swf_caching){this.settings.flash_url=this.settings.flash_url+(this.settings.flash_url.indexOf("?")<0?"?":"&")+"preventswfcaching="+new Date().getTime()}if(!this.settings.preserve_relative_urls){this.settings.upload_url=SWFUpload.completeURL(this.settings.upload_url);this.settings.button_image_url=SWFUpload.completeURL(this.settings.button_image_url)}delete this.ensureDefault};SWFUpload.prototype.loadFlash=function(){var a,b;if(document.getElementById(this.movieName)!==null){throw"ID "+this.movieName+" is already in use. The Flash Object could not be added"}a=document.getElementById(this.settings.button_placeholder_id)||this.settings.button_placeholder;if(a==undefined){throw"Could not find the placeholder element: "+this.settings.button_placeholder_id}b=document.createElement("div");b.innerHTML=this.getFlashHTML();a.parentNode.replaceChild(b.firstChild,a);if(window[this.movieName]==undefined){window[this.movieName]=this.getMovieElement()}};SWFUpload.prototype.getFlashHTML=function(){return['<object id="',this.movieName,'" type="application/x-shockwave-flash" data="',this.settings.flash_url,'" width="',this.settings.button_width,'" height="',this.settings.button_height,'" class="swfupload">','<param name="wmode" value="',this.settings.button_window_mode,'" />','<param name="movie" value="',this.settings.flash_url,'" />','<param name="quality" value="high" />','<param name="menu" value="false" />','<param name="allowScriptAccess" value="always" />','<param name="flashvars" value="'+this.getFlashVars()+'" />',"</object>"].join("")};SWFUpload.prototype.getFlashVars=function(){var b=this.buildParamString();var a=this.settings.http_success.join(",");return["movieName=",encodeURIComponent(this.movieName),"&uploadURL=",encodeURIComponent(this.settings.upload_url),"&useQueryString=",encodeURIComponent(this.settings.use_query_string),"&requeueOnError=",encodeURIComponent(this.settings.requeue_on_error),"&httpSuccess=",encodeURIComponent(a),"&assumeSuccessTimeout=",encodeURIComponent(this.settings.assume_success_timeout),"&params=",encodeURIComponent(b),"&filePostName=",encodeURIComponent(this.settings.file_post_name),"&fileTypes=",encodeURIComponent(this.settings.file_types),"&fileTypesDescription=",encodeURIComponent(this.settings.file_types_description),"&fileSizeLimit=",encodeURIComponent(this.settings.file_size_limit),"&fileUploadLimit=",encodeURIComponent(this.settings.file_upload_limit),"&fileQueueLimit=",encodeURIComponent(this.settings.file_queue_limit),"&debugEnabled=",encodeURIComponent(this.settings.debug_enabled),"&buttonImageURL=",encodeURIComponent(this.settings.button_image_url),"&buttonWidth=",encodeURIComponent(this.settings.button_width),"&buttonHeight=",encodeURIComponent(this.settings.button_height),"&buttonText=",encodeURIComponent(this.settings.button_text),"&buttonTextTopPadding=",encodeURIComponent(this.settings.button_text_top_padding),"&buttonTextLeftPadding=",encodeURIComponent(this.settings.button_text_left_padding),"&buttonTextStyle=",encodeURIComponent(this.settings.button_text_style),"&buttonAction=",encodeURIComponent(this.settings.button_action),"&buttonDisabled=",encodeURIComponent(this.settings.button_disabled),"&buttonCursor=",encodeURIComponent(this.settings.button_cursor)].join("")};SWFUpload.prototype.getMovieElement=function(){if(this.movieElement==undefined){this.movieElement=document.getElementById(this.movieName)}if(this.movieElement===null){throw"Could not find Flash element"}return this.movieElement};SWFUpload.prototype.buildParamString=function(){var c=this.settings.post_params;var b=[];if(typeof(c)==="object"){for(var a in c){if(c.hasOwnProperty(a)){b.push(encodeURIComponent(a.toString())+"="+encodeURIComponent(c[a].toString()))}}}return b.join("&")};SWFUpload.prototype.destroy=function(){try{this.cancelUpload(null,false);var a=null;a=this.getMovieElement();if(a&&typeof(a.CallFunction)==="unknown"){for(var c in a){try{if(typeof(a[c])==="function"){a[c]=null}}catch(e){}}try{a.parentNode.removeChild(a)}catch(b){}}window[this.movieName]=null;SWFUpload.instances[this.movieName]=null;delete SWFUpload.instances[this.movieName];this.movieElement=null;this.settings=null;this.customSettings=null;this.eventQueue=null;this.movieName=null;return true}catch(d){return false}};SWFUpload.prototype.displayDebugInfo=function(){this.debug(["---SWFUpload Instance Info---\n","Version: ",SWFUpload.version,"\n","Movie Name: ",this.movieName,"\n","Settings:\n","\t","upload_url: ",this.settings.upload_url,"\n","\t","flash_url: ",this.settings.flash_url,"\n","\t","use_query_string: ",this.settings.use_query_string.toString(),"\n","\t","requeue_on_error: ",this.settings.requeue_on_error.toString(),"\n","\t","http_success: ",this.settings.http_success.join(", "),"\n","\t","assume_success_timeout: ",this.settings.assume_success_timeout,"\n","\t","file_post_name: ",this.settings.file_post_name,"\n","\t","post_params: ",this.settings.post_params.toString(),"\n","\t","file_types: ",this.settings.file_types,"\n","\t","file_types_description: ",this.settings.file_types_description,"\n","\t","file_size_limit: ",this.settings.file_size_limit,"\n","\t","file_upload_limit: ",this.settings.file_upload_limit,"\n","\t","file_queue_limit: ",this.settings.file_queue_limit,"\n","\t","debug: ",this.settings.debug.toString(),"\n","\t","prevent_swf_caching: ",this.settings.prevent_swf_caching.toString(),"\n","\t","button_placeholder_id: ",this.settings.button_placeholder_id.toString(),"\n","\t","button_placeholder: ",(this.settings.button_placeholder?"Set":"Not Set"),"\n","\t","button_image_url: ",this.settings.button_image_url.toString(),"\n","\t","button_width: ",this.settings.button_width.toString(),"\n","\t","button_height: ",this.settings.button_height.toString(),"\n","\t","button_text: ",this.settings.button_text.toString(),"\n","\t","button_text_style: ",this.settings.button_text_style.toString(),"\n","\t","button_text_top_padding: ",this.settings.button_text_top_padding.toString(),"\n","\t","button_text_left_padding: ",this.settings.button_text_left_padding.toString(),"\n","\t","button_action: ",this.settings.button_action.toString(),"\n","\t","button_disabled: ",this.settings.button_disabled.toString(),"\n","\t","custom_settings: ",this.settings.custom_settings.toString(),"\n","Event Handlers:\n","\t","swfupload_loaded_handler assigned: ",(typeof this.settings.swfupload_loaded_handler==="function").toString(),"\n","\t","file_dialog_start_handler assigned: ",(typeof this.settings.file_dialog_start_handler==="function").toString(),"\n","\t","file_queued_handler assigned: ",(typeof this.settings.file_queued_handler==="function").toString(),"\n","\t","file_queue_error_handler assigned: ",(typeof this.settings.file_queue_error_handler==="function").toString(),"\n","\t","upload_start_handler assigned: ",(typeof this.settings.upload_start_handler==="function").toString(),"\n","\t","upload_progress_handler assigned: ",(typeof this.settings.upload_progress_handler==="function").toString(),"\n","\t","upload_error_handler assigned: ",(typeof this.settings.upload_error_handler==="function").toString(),"\n","\t","upload_success_handler assigned: ",(typeof this.settings.upload_success_handler==="function").toString(),"\n","\t","upload_complete_handler assigned: ",(typeof this.settings.upload_complete_handler==="function").toString(),"\n","\t","debug_handler assigned: ",(typeof this.settings.debug_handler==="function").toString(),"\n"].join(""))};SWFUpload.prototype.addSetting=function(b,c,a){if(c==undefined){return(this.settings[b]=a)}else{return(this.settings[b]=c)}};SWFUpload.prototype.getSetting=function(a){if(this.settings[a]!=undefined){return this.settings[a]}return""};SWFUpload.prototype.callFlash=function(functionName,argumentArray){argumentArray=argumentArray||[];var movieElement=this.getMovieElement();var returnValue,returnString;try{returnString=movieElement.CallFunction('<invoke name="'+functionName+'" returntype="javascript">'+__flash__argumentsToXML(argumentArray,0)+"</invoke>");returnValue=eval(returnString)}catch(ex){throw"Call to "+functionName+" failed"}if(returnValue!=undefined&&typeof returnValue.post==="object"){returnValue=this.unescapeFilePostParams(returnValue)}return returnValue};SWFUpload.prototype.selectFile=function(){this.callFlash("SelectFile")};SWFUpload.prototype.selectFiles=function(){this.callFlash("SelectFiles")};SWFUpload.prototype.startUpload=function(a){this.callFlash("StartUpload",[a])};SWFUpload.prototype.cancelUpload=function(a,b){if(b!==false){b=true}this.callFlash("CancelUpload",[a,b])};SWFUpload.prototype.stopUpload=function(){this.callFlash("StopUpload")};SWFUpload.prototype.getStats=function(){return this.callFlash("GetStats")};SWFUpload.prototype.setStats=function(a){this.callFlash("SetStats",[a])};SWFUpload.prototype.getFile=function(a){if(typeof(a)==="number"){return this.callFlash("GetFileByIndex",[a])}else{return this.callFlash("GetFile",[a])}};SWFUpload.prototype.addFileParam=function(a,b,c){return this.callFlash("AddFileParam",[a,b,c])};SWFUpload.prototype.removeFileParam=function(a,b){this.callFlash("RemoveFileParam",[a,b])};SWFUpload.prototype.setUploadURL=function(a){this.settings.upload_url=a.toString();this.callFlash("SetUploadURL",[a])};SWFUpload.prototype.setPostParams=function(a){this.settings.post_params=a;this.callFlash("SetPostParams",[a])};SWFUpload.prototype.addPostParam=function(a,b){this.settings.post_params[a]=b;this.callFlash("SetPostParams",[this.settings.post_params])};SWFUpload.prototype.removePostParam=function(a){delete this.settings.post_params[a];this.callFlash("SetPostParams",[this.settings.post_params])};SWFUpload.prototype.setFileTypes=function(a,b){this.settings.file_types=a;this.settings.file_types_description=b;this.callFlash("SetFileTypes",[a,b])};SWFUpload.prototype.setFileSizeLimit=function(a){this.settings.file_size_limit=a;this.callFlash("SetFileSizeLimit",[a])};SWFUpload.prototype.setFileUploadLimit=function(a){this.settings.file_upload_limit=a;this.callFlash("SetFileUploadLimit",[a])};SWFUpload.prototype.setFileQueueLimit=function(a){this.settings.file_queue_limit=a;this.callFlash("SetFileQueueLimit",[a])};SWFUpload.prototype.setFilePostName=function(a){this.settings.file_post_name=a;this.callFlash("SetFilePostName",[a])};SWFUpload.prototype.setUseQueryString=function(a){this.settings.use_query_string=a;this.callFlash("SetUseQueryString",[a])};SWFUpload.prototype.setRequeueOnError=function(a){this.settings.requeue_on_error=a;this.callFlash("SetRequeueOnError",[a])};SWFUpload.prototype.setHTTPSuccess=function(a){if(typeof a==="string"){a=a.replace(" ","").split(",")}this.settings.http_success=a;this.callFlash("SetHTTPSuccess",[a])};SWFUpload.prototype.setAssumeSuccessTimeout=function(a){this.settings.assume_success_timeout=a;this.callFlash("SetAssumeSuccessTimeout",[a])};SWFUpload.prototype.setDebugEnabled=function(a){this.settings.debug_enabled=a;this.callFlash("SetDebugEnabled",[a])};SWFUpload.prototype.setButtonImageURL=function(a){if(a==undefined){a=""}this.settings.button_image_url=a;this.callFlash("SetButtonImageURL",[a])};SWFUpload.prototype.setButtonDimensions=function(c,a){this.settings.button_width=c;this.settings.button_height=a;var b=this.getMovieElement();if(b!=undefined){b.style.width=c+"px";b.style.height=a+"px"}this.callFlash("SetButtonDimensions",[c,a])};SWFUpload.prototype.setButtonText=function(a){this.settings.button_text=a;this.callFlash("SetButtonText",[a])};SWFUpload.prototype.setButtonTextPadding=function(b,a){this.settings.button_text_top_padding=a;this.settings.button_text_left_padding=b;this.callFlash("SetButtonTextPadding",[b,a])};SWFUpload.prototype.setButtonTextStyle=function(a){this.settings.button_text_style=a;this.callFlash("SetButtonTextStyle",[a])};SWFUpload.prototype.setButtonDisabled=function(a){this.settings.button_disabled=a;this.callFlash("SetButtonDisabled",[a])};SWFUpload.prototype.setButtonAction=function(a){this.settings.button_action=a;this.callFlash("SetButtonAction",[a])};SWFUpload.prototype.setButtonCursor=function(a){this.settings.button_cursor=a;this.callFlash("SetButtonCursor",[a])};SWFUpload.prototype.queueEvent=function(b,c){if(c==undefined){c=[]}else{if(!(c instanceof Array)){c=[c]}}var a=this;if(typeof this.settings[b]==="function"){this.eventQueue.push(function(){this.settings[b].apply(this,c)});setTimeout(function(){a.executeNextEvent()},0)}else{if(this.settings[b]!==null){throw"Event handler "+b+" is unknown or is not a function"}}};SWFUpload.prototype.executeNextEvent=function(){var a=this.eventQueue?this.eventQueue.shift():null;if(typeof(a)==="function"){a.apply(this)}};SWFUpload.prototype.unescapeFilePostParams=function(c){var e=/[$]([0-9a-f]{4})/i;var f={};var d;if(c!=undefined){for(var a in c.post){if(c.post.hasOwnProperty(a)){d=a;var b;while((b=e.exec(d))!==null){d=d.replace(b[0],String.fromCharCode(parseInt("0x"+b[1],16)))}f[d]=c.post[a]}}c.post=f}return c};SWFUpload.prototype.testExternalInterface=function(){try{return this.callFlash("TestExternalInterface")}catch(a){return false}};SWFUpload.prototype.flashReady=function(){var a=this.getMovieElement();if(!a){this.debug("Flash called back ready but the flash movie can't be found.");return}this.cleanUp(a);this.queueEvent("swfupload_loaded_handler")};SWFUpload.prototype.cleanUp=function(a){try{if(this.movieElement&&typeof(a.CallFunction)==="unknown"){this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");for(var c in a){try{if(typeof(a[c])==="function"){a[c]=null}}catch(b){}}}}catch(d){}window.__flash__removeCallback=function(e,f){try{if(e){e[f]=null}}catch(g){}}};SWFUpload.prototype.fileDialogStart=function(){this.queueEvent("file_dialog_start_handler")};SWFUpload.prototype.fileQueued=function(a){a=this.unescapeFilePostParams(a);this.queueEvent("file_queued_handler",a)};SWFUpload.prototype.fileQueueError=function(a,c,b){a=this.unescapeFilePostParams(a);this.queueEvent("file_queue_error_handler",[a,c,b])};SWFUpload.prototype.fileDialogComplete=function(b,c,a){this.queueEvent("file_dialog_complete_handler",[b,c,a])};SWFUpload.prototype.uploadStart=function(a){a=this.unescapeFilePostParams(a);this.queueEvent("return_upload_start_handler",a)};SWFUpload.prototype.returnUploadStart=function(a){var b;if(typeof this.settings.upload_start_handler==="function"){a=this.unescapeFilePostParams(a);b=this.settings.upload_start_handler.call(this,a)}else{if(this.settings.upload_start_handler!=undefined){throw"upload_start_handler must be a function"}}if(b===undefined){b=true}b=!!b;this.callFlash("ReturnUploadStart",[b])};SWFUpload.prototype.uploadProgress=function(a,c,b){a=this.unescapeFilePostParams(a);this.queueEvent("upload_progress_handler",[a,c,b])};SWFUpload.prototype.uploadError=function(a,c,b){a=this.unescapeFilePostParams(a);this.queueEvent("upload_error_handler",[a,c,b])};SWFUpload.prototype.uploadSuccess=function(b,a,c){b=this.unescapeFilePostParams(b);this.queueEvent("upload_success_handler",[b,a,c])};SWFUpload.prototype.uploadComplete=function(a){a=this.unescapeFilePostParams(a);this.queueEvent("upload_complete_handler",a)};SWFUpload.prototype.debug=function(a){this.queueEvent("debug_handler",a)};SWFUpload.prototype.debugMessage=function(c){if(this.settings.debug){var a,d=[];if(typeof c==="object"&&typeof c.name==="string"&&typeof c.message==="string"){for(var b in c){if(c.hasOwnProperty(b)){d.push(b+": "+c[b])}}a=d.join("\n")||"";d=a.split("\n");a="EXCEPTION: "+d.join("\nEXCEPTION: ");SWFUpload.Console.writeLine(a)}else{SWFUpload.Console.writeLine(c)}}};SWFUpload.Console={};SWFUpload.Console.writeLine=function(d){var b,a;try{b=document.getElementById("SWFUpload_Console");if(!b){a=document.createElement("form");document.getElementsByTagName("body")[0].appendChild(a);b=document.createElement("textarea");b.id="SWFUpload_Console";b.style.fontFamily="monospace";b.setAttribute("wrap","off");b.wrap="off";b.style.overflow="auto";b.style.width="700px";b.style.height="350px";b.style.margin="5px";a.appendChild(b)}b.value+=d+"\n";b.scrollTop=b.scrollHeight-b.clientHeight}catch(c){alert("Exception: "+c.name+" Message: "+c.message)}};
/*
Uploadify v3.1.1
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
(function($) {
// These methods can be called by adding them as the first argument in the uploadify plugin call
var methods = {
init : function(options, swfUploadOptions) {
return this.each(function() {
// Create a reference to the jQuery DOM object
var $this = $(this);
// Clone the original DOM object
var $clone = $this.clone();
// Setup the default options
var settings = $.extend({
// Required Settings
id : $this.attr('id'), // The ID of the DOM object
swf : 'uploadify.swf', // The path to the uploadify SWF file
uploader : 'uploadify.php', // The path to the server-side upload script
// Options
auto : true, // Automatically upload files when added to the queue
buttonClass : '', // A class name to add to the browse button DOM object
buttonCursor : 'hand', // The cursor to use with the browse button
buttonImage : null, // (String or null) The path to an image to use for the Flash browse button if not using CSS to style the button
buttonText : 'SELECT FILES', // The text to use for the browse button
checkExisting : false, // The path to a server-side script that checks for existing files on the server
debug : false, // Turn on swfUpload debugging mode
fileObjName : 'Filedata', // The name of the file object to use in your server-side script
fileSizeLimit : 0, // The maximum size of an uploadable file in KB (Accepts units B KB MB GB if string, 0 for no limit)
fileTypeDesc : 'All Files', // The description for file types in the browse dialog
fileTypeExts : '*.*', // Allowed extensions in the browse dialog (server-side validation should also be used)
height : 30, // The height of the browse button
method : 'post', // The method to use when sending files to the server-side upload script
multi : true, // Allow multiple file selection in the browse dialog
formData : {}, // An object with additional data to send to the server-side upload script with every file upload
preventCaching : true, // Adds a random value to the Flash URL to prevent caching of it (conflicts with existing parameters)
progressData : 'percentage', // ('percentage' or 'speed') Data to show in the queue item during a file upload
queueID : false, // The ID of the DOM object to use as a file queue (without the #)
queueSizeLimit : 999, // The maximum number of files that can be in the queue at one time
removeCompleted : true, // Remove queue items from the queue when they are done uploading
removeTimeout : 3, // The delay in seconds before removing a queue item if removeCompleted is set to true
requeueErrors : false, // Keep errored files in the queue and keep trying to upload them
successTimeout : 30, // The number of seconds to wait for Flash to detect the server's response after the file has finished uploading
uploadLimit : 0, // The maximum number of files you can upload
width : 120, // The width of the browse button
// Events
overrideEvents : [] // (Array) A list of default event handlers to skip
/*
onCancel // Triggered when a file is cancelled from the queue
onClearQueue // Triggered during the 'clear queue' method
onDestroy // Triggered when the uploadify object is destroyed
onDialogClose // Triggered when the browse dialog is closed
onDialogOpen // Triggered when the browse dialog is opened
onDisable // Triggered when the browse button gets disabled
onEnable // Triggered when the browse button gets enabled
onFallback // Triggered is Flash is not detected
onInit // Triggered when Uploadify is initialized
onQueueComplete // Triggered when all files in the queue have been uploaded
onSelectError // Triggered when an error occurs while selecting a file (file size, queue size limit, etc.)
onSelect // Triggered for each file that is selected
onSWFReady // Triggered when the SWF button is loaded
onUploadComplete // Triggered when a file upload completes (success or error)
onUploadError // Triggered when a file upload returns an error
onUploadSuccess // Triggered when a file is uploaded successfully
onUploadProgress // Triggered every time a file progress is updated
onUploadStart // Triggered immediately before a file upload starts
*/
}, options);
// Prepare settings for SWFUpload
var swfUploadSettings = {
assume_success_timeout : settings.successTimeout,
button_placeholder_id : settings.id,
button_width : settings.width,
button_height : settings.height,
button_text : null,
button_text_style : null,
button_text_top_padding : 0,
button_text_left_padding : 0,
button_action : (settings.multi ? SWFUpload.BUTTON_ACTION.SELECT_FILES : SWFUpload.BUTTON_ACTION.SELECT_FILE),
button_disabled : false,
button_cursor : (settings.buttonCursor == 'arrow' ? SWFUpload.CURSOR.ARROW : SWFUpload.CURSOR.HAND),
button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT,
debug : settings.debug,
requeue_on_error : settings.requeueErrors,
file_post_name : settings.fileObjName,
file_size_limit : settings.fileSizeLimit,
file_types : settings.fileTypeExts,
file_types_description : settings.fileTypeDesc,
file_queue_limit : settings.queueSizeLimit,
file_upload_limit : settings.uploadLimit,
flash_url : settings.swf,
prevent_swf_caching : settings.preventCaching,
post_params : settings.formData,
upload_url : settings.uploader,
use_query_string : (settings.method == 'get'),
// Event Handlers
file_dialog_complete_handler : handlers.onDialogClose,
file_dialog_start_handler : handlers.onDialogOpen,
file_queued_handler : handlers.onSelect,
file_queue_error_handler : handlers.onSelectError,
swfupload_loaded_handler : settings.onSWFReady,
upload_complete_handler : handlers.onUploadComplete,
upload_error_handler : handlers.onUploadError,
upload_progress_handler : handlers.onUploadProgress,
upload_start_handler : handlers.onUploadStart,
upload_success_handler : handlers.onUploadSuccess
}
// Merge the user-defined options with the defaults
if (swfUploadOptions) {
swfUploadSettings = $.extend(swfUploadSettings, swfUploadOptions);
}
// Add the user-defined settings to the swfupload object
swfUploadSettings = $.extend(swfUploadSettings, settings);
// Detect if Flash is available
var playerVersion = swfobject.getFlashPlayerVersion();
var flashInstalled = (playerVersion.major >= 9);
if (flashInstalled) {
// Create the swfUpload instance
window['uploadify_' + settings.id] = new SWFUpload(swfUploadSettings);
var swfuploadify = window['uploadify_' + settings.id];
// Add the SWFUpload object to the elements data object
$this.data('uploadify', swfuploadify);
// Wrap the instance
var $wrapper = $('<div />', {
'id' : settings.id,
'class' : 'uploadify',
'css' : {
'height' : settings.height + 'px',
'width' : settings.width + 'px'
}
});
$('#' + swfuploadify.movieName).wrap($wrapper);
// Recreate the reference to wrapper
$wrapper = $('#' + settings.id);
// Add the data object to the wrapper
$wrapper.data('uploadify', swfuploadify);
// Create the button
var $button = $('<div />', {
'id' : settings.id + '-button',
'class' : 'uploadify-button ' + settings.buttonClass
});
if (settings.buttonImage) {
$button.css({
'background-image' : "url('" + settings.buttonImage + "')",
'text-indent' : '-9999px'
});
}
$button.html('<span class="uploadify-button-text">' + settings.buttonText + '</span>')
.css({
'height' : settings.height + 'px',
'line-height' : settings.height + 'px',
'width' : settings.width + 'px'
});
// Append the button to the wrapper
$wrapper.append($button);
// Adjust the styles of the movie
$('#' + swfuploadify.movieName).css({
'position' : 'absolute',
'z-index' : 1
});
// Create the file queue
if (!settings.queueID) {
var $queue = $('<div />', {
'id' : settings.id + '-queue',
'class' : 'uploadify-queue'
});
$wrapper.after($queue);
swfuploadify.settings.queueID = settings.id + '-queue';
swfuploadify.settings.defaultQueue = true;
}
// Create some queue related objects and variables
swfuploadify.queueData = {
files : {}, // The files in the queue
filesSelected : 0, // The number of files selected in the last select operation
filesQueued : 0, // The number of files added to the queue in the last select operation
filesReplaced : 0, // The number of files replaced in the last select operation
filesCancelled : 0, // The number of files that were cancelled instead of replaced
filesErrored : 0, // The number of files that caused error in the last select operation
uploadsSuccessful : 0, // The number of files that were successfully uploaded
uploadsErrored : 0, // The number of files that returned errors during upload
averageSpeed : 0, // The average speed of the uploads in KB
queueLength : 0, // The number of files in the queue
queueSize : 0, // The size in bytes of the entire queue
uploadSize : 0, // The size in bytes of the upload queue
queueBytesUploaded : 0, // The size in bytes that have been uploaded for the current upload queue
uploadQueue : [], // The files currently to be uploaded
errorMsg : 'Some files were not added to the queue:'
};
// Save references to all the objects
swfuploadify.original = $clone;
swfuploadify.wrapper = $wrapper;
swfuploadify.button = $button;
swfuploadify.queue = $queue;
// Call the user-defined init event handler
if (settings.onInit) settings.onInit.call($this, swfuploadify);
} else {
// Call the fallback function
if (settings.onFallback) settings.onFallback.call($this);
}
});
},
// Stop a file upload and remove it from the queue
cancel : function(fileID, supressEvent) {
var args = arguments;
this.each(function() {
// Create a reference to the jQuery DOM object
var $this = $(this),
swfuploadify = $this.data('uploadify'),
settings = swfuploadify.settings,
delay = -1;
if (args[0]) {
// Clear the queue
if (args[0] == '*') {
var queueItemCount = swfuploadify.queueData.queueLength;
$('#' + settings.queueID).find('.uploadify-queue-item').each(function() {
delay++;
if (args[1] === true) {
swfuploadify.cancelUpload($(this).attr('id'), false);
} else {
swfuploadify.cancelUpload($(this).attr('id'));
}
$(this).find('.data').removeClass('data').html(' - Cancelled');
$(this).find('.uploadify-progress-bar').remove();
$(this).delay(1000 + 100 * delay).fadeOut(500, function() {
$(this).remove();
});
});
swfuploadify.queueData.queueSize = 0;
swfuploadify.queueData.queueLength = 0;
// Trigger the onClearQueue event
if (settings.onClearQueue) settings.onClearQueue.call($this, queueItemCount);
} else {
for (var n = 0; n < args.length; n++) {
swfuploadify.cancelUpload(args[n]);
$('#' + args[n]).find('.data').removeClass('data').html(' - Cancelled');
$('#' + args[n]).find('.uploadify-progress-bar').remove();
$('#' + args[n]).delay(1000 + 100 * n).fadeOut(500, function() {
$(this).remove();
});
}
}
} else {
var item = $('#' + settings.queueID).find('.uploadify-queue-item').get(0);
$item = $(item);
swfuploadify.cancelUpload($item.attr('id'));
$item.find('.data').removeClass('data').html(' - Cancelled');
$item.find('.uploadify-progress-bar').remove();
$item.delay(1000).fadeOut(500, function() {
$(this).remove();
});
}
});
},
// Revert the DOM object back to its original state
destroy : function() {
this.each(function() {
// Create a reference to the jQuery DOM object
var $this = $(this),
swfuploadify = $this.data('uploadify'),
settings = swfuploadify.settings;
// Destroy the SWF object and
swfuploadify.destroy();
// Destroy the queue
if (settings.defaultQueue) {
$('#' + settings.queueID).remove();
}
// Reload the original DOM element
$('#' + settings.id).replaceWith(swfuploadify.original);
// Call the user-defined event handler
if (settings.onDestroy) settings.onDestroy.call(this);
delete swfuploadify;
});
},
// Disable the select button
disable : function(isDisabled) {
this.each(function() {
// Create a reference to the jQuery DOM object
var $this = $(this),
swfuploadify = $this.data('uploadify'),
settings = swfuploadify.settings;
// Call the user-defined event handlers
if (isDisabled) {
swfuploadify.button.addClass('disabled');
if (settings.onDisable) settings.onDisable.call(this);
} else {
swfuploadify.button.removeClass('disabled');
if (settings.onEnable) settings.onEnable.call(this);
}
// Enable/disable the browse button
swfuploadify.setButtonDisabled(isDisabled);
});
},
// Get or set the settings data
settings : function(name, value, resetObjects) {
var args = arguments;
var returnValue = value;
this.each(function() {
// Create a reference to the jQuery DOM object
var $this = $(this),
swfuploadify = $this.data('uploadify'),
settings = swfuploadify.settings;
if (typeof(args[0]) == 'object') {
for (var n in value) {
setData(n,value[n]);
}
}
if (args.length === 1) {
returnValue = settings[name];
} else {
switch (name) {
case 'uploader':
swfuploadify.setUploadURL(value);
break;
case 'formData':
if (!resetObjects) {
value = $.extend(settings.formData, value);
}
swfuploadify.setPostParams(settings.formData);
break;
case 'method':
if (value == 'get') {
swfuploadify.setUseQueryString(true);
} else {
swfuploadify.setUseQueryString(false);
}
break;
case 'fileObjName':
swfuploadify.setFilePostName(value);
break;
case 'fileTypeExts':
swfuploadify.setFileTypes(value, settings.fileTypeDesc);
break;
case 'fileTypeDesc':
swfuploadify.setFileTypes(settings.fileTypeExts, value);
break;
case 'fileSizeLimit':
swfuploadify.setFileSizeLimit(value);
break;
case 'uploadLimit':
swfuploadify.setFileUploadLimit(value);
break;
case 'queueSizeLimit':
swfuploadify.setFileQueueLimit(value);
break;
case 'buttonImage':
swfuploadify.button.css('background-image', settingValue);
break;
case 'buttonCursor':
if (value == 'arrow') {
swfuploadify.setButtonCursor(SWFUpload.CURSOR.ARROW);
} else {
swfuploadify.setButtonCursor(SWFUpload.CURSOR.HAND);
}
break;
case 'buttonText':
$('#' + settings.id + '-button').find('.uploadify-button-text').html(value);
break;
case 'width':
swfuploadify.setButtonDimensions(value, settings.height);
break;
case 'height':
swfuploadify.setButtonDimensions(settings.width, value);
break;
case 'multi':
if (value) {
swfuploadify.setButtonAction(SWFUpload.BUTTON_ACTION.SELECT_FILES);
} else {
swfuploadify.setButtonAction(SWFUpload.BUTTON_ACTION.SELECT_FILE);
}
break;
}
settings[name] = value;
}
});
if (args.length === 1) {
return returnValue;
}
},
// Stop the current uploads and requeue what is in progress
stop : function() {
this.each(function() {
// Create a reference to the jQuery DOM object
var $this = $(this),
swfuploadify = $this.data('uploadify');
// Reset the queue information
swfuploadify.queueData.averageSpeed = 0;
swfuploadify.queueData.uploadSize = 0;
swfuploadify.queueData.bytesUploaded = 0;
swfuploadify.queueData.uploadQueue = [];
swfuploadify.stopUpload();
});
},
// Start uploading files in the queue
upload : function() {
var args = arguments;
this.each(function() {
// Create a reference to the jQuery DOM object
var $this = $(this),
swfuploadify = $this.data('uploadify');
// Reset the queue information
swfuploadify.queueData.averageSpeed = 0;
swfuploadify.queueData.uploadSize = 0;
swfuploadify.queueData.bytesUploaded = 0;
swfuploadify.queueData.uploadQueue = [];
// Upload the files
if (args[0]) {
if (args[0] == '*') {
swfuploadify.queueData.uploadSize = swfuploadify.queueData.queueSize;
swfuploadify.queueData.uploadQueue.push('*');
swfuploadify.startUpload();
} else {
for (var n = 0; n < args.length; n++) {
swfuploadify.queueData.uploadSize += swfuploadify.queueData.files[args[n]].size;
swfuploadify.queueData.uploadQueue.push(args[n]);
}
swfuploadify.startUpload(swfuploadify.queueData.uploadQueue.shift());
}
} else {
swfuploadify.startUpload();
}
});
}
}
// These functions handle all the events that occur with the file uploader
var handlers = {
// Triggered when the file dialog is opened
onDialogOpen : function() {
// Load the swfupload settings
var settings = this.settings;
// Reset some queue info
this.queueData.errorMsg = 'Some files were not added to the queue:';
this.queueData.filesReplaced = 0;
this.queueData.filesCancelled = 0;
// Call the user-defined event handler
if (settings.onDialogOpen) settings.onDialogOpen.call(this);
},
// Triggered when the browse dialog is closed
onDialogClose : function(filesSelected, filesQueued, queueLength) {
// Load the swfupload settings
var settings = this.settings;
// Update the queue information
this.queueData.filesErrored = filesSelected - filesQueued;
this.queueData.filesSelected = filesSelected;
this.queueData.filesQueued = filesQueued - this.queueData.filesCancelled;
this.queueData.queueLength = queueLength;
// Run the default event handler
if ($.inArray('onDialogClose', settings.overrideEvents) < 0) {
if (this.queueData.filesErrored > 0) {
alert(this.queueData.errorMsg);
}
}
// Call the user-defined event handler
if (settings.onDialogClose) settings.onDialogClose.call(this, this.queueData);
// Upload the files if auto is true
if (settings.auto) $('#' + settings.id).uploadify('upload', '*');
},
// Triggered once for each file added to the queue
onSelect : function(file) {
// Load the swfupload settings
var settings = this.settings;
// Check if a file with the same name exists in the queue
var queuedFile = {};
for (var n in this.queueData.files) {
queuedFile = this.queueData.files[n];
if (queuedFile.uploaded != true && queuedFile.name == file.name) {
var replaceQueueItem = confirm('The file named "' + file.name + '" is already in the queue.\nDo you want to replace the existing item in the queue?');
if (!replaceQueueItem) {
this.cancelUpload(file.id);
this.queueData.filesCancelled++;
return false;
} else {
$('#' + queuedFile.id).remove();
this.cancelUpload(queuedFile.id);
this.queueData.filesReplaced++;
}
}
}
// Get the size of the file
var fileSize = Math.round(file.size / 1024);
var suffix = 'KB';
if (fileSize > 1000) {
fileSize = Math.round(fileSize / 1000);
suffix = 'MB';
}
var fileSizeParts = fileSize.toString().split('.');
fileSize = fileSizeParts[0];
if (fileSizeParts.length > 1) {
fileSize += '.' + fileSizeParts[1].substr(0,2);
}
fileSize += suffix;
// Truncate the filename if it's too long
var fileName = file.name;
if (fileName.length > 25) {
fileName = fileName.substr(0,25) + '...';
}
// Run the default event handler
if ($.inArray('onSelect', settings.overrideEvents) < 0) {
// Add the file item to the queue
$('#' + settings.queueID).append('<div id="' + file.id + '" class="uploadify-queue-item">\
<div class="cancel">\
<a href="javascript:$(\'#' + settings.id + '\').uploadify(\'cancel\', \'' + file.id + '\')">X</a>\
</div>\
<span class="fileName">' + fileName + ' (' + fileSize + ')</span><span class="data"></span>\
<div class="uploadify-progress">\
<div class="uploadify-progress-bar"><!--Progress Bar--></div>\
</div>\
</div>');
}
this.queueData.queueSize += file.size;
this.queueData.files[file.id] = file;
// Call the user-defined event handler
if (settings.onSelect) settings.onSelect.apply(this, arguments);
},
// Triggered when a file is not added to the queue
onSelectError : function(file, errorCode, errorMsg) {
// Load the swfupload settings
var settings = this.settings;
// Run the default event handler
if ($.inArray('onSelectError', settings.overrideEvents) < 0) {
switch(errorCode) {
case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
if (settings.queueSizeLimit > errorMsg) {
this.queueData.errorMsg += '\nThe number of files selected exceeds the remaining upload limit (' + errorMsg + ').';
} else {
this.queueData.errorMsg += '\nThe number of files selected exceeds the queue size limit (' + settings.queueSizeLimit + ').';
}
break;
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
this.queueData.errorMsg += '\nThe file "' + file.name + '" exceeds the size limit (' + settings.fileSizeLimit + ').';
break;
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
this.queueData.errorMsg += '\nThe file "' + file.name + '" is empty.';
break;
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
this.queueData.errorMsg += '\nThe file "' + file.name + '" is not an accepted file type (' + settings.fileTypeDesc + ').';
break;
}
}
if (errorCode != SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
delete this.queueData.files[file.id];
}
// Call the user-defined event handler
if (settings.onSelectError) settings.onSelectError.apply(this, arguments);
},
// Triggered when all the files in the queue have been processed
onQueueComplete : function() {
if (this.settings.onQueueComplete) this.settings.onQueueComplete.call(this, this.settings.queueData);
},
// Triggered when a file upload successfully completes
onUploadComplete : function(file) {
// Load the swfupload settings
var settings = this.settings,
swfuploadify = this;
// Check if all the files have completed uploading
var stats = this.getStats();
this.queueData.queueLength = stats.files_queued;
if (this.queueData.uploadQueue[0] == '*') {
if (this.queueData.queueLength > 0) {
this.startUpload();
} else {
this.queueData.uploadQueue = [];
// Call the user-defined event handler for queue complete
if (settings.onQueueComplete) settings.onQueueComplete.call(this, this.queueData);
}
} else {
if (this.queueData.uploadQueue.length > 0) {
this.startUpload(this.queueData.uploadQueue.shift());
} else {
this.queueData.uploadQueue = [];
// Call the user-defined event handler for queue complete
if (settings.onQueueComplete) settings.onQueueComplete.call(this, this.queueData);
}
}
// Call the default event handler
if ($.inArray('onUploadComplete', settings.overrideEvents) < 0) {
if (settings.removeCompleted) {
switch (file.filestatus) {
case SWFUpload.FILE_STATUS.COMPLETE:
setTimeout(function() {
if ($('#' + file.id)) {
swfuploadify.queueData.queueSize -= file.size;
swfuploadify.queueData.queueLength -= 1;
delete swfuploadify.queueData.files[file.id]
$('#' + file.id).fadeOut(500, function() {
$(this).remove();
});
}
}, settings.removeTimeout * 1000);
break;
case SWFUpload.FILE_STATUS.ERROR:
if (!settings.requeueErrors) {
setTimeout(function() {
if ($('#' + file.id)) {
swfuploadify.queueData.queueSize -= file.size;
swfuploadify.queueData.queueLength -= 1;
delete swfuploadify.queueData.files[file.id];
$('#' + file.id).fadeOut(500, function() {
$(this).remove();
});
}
}, settings.removeTimeout * 1000);
}
break;
}
} else {
file.uploaded = true;
}
}
// Call the user-defined event handler
if (settings.onUploadComplete) settings.onUploadComplete.call(this, file);
},
// Triggered when a file upload returns an error
onUploadError : function(file, errorCode, errorMsg) {
// Load the swfupload settings
var settings = this.settings;
// Set the error string
var errorString = 'Error';
switch(errorCode) {
case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
errorString = 'HTTP Error (' + errorMsg + ')';
break;
case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
errorString = 'Missing Upload URL';
break;
case SWFUpload.UPLOAD_ERROR.IO_ERROR:
errorString = 'IO Error';
break;
case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
errorString = 'Security Error';
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
alert('The upload limit has been reached (' + errorMsg + ').');
errorString = 'Exceeds Upload Limit';
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
errorString = 'Failed';
break;
case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
break;
case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
errorString = 'Validation Error';
break;
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
errorString = 'Cancelled';
this.queueData.queueSize -= file.size;
this.queueData.queueLength -= 1;
if (file.status == SWFUpload.FILE_STATUS.IN_PROGRESS || $.inArray(file.id, this.queueData.uploadQueue) >= 0) {
this.queueData.uploadSize -= file.size;
}
// Trigger the onCancel event
if (settings.onCancel) settings.onCancel.call(this, file);
delete this.queueData.files[file.id];
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
errorString = 'Stopped';
break;
}
// Call the default event handler
if ($.inArray('onUploadError', settings.overrideEvents) < 0) {
if (errorCode != SWFUpload.UPLOAD_ERROR.FILE_CANCELLED && errorCode != SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED) {
$('#' + file.id).addClass('uploadify-error');
}
// Reset the progress bar
$('#' + file.id).find('.uploadify-progress-bar').css('width','1px');
// Add the error message to the queue item
if (errorCode != SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND && file.status != SWFUpload.FILE_STATUS.COMPLETE) {
$('#' + file.id).find('.data').html(' - ' + errorString);
}
}
var stats = this.getStats();
this.queueData.uploadsErrored = stats.upload_errors;
// Call the user-defined event handler
if (settings.onUploadError) settings.onUploadError.call(this, file, errorCode, errorMsg, errorString);
},
// Triggered periodically during a file upload
onUploadProgress : function(file, fileBytesLoaded, fileTotalBytes) {
// Load the swfupload settings
var settings = this.settings;
// Setup all the variables
var timer = new Date();
var newTime = timer.getTime();
var lapsedTime = newTime - this.timer;
if (lapsedTime > 500) {
this.timer = newTime;
}
var lapsedBytes = fileBytesLoaded - this.bytesLoaded;
this.bytesLoaded = fileBytesLoaded;
var queueBytesLoaded = this.queueData.queueBytesUploaded + fileBytesLoaded;
var percentage = Math.round(fileBytesLoaded / fileTotalBytes * 100);
// Calculate the average speed
var suffix = 'KB/s';
var mbs = 0;
var kbs = (lapsedBytes / 1024) / (lapsedTime / 1000);
kbs = Math.floor(kbs * 10) / 10;
if (this.queueData.averageSpeed > 0) {
this.queueData.averageSpeed = Math.floor((this.queueData.averageSpeed + kbs) / 2);
} else {
this.queueData.averageSpeed = Math.floor(kbs);
}
if (kbs > 1000) {
mbs = (kbs * .001);
this.queueData.averageSpeed = Math.floor(mbs);
suffix = 'MB/s';
}
// Call the default event handler
if ($.inArray('onUploadProgress', settings.overrideEvents) < 0) {
if (settings.progressData == 'percentage') {
$('#' + file.id).find('.data').html(' - ' + percentage + '%');
} else if (settings.progressData == 'speed' && lapsedTime > 500) {
$('#' + file.id).find('.data').html(' - ' + this.queueData.averageSpeed + suffix);
}
$('#' + file.id).find('.uploadify-progress-bar').css('width', percentage + '%');
}
// Call the user-defined event handler
if (settings.onUploadProgress) settings.onUploadProgress.call(this, file, fileBytesLoaded, fileTotalBytes, queueBytesLoaded, this.queueData.uploadSize);
},
// Triggered right before a file is uploaded
onUploadStart : function(file) {
// Load the swfupload settings
var settings = this.settings;
var timer = new Date();
this.timer = timer.getTime();
this.bytesLoaded = 0;
if (this.queueData.uploadQueue.length == 0) {
this.queueData.uploadSize = file.size;
}
if (settings.checkExisting) {
$.ajax({
type : 'POST',
async : false,
url : settings.checkExisting,
data : {filename: file.name},
success : function(data) {
if (data == 1) {
var overwrite = confirm('A file with the name "' + file.name + '" already exists on the server.\nWould you like to replace the existing file?');
if (!overwrite) {
this.cancelUpload(file.id);
$('#' + file.id).remove();
if (this.queueData.uploadQueue.length > 0 && this.queueData.queueLength > 0) {
if (this.queueData.uploadQueue[0] == '*') {
this.startUpload();
} else {
this.startUpload(this.queueData.uploadQueue.shift());
}
}
}
}
}
});
}
// Call the user-defined event handler
if (settings.onUploadStart) settings.onUploadStart.call(this, file);
},
// Triggered when a file upload returns a successful code
onUploadSuccess : function(file, data, response) {
// Load the swfupload settings
var settings = this.settings;
var stats = this.getStats();
this.queueData.uploadsSuccessful = stats.successful_uploads;
this.queueData.queueBytesUploaded += file.size;
// Call the default event handler
if ($.inArray('onUploadSuccess', settings.overrideEvents) < 0) {
$('#' + file.id).find('.data').html(' - Complete');
}
// Call the user-defined event handler
if (settings.onUploadSuccess) settings.onUploadSuccess.call(this, file, data, response);
}
}
$.fn.uploadify = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('The method ' + method + ' does not exist in $.uploadify');
}
}
})($); | 10npsite | trunk/Public/jsLibrary/uploadify/jquery.uploadify-3.1.js | JavaScript | asf20 | 65,235 |
<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
// Define a destination
$targetFolder = '/uploads'; // Relative to the root and should match the upload folder in the uploader script
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $targetFolder . '/' . $_POST['filename'])) {
echo 1;
} else {
echo 0;
}
?> | 10npsite | trunk/Public/jsLibrary/uploadify/check-exists.php | PHP | asf20 | 426 |
<script language="javascript">
function show(title,msg)
{
var d_mask=document.getElementById('mask');
var d_dialog =document.getElementById('dialog');
d_mask.style.width = document.body.clientWidth ;
d_mask.style.height=document.body.clientHeight;
d_dialog.style.top = document.body.clientHeight / 2 -260;
d_dialog.style.left =document.body.clientWidth / 2 -100;
var Inner = "<input type='button' value='Close' onclick='DialogClose()'/>"
var info = "<table cellspacing='0' width='100%' height='100%'>"+
"<tr class='dgtitle'><td>"
+title
+"</td><td align='right'><input type='button' value='Close' onclick='DialogClose()'class='formButton'/></td></tr>"
+"<tr><td colspan='2'>"
+msg
+"</td></tr>"
+"<tr class='dgfooter'><td></td><td>"
+"</td></tr>"
+"</table>";
d_dialog.innerHTML =info;
disableSelect()
d_mask.style.visibility='visible';
d_dialog.style.visibility='visible';
}
function Icon_Close_Over(obj)
{
obj.src='close.gif';
}
function Icon_Close_Out(obj)
{
obj.src='close1.gif'
}
function DialogClose()
{
var d_mask=document.getElementById('mask');
var d_dialog = document.getElementById('dialog');
parent.getifheight();//当记录没有时或很少时还原其框架在原来的页面中的高度
enableSelect()
d_mask.style.visibility='hidden';
d_dialog.style.visibility='hidden';
}
function disableSelect()
{
for(i=0;i<document.all.length;i++)
if(document.all(i).tagName=="SELECT")
document.all(i).disabled = true;
}
function enableSelect()
{
for(i=0;i<document.all.length;i++){
if(document.all(i).tagName=="SELECT")
{
document.all(i).disabled = false;
}
}
}
function divBlock_event_mousedown()
{
var e, obj, temp;
obj=document.getElementById('dialog');
e=window.event?window.event:e;
obj.startX=e.clientX-obj.offsetLeft;
obj.startY=e.clientY-obj.offsetTop;
document.onmousemove=document_event_mousemove;
temp=document.attachEvent?document.attachEvent('onmouseup',document_event_mouseup):document.addEventListener('mouseup',document_event_mouseup,'');
}
function document_event_mousemove(e)
{
var e, obj;
obj=document.getElementById('dialog');
e=window.event?window.event:e;
with(obj.style){
position='absolute';
left=e.clientX-obj.startX+'px';
top=e.clientY-obj.startY+'px';
}
}
function document_event_mouseup(e)
{
var temp;
document.onmousemove='';
temp=document.detachEvent?parent.detachEvent('onmouseup',document_event_mouseup):document.removeEventListener('mouseup',document_event_mouseup,'');
}
window.onresize = function()
{
var d_mask=document.getElementById('mask');
var d_dialog = document.getElementById('dialog');
d_mask.style.width = document.body.clientWidth ;
d_mask.style.height=document.body.clientHeight;
}
?>
| 10npsite | trunk/Public/jsLibrary/jsAlert.asp | Classic ASP | asf20 | 3,262 |
// JavaScript Document
function confirmDel(str)
{
return confirm(str);
}
//date参照时间, n表示天数
//返回参照时间n天之后的日期
function showdate(datestr,n)
{
if(datestr=="")
{
var uom = new Date();
}
else
{
var r= datestr.replace("-","/");
var uom = new Date(""+r);
}
uom.setDate(uom.getDate()+n);
uom = uom.getFullYear() + "-" + (uom.getMonth()+1) + "-" + uom.getDate()+ " "+uom.getHours()+":"+uom.getMinutes()+":"+uom.getSeconds();
return uom;
}
function Match(str,pattern,flag){
var flagv;
if(flag=="")
{
flagv="i";//忽略大小写
}
re = new RegExp(pattern,flagv); // 创建正则表达式对象。
r = str.match(re); // 在字符串 s 中查找匹配。
return(r); // 返回匹配结果。
}
//图片等比例缩放
function DrawImage(ImgD,widthn,heightn,altstr){
//用法<img src="" onload=javascript:DrawImage(this,widthn,heightn,altstr);>
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= widthn/heightn){
if(image.width>widthn){
ImgD.width=widthn;
ImgD.height=(image.height*widthn)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt= altstr;
}
else{
if(image.height>heightn){
ImgD.height=heightn;
ImgD.width=(image.width*heightn)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=altstr;
}
}
}
//显示一个隐藏了的标签
function showele(str)
{
document.getElementById(str).style.display="";
}
//隐藏一个标签内容
function hiddenele(str)
{
document.getElementById(str).style.display="none";
}
//验证表单项的写法,不成功返回false,成功不返回操作
function nzeletype(elename,altstr,type)
{
var temp=document.getElementById(elename).value;
//验证整型数字
if(type=="int")
{
if(!temp.match(/^[\d]+$/)|| temp=="")
{
alert(altstr);
document.getElementById(elename).value="";
document.getElementById(elename).focus();
return false;
}
}
//验证浮点数字
if(type=="float")
{
if(!temp.match(/^[\d\.]+$/)|| temp=="")
{
alert(altstr);
document.getElementById(elename).value="";
document.getElementById(elename).focus();
return false;
}
}
//验证字符串不能为空
if(type=="string")
{
if(temp=="")
{
alert(altstr);
document.getElementById(elename).focus();
return false;
}
}
//验证电子邮件
if(type=="email")
{
if(!temp.match(/^[\w\-\.]+@[\w\-\.]+\.[\w]+$/))
{
alert(altstr);
document.getElementById(elename).value="";
document.getElementById(elename).focus();
return false;
}
}
if(type=="date"){
temt=document.getElementById(elename).value;
if(!temt.match(/^[\d]{2,4}\-[\d]{1,2}\-[\d]{1,2}/)){
alert(altstr);
document.getElementById(elename).value="";
document.getElementById(elename).focus();
return false;
}
}
return true;
}
//骊一个小数进行四舍五入,fractionDigits为保留的位数
function round2(number,fractionDigits){
with(Math){
return round(number*pow(10,fractionDigits))/pow(10,fractionDigits);
}
}
//常规的表单提交时的检查是否符合条件 当不符合正则的表达式时返回false 符合则返回true
/*
altstr 提示信息
eid 文档里的id
zhence 正则表达式
*/
function checkfromOption(altstr,eid,zhence)
{
temp=document.getElementById(eid).value;
if(!temp.match(zhence))
{
alert(altstr);
document.getElementById(eid).focus();
return false;
}
return true;
}
//弹出隐藏层
function chen_ShowDiv(show_div,bg_div){
document.getElementById(show_div).style.display='block';
document.getElementById(bg_div).style.display='block' ;
var bgdiv = document.getElementById(bg_div);
bgdiv.style.width = document.body.scrollWidth;
// bgdiv.style.height = $(document).height();
$("#"+bg_div).height($(document).height());
};
//关闭弹出层
function chen_CloseDiv(show_div,bg_div)
{
document.getElementById(show_div).style.display='none';
document.getElementById(bg_div).style.display='none';
};
//用正则获取第一个括号里的内容
function getkuohaostr(str,patter)
{
if(str=="") return "";
temp=str.match(patter)
if(temp!=null){
if(temp.length>0){
return temp[0].replace(patter,"$1");
}
}
return "";
}
function addCookie(objName,objValue,objHours){//添加cookie
var str = objName + "=" + escape(objValue);
if(objHours > 0){//为0时不设定过期时间,浏览器关闭时cookie自动消失
var date = new Date();
var ms = objHours*3600*1000;
date.setTime(date.getTime() + ms);
str += "; expires=" + date.toGMTString();
}
document.cookie = str;
}
function getCookie(objName){//获取指定名称的cookie的值
var arrStr = document.cookie.split("; ");
for(var i = 0;i < arrStr.length;i ++){
var temp = arrStr[i].split("=");
if(temp[0] == objName) return unescape(temp[1]);
}
}
//用cookie的方式判断会员是否登陆
function isuserlogin(altstr)
{
uchome_auth=getCookie("uchome_auth");
return (uchome_auth)?true:false;
}
| 10npsite | trunk/Public/jsLibrary/Jslibary.js | JavaScript | asf20 | 5,410 |
@charset "utf-8";
/*
* artDialog skin
* http://code.google.com/p/artdialog/
* (c) 2009-2011 TangBin, http://www.planeArt.cn
*
* This is licensed under the GNU LGPL, version 2.1 or later.
* For details, see: http://creativecommons.org/licenses/LGPL/2.1/
*/
/* common start */
body { _margin:0; _height:100%; /*IE6 BUG*/ }
.aui_outer { text-align:left; }
table.aui_border, table.aui_dialog { border:0; margin:0; border-collapse:collapse; width:auto; }
.aui_nw, .aui_n, .aui_ne, .aui_w, .aui_c, .aui_e, .aui_sw, .aui_s, .aui_se, .aui_header, .aui_tdIcon, .aui_main, .aui_footer { padding:0; }
.aui_header, .aui_buttons button { font: 12px/1.11 'Microsoft Yahei', Tahoma, Arial, Helvetica, STHeiti; _font-family:Tahoma,Arial,Helvetica,STHeiti; -o-font-family: Tahoma, Arial; }
.aui_title { overflow:hidden; text-overflow: ellipsis; }
.aui_state_noTitle .aui_title { display:none; }
.aui_close { display:block; position:absolute; text-decoration:none; outline:none; _cursor:pointer; }
.aui_close:hover { text-decoration:none; }
.aui_main { text-align:center; min-width:9em; min-width:0\9/*IE8 BUG*/; }
.aui_content { display:inline-block; *zoom:1; *display:inline; text-align:left; border:none 0; }
.aui_content.aui_state_full { display:block; width:100%; margin:0; padding:0!important; height:100%; }
.aui_loading { width:96px; height:32px; text-align:left; text-indent:-999em; overflow:hidden; background:url(icons/loading.gif) no-repeat center center; }
.aui_icon { vertical-align: middle; }
.aui_icon div { width:48px; height:48px; margin:10px 0 10px 10px; background-position: center center; background-repeat:no-repeat; }
.aui_buttons { padding:8px; text-align:right; white-space:nowrap; }
.aui_buttons button { margin-left:15px; padding: 6px 8px; cursor: pointer; display: inline-block; text-align: center; line-height: 1; *padding:4px 10px; *height:2em; letter-spacing:2px; font-family: Tahoma, Arial/9!important; width:auto; overflow:visible; *width:1; color: #333; border: solid 1px #999; border-radius: 5px; background: #DDD; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#DDDDDD'); background: linear-gradient(top, #FFF, #DDD); background: -moz-linear-gradient(top, #FFF, #DDD); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFF), to(#DDD)); text-shadow: 0px 1px 1px rgba(255, 255, 255, 1); box-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0 -1px 0 rgba(0, 0, 0, .09); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: box-shadow linear .2s; }
.aui_buttons button::-moz-focus-inner{ border:0; padding:0; margin:0; }
.aui_buttons button:focus { outline:none 0; border-color:#426DC9; box-shadow:0 0 8px rgba(66, 109, 201, .9); }
.aui_buttons button:hover { color:#000; border-color:#666; }
.aui_buttons button:active { border-color:#666; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#DDDDDD', endColorstr='#FFFFFF'); background: linear-gradient(top, #DDD, #FFF); background: -moz-linear-gradient(top, #DDD, #FFF); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#DDD), to(#FFF)); box-shadow:inset 0 1px 5px rgba(66, 109, 201, .9), inset 0 1px 1em rgba(0, 0, 0, .3); }
.aui_buttons button[disabled] { cursor:default; color:#666; background:#DDD; border: solid 1px #999; filter:alpha(opacity=50); opacity:.5; box-shadow:none; }
button.aui_state_highlight { color: #FFF; border: solid 1px #1c6a9e; background: #2288cc; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); text-shadow: -1px -1px 1px #1c6a9e; }
button.aui_state_highlight:hover { color:#FFF; border-color:#0F3A56; }
button.aui_state_highlight:active { border-color:#1c6a9e; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); }
/* common end */
.aui_inner { background:#FFF; }
.aui_titleBar { width:100%; }
.aui_title { position:absolute; left:0; top:0; width:100%; height:22px; text-align:left; text-indent:-999em; }
.aui_nw, .aui_ne, .aui_sw, .aui_se, .aui_n, .aui_s, .aui_close { background-image:url(idialog/idialog_s.png); background-repeat:no-repeat; }
.aui_nw { width:15px; height:15px; background-position: 0 0; _png:idialog/ie6/aui_nw.png; }
.aui_ne { width:15px; height:15px; background-position: -15px 0; _png:idialog/ie6/aui_ne.png; }
.aui_sw { width:15px; height:15px; background-position: 0 -15px; _png:idialog/ie6/aui_sw.png; }
.aui_se { width:15px; height:15px; background-position: -15px -15px; _png:idialog/ie6/aui_se.png; }
.aui_close { position:absolute; right:-8px; top:-8px; _z-index:1; width:34px; height:34px; _font-size:0; _line-height:0; text-indent:-9999em; background-position:0 -60px; _png:idialog/ie6/aui_close.png; }
.aui_close:hover { background-position:0 -94px; _png:idialog/ie6/aui_close.hover.png; }
.aui_n, .aui_s { background-repeat:repeat-x; }
.aui_n { background-position: 0 -30px; _png:idialog/ie6/aui_n.png; }
.aui_s { background-position: 0 -45px; _png:idialog/ie6/aui_s.png; }
.aui_w, .aui_e { background-image:url(idialog/idialog_s2.png); background-repeat:repeat-y; }
.aui_w { background-position:left top; _png:idialog/ie6/aui_w.png; }
.aui_e { background-position: right bottom; _png:idialog/ie6/aui_e.png; }
@media screen and (min-width:0) {/* css3 */
.aui_nw, .aui_ne, .aui_sw, .aui_se{ width:5px; height:5px; }
.aui_nw, .aui_n, .aui_ne, .aui_w, .aui_e, .aui_sw, .aui_s, .aui_se { background:none; }
.aui_sw, .aui_s, .aui_se { background:url(idialog/idialog_s.png) repeat-x 0 -45px; }
.aui_sw { border-radius:0 0 0 5px; }
.aui_se { border-radius:0 0 5px 0; }
.aui_outer { border:1px solid #929292; border-radius:5px; box-shadow:0 3px 8px rgba(0, 0, 0, .2); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: -webkit-box-shadow linear .2s; }
.aui_border { border-radius:5px; background:#FFF; }
.aui_state_drag .aui_outer { box-shadow:none; }
.aui_state_lock .aui_outer { box-shadow:0 3px 26px rgba(0, 0, 0, .9); }
.aui_outer:active { box-shadow:0 0 5px rgba(0, 0, 0, .1)!important; }
.aui_state_drag .aui_outer { box-shadow:none!important; }
.aui_close { right:-16px; top:-16px; }
}
@media screen and (-webkit-min-device-pixel-ratio:0) {/* apple | webkit */
.aui_close { right:auto; left:-16px; top:-16px; }
}
| 10npsite | trunk/Public/jsLibrary/jquery/skins/idialog.css | CSS | asf20 | 6,794 |
@charset "utf-8";
/*
* artDialog skin
* http://code.google.com/p/artdialog/
* (c) 2009-2011 TangBin, http://www.planeArt.cn
*
* This is licensed under the GNU LGPL, version 2.1 or later.
* For details, see: http://creativecommons.org/licenses/LGPL/2.1/
*/
/* common start */
body { _margin:0; _height:100%; /*IE6 BUG*/ }
.aui_outer { text-align:left; }
table.aui_border, table.aui_dialog { border:0; margin:0; border-collapse:collapse; width:auto; }
.aui_nw, .aui_n, .aui_ne, .aui_w, .aui_c, .aui_e, .aui_sw, .aui_s, .aui_se, .aui_header, .aui_tdIcon, .aui_main, .aui_footer { padding:0; }
.aui_header, .aui_buttons button { font: 12px/1.11 'Microsoft Yahei', Tahoma, Arial, Helvetica, STHeiti; _font-family:Tahoma,Arial,Helvetica,STHeiti; -o-font-family: Tahoma, Arial; }
.aui_title { overflow:hidden; text-overflow: ellipsis; }
.aui_state_noTitle .aui_title { display:none; }
.aui_close { display:block; position:absolute; text-decoration:none; outline:none; _cursor:pointer; }
.aui_close:hover { text-decoration:none; }
.aui_main { text-align:center; min-width:9em; min-width:0\9/*IE8 BUG*/; }
.aui_content { display:inline-block; *zoom:1; *display:inline; text-align:left; border:none 0; }
.aui_content.aui_state_full { display:block; width:100%; margin:0; padding:0!important; height:100%; }
.aui_loading { width:96px; height:32px; text-align:left; text-indent:-999em; overflow:hidden; background:url(icons/loading.gif) no-repeat center center; }
.aui_icon { vertical-align: middle; }
.aui_icon div { width:48px; height:48px; margin:10px 0 10px 10px; background-position: center center; background-repeat:no-repeat; }
.aui_buttons { padding:8px; text-align:right; white-space:nowrap; }
.aui_buttons button { margin-left:15px; padding: 6px 8px; cursor: pointer; display: inline-block; text-align: center; line-height: 1; *padding:4px 10px; *height:2em; letter-spacing:2px; font-family: Tahoma, Arial/9!important; width:auto; overflow:visible; *width:1; color: #333; border: solid 1px #999; border-radius: 5px; background: #DDD; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#DDDDDD'); background: linear-gradient(top, #FFF, #DDD); background: -moz-linear-gradient(top, #FFF, #DDD); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFF), to(#DDD)); text-shadow: 0px 1px 1px rgba(255, 255, 255, 1); box-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0 -1px 0 rgba(0, 0, 0, .09); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: box-shadow linear .2s; }
.aui_buttons button::-moz-focus-inner{ border:0; padding:0; margin:0; }
.aui_buttons button:focus { outline:none 0; border-color:#426DC9; box-shadow:0 0 8px rgba(66, 109, 201, .9); }
.aui_buttons button:hover { color:#000; border-color:#666; }
.aui_buttons button:active { border-color:#666; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#DDDDDD', endColorstr='#FFFFFF'); background: linear-gradient(top, #DDD, #FFF); background: -moz-linear-gradient(top, #DDD, #FFF); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#DDD), to(#FFF)); box-shadow:inset 0 1px 5px rgba(66, 109, 201, .9), inset 0 1px 1em rgba(0, 0, 0, .3); }
.aui_buttons button[disabled] { cursor:default; color:#666; background:#DDD; border: solid 1px #999; filter:alpha(opacity=50); opacity:.5; box-shadow:none; }
button.aui_state_highlight { color: #FFF; border: solid 1px #1c6a9e; background: #2288cc; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); text-shadow: -1px -1px 1px #1c6a9e; }
button.aui_state_highlight:hover { color:#FFF; border-color:#0F3A56; }
button.aui_state_highlight:active { border-color:#1c6a9e; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); }
/* common end */
.aui_inner { background:rgba(0, 0, 0, .7); }
.aui_dialog { background:#FFF; border-radius:3px; }
.aui_outer { border:1px solid #000; border-radius:5px; box-shadow: 0 3px 0 rgba(0,0,0,0.1); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: -webkit-box-shadow linear .2s; }
.aui_state_lock .aui_outer { box-shadow:0 3px 26px rgba(0, 0, 0, .9); }
.aui_outer:active { box-shadow:none!important; }
.aui_state_drag .aui_outer { box-shadow:none!important; }
.aui_border { border-radius:3px; }
.aui_nw, .aui_ne { width:5px; height:37px; }
.aui_sw, .aui_se { width:5px; height:5px; }
.aui_nw, .aui_n, .aui_ne, .aui_w, .aui_e, .aui_sw, .aui_s, .aui_se { background:rgba(0, 0, 0, .7); background:#000\9!important; filter:alpha(opacity=70); }
.aui_titleBar { width:100%; height:0; position:relative; bottom:33px; _bottom:0; _margin-top:-33px; }
.aui_title { height:27px; line-height:27px; padding:0 16px 0 5px; color:#FFF; font-weight:700; text-shadow:0 1px 0 #000; }
.aui_close { padding:0; top:2px; right:5px; width:21px; height:21px; line-height:21px; font-size:18px; text-align:center; color:#EBEBEB; font-family: Helvetica, STHeiti; _font-family: '\u9ed1\u4f53', 'Book Antiqua', Palatino; border:1px solid transparent; _border:0 none; background:#000; border-radius:15px; }
.aui_state_drag .aui_close { color:#FFF; }
.aui_close:hover { background:#C72015; border:1px solid #000; _border:0 none; box-shadow: 0 1px 0 rgba(255, 255, 255, .3), inset 0 1px 0 rgba(255, 255, 255, .3); }
.aui_close:active { box-shadow: none; }
.aui_state_noTitle { }
.aui_content { color:#666; }
.aui_state_noTitle .aui_nw, .aui_state_noTitle .aui_ne { height:5px; }
.aui_state_noTitle .aui_titleBar { bottom:0; _bottom:0; _margin-top:0; }
.aui_state_noTitle .aui_close { top:5px; }
| 10npsite | trunk/Public/jsLibrary/jquery/skins/twitter.css | CSS | asf20 | 6,110 |
@charset "utf-8";
/*
* artDialog skin
* http://code.google.com/p/artdialog/
* (c) 2009-2011 TangBin, http://www.planeArt.cn
*
* This is licensed under the GNU LGPL, version 2.1 or later.
* For details, see: http://creativecommons.org/licenses/LGPL/2.1/
*/
/* common start */
body { _margin:0; _height:100%; /*IE6 BUG*/ }
.aui_outer { text-align:left; }
table.aui_border, table.aui_dialog { border:0; margin:0; border-collapse:collapse; width:auto; }
.aui_nw, .aui_n, .aui_ne, .aui_w, .aui_c, .aui_e, .aui_sw, .aui_s, .aui_se, .aui_header, .aui_tdIcon, .aui_main, .aui_footer { padding:0; }
.aui_header, .aui_buttons button { font: 12px/1.11 'Microsoft Yahei', Tahoma, Arial, Helvetica, STHeiti; _font-family:Tahoma,Arial,Helvetica,STHeiti; -o-font-family: Tahoma, Arial; }
.aui_title { overflow:hidden; text-overflow: ellipsis; }
.aui_state_noTitle .aui_title { display:none; }
.aui_close { display:block; position:absolute; text-decoration:none; outline:none; _cursor:pointer; }
.aui_close:hover { text-decoration:none; }
.aui_main { text-align:center; min-width:9em; min-width:0\9/*IE8 BUG*/; }
.aui_content { display:inline-block; *zoom:1; *display:inline; text-align:left; border:none 0; }
.aui_content.aui_state_full { display:block; width:100%; margin:0; padding:0!important; height:100%; }
.aui_loading { width:96px; height:32px; text-align:left; text-indent:-999em; overflow:hidden; background:url(icons/loading.gif) no-repeat center center; }
.aui_icon { vertical-align: middle; }
.aui_icon div { width:48px; height:48px; margin:10px 0 10px 10px; background-position: center center; background-repeat:no-repeat; }
.aui_buttons { padding:8px; text-align:right; white-space:nowrap; }
.aui_buttons button { margin-left:15px; padding: 6px 8px; cursor: pointer; display: inline-block; text-align: center; line-height: 1; *padding:4px 10px; *height:2em; letter-spacing:2px; font-family: Tahoma, Arial/9!important; width:auto; overflow:visible; *width:1; color: #333; border: solid 1px #999; border-radius: 5px; background: #DDD; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#DDDDDD'); background: linear-gradient(top, #FFF, #DDD); background: -moz-linear-gradient(top, #FFF, #DDD); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFF), to(#DDD)); text-shadow: 0px 1px 1px rgba(255, 255, 255, 1); box-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0 -1px 0 rgba(0, 0, 0, .09); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: box-shadow linear .2s; }
.aui_buttons button::-moz-focus-inner{ border:0; padding:0; margin:0; }
.aui_buttons button:focus { outline:none 0; border-color:#426DC9; box-shadow:0 0 8px rgba(66, 109, 201, .9); }
.aui_buttons button:hover { color:#000; border-color:#666; }
.aui_buttons button:active { border-color:#666; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#DDDDDD', endColorstr='#FFFFFF'); background: linear-gradient(top, #DDD, #FFF); background: -moz-linear-gradient(top, #DDD, #FFF); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#DDD), to(#FFF)); box-shadow:inset 0 1px 5px rgba(66, 109, 201, .9), inset 0 1px 1em rgba(0, 0, 0, .3); }
.aui_buttons button[disabled] { cursor:default; color:#666; background:#DDD; border: solid 1px #999; filter:alpha(opacity=50); opacity:.5; box-shadow:none; }
button.aui_state_highlight { color: #FFF; border: solid 1px #1c6a9e; background: #2288cc; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); text-shadow: -1px -1px 1px #1c6a9e; }
button.aui_state_highlight:hover { color:#FFF; border-color:#0F3A56; }
button.aui_state_highlight:active { border-color:#1c6a9e; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); }
/* common end */
.aui_inner { background:#f0f1f9; }
.aui_titleBar { width:100%; height:0; position:relative; bottom:27px; _bottom:0; _margin-top:-27px; }
.aui_title { height:27px; line-height:27px; padding:0 37px 0 0; _padding:0; color:#333; text-shadow:1px 1px 0 rgba(255, 255, 255, .7); }
.aui_nw, .aui_ne, .aui_sw, .aui_se, .aui_n, .aui_s, .aui_close { background-image:url(opera/s1.png); background-repeat:no-repeat; }
.aui_nw { width:15px; height:32px; background-position: 0 0; _png:opera/ie6/aui_nw.png; }
.aui_ne { width:15px; height:32px; background-position: -15px 0; _png:opera/ie6/aui_ne.png; }
.aui_sw { width:15px; height:15px; background-position: 0 -33px; _png:opera/ie6/aui_sw.png; }
.aui_se { width:15px; height:15px; background-position: -15px -33px; _png:opera/ie6/aui_se.png; }
.aui_close { top:0; right:0; _z-index:1; width:27px; height:27px; _font-size:0; _line-height:0; *zoom:1; text-indent:-9999em; background-position:0 -96px; _png:opera/ie6/aui_close.png; }
.aui_close:hover { background-position:0 -123px; _png:opera/ie6/aui_close.hover.png; }
.aui_n, .aui_s { background-repeat:repeat-x; }
.aui_n { background-position: 0 -48px; _png:opera/ie6/aui_n.png; }
.aui_s { background-position: 0 -81px; _png:opera/ie6/aui_s.png; }
.aui_w, .aui_e { background-image:url(opera/s2.png); background-repeat:repeat-y; }
.aui_w { background-position:left top; _png:opera/ie6/aui_w.png; }
.aui_e { background-position: right bottom; _png:opera/ie6/aui_e.png; }
.aui_icon, .aui_main { padding-top:10px; }
.aui_state_noTitle .aui_nw, .aui_state_noTitle .aui_ne, .aui_state_noTitle .aui_sw, .aui_state_noTitle .aui_se { width:3px; height:3px; }
.aui_state_noTitle .aui_inner { border:1px solid #666; background:#FFF; }
.aui_state_noTitle .aui_outer { box-shadow:none; }
.aui_state_noTitle .aui_nw, .aui_state_noTitle .aui_n, .aui_state_noTitle .aui_ne, .aui_state_noTitle .aui_w, .aui_state_noTitle .aui_e, .aui_state_noTitle .aui_sw, .aui_state_noTitle .aui_s, .aui_state_noTitle .aui_se { background:rgba(0, 0, 0, .05); background:#000\9!important; filter:alpha(opacity=5)!important; }
.aui_state_noTitle .aui_titleBar { bottom:0; _bottom:0; _margin-top:0; }
.aui_state_noTitle .aui_close { top:0; right:0; width:18px; height:18px; line-height:18px; text-align:center; text-indent:0; font-family: Helvetica, STHeiti; _font-family: '\u9ed1\u4f53', 'Book Antiqua', Palatino; font-size:18px; text-decoration:none; color:#214FA3; background:none; filter:!important; }
.aui_state_noTitle .aui_close:hover, .aui_state_noTitle .aui_close:active { text-decoration:none; color:#900; } | 10npsite | trunk/Public/jsLibrary/jquery/skins/opera.css | CSS | asf20 | 6,873 |
@charset "utf-8";
/*
* artDialog skin
* http://code.google.com/p/artdialog/
* (c) 2009-2011 TangBin, http://www.planeArt.cn
*
* This is licensed under the GNU LGPL, version 2.1 or later.
* For details, see: http://creativecommons.org/licenses/LGPL/2.1/
*/
/* common start */
body { _margin:0; _height:100%; /*IE6 BUG*/ }
.aui_outer { text-align:left; }
table.aui_border, table.aui_dialog { border:0; margin:0; border-collapse:collapse; width:auto; }
.aui_nw, .aui_n, .aui_ne, .aui_w, .aui_c, .aui_e, .aui_sw, .aui_s, .aui_se, .aui_header, .aui_tdIcon, .aui_main, .aui_footer { padding:0; }
.aui_header, .aui_buttons button { font: 12px/1.11 'Microsoft Yahei', Tahoma, Arial, Helvetica, STHeiti; _font-family:Tahoma,Arial,Helvetica,STHeiti; -o-font-family: Tahoma, Arial; }
.aui_title { overflow:hidden; text-overflow: ellipsis; }
.aui_state_noTitle .aui_title { display:none; }
.aui_close { display:block; position:absolute; text-decoration:none; outline:none; _cursor:pointer; }
.aui_close:hover { text-decoration:none; }
.aui_main { text-align:center; min-width:9em; min-width:0 \9/*IE8 BUG*/; }
.aui_content { display:inline-block; *zoom:1; *display:inline; text-align:left; border:none 0; }
.aui_content.aui_state_full { display:block; width:100%; margin:0; padding:0!important; height:100%; }
.aui_loading { width:96px; height:32px; text-align:left; text-indent:-999em; overflow:hidden; background:url(icons/loading.gif) no-repeat center center; }
.aui_icon { vertical-align: middle; }
.aui_icon div { width:48px; height:48px; margin:10px 0 10px 10px; background-position: center center; background-repeat:no-repeat; }
.aui_buttons { padding:8px; text-align:right; white-space:nowrap; }
.aui_buttons button { margin-left:15px; padding: 6px 8px; cursor: pointer; display: inline-block; text-align: center; line-height: 1; *padding:4px 10px; *height:2em; letter-spacing:2px; font-family: Tahoma, Arial/9!important; width:auto; overflow:visible; *width:1; color: #333; border: solid 1px #999; border-radius: 5px; background: #DDD; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#DDDDDD'); background: linear-gradient(top, #FFF, #DDD); background: -moz-linear-gradient(top, #FFF, #DDD); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFF), to(#DDD)); text-shadow: 0px 1px 1px rgba(255, 255, 255, 1); box-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0 -1px 0 rgba(0, 0, 0, .09); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: box-shadow linear .2s; }
.aui_buttons button::-moz-focus-inner{ border:0; padding:0; margin:0; }
.aui_buttons button:focus { outline:none 0; border-color:#426DC9; box-shadow:0 0 8px rgba(66, 109, 201, .9); }
.aui_buttons button:hover { color:#000; border-color:#666; }
.aui_buttons button:active { border-color:#666; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#DDDDDD', endColorstr='#FFFFFF'); background: linear-gradient(top, #DDD, #FFF); background: -moz-linear-gradient(top, #DDD, #FFF); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#DDD), to(#FFF)); box-shadow:inset 0 1px 5px rgba(66, 109, 201, .9), inset 0 1px 1em rgba(0, 0, 0, .3); }
.aui_buttons button[disabled] { cursor:default; color:#666; background:#DDD; border: solid 1px #999; filter:alpha(opacity=50); opacity:.5; box-shadow:none; }
button.aui_state_highlight { color: #FFF; border: solid 1px #3399dd; background: #2288cc; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); text-shadow: -1px -1px 1px #1c6a9e; }
button.aui_state_highlight:hover { color:#FFF; border-color:#1c6a9e; }
button.aui_state_highlight:active { border-color:#1c6a9e; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); }
/* common end */
.aui_inner { background:#f7f7f7; }
.aui_titleBar { width:100%; height:0; position:relative; bottom:30px; _bottom:0; _margin-top:-30px; }
.aui_title { height:29px; line-height:29px; padding:0 25px 0 0; _padding:0; text-indent:5px; color:#FFF; font-weight:700; text-shadow:-1px -1px 0 rgba(0, 0, 0, .7); }
.aui_nw, .aui_ne, .aui_sw, .aui_se, .aui_n, .aui_s, .aui_close { background-image:url(black/bg.png); background-repeat:no-repeat; }
.aui_nw { width:15px; height:38px; background-position: 0 0; _png:black/ie6/nw.png; }
.aui_ne { width:15px; height:38px; background-position: -15px 0; _png:black/ie6/ne.png; }
.aui_sw { width:15px; height:18px; background-position: 0 -38px; _png:black/ie6/sw.png; }
.aui_se { width:15px; height:18px; background-position: -15px -38px; _png:black/ie6/se.png; }
.aui_close { top:4px; right:4px; _z-index:1; width:20px; height:20px; _font-size:0; _line-height:0; text-indent:-9999em; background-position:0 -112px; _png:black/ie6/close.png; }
.aui_close:hover { background-position:0 -132px; }
.aui_n, .aui_s { background-repeat:repeat-x; }
.aui_n { background-position: 0 -56px; _png:black/ie6/n.png; }
.aui_s { background-position: 0 -94px; _png:black/ie6/s.png; }
.aui_w, .aui_e { background-image:url(black/bg2.png); background-repeat:repeat-y; }
.aui_w { background-position:left top; _png:black/ie6/w.png; }
.aui_e { background-position: right bottom; _png:black/ie6/e.png; }
aui_icon, .aui_main { padding-top:3px; }
@media screen and (min-width:0) {
.aui_outer { border-radius:8px; box-shadow:0 5px 15px rgba(0, 0, 0, .4); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: -webkit-box-shadow linear .2s; }
.aui_state_drag .aui_outer { box-shadow:none; }
.aui_state_lock .aui_outer { box-shadow:0 3px 26px rgba(0, 0, 0, .9); }
.aui_outer:active { box-shadow:0 0 5px rgba(0, 0, 0, .1)!important; }
.aui_state_drag .aui_outer { box-shadow:none!important; }
.aui_nw, .aui_ne, .aui_sw, .aui_se, .aui_n, .aui_s, .aui_close { background-image:url(black/bg_css3.png); }
.aui_nw { width:5px; height:31px; }
.aui_ne { width:5px; height:31px; background-position: -5px 0; _png:black/ie6/ne.png; }
.aui_sw { width:5px; height:5px;background-position: 0 -31px; }
.aui_se { width:5px; height:5px; background-position: -5px -31px; }
.aui_close { background-position:0 -72px; }
.aui_close:hover { background-position:0 -92px; }
.aui_n { background-position: 0 -36px; }
.aui_s { background-position: 0 -67px; }
.aui_w, .aui_e { background-image:url(black/bg_css3_2.png); }
}
.aui_state_noTitle .aui_nw, .aui_state_noTitle .aui_ne, .aui_state_noTitle .aui_sw, .aui_state_noTitle .aui_se { width:3px; height:3px; }
.aui_state_noTitle .aui_inner { border:1px solid #666; background:#FFF; }
.aui_state_noTitle .aui_outer { box-shadow:none; }
.aui_state_noTitle .aui_nw, .aui_state_noTitle .aui_n, .aui_state_noTitle .aui_ne, .aui_state_noTitle .aui_w, .aui_state_noTitle .aui_e, .aui_state_noTitle .aui_sw, .aui_state_noTitle .aui_s, .aui_state_noTitle .aui_se { background:rgba(0, 0, 0, .05); background:#000\9!important; filter:alpha(opacity=5)!important; }
.aui_state_noTitle .aui_titleBar { bottom:0; _bottom:0; _margin-top:0; }
.aui_state_noTitle .aui_close { top:0; right:0; width:18px; height:18px; line-height:18px; text-align:center; text-indent:0; font-family: Helvetica, STHeiti; _font-family: '\u9ed1\u4f53', 'Book Antiqua', Palatino; font-size:18px; text-decoration:none; color:#214FA3; background:none; filter:!important; }
.aui_state_noTitle .aui_close:hover, .aui_state_noTitle .aui_close:active { text-decoration:none; color:#900; } | 10npsite | trunk/Public/jsLibrary/jquery/skins/black.css | CSS | asf20 | 7,958 |
@charset "utf-8";
/*
* artDialog skin
* http://code.google.com/p/artdialog/
* (c) 2009-2011 TangBin, http://www.planeArt.cn
*
* This is licensed under the GNU LGPL, version 2.1 or later.
* For details, see: http://creativecommons.org/licenses/LGPL/2.1/
*/
/* common start */
body { _margin:0; _height:100%; /*IE6 BUG*/ }
.aui_outer { text-align:left; }
table.aui_border, table.aui_dialog { border:0; margin:0; border-collapse:collapse; width:auto; }
.aui_nw, .aui_n, .aui_ne, .aui_w, .aui_c, .aui_e, .aui_sw, .aui_s, .aui_se, .aui_header, .aui_tdIcon, .aui_main, .aui_footer { padding:0; }
.aui_header, .aui_buttons button { font: 12px/1.11 'Microsoft Yahei', Tahoma, Arial, Helvetica, STHeiti; _font-family:Tahoma,Arial,Helvetica,STHeiti; -o-font-family: Tahoma, Arial; }
.aui_title { overflow:hidden; text-overflow: ellipsis; }
.aui_state_noTitle .aui_title { display:none; }
.aui_close { display:block; position:absolute; text-decoration:none; outline:none; _cursor:pointer; }
.aui_close:hover { text-decoration:none; }
.aui_main { text-align:center; min-width:9em; min-width:0\9/*IE8 BUG*/; }
.aui_content { display:inline-block; *zoom:1; *display:inline; text-align:left; border:none 0; }
.aui_content.aui_state_full { display:block; width:100%; margin:0; padding:0!important; height:100%; }
.aui_loading { width:96px; height:32px; text-align:left; text-indent:-999em; overflow:hidden; background:url(icons/loading.gif) no-repeat center center; }
.aui_icon { vertical-align: middle; }
.aui_icon div { width:48px; height:48px; margin:10px 0 10px 10px; background-position: center center; background-repeat:no-repeat; }
.aui_buttons { padding:8px; text-align:right; white-space:nowrap; }
.aui_buttons button { margin-left:15px; padding: 6px 8px; cursor: pointer; display: inline-block; text-align: center; line-height: 1; *padding:4px 10px; *height:2em; letter-spacing:2px; font-family: Tahoma, Arial/9!important; width:auto; overflow:visible; *width:1; color: #333; border: solid 1px #999; border-radius: 5px; background: #DDD; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#DDDDDD'); background: linear-gradient(top, #FFF, #DDD); background: -moz-linear-gradient(top, #FFF, #DDD); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFF), to(#DDD)); text-shadow: 0px 1px 1px rgba(255, 255, 255, 1); box-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0 -1px 0 rgba(0, 0, 0, .09); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: box-shadow linear .2s; }
.aui_buttons button::-moz-focus-inner{ border:0; padding:0; margin:0; }
.aui_buttons button:focus { outline:none 0; border-color:#426DC9; box-shadow:0 0 8px rgba(66, 109, 201, .9); }
.aui_buttons button:hover { color:#000; border-color:#666; }
.aui_buttons button:active { border-color:#666; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#DDDDDD', endColorstr='#FFFFFF'); background: linear-gradient(top, #DDD, #FFF); background: -moz-linear-gradient(top, #DDD, #FFF); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#DDD), to(#FFF)); box-shadow:inset 0 1px 5px rgba(66, 109, 201, .9), inset 0 1px 1em rgba(0, 0, 0, .3); }
.aui_buttons button[disabled] { cursor:default; color:#666; background:#DDD; border: solid 1px #999; filter:alpha(opacity=50); opacity:.5; box-shadow:none; }
button.aui_state_highlight { color: #FFF; border: solid 1px #1c6a9e; background: #2288cc; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); text-shadow: -1px -1px 1px #1c6a9e; }
button.aui_state_highlight:hover { color:#FFF; border-color:#0F3A56; }
button.aui_state_highlight:active { border-color:#1c6a9e; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); }
/* common end */
.aui_inner { background:#FFF; }
.aui_titleBar { width:100%; height:0; position:relative; bottom:26px; _bottom:0; _margin-top:-26px;}
.aui_title { height:26px; line-height:23px; padding:0 60px 0 5px; color:#FFF; font-weight:700; text-shadow:0 1px 0 #000; }
.aui_nw, .aui_ne, .aui_w, .aui_e, .aui_sw, .aui_se, .aui_close { background-image:url(chrome/chrome_s.png); background-repeat:no-repeat; }
.aui_nw { width:5px; height:26px; background-position: -46px -8px; }
.aui_ne { width:5px; height:26px; background-position: -53px -8px; }
.aui_w { background-position:-60px 0; background-repeat:repeat-y; }
.aui_e { background-position:-65px 0; background-repeat:repeat-y; }
.aui_sw { width:5px; height:5px; background-position: -46px -2px;}
.aui_se { width:5px; height:5px; background-position: -53px -2px;}
.aui_close { top:1px; right:0; width:44px; height:17px; background-position:0 0; _font-size:0; _line-height:0; text-indent:-9999em; }
.aui_close:hover { background-position:0 -18px; }
.aui_n, .aui_s { background-image:url(chrome/border.png); background-repeat:repeat-x; }
.aui_n { background-position:0 top; }
.aui_s { background-position: 0 bottom; }
.aui_buttons { background-color:#F6F6F6; border-top:solid 1px #DADEE5; }
.aui_state_noTitle .aui_nw, .aui_state_noTitle .aui_ne, .aui_state_noTitle .aui_sw, .aui_state_noTitle .aui_se { width:3px; height:3px; }
.aui_state_noTitle .aui_inner { border:1px solid #666; background:#FFF; }
.aui_state_noTitle .aui_outer { box-shadow:none; }
.aui_state_noTitle .aui_nw, .aui_state_noTitle .aui_n, .aui_state_noTitle .aui_ne, .aui_state_noTitle .aui_w, .aui_state_noTitle .aui_e, .aui_state_noTitle .aui_sw, .aui_state_noTitle .aui_s, .aui_state_noTitle .aui_se { background:rgba(0, 0, 0, .05); background:#000\9!important; filter:alpha(opacity=5)!important; }
.aui_state_noTitle .aui_titleBar { bottom:0; _bottom:0; _margin-top:0; }
.aui_state_noTitle .aui_close { top:0; right:0; width:18px; height:18px; line-height:18px; text-align:center; text-indent:0; font-family: Helvetica, STHeiti; _font-family: '\u9ed1\u4f53', 'Book Antiqua', Palatino; font-size:18px; text-decoration:none; color:#214FA3; background:none; filter:!important; }
.aui_state_noTitle .aui_close:hover, .aui_state_noTitle .aui_close:active { text-decoration:none; color:#900; }
| 10npsite | trunk/Public/jsLibrary/jquery/skins/chrome.css | CSS | asf20 | 6,600 |
@charset "utf-8";
/*
* artDialog skin
* http://code.google.com/p/artdialog/
* (c) 2009-2011 TangBin, http://www.planeArt.cn
*
* This is licensed under the GNU LGPL, version 2.1 or later.
* For details, see: http://creativecommons.org/licenses/LGPL/2.1/
*/
/* common start */
body { _margin:0; _height:100%; /*IE6 BUG*/ }
.aui_outer { text-align:left; }
table.aui_border, table.aui_dialog { border:0; margin:0; border-collapse:collapse; width:auto; }
.aui_nw, .aui_n, .aui_ne, .aui_w, .aui_c, .aui_e, .aui_sw, .aui_s, .aui_se, .aui_header, .aui_tdIcon, .aui_main, .aui_footer { padding:0; }
.aui_header, .aui_buttons button { font: 12px/1.11 'Microsoft Yahei', Tahoma, Arial, Helvetica, STHeiti; _font-family:Tahoma,Arial,Helvetica,STHeiti; -o-font-family: Tahoma, Arial; }
.aui_title { overflow:hidden; text-overflow: ellipsis; }
.aui_state_noTitle .aui_title { display:none; }
.aui_close { display:block; position:absolute; text-decoration:none; outline:none; _cursor:pointer; }
.aui_close:hover { text-decoration:none; }
.aui_main { text-align:center; min-width:9em; min-width:0 \9/*IE8 BUG*/; }
.aui_content { display:inline-block; *zoom:1; *display:inline; text-align:left; border:none 0; }
.aui_content.aui_state_full { display:block; width:100%; margin:0; padding:0!important; height:100%; }
.aui_loading { width:96px; height:32px; text-align:left; text-indent:-999em; overflow:hidden; background:url(icons/loading.gif) no-repeat center center; }
.aui_icon { vertical-align: middle; }
.aui_icon div { width:48px; height:48px; margin:10px 0 10px 10px; background-position: center center; background-repeat:no-repeat; }
.aui_buttons { padding:8px; text-align:right; white-space:nowrap; }
.aui_buttons button { margin-left:15px; padding: 6px 8px; cursor: pointer; display: inline-block; text-align: center; line-height: 1; *padding:4px 10px; *height:2em; letter-spacing:2px; font-family: Tahoma, Arial/9!important; width:auto; overflow:visible; *width:1; color: #333; border: solid 1px #999; border-radius: 5px; background: #DDD; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#DDDDDD'); background: linear-gradient(top, #FFF, #DDD); background: -moz-linear-gradient(top, #FFF, #DDD); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFF), to(#DDD)); text-shadow: 0px 1px 1px rgba(255, 255, 255, 1); box-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0 -1px 0 rgba(0, 0, 0, .09); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: box-shadow linear .2s; }
.aui_buttons button::-moz-focus-inner{ border:0; padding:0; margin:0; }
.aui_buttons button:focus { outline:none 0; border-color:#426DC9; box-shadow:0 0 8px rgba(0, 50, 0, .7); }
.aui_buttons button:hover { color:#000; border-color:#666; }
.aui_buttons button:active { border-color:#666; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#DDDDDD', endColorstr='#FFFFFF'); background: linear-gradient(top, #DDD, #FFF); background: -moz-linear-gradient(top, #DDD, #FFF); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#DDD), to(#FFF)); box-shadow:inset 0 1px 5px rgba(0, 50, 0, .7), inset 0 1px 1em rgba(0, 0, 0, .3); }
.aui_buttons button[disabled] { cursor:default; color:#666; background:#DDD; border: solid 1px #999; filter:alpha(opacity=50); opacity:.5; box-shadow:none; }
button.aui_state_highlight { color: #FFF; border: solid 1px #679a10; background: #7cb61b; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#98d237', endColorstr='#7cb61b'); background: linear-gradient(top, #98d237, #7cb61b); background: -moz-linear-gradient(top, #98d237, #7cb61b); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#98d237), to(#7cb61b)); text-shadow: -1px -1px 1px #679a10; }
button.aui_state_highlight:focus { border-color:#679a10; }
button.aui_state_highlight:hover { color:#FFF; border-color:#3c5412; }
button.aui_state_highlight:active { border-color:#3c5412; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#98d237', endColorstr='#7cb61b'); background: linear-gradient(top, #98d237, #7cb61b); background: -moz-linear-gradient(top, #98d237, #7cb61b); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#98d237), to(#7cb61b)); }
/* common end */
.aui_inner { background:#f7f7f7; }
.aui_titleBar { width:100%; height:0; position:relative; bottom:30px; _bottom:0; _margin-top:-30px; }
.aui_title { height:29px; line-height:29px; padding:0 25px 0 0; _padding:0; text-indent:5px; color:#FFF; font-weight:700; text-shadow:-1px -1px 0 rgba(0, 50, 0, .7); }
.aui_nw, .aui_ne, .aui_sw, .aui_se, .aui_n, .aui_s, .aui_close { background-image:url(green/bg.png); background-repeat:no-repeat; }
.aui_nw { width:15px; height:38px; background-position: 0 0; _png:green/ie6/nw.png; }
.aui_ne { width:15px; height:38px; background-position: -15px 0; _png:green/ie6/ne.png; }
.aui_sw { width:15px; height:18px; background-position: 0 -38px; _png:green/ie6/sw.png; }
.aui_se { width:15px; height:18px; background-position: -15px -38px; _png:green/ie6/se.png; }
.aui_close { top:4px; right:4px; _z-index:1; width:20px; height:20px; _font-size:0; _line-height:0; text-indent:-9999em; background-position:0 -112px; _png:green/ie6/close.png; }
.aui_close:hover { background-position:0 -132px; }
.aui_n, .aui_s { background-repeat:repeat-x; }
.aui_n { background-position: 0 -56px; _png:green/ie6/n.png; }
.aui_s { background-position: 0 -94px; _png:green/ie6/s.png; }
.aui_w, .aui_e { background-image:url(green/bg2.png); background-repeat:repeat-y; }
.aui_w { background-position:left top; _png:green/ie6/w.png; }
.aui_e { background-position: right bottom; _png:green/ie6/e.png; }
aui_icon, .aui_main { padding-top:3px; }
@media screen and (min-width:0) {
.aui_outer { border-radius:8px; box-shadow:0 5px 15px rgba(0, 50, 0, .4); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: -webkit-box-shadow linear .2s; }
.aui_state_lock .aui_outer { box-shadow:0 3px 26px rgba(0, 0, 0, .9); }
.aui_outer:active { box-shadow:0 0 5px rgba(0, 50, 0, .1)!important; }
.aui_state_drag .aui_outer { box-shadow:none!important; }
.aui_nw, .aui_ne, .aui_sw, .aui_se, .aui_n, .aui_s, .aui_close { background-image:url(green/bg_css3.png); }
.aui_nw { width:5px; height:31px; }
.aui_ne { width:5px; height:31px; background-position: -5px 0; _png:green/ie6/ne.png; }
.aui_sw { width:5px; height:5px;background-position: 0 -31px; }
.aui_se { width:5px; height:5px; background-position: -5px -31px; }
.aui_close { background-position:0 -72px; }
.aui_close:hover { background-position:0 -92px; }
.aui_n { background-position: 0 -36px; }
.aui_s { background-position: 0 -67px; }
.aui_w, .aui_e { background-image:url(green/bg_css3_2.png); }
}
.aui_state_noTitle .aui_nw, .aui_state_noTitle .aui_ne, .aui_state_noTitle .aui_sw, .aui_state_noTitle .aui_se { width:3px; height:3px; }
.aui_state_noTitle .aui_inner { border:1px solid #666; background:#FFF; }
.aui_state_noTitle .aui_outer { box-shadow:none; }
.aui_state_noTitle .aui_nw, .aui_state_noTitle .aui_n, .aui_state_noTitle .aui_ne, .aui_state_noTitle .aui_w, .aui_state_noTitle .aui_e, .aui_state_noTitle .aui_sw, .aui_state_noTitle .aui_s, .aui_state_noTitle .aui_se { background:rgba(0, 0, 0, .05); background:#000\9!important; filter:alpha(opacity=5)!important; }
.aui_state_noTitle .aui_titleBar { bottom:0; _bottom:0; _margin-top:0; }
.aui_state_noTitle .aui_close { top:0; right:0; width:18px; height:18px; line-height:18px; text-align:center; text-indent:0; font-family: Helvetica, STHeiti; _font-family: '\u9ed1\u4f53', 'Book Antiqua', Palatino; font-size:18px; text-decoration:none; color:#214FA3; background:none; filter:!important; }
.aui_state_noTitle .aui_close:hover, .aui_state_noTitle .aui_close:active { text-decoration:none; color:#900; } | 10npsite | trunk/Public/jsLibrary/jquery/skins/green.css | CSS | asf20 | 7,963 |
@charset "utf-8";
/*
* artDialog skin
* http://code.google.com/p/artdialog/
* (c) 2009-2011 TangBin, http://www.planeArt.cn
*
* This is licensed under the GNU LGPL, version 2.1 or later.
* For details, see: http://creativecommons.org/licenses/LGPL/2.1/
*/
/* common start */
body { _margin:0; _height:100%; /*IE6 BUG*/ }
.aui_outer { text-align:left; }
table.aui_border, table.aui_dialog { border:0; margin:0; border-collapse:collapse; width:auto; }
.aui_nw, .aui_n, .aui_ne, .aui_w, .aui_c, .aui_e, .aui_sw, .aui_s, .aui_se, .aui_header, .aui_tdIcon, .aui_main, .aui_footer { padding:0; }
.aui_header, .aui_buttons button { font: 12px/1.11 'Microsoft Yahei', Tahoma, Arial, Helvetica, STHeiti; _font-family:Tahoma,Arial,Helvetica,STHeiti; -o-font-family: Tahoma, Arial; }
.aui_title { overflow:hidden; text-overflow: ellipsis; }
.aui_state_noTitle .aui_title { display:none; }
.aui_close { display:block; position:absolute; text-decoration:none; outline:none; _cursor:pointer; }
.aui_close:hover { text-decoration:none; }
.aui_main { text-align:center; min-width:9em; min-width:0\9/*IE8 BUG*/; }
.aui_content { display:inline-block; *zoom:1; *display:inline; text-align:left; border:none 0; }
.aui_content.aui_state_full { display:block; width:100%; margin:0; padding:0!important; height:100%; }
.aui_loading { width:96px; height:32px; text-align:left; text-indent:-999em; overflow:hidden; background:url(icons/loading.gif) no-repeat center center; }
.aui_icon { vertical-align: middle; }
.aui_icon div { width:48px; height:48px; margin:10px 0 10px 10px; background-position: center center; background-repeat:no-repeat; }
.aui_buttons { padding:8px; text-align:right; white-space:nowrap; }
.aui_buttons button { margin-left:15px; padding: 6px 8px; cursor: pointer; display: inline-block; text-align: center; line-height: 1; *padding:4px 10px; *height:2em; letter-spacing:2px; font-family: Tahoma, Arial/9!important; width:auto; overflow:visible; *width:1; color: #333; border: solid 1px #999; border-radius: 5px; background: #DDD; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#DDDDDD'); background: linear-gradient(top, #FFF, #DDD); background: -moz-linear-gradient(top, #FFF, #DDD); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFF), to(#DDD)); text-shadow: 0px 1px 1px rgba(255, 255, 255, 1); box-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0 -1px 0 rgba(0, 0, 0, .09); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: box-shadow linear .2s; }
.aui_buttons button::-moz-focus-inner{ border:0; padding:0; margin:0; }
.aui_buttons button:focus { outline:none 0; border-color:#426DC9; box-shadow:0 0 8px rgba(66, 109, 201, .9); }
.aui_buttons button:hover { color:#000; border-color:#666; }
.aui_buttons button:active { border-color:#666; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#DDDDDD', endColorstr='#FFFFFF'); background: linear-gradient(top, #DDD, #FFF); background: -moz-linear-gradient(top, #DDD, #FFF); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#DDD), to(#FFF)); box-shadow:inset 0 1px 5px rgba(66, 109, 201, .9), inset 0 1px 1em rgba(0, 0, 0, .3); }
.aui_buttons button[disabled] { cursor:default; color:#666; background:#DDD; border: solid 1px #999; filter:alpha(opacity=50); opacity:.5; box-shadow:none; }
button.aui_state_highlight { color: #FFF; border: solid 1px #1c6a9e; background: #2288cc; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); text-shadow: -1px -1px 1px #1c6a9e; }
button.aui_state_highlight:hover { color:#FFF; border-color:#0F3A56; }
button.aui_state_highlight:active { border-color:#1c6a9e; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); }
/* common end */
.aui_inner { background:#FFF; border:1px solid #666; }
.aui_nw, .aui_ne, .aui_sw, .aui_se { width:3px; height:3px; }
.aui_nw, .aui_n, .aui_ne, .aui_w, .aui_e, .aui_sw, .aui_s, .aui_se { background:rgba(0, 0, 0, .05); background:#000\9!important; filter:alpha(opacity=5); }
.aui_titleBar { position:relative; height:100%; }
.aui_title { position:absolute; top:0; left:0; width:100%; height:24px; text-indent:-9999em; overflow:hidden; }
.aui_state_drag .aui_title { color:#666; }
.aui_close { padding:0; top:0; right:0; width:18px; height:18px; line-height:18px; text-align:center; font-family: Helvetica, STHeiti; _font-family: '\u9ed1\u4f53', 'Book Antiqua', Palatino; font-size:18px; text-decoration:none; color:#214FA3; }
.aui_close:hover, .aui_close:active { text-decoration:none; color:#900; }
.aui_content { color:#666; }
.aui_state_focus .aui_content { color:#000; }
@media screen and (min-width:0) {
.aui_close { width:20px; height:20px; line-height:20px; right:-10px; top:-10px; border-radius:20px; background:#999; color:#FFF; box-shadow:0 1px 3px rgba(0, 0, 0, .3); -moz-transition: linear .06s; -webkit-transition: linear .06s; transition: linear .06s; }
.aui_close:hover { width:24px; height:24px; line-height:24px; right:-12px; top:-12px; color:#FFF; box-shadow:0 1px 3px rgba(209, 40, 42, .5); background:#d1282a; border-radius:24px; }
.aui_state_lock .aui_dialog { box-shadow:0 3px 26px rgba(0, 0, 0, .9); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: -webkit-box-shadow linear .2s; }
.aui_dialog:active { box-shadow:0 0 5px rgba(0, 0, 0, .1)!important; }
.aui_state_drag .aui_outer { box-shadow:none!important; }
}
| 10npsite | trunk/Public/jsLibrary/jquery/skins/simple.css | CSS | asf20 | 5,993 |
@charset "utf-8";
/*
* artDialog skin
* http://code.google.com/p/artdialog/
* (c) 2009-2011 TangBin, http://www.planeArt.cn
*
* This is licensed under the GNU LGPL, version 2.1 or later.
* For details, see: http://creativecommons.org/licenses/LGPL/2.1/
*/
/* common start */
body { _margin:0; _height:100%; /*IE6 BUG*/ }
.aui_outer { text-align:left; }
table.aui_border, table.aui_dialog { border:0; margin:0; border-collapse:collapse; width:auto; }
.aui_nw, .aui_n, .aui_ne, .aui_w, .aui_c, .aui_e, .aui_sw, .aui_s, .aui_se, .aui_header, .aui_tdIcon, .aui_main, .aui_footer { padding:0; }
.aui_header, .aui_buttons button { font: 12px/1.11 'Microsoft Yahei', Tahoma, Arial, Helvetica, STHeiti; _font-family:Tahoma,Arial,Helvetica,STHeiti; -o-font-family: Tahoma, Arial; }
.aui_title { overflow:hidden; text-overflow: ellipsis; }
.aui_state_noTitle .aui_title { display:none; }
.aui_close { display:block; position:absolute; text-decoration:none; outline:none; _cursor:pointer; }
.aui_close:hover { text-decoration:none; }
.aui_main { text-align:center; min-width:9em; min-width:0 \9/*IE8 BUG*/; }
.aui_content { display:inline-block; *zoom:1; *display:inline; text-align:left; border:none 0; }
.aui_content.aui_state_full { display:block; width:100%; margin:0; padding:0!important; height:100%; }
.aui_loading { width:96px; height:32px; text-align:left; text-indent:-999em; overflow:hidden; background:url(icons/loading.gif) no-repeat center center; }
.aui_icon { vertical-align: middle; }
.aui_icon div { width:48px; height:48px; margin:10px 0 10px 10px; background-position: center center; background-repeat:no-repeat; }
.aui_buttons { padding:8px; text-align:right; white-space:nowrap; }
.aui_buttons button { margin-left:15px; padding: 6px 8px; cursor: pointer; display: inline-block; text-align: center; line-height: 1; *padding:4px 10px; *height:2em; letter-spacing:2px; font-family: Tahoma, Arial/9!important; width:auto; overflow:visible; *width:1; color: #333; border: solid 1px #999; border-radius: 5px; background: #DDD; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#DDDDDD'); background: linear-gradient(top, #FFF, #DDD); background: -moz-linear-gradient(top, #FFF, #DDD); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFF), to(#DDD)); text-shadow: 0px 1px 1px rgba(255, 255, 255, 1); box-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0 -1px 0 rgba(0, 0, 0, .09); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: box-shadow linear .2s; }
.aui_buttons button::-moz-focus-inner{ border:0; padding:0; margin:0; }
.aui_buttons button:focus { outline:none 0; border-color:#426DC9; box-shadow:0 0 8px rgba(66, 109, 201, .9); }
.aui_buttons button:hover { color:#000; border-color:#666; }
.aui_buttons button:active { border-color:#666; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#DDDDDD', endColorstr='#FFFFFF'); background: linear-gradient(top, #DDD, #FFF); background: -moz-linear-gradient(top, #DDD, #FFF); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#DDD), to(#FFF)); box-shadow:inset 0 1px 5px rgba(66, 109, 201, .9), inset 0 1px 1em rgba(0, 0, 0, .3); }
.aui_buttons button[disabled] { cursor:default; color:#666; background:#DDD; border: solid 1px #999; filter:alpha(opacity=50); opacity:.5; box-shadow:none; }
button.aui_state_highlight { color: #FFF; border: solid 1px #3399dd; background: #2288cc; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); text-shadow: -1px -1px 1px #1c6a9e; }
button.aui_state_highlight:hover { color:#FFF; border-color:#1c6a9e; }
button.aui_state_highlight:active { border-color:#1c6a9e; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33bbee', endColorstr='#2288cc'); background: linear-gradient(top, #33bbee, #2288cc); background: -moz-linear-gradient(top, #33bbee, #2288cc); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#33bbee), to(#2288cc)); }
/* common end */
.aui_inner { background:#f7f7f7; }
.aui_titleBar { width:100%; height:0; position:relative; bottom:30px; _bottom:0; _margin-top:-30px; }
.aui_title { height:29px; line-height:29px; padding:0 25px 0 0; _padding:0; text-indent:5px; color:#FFF; font-weight:700; text-shadow:-1px -1px 0 rgba(33, 79, 183, .7); }
.aui_nw, .aui_ne, .aui_sw, .aui_se, .aui_n, .aui_s, .aui_close { background-image:url(blue/bg.png); background-repeat:no-repeat; }
.aui_nw { width:15px; height:38px; background-position: 0 0; _png:blue/ie6/nw.png; }
.aui_ne { width:15px; height:38px; background-position: -15px 0; _png:blue/ie6/ne.png; }
.aui_sw { width:15px; height:18px; background-position: 0 -38px; _png:blue/ie6/sw.png; }
.aui_se { width:15px; height:18px; background-position: -15px -38px; _png:blue/ie6/se.png; }
.aui_close { top:4px; right:4px; _z-index:1; width:20px; height:20px; _font-size:0; _line-height:0; text-indent:-9999em; background-position:0 -112px; _png:blue/ie6/close.png; }
.aui_close:hover { background-position:0 -132px; }
.aui_n, .aui_s { background-repeat:repeat-x; }
.aui_n { background-position: 0 -56px; _png:blue/ie6/n.png; }
.aui_s { background-position: 0 -94px; _png:blue/ie6/s.png; }
.aui_w, .aui_e { background-image:url(blue/bg2.png); background-repeat:repeat-y; }
.aui_w { background-position:left top; _png:blue/ie6/w.png; }
.aui_e { background-position: right bottom; _png:blue/ie6/e.png; }
aui_icon, .aui_main { padding-top:3px; }
@media screen and (min-width:0) {
.aui_outer { border-radius:8px; box-shadow:0 5px 15px rgba(2, 37, 69, .4); -moz-transition:-moz-box-shadow linear .2s; -webkit-transition: -webkit-box-shadow linear .2s; transition: -webkit-box-shadow linear .2s; }
.aui_state_drag .aui_outer { box-shadow:none; }
.aui_state_lock .aui_outer { box-shadow:0 3px 26px rgba(0, 0, 0, .9); }
.aui_outer:active { box-shadow:0 0 5px rgba(2, 37, 69, .1)!important; }
.aui_state_drag .aui_outer { box-shadow:none!important; }
.aui_nw, .aui_ne, .aui_sw, .aui_se, .aui_n, .aui_s, .aui_close { background-image:url(blue/bg_css3.png); }
.aui_nw { width:5px; height:31px; }
.aui_ne { width:5px; height:31px; background-position: -5px 0; _png:blue/ie6/ne.png; }
.aui_sw { width:5px; height:5px;background-position: 0 -31px; }
.aui_se { width:5px; height:5px; background-position: -5px -31px; }
.aui_close { background-position:0 -72px; }
.aui_close:hover { background-position:0 -92px; }
.aui_n { background-position: 0 -36px; }
.aui_s { background-position: 0 -67px; }
.aui_w, .aui_e { background-image:url(blue/bg_css3_2.png); }
}
.aui_state_noTitle .aui_nw, .aui_state_noTitle .aui_ne, .aui_state_noTitle .aui_sw, .aui_state_noTitle .aui_se { width:3px; height:3px; }
.aui_state_noTitle .aui_inner { border:1px solid #666; background:#FFF; }
.aui_state_noTitle .aui_outer { box-shadow:none; }
.aui_state_noTitle .aui_nw, .aui_state_noTitle .aui_n, .aui_state_noTitle .aui_ne, .aui_state_noTitle .aui_w, .aui_state_noTitle .aui_e, .aui_state_noTitle .aui_sw, .aui_state_noTitle .aui_s, .aui_state_noTitle .aui_se { background:rgba(0, 0, 0, .05); background:#000\9!important; filter:alpha(opacity=5)!important; }
.aui_state_noTitle .aui_titleBar { bottom:0; _bottom:0; _margin-top:0; }
.aui_state_noTitle .aui_close { top:0; right:0; width:18px; height:18px; line-height:18px; text-align:center; text-indent:0; font-family: Helvetica, STHeiti; _font-family: '\u9ed1\u4f53', 'Book Antiqua', Palatino; font-size:18px; text-decoration:none; color:#214FA3; background:none; filter:!important; }
.aui_state_noTitle .aui_close:hover, .aui_state_noTitle .aui_close:active { text-decoration:none; color:#900; } | 10npsite | trunk/Public/jsLibrary/jquery/skins/blue.css | CSS | asf20 | 7,952 |
jQuery.fn.extend({
jsRightMenu: function(options) {
options = $.extend({
menuList: []
}, options);
return this.each(function() {
if ($("#div_RightMenu", $(this)).size() == 0) {
var menuCount = options.menuList.length;
if (menuCount > 0) {
var divMenuList = "<div id=\"div_RightMenu\" class=\"div_RightMenu\">";
for (var i = 0; i < menuCount; i++) {
divMenuList += "<div class=\"divMenuItem\" id='divMenuItem_"+i+"' onclick=\"" + options.menuList[i].clickEvent + "\" >" + options.menuList[i].menuName + "</div><hr size=1>";
$("#divMenuItem_"+i).bind("onmouseover",function(){
document.getElementById("divMenuItem_"+i).style.backgroundColor = "#6EC447";
});
}
divMenuList += "</div>";
$(this).append(divMenuList);
var objM = $(".divMenuItem");
$("#div_RightMenu").hide();
objM.bind("mouseover", function() {
//this.style.backgroundColor = "#316ac5";
//this.style.paddingLeft = "30px";
});
objM.bind("mouseout", function() {
//this.style.backgroundColor = '#EAEAEA';
});
}
}
this.oncontextmenu = function() {
var objMenu = $("#div_RightMenu");
if (objMenu.size() > 0) {
objMenu.hide();
var event = arguments[0] || window.event;
var clientX = event.clientX;
var clientY = event.clientY;
var redge = document.body.clientWidth - clientX;
var bedge = document.body.clientHeight - clientY;
var menu = objMenu.get(0);
var menuLeft = 0;
var menuTop = 0;
if (redge < menu.offsetWidth)
menuLeft = document.body.scrollLeft + clientX - menu.offsetWidth;
else
menuLeft = document.body.scrollLeft + clientX;
if (bedge < menu.offsetHeight)
menuTop = document.body.scrollTop + clientY - menu.offsetHeight;
else
menuTop = document.body.scrollTop + clientY;
objMenu.css({ top: menuTop + "px", left: menuLeft + "px" });
objMenu.show();
return false;
}
}
document.onclick = function() {
var objMenu = $("#div_RightMenu");
if (objMenu.size() > 0) objMenu.hide();
}
});
}
});
function setdiv(i)
{
document.getElementById("divMenuItem_"+i).style.backgroundColor = "#6EC447";
}
| 10npsite | trunk/Public/jsLibrary/jquery/jquery.RightMenu.js | JavaScript | asf20 | 3,027 |
/* 图片延迟加载
使用方法 如: $(".switch_textarea").lazyload();
详细出处参考:http://www.jb51.net/article/25706.htm
* Lazy Load - jQuery plugin for lazy loading images
*
* Copyright (c) 2007-2009 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* http://www.appelsiini.net/projects/lazyload
*
* Version: 1.5.0
*
* Modify by @cnbaiying
* Modify time: 2010-12-16
*/
(function($) {
$.fn.lazyload = function(options) {
var settings = {
threshold : 0, //阀值
failurelimit : 0,
event : "scroll",
effect : "show",
container : window
};
if(options) {
$.extend(settings, options);
}
/* Fire one scroll event per scroll. Not one scroll event per image. */
var elements = this;
if ("scroll" == settings.event) {
$(settings.container).bind("scroll", function(event) {
var counter = 0;
elements.each(function() {
if ($.abovethetop($(this).parent(), settings) || $.leftofbegin($(this).parent(), settings)) {
/* Nothing. */
} else if (!$.belowthefold($(this).parent(), settings) && !$.rightoffold($(this).parent(), settings)) {
$(this).trigger("appear");
} else {
if (counter++ > settings.failurelimit) {
return false;
}
}
});
/* Remove image from array so it is not looped next time. */
var temp = $.grep(elements, function(element) {
return !element.loaded;
});
elements = $(temp);
});
}
this.each(function() {
var self = this;
/* When appear is triggered load original image. */
$(self).one("appear", function() {
if (!this.loaded) {
//alert($(self).parent().html($(self).html()));
var tmp_str = $(self).html();
tmp_str = tmp_str.replace("<", "<");
tmp_str = tmp_str.replace(">", ">");
$(self).parent().append(tmp_str);
self.loaded = true;
}
});
/* When wanted event is triggered load original image */
/* by triggering appear. */
if ("scroll" != settings.event) {
$(self).bind(settings.event, function(event) {
if (!self.loaded) {
$(self).trigger("appear");
}
});
}
});
/* Force initial check if images should appear. */
$(settings.container).trigger(settings.event);
return this;
};
/* Convenience methods in jQuery namespace. */
/* Use as $.belowthefold(element, {threshold : 100, container : window}) */
$.belowthefold = function(element, settings) {
if (settings.container === undefined || settings.container === window) {
var fold = $(window).height() + $(window).scrollTop();
} else {
var fold = $(settings.container).offset().top + $(settings.container).height();
}
return fold <= $(element).offset().top - settings.threshold;
};
$.rightoffold = function(element, settings) {
if (settings.container === undefined || settings.container === window) {
var fold = $(window).width() + $(window).scrollLeft();
} else {
var fold = $(settings.container).offset().left + $(settings.container).width();
}
return fold <= $(element).offset().left - settings.threshold;
};
$.abovethetop = function(element, settings) {
if (settings.container === undefined || settings.container === window) {
var fold = $(window).scrollTop();
} else {
var fold = $(settings.container).offset().top;
}
return fold >= $(element).offset().top + settings.threshold + $(element).height();
};
$.leftofbegin = function(element, settings) {
if (settings.container === undefined || settings.container === window) {
var fold = $(window).scrollLeft();
} else {
var fold = $(settings.container).offset().left;
}
return fold >= $(element).offset().left + settings.threshold + $(element).width();
};
/* Custom selectors for your convenience. */
/* Use as $("img:below-the-fold").something() */
$.extend($.expr[':'], {
"below-the-fold" : "$.belowthefold(a, {threshold : 0, container: window})",
"above-the-fold" : "!$.belowthefold(a, {threshold : 0, container: window})",
"right-of-fold" : "$.rightoffold(a, {threshold : 0, container: window})",
"left-of-fold" : "!$.rightoffold(a, {threshold : 0, container: window})"
});
})(jQuery);
| 10npsite | trunk/Public/jsLibrary/jquery/jquery.lazyload.js | JavaScript | asf20 | 4,122 |
/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
var path = options.path ? '; path=' + options.path : '';
var domain = options.domain ? '; domain=' + options.domain : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
}; | 10npsite | trunk/Public/jsLibrary/jquery/jquery.cookie.js | JavaScript | asf20 | 3,937 |
/*
* ContextMenu - jQuery plugin for right-click context menus
*
* Author: Chris Domigan
* Contributors: Dan G. Switzer, II
* Parts of this plugin are inspired by Joern Zaefferer's Tooltip plugin
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Version: r2
* Date: 16 July 2007
*
* For documentation visit http://www.trendskitchens.co.nz/jquery/contextmenu/
*
*/
(function($) {
var menu, shadow, trigger, content, hash, currentTarget;
var defaults = {
menuStyle: {
listStyle: 'none',
padding: '1px',
margin: '0px',
backgroundColor: '#fff',
border: '1px solid #999',
width: '100px'
},
itemStyle: {
margin: '0px',
color: '#000',
display: 'block',
cursor: 'default',
padding: '3px',
border: '1px solid #fff',
backgroundColor: 'transparent'
},
itemHoverStyle: {
border: '1px solid #0a246a',
backgroundColor: '#b6bdd2'
},
eventPosX: 'pageX',
eventPosY: 'pageY',
shadow : true,
onContextMenu: null,
onShowMenu: null
};
$.fn.contextMenu = function(id, options) {
if (!menu) { // Create singleton menu
menu = $('<div id="jqContextMenu"></div>')
.hide()
.css({position:'absolute', zIndex:'500'})
.appendTo('body')
.bind('click', function(e) {
e.stopPropagation();
});
}
if (!shadow) {
shadow = $('<div></div>')
.css({backgroundColor:'#000',position:'absolute',opacity:0.2,zIndex:499})
.appendTo('body')
.hide();
}
hash = hash || [];
hash.push({
id : id,
menuStyle: $.extend({}, defaults.menuStyle, options.menuStyle || {}),
itemStyle: $.extend({}, defaults.itemStyle, options.itemStyle || {}),
itemHoverStyle: $.extend({}, defaults.itemHoverStyle, options.itemHoverStyle || {}),
bindings: options.bindings || {},
shadow: options.shadow || options.shadow === false ? options.shadow : defaults.shadow,
onContextMenu: options.onContextMenu || defaults.onContextMenu,
onShowMenu: options.onShowMenu || defaults.onShowMenu,
eventPosX: options.eventPosX || defaults.eventPosX,
eventPosY: options.eventPosY || defaults.eventPosY
});
var index = hash.length - 1;
$(this).bind('contextmenu', function(e) {
// Check if onContextMenu() defined
var bShowContext = (!!hash[index].onContextMenu) ? hash[index].onContextMenu(e) : true;
if (bShowContext) display(index, this, e, options);
return false;
});
return this;
};
function display(index, trigger, e, options) {
var cur = hash[index];
content = $('#'+cur.id).find('ul:first').clone(true);
content.css(cur.menuStyle).find('li').css(cur.itemStyle).hover(
function() {
$(this).css(cur.itemHoverStyle);
},
function(){
$(this).css(cur.itemStyle);
}
).find('img').css({verticalAlign:'middle',paddingRight:'2px'});
// Send the content to the menu
menu.html(content);
// if there's an onShowMenu, run it now -- must run after content has been added
// if you try to alter the content variable before the menu.html(), IE6 has issues
// updating the content
if (!!cur.onShowMenu) menu = cur.onShowMenu(e, menu);
$.each(cur.bindings, function(id, func) {
$('#'+id, menu).bind('click', function(e) {
hide();
func(trigger, currentTarget);
});
});
menu.css({'left':e[cur.eventPosX],'top':e[cur.eventPosY]}).show();
if (cur.shadow) shadow.css({width:menu.width(),height:menu.height(),left:e.pageX+2,top:e.pageY+2}).show();
$(document).one('click', hide);
}
function hide() {
menu.hide();
shadow.hide();
}
// Apply defaults
$.contextMenu = {
defaults : function(userDefaults) {
$.each(userDefaults, function(i, val) {
if (typeof val == 'object' && defaults[i]) {
$.extend(defaults[i], val);
}
else defaults[i] = val;
});
}
};
})(jQuery);
$(function() {
$('div.contextMenu').hide();
}); | 10npsite | trunk/Public/jsLibrary/jquery/jquery.contextmenu.r2.js | JavaScript | asf20 | 4,441 |
<?
require "../global.php";
?>
dollsgerate=<? echo $Exchangerate["dol"];?>;//人民币和美元之间的惠率
| 10npsite | trunk/Public/jsLibrary/golbal_js.php | PHP | asf20 | 119 |
tmsgname="";
tdialogname="";
twidthnum="";//模似对话宽宽度
theightnum="";//模似对话框高度
/*参数为一个数组
//CsArr["title"]为显示标题
CsArr["msg"]为显示内容
CsArr["msgname"]父页面中div的id 显示对话框窗口
CsArr["dialogname"]父页面中div的id 显示对话框窗口
CsArr["heightnum"] 对话框的距离屏幕顶端高度
CsArr["widthnum"]//对话框的距离屏幕顶端宽度
*/
function show(CsArr)
{
if(CsArr["heightnum"]=="")
{
CsArr["heightnum"]="300";//若没有定义默认为300
}
if(CsArr["widthnum"]=="")
{
CsArr["widthnum"]="300";//若没有定义默认为300
}
tmsgname=CsArr["msgname"];
tdialogname=CsArr["dialogname"];
theightnum=CsArr["heightnum"];
twidthnum=CsArr["widthnum"];
var d_mask=document.getElementById(CsArr["msgname"]);
var d_dialog =document.getElementById(CsArr["dialogname"]);
d_mask.style.width = document.body.clientWidth ;
d_mask.style.height=document.body.clientHeight;
d_dialog.style.top = document.body.clientHeight / 2 -CsArr["heightnum"];
d_dialog.style.left =document.body.clientWidth / 2 -CsArr["widthnum"];
var Inner = "<input type='button' value='Close' onclick='DialogClose()'/>"
var info = "<table cellspacing='0' width='100%' height='100%'>"+
"<tr class='dgtitle'><td>"
+CsArr['title']
+"</td><td align='right'><input type='button' value='Close' onclick='DialogClose()'class='formButton'/></td></tr>"
+"<tr><td colspan='2' valign='top'>"
+CsArr['msg']
+"</td></tr>"
+"<tr class='dgfooter'><td></td><td>"
+"</td></tr>"
+"</table>";
d_dialog.innerHTML =info;
d_mask.style.visibility='visible';
d_dialog.style.visibility='visible';
}
function Icon_Close_Over(obj)
{
obj.src='close.gif';
}
function Icon_Close_Out(obj)
{
obj.src='close1.gif'
}
function DialogClose()
{
var d_mask=document.getElementById(tmsgname);
var d_dialog = document.getElementById(tdialogname);
//parent.getifheight();//当记录没有时或很少时还原其框架在原来的页面中的高度
enableSelect()
d_mask.style.visibility='hidden';
d_dialog.style.visibility='hidden';
}
function disableSelect()
{
for(i=0;i<document.all.length;i++)
if(document.all(i).tagName=="SELECT")
document.all(i).disabled = true;
}
function enableSelect()
{
for(i=0;i<document.all.length;i++){
if(document.all(i).tagName=="SELECT")
{
document.all(i).disabled = false;
}
}
}
function divBlock_event_mousedown()
{
var e, obj, temp;
obj=document.getElementById(tdialogname);
e=window.event?window.event:e;
obj.startX=e.clientX-obj.offsetLeft;
obj.startY=e.clientY-obj.offsetTop;
document.onmousemove=document_event_mousemove;
temp=document.attachEvent?document.attachEvent('onmouseup',document_event_mouseup):document.addEventListener('mouseup',document_event_mouseup,'');
}
function document_event_mousemove(e)
{
var e, obj;
obj=document.getElementById(tdialogname);
e=window.event?window.event:e;
with(obj.style){
position='absolute';
left=e.clientX-obj.startX+'px';
top=e.clientY-obj.startY+'px';
}
}
function document_event_mouseup(e)
{
var temp;
document.onmousemove='';
temp=document.detachEvent?parent.detachEvent('onmouseup',document_event_mouseup):document.removeEventListener('mouseup',document_event_mouseup,'');
}
window.onresize = function()
{
var d_mask=document.getElementById(tmsgname);
var d_dialog = document.getElementById(tdialogname);
d_mask.style.width = document.body.clientWidth ;
d_mask.style.height=document.body.clientHeight;
}
/*
使用说明
1、首先在周用页面引入此js页面 这里的#dialog根据div名称而定
2、添加css样式,
<style type='text/css'>
.#dialog{
visibility: hidden;
background-color: #f7fcfe;
z-index: 100;
width: 300px;
position: absolute;
height: 200px;
}
</style>
3、在定义一个函数
给相关的项赋值,如:
//CsArr["title"]为显示标题
CsArr["msg"]为显示内容
CsArr["msgname"]父页面中div的id 显示对话框窗口
CsArr["dialogname"]父页面中div的id 显示对话框窗口
CsArr["heightnum"] 对话框的距离屏幕顶端高度
CsArr["widthnum"]//对话框的距离屏幕顶端宽度
4、在父页面里的相关标签调用函数"show(CsArr)"
*/
| 10npsite | trunk/Public/jsLibrary/jsAlert_iframe.js | JavaScript | asf20 | 4,764 |
/*
// ClearBox Config File (CSS)
*/
.CB_TextNav, #CB_ShowTh, #CB_Thumbs2, #CB_Thumbs, .CB_RoundPixBugFix, #CB_Padding, #CB_ImgContainer, #CB_PrevNext, #CB_ContentHide, #CB_OSD, #CB_Text, #CB_Window, #CB_Image, #CB_TopLeft, #CB_Top, #CB_TopRight, #CB_Left, #CB_Content, #CB_Right, #CB_BtmLeft, #CB_Btm, #CB_BtmRight, #CB_Prev, #CB_Prev:hover, #CB_Prev:focus, #CB_Prev:active, #CB_Next, #CB_Next:hover, #CB_Next:focus, #CB_Next:active, #CB_CloseWindow, #CB_SlideShowS, #CB_SlideShowP, #CB_SlideShowBar, #CB_Email {
margin: 0;
padding: 0;
background-color: transparent;
border: 0;
outline-style: none;
outline: 0;
}
.absolute {
position: absolute;
}
#CB_NotImgContent {
position: absolute;
width: 0px;
height: 0px;
}
#CB_NotIC, #CB_NotImgContent {
border: none;
outline-style: none;
outline: 0;
}
#CB_Window {
width: 0px;
border-spacing: 0px;
border-width: 0px;
}
.CB_Sep {
color: #bbb;
}
.CB_TnThumbs {
width: 0px;
height: 0px;
border: 0px;
padding: 0;
margin: 0;
visibility: hidden;
}
.CB_BtmNav {
position: relative;
top: 4px;
border: 0;
padding: 0px 0px 0px 3px;
}
#CB_ImgHide {
position: absolute;
visibility: hidden;
z-index: 1098;
left: 0px;
}
#CB_ShowTh {
width: 100%;
height: 20%;
visibility: hidden;
position: absolute;
z-index: 1097;
bottom: 0px;
left: 0px;
}
#CB_Thumbs {
display: none;
height: 62px;
padding-top: 10px;
position: absolute;
z-index: 1100;
overflow: hidden;
bottom: 0px;
left: 0px;
}
#CB_Thumbs2 {
margin: auto 0;
height: 52px;
position: absolute;
}
.CB_ThumbsImg {
position: absolute;
cursor: pointer;
border: 1px solid #000;
}
#CB_ThumbsActImg {
cursor: default;
border: 1px dotted #000;
}
.CB_RoundPixBugFix {
display: block;
visibility: hidden;
font-family: arial;
font-size: 1pt;
}
#CB_ImgContainer {
position: relative;
width: 100%;
}
#CB_PrevNext {
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
z-index: 1002;
}
#CB_NavPrev, #CB_NavNext {
visibility: hidden;
position: absolute;
z-index: 1001;
top: 47%;
cursor: pointer;
}
#CB_NavPrev {
left: 18px;
}
#CB_NavNext {
right: 14px;
}
#CB_ContentHide {
position: absolute;
z-index: 1000;
top: 0px;
left: 0px;
}
#CB_OSD {
position: absolute;
left: 50%;
z-index: 5000;
font-family: arial;
font-size: 22px;
color: #fff;
background-color: #000;
visibility: hidden;
}
#CB_Text {
position: relative;
text-align: left;
overflow: hidden;
}
#CB_TT, #CB_TC {
position: relative;
}
#CB_TT, #CB_HiddenText {
white-space: nowrap;
}
#CB_TC {
margin-top: 2px;
overflow-y: auto;
}
#CB_TG {
margin-top: -2px;
}
#CB_Window {
left:50%;
position:absolute;
top:50%;
visibility:hidden;
z-index: 1100;
border-collapse: separate;
}
#CB_Image {
position: relative;
}
#CB_TopLeft {
background-image:url(pic/s_topleft.png);
background-position:right bottom;
}
#CB_Top {
background-image:url(pic/s_top.png);
background-position:left bottom;
}
#CB_TopRight {
background-image:url(pic/s_topright.png);
background-position:left bottom;
}
#CB_Left {
background-image:url(pic/s_left.png);
background-position:right top;
}
#CB_Right {
background-image:url(pic/s_right.png);
background-position:left top;
}
#CB_BtmLeft {
background-image:url(pic/s_btmleft.png);
background-position:right top;
}
#CB_Btm {
background-image:url(pic/s_btm.png);
background-position:left top;
}
#CB_BtmRight {
background-image:url(pic/s_btmright.png);
background-position:left top;
}
#CB_Prev, #CB_Next {
background: transparent url(pic/blank.gif) no-repeat scroll 0%;
display: block;
width: 49%;
cursor: pointer;
z-index: 1102;
}
.CB_TextNav {
text-decoration: underline;
padding-right: 5px;
color: #999;
cursor: pointer;
border: none;
}
.CB_TextNav:hover {
text-decoration: underline;
color: #555;
border: none;
}
#CB_Prev {
float: left;
left: 0px;
}
#CB_Next {
float: right;
left: 0px;
}
#CB_Prev:hover {
background:transparent;
}
#CB_Next:hover {
background:transparent;
}
#CB_CloseWindow {
position: absolute;
z-index: 1104;
cursor: pointer;
}
#CB_SlideShowS, #CB_SlideShowP {
position: absolute;
left: -27px;
top: -14px;
z-index: 1104;
cursor: pointer;
}
#CB_SlideShowBar {
width: 0px;
position: absolute;
height: 2px;
display: none;
z-index: 1102;
}
#CB_HiddenText, #CB_HiddenTextC {
position: absolute;
visibility: hidden;
z-index: -1000;
top: -100px;
left: -100000px;
}
.CB_PreloadBugFix {
width: 0px;
height: 0px;
z-index: -1000;
visibility: hidden;
position: absolute;
} | 10npsite | trunk/Public/jsLibrary/clearbox/config/grow_transparent/cb_style.css | CSS | asf20 | 4,837 |
/*
// ClearBox Config File (JavaScript)
*/
var
// CB layout:
CB_WindowColor='transparent', // color of the CB window (note: you have to change the rounded-corner PNGs too!), transparent is also working
CB_MinWidth=120, // minimum (only at images) or initial width of CB window
CB_MinHeight=120, // initial heigth of CB window
CB_WinPadd=25, // padding of the CB window from sides of the browser
CB_RoundPix=0, // change this setting only if you are generating new PNGs for rounded corners
CB_ImgBorder=0, // border size around the picture in CB window
CB_ImgBorderColor='#ddd', // border color around the picture in CB window
CB_Padd=3, // padding around inside the CB window
CB_BodyMarginLeft=0, //
CB_BodyMarginRight=0, // if you set margin to <body>,
CB_BodyMarginTop=0, // please change these settings!
CB_BodyMarginBottom=0, //
CB_ShowThumbnails='auto', // it tells CB how to show the thumbnails ('auto', 'always' or 'off') thumbnails are only in picture-mode!
CB_ThumbsBGColor='#000', // color of the thumbnail layer
CB_ThumbsBGOpacity=.75, // opacity of the thumbnail layer
CB_ActThumbOpacity=.5, // thumbnail opacity of the current viewed image
CB_SlideShowBarColor='#000', // color of the slideshow bar
CB_SlideShowBarOpacity=.5, // opacity of the slideshow bar
CB_SlideShowBarPadd=2, // padding of the slideshow bar (left and right)
CB_SlideShowBarTop=2, // position of the slideshow bar from the top of the picture
CB_SimpleDesign='off', // if it's 'on', CB doesn't show the frame but only the content - really nice ;)
CB_CloseBtnTop=-14, // vertical position of the close button in picture mode
CB_CloseBtnRight=-27, // horizontal position of the close button in picture mode
CB_CloseBtn2Top=-14, // vertical position of the close button in content mode
CB_CloseBtn2Right=-27, // horizontal position of the close button in content mode
CB_OSD='on', // turns on OSD
// CB font, text and navigation (at the bottom of CB window) settings:
CB_FontT='Verdana', //
CB_FontSizeT=12, // these variables are referring to the title or caption line
CB_FontColorT='#ddd', //
CB_FontWeightT='normal', //
CB_FontC='arial', //
CB_FontSizeC=11, // these variables are referring to
CB_FontColorC='#aaa', // comment lines under the title
CB_FontWeightC='normal', //
CB_TextAlignC='justify', //
CB_TxtHMax=42, // maximum height of the comment box in pixels
CB_FontG='arial', //
CB_FontSizeG=11, // these variables are referring to the gallery name
CB_FontColorG='#777', //
CB_FontWeightG='normal', //
CB_TextH=35, // default height of the text area under the content in CB window (adding a comment will modify this setting), if you change the font sizes, you maybe have to change this setting
CB_PadT=10, // space in pixels between the content and the title or caption line
CB_ShowURL='off', // it shows the url of the content if no title or caption is given
CB_ItemNum='on', // it shows the ordinal number of the content in galleries
CB_ItemNumBracket='()', // whatever you want ;)
CB_ShowGalName='on', // it shows gallery name
CB_TextNav='on', // it shows previous and next navigation
CB_NavTextImgPrvNxt='on', // it shows previous and next buttons instead of text
CB_ShowDL='on', // it shows download controls
CB_NavTextImgDL='on', // it shows download buttons instead of text
CB_ImgRotation='on', // it shows the image rotation controls
CB_NavTextImgRot='on', // it shows the image rotation buttons instead of text
// Settings of the document-hiding layer:
CB_HideColor='#000', // color of the layer
CB_HideOpacity=.9, // opacity (0 is invisible, 1 is 100% color) of the layer
CB_HideOpacitySpeed=400, // speed of fading
CB_CloseOnH='on', // CB will close, if you click on background
// CB animation settings:
CB_Animation='grow', // 'double', 'normal', 'off', 'grow' or 'warp' (high cpu usage)
CB_ImgOpacitySpeed=450, // speed of content fading (in ms)
CB_TextOpacitySpeed=350, // speed of text fading under the picture (in ms)
CB_AnimSpeed=400, // speed of the resizing animation of CB window (in ms)
CB_ImgTextFade='on', // turns on or off the fading of content and text
CB_FlashHide='off', // it hides flash animations on the page before CB starts
CB_SelectsHide='on', // it hides select boxes on the page before CB starts
CB_SlShowTime=7, // default speed of the slideshow (in sec)
CB_Preload='on', // preload neighbour pictures in galleries
// Images using by CB settings:
CB_PictureStart='start.png', //
CB_PicturePause='pause.png', //
CB_PictureClose='close.png', // filenames of some images using by clearbox
CB_PictureNext='next.png', // (there are other images specified in clearbox.css!)
CB_PicturePrev='prev.png', //
// CB professional settings:
CB_PicDir=CB_ScriptDir+'/config/'+CB_Config+'/pic', // CHANGE ONLY IF YOU CHANGED THE DEFAULT DIRECTORY-STRUCTURE OF CB!
CB_AllowedToRun='on', // if 'off', CB won't start (you can change this variable without reload!)
CB_AllowExtFunctLoad='off', // if 'on', CB will run a function named CB_ExternalFunctionLoad(); every time after a new content has loaded (useful for audit, etc)
CB_AllowExtFunctPageLoad='off', // if 'on', CB will run a function named CB_ExternalFunctionPageLoad(); after your page has fully loaded
CB_AllowExtFunctCBClose='off' // if 'on', CB will run a function named CB_ExternalFunctionCBClose(); after CB window has closed
; | 10npsite | trunk/Public/jsLibrary/clearbox/config/grow_transparent/cb_config.js | JavaScript | asf20 | 5,740 |
@charset "utf-8";
/*
// ClearBox Config File (CSS)
*/
.CB_TextNav, #CB_ShowTh, #CB_Thumbs2, #CB_Thumbs, .CB_RoundPixBugFix, #CB_Padding, #CB_ImgContainer, #CB_PrevNext, #CB_ContentHide, #CB_Text, #CB_Window, #CB_Image, #CB_TopLeft, #CB_Top, #CB_TopRight, #CB_Left, #CB_Content, #CB_Right, #CB_BtmLeft, #CB_Btm, #CB_BtmRight, #CB_Prev, #CB_Prev:hover, #CB_Prev:focus, #CB_Prev:active, #CB_Next, #CB_Next:hover, #CB_Next:focus, #CB_Next:active, #CB_CloseWindow, #CB_SlideShowS, #CB_SlideShowP, #CB_SlideShowBar, #CB_Email, #CB_OSD {
margin: 0;
padding: 0;
background-color: transparent;
border: 0;
outline-style: none;
outline: 0;
}
.absolute {
position: absolute;
}
#CB_NotImgContent {
position: absolute;
width: 0px;
height: 0px;
}
#CB_NotIC, #CB_NotImgContent {
border: none;
outline-style: none;
outline: 0;
}
#CB_Window {
width: 0px;
border-spacing: 0px;
border-width: 0px;
}
.CB_Sep {
color: #bbb;
}
.CB_TnThumbs {
width: 0px;
height: 0px;
border: 0px;
padding: 0;
margin: 0;
visibility: hidden;
}
.CB_BtmNav {
position: relative;
top: 4px;
border: 0;
padding: 0px 0px 0px 3px;
}
#CB_ImgHide {
position: absolute;
visibility: hidden;
z-index: 1098;
left: 0px;
}
#CB_ShowTh {
width: 100%;
height: 20%;
visibility: hidden;
position: absolute;
z-index: 1097;
bottom: 0px;
left: 0px;
}
#CB_Thumbs {
display: none;
height: 62px;
padding-top: 10px;
position: absolute;
z-index: 1100;
overflow: hidden;
bottom: 0px;
left: 0px;
}
#CB_Thumbs2 {
margin: auto 0;
height: 52px;
position: absolute;
}
.CB_ThumbsImg {
position: absolute;
cursor: pointer;
border: 1px solid #eee;
}
#CB_ThumbsActImg {
cursor: default;
border: 1px dotted #fff;
}
.CB_RoundPixBugFix {
display: block;
visibility: hidden;
font-family: arial;
font-size: 1pt;
}
#CB_ImgContainer {
position: relative;
width: 100%;
height:150px;
}
#CB_PrevNext {
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
z-index: 1002;
}
#CB_NavPrev, #CB_NavNext {
visibility: hidden;
position: absolute;
z-index: 1001;
top: 47%;
cursor: pointer;
}
#CB_NavPrev {
left: 18px;
}
#CB_NavNext {
right: 14px;
}
#CB_ContentHide {
position: absolute;
z-index: 1000;
top: 0px;
left: 0px;
}
#CB_OSD {
position: absolute;
left: 50%;
z-index: 5000;
font-family: arial;
font-size: 22px;
color: #fff;
background-color: #000;
visibility: hidden;
}
#CB_Text {
position: relative;
text-align: left;
overflow: hidden;
}
#CB_TT, #CB_TC {
position: relative;
}
#CB_TT, #CB_HiddenText {
white-space: nowrap;
}
#CB_TC {
margin-top: 2px;
overflow-y: auto;
}
#CB_TG {
margin-top: -2px;
}
#CB_Window {
left:50%;
position:absolute;
top:50%;
visibility:hidden;
z-index: 1100;
border-collapse: separate;
}
#CB_Image {
position: relative;
}
#CB_TopLeft {
background-image:url(pic/s_topleft.png);
background-position:right bottom;
}
#CB_Top {
background-image:url(pic/s_top.png);
background-position:left bottom;
}
#CB_TopRight {
background-image:url(pic/s_topright.png);
background-position:left bottom;
}
#CB_Left {
background-image:url(pic/s_left.png);
background-position:right top;
}
#CB_Right {
background-image:url(pic/s_right.png);
background-position:left top;
}
#CB_BtmLeft {
background-image:url(pic/s_btmleft.png);
background-position:right top;
}
#CB_Btm {
background-image:url(pic/s_btm.png);
background-position:left top;
}
#CB_BtmRight {
background-image:url(pic/s_btmright.png);
background-position:left top;
}
#CB_Prev, #CB_Next {
background: transparent url(pic/blank.gif) no-repeat scroll 0%;
display: block;
width: 49%;
cursor: pointer;
z-index: 1102;
}
.CB_TextNav {
text-decoration: underline;
padding-right: 5px;
color: #999;
cursor: pointer;
border: none;
}
.CB_TextNav:hover {
text-decoration: underline;
color: #555;
border: none;
}
#CB_Prev {
float: left;
left: 0px;
}
#CB_Next {
float: right;
left: 0px;
}
#CB_Prev:hover {
background:transparent;
}
#CB_Next:hover {
background:transparent;
}
#CB_CloseWindow {
position: absolute;
z-index: 1104;
cursor: pointer;
}
#CB_SlideShowS, #CB_SlideShowP {
position: absolute;
left: -11px;
top: -10px;
z-index: 1104;
cursor: pointer;
}
#CB_SlideShowBar {
width: 0px;
position: absolute;
height: 2px;
display: none;
z-index: 1102;
}
#CB_HiddenText, #CB_HiddenTextC {
position: absolute;
visibility: hidden;
z-index: -1000;
top: -100px;
left: -100000px;
}
.CB_PreloadBugFix {
width: 0px;
height: 0px;
z-index: -1000;
visibility: hidden;
position: absolute;
} | 10npsite | trunk/Public/jsLibrary/clearbox/config/default/cb_style.css | CSS | asf20 | 4,872 |
/*
// ClearBox Config File (JavaScript)
*/
var
// CB layout:
CB_WindowColor='#fff', // color of the CB window (note: you have to change the rounded-corner PNGs too!), transparent is also working
CB_MinWidth=120, // minimum (only at images) or initial width of CB window
CB_MinHeight=120, // initial heigth of CB window
CB_WinPadd=15, // padding of the CB window from sides of the browser
CB_RoundPix=12, // change this setting only if you are generating new PNGs for rounded corners
CB_ImgBorder=0, // border size around the picture in CB window
CB_ImgBorderColor='#ddd', // border color around the picture in CB window
CB_Padd=4, // padding around inside the CB window
CB_BodyMarginLeft=5, //
CB_BodyMarginRight=5, // if you set margin to <body>,
CB_BodyMarginTop=0, // please change these settings!
CB_BodyMarginBottom=0, //
CB_ShowThumbnails='auto', // it tells CB how to show the thumbnails ('auto', 'always' or 'off') thumbnails are only in picture-mode!
CB_ThumbsBGColor='#000', // color of the thumbnail layer
CB_ThumbsBGOpacity=.35, // opacity of the thumbnail layer
CB_ActThumbOpacity=.65, // thumbnail opacity of the current viewed image
CB_SlideShowBarColor='#fff', // color of the slideshow bar
CB_SlideShowBarOpacity=.5, // opacity of the slideshow bar
CB_SlideShowBarPadd=17, // padding of the slideshow bar (left and right)
CB_SlideShowBarTop=2, // position of the slideshow bar from the top of the picture
CB_SimpleDesign='off', // if it's 'on', CB doesn't show the frame but only the content - really nice ;)
CB_CloseBtnTop=-10, // vertical position of the close button in picture mode
CB_CloseBtnRight=-14, // horizontal position of the close button in picture mode
CB_CloseBtn2Top=-20, // vertical position of the close button in content mode
CB_CloseBtn2Right=-30, // horizontal position of the close button in content mode
CB_OSD='on', // turns on OSD
// CB font, text and navigation (at the bottom of CB window) settings:
CB_FontT='Verdana', //
CB_FontSizeT=12, // these variables are referring to the title or caption line
CB_FontColorT='#777', //
CB_FontWeightT='normal', //
CB_FontC='arial', //
CB_FontSizeC=11, // these variables are referring to
CB_FontColorC='#aaa', // comment lines under the title
CB_FontWeightC='normal', //
CB_TextAlignC='justify', //
CB_TxtHMax=42, // maximum height of the comment box in pixels
CB_FontG='arial', //
CB_FontSizeG=11, // these variables are referring to the gallery name
CB_FontColorG='#999', //
CB_FontWeightG='normal', //
CB_TextH=35, // default height of the text area under the content in CB window (adding a comment will modify this setting), if you change the font sizes, you maybe have to change this setting
CB_PadT=10, // space in pixels between the content and the title or caption line
CB_ShowURL='off', // it shows the url of the content if no title or caption is given
CB_ItemNum='on', // it shows the ordinal number of the content in galleries
CB_ItemNumBracket='()', // whatever you want ;)
CB_ShowGalName='on', // it shows gallery name
CB_TextNav='on', // it shows previous and next navigation
CB_NavTextImgPrvNxt='on', // it shows previous and next buttons instead of text
CB_ShowDL='on', // it shows download controls
CB_NavTextImgDL='on', // it shows download buttons instead of text
CB_ImgRotation='on', // it shows the image rotation controls
CB_NavTextImgRot='on', // it shows the image rotation buttons instead of text
// Settings of the document-hiding layer:
CB_HideColor='#000', // color of the layer
CB_HideOpacity=.85, // opacity (0 is invisible, 1 is 100% color) of the layer
CB_HideOpacitySpeed=400, // speed of fading
CB_CloseOnH='on', // CB will close, if you click on background
// CB animation settings:
CB_Animation='double', // 'double', 'normal', 'off', 'grow' or 'warp' (high cpu usage)
CB_ImgOpacitySpeed=450, // speed of content fading (in ms)
CB_TextOpacitySpeed=350, // speed of text fading under the picture (in ms)
CB_AnimSpeed=400, // speed of the resizing animation of CB window (in ms)
CB_ImgTextFade='on', // turns on or off the fading of content and text
CB_FlashHide='off', // it hides flash animations on the page before CB starts
CB_SelectsHide='on', // it hides select boxes on the page before CB starts
CB_SlShowTime=5, // default speed of the slideshow (in sec)
CB_Preload='on', // preload neighbour pictures in galleries
// Images using by CB settings:
CB_PictureStart='start.png', //
CB_PicturePause='pause.png', //
CB_PictureClose='close.png', // filenames of some images using by clearbox
CB_PictureNext='next.png', // (there are other images specified in clearbox.css!)
CB_PicturePrev='prev.png', //
// CB professional settings:
CB_PicDir=CB_ScriptDir+'/config/'+CB_Config+'/pic', // CHANGE ONLY IF YOU CHANGED THE DEFAULT DIRECTORY-STRUCTURE OF CB!
CB_AllowedToRun='on', // if 'off', CB won't start (you can change this variable without reload!)
CB_AllowExtFunctLoad='off', // if 'on', CB will run a function named CB_ExternalFunctionLoad(); every time after a new content has loaded (useful for audit, etc)
CB_AllowExtFunctPageLoad='off', // if 'on', CB will run a function named CB_ExternalFunctionPageLoad(); after your page has fully loaded
CB_AllowExtFunctCBClose='off' // if 'on', CB will run a function named CB_ExternalFunctionCBClose(); after CB window has closed
; | 10npsite | trunk/Public/jsLibrary/clearbox/config/default/cb_config.js | JavaScript | asf20 | 5,739 |
//
// ClearBox Language File (JavaScript)
//
var
CB_NavTextPrv='previous', // text of previous image
CB_NavTextNxt='next', // text of next image
CB_NavTextFull='full size', // text of original size (only at pictures)
CB_NavTextOpen='open in new browser window', // text of open in a new browser window
CB_NavTextDL='download', // text of download picture or any other content
CB_NavTextClose='close clearbox', // text of close CB
CB_NavTextStart='start slideshow', // text of start slideshow
CB_NavTextStop='stop slideshow', // text of stop slideshow
CB_NavTextRotR='rotate image right by 90 degrees', // text of rotation right
CB_NavTextRotL='rotate image left by 90 degrees' // text of rotation left
; | 10npsite | trunk/Public/jsLibrary/clearbox/language/en/cb_language.js | JavaScript | asf20 | 772 |
//
// ClearBox Language File (JavaScript)
//
var
CB_NavTextPrv='上一张', // text of previous image
CB_NavTextNxt='下一张', // text of next image
CB_NavTextFull='', // text of original size (only at pictures)
CB_NavTextOpen='Open to new Page', // text of open in a new browser window
CB_NavTextDL='Download', // text of download picture or any other content
CB_NavTextClose='Close', // text of close CB
CB_NavTextStart='', // text of start slideshow
CB_NavTextStop='停止幻灯片', // text of stop slideshow
CB_NavTextRotR='向右旋转90', // text of rotation right
CB_NavTextRotL='向左旋转90' // text of rotation left
; | 10npsite | trunk/Public/jsLibrary/clearbox/language/cn/cb_language.js | JavaScript | asf20 | 699 |
/*
// ClearBox Config File (CSS)
*/
.CB_TextNav, #CB_ShowTh, #CB_Thumbs2, #CB_Thumbs, .CB_RoundPixBugFix, #CB_Padding, #CB_ImgContainer, #CB_PrevNext, #CB_ContentHide, #CB_OSD, #CB_Text, #CB_Window, #CB_Image, #CB_TopLeft, #CB_Top, #CB_TopRight, #CB_Left, #CB_Content, #CB_Right, #CB_BtmLeft, #CB_Btm, #CB_BtmRight, #CB_Prev, #CB_Prev:hover, #CB_Prev:focus, #CB_Prev:active, #CB_Next, #CB_Next:hover, #CB_Next:focus, #CB_Next:active, #CB_CloseWindow, #CB_SlideShowS, #CB_SlideShowP, #CB_SlideShowBar, #CB_Email {
margin: 0;
padding: 0;
background-color: transparent;
border: 0;
outline-style: none;
outline: 0;
}
.absolute {
position: absolute;
}
#CB_NotImgContent {
position: absolute;
width: 0px;
height: 0px;
}
#CB_NotIC, #CB_NotImgContent {
border: none;
outline-style: none;
outline: 0;
}
#CB_Window {
width: 0px;
border-spacing: 0px;
border-width: 0px;
}
.CB_Sep {
color: #bbb;
}
.CB_TnThumbs {
width: 0px;
height: 0px;
border: 0px;
padding: 0;
margin: 0;
visibility: hidden;
}
.CB_BtmNav {
position: relative;
top: 4px;
border: 0;
padding: 0px 0px 0px 3px;
}
#CB_ImgHide {
position: absolute;
visibility: hidden;
z-index: 1098;
left: 0px;
}
#CB_ShowTh {
width: 100%;
height: 20%;
visibility: hidden;
position: absolute;
z-index: 1097;
bottom: 0px;
left: 0px;
}
#CB_Thumbs {
display: none;
height: 62px;
padding-top: 10px;
position: absolute;
z-index: 1100;
overflow: hidden;
bottom: 0px;
left: 0px;
}
#CB_Thumbs2 {
margin: auto 0;
height: 52px;
position: absolute;
}
.CB_ThumbsImg {
position: absolute;
cursor: pointer;
border: 1px solid #000;
}
#CB_ThumbsActImg {
cursor: default;
border: 1px dotted #000;
}
.CB_RoundPixBugFix {
display: block;
visibility: hidden;
font-family: arial;
font-size: 1pt;
}
#CB_ImgContainer {
position: relative;
width: 100%;
}
#CB_PrevNext {
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
z-index: 1002;
}
#CB_NavPrev, #CB_NavNext {
visibility: hidden;
position: absolute;
z-index: 1001;
top: 47%;
cursor: pointer;
}
#CB_NavPrev {
left: 18px;
}
#CB_NavNext {
right: 14px;
}
#CB_ContentHide {
position: absolute;
z-index: 1000;
top: 0px;
left: 0px;
}
#CB_OSD {
position: absolute;
left: 50%;
z-index: 5000;
font-family: arial;
font-size: 22px;
color: #fff;
background-color: #000;
visibility: hidden;
}
#CB_Text {
position: relative;
text-align: left;
overflow: hidden;
}
#CB_TT, #CB_TC {
position: relative;
}
#CB_TT, #CB_HiddenText {
white-space: nowrap;
}
#CB_TC {
margin-top: 2px;
overflow-y: auto;
}
#CB_TG {
margin-top: -2px;
}
#CB_Window {
left:50%;
position:absolute;
top:50%;
visibility:hidden;
z-index: 1100;
border-collapse: separate;
}
#CB_Image {
position: relative;
}
#CB_TopLeft {
background-image:url(pic/s_topleft.png);
background-position:right bottom;
}
#CB_Top {
background-image:url(pic/s_top.png);
background-position:left bottom;
}
#CB_TopRight {
background-image:url(pic/s_topright.png);
background-position:left bottom;
}
#CB_Left {
background-image:url(pic/s_left.png);
background-position:right top;
}
#CB_Right {
background-image:url(pic/s_right.png);
background-position:left top;
}
#CB_BtmLeft {
background-image:url(pic/s_btmleft.png);
background-position:right top;
}
#CB_Btm {
background-image:url(pic/s_btm.png);
background-position:left top;
}
#CB_BtmRight {
background-image:url(pic/s_btmright.png);
background-position:left top;
}
#CB_Prev, #CB_Next {
background: transparent url(pic/blank.gif) no-repeat scroll 0%;
display: block;
width: 49%;
cursor: pointer;
z-index: 1102;
}
.CB_TextNav {
text-decoration: underline;
padding-right: 5px;
color: #999;
cursor: pointer;
border: none;
}
.CB_TextNav:hover {
text-decoration: underline;
color: #555;
border: none;
}
#CB_Prev {
float: left;
left: 0px;
}
#CB_Next {
float: right;
left: 0px;
}
#CB_Prev:hover {
background:transparent;
}
#CB_Next:hover {
background:transparent;
}
#CB_CloseWindow {
position: absolute;
z-index: 1104;
cursor: pointer;
}
#CB_SlideShowS, #CB_SlideShowP {
position: absolute;
left: -27px;
top: -14px;
z-index: 1104;
cursor: pointer;
}
#CB_SlideShowBar {
width: 0px;
position: absolute;
height: 2px;
display: none;
z-index: 1102;
}
#CB_HiddenText, #CB_HiddenTextC {
position: absolute;
visibility: hidden;
z-index: -1000;
top: -100px;
left: -100000px;
}
.CB_PreloadBugFix {
width: 0px;
height: 0px;
z-index: -1000;
visibility: hidden;
position: absolute;
} | 10npsite | trunk/Public/jsLibrary/clearbox/clearbox/config/grow_transparent/cb_style.css | CSS | asf20 | 4,837 |
/*
// ClearBox Config File (JavaScript)
*/
var
// CB layout:
CB_WindowColor='transparent', // color of the CB window (note: you have to change the rounded-corner PNGs too!), transparent is also working
CB_MinWidth=120, // minimum (only at images) or initial width of CB window
CB_MinHeight=120, // initial heigth of CB window
CB_WinPadd=25, // padding of the CB window from sides of the browser
CB_RoundPix=0, // change this setting only if you are generating new PNGs for rounded corners
CB_ImgBorder=0, // border size around the picture in CB window
CB_ImgBorderColor='#ddd', // border color around the picture in CB window
CB_Padd=3, // padding around inside the CB window
CB_BodyMarginLeft=0, //
CB_BodyMarginRight=0, // if you set margin to <body>,
CB_BodyMarginTop=0, // please change these settings!
CB_BodyMarginBottom=0, //
CB_ShowThumbnails='auto', // it tells CB how to show the thumbnails ('auto', 'always' or 'off') thumbnails are only in picture-mode!
CB_ThumbsBGColor='#000', // color of the thumbnail layer
CB_ThumbsBGOpacity=.75, // opacity of the thumbnail layer
CB_ActThumbOpacity=.5, // thumbnail opacity of the current viewed image
CB_SlideShowBarColor='#000', // color of the slideshow bar
CB_SlideShowBarOpacity=.5, // opacity of the slideshow bar
CB_SlideShowBarPadd=2, // padding of the slideshow bar (left and right)
CB_SlideShowBarTop=2, // position of the slideshow bar from the top of the picture
CB_SimpleDesign='off', // if it's 'on', CB doesn't show the frame but only the content - really nice ;)
CB_CloseBtnTop=-14, // vertical position of the close button in picture mode
CB_CloseBtnRight=-27, // horizontal position of the close button in picture mode
CB_CloseBtn2Top=-14, // vertical position of the close button in content mode
CB_CloseBtn2Right=-27, // horizontal position of the close button in content mode
CB_OSD='on', // turns on OSD
// CB font, text and navigation (at the bottom of CB window) settings:
CB_FontT='Verdana', //
CB_FontSizeT=12, // these variables are referring to the title or caption line
CB_FontColorT='#ddd', //
CB_FontWeightT='normal', //
CB_FontC='arial', //
CB_FontSizeC=11, // these variables are referring to
CB_FontColorC='#aaa', // comment lines under the title
CB_FontWeightC='normal', //
CB_TextAlignC='justify', //
CB_TxtHMax=42, // maximum height of the comment box in pixels
CB_FontG='arial', //
CB_FontSizeG=11, // these variables are referring to the gallery name
CB_FontColorG='#777', //
CB_FontWeightG='normal', //
CB_TextH=35, // default height of the text area under the content in CB window (adding a comment will modify this setting), if you change the font sizes, you maybe have to change this setting
CB_PadT=10, // space in pixels between the content and the title or caption line
CB_ShowURL='off', // it shows the url of the content if no title or caption is given
CB_ItemNum='on', // it shows the ordinal number of the content in galleries
CB_ItemNumBracket='()', // whatever you want ;)
CB_ShowGalName='on', // it shows gallery name
CB_TextNav='on', // it shows previous and next navigation
CB_NavTextImgPrvNxt='on', // it shows previous and next buttons instead of text
CB_ShowDL='on', // it shows download controls
CB_NavTextImgDL='on', // it shows download buttons instead of text
CB_ImgRotation='on', // it shows the image rotation controls
CB_NavTextImgRot='on', // it shows the image rotation buttons instead of text
// Settings of the document-hiding layer:
CB_HideColor='#000', // color of the layer
CB_HideOpacity=.9, // opacity (0 is invisible, 1 is 100% color) of the layer
CB_HideOpacitySpeed=400, // speed of fading
CB_CloseOnH='on', // CB will close, if you click on background
// CB animation settings:
CB_Animation='grow', // 'double', 'normal', 'off', 'grow' or 'warp' (high cpu usage)
CB_ImgOpacitySpeed=450, // speed of content fading (in ms)
CB_TextOpacitySpeed=350, // speed of text fading under the picture (in ms)
CB_AnimSpeed=400, // speed of the resizing animation of CB window (in ms)
CB_ImgTextFade='on', // turns on or off the fading of content and text
CB_FlashHide='off', // it hides flash animations on the page before CB starts
CB_SelectsHide='on', // it hides select boxes on the page before CB starts
CB_SlShowTime=7, // default speed of the slideshow (in sec)
CB_Preload='on', // preload neighbour pictures in galleries
// Images using by CB settings:
CB_PictureStart='start.png', //
CB_PicturePause='pause.png', //
CB_PictureClose='close.png', // filenames of some images using by clearbox
CB_PictureNext='next.png', // (there are other images specified in clearbox.css!)
CB_PicturePrev='prev.png', //
// CB professional settings:
CB_PicDir=CB_ScriptDir+'/config/'+CB_Config+'/pic', // CHANGE ONLY IF YOU CHANGED THE DEFAULT DIRECTORY-STRUCTURE OF CB!
CB_AllowedToRun='on', // if 'off', CB won't start (you can change this variable without reload!)
CB_AllowExtFunctLoad='off', // if 'on', CB will run a function named CB_ExternalFunctionLoad(); every time after a new content has loaded (useful for audit, etc)
CB_AllowExtFunctPageLoad='off', // if 'on', CB will run a function named CB_ExternalFunctionPageLoad(); after your page has fully loaded
CB_AllowExtFunctCBClose='off' // if 'on', CB will run a function named CB_ExternalFunctionCBClose(); after CB window has closed
; | 10npsite | trunk/Public/jsLibrary/clearbox/clearbox/config/grow_transparent/cb_config.js | JavaScript | asf20 | 5,740 |
/*
// ClearBox Config File (CSS)
*/
.CB_TextNav, #CB_ShowTh, #CB_Thumbs2, #CB_Thumbs, .CB_RoundPixBugFix, #CB_Padding, #CB_ImgContainer, #CB_PrevNext, #CB_ContentHide, #CB_Text, #CB_Window, #CB_Image, #CB_TopLeft, #CB_Top, #CB_TopRight, #CB_Left, #CB_Content, #CB_Right, #CB_BtmLeft, #CB_Btm, #CB_BtmRight, #CB_Prev, #CB_Prev:hover, #CB_Prev:focus, #CB_Prev:active, #CB_Next, #CB_Next:hover, #CB_Next:focus, #CB_Next:active, #CB_CloseWindow, #CB_SlideShowS, #CB_SlideShowP, #CB_SlideShowBar, #CB_Email, #CB_OSD {
margin: 0;
padding: 0;
background-color: transparent;
border: 0;
outline-style: none;
outline: 0;
}
.absolute {
position: absolute;
}
#CB_NotImgContent {
position: absolute;
width: 0px;
height: 0px;
}
#CB_NotIC, #CB_NotImgContent {
border: none;
outline-style: none;
outline: 0;
}
#CB_Window {
width: 0px;
border-spacing: 0px;
border-width: 0px;
}
.CB_Sep {
color: #bbb;
}
.CB_TnThumbs {
width: 0px;
height: 0px;
border: 0px;
padding: 0;
margin: 0;
visibility: hidden;
}
.CB_BtmNav {
position: relative;
top: 4px;
border: 0;
padding: 0px 0px 0px 3px;
}
#CB_ImgHide {
position: absolute;
visibility: hidden;
z-index: 1098;
left: 0px;
}
#CB_ShowTh {
width: 100%;
height: 20%;
visibility: hidden;
position: absolute;
z-index: 1097;
bottom: 0px;
left: 0px;
}
#CB_Thumbs {
display: none;
height: 62px;
padding-top: 10px;
position: absolute;
z-index: 1100;
overflow: hidden;
bottom: 0px;
left: 0px;
}
#CB_Thumbs2 {
margin: auto 0;
height: 52px;
position: absolute;
}
.CB_ThumbsImg {
position: absolute;
cursor: pointer;
border: 1px solid #eee;
}
#CB_ThumbsActImg {
cursor: default;
border: 1px dotted #fff;
}
.CB_RoundPixBugFix {
display: block;
visibility: hidden;
font-family: arial;
font-size: 1pt;
}
#CB_ImgContainer {
position: relative;
width: 100%;
}
#CB_PrevNext {
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
z-index: 1002;
}
#CB_NavPrev, #CB_NavNext {
visibility: hidden;
position: absolute;
z-index: 1001;
top: 47%;
cursor: pointer;
}
#CB_NavPrev {
left: 18px;
}
#CB_NavNext {
right: 14px;
}
#CB_ContentHide {
position: absolute;
z-index: 1000;
top: 0px;
left: 0px;
}
#CB_OSD {
position: absolute;
left: 50%;
z-index: 5000;
font-family: arial;
font-size: 22px;
color: #fff;
background-color: #000;
visibility: hidden;
}
#CB_Text {
position: relative;
text-align: left;
overflow: hidden;
}
#CB_TT, #CB_TC {
position: relative;
}
#CB_TT, #CB_HiddenText {
white-space: nowrap;
}
#CB_TC {
margin-top: 2px;
overflow-y: auto;
}
#CB_TG {
margin-top: -2px;
}
#CB_Window {
left:50%;
position:absolute;
top:50%;
visibility:hidden;
z-index: 1100;
border-collapse: separate;
}
#CB_Image {
position: relative;
}
#CB_TopLeft {
background-image:url(pic/s_topleft.png);
background-position:right bottom;
}
#CB_Top {
background-image:url(pic/s_top.png);
background-position:left bottom;
}
#CB_TopRight {
background-image:url(pic/s_topright.png);
background-position:left bottom;
}
#CB_Left {
background-image:url(pic/s_left.png);
background-position:right top;
}
#CB_Right {
background-image:url(pic/s_right.png);
background-position:left top;
}
#CB_BtmLeft {
background-image:url(pic/s_btmleft.png);
background-position:right top;
}
#CB_Btm {
background-image:url(pic/s_btm.png);
background-position:left top;
}
#CB_BtmRight {
background-image:url(pic/s_btmright.png);
background-position:left top;
}
#CB_Prev, #CB_Next {
background: transparent url(pic/blank.gif) no-repeat scroll 0%;
display: block;
width: 49%;
cursor: pointer;
z-index: 1102;
}
.CB_TextNav {
text-decoration: underline;
padding-right: 5px;
color: #999;
cursor: pointer;
border: none;
}
.CB_TextNav:hover {
text-decoration: underline;
color: #555;
border: none;
}
#CB_Prev {
float: left;
left: 0px;
}
#CB_Next {
float: right;
left: 0px;
}
#CB_Prev:hover {
background:transparent;
}
#CB_Next:hover {
background:transparent;
}
#CB_CloseWindow {
position: absolute;
z-index: 1104;
cursor: pointer;
}
#CB_SlideShowS, #CB_SlideShowP {
position: absolute;
left: -11px;
top: -10px;
z-index: 1104;
cursor: pointer;
}
#CB_SlideShowBar {
width: 0px;
position: absolute;
height: 2px;
display: none;
z-index: 1102;
}
#CB_HiddenText, #CB_HiddenTextC {
position: absolute;
visibility: hidden;
z-index: -1000;
top: -100px;
left: -100000px;
}
.CB_PreloadBugFix {
width: 0px;
height: 0px;
z-index: -1000;
visibility: hidden;
position: absolute;
} | 10npsite | trunk/Public/jsLibrary/clearbox/clearbox/config/default/cb_style.css | CSS | asf20 | 4,837 |
/*
// ClearBox Config File (JavaScript)
*/
var
// CB layout:
CB_WindowColor='#fff', // color of the CB window (note: you have to change the rounded-corner PNGs too!), transparent is also working
CB_MinWidth=120, // minimum (only at images) or initial width of CB window
CB_MinHeight=120, // initial heigth of CB window
CB_WinPadd=15, // padding of the CB window from sides of the browser
CB_RoundPix=12, // change this setting only if you are generating new PNGs for rounded corners
CB_ImgBorder=0, // border size around the picture in CB window
CB_ImgBorderColor='#ddd', // border color around the picture in CB window
CB_Padd=4, // padding around inside the CB window
CB_BodyMarginLeft=0, //
CB_BodyMarginRight=0, // if you set margin to <body>,
CB_BodyMarginTop=0, // please change these settings!
CB_BodyMarginBottom=0, //
CB_ShowThumbnails='auto', // it tells CB how to show the thumbnails ('auto', 'always' or 'off') thumbnails are only in picture-mode!
CB_ThumbsBGColor='#000', // color of the thumbnail layer
CB_ThumbsBGOpacity=.35, // opacity of the thumbnail layer
CB_ActThumbOpacity=.65, // thumbnail opacity of the current viewed image
CB_SlideShowBarColor='#fff', // color of the slideshow bar
CB_SlideShowBarOpacity=.5, // opacity of the slideshow bar
CB_SlideShowBarPadd=17, // padding of the slideshow bar (left and right)
CB_SlideShowBarTop=2, // position of the slideshow bar from the top of the picture
CB_SimpleDesign='off', // if it's 'on', CB doesn't show the frame but only the content - really nice ;)
CB_CloseBtnTop=-10, // vertical position of the close button in picture mode
CB_CloseBtnRight=-14, // horizontal position of the close button in picture mode
CB_CloseBtn2Top=-20, // vertical position of the close button in content mode
CB_CloseBtn2Right=-30, // horizontal position of the close button in content mode
CB_OSD='on', // turns on OSD
// CB font, text and navigation (at the bottom of CB window) settings:
CB_FontT='Verdana', //
CB_FontSizeT=12, // these variables are referring to the title or caption line
CB_FontColorT='#777', //
CB_FontWeightT='normal', //
CB_FontC='arial', //
CB_FontSizeC=11, // these variables are referring to
CB_FontColorC='#aaa', // comment lines under the title
CB_FontWeightC='normal', //
CB_TextAlignC='justify', //
CB_TxtHMax=42, // maximum height of the comment box in pixels
CB_FontG='arial', //
CB_FontSizeG=11, // these variables are referring to the gallery name
CB_FontColorG='#999', //
CB_FontWeightG='normal', //
CB_TextH=35, // default height of the text area under the content in CB window (adding a comment will modify this setting), if you change the font sizes, you maybe have to change this setting
CB_PadT=10, // space in pixels between the content and the title or caption line
CB_ShowURL='off', // it shows the url of the content if no title or caption is given
CB_ItemNum='on', // it shows the ordinal number of the content in galleries
CB_ItemNumBracket='()', // whatever you want ;)
CB_ShowGalName='on', // it shows gallery name
CB_TextNav='on', // it shows previous and next navigation
CB_NavTextImgPrvNxt='on', // it shows previous and next buttons instead of text
CB_ShowDL='on', // it shows download controls
CB_NavTextImgDL='on', // it shows download buttons instead of text
CB_ImgRotation='on', // it shows the image rotation controls
CB_NavTextImgRot='on', // it shows the image rotation buttons instead of text
// Settings of the document-hiding layer:
CB_HideColor='#000', // color of the layer
CB_HideOpacity=.85, // opacity (0 is invisible, 1 is 100% color) of the layer
CB_HideOpacitySpeed=400, // speed of fading
CB_CloseOnH='on', // CB will close, if you click on background
// CB animation settings:
CB_Animation='double', // 'double', 'normal', 'off', 'grow' or 'warp' (high cpu usage)
CB_ImgOpacitySpeed=450, // speed of content fading (in ms)
CB_TextOpacitySpeed=350, // speed of text fading under the picture (in ms)
CB_AnimSpeed=400, // speed of the resizing animation of CB window (in ms)
CB_ImgTextFade='on', // turns on or off the fading of content and text
CB_FlashHide='off', // it hides flash animations on the page before CB starts
CB_SelectsHide='on', // it hides select boxes on the page before CB starts
CB_SlShowTime=5, // default speed of the slideshow (in sec)
CB_Preload='on', // preload neighbour pictures in galleries
// Images using by CB settings:
CB_PictureStart='start.png', //
CB_PicturePause='pause.png', //
CB_PictureClose='close.png', // filenames of some images using by clearbox
CB_PictureNext='next.png', // (there are other images specified in clearbox.css!)
CB_PicturePrev='prev.png', //
// CB professional settings:
CB_PicDir=CB_ScriptDir+'/config/'+CB_Config+'/pic', // CHANGE ONLY IF YOU CHANGED THE DEFAULT DIRECTORY-STRUCTURE OF CB!
CB_AllowedToRun='on', // if 'off', CB won't start (you can change this variable without reload!)
CB_AllowExtFunctLoad='off', // if 'on', CB will run a function named CB_ExternalFunctionLoad(); every time after a new content has loaded (useful for audit, etc)
CB_AllowExtFunctPageLoad='off', // if 'on', CB will run a function named CB_ExternalFunctionPageLoad(); after your page has fully loaded
CB_AllowExtFunctCBClose='off' // if 'on', CB will run a function named CB_ExternalFunctionCBClose(); after CB window has closed
; | 10npsite | trunk/Public/jsLibrary/clearbox/clearbox/config/default/cb_config.js | JavaScript | asf20 | 5,739 |
//
// ClearBox Language File (JavaScript)
//
var
CB_NavTextPrv='previous', // text of previous image
CB_NavTextNxt='next', // text of next image
CB_NavTextFull='full size', // text of original size (only at pictures)
CB_NavTextOpen='open in new browser window', // text of open in a new browser window
CB_NavTextDL='download', // text of download picture or any other content
CB_NavTextClose='close clearbox', // text of close CB
CB_NavTextStart='start slideshow', // text of start slideshow
CB_NavTextStop='stop slideshow', // text of stop slideshow
CB_NavTextRotR='rotate image right by 90 degrees', // text of rotation right
CB_NavTextRotL='rotate image left by 90 degrees' // text of rotation left
; | 10npsite | trunk/Public/jsLibrary/clearbox/clearbox/language/en/cb_language.js | JavaScript | asf20 | 772 |
//
// ClearBox Language File (JavaScript)
//
var
CB_NavTextPrv='上一张', // text of previous image
CB_NavTextNxt='下一张', // text of next image
CB_NavTextFull='全尺寸', // text of original size (only at pictures)
CB_NavTextOpen='在新的窗口中打开', // text of open in a new browser window
CB_NavTextDL='下载', // text of download picture or any other content
CB_NavTextClose='关闭窗口', // text of close CB
CB_NavTextStart='幻灯片', // text of start slideshow
CB_NavTextStop='停止幻灯片', // text of stop slideshow
CB_NavTextRotR='向右旋转90', // text of rotation right
CB_NavTextRotL='向左旋转90' // text of rotation left
; | 10npsite | trunk/Public/jsLibrary/clearbox/clearbox/language/cn/cb_language.js | JavaScript | asf20 | 732 |
var CB_ScriptDir='/jsLibrary/clearbox/clearbox';
var CB_Language='cn';
//
// ClearBox load:
//
var CB_Scripts = document.getElementsByTagName('script');
for(i=0;i<CB_Scripts.length;i++){
if (CB_Scripts[i].getAttribute('src')){
var q=CB_Scripts[i].getAttribute('src');
if(q.match('clearbox.js')){
var url = q.split('clearbox.js');
var path = url[0];
var query = url[1].substring(1);
var pars = query.split('&');
for(j=0; j<pars.length; j++) {
par = pars[j].split('=');
switch(par[0]) {
case 'config': {
CB_Config = par[1];
break;
}
case 'dir': {
CB_ScriptDir = par[1];
break;
}
case 'lng': {
CB_Language = par[1];
break;
}
}
}
}
}
}
if(!CB_Config){
var CB_Config='default';
}
document.write('<link rel="stylesheet" type="text/css" href="'+CB_ScriptDir+'/config/'+CB_Config+'/cb_style.css" />');
document.write('<script type="text/javascript" src="'+CB_ScriptDir+'/config/'+CB_Config+'/cb_config.js"></script>');
document.write('<script type="text/javascript" src="'+CB_ScriptDir+'/language/'+CB_Language+'/cb_language.js"></script>');
document.write('<script type="text/javascript" src="'+CB_ScriptDir+'/core/cb_core.js"></script>'); | 10npsite | trunk/Public/jsLibrary/clearbox/clearbox.js | JavaScript | asf20 | 1,323 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>kimosft-jscalendar 开发文档</title>
<style type="text/css">
<!--
body {
font-family: "微软雅黑", Tahoma, Verdana;
font-size: 12px;
font-weight: normal;
margin: 50px 10px;
}
span, label, p, input {
font-family: "微软雅黑", Tahoma, Verdana;
font-size: 12px;
font-weight: normal;
}
form {
margin: 0;
padding: 0;
}
ul {
margin: 0;
}
h1 {
font-family: "微软雅黑", Tahoma, Verdana;
font-size: 16px;
font-weight: bold;
}
h2 {
font-family: "微软雅黑", Tahoma, Verdana;
font-size: 14px;
font-weight: bold;
}
div.effect {
border: 1px dotted #3C78B5;
background-color: #D8E4F1;
padding: 10px;
width: 98%;
}
div.source {
border: 1px solid #CCC;/*#090*/
background-color: #F5F5F5;/*#DFD*/
padding: 10px;
width: 98%;
}
.color_red {
color:#FF0000;
}
.b {
font-weight: bold;
}
-->
</style>
</head>
<body>
<script type="text/javascript" src="calendar.js"></script>
<form id="form1" name="form1" method="post" action="">
<h1>1、什么是 kimsoft-jscalendar ?</h1>
<ul>
<li>一个简洁的avaScript日历控件,可在Java Web 项目,.NET Web 项目中使用</li>
</ul>
<h1>2、kimsoft-jscalendar 有什么特点?</h1>
<ul>
<li>1、小巧,单文件 </li>
<li>2、支持多语言,并可自由扩充(目前支持简体中文,繁体中文,英语美国和英语英国)</li>
<li> 3、兼容ie6.0+, firefox1.0+, Opera9,其它浏览器未测试</li>
<li>4、回显选定的时间,这是很多其它日历控件没有的 </li>
<li>5、Apache license 2.0,商业友好。可免费使用,自由修改传播,但请保留版权信息</li>
<li>6、用 iframe 解决 IE 中层在 select 控件上显示的问题</li>
<li>7、其它特点有特发现...</li>
</ul>
<h1>3、版本:</h1>
<ul>
<li>V20080409(制作了此帮助文档) <a href="http://code.google.com/p/kimsoft-jscalendar/downloads/list" target="_blank">下载</a></li>
<li>V20080322(第一次在Google Code上发布)</li>
</ul>
<h1>4、使用说明:</h1>
<h2>4.1、将 js 文件导入到页面中(可以是 html, jsp, asp, aspx, php)等。</h2>
<div class="source"><script type="text/javascript" src="calendar.js"></script></div>
<br />
注意以下点:
<ul>
<li> calendar.js 文件内容编写是UTF-8,请一定要将此文件的编码设置为UTF-8</li>
<li> 上面的代码内容<span class="color_red b">一定要放在HTML的<body></body>之间</span>,特别是在符合XHTML规范的文档中</li>
<li>包含此文件后,此页面已经自动实例化了一个日历对象 calendar,现在就可以使用了</li>
</ul>
<h2>4.2、一个最简单的例子<br />
</h2>
<div class="source">用预定义的 calendar 对象生成日历代码:<input name="date" type="text" id="date" onclick=<strong>"calendar.show(this);</strong>" size="10" maxlength="10" readonly="readonly" /><br />
</div>
<br />
<div class="effect">效果:
<input name="date" type="text" id="date" onclick="calendar.show(this);" size="10" maxlength="10" readonly="readonly" />
</div>
<br />
当然也可以这样:<br />
</p>
<div class="source">new 一个新的日历对象并生成日历代码:<input name="date" type="text" id="date" onclick=<strong>"new Calendar().show(this);</strong>" size="10" maxlength="10" readonly="readonly "/><br />
</div>
<br />
<div class="effect">效果:
<input name="date2" type="text" id="date2" onclick="new Calendar().show(this);" size="10" maxlength="10" readonly="readonly" />
</div>
<br />
<h2>4.3、指定开始年份和结束年份的日历<br />
</h2>
<div class="source"> 指定开始年份和结束年份的日历代码:<input name="range_date" type="text" id="range_date" onclick="new Calendar(2000, 2008).show(this);" size="10" maxlength="10" readonly="readonly" /><br />
</div>
<br />
<div class="effect"> 只能选择 2000 到 2008年间的日期:
<input name="range_date" type="text" id="range_date" onclick="new Calendar(2000, 2008).show(this);" size="10" maxlength="10" readonly="readonly" />
</div>
<h2>4.4、多语言版本支持(可自由扩充),目前支持的语言:0(zh_cn)|1(en_us)|2(en_en)|3(zh_tw)</h2>
<div class="source"> 中文日历代码: <input name="cn_date" type="text" id="cn_date" onclick="new Calendar().show(this);" size="10" maxlength="10" readonly="readonly" /><br />
</div>
<br />
<div class="effect">中文日历效果:
<input name="cn_date" type="text" id="cn_date" onclick="new Calendar().show(this);" size="10" maxlength="10" readonly="readonly"/>
</div>
<br />
<div class="source"> 繁体中文日历代码: <input name="tw_date" type="text" id="tw_date" onclick="new Calendar(null, null, 3).show(this);" size="10" maxlength="10" readonly="readonly" /><br />
</div>
<br />
<div class="effect">繁体中文日历效果:
<input name="tw_date" type="text" id="tw_date" onclick="new Calendar(null, null, 3).show(this);" size="10" maxlength="10" readonly="readonly" />
<br />
</div>
<br />
<div class="source"> 英文日历代码: <input name="en_date" type="text" id="en_date" onclick="new Calendar(null, null, 1).show(this);" size="10" maxlength="10" readonly="readonly" /><br />
</div>
<br />
<div class="effect">英文日历效果:
<input name="en_date" type="text" id="en_date" onclick="new Calendar(null, null, 1).show(this);" size="10" maxlength="10" readonly="readonly" />
</div>
<h2>4.5、在一个控件上点击选择,在另外一个控件上显示日期</h2>
<div class="source"> 代码:<br />
<input name="control_date" type="text" id="control_date"size="10" maxlength="10" readonly="readonly" /><br />
<input type="button" name="button" id="button" value="选择日期" onclick="new Calendar().show(this.form.control_date);" /><br />
</div>
<br />
<div class="effect">效果:
<input name="control_date" type="text" id="control_date"size="10" maxlength="10" readonly="readonly" />
<label>
<input type="button" name="button" id="button" value="选择日期" onclick="new Calendar().show(this.form.control_date);" />
</label>
</div>
<h2>4.6、其它功能</h2>
其它功能请参考 calendar.js 源码,里面有详细的注释,本文档源码也是很好的代码资源,有问题请<a href="http://code.google.com/p/kimsoft-jscalendar/issues/list" target="_blank">提交ISSUES</a><br />
<h1>5、相关资源:</h1>
<ul>
<li>Google Code: <a href="http://code.google.com/p/kimsoft-jscalendar/" target="_blank">http://code.google.com/p/kimsoft-jscalendar/</a></li>
<li>kimsoft's Blog: <a href="http://blog.csdn.net/kimsoft" target="_blank">http://blog.csdn.net/kimsoft</a></li>
<li>kimsoft's Mail: <a href="mailto:jinqinghua@gmail.com">jinqinghua@gmail.com</a></li>
</ul>
<h1>6、License:</h1>
<ul>
<li>基于 Apache license 2.0,商业友好。可免费使用,自由修改传播,但请保留版权信息</li>
</ul>
</form>
</body>
</html>
| 10npsite | trunk/Public/jsLibrary/calendar_help.html | HTML | asf20 | 8,081 |
// JavaScript Document
function show(title,msg)
{
var d_mask=document.getElementById('mask');
var d_dialog =document.getElementById('dialog');
d_mask.style.width = document.body.clientWidth ;
d_mask.style.height=document.body.clientHeight;
d_dialog.style.top = document.body.clientHeight / 2 -260;
d_dialog.style.left =document.body.clientWidth / 2 -100;
var Inner = "<input type='button' value='Close' onclick='DialogClose()'/>"
var info = "<table cellspacing='0' width='100%' height='100%'>"+
"<tr class='dgtitle'><td>"
+title
+"</td><td align='right'><input type='button' value='Close' onclick='DialogClose()'class='formButton'/></td></tr>"
+"<tr><td colspan='2'>"
+msg
+"</td></tr>"
+"<tr class='dgfooter'><td></td><td>"
+"</td></tr>"
+"</table>";
d_dialog.innerHTML =info;
disableSelect()
d_mask.style.visibility='visible';
d_dialog.style.visibility='visible';
}
function Icon_Close_Over(obj)
{
obj.src='close.gif';
}
function Icon_Close_Out(obj)
{
obj.src='close1.gif'
}
function DialogClose()
{
var d_mask=document.getElementById('mask');
var d_dialog = document.getElementById('dialog');
parent.getifheight();//当记录没有时或很少时还原其框架在原来的页面中的高度
enableSelect()
d_mask.style.visibility='hidden';
d_dialog.style.visibility='hidden';
}
function disableSelect()
{
for(i=0;i<document.all.length;i++)
if(document.all(i).tagName=="SELECT")
document.all(i).disabled = true;
}
function enableSelect()
{
for(i=0;i<document.all.length;i++){
if(document.all(i).tagName=="SELECT")
{
document.all(i).disabled = false;
}
}
}
function divBlock_event_mousedown()
{
var e, obj, temp;
obj=document.getElementById('dialog');
e=window.event?window.event:e;
obj.startX=e.clientX-obj.offsetLeft;
obj.startY=e.clientY-obj.offsetTop;
document.onmousemove=document_event_mousemove;
temp=document.attachEvent?document.attachEvent('onmouseup',document_event_mouseup):document.addEventListener('mouseup',document_event_mouseup,'');
}
function document_event_mousemove(e)
{
var e, obj;
obj=document.getElementById('dialog');
e=window.event?window.event:e;
with(obj.style){
position='absolute';
left=e.clientX-obj.startX+'px';
top=e.clientY-obj.startY+'px';
}
}
function document_event_mouseup(e)
{
var temp;
document.onmousemove='';
temp=document.detachEvent?parent.detachEvent('onmouseup',document_event_mouseup):document.removeEventListener('mouseup',document_event_mouseup,'');
}
window.onresize = function()
{
var d_mask=document.getElementById('mask');
var d_dialog = document.getElementById('dialog');
d_mask.style.width = document.body.clientWidth ;
d_mask.style.height=document.body.clientHeight;
}
| 10npsite | trunk/Public/jsLibrary/jsAlert.js | JavaScript | asf20 | 3,252 |
/*
clearbox by pyro
script home: http://www.clearbox.hu
email: clearboxjs(at)gmail(dot)com
MSN: pyro(at)radiomax(dot)hu
support forum 1: http://www.sg.hu/listazas.php3?id=1172325655
*/
var CB_ScriptDir='/jsLibrary/clearbox';
var CB_Language='cn';
//
// ClearBox load:
//
var CB_Scripts = document.getElementsByTagName('script');
for(i=0;i<CB_Scripts.length;i++){
if (CB_Scripts[i].getAttribute('src')){
var q=CB_Scripts[i].getAttribute('src');
if(q.match('clearbox.js')){
var url = q.split('clearbox.js');
var path = url[0];
var query = url[1].substring(1);
var pars = query.split('&');
for(j=0; j<pars.length; j++) {
par = pars[j].split('=');
switch(par[0]) {
case 'config': {
CB_Config = par[1];
break;
}
case 'dir': {
CB_ScriptDir = par[1];
break;
}
case 'lng': {
CB_Language = par[1];
break;
}
}
}
}
}
}
if(!CB_Config){
var CB_Config='default';
}
document.write('<link rel="stylesheet" type="text/css" href="'+CB_ScriptDir+'/config/'+CB_Config+'/cb_style.css" />');
document.write('<script type="text/javascript" src="'+CB_ScriptDir+'/config/'+CB_Config+'/cb_config.js"></script>');
document.write('<script type="text/javascript" src="'+CB_ScriptDir+'/language/'+CB_Language+'/cb_language.js"></script>');
document.write('<script type="text/javascript" src="'+CB_ScriptDir+'/core/cb_core.js"></script>'); | 10npsite | trunk/Public/jsLibrary/clearbox.js | JavaScript | asf20 | 1,701 |
@charset "utf-8";
/* CSS Document */
body{
margin:0 auto;
padding:0;
font-size:12px;
font-family:"宋体";
}
ul,li{list-style:none; float:left; margin:0; padding:0;}
p{margin:0; padding:0;}
i{font-style:normal;}
a{text-decoration:none; cursor:pointer; outline:none;}
img{border:none;}
span{float:left;}
.f{float:left;}
.f1{float:right;}
.clear{clear:both;}
.ml20{margin-left:20px;}
.yellow{color:#ffa800;}
.q_blue{color:#37d0d0;}
.gray{color:#7b7b7b;}
.dark_gray{color:#525252;}
.bg_gray1{background:#f6f6f6;}
.bg_q_yellow{background:#fff7c8;}
.bg_q_blue{background:#e4f4ff;}
.black{color:#000;}
.blue{color:#01507b;}
.blue1{color:#07bcbc;}
.blue2{color:#00AAF9;}
.green{color:#8ec53f;}
.dark_green{color:#21A656;}
.white{color:#fff;}
.zs{color:#c97120;}
.red{color:#FE7701;}
.dark_red{color:#fe0000;}
.underline{text-decoration:underline;}
.bold{font-weight:bold;}
.mt5{margin-top:5px;}
.mt10{margin-top:10px;}
.mt15{margin-top:15px;}
.font12{font-size:12px;}
.font14{font-size:14px;}
.font16{font-size:16px;}
.font18{font-size:18px;}
.font24{font-size:24px;}
.font36{font-size:36px;}
.font30{font-size:30px;}
.ari{font-family:Arial, Helvetica, sans-serif;}
/*for top*/
.header { width:100%; background:#f4f4f4; border-bottom:1px solid #e2e2e2; height:30px; overflow:hidden; line-height:30px; }
.head {width:1000px; margin:0 auto; color:#7b7b7b; font-size:14px; overflow:hidden; }
.head_left {width:579px; float:left; margin-left:6px; _margin-left:3px; }
.head a {color:#7b7b7b; }
.head_right { float:left; width:415px; }
.head_right li { float:left; margin-left:15px; }
.more { float:left; }
.more a { background:url(../images/tb.png) no-repeat; background-position:33px -210px; padding-right:12px; }
.more_xl { width:80px; background:#f4f4f4; overflow:hidden; border:1px solid #e2e2e2; border-top-width:0px; display:block; }
.more_xl a { width:80px; height:32px; text-align:center; line-height:32px; display:block; overflow:hidden; }
.more_xl a:hover { background:#37d0d0; color:#fff; }
.user_tx{
float:left;
width:100%;
height:30px;
line-height:30px;
overflow:hidden;
}
.user_tx a{
float:left;
}
/*for menu*/
.menu { width:1000px; margin:0 auto; height:73px; overflow:hidden;}
.logo { float:left; width:356px; height:44px; margin-top:14px; }
.logo ul { float:left; margin:0; padding:0; }
.logo ul li { float:left; width:100%; }
.logo .city { float:right; width:102px; margin-left:24px; color:#828282; font-weight:bold; font-size:14px; margin-top:5px; line-height:20px; }
.logo .city a { color:#828282; font-weight:normal; font-size:12px;border:1px solid #fff; background:white;position:relative; z-index:1; display:block; width:70px; height:20px; text-align:center; }
.logo .city a.hover {border:1px solid #FF9900;border-bottom:none;}
ul.from_dest {padding:10px;margin:-2px 0px 0px 0px;width:400px;background:white;border:1px solid #FF9900;display:none;z-index:0; position:relative;}
ul.from_dest li {float:left;width:auto;text-align:center;}
ul.from_dest li a {color:#828282;}
ul.from_dest li a:hover{color:#FF6600;}
/*主菜单*/
.nav { float:left; width:383px; font-size:14px; height:73px; line-height:73px; overflow:hidden;}
.nav a { color:#585858; margin-right:39px; background:url(../images/xl_bg.jpg) no-repeat right; padding-right:13px; }
.nav .index { background:none; padding:0; }
.nav .xl {
width:110px;
*margin-left:-20px;
/*position:absolute;*/
width:110px;
background:#fff;
overflow:hidden;
/*margin:30px 0px 0px -35px;
*margin:0px 0px 0px -20px;*/
}
.nav .xl a { width:110px; height:32px; text-align:center; line-height:32px; display:block; overflow:hidden; }
.nav .xl a:hover { /*background:url(../images/hover_bg.jpg) no-repeat;*/ background:#36D0CE; color:#fff; }
.yd { float:right;height:73px; }
.tel { float:left; width:110px; overflow:hidden; }
.tel li { width:100%; float:left; }
.tel_title { background:url(../images/tb.png) no-repeat; background-position:left -151px; padding-left:20px; color:#7b7b7b; font-size:14px; font-weight:bold; margin-top:18px; }
.telphone { font-size:18px; font-family:Arial, Helvetica, sans-serif; line-height:25px; }
.telphone span { float:left; }
/*登录框*/
.login_box {float:right;height:61px;white-space:nowrap;overflow: hidden;}
.login_box .login_info {padding-top:10px;}
.login_box .login_info .login_thumb {float: left;margin: 6px 6px 0 0;padding: 3px 0 0 3px;width: 24px;height: 24px;background: url(image/thumb20bg.gif) no-repeat;display: block;}
.login_box .login_info .login_thumb img {width: 20px;height: 20px;}
.login_box .login_info .loginName {color:#38CFD0;font-weight:bold;}
.login_box .login_menu {margin:24px 0px 0px 0px; padding:0;}
.login_box .login_menu li {float:left;margin-right:10px;}
.login_box .login_menu li a {color:#7D7D7D;}
.yh { float:right; height:73px; }
.yh li { float:left; margin-top:8px; }
.yh span { margin-right:10px; }
.yh img { margin-right:10px; height:30px; width:30px;}
.yh a { color:#616060; }
/*for search*/
.search { width:100%; background:url(../images/nav_bg.jpg) repeat-x; height:42px; }
.search_content { width:1000px; margin:0 auto; height:42px; overflow:hidden; }
.search ul { width:100%; overflow:hidden; height:42px; float:left; margin:0; padding:0; }
.search li { float:left; height:42px; line-height:42px; }
.bq { float:left; width:359px; overflow:hidden; }
.bq input { background:url(../images/input_bg.jpg) no-repeat; border:none; height:33px; width:232px; color:#a1a1a1; text-indent:1em; float:left; margin-top:5px; line-height:33px; overflow:hidden; }
.search_chose { width:42px; border:1px solid #62b40f; background:#f1ffe5; height:auto; margin-top:5px; overflow:hidden; float:left; *margin-left:-2px;
_margin-left:-15px; }
.search_chose a { float:left; display:block; width:42px; height:31px; text-align:center; line-height:31px; }
.chose_xl { width:42px; background:#f1ffe5; overflow:hidden; border:1px solid #62b40f; border-top-width:0px; display:block; }
.chose_xl a { width:42px; height:23px; text-align:center; line-height:23px; display:block; overflow:hidden; color:#4e4e4e; }
.chose_xl a:hover { background:#62b40f; color:#fff; }
.button input { float:left; background:url(../images/search_button.jpg) no-repeat; width:81px; height:33px; display:block; cursor:pointer; }
.rm { margin-left:13px; color:#585858; }
.rm a { float:left; color:#fff; margin-left:7px; }
.search_content .gwc { float:right; background:url(../images/gwc.jpg) no-repeat; width:105px; height:26px; line-height:30px; margin-top:10px; padding-left:31px; }
.content { width:1000px; margin:0 auto; }
/*for rmxl*/
.rmxl { margin-top:3px; border:1px solid #dbdbdb; width:974px; float:left; font-size:14px; line-height:33px; color:#5a5a5a; padding:0px 12px 0px 12px; overflow:hidden; }
.rmxl a {float:left; color:#5a5a5a; margin-left:20px; }
/*for banner*/
.banner {width:1000px; float:left; margin-top:5px; height:241px; overflow:hidden; }
.rm_mdd {float:left; width:138px; overflow:hidden; }
.mdd_title {background:url(../images/rm_top.jpg) no-repeat; height:36px; color:#fff; width:138px; line-height:36px; text-align:center; font-size:14px; font-weight:bold; overflow:hidden; }
.mdd_xl {float:left; background:url(../images/rm_center.jpg) repeat-y; width:124px; padding:0px 10px 0px 4px; overflow:hidden; height:200px; }
.mdd_left {float:left; width:134px; padding:0px 0px 0px 4px; background:url(../images/rm_center.jpg) repeat-y; height:200px; overflow:hidden; }
.bk {float:left; height:200px; width:134px; line-height:26px; }
.bk ul {float:left; text-align:left; width:134px; margin:0; padding:0; }
.bk ul li {float:left; width:134px; overflow:hidden; }
.bk ul li span {float:left; width:134px; }
.main .gray { }
.mdd_left .active_cat {cursor:pointer; color:#7b7b7b; }
.bk ul li span a {color:#7b7b7b; }
.mdd_xl li {background:url(../images/tb.png) no-repeat; background-position:100px -230px; padding:0px 10px 0px 10px; font-size:14px; font-weight:bold; overflow:hidden; width:109px; height:27px; line-height:27px; }
.bk ul li .main_bt { width:118px; padding:0 5px 0px 5px; overflow:hidden; border-color:#fff; border-width:1px 0px 1px 1px; border-style:solid; position:relative; z-index:1; }
.bk ul li .main_bt h3 {font-size:14px; font-weight:bold; margin:0; padding:0; }
.bk ul li .main_bt a {float:left; }
.bk ul li em {font-style:normal; color:#ffa800; float:right; font-weight:normal; }
.main .h3_cat {display:none; position:absolute; margin-left:129px; *margin-left:-1px;border:1px solid #FF9933; top:189px; z-index:1; min-height:233px; background:#fff; height:auto !important; height:233px; overflow:visible; }
.main .shadow {float:left; background:#fff; width:837px; display:block; border-left-width:1px; padding:5px 0px 10px 28px; }
.mdd_left .bk .shadow ul .rm_title {float:left; width:90px; margin-right:10px; }
.mdd_left .bk .shadow ul li {background:url(../images/tcc_sj.gif) no-repeat center left; float:left; width:730px; }
.mdd_left .bk .shadow ul li span {float:left; width:auto; margin-right:12px; }
.mdd_left .bk .shadow ul {padding:0; width:100%; border:none; float:left; line-height:27px; margin-top:5px; }
.mdd_left .shadow ul li a {padding:0; color:#7b7b7b; font-size:14px; float:left; }
.main .active_cat h3 span {display:none; }
.main .active_cat .main_bt {
width:119px;
background:#fff;
z-index:5000;
border-top-width: 1px;
border-right-width: 0px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #FF9933;
border-right-color: #FF9933;
border-bottom-color: #FF9933;
border-left-color: #FF9933;
}
.main .active_cat .h3_cat { display:block; }
.main .active_cat em { display:none; }
.rm_bottom { width:138px; background:url(../images/rm_bottom.jpg) no-repeat; height:5px; float:left; }
/*for left_banner*/
.left_banner { float:left; margin-left:5px; width:170px; height:241px; overflow:hidden; }
.left_banner li { float:left; }
.center_banner { float:left; width:506px; margin-left:5px; overflow:hidden; }
/*for content_main*/
.content_main { float:left; width:1000px; overflow:hidden; margin:10px 0px 20px 0px; }
/*for main_left*/
.main_left { float:left; width:176px; overflow:hidden; margin-right:15px; }
/*jr*/
.jr { float:left; width:170px; height:147px; padding:2px; border:1px solid #ffe091; overflow:hidden; }
.jr ul { float:left; width:170px; height:147px; background:#fff7d3; margin:0; padding:0; line-height:20px; }
.jr li { float:left; width:164px; margin-top:5px; padding-left:6px; }
.jr li img { float:left; }
.jr li span { float:left; margin-left:10px; color:#505050; font-size:14px; }
/*for tj*/
.tj {
width:176px;
float:left;
overflow:hidden;
margin-top:10px;
}
.tj_title{
float:left;
height:45px;
width:176px;
overflow:hidden;
}
.tj_nr{
float:left;
width:174px;
border:1px solid #ffdf7e;
overflow:hidden;
}
.fn {
float:left;
width:174px;
border-top:1px solid #ffdf7e;
margin-top:-1px;
overflow:hidden;
}
.fn ul{
float:left;
width:174px;
margin:0;
padding:0;
}
.fn .fn_title{
font-weight:bold;
color:#505050;
font-size:14px;
width:155px;
background:#fff7d3;
height:34px;
line-height:34px;
padding-left:17px;
margin:1px;
}
.pink{
background:#fffcf0;
}
.fn ul li{
float:left;
width:157px;
font-size:12px;
line-height:34px;
padding-left:17px;
overflow:hidden;
}
.fn ul li a{
color:#505050;
display:block;
width:65px;
float:left;
overflow:hidden;
text-align:left;
margin-right:8px;
}
/*for why*/
.why{
float:left;
width:174px;
border:1px solid #ddd;
margin-top:8px;
overflow:hidden;
background:#fbfbfb;
}
.b1{
float:left;
width:100%;
border-top:1px solid #ddd;
margin-top:-1px;
}
.b1 .b1_title{
padding:0;
border:none;
width:100%;
height:38px;
overflow:hidden;
position:relative;
margin:1px 0px 0px 0px;
z-index:1;
}
.b1 ul{
float:left;
width:154px;
border-top:1px dashed #ddd;
margin:0px 4px 0px 4px;
_margin:0px 2px 0px 2px;
padding:0px 0px 0px 12px;
height:39px;
line-height:39px;
color:#646464;
font-size:13px;
font-weight:bold;
margin-top:-1px;
}
/*for main_center*/
.xl_img{
float:left;
width:79px;
height:46px;
}
.main_center{
float:left;
width:523px;
overflow:hidden;
}
.con{
font-size:12px;
margin: 0px;
width:523px;
overflow:hidden;
}
.tags{
margin:0;
height:47px;
width:512px;
background:#ffe7a5;
background:url(../images/xlbg.jpg) repeat-x;
padding-left:12px;
}
.tags li {
float:left;
list-style:none;
height:37px;
margin:10px 22px 0px 0px;
}
.tags li a {
font-size:14px;
font-weight:bold;
float: left;
color:#e99a00;
line-height:37px;
height:37px;
cursor:pointer;
}
.tags li.selectTag {
background:url(../images/xx_hover.jpg) left top no-repeat;
padding-left:25px;
}
.tags li.selectTag a {
background:url(../images/xx_hover.jpg) right top no-repeat;
padding-right:25px;
color: #ffa800;
}
.tagContent_main {
float:left;
width:524px;
overflow:hidden;
}
.fn_next{
float:left;
width:507px;
height:30px;
border-left:1px solid #d3d3d3;
border-right:1px solid #d3d3d3;
border-bottom:1px solid #d3d3d3;
background:url(../images/fn_bg.jpg);
line-height:35px;
padding-left:14px;
font-size:12px;
overflow:hidden;
}
.fn_next li{
float:left;
}
.fn_next .rm_gjc a{
color:#5a5a5a;
cursor:pointer;
margin-right:20px;
float:left;
}
.tagContent{
float:left;
width:524px;
overflow:hidden;
margin-top:5px;
}
.tagContent ul{
margin:0;
padding:8px 0px 13px 0px;
border-bottom:1px dashed #e5e5e5;
width:100%;
overflow:hidden;
background:#fff;
height:46px;
overflow:hidden;
}
.tagContent .bg_gray{
background:#f6fff4;
cursor:pointer;
}
.tagContent li{
float:left;
margin:0;
padding:0;
}
.tagContent .w357{
width:367px;
height:46px;
float:left;
margin-left:11px;
text-align:left;
line-height:20px;
overflow:hidden;
}
.tagContent li p { font-size:14px; font-weight:bold; padding:0; margin:0; width:357px; height:20px; overflow:hidden;float:left; }
.tagContent li p .xl_sm{ max-width:280px;_width:expression(document.body.clientWidth > 280? "280px" : "auto"); overflow:hidden;}
.tagContent li p .green{
color:#8ec53f;
font-size:14px;
}
.tagContent li p span{
float:left;
}
.tagContent li p .red{
color:#fe7701;
margin-left:13px;
}
.tagContent .w357 .font12{
font-size:12px;
font-weight:normal;
clear:both;
line-height:25px;
color:#d48d01;
margin-top:7px;
height:25px;
overflow:hidden;
}
.tagContent .w357 .font12 span{
margin-right:12px;
}
.tagContent .w357 .font12 a{
color:#d48c00;
}
.tagContent .hy{
display:block;
width:62px;
height:45px;
float:right;
margin-right:5px;
background:url(../images/tb.png) no-repeat;
background-position:0px -502px;
text-align:center;
line-height:35px;
font-size:14px;
font-weight:bold;
}
.tagContent .hy a{
color:#fff;
}
.Content1{
float:left;
width:524px;
display:block;
}
.Content2{
float:left;
width:524px;
display:none;
}
.Content3{
float:left;
width:524px;
display:none;
}
.Content4{
float:left;
width:524px;
display:none;
}
.Content5{
float:left;
width:524px;
display:none;
}
.Content6{
float:left;
width:524px;
display:none;
}
/*for right*/
.right{
float:right;
width:269px;
}
.right ul{
float:left;
width:100%;
margin:0;
padding:0;
}
.right ul li{
float:left;
}
.right .right_title{
border-bottom:1px dashed #dbdbdb;
padding-bottom:4px;
float:left;
margin:0px;
}
.right .right_title .left_title{
font-family:"微软雅黑", "宋体";
font-size:24px;
color:#888;
}
.right .dp{
float:left;
width:269px;
margin-top:20px;
}
.right .myd{
background:#fff6de;
width:240px;
height:47px;
line-height:47px;
padding:0px 15px 0px 14px;
float:left;
}
.right .myd .green{
font-size:14px;
font-weight:bold;
color:#70bf0a;
}
.right .myd .yellow{
font-family:Arial, Helvetica, sans-serif;
font-size:30px;
font-weight:bold;
float:right;
}
.right .dp_nr{
width:269px;
margin-top:13px;
}
.right .dp_nr li{
float:left;
width:100%;
margin-top:4px;
height:16px;
overflow:hidden;
line-height:16px;
}
.right .dp_nr li span{
float:left;
}
.right .dp_nr li span a{
float:left;
margin-left:10px;
color:#8c8c8c;
}
.right .dp_nr li .pf{
margin-left:10px;
color:#ffa800;
font-weight:bold;
height:16px;
line-height:16px;
}
.right .dp_nr li .pf img{
float:left;
margin-right:5px;
}
.right .jfph{
float:left;
width:269px;
margin-top:30px;
}
.right .jfph_nr{
width:269px;
margin-top:13px;
}
.right .jfph_nr li{
float:left;
width:100%;
margin-top:4px;
height:16px;
overflow:hidden;
line-height:16px;
}
.right .jfph_nr li img{
width:18px;
height:18px;
float:left;
}
.right .jfph_nr li span{
float:left;
}
.right .jfph_nr li span a{
float:left;
margin-left:10px;
color:#8c8c8c;
}
.right .jf{
float:right;
height:26px;
}
.right .jf a{
font-size:14px;
color:#545454;
margin-top:14px;
display:block;
}
.right .mxt{
float:left;
width:269px;
margin-top:30px;
}
.right .mxt .jrmx{
float:left;
margin:8px 0 0 8px;
font-family:"微软雅黑", "宋体";
}
.right .mxt .jrmx span{
float:left;
}
.right .mxt .mxt_nr{
float:left;
margin-top:5px;
width:269px;
}
.right .mxt .mxt_nr p{
float:left;
margin:0;
padding:0;
}
.right .mxt .mxt_nr p span{
float:left;
}
.right .mxt .mxt_nr .mxt_nr_right{
float:right;
margin:7px 0 0 8px;
width:104px;
}
.right .mxt .mxt_nr .mxt_nr_right span{
float:left;
width:100%;
text-align:left;
line-height:19px;
font-size:14px;
}
.right .drxl{
float:left;
margin-top:30px;
}
.right ul { float:left; width:269px; }
.right .drxl .fl_nr li { float:left; margin-top:9px; font-size:14px; width:100%; height:27px; _overflow:hidden; _height:30px; line-height:25px; _line-height:27px; _margin-top:2px; }
.right .drxl .fl_nr li span { float:left; }
.right .drxl .fl_nr li a { float:left; color:#000; margin:10px 0 0 11px; display:block; }
.right .phb { float:left; margin-top:35px; clear: both; }
.right .phb .fl_nr { padding:0px; float:left; }
.right .phb .fl_nr span { margin:10px 6px 0px 7px; padding:0; float:left;}
.right .phb .fl_nr span a{
float:left;
}
.right .phb .fl_nr span a img{width:40px; height:40px;}
.right .phb .fl_nr .left_w7{
margin-left:7px;
}
.right .yjgl{
float:left;
margin-top:28px;
width:100%;
}
.right .yjgl li{
margin-top:10px;
}
.right .yjgl .fl_nr li{
width:100%;
float:left;
}
.right .yjgl .fl_nr li span{
float:left;
}
.right .yjgl .yjgl_nr{
float:left;
margin-top:5px;
width:269px;
}
.right .yjgl .yjgl_nr p{
float:left;
margin:0;
padding:0;
}
.right .yjgl .yjgl_nr p span{
float:left;
}
.right .yjgl .yjgl_nr .yjgl_nr_right{
float:left;
margin:0 0 0 12px;
width:146px;
overflow:hidden;
height:68px;
}
.right .yjgl .yjgl_nr .yjgl_nr_right span{
float:left;
width:146px;
text-align:left;
line-height:16px;
height:16px;
overflow:hidden;
margin-top:5px;
}
.right .yjgl .yjgl_nr .yjgl_nr_right span a{
font-size:14px;
}
.right .yjgl .yjgl_nr .yjgl_nr_right .yj_ly a{
font-size:12px;
float:left;
display:block;
height:16px;
overflow:hidden;
}
.right .yjgl .yjgl_nr .yjgl_nr_right .yj_ly img{
margin-right:5px;
float:left;
}
.right .yjgl .fl_nr .yj_lb{
float:left;
height:16px;
line-height:16px;
}
.right .yjgl .fl_nr .yj_lb span{
float:left;
height:16px;
line-height:16px;
overflow:hidden;
}
.right .yjgl .fl_nr .yj_lb span a{
display:block;
height:16px;
line-height:18px;
overflow:hidden;
margin-left:5px;
color:#7a7a7a;
float:left;
}
.right .yjgl .fl_nr .yj_lb img{
margin:0;
}
.lyww{
float:left;
margin-top:30px;
width:269px;
}
.ly_nr{
width:100%;
float:left;
}
.ly_nr img{
float:left;
}
.ly_nr li{
margin-top:10px;
height:16px;
overflow:hidden;
line-height:16px;
width:100%;
}
.ly_nr li span{
float:left;
}
.ly_nr li span a{
float:left;
margin-left:10px;
color:#7A7A7A;
}
.ly_nr li .answer{
float:right;
background:url(../images/tb.png) no-repeat;
}
.ly_nr li .answer a{
color:#fff;
margin:0;
width:44px;
height:16px;
text-align:center;
}
.ly_nr li .answer1{
background-position:0px -318px;
}
.ly_nr li .answer2{
background-position:-57px -334px;
}
/*for footer*/
.bottom{
width:1000px;
margin:0 auto;
}
.footer{
float:left;
width:1000px;
margin-top:34px;
}
.help{
float:left;
width:995px;
border:1px solid #ffe9b8;
border-right-width:0px;
overflow:hidden;
margin:0px 2px 0px 2px;
}
.help ul{
float:left;
border-right:1px solid #ffe9b8;
width:198px;
height:134px;
padding:0;
margin:0;
overflow:hidden;
}
.help ul li{
width:183px;
float:left;
padding-left:15px;
line-height:20px;
font-size:13px;
}
.help ul li a{
color:#5e5e5e;
}
.help ul .help_title{
height:34px;
width:181px;
margin:1px 1px 11px 1px;
background:#fff4da;
line-height:34px;
padding-left:15px;
color:#5e5e5e;
font-weight:bold;
font-size:13px;
}
.friend{
float:left;
width:1000px;
border-bottom:1px solid #eaeae5;
padding-bottom:14px;
margin-bottom:12px;
overflow:hidden;
}
.friend ul{
float:left;
width:954px;
padding:0px 23px 0px 13px;
margin:5px 0px 0px 0px;
font-size:13px;
line-height:22px;
}
.friend ul li{
float:left;
}
.friend ul li img{
float:left;
}
.friend ul .sj{
width:880px;
overflow:hidden;
margin:0;
}
.friend ul li a{
float:left;
color:#767676;
margin-left:14px;
}
.friend .ks{
width:975px;
height:16px;
float:left;
text-align:center;
margin-top:15px;
padding-left:25px;
}
.friend .ks li{
float:left;
border-right:1px solid #767676;
padding-right:20px;
height:16px;
line-height:16px;
margin-left:20px;
}
.friend .ks li a{
margin:0;
padding:0;
float:left;
font-weight:bold;
}
.bqxx{
width:995px;
float:left;
color:#8c8c8c;
font-size:13px;
padding:0px 0px 30px 0px;
margin:0;
}
.bqxx li{
float:left;
}
/*for wz*/
.wz{
float:left;
margin-top:18px;
width:100%;
border-bottom:1px dashed #dbdbdb;
padding-bottom:8px;
}
.wz ul{
float:left;
margin:0;
padding:0;
color:#505050;
}
.wz ul li{
float:left;
}
.wz ul li span{
margin-left:10px;
}
.wz ul li a{
color:#505050;
}
.wz .fx{
float:right;
}
.wz .fx li a{
color:#00aaf9;
font-weight:bold;
}
.wz .fx li span{
color:#00aaf9;
font-weight:bold;
}
/*-------------------------------------------------------------------*/
/*for 商品详情*/
/*for product*/
.product{
float:left;
width:1000px;
margin-top:24px;
}
.product ul{
float:left;
margin:0;
padding:0;
width:1000px;
overflow:hidden;
}
.product ul li{
float:left;
font-family:"微软雅黑", "宋体";
font-size:18px;
color:#4e9700;
width:100%;
}
.product ul li span{
float:left;
margin:0;
padding:0;
}
.main_title{
font-family:"微软雅黑", "宋体";
font-size:24px;
color:#4e9700;
}
.product ul .xqjs{
font-family:"宋体";
margin-top:10px;
color:#3c3c3c;
font-size:13px;
}
.product ul .xqjs span{
float:left;
margin-right:15px;
}
.product ul .xqjs span a{
float:left;
}
/*for spxq*/
.spxq{
float:left;
width:1000px;
margin-top:23px;
}
.xc{
float:left;
width:369px;
}
.xc .dt{
float:left;
width:100%;
}
.xc .xt{
float:left;
width:100%;
margin-top:6px;
}
.xc .xt li{
float:left;
margin-right:2px;
}
.xc .xt li span{
float:left;
margin-right:6px;
}
.xc_an{
float:left;
}
.xc_an a{
width:13px;
float:left;
height:34px;
background:#ffeecd;
color:#4e4e4e;
text-align:center;
line-height:34px;
}
/*for kj*/
.kj{
float:left;
width:331px;
border:1px solid #bbd997;
border-radius:4px;
margin-top:14px;
padding:13px 18px 13px 18px;
overflow:hidden;
}
.kj li{
float:left;
width:331px;
}
.kj li span{
float:left;
width:331px;
line-height:25px;
}
.kj li span a{
color:#00aaf9;
}
.kj_title{
font-family:"微软雅黑", "宋体";
font-size:18px;
color:#46a600;
background:url(../images/kj_bz.jpg) no-repeat;
padding-left:30px;
padding-bottom:10px;
}
/*for xq_right*/
.xq_right{
float:right;
width:610px;
overflow:hidden;
}
.xq_right ul{
float:left;
margin:0;
padding:0;
width:610px;
}
.xq_right ul li{
float:left;
}
.xq_right ul li span{
float:none;
margin:0;
padding:0;
}
.jg{
font-size:24px;
color:#ff9600;
font-weight:bold;
font-family:Arial, Helvetica, sans-serif;
}
.xq_right ul .zxzx{
float:right;
background:url(../images/zx.jpg) no-repeat;
padding-left:21px;
height:17px;
line-height:17px;
margin-top:12px;
}
.xq_right ul .zxzx a{
color:#67abf9;
font-size:14px;
font-weight:bold;
}
.xq_right .yhhd{
float:left;
margin-top:16px;
width:610px;
*margin-top:19px;
}
.yh_left{
width:290px;
background:#fff4fa;
border-radius:3px;
padding:10px 14px 14px 14px;
overflow:hidden;
}
.xq_right ul .yh_left span{
float:left;
width:290px;
}
.xq_right ul .yh_left .yh_nr{
float:left;
margin-top:10px;
color:#4e4e4e;
line-height:25px;
}
.xq_right ul .yh_left .yh_nr2{
float:left;
margin-top:10px;
color:#4e4e4e;
}
.yh_title{
float:left;
color:#4e4e4e;
font-size:14px;
font-weight:bold;
}
.xq_right ul .yh_left .yh_nr2 i{
float:left;
padding:0;
margin:0px 4px 0px 0px;
letter-spacing:3px;
}
.xq_right ul .yh_right{
width:250px;
background:#f4fdff;
border-radius:3px;
padding:10px 14px 14px 14px;
float:right;
overflow:hidden;
}
.xq_right ul .yh_right span{
float:left;
width:250px;
overflow:hidden;
}
.xq_right ul .yh_right .yh_right_nr{
float:left;
margin-top:10px;
}
.xq_right ul .yh_right .yh_right_nr i{
float:left;
color:#67abf9;
font-weight:bold;
margin-right:15px;
line-height:25px;
padding:0;
}
/*for chose_time*/
.xq_right .chose_time{
float:left;
width:600px;
background:url(../images/xq_bg.jpg) repeat-x;
margin-top:10px;
border:1px solid #ffcf71;
border-radius:3px;
height:242px;
overflow:hidden;
padding:6px 4px 15px 4px;
}
.xq_right .chose_time li{
float:left;
width:600px;
}
.xq_right ul li .num{
float:left;
width:26px;
height:26px;
line-height:26px;
text-align:center;
font-size:14px;
font-weight:bold;
background:url(../images/tb.png) no-repeat;
background-position:-94px -218px;
color:#fff;
margin-left:3px;
}
.xq_right ul li .sjd{
float:left;
height:26px;
line-height:26px;
font-size:14px;
font-weight:bold;
margin-left:7px;
}
.xq_right .chose_time .xz_sj{
float:left;
width:574px;
margin-top:12px;
height:83px;
border:1px solid #ffce71;
background:#fff;
padding:8px 12px 8px 12px;
}
.xq_right .chose_time .xz_sj span a{
float:left;
color:#505050;
font-size:14px;
font-weight:bold;
background:url(../images/sjd_bg.jpg) right center no-repeat;
padding-right:15px;
}
.xq_right .chose_time .people_num{
float:left;
margin-top:21px;
}
.xq_right ul li .rs_chose{
float:left;
height:28px;
line-height:28px;
font-size:14px;
font-weight:bold;
margin-left:7px;
width:57px;
border:1px solid #a7a6ac;
background:#fff;
text-indent:4px;
}
.xq_right ul li .up{
float:left;
margin-left:3px;
width:18px;
overflow:hidden;
margin-top:-2px;
}
.xq_right ul li .up a{
float:left;
margin-top:2px;
}
.xq_right .chose_time .chose_button{
float:left;
margin-top:14px;
}
.xq_right .chose_time .chose_button span{
float:left;
margin-right:10px;
}
.xq_right .chose_time .chose_button .ljyd{
display:block;
background:url(../images/tb.png) no-repeat;
background-position:0px -599px;
width:173px;
height:40px;
text-align:center;
line-height:40px;
color:#fff;
font-size:18px;
font-weight:bold;
}
.xq_right .chose_time .chose_button .add_gw{
display:block;
background:url(../images/tb.png) no-repeat;
background-position:0px -842px;
width:133px;
height:40px;
text-align:center;
line-height:40px;
color:#fff;
font-size:18px;
font-weight:bold;
padding-left:40px;
}
.xq_right .chose_time .chose_button .ydsm{
float:left;
width:220px;
margin:0px 0px 0px 10px;
line-height:20px;
color:#4e4e4e;
}
.xq_right .chose_time .chose_button .ydsm i{
float:left;
width:220px;
}
/*for xc_js*/
.xc_js{
float:left;
width:1000px;
margin-top:30px;
}
.xc_left{
float:left;
width:800px;
}
.xc_ts{
float:left;
width:798px;
border:1px solid #ffce49;
}
.xc_title{
float:left;
height:39px;
background:#ffe69f;
width:780px;
padding-left:18px;
line-height:39px;
overflow:hidden;
}
.xc_title li{
float:left;
margin-right:20px;
font-family:"微软雅黑", "宋体";
font-size:16px;
color:#bc5400;
}
.xc_title li a{
float:left;
font-family:"微软雅黑", "宋体";
font-size:16px;
color:#bc5400;
}
.xc_title .xc_hover{
background:url(../images/tb.png) no-repeat;
background-position:0px -440px;
margin-top:3px;
padding-left:18px;
}
.xc_title .xc_hover a{
background:url(../images/tb.png) no-repeat;
background-position:-24px -440px;
_background-position:-23px -440px;
padding-right:18px;
display:block;
font-family:"微软雅黑", "宋体";
font-size:16px;
color:#ffa800;
}
.xc_nr{
float:left;
width:774px;
margin-left:4px;
_margin-left:2px;
margin-top:3px;
background:url(../images/xc_bg.jpg) repeat-x;
height:39px;
border:1px solid #ffe69f;
line-height:39px;
padding-left:14px;
}
.xc_nr li{
float:left;
margin-right:12px;
}
.xc_nr li img{
float:left;
margin-top:15px;
}
.xc_nr .other{
float:right;
font-size:14px;
}
.xc_nr .other span{
float:left;
margin:0px 0px 0px 10px;
padding:0;
}
.jt_xc{
float:left;
width:790px;
margin:0px 4px 0px 4px;
_margin:0px 2px 0px 2px;
margin-top:23px;
overflow:hidden;
}
.one{
float:left;
width:100%;
}
.apfd{
float:left;
width:100%;
}
.one_left{
float:left;
padding-left:6px;
width:79px;
}
.one_left span{
float:left;
font-size:14px;
color:#ff6600;
font-weight:bold;
margin-right:4px;
}
.one_left .sjap{
font-size:14px;
color:#404241;
font-weight:normal;
}
.jtap{
float:left;
width:705px;
}
.jtap ul{
float:left;
width:100%;
padding-bottom:20px;
}
.jtap .jd_name{
float:left;
width:100%;
background:#f0fde9;
height:38px;
margin-bottom:10px;
padding:0px;
}
.jtap .jd_name li{
float:left;
width:auto;
height:38px;
line-height:38px;
color:#fc6800;
font-weight:bold;
margin-left:10px;
}
.jtap ul li{
float:left;
width:100%;
overflow:hidden;
line-height:20px;
}
.jd_img img{
float:left;
border:1px solid #989b92;
padding:1px;
margin-right:28px;
}
.jtap ul li span{
float:left;
}
.jtap ul .xc_mdd{
float:left;
font-size:14px;
color:#fb6600;
}
.jtap ul .xc_mdd span img{
float:left;
margin:2px 6px 0px 6px;
}
/*for 费用说明*/
.f2{
float:left;
width:798px;
border:1px solid #ffce49;
margin-top:12px;
line-height:20px;
font-size:12px;
}
.f2_title{
float:left;
height:39px;
background:#ffe69f;
width:780px;
padding-left:18px;
line-height:39px;
overflow:hidden;
}
.f2_title li{
float:left;
margin-right:20px;
font-family:"微软雅黑", "宋体";
font-size:16px;
color:#bc5400;
}
.f2_title li a{
float:left;
font-family:"微软雅黑", "宋体";
font-size:16px;
color:#bc5400;
}
.f2_title .xc_hover{
background:url(../images/tb.png) no-repeat;
background-position:0px -440px;
margin-top:3px;
padding-left:18px;
}
.f2_title .xc_hover a{
background:url(../images/tb.png) no-repeat;
background-position:-24px -440px;
_background-position:-23px -440px;
padding-right:18px;
display:block;
font-family:"微软雅黑", "宋体";
font-size:16px;
color:#ffa800;
}
.f2_content{
float:left;
width:782px;
margin:9px 8px 0px 8px;
_margin:9px 4px 0px 4px;
overflow:hidden;
}
.f2_content ul{
float:left;
width:100%;
padding-bottom:20px;
}
.f2_content ul li{
float:left;
width:100%;
}
.f2_content .f2_name{
background:#f0fde9;
height:38px;
line-height:38px;
margin-bottom:10px;
padding:0px;
}
.f2_name li{
float:left;
margin-left:10px;
font-weight:bold;
color:#333;
}
/*for 如何预订*/
.yd_content{
float:left;
width:706px;
margin:35px 38px 0px 54px;
_margin:35px 19px 0px 27px;
overflow:hidden;
}
.yd_content ul{
float:left;
width:100%;
padding-bottom:42px;
}
.yd_bz{
float:left;
width:53px;
height:41px;
line-height:41px;
font-family:"微软雅黑", "宋体";
color:#ffa800;
font-size:20px;
padding-left:30px;
background:url(../images/bz_bg.jpg) no-repeat;
}
.bz_xq{
float:left;
margin-left:20px;
width:602px;
}
.bz_xq p{
width:100%;
float:left;
padding-bottom:10px;
}
.bz_xq span{
float:left;
color:#5a5a5a;
font-size:12px;
border-color:3c3c3c;
background:#efefef;
padding:7px 9px 9px 11px;
border-style:solid;
border-width:0px 1px 1px 0px;
display:block;
}
.bz_xq img{
float:left;
margin:14px 7px 0px 7px;
}
.bz_xq a{
float:left;
height:41px;
line-height:41px;
display:block;
margin-right:15px;
color:#5a5a5a;
}
/*for 客户回访记录*/
.hh_content{
float:left;
width:780px;
margin:13px 10px 0px 8px;
_margin:13px 5px 0px 4px;
overflow:hidden;
}
.hh_content ul{
padding-bottom:5px;
width:100%;
float:left;
}
.kh_myd{
float:left;
width:80px;
height:55px;
background:url(../images/tb.png) no-repeat;
background-position:-124px -315px;
color:#fff;
}
.kh_myd span{
float:right;
margin-right:13px;
width:67px;
text-align:right;
}
.kh_myd .myd_xt{
font-style:italic;
font-weight:bold;
font-size:24px;
*margin-right:10px;
font-family:Arial, Helvetica, sans-serif;
}
.kh_dp{
float:left;
width:675px;
margin-left:5px;
background:#f3f9ed;
padding:10px;
}
.kh_dp p{
float:left;
width:100%;
}
.who_dp{
background:url(../images/tb.png) no-repeat;
background-position:-188px -10px;
color:#ff6600;
padding-left:20px;
float:right;
line-height:14px;
}
.dp_fy{
font-size:13px;
font-family:"微软雅黑", "宋体";
margin-left:80px;
_margin-left:40px;
}
.dp_fy span{
float:left;
margin-right:20px;
}
.dp_fy a{
display:block;
padding:5px;
color:#ffa800;
float:left;
margin-right:5px;
}
.cydp{
float:left;
width:780px;
background:#ffe8a7;
border-top:1px solid #ffce4a;
height:39px;
line-height:39px;
padding:0px 4px 0px 14px;
_padding:0px 4px 0px 7px;
}
.cydp li{
float:left;
height:39px;
line-height:39px;
margin-right:20px;
font-size:13px;
color:#444;
}
.cydp li .kh_hf{
float:left;
margin-right:25px;
}
.cydp li .qdp{
float:left;
width:91px;
height:32px;
line-height:32px;
text-align:center;
background:url(../images/tb.png) no-repeat;
background-position:-29px -555px;
color:#fff;
margin-top:4px;
}
/*for 在线咨询*/
.zx_content{
float:left;
width:740px;
margin:18px 33px 0px 25px;
_margin:18px 16px 0px 12px;
overflow:hidden;
padding-bottom:10px;
}
.zx_content ul{
float:left;
width:100%;
border-bottom:1px solid #ebe6c9;
padding-bottom:12px;
margin-top:12px;
}
.wi5{
float:left;
width:680px;
overflow:hidden;
margin-left:5px;
}
.wi5 p{
float:left;
width:680px;
}
.wi5 p a{
float:left;
margin-right:5px;
color:#2C629E;
}
.wi5 .yyhf{
float:left;
width:658px;
background:#fcf9e6;
border:1px solid #ebe6c9;
padding:10px;
margin-top:15px;
}
.zx_fb{
float:left;
width:690px;
margin:0px 33px 0px 75px;
_margin:0px 16px 0px 37px;
overflow:hidden;
padding-bottom:20px;
}
.zx_fb ul{
padding-bottom:20px;
width:100%;
float:left;
}
.zx_fb ul li{
float:left;
width:100%;
}
.zx_title{
float:left;
width:100%;
font-family:"微软雅黑", "宋体";
color:#343434;
font-size:18px;
}
.zx_fy{
font-size:13px;
font-family:"微软雅黑", "宋体";
}
.zx_fy span{
float:left;
margin-right:20px;
}
.zx_fy a{
display:block;
padding:5px;
color:#ffa800;
float:left;
margin-right:5px;
}
.text2 textarea{
float:left;
width:685px;
height:73px;
border:1px solid #ffce4a;
border-radius:3px;
line-height:20px;
text-indent:3px;
overflow:hidden;
}
.text3{
margin-top:10px;
}
.text3 textarea{
float:left;
width:685px;
height:26px;
border:1px solid #ffce4a;
border-radius:3px;
line-height:20px;
text-indent:3px;
overflow:hidden;
}
.text3 input{
width:45px;
height:20px;
border:1px solid #999;
margin-right:3px;
}
.zx_tj{
float:right;
background:url(../images/tb.png) no-repeat;
background-position:-29px -555px;
color:#fff;
width:91px;
height:32px;
line-height:32px;
text-align:center;
}
/*for 行程right*/
.xc_right{
float:right;
width:193px;
overflow:hidden;
}
.xb{
float:left;
width:171px;
border:1px solid #e6e6e6;
color:#666;
padding:0px 10px 10px 10px;
}
.xb li{
float:left;
width:100%;
margin-top:10px;
}
.xb span{
margin-right:10px;
float:left;
}
.xb a{
color:#666;
}
/*for 快捷入口*/
.door{
float:left;
width:100%;
margin-top:5px;
}
.door ul{
float:left;
width:100%;
margin-top:5px;
}
.door li{
width:86px;
height:23px;
line-height:23px;
text-align:center;
border:1px solid #e6e6e6;
padding-left:6px;
color:#666;
cursor:pointer;
}
.door li span a{
color:#666;
}
.door .door_hover{
border:1px solid #94d05b;
background:#68bc17;
color:#fff;
}
.door .door_hover span a{
color:#fff;
}
.door .door_hover .yellow{
color:#fff;
}
/*for 顶一下*/
.dyx{
float:left;
background:url(../images/tb.png) no-repeat;
background-position:0px -718px;
width:193px;
height:104px;
margin-top:10px;
}
.dyx_rq{
float:left;
margin:19px 0px 0px 16px;
_margin:19px 0px 0px 8px;
}
.dyx_rq span{
float:left;
}
.dyx_button a{
float:left;
width:193px;
height:25px;
line-height:25px;
text-align:center;
color:#fff;
font-family:"时尚中黑简体", "微软雅黑", "宋体";
font-size:20px;
margin-top:25px;
text-shadow:1px 1px #d19930;
}
/*for 驴友印象*/
.lyyx{
float:left;
width:100%;
margin-top:20px;
}
.lyyx ul{
float:left;
width:100%;
font-size:18px;
font-family:"微软雅黑", "宋体";
color:#505050;
}
.lyyx .yx_bq{
color:#fff;
font-size:12px;
font-family:"宋体";
margin-top:15px;
}
.lyyx .yx_bq li{
float:left;
width:100%;
}
.lyyx .yx_bq span{
float:right;
padding:7px;
}
.bg_green{
background:#32a300;
}
.bg_red{
background:#d00040;
}
.bg_blue{
background:#97dfc2;
}
.bg_yellow{
background:#ffa800;
}
.bg_pink{
background:#e250b1;
}
.bg_darkblue{
background:#016a7b;
}
/*for 右边统一样式*/
.tyys{
float:left;
width:191px;
border:1px solid #ffce4a;
overflow:hidden;
margin-top:20px;
}
.ty2{
float:left;
width:100%;
border-top:1px solid #ffce4a;
margin-top:-1px;
padding-bottom:20px;
}
.ty2 ul{
float:left;
}
.ty2_title{
float:left;
padding:0px 12px 0px 21px;
width:158px;
background:url(../images/right_title_bg.jpg) repeat-x;
height:39px;
line-height:39px;
overflow:hidden;
}
.ty2_title .m_title{
font-size:16px;
font-family:"微软雅黑", "宋体";
color:#ff7800;
float:left;
}
.ty2_title a{
color:#3a3a3a;
}
/*for 我浏览过的*/
.ty2 .ly_before{
width:150px;
padding:20px 21px 0px 21px;
overflow:hidden;
}
.ty2 .ly_before li{
float:left;
width:100%;
text-align:center;
line-height:20px;
}
/*for 猜你喜欢*/
.cnxh{
float:left;
width:177px;
padding:8px 8px 0px 8px;
}
.cnxh li{
float:left;
width:100%;
margin-bottom:13px;
}
.cnxh li p{
float:left;
color:#151515;
}
.xh_sm{
float:left;
width:102px;
margin-left:10px;
line-height:22px;
}
.xh_sm span{
float:left;
width:100%;
}
.xh_sm a{
color:#151515;
}
/*for 相关游记攻略*/
.xgyj{
float:left;
width:169px;
padding:7px 12px 0px 12px;
overflow:hidden;
}
.xgyj li{
float:left;
width:100%;
padding-bottom:10px;
line-height:16px;
color:#8c8c8c;
overflow:hidden;
}
.xgyj li a{
color:#8c8c8c;
}
.xgyj li span{
float:left;
height:16px;
overflow:hidden;
}
.xgyj li span img{
float:left;
margin-right:5px;
}
/*for 相关小组*/
.xgxz{
float:left;
width:169px;
padding:20px 12px 0px 12px;
}
.xgxz li{
float:none;
width:100%;
list-style-image:url(../images/list_before.jpg);
list-style-position:inside;
color:#3a3a3a;
*padding-left:10px;
*margin-left:-15px;
margin-bottom:10px;
}
.xgxz li a{
color:#3a3a3a;
}
/*-------------------------------------------------------------------*/
/*for 梦之旅客栈*/
.sp_left{
float:left;
width:478px;
overflow:hidden;
}
/*for kz_xc*/
.kz_xc{
float:left;
width:478px;
overflow:hidden;
}
.kz_xc .dt{
float:left;
width:100%;
}
.kz_xc .xt{
float:left;
width:100%;
margin-top:6px;
}
.kz_xc .xt li{
float:left;
}
.kz_xc_an span{
float:left;
margin-right:4px;
}
.kz_xc_an{
width:446px;
overflow:hidden;
margin:0px 0px 0px 4px;
height:66px;
}
.kz_xc .xt li img{
float:left;
border:1px solid #F8AE0F;
padding:5px 3px 5px 3px;
}
.kz_xc .xt li .bd_red img{
border:1px solid #F00;
}
.kz_xc a{
width:14px;
float:left;
height:66px;
background:url(../images/left_button.jpg) no-repeat;
color:#4e4e4e;
text-align:center;
line-height:66px;
display:block;
}
/*for ydxz*/
.ydxz{
float:left;
width:478px;
margin-top:15px;
overflow:hidden;
}
.ydxz ul{
float:left;
margin:0;
padding:0;
width:478px;
}
.xz_title{
float:left;
width:478px;
height:34px;
line-height:34px;
background:url(../images/line_bottom_bg.jpg) repeat-x left bottom;
padding-bottom:3px;
}
.xz_title li{
background:url(../images/xxk_bg_kz.jpg) no-repeat;
width:108px;
height:34px;
line-height:34px;
font-family:"微软雅黑", "宋体";
font-size:18px;
color:#fff;
text-align:center;
margin-left:4px;
}
.ydxz .xz_nr{
float:left;
margin-top:14px;
line-height:24px;
color:#2c1712;
font-size:14px;
width:465px;
}
.xz_nr li{
float:left;
width:465px;
padding-left:13px;
}
.xz_nr li span{
float:left;
margin:0;
padding:0;
}
.xz_nr li a{
float:left;
margin:0;
padding:0;
color:#2c1712;
}
/*for zg*/
.zg{
float:left;
width:458px;
height:103px;
margin-top:30px;
background:#fffadc;
border:1px solid #ffe7b9;
border-radius:5px;
padding:14px 9px 19px 9px;
}
.zgxx{
margin:0;
width:100%;
float:left;
height:48px;
overflow:hidden;
border-bottom:1px dashed #ffbe76;
padding:0px 0px 15px 0px;
}
.yh_tx{
float:left;
background:#fff;
overflow:hidden;
border:1px solid #ccc;
padding:2px;
border-radius:2px;
display:block;
width:48px;
height:48px;
overflow:hidden;
}
.yh_tx img{
float:left;
width:48px;
height:48px;
}
.sq_zg{
float:right;
margin-top:7px;
}
.yh_xx{
float:left;
margin-left:12px;
width:200px;
height:48px;
}
.yh_xx p{
float:left;
width:200px;
margin:0;
padding:0;
}
.yh_xx span{
float:left;
margin:0;
padding:0;
}
.zy{
font-size:14px;
font-family:"微软雅黑", "宋体";
}
.yh_xx .add_gz{
margin-top:7px;
}
.yh_xx .add_gz a{
color:#fff;
padding:6px 8px 6px 8px;
display:block;
margin-right:4px;
}
.gz{
background:#5cb207;
}
.xx{
background:#ffa800;
}
.zh{
background:#5ccacb;
}
.sq_zg img{
float:left;
}
.zgdt{
float:left;
width:100%;
padding:0;
margin:20px 0px 0px 0px;
font-size:14px;
font-family:"微软雅黑", "宋体";
}
.zgdt li{
float:left;
margin-right:14px;
}
.zgdt li span{
float:left;
}
.zgdt li .yellow{
margin:0px 3px 0px 3px;
}
/*for sp_right*/
.sp_right{
float:right;
width:500px;
}
.fj_title{
float:left;
width:100%;
}
.fj_title ul{
float:left;
width:100%;
}
.fd_name{
float:left;
font-family:"微软雅黑", "宋体";
font-size:18px;
color:#515151;
line-height:24px;
background:url(../images/bottom_bg.jpg) left bottom repeat-x;
width:100%;
padding:8px 0px 12px 0px;
}
.xq{
line-height:28px;
color:#8b8b8b;
font-size:14px;
margin-top:20px;
}
.xq li{
float:left;
width:100%;
}
.xq .address{
float:left;
width:380px;
overflow:hidden;
}
.nx{
position:absolute;
margin:97px 0px 0px 380px;
*margin:97px 0px 0px -120px;
}
.nx img{
float:left;
}
/*for 人气*/
.rq{
background:#fffff8;
border:1px solid #ffe6b7;
border-radius:4px;
height:92px;
line-height:92px;
margin-top:25px;
overflow:hidden;
}
.rq li{
float:left;
}
.rq_name{
margin-left:16px;
color:#494949;
margin-top:5px;
}
.rq_sz{
font-size:30px;
color:#ff9e02;
font-weight:bold;
}
.rq .d{
float:right;
}
.rq .d a{
width:60px;
height:60px;
overflow:hidden;
background:url(../images/d.png) no-repeat;
display:block;
float:right;
margin:15px 22px 0px 0px;
_margin:15px 11px 0px 0px;
}
/*for jd_pf*/
.jdpf{
float:left;
width:498px;
margin-top:20px;
overflow:hidden;
border:1px solid #fc7e04;
border-radius:5px;
overflow:hidden;
}
.pf_title{
float:left;
width:100%;
height:53px;
background:#ffb516;
border-bottom:1px solid #fc7e04;
line-height:53px;
color:#fff;
}
.pf_bt{
font-family:"微软雅黑", "宋体";
padding-left:12px;
}
.pf_bt span{
float:left;
margin-right:16px;
}
.ly_pl{
float:right;
background:url(../images/kz_bg.png) no-repeat;
background-position:0px -372px;
margin:6px 7px 0px 0px;
overflow:hidden;
}
.ly_pl a{
float:left;
width:87px;
height:40px;
line-height:40px;
text-align:center;
color:#fff;
font-size:18px;
font-family:"微软雅黑", "宋体";
}
.jdpf_nr{
float:left;
width:445px;
padding:3px 30px 18px 25px;
overflow:hidden;
background:#fffadc;
}
.jdpf_nr ul{
float:left;
width:100%;
margin-top:10px;
}
.jdpf_nr ul li{
float:left;
}
.pf_name{
font-family:"微软雅黑", "宋体";
font-size:14px;
color:#515151;
}
.pf_fs{
margin-left:10px;
width:325px;
height:12px;
border:1px solid #ffc14a;
border-radius:5px;
margin-top:4px;
background:#fff;
}
.pf_fs span{
background:#ffb417;
border-right:1px solid #ffb417;
border-radius:0px 5px 5px 0px;
height:12px;
float:left;
}
.b85{
width:88%;
}
.b86{
width:86%;
}
.b95{
width:95%;
}
.b94{
width:94%;
}
.jdpf_nr ul .bf_sm{
float:right;
font-size:14px;
font-family:"微软雅黑", "宋体";
color:#fc8004;
font-style:italic;
margin-top:2px;
}
/*for 价格*/
.fj_price{
float:left;
width:1000px;
margin-top:20px;
}
.fj_price ul{
width:100%;
float:left;
}
.fj_price ul li{
float:left;
}
.fj_price_title{
font-family:"微软雅黑", "宋体";
font-size:24px;
color:#ff9c00;
border-bottom:1px dashed #cacaca;
padding-bottom:12px;
width:100%;
}
.fx_nr{
margin-top:13px;
height:75px;
overflow:hidden;
}
.js{
margin-left:12px;
line-height:24px;
height:75px;
overflow:hidden;
}
.js span{
float:none;
}
.sj_time{
margin-left:89px;
}
.fj_price ul .ljyd{
float:right;
margin:25px 30px 0px 0px;
_margin:25px 15px 0px 0px;
}
/*for jdxx*/
.jdxx{
float:left;
width:1000px;
margin-top:45px;
}
/*for jdxx_left*/
.jdxx_left{
float:left;
width:570px;
overflow:hidden;
}
.k1{
float:left;
width:570px;
overflow:hidden;
}
.jdxx_title{
float:left;
width:100%;
border-bottom:1px dashed #cacaca;
padding-bottom:12px;
font-size:24px;
font-family:"微软雅黑", "宋体";
color:#ff9c00;
}
.jdxx_nr{
float:left;
width:100%;
margin-top:20px;
font-size:14px;
color:#5d5d5d;
line-height:24px;
}
.jdxx_nr .yellow{
font-family:"微软雅黑", "宋体";
margin:0px 20px 0px 10px;
}
.jdxx_nr span img{
float:left;
margin:8px 0px 0px 0px;
}
.k2{
float:left;
width:570px;
margin-top:30px;
overflow:hidden;
}
.jdxx_nr p{
float:left;
margin:0;
padding:0;
width:570px;
overflow:hidden;
}
.jdxx_nr .img{
float:left;
margin:15px 0px 15px 0px;
width:570px;
}
.jdxx_title p{
float:left;
}
.jdxx_title .k2_title{
float:right;
font-size:14px;
}
.jdxx_title .k2_title span{
float:none;
font-family:"宋体";
}
.jdxx_title .k2_title .font30{
margin:0px 23px 0px 0px;
font-family:"微软雅黑", "宋体";
}
.k2 ul{
float:left;
width:570px;
}
.jdxx_nr .yk{
float:left;
width:60px;
margin-right:20px;
}
.jdxx_nr .yk p{
width:60px;
float:left;
}
.jdxx_nr .yk span{
float:left;
width:60px;
}
.jdxx_nr .yk .yhm{
float:left;
width:100%;
text-align:center;
}
.jdxx_nr .yk .yhm a{
display:block;
width:60px;
color:#5076ba;
font-size:12px;
}
.jdxx_nr .yk img{
float:left;
border:1px solid #e6e7e9;
padding:4px;
width:40px;
height:40px;
margin:0px 5px 0px 5px;
}
.k2_nr{
width:570px;
margin-top:50px;
}
.k2_nr p{
float:left;
}
.jdxx_nr .yhdp_nr{
float:left;
width:490px;
}
.jdxx_nr .yhdp_nr p{
float:left;
width:490px;
overflow:hidden;
}
.jdxx_nr .yhdp_nr p .yh_dp img{
float:left;
margin:4px 0px 0px 0px;
}
.jdxx_nr .yhdp_nr p .dp_time{
float:right;
font-size:12px;
color:#999;
}
.jdxx_nr .yhdp_nr p .dp_time a{
float:left;
margin-right:10px;
font-size:12px;
color:#ff7d01;
}
.jdxx_nr .yhdp_nr .dp_content{
width:490px;
margin-top:20px;
font-size:12px;
color:#0f0f0f;
overflow:hidden;
}
.k2 .fy{
float:left;
width:568px;
margin-top:20px;
background:#f7f7f7;
border:1px solid #d2d6da;
height:33px;
line-height:33px;
}
.k2 .fy li{
float:left;
margin-left:10px;
}
.k2 .fy li .fy_hover{
color:#ff9c00;
font-weight:bold;
}
.k2 .fy li a{
font-size:14px;
color:#7e8591;
float:left;
margin-right:10px;
}
.k2 .fy li a:hover{
color:#ff9c00;
}
.k2 .fy .next{
float:right;
margin:0;
}
.k2 .fb_ly{
float:left;
width:570px;
}
.fb_title{
width:69px;
height:54px;
text-align:center;
font-size:18px;
color:#ff9c00;
font-family:"微软雅黑", "宋体";
}
.text{
float:right;
}
.text textarea{
float:right;
width:490px;
height:52px;
background:#fcfce9;
border:1px solid #faed8d;
overflow:hidden;
}
.fb_ly .input{
float:right;
}
.fb_ly .input input{
width:59px;
height:23px;
border:none;
overflow:hidden;
margin-top:4px;
background:url(../images/fs.jpg) no-repeat;
cursor:pointer;
}
/*for jdxx_right*/
.jdxx_right{
float:right;
width:400px;
overflow:hidden;
}
.k3{
float:left;
width:364px;
overflow:hidden;
background:#fffadc;
border:1px solid #ffe3cd;
border-radius:10px;
padding:17px;
}
.jdxx_right .jdxx_title{
float:left;
width:100%;
padding-bottom:16px;
font-size:24px;
font-family:"微软雅黑", "宋体";
color:#ff9c00;
border-bottom:none;
}
.k4{
float:left;
width:364px;
overflow:hidden;
background:#fffadc;
border:1px solid #ffe3cd;
border-radius:10px;
padding:17px;
margin-top:33px;
}
.k4 ul{
float:left;
width:100%;
border:none;
}
.ts_nr{
float:left;
width:100%;
font-family:"微软雅黑", "宋体";
line-height:30px;
}
.ts_nr span{
float:left;
}
.dark_bg{
background:#996600;
color:#fff;
}
.bf{
width:100%;
float:left;
margin-bottom:10px;
}
.bf i{
float:right;
}
.all{
color:#356fd9;
background:url(../images/all.jpg) right no-repeat;
padding-right:10px;
width:30px;
float:right;
}
.little{
display:none;
color:#356fd9;
background:url(../images/little.jpg) right no-repeat;
padding-right:10px;
width:30px;
float:right;
}
.ts_add{
font-family:"微软雅黑", "宋体";
font-size:14px;
color:#fc7905;
margin:0px 0px 0px 0px;
}
.ts_button{
float:right;
}
.ts_nr input{
width:186px;
height:24px;
float:left;
border:1px solid #fd8204;
text-indent:1em;
line-height:24px;
}
.ts_nr button{
border:none;
background:url(../images/kz_bg.png) no-repeat;
background-position:0px -434px;
color:#fff;
width:91px;
height:26px;
line-height:26px;
margin-left:3px;
cursor:pointer;
float:left;
}
/*for 浏览过的客栈*/
.ll_before{
float:left;
width:100%;
}
.ll_before li{
float:left;
width:100%;
font-size:14px;
line-height:24px;
}
.ll_before li span{
float:left;
margin-right:20px;
}
.ll_before li .ma_none{
margin:0;
}
.ll_before li a{
color:#363636;
}
.ll_before li span a{
color:#363636;
}
/*for 周边旅游推荐*/
.lytj{
float:left;
width:100%;
}
.lytj li{
float:left;
width:100%;
height:31px;
overflow:hidden;
margin-top:10px;
line-height:31px;
font-size:14px;
}
.lytj li span{
float:left;
}
.lytj li span img{
float:left;
margin-right:10px;
}
.lytj li span a{
color:#363636;
}
/*------------------------------------------------------*/
/*for 客栈列表页面*/
.kz_list_content{
width:100%;
background:url(../images/kz_list_bg.jpg) #fff repeat-x;
height:auto;
float:left;
}
/*for kzlist_left*/
.kzlist_left{
float:left;
width:400px;
overflow:hidden;
margin-top:13px;
}
/*for 搜索客栈*/
.searchkz{
float:left;
width:350px;
background:#ffa800;
padding:15px 25px 15px 25px;
border-radius:5px;
overflow:hidden;
}
.kzlist_left_title{
float:left;
width:100%;
font-size:24px;
font-family:"微软雅黑", "宋体";
}
.skz_nr{
float:left;
width:350px;
margin-top:20px;
overflow:hidden;
}
.skz_nr .mn{
float:left;
width:350px;
padding-bottom:10px;
display:block;
cursor:pointer;
}
.skz_nr ul{
float:left;
width:350px;
overflow:hidden;
}
.skz_nr ul input{
float:left;
width:350px;
height:39px;
border:none;
line-height:39px;
background:url(../images/mn_select.jpg) #fff no-repeat;
background-position:320px 13px;
border-radius:4px;
color:#2454a6;
text-indent:10px;
overflow:hidden;
cursor:pointer;
}
.skz_nr ul li{
float:left;
width:100%;
color:#2454a6;
}
.kz_active .mn_xl{
display:block;
}
.mn_xl{
background:#fff;
margin:39px 0px 0px 0px;
*margin:39px 0px 0px -350px;
text-align:center;
line-height:20px;
display:none;
position:absolute;
}
.mn_xl a{
color:#2454a6;
display:block;
width:100%;
}
.skz_nr .gjz{
float:left;
width:350px;
padding-bottom:10px;
}
.skz_nr .gjz ul input{
float:left;
width:350px;
height:39px;
border:none;
line-height:39px;
background:#fff;
border-radius:4px;
color:#2454a6;
text-indent:10px;
overflow:hidden;
}
.skz_nr .mn .year{
float:left;
width:118px;
margin-right:18px;
overflow:hidden;
}
.skz_nr .mn .year ul{
float:left;
width:100%;
}
.skz_nr .mn .year ul li{
float:left;
width:100%;
}
.skz_nr .mn .year ul input{
float:left;
width:118px;
height:39px;
border:none;
line-height:39px;
background:url(../images/year.jpg) #fff no-repeat;
background-position:95px 13px;
border-radius:4px;
color:#2454a6;
text-indent:10px;
overflow:hidden;
}
.skz_nr .mn .yf{
float:left;
width:98px;
margin-right:18px;
}
.skz_nr .mn .yf ul{
float:left;
width:98px;
}
.skz_nr .mn .yf ul li{
float:left;
}
.skz_nr .mn .yf ul input{
float:left;
width:98px;
height:39px;
border:none;
line-height:39px;
background:url(../images/mn_select.jpg) #fff no-repeat;
background-position:68px 13px;
border-radius:4px;
color:#2454a6;
text-indent:10px;
overflow:hidden;
}
.kzlist_ss{
float:left;
width:350px;
text-align:center;
margin-top:10px;
}
.kzlist_ss button{
width:139px;
height:41px;
overflow:hidden;
background:url(../images/kzlist_ss.jpg) no-repeat;
border:none;
}
.search_gjc{
float:left;
line-height:20px;
margin-left:10px;
height:20px;
overflow:hidden;
}
.skz_s_nr .search_gjc ul li{
width:auto;
float:left;
color:#fff;
}
.search_gjc a{
float:left;
color:#fff;
margin-right:5px;
}
/*for 今日入住*/
.jrrz{
float:left;
width:380px;
margin-top:20px;
padding:0px 10px 0px 10px;
font-family:"微软雅黑", "宋体";
font-size:14px;
}
.jrrz li{
float:left;
width:100%;
line-height:24px;
}
/*for 英文*/
.yw{
float:left;
width:400px;
overflow:hidden;
margin-top:20px;
}
/*for 推荐的客栈*/
.tj_kz{
float:left;
width:100%;
}
.tj_kz li{
float:left;
width:100%;
font-size:14px;
line-height:24px;
padding-bottom:10px;
}
.tj_kz li span{
float:left;
margin-right:7px;
width:114px;
height:95px;
overflow:hidden;
}
.tj_kz li span img{
background:#fff;
border:1px solid #d5d4d3;
padding:1px;
width:110px;
height:70px;
float:left;
}
.tj_kz li .ma_none{
margin:0;
}
.tj_kz li a{
color:#363636;
}
.tj_kz li span a{
color:#ff9c00;
display:block;
width:114px;
text-align:center;
overflow:hidden;
}
/*for kzlist_right*/
.kzlist_right{
float:right;
width:570px;
margin-top:13px;
}
/*for kz_list_tj*/
.kz_list_tj{
float:left;
width:570px;
overflow:hidden;
}
.kz_list_tj ul{
float:left;
}
.kztj_title{
border-bottom:3px solid #ff8512;
height:34px;
overflow:hidden;
width:100%;
}
.kztj_title li{
float:left;
margin-left:6px;
background:url(../images/kz_bg.png) no-repeat;
background-position:0px 0px;
width:108px;
height:34px;
line-height:34px;
text-align:center;
color:#fff;
overflow:hidden;
font-family:"微软雅黑", "宋体";
font-size:18px;
}
.kztj_title .gdtj{
float:right;
background:none;
width:auto;
margin:0px 20px 0px 0px;
_margin:0px 10px 0px 0px;
}
.kztj_title .gdtj a{
float:left;
font-size:12px;
font-family:"微软雅黑", "宋体";
color:#303030;
margin-top:5px;
}
.kzlist_tj_nr{
padding:30px 10px 20px 26px;
width:534px;
float:left;
color:#464646;
}
.kzlist_tj_nr li{
float:left;
}
.kzlist_tj_nr .kz_tj_jd{
float:right;
width:453px;
line-height:20px;
}
.kz_tj_jd p{
width:100%;
height:33px;
line-height:33px;
overflow:hidden;
}
.kz_tj_jd p img{
float:left;
margin-top:5px;
}
.kz_tj_jd p a{
font-size:18px;
font-family:"微软雅黑", "宋体";
color:#464646;
width:215px;
display:block;
float:left;
overflow:hidden;
height:33px;
line-height:33px;
}
.kz_tj_jd p .yellow{
font-size:18px;
font-family:"微软雅黑", "宋体";
font-weight:bold;
margin:0px 10px 0px 30px;
}
.kz_tj_jd p .blue{
color:#1e4a9c;
font-size:18px;
font-family:"微软雅黑", "宋体";
font-weight:bold;
margin-right:10px;
}
.kzsy p{
border-bottom:1px dashed #cacaca;
}
.kzsy p a{
font-size:18px;
font-family:"微软雅黑", "宋体";
color:#464646;
width:215px;
display:block;
float:left;
overflow:hidden;
height:33px;
line-height:33px;
}
.kzsy p .yellow{
font-size:18px;
font-family:"微软雅黑", "宋体";
font-weight:bold;
margin:0px 10px 0px 50px;
}
.kzsy p .blue{
color:#1e4a9c;
font-size:18px;
font-family:"微软雅黑", "宋体";
font-weight:bold;
float:right;
margin-right:20px;
}
/*for 按条件筛选*/
.sx{
margin-top:30px;
float:left;
width:570px;
}
.sx ul{
float:left;
}
.sx_title{
width:100%;
font-family:"微软雅黑", "宋体";
font-size:24px;
color:#ffa800;
}
.sx_nr{
width:550px;
margin-top:20px;
line-height:25px;
padding-left:20px;
color:#38363b;
font-family:"微软雅黑", "宋体";
font-size:14px;
}
.sx_nr li{
width:100%;
float:left;
}
/*for 客栈搜索列表*/
.kzlb{
float:left;
width:570px;
}
.kzlb_nr{
float:left;
width:552px;
height:132px;
background:#f6f6f6;
padding:9px;
overflow:hidden;
margin-top:13px;
border-radius:3px;
}
.kzlb_js{
float:left;
border-right:1px dotted #ccc;
padding-right:20px;
width:416px;
height:132px;
}
.kzlb_tp{
background:url(../images/kz_bg.png) no-repeat;
background-position:0px -230px;
width:120px;
height:80px;
overflow:hidden;
padding:2px 7px 42px 5px;
}
.kzlb_jj{
float:left;
margin-left:8px;
width:275px;
}
.kzlb_jj p{
float:left;
width:275px;
line-height:24px;
font-family:"微软雅黑", "宋体";
color:#282828;
height:24px;
overflow:hidden;
}
.kzlb_jj .kzlb_jj_nr{
float:left;
height:44px;
}
.kzlb_jj .kz_ly{
float:left;
margin-top:13px;
}
.kz_price{
float:left;
width:92px;
padding-left:20px;
height:132px;
}
.kz_price .yellow{
float:left;
font-family:"微软雅黑", "宋体";
font-size:18px;
margin-top:27px;
}
.kz_ly span{
float:left;
line-height:16px;
font-size:14px;
margin-right:5px;
color:#767676;
}
.kz_ly span a{
color:#767676;
float:left;
}
.kz_ly .kz_bfb{
background:url(../images/kz_bg.png) no-repeat;
background-position:0px -186px;
width:38px;
height:21px;
line-height:21px;
text-align:center;
color:#fff;
font-weight:bold;
}
.kz_qkk{
float:left;
background:url(../images/kz_bg.png) no-repeat;
background-position:0px -52px;
margin-top:28px;
}
.kz_qkk a{
width:92px;
height:40px;
line-height:40px;
text-align:center;
color:#fff;
font-weight:bold;
font-size:14px;
display:block;
}
/*for 客栈列表翻页*/
.kz_fy{
float:left;
width:540px;
margin-top:10px;
background:#f6f6f6;
height:39px;
padding:0px 15px 0px 15px;
}
.kz_fy li{
height:39px;
overflow:hidden;
}
.kz_fy a{
padding:6px;
display:block;
float:left;
color:#38363b;
font-family:"微软雅黑", "宋体";
font-size:14px;
height:18px;
margin-top:4px;
}
.kz_fy .kz_fy_hover{
background:#ffa800;
color:#fff;
}
.kz_fy a:hover{
background:#ffa800;
color:#fff;
}
/*-----------------------------------------------------*/
/*for 就近度假*/
/*for 浏览方式选择*/
.llfs{
float:left;
width:100%;
}
.llfs_title{
float:left;
width:100%;
border-bottom:1px dashed #dbdbdb;
color:#515151;
font-family:"微软雅黑", "宋体";
font-size:16px;
padding-bottom:5px;
height:20px;
overflow:hidden;
}
.fs{
float:left;
width:100%;
}
.fs ul{
float:left;
width:100%;
color:#515151;
line-height:18px;
overflow:hidden;
margin-top:5px;
}
.fs ul li{
float:left;
width:auto;
line-height:18px;
}
.fs ul a{
float:left;
color:#515151;
display:block;
padding:0px 8px 0px 8px;
height:18px;
width:auto;
line-height:18px;
display:block;
margin:0px 0px 0px 10px;
_margin:0px 0px 0px 5px;
background:#fff;
}
.fs ul .xz_hover a{
background:#ffa800;
color:#fff;
}
.fs ul a:hover{
background:#ffa800;
color:#fff;
}
/*for 今日推荐*/
.jrtj{
float:left;
width:521px;
border:1px solid #66b619;
margin:17px 0px 10px 0px;
padding-bottom:12px;
}
.jrtj ul{
float:left;
width:501px;
height:80px;
overflow:hidden;
padding:0px 10px 12px 10px;
}
.jrtj .jrtj_title{
padding-bottom:0px;
margin-bottom:12px;
height:30px;
line-height:30px;
color:#fff;
background:#519a03;
border-bottom:1px solid #66b619;
}
.jrtj_tp{
height:78px;
width:78px;
overflow:hidden;
float:left;
background:#f8ffef;
padding:1px;
}
.jrtj ul li img{
border:1px solid #ccc;
padding:1px;
}
.jrtj_xl{
float:left;
margin-left:20px;
height:80px;
width:305px;
overflow:hidden;
}
.jrtj_xl p{
float:left;
width:100%;
}
.jrtj_qkk{
float:right;
background:url(../images/kz_bg.png) no-repeat;
background-position:0px -116px;
margin-top:20px;
}
.jrtj_qkk a{
width:81px;
height:40px;
text-align:center;
line-height:40px;
display:block;
color:#fff;
font-size:14px;
}
/*for 就近度假翻页*/
.jj_fy{
float:left;
width:521px;
border:1px solid #fddb81;
border-radius:3px;
height:32px;
margin-top:10px;
overflow:hidden;
}
.jj_fy ul{
width:519px;
padding:1px;
background:#fff7d3;
height:30px;
line-height:30px;
overflow:hidden;
font-size:14px;
}
.jj_fy ul li{
height:30px;
line-height:30px;
}
.jj_fy ul .fy_left{
margin-left:14px;
}
.jj_fy ul a{
color:#d48d01;
}
.jj_fy ul .fy_left a{
margin-right:5px;
}
.jj_fy ul .fy_right{
float:right;
margin-right:10px;
}
.jj_fy ul .fy_right a{
float:left;
margin-left:10px;
}
/*for 广告位*/
.ggw{
float:left;
width:100%;
margin-top: 10px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
/*----------------------------------------*/
/*for 客栈首页*/
/*for 搜索客栈*/
.searchkz_s{
float:left;
width:540px;
background:#ffa800;
padding:15px 25px 15px 30px;
border-radius:5px;
overflow:hidden;
margin-top:14px;
}
.skz_s_nr{
float:left;
width:540px;
margin-top:20px;
overflow:hidden;
}
.skz_s_nr .mn{
float:left;
padding-bottom:10px;
display:block;
cursor:pointer;
}
.skz_s_nr ul{
float:left;
overflow:hidden;
}
.skz_s_nr ul input{
float:left;
width:250px;
height:39px;
border:none;
line-height:39px;
background:url(../images/mn_select.jpg) #fff no-repeat;
background-position:220px 13px;
border-radius:4px;
color:#2454a6;
text-indent:10px;
overflow:hidden;
cursor:pointer;
}
.skz_s_nr ul li{
float:left;
width:100%;
color:#2454a6;
}
.kz_active .mn_xl{
display:block;
}
.mn_xl{
background:#fff;
margin:39px 0px 0px 0px;
*margin:39px 0px 0px -350px;
text-align:center;
line-height:20px;
display:none;
position:absolute;
}
.mn_xl a{
color:#2454a6;
display:block;
width:100%;
}
.skz_s_nr .gjz{
float:left;
width:540px;
padding-bottom:10px;
}
.skz_s_nr .gjz ul input{
float:left;
width:520px;
*width:522px;
height:39px;
border:none;
line-height:39px;
background:#fff;
border-radius:4px;
color:#2454a6;
text-indent:10px;
overflow:hidden;
}
.skz_s_nr .mn .year{
float:left;
width:118px;
margin-right:18px;
overflow:hidden;
}
.skz_s_nr .mn .year ul{
float:left;
width:100%;
}
.skz_s_nr .mn .year ul li{
float:left;
width:100%;
}
.skz_s_nr .mn .year ul input{
float:left;
width:118px;
height:39px;
border:none;
line-height:39px;
background:url(../images/year.jpg) #fff no-repeat;
background-position:95px 13px;
border-radius:4px;
color:#2454a6;
text-indent:10px;
overflow:hidden;
}
.skz_s_nr .mn .yf{
float:left;
width:98px;
margin-right:18px;
}
.skz_s_nr .mn .yf ul{
float:left;
width:98px;
}
.skz_s_nr .mn .yf ul li{
float:left;
}
.skz_s_nr .mn .yf ul input{
float:left;
width:98px;
height:39px;
border:none;
line-height:39px;
background:url(../images/mn_select.jpg) #fff no-repeat;
background-position:68px 13px;
border-radius:4px;
color:#2454a6;
text-indent:10px;
overflow:hidden;
}
.skz_s_nr .kz_s_ss{
float:left;
text-align:center;
width:139px;
}
.skz_s_nr .kz_s_ss ul{
float:left;
width:139px;
}
.skz_s_nr .kz_s_ss button{
width:139px;
height:41px;
overflow:hidden;
background:url(../images/kzlist_ss.jpg) no-repeat;
border:none;
}
/*for 最经济实惠的客栈集中地*/
.zjj{
float:left;
margin-left:25px;
width:380px;
overflow:hidden;
margin-top:14px;
}
.zjj ul{
float:left;
width:100%;
}
.zjj_title{
font-size:30px;
color:#ff810a;
font-family:"微软雅黑", "宋体";
}
.zjj_nr{
float:left;
margin-top:19px;
}
.zjj_nr li{
float:left;
width:100%;
margin-top:10px;
font-family:"微软雅黑", "宋体";
font-size:14px;
font-weight:bold;
}
/*for 英文*/
.yw_s{
float:left;
width:400px;
overflow:hidden;
}
/*for 逛逛店*/
.ggd{
float:left;
width:100%;
margin-top:15px;
}
/*for 客栈首页广告*/
.sy_gg{
float:left;
width:570px;
overflow:hidden;
}
/*for 最新加入*/
.new_add{
float:left;
width:570px;
overflow:hidden;
margin-top:32px;
}
.new_add ul{
width:100%;
float:left;
border:none;
}
.new_add ul li{
float:left;
line-height:24px;
}
.new_add ul li a{
color:#303030;
font-size:14px;
/*border-right:1px solid #303030;*/
height:18px;
width:auto;
/*padding-right:3px;*/
margin-right:5px;
}
.new_add ul li a:hover{
color:#ffa800;
text-decoration:underline;
border-right-color:#ffa800;
}
/*-------------------------------------------------------------------*/
/*for 购物车*/
.content_lc{
float:left;
width:100%;
background:url(../images/zflc_bg.jpg) repeat-x;
}
.w1000{
width:1000px;
margin:0 auto;
}
/*for 流程头部*/
.lc{
float:left;
height:119px;
width:100%;
margin-top:22px;
}
.lc ul{
float:left;
width:100%;
text-align:left;
}
.lc .lc_lb{
float:left;
height:46px;
width:100%;
background:url(../images/lc_lb_bg.jpg);
}
.lc .lc_lb li{
float:left;
}
.lc .lc_lb .lb_bt{
height:37px;
background:url(../images/lb_bt_bg.jpg);
margin:10px 0px 0px 12px;
line-height:37px;
padding:0px 30px 0px 30px;
color:#ffa800;
font-size:14px;
font-weight:bold;
}
.lc .lc_lb .lc_tb{
float:right;
margin:13px 30px 0px 0px;
_margin:13px 15px 0px 0px;
padding:0;
}
.lc .lc_lb .lc_tb span{
float:left;
margin:0px 0px 0px 33px;
padding:0;
}
.lc .lc_tb .num1{
background:url(../images/lc_tb.png) 0 0 no-repeat;
width:82px;
height:21px;
display:block;
}
.lc .lc_tb .num2{
background:url(../images/lc_tb.png) no-repeat;
background-position:-115px 0px;
width:101px;
height:21px;
display:block;
}
.lc .lc_tb .num1_gray{
background:url(../images/lc_tb.png) no-repeat;
background-position:0px -45px;
width:82px;
height:21px;
display:block;
}
.lc .lc_tb .num2_gray{
background:url(../images/lc_tb.png) no-repeat;
background-position:-115px -45px;
width:101px;
height:21px;
display:block;
}
.lc .lc_tb .num3{
background:url(../images/lc_tb.png) no-repeat;
background-position:-243px 0px;
width:99px;
height:21px;
display:block;
}
.lc .lc_tb .num3_gray{
background:url(../images/lc_tb.png) no-repeat;
background-position:-243px -45px;
width:99px;
height:21px;
display:block;
}
.lc .lc_tb .num4{
background:url(../images/lc_tb.png) no-repeat;
background-position:-358px 0px;
width:103px;
height:21px;
display:block;
}
.lc .lc_tb .num4_gray{
background:url(../images/lc_tb.png) no-repeat;
background-position:-358px -45px;
width:103px;
height:21px;
display:block;
}
/*for 操作提示*/
.czts{
float:left;
_float:none;
width:100%;
height:30px;
background:url(../images/cz_border.jpg) left no-repeat;
}
.czts li{
float:left;
width:965px;
_width:966px;
background:url(../images/cz_border.jpg) right no-repeat;
margin-left:35px;
_margin-left:17px;
}
.czts li span{
float:left;
color:#7a7a7a;
line-height:30px;
}
/*for 购物车列表*/
.gwc_lb{
float:left;
width:998px;
border:1px solid #dedede;
margin:0px;
padding:0px;
overflow:hidden;
}
.gwc_lb .gwc_bottom{
padding:23px 0px 67px 0px;
border-bottom:1px solid #dedede;
float:left;
width:998px;
}
.gwc_lb .gwc_bottom2{
padding:23px 0px 0px 0px;
float:left;
width:998px;
}
.gwc_cp_tp{
float:left;
width:79px;
margin:0px 16px 0px 16px;
_margin:0px 8px 0px 8px;
}
.gwc_lb_nr{
float:left;
width:887px;
}
.gwc_lb_title{
float:left;
width:872px;
margin-right:15px;
}
.gw_cp_title{
float:left;
font-size:14px;
font-weight:bold;
}
.gwc_cp_nr{
float:left;
width:872px;
line-height:22px;
color:#646464;
font-size:12px;
}
.gwc_lb .cz_cp{
float:right;
}
.gwc_lb .cz_cp span{
float:left;
}
.gwc_lb .cz_cp span a{
float:left;
margin-left:15px;
width:50px;
text-align:center;
height:20px;
border:1px solid #a8a8a8;
border-radius:3px;
line-height:20px;
background:url(../images/cz_cp_bg.jpg);
cursor:pointer;
color:#000;
}
.gwc_lb .cz_cp span a:hover{
background:url(../images/cz_cp_bg_hover.jpg);
}
.gwc_cp_jj{
display:block;
float:left;
line-height:22px;
width:100%;
}
/*for修改产品*/
.gwc_lb .xg_cp{
float:left;
background:#fff;
width:887px;
border:none;
padding:0;
text-align:left;
line-height:20px;
}
.xg_cp ul{
float:left;
width:100%;
}
.gwc_lb .xl{
float:left;
width:100%;
}
.xg_cp li{
width:100%;
}
.xg_cp select{
border:1px solid #999;
}
.xg_cp .rs select{
width:70px;
border:1px solid #7e9db9;
margin-right:14px;
padding:0;
}
.xg_cp li a{
width:52px;
height:20px;
border:1px solid #a7a7a7;
cursor:pointer;
color:#253d6b;
border-radius:3px;
line-height:20px;
display:block;
text-align:center;
margin:20px 3px 0px 5px;
_margin:20px 3px 0px 2px;
float:left;
}
/*for 必选项目*/
.xg_cp .bxxm{
float:left;
width:870px;
margin-top:35px;
border:1px solid #a4a4a4;
}
.xg_cp .bxxm li{
float:left;
width:830px;
border-top:1px solid #a4a4a4;
margin-top:-1px;
padding:0px 20px 0px 20px;
height:42px;
line-height:42px;
}
.xg_cp .bxxm .gw_jq{
margin-left:80px;
font-size:14px;
color:#ffa800;
font-weight:bold;
}
.xg_cp .bxxm .f1{
float:right;
margin-top:12px;
}
.xg_cp .bxxm input{
float:left;
margin:15px 3px 0px 3px;
*margin:10px 3px 0px 3px;
}
.bxxm_title{
float:left;
color:#005d80;
font-size:14px;
}
/*for 总计*/
.gwc_lb .zj{
float:left;
width:998px;
background:url(../images/js_bg.jpg);
}
.gwc_lb .zj li{
float:left;
line-height:54px;
}
.gwc_lb .zj .sum{
font-size:14px;
width:948px;
padding:0px 25px 0px 25px;
}
.gwc_lb .zj .next_gw{
padding-left:25px;
width:100%;
background:url(../images/next_gw.jpg) no-repeat;
height:66px;
line-height:66px;
}
.next_gw .return{
width:832px;
float:left;
line-height:75px;
height:66px;
overflow:hidden;
}
.next_gw .return a{
color:#000;
height:20px;
text-align:center;
border:1px solid #a7a7a7;
line-height:20px;
margin-top:23px;
border-radius:3px;
float:left;
padding:0px 5px;
}
.next_gw .go_next{
position:absolute;
margin:15px 0px 0px 0px;
}
.next_gw .go_next a{
background:url(../images/go_next.png) no-repeat;
width:120px;
height:37px;
float:left;
color:#fff;
line-height:normal;
font-size:18px;
font-family:"微软雅黑", "宋体";
padding:10px 0px 0px 28px;
font-style:italic;
text-shadow:1px 1px #99ae3c;
}
.next_gw .go_next a:hover{
background:url(../images/go_next_hover.png) no-repeat;
}
/*for 购物车第2步*/
.gw_bz{
float:right;
width:41px;
height:44px;
background:url(../images/gw_bz.png) no-repeat;
line-height:44px;
padding-left:15px;
color:#fff;
font-style:italic;
font-size:18px;
font-weight:bold;
font-family:"微软雅黑", "宋体";
}
/*财物车登录*/
.gwc_login{
overflow:hidden;
width:898px;
margin-top:36px;
border-top:1px solid #dedede;
padding:85px 50px 85px 50px;
overflow:hidden;
font-family:"微软雅黑", "宋体";
}
.yzh{
float:left;
width:368px;
background:url(../images/gwc_login.png) right no-repeat;
padding-right:80px;
_padding-right:60px;
}
.yzh li{
width:368px;
float:left;
}
.gwc_login_title{
font-size:24px;
margin-bottom:35px;
}
.user{
margin-top:15px;
height:40px;
line-height:40px;
}
.user span{
float:left;
}
.user input{
border:1px solid #ececec;
border-radius:2px;
height:36px;
line-height:36px;
width:306px;
margin-left:26px;
*margin-left:13px;
color:#cfcfcf;
text-indent:1em;
font-size:16px;
}
.ds{
margin-top:15px;
}
.ds span{
float:left;
margin-right:15px;
font-size:16px;
color:#989898;
}
.ds a{
color:#989898;
font-size:14px;
}
.go_login{
margin-top:15px;
}
.go_login span{
float:right;
}
.go_login span button{
background:#ffa800;
color:#fff;
width:140px;
height:40px;
border:none;
border-radius:4px;
cursor:pointer;
font-size:16px;
font-family:"微软雅黑", "宋体";
}
.dsf{
margin:15px 0px 0px 10px;
float:left;
}
.dsf span{
float:left;
margin-right:13px;
}
.wzh{
float:left;
margin:50px 0px 0px 50px;
width:400px;
}
| 10npsite | trunk/Public/css/index.css | CSS | asf20 | 76,645 |
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html>
<head>
<title>页面提示</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv='Refresh' content='{$waitSecond};URL={$jumpUrl}'>
<style>
html, body{margin:0; padding:0; border:0 none;font:14px Tahoma,Verdana;line-height:150%;background:white}
a{text-decoration:none; color:#174B73; border-bottom:1px dashed gray}
a:hover{color:#F60; border-bottom:1px dashed gray}
div.message{margin:10% auto 0px auto;clear:both;padding:5px;border:1px solid silver; text-align:center; width:45%}
span.wait{color:blue;font-weight:bold}
span.error{color:red;font-weight:bold}
span.success{color:blue;font-weight:bold}
div.msg{margin:20px 0px}
</style>
</head>
<body>
<div class="message">
<div class="msg">
<present name="message" >
<span class="success">{$msgTitle}{$message}</span>
<else/>
<span class="error">{$msgTitle}{$error}</span>
</present>
</div>
<div class="tip">
<present name="closeWin" >
页面将在 <span class="wait">{$waitSecond}</span> 秒后自动关闭,如果不想等待请点击 <a href="{$jumpUrl}">这里</a> 关闭
<else/>
页面将在 <span class="wait">{$waitSecond}</span> 秒后自动跳转,如果不想等待请点击 <a href="{$jumpUrl}">这里</a> 跳转
</present>
</div>
</div>
</body>
</html> | 10npsite | trunk/DThinkPHP/Tpl/dispatch_jump.tpl | Smarty | asf20 | 1,434 |
<div id="think_page_trace" style="background:white;margin:6px;font-size:14px;border:1px dashed silver;padding:8px">
<fieldset id="querybox" style="margin:5px;">
<legend style="color:gray;font-weight:bold">页面Trace信息</legend>
<div style="overflow:auto;height:300px;text-align:left;">
<?php $_trace = trace();foreach ($_trace as $key=>$info){
echo $key.' : '.$info.'<br/>';
}?>
</div>
</fieldset>
</div> | 10npsite | trunk/DThinkPHP/Tpl/page_trace.tpl | Smarty | asf20 | 417 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>系统发生错误</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta name="Generator" content="EditPlus"/>
<style>
body{
font-family: 'Microsoft Yahei', Verdana, arial, sans-serif;
font-size:14px;
}
a{text-decoration:none;color:#174B73;}
a:hover{ text-decoration:none;color:#FF6600;}
h2{
border-bottom:1px solid #DDD;
padding:8px 0;
font-size:25px;
}
.title{
margin:4px 0;
color:#F60;
font-weight:bold;
}
.message,#trace{
padding:1em;
border:solid 1px #000;
margin:10px 0;
background:#FFD;
line-height:150%;
}
.message{
background:#FFD;
color:#2E2E2E;
border:1px solid #E0E0E0;
}
#trace{
background:#E7F7FF;
border:1px solid #E0E0E0;
color:#535353;
}
.notice{
padding:10px;
margin:5px;
color:#666;
background:#FCFCFC;
border:1px solid #E0E0E0;
}
.red{
color:red;
font-weight:bold;
}
</style>
</head>
<body>
<div class="notice">
<h2>系统发生错误 </h2>
<div >您可以选择 [ <A HREF="<?php echo(strip_tags($_SERVER['PHP_SELF']))?>">重试</A> ] [ <A HREF="javascript:history.back()">返回</A> ] 或者 [ <A HREF="<?php echo(__APP__);?>">回到首页</A> ]</div>
<?php if(isset($e['file'])) {?>
<p><strong>错误位置:</strong> FILE: <span class="red"><?php echo $e['file'] ;?></span> LINE: <span class="red"><?php echo $e['line'];?></span></p>
<?php }?>
<p class="title">[ 错误信息 ]</p>
<p class="message"><?php echo strip_tags($e['message']);?></p>
<?php if(isset($e['trace'])) {?>
<p class="title">[ TRACE ]</p>
<p id="trace">
<?php echo nl2br($e['trace']);?>
</p>
<?php }?>
</div>
<div align="center" style="color:#FF3300;margin:5pt;font-family:Verdana"><span style='color:silver'> { WWW.MZL5.COM }</span>
</div>
</body>
</html> | 10npsite | trunk/DThinkPHP/Tpl/think_exception.tpl | Smarty | asf20 | 1,954 |
<?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
public function index(){
header("Content-Type:text/html; charset=utf-8");
echo '<div style="font-weight:normal;color:blue;float:left;width:345px;text-align:center;border:1px solid silver;background:#E8EFFF;padding:8px;font-size:14px;font-family:Tahoma">^_^ Hello,欢迎使用<span style="font-weight:bold;color:red">ThinkPHP</span></div>';
}
} | 10npsite | trunk/DThinkPHP/Tpl/default_index.tpl | Smarty | asf20 | 467 |
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id: zh-cn.php 2702 2012-02-02 12:35:01Z liu21st $
/**
+------------------------------------------------------------------------------
* ThinkPHP 简体中文语言包
+------------------------------------------------------------------------------
* @category Think
* @package Lang
* @author liu21st <liu21st@gmail.com>
* @version $Id: zh-cn.php 2702 2012-02-02 12:35:01Z liu21st $
+------------------------------------------------------------------------------
*/
return array(
// 核心
'_MODULE_NOT_EXIST_'=> '无法加载模块',
'_ERROR_ACTION_'=> '非法操作',
'_LANGUAGE_NOT_LOAD_'=> '无法加载语言包',
'_TEMPLATE_NOT_EXIST_'=> '模板不存在',
'_MODULE_'=>'模块',
'_ACTION_'=>'操作',
'_ACTION_NOT_EXIST_'=>'控制器不存在或者没有定义',
'_MODEL_NOT_EXIST_'=>'模型不存在或者没有定义',
'_VALID_ACCESS_'=>'没有权限',
'_XML_TAG_ERROR_'=>'XML标签语法错误',
'_DATA_TYPE_INVALID_'=>'非法数据对象!',
'_OPERATION_WRONG_'=>'操作出现错误',
'_NOT_LOAD_DB_'=>'无法加载数据库',
'_NOT_SUPPORT_DB_'=>'系统暂时不支持数据库',
'_NO_DB_CONFIG_'=>'没有定义数据库配置',
'_NOT_SUPPERT_'=>'系统不支持',
'_CACHE_TYPE_INVALID_'=>'无法加载缓存类型',
'_FILE_NOT_WRITEABLE_'=>'目录(文件)不可写',
'_METHOD_NOT_EXIST_'=>'您所请求的方法不存在!',
'_CLASS_NOT_EXIST_'=>'实例化一个不存在的类!',
'_CLASS_CONFLICT_'=>'类名冲突',
'_TEMPLATE_ERROR_'=>'模板引擎错误',
'_CACHE_WRITE_ERROR_'=>'缓存文件写入失败!',
'_TAGLIB_NOT_EXIST_'=>'标签库未定义',
'_OPERATION_FAIL_'=>'操作失败!',
'_OPERATION_SUCCESS_'=>'操作成功!',
'_SELECT_NOT_EXIST_'=>'记录不存在!',
'_EXPRESS_ERROR_'=>'表达式错误',
'_TOKEN_ERROR_'=>'表单令牌错误',
'_RECORD_HAS_UPDATE_'=>'记录已经更新',
'_NOT_ALLOW_PHP_'=>'模板禁用PHP代码',
); | 10npsite | trunk/DThinkPHP/Lang/zh-cn.php | PHP | asf20 | 2,666 |
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id: alias.php 2702 2012-02-02 12:35:01Z liu21st $
if (!defined('THINK_PATH')) exit();
// 系统别名定义文件
return array(
'Model' => CORE_PATH.'Core/Model.class.php',
'Db' => CORE_PATH.'Core/Db.class.php',
'Log' => CORE_PATH.'Core/Log.class.php',
'ThinkTemplate' => CORE_PATH.'Template/ThinkTemplate.class.php',
'TagLib' => CORE_PATH.'Template/TagLib.class.php',
'Cache' => CORE_PATH.'Core/Cache.class.php',
'Widget' => CORE_PATH.'Core/Widget.class.php',
'TagLibCx' => CORE_PATH.'Driver/TagLib/TagLibCx.class.php',
); | 10npsite | trunk/DThinkPHP/Conf/alias.php | PHP | asf20 | 1,238 |
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id: convention.php 2756 2012-02-19 10:38:32Z liu21st $
/**
+------------------------------------------------------------------------------
* ThinkPHP惯例配置文件
* 该文件请不要修改,如果要覆盖惯例配置的值,可在项目配置文件中设定和惯例不符的配置项
* 配置名称大小写任意,系统会统一转换成小写
* 所有配置参数都可以在生效前动态改变
+------------------------------------------------------------------------------
* @category Think
* @package Common
* @author liu21st <liu21st@gmail.com>
* @version $Id: convention.php 2756 2012-02-19 10:38:32Z liu21st $
+------------------------------------------------------------------------------
*/
if (!defined('THINK_PATH')) exit();
return array(
/* 项目设定 */
'APP_STATUS' => 'debug', // 应用调试模式状态 调试模式开启后有效 默认为debug 可扩展 并自动加载对应的配置文件
'APP_FILE_CASE' => false, // 是否检查文件的大小写 对Windows平台有效
'APP_AUTOLOAD_PATH' => '',// 自动加载机制的自动搜索路径,注意搜索顺序
'APP_TAGS_ON' => true, // 系统标签扩展开关
'APP_SUB_DOMAIN_DEPLOY' => false, // 是否开启子域名部署
'APP_SUB_DOMAIN_RULES' => array(), // 子域名部署规则
'APP_SUB_DOMAIN_DENY' => array(), // 子域名禁用列表
'APP_GROUP_LIST' => '', // 项目分组设定,多个组之间用逗号分隔,例如'Home,Admin'
/* Cookie设置 */
'COOKIE_EXPIRE' => 3600, // Coodie有效期
'COOKIE_DOMAIN' => '', // Cookie有效域名
'COOKIE_PATH' => '/', // Cookie路径
'COOKIE_PREFIX' => '', // Cookie前缀 避免冲突
/* 默认设定 */
'DEFAULT_APP' => '@', // 默认项目名称,@表示当前项目
'DEFAULT_LANG' => 'zh-cn', // 默认语言
'DEFAULT_THEME' => '', // 默认模板主题名称
'DEFAULT_GROUP' => 'Home', // 默认分组
'DEFAULT_MODULE' => 'Index', // 默认模块名称
'DEFAULT_ACTION' => 'index', // 默认操作名称
'DEFAULT_CHARSET' => 'utf-8', // 默认输出编码
'DEFAULT_TIMEZONE' => 'PRC', // 默认时区
'DEFAULT_AJAX_RETURN' => 'JSON', // 默认AJAX 数据返回格式,可选JSON XML ...
'DEFAULT_FILTER' => 'htmlspecialchars', // 默认参数过滤方法 用于 $this->_get('变量名');$this->_post('变量名')...
/* 数据库设置 */
'DB_TYPE' => 'mysql', // 数据库类型
'DB_HOST' => 'localhost', // 服务器地址
'DB_NAME' => '', // 数据库名
'DB_USER' => 'root', // 用户名
'DB_PWD' => '', // 密码
'DB_PORT' => '', // 端口
'DB_PREFIX' => 'think_', // 数据库表前缀
'DB_FIELDTYPE_CHECK' => false, // 是否进行字段类型检查
'DB_FIELDS_CACHE' => true, // 启用字段缓存
'DB_CHARSET' => 'utf8', // 数据库编码默认采用utf8
'DB_DEPLOY_TYPE' => 0, // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
'DB_RW_SEPARATE' => false, // 数据库读写是否分离 主从式有效
'DB_MASTER_NUM' => 1, // 读写分离后 主服务器数量
'DB_SQL_BUILD_CACHE' => false, // 数据库查询的SQL创建缓存
'DB_SQL_BUILD_QUEUE' => 'file', // SQL缓存队列的缓存方式 支持 file xcache和apc
'DB_SQL_BUILD_LENGTH' => 20, // SQL缓存的队列长度
/* 数据缓存设置 */
'DATA_CACHE_TIME' => 0, // 数据缓存有效期 0表示永久缓存
'DATA_CACHE_COMPRESS' => false, // 数据缓存是否压缩缓存
'DATA_CACHE_CHECK' => false, // 数据缓存是否校验缓存
'DATA_CACHE_TYPE' => 'File', // 数据缓存类型,支持:File|Db|Apc|Memcache|Shmop|Sqlite|Xcache|Apachenote|Eaccelerator
'DATA_CACHE_PATH' => TEMP_PATH,// 缓存路径设置 (仅对File方式缓存有效)
'DATA_CACHE_SUBDIR' => false, // 使用子目录缓存 (自动根据缓存标识的哈希创建子目录)
'DATA_PATH_LEVEL' => 1, // 子目录缓存级别
/* 错误设置 */
'ERROR_MESSAGE' => '您浏览的页面暂时发生了错误!请稍后再试~',//错误显示信息,非调试模式有效
'ERROR_PAGE' => '', // 错误定向页面
'SHOW_ERROR_MSG' => false, // 显示错误信息
/* 日志设置 */
'LOG_RECORD' => false, // 默认不记录日志
'LOG_TYPE' => 3, // 日志记录类型 0 系统 1 邮件 3 文件 4 SAPI 默认为文件方式
'LOG_DEST' => '', // 日志记录目标
'LOG_EXTRA' => '', // 日志记录额外信息
'LOG_LEVEL' => 'EMERG,ALERT,CRIT,ERR',// 允许记录的日志级别
'LOG_FILE_SIZE' => 2097152, // 日志文件大小限制
'LOG_EXCEPTION_RECORD' => false, // 是否记录异常信息日志
/* SESSION设置 */
'SESSION_AUTO_START' => true, // 是否自动开启Session
'SESSION_OPTIONS' => array(), // session 配置数组 支持type name id path expire domian 等参数
'SESSION_TYPE' => '', // session hander类型 默认无需设置 除非扩展了session hander驱动
'SESSION_PREFIX' => '', // session 前缀
'VAR_SESSION_ID' => 'session_id', //sessionID的提交变量
/* 模板引擎设置 */
'TMPL_CONTENT_TYPE' => 'text/html', // 默认模板输出类型
'TMPL_ACTION_ERROR' => THINK_PATH.'Tpl/dispatch_jump.tpl', // 默认错误跳转对应的模板文件
'TMPL_ACTION_SUCCESS' => THINK_PATH.'Tpl/dispatch_jump.tpl', // 默认成功跳转对应的模板文件
'TMPL_EXCEPTION_FILE' => THINK_PATH.'Tpl/think_exception.tpl',// 异常页面的模板文件
'TMPL_DETECT_THEME' => false, // 自动侦测模板主题
'TMPL_TEMPLATE_SUFFIX' => '.html', // 默认模板文件后缀
'TMPL_FILE_DEPR'=>'/', //模板文件MODULE_NAME与ACTION_NAME之间的分割符,只对项目分组部署有效
/* URL设置 */
'URL_CASE_INSENSITIVE' => false, // 默认false 表示URL区分大小写 true则表示不区分大小写
'URL_MODEL' => 1, // URL访问模式,可选参数0、1、2、3,代表以下四种模式:
// 0 (普通模式); 1 (PATHINFO 模式); 2 (REWRITE 模式); 3 (兼容模式) 默认为PATHINFO 模式,提供最好的用户体验和SEO支持
'URL_PATHINFO_DEPR' => '/', // PATHINFO模式下,各模块和操作之间的分割符号
'URL_PATHINFO_DEPR_CAN' =>'-', //PATHINFO模式下,问号后各参数之间的分割符号
'URL_PATHINFO_FETCH' => 'ORIG_PATH_INFO,REDIRECT_PATH_INFO,REDIRECT_URL', // 用于兼容判断PATH_INFO 参数的SERVER替代变量列表
'URL_HTML_SUFFIX' => '', // URL伪静态后缀设置
/* 系统变量名称设置 */
'VAR_GROUP' => 'g', // 默认分组获取变量
'VAR_MODULE' => 'm', // 默认模块获取变量
'VAR_ACTION' => 'a', // 默认操作获取变量
'VAR_AJAX_SUBMIT' => 'ajax', // 默认的AJAX提交变量
'VAR_PATHINFO' => 's', // PATHINFO 兼容模式获取变量例如 ?s=/module/action/id/1 后面的参数取决于URL_PATHINFO_DEPR
'VAR_URL_PARAMS' => '_URL_', // PATHINFO URL参数变量
'VAR_TEMPLATE' => 't', // 默认模板切换变量
); | 10npsite | trunk/DThinkPHP/Conf/convention.php | PHP | asf20 | 8,480 |
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id: debug.php 2781 2012-02-24 05:31:47Z liu21st $
/**
+------------------------------------------------------------------------------
* ThinkPHP 默认的调试模式配置文件
* 如果项目有定义自己的调试模式配置文件,本文件无效
+------------------------------------------------------------------------------
* @category Think
* @package Common
* @author liu21st <liu21st@gmail.com>
* @version $Id: debug.php 2781 2012-02-24 05:31:47Z liu21st $
+------------------------------------------------------------------------------
*/
if (!defined('THINK_PATH')) exit();
// 调试模式下面默认设置 可以在项目配置目录下重新定义 debug.php 覆盖
return array(
'LOG_RECORD'=>true, // 进行日志记录
'LOG_EXCEPTION_RECORD' => true, // 是否记录异常信息日志
'LOG_LEVEL' => 'EMERG,ALERT,CRIT,ERR,WARN,NOTIC,INFO,DEBUG,SQL', // 允许记录的日志级别
'DB_FIELDS_CACHE'=> false, // 字段缓存信息
'APP_FILE_CASE' => true, // 是否检查文件的大小写 对Windows平台有效
'TMPL_CACHE_ON' => false, // 是否开启模板编译缓存,设为false则每次都会重新编译
'TMPL_STRIP_SPACE' => false, // 是否去除模板文件里面的html空格与换行
'SHOW_ERROR_MSG' => true, // 显示错误信息
); | 10npsite | trunk/DThinkPHP/Conf/debug.php | PHP | asf20 | 2,000 |
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id: mode.php 2702 2012-02-02 12:35:01Z liu21st $
/**
+------------------------------------------------------------------------------
* ThinkPHP 模式配置文件 定义格式
+------------------------------------------------------------------------------
* 包括: core 编译列表文件定义
* alias 项目类库别名定义
* extends 系统行为定义
* tags 应用行为定义
* config 模式配置定义
* common 项目公共文件定义
* 可以只定义其中一项或者多项 其他则取默认模式配置
+------------------------------------------------------------------------------
*/
return array(
// 系统核心列表文件定义 无需加载Portal Think Log ThinkException类库
// 需要纳入编译缓存的文件都可以在此定义 其中 App Action类库必须定义
// 不在编译列表中的类库 如果需要自动加载 可以定义别名列表
/*
例如:
'core' => array(
THINK_PATH.'Common/functions.php', // 标准模式函数库
CORE_PATH.'Core/Log.class.php', // 日志处理类
CORE_PATH.'Core/Dispatcher.class.php', // URL调度类
CORE_PATH.'Core/App.class.php', // 应用程序类
CORE_PATH.'Core/Action.class.php', // 控制器类
CORE_PATH.'Core/View.class.php', // 视图类
),*/
// 项目别名定义文件 [支持数组直接定义或者文件名定义]
// 例如 'alias' => CONF_PATH.'alias.php',
// 系统行为定义文件 [必须 支持数组直接定义或者文件名定义 ]
// 例如 'extends' => THINK_PATH.'Conf/tags.php',
// 项目应用行为定义文件 [支持数组直接定义或者文件名定义]
// 例如 'tags' => CONF_PATH.'tags.php',
// 项目公共文件
// 例如 'common' => COMMON_PATH.'common.php',
// 模式配置文件 [支持数组直接定义或者文件名定义](如有相同则覆盖项目配置文件中的配置)
// 例如 'config' => array(),
); | 10npsite | trunk/DThinkPHP/Conf/mode.php | PHP | asf20 | 2,727 |
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id: tags.php 2726 2012-02-11 13:34:24Z liu21st $
// 系统默认的核心行为扩展列表文件
return array(
'app_init'=>array(
),
'app_begin'=>array(
'ReadHtmlCache', // 读取静态缓存
),
'route_check'=>array(
'CheckRoute', // 路由检测
),
'app_end'=>array(),
'path_info'=>array(),
'action_begin'=>array(),
'action_end'=>array(),
'view_begin'=>array(),
'view_template'=>array(
'LocationTemplate', // 自动定位模板文件
),
'view_parse'=>array(
'ParseTemplate', // 模板解析 支持PHP、内置模板引擎和第三方模板引擎
),
'view_filter'=>array(
'ContentReplace', // 模板输出替换
'TokenBuild', // 表单令牌
'WriteHtmlCache', // 写入静态缓存
'ShowRuntime', // 运行时间显示
),
'view_end'=>array(
'ShowPageTrace', // 页面Trace显示
),
); | 10npsite | trunk/DThinkPHP/Conf/tags.php | PHP | asf20 | 1,580 |
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id: CacheFile.class.php 2791 2012-02-29 10:08:57Z liu21st $
/**
+------------------------------------------------------------------------------
* 文件类型缓存类
+------------------------------------------------------------------------------
* @category Think
* @package Think
* @subpackage Util
* @author liu21st <liu21st@gmail.com>
* @version $Id: CacheFile.class.php 2791 2012-02-29 10:08:57Z liu21st $
+------------------------------------------------------------------------------
*/
class CacheFile extends Cache {
/**
+----------------------------------------------------------
* 缓存存储前缀
+----------------------------------------------------------
* @var string
* @access protected
+----------------------------------------------------------
*/
protected $prefix='~@';
/**
+----------------------------------------------------------
* 架构函数
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
*/
public function __construct($options='') {
if(!empty($options)) {
$this->options = $options;
}
$this->options['temp'] = !empty($options['temp'])?$options['temp']:C('DATA_CACHE_PATH');
$this->options['expire'] = isset($options['expire'])?$options['expire']:C('DATA_CACHE_TIME');
$this->options['length'] = isset($options['length'])?$options['length']:0;
if(substr($this->options['temp'], -1) != '/') $this->options['temp'] .= '/';
$this->connected = is_dir($this->options['temp']) && is_writeable($this->options['temp']);
$this->init();
}
/**
+----------------------------------------------------------
* 初始化检查
+----------------------------------------------------------
* @access private
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
private function init() {
$stat = stat($this->options['temp']);
$dir_perms = $stat['mode'] & 0007777; // Get the permission bits.
$file_perms = $dir_perms & 0000666; // Remove execute bits for files.
// 创建项目缓存目录
if (!is_dir($this->options['temp'])) {
if (! mkdir($this->options['temp']))
return false;
chmod($this->options['temp'], $dir_perms);
}
}
/**
+----------------------------------------------------------
* 是否连接
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
private function isConnected() {
return $this->connected;
}
/**
+----------------------------------------------------------
* 取得变量的存储文件名
+----------------------------------------------------------
* @access private
+----------------------------------------------------------
* @param string $name 缓存变量名
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
*/
private function filename($name) {
$name = md5($name);
if(C('DATA_CACHE_SUBDIR')) {
// 使用子目录
$dir ='';
for($i=0;$i<C('DATA_PATH_LEVEL');$i++) {
$dir .= $name{$i}.'/';
}
if(!is_dir($this->options['temp'].$dir)) {
mk_dir($this->options['temp'].$dir);
}
$filename = $dir.$this->prefix.$name.'.php';
}else{
$filename = $this->prefix.$name.'.php';
}
return $this->options['temp'].$filename;
}
/**
+----------------------------------------------------------
* 读取缓存
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $name 缓存变量名
+----------------------------------------------------------
* @return mixed
+----------------------------------------------------------
*/
public function get($name) {
$filename = $this->filename($name);
if (!$this->isConnected() || !is_file($filename)) {
return false;
}
N('cache_read',1);
$content = file_get_contents($filename);
if( false !== $content) {
$expire = (int)substr($content,8, 12);
if($expire != 0 && time() > filemtime($filename) + $expire) {
//缓存过期删除缓存文件
unlink($filename);
return false;
}
if(C('DATA_CACHE_CHECK')) {//开启数据校验
$check = substr($content,20, 32);
$content = substr($content,52, -3);
if($check != md5($content)) {//校验错误
return false;
}
}else {
$content = substr($content,20, -3);
}
if(C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
//启用数据压缩
$content = gzuncompress($content);
}
$content = unserialize($content);
return $content;
}
else {
return false;
}
}
/**
+----------------------------------------------------------
* 写入缓存
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $name 缓存变量名
* @param mixed $value 存储数据
* @param int $expire 有效时间 0为永久
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
public function set($name,$value,$expire=null) {
N('cache_write',1);
if(is_null($expire)) {
$expire = $this->options['expire'];
}
$filename = $this->filename($name);
$data = serialize($value);
if( C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
//数据压缩
$data = gzcompress($data,3);
}
if(C('DATA_CACHE_CHECK')) {//开启数据校验
$check = md5($data);
}else {
$check = '';
}
$data = "<?php\n//".sprintf('%012d',$expire).$check.$data."\n?>";
$result = file_put_contents($filename,$data);
if($result) {
if($this->options['length']>0) {
// 记录缓存队列
$this->queue($name);
}
clearstatcache();
return true;
}else {
return false;
}
}
/**
+----------------------------------------------------------
* 删除缓存
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $name 缓存变量名
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
public function rm($name) {
return unlink($this->filename($name));
}
/**
+----------------------------------------------------------
* 清除缓存
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $name 缓存变量名
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
public function clear() {
$path = $this->options['temp'];
if ( $dir = opendir( $path ) ) {
while ( $file = readdir( $dir ) ) {
$check = is_dir( $file );
if ( !$check )
unlink( $path . $file );
}
closedir( $dir );
return true;
}
}
} | 10npsite | trunk/DThinkPHP/Lib/Driver/Cache/CacheFile.class.php | PHP | asf20 | 9,395 |
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id: DbMysql.class.php 2791 2012-02-29 10:08:57Z liu21st $
define('CLIENT_MULTI_RESULTS', 131072);
/**
+------------------------------------------------------------------------------
* Mysql数据库驱动类
+------------------------------------------------------------------------------
* @category Think
* @package Think
* @subpackage Db
* @author liu21st <liu21st@gmail.com>
* @version $Id: DbMysql.class.php 2791 2012-02-29 10:08:57Z liu21st $
+------------------------------------------------------------------------------
*/
class DbMysql extends Db{
/**
+----------------------------------------------------------
* 架构函数 读取数据库配置信息
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param array $config 数据库配置数组
+----------------------------------------------------------
*/
public function __construct($config=''){
if ( !extension_loaded('mysql') ) {
throw_exception(L('_NOT_SUPPERT_').':mysql');
}
if(!empty($config)) {
$this->config = $config;
if(empty($this->config['params'])) {
$this->config['params'] = array();
}
}
}
/**
+----------------------------------------------------------
* 连接数据库方法
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function connect($config='',$linkNum=0,$force=false) {
if ( !isset($this->linkID[$linkNum]) ) {
if(empty($config)) $config = $this->config;
// 处理不带端口号的socket连接情况
$host = $config['hostname'].($config['hostport']?":{$config['hostport']}":'');
// 是否长连接
$pconnect = !empty($config['params']['persist'])? $config['params']['persist']:$this->pconnect;
if($pconnect) {
$this->linkID[$linkNum] = mysql_pconnect( $host, $config['username'], $config['password'],CLIENT_MULTI_RESULTS);
}else{
$this->linkID[$linkNum] = mysql_connect( $host, $config['username'], $config['password'],true,CLIENT_MULTI_RESULTS);
}
if ( !$this->linkID[$linkNum] || (!empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) ) {
throw_exception(mysql_error());
}
$dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
if ($dbVersion >= '4.1') {
//使用UTF8存取数据库 需要mysql 4.1.0以上支持
mysql_query("SET NAMES '".C('DB_CHARSET')."'", $this->linkID[$linkNum]);
}
//设置 sql_model
if($dbVersion >'5.0.1'){
mysql_query("SET sql_mode=''",$this->linkID[$linkNum]);
}
// 标记连接成功
$this->connected = true;
// 注销数据库连接配置信息
if(1 != C('DB_DEPLOY_TYPE')) unset($this->config);
}
return $this->linkID[$linkNum];
}
/**
+----------------------------------------------------------
* 释放查询结果
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
*/
public function free() {
mysql_free_result($this->queryID);
$this->queryID = null;
}
/**
+----------------------------------------------------------
* 执行查询 返回数据集
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $str sql指令
+----------------------------------------------------------
* @return mixed
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function query($str) {
if(0===stripos($str, 'call')){ // 存储过程查询支持
$this->close();
}
$this->initConnect(false);
if ( !$this->_linkID ) return false;
$this->queryStr = $str;
//释放前次的查询结果
if ( $this->queryID ) { $this->free(); }
N('db_query',1);
// 记录开始执行时间
G('queryStartTime');
$this->queryID = mysql_query($str, $this->_linkID);
$this->debug();
if ( false === $this->queryID ) {
$this->error();
return false;
} else {
$this->numRows = mysql_num_rows($this->queryID);
return $this->getAll();
}
}
/**
+----------------------------------------------------------
* 执行语句
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $str sql指令
+----------------------------------------------------------
* @return integer
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function execute($str) {
$this->initConnect(true);
if ( !$this->_linkID ) return false;
$this->queryStr = $str;
//释放前次的查询结果
if ( $this->queryID ) { $this->free(); }
N('db_write',1);
// 记录开始执行时间
G('queryStartTime');
$result = mysql_query($str, $this->_linkID) ;
$this->debug();
if ( false === $result) {
$this->error();
return false;
} else {
$this->numRows = mysql_affected_rows($this->_linkID);
$this->lastInsID = mysql_insert_id($this->_linkID);
return $this->numRows;
}
}
/**
+----------------------------------------------------------
* 启动事务
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return void
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function startTrans() {
$this->initConnect(true);
if ( !$this->_linkID ) return false;
//数据rollback 支持
if ($this->transTimes == 0) {
mysql_query('START TRANSACTION', $this->_linkID);
}
$this->transTimes++;
return ;
}
/**
+----------------------------------------------------------
* 用于非自动提交状态下面的查询提交
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function commit() {
if ($this->transTimes > 0) {
$result = mysql_query('COMMIT', $this->_linkID);
$this->transTimes = 0;
if(!$result){
throw_exception($this->error());
}
}
return true;
}
/**
+----------------------------------------------------------
* 事务回滚
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function rollback() {
if ($this->transTimes > 0) {
$result = mysql_query('ROLLBACK', $this->_linkID);
$this->transTimes = 0;
if(!$result){
throw_exception($this->error());
}
}
return true;
}
/**
+----------------------------------------------------------
* 获得所有的查询数据
+----------------------------------------------------------
* @access private
+----------------------------------------------------------
* @return array
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
private function getAll() {
//返回数据集
$result = array();
if($this->numRows >0) {
while($row = mysql_fetch_assoc($this->queryID)){
$result[] = $row;
}
mysql_data_seek($this->queryID,0);
}
return $result;
}
/**
+----------------------------------------------------------
* 取得数据表的字段信息
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
*/
public function getFields($tableName) {
$result = $this->query('SHOW COLUMNS FROM '.$this->parseKey($tableName));
$info = array();
if($result) {
foreach ($result as $key => $val) {
$info[$val['Field']] = array(
'name' => $val['Field'],
'type' => $val['Type'],
'notnull' => (bool) ($val['Null'] === ''), // not null is empty, null is yes
'default' => $val['Default'],
'primary' => (strtolower($val['Key']) == 'pri'),
'autoinc' => (strtolower($val['Extra']) == 'auto_increment'),
);
}
}
return $info;
}
/**
+----------------------------------------------------------
* 取得数据库的表信息
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
*/
public function getTables($dbName='') {
if(!empty($dbName)) {
$sql = 'SHOW TABLES FROM '.$dbName;
}else{
$sql = 'SHOW TABLES ';
}
$result = $this->query($sql);
$info = array();
foreach ($result as $key => $val) {
$info[$key] = current($val);
}
return $info;
}
/**
+----------------------------------------------------------
* 替换记录
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param mixed $data 数据
* @param array $options 参数表达式
+----------------------------------------------------------
* @return false | integer
+----------------------------------------------------------
*/
public function replace($data,$options=array()) {
foreach ($data as $key=>$val){
$value = $this->parseValue($val);
if(is_scalar($value)) { // 过滤非标量数据
$values[] = $value;
$fields[] = $this->parseKey($key);
}
}
$sql = 'REPLACE INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES ('.implode(',', $values).')';
return $this->execute($sql);
}
/**
+----------------------------------------------------------
* 插入记录
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param mixed $datas 数据
* @param array $options 参数表达式
* @param boolean $replace 是否replace
+----------------------------------------------------------
* @return false | integer
+----------------------------------------------------------
*/
public function insertAll($datas,$options=array(),$replace=false) {
if(!is_array($datas[0])) return false;
$fields = array_keys($datas[0]);
array_walk($fields, array($this, 'parseKey'));
$values = array();
foreach ($datas as $data){
$value = array();
foreach ($data as $key=>$val){
$val = $this->parseValue($val);
if(is_scalar($val)) { // 过滤非标量数据
$value[] = $val;
}
}
$values[] = '('.implode(',', $value).')';
}
$sql = ($replace?'REPLACE':'INSERT').' INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES '.implode(',',$values);
return $this->execute($sql);
}
/**
+----------------------------------------------------------
* 关闭数据库
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
*/
public function close() {
if ($this->_linkID){
mysql_close($this->_linkID);
}
$this->_linkID = null;
}
/**
+----------------------------------------------------------
* 数据库错误信息
* 并显示当前的SQL语句
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
*/
public function error() {
$this->error = mysql_error($this->_linkID);
if($this->debug && '' != $this->queryStr){
$this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
}
return $this->error;
}
/**
+----------------------------------------------------------
* SQL指令安全过滤
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $str SQL字符串
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
*/
public function escapeString($str) {
if($this->_linkID) {
return mysql_real_escape_string($str,$this->_linkID);
}else{
return mysql_escape_string($str);
}
}
/**
+----------------------------------------------------------
* 字段和表名处理添加`
+----------------------------------------------------------
* @access protected
+----------------------------------------------------------
* @param string $key
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
*/
protected function parseKey(&$key) {
$key = trim($key);
if(!preg_match('/[,\'\"\*\(\)`.\s]/',$key)) {
$key = '`'.$key.'`';
}
return $key;
}
} | 10npsite | trunk/DThinkPHP/Lib/Driver/Db/DbMysql.class.php | PHP | asf20 | 16,652 |
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2007 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id: DbMysqli.class.php 2791 2012-02-29 10:08:57Z liu21st $
/**
+------------------------------------------------------------------------------
* Mysqli数据库驱动类
+------------------------------------------------------------------------------
* @category Think
* @package Think
* @subpackage Db
* @author liu21st <liu21st@gmail.com>
* @version $Id: DbMysqli.class.php 2791 2012-02-29 10:08:57Z liu21st $
+------------------------------------------------------------------------------
*/
class DbMysqli extends Db{
/**
+----------------------------------------------------------
* 架构函数 读取数据库配置信息
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param array $config 数据库配置数组
+----------------------------------------------------------
*/
public function __construct($config=''){
if ( !extension_loaded('mysqli') ) {
throw_exception(L('_NOT_SUPPERT_').':mysqli');
}
if(!empty($config)) {
$this->config = $config;
}
}
/**
+----------------------------------------------------------
* 连接数据库方法
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function connect($config='',$linkNum=0) {
if ( !isset($this->linkID[$linkNum]) ) {
if(empty($config)) $config = $this->config;
$this->linkID[$linkNum] = new mysqli($config['hostname'],$config['username'],$config['password'],$config['database'],$config['hostport']?intval($config['hostport']):3306);
if (mysqli_connect_errno()) throw_exception(mysqli_connect_error());
$dbVersion = $this->linkID[$linkNum]->server_version;
if ($dbVersion >= '4.1') {
// 设置数据库编码 需要mysql 4.1.0以上支持
$this->linkID[$linkNum]->query("SET NAMES '".C('DB_CHARSET')."'");
}
//设置 sql_model
if($dbVersion >'5.0.1'){
$this->linkID[$linkNum]->query("SET sql_mode=''");
}
// 标记连接成功
$this->connected = true;
//注销数据库安全信息
if(1 != C('DB_DEPLOY_TYPE')) unset($this->config);
}
return $this->linkID[$linkNum];
}
/**
+----------------------------------------------------------
* 释放查询结果
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
*/
public function free() {
$this->queryID->free_result();
$this->queryID = null;
}
/**
+----------------------------------------------------------
* 执行查询 返回数据集
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $str sql指令
+----------------------------------------------------------
* @return mixed
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function query($str) {
$this->initConnect(false);
if ( !$this->_linkID ) return false;
$this->queryStr = $str;
//释放前次的查询结果
if ( $this->queryID ) $this->free();
N('db_query',1);
// 记录开始执行时间
G('queryStartTime');
$this->queryID = $this->_linkID->query($str);
// 对存储过程改进
if( $this->_linkID->more_results() ){
while (($res = $this->_linkID->next_result()) != NULL) {
$res->free_result();
}
}
$this->debug();
if ( false === $this->queryID ) {
$this->error();
return false;
} else {
$this->numRows = $this->queryID->num_rows;
$this->numCols = $this->queryID->field_count;
return $this->getAll();
}
}
/**
+----------------------------------------------------------
* 执行语句
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $str sql指令
+----------------------------------------------------------
* @return integer
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function execute($str) {
$this->initConnect(true);
if ( !$this->_linkID ) return false;
$this->queryStr = $str;
//释放前次的查询结果
if ( $this->queryID ) $this->free();
N('db_write',1);
// 记录开始执行时间
G('queryStartTime');
$result = $this->_linkID->query($str);
$this->debug();
if ( false === $result ) {
$this->error();
return false;
} else {
$this->numRows = $this->_linkID->affected_rows;
$this->lastInsID = $this->_linkID->insert_id;
return $this->numRows;
}
}
/**
+----------------------------------------------------------
* 启动事务
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return void
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function startTrans() {
$this->initConnect(true);
//数据rollback 支持
if ($this->transTimes == 0) {
$this->_linkID->autocommit(false);
}
$this->transTimes++;
return ;
}
/**
+----------------------------------------------------------
* 用于非自动提交状态下面的查询提交
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function commit() {
if ($this->transTimes > 0) {
$result = $this->_linkID->commit();
$this->_linkID->autocommit( true);
$this->transTimes = 0;
if(!$result){
throw_exception($this->error());
}
}
return true;
}
/**
+----------------------------------------------------------
* 事务回滚
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function rollback() {
if ($this->transTimes > 0) {
$result = $this->_linkID->rollback();
$this->transTimes = 0;
if(!$result){
throw_exception($this->error());
}
}
return true;
}
/**
+----------------------------------------------------------
* 获得所有的查询数据
+----------------------------------------------------------
* @access private
+----------------------------------------------------------
* @param string $sql sql语句
+----------------------------------------------------------
* @return array
+----------------------------------------------------------
*/
private function getAll() {
//返回数据集
$result = array();
if($this->numRows>0) {
//返回数据集
for($i=0;$i<$this->numRows ;$i++ ){
$result[$i] = $this->queryID->fetch_assoc();
}
$this->queryID->data_seek(0);
}
return $result;
}
/**
+----------------------------------------------------------
* 取得数据表的字段信息
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function getFields($tableName) {
$result = $this->query('SHOW COLUMNS FROM '.$this->parseKey($tableName));
$info = array();
if($result) {
foreach ($result as $key => $val) {
$info[$val['Field']] = array(
'name' => $val['Field'],
'type' => $val['Type'],
'notnull' => (bool) ($val['Null'] === ''), // not null is empty, null is yes
'default' => $val['Default'],
'primary' => (strtolower($val['Key']) == 'pri'),
'autoinc' => (strtolower($val['Extra']) == 'auto_increment'),
);
}
}
return $info;
}
/**
+----------------------------------------------------------
* 取得数据表的字段信息
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function getTables($dbName='') {
$sql = !empty($dbName)?'SHOW TABLES FROM '.$dbName:'SHOW TABLES ';
$result = $this->query($sql);
$info = array();
if($result) {
foreach ($result as $key => $val) {
$info[$key] = current($val);
}
}
return $info;
}
/**
+----------------------------------------------------------
* 替换记录
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param mixed $data 数据
* @param array $options 参数表达式
+----------------------------------------------------------
* @return false | integer
+----------------------------------------------------------
*/
public function replace($data,$options=array()) {
foreach ($data as $key=>$val){
$value = $this->parseValue($val);
if(is_scalar($value)) { // 过滤非标量数据
$values[] = $value;
$fields[] = $this->parseKey($key);
}
}
$sql = 'REPLACE INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES ('.implode(',', $values).')';
return $this->execute($sql);
}
/**
+----------------------------------------------------------
* 插入记录
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param mixed $datas 数据
* @param array $options 参数表达式
* @param boolean $replace 是否replace
+----------------------------------------------------------
* @return false | integer
+----------------------------------------------------------
*/
public function insertAll($datas,$options=array(),$replace=false) {
if(!is_array($datas[0])) return false;
$fields = array_keys($datas[0]);
array_walk($fields, array($this, 'parseKey'));
$values = array();
foreach ($datas as $data){
$value = array();
foreach ($data as $key=>$val){
$val = $this->parseValue($val);
if(is_scalar($val)) { // 过滤非标量数据
$value[] = $val;
}
}
$values[] = '('.implode(',', $value).')';
}
$sql = ($replace?'REPLACE':'INSERT').' INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES '.implode(',',$values);
return $this->execute($sql);
}
/**
+----------------------------------------------------------
* 关闭数据库
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
*/
public function close() {
if ($this->_linkID){
$this->_linkID->close();
}
$this->_linkID = null;
}
/**
+----------------------------------------------------------
* 数据库错误信息
* 并显示当前的SQL语句
+----------------------------------------------------------
* @static
* @access public
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
*/
public function error() {
$this->error = $this->_linkID->error;
if($this->debug && '' != $this->queryStr){
$this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
}
return $this->error;
}
/**
+----------------------------------------------------------
* SQL指令安全过滤
+----------------------------------------------------------
* @static
* @access public
+----------------------------------------------------------
* @param string $str SQL指令
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
*/
public function escapeString($str) {
if($this->_linkID) {
return $this->_linkID->real_escape_string($str);
}else{
return addslashes($str);
}
}
/**
+----------------------------------------------------------
* 字段和表名处理添加`
+----------------------------------------------------------
* @access protected
+----------------------------------------------------------
* @param string $key
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
*/
protected function parseKey(&$key) {
$key = trim($key);
if(!preg_match('/[,\'\"\*\(\)`.\s]/',$key)) {
$key = '`'.$key.'`';
}
return $key;
}
} | 10npsite | trunk/DThinkPHP/Lib/Driver/Db/DbMysqli.class.php | PHP | asf20 | 16,187 |