整合:Xaraya:技术文档

来自站长百科
Firebrance讨论 | 贡献2008年11月7日 (五) 16:51的版本
跳转至: 导航、​ 搜索

Xaraya的Gallery2整合模块的技术文档。

包括的Hook

gallery2模块提供create,update,delete API hook和一个search GUI hook。API hook仅用于roles模块,因为这些hook被用作与G2的用户/组管理的同步。

所有的hook都应被激活。而它们在gallery2模块安装过程中就被自动激活了。如果这些hook不处于活动状态而需要激活的话,请打开管理面板(Admin panel) -> 模块(Modules) -> 配置hook(Configure Hooks)并点击gallery2链接。选择roles模块来启用用户/组的同步功能。

认证/会话管理

Xaraya负责认证并将经认证的用户递送给G2。xaraya和G2均具有各自的会话管理和cookies。唯一的区别就是,G2会在为相同用户创建会话之前先检查是否已存在一个xaraya会话。

用户-/组管理

Both applications still have their own user-/group management. But G2 is not allowed to initiate a change. Everytime you create, update or delete a role (user/group) in xaraya, the gallery2 module instantaneously creates, updates or deletes the user/group in G2. Same for group memberships. If you delete a user in xaraya, the G2 user receives a random password. That leaves the possibility to recall this role in xaraya. If you purge the role, it gets deleted in G2 too.

初始用户-/组同步

初始用户及组同步,即G2用户/组导入xaraya及xaraya角色向G2的导出,是基于唯一角色名称/ G2 userName / groupName之上的。有三类特殊组及一个特殊用户是经内部进行映射的:

  • xaraya: 'Everybody'被映射到G2: 'Everybody' (默认名称)
  • xaraya: 'Administrators'被映射到G2: 'Site Admins' (默认名称)
  • xaraya: 'Users' 被映射到G2: '?' (默认名称)
  • xaraya: 'anonymous'被映射到G2: 'guest' (默认名称)
  • 其他所有组/用户,包括管理员,都基于各自唯一用户名而经映射。

G2用户组和xaraya角色的导入/导出在你点击Modify Config 视图中的"Update Config"后就开始了,但仅当你所提供的config参量有效时才可行。

如果发生冲突,即在初始同步之前xaraya角色和G2用户/组唯一用户名皆相同的话,我们就会使用取自xaraya的数据来进行G2用户数据的更新。

  • 注:如果你希望映射某些特定用户/组的话,在配置该模块之前,确保它们在xaraya和G2中具有相同的唯一用户名。
  • 注:所有用户必须为G2 User用户组中的成员,但管理员绝不能是xaraya User用户组的成员。我们会处理这个问题的,因此在查看数据库时碰上了此类"不一致性"的话不要多想。

我们还会从G2中删除审核中的用户。如果他们还没有注册xaraya的话,看到这种变化之后就会注意到的,然后就会注册。:)

所有后继的同步(登入,登出,创建,更新,删除角色)都是基于xaraya uid至G2 entityId的映射上的。

权限/特权

你可以在G2中管理G2权限,而不用xaraya的roles/ privileges 模块。但所有的xaraya用户组也存在于G2中。所以只要为G2中的默认用户组/管理员组/所有人组指定权限,所有已注册用户/管理员/所有人就会具有相应的这些权限了。

更多相关信息请见有关Gallery2权限管理的资料。

可视化整合

不使用任何HTML框架。G2生成不带... section和标签的HTML并将其返回wrapper模块。接着我们将所有东西都放入一个几乎为空的xaraya模板。G2也会返回javascript,css和页面标题。而我们在创建的xaraya 页面中包括进所有东西。

如果你想自定义外观的话,可以选取某个现有G2外观主题作为开始。然后你可以自定义G2模板,外观主题和风格页来做进一步的细节调整。G2使用smarty作为自己的模板引擎,所以你可能已对G2外观主题的自创胸有成竹了。


菜单链接

TODO: 我们会将所有来自G2的菜单链接自动发送到xaraya,目的就是具有唯一的xaraya菜单。

搜素hook

TODO: 我们会添加一个搜索(search) hook这样就可以从xaraya搜索G2项目,评论…了。

URL,直接和间接请求

We configure G2 to run all requests through xaraya. The xaraya core sees that the request is intended for the gallery2 module and the gallery2 module passes the request to G2 itself.

The only exception are the download links/requests. G2 features an image firewall. Unlike ordinary gallery scripts, there's no way you can download any images from G2 than through the application. The developers of G2 spent a lot of effort in trying to reduce the time needed to process download requests. If all these download requests would run through the xaraya core before G2 received them, it'd be bloody slow. That's why all download links/requests go directly to G2, bypassing xaraya.

For now, xaraya short urls are not supported by this module. But you can activate the G2 Url rewrite module which generates also very nice URLs.

语言设定

Xaraya and G2 manage language settings the same way. There's a site wide language default, a user language setting and a language setting per session. A base module updateconfig hook synchronizes the site default language with G2 and on each request we hand over the current language setting of the active xaraya user to G2. If G2 has the language lang_COUNTRY installed, it sets the language accordingly, if not, it tries the fallback lang_ANYOTHERCOUNTRY, if that fails, it uses the old language setting.