本文整理汇总了PHP中WebPage::p方法的典型用法代码示例。如果您正苦于以下问题:PHP WebPage::p方法的具体用法?PHP WebPage::p怎么用?PHP WebPage::p使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebPage
的用法示例。
在下文中一共展示了WebPage::p方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ReadMandatoryParam
require_once APPROOT . '/application/clipage.class.inc.php';
require_once APPROOT . '/application/startup.inc.php';
function ReadMandatoryParam($oP, $sParam, $sSanitizationFilter = 'parameter')
{
$sValue = utils::ReadParam($sParam, null, true, $sSanitizationFilter);
if (is_null($sValue)) {
$oP->p("ERROR: Missing argument '{$sParam}'\n");
exit(29);
}
return trim($sValue);
}
/////////////////////////////////
// Main program
if (!utils::IsModeCLI()) {
$oP = new WebPage(Dict::S("TitleSynchroExecution"));
$oP->p("This page is used internally by iTop");
$oP->output();
exit - 2;
}
$oP = new CLIPage(Dict::S("TitleSynchroExecution"));
try {
utils::UseParamFile();
} catch (Exception $e) {
$oP->p("Error: " . $e->GetMessage());
$oP->output();
exit - 2;
}
// Next steps:
// specific arguments: 'csvfile'
//
$sAuthUser = ReadMandatoryParam($oP, 'auth_user', 'raw_data');
示例2: DisplayAttachments
public function DisplayAttachments($oObject, WebPage $oPage, $bEditMode = false)
{
// Exit here if the class is not allowed
if (!$this->IsTargetObject($oObject)) {
return;
}
$oSearch = DBObjectSearch::FromOQL("SELECT Attachment WHERE item_class = :class AND item_id = :item_id");
$oSet = new DBObjectSet($oSearch, array(), array('class' => get_class($oObject), 'item_id' => $oObject->GetKey()));
if ($this->GetAttachmentsPosition() == 'relations') {
$sTitle = $oSet->Count() > 0 ? Dict::Format('Attachments:TabTitle_Count', $oSet->Count()) : Dict::S('Attachments:EmptyTabTitle');
$oPage->SetCurrentTab($sTitle);
}
$oPage->add_style(<<<EOF
.attachment {
\tdisplay: inline-block;
\ttext-align:center;
\tfloat:left;
\tpadding:5px;\t
}
.attachment:hover {
\tbackground-color: #e0e0e0;
}
.attachment img {
\tborder: 0;
}
.attachment a {
\ttext-decoration: none;
\tcolor: #1C94C4;
}
.btn_hidden {
\tdisplay: none;
}
EOF
);
$oPage->add('<fieldset>');
$oPage->add('<legend>' . Dict::S('Attachments:FieldsetTitle') . '</legend>');
if ($bEditMode) {
$sIsDeleteEnabled = $this->m_bDeleteEnabled ? 'true' : 'false';
$iTransactionId = $oPage->GetTransactionId();
$sClass = get_class($oObject);
$sTempId = session_id() . '_' . $iTransactionId;
$sDeleteBtn = Dict::S('Attachments:DeleteBtn');
$oPage->add_script(<<<EOF
\tfunction RemoveNewAttachment(att_id)
\t{
\t\t\$('#attachment_'+att_id).attr('name', 'removed_attachments[]');
\t\t\$('#display_attachment_'+att_id).hide();
\t\t\$('#attachment_plugin').trigger('remove_attachment', [att_id]);
\t\treturn false; // Do not submit the form !
\t}
\tfunction ajaxFileUpload()
\t{
\t\t//starting setting some animation when the ajax starts and completes
\t\t\$("#attachment_loading").ajaxStart(function(){
\t\t\t\$(this).show();
\t\t}).ajaxComplete(function(){
\t\t\t\$(this).hide();
\t\t});
\t\t
\t\t/*
\t\t\tprepareing ajax file upload
\t\t\turl: the url of script file handling the uploaded files
fileElementId: the file type of input element id and it will be the index of \$_FILES Array()
\t\t\tdataType: it support json, xml
\t\t\tsecureuri:use secure protocol
\t\t\tsuccess: call back function when the ajax complete
\t\t\terror: callback function when the ajax failed
\t\t\t
*/
\t\t\$.ajaxFileUpload
\t\t(
\t\t\t{
\t\t\t\turl: GetAbsoluteUrlModulesRoot()+'itop-attachments/ajax.attachment.php?obj_class={$sClass}&temp_id={$sTempId}&operation=add',
\t\t\t\tsecureuri:false,
\t\t\t\tfileElementId:'file',
\t\t\t\tdataType: 'json',
\t\t\t\tsuccess: function (data, status)
\t\t\t\t{
\t\t\t\t\tif(typeof(data.error) != 'undefined')
\t\t\t\t\t{
\t\t\t\t\t\tif(data.error != '')
\t\t\t\t\t\t{
\t\t\t\t\t\t\talert(data.error);
\t\t\t\t\t\t}
\t\t\t\t\t\telse
\t\t\t\t\t\t{
\t\t\t\t\t\t\tvar sDownloadLink = GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?operation=download_document&class=Attachment&id='+data.att_id+'&field=contents';
\t\t\t\t\t\t\t\$('#attachments').append('<div class="attachment" id="display_attachment_'+data.att_id+'"><a href="'+sDownloadLink+'"><img src="'+data.icon+'"><br/>'+data.msg+'<input id="attachment_'+data.att_id+'" type="hidden" name="attachments[]" value="'+data.att_id+'"/></a><br/><input type="button" class="btn_hidden" value="{$sDeleteBtn}" onClick="RemoveNewAttachment('+data.att_id+');"/></div>');
\t\t\t\t\t\t\tif({$sIsDeleteEnabled})
\t\t\t\t\t\t\t{
\t\t\t\t\t\t\t\t\$('#display_attachment_'+data.att_id).hover( function() { \$(this).children(':button').toggleClass('btn_hidden'); } );
\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\$('#attachment_plugin').trigger('add_attachment', [data.att_id, data.msg]);
\t\t\t\t\t\t\t
\t\t\t\t\t\t\t//alert(data.msg);
\t\t\t\t\t\t}
\t\t\t\t\t}
\t\t\t\t},
\t\t\t\terror: function (data, status, e)
\t\t\t\t{
//.........这里部分代码省略.........
示例3: DeleteObjects
/**
* Perform all the needed checks to delete one (or more) objects
*/
public static function DeleteObjects(WebPage $oP, $sClass, $aObjects, $bPreview, $sCustomOperation, $aContextData = array())
{
$oDeletionPlan = new DeletionPlan();
foreach ($aObjects as $oObj) {
if ($bPreview) {
$oObj->CheckToDelete($oDeletionPlan);
} else {
$oObj->DBDeleteTracked(CMDBObject::GetCurrentChange(), null, $oDeletionPlan);
}
}
if ($bPreview) {
if (count($aObjects) == 1) {
$oObj = $aObjects[0];
$oP->add("<h1>" . Dict::Format('UI:Delete:ConfirmDeletionOf_Name', $oObj->GetName()) . "</h1>\n");
} else {
$oP->add("<h1>" . Dict::Format('UI:Delete:ConfirmDeletionOf_Count_ObjectsOf_Class', count($aObjects), MetaModel::GetName($sClass)) . "</h1>\n");
}
// Explain what should be done
//
$aDisplayData = array();
foreach ($oDeletionPlan->ListDeletes() as $sTargetClass => $aDeletes) {
foreach ($aDeletes as $iId => $aData) {
$oToDelete = $aData['to_delete'];
$bAutoDel = $aData['mode'] == DEL_SILENT || $aData['mode'] == DEL_AUTO;
if (array_key_exists('issue', $aData)) {
if ($bAutoDel) {
if (isset($aData['requested_explicitely'])) {
$sConsequence = Dict::Format('UI:Delete:CannotDeleteBecause', $aData['issue']);
} else {
$sConsequence = Dict::Format('UI:Delete:ShouldBeDeletedAtomaticallyButNotPossible', $aData['issue']);
}
} else {
$sConsequence = Dict::Format('UI:Delete:MustBeDeletedManuallyButNotPossible', $aData['issue']);
}
} else {
if ($bAutoDel) {
if (isset($aData['requested_explicitely'])) {
$sConsequence = '';
// not applicable
} else {
$sConsequence = Dict::S('UI:Delete:WillBeDeletedAutomatically');
}
} else {
$sConsequence = Dict::S('UI:Delete:MustBeDeletedManually');
}
}
$aDisplayData[] = array('class' => MetaModel::GetName(get_class($oToDelete)), 'object' => $oToDelete->GetHyperLink(), 'consequence' => $sConsequence);
}
}
foreach ($oDeletionPlan->ListUpdates() as $sRemoteClass => $aToUpdate) {
foreach ($aToUpdate as $iId => $aData) {
$oToUpdate = $aData['to_reset'];
if (array_key_exists('issue', $aData)) {
$sConsequence = Dict::Format('UI:Delete:CannotUpdateBecause_Issue', $aData['issue']);
} else {
$sConsequence = Dict::Format('UI:Delete:WillAutomaticallyUpdate_Fields', $aData['attributes_list']);
}
$aDisplayData[] = array('class' => MetaModel::GetName(get_class($oToUpdate)), 'object' => $oToUpdate->GetHyperLink(), 'consequence' => $sConsequence);
}
}
$iImpactedIndirectly = $oDeletionPlan->GetTargetCount() - count($aObjects);
if ($iImpactedIndirectly > 0) {
if (count($aObjects) == 1) {
$oObj = $aObjects[0];
$oP->p(Dict::Format('UI:Delete:Count_Objects/LinksReferencing_Object', $iImpactedIndirectly, $oObj->GetName()));
} else {
$oP->p(Dict::Format('UI:Delete:Count_Objects/LinksReferencingTheObjects', $iImpactedIndirectly));
}
$oP->p(Dict::S('UI:Delete:ReferencesMustBeDeletedToEnsureIntegrity'));
}
if ($iImpactedIndirectly > 0 || $oDeletionPlan->FoundStopper()) {
$aDisplayConfig = array();
$aDisplayConfig['class'] = array('label' => 'Class', 'description' => '');
$aDisplayConfig['object'] = array('label' => 'Object', 'description' => '');
$aDisplayConfig['consequence'] = array('label' => 'Consequence', 'description' => Dict::S('UI:Delete:Consequence+'));
$oP->table($aDisplayConfig, $aDisplayData);
}
if ($oDeletionPlan->FoundStopper()) {
if ($oDeletionPlan->FoundSecurityIssue()) {
$oP->p(Dict::S('UI:Delete:SorryDeletionNotAllowed'));
} elseif ($oDeletionPlan->FoundManualOperation()) {
$oP->p(Dict::S('UI:Delete:PleaseDoTheManualOperations'));
} else {
$oP->p(Dict::S('UI:Delete:PleaseDoTheManualOperations'));
}
$oAppContext = new ApplicationContext();
$oP->add("<form method=\"post\">\n");
$oP->add("<input type=\"hidden\" name=\"transaction_id\" value=\"" . utils::ReadParam('transaction_id') . "\">\n");
$oP->add("<input type=\"button\" onclick=\"window.history.back();\" value=\"" . Dict::S('UI:Button:Back') . "\">\n");
$oP->add("<input DISABLED type=\"submit\" name=\"\" value=\"" . Dict::S('UI:Button:Delete') . "\">\n");
$oP->add($oAppContext->GetForForm());
$oP->add("</form>\n");
} else {
if (count($aObjects) == 1) {
$oObj = $aObjects[0];
$id = $oObj->GetKey();
$oP->p('<h1>' . Dict::Format('UI:Delect:Confirm_Object', $oObj->GetHyperLink()) . '</h1>');
//.........这里部分代码省略.........
示例4: DisplayAttachments
public function DisplayAttachments($oObject, WebPage $oPage, $bEditMode = false)
{
// Exit here if the class is not allowed
if (!$this->IsTargetObject($oObject)) {
return;
}
$oSearch = DBObjectSearch::FromOQL("SELECT Attachment WHERE item_class = :class AND item_id = :item_id");
$oSet = new DBObjectSet($oSearch, array(), array('class' => get_class($oObject), 'item_id' => $oObject->GetKey()));
if ($this->GetAttachmentsPosition() == 'relations') {
$sTitle = $oSet->Count() > 0 ? Dict::Format('Attachments:TabTitle_Count', $oSet->Count()) : Dict::S('Attachments:EmptyTabTitle');
$oPage->SetCurrentTab($sTitle);
}
$oPage->add_style(<<<EOF
.attachment {
\tdisplay: inline-block;
\ttext-align:center;
\tfloat:left;
\tpadding:5px;\t
}
.attachment:hover {
\tbackground-color: #e0e0e0;
}
.attachment img {
\tborder: 0;
}
.attachment a {
\ttext-decoration: none;
\tcolor: #1C94C4;
}
.btn_hidden {
\tdisplay: none;
}
.drag_in {
\t-webkit-box-shadow:inset 0 0 10px 2px #1C94C4;
\tbox-shadow:inset 0 0 10px 2px #1C94C4;
}
#history .attachment-history-added {
\tpadding: 0;
\tfloat: none;
}
EOF
);
$oPage->add('<fieldset>');
$oPage->add('<legend>' . Dict::S('Attachments:FieldsetTitle') . '</legend>');
if ($bEditMode) {
$sIsDeleteEnabled = $this->m_bDeleteEnabled ? 'true' : 'false';
$iTransactionId = $oPage->GetTransactionId();
$sClass = get_class($oObject);
$sTempId = session_id() . '_' . $iTransactionId;
$sDeleteBtn = Dict::S('Attachments:DeleteBtn');
$oPage->add_script(<<<EOF
\tfunction RemoveAttachment(att_id)
\t{
\t\t\$('#attachment_'+att_id).attr('name', 'removed_attachments[]');
\t\t\$('#display_attachment_'+att_id).hide();
\t\t\$('#attachment_plugin').trigger('remove_attachment', [att_id]);
\t\treturn false; // Do not submit the form !
\t}
EOF
);
$oPage->add('<span id="attachments">');
while ($oAttachment = $oSet->Fetch()) {
$iAttId = $oAttachment->GetKey();
$oDoc = $oAttachment->Get('contents');
$sFileName = $oDoc->GetFileName();
$sIcon = utils::GetAbsoluteUrlAppRoot() . AttachmentPlugIn::GetFileIcon($sFileName);
$sPreview = $oDoc->IsPreviewAvailable() ? 'true' : 'false';
$sDownloadLink = utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=download_document&class=Attachment&id=' . $iAttId . '&field=contents';
$oPage->add('<div class="attachment" id="display_attachment_' . $iAttId . '"><a data-preview="' . $sPreview . '" href="' . $sDownloadLink . '"><img src="' . $sIcon . '"><br/>' . $sFileName . '<input id="attachment_' . $iAttId . '" type="hidden" name="attachments[]" value="' . $iAttId . '"/></a><br/> <input id="btn_remove_' . $iAttId . '" type="button" class="btn_hidden" value="Delete" onClick="RemoveAttachment(' . $iAttId . ');"/> </div>');
}
// Suggested attachments are listed here but treated as temporary
$aDefault = utils::ReadParam('default', array(), false, 'raw_data');
if (array_key_exists('suggested_attachments', $aDefault)) {
$sSuggestedAttachements = $aDefault['suggested_attachments'];
if (is_array($sSuggestedAttachements)) {
$sSuggestedAttachements = implode(',', $sSuggestedAttachements);
}
$oSearch = DBObjectSearch::FromOQL("SELECT Attachment WHERE id IN({$sSuggestedAttachements})");
$oSet = new DBObjectSet($oSearch, array());
if ($oSet->Count() > 0) {
while ($oAttachment = $oSet->Fetch()) {
// Mark the attachments as temporary attachments for the current object/form
$oAttachment->Set('temp_id', $sTempId);
$oAttachment->DBUpdate();
// Display them
$iAttId = $oAttachment->GetKey();
$oDoc = $oAttachment->Get('contents');
$sFileName = $oDoc->GetFileName();
$sIcon = utils::GetAbsoluteUrlAppRoot() . AttachmentPlugIn::GetFileIcon($sFileName);
$sDownloadLink = utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=download_document&class=Attachment&id=' . $iAttId . '&field=contents';
$sPreview = $oDoc->IsPreviewAvailable() ? 'true' : 'false';
$oPage->add('<div class="attachment" id="display_attachment_' . $iAttId . '"><a data-preview="' . $sPreview . '" href="' . $sDownloadLink . '"><img src="' . $sIcon . '"><br/>' . $sFileName . '<input id="attachment_' . $iAttId . '" type="hidden" name="attachments[]" value="' . $iAttId . '"/></a><br/> <input id="btn_remove_' . $iAttId . '" type="button" class="btn_hidden" value="Delete" onClick="RemoveAttachment(' . $iAttId . ');"/> </div>');
$oPage->add_ready_script("\$('#attachment_plugin').trigger('add_attachment', [{$iAttId}, '" . addslashes($sFileName) . "']);");
}
}
}
$oPage->add('</span>');
$oPage->add('<div style="clear:both"></div>');
$sMaxUpload = $this->GetMaxUpload();
$oPage->p(Dict::S('Attachments:AddAttachment') . '<input type="file" name="file" id="file"><span style="display:none;" id="attachment_loading"> <img src="../images/indicator.gif"></span> ' . $sMaxUpload);
//.........这里部分代码省略.........
示例5: DisplayExpressionForm
function DisplayExpressionForm(WebPage $oP, $sAction, $sExpression = '', $sExceptionMessage = '')
{
$oP->add('<fieldset><legend>' . Dict::S('Core:BulkExport:ScopeDefinition') . '</legend>');
$oP->add('<form id="export-form" action="' . $sAction . '" method="post">');
$oP->add('<input type="hidden" name="interactive" value="1">');
$oP->add('<table style="width:100%" class="export_parameters">');
$sExpressionHint = empty($sExceptionMessage) ? '' : '<tr><td colspan="2">' . htmlentities($sExceptionMessage, ENT_QUOTES, 'UTF-8') . '</td></tr>';
$oP->add('<tr><td class="column-label"><span style="white-space: nowrap;"><input type="radio" name="query_mode" value="oql" id="radio_oql" checked><label for="radio_oql">' . Dict::S('Core:BulkExportLabelOQLExpression') . '</label></span></td>');
$oP->add('<td><textarea style="width:100%" cols="70" rows="8" name="expression" id="textarea_oql" placeholder="' . Dict::S('Core:BulkExportQueryPlaceholder') . '">' . htmlentities($sExpression, ENT_QUOTES, 'UTF-8') . '</textarea></td></tr>');
$oP->add($sExpressionHint);
$oP->add('<tr><td class="column-label"><span style="white-space: nowrap;"><input type="radio" name="query_mode" value="phrasebook" id="radio_phrasebook"><label for="radio_phrasebook">' . Dict::S('Core:BulkExportLabelPhrasebookEntry') . '</label></span></td>');
$oP->add('<td><select name="query" id="select_phrasebook">');
$oP->add('<option value="">' . Dict::S('UI:SelectOne') . '</option>');
$oSearch = DBObjectSearch::FromOQL('SELECT QueryOQL');
$oQueries = new DBObjectSet($oSearch);
while ($oQuery = $oQueries->Fetch()) {
$oP->add('<option value="' . $oQuery->GetKey() . '">' . htmlentities($oQuery->Get('name'), ENT_QUOTES, 'UTF-8') . '</option>');
}
$oP->add('</select></td></tr>');
$oP->add('<tr><td colspan="2" style="text-align:right"><button type="submit" id="next-btn">' . Dict::S('UI:Button:Next') . '</button></td></tr>');
$oP->add('</table>');
$oP->add('</form>');
$oP->add('</fieldset>');
$oP->p('<a target="_blank" href="' . utils::GetAbsoluteUrlAppRoot() . 'webservices/export-v2.php">' . Dict::S('Core:BulkExportCanRunNonInteractive') . '</a>');
$oP->p('<a target="_blank" href="' . utils::GetAbsoluteUrlAppRoot() . 'webservices/export.php">' . Dict::S('Core:BulkExportLegacyExport') . '</a>');
$sJSEmptyOQL = json_encode(Dict::S('Core:BulkExportMessageEmptyOQL'));
$sJSEmptyQueryId = json_encode(Dict::S('Core:BulkExportMessageEmptyPhrasebookEntry'));
$oP->add_ready_script(<<<EOF
var colWidth = 0;
\$('td.column-label').each(function() {
\tvar jLabel = \$(this).find('span');
\tcolWidth = Math.max(colWidth, jLabel.width());
});
\$('td.column-label').each(function() {
\tvar jLabel = \$(this).width(colWidth);
});
\t\t
\$('#textarea_oql').on('change keyup', function() {
\t\$('#radio_oql').prop('checked', true);
});
\$('#select_phrasebook').on('change', function() {
\t\$('#radio_phrasebook').prop('checked', true);
});
\$('#export-form').on('submit', function() {
\tif (\$('#radio_oql').prop('checked'))
\t{
\t\tvar sOQL = \$('#textarea_oql').val();
\t\tif (sOQL == '')
\t\t{
\t\t\talert({$sJSEmptyOQL});
\t\t\treturn false;
\t\t}
\t}
\telse
\t{
\t\tvar sQueryId = \$('#select_phrasebook').val();
\t\tif (sQueryId == '')
\t\t{
\t\t\talert({$sJSEmptyQueryId});
\t\t\treturn false;
\t\t}
\t}
\treturn true;
});
EOF
);
}
示例6: DisplayStatusTab
/**
* Displays the status (SynchroLog) of the datasource in a graphical manner
* @param $oPage WebPage
* @return void
*/
protected function DisplayStatusTab(WebPage $oPage)
{
$oPage->SetCurrentTab(Dict::S('Core:SynchroStatus'));
$sSelectSynchroLog = 'SELECT SynchroLog WHERE sync_source_id = :source_id';
$oSetSynchroLog = new CMDBObjectSet(DBObjectSearch::FromOQL($sSelectSynchroLog), array('start_date' => false), array('source_id' => $this->GetKey()));
$oSetSynchroLog->SetLimit(100);
// Display only the 100 latest runs
if ($oSetSynchroLog->Count() > 0) {
$oLastLog = $oSetSynchroLog->Fetch();
$sStartDate = $oLastLog->Get('start_date');
$oLastLog->Get('stats_nb_replica_seen');
$iLastLog = 0;
$iDSid = $this->GetKey();
if ($oLastLog->Get('status') == 'running') {
// Still running !
$oPage->p('<h2>' . Dict::Format('Core:Synchro:SynchroRunningStartedOn_Date', $sStartDate) . '</h2>');
} else {
$sEndDate = $oLastLog->Get('end_date');
$iLastLog = $oLastLog->GetKey();
$oPage->p('<h2>' . Dict::Format('Core:Synchro:SynchroEndedOn_Date', $sEndDate) . '</h2>');
$sOQL = "SELECT SynchroReplica WHERE sync_source_id={$iDSid}";
$oSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL));
$iCountAllReplicas = $oSet->Count();
$sAllReplicas = "<a href=\"../synchro/replica.php?operation=oql&datasource={$iDSid}&oql={$sOQL}\">{$iCountAllReplicas}</a>";
$sOQL = "SELECT SynchroReplica WHERE sync_source_id={$iDSid} AND status_last_error !=''";
$oSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL));
$iCountAllErrors = $oSet->Count();
$sAllErrors = "<a href=\"../synchro/replica.php?operation=oql&datasource={$iDSid}&oql={$sOQL}\">{$iCountAllErrors}</a>";
$sOQL = "SELECT SynchroReplica WHERE sync_source_id={$iDSid} AND status_last_warning !=''";
$oSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL));
$iCountAllWarnings = $oSet->Count();
$sAllWarnings = "<a href=\"../synchro/replica.php?operation=oql&datasource={$iDSid}&oql={$sOQL}\">{$iCountAllWarnings}</a>";
$oPage->p('<h2>' . Dict::Format('Core:Synchro:ListReplicas_AllReplicas_Errors_Warnings', $sAllReplicas, $sAllErrors, $sAllWarnings) . '</h2>');
}
$oPage->add('<table class="synoptics"><tr><td style="color:#333;vertical-align:top">');
// List all the log entries for the user to select
$oPage->add('<h2 style="line-height:55px;">' . Dict::S('Core:Synchro:History') . '</h2>');
$oSetSynchroLog->Rewind();
$oPage->add('<select size="25" onChange="UpdateSynoptics(this.value);">');
$sSelected = ' selected';
// First log is selected by default
$sScript = "var aSynchroLog = {\n";
while ($oLog = $oSetSynchroLog->Fetch()) {
$sLogTitle = Dict::Format('Core:SynchroLogTitle', $oLog->Get('status'), $oLog->Get('start_date'));
$oPage->add('<option value="' . $oLog->GetKey() . '"' . $sSelected . '>' . $sLogTitle . '</option>');
$sSelected = '';
// only the first log is selected by default
$aData = $this->ProcessLog($oLog);
$sScript .= '"' . $oLog->GetKey() . '": ' . json_encode($aData) . ",\n";
}
$sScript .= "end: 'Done'";
$sScript .= "};\n";
$sScript .= <<<EOF
\t\t\tvar sLastLog = '{$iLastLog}';
\tfunction ToggleSynoptics(sId, bShow)
\t{
\t\tif (bShow)
\t\t{
\t\t\t\$(sId).show();
\t\t}
\t\telse
\t\t{
\t\t\t\$(sId).hide();
\t\t}
\t}
\t
\tfunction UpdateSynoptics(id)
\t{
\t\tvar aValues = aSynchroLog[id];
\t\tif (aValues == undefined) return;
\t\t
\t\tfor (var sKey in aValues)
\t\t{
\t\t\t\$('#c_'+sKey).html(aValues[sKey]);
\t\t\tvar fOpacity = (aValues[sKey] == 0) ? 0.3 : 1;
\t\t\t\$('#'+sKey).fadeTo("slow", fOpacity);
\t\t}
\t\t//alert('id = '+id+', lastLog='+sLastLog+', id==sLastLog: '+(id==sLastLog)+' obj_updated_errors: '+aValues['obj_updated_errors']);
\t\tif ( (id == sLastLog) && (aValues['obj_new_errors'] > 0) )
\t\t{
\t\t\t\$('#new_errors_link').show();
\t\t}
\t\telse
\t\t{
\t\t\t\$('#new_errors_link').hide();
\t\t}
\t\t
\t\tif ( (id == sLastLog) && (aValues['obj_updated_errors'] > 0) )
\t\t{
\t\t\t\$('#updated_errors_link').show();
\t\t}
\t\telse
\t\t{
\t\t\t\$('#updated_errors_link').hide();
\t\t}
//.........这里部分代码省略.........
示例7: DownloadDocument
/**
* Downloads a document to the browser, either as 'inline' or 'attachment'
*
* @param WebPage $oPage The web page for the output
* @param string $sClass Class name of the object
* @param mixed $id Identifier of the object
* @param string $sAttCode Name of the attribute containing the document to download
* @param string $sContentDisposition Either 'inline' or 'attachment'
* @return none
*/
function DownloadDocument(WebPage $oPage, $sClass, $id, $sAttCode, $sContentDisposition = 'attachment')
{
try {
$oObj = MetaModel::GetObject($sClass, $id, false, false);
if (!is_object($oObj)) {
throw new Exception("Invalid id ({$id}) for class '{$sClass}' - the object does not exist or you are not allowed to view it");
}
$oDocument = $oObj->Get($sAttCode);
if (is_object($oDocument)) {
$oPage->TrashUnexpectedOutput();
$oPage->SetContentType($oDocument->GetMimeType());
$oPage->SetContentDisposition($sContentDisposition, $oDocument->GetFileName());
$oPage->add($oDocument->GetData());
}
} catch (Exception $e) {
$oPage->p($e->getMessage());
}
}
示例8: CLIPage
}
////////////////////////////////////////////////////////////////////////////////
//
// Main
//
set_time_limit(0);
// Some background actions may really take long to finish (like backup)
if (utils::IsModeCLI()) {
$oP = new CLIPage("iTop - CRON");
} else {
$oP = new WebPage("iTop - CRON");
}
try {
utils::UseParamFile();
} catch (Exception $e) {
$oP->p("Error: " . $e->GetMessage());
$oP->output();
exit - 2;
}
if (utils::IsModeCLI()) {
// Next steps:
// specific arguments: 'csvfile'
//
$sAuthUser = ReadMandatoryParam($oP, 'auth_user', 'raw_data');
$sAuthPwd = ReadMandatoryParam($oP, 'auth_pwd', 'raw_data');
if (UserRights::CheckCredentials($sAuthUser, $sAuthPwd)) {
UserRights::Login($sAuthUser);
// Login & set the user's language
} else {
$oP->p("Access wrong credentials ('{$sAuthUser}')");
$oP->output();
示例9: DisplayRequestLists
/**
* Helper to display lists (UserRequest, Incident, etc.)
* Adjust the presentation depending on the following cases:
* - no item at all
* - items of one class only
* - items of several classes
*/
function DisplayRequestLists(WebPage $oP, $aClassToSet)
{
$iNotEmpty = 0;
// Count of types for which there are some items to display
foreach ($aClassToSet as $sClass => $oSet) {
if ($oSet->Count() > 0) {
$iNotEmpty++;
}
}
if ($iNotEmpty == 0) {
$oP->p(Dict::S('Portal:NoOpenRequest'));
} else {
foreach ($aClassToSet as $sClass => $oSet) {
if ($iNotEmpty > 1) {
// Differentiate the sublists
$oP->add("<h2>" . MetaModel::GetName($sClass) . "</h2>\n");
}
if ($oSet->Count() > 0) {
$sZList = GetConstant($sClass, 'LIST_ZLIST');
$aZList = explode(',', $sZList);
$oP->DisplaySet($oSet, $aZList, Dict::S('Portal:NoOpenRequest'));
}
}
}
}
示例10: CLIPage
$oP->p("Error the query can not be executed.");
if ($e instanceof CoreException) {
$oP->p($e->GetHtmlDesc());
} else {
$oP->p($e->getMessage());
}
}
}
if (!$oP) {
// Display a short message about how to use this page
$bModeCLI = utils::IsModeCLI();
if ($bModeCLI) {
$oP = new CLIPage("iTop - Export");
} else {
$oP = new WebPage("iTop - Export");
}
$oP->p("General purpose export page.");
$oP->p("Parameters:");
$oP->p(" * expression: an OQL expression (URL encoded if needed)");
$oP->p(" * query: (alternative to 'expression') the id of an entry from the query phrasebook");
$oP->p(" * arg_xxx: (needed if the query has parameters) the value of the parameter 'xxx'");
$oP->p(" * format: (optional, default is html) the desired output format. Can be one of 'html', 'spreadsheet', 'csv', 'xlsx' or 'xml'");
$oP->p(" * fields: (optional, no effect on XML format) list of fields (attribute codes, or alias.attcode) separated by a coma");
$oP->p(" * fields_advanced: (optional, no effect on XML/HTML formats ; ignored is fields is specified) If set to 1, the default list of fields will include the external keys and their reconciliation keys");
$oP->p(" * filename: (optional, no effect in CLI mode) if set then the results will be downloaded as a file");
}
if ($sFileName != '') {
$oP->add_header('Content-Disposition: attachment; filename="' . $sFileName . '"');
}
$oP->TrashUnexpectedOutput();
$oP->output();
示例11: DisplayAsBlock
protected function DisplayAsBlock(WebPage $oPage, DBObjectSet $oValue, $aArgs = array(), $sFormPrefix, $oCurrentObj, $bDisplayMenu)
{
$oLinksetDef = MetaModel::GetAttributeDef($this->sClass, $this->sAttCode);
$sTargetClass = $oLinksetDef->GetLinkedClass();
if ($oCurrentObj && $oCurrentObj->IsNew() && $bDisplayMenu) {
$oPage->p(Dict::Format('UI:BeforeAdding_Class_ObjectsSaveThisObject', MetaModel::GetName($sTargetClass)));
} else {
$oFilter = new DBObjectSearch($sTargetClass);
$oFilter->AddCondition($oLinksetDef->GetExtKeyToMe(), $oCurrentObj->GetKey(), '=');
$aDefaults = array($oLinksetDef->GetExtKeyToMe() => $oCurrentObj->GetKey());
$oAppContext = new ApplicationContext();
foreach ($oAppContext->GetNames() as $sKey) {
// The linked object inherits the parent's value for the context
if (MetaModel::IsValidAttCode($this->sClass, $sKey) && $oCurrentObj) {
$aDefaults[$sKey] = $oCurrentObj->Get($sKey);
}
}
$aParams = array('target_attr' => $oLinksetDef->GetExtKeyToMe(), 'object_id' => $oCurrentObj ? $oCurrentObj->GetKey() : null, 'menu' => $bDisplayMenu, 'default' => $aDefaults, 'table_id' => $this->sClass . '_' . $this->sAttCode);
$oBlock = new DisplayBlock($oFilter, 'list', false);
$oBlock->Display($oPage, $this->sInputid, $aParams);
}
}
示例12: WebPage
// Main program
//
/////////////////////////////////////////////////////////////////////////////
require_once '../approot.inc.php';
require_once APPROOT . '/application/application.inc.php';
require_once APPROOT . '/application/ajaxwebpage.class.inc.php';
require_once APPROOT . '/application/startup.inc.php';
$operation = utils::ReadParam('operation', '');
require_once APPROOT . '/application/loginwebpage.class.inc.php';
LoginWebPage::DoLogin();
// Check user rights and prompt if needed
$oP = new WebPage('Replay queries.log');
ini_set('memory_limit', '512M');
require_once APPROOT . '/data/queries.log';
$iCount = count($aQueriesLog);
$oP->p("Nombre de requêtes: " . $iCount);
$sOperation = utils::ReadParam('operation', '');
switch ($sOperation) {
case '':
default:
$oP->add("<ol>\n");
foreach ($aQueriesLog as $sQueryId => $aOqlData) {
$sOql = $aOqlData['oql'];
$sOqlHtml = htmlentities($sOql, ENT_QUOTES, 'UTF-8');
$oP->add("<li>{$sOqlHtml} <a href=\"?operation=zoom&query={$sQueryId}\">zoom</a></li>\n");
}
$oP->add("</ol>\n");
$oP->add("<form action=\"?operation=benchmark&repeat=3\" method=\"post\">\n");
$oP->add("<input type=\"submit\" value=\"Benchmark (3 repeats)!\">\n");
$oP->add("</form>\n");
$oP->add("<form action=\"?operation=check\" method=\"post\">\n");
示例13: Display
public function Display(WebPage $oPage)
{
// Check if there are some manual steps required:
$aManualSteps = array();
$aAvailableModules = SetupUtils::AnalyzeInstallation($this->oWizard);
$sRootUrl = utils::GetAbsoluteUrlAppRoot();
$aSelectedModules = json_decode($this->oWizard->GetParameter('selected_modules'), true);
foreach ($aSelectedModules as $sModuleId) {
if (!empty($aAvailableModules[$sModuleId]['doc.manual_setup'])) {
$aManualSteps[$aAvailableModules[$sModuleId]['label']] = $sRootUrl . $aAvailableModules[$sModuleId]['doc.manual_setup'];
}
}
if (count($aManualSteps) > 0) {
$oPage->add("<h2>Manual operations required</h2>");
$oPage->p("In order to complete the installation, the following manual operations are required:");
foreach ($aManualSteps as $sModuleLabel => $sUrl) {
$oPage->p("<a href=\"{$sUrl}\" target=\"_blank\">Manual instructions for {$sModuleLabel}</a>");
}
$oPage->add("<h2>Congratulations for installing " . ITOP_APPLICATION . "</h2>");
} else {
$oPage->add("<h2>Congratulations for installing " . ITOP_APPLICATION . "</h2>");
$oPage->ok("The installation completed successfully.");
}
if ($this->oWizard->GetParameter('mode', '') == 'upgrade' && $this->oWizard->GetParameter('db_backup', false)) {
$sBackupDestination = $this->oWizard->GetParameter('db_backup_path', '');
if (file_exists($sBackupDestination)) {
// To mitigate security risks: pass only the filename without the extension, the download will add the extension itself
$sTruncatedFilePath = preg_replace('/\\.zip$/', '', $sBackupDestination);
$oPage->p('Your backup is ready');
$oPage->p('<a style="background:transparent;" href="' . utils::GetAbsoluteUrlAppRoot() . 'setup/ajax.dataloader.php?operation=async_action&step_class=WizStepDone¶ms[backup]=' . urlencode($sTruncatedFilePath) . '" target="_blank"><img src="../images/tar.png" style="border:0;vertical-align:middle;"> Download ' . basename($sBackupDestination) . '</a>');
} else {
$oPage->p('<img src="../images/error.png"/> Warning: Backup creation failed !');
}
}
// Form goes here.. No back button since the job is done !
$oPage->add('<table style="width:600px;border:0;padding:0;"><tr>');
$oPage->add("<td><a style=\"background:transparent;padding:0;\" title=\"Free: Register your iTop version.\" href=\"http://www.combodo.com/register?product=iTop&version=" . urlencode(ITOP_VERSION . " revision " . ITOP_REVISION) . "\" target=\"_blank\"><img style=\"border:0\" src=\"../images/setup-register.gif\"/></td></a>");
$oPage->add("<td><a style=\"background:transparent;padding:0;\" title=\"Get Professional Support from Combodo\" href=\"http://www.combodo.com/itopsupport\" target=\"_blank\"><img style=\"border:0\" src=\"../images/setup-support.gif\"/></td></a>");
$oPage->add("<td><a style=\"background:transparent;padding:0;\" title=\"Get Professional Training from Combodo\" href=\"http://www.combodo.com/itoptraining\" target=\"_blank\"><img style=\"border:0\" src=\"../images/setup-training.gif\"/></td></a>");
$oPage->add('</tr></table>');
$sForm = '<form method="post" action="' . $this->oWizard->GetParameter('application_url') . 'pages/UI.php">';
$sForm .= '<input type="hidden" name="auth_user" value="' . htmlentities($this->oWizard->GetParameter('admin_user'), ENT_QUOTES, 'UTF-8') . '">';
$sForm .= '<input type="hidden" name="auth_pwd" value="' . htmlentities($this->oWizard->GetParameter('admin_pwd'), ENT_QUOTES, 'UTF-8') . '">';
$sForm .= "<p style=\"text-align:center;width:100%\"><button id=\"enter_itop\" type=\"submit\">Enter " . ITOP_APPLICATION . "</button></p>";
$sForm .= '</form>';
$sPHPVersion = phpversion();
$sMySQLVersion = SetupUtils::GetMySQLVersion($this->oWizard->GetParameter('db_server'), $this->oWizard->GetParameter('db_user'), $this->oWizard->GetParameter('db_pwd'));
$oPage->add('<img style="border:0" src="http://www.combodo.com/stats/?p=' . urlencode(ITOP_APPLICATION) . '&v=' . urlencode(ITOP_VERSION) . '&php=' . urlencode($sPHPVersion) . '&mysql=' . urlencode($sMySQLVersion) . '&os=' . urlencode(PHP_OS) . '"/>');
$sForm = addslashes($sForm);
$oPage->add_ready_script("\$('#wiz_form').after('{$sForm}');");
}
示例14: DisplayImportHistory
/**
* Display the history of bulk imports
*/
static function DisplayImportHistory(WebPage $oPage, $bFromAjax = false, $bShowAll = false)
{
$sAjaxDivId = "CSVImportHistory";
if (!$bFromAjax) {
$oPage->add('<div id="' . $sAjaxDivId . '">');
}
$oPage->p(Dict::S('UI:History:BulkImports+') . ' <span id="csv_history_reload"></span>');
$oBulkChangeSearch = DBObjectSearch::FromOQL("SELECT CMDBChange WHERE origin IN ('csv-interactive', 'csv-import.php')");
$iQueryLimit = $bShowAll ? 0 : appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit());
$oBulkChanges = new DBObjectSet($oBulkChangeSearch, array('date' => false), array(), null, $iQueryLimit);
$oAppContext = new ApplicationContext();
$bLimitExceeded = false;
if ($oBulkChanges->Count() > appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit())) {
$bLimitExceeded = true;
if (!$bShowAll) {
$iMaxObjects = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit());
$oBulkChanges->SetLimit($iMaxObjects);
}
}
$oBulkChanges->Seek(0);
$aDetails = array();
while ($oChange = $oBulkChanges->Fetch()) {
$sDate = '<a href="csvimport.php?step=10&changeid=' . $oChange->GetKey() . '&' . $oAppContext->GetForLink() . '">' . $oChange->Get('date') . '</a>';
$sUser = $oChange->GetUserName();
if (preg_match('/^(.*)\\(CSV\\)$/i', $oChange->Get('userinfo'), $aMatches)) {
$sUser = $aMatches[1];
} else {
$sUser = $oChange->Get('userinfo');
}
$oOpSearch = DBObjectSearch::FromOQL("SELECT CMDBChangeOpCreate WHERE change = :change_id");
$oOpSet = new DBObjectSet($oOpSearch, array(), array('change_id' => $oChange->GetKey()));
$iCreated = $oOpSet->Count();
// Get the class from the first item found (assumption: a CSV load is done for a single class)
if ($oCreateOp = $oOpSet->Fetch()) {
$sClass = $oCreateOp->Get('objclass');
}
$oOpSearch = DBObjectSearch::FromOQL("SELECT CMDBChangeOpSetAttribute WHERE change = :change_id");
$oOpSet = new DBObjectSet($oOpSearch, array(), array('change_id' => $oChange->GetKey()));
$aModified = array();
$aAttList = array();
while ($oModified = $oOpSet->Fetch()) {
// Get the class (if not done earlier on object creation)
$sClass = $oModified->Get('objclass');
$iKey = $oModified->Get('objkey');
$sAttCode = $oModified->Get('attcode');
$aAttList[$sClass][$sAttCode] = true;
$aModified["{$sClass}::{$iKey}"] = true;
}
$iModified = count($aModified);
// Assumption: there is only one class of objects being loaded
// Then the last class found gives us the class for every object
if ($iModified > 0 || $iCreated > 0) {
$aDetails[] = array('date' => $sDate, 'user' => $sUser, 'class' => $sClass, 'created' => $iCreated, 'modified' => $iModified);
}
}
$aConfig = array('date' => array('label' => Dict::S('UI:History:Date'), 'description' => Dict::S('UI:History:Date+')), 'user' => array('label' => Dict::S('UI:History:User'), 'description' => Dict::S('UI:History:User+')), 'class' => array('label' => Dict::S('Core:AttributeClass'), 'description' => Dict::S('Core:AttributeClass+')), 'created' => array('label' => Dict::S('UI:History:StatsCreations'), 'description' => Dict::S('UI:History:StatsCreations+')), 'modified' => array('label' => Dict::S('UI:History:StatsModifs'), 'description' => Dict::S('UI:History:StatsModifs+')));
if ($bLimitExceeded) {
if ($bShowAll) {
// Collapsible list
$oPage->add('<p>' . Dict::Format('UI:CountOfResults', $oBulkChanges->Count()) . ' <a class="truncated" onclick="OnTruncatedHistoryToggle(false);">' . Dict::S('UI:CollapseList') . '</a></p>');
} else {
// Truncated list
$iMinDisplayLimit = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit());
$sCollapsedLabel = Dict::Format('UI:TruncatedResults', $iMinDisplayLimit, $oBulkChanges->Count());
$sLinkLabel = Dict::S('UI:DisplayAll');
$oPage->add('<p>' . $sCollapsedLabel . ' <a class="truncated" onclick="OnTruncatedHistoryToggle(true);">' . $sLinkLabel . '</p>');
$oPage->add_ready_script(<<<EOF
\t\$('#{$sAjaxDivId} table.listResults').addClass('truncated');
\t\$('#{$sAjaxDivId} table.listResults tr:last td').addClass('truncated');
EOF
);
$sAppContext = $oAppContext->GetForLink();
$oPage->add_script(<<<EOF
\tfunction OnTruncatedHistoryToggle(bShowAll)
\t{
\t\t\$('#csv_history_reload').html('<img src="../images/indicator.gif"/>');
\t\t\$.get(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?{$sAppContext}', {operation: 'displayCSVHistory', showall: bShowAll}, function(data)
\t\t\t{
\t\t\t\t\$('#{$sAjaxDivId}').html(data);
\t\t\t\tvar table = \$('#{$sAjaxDivId} .listResults');
\t\t\t\ttable.tableHover(); // hover tables
\t\t\t\ttable.tablesorter( { widgets: ['myZebra', 'truncatedList']} ); // sortable and zebra tables
\t\t\t}
\t\t);
\t}
EOF
);
}
} else {
// Normal display - full list without any decoration
}
$oPage->table($aConfig, $aDetails);
if (!$bFromAjax) {
$oPage->add('</div>');
}
}