本文整理汇总了PHP中ModuleManager::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleManager::getInstance方法的具体用法?PHP ModuleManager::getInstance怎么用?PHP ModuleManager::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleManager
的用法示例。
在下文中一共展示了ModuleManager::getInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: database_initialize
/**
* Perform database initialization.
*
* @param boolean $create_database
* @return boolean
*/
function database_initialize($create_database)
{
global $db, $db_config, $data_path;
$result = false;
$database_exists = false;
$sql_file = 'units/database/init.sql';
$xml_file = $data_path . 'system_init.xml';
if (!file_exists($sql_file) || !file_exists($xml_file)) {
trigger_error('Can not initialize database, missing configuration!', E_USER_ERROR);
return $result;
}
// make a log entry
trigger_error('Initializing database: ' . $db_config['name'], E_USER_NOTICE);
// get initialization SQL
$sql = file_get_contents($sql_file);
// create database if needed
if ($create_database) {
try {
$db->create($db_config['name']);
$db->select($db_config['name']);
$database_exists = true;
} catch (Exception $error) {
$database_exists = false;
}
} else {
$database_exists = true;
}
// create database
if ($database_exists && $db->multi_query($sql)) {
$module_manager = ModuleManager::getInstance();
$module_handler = ModuleHandler::getInstance();
$admin_manager = UserManager::getInstance();
// populate tables
$raw_data = file_get_contents($xml_file);
$data = new XMLParser($raw_data, $xml_file);
$data->parse();
// go over XML file and insert data
foreach ($data->document->tagChildren as $item) {
switch ($item->tagName) {
case 'module':
// insert data
$module_manager->insertData(array('name' => $item->tagAttrs['name'], 'order' => $item->tagAttrs['order'], 'preload' => $item->tagAttrs['preload'] == 'yes' ? 1 : 0, 'active' => 1));
// initialize module
$module = $module_handler->_loadModule($item->tagAttrs['name']);
if (!is_null($module)) {
$module->onInit();
}
break;
case 'user':
$salt = hash('sha256', UserManager::SALT . strval(time()));
$password = hash_hmac('sha256', $item->tagAttrs['password'], $salt);
$admin_manager->insertData(array('username' => $item->tagAttrs['username'], 'password' => $password, 'fullname' => $item->tagAttrs['fullname'], 'level' => $item->tagAttrs['level'], 'verified' => 1, 'salt' => $salt));
break;
}
}
// set result
$result = true;
}
return $result;
}
示例2: loadModules
/**
* Load all modules in specified path
*
* @param boolean $include_only
*/
function loadModules($include_only = false)
{
global $db_use, $data_path;
$preload_list = array();
$normal_list = array();
if ($db_use) {
// database available, form module list from database entries
$manager = ModuleManager::getInstance();
// get priority module list
$preload_raw = $manager->getItems($manager->getFieldNames(), array('active' => 1, 'preload' => 1), array('order'));
// get normal module list
$normal_raw = $manager->getItems($manager->getFieldNames(), array('active' => 1, 'preload' => 0), array('order'));
foreach ($preload_raw as $preload_item) {
$preload_list[] = $preload_item->name;
}
foreach ($normal_raw as $normal_item) {
$normal_list[] = $normal_item->name;
}
} else {
// no database available use system initialization file
$file = $data_path . 'system_init.xml';
if (file_exists($file)) {
$xml = new XMLParser(@file_get_contents($file), $file);
$xml->Parse();
foreach ($xml->document->tagChildren as $xml_tag) {
if ($xml_tag->tagName == 'module') {
$normal_list[] = $xml_tag->tagAttrs['name'];
}
}
}
}
// load modules
if (count($preload_list) > 0) {
foreach ($preload_list as $module_name) {
$this->_loadModule($module_name);
}
}
if (count($normal_list) > 0) {
if ($include_only) {
foreach ($normal_list as $module_name) {
$this->_includeModule($module_name);
}
} else {
foreach ($normal_list as $module_name) {
$this->_loadModule($module_name);
}
}
}
}
示例3: getTreeFromDatabase
public function getTreeFromDatabase($id,$ebene)
{
$aktDate=date("Y")."-".date("n")."-".date("j");
$SQLQuery="Select ".$this->articleTable.".article_id, ".$this->articleTable.".article_type, "
.$this->descriptionTable.".alias_external_link, "
.$this->descriptionTable.".article_linktext, "
.$this->descriptionTable.".Module, "
.$this->descriptionTable.".module_has_tree, "
.$this->descriptionTable.".article_url, "
.$this->descriptionTable.".article_content, "
.$this->descriptionTable.".article_as_link, "
.$this->descriptionTable.".module_parameter, "
.$this->descriptionTable.".show_navi, "
.$this->parentIDTable.".parent_id, ".$this->descriptionTable.".farbe " .
"FROM ".$this->articleTable." " .
"join ".$this->descriptionTable." USING (article_id) ".
"join ".$this->parentIDTable." USING (article_id) ";
$SQLQuery.="where ".$this->parentIDTable.".parent_id='".$id."' " .
"and ".$this->articleTable.".published='1' and ".$this->articleTable.".viewable='1' and language_id='".$this->lang."' ".
" ORDER by sort_order";
$result = AGDO::getInstance()->GetAll($SQLQuery);
if(!empty($result))
{
for ($zaehler=0; $zaehler< count($result);$zaehler++ )
{
if ($result[$zaehler]['article_id']=="4")
$this->home=$result[$zaehler];
if ($ebene==2)
{
$this->setFlavour($result[$zaehler]['article_id']);
}
if ($ebene==4)
{
$this->setSecondFlavour($result[$zaehler]['parent_id']);
}
if ($result[$zaehler]['article_type']=="4" && $result[$zaehler]['article_as_link'])
$result[$zaehler]['article_url']=$this->getArticleURL($result[$zaehler]['article_content']);
$result[$zaehler]['mark']=false;
if (!empty($this->user))
$result[$zaehler]['permission']=$this->getPermission($result[$zaehler]['article_id'], $this->user);
else
{
$result[$zaehler]['permission']="2"; ///
}
$moduleTree=array();
if (!empty($result[$zaehler]['Module'])&& $result[$zaehler]['show_navi'])
{
$modul = ModuleManager::getInstance()->getModuleByName($result[$zaehler]['Module']);
if (!empty($modul))
{
$modul->setConnection(AGDO::getInstance());
if ($modul->hasFrontendNavigation())
$moduleTree = $modul->getFrontendNavigationData(Request::getInstance()->getRequests(),$result[$zaehler]);
}
}
//if ($result[$zaehler]['show_navi'])
$result[$zaehler]['Child']=$this->getTreeFromDatabase($result[$zaehler]['article_id'],($ebene+1));
/*else
$result[$zaehler]['Child']=array();*/
if (!empty($moduleTree))
$result[$zaehler]['Child']=array_merge($result[$zaehler]['Child'], $moduleTree);
if ($ebene>2)
{
$this->flavourArray[$result[$zaehler]['article_id']]=$this->getFlavour();
$result[$zaehler]['flavour']=$this->getFlavour();
}
if ($ebene>3)
{
$this->flavourArray2[$result[$zaehler]['article_id']]=$result[$zaehler]['parent_id'];
$result[$zaehler]['flavour2']=$result[$zaehler]['parent_id'];
$this->setSecondFlavour($result[$zaehler]['parent_id']);
$result[$zaehler]['self']=$result[$zaehler]['article_id'];
}
}
}
return $result;
}
示例4: generate
public function generate($array, $langshort, $langID, $mode)
{
//print_r($array);
//echo $langID;
Logger::getInstance()->Log($_POST, LOG_ABLAUF);
//$array['article_url_de'] = iconv('ISO-8859-1',"UTF-8",$array['article_url_de']);
Logger::getInstance()->Log($array, LOG_ABLAUF);
$arrayKeys = array_keys($array);
$returnArray=array();
if (ModuleManager::getInstance()->getModuleByName('Rechteverwaltung'))
{
$rechteverwaltung = ModuleManager::getInstance()->getModuleByName('Rechteverwaltung');
$rechteverwaltung->setConnection(AGDO::getInstance());
$rechteverwaltung->setLanguage(1);
$rechteverwaltung->calculate();
$permissions = array();
foreach ($arrayKeys as $keys)
{
if (!(strpos($keys,'role_')===false))
{
//echo strpos($keys,'e_');
$roleID = substr($keys,5);
//echo $roleID;
$permission = $array['GroupSelect_'.$roleID];
$permissions[]=array('permission'=>$permission,'role_id'=>$roleID);
//
}
}
if (isset( $array['ID']))
$rechteverwaltung->setPermissions($permissions, $array['ID']);
if (isset($array['rolerekursiv']))
{
$this->updateRecPermission($rechteverwaltung, $permissions, $array['ID']);
}
}
if (isset($array['tag_new']))
$returnArray['tags']=$array['tag_new'];
else
{
if (isset($array['tags']))
$returnArray['tags']=$array['tags'];
else
$returnArray['tags']="";
}
if (isset($array['kopfbild_de']))
$returnArray['kopfbild']=$array['kopfbild_de'];
if(empty($array['kopfbildgalerie_on_de']))
$returnArray['kopfbildgalerie_on'] = 'no';
if (isset($array['kopfbild_slideshow']))
$returnArray['kopfbild_slideshow']=$array['kopfbild_slideshow'];
else
$returnArray['kopfbild_slideshow']='';
if (isset($array['facebook']))
$returnArray['facebook']=1;
else
$returnArray['facebook']=0;
if (isset($array['twitter']))
$returnArray['twitter']=1;
else
$returnArray['twitter']=0;
if (empty($array['twitter_text']))
$returnArray['twitter_text']="";
if (empty($array['facebook_title']))
$returnArray['facebook_title']="";
if (empty($array['facebook_description']))
$returnArray['facebook_description']="";
if (empty($array['facebook_image']))
$returnArray['facebook_image']="";
if (isset($array['tags']) && $array['tags']=='Keine')
$returnArray['tags']=NULL;
// JA 09.03.2010 Rating
$returnArray['rating_enabled'] = !empty($array['rating_enabled']) + '';
$returnArray['show_rating'] = !empty($array['show_rating']) + '';
if(isset($array['avg_rating']))
$returnArray['avg_rating'] = $array['avg_rating'];
if(!empty($array['reset_rating'])){
// reset data
$returnArray['avg_rating'] = $returnArray['rating_count'] = 0;
// delete rating info
$settings = unserialize(SETTINGS);
$table = $this->dbconnector->getPrefix() . $settings['rating']['table'];
$query = "DELETE FROM $table
WHERE article_id = ".$array['article_id'];
$result = $this->dbverbindung->Execute($query);
}
foreach ($arrayKeys as $keys)
{
// JA 23.06.2009: that method is unsafe and kills description.
/*
if (strpos($keys,"_".$langshort)>0)
{
$newkey=substr($keys,0,strpos($keys,"_".$langshort));
$returnArray[$newkey]=$array[$keys];
}
*/
//.........这里部分代码省略.........
示例5: tag_ModuleList
/**
* Handle tag _module_list used to display list of all modules on the system
*
* @param array $params
* @param array $children
*/
public function tag_ModuleList($params, $children)
{
global $module_path;
$list = array();
$raw_list = $this->getModuleList();
$manager = ModuleManager::getInstance();
$modules_in_use = $manager->getItems(array('id', 'order', 'name', 'preload', 'active'), array(), array('preload', 'order'));
// add modules from database
foreach ($modules_in_use as $module) {
if (in_array($module->name, $raw_list)) {
// module in database exists on disk
if ($module->active) {
$list[$module->name] = array('status' => 'active');
} else {
$list[$module->name] = array('status' => 'inactive');
}
} else {
// module does not exist on disk
$list[$module->name] = array('status' => 'missing');
}
$list[$module->name]['active'] = $module->active;
$list[$module->name]['preload'] = $module->preload;
$list[$module->name]['order'] = $module->order;
}
// add missing modules available on drive
foreach ($raw_list as $module_name) {
if (!array_key_exists($module_name, $list)) {
$list[$module_name] = array('status' => 'not_initialized', 'active' => 0, 'preload' => 0, 'order' => '');
}
}
$template = new TemplateHandler(isset($params['template']) ? $params['template'] : 'module.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
foreach ($list as $name => $definition) {
$icon_file = _BASEPATH . '/' . $module_path . $name . '/images/icon.svg';
if (file_exists($icon_file)) {
$icon = url_GetFromFilePath($icon_file);
} else {
$icon = url_GetFromFilePath($this->path . 'images/icons/16/modules.svg');
}
$params = array('name' => $name, 'icon' => $icon, 'status' => $definition['status'], 'active' => $definition['active'], 'active_symbol' => $definition['active'] ? CHAR_CHECKED : CHAR_UNCHECKED, 'preload' => $definition['preload'], 'preload_symbol' => $definition['preload'] ? CHAR_CHECKED : CHAR_UNCHECKED, 'order' => $definition['order'], 'item_activate' => url_MakeHyperlink($this->getLanguageConstant('activate'), window_Open($this->name . '_module_dialog', 300, $this->getLanguageConstant('title_module_activate'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'module_activate'), array('module_name', $name)))), 'item_deactivate' => url_MakeHyperlink($this->getLanguageConstant('deactivate'), window_Open($this->name . '_module_dialog', 300, $this->getLanguageConstant('title_module_deactivate'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'module_deactivate'), array('module_name', $name)))), 'item_initialise' => url_MakeHyperlink($this->getLanguageConstant('initialise'), window_Open($this->name . '_module_dialog', 300, $this->getLanguageConstant('title_module_initialise'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'module_initialise'), array('module_name', $name)))), 'item_disable' => url_MakeHyperlink($this->getLanguageConstant('disable'), window_Open($this->name . '_module_dialog', 300, $this->getLanguageConstant('title_module_disable'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'module_disable'), array('module_name', $name)))));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
示例6: processException
/**
* Of course, even exceptions shouldn't be fatal for the bot's run-time.
* Therefore we want to catch exceptions which occur as well.
*
* @param Exception $pException The exception that has occured.
* @return true
*/
public function processException(\Exception $pException)
{
if (self::$Context != null && self::$Context instanceof Bot) {
$sExceptionSource = self::$Source;
ModuleManager::getInstance()->onException(self::$Context, $sExceptionSource, $pException);
self::$Source = null;
return true;
}
echo '[Exception] Exception occured in "' . $pException->getFile() . '" on line ';
echo $pException->getLine() . ': "' . $pException->getMessage() . '".' . PHP_EOL;
return true;
}