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

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.

主站蜘蛛池模板: 永州市| 宿州市| 读书| 高安市| 东丽区| 江阴市| 甘南县| 唐河县| 南宫市| 台北市| 威海市| 壤塘县| 黑龙江省| 东至县| 闽清县| 溧水县| 鹤峰县| 宁海县| 北票市| 承德市| 新巴尔虎右旗| 永寿县| 寿光市| 建阳市| 仙游县| 广州市| 南投市| 隆化县| 万全县| 开原市| 肇州县| 罗平县| 隆德县| 嵊泗县| 栾城县| 临沭县| 射洪县| 二连浩特市| 手游| 婺源县| 武冈市|