[commits] [Wiki] changed: Doc/Dev/HordeAjaxApplications/Example
guest [187.224.52.153] Fri, 22 Dec 2023 03:00:49 + Modified page: https://wiki.horde.org/Doc/Dev/HordeAjaxApplications/Example New Revision: 6 Change log: Revert @@ -1,117 +1,22 @@ -++ Ajax Example using the skeleton App: - -This example uses the skeleton app to create an ajax function "helloAjax". This function takes a string as argument and returns a new string saying "Hello $string". - -1. Create the Ajax Handler Class: -- Create the Application folder: -# cd skeleton/lib/Ajax -# mkdir Application - -- Create a new file named "Handler.php" inside the skeleton/lib/Ajax/Application folder. -The Handler.php will contain the Skeleton_Ajax_Application_Handler Class. -Add the following content to this file: --- - --class Skeleton_Ajax_Application_Handler extends Horde_Core_Ajax_Application_Handler { - -public function helloAjax() { -$data = $this->vars->name; -$answer = 'Hello ' . $data; -return $answer; -} -} --- - -The argument of the helloAjax function is called "name". -To access the arguments you have to call "$this->vars->NAME_OF_THE_ARGUMENT". -In this example we store the value of "name" in a variable $data: -$data = $this->vars->name; -Then we create a new string saying "Hello $data" and return this new string. - -2. Load the Skeleton_Ajax_Application_Handler Class: -Open the skeleton/lib/Ajax/Application.php file and add the following line to the _init() function: --- -$this->addHandler('Skeleton_Ajax_Application_Handler'); --- - - -3. Call the helloAjax function via javascript: -- Create the skeleton/js folder: -# cd skeleton -# mkdir js - -- Create the skeleton/js/skeleton.js file with the following content: --- -SkeletonCore = { - -onDomLoad: function() -{ -var myName = 'Foobar'; -HordeCore.doAction('helloAjax', {name: Object.toJSON(myName)}, {callback: function(result) { -console.log('Ajax answer: ' + result); -}}); -} - -} -document.observe('dom:loaded', SkeletonCore.onDomLoad.bind(SkeletonCore)); --- - -The "myName" variable holds the string we want to send to the helloAjax funtion. -The helloAjax function is called by "HordeCore.doAction". -HordeCore.doAction takes three arguments: -1). Name of the Ajax function: -the helloAjax function we created in step 1. - -2). Argument list (in json format) of the Ajax function: -the "name" argument we accessed in step 1 via "$this->vars->name". - -3). A callback function to access the returned data of the Ajax function: -the "result" variable holds the "Hello $data" string we returned in step 1. - -Inside the callback we print the content of the "result" variable (Hello foobar) to the browser console. - - -4. Load the skeleton.js file. -Open the skeleton/list.php file and add the following line after "$page_output->addScriptFile('tables.js', 'horde');": --- - -$page_output->addScriptFile('skeleton.js'); - --- - -5. Test if everything works: -Access the skeleton app in your browser and open the console. If everything worked you'll see the following message: Ajax answer: Hello Foobar - - - -++ Pre git split - -*This below is outdated information. Use the horde git-tool command to create a new module* - - Boneyard - an example of a dynamic "skeleton". - + In this article, I will show you some minimal setup for a "horde5 dynamic view" application as demonstrated by hermes time tracking and kronolith calendar Pre-requisite We have a working git checkout of a 5.2 or master installation of horde with some authentication and prefs backend working and the migrations inplace. If your setup did not involve editing install_dev.conf, you probably have something else and I cannot guarantee this walkthrough will work for you without adopting some parts. - + Let's generate a fresh application called boneyard - maintaina:/srv/git/horde5-webmail/horde # php framework/bin/horde-generate-module boneyard "Ralf Lang " Started new Module in /srv/git/horde5-webmail/horde/boneyard! Register the new Module with a file in the config/registry.d directory: applications['boneyard'] = array('name' => _("Boneyard")); - We put a file with this oneliner into the directory as advised @@ -119,12 +24,11 @@ Now let's re-run the script generating the links for the git checkout installation - maintaina:/srv/git/horde5-webmail/horde # php framework/bin/install_dev EMPTYING old web directory /srv/www/vhosts.d/horde.ralf-lang.de - + LINKING horde Setting static directory permissions... LINKING applications to web directory /srv/www/vhosts.d/horde.ralf-lang.de LINKING sam @@ -153,35 +57,29 @@ [ INFO ] Package(s) to install: ALL (129 packages) [ INFO ] Installing package ActiveSync [.. snip ..] [ INFO ] Installing package xxhash - - Now boneyard is set up in your web-accessible dir. Let's make the config dir web-writeable - chown wwwrun:www
[commits] [Wiki] changed: Doc/Dev/HordeAjaxApplications/Example
rlang Wed, 23 May 2018 06:24:59 + Modified page: https://wiki.horde.org/Doc/Dev/HordeAjaxApplications/Example New Revision: 5 Change log: Marc Unger's new howto @@ -1,4 +1,97 @@ +++ Ajax Example using the skeleton App: + +This example uses the skeleton app to create an ajax function "helloAjax". This function takes a string as argument and returns a new string saying "Hello $string". + +1. Create the Ajax Handler Class: +- Create the Application folder: +# cd skeleton/lib/Ajax +# mkdir Application + +- Create a new file named "Handler.php" inside the skeleton/lib/Ajax/Application folder. +The Handler.php will contain the Skeleton_Ajax_Application_Handler Class. +Add the following content to this file: +-- + ++class Skeleton_Ajax_Application_Handler extends Horde_Core_Ajax_Application_Handler { + +public function helloAjax() { +$data = $this->vars->name; +$answer = 'Hello ' . $data; +return $answer; +} +} +-- + +The argument of the helloAjax function is called "name". +To access the arguments you have to call "$this->vars->NAME_OF_THE_ARGUMENT". +In this example we store the value of "name" in a variable $data: +$data = $this->vars->name; +Then we create a new string saying "Hello $data" and return this new string. + +2. Load the Skeleton_Ajax_Application_Handler Class: +Open the skeleton/lib/Ajax/Application.php file and add the following line to the _init() function: +-- +$this->addHandler('Skeleton_Ajax_Application_Handler'); +-- + + +3. Call the helloAjax function via javascript: +- Create the skeleton/js folder: +# cd skeleton +# mkdir js + +- Create the skeleton/js/skeleton.js file with the following content: +-- +SkeletonCore = { + +onDomLoad: function() +{ +var myName = 'Foobar'; +HordeCore.doAction('helloAjax', {name: Object.toJSON(myName)}, {callback: function(result) { +console.log('Ajax answer: ' + result); +}}); +} + +} +document.observe('dom:loaded', SkeletonCore.onDomLoad.bind(SkeletonCore)); +-- + +The "myName" variable holds the string we want to send to the helloAjax funtion. +The helloAjax function is called by "HordeCore.doAction". +HordeCore.doAction takes three arguments: +1). Name of the Ajax function: +the helloAjax function we created in step 1. + +2). Argument list (in json format) of the Ajax function: +the "name" argument we accessed in step 1 via "$this->vars->name". + +3). A callback function to access the returned data of the Ajax function: +the "result" variable holds the "Hello $data" string we returned in step 1. + +Inside the callback we print the content of the "result" variable (Hello foobar) to the browser console. + + +4. Load the skeleton.js file. +Open the skeleton/list.php file and add the following line after "$page_output->addScriptFile('tables.js', 'horde');": +-- + +$page_output->addScriptFile('skeleton.js'); + +-- + +5. Test if everything works: +Access the skeleton app in your browser and open the console. If everything worked you'll see the following message: Ajax answer: Hello Foobar + + + +++ Pre git split + +*This below is outdated information. Use the horde git-tool command to create a new module* + + Boneyard - an example of a dynamic "skeleton". In this article, I will show you some minimal setup for a "horde5 dynamic view" application as demonstrated by hermes time tracking and kronolith calendar -- commits mailing list Frequently Asked Questions: http://wiki.horde.org/FAQ To unsubscribe, mail: commits-unsubscr...@lists.horde.org
[commits] [Wiki] changed: Doc/Dev/HordeAjaxApplications/Example
rlang Wed, 16 Dec 2015 11:41:48 + Modified page: http://wiki.horde.org/Doc/Dev/HordeAjaxApplications/Example New Revision: 2 Change log: Try to show the code as code @@ -13,10 +13,10 @@ Started new Module in /srv/git/horde5-webmail/horde/boneyard! Register the new Module with a file in the config/registry.d directory: -applications['boneyard'] = array('name' => _("Boneyard")); +``applications['boneyard'] = array('name' => _("Boneyard"));`` We put a file with this oneliner into the directory as advised @@ -70,16 +70,16 @@ At this point, we do not care about the actual contents of this config - the defaults are just fine. If you only see "horde" and some library names, you most probably have not edited registry.local.php to contain something like: - Now "Boneyard" should appear in your horde topbar with some bogus buttons and content Let's create the structure of a "dynamic" application -- commits mailing list Frequently Asked Questions: http://wiki.horde.org/FAQ To unsubscribe, mail: commits-unsubscr...@lists.horde.org
[commits] [Wiki] changed: Doc/Dev/HordeAjaxApplications/Example
rlang Wed, 16 Dec 2015 11:44:37 + Modified page: http://wiki.horde.org/Doc/Dev/HordeAjaxApplications/Example New Revision: 4 Change log: goes on its own line @@ -8,15 +8,17 @@ Let's generate a fresh application called boneyard -maintaina:/srv/git/horde5-webmail/horde # php framework/bin/horde-generate-module boneyard "Ralf Lang" + +maintaina:/srv/git/horde5-webmail/horde # php framework/bin/horde-generate-module boneyard "Ralf Lang " Started new Module in /srv/git/horde5-webmail/horde/boneyard! Register the new Module with a file in the config/registry.d directory: applications['boneyard'] = array('name' => _("Boneyard")); +$this->applications['boneyard'] = array('name' => _("Boneyard")); + We put a file with this oneliner into the directory as advised @@ -24,9 +26,10 @@ Now let's re-run the script generating the links for the git checkout installation -maintaina:/srv/git/horde5-webmail/horde # php framework/bin/install_dev + +maintaina:/srv/git/horde5-webmail/horde # php framework/bin/install_dev EMPTYING old web directory /srv/www/vhosts.d/horde.ralf-lang.de LINKING horde Setting static directory permissions... @@ -56,30 +59,36 @@ [ INFO ] Package(s) to install: ALL (129 packages) [ INFO ] Installing package ActiveSync [.. snip ..] -[ INFO ] Installing package xxhash +[ INFO ] Installing package xxhash + + Now boneyard is set up in your web-accessible dir. Let's make the config dir web-writeable -chown wwwrun:www /srv/www/vhosts.d/horde.ralf-lang.de/boneyard/config + +chown wwwrun:www /srv/www/vhosts.d/horde.ralf-lang.de/boneyard/config + This is for SUSE - debian or redhat may have different user/group for the web server. Next go to $yourdomain/admin/config/ the admin panel and generate the conf.php file by clicking on the "boneyard" entry and then the "create boneyard config" button. At this point, we do not care about the actual contents of this config - the defaults are just fine. If you only see "horde" and some library names, you most probably have not edited registry.local.php to contain something like: - + +$app_fileroot = '/srv/www/vhosts.d/horde.ralf-lang.de/'; + Now "Boneyard" should appear in your horde topbar with some bogus buttons and content Let's create the structure of a "dynamic" application -- commits mailing list Frequently Asked Questions: http://wiki.horde.org/FAQ To unsubscribe, mail: commits-unsubscr...@lists.horde.org