Exemplo n.º 1
0
 /**
  * Allows public access to protected method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function respond()
 {
     return parent::respond();
 }
Exemplo n.º 2
0
 /**
  * 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.');
 }
Exemplo n.º 3
0
        // 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();
Exemplo n.º 4
0
        //
        // 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&apos;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();
Exemplo n.º 5
0
 /**
  * Returns a reference to the global JWeb object, only creating it if it doesn't already exist.
  *
  * This method must be invoked as: $web = JWeb::getInstance();
  *
  * @param   string  $name  The name (optional) of the JWeb class to instantiate.
  *
  * @return  JWeb
  *
  * @since   11.3
  */
 public static function getInstance($name = null)
 {
     // Only create the object if it doesn't exist.
     if (empty(self::$instance)) {
         if (class_exists($name) && is_subclass_of($name, 'JWeb')) {
             self::$instance = new $name();
         } else {
             self::$instance = new JWeb();
         }
     }
     return self::$instance;
 }
Exemplo n.º 6
0
*/
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();