<?php
// Copyright (C) 2011-2016 Combodo SARL
//
// This file is part of iTop.
//
// iTop is free software; you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// iTop is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
define('TOOLKITENV', 'toolkit');
function RebuildToolkitEnvironment()
{
$oConfig = new Config(APPCONF.'production'.'/'.ITOP_CONFIG_FILE);
$oToolkitConfig = clone($oConfig);
$oToolkitConfig->ChangeModulesPath('production', TOOLKITENV);
if (file_exists(APPROOT.'data/production.delta.xml'))
{
copy(APPROOT.'data/production.delta.xml', APPROOT.'data/toolkit.delta.xml');
}
if (is_dir(APPROOT.'data/toolkit-modules'))
{
// Cleanup before copying
SetupUtils::rrmdir(APPROOT.'data/toolkit-modules');
}
if (is_dir(APPROOT.'data/production-modules'))
{
SetupUtils::copydir(APPROOT.'data/production-modules', APPROOT.'data/toolkit-modules');
}
$oEnvironment = new RunTimeEnvironment(TOOLKITENV);
$oEnvironment->WriteConfigFileSafe($oToolkitConfig);
$oEnvironment->CompileFrom('production');
}
function MakeDictEntry($sKey, $sValueFromOldSystem, $sDefaultValue, &$bNotInDico)
{
$sValue = Dict::S($sKey, 'x-no-nothing');
if ($sValue == 'x-no-nothing')
{
$bNotInDico = true;
$sValue = $sValueFromOldSystem;
if (strlen($sValue) == 0)
{
$sValue = $sDefaultValue;
}
}
return " '$sKey' => '".str_replace("'", "\\'", $sValue)."',\n";
}
function MakeDictionaryTemplate($sModules = '', $sLanguage = 'EN US')
{
$sRes = '';
Dict::SetDefaultLanguage($sLanguage);
$aAvailableLanguages = Dict::GetLanguages();
$sDesc = $aAvailableLanguages[$sLanguage]['description'];
$sLocalizedDesc = $aAvailableLanguages[$sLanguage]['localized_description'];
$sRes .= "// Dictionary conventions\n";
$sRes .= htmlentities("// Class:<class_name>\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>+\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>+\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>/Value:<value>\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>/Value:<value>+\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>/Stimulus:<stimulus_code>\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>/Stimulus:<stimulus_code>+\n", ENT_QUOTES, 'UTF-8');
$sRes .= "\n";
// Note: I did not use EnumCategories(), because a given class maybe found in several categories
// Need to invent the "module", to characterize the origins of a class
if (strlen($sModules) == 0)
{
$aModules = array('bizmodel', 'core/cmdb', 'gui' , 'application', 'addon/userrights', 'monitoring');
}
else
{
$aModules = explode(', ', $sModules);
}
$sRes .= "//////////////////////////////////////////////////////////////////////\n";
$sRes .= "// Note: The classes have been grouped by categories: ".implode(', ', $aModules)."\n";
$sRes .= "//////////////////////////////////////////////////////////////////////\n";
foreach ($aModules as $sCategory)
{
$sRes .= "//////////////////////////////////////////////////////////////////////\n";
$sRes .= "// Classes in '$sCategory'\n";
$sRes .= "//////////////////////////////////////////////////////////////////////\n";
$sRes .= "//\n";
$sRes .= "\n";
foreach (MetaModel::GetClasses($sCategory) as $sClass)
{
if (!MetaModel::HasTable($sClass)) continue;
$bNotInDico = false;
$bNotImportant = true;
$sClassRes = "//\n";
$sClassRes .= "// Class: $sClass\n";
$sClassRes .= "//\n";
$sClassRes .= "\n";
$sClassRes .= "Dict::Add('$sLanguage', '$sDesc', '$sLocalizedDesc', array(\n";
$sClassRes .= MakeDictEntry("Class:$sClass", MetaModel::GetName_Obsolete($sClass), $sClass, $bNotInDico);
$sClassRes .= MakeDictEntry("Class:$sClass+", MetaModel::GetClassDescription_Obsolete($sClass), '', $bNotImportant);
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
{
if ($sAttCode == 'friendlyname') continue;
// Skip this attribute if not originaly defined in this class
if (MetaModel::GetAttributeOrigin($sClass, $sAttCode) != $sClass) continue;
$sClassRes .= MakeDictEntry("Class:$sClass/Attribute:$sAttCode", $oAttDef->GetLabel_Obsolete(), $sAttCode, $bNotInDico);
$sClassRes .= MakeDictEntry("Class:$sClass/Attribute:$sAttCode+", $oAttDef->GetDescription_Obsolete(), '', $bNotImportant);
if ($oAttDef instanceof AttributeEnum)
{
if (MetaModel::GetStateAttributeCode($sClass) == $sAttCode)
{
foreach (MetaModel::EnumStates($sClass) as $sStateCode => $aStateData)
{
if (array_key_exists('label', $aStateData))
{
$sValue = $aStateData['label'];
}
else
{
$sValue = MetaModel::GetStateLabel($sClass, $sStateCode);
}
if (array_key_exists('description', $aStateData))
{
$sValuePlus = $aStateData['description'];
}
else
{
$sValuePlus = MetaModel::GetStateDescription($sClass, $sStateCode);
}
$sClassRes .= MakeDictEntry("Class:$sClass/Attribute:$sAttCode/Value:$sStateCode", $sValue, '', $bNotInDico);
$sClassRes .= MakeDictEntry("Class:$sClass/Attribute:$sAttCode/Value:$sStateCode+", $sValuePlus, '', $bNotImportant);
}
}
else
{
foreach ($oAttDef->GetAllowedValues() as $sKey => $value)
{
$sClassRes .= MakeDictEntry("Class:$sClass/Attribute:$sAttCode/Value:$sKey", $value, '', $bNotInDico);
$sClassRes .= MakeDictEntry("Class:$sClass/Attribute:$sAttCode/Value:$sKey+", $value, '', $bNotImportant);
}
}
}
}
foreach(MetaModel::EnumStimuli($sClass) as $sStimulusCode => $oStimulus)
{
$sClassRes .= MakeDictEntry("Class:$sClass/Stimulus:$sStimulusCode", $oStimulus->GetLabel_Obsolete(), '', $bNotInDico);
$sClassRes .= MakeDictEntry("Class:$sClass/Stimulus:$sStimulusCode+", $oStimulus->GetDescription_Obsolete(), '', $bNotImportant);
}
$sClassRes .= "));\n";
$sClassRes .= "\n";
$sRes .= $sClassRes;
}
}
return $sRes;
}
function CheckDBSchema()
{
$aAnalysis = array();
list($aErrors, $aSugFix) = MetaModel::DBCheckFormat();
foreach ($aErrors as $sClass => $aTarget)
{
foreach ($aTarget as $sAttCode => $aIssues)
{
foreach ($aIssues as $sIssue)
{
$aAnalysis[$sClass]['table_issues'][$sAttCode][] = $sIssue;
}
}
}
foreach ($aSugFix as $sClass => $aTarget)
{
foreach ($aTarget as $sAttCode => $aQueries)
{
foreach ($aQueries as $sQuery)
{
if (!empty($sQuery))
{
$aAnalysis[$sClass]['table_fixes'][$sAttCode][] = $sQuery;
}
}
}
}
list($aErrors, $aSugFix) = MetaModel::DBCheckViews();
foreach ($aErrors as $sClass => $aTarget)
{
foreach ($aTarget as $sAttCode => $aIssues)
{
foreach ($aIssues as $sIssue)
{
$aAnalysis[$sClass]['view_issues'][$sAttCode][] = $sIssue;
}
}
}
foreach ($aSugFix as $sClass => $aTarget)
{
foreach ($aTarget as $sAttCode => $aQueries)
{
foreach ($aQueries as $sQuery)
{
if (!empty($sQuery))
{
$aAnalysis[$sClass]['view_fixes'][$sAttCode][] = $sQuery;
}
}
}
}
return $aAnalysis;
}
function InitDataModel($sConfigFileName, $bModelOnly = true)
{
require_once(APPROOT.'/core/log.class.inc.php');
require_once(A
没有合适的资源?快使用搜索试试~ 我知道了~
iTopDataModelToolkit-2.3.zip
共3个文件
php:2个
css:1个
需积分: 25 23 下载量 194 浏览量
2019-08-17
10:47:19
上传
评论
收藏 9KB ZIP 举报
温馨提示
itop二次开发利器,iTop自定义CI模型,需要Toolkit工具, 1.下载附件中的Toolkit。直接解压到对应的webroot下。 2.直接访问http://xxx/toolkit访问。
资源详情
资源评论
资源推荐
收起资源包目录
iTopDataModelToolkit-2.3.zip (3个子文件)
toolkit
ajax.toolkit.php 18KB
toolkit.css 746B
index.php 12KB
共 3 条
- 1
shanren067
- 粉丝: 1
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0