add description of function

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10764 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
chschy 2012-06-05 05:33:14 +00:00
parent 5a510567d1
commit ebfe89ca32
10 changed files with 243 additions and 120 deletions

View file

@ -2,7 +2,7 @@
/**
* @class DisplayHandler
* @author NHN (developers@xpressengine.com)
* @brief DisplayHandler is responsible for displaying the execution result. \n
* DisplayHandler is responsible for displaying the execution result. \n
* Depending on the request type, it can display either HTML or XML content.\n
* Xml content is simple xml presentation of variables in oModule while html content
* is the combination of the variables of oModue and template files/.
@ -16,11 +16,11 @@
var $handler = null;
/**
* @brief print either html or xml content given oModule object
* @remark addon execution and the trigger execution are included within this method, which
* might create inflexibility for the fine grained caching
* @param[in] $oModule the module object
**/
* print either html or xml content given oModule object
* @remark addon execution and the trigger execution are included within this method, which might create inflexibility for the fine grained caching
* @param ModuleObject $oModule the module object
* @return void
**/
function printContent(&$oModule) {
// Check if the gzip encoding supported
if(
@ -82,9 +82,10 @@
/**
* @brief Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n
* This method only functions when __DEBUG__ variable is set to 1.
* __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php
* Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n
* This method only functions when __DEBUG__ variable is set to 1.
* __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php
* @return void
**/
function _debugOutput() {
if(!__DEBUG__) return;
@ -221,7 +222,8 @@
}
/**
* @brief print a HTTP HEADER for XML, which is encoded in UTF-8
* print a HTTP HEADER for XML, which is encoded in UTF-8
* @return void
**/
function _printXMLHeader() {
header("Content-Type: text/xml; charset=UTF-8");
@ -234,7 +236,8 @@
/**
* @brief print a HTTP HEADER for HTML, which is encoded in UTF-8
* print a HTTP HEADER for HTML, which is encoded in UTF-8
* @return void
**/
function _printHTMLHeader() {
header("Content-Type: text/html; charset=UTF-8");
@ -247,7 +250,8 @@
/**
* @brief print a HTTP HEADER for JSON, which is encoded in UTF-8
* print a HTTP HEADER for JSON, which is encoded in UTF-8
* @return void
**/
function _printJSONHeader() {
header("Content-Type: text/html; charset=UTF-8");
@ -260,7 +264,8 @@
/**
* @brief print a HTTP HEADER for HTML, which is encoded in UTF-8
* print a HTTP HEADER for HTML, which is encoded in UTF-8
* @return void
**/
function _printHttpStatusCode($code) {
$statusMessage = Context::get('http_status_message');

View file

@ -2,8 +2,9 @@
class HTMLDisplayHandler {
/**
* @brief Produce HTML compliant content given a module object.\n
* @param[in] $oModule the module object
* Produce HTML compliant content given a module object.\n
* @param ModuleObject $oModule the module object
* @return string compiled template string
**/
function toDoc(&$oModule)
{
@ -79,6 +80,11 @@ class HTMLDisplayHandler {
return $output;
}
/**
* when display mode is HTML, prepare code before print.
* @param string $output compiled template string
* @return void
**/
function prepareToPrint(&$output) {
if(Context::getResponseMethod() != 'HTML') return;
@ -151,6 +157,11 @@ class HTMLDisplayHandler {
$oModuleController->replaceDefinedLangCode($output);
}
/**
* when display mode is HTML, prepare code before print about <input> tag value.
* @param array $match input value.
* @return string input value.
**/
function _preserveValue($match)
{
$INPUT_ERROR = Context::get('INPUT_ERROR');
@ -181,6 +192,11 @@ class HTMLDisplayHandler {
return $str.' />';
}
/**
* when display mode is HTML, prepare code before print about <select> tag value.
* @param array $matches select tag.
* @return string select tag.
**/
function _preserveSelectValue($matches)
{
$INPUT_ERROR = Context::get('INPUT_ERROR');
@ -200,6 +216,11 @@ class HTMLDisplayHandler {
return $mm[0].implode('', $m[0]).'</select>';
}
/**
* when display mode is HTML, prepare code before print about <textarea> tag value.
* @param array $matches textarea tag information.
* @return string textarea tag
**/
function _preserveTextAreaValue($matches)
{
$INPUT_ERROR = Context::get('INPUT_ERROR');
@ -208,23 +229,29 @@ class HTMLDisplayHandler {
}
/**
* @brief add html style code extracted from html body to Context, which will be
* add html style code extracted from html body to Context, which will be
* printed inside <header></header> later.
* @param[in] $oModule the module object
* @param array $matches
* @return void
**/
function _moveStyleToHeader($matches) {
Context::addHtmlHeader($matches[0]);
}
/**
* @brief add given .css or .js file names in widget code to Context
* @param[in] $oModule the module object
* add given .css or .js file names in widget code to Context
* @param array $matches
* @return void
**/
function _transMeta($matches) {
if($matches[1]) return '';
Context::loadFile($matches[2]);
}
/**
* import basic .js files.
* @return void
**/
function _loadJSCSS()
{
$oContext =& Context::getInstance();
@ -260,6 +287,10 @@ class HTMLDisplayHandler {
}
}
/**
* add meta tag.
* @return void
**/
function _addMetaTag()
{
$oContext =& Context::getInstance();

View file

@ -1,6 +1,11 @@
<?php
class JSONDisplayHandler {
/**
* Produce JSON compliant content given a module object.\n
* @param ModuleObject $oModule the module object
* @return string
**/
function toDoc(&$oModule)
{
$variables = $oModule->getVariables();

View file

@ -2,8 +2,9 @@
class VirtualXMLDisplayHandler {
/**
* @brief Produce virtualXML compliant content given a module object.\n
* @param[in] $oModule the module object
* Produce virtualXML compliant content given a module object.\n
* @param ModuleObject $oModule the module object
* @return string
**/
function toDoc(&$oModule)

View file

@ -2,8 +2,9 @@
class XMLDisplayHandler {
/**
* @brief Produce XML compliant content given a module object.\n
* @param[in] $oModule the module object
* Produce XML compliant content given a module object.\n
* @param ModuleObject $oModule the module object
* @return string
**/
function toDoc(&$oModule)
{
@ -21,8 +22,9 @@ class XMLDisplayHandler {
}
/**
* @brief produce XML code given variable object\n
* @param[in] $oModule the module object
* produce XML code given variable object\n
* @param object $obj
* @return string
**/
function _makeXmlDoc($obj) {
if(!count($obj)) return;

View file

@ -10,7 +10,9 @@
class EditorHandler extends Object {
/**
* @brief set the xml and other information of the component
* set the xml and other information of the component
* @param object $info editor information
* @return void
**/
function setInfo($info) {
Context::set('component_info', $info);

View file

@ -2,7 +2,7 @@
/**
* @class ModuleHandler
* @author NHN (developers@xpressengine.com)
* @brief Handling modules
* Handling modules
*
* @remarks This class is to excute actions of modules.
* Constructing an instance without any parameterconstructor, it finds the target module based on Context.
@ -23,8 +23,13 @@
var $httpStatusCode = NULL; ///< http status code.
/**
* @brief constructor
* @remarks it prepares variables to use in moduleHandler
* prepares variables to use in moduleHandler
* @param string $module name of module
* @param string $act name of action
* @param int $mid
* @param int $document_srl
* @param int $module_srl
* @return void
**/
function ModuleHandler($module = '', $act = '', $mid = '', $document_srl = '', $module_srl = '') {
// If XE has not installed yet, set module as install
@ -63,8 +68,8 @@
}
/**
* @brief Initialization. It finds the target module based on module, mid, document_srl, and prepares to execute an action
* @return true: OK, false: redirected
* Initialization. It finds the target module based on module, mid, document_srl, and prepares to execute an action
* @return boolean true: OK, false: redirected
**/
function init() {
$oModuleModel = &getModel('module');
@ -172,8 +177,8 @@
}
/**
* @brief get a module instance and execute an action
* @return executed module instance
* get a module instance and execute an action
* @return ModuleObject executed module instance
**/
function procModule() {
$oModuleModel = &getModel('module');
@ -458,6 +463,10 @@
return $oModule;
}
/**
* set error message to Session.
* @return void
**/
function _setInputErrorToContext()
{
if($_SESSION['XE_VALIDATOR_ERROR'] && !Context::get('XE_VALIDATOR_ERROR')) Context::set('XE_VALIDATOR_ERROR', $_SESSION['XE_VALIDATOR_ERROR']);
@ -468,6 +477,10 @@
$this->_clearErrorSession();
}
/**
* clear error message to Session.
* @return void
**/
function _clearErrorSession()
{
$_SESSION['XE_VALIDATOR_ERROR'] = '';
@ -476,6 +489,10 @@
$_SESSION['XE_VALIDATOR_RETURN_URL'] = '';
}
/**
* occured error when, set input values to session.
* @return void
**/
function _setInputValueToSession()
{
$requestVars = Context::getRequestVars();
@ -484,9 +501,9 @@
}
/**
* @brief display contents from executed module
* @param[in] $oModule module instance
* @return none
* display contents from executed module
* @param ModuleObject $oModule module instance
* @return void
**/
function displayContent($oModule = NULL) {
// If the module is not set or not an object, set error
@ -594,20 +611,20 @@
}
/**
* @brief returns module's path
* @param[in] $module module name
* @return path of the module
* returns module's path
* @param string $module module name
* @return string path of the module
**/
function getModulePath($module) {
return sprintf('./modules/%s/', $module);
}
/**
* @brief It creates a module instance
* @param[in] $module module name
* @param[in] $type instance type, (e.g., view, controller, model)
* @param[in] $kind admin or svc
* @return module instance (if failed it returns null)
* It creates a module instance
* @param string $module module name
* @param string $type instance type, (e.g., view, controller, model)
* @param string $kind admin or svc
* @return ModuleObject module instance (if failed it returns null)
* @remarks if there exists a module instance created before, returns it.
**/
function &getModuleInstance($module, $type = 'view', $kind = '') {
@ -696,10 +713,10 @@
}
/**
* @brief call a trigger
* @param[in] $trigger_name trigger's name to call
* @param[in] $called_position called position
* @param[in] $obj an object as a parameter to trigger
* call a trigger
* @param string $trigger_name trigger's name to call
* @param string $called_position called position
* @param object $obj an object as a parameter to trigger
* @return Object
**/
function triggerCall($trigger_name, $called_position, &$obj) {
@ -728,7 +745,9 @@
}
/**
* @brief get http status message by http status code
* get http status message by http status code
* @param string $code
* @return string
**/
function _setHttpStatusMessage($code) {
$statusMessageList = array(

View file

@ -2,7 +2,7 @@
/**
* @class ModuleObject
* @author NHN (developers@xpressengine.com)
* @brief base class of ModuleHandler
* base class of ModuleHandler
**/
class ModuleObject extends Object {
@ -30,16 +30,18 @@
var $module_config = NULL;
/**
* @brief setter to set the name of module
* @param name of module
* setter to set the name of module
* @param string $module name of module
* @return void
**/
function setModule($module) {
$this->module = $module;
}
/**
* @brief setter to set the name of module path
* @param the directory path to a module directory
* setter to set the name of module path
* @param string $path the directory path to a module directory
* @return void
**/
function setModulePath($path) {
if(substr($path,-1)!='/') $path.='/';
@ -47,25 +49,28 @@
}
/**
* @brief setter to set an url for redirection
* @param $url url for redirection
* setter to set an url for redirection
* @param string $url url for redirection
* @remark redirect_url is used only for ajax requests
* @return void
**/
function setRedirectUrl($url='./') {
$this->add('redirect_url', $url);
}
/**
* @brief get url for redirection
* get url for redirection
* @return string redirect_url
**/
function getRedirectUrl(){
return $this->get('redirect_url');
}
/**
* @brief set message
* @param $message a message string
* @param $type type of message (error, info, update)
* set message
* @param string $message a message string
* @param string $type type of message (error, info, update)
* @return void
**/
function setMessage($message, $type = null){
parent::setMessage($message);
@ -73,15 +78,17 @@
}
/**
* @brief set type of message
* @param $type type of message (error, info, update)
* set type of message
* @param string $type type of message (error, info, update)
* @return void
**/
function setMessageType($type){
$this->add('message_type', $type);
}
/**
* @brief get type of message
* get type of message
* @return string $type
**/
function getMessageType(){
$type = $this->get('message_type');
@ -92,9 +99,10 @@
}
/**
* @brief sett to set the template path for refresh.html
* @remark refresh.html is executed as a result of method execution
* sett to set the template path for refresh.html
* refresh.html is executed as a result of method execution
* Tpl as the common run of the refresh.html ..
* @return void
**/
function setRefreshPage() {
$this->setTemplatePath('./common/tpl');
@ -103,16 +111,19 @@
/**
* @brief sett to set the action name
* sett to set the action name
* @param string $act
* @return void
**/
function setAct($act) {
$this->act = $act;
}
/**
* @brief sett to set module information
* @param[in] $module_info object containing module information
* @param[in] $xml_info object containing module description
* sett to set module information
* @param object $module_info object containing module information
* @param object $xml_info object containing module description
* @return void
**/
function setModuleInfo($module_info, $xml_info) {
// The default variable settings
@ -172,8 +183,9 @@
}
/**
* @brief set the stop_proc and approprate message for msg_code
* @param $msg_code an error code
* set the stop_proc and approprate message for msg_code
* @param string $msg_code an error code
* @return ModuleObject $this
**/
function stop($msg_code) {
// flag setting to stop the proc processing
@ -195,7 +207,9 @@
}
/**
* @brief set the file name of the template file
* set the file name of the template file
* @param string name of file
* @return void
**/
function setTemplateFile($filename) {
if(substr($filename,-5)!='.html') $filename .= '.html';
@ -203,14 +217,17 @@
}
/**
* @brief retrieve the directory path of the template directory
* retrieve the directory path of the template directory
* @return string
**/
function getTemplateFile() {
return $this->template_file;
}
/**
* @brief set the directory path of the template directory
* set the directory path of the template directory
* @param string path of template directory.
* @return void
**/
function setTemplatePath($path) {
if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path;
@ -219,15 +236,17 @@
}
/**
* @brief retrieve the directory path of the template directory
* retrieve the directory path of the template directory
* @return string
**/
function getTemplatePath() {
return $this->template_path;
}
/**
* @brief set the file name of the temporarily modified by admin
* set the file name of the temporarily modified by admin
* @param string name of file
* @return void
**/
function setEditedLayoutFile($filename) {
if(substr($filename,-5)!='.html') $filename .= '.html';
@ -235,14 +254,17 @@
}
/**
* @brief retreived the file name of edited_layout_file
* retreived the file name of edited_layout_file
* @return string
**/
function getEditedLayoutFile() {
return $this->edited_layout_file;
}
/**
* @brief set the file name of the layout file
* set the file name of the layout file
* @param string name of file
* @return void
**/
function setLayoutFile($filename) {
if(substr($filename,-5)!='.html') $filename .= '.html';
@ -250,14 +272,16 @@
}
/**
* @brief get the file name of the layout file
* get the file name of the layout file
* @return string
**/
function getLayoutFile() {
return $this->layout_file;
}
/**
* @brief set the directory path of the layout directory
* set the directory path of the layout directory
* @param string path of layout directory.
**/
function setLayoutPath($path) {
if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path;
@ -266,15 +290,16 @@
}
/**
* @brief set the directory path of the layout directory
* set the directory path of the layout directory
* @return string
**/
function getLayoutPath() {
return $this->layout_path;
}
/**
* @brief excute the member method specified by $act variable
*
* excute the member method specified by $act variable
* @return boolean true : success false : fail
**/
function proc() {
// pass if stop_proc is true

View file

@ -2,7 +2,7 @@
/**
* @class PageHandler
* @author NHN (developers@xpressengine.com)
* @brief handles page navigation
* handles page navigation
* @version 0.1
*
* @remarks Getting total counts, number of pages, current page number, number of items per page,
@ -20,11 +20,12 @@
var $point = 0; ///< increments per getNextPage()
/**
* @brief constructor
* @param[in] $total_count number of total items
* @param[in] $total_page number of total pages
* @param[in] $cur_page current page number
* @param[in] $page_count number of page links displayed at one time
* constructor
* @param int $total_count number of total items
* @param int $total_page number of total pages
* @param int $cur_page current page number
* @param int $page_count number of page links displayed at one time
* @return void
**/
function PageHandler($total_count, $total_page, $cur_page, $page_count = 10) {
$this->total_count = $total_count;
@ -45,8 +46,8 @@
}
/**
* @brief request next page
* @return next page number
* request next page
* @return int next page number
**/
function getNextPage() {
$page = $this->first_page+$this->point++;
@ -54,6 +55,11 @@
return $page;
}
/**
* return number of page that added offset.
* @param int $offset
* @return int
**/
function getPage($offset)
{
return max(min($this->cur_page + $offset, $this->total_page), '');

View file

@ -2,7 +2,7 @@
/**
* @class TemplateHandler
* @author NHN (developers@xpressengine.com)
* @brief template compiler
* template compiler
* @version 0.1
* @remarks It compiles template file by using regular expression into php
* code, and XE caches compiled code for further uses
@ -22,6 +22,10 @@ class TemplateHandler {
var $handler_mtime = 0;
/**
* constructor
* @return void
**/
function TemplateHandler()
{
// TODO: replace this with static variable in PHP5
@ -33,7 +37,7 @@ class TemplateHandler {
}
/**
* @brief returns TemplateHandler's singleton object
* returns TemplateHandler's singleton object
* @return TemplateHandler instance
**/
function &getInstance()
@ -51,7 +55,11 @@ class TemplateHandler {
}
/**
* @brief set variables for template compile
* set variables for template compile
* @param string $tpl_path
* @param string $tpl_filename
* @param string $tpl_file
* @return void
**/
function init($tpl_path, $tpl_filename, $tpl_file='')
{
@ -80,11 +88,11 @@ class TemplateHandler {
}
/**
* @brief compiles specified tpl file and execution result in Context into resultant content
* @param[in] $tpl_path path of the directory containing target template file
* @param[in] $tpl_filename target template file's name
* @param[in] $tpl_file if specified use it as template file's full path
* @return Returns compiled result in case of success, NULL otherwise
* compiles specified tpl file and execution result in Context into resultant content
* @param string $tpl_path path of the directory containing target template file
* @param string $tpl_filename target template file's name
* @param string $tpl_file if specified use it as template file's full path
* @return string Returns compiled result in case of success, NULL otherwise
*/
function compile($tpl_path, $tpl_filename, $tpl_file='') {
global $__templatehandler_root_tpl;
@ -140,10 +148,10 @@ class TemplateHandler {
}
/**
* @brief compile specified file and immediately return
* @param[in] $tpl_path path of the directory containing target template file
* @param[in] $tpl_filename target template file's name
* @return Returns compiled content in case of success or NULL in case of failure
* compile specified file and immediately return
* @param string $tpl_path path of the directory containing target template file
* @param string $tpl_filename target template file's name
* @return string Returns compiled content in case of success or NULL in case of failure
**/
function compileDirect($tpl_path, $tpl_filename) {
$this->init($tpl_path, $tpl_filename, null);
@ -158,11 +166,9 @@ class TemplateHandler {
}
/**
* @brief compile a template file specified in $tpl_file and
* @pre files specified by $tpl_file exists.
* @param[in] $tpl_file path of tpl file
* @param[in] $compiled_tpl_file if specified, write compiled result into the file
* @return compiled result in case of success or NULL in case of error
* parse syntax.
* @param string $buff template file
* @return string compiled result in case of success or NULL in case of error
**/
function parse($buff=null) {
if(is_null($buff)) {
@ -202,10 +208,13 @@ class TemplateHandler {
}
/**
* @brief 1. remove ruleset from form tag
* preg_replace_callback handler
* 1. remove ruleset from form tag
* 2. add hidden tag with ruleset value
* 3. if empty default hidden tag, generate hidden tag (ex:mid, vid, act...)
* 4. generate return url, return url use in server side validator
* @param array $matches
* @return string
**/
function _compileFormAuthGeneration($matches)
{
@ -272,11 +281,9 @@ class TemplateHandler {
}
/**
* @brief fetch using ob_* function
* @param[in] $compiled_tpl_file path of compiled template file
* @param[in] $buff if buff is not null, eval it instead of including compiled template file
* @param[in] $tpl_path set context's tpl path
* @return result string
* fetch using ob_* function
* @param string $buff if buff is not null, eval it instead of including compiled template file
* @return string
**/
function _fetch($buff) {
if(!$buff) return;
@ -300,10 +307,12 @@ class TemplateHandler {
}
/**
* @brief change image path
* @pre $matches is an array containg three elements
* @param[in] $matches match
* @return changed result
* preg_replace_callback hanlder
*
* replace image path
* @param array $match
*
* @return string changed result
**/
function _replacePath($match)
{
@ -320,6 +329,11 @@ class TemplateHandler {
return substr($match[0],0,-strlen($match[1])-6)."src=\"{$src}\"";
}
/**
* replace loop and cond template syntax
* @param string $buff
* @return string changed result
**/
function _parseInline($buff)
{
if(preg_match_all('/<([a-zA-Z]+\d?)(?>(?!<[a-z]+\d?[\s>]).)*?(?:[ \|]cond| loop)="/s', $buff, $match) === false) return $buff;
@ -408,6 +422,12 @@ class TemplateHandler {
return $buff;
}
/**
* preg_replace_callback hanlder
* replace php code.
* @param array $m
* @return string changed result
**/
function _parseResource($m)
{
// {@ ... } or {$var} or {func(...)}
@ -545,6 +565,11 @@ class TemplateHandler {
return $m[0];
}
/**
* change relative path
* @param string $path
* @return string
**/
function _getRelativeDir($path)
{
$_path = $path;
@ -573,7 +598,9 @@ class TemplateHandler {
}
/**
* @brief replace PHP variables of $ character
* replace PHP variables of $ character
* @param string $php
* @return string $__Context->varname
**/
function _replaceVar($php) {
if(!strlen($php)) return '';