openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 56eb09aca458195c2755787a1bf498c4e2dbf0f4
parent a86a69d1d3d36a175d665f6456c5830b906bd7bd
Author: Jan Dankert <devnull@localhost>
Date:   Sat,  9 Dec 2017 23:01:56 +0100

In Component.class.php aufgeräumt und andere Templates entsprechend nachgezogen.

Diffstat:
action/FolderAction.class.php | 26++++++++++++++++++--------
action/TitleAction.class.php | 4+++-
model/Folder.class.php | 7+++++--
modules/template-engine/components/html/Component.class.php | 10----------
util/Publish.class.php | 304++++++++++++++++++++++++++++++++++++++++----------------------------------------
5 files changed, 178 insertions(+), 173 deletions(-)

diff --git a/action/FolderAction.class.php b/action/FolderAction.class.php @@ -2,6 +2,7 @@ namespace cms\action; +use ArchiveTar; use cms\model\Template; use cms\model\Page; use cms\model\Folder; @@ -10,8 +11,12 @@ use cms\model\File; use cms\model\Link; use Http; +use Publish; use Session; use \Html; +use Text; +use Upload; + // OpenRat Content Management System // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de // @@ -1001,7 +1006,7 @@ class FolderAction extends ObjectAction * @param String Abgek�rzter Bytewert * @return Integer Byteanzahl */ - function stringToBytes($val) + private function stringToBytes($val) { $val = trim($val); $last = strtolower($val{strlen($val)-1}); @@ -1052,7 +1057,6 @@ class FolderAction extends ObjectAction /** * Anzeige aller Objekte in diesem Ordner. - * @return unknown_type */ public function previewView() { @@ -1066,7 +1070,9 @@ class FolderAction extends ObjectAction // Schleife ueber alle Objekte in diesem Ordner foreach( $this->folder->getObjects() as $o ) { - $id = $o->objectid; + /* @var $o Object */ + + $id = $o->objectid; if ( $o->hasRight(ACL_READ) ) { @@ -1111,7 +1117,6 @@ class FolderAction extends ObjectAction /** * Anzeige aller Objekte in diesem Ordner. - * @return unknown_type */ public function contentView() { @@ -1127,7 +1132,8 @@ class FolderAction extends ObjectAction // Schleife ueber alle Objekte in diesem Ordner foreach( $this->folder->getObjects() as $o ) { - $id = $o->objectid; + /* @var $o Object */ + $id = $o->objectid; if ( $o->hasRight(ACL_READ) ) { @@ -1181,6 +1187,7 @@ class FolderAction extends ObjectAction // Schleife ueber alle Objekte in diesem Ordner foreach( $this->folder->getObjects() as $o ) { + /* @var $o Object */ $id = $o->objectid; if ( $o->hasRight(ACL_READ) ) @@ -1290,14 +1297,15 @@ class FolderAction extends ObjectAction // Schleife ueber alle Objekte in diesem Ordner foreach( $this->folder->getObjects() as $o ) { + /* @var $o Object */ $id = $o->objectid; if ( $o->hasRight(ACL_READ) ) { $list[$id]['id' ] = $id; - $list[$id]['name'] = Text::maxLaenge( 30,$o->name ); - $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename ); - $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc ); + $list[$id]['name'] = Text::maxLength( 30,$o->name ); + $list[$id]['filename'] = Text::maxLength( 20,$o->filename ); + $list[$id]['desc'] = Text::maxLength( 30,$o->desc ); if ( $list[$id]['desc'] == '' ) $list[$id]['desc'] = lang('NO_DESCRIPTION_AVAILABLE'); $list[$id]['desc'] = 'ID '.$id.' - '.$list[$id]['desc']; @@ -1342,6 +1350,7 @@ class FolderAction extends ObjectAction $this->setTemplateVar('orderbylastchange_url',Html::url('folder','reorder',0,array('type'=>'lastchange')) ); $this->setTemplateVar('object' ,$list ); $this->setTemplateVar('act_objectid',$this->folder->id); + $this->setTemplateVar('token',token() ); } @@ -1418,6 +1427,7 @@ class FolderAction extends ObjectAction $children = array(); foreach( $contents as $o ) { + /* @var $o Object */ $children[$o->objectid] = array('id'=>$o->objectid,'name'=>$o->name,'type'=>$o->getType()); } $tmp+= $children; diff --git a/action/TitleAction.class.php b/action/TitleAction.class.php @@ -84,7 +84,9 @@ class TitleAction extends Action // Urls zum Benutzerprofil und zum Abmelden //$this->setTemplateVar('profile_url',Html::url( 'profile' )); //$this->setTemplateVar('logout_url' ,Html::url( 'index','logout' )); - + $this->setTemplateVar('isAdmin',$this->userIsAdmin() ); + $this->setTemplateVar('isLoggedIn',$this->userIsLoggedIn() ); + if ( config('interface','session','auto_extend') ) { $this->setTemplateVar('ping_url' ,Html::url('title','ping') ); diff --git a/model/Folder.class.php b/model/Folder.class.php @@ -35,7 +35,10 @@ class Folder extends Object var $name = ''; var $filename = ''; var $desc = ''; - var $publish = null; + /** + * @var \Publish + */ + public $publish = null; function __construct( $objectid='' ) @@ -179,7 +182,7 @@ class Folder extends Object /** * Liest alle Objekte in diesem Ordner - * @return Array von Objekten + * @return array[Object] Objekte */ function getObjects() { diff --git a/modules/template-engine/components/html/Component.class.php b/modules/template-engine/components/html/Component.class.php @@ -187,22 +187,12 @@ class Expression return "'".$value."'"; case 'var': return $invert.'$'.$value; - case 'function': - return $invert.$value.'()'; - case 'method': - return $invert.'$this->'.$value.'()'; case 'size': return '@count($'.$value.')'; - case 'property': - return $invert.'$this->'.$value; case 'message': // macht aus "text1{var}text2" => "text1".$var."text2" $value = preg_replace('/{(\w+)\}/','\'.$\\1.\'',$value); return 'lang('."'".$value."'".')'; - case 'messagevar': - return 'lang($'.$value.')'; - case 'mode': - return $invert.'$mode=="'.$value.'"'; case 'arrayvar': list($arr,$key) = explode(':',$value.':none'); return $invert.'@$'.$arr.'['.$key.']'; diff --git a/util/Publish.class.php b/util/Publish.class.php @@ -17,13 +17,13 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** - * Diese Klasse kapselt das Veroeffentlichen von Dateien.<br> - * <br> - * Hier werden<br> - * - Dateien in das Zielverzeichnis kopiert<br> - * - Dateien per FTP veroeffentlicht<br> - * - Zielverzeichnisse aufgeraeumt<br> - * - Systembefehle ausgefuehrt. + * Diese Klasse kapselt das Veroeffentlichen von Dateien.<br> + * <br> + * Hier werden<br> + * - Dateien in das Zielverzeichnis kopiert<br> + * - Dateien per FTP veroeffentlicht<br> + * - Zielverzeichnisse aufgeraeumt<br> + * - Systembefehle ausgefuehrt. * * @author Jan Dankert * @package openrat.services @@ -80,27 +80,27 @@ class Publish * Fehlermeldung. * * @var String - */ + */ var $log = array(); /** * Stellt nach der Ver�ffentlichung fest, ob der Vorgang erfolgreich ist. * Falls nicht, enth�lt die Variable 'log' eine Fehlermeldung. * @var boolean - */ + */ var $ok = true; - - /** - * Konstruktor.<br> - * <br> - * Oeffnet ggf. Verbindungen. - * - * @return Publish + + /** + * Konstruktor.<br> + * <br> + * Oeffnet ggf. Verbindungen. + * + * @return Publish */ function Publish() - { - global $conf; - $confPublish = $conf['publish']; + { + global $conf; + $confPublish = $conf['publish']; if ( $conf['security']['nopublish'] ) { @@ -110,56 +110,56 @@ class Publish } $project = Session::getProject(); - - // Feststellen, ob FTP benutzt wird. + + // Feststellen, ob FTP benutzt wird. // Dazu muss FTP aktiviert sein (enable=true) und eine URL vorhanden sein. $ftpUrl = ''; if ( $conf['publish']['ftp']['enable'] ) { if ( $conf['publish']['ftp']['per_project'] && !empty($project->ftp_url) ) $ftpUrl = $project->ftp_url; - elseif ( !empty($conf['publish']['ftp']['host']) ) + elseif ( !empty($conf['publish']['ftp']['host']) ) $ftpUrl = $project->ftp_url; } if ( ! empty($ftpUrl) ) { - $this->with_ftp = true; + $this->with_ftp = true; $this->ftp = new Ftp( $project->ftp_url ); // Aufbauen einer FTP-Verbindung - - if ( ! $this->ftp->ok ) // FTP-Verbindung ok? - { - $this->ok = false; - $this->log = $this->ftp->log; - return; // Ende. Ohne FTP brauchen wir nicht weitermachen. - } - + + if ( ! $this->ftp->ok ) // FTP-Verbindung ok? + { + $this->ok = false; + $this->log = $this->ftp->log; + return; // Ende. Ohne FTP brauchen wir nicht weitermachen. + } + $this->ftp->passive = ( $project->ftp_passive == '1' ); } - $localDir = rtrim( $project->target_dir,'/' ); + $localDir = rtrim( $project->target_dir,'/' ); if ( $confPublish['filesystem']['per_project'] && (!empty($localDir)) ) - { + { $this->local_destdir = $localDir; // Projekteinstellung verwenden. - } + } else - { - if ( empty( $localDir)) + { + if ( empty( $localDir)) $localDir = $project->name; - // Konfiguriertes Verzeichnis verwenden. + // Konfiguriertes Verzeichnis verwenden. $this->local_destdir = $confPublish['filesystem']['directory'].$localDir; - } + } // Sofort pruefen, ob das Zielverzeichnis ueberhaupt beschreibbar ist. if ( $this->local_destdir != '' ) { if ( !is_writeable( $this->local_destdir ) ) - { - $this->ok = false; - $this->log[] = 'directory not writable: '.$this->local_destdir; - $this->log[] = 'please correct the file permissions.'; + { + $this->ok = false; + $this->log[] = 'directory not writable: '.$this->local_destdir; + $this->log[] = 'please correct the file permissions.'; return; } @@ -171,51 +171,51 @@ class Publish if ( $confPublish['command']['enable'] ) { - if ( $confPublish['command']['per_project'] && !empty($project->cmd_after_publish) ) + if ( $confPublish['command']['per_project'] && !empty($project->cmd_after_publish) ) $this->cmd_after_publish = $project->cmd_after_publish; - else - $this->cmd_after_publish = @$confPublish['command']['command']; - } - - // Im Systemkommando Variablen ersetzen + else + $this->cmd_after_publish = @$confPublish['command']['command']; + } + + // Im Systemkommando Variablen ersetzen $this->cmd_after_publish = str_replace('{name}' ,$project->name ,$this->cmd_after_publish); $this->cmd_after_publish = str_replace('{dir}' ,$this->local_destdir ,$this->cmd_after_publish); $this->cmd_after_publish = str_replace('{dirbase}',basename($this->local_destdir),$this->cmd_after_publish); } - - - - /** - * Kopieren einer Datei aus dem tempor�ren Verzeichnis in das Zielverzeichnis.<br> - * Falls notwenig, wird ein Hochladen per FTP ausgef�hrt. - * - * @param String $tmp_filename - * @param String $dest_filename + + + + /** + * Kopieren einer Datei aus dem tempor�ren Verzeichnis in das Zielverzeichnis.<br> + * Falls notwenig, wird ein Hochladen per FTP ausgef�hrt. + * + * @param String $tmp_filename + * @param String $dest_filename */ function copy( $tmp_filename,$dest_filename,$lastChangeDate=null ) - { - if ( !$this->ok) - return; + { + if ( !$this->ok) + return; global $conf; $source = $tmp_filename; if ( $this->with_local ) { - $dest = $this->local_destdir.'/'.$dest_filename; - + $dest = $this->local_destdir.'/'.$dest_filename; + if (!@copy( $source,$dest )); { - if ( ! $this->mkdirs( dirname($dest) ) ) - return; // Fehler bei Verzeichniserstellung, also abbrechen. + if ( ! $this->mkdirs( dirname($dest) ) ) + return; // Fehler bei Verzeichniserstellung, also abbrechen. if (!@copy( $source,$dest )) - { - $this->ok = false; - $this->log[] = 'failed copying local file:'; - $this->log[] = 'source : '.$source; - $this->log[] = 'destination: '.$dest; - return; // Fehler beim Kopieren, also abbrechen. + { + $this->ok = false; + $this->log[] = 'failed copying local file:'; + $this->log[] = 'source : '.$source; + $this->log[] = 'destination: '.$dest; + return; // Fehler beim Kopieren, also abbrechen. } if ( ! is_null($lastChangeDate) ) @touch( $dest,$lastChangeDate ); @@ -223,45 +223,45 @@ class Publish Logger::debug("published: $dest"); } - if (!empty($conf['security']['chmod'])) + if (!empty($conf['security']['chmod'])) { - // CHMOD auf der Datei ausfuehren. - if ( ! @chmod($dest,octdec($conf['security']['chmod'])) ) - { - $this->ok = false; - $this->log[] = 'Unable to CHMOD file '.$dest; - return; - } + // CHMOD auf der Datei ausfuehren. + if ( ! @chmod($dest,octdec($conf['security']['chmod'])) ) + { + $this->ok = false; + $this->log[] = 'Unable to CHMOD file '.$dest; + return; + } } } if ( $this->with_ftp ) // Falls FTP aktiviert { $dest = $dest_filename; - $this->ftp->put( $source,$dest ); - - if ( ! $this->ftp->ok ) - { - $this->ok = false; - $this->log[] = $this->ftp->log; + $this->ftp->put( $source,$dest ); + + if ( ! $this->ftp->ok ) + { + $this->ok = false; + $this->log[] = $this->ftp->log; } } } - - - /** - * Rekursives Anlagen von Verzeichnisse - * Nett gemacht. - * Quelle: http://de3.php.net/manual/de/function.mkdir.php - * Thx to acroyear at io dot com - * - * @param String Verzeichnis + + + /** + * Rekursives Anlagen von Verzeichnisse + * Nett gemacht. + * Quelle: http://de3.php.net/manual/de/function.mkdir.php + * Thx to acroyear at io dot com + * + * @param String Verzeichnis * @return boolean */ function mkdirs( $strPath ) - { - global $conf; + { + global $conf; if ( is_dir($strPath) ) return true; @@ -270,96 +270,96 @@ class Publish if ( !$this->mkdirs($pStrPath) ) return false; - if ( ! @mkdir($strPath,0777) ) - { - $this->ok = false; - $this->log[] = 'Cannot create directory: '.$strPath; - return false; - } - - // CHMOD auf dem Verzeichnis ausgef�hren. - if (!empty($conf['security']['chmod_dir'])) - { - if ( ! @chmod($strPath,octdec($conf['security']['chmod_dir'])) ) - { - $this->ok = false; - $this->log[] = 'Unable to CHMOD directory: '.$strPath; - return false; - } - } - - + if ( ! @mkdir($strPath,0777) ) + { + $this->ok = false; + $this->log[] = 'Cannot create directory: '.$strPath; + return false; + } + + // CHMOD auf dem Verzeichnis ausgef�hren. + if (!empty($conf['security']['chmod_dir'])) + { + if ( ! @chmod($strPath,octdec($conf['security']['chmod_dir'])) ) + { + $this->ok = false; + $this->log[] = 'Unable to CHMOD directory: '.$strPath; + return false; + } + } + + return $this->ok; } - - /** - * Beenden des Ver�ffentlichungs-Vorganges.<br> - * Eine vorhandene FTP-Verbindung wird geschlossen.<br> - * Falls entsprechend konfiguriert, wird ein Systemkommando ausgef�hrt. + + /** + * Beenden des Ver�ffentlichungs-Vorganges.<br> + * Eine vorhandene FTP-Verbindung wird geschlossen.<br> + * Falls entsprechend konfiguriert, wird ein Systemkommando ausgef�hrt. */ - function close() + public function close() { if ( $this->with_ftp ) { Logger::debug('Closing FTP connection' ); $this->ftp->close(); } - + // Ausfuehren des Systemkommandos. - if ( !empty($this->cmd_after_publish) && $this->ok ) - { - $ausgabe = array(); + if ( !empty($this->cmd_after_publish) && $this->ok ) + { + $ausgabe = array(); $rc = false; Logger::debug('Executing system command: '.$this->cmd_after_publish ); $user = Session::getUser(); putenv("CMS_USER_NAME=".$user->name ); putenv("CMS_USER_ID=" .$user->userid); - putenv("CMS_USER_MAIL=".$user->mail ); - exec( $this->cmd_after_publish,$ausgabe,$rc ); - - if ( $rc != 0 ) // Wenn Returncode ungleich 0, dann Ausgabe ins Log schreiben und Fehler melden. - { - $this->log = $ausgabe; - $this->log[] = 'OpenRat: System command failed - returncode is '.$rc; + putenv("CMS_USER_MAIL=".$user->mail ); + exec( $this->cmd_after_publish,$ausgabe,$rc ); + + if ( $rc != 0 ) // Wenn Returncode ungleich 0, dann Ausgabe ins Log schreiben und Fehler melden. + { + $this->log = $ausgabe; + $this->log[] = 'OpenRat: System command failed - returncode is '.$rc; $this->ok = false; - Logger::warn('System command '.$this->cmd_after_publish.' failed with status '.$rc ); - + Logger::warn('System command '.$this->cmd_after_publish.' failed with status '.$rc ); + } else { Logger::debug('System command successful' ); - } - + } + } } - - /** - * Aufraeumen des Zielverzeichnisses.<br><br> - * Es wird der komplette Zielordner samt Unterverzeichnissen durchsucht. Jede - * Datei, die laenger existiert als der aktuelle Request alt ist, wird geloescht.<br> - * Natuerlich darf diese Funktion nur nach einem Gesamt-Veroeffentlichen ausgefuehrt werden. + + /** + * Aufraeumen des Zielverzeichnisses.<br><br> + * Es wird der komplette Zielordner samt Unterverzeichnissen durchsucht. Jede + * Datei, die laenger existiert als der aktuelle Request alt ist, wird geloescht.<br> + * Natuerlich darf diese Funktion nur nach einem Gesamt-Veroeffentlichen ausgefuehrt werden. */ function clean() - { - if ( $this->ok ) - return; + { + if ( $this->ok ) + return; if ( !empty($this->local_destdir) ) $this->cleanFolder($this->local_destdir); } - - - - /** - * Aufr�umen eines Verzeichnisses.<br><br> - * Dateien, die l�nger existieren als der aktuelle Request alt ist, werden gel�scht.<br> - * - * @param String Verzeichnis + + + + /** + * Aufr�umen eines Verzeichnisses.<br><br> + * Dateien, die l�nger existieren als der aktuelle Request alt ist, werden gel�scht.<br> + * + * @param String Verzeichnis */ function cleanFolder( $folderName ) {