本文整理匯總了PHP中FileModel::hasAttachment方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileModel::hasAttachment方法的具體用法?PHP FileModel::hasAttachment怎麽用?PHP FileModel::hasAttachment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FileModel
的用法示例。
在下文中一共展示了FileModel::hasAttachment方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: compare
/**
* Returns comparison information based on criteria arguments. Virtual questions always return an empty array.
*
* @param array See argument array below
* @return array Following this structure:
* array($criteria_term => array(array('question' => QuestionModel,
* 'messages' => array(string)
* )
* )
* )
*/
public function compare($args = array())
{
// Comparison criteria
$args = array_merge(array('model_fail' => true, 'model_pass' => false, 'additional_information' => false), $args);
if ($this->question->virtualQuestion) {
return array();
}
if ($this->compareInstance->depth !== 'response') {
throw new Exception('Comparison not possible since compare instance depth not set to response');
}
if ($this->depth !== 'response') {
throw new Exception('Comparison not possible since depth not set to response');
}
$modelPageRows = self::$pageTable->fetchRows('pageID', $this->question->pageID, null, $this->question->instanceID);
$modelPageRow = $modelPageRows[0];
$pageGUID = $modelPageRow->pageGUID;
$comparePageRows = self::$pageTable->fetchRows('pageGUID', $pageGUID, null, $this->compareInstance->instanceID);
$comparePageRow = $comparePageRows[0];
$compareQuestionRows = self::$questionTable->fetchRows('questionGUID', $this->question->questionGUID, null, $comparePageRow->pageID);
$compareQuestionRow = $compareQuestionRows[0];
$compareQuestion = new QuestionModel(array('questionID' => $compareQuestionRow->questionID, 'depth' => 'response'));
$response = $compareQuestion->getResponse();
$result = array();
foreach ($args as $key => $value) {
$result[$key] = array();
}
if ($args['model_fail'] || $args['model_pass']) {
$messages = array();
$remediationInfo = '';
$pass = null;
while ($modelResponse = $this->nextModelResponse()) {
switch ($modelResponse->type) {
case "no preference":
break;
case "match":
if ($modelResponse->target == $response->responseText) {
$messages['pass'][] = "Matches " . $modelResponse->target;
$pass = true;
} else {
$messages['fail'][] = "Does not match " . $modelResponse->target;
$pass = false;
break;
}
break;
case "selected":
if ($modelResponse->promptText() == $response->promptText()) {
$messages['pass'][] = "Prompt selected: " . $modelResponse->promptText();
$pass = true;
} else {
$messages['fail'][] = "Prompt not selected: " . $modelResponse->promptText();
$pass = false;
break;
}
break;
case "not selected":
if ($modelResponse->promptText() == $response->promptText()) {
$messages['fail'][] = "Prompt selected: " . $modelResponse->promptText();
$pass = false;
break;
} else {
$messages['pass'][] = "Prompt not selected: " . $modelResponse->promptText();
$pass = true;
}
break;
case "or selected":
if ($modelResponse->promptText() == $response->promptText()) {
$messages['pass'][] = "Or prompt selected: " . $modelResponse->promptText();
$pass = true;
} else {
if ($pass !== TRUE) {
$messages['fail'][] = "And prompt not selected: " . $modelResponse->promptText();
$pass = false;
}
}
break;
case "remediation info":
$remediationInfo = $modelResponse->info;
break;
case "require attachment":
$file = new FileModel($compareQuestion);
if ($file->hasAttachment()) {
$pass = true;
$messages['pass'][] = 'Has attachment';
} else {
$pass = false;
$messages['fail'][] = 'No attachment';
}
break;
default:
//.........這裏部分代碼省略.........