当前位置: 首页>>代码示例>>PHP>>正文


PHP MetaModel::ApplyParams方法代码示例

本文整理汇总了PHP中MetaModel::ApplyParams方法的典型用法代码示例。如果您正苦于以下问题:PHP MetaModel::ApplyParams方法的具体用法?PHP MetaModel::ApplyParams怎么用?PHP MetaModel::ApplyParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MetaModel的用法示例。


在下文中一共展示了MetaModel::ApplyParams方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _DoExecute

 protected function _DoExecute($oTrigger, $aContextArgs, &$oLog)
 {
     $sPreviousUrlMaker = ApplicationContext::SetUrlMakerClass();
     try {
         $sScriptPath = $this->Get('script_path');
         if (!is_executable($sScriptPath)) {
             throw new Exception('cannot execute script');
         }
         $sCMD = '';
         $aParams = explode("\n", $this->Get('params'));
         array_walk($aParams, function (&$aParam) {
             $aParam = explode('=', $aParam);
             $aParam = array_map('trim', $aParam);
         });
         foreach ($aParams as $aParam) {
             if (count($aParam) == 2) {
                 $sVarName = $aParam[0];
                 $sVarValue = MetaModel::ApplyParams($aParam[1], $aContextArgs);
                 if ($sVarValue == $aParam[1]) {
                     $sVarValue = '';
                     // Значит ApplyParams не нашел такого плейсхолдера
                     if ($this->IsBeingTested() && !is_null($oLog)) {
                         $oLog->Set('log', $oLog->Get('log') . "There is no value for placeholder: {$aParam['1']}\n");
                     }
                 }
             } else {
                 $sVarName = $aParam[0];
                 $sVarValue = MetaModel::ApplyParams($aParam[0], $aContextArgs);
                 if ($sVarValue == $aParam[0]) {
                     $sVarValue = '';
                     if ($this->IsBeingTested() && !is_null($oLog)) {
                         $oLog->Set('log', $oLog->Get('log') . "There is no value for placeholder: {$aParam['0']}\n");
                     }
                 }
             }
             $sVarName = str_replace('->', '_', $sVarName);
             $sVarName = str_replace('$', '', $sVarName);
             $sVarName = strtoupper($sVarName);
             $sCMD .= $sVarName . '="' . $sVarValue . '" ';
         }
         $sCMD .= ' ' . $sScriptPath;
         if ($this->IsBeingTested()) {
             if (!is_null($oLog)) {
                 $oLog->Set('log', $oLog->Get('log') . "Start executing shell command:\n{$sCMD}");
             }
             return "Script will be started.";
         }
         if (!is_null($oLog)) {
             $oLog->Set('log', shell_exec($sCMD));
         }
         return "Script {$sScriptPath} successfully started.";
     } catch (Exception $e) {
         ApplicationContext::SetUrlMakerClass($sPreviousUrlMaker);
         throw $e;
         // Ошибка выбрасывается на верхний уровень и записывается в лог оповещения.
     }
     ApplicationContext::SetUrlMakerClass($sPreviousUrlMaker);
 }
开发者ID:itop-itsm-ru,项目名称:action-shell-exec,代码行数:58,代码来源:main.action-shell-exec.php

示例2: Render

 public function Render(WebPage $oPage, $aParams = array())
 {
     $this->m_sTemplate = MetaModel::ApplyParams($this->m_sTemplate, $aParams);
     $iStart = 0;
     $iEnd = strlen($this->m_sTemplate);
     $iCount = 0;
     $iBeforeTagPos = $iStart;
     $iAfterTagPos = $iStart;
     while ($sTag = $this->GetNextTag($iStart, $iEnd)) {
         $sContent = $this->GetTagContent($sTag, $iStart, $iEnd);
         $iAfterTagPos = $iEnd + strlen('</' . $sTag . '>');
         $sOuterTag = substr($this->m_sTemplate, $iStart, $iAfterTagPos - $iStart);
         $oPage->add(substr($this->m_sTemplate, $iBeforeTagPos, $iStart - $iBeforeTagPos));
         if ($sTag == DisplayBlock::TAG_BLOCK) {
             try {
                 $oBlock = DisplayBlock::FromTemplate($sOuterTag);
                 if (is_object($oBlock)) {
                     $oBlock->Display($oPage, 'block_' . self::$iBlockCount, $aParams);
                 }
             } catch (OQLException $e) {
                 $oPage->p('Error in template (please contact your administrator) - Invalid query<!--' . $sOuterTag . '-->');
             } catch (Exception $e) {
                 $oPage->p('Error in template (please contact your administrator)<!--' . $e->getMessage() . '--><!--' . $sOuterTag . '-->');
             }
             self::$iBlockCount++;
         } else {
             $aAttributes = $this->GetTagAttributes($sTag, $iStart, $iEnd);
             //$oPage->p("Tag: $sTag - ($iStart, $iEnd)");
             $this->RenderTag($oPage, $sTag, $aAttributes, $sContent);
         }
         $iAfterTagPos = $iEnd + strlen('</' . $sTag . '>');
         $iBeforeTagPos = $iAfterTagPos;
         $iStart = $iEnd;
         $iEnd = strlen($this->m_sTemplate);
         $iCount++;
     }
     $oPage->add(substr($this->m_sTemplate, $iAfterTagPos));
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:38,代码来源:template.class.inc.php

示例3: _DoExecute

 protected function _DoExecute($oTrigger, $aContextArgs, &$oLog)
 {
     $sPreviousUrlMaker = ApplicationContext::SetUrlMakerClass();
     try {
         $this->m_iRecipients = 0;
         $this->m_aMailErrors = array();
         $bRes = false;
         // until we do succeed in sending the email
         // Determine recicipients
         //
         $sTo = $this->FindRecipients('to', $aContextArgs);
         $sCC = $this->FindRecipients('cc', $aContextArgs);
         $sBCC = $this->FindRecipients('bcc', $aContextArgs);
         $sFrom = MetaModel::ApplyParams($this->Get('from'), $aContextArgs);
         $sReplyTo = MetaModel::ApplyParams($this->Get('reply_to'), $aContextArgs);
         $sSubject = MetaModel::ApplyParams($this->Get('subject'), $aContextArgs);
         $sBody = MetaModel::ApplyParams($this->Get('body'), $aContextArgs);
         $oObj = $aContextArgs['this->object()'];
         $sMessageId = sprintf('iTop_%s_%d_%f@%s.openitop.org', get_class($oObj), $oObj->GetKey(), microtime(true), MetaModel::GetEnvironmentId());
         $sReference = '<' . $sMessageId . '>';
     } catch (Exception $e) {
         ApplicationContext::SetUrlMakerClass($sPreviousUrlMaker);
         throw $e;
     }
     ApplicationContext::SetUrlMakerClass($sPreviousUrlMaker);
     if (!is_null($oLog)) {
         // Note: we have to secure this because those values are calculated
         // inside the try statement, and we would like to keep track of as
         // many data as we could while some variables may still be undefined
         if (isset($sTo)) {
             $oLog->Set('to', $sTo);
         }
         if (isset($sCC)) {
             $oLog->Set('cc', $sCC);
         }
         if (isset($sBCC)) {
             $oLog->Set('bcc', $sBCC);
         }
         if (isset($sFrom)) {
             $oLog->Set('from', $sFrom);
         }
         if (isset($sSubject)) {
             $oLog->Set('subject', $sSubject);
         }
         if (isset($sBody)) {
             $oLog->Set('body', $sBody);
         }
     }
     $oEmail = new EMail();
     if ($this->IsBeingTested()) {
         $oEmail->SetSubject('TEST[' . $sSubject . ']');
         $sTestBody = $sBody;
         $sTestBody .= "<div style=\"border: dashed;\">\n";
         $sTestBody .= "<h1>Testing email notification " . $this->GetHyperlink() . "</h1>\n";
         $sTestBody .= "<p>The email should be sent with the following properties\n";
         $sTestBody .= "<ul>\n";
         $sTestBody .= "<li>TO: {$sTo}</li>\n";
         $sTestBody .= "<li>CC: {$sCC}</li>\n";
         $sTestBody .= "<li>BCC: {$sBCC}</li>\n";
         $sTestBody .= "<li>From: {$sFrom}</li>\n";
         $sTestBody .= "<li>Reply-To: {$sReplyTo}</li>\n";
         $sTestBody .= "<li>References: {$sReference}</li>\n";
         $sTestBody .= "</ul>\n";
         $sTestBody .= "</p>\n";
         $sTestBody .= "</div>\n";
         $oEmail->SetBody($sTestBody);
         $oEmail->SetRecipientTO($this->Get('test_recipient'));
         $oEmail->SetRecipientFrom($this->Get('test_recipient'));
         $oEmail->SetReferences($sReference);
         $oEmail->SetMessageId($sMessageId);
     } else {
         $oEmail->SetSubject($sSubject);
         $oEmail->SetBody($sBody);
         $oEmail->SetRecipientTO($sTo);
         $oEmail->SetRecipientCC($sCC);
         $oEmail->SetRecipientBCC($sBCC);
         $oEmail->SetRecipientFrom($sFrom);
         $oEmail->SetRecipientReplyTo($sReplyTo);
         $oEmail->SetReferences($sReference);
         $oEmail->SetMessageId($sMessageId);
     }
     if (isset($aContextArgs['attachments'])) {
         $aAttachmentReport = array();
         foreach ($aContextArgs['attachments'] as $oDocument) {
             $oEmail->AddAttachment($oDocument->GetData(), $oDocument->GetFileName(), $oDocument->GetMimeType());
             $aAttachmentReport[] = array($oDocument->GetFileName(), $oDocument->GetMimeType(), strlen($oDocument->GetData()));
         }
         $oLog->Set('attachments', $aAttachmentReport);
     }
     if (empty($this->m_aMailErrors)) {
         if ($this->m_iRecipients == 0) {
             return 'No recipient';
         } else {
             $iRes = $oEmail->Send($aErrors, false, $oLog);
             // allow asynchronous mode
             switch ($iRes) {
                 case EMAIL_SEND_OK:
                     return "Sent";
                 case EMAIL_SEND_PENDING:
                     return "Pending";
//.........这里部分代码省略.........
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:101,代码来源:action.class.inc.php


注:本文中的MetaModel::ApplyParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。