Returns the text displayed in the widget

@param ModelHistory $history one ModelHistory entity
@return string
430722
public function historyText(ModelHistory $history): string
    {
        $action = '';
        switch ($history->action) {
            case ModelHistory::ACTION_CREATE:
                $action = __d('model_history', 'created');
                break;
            case ModelHistory::ACTION_UPDATE:
                $action = __d('model_history', 'updated');
                break;
            case ModelHistory::ACTION_DELETE:
                $action = __d('model_history', 'deleted');
                break;
            case ModelHistory::ACTION_COMMENT:
                $action = __d('model_history', 'commented');
                break;
            default:
        }
        if (empty($history->user_id)) {
            $username = 'Anonymous';
        } else {
            $userNameFields = TableRegistry::get($history->model)->getUserNameFields(true);
            $firstname = $history->user->{$userNameFields['firstname']};
            $lastname = $history->user->{$userNameFields['lastname']};
            $username = $firstname . ' ' . $lastname;
        }

        return ucfirst($action) . ' ' . __d('model_history', 'by') . ' ' . $username;
    }
1285365
public function getHistorySummary() {

		$history = $this->History();
		$query = new SQLSelect(
			"Term, COUNT(*) AS Frequency, ((COUNT(*) * 100.00) / {$history->count()}) AS FrequencyPercentage, AVG(Time) AS AverageTimeTaken, (Results > 0) AS Results",
			'ExtensibleSearch',
			"ExtensibleSearchPageID = {$this->ID}",
			array(
				'Frequency' => 'DESC',
				'Term' => 'ASC'
			),
			array(
				'Term',
				'Results'
			)
		);

		// These will require display formatting.

		$analytics = ArrayList::create();
		foreach($query->execute() as $result) {
			$result = ArrayData::create(
				$result
			);
			$result->FrequencyPercentage = sprintf('%.2f %%', $result->FrequencyPercentage);
			$result->AverageTimeTaken = sprintf('%.5f', $result->AverageTimeTaken);
			$result->Results = $result->Results ? _t('EXTENSIBLE_SEARCH.TRUE', 'true') : _t('EXTENSIBLE_SEARCH.FALSE', 'false');
			$analytics->push($result);
		}
		return $analytics;
	}
279737
function getHistory(context) {
  if (!historyMap.has(context)) {
    clear(context);
  }
  return historyMap.get(context);
}
370379
public function col_feedback(\stdClass $history) {
        if ($this->is_downloading()) {
            return $history->feedback;
        } else {
            // We need the activity context, not the course context.
            $gradeitem = $this->gradeitems[$history->itemid];
            $context = $gradeitem->get_context();

            $feedback = file_rewrite_pluginfile_urls(
                $history->feedback,
                'pluginfile.php',
                $context->id,
                GRADE_FILE_COMPONENT,
                GRADE_HISTORY_FEEDBACK_FILEAREA,
                $history->id
            );

            return format_text($feedback, $history->feedbackformat, array('context' => $context));
        }
    }
1131393
public function history($id)
    {
        $blog = $this->repository->find($id);

        return view('cms::modules.blogs.history')
            ->with('blog', $blog);
    }
801915
public function col_grader(\stdClass $history) {
        if (empty($history->usermodified)) {
            // Not every row has a valid usermodified.
            return '';
        }

        $grader = new \stdClass();
        $grader = username_load_fields_from_object($grader, $history, 'grader');
        $name = fullname($grader);

        if ($this->download) {
            return $name;
        }

        $userid = $history->usermodified;
        $profileurl = new \moodle_url('/user/view.php', array('id' => $userid, 'course' => $this->courseid));

        return \html_writer::link($profileurl, $name);
    }
1229215
public function render_assign_attempt_history(assign_attempt_history $history) {
        $o = '';

        $submittedstr = get_string('submitted', 'assign');
        $gradestr = get_string('grade');
        $gradedonstr = get_string('gradedon', 'assign');
        $gradedbystr = get_string('gradedby', 'assign');

        // Don't show the last one because it is the current submission.
        array_pop($history->submissions);

        // Show newest to oldest.
        $history->submissions = array_reverse($history->submissions);

        if (empty($history->submissions)) {
            return '';
        }

        $containerid = 'attempthistory' . uniqid();
        $o .= $this->output->heading(get_string('attempthistory', 'assign'), 3);
        $o .= $this->box_start('attempthistory', $containerid);

        foreach ($history->submissions as $i => $submission) {
            $grade = null;
            foreach ($history->grades as $onegrade) {
                if ($onegrade->attemptnumber == $submission->attemptnumber) {
                    if ($onegrade->grade != ASSIGN_GRADE_NOT_SET) {
                        $grade = $onegrade;
                    }
                    break;
                }
            }

            $editbtn = '';

            if ($submission) {
                $submissionsummary = userdate($submission->timemodified);
            } else {
                $submissionsummary = get_string('nosubmission', 'assign');
            }

            $attemptsummaryparams = array('attemptnumber'=>$submission->attemptnumber+1,
                                          'submissionsummary'=>$submissionsummary);
            $o .= $this->heading(get_string('attemptheading', 'assign', $attemptsummaryparams), 4);

            $t = new html_table();

            if ($submission) {
                $cell1 = new html_table_cell(get_string('submissionstatus', 'assign'));
                $cell2 = new html_table_cell(get_string('submissionstatus_' . $submission->status, 'assign'));
                $t->data[] = new html_table_row(array($cell1, $cell2));

                foreach ($history->submissionplugins as $plugin) {
                    $pluginshowsummary = !$plugin->is_empty($submission) || !$plugin->allow_submissions();
                    if ($plugin->is_enabled() &&
                            $plugin->is_visible() &&
                            $plugin->has_user_summary() &&
                            $pluginshowsummary) {

                        $cell1 = new html_table_cell($plugin->get_name());
                        $pluginsubmission = new assign_submission_plugin_submission($plugin,
                                                                                    $submission,
                                                                                    assign_submission_plugin_submission::SUMMARY,
                                                                                    $history->coursemoduleid,
                                                                                    $history->returnaction,
                                                                                    $history->returnparams);
                        $cell2 = new html_table_cell($this->render($pluginsubmission));

                        $t->data[] = new html_table_row(array($cell1, $cell2));
                    }
                }
            }

            if ($grade) {
                // Heading 'feedback'.
                $title = get_string('feedback', 'assign', $i);
                $title .= $this->output->spacer(array('width'=>10));
                if ($history->cangrade) {
                    // Edit previous feedback.
                    $returnparams = http_build_query($history->returnparams);
                    $urlparams = array('id' => $history->coursemoduleid,
                                   'rownum'=>$history->rownum,
                                   'useridlistid'=>$history->useridlistid,
                                   'attemptnumber'=>$grade->attemptnumber,
                                   'action'=>'grade',
                                   'returnaction'=>$history->returnaction,
                                   'returnparams'=>$returnparams);
                    $url = new moodle_url('/mod/assign/view.php', $urlparams);
                    $icon = new pix_icon('gradefeedback',
                                            get_string('editattemptfeedback', 'assign', $grade->attemptnumber+1),
                                            'mod_assign');
                    $title .= $this->output->action_icon($url, $icon);
                }
                $cell = new html_table_cell($title);
                $cell->attributes['class'] = 'feedbacktitle';
                $cell->colspan = 2;
                $t->data[] = new html_table_row(array($cell));

                // Grade.
                $cell1 = new html_table_cell($gradestr);
                $cell2 = $grade->gradefordisplay;
                $t->data[] = new html_table_row(array($cell1, $cell2));

                // Graded on.
                $cell1 = new html_table_cell($gradedonstr);
                $cell2 = new html_table_cell(userdate($grade->timemodified));
                $t->data[] = new html_table_row(array($cell1, $cell2));

                // Graded by set to a real user. Not set can be empty or -1.
                if (!empty($grade->grader) && is_object($grade->grader)) {
                    $cell1 = new html_table_cell($gradedbystr);
                    $cell2 = new html_table_cell($this->output->user_picture($grade->grader) .
                                                 $this->output->spacer(array('width' => 30)) . fullname($grade->grader));
                    $t->data[] = new html_table_row(array($cell1, $cell2));
                }

                // Feedback from plugins.
                foreach ($history->feedbackplugins as $plugin) {
                    if ($plugin->is_enabled() &&
                        $plugin->is_visible() &&
                        $plugin->has_user_summary() &&
                        !$plugin->is_empty($grade)) {

                        $cell1 = new html_table_cell($plugin->get_name());
                        $pluginfeedback = new assign_feedback_plugin_feedback(
                            $plugin, $grade, assign_feedback_plugin_feedback::SUMMARY, $history->coursemoduleid,
                            $history->returnaction, $history->returnparams
                        );
                        $cell2 = new html_table_cell($this->render($pluginfeedback));
                        $t->data[] = new html_table_row(array($cell1, $cell2));
                    }

                }

            }

            $o .= html_writer::table($t);
        }
        $o .= $this->box_end();
        $jsparams = array($containerid);

        $this->page->requires->yui_module('moodle-mod_assign-history', 'Y.one("#' . $containerid . '").history');

        return $o;
    }
131952
public function securityHistory()
    {
        $history = $this->wrappedObject->security()->get();

        $history->each(function ($item) {
            $item->security = true;
        });

        return $this->presenter->decorate($history);
    }
557854
public function saveHistory(History $history, Invoice $invoice)
    {
        return $this->connector->save($history, $invoice);
    }
1186055
public function buildDiff(ModelHistory $historyEntry): array
    {
        if ($historyEntry->revision == 1) {
            return [];
        }

        $previousRevisions = $this->find()
            ->where([
                'model' => $historyEntry->model,
                'foreign_key' => $historyEntry->foreign_key,
                'revision <' => $historyEntry->revision
            ])
            ->order(['revision' => 'DESC'])
            ->toArray();

        $entity = $this->getEntityWithHistory($historyEntry->model, $historyEntry->foreign_key);

        $diffOutput = [
            'changed' => [],
            'changedBefore' => [],
            'unchanged' => []
        ];

        $fieldConfig = TableRegistry::get($historyEntry->model)->getFields();
        $transformers = [];

        // 1. Get old values for changed fields in passed entry, ignore arrays
        foreach ($historyEntry->data as $fieldName => $newValue) {
            foreach ($previousRevisions as $revision) {
                if (isset($revision->data[$fieldName])) {
                    if (!isset($fieldConfig[$fieldName])) {
                        continue 2;
                    }
                    if (isset($fieldConfig[$fieldName]['displayParser']) && is_callable($fieldConfig[$fieldName]['displayParser'])) {
                        $callback = $fieldConfig[$fieldName]['displayParser'];
                        $diffOutput['changed'][$fieldName] = [
                            'old' => $callback($fieldName, $revision->data[$fieldName], $entity),
                            'new' => $callback($fieldName, $newValue, $entity)
                        ];
                        continue 2;
                    }
                    $type = $fieldConfig[$fieldName]['type'];

                    if (!isset($transformers[$type])) {
                        $transformers[$type] = Transform::get($type);
                    }

                    $diffOutput['changed'][$fieldName] = [
                        'old' => $transformers[$type]->display($fieldName, $revision->data[$fieldName], $historyEntry->model),
                        'new' => $transformers[$type]->display($fieldName, $newValue, $historyEntry->model)
                    ];
                    continue 2;
                }
            }
        }

        $currentEntity = TableRegistry::get($historyEntry->model)->get($historyEntry->foreign_key);

        // 2. Try to get old values for any other fields defined in searchableFields and
        foreach ($fieldConfig as $fieldName => $data) {
            foreach ($previousRevisions as $revisionIndex => $revision) {
                if (!isset($revision->data[$fieldName])) {
                    continue;
                }
                if (isset($diffOutput['changed'][$fieldName])) {
                    continue 2;
                }
                if ($revision->data[$fieldName] != $currentEntity->{$fieldName}) {
                    if (isset($data['displayParser']) && is_callable($data['displayParser'])) {
                        $callback = $data['displayParser'];
                        $diffOutput['changedBefore'][$fieldName] = [
                            'old' => $callback($fieldName, $revision->data[$fieldName], $entity),
                            'new' => $callback($fieldName, $currentEntity->{$fieldName}, $entity)
                        ];
                        continue 2;
                    }

                    $type = $data['type'];

                    if (!isset($transformers[$type])) {
                        $transformers[$type] = Transform::get($type);
                    }

                    $diffOutput['changedBefore'][$fieldName] = [
                        'old' => $transformers[$type]->display($fieldName, $revision->data[$fieldName], $historyEntry->model),
                        'new' => $transformers[$type]->display($fieldName, $currentEntity->{$fieldName}, $historyEntry->model)
                    ];
                    continue 2;
                }
            }
        }

        // 3. Get all unchanged fields
        foreach ($fieldConfig as $fieldName => $data) {
            foreach ($previousRevisions as $revision) {
                if (!isset($revision->data[$fieldName])) {
                    continue;
                }
                if (isset($diffOutput['changed'][$fieldName]) || isset($diffOutput['changedBefore'][$fieldName])) {
                    continue 2;
                }

                if (isset($data['displayParser']) && is_callable($data['displayParser'])) {
                    $callback = $data['displayParser'];
                    $diffOutput['unchanged'][$fieldName] = $callback($fieldName, $currentEntity->{$fieldName}, $entity);
                    continue 2;
                }

                $type = $data['type'];

                if (!isset($transformers[$type])) {
                    $transformers[$type] = Transform::get($type);
                }

                $diffOutput['unchanged'][$fieldName] = $transformers[$type]->display($fieldName, $currentEntity->{$fieldName}, $historyEntry->model);
                continue 2;
            }
        }

        // Translate all the fieldnames
        foreach ($diffOutput as $type => $dataArr) {
            if (!empty($dataArr)) {
                foreach ($dataArr as $fieldName => $values) {
                    $localizedField = $this->_translateFieldname($fieldName, $historyEntry->model);
                    if ($localizedField != $fieldName) {
                        $dataArr[$localizedField] = $values;
                        unset($dataArr[$fieldName]);
                    }
                }
                $diffOutput[$type] = $dataArr;
            }
        }

        return $diffOutput;
    }
974736
public function DeployHistory() {
		$history = $this
			->Deployments()
			->sort('LastEdited DESC');
		$repo = $this->Project()->getRepository();
		if(!$repo) {
			return $history;
		}

		$ammendedHistory = new ArrayList();
		foreach($history as $deploy) {
			if(!$deploy->SHA) {
				continue;
			}
			try {
				$commit = $repo->getCommit($deploy->SHA);
				if($commit) {
					$deploy->Message = Convert::raw2xml($commit->getMessage());
				}
				// We can't find this SHA, so we ignore adding a commit message to the deployment
			} catch (Exception $ex) { }
			$ammendedHistory->push($deploy);
		}

		return $ammendedHistory;
	}
336331
public function getHistory()
    {
        $history = array(
            1 => new MaintenanceState(json_decode($this->getDriver()->get(self::PREFIX . self::LAST_MODE), true))
        );

        $i = 2;
        while ($data = json_decode($this->getDriver()->get(self::PREFIX . $i), true)) {
            $history[$i] = new MaintenanceState($data);
            $i++;
        }
        return $history;
    }
525114
protected void setHistoryEnabled (boolean historyEnabled)
    {
        if (historyEnabled && _historyModel == null) {
            _historyModel = _scrollbar.getModel();
            _historyModel.addChangeListener(this);
            resetHistoryOffset();

            // out with the subtitles, we'll be displaying history
            clearGlyphs(_subtitles);

            // "scroll" down to the latest history entry
            updateHistBar(_history.size() - 1);

            // refigure our history
            figureCurrentHistory();

        } else if (!historyEnabled && _historyModel != null) {
            _historyModel.removeChangeListener(this);
            _historyModel = null;

            // out with the history, we'll be displaying subtitles
            clearGlyphs(_showingHistory);
        }
    }
877755
public function messageHistory($date) {
        try{
            if(empty($date))
                throw new Exception('时间不能为空');
            $ret = $this->curl('/message/history', array('date' => $date));
            if(empty($ret))
                throw new Exception('请求失败');
            return $ret;
        }catch (Exception $e) {
            print_r($e->getMessage());
        }
    }
963003
public function getHistoryArticles()
    {
        if ($aArticlesIds = $this->getSession()->getVariable('aHistoryArticles')) {
            return $aArticlesIds;
        } elseif ($sArticlesIds = \OxidEsales\Eshop\Core\Registry::getUtilsServer()->getOxCookie('aHistoryArticles')) {
            return explode('|', $sArticlesIds);
        }
    }
155502
public function getHistory()
    {
        $dqb = $this->_em->createQueryBuilder();
        $dqb->select(array('j'))
            ->from('PlaygroundCore\Entity\Cronjob', 'j')
            ->where($dqb->expr()->in('j.status', array(
                self::STATUS_SUCCESS, self::STATUS_MISSED, self::STATUS_ERROR,
            )))
            ->orderBy('j.scheduleTime', 'ASC');

        return $dqb->getQuery()->getResult();
    }
1168302
public static function history(History $history)
    {
        return function (callable $handler) use ($history) {
            return function (
                CommandInterface $command,
                RequestInterface $request = null
            ) use ($handler, $history) {
                $ticket = $history->start($command, $request);
                return $handler($command, $request)
                    ->then(
                        function ($result) use ($history, $ticket) {
                            $history->finish($ticket, $result);
                            return $result;
                        },
                        function ($reason) use ($history, $ticket) {
                            $history->finish($ticket, $reason);
                            return Promise\rejection_for($reason);
                        }
                    );
            };
        };
    }