/** * Tests the JWeb::getInstance method. * * @return void * * @since 11.3 */ public function testGetInstance() { $this->assertInstanceOf('JWebInspector', JWeb::getInstance('JWebInspector'), 'Tests that getInstance will instantiate a valid child class of JWeb.'); $this->inspector->setClassInstance('foo'); $this->assertThat(JWeb::getInstance('JWebInspector'), $this->equalTo('foo'), 'Tests that singleton value is returned.'); $this->inspector->setClassInstance(null); $this->assertInstanceOf('JWeb', JWeb::getInstance('Foo'), 'Tests that getInstance will instantiate a valid child class of JWeb given a non-existent type.'); }
// // You can append to the body of the response using appendBody. // // Set up the beginning of the HTML repsonse. $this->appendBody('<html>')->appendBody('<head>')->appendBody('<title>JWeb - Detect Client</title>')->appendBody('</head>')->appendBody('<body style="font-family:verdana;">'); // Introduce the page. $this->appendBody('<p>Welcome to the Joomla! Platform's <code style="font-size:140%">JWeb</code> class.</p>'); // Start a list. $this->appendBody('<ul>'); // // The client information is accessible via the get method. // // Get the user agent string. $this->appendBody(sprintf('<li>User-agent: <em>%s</em></li>', $this->client->userAgent)); // Determine if this is a mobile device. $this->appendBody(sprintf('<li>Is a mobile device? <em>%s</em></li>', $this->client->mobile ? 'Yes' : 'No')); // Get the platform. $this->appendBody(sprintf('<li>Platform: <em>%s</em></li>', $this->client->platform)); // Get the engine. $this->appendBody(sprintf('<li>Engine: <em>%s</em></li>', $this->client->engine)); // Get the browser and version. $this->appendBody(sprintf('<li>Browser: <em>%s (%s)</em></li>', $this->client->browser, $this->client->browserVersion)); $this->appendBody('</ul>'); // Finished up the HTML repsonse. $this->appendBody('</body>')->appendBody('</html>'); } } // Instantiate the application object, passing the class name to JWeb::getInstance // and use chaining to execute the application. JWeb::getInstance('DetectClient')->execute();
// Iterate through the elements in the stream. foreach ($reader->entry as $entry) { echo '<div class="cell">'; echo $entry->content->data(); echo '</div>'; } // Get the buffer output. $output = ob_get_clean(); // Push the output into the document buffer. $this->document->setBuffer($output, array('type' => 'component', 'name' => 'main')); } /** * Method to get the template name. This is needed for compatability with JApplication. * * @return string The theme name. * * @since 12.1 */ public function getTemplate() { return $this->get('theme'); } } // Instantiate the application. $application = JWeb::getInstance('FlickrFeed'); // Initialise the application. $application->initialise(); // Store the application. JFactory::$application = $application; // Execute the application. $application->execute();
*/ class HelloWww extends JWeb { /** * Overrides the parent doExecute method to run the web application. * * This method should include your custom code that runs the application. * * @return void * * @since 11.3 */ protected function doExecute() { // This application will just output a simple HTML document. // Use the setBody method to set the output. // JWeb will take care of all the headers and such for you. $this->setBody('<html> <head> <title>Hello WWW</title> </head> <body style="font-family:verdana;"> <p>Hello WWW!</p> </body> </html>'); } } // Instantiate the application object, passing the class name to JWeb::getInstance // and use chaining to execute the application. JWeb::getInstance('HelloWww')->execute();