本文整理汇总了PHP中Versions::compare方法的典型用法代码示例。如果您正苦于以下问题:PHP Versions::compare方法的具体用法?PHP Versions::compare怎么用?PHP Versions::compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Versions
的用法示例。
在下文中一共展示了Versions::compare方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: source
/**
* Load the source editor
*
* @return string
*/
public function source()
{
$this->isValid($this->intId);
if (is_dir(TL_ROOT . '/' . $this->intId)) {
$this->log('Folder "' . $this->intId . '" cannot be edited', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
} elseif (!file_exists(TL_ROOT . '/' . $this->intId)) {
$this->log('File "' . $this->intId . '" does not exist', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
$this->import('BackendUser', 'User');
// Check user permission
if (!$this->User->hasAccess('f5', 'fop')) {
$this->log('Not enough permissions to edit the file source of file "' . $this->intId . '"', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
$objFile = new \File($this->intId, true);
// Check whether file type is editable
if (!in_array($objFile->extension, trimsplit(',', strtolower(\Config::get('editableFiles'))))) {
$this->log('File type "' . $objFile->extension . '" (' . $this->intId . ') is not allowed to be edited', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
$objMeta = null;
$objVersions = null;
// Add the versioning routines
if ($this->blnIsDbAssisted && \Dbafs::shouldBeSynchronized($this->intId)) {
$objMeta = \FilesModel::findByPath($objFile->value);
if ($objMeta === null) {
$objMeta = \Dbafs::addResource($objFile->value);
}
$objVersions = new \Versions($this->strTable, $objMeta->id);
if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['hideVersionMenu']) {
// Compare versions
if (\Input::get('versions')) {
$objVersions->compare();
}
// Restore a version
if (\Input::post('FORM_SUBMIT') == 'tl_version' && \Input::post('version') != '') {
$objVersions->restore(\Input::post('version'));
// Purge the script cache (see #7005)
if ($objFile->extension == 'css' || $objFile->extension == 'scss' || $objFile->extension == 'less') {
$this->import('Automator');
$this->Automator->purgeScriptCache();
}
$this->reload();
}
}
$objVersions->initialize();
}
$strContent = $objFile->getContent();
if ($objFile->extension == 'svgz') {
$strContent = gzdecode($strContent);
}
// Process the request
if (\Input::post('FORM_SUBMIT') == 'tl_files') {
// Restore the basic entities (see #7170)
$strSource = \StringUtil::restoreBasicEntities(\Input::postRaw('source'));
// Save the file
if (md5($strContent) != md5($strSource)) {
if ($objFile->extension == 'svgz') {
$strSource = gzencode($strSource);
}
// Write the file
$objFile->write($strSource);
$objFile->close();
// Update the database
if ($this->blnIsDbAssisted && $objMeta !== null) {
/** @var \FilesModel $objMeta */
$objMeta->hash = $objFile->hash;
$objMeta->save();
$objVersions->create();
}
// Purge the script cache (see #7005)
if ($objFile->extension == 'css' || $objFile->extension == 'scss' || $objFile->extension == 'less') {
$this->import('Automator');
$this->Automator->purgeScriptCache();
}
}
if (\Input::post('saveNclose')) {
\System::setCookie('BE_PAGE_OFFSET', 0, 0);
$this->redirect($this->getReferer());
}
$this->reload();
}
$codeEditor = '';
// Prepare the code editor
if (\Config::get('useCE')) {
$selector = 'ctrl_source';
$type = $objFile->extension;
// Load the code editor configuration
ob_start();
include TL_ROOT . '/system/config/ace.php';
$codeEditor = ob_get_contents();
ob_end_clean();
unset($selector, $type);
//.........这里部分代码省略.........
示例2: edit
/**
* Auto-generate a form to edit the current database record
*
* @param integer $intId
* @param integer $ajaxId
*
* @return string
*/
public function edit($intId = null, $ajaxId = null)
{
if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notEditable']) {
$this->log('Table "' . $this->strTable . '" is not editable', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
if ($intId != '') {
$this->intId = $intId;
}
// Get the current record
$objRow = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE id=?")->limit(1)->execute($this->intId);
// Redirect if there is no record with the given ID
if ($objRow->numRows < 1) {
$this->log('Could not load record "' . $this->strTable . '.id=' . $this->intId . '"', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
$this->objActiveRecord = $objRow;
$return = '';
$this->values[] = $this->intId;
$this->procedure[] = 'id=?';
$this->blnCreateNewVersion = false;
$objVersions = new \Versions($this->strTable, $this->intId);
if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['hideVersionMenu']) {
// Compare versions
if (\Input::get('versions')) {
$objVersions->compare();
}
// Restore a version
if (\Input::post('FORM_SUBMIT') == 'tl_version' && \Input::post('version') != '') {
$objVersions->restore(\Input::post('version'));
$this->reload();
}
}
$objVersions->initialize();
// Build an array from boxes and rows
$this->strPalette = $this->getPalette();
$boxes = trimsplit(';', $this->strPalette);
$legends = array();
if (!empty($boxes)) {
foreach ($boxes as $k => $v) {
$eCount = 1;
$boxes[$k] = trimsplit(',', $v);
foreach ($boxes[$k] as $kk => $vv) {
if (preg_match('/^\\[.*\\]$/', $vv)) {
++$eCount;
continue;
}
if (preg_match('/^\\{.*\\}$/', $vv)) {
$legends[$k] = substr($vv, 1, -1);
unset($boxes[$k][$kk]);
} elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$vv]['exclude'] || !is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$vv])) {
unset($boxes[$k][$kk]);
}
}
// Unset a box if it does not contain any fields
if (count($boxes[$k]) < $eCount) {
unset($boxes[$k]);
}
}
$class = 'tl_tbox';
$fs = $this->Session->get('fieldset_states');
$blnIsFirst = true;
// Render boxes
foreach ($boxes as $k => $v) {
$strAjax = '';
$blnAjax = false;
$key = '';
$cls = '';
$legend = '';
if (isset($legends[$k])) {
list($key, $cls) = explode(':', $legends[$k]);
$legend = "\n" . '<legend onclick="AjaxRequest.toggleFieldset(this,\'' . $key . '\',\'' . $this->strTable . '\')">' . (isset($GLOBALS['TL_LANG'][$this->strTable][$key]) ? $GLOBALS['TL_LANG'][$this->strTable][$key] : $key) . '</legend>';
}
if (isset($fs[$this->strTable][$key])) {
$class .= $fs[$this->strTable][$key] ? '' : ' collapsed';
} else {
$class .= $cls && $legend ? ' ' . $cls : '';
}
$return .= "\n\n" . '<fieldset' . ($key ? ' id="pal_' . $key . '"' : '') . ' class="' . $class . ($legend ? '' : ' nolegend') . '">' . $legend;
// Build rows of the current box
foreach ($v as $vv) {
if ($vv == '[EOF]') {
if ($blnAjax && \Environment::get('isAjaxRequest')) {
return $strAjax . '<input type="hidden" name="FORM_FIELDS[]" value="' . specialchars($this->strPalette) . '">';
}
$blnAjax = false;
$return .= "\n" . '</div>';
continue;
}
if (preg_match('/^\\[.*\\]$/', $vv)) {
$thisId = 'sub_' . substr($vv, 1, -1);
$blnAjax = $ajaxId == $thisId && \Environment::get('isAjaxRequest') ? true : false;
//.........这里部分代码省略.........
示例3: edit
/**
* Auto-generate a form to edit the current database record
* @param integer
* @param integer
* @return string
*/
public function edit($intID = false, $ajaxId = false)
{
if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notEditable']) {
\System::log('Table ' . $this->strTable . ' is not editable', __METHOD__, TL_ERROR);
\Controller::redirect('contao/main.php?act=error');
}
if ($intID) {
$this->intId = $intID;
}
// Get the current record
$objRow = \Database::getInstance()->prepare("SELECT * FROM {$this->strTable} WHERE id=?")->limit(1)->execute($this->intId);
// Redirect if there is no record with the given ID
if ($objRow->numRows < 1) {
\System::log('Could not load record "' . $this->strTable . '.id=' . $this->intId . '"', __METHOD__, TL_ERROR);
\Controller::redirect('contao/main.php?act=error');
} elseif ($objRow->language != '') {
\System::log('Cannot edit language record "' . $this->strTable . '.id=' . $this->intId . '"', __METHOD__, TL_ERROR);
\Controller::redirect('contao/main.php?act=error');
}
$this->objActiveRecord = $objRow;
$return = '';
$this->values[] = $this->intId;
$this->procedure[] = 'id=?';
$this->blnCreateNewVersion = false;
$objVersions = new \Versions($this->strTable, $this->intId);
// Compare versions
if (\Input::get('versions')) {
$objVersions->compare();
}
// Restore a version
if (\Input::post('FORM_SUBMIT') == 'tl_version' && \Input::post('version') != '') {
$objVersions->restore(\Input::post('version'));
$this->reload();
}
$objVersions->initialize();
// Load and/or change language
$this->blnEditLanguage = false;
if (!empty($this->arrTranslations)) {
$blnLanguageUpdated = false;
$session = $this->Session->getData();
if (\Input::post('FORM_SUBMIT') == 'tl_language') {
if (in_array(\Input::post('language'), $this->arrTranslations)) {
$session['language'][$this->strTable][$this->intId] = \Input::post('language');
} else {
unset($session['language'][$this->strTable][$this->intId]);
}
$blnLanguageUpdated = true;
} elseif (\Input::post('FORM_SUBMIT') == $this->strTable && isset($_POST['deleteLanguage'])) {
$this->Database->prepare("DELETE FROM {$this->strTable} WHERE pid=? AND language=?")->execute($this->intId, $session['language'][$this->strTable][$this->intId]);
unset($session['language'][$this->strTable][$this->intId]);
$blnLanguageUpdated = true;
}
if ($blnLanguageUpdated) {
$this->Session->setData($session);
$_SESSION['TL_INFO'] = '';
\Controller::reload();
}
if ($_SESSION['BE_DATA']['language'][$this->strTable][$this->intId] != '' && in_array($_SESSION['BE_DATA']['language'][$this->strTable][$this->intId], $this->arrTranslations)) {
$objRow = $this->Database->prepare("SELECT * FROM {$this->strTable} WHERE pid=? AND language=?")->execute($this->intId, $_SESSION['BE_DATA']['language'][$this->strTable][$this->intId]);
if (!$objRow->numRows) {
$intId = $this->Database->prepare("INSERT INTO {$this->strTable} (pid,tstamp,language) VALUES (?,?,?)")->execute($this->intId, time(), $_SESSION['BE_DATA']['language'][$this->strTable][$this->intId])->insertId;
$objRow = $this->Database->prepare("SELECT * FROM {$this->strTable} WHERE id=?")->execute($intId);
}
$this->objActiveRecord = $objRow;
$this->values = array($this->intId, $_SESSION['BE_DATA']['language'][$this->strTable][$this->intId]);
$this->procedure = array('pid=?', 'language=?');
$this->blnEditLanguage = true;
}
}
// Build an array from boxes and rows
$this->strPalette = $this->getPalette();
$boxes = trimsplit(';', $this->strPalette);
$legends = array();
if (!empty($boxes)) {
foreach ($boxes as $k => $v) {
$eCount = 1;
$boxes[$k] = trimsplit(',', $v);
foreach ($boxes[$k] as $kk => $vv) {
if (preg_match('/^\\[.*\\]$/i', $vv)) {
++$eCount;
continue;
}
if (preg_match('/^\\{.*\\}$/', $vv)) {
$legends[$k] = substr($vv, 1, -1);
unset($boxes[$k][$kk]);
} elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$vv]['exclude'] || !is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$vv])) {
unset($boxes[$k][$kk]);
} elseif ($this->blnEditLanguage && !$GLOBALS['TL_DCA'][$this->strTable]['fields'][$vv]['attributes']['multilingual']) {
unset($boxes[$k][$kk]);
}
}
// Unset a box if it does not contain any fields
if (count($boxes[$k]) < $eCount) {
unset($boxes[$k]);
//.........这里部分代码省略.........