Deploying an Automated Joomla! Updates Server

Дата добавления:
02.01.2017
Последнее изменение:
12.01.2017
Хиты:
4672
Рейтинг:
 
Голосовать:
Хорошо - Плохо

Ответ

As of version 1.6, Joomla! has featured an update system. If you are an extension developer, starting from January 10, 2017 you will be required to use the Joomla! Update System in order for your extensions to be listed on Joomla! Extensions Directory.

As a part of the Update System, you must launch an updates server on your site. For detail, see Joomla! Update System Requirement in Joomla! Extensions Directory knowledge base.

This tutorial describes how to get an updates server up and running in less than 10 minutes using DW Anything Studio. The server will be connected to your downloads system to publish the updates automatically.

The Basics

You'll need your server to render an XML document by the request from Joomla! Update System. Based upon data from your downloads system, this document should provide an information about the latest version of your extension available for download from your site.

For the purposes of this tutorial, we'll connect the updates server to the Phoca Download component, but the principles described below could be applied to the other download systems as well.

Requirements

In order to deploy an updates server, you'll need the following:

  • DW Anything Studio installed on your publicly available site

  • Database client, e.g. PhpMyAdmin.

Creating a DW Anything Studio Template

  1. On your downloads site with DW Anything Studio, go to administrator panel.

  2. Click ComponentsDW AnythingTemplates to open DW Anything Studio templates management page.

  3. Click New to create a new template.

  4. Copy the following text and paste it into the Source code text box.

    <updates>
        <update>
           <name>{$data.item.name}</name>
           <description>{$data.item.description}</description>
           <element>{$data.item.element}</element>
           <type>{$data.item.type}</type>
           <version>{$data.item.version}</version>
           <downloads>
               <downloadurl type="full" format="zip">{$data.item.downloadurl}</downloadurl>
           </downloads>
           <tags>
               <tag>stable</tag>
           </tags>
           <targetplatform name="joomla" version="3.6"/>
        </update>
    </updates>
  5. In the Template name box, type update_server_xml.

  6. Click Save & close.

Preparing Database Schema

At this point you need to analyse your downloads component database tables to check if it holds all of the information you need to fill in the server XML response as defined the template on a previous step.

You'll have to figure out, which data is already available from you downloads component and could be mapped to your template's variables directly, and which one needs to be supplied from elsewhere. To store the missing data, you should create and fill in an auxiliary table.

The table below lists all of the template variables and the results of the analysis of the #__phocadownload[1] table, containing the list of files available for download via Phoca Download component.

Table B.5. The analysis of the #__phocadownload database table

Template Variable Name (brackets and $ sign omitted)DescriptionPossible Mapping from #__phocadownload TableColumns Required in Auxiliary Table
data.item.name The extension name as appears in the name column of the Extension Manager's Update view title
data.item.description A brief description of your extension Can also be a title, optionally combined with some general descriptive text, such as Update of .... This could be done via query later on
data.item.element The installed name of the extension. For plugins, this needs to be same as plugin attribute value for main file in plugin manifest. For <filename plugin="pluginname">pluginname.php</filename>, element value should be pluginname element
data.item.type Type of the extension (component, module, plugin, etc.) type
data.item.downloadurl The URL to download the extension update from Check the format of the actual download URLs on your site and build it from data in downloads component table.
You'll also need an id_phocadownload column to link an auxiliary table record to the downloads item

 

You can also include some other optional fields in your server's response XML, as described in Deploying an Update Server on Joomla! Documentation site.

Next, add the auxiliary database table #__dwa_update_server to your database.

  1. Open your database in database client such as PhpMyAdmin etc.

  2. Execute the following database query (be sure to replace #__ with actual database prefixes used on your site):

    CREATE TABLE `#__dwa_update_server` (
    `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `element` VARCHAR(255) NOT NULL,
    `type` VARCHAR(255) NOT NULL,
    `id_phocadownload` INT(11) UNSIGNED NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `FK_#__dwa_update_server_#__phocadownload` (`id_phocadownload`),
    CONSTRAINT `FK_#__dwa_update_server_#__phocadownload` FOREIGN KEY (`id_phocadownload`) 
      REFERENCES `#__phocadownload` (`id`) ON DELETE CASCADE
    )
    COMMENT='Update server definitions for DW Anything'
    COLLATE='utf8_general_ci'
    ;
  3. Add a record to database table to store any additional data and link it to an appropriate record in #__phocadownload table. Take a note of the value of an id column (primary key) of this record. It will be used to build an update server URL later on.

Defining a DW Anything Studio Dataset

  1. Go to the Datasets list (ComponentsDW AnythingDatasets administrator panel menu) and click New to create a dataset.

  2. Enter the following dataset parameters.

    Table B.6. Updates server dataset parameters

    ParameterValueDescription
    Dataset name update_server_data
  3. Click Save and Close.

  4. DW Anything Studio takes you to the Add Dataset Query form to define an SQL query to fetch data from database.

  5. Enter the following query parameters:

    Table B.7. Updates server query parameters

    ParameterValueDescription
    Parent query root This is a top-level query
    Query name item The article data will be stored as the item variable. Note that the query name must be alphanumeric
    Query source SELECT s.*, d.title AS name, CONCAT(d.title, ' download available') AS description, d.version AS version, CONCAT('http://yoursite.com/category/', d.catid, '.html?download=', d.id) AS downloadurl FROM #__dwa_update_server s LEFT JOIN #__phocadownload d ON s.id_phocadownload = d.id WHERE s.id = '{param.request.key}'

    Note how the downloadurl value is formed. Form the URL according to your downloads component's URL routing rules.

    Be sure to replace yoursite.com with an actual name of your downloads server

    Single row yes The single row of data will be stored as a variable
  6. Click Save & Close.

Defining a DW Anything Studio Document

  1. Go to the Documents list (ComponentsDW AnythingDocuments administrator panel menu) and click New to create a document.

  2. Enter the following document parameters.

    Table B.8. Updates server document parameters

    ParameterValueDescription
    Document name update_server
    Template update_server_xml Assigning a previously defined template to a document
    Dataset update_server_data Assigning a previously defined dataset to a document
  3. Click Save & Close.

  4. Take a note of the value shown in an ID column of the documents list. This value will be used to build an update server URL later on.

Adding Updates Support to Your Extension Package

In your extensions manifest file, within the root extension element, add the following code.

 <extension>
 <...>
 <updateservers>
    <server type="extension" priority="1" name="My Extension's Updates">
http://example.com/index.php?option=com_dwanything&amp;
id=dwanything_document_id&amp;format=raw&amp;key=id_from_aux_table
</server>
 </updateservers>
 </extension>

Important! The server tag must be a single line of text, no line breaks! The line breaks in this documentation are added for clarity only.

Replace dwanything_document_id with an id of a record with additional information stored as described in Defining a DW Anything Studio Document above.

Replace id_from_aux_table with an id of a record with additional information stored as described in Preparing Database Schema above.

See also



[1] Use actual database prefix instead of the #__ characters here and below.

Категория

Добавить комментарий


Защитный код
Обновить

SEO by Artio