芝麻web文件管理V1.00
编辑当前文件:/home/p/r/i/prismawe/clients/canaldegap.fr_old/modules/CTLModuleMaker/function.createModuleFile.php
Lang("friendlyname"); } /*--------------------------------------------------------- GetVersion() This can return any string, preferably a number or something that makes sense for designating a version. The CMS will use this to identify whether or not the installed version of the module is current, and the module will use it to figure out how to upgrade itself if requested. ---------------------------------------------------------*/ function GetVersion() { return "'.$infos['version'].'"; } /*--------------------------------------------------------- GetDependencies() Your module may need another module to already be installed before you can install it. This method returns a list of those dependencies and minimum version numbers that this module requires. It should return an hash, eg. return array("somemodule"=>"1.0", "othermodule"=>"1.1"); ---------------------------------------------------------*/ function GetDependencies() { return array(); } /*--------------------------------------------------------- GetHelp() This returns HTML information on the module. Typically, you"ll want to include information on how to use the module. See the note on localization at the top of this file. ---------------------------------------------------------*/ function GetHelp() { return $this->Lang("help"); } /*--------------------------------------------------------- GetAuthor() This returns a string that is presented in the Module Admin if you click on the "About" link. ---------------------------------------------------------*/ function GetAuthor() { return "CTLModuleMaker '.$makerversion.'"; // of course you may change this, but it would be nice // to keep a mention of the CTLModuleMaker somewhere } /*--------------------------------------------------------- GetAuthorEmail() This returns a string that is presented in the Module Admin if you click on the "About" link. It helps users of your module get in touch with you to send bug reports, questions, cases of beer, and/or large sums of money. ---------------------------------------------------------*/ function GetAuthorEmail() { return ""; } /*--------------------------------------------------------- IsPluginModule() This function returns true or false, depending upon whether users can include the module in a page or template using a smarty tag of the form {cms_module module="Prod" param1=val param2=val...} If your module does not get included in pages or templates, return "false" here. ---------------------------------------------------------*/ function IsPluginModule() { return true; } /*--------------------------------------------------------- HasAdmin() This function returns a boolean value, depending on whether your module adds anything to the Admin area of the site. For the rest of these comments, I"ll be calling the admin part of your module the "Admin Panel" for want of a better term. ---------------------------------------------------------*/ function HasAdmin() { return true; } function GetAdminSection() {return "content";} function GetAdminDescription() {return $this->Lang("admindescription");} function VisibleToAdminUser(){ return ($this->CheckPermission("'.$infos['nameofmodule'].'_normaluser") || $this->CheckPermission("'.$infos['nameofmodule'].'_advanced")); } '; if(!isset($infos['is_shared']) || !$infos['is_shared']){ $moduleFile .= ' /*--------------------------------------------------------- Module Constructor ---------------------------------------------------------*/ function '.$infos['nameofmodule'].'() { global $gCms; $smarty =& $gCms->GetSmarty(); $smarty->register_function("'.$infos['nameofmodule'].'_breadcrumbs", array(&$this,"function_modbreadcrumbs")); $smarty->register_function("'.$infos['nameofmodule'].'_get_levelitem", array(&$this,"function_get_levelitem")); parent::CMSModule(); } '; } $moduleFile .= ' /*--------------------------------------------------------- SetParameters() This function enables you to create mappings for your module when using "Pretty Urls". Typically, modules create internal links that have big ugly strings along the lines of: index.php?mact=ModName,cntnt01,actionName,0&cntnt01param1=1&cntnt01param2=2&cntnt01returnid=3 You might prefer these to look like: /ModuleFunction/2/3 To do this, you have to register routes and map your parameters in a way that the API will be able to understand. Also note that any calls to CreateLink will need to be updated to pass the pretty url parameter. Since the Skeleton doesn"t really create any links, the section below is commented out, but you can use it to figure out pretty urls. ---------------------------------------------------------*/ function SetParameters() { '; $modname = '['.substr($infos['nameofmodule'],0,1).strtoupper(substr($infos['nameofmodule'],0,1)).']'.substr($infos['nameofmodule'],1); $moduleFile .= ' // these are for internal pretty URLS. // you may change these, but you will also need to change the BuildPrettyURLs function below accordingly // see FAQ for more info on this $defact = array("action"=>"default"); $this->RegisterRoute("/'.$modname.'\\/([Qq]uery)\\/(?P
[0-9]+)\\/(?P
[0-9]+)$/", $defact); $this->RegisterRoute("/'.$modname.'\\/([Qq]uery)\\/(?P
[0-9]+)\\/(?P
[0-9]+)\\/(?P
[0-9]+)\\/(?P
[0-9]+)$/", $defact); $this->RegisterRoute("/'.$modname.'\\/([Dd]etail)\\/(?P
[^\\/]+)\\/(?P
[0-9]+)$/", $defact); $this->RegisterRoute("/'.$modname.'\\/(?P
[^\\/]+)\\/(?P
[0-9]+)$/", $defact); $this->RegisterRoute("/'.$modname.'\\/(?P
[^\\/]+)\\/(?P
[^\\/]+)\\/(?P
[0-9]+)$/", $defact); $this->RegisterRoute("/'.$modname.'\\/(?P
[^\\/]+)\\/(?P
[0-9]+)\\/(?P
[0-9]+)\\/(?P
[0-9]+)$/", $defact); $this->RegisterRoute("/'.$modname.'\\/(?P
[^\\/]+)\\/(?P
[^\\/]+)\\/(?P
[0-9]+)\\/(?P
[0-9]+)\\/(?P
[0-9]+)$/", $defact); $this->RestrictUnknownParams(); $this->CreateParameter("action", "default", $this->Lang("phelp_action")); $this->CreateParameter("what", "", $this->Lang("phelp_what")); $this->SetParameterType("what",CLEAN_STRING); $this->CreateParameter("alias", "", $this->Lang("phelp_alias")); $this->SetParameterType("alias",CLEAN_STRING); $this->CreateParameter("showdefault", false, $this->Lang("phelp_showdefault")); $this->SetParameterType("showdefault",CLEAN_INT); $this->CreateParameter("parent", "", $this->Lang("phelp_parent")); $this->SetParameterType("parent",CLEAN_STRING); $this->CreateParameter("limit", 0, $this->Lang("phelp_limit")); $this->SetParameterType("limit",CLEAN_INT); $this->CreateParameter("nbperpage", 0, $this->Lang("phelp_nbperpage")); $this->SetParameterType("nbperpage",CLEAN_STRING); $this->CreateParameter("orderby", 0, $this->Lang("phelp_orderby")); $this->SetParameterType("orderby",CLEAN_STRING); $this->CreateParameter("detailpage", "", $this->Lang("phelp_detailpage")); $this->SetParameterType("detailpage",CLEAN_STRING); $this->CreateParameter("random", 0, $this->Lang("phelp_random")); $this->SetParameterType("random",CLEAN_INT); $this->CreateParameter("listtemplate", "", $this->lang("phelp_listtemplate")); $this->SetParameterType("listtemplate",CLEAN_STRING); $this->CreateParameter("finaltemplate", "", $this->lang("phelp_finaltemplate")); $this->SetParameterType("finaltemplate",CLEAN_STRING); $this->CreateParameter("forcelist", "0", $this->lang("phelp_forcelist")); $this->SetParameterType("forcelist",CLEAN_STRING); $this->CreateParameter("inline", 0, $this->lang("phelp_inline")); $this->SetParameterType("inline",CLEAN_STRING); $this->CreateParameter("searchmode", "advanced", $this->lang("phelp_searchmode")); $this->SetParameterType("searchmode",CLEAN_STRING); $this->CreateParameter("query", 0, $this->lang("phelp_query")); $this->SetParameterType("query",CLEAN_STRING); $this->CreateParameter("toaction", "", $this->Lang("phelp_toaction")); $this->SetParameterType("toaction",CLEAN_STRING); $this->SetParameterType("pageindex",CLEAN_INT); // for the search form (trick from ikulis) : $this->SetParameterType(CLEAN_REGEXP."/date_.*/",CLEAN_STRING); $this->SetParameterType(CLEAN_REGEXP."/field_.*/",CLEAN_STRING); $this->SetParameterType(CLEAN_REGEXP."/compare_.*/",CLEAN_STRING); $this->SetParameterType("submitsearch",CLEAN_STRING); $this->SetParameterType("searchfield",CLEAN_STRING); '; if($infos["dofeadd"]) $moduleFile .= ' // for the frontend add action $this->SetParameterType(CLEAN_REGEXP."/feadd.*/",CLEAN_STRING); $this->SetParameterType(CLEAN_REGEXP."/fefile.*/",CLEAN_STRING); $this->SetParameterType("captcha_input", CLEAN_STRING); '; $moduleFile .= ' } function GetEventDescription($eventname) { $eventname = str_replace("'.$infos['nameofmodule'].'", "", $eventname); return $this->lang("eventdesc".$eventname); } function InstallPostMessage() { return $this->Lang("postinstall"); } function UninstallPostMessage() { return $this->Lang("postuninstall"); } function UninstallPreMessage() { return $this->Lang("really_uninstall"); } /*--------------------------------------------------------- Install() When your module is installed, you may need to do some setup. Typical things that happen here are the creation and prepopulation of database tables, database sequences, permissions, preferences, etc. For information on the creation of database tables, check out the ADODB Data Dictionary page at http://phplens.com/lens/adodb/docs-datadict.htm This function can return a string in case of any error, and CMS will not consider the module installed. Successful installs should return FALSE or nothing at all. ---------------------------------------------------------*/ function Install() { global $gCms; require "method.install.php"; } /*--------------------------------------------------------- Uninstall() Sometimes, an exceptionally unenlightened or ignorant admin will wish to uninstall your module. While it would be best to lay into these idiots with a cluestick, we will do the magnanimous thing and remove the module and clean up the database, permissions, and preferences that are specific to it. This is the method where we do this. ---------------------------------------------------------*/ function Uninstall() { global $gCms; require "method.uninstall.php"; } function SearchResult($returnid, $itemid, $level = "") { $result = array(); $wantedparam = false; $newparams = array(); if($level == "'.$levels[count($levels)-1][0].'"){ // we seek an element of the last level, and will display the detail view $wantedparam = "alias"; }else{ if($newparams["what"] = $this->get_nextlevel($level)){ // we seek an element of another level, and will display the list view of its children $wantedparam = "parent"; } } if ($wantedparam){ $tablename = cms_db_prefix()."module_'.$infos['nameofmodule'].'_".$level; $db =& $this->GetDb(); $query = "SELECT name, alias FROM $tablename WHERE id = ?"; $dbresult = $db->Execute( $query, array( $itemid ) ); if ($dbresult){ $row = $dbresult->FetchRow(); $newparams[$wantedparam] = $row["alias"]; //0 position is the prefix displayed in the list results. $result[0] = $this->GetFriendlyName(); //1 position is the title $result[1] = $row["name"]; //2 position is the URL to the title. $result[2] = $this->CreateLink($id, "default", $returnid, "", $newparams, "", true, false, "", false, $this->BuildPrettyUrls($newparams, $returnid)); } } return $result; } function SearchReindex(&$module) { $db =& $this->GetDb(); '; foreach($levels as $level){ $indexedfields = ''; foreach($level[4] as $field){ if($field[3] == 1) $indexedfields .= ($indexedfields == ''?'':' ').'$item->'.$field[0]; } $moduleFile .= 'if($this->GetPreference("searchmodule_index_'.$level[0].'",false)){ $itemlist = $this->get_level_'.$level[0].'(); foreach($itemlist as $item){ $text = "'.$indexedfields.'"; $module->AddWords($this->GetName(), $item->id, "'.$level[0].'", $text, NULL); } } '; } $moduleFile .= ' } /* --------------------------------------------- NOT PART OF THE NORMAL MODULE API ----------------------------------------------*/ function getDefaultTemplates(){ // returns an array of the templates that are selected as default (just so that we don\'t delete them) $result = array(); $result[] = $this->GetPreference("finaltemplate"); $result[] = $this->GetPreference("searchresultstemplate"); '; foreach($levels as $level){ $moduleFile .= '$result[] = $this->GetPreference("listtemplate_'.$level[0].'"); '; } $moduleFile .= 'return $result; } function getOrderType($what){ // returns whether a level is ordered by parent or not '; $tmp = ''; foreach($levels as $level){ $tmp .= ($tmp==''?'':',').'"'.$level[0].'"=>'.($level[6]?'true':'false'); } $moduleFile .= '$return = array('.$tmp.'); return (isset($return[$what])?$return[$what]:false); } function DoAction($action, $id, $params, $returnid=-1){ global $gCms; '; $moduleFile .= $this->createActions($infos, $levels, $hasdynamiclists, $multiplefiles); $moduleFile .= ' } '; $moduleFile .= $this->getFileContent('functions'.DIRECTORY_SEPARATOR.'plcreatealias.php'); $moduleFile .= $this->getFileContent('functions'.DIRECTORY_SEPARATOR.'checkalias.php'); $moduleFile .= $this->getFileContent('functions'.DIRECTORY_SEPARATOR.'BuildPrettyUrls.php'); $moduleFile .= $this->getFileContent('functions'.DIRECTORY_SEPARATOR.'DoCheckboxes.php'); $moduleFile .= $this->getFileContent('functions'.DIRECTORY_SEPARATOR.'parsekeywords.php'); if($infos["dofeadd"]) $moduleFile .= ' function feadd_permcheck($what, $itemid, $alias){ global $gCms; $return = true; require "function.feadd_permcheck.php"; return $return; } '; $moduleFile .= $this->createDBGetFunctions($infos, $levels, $predefinedlists, $multiplefiles); if($infos['hasfilefields']) $moduleFile .= $this->getFileContent('functions'.DIRECTORY_SEPARATOR.'filefunctions.php'); $moduleFile .= $this->getFileContent('functions'.DIRECTORY_SEPARATOR.'getFileContent.php'); $moduleFile .= ' } ?> '; ?>