protected function initDiskPath() { if ($this->record['fileCategory'] == 'image') { $request = CoreServices2::getRequest(); $width = $request->getFromGet('width'); $height = $request->getFromGet('height'); $ignoreProportions = $request->getFromGet('ignoreProportions'); $crop = $request->getFromGet('crop'); $backgroundColor = $request->getFromGet('backgroundColor'); $keepSmall = $request->getFromGet('keepSmall'); } $files = CoreServices2::getFiles(); if (empty($width) && empty($height)) { $this->diskPath = $files->getDiskPath($this->record['fileBaseName'], $this->record['fileExtension']); } else { $options = array('width' => $width, 'height' => $height, 'ignoreProportions' => $ignoreProportions, 'crop' => $crop, 'backgroundColor' => $backgroundColor, 'keepSmall' => $keepSmall); $this->diskPath = $files->getResizedImageDiskPath($this->record['fileBaseName'], $this->record['fileExtension'], $options); if (!is_file($this->diskPath)) { $files->resizeImage($this->diskPath, $this->record['fileBaseName'], $this->record['fileExtension'], $options); } } if (!is_file($this->diskPath)) { $this->error(3); } }
public function assignDisplayVariables() { parent::assignDisplayVariables(); $display = CoreServices2::getDisplay(); $display->assign('loginForm', $this->loginForm); $this->assignErrorValue(); }
protected function checkUserPermissionsForRecord() { if ($this->currentUser['adminRole'] < $this->adminRoles['adminRoleSuperadmin'] && $this->currentUser['id'] != $this->record['id']) { CoreServices2::getDB()->transactionCommit(); CoreUtils::redirect($this->getListPageAddress()); } }
public function getImageLink(&$record, $width = null, $height = null, $ignoreProportions = null, $crop = null, $backgroundColor = null, $keepSmall = null) { $options = $this->getCommonOptions($record); if ($width) { $options[] = 'width'; $options[] = $width; } if ($height) { $options[] = 'height'; $options[] = $height; } if ($ignoreProportions) { $options[] = 'ignoreProportions'; $options[] = $ignoreProportions; } if ($crop) { $options[] = 'crop'; $options[] = $crop; } if ($backgroundColor) { $options[] = 'backgroundColor'; $options[] = $backgroundColor; } if ($keepSmall) { $options[] = 'keepSmall'; $options[] = $keepSmall; } return CoreServices2::getUrl()->createAddress($options); }
public function createHTML(&$record) { $params = array('_m', $record['subpageModule'], '_o', $record['subpageMode']); if ($record['subpageModule'] == 'Subpage' && $record['subpageMode'] == 'Website') { $params = array_merge($params, array('id', $record['id'])); } return CoreServices2::getUrl()->createHTML($params); }
public function assignDisplayVariables() { parent::assignDisplayVariables(); $display = CoreServices2::getDisplay(); if ($this->gallery) { $display->assign('gallery', $this->gallery); } }
public function assignDisplayVariables() { parent::assignDisplayVariables(); $display = CoreServices2::getDisplay(); $display->assign('mainForm', $this->form); if (!is_null($this->errorMessageContainer) && $this->errorMessageContainer->isAnyErrorMessage()) { $display->assign('formErrorMessages', $this->errorMessageContainer); } }
protected function reportError($message) { $from = CoreConfig::get('Environment', 'errorEmailSender'); $listTo = array(CoreConfig::get('Environment', 'errorEmailRecipient')); $listCC = array(); $lang = CoreConfig::get('CoreLangs', 'defaultLangCMS'); $subject = CoreConfig::get('Environment', 'websiteName') . ' - ' . DictForCMS::get($lang, 'garbageCollectorFailure'); $content = DictForCMS::get($lang, 'garbageCollectorFailure') . ":\n" . $message; CoreServices2::getMail()->sendPlainText($from, $listTo, $listCC, $subject, $content); }
protected function prepareAdditionalData() { parent::prepareAdditionalData(); if (!empty($this->currentUser['id'])) { if (CoreServices2::getRequest()->getFromGet('logout') == 1) { CoreServices2::getAccess()->logout(); $this->redirectToHomePage(); } } }
protected function redirectToPage($url, $layoutType) { switch ($layoutType) { case 'standard': CoreUtils::redirect(CoreServices2::getUrl()->createAddress('_m', 'Helper', '_o', 'WebsiteThickboxParentRedirect', 'url', $url)); case 'thickbox': CoreUtils::redirect($url); default: throw new CoreException('Invalid layout type ' . $layoutType); } }
public function getOldRecords($time, $limit) { $db = CoreServices2::getDB(); $sql = ' SELECT * FROM _tmpRecord WHERE _tmpRecordCreateTime < ' . $db->prepareInputValue($time) . ' ORDER BY _tmpRecordCreateTime ASC LIMIT 0, ' . $db->prepareInputValue($limit); return $db->getRows($sql); }
public function assignDisplayVariables() { parent::assignDisplayVariables(); $display = CoreServices2::getDisplay(); $display->assign('recordList', $this->recordList); if ($this->searchForm) { $display->assign('searchForm', $this->searchForm); } if ($this->deletionForm) { $display->assign('deletionForm', $this->deletionForm); } }
public function assignDisplayVariables() { parent::assignDisplayVariables(); $display = CoreServices2::getDisplay(); $display->assign('interfaceLang', CoreServices::get('lang')->getLang('Website')); if (!empty($this->currentUser['id'])) { $userName = !empty($this->currentUser['userFirstName']) && !empty($this->currentUser['userSurname']) ? $this->currentUser['userFirstName'] . ' ' . $this->currentUser['userSurname'] : $this->currentUser['userEmail']; $display->assign('userName', $userName); $display->assign('currentUserName', $userName); $display->assign('userCredits', $this->currentUser['userCredits']); } }
public function getRecordPath($recordId) { $db = CoreServices2::getDB(); $sql = ' SELECT company.id as companyId, companyName FROM company WHERE company.id = ' . $db->prepareInputValue($recordId) . ' LIMIT 0,1'; return $db->getRow($sql); }
public function getWellPointsByWellId($wellId) { $db = CoreServices2::getDB(); $sql = ' SELECT * FROM well3dpoint WHERE wellId = ' . $db->prepareInputValue($wellId) . ' Order By number'; return $db->getRows($sql); }
public function getRecordPath($recordId) { $db = CoreServices2::getDB(); $sql = ' SELECT companyId, companyName, project.id as projectId, projectName FROM project Left join company ON (companyId = company.id) WHERE project.id = ' . $db->prepareInputValue($recordId) . ' LIMIT 0,1'; return $db->getRow($sql); }
public function getRecordByAbbr($abbr) { $db = CoreServices2::getDB(); $sql = ' SELECT * FROM country WHERE countryAbbr = ' . $db->prepareInputValue(strtoupper($abbr)) . ' ORDER BY id LIMIT 0, 1'; $rows = $db->getRows($sql); if (sizeof($rows) == 1) { return $rows[0]; } return $this->getRecordTemplate(); }
protected function initRecord() { $id = CoreServices::get('request')->getFromRequest('id'); if (!empty($id)) { $this->record = $this->dao->getRecordById($id); if (!$this->record['id']) { CoreServices::get('db')->transactionCommit(); CoreUtils::redirect($this->getListPageAddress()); } } else { CoreUtils::redirect(CoreServices2::getUrl()->createAddress('_m', 'Settings', '_o', 'CMSList')); } $this->initMultiselectRelations(); $this->recordOldValues = $this->record; // clone! $this->checkUserPermissionsForRecord(); }
public function getRecordPath($recordId) { $db = CoreServices2::getDB(); $sql = ' SELECT companyName, projectName, projectId, companyId, site.id as siteId, siteName FROM site LEFT JOIN project on (projectId = project.id) LEFT JOIN company ON (companyId = company.id) WHERE site.id = ' . $db->prepareInputValue($recordId) . ' LIMIT 0,1'; return $db->getRow($sql); }
protected function checkHTTPS() { $httpsOn = CoreServices2::getUrl()->isHTTPSOn(); if ($this->getSessionName() == 'CMSSession') { $httpsRequired = CoreConfig::get('Environment', 'httpsForCMS'); } elseif ($this->getSessionName() == 'WebsiteSession') { $httpsRequired = CoreConfig::get('Environment', 'httpsForWebsite'); } else { $httpsRequired = False; // i tak nie ma sesji! } if ($httpsRequired && !$httpsOn) { CoreUtils::redirect(CoreServices::get('url')->getCurrentExactAddress('https')); } if (!$httpsRequired && $httpsOn) { CoreUtils::redirect(CoreServices::get('url')->getCurrentExactAddress('http')); } }
public function getList($recordType, $statsSimpleName, &$recordColumns, $pagination, $order) { $recordColumnsModified = $recordColumns; // kopia! to ważne! $this->prepareRecordColumnList($recordColumnsModified, $recordType); $columnsSQL = $this->adaptColumnsSQL(implode(', ', array_keys($recordColumnsModified)) . ', statsSimpleValue'); $orderBySQL = $this->orderSQL($columns, $order); $offset = null; $limit = null; if ($pagination->getType() == 'Standard') { $offset = $pagination->getCurrentOffset(); $limit = $pagination->getMaxRecordsOnPage(); } $db = CoreServices2::getDB(); $sql = ' SELECT ' . $recordType . '.id AS ' . $recordType . 'Id, ' . $columnsSQL . ' FROM statsSimple, ' . $recordType . ' WHERE statsSimple.recordType = ' . $db->prepareInputValue($recordType) . ' AND statsSimpleName = ' . $db->prepareInputValue($statsSimpleName) . ' AND statsSimple.recordId = ' . $recordType . '.id ORDER BY ' . $orderBySQL . ' ' . $this->getLimitSQLClause($offset, $limit); return $db->getRows($sql); }
protected function assignDisplayVariables() { $this->display->assign('globalCharset', strtolower(CoreConfig::get('CoreDisplay', 'globalCharset'))); $this->display->assign('url', CoreServices2::getUrl()); }
protected function handleDeleteRequest() { parent::handleDeleteRequest(); $this->setRedirectAddress(CoreServices2::getUrl()->createAddress('_m', 'Home', '_o', 'CMSEdit')); }
protected function getNoPermissionsAddress() { return CoreServices2::getUrl()->createAddress(); }
protected function setDisplayBasics() { CoreServices2::getDisplay()->setRootTemplateType($this->layout->getBaseTemplate()); CoreServices2::getDisplay()->setLang(CoreServices::get('lang')->getLang('CMS')); }
public function assignDisplayVariables() { parent::assignDisplayVariables(); $display = CoreServices2::getDisplay(); $display->assign('editButtonOff', 1); }
/** * It is enough to call this function only once after the whole subtree was removed; * of course in such case the parameter is the subtree root. * This must be triggered by a controller. * Keeping consistency of the tree structure is controllers' responsibility. */ public function updateTreeOnDelete(&$record) { $db = CoreServices2::getDB(); $difference = intval($record['subpageRight']) - intval($record['subpageLeft']) + 1; $sql = ' UPDATE subpage SET subpageLeft = subpageLeft - ' . $difference . ' WHERE subpageLeft > ' . $db->prepareInputValue($record['subpageRight']); $db->change($sql); $sql = ' UPDATE subpage SET subpageRight = subpageRight - ' . $difference . ' WHERE subpageRight > ' . $db->prepareInputValue($record['subpageRight']); $db->change($sql); }
public function assignDisplayVariables() { parent::assignDisplayVariables(); $display = CoreServices2::getDisplay(); $display->assign('fileUrl', CoreServices2::getAttachmentLocationManager()); $display->assign('subpageUrl', CoreServices::get('websiteMenuManager')); $display->assign('subpage', $this->subpage); $menuStruct = $this->getMenuStruct(); if (!empty($menuStruct)) { $display->assign('menu', $menuStruct); } if (!empty($this->showCancelNewsletterSubscriptionLink)) { $display->assign('showCancelNewsletterSubscriptionLink', 1); } $display->assign('newsletterForm', $this->newsletterForm); $display->assign('bannerList', $this->bannerList); $display->assign('bannerImageList', $this->bannerImageList); $display->assign('loginForm', $this->loginForm); $display->assign('loginErrorMessages', $this->loginErrorMessageContainer); $display->assign('filterForm', $this->filterForm); $display->assign('fullUrl', CoreServices2::getUrl()->getCurrentExactAddress()); $display->assign('paginationForm', $this->paginationForm); }
protected function isControllerUsagePermitted() { $this->currentUserId = CoreServices2::getAccess()->getCurrentUserId(); return $this->getSessionName() == 'CMSSession' && !empty($this->currentUserId); }
protected function deleteDiskFile(&$record) { if ($record['fileBaseName']) { CoreServices2::getFiles()->removeFile($record['fileBaseName'], $record['fileExtension'], $record['fileCategory'] == 'image'); $record['fileBaseName'] = null; $record['fileExtension'] = null; $record['fileMimeType'] = null; } }