コード例 #1
0
ファイル: main.php プロジェクト: sea75300/fanpresscm3
 public function process()
 {
     $maxStep = max(array_keys($this->subTemplates));
     if ($this->step > $maxStep) {
         die('Undefined step!');
     }
     $disabledTabs = array_keys(array_keys($this->subTemplates));
     $disabledTabs = array_slice($disabledTabs, $this->step === 1 ? 1 : $this->step, $maxStep);
     $this->view->addJsVars(array('disabledTabs' => $disabledTabs, 'activeTab' => $this->step === 1 ? 0 : $this->step - 1));
     $this->view->addJsLangVars(array('dbTestFailed' => $this->lang->translate('INSTALLER_DBCONNECTION_FAILEDMSG')));
     $this->view->assign('tabCounter', 1);
     $this->view->assign('subTabs', $this->subTabs);
     $this->view->assign('subTemplate', $this->subTemplates[$this->step]);
     $this->view->assign('maxStep', $maxStep);
     $this->view->assign('currentStep', $this->step);
     $this->view->assign('step', $this->step + 1);
     $this->view->assign('showNextButton', true);
     $this->view->assign('showReload', false);
     $this->view->setViewJsFiles(array(\fpcm\classes\baseconfig::$jsPath . 'installer.js', \fpcm\classes\loader::libGetFileUrl('password-generator', 'password-generator.min.js')));
     if (method_exists($this, 'runAfterStep' . ($this->step - 1))) {
         call_user_func(array($this, 'runAfterStep' . ($this->step - 1)));
     }
     if (method_exists($this, 'runStep' . $this->step)) {
         call_user_func(array($this, 'runStep' . $this->step));
     }
     $this->view->render();
 }
コード例 #2
0
ファイル: useradd.php プロジェクト: sea75300/fanpresscm3
 public function process()
 {
     if (!parent::process()) {
         return false;
     }
     $userRolls = new \fpcm\model\users\userRollList();
     $this->view->assign('userRolls', $userRolls->getUserRollsTranslated());
     $this->view->assign('author', $this->author);
     $this->view->assign('showDisableButton', false);
     $this->view->setViewJsFiles(array(\fpcm\classes\loader::libGetFileUrl('password-generator', 'password-generator.min.js')));
     $this->view->addJsVars(array('fpcmNavigationActiveItemId' => 'submenu-itemnav-item-users'));
     $this->view->render();
 }
コード例 #3
0
ファイル: dbBackup.php プロジェクト: sea75300/fanpresscm3
 /**
  * Auszuführender Cron-Code
  */
 public function run()
 {
     if (\fpcm\classes\baseconfig::$fpcmDatabase->getDbtype() == 'pgsql') {
         $this->updateLastExecTime();
         return true;
     }
     include_once \fpcm\classes\loader::libGetFilePath('Ifsnop/Mysqldump', 'Mysqldump.php');
     $dbconfig = \fpcm\classes\baseconfig::getDatabaseConfig();
     $dumpSettings = array();
     $this->dumpfile = \fpcm\classes\baseconfig::$dbdumpDir . '/' . $dbconfig['DBNAME'] . '_' . date('Y-m-d_H-i-s') . '.sql';
     if (function_exists('gzopen')) {
         $dumpSettings['compress'] = \Ifsnop\Mysqldump\Mysqldump::GZIP;
         $this->dumpfile .= '.gz';
     }
     $dumpSettings['single-transaction'] = false;
     $dumpSettings['lock-tables'] = false;
     $dumpSettings['add-locks'] = false;
     $dumpSettings['extended-insert'] = false;
     $dumpSettings['no-autocommit'] = false;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableArticles;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableAuthors;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableCategories;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableComments;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableConfig;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableCronjobs;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableFiles;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableIpAdresses;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableModules;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tablePermissions;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableRoll;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableSessions;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableSmileys;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableTexts;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableRevisions;
     $dumpSettings['include-tables'] = $this->events->runEvent('cronjobDbDumpIncludeTables', $dumpSettings['include-tables']);
     \fpcm\classes\logs::syslogWrite('Create new database dump in "' . \fpcm\model\files\ops::removeBaseDir($this->dumpfile, true) . '"...');
     $mysqlDump = new \Ifsnop\Mysqldump\Mysqldump($dbconfig['DBNAME'], $dbconfig['DBUSER'], $dbconfig['DBPASS'], $dbconfig['DBHOST'], $dbconfig['DBTYPE'], $dumpSettings);
     $mysqlDump->start($this->dumpfile);
     $this->updateLastExecTime();
     if (!file_exists($this->dumpfile)) {
         \fpcm\classes\logs::syslogWrite('Unable to create database dump in "' . \fpcm\model\files\ops::removeBaseDir($this->dumpfile, true) . '", file not found. See system check and error log!');
         return false;
     }
     \fpcm\classes\logs::syslogWrite('New database dump created in "' . \fpcm\model\files\ops::removeBaseDir($this->dumpfile, true) . '".');
     $text = \fpcm\classes\baseconfig::$fpcmLanguage->translate('CRONJOB_DBBACKUPS_TEXT', array('{{filetime}}' => date(\fpcm\classes\baseconfig::$fpcmConfig->system_dtmask, $this->getLastExecTime()), '{{dumpfile}}' => \fpcm\model\files\ops::removeBaseDir($this->dumpfile, true)));
     $email = new \fpcm\classes\email(\fpcm\classes\baseconfig::$fpcmConfig->system_email, \fpcm\classes\baseconfig::$fpcmLanguage->translate('CRONJOB_DBBACKUPS_SUBJECT'), $text);
     $email->submit();
     return true;
 }
コード例 #4
0
 /**
  * Array von Javascript-Variablen, welche in Editor-Template genutzt werden
  * @return array
  */
 public function getJsVars()
 {
     $editorStyles = array(array('title' => $this->language->translate('GLOBAL_SELECT'), 'value' => ''));
     $cache = new \fpcm\classes\cache('tinymce_plugins');
     if ($cache->isExpired()) {
         $path = dirname(\fpcm\classes\loader::libGetFilePath('tinymce4', 'tinymce.min.js'));
         $path .= '/plugins/*';
         $pluginFolders = implode(' ', array_map('basename', glob($path, GLOB_ONLYDIR)));
         $cache->write($pluginFolders, $this->config->system_cache_timeout);
     } else {
         $pluginFolders = $cache->read();
     }
     $params = array('fpcmTinyMceLang' => $this->config->system_lang, 'fpcmTinyMceElements' => '~readmore', 'fpcmTinyMcePlugins' => $pluginFolders, 'fpcmTinyMceToolbar' => 'formatselect fontsizeselect | bold italic underline strikethrough | forecolor backcolor | alignleft aligncenter alignright alignjustify outdent indent | subscript superscript table toc | bullist numlist | fpcm_readmore hr blockquote | link unlink anchor image media | emoticons charmap insertdatetime template | undo redo removeformat searchreplace fullscreen code restoredraft', 'fpcmTinyMceCssClasses' => array_merge($editorStyles, $this->getEditorStyles()), 'fpcmTinyMceLinkList' => $this->getEditorLinks(), 'fpcmTinyMceImageList' => $this->getFileList(), 'fpcmTinyMceTextpattern' => $this->getTextPatterns(), 'fpcmTinyMceDefaultFontsize' => $this->config->system_editor_fontsize, 'fpcmTinyMceReadmoreBlockHL' => $this->language->translate('EDITOR_HTML_BUTTONS_READMORE'), 'fpcmTinyMceTemplatesList' => $this->getTemplateDrafts(), 'fpcmTinyMceAutosavePrefix' => 'fpcm-editor-as-' . $this->session->getUserId());
     return $this->events->runEvent('editorInitTinymce', $params);
 }
コード例 #5
0
ファイル: creator.php プロジェクト: sea75300/fanpresscm3
 protected function createConfigFiles()
 {
     if (!$this->finalResult) {
         return false;
     }
     include_once \fpcm\classes\loader::libGetFilePath('spyc', 'Spyc.php');
     $confdir = $this->moddir . '/config/';
     file_put_contents($confdir . 'controllers.yml', "## Module Controller list file\n---\n");
     if (!file_put_contents($confdir . 'dependencies.yml', "## Module dependency file\n---\n" . $this->info['dependencies'])) {
         trigger_error('Unable to create dependency config file "' . $confdir . 'dependencies.yml"');
         return false;
     }
     unset($this->info['dependencies']);
     $this->info['description'] = '"' . $this->info['description'] . '"';
     $ymlstring = "## Module list config file\n";
     $ymlstring .= str_replace('description: >', 'description: ', \Spyc::YAMLDump($this->info, 0, 0));
     if (!file_put_contents($confdir . 'modulelist.yml', $ymlstring)) {
         trigger_error('Unable to create modulelist config file "' . $confdir . 'modulelist.yml"');
         return false;
     }
     return true;
 }
コード例 #6
0
ファイル: useredit.php プロジェクト: sea75300/fanpresscm3
 public function process()
 {
     if (!parent::process()) {
         return false;
     }
     $userRolls = new \fpcm\model\users\userRollList();
     $this->view->assign('userRolls', $userRolls->getUserRollsTranslated());
     $this->view->assign('languages', array_flip($this->lang->getLanguages()));
     $timezones = array();
     foreach ($this->getTimeZones() as $area => $zones) {
         foreach ($zones as $zone) {
             $timezones[$area][$zone] = $zone;
         }
     }
     $this->view->assign('timezoneAreas', $timezones);
     $this->view->assign('externalSave', true);
     $this->view->assign('articleLimitList', \fpcm\model\system\config::getAcpArticleLimits());
     $this->view->assign('defaultFontsizes', \fpcm\model\system\config::getDefaultFontsizes());
     $userList = new \fpcm\model\users\userList();
     $showDisableButton = !$this->userEnabled && ($this->userId == $this->session->getUserId() || $userList->countActiveUsers() == 1) ? false : true;
     $this->view->assign('showDisableButton', $showDisableButton);
     $this->view->setViewJsFiles(array(\fpcm\classes\loader::libGetFileUrl('password-generator', 'password-generator.min.js')));
     $this->view->addJsVars(array('fpcmNavigationActiveItemId' => 'submenu-itemnav-item-users', 'fpcmDtMasks' => \fpcm\classes\baseconfig::$dateTimeMasks));
     $this->view->render();
 }
コード例 #7
0
ファイル: jqupload.php プロジェクト: sea75300/fanpresscm3
 /**
  * Controller-Processing
  */
 public function process()
 {
     require_once \fpcm\classes\loader::libGetFilePath('jqupload', '/UploadHandler.php', 'server');
     $options = array('script_url' => \fpcm\classes\baseconfig::$rootPath . $this->getControllerLink('ajax/jqupload'), 'upload_dir' => \fpcm\classes\baseconfig::$uploadDir, 'upload_url' => \fpcm\classes\baseconfig::$uploadDir, 'accept_file_types' => '/\\.(gif|jpe?g|png|bmp)$/i', 'image_versions' => array('thumbnail' => array('upload_dir' => \fpcm\classes\baseconfig::$uploadDir . 'thumbs/', 'upload_url' => \fpcm\classes\baseconfig::$uploadDir . 'thumbs/', 'crop' => false, 'max_width' => $this->config->file_img_thumb_width, 'max_height' => $this->config->file_img_thumb_height)));
     $handler = new \UploadHandler($options);
 }
コード例 #8
0
ファイル: htmlEditor.php プロジェクト: sea75300/fanpresscm3
 /**
  * Liefert zu ladender Javascript-Dateien für Editor zurück
  * @return array
  */
 public function getJsFiles()
 {
     return array_merge($this->fileLib->getCmJsFiles(), array(\fpcm\classes\loader::libGetFileUrl('leela-colorpicker', 'leela.colorpicker-1.0.2.jquery.min.js'), \fpcm\classes\baseconfig::$jsPath . 'editor.js', \fpcm\classes\baseconfig::$jsPath . 'editor_videolinks.js'));
 }
コード例 #9
0
ファイル: fileuploader.php プロジェクト: sea75300/fanpresscm3
 /**
  * Führt Upload von Module-Package via HTML-Form + PHP sowie Installation aus Modulmanager durch
  * @return boolean
  */
 public function processModuleUpload()
 {
     $tempNames = $this->uploader['tmp_name'];
     $fileNames = $this->uploader['name'];
     $fileTypes = $this->uploader['type'];
     foreach ($tempNames as $key => $value) {
         if (!is_uploaded_file($value) || !isset($fileNames[$key]) || !isset($fileTypes[$key])) {
             continue;
         }
         $ext = pathinfo($fileNames[$key], PATHINFO_EXTENSION);
         $ext = $ext ? strtolower($ext) : '';
         if ($ext != 'zip') {
             return false;
         }
         $fileName = \fpcm\classes\baseconfig::$tempDir . $fileNames[$key];
         if (!move_uploaded_file($value, $fileName)) {
             return false;
         }
         $data = \fpcm\model\packages\package::explodeModuleFileName(basename($fileNames[$key], '.zip'));
         $package = new \fpcm\model\packages\module('module', $data[0], $data[1]);
         $res = $package->extract();
         $extractPath = $package->getExtractPath();
         $modulelisteConfigFile = realpath($extractPath . $data[0] . '/config/modulelist.yml');
         if (!file_exists($modulelisteConfigFile)) {
             return $res;
         }
         include_once \fpcm\classes\loader::libGetFilePath('spyc', 'Spyc.php');
         $modulelisteConfig = \Spyc::YAMLLoad($modulelisteConfigFile);
         if ($res !== true) {
             return $res;
         }
         $package->setCopyDestination($modulelisteConfig['vendor'] . '/');
         $res = $package->copy();
         if ($res !== true) {
             return $res;
         }
         $package->cleanup();
         $moduleClass = \fpcm\model\abstracts\module::getModuleClassName($modulelisteConfig['vendor'] . '/' . $modulelisteConfig['key']);
         if (class_exists($moduleClass)) {
             $modObj = new $moduleClass($modulelisteConfig['vendor'] . $modulelisteConfig['key'], '', $data[1]);
             $res = $modObj->isInstalled() ? $modObj->runUpdate() : $modObj->runInstall();
             if ($res !== true) {
                 return $res;
             }
         }
     }
     return true;
 }
コード例 #10
0
ファイル: filelist.php プロジェクト: sea75300/fanpresscm3
 public function process()
 {
     if (!parent::process()) {
         return false;
     }
     $loadAjax = $this->fileList->getDatabaseFileCount() >= 1 ? true : false;
     $this->view->assign('loadAjax', $loadAjax);
     $this->view->addJsVars(array('fpcmBaseUrl' => \fpcm\classes\baseconfig::$rootPath, 'fpcmFmgrMode' => $this->mode, 'fpcmEditorType' => $this->config->system_editor, 'fpcmJqUploadInit' => $this->config->file_uploader_new));
     $this->view->addJsLangVars(array('newNameMsg' => $this->lang->translate('FILE_LIST_RENAME_NEWNAME')));
     $this->view->assign('newUploader', $this->config->file_uploader_new);
     $this->view->assign('jquploadPath', \fpcm\classes\loader::libGetFileUrl('jqupload'));
     $this->view->setViewJsFiles(array(\fpcm\classes\baseconfig::$jsPath . 'filemanager.js'));
     if ($this->config->file_uploader_new) {
         $this->view->assign('actionPath', \fpcm\classes\baseconfig::$rootPath . $this->getControllerLink('ajax/jqupload'));
     } else {
         $this->view->assign('actionPath', \fpcm\classes\baseconfig::$rootPath . $this->getControllerLink('files/list', array('mode' => $this->mode)));
         $translInfo = array('{{filecount}}' => ini_get("max_file_uploads"), '{{filesize}}' => \fpcm\classes\tools::calcSize(\fpcm\classes\baseconfig::uploadFilesizeLimit(true), 0));
         $this->view->assign('maxFilesInfo', $this->lang->translate('FILE_LIST_PHPMAXINFO', $translInfo));
     }
     $this->initViewAssigns(array(), array(), \fpcm\classes\tools::calcPagination(1, 1, 0, 0));
     $this->initPermissions();
     $this->view->render();
 }
コード例 #11
0
ファイル: imagelist.php プロジェクト: sea75300/fanpresscm3
 /**
  * Erzeugt Thumbanils für Dateimanager
  * @param arraye $folderFiles
  */
 public function createFilemanagerThumbs($folderFiles = null)
 {
     $folderFiles = is_null($folderFiles) ? $this->getFolderList() : $folderFiles;
     include_once \fpcm\classes\loader::libGetFilePath('PHPImageWorkshop', 'ImageWorkshop.php');
     $filesizeLimit = \fpcm\classes\baseconfig::memoryLimit(true) * 0.025;
     $memoryWorkLimit = \fpcm\classes\baseconfig::memoryLimit(true) * 0.5;
     foreach ($folderFiles as $folderFile) {
         if (filesize($folderFile) >= $filesizeLimit) {
             $msgPath = ops::removeBaseDir($folderFile);
             \fpcm\classes\logs::syslogWrite("Skip filemanager thumbnail generation for {$msgPath} because of image dimension. You may reduce file size?");
             continue;
         }
         $phpImgWsp = \PHPImageWorkshop\ImageWorkshop::initFromPath($folderFile);
         $image = new \fpcm\model\files\image(basename($folderFile), '', '');
         if (file_exists($image->getFileManagerThumbnail())) {
             $image = null;
             $phpImgWsp = null;
             continue;
         }
         if (memory_get_usage(true) < $memoryWorkLimit) {
             $phpImgWsp->cropMaximumInPixel(0, 0, "MM");
         }
         $phpImgWsp->resizeInPixel(100, 100);
         $phpImgWsp->save(dirname($image->getFileManagerThumbnail()), basename($image->getFileManagerThumbnail()));
         if (!file_exists($image->getFileManagerThumbnail())) {
             trigger_error('Unable to create filemanager thumbnail: ' . $image->getFileManagerThumbnail());
         }
         $image = null;
         $phpImgWsp = null;
     }
 }
コード例 #12
0
ファイル: finalizer.php プロジェクト: sea75300/fanpresscm3
 /**
  * Prüfung von Dateisystem-Strukturen
  * @return bool
  */
 private function checkFilesystem()
 {
     if (file_exists(\fpcm\classes\baseconfig::$viewsDir . 'logs/cronjobs.php')) {
         unlink(\fpcm\classes\baseconfig::$viewsDir . 'logs/cronjobs.php');
     }
     if ($this->checkVersion('3.2.0', '>=')) {
         return true;
     }
     if (is_dir(\fpcm\classes\baseconfig::$dataDir . 'dbstruct')) {
         \fpcm\model\files\ops::deleteRecursive(\fpcm\classes\baseconfig::$dataDir . 'dbstruct');
     }
     if (is_dir(\fpcm\classes\baseconfig::$dataDir . 'dbstruct')) {
         \fpcm\model\files\ops::deleteRecursive(\fpcm\classes\baseconfig::$dataDir . 'dbstruct');
     }
     if (file_exists(\fpcm\classes\baseconfig::$jsPath . 'backupmgr.js')) {
         unlink(\fpcm\classes\baseconfig::$jsPath . 'backupmgr.js');
     }
     $libPath = \fpcm\classes\loader::libGetFilePath('jquery', 'jquery-2.1.4.min.js');
     if ($libPath) {
         unlink($libPath);
     }
     return true;
 }
コード例 #13
0
ファイル: fileLib.php プロジェクト: sea75300/fanpresscm3
 /**
  * Gibt JS library für Public Controller zurück
  * @return array
  */
 public function getJsPubliclib()
 {
     $modulesFiles = $this->events->runEvent('publicAddJsFiles');
     $modulesFiles = $modulesFiles ? $modulesFiles : array();
     return array_merge(array(\fpcm\classes\loader::libGetFileUrl('jquery', 'jquery-3.1.0.min.js'), \fpcm\classes\baseconfig::$rootPath . 'js/fpcm.js'), $modulesFiles);
 }
コード例 #14
0
ファイル: modulelist.php プロジェクト: sea75300/fanpresscm3
 /**
  * Config-Dateien anhand von Modul-Key und Dateinamen auslesen
  * @param string $moduleKey
  * @param string $configFile
  * @return array
  */
 public function getConfigByModuleKey($moduleKey, $configFile)
 {
     $path = \fpcm\classes\baseconfig::$moduleDir . $moduleKey . '/config/' . $configFile . '.yml';
     if (!file_exists($path)) {
         return array();
     }
     include_once \fpcm\classes\loader::libGetFilePath('spyc', 'Spyc.php');
     return \Spyc::YAMLLoad($path);
 }
コード例 #15
0
ファイル: commentedit.php プロジェクト: sea75300/fanpresscm3
 public function process()
 {
     if (!parent::process()) {
         return false;
     }
     $mode = (int) $this->getRequestVar('mode');
     if ($mode == 2) {
         $this->view->setShowHeader(0);
         $this->view->setShowFooter(0);
     }
     $this->view->setViewJsFiles(array(\fpcm\classes\loader::libGetFileUrl('tinymce4', 'tinymce.min.js'), \fpcm\classes\baseconfig::$jsPath . 'editor_comments.js'));
     $this->view->addJsVars(array('fpcmTinyMceLang' => $this->config->system_lang, 'fpcmTinyMcePlugins' => 'autolink charmap code image link lists media nonbreaking wordcount fpcm_emoticons autoresize', 'fpcmTinyMceToolbar' => 'fontsizeselect | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist blockquote | link unlink anchor image media emoticons charmap | undo redo removeformat searchreplace fullscreen code', 'fpcmNavigationActiveItemId' => 'itemnav-item-editcomments'));
     if ($this->comment->getChangeuser() && $this->comment->getChangetime()) {
         $changeUser = new \fpcm\model\users\author($this->comment->getChangeuser());
         $this->view->assign('changeInfo', $this->lang->translate('COMMMENT_LASTCHANGE', array('{{username}}' => $changeUser->exists() ? $changeUser->getDisplayname() : $this->lang->translate('GLOBAL_NOTFOUND'), '{{time}}' => date($this->config->system_dtmask, $this->comment->getChangetime()))));
     } else {
         $this->view->assign('changeInfo', $this->lang->translate('GLOBAL_NOCHANGE'));
     }
     $this->view->assign('ipWhoisLink', substr($this->comment->getIpaddress(), -1) === '*' ? false : true);
     $this->view->assign('comment', $this->comment);
     $this->view->assign('commentsMode', $mode);
     $this->view->assign('permApprove', $this->approve);
     $this->view->assign('permPrivate', $this->private);
     $this->view->render();
 }
コード例 #16
0
ファイル: view.php プロジェクト: sea75300/fanpresscm3
 /**
  * Force to load jQuery in Pub-Controllers before other JS-Files if not already done
  * @since FPCM 3.2.0
  */
 public function prependjQuery()
 {
     if ($this->config->system_loader_jquery) {
         return false;
     }
     array_unshift($this->viewJsFiles, \fpcm\classes\loader::libGetFileUrl('jquery', 'jquery-3.1.0.min.js'));
 }
コード例 #17
0
ファイル: yatdl.php プロジェクト: sea75300/fanpresscm3
 /**
  * Konstruktor
  * @param string $filePath
  */
 public function __construct($filePath)
 {
     $this->db = \fpcm\classes\baseconfig::$fpcmDatabase;
     $this->isPg = $this->db->getDbtype() == 'pgsql' ? true : false;
     $this->colTypes = $this->db->getYaTDLDataTypes();
     include_once \fpcm\classes\loader::libGetFilePath('spyc', 'Spyc.php');
     $this->yamlArray = \Spyc::YAMLLoad($filePath);
 }
コード例 #18
0
ファイル: image.php プロジェクト: sea75300/fanpresscm3
 /**
  * Erzeugt ein Thumbnail für das aktuelle Bild
  * @return boolean
  */
 public function createThumbnail()
 {
     include_once \fpcm\classes\loader::libGetFilePath('PHPImageWorkshop', 'ImageWorkshop.php');
     $phpImgWsp = \PHPImageWorkshop\ImageWorkshop::initFromPath($this->getFullpath());
     if (memory_get_usage(true) < \fpcm\classes\baseconfig::memoryLimit(true) * 0.5) {
         $phpImgWsp->cropMaximumInPixel(0, 0, 'MM');
     }
     $phpImgWsp->resizeInPixel($this->config->file_img_thumb_width, $this->config->file_img_thumb_height);
     $phpImgWsp->save($this->getFilepath() . dirname($this->getThumbnail()), basename($this->getThumbnail()), true, null, 85);
     $this->events->runEvent('thumbnailCreate', $this);
     if (!file_exists($this->getFilepath() . $this->getThumbnail())) {
         trigger_error('Unable to create filemanager thumbnail: ' . $this->getThumbnail());
         return false;
     }
     return true;
 }
コード例 #19
0
ファイル: articleedit.php プロジェクト: sea75300/fanpresscm3
 /**
  * @see \fpcm\controller\abstracts\controller::request()
  * @return boolean
  */
 public function request()
 {
     if (is_null($this->getRequestVar('articleid'))) {
         $this->redirect('articles/list');
     }
     $this->article = new \fpcm\model\articles\article($this->getRequestVar('articleid'));
     if (!$this->article->exists()) {
         $this->view->setNotFound('LOAD_FAILED_ARTICLE', 'articles/list');
         return true;
     }
     if (!$this->article->getEditPermission()) {
         $this->view = new \fpcm\model\view\error();
         $this->view->addErrorMessage('PERMISSIONS_REQUIRED');
         $this->view->render();
         return false;
     }
     if ($this->getRequestVar('revrestore')) {
         $this->view->addNoticeMessage('SAVE_SUCCESS_ARTICLEREVRESTORE');
     }
     $this->checkPageToken = $this->checkPageToken();
     if ($this->buttonClicked('doAction') && !$this->checkPageToken) {
         $this->view->addErrorMessage('CSRF_INVALID');
     }
     $revisionIdsArray = !is_null($this->getRequestVar('revisionIds')) ? array_map('intval', $this->getRequestVar('revisionIds')) : false;
     if ($this->buttonClicked('revisionDelete') && $revisionIdsArray && !$this->showRevision && $this->checkPageToken) {
         if ($this->article->deleteRevisions($revisionIdsArray)) {
             $this->view->addNoticeMessage('DELETE_SUCCESS_REVISIONS');
         } else {
             $this->view->addErrorMessage('DELETE_FAILED_REVISIONS');
         }
     }
     $this->revisionId = !is_null($this->getRequestVar('rev')) ? (int) $this->getRequestVar('rev') : (is_array($revisionIdsArray) ? array_shift($revisionIdsArray) : false);
     if ($this->buttonClicked('articleRevisionRestore') && ($this->getRequestVar('rev') || $this->getRequestVar('revisionIds')) && $this->checkPageToken) {
         if ($this->revisionId && $this->article->restoreRevision($this->revisionId)) {
             $this->redirect('articles/edit&articleid=' . $this->article->getId() . '&revrestore=1');
         } else {
             $this->view->addErrorMessage('SAVE_FAILED_ARTICLEREVRESTORE');
         }
     }
     if ($this->revisionId) {
         include_once \fpcm\classes\loader::libGetFilePath('PHP-FineDiff', 'finediff.php');
         $this->currentArticle = clone $this->article;
         if (!$this->revisionId) {
             $this->revisionId = (int) $this->getRequestVar('rev');
         }
         $this->showRevision = $this->article->getRevision($this->revisionId) ? true : false;
         $from = $this->currentArticle->getContent();
         $to = $this->article->getContent();
         $opcode = \FineDiff::getDiffOpcodes($from, $to, \FineDiff::$sentenceGranularity);
         $this->view->assign('textFrom', \FineDiff::renderDiffToHTMLFromOpcodes($from, $opcode));
         $this->view->assign('textTo', \FineDiff::renderDiffToHTMLFromOpcodes($to, $opcode));
     }
     if ($this->buttonClicked('articleDelete') && !$this->showRevision && $this->checkPageToken) {
         if ($this->article->delete()) {
             $this->redirect('articles/listall');
         } else {
             $this->view->addErrorMessage('DELETE_FAILED_ARTICLE');
         }
     }
     $res = false;
     $allTimer = time();
     if ($this->buttonClicked('articleSave') && !$this->showRevision && $this->checkPageToken) {
         $this->article->prepareRevision();
         $data = $this->getRequestVar('article', array(4, 7));
         $this->article->setTitle($data['title']);
         $this->article->setContent($data['content']);
         $cats = $this->categoryList->getCategoriesCurrentUser();
         $categories = isset($data['categories']) ? array_map('intval', $data['categories']) : array(array_shift($cats)->getId());
         $this->article->setCategories($categories);
         if (isset($data['postponed']) && !isset($data['archived'])) {
             $timer = strtotime($data['postponedate'] . ' ' . (int) $data['postponehour'] . ':' . (int) $data['postponeminute'] . ':00');
             $postpone = 1;
             if ($timer === false) {
                 $timer = $allTimer;
                 $postpone = 0;
             }
             $this->article->setPostponed($postpone);
             $this->article->setCreatetime($timer);
         } else {
             if ($this->article->getPostponed() || $this->article->getDraft() && !isset($data['draft'])) {
                 $this->article->setCreatetime($allTimer);
             }
             $this->article->setPostponed(0);
         }
         $this->article->setPinned(isset($data['pinned']) ? 1 : 0);
         $this->article->setDraft(isset($data['draft']) ? 1 : 0);
         $this->article->setComments(isset($data['comments']) ? 1 : 0);
         $this->article->setApproval($this->permissions->check(array('article' => 'approve')) ? 1 : 0);
         $this->article->setImagepath(isset($data['imagepath']) ? $data['imagepath'] : '');
         $this->article->setSources(isset($data['sources']) ? $data['sources'] : '');
         if (isset($data['archived'])) {
             $this->article->setArchived(1);
             $this->article->setPinned(0);
             $this->article->setDraft(0);
         } else {
             $this->article->setArchived(0);
         }
         if (!$this->article->getTitle() || !$this->article->getContent()) {
             $this->view->addErrorMessage('SAVE_FAILED_ARTICLE_EMPTY');
             return true;
         }
         if (isset($data['author']) && trim($data['author'])) {
             $this->article->setCreateuser($data['author']);
         }
         if (isset($data['tweettxt']) && $data['tweettxt']) {
             $this->article->setTweetOverride($data['tweettxt']);
         }
         $this->article->setChangetime($allTimer);
         $this->article->setChangeuser($this->session->getUserId());
         $this->article->setMd5path($this->article->getArticleNicePath());
         $this->article->prepareDataSave();
         $saved = true;
         $res = $this->article->update();
         if ($res) {
             $this->article->createRevision();
         }
     }
     $this->handleCommentActions();
     if ($res || $this->getRequestVar('added') == 1) {
         $this->view->addNoticeMessage('SAVE_SUCCESS_ARTICLE');
     } elseif ($this->getRequestVar('added') == 2) {
         $this->view->addNoticeMessage('SAVE_SUCCESS_ARTICLE_APPROVAL');
     } elseif (isset($saved) && !$res) {
         $this->view->addErrorMessage('SAVE_FAILED_ARTICLE');
     }
     if (!$this->revisionId) {
         $this->article->prepareDataLoad();
     }
     return true;
 }