本文整理汇总了PHP中Message::addConfirmation方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::addConfirmation方法的具体用法?PHP Message::addConfirmation怎么用?PHP Message::addConfirmation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::addConfirmation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Generate module
*/
protected function compile()
{
// Create files
if (\Input::post('FORM_SUBMIT') == 'tl_newsport') {
$objModel = NewsportConfigModel::findByPk($this->objDc->id);
if ($objModel === null) {
return;
}
$importer = new NewsImporter($objModel);
if ($importer->run()) {
// Confirm and reload
\Message::addConfirmation($GLOBALS['TL_LANG']['tl_newsport_config']['confirm']);
$this->reload();
}
}
$this->Template->base = \Environment::get('base');
$this->Template->href = $this->getReferer(true);
$this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']);
$this->Template->action = ampersand(\Environment::get('request'));
$this->Template->selectAll = $GLOBALS['TL_LANG']['MSC']['selectAll'];
$this->Template->button = $GLOBALS['TL_LANG']['MSC']['backBT'];
$this->Template->message = \Message::generate();
$this->Template->submit = specialchars($GLOBALS['TL_LANG']['tl_newsport_config']['import'][0]);
$this->Template->headline = sprintf($GLOBALS['TL_LANG']['tl_newsport_config']['headline'], \Input::get('id'));
$this->Template->explain = $GLOBALS['TL_LANG']['tl_newsport_config']['make'][1];
$this->Template->label = $GLOBALS['TL_LANG']['tl_newsport_config']['label'];
}
示例2: generateSprite
/**
* Generate sprite from given data
*/
public function generateSprite(\DataContainer $row)
{
// Get the theme meta data
$objTheme = $this->Database->prepare("SELECT * FROM tl_theme WHERE id=?")->execute($row->id);
if ($objTheme->numRows < 1) {
return;
}
if ($objTheme->spritegen_enable != false) {
// Replace the numeric folder IDs
$objInputFolder = FilesModel::findByPk($objTheme->spritegen_source);
$objOutputFolder = FilesModel::findByPk($objTheme->spritegen_output_folder);
if ($objInputFolder !== null) {
// Provide settings for SpriteGen()
$cssSprites = new \SpriteGen();
$cssSprites->addImageFolder(TL_ROOT . '/' . $objInputFolder->path);
$cssSprites->setOutputFolder(TL_ROOT . '/' . $objOutputFolder->path);
$cssSprites->setCacheTime(0);
$cssSprites->useDatabase($objTheme->spritegen_modify_selectors, unserialize($objTheme->spritegen_selectors));
// Generate Sprite
$cssSprites->generateSprite($objTheme->spritegen_output_file, $objTheme->id, true, $objTheme->spritegen_direction, $objTheme->spritegen_output_width);
// Display success confirmation
\Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['spritegen_successful']);
$this->log('Generated image and style sheet for sprite ' . $objTheme->spritegen_output_file, __METHOD__, CRON);
}
}
}
示例3: sendConfirmationNotificationBe
public static function sendConfirmationNotificationBe(\DataContainer $objDc)
{
if (($objSubmission = static::findByPk($objDc->id)) !== null) {
static::sendConfirmationNotification($objSubmission->id);
\Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['confirmationNotificationSent']);
\Controller::redirect(Url::addQueryString('id=' . $objSubmission->pid, Url::removeQueryString(array('key'))));
}
}
示例4: updateRobotsTxt
/**
* Update the robots.txt when the page was stored.
*/
public function updateRobotsTxt(DataContainer $dc)
{
if (Hofff\Contao\RobotsTxtEditor\RobotsTxtEditor::generateRobotsTxts()) {
\Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['robotstxt_updated']);
} else {
\Message::addError($GLOBALS['TL_LANG']['ERR']['robotstxt_not_updated']);
}
}
示例5: run
/**
* Run the controller and parse the password template
*/
public function run()
{
/** @var \BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_password');
if (\Input::post('FORM_SUBMIT') == 'tl_password') {
$pw = \Input::postUnsafeRaw('password');
$cnf = \Input::postUnsafeRaw('confirm');
// The passwords do not match
if ($pw != $cnf) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
} elseif (utf8_strlen($pw) < \Config::get('minPasswordLength')) {
\Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], \Config::get('minPasswordLength')));
} elseif ($pw == $this->User->username) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
} else {
// Make sure the password has been changed
if (\Encryption::verify($pw, $this->User->password)) {
\Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
} else {
$this->loadDataContainer('tl_user');
// Trigger the save_callback
if (is_array($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'])) {
foreach ($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'] as $callback) {
if (is_array($callback)) {
$this->import($callback[0]);
$pw = $this->{$callback[0]}->{$callback[1]}($pw);
} elseif (is_callable($callback)) {
$pw = $callback($pw);
}
}
}
$objUser = \UserModel::findByPk($this->User->id);
$objUser->pwChange = '';
$objUser->password = \Encryption::hash($pw);
$objUser->save();
\Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
$this->redirect('' . $GLOBALS['TL_CONFIG']['backendPath'] . '/main.php');
}
}
$this->reload();
}
$objTemplate->theme = \Backend::getTheme();
$objTemplate->messages = \Message::generate();
$objTemplate->base = \Environment::get('base');
$objTemplate->language = $GLOBALS['TL_LANGUAGE'];
$objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
$objTemplate->charset = \Config::get('characterSet');
$objTemplate->action = ampersand(\Environment::get('request'));
$objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pw_change'];
$objTemplate->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
$objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];
$objTemplate->output();
}
示例6: run
/**
* Run the controller and parse the password template
*/
public function run()
{
$this->Template = new BackendTemplate('be_password');
if (Input::post('FORM_SUBMIT') == 'tl_password') {
$pw = Input::post('password');
$cnf = Input::post('confirm');
// Do not allow special characters
if (preg_match('/[#\\(\\)\\/<=>]/', html_entity_decode(Input::post('password')))) {
Message::addError($GLOBALS['TL_LANG']['ERR']['extnd']);
} elseif ($pw != $cnf) {
Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
} elseif (utf8_strlen($pw) < $GLOBALS['TL_CONFIG']['minPasswordLength']) {
Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], $GLOBALS['TL_CONFIG']['minPasswordLength']));
} elseif ($pw == $this->User->username) {
Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
} else {
list(, $strSalt) = explode(':', $this->User->password);
$strPassword = sha1($strSalt . $pw);
// Make sure the password has been changed
if ($strPassword . ':' . $strSalt == $this->User->password) {
Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
} else {
$strSalt = substr(md5(uniqid(mt_rand(), true)), 0, 23);
$strPassword = sha1($strSalt . $pw);
$objUser = UserModel::findByPk($this->User->id);
$objUser->pwChange = '';
$objUser->password = $strPassword . ':' . $strSalt;
$objUser->save();
Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
$this->redirect('contao/main.php');
}
}
$this->reload();
}
$this->Template->theme = $this->getTheme();
$this->Template->messages = Message::generate();
$this->Template->base = Environment::get('base');
$this->Template->language = $GLOBALS['TL_LANGUAGE'];
$this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
$this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
$this->Template->action = ampersand(Environment::get('request'));
$this->Template->headline = $GLOBALS['TL_LANG']['MSC']['pw_change'];
$this->Template->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
$this->Template->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
$this->Template->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];
$this->Template->output();
}
示例7: run
/**
* Generate the module
*
* @return string
*/
public function run()
{
$template = new \BackendTemplate('be_css_class_replacer_update');
$template->isActive = $this->isActive();
$template->action = ampersand(\Environment::get('request'));
$template->message = \Message::generate();
$template->headline = specialchars($GLOBALS['TL_LANG']['tl_maintenance']['css-class-replacer-headline']);
$template->description = specialchars($GLOBALS['TL_LANG']['tl_maintenance']['css-class-replacer-description']);
$template->submit = specialchars($GLOBALS['TL_LANG']['tl_maintenance']['css-class-replacer-submit']);
if ($this->isActive()) {
$rules = RuleModel::findAll();
$helper = new BackendHelper();
$helper->updateCacheableValues($rules);
\Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_maintenance']['css-class-replacer-message'], $rules->count()));
\Controller::reload();
}
return $template->parse();
}
示例8: checkFileServerConnection
/**
* Check the FTP connection
* @param \DataContainer
*/
public function checkFileServerConnection(\DataContainer $dc)
{
if ($dc->activeRecord->type != 'ftp' || $dc->activeRecord->file_connection != 'ftp') {
return;
}
$strClass = $GLOBALS['NOTIFICATION_CENTER']['FTP'][$dc->activeRecord->ftp_type];
if (!class_exists($strClass)) {
\Message::addError($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_error_class']);
return;
}
$objHandler = new $strClass();
try {
$objHandler->connect($dc->activeRecord);
} catch (\Exception $e) {
\Message::addError(sprintf($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_error_connect'], $e->getMessage()));
return;
}
\Message::addConfirmation($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_confirm']);
}
示例9: run
/**
* Run the controller and parse the password template
*/
public function run()
{
$this->Template = new BackendTemplate('be_password');
if (Input::post('FORM_SUBMIT') == 'tl_password') {
$pw = Input::post('password', true);
$cnf = Input::post('confirm', true);
// The passwords do not match
if ($pw != $cnf) {
Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
} elseif (utf8_strlen($pw) < $GLOBALS['TL_CONFIG']['minPasswordLength']) {
Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], $GLOBALS['TL_CONFIG']['minPasswordLength']));
} elseif ($pw == $this->User->username) {
Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
} else {
// Make sure the password has been changed
if (crypt($pw, $this->User->password) == $this->User->password) {
Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
} else {
$objUser = UserModel::findByPk($this->User->id);
$objUser->pwChange = '';
$objUser->password = Encryption::hash($pw);
$objUser->save();
Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
$this->redirect('contao/main.php');
}
}
$this->reload();
}
$this->Template->theme = $this->getTheme();
$this->Template->messages = Message::generate();
$this->Template->base = Environment::get('base');
$this->Template->language = $GLOBALS['TL_LANGUAGE'];
$this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
$this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
$this->Template->action = ampersand(Environment::get('request'));
$this->Template->headline = $GLOBALS['TL_LANG']['MSC']['pw_change'];
$this->Template->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
$this->Template->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
$this->Template->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];
$this->Template->output();
}
示例10: compile
/**
* Generate module
*/
protected function compile()
{
// Create files
if (\Input::post('FORM_SUBMIT') == 'tl_entity_import') {
$objModel = EntityImportConfigModel::findByPk($this->objDc->id);
if ($objModel === null) {
return;
}
if (class_exists($objModel->importerClass)) {
// use a particular importer (e.g. NewsImporter)
\Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_entity_import_config']['importerInfo'], $objModel->importerClass));
$importer = new $objModel->importerClass($objModel);
} else {
\Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_entity_import_config']['importerInfo'], 'Importer'));
$importer = new Importer($objModel);
}
if ($importer->run(\Input::post('dry-run'))) {
// Confirm and reload
$strMessage = $GLOBALS['TL_LANG']['tl_entity_import_config']['confirm'];
if (\Input::post('dry-run')) {
$strMessage = $GLOBALS['TL_LANG']['tl_entity_import_config']['confirmDry'];
}
\Message::addConfirmation($strMessage);
\Controller::reload();
}
}
$this->Template->base = \Environment::get('base');
$this->Template->href = \Controller::getReferer(true);
$this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']);
$this->Template->action = ampersand(\Environment::get('request'));
$this->Template->selectAll = $GLOBALS['TL_LANG']['MSC']['selectAll'];
$this->Template->button = $GLOBALS['TL_LANG']['MSC']['backBT'];
$this->Template->message = \Message::generate();
$this->Template->submit = specialchars($GLOBALS['TL_LANG']['tl_entity_import_config']['import'][0]);
$this->Template->dryRun = specialchars($GLOBALS['TL_LANG']['tl_entity_import_config']['dryRun'][0]);
$this->Template->headline = sprintf($GLOBALS['TL_LANG']['tl_entity_import_config']['headline'], \Input::get('id'));
$this->Template->explain = $GLOBALS['TL_LANG']['tl_entity_import_config']['make'][1];
$this->Template->label = $GLOBALS['TL_LANG']['tl_entity_import_config']['label'];
}
示例11: newsletterIcon
/**
* Return the "newsletter" button
* @param array
* @param string
* @param string
* @param string
* @param string
* @param string
* @return string
*/
public function newsletterIcon($row, $href, $label, $title, $icon, $attributes)
{
$objArchive = \NewsArchiveModel::findByPk($row['pid']);
if (!$objArchive->newsletter || !$objArchive->newsletter_channel || !$objArchive->nc_notification) {
return '';
}
// Toggle the record
if (Input::get('newsletter')) {
if ($this->sendNewsMessage(Input::get('newsletter'))) {
Message::addConfirmation($GLOBALS['TL_LANG']['tl_news']['message_news_newsletter_confirm']);
} else {
Message::addError($GLOBALS['TL_LANG']['tl_news']['message_news_newsletter_error']);
}
$this->redirect($this->getReferer());
}
// Return just an image if newsletter was sent
if ($row['newsletter']) {
return Image::getHtml(str_replace('.png', '_.png', $icon), $label);
}
// Add the confirmation popup
$intRecipients = \NewsletterRecipientsModel::countBy(array("pid=? AND active=1"), $objArchive->newsletter_channel);
$attributes = 'onclick="if(!confirm(\'' . sprintf($GLOBALS['TL_LANG']['tl_news']['sendNewsletterConfirm'], $intRecipients) . '\'))return false;Backend.getScrollOffset()"';
return '<a href="' . $this->addToUrl($href . '&newsletter=' . $row['id']) . '" title="' . specialchars($title) . '"' . $attributes . '>' . Image::getHtml($icon, $label) . '</a> ';
}
示例12: importStyleSheet
//.........这里部分代码省略.........
$strBuffer = '';
break;
}
}
}
} elseif ($char == '@') {
$intLevel = 0;
$strSelector = '';
while ($i < $intLength) {
$strBuffer .= $strFile[$i++];
if ($strFile[$i] == '{') {
if (++$intLevel == 1) {
++$i;
$strSelector = $strBuffer;
$strBuffer = '';
}
} elseif ($strFile[$i] == '}') {
if (--$intLevel == 0) {
$arrTokens[] = array('type' => 'atblock', 'selector' => $strSelector, 'content' => $strBuffer);
$strBuffer = '';
break;
}
}
}
} else {
$strSelector = '';
while ($i < $intLength) {
$strBuffer .= $strFile[$i++];
if ($strFile[$i] == '{') {
++$i;
$strSelector = $strBuffer;
$strBuffer = '';
} elseif ($strFile[$i] == '}') {
$arrTokens[] = array('type' => 'block', 'selector' => $strSelector, 'content' => $strBuffer);
$strBuffer = '';
break;
}
}
}
}
foreach ($arrTokens as $arrToken) {
// Comments
if ($arrToken['type'] == 'comment') {
// Category (comments start with /** and contain only one line)
if (strncmp($arrToken['content'], '/**', 3) === 0 && substr_count($arrToken['content'], "\n") == 2) {
$strCategory = trim(str_replace(array('/*', '*/', '*'), '', $arrToken['content']));
} elseif (strpos($arrToken['content'], "\n") === false) {
$strComment = trim(str_replace(array('/*', '*/', '*'), '', $arrToken['content']));
}
} elseif ($arrToken['type'] == 'atblock') {
$arrSet = array('pid' => $insertId, 'category' => $strCategory, 'comment' => $strComment, 'sorting' => $intSorting += 128, 'selector' => trim($arrToken['selector']), 'own' => $arrToken['content']);
$this->Database->prepare("INSERT INTO tl_style %s")->set($arrSet)->execute();
$strComment = '';
} else {
$arrDefinition = array('pid' => $insertId, 'category' => $strCategory, 'comment' => $strComment, 'sorting' => $intSorting += 128, 'selector' => trim($arrToken['selector']), 'attributes' => $arrToken['content']);
$this->createDefinition($arrDefinition);
$strComment = '';
}
}
// Write the style sheet
$this->updateStyleSheet($insertId);
// Notify the user
if ($strName . '.css' != basename($strCssFile)) {
\Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_style_sheet']['css_renamed'], basename($strCssFile), $strName . '.css'));
} else {
\Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_style_sheet']['css_imported'], $strName . '.css'));
}
}
// Redirect
\System::setCookie('BE_PAGE_OFFSET', 0, 0);
$this->redirect(str_replace('&key=import', '', \Environment::get('request')));
}
// Return form
return '
<div id="tl_buttons">
<a href="' . ampersand(str_replace('&key=import', '', \Environment::get('request'))) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>
' . \Message::generate() . '
<form action="' . ampersand(\Environment::get('request'), true) . '" id="tl_style_sheet_import" class="tl_form" method="post" enctype="multipart/form-data">
<div class="tl_formbody_edit">
<input type="hidden" name="FORM_SUBMIT" value="tl_style_sheet_import">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">
<input type="hidden" name="MAX_FILE_SIZE" value="' . \Config::get('maxFileSize') . '">
<div class="tl_tbox">
<h3>' . $GLOBALS['TL_LANG']['tl_style_sheet']['source'][0] . '</h3>' . $objUploader->generateMarkup() . (isset($GLOBALS['TL_LANG']['tl_style_sheet']['source'][1]) ? '
<p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['tl_style_sheet']['source'][1] . '</p>' : '') . '
</div>
</div>
<div class="tl_formbody_submit">
<div class="tl_submit_container">
<input type="submit" name="save" id="save" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['tl_style_sheet']['import'][0]) . '">
</div>
</div>
</form>';
}
示例13: addConfirmationMessage
/**
* Add a confirmation message
*
* @param string $strMessage The confirmation
*
* @deprecated Use Message::addConfirmation() instead
*/
protected function addConfirmationMessage($strMessage)
{
\Message::addConfirmation($strMessage);
}
示例14: importFromPath
/**
* Import files from selected folder
*
* @param string $strPath
*/
protected function importFromPath($strPath)
{
$arrFiles = scan(TL_ROOT . '/' . $strPath);
if (empty($arrFiles)) {
\Message::addError($GLOBALS['TL_LANG']['MSC']['noFilesInFolder']);
\Controller::reload();
}
$blnEmpty = true;
$arrDelete = array();
$objProducts = \Database::getInstance()->prepare("SELECT * FROM tl_iso_product WHERE pid=0")->execute();
while ($objProducts->next()) {
$arrImageNames = array();
$arrImages = deserialize($objProducts->images);
if (!is_array($arrImages)) {
$arrImages = array();
} else {
foreach ($arrImages as $row) {
if ($row['src']) {
$arrImageNames[] = $row['src'];
}
}
}
$arrPattern = array();
$arrPattern[] = $objProducts->alias ? standardize($objProducts->alias) : null;
$arrPattern[] = $objProducts->sku ? $objProducts->sku : null;
$arrPattern[] = $objProducts->sku ? standardize($objProducts->sku) : null;
$arrPattern[] = !empty($arrImageNames) ? implode('|', $arrImageNames) : null;
// !HOOK: add custom import regex patterns
if (isset($GLOBALS['ISO_HOOKS']['addAssetImportRegexp']) && is_array($GLOBALS['ISO_HOOKS']['addAssetImportRegexp'])) {
foreach ($GLOBALS['ISO_HOOKS']['addAssetImportRegexp'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$arrPattern = $objCallback->{$callback}[1]($arrPattern, $objProducts);
}
}
$strPattern = '@^(' . implode('|', array_filter($arrPattern)) . ')@i';
$arrMatches = preg_grep($strPattern, $arrFiles);
if (!empty($arrMatches)) {
$arrNewImages = array();
foreach ($arrMatches as $file) {
if (is_dir(TL_ROOT . '/' . $strPath . '/' . $file)) {
$arrSubfiles = scan(TL_ROOT . '/' . $strPath . '/' . $file);
if (!empty($arrSubfiles)) {
foreach ($arrSubfiles as $subfile) {
if (is_file($strPath . '/' . $file . '/' . $subfile)) {
$objFile = new \File($strPath . '/' . $file . '/' . $subfile);
if ($objFile->isGdImage) {
$arrNewImages[] = $strPath . '/' . $file . '/' . $subfile;
}
}
}
}
} elseif (is_file(TL_ROOT . '/' . $strPath . '/' . $file)) {
$objFile = new \File($strPath . '/' . $file);
if ($objFile->isGdImage) {
$arrNewImages[] = $strPath . '/' . $file;
}
}
}
if (!empty($arrNewImages)) {
foreach ($arrNewImages as $strFile) {
$pathinfo = pathinfo(TL_ROOT . '/' . $strFile);
// Will recursively create the folder
$objFolder = new \Folder('isotope/' . strtolower(substr($pathinfo['filename'], 0, 1)));
$strCacheName = $pathinfo['filename'] . '-' . substr(md5_file(TL_ROOT . '/' . $strFile), 0, 8) . '.' . $pathinfo['extension'];
\Files::getInstance()->copy($strFile, $objFolder->path . '/' . $strCacheName);
$arrImages[] = array('src' => $strCacheName);
$arrDelete[] = $strFile;
\Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['MSC']['assetImportConfirmation'], $pathinfo['filename'] . '.' . $pathinfo['extension'], $objProducts->name));
$blnEmpty = false;
}
\Database::getInstance()->prepare("UPDATE tl_iso_product SET images=? WHERE id=?")->execute(serialize($arrImages), $objProducts->id);
}
}
}
if (!empty($arrDelete)) {
$arrDelete = array_unique($arrDelete);
foreach ($arrDelete as $file) {
\Files::getInstance()->delete($file);
}
}
if ($blnEmpty) {
\Message::addInfo($GLOBALS['TL_LANG']['MSC']['assetImportNoFilesFound']);
}
\Controller::reload();
}
示例15: sync
/**
* Synchronize the file system with the database
*
* @return string
*/
public function sync()
{
if (!$this->blnIsDbAssisted) {
return '';
}
$this->import('BackendUser', 'User');
$this->loadLanguageFile('tl_files');
// Check the permission to synchronize
if (!$this->User->hasAccess('f6', 'fop')) {
$this->log('Not enough permissions to synchronize the file system', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
// Synchronize
$strLog = \Dbafs::syncFiles();
// Show the results
$arrMessages = array();
$arrCounts = array('Added' => 0, 'Changed' => 0, 'Unchanged' => 0, 'Moved' => 0, 'Deleted' => 0);
// Read the log file
$fh = fopen(TL_ROOT . '/' . $strLog, 'rb');
while (($buffer = fgets($fh)) !== false) {
list($type, $file) = explode('] ', trim(substr($buffer, 1)), 2);
// Add a message depending on the type
switch ($type) {
case 'Added':
$arrMessages[] = '<p class="tl_new">' . sprintf($GLOBALS['TL_LANG']['tl_files']['syncAdded'], specialchars($file)) . '</p>';
break;
case 'Changed':
$arrMessages[] = '<p class="tl_info">' . sprintf($GLOBALS['TL_LANG']['tl_files']['syncChanged'], specialchars($file)) . '</p>';
break;
case 'Unchanged':
$arrMessages[] = '<p class="tl_confirm hidden">' . sprintf($GLOBALS['TL_LANG']['tl_files']['syncUnchanged'], specialchars($file)) . '</p>';
break;
case 'Moved':
list($source, $target) = explode(' to ', $file, 2);
$arrMessages[] = '<p class="tl_info">' . sprintf($GLOBALS['TL_LANG']['tl_files']['syncMoved'], specialchars($source), specialchars($target)) . '</p>';
break;
case 'Deleted':
$arrMessages[] = '<p class="tl_error">' . sprintf($GLOBALS['TL_LANG']['tl_files']['syncDeleted'], specialchars($file)) . '</p>';
break;
}
++$arrCounts[$type];
}
// Close the log file
unset($buffer);
fclose($fh);
// Confirm
\Message::addConfirmation($GLOBALS['TL_LANG']['tl_files']['syncComplete']);
$return = '
<div id="tl_buttons">
<a href="' . $this->getReferer(true) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b" onclick="Backend.getScrollOffset()">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>
' . \Message::generate() . '
<div id="sync-results">
<p class="left">' . sprintf($GLOBALS['TL_LANG']['tl_files']['syncResult'], \System::getFormattedNumber($arrCounts['Added'], 0), \System::getFormattedNumber($arrCounts['Changed'], 0), \System::getFormattedNumber($arrCounts['Unchanged'], 0), \System::getFormattedNumber($arrCounts['Moved'], 0), \System::getFormattedNumber($arrCounts['Deleted'], 0)) . '</p>
<p class="right"><input type="checkbox" id="show-hidden" class="tl_checkbox" onclick="Backend.toggleUnchanged()"> <label for="show-hidden">' . $GLOBALS['TL_LANG']['tl_files']['syncShowUnchanged'] . '</label></p>
<div class="clear"></div>
</div>
<div class="tl_message nobg" id="result-list" style="margin-bottom:2em">';
// Add the messages
foreach ($arrMessages as $strMessage) {
$return .= "\n " . $strMessage;
}
$return .= '
</div>
<div class="tl_submit_container">
<a href="' . $this->getReferer(true) . '" class="tl_submit" style="display:inline-block">' . $GLOBALS['TL_LANG']['MSC']['continue'] . '</a>
</div>
';
return $return;
}