从头开始创建JFusion插件

场景 (The Scenario)

A problem that all businesses face, when creating a dynamic website, either for the first time or to expand on a new venture, is what software to use. Everyone has a vague idea of what forms of content they want, and systems for user interaction, but there’s never an absolute solution for all.

所有企业在创建动态网站时(无论是首次创建还是扩展新业务)都面临的问题是使用什么软件。 每个人对他们想要什么形式的内容以及用于用户交互的系统都有一个模糊的想法,但是从来没有一个绝对的解决方案。

“无限扩展”的局限性 (Limitations of ‘limitless extending’)

To overcome this problem, the most common approach is to have one platform and build or extend it to meet the needs. With software like Joomla or WordPress, this can be achieved with plugins/extensions. Even so, the complex functionality some businesses may require, may not be available as a plugin, and could require a large investment in a proprietary plugin or extension that costs a lot of money to make and maintain. And may become outdated in functionality, or cause problems for further business expansion.

为了克服这个问题,最常见的方法是拥有一个平台并构建或扩展它以满足需求。 使用Joomla或WordPress之类的软件,可以通过插件/扩展来实现。 即使这样,某些企业可能需要的复杂功能,可能无法作为插件使用,并且可能需要大量投资于专有的插件或扩展程序,而这会花费大量的制造和维护费用。 并且可能在功能上过时,或对进一步的业务扩展造成问题。

Relyiance on paying for existing commercial addons can also cause some negative implications when it comes to tweaking paid-for code. From not having the legal option, because of the licenses involved, or the developers don’t provide a straight forward way to achieve your tweaks, if their addons are too simplified and fit a blackbox standard (serve an easily identifiable purpose but no one knows how it actually functions).

在调整付费代码时,依靠为现有的商业附加组件付费还可能带来一些负面影响。 如果他们的加载项过于简化并符合黑匣子标准(出于易于识别的目的,但没人知道),则由于所涉及的许可,或者由于涉及的许可证而没有法律选择权,或者开发人员没有提供直接的方法来进行调整实际运作方式)。

结合“量身定制”软件 (Combining ‘tailored for a specific purpose’ software)

Another option to limitless extending, is to use multiple software pieces that each serve a specific purpose, and just rely on using a different piece of software for the different online environments you need to offer. The only problem with this approach is keeping data intact that would most likely be the same in either software, and transitioning from one software to another smooth as well.

无限扩展的另一种选择是使用多个软件,每个软件都有特定的用途,并且仅依赖于为需要提供的不同在线环境使用不同的软件。 这种方法的唯一问题是保持完整的数据(很可能在两个软件中都是相同的),以及从一个软件平稳过渡到另一个软件。

In particular, the main areas site owners would consider to be seamless are:

特别是,站点所有者认为无缝的主要区域是:

  • Themes/Templates

    主题/模板
  • User credentials and personal information

    用户凭证和个人信息
  • Generic user actions

    通用用户操作

Themes can be an issue with smaller companies, as it can often to too expensive to contract someone to craft a theme compatible with their setup. Already employed designers may not harbor the required experties to clone a theme that’ll work with a particular platform.

对于较小的公司而言,主题可能是个问题,因为与某人签约以制作与他们的设置兼容的主题通常过于昂贵。 已经聘用的设计师可能没有必要的专业知识来克隆可以在特定平台上使用的主题。

JFusion的来历 (Where JFusion comes in)

JFusion is, as of this article, the most popular user integration extension for Joomla to integrate users with Joomla from other PHP software seamlessly, by syncing user data. The extension uses it’s own plugin system (known as JFusion plugins) which can be created to support any other software, so long as you can figure out the inner workings of the other software. Most likely from looking at the documentation, code comments, and good old hacking. For the developer that wants to tie users from Joomla across to other software without worrying about creating an entire framework of their own from scratch, this extension is the best of it’s kind in the open source space and will save you a lifetime of coding.

截至本文,JFusion是Joomla最受欢迎的用户集成扩展,可通过同步用户数据将用户与其他PHP软件的Joomla无缝集成。 该扩展使用它自己的插件系统(称为JFusion插件),可以创建该插件系统以支持任何其他软件,只要您能弄清楚其他软件的内部工作原理即可。 很可能是通过查看文档,代码注释和良好的旧黑客技巧。 对于希望将Joomla的用户与其他软件联系在一起的开发人员,而不必担心从头开始创建自己的整个框架,此扩展是开源领域中同类产品中最好的,并且可以节省您的编码工作时间。

The user integration implementations this extension offers are the most common you can find from other software which you can currently offer for any plugin you create:

该扩展程序提供的用户集成实现是最常见的,您可以从其他软件中找到,这些软件当前可以为您创建的任何插件提供:

  • Dual login (SSO)

    双重登入(SSO)
  • Dual logout

    双重登出
  • Dual registration

    双重注册
  • Template integration

    模板整合
  • Activity integration

    活动整合
  • User sync

    用户同步
  • Delete multiple instances of user

    删除用户的多个实例
  • Change password from multiple instances of user

    从多个用户实例更改密码

安装JFusion (Installing JFusion)

To install JFusion head over to the JFusion website. Once there you can download it directly.

要安装JFusion,请转到JFusion网站 。 在那里,您可以直接下载。

When ready, head over to your Joomla site (preferably a testing server, not production) which you feel comfortable to test in during the stages of development of your JFusion plugin. Be sure to have your admin credentials ready and go to the administrator page of Joomla (http://yoursite.com/joomla/administrator) and login.

准备就绪后,请转到您的Joomla站点(最好是测试服务器,而不是生产服务器),您可以在JFusion插件开发阶段轻松进行测试。 确保准备好管理员凭据,然后转到Joomla的管理员页面(http://yoursite.com/joomla/administrator)并登录。

Once you’re logged in click the extension manager logo (icon below) or select it from the main menu by going to extensions, then ‘extension manager’.

登录后,单击扩展程序管理器徽标(下面的图标),或者从主菜单中选择扩展名,然后选择“扩展管理器”。

This will lead you to the extension manager page, where there’s several options for installing extensions. Look for ‘Upload Package File’, inside this box is an upload field to add and install Joomla extensions. Without extracting the archive you just downloaded click ‘choose’ and find the jfusion download and confirm uploading it.

这将带您进入扩展管理器页面,其中有几个用于安装扩展的选项。 查找“上传软件包文件”,此框内是一个上传字段,用于添加和安装Joomla扩展。 在不提取您刚刚下载的档案的情况下,单击“选择”并找到文件下载并确认上传。

Once the file has uploaded you should see a new page with a blue installation confirmation message at the top of the screen similar to the screen-shot below.

上载文件后,您将在屏幕顶部看到一个带有蓝色安装确认消息的新页面,类似于以下屏幕截图。

Along with this, you should see a list of installed components that this plugin depends on (see screen-shot below). Make sure each item on the list corresponds with a tick to confirm the items successful installation. If any items have a cross next to them, reinstall, or request support on the JFusion site.

与此同时,您应该看到此插件依赖的已安装组件的列表(请参见下面的屏幕截图)。 确保列表中的每个项目都带有一个勾号,以确认项目已成功安装。 如果任何项目旁边有叉号,请在JFusion站点上重新安装或请求支持。

Now that everything is installed you can configure the main plugin, known as the master. This needs to be configured to allow all the other plugins to function and allocates which software the user actions occur before triggering the effects onto other software.

现在已经安装了所有内容,您可以配置称为主插件的主插件。 需要对此进行配置,以允许所有其他插件运行并分配用户操作在触发效果到其他软件之前执行的软件。

配置主插件 (Configuring the master plugin)

To configure the master plugin select ‘Joomla Options’ from the JFusion menu, which is the components menu (components > JFusion > Joomla Options), or go to components > cPanel and select ‘Joomla Options’.

要配置主插件,请从组件菜单(组件> JFusion> Joomla选项)的JFusion菜单中选择“ Joomla选项”,或转到组件> cPanel并选择“ Joomla选项”。

This will bring you to a page that allows you to edit the configuration of (what is currently) the only master plugin (master plugin applies to current joomla installation) that can be enabled in JFusion due to the current restrictions of the framework.

这将带您进入一个页面,该页面允许您编辑(当前)唯一可以在JFusion中启用的主插件(主插件适用于当前的joomla安装)的配置(由于框架的当前限制)。

By default, thanks to the settings, JFusion can figure out automatically that you won’t actually need to configure any special requirements for the site at this stage, and you can simply click ‘apply’ or ‘save’ and the plugin should now be ready for enabling.

默认情况下,由于设置,JFusion可以自动确定您实际上不需要在此阶段配置该站点的任何特殊要求,您只需单击“应用”或“保存”,该插件现在应为准备启用。

Select ‘Configure Plugins’ from the JFusion menu. On this page you will see a table filled with a list of plugins you can use by default with JFusion. At this stage all the boxes should be grayed out except for the row with the plugin called joomla_int (Joomla internal plugin, what we’ve just been working with). This row should be filled mostly with red crosses in each box and a few grayed out boxes, with the exception of one column labelled ‘Status’ which should contain a green tick with the words ‘good config’ written next to it if the configuration was automatically detected.

从JFusion菜单中选择“配置插件”。 在此页面上,您将看到一个表格,其中列出了您可以默认在JFusion中使用的插件列表。 在此阶段,除了带有名为joomla_int的插件(Joomla内部插件,我们一直在使用的插件)的行之外,所有框均应显示为灰色。 此行应在每个框内大多数都用红叉填充,并在一些灰色框内填充,但标有“状态”的一栏除外,该列应包含一个绿色的勾号,如果配置为则在其旁边写上“好配置”字样。自动检测到。

Click the red cross on the ‘joomla_int’ row which corresponds to the ‘Master’ Column and you should now see a line of configuration settings similar to the screen-shot below:

单击与“主”列相对应的“ joomla_int”行上的红叉,现在您应该会看到类似于以下屏幕截图的一行配置设置:

If you do, JFusion will now be ready to work on your site and you can simply pick any pre-developed plugin you want to configure to setup as a slave plugin with your Joomla site, or start work on your plugin, both of which I’ll be covering.

如果这样做,JFusion现在可以在您的站点上工作了,您只需选择要配置为Joomla站点设置为从属插件的任何预先开发的插件,或者就可以开始在您的插件上进行工作,会掩盖的。

JFusion默认提供什么 (What JFusion offers by default)

The current developers and contributors of JFusion have already created plugins which are included (but not configured) within the extension by default.

JFusion的当前开发人员和贡献者已经创建了默认情况下包含(但未配置)在扩展中的插件。

As of JFusion 1.6, the current plugins are available for the different software you can setup JFusion with, without any coding within a matter of minutes. These plugin folders (with plugin files inside) can be found in the joomla/administrator/components/com_jfusion/plugins folder.

从JFusion 1.6开始,当前的插件可用于您可以设置JFusion的各种软件,而无需在几分钟内进行任何编码。 这些插件文件夹(其中包含插件文件)可以在joomla / administrator / components / com_jfusion / plugins文件夹中找到。

  • DokuWiki

    DokuWiki
  • eFront

    eFront
  • Elgg

    埃尔格
  • Gallery2

    图库2
  • External Joomla site (synching users from one joomla to another)

    外部Joomla网站(将用户从一个joomla同步到另一个)
  • Internal Joomla site (IMPORTANT: This allows the JFusion operations that happen within Joomla)

    内部Joomla网站(重要信息:这允许在Joomla中进行JFusion操作)
  • Magento

    Magento
  • MediaWiki

    MediaWiki
  • Moodle

    面条
  • MyBB

    MyBB
  • OSCommerce

    OSCommerce
  • phpBB3

    phpBB3
  • PrestaShop

    PrestaShop
  • SMF

    SMF
  • SMF2

    SMF2
  • vBulletin

    v公告
  • WordPress

    WordPress的

There’s other plugins available on the JFusion third party plugin forum, that have been created by people that you should check out, that way you can see if what you want to integrate hasn’t already been previously developed.

JFusion第三方插件论坛上还有其他可用的插件,这些插件是由您应该签出的人员创建的,这样您就可以查看要集成的内容之前是否尚未开发。

These plugins are only limited to support from the authors if the author chooses, and there’s no guarantee of the plugin being functional, bug free, or safe. None the less the option is always there, and most third party plugins like JFusion are open source and free to modifications or code contributions.

这些插件仅在作者选择的情况下才能得到作者的支持,并且不能保证插件功能正常,无错误或安全。 尽管如此,该选项始终存在,并且大多数第三方插件(如JFusion)都是开源的,并且可以自由修改或贡献代码。

创建自己的插件 (Creating your own plugin)

Before coding a plugin, you first need to consider what you’re setting out to achieve. JFusion allows you to sync and work with all variations of user data, but you don’t necessarily need to comply with offering all the different functionality that the JFusion framework offers. You only need to incorporate what aspects you or anyone else would use.

在对插件进行编码之前,您首先需要考虑要实现的目标。 JFusion允许您同步和处理用户数据的所有变体,但不一定需要提供JFusion框架提供的所有不同功能。 您只需要合并您或任何其他人将使用的方面。

如何创建一个空白插件 (How to create a blank plugin)

Whenever you create a new plugin for JFusion, you must always use the following structure, making sure to also mimic file names exactly as stated. This folder and the contained files go inside the directory joomla/administrator/components/com_jfusion/plugins/:

每当为JFusion创建新插件时,都必须始终使用以下结构,并确保也完全按照规定模仿文件名。 该文件夹和包含的文件位于目录joomla / administrator / components / com_jfusion / plugins /中:

Folder

nameofyourplugin

您的插件名称

(Replace nameofyourplugin with the actual name of your software in the style represented above which is letters only, lowercase, no spaces or special characters).

(将nameofyourplugin替换为上面表示的样式的软件实际名称,该名称只能是字母,小写字母,无空格或特殊字符)。

文件夹内 (Inside of the folder)

Inside the folder, create 5 blank files with specific filenames and file type extensions, see below. These files , and the folder they are contained in, are absolutely mandatory for any plugin.

在该文件夹内,创建5个空白文件,这些文件具有特定的文件名和文件类型扩展名,请参见下文。 这些文件及其包含的文件夹对于任何插件都是绝对必需的。

admin.php

admin.php

This contains functions specific to the administration of JFusion, and your plugin, such as deleting users and configuring the aspects of integration.

它包含特定于JFusion和您的插件管理的功能,例如删除用户和配置集成方面。

auth.php

auth.php

This contains functions that handle formatting data and preparing it for the authentication processes that are required to occur when working around other platforms with custom data encryption methods.

它包含一些功能,这些功能可以处理数据格式并为在使用自定义数据加密方法的其他平台上工作时需要进行的身份验证过程做准备。

index.html

index.html

Simply, a static html file with some very basic text to fend off people peaking into your development directories.

简单地说,一个带有一些非常基础文本的静态html文件可以抵御那些进入您的开发目录的人们。

jfusion.xml

jfusion.xml

A common practice, used in a lot of web software now, is to provide an xml file containing documentation about the plugin itself, such as author, date created, and so on. It also contains templating information for the configuration page of the plugin which will be explained later.

现在,许多Web软件中使用的一种常见做法是提供一个xml文件,其中包含有关插件本身的文档,例如作者,创建日期等。 它还包含插件配置页面的模板信息,稍后将进行说明。

public.php

public.php

A file containing a collection of functions for use within any other function of this plugins php files (an include file).

包含用于此插件的任何其他功能的php文件(包括文件)的功能集合的文件。

user.php

user.php

This file contains functions relevant to the user sync operations you want to perform.

该文件包含与您要执行的用户同步操作相关的功能。

You can also create any number of other files of any type within this folder, and incorporate any dependencies on the custom files you have created, simply by including them in the primary plugin files that depend on them.

您还可以在此文件夹中创建任意数量的任何其他类型的其他文件,并将对您创建的自定义文件的任何依赖关系合并在一起,只需将它们包括在依赖于它们的主插件文件中即可。

快速笔记 (Quick note)

For the purpose of this tutorial I am using eyeOS as the software I want to integrate with the plugin wrote in this tutorial although the approach and techniques in these tutorials will apply to all plugins.

就本教程而言,我将eyeOS用作要与本教程中编写的插件集成的软件,尽管这些教程中的方法和技术将适用于所有插件。

下一步是什么? (What’s next?)

This tutorial is part of the series and this continues on in another part next week.

本教程是该系列的一部分,下周将继续进行。

翻译自: https://www.sitepoint.com/creating-a-jfusion-plugin-from-scratch/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值