From 500c5f3bf23f3dc5aed25702863c40f7d7df2b80 Mon Sep 17 00:00:00 2001 From: eddieajau Date: Wed, 21 Sep 2011 15:02:00 +1000 Subject: [PATCH] Removed examples tree (moved to https://github.com/joomla/joomla-platform-examples). --- examples/applications/101-hello-world/run.php | 60 -------- examples/applications/argv/run.php | 134 ------------------ .../applications/database/configuration.php | 70 --------- examples/applications/database/run.php | 124 ---------------- .../show-config/configuration.php | 48 ------- examples/applications/show-config/run.php | 125 ---------------- 6 files changed, 561 deletions(-) delete mode 100755 examples/applications/101-hello-world/run.php delete mode 100755 examples/applications/argv/run.php delete mode 100644 examples/applications/database/configuration.php delete mode 100755 examples/applications/database/run.php delete mode 100644 examples/applications/show-config/configuration.php delete mode 100755 examples/applications/show-config/run.php diff --git a/examples/applications/101-hello-world/run.php b/examples/applications/101-hello-world/run.php deleted file mode 100755 index 9c95f41b5b..0000000000 --- a/examples/applications/101-hello-world/run.php +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/php -out('Hello world!'); - } -} - -// Instantiate the application object, passing the class name to JCli::getInstance -// and use chaining to execute the application. -JCli::getInstance('HelloWorld')->execute(); diff --git a/examples/applications/argv/run.php b/examples/applications/argv/run.php deleted file mode 100755 index 865963c6ce..0000000000 --- a/examples/applications/argv/run.php +++ /dev/null @@ -1,134 +0,0 @@ -#!/usr/bin/php -out(); - $this->out('JOOMLA PLATFORM ARGV EXAMPLE'); - $this->out('============================'); - $this->out(); - - // You can look for named command line arguments in the form of: - // (a) -n value - // (b) --name=value - // - // Try running file like this: - // $ ./run.php -fa - // $ ./run.php -f foo - // $ ./run.php --set=match - // - // The values are accessed using the $this->input->get() method. - // $this->input is an instance of a JInputCli object. - - // This is an example of an option using short args (-). - $value = $this->input->get('a'); - $this->out( - sprintf( - '%25s = %s', 'a', - var_export($value, true) - ) - ); - - $value = $this->input->get('f'); - $this->out( - sprintf( - '%25s = %s', 'f', - var_export($value, true) - ) - ); - - // This is an example of an option using long args (--). - $value = $this->input->get('set'); - $this->out( - sprintf( - '%25s = %s', 'set', - var_export($value, true) - ) - ); - - // You can also apply defaults to the command line options. - $value = $this->input->get('f', 'default'); - $this->out( - sprintf( - '%25s = %s', 'f (with default)', - var_export($value, true) - ) - ); - - // You can also apply input filters found in the JFilterInput class. - // Try running this file like this: - // $ ./run.php -f one2 - - $value = $this->input->get('f', 0, 'INT'); - $this->out( - sprintf( - '%25s = %s', 'f (cast to int)', - var_export($value, true) - ) - ); - - // Print out all the remaining command line arguments used to run this file. - if (!empty($this->input->args)) - { - $this->out(); - $this->out('These are the remaining arguments passed:'); - $this->out(); - - // Unallocated arguments are found in $this->input->args. - // Try running the file like this: - // $ ./run.php -f foo bar - - foreach ($this->input->args as $arg) - { - $this->out($arg); - } - } - - // Print a blank line at the end. - $this->out(); - } -} - -// Instantiate the application object, passing the class name to JCli::getInstance -// and use chaining to execute the application. -JCli::getInstance('Argv')->execute(); diff --git a/examples/applications/database/configuration.php b/examples/applications/database/configuration.php deleted file mode 100644 index 0fa07f5ad0..0000000000 --- a/examples/applications/database/configuration.php +++ /dev/null @@ -1,70 +0,0 @@ -dbo = JDatabase::getInstance( - array( - 'driver' => $this->get('dbDriver'), - 'host' => $this->get('dbHost'), - 'user' => $this->get('dbUser'), - 'password' => $this->get('dbPass'), - 'database' => $this->get('dbName'), - 'prefix' => $this->get('dbPrefix'), - ) - ); - } - - /** - * Execute the application. - * - * @return void - * - * @since 11.3 - */ - public function execute() - { - // Get the quey builder class from the database. - $query = $this->dbo->getQuery(true); - - // Set up a query to select everything in the 'db' table. - $query->select('*') - ->from($this->dbo->qn('db')); - - // Push the query builder object into the database connector. - $this->dbo->setQuery($query); - - // Get all the returned rows from the query as an array of objects. - $rows = $this->dbo->loadObjectList(); - - // Just dump the value returned. - var_dump($rows); - } -} - -// Wrap the execution in a try statement to catch any exceptions thrown anywhere in the script. -try -{ - // Instantiate the application object, passing the class name to JCli::getInstance - // and use chaining to execute the application. - JCli::getInstance('DatabaseApp')->execute(); -} -catch (Exception $e) -{ - // An exception has been caught, just echo the message. - fwrite(STDOUT, $e->getMessage() . "\n"); - exit($e->getCode()); -} diff --git a/examples/applications/show-config/configuration.php b/examples/applications/show-config/configuration.php deleted file mode 100644 index ddfde5e3b9..0000000000 --- a/examples/applications/show-config/configuration.php +++ /dev/null @@ -1,48 +0,0 @@ -out(); - $this->out('Configuration settings loaded from configuration.php:'); - - // JCli will automatically look for and load 'configuration.php'. - // Use the 'get' method to access any configuration properties. - $this->out( - sprintf( - '%-25s = %2d', 'Default weapon strength', - $this->get('weapons') - ) - ); - - $this->out( - sprintf( - '%-25s = %2d', 'Default armour rating', - $this->get('armour') - ) - ); - - $this->out( - sprintf( - '%-25s = %4.1f', 'Default health level', - $this->get('health') - ) - ); - - // Print a blank line and new heading. - $this->out(); - $this->out('System settings:'); - - // There are also a number of built in properties available, for example: - $this->out( - sprintf( - '%-25s = %s', 'cwd', - $this->get('cwd') - ) - ); - - $this->out( - sprintf( - '%-25s = %s', 'execution.timestamp', - $this->get('execution.timestamp') - ) - ); - - $this->out( - sprintf( - '%-25s = %s', 'execution.timestamp', - $this->get('execution.timestamp') - ) - ); - - // Print a blank line and new heading. - $this->out(); - $this->out('Custom settings:'); - - // We can also make custom settings during the execution of the the application using the 'set' method. - $this->set('race', 'elf'); - - $this->out( - sprintf( - '%-25s = %s', 'Race', - $this->get('race') - ) - ); - - // Finish up. - $this->out(); - $this->out('Thanks for playing!'); - $this->out(); - } -} - -// Instantiate the application object, passing the class name to JCli::getInstance -// and use chaining to execute the application. -JCli::getInstance('ShowConfig')->execute();