官术网_书友最值得收藏!

Moodle's API

Moodle's API is a mix of library functions and classes. Moodle was originally based on the version 4 series of PHP, and as such, most of its API is built around functions defined in PHP library files. However, some of the newer constructs of Moodle use object-oriented structures and as such provide extensible classes.

Most of Moodle's main libraries are kept in the /lib/ directory. All of these files generally adhere to the naming convention [function]lib.php. Some of the examples are textlib.php and weblib.php. These library files contain Moodle's API.

Almost all of the core libraries are included in the execution stream when you load config.php via its inclusion of /lib/setup.php. The setup.php file includes these via the following lines:

require_once($CFG->libdir .'/textlib.class.php'); // Functions to handle multibyte strings
require_once($CFG->libdir .'/weblib.php'); // Functions for producing HTML
require_once($CFG->libdir .'/dmllib.php'); // Functions to handle DB data (DML)
require_once($CFG->libdir .'/datalib.php'); // Legacy lib with a big-mix of functions.
require_once($CFG->libdir .'/accesslib.php'); // Access control functions
require_once($CFG->libdir .'/deprecatedlib.php'); // Deprecated functions included for backward compatibility
require_once($CFG->libdir .'/moodlelib.php'); // Other general-purpose functions
require_once($CFG->libdir .'/eventslib.php'); // Events functions
require_once($CFG->libdir .'/grouplib.php'); // Groups functions

These by no means define all of the functions available in Moodle, and in fact each of these libraries may include other libraries. However, the core of the functions that you will need are contained within these libraries. In fact, the ones that you will need to look at the most are:

  • moodlelib.php
  • weblib.php
  • dmllib.php
  • accesslib.php
  • grouplib.php

There are many other libraries that you will use, as you start to carry out specific functions. Most of these are stored in the /lib/ directory. However, others may be in specific functional areas such as /course/ and /blocks/.

Many of the specific libraries define classes that you can use. Libraries such as /lib/pagelib.php and /lib/formslib.php define classes that are designed to be extended in order to handle output to screen. pagelib.php defines specific page types, with all of the functions necessary to manage page output and create your own page types. Likewise, formslib.php defines Moodle's implementation of the PEAR QuickForm classes in order to handle web-based forms.

There is no single, all-encompassing document for all of Moodle's API. However, you can find out more about each specific area in the developer documentation at Moodle Docs. A good place to start is http://docs.moodle.org/en/Development:Developer_documentation#Core_components_that_affect_everything.

Another resource that can help is the Moodle code cross reference. This is an online resource that is generated from the code and inline comments in order to produce documentation. It is generated automatically by using PHPXref. The reference can be found at http://docs.moodle.org/en/Development:Code_Cross-Reference. Note that it may not be up-to-date and maintained. Still, it does provide an easy overview.

主站蜘蛛池模板: 遵义县| 广汉市| 荔浦县| 绥中县| 邮箱| 观塘区| 灌南县| 周宁县| 驻马店市| 九寨沟县| 沈丘县| 新巴尔虎左旗| 同江市| 准格尔旗| 红桥区| 宁陕县| 永定县| 游戏| 华容县| 怀化市| 和林格尔县| 吴桥县| 大悟县| 山阳县| 视频| 庐江县| 同仁县| 昌图县| 兴国县| 云安县| 泸定县| 赞皇县| 廊坊市| 饶阳县| 连平县| 丘北县| 奈曼旗| 双鸭山市| 会理县| 永川市| 成武县|