commit ca0beb7d616105143590d6fb3c7f11a074d18c4c
parent 42ec67aa39e543f0b168393ef217937647a469d3
Author: Jan Dankert <develop@jandankert.de>
Date: Fri, 18 Sep 2020 23:04:13 +0200
Refactoring: Renaming module "cms/publish" to "cms/generator"
Diffstat:
59 files changed, 1718 insertions(+), 1718 deletions(-)
diff --git a/modules/cms/action/FileAction.class.php b/modules/cms/action/FileAction.class.php
@@ -6,8 +6,8 @@ use cms\model\Folder;
use cms\model\BaseObject;
use cms\model\File;
-use cms\publish\PublishPreview;
-use cms\publish\PublishPublic;
+use cms\generator\PublishPreview;
+use cms\generator\PublishPublic;
use util\Http;
use util\Html;
use util\Upload;
diff --git a/modules/cms/action/FolderAction.class.php b/modules/cms/action/FolderAction.class.php
@@ -17,7 +17,7 @@ use cms\model\Link;
use cms\model\Text;
use cms\model\Url;
-use cms\publish\PublishPublic;
+use cms\generator\PublishPublic;
use util\Http;
use Publish;
use util\Session;
diff --git a/modules/cms/action/PageAction.class.php b/modules/cms/action/PageAction.class.php
@@ -12,9 +12,9 @@ use cms\model\Folder;
use cms\model\BaseObject;
use cms\model\Language;
use cms\model\Model;
-use cms\publish\PageContext;
-use cms\publish\PublishPreview;
-use cms\publish\PublishPublic;
+use cms\generator\PageContext;
+use cms\generator\PublishPreview;
+use cms\generator\PublishPublic;
use configuration\Config;
use util\Html;
use util\Http;
diff --git a/modules/cms/action/PageelementAction.class.php b/modules/cms/action/PageelementAction.class.php
@@ -11,8 +11,8 @@ use cms\model\Template;
use cms\model\Page;
use cms\model\Folder;
use cms\model\BaseObject;
-use cms\publish\PublishEdit;
-use cms\publish\PublishPreview;
+use cms\generator\PublishEdit;
+use cms\generator\PublishPreview;
use util\Html;
use LogicException;
use util\Transformer;
diff --git a/modules/cms/action/TemplateAction.class.php b/modules/cms/action/TemplateAction.class.php
@@ -11,7 +11,7 @@ use cms\model\Page;
use cms\model\TemplateModel;
-use cms\publish\PublishPublic;
+use cms\generator\PublishPublic;
use util\Session;
use util\Html;
use util\Text;
diff --git a/modules/cms/generator/PageContext.class.php b/modules/cms/generator/PageContext.class.php
@@ -0,0 +1,35 @@
+<?php
+
+
+namespace cms\generator;
+
+
+/**
+ * The page context, necessary for generating and publishing a page.
+ */
+class PageContext
+{
+
+ /**
+ * The source page, links are generated from the view of this page.
+ * @var int
+ */
+ public $sourceObjectId;
+
+ /**
+ * Language.
+ * @var int
+ */
+ public $languageId;
+
+ /**
+ * Model.
+ * @var int
+ */
+ public $modelId;
+
+ public function __construct( $sourceObjectId = null )
+ {
+ $this->sourceObjectId = $sourceObjectId;
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/Publish.class.php b/modules/cms/generator/Publish.class.php
@@ -0,0 +1,41 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+namespace cms\generator;
+
+use cms\model\BaseObject;
+
+/**
+ * Strategy-baseclass for generating and publishing content.
+ *
+ * @author Jan Dankert
+ */
+abstract class Publish
+{
+ abstract public function isPublic();
+
+ abstract public function linkToObject( BaseObject $from, BaseObject $to );
+
+ abstract public function isSimplePreview();
+
+ abstract public function copy($tmp_filename,$dest_filename,$lastChangeDate=null);
+
+ abstract public function clean();
+
+ abstract public function close();
+}
+
diff --git a/modules/cms/generator/PublishEdit.class.php b/modules/cms/generator/PublishEdit.class.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace cms\generator;
+
+use cms\model\BaseObject;
+use cms\model\Link;
+use cms\model\Url;
+
+/**
+ * @author Jan Dankert
+ */
+
+class PublishEdit extends Publish
+{
+ /**
+ * @param $from \cms\model\BaseObject
+ * @param $to \cms\model\BaseObject
+ */
+ public function linkToObject( BaseObject $from, BaseObject $to )
+ {
+ return '->'.$to;
+ }
+
+ public function isPublic()
+ {
+ return false;
+ }
+
+ public function copy($tmp_filename,$dest_filename,$lastChangeDate=null)
+ {
+ // nothing to do.
+ }
+
+ public function clean()
+ {
+ // nothing to do.
+ }
+
+ public function close()
+ {
+ // nothing to do.
+ }
+
+ public function isSimplePreview()
+ {
+ return true;
+ }
+
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/PublishPreview.class.php b/modules/cms/generator/PublishPreview.class.php
@@ -0,0 +1,132 @@
+<?php
+
+namespace cms\generator;
+
+use cms\model\Alias;
+use cms\model\BaseObject;
+use cms\model\Link;
+use cms\model\Url;
+use util\exception\GeneratorException;
+
+/**
+ * Created by PhpStorm.
+ * User: dankert
+ * Date: 10.08.18
+ * Time: 23:47
+ */
+
+class PublishPreview extends Publish
+{
+ /**
+ * @param $from \cms\model\BaseObject
+ * @param $to \cms\model\BaseObject
+ */
+ public function linkToObject( BaseObject $from, BaseObject $to )
+ {
+
+ $param = array(
+ 'oid' => '__OID__'.$to->objectid.'__',
+ REQ_PARAM_MODEL_ID => $from->modelid ,
+ REQ_PARAM_LANGUAGE_ID => $from->languageid );
+
+ if ( $from->icons )
+ $param['withIcons'] = '1';
+
+
+ // Interne Verlinkungen in der Seitenvorschau
+ switch( $to->typeid )
+ {
+ case BaseObject::TYPEID_FILE:
+ case BaseObject::TYPEID_IMAGE:
+ case BaseObject::TYPEID_TEXT:
+ $inhalt = \util\Html::url('file','show',$to->objectid,$param);
+ break;
+ case BaseObject::TYPEID_PAGE:
+ $inhalt = \util\Html::url('page','show',$to->objectid,$param);
+ break;
+
+ case BaseObject::TYPEID_LINK:
+ $link = new Link( $to->objectid );
+ $link->load();
+
+ $linkedObject = new BaseObject( $link->linkedObjectId );
+ $linkedObject->objectLoad();
+
+ switch( $linkedObject->typeid )
+ {
+ case BaseObject::TYPEID_FILE:
+ $inhalt = \util\Html::url('file','show',$link->linkedObjectId,$param);
+ break;
+
+ case BaseObject::TYPEID_PAGE:
+ $inhalt = \util\Html::url('page','show',$link->linkedObjectId,$param);
+ break;
+ case BaseObject::TYPEID_URL:
+ $inhalt = \util\Html::url('url','show',$link->linkedObjectId,$param);
+ break;
+ default:
+ $inhalt = 'Unknown link type: '.$linkedObject->typeid;
+ }
+ break;
+
+ case BaseObject::TYPEID_ALIAS:
+ $alias = new Alias( $to->objectid );
+ $alias->load();
+ $alias->linkedObjectId;
+
+ $linkedObject = new BaseObject( $alias->linkedObjectId );
+ $linkedObject->objectLoad();
+
+ switch( $linkedObject->typeid )
+ {
+ case BaseObject::TYPEID_FILE:
+ $inhalt = \util\Html::url('file','show',$alias->linkedObjectId,$param);
+ break;
+
+ case BaseObject::TYPEID_PAGE:
+ $inhalt = \util\Html::url('page','show',$alias->linkedObjectId,$param);
+ break;
+ default:
+ $inhalt = 'Unknown link type: '.$linkedObject->typeid;
+ }
+ break;
+
+ case BaseObject::TYPEID_URL:
+ $url = new Url( $to->objectid );
+ $url->load();
+ $inhalt = $url->url;
+
+ break;
+ default:
+ throw new GeneratorException('Unknown type '.$to->typeid.' in target '.$to->__toString() );
+
+ }
+
+ return $inhalt;
+
+ }
+
+ public function isPublic()
+ {
+ return false;
+ }
+
+ public function copy($tmp_filename,$dest_filename,$lastChangeDate=null)
+ {
+ // nothing to do.
+ }
+
+ public function clean()
+ {
+ // nothing to do.
+ }
+
+ public function close()
+ {
+ // nothing to do.
+ }
+ public function isSimplePreview()
+ {
+ return false;
+ }
+}
diff --git a/modules/cms/generator/PublishPublic.class.php b/modules/cms/generator/PublishPublic.class.php
@@ -0,0 +1,389 @@
+<?php
+
+namespace cms\generator;
+
+use cms\model\BaseObject;
+use cms\model\File;
+use cms\model\Folder;
+use cms\model\Link;
+use cms\model\Page;
+use cms\model\Project;
+use cms\model\Url;
+use cms\generator\target\Dav;
+use cms\generator\target\Fax;
+use cms\generator\target\Ftp;
+use cms\generator\target\Ftps;
+use cms\generator\target\Local;
+use cms\generator\target\NoTarget;
+use cms\generator\target\Scp;
+use cms\generator\target\SFtp;
+use cms\generator\target\Target;
+use util\exception\PublisherException;
+use util\FileUtils;
+use logger\Logger;
+use util\exception\UIException;
+use util\Session;
+
+
+
+/**
+ * User: dankert
+ * Date: 10.08.18
+ * Time: 23:47
+ */
+
+class PublishPublic extends Publish
+{
+ const SCHEMA_ABSOLUTE = 1;
+ const SCHEMA_RELATIVE = 2;
+
+ const MAX_RECURSIVE_COUNT = 10;
+
+
+ /**
+ * The target to which the file will be copied to.
+ *
+ * @var Target
+ */
+ private $target;
+
+ private $localDestinationDirectory = '';
+
+ /**
+ * Enthaelt die gleichnamige Einstellung aus dem Projekt.
+ * @var boolean
+ */
+ private $contentNegotiation = false;
+
+ /**
+ * Enthaelt die gleichnamige Einstellung aus dem Projekt.
+ * @var boolean
+ */
+ private $cutIndex = false;
+
+ /**
+ * Enthaelt die gleichnamige Einstellung aus dem Projekt.
+ * @var String
+ */
+ private $commandAfterPublish = '';
+
+ /**
+ * Enthaelt am Ende der Ver�ffentlichung ein Array mit den ver�ffentlichten Objekten.
+ * @var Array
+ */
+ public $publishedObjects = array();
+
+ /**
+ * Enthaelt im Fehlerfall (wenn 'ok' auf 'false' steht) eine
+ * Fehlermeldung.
+ *
+ * @var String
+ */
+ public $log = array();
+
+ /**
+ * Konstruktor.<br>
+ * <br>
+ * Oeffnet ggf. Verbindungen.
+ *
+ * @return Publish
+ */
+ public function __construct( $projectid )
+ {
+ $confPublish = config('publish');
+
+ $project = Project::create( $projectid );
+ $project->load();
+
+ $this->linkSchema = ($project->linkAbsolute ? self::SCHEMA_ABSOLUTE : self::SCHEMA_RELATIVE);
+
+ $targetScheme = parse_url( $project->target_dir,PHP_URL_SCHEME );
+
+ $availableTargets = [ Local::class,Ftp::class,Ftps::class,Fax::class,SFtp::class,Scp::class,Dav::class ];
+
+ /** @var Target $target */
+ foreach($availableTargets as $target )
+ {
+ if ( $target::isAvailable() && $target::accepts( $targetScheme ))
+ {
+ $this->target = new $target( $project->target_dir );
+ break;
+ }
+ }
+
+ if ( empty( $this->target ) )
+ throw new PublisherException('Cannot publish to the scheme '.$targetScheme );
+
+ $this->contentNegotiation = ( $project->content_negotiation == '1' );
+ $this->cutIndex = ( $project->cut_index == '1' );
+
+ if ( $confPublish['command']['enable'] )
+ {
+ if ( $confPublish['command']['per_project'] && !empty($project->cmd_after_publish) )
+ $this->commandAfterPublish = $project->cmd_after_publish;
+ else
+ $this->commandAfterPublish = @$confPublish['command']['command'];
+ }
+
+ // Im Systemkommando Variablen ersetzen
+ $this->commandAfterPublish = str_replace('{name}' ,$project->name ,$this->commandAfterPublish);
+ $this->commandAfterPublish = str_replace('{dir}' ,$this->localDestinationDirectory ,$this->commandAfterPublish);
+ $this->commandAfterPublish = str_replace('{dirbase}',basename($this->localDestinationDirectory),$this->commandAfterPublish);
+
+ if ( config('security','nopublish') )
+ {
+ $this->target = new NoTarget();
+ Logger::warn('publishing is disabled.');
+ }
+ }
+
+
+
+ /**
+ * @var int
+ */
+ private $linkSchema;
+
+ /**
+ * @param $from \cms\model\BaseObject
+ * @param $to \cms\model\BaseObject
+ */
+ public function linkToObject( BaseObject $from, BaseObject $to ) {
+
+ $schema = $this->linkSchema;
+
+ $counter = 0;
+ while( $to->typeid == BaseObject::TYPEID_LINK )
+ {
+ if ( $counter++ > self::MAX_RECURSIVE_COUNT)
+ throw new \LogicException("Too much redirects while following a link. Stopped at #".$to->objectid );
+
+ $link = new Link( $to->objectid );
+ $link->load();
+
+ $to = new BaseObject( $link->linkedObjectId );
+ $to->objectLoad();
+ }
+
+ switch( $to->typeid )
+ {
+ case BaseObject::TYPEID_FILE:
+ case BaseObject::TYPEID_IMAGE:
+ case BaseObject::TYPEID_TEXT:
+
+ $f = new File( $to->objectid );
+
+ $p = Project::create( $to->projectid )->load();
+ $f->content_negotiation = $p->content_negotiation;
+
+ $f->load();
+ $filename = $f->filename();
+ break;
+
+ case BaseObject::TYPEID_PAGE:
+
+ $p = new Page( $to->objectid );
+ $p->languageid = $from->languageid;
+ $p->modelid = $from->modelid;
+ $p->cut_index = $from->cut_index;
+ $p->content_negotiation = $from->content_negotiation;
+ $p->withLanguage = $from->withLanguage;
+ $p->withModel = $from->withModel;
+ $p->load();
+ $filename = $p->getFilename();
+ break;
+
+ case BaseObject::TYPEID_URL:
+ $url = new Url( $to->objectid );
+ $url->load();
+ return $url->url;
+ default:
+ throw new \LogicException("Could not build a link to the unknown Type ".$to->typeid.':'.$to->getType() );
+ }
+
+
+ if ( $from->projectid != $to->projectid )
+ {
+ // Target object is in another project.
+ // we have to use absolute URLs.
+ $schema = self::SCHEMA_ABSOLUTE;
+
+ // Target is in another Project. So we have to create an absolute URL.
+ $targetProject = Project::create( $to->projectid )->load();
+ $host = $targetProject->url;
+
+ if ( ! strpos($host,'//' ) === FALSE ) {
+ // No protocol in hostname. So we have to prepend the URL with '//'.
+ $host = '//'.$host;
+ }
+ }
+ else {
+ $host = '';
+ }
+
+
+
+
+ if ( $schema == self::SCHEMA_RELATIVE )
+ {
+ $folder = new Folder( $from->getParentFolderId() );
+ $folder->load();
+ $fromPathFolders = $folder->parentObjectFileNames(false,true);
+
+ $folder = new Folder($to->getParentFolderId() );
+
+ $toPathFolders = $folder->parentObjectFileNames(false, true);
+
+ // Shorten the relative URL
+ // if the actual page is /path/folder1/page1
+ // and the target page is /path/folder2/page2
+ // we shorten the link from ../../path/folder2/page2
+ // to ../folder2/page2
+ foreach( $fromPathFolders as $folderId => $folderFileName ) {
+ if ( count($toPathFolders) >= 1 && array_keys($toPathFolders)[0] == $folderId ) {
+ unset( $fromPathFolders[$folderId] );
+ unset( $toPathFolders [$folderId] );
+ }else {
+ break;
+ }
+
+ }
+
+ if ( $fromPathFolders )
+ $path = str_repeat( '../',count($fromPathFolders) );
+ else
+ $path = './'; // Just to clarify- this could be blank too.
+
+ if ( $toPathFolders )
+ $path .= implode('/',$toPathFolders).'/';
+ }
+ else {
+ // Absolute Pfadangaben
+ $folder = new Folder( $to->getParentFolderId() );
+ $toPathFolders = $folder->parentObjectFileNames(false, true);
+
+ $path = '/';
+
+ if ( $toPathFolders )
+ $path .= implode('/',$toPathFolders).'/';
+ }
+
+
+ $uri = $host . $path . $filename;
+
+ if( !$uri )
+ $uri = '.';
+
+ return $uri;
+ }
+
+
+
+
+
+ /**
+ * 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
+ */
+ public function copy( $tmp_filename,$dest_filename,$lastChangeDate=null )
+ {
+ $this->target->put($tmp_filename,$dest_filename,$lastChangeDate);
+ }
+
+
+
+
+ /**
+ * Beenden des Ver�ffentlichungs-Vorganges.<br>
+ * Eine vorhandene FTP-Verbindung wird geschlossen.<br>
+ * Falls entsprechend konfiguriert, wird ein Systemkommando ausgef�hrt.
+ */
+ public function close()
+ {
+ $this->target->close();
+
+ // Ausfuehren des Systemkommandos.
+ if ( !empty($this->commandAfterPublish) )
+ {
+ $ausgabe = array();
+ $rc = false;
+ Logger::debug('Executing system command: '.Logger::sanitizeInput($this->commandAfterPublish) );
+ $user = Session::getUser();
+ putenv("CMS_USER_NAME=".$user->name );
+ putenv("CMS_USER_ID=" .$user->userid);
+ putenv("CMS_USER_MAIL=".$user->mail );
+
+ exec( $this->commandAfterPublish,$ausgabe,$rc );
+
+ if ( $rc != 0 ) // Wenn Returncode ungleich 0, dann Fehler melden.
+ throw new PublisherException('System command failed - returncode is ' . $rc . "\n" .
+ $ausgabe);
+ 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.
+ */
+ public function clean()
+ {
+ if ( !empty($this->localDestinationDirectory) )
+ $this->cleanFolder($this->localDestinationDirectory);
+ }
+
+
+
+ /**
+ * Aufr�umen eines Verzeichnisses.<br><br>
+ * Dateien, die l�nger existieren als der aktuelle Request alt ist, werden gel�scht.<br>
+ *
+ * @param String Verzeichnis
+ */
+ private function cleanFolder( $folderName )
+ {
+ $dh = opendir( $folderName );
+
+ while( $file = readdir($dh) )
+ {
+ if ( $file != '.' && $file != '..')
+ {
+ $fullpath = $folderName.'/'.$file;
+
+ // Wenn eine Datei beschreibbar und entsprechend alt
+ // ist, dann entfernen
+ if ( is_file($fullpath) &&
+ is_writable($fullpath) &&
+ filemtime($fullpath) < START_TIME )
+ unlink($fullpath);
+
+ // Bei Ordnern rekursiv absteigen
+ if ( is_dir( $fullpath) )
+ {
+ $this->cleanFolder($fullpath);
+ @rmdir($fullpath);
+ }
+ }
+ }
+ }
+
+
+ public function isSimplePreview()
+ {
+ return false;
+ }
+
+ public function isPublic()
+ {
+ return true;
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/README.md b/modules/cms/generator/README.md
@@ -0,0 +1,5 @@
+# Publishing
+
+The Publish objects are used for
+- creating links to other node objects.
+- copying the generated file to a live server.+
\ No newline at end of file
diff --git a/modules/cms/generator/filter/AbstractFilter.class.php b/modules/cms/generator/filter/AbstractFilter.class.php
@@ -0,0 +1,10 @@
+<?php
+
+
+namespace cms\generator\filter;
+
+
+abstract class AbstractFilter
+{
+ public abstract function filter( $value );
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/filter/Base64DecodeFilter.class.php b/modules/cms/generator/filter/Base64DecodeFilter.class.php
@@ -0,0 +1,13 @@
+<?php
+
+
+namespace cms\generator\filter;
+
+
+class Base64DecodeFilter extends AbstractFilter
+{
+ public function filter( $value )
+ {
+ return base64_decode( $value );
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/filter/Base64EncodeFilter.class.php b/modules/cms/generator/filter/Base64EncodeFilter.class.php
@@ -0,0 +1,13 @@
+<?php
+
+
+namespace cms\generator\filter;
+
+
+class Base64EncodeFilter extends AbstractFilter
+{
+ public function filter( $value )
+ {
+ return base64_encode( $value );
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/filter/Csv2HtmlFilter.class.php b/modules/cms/generator/filter/Csv2HtmlFilter.class.php
@@ -0,0 +1,42 @@
+<?php
+
+
+namespace cms\generator\filter;
+
+
+class Csv2HtmlFilter extends AbstractFilter
+{
+ public $withHeader = false;
+ public $delimiter = ';';
+ public $enclosure = '"';
+
+ public function filter( $value )
+ {
+ $outputRow = function( $line, $cellTag) {
+ return "<tr><$cellTag>".implode("</$cellTag><$cellTag>",str_getcsv( $line,$this->delimiter,$this->enclosure ))."</$cellTag></tr>";
+
+ };
+
+ $lines = explode("\n",$value );
+
+ $out = '';
+ $out .= '<table>';
+
+ if ( $this->withHeader && $lines )
+ {
+ $out .= '<thead>';
+ $out .= $outputRow( array_shift($lines),'th');
+ $out .= '</thead>';
+ }
+
+
+ $out .= '<tbody>';
+ foreach( $lines as $line )
+ $out .= $outputRow( $line,'td');
+ $out .= '</tbody>';
+
+ $out .= '</table>';
+
+ return $out;
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/filter/JavascriptMinifierFilter.class.php b/modules/cms/generator/filter/JavascriptMinifierFilter.class.php
@@ -0,0 +1,20 @@
+<?php
+
+
+namespace cms\generator\filter;
+
+
+use util\JSqueeze;
+
+class JavascriptMinifierFilter extends AbstractFilter
+{
+ public $singleLine = true;
+ public $keepImportantComments = true;
+ public $specialVarRx = false;
+
+ public function filter( $value )
+ {
+ $jz = new JSqueeze();
+ return $jz->squeeze( $value, (bool)$this->singleLine, (bool)$this->keepImportantComments, (bool)$this->specialVarRx );
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/filter/LessFilter.class.php b/modules/cms/generator/filter/LessFilter.class.php
@@ -0,0 +1,31 @@
+<?php
+
+
+namespace cms\generator\filter;
+
+
+use \Less_Parser;
+
+class LessFilter extends AbstractFilter
+{
+ public $sourceMap = false;
+ public $indentation = ' ';
+ public $compress = false;
+ public $variables = array();
+
+ public function filter($value)
+ {
+ $parser = new Less_Parser(array(
+ 'sourceMap' => $this->sourceMap,
+ 'indentation' => $this->indentation,
+ 'outputSourceFiles' => false,
+ 'compress' => (bool) $this->compress,
+ ));
+
+ $parser->parse($value);
+
+ $parser->modifyVars( (array) $this->variables );
+
+ return $parser->getCss();
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/filter/README.md b/modules/cms/generator/filter/README.md
@@ -0,0 +1,7 @@
+# Filters
+
+Filters are executed by the CMS after generating a node object.
+
+## Example
+
+A script file is generated and before publishing it should be minified. This is done by the JavascriptMinifierFilter.+
\ No newline at end of file
diff --git a/modules/cms/generator/target/Dav.class.php b/modules/cms/generator/target/Dav.class.php
@@ -0,0 +1,88 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+namespace cms\generator\target;
+
+use logger\Logger;
+use util\exception\PublisherException;
+use util\exception\UIException;
+use util\Url;
+
+
+/**
+ * Publishing a file over WebDAV.
+ *
+ * @author Jan Dankert
+ */
+class Dav extends Target
+{
+ /**
+ * @var false|resource
+ */
+ private $fp;
+
+ public function checkConnection()
+ {
+ $content = "HEAD / HTTP/1.1\r\n";
+ $content .= "Host: ".$this->url->host."\r\n";
+ $content .= "Connection: Close\r\n";
+ $content .= "\r\n";
+
+ fwrite($this->fp, $content );
+ }
+
+
+ public function put($source, $dest, $time)
+ {
+ $content = "PUT $dest HTTP/1.1\r\n";
+ $content .= "Host: ".$this->url->host."\r\n";
+ $content .= "Connection: Close\r\n";
+ $content .= "\r\n";
+
+ fwrite($this->fp, $content);
+ fwrite($this->fp, file_get_contents($source));
+ }
+
+
+ public function mkcol( $dir ) {
+ $content = "MKCOL $dir HTTP/1.1\r\n";
+ $content .= "Host: ".$this->url->host."\r\n";
+ $content .= "Connection: Close\r\n";
+ $content .= "\r\n";
+ fwrite($this->fp, $content);
+ }
+
+ public function close()
+ {
+ fclose($this->fp);
+ }
+
+ protected static function acceptsSchemes()
+ {
+ return ['dav'];
+ }
+
+ public function open()
+ {
+ $this->fp = fsockopen($this->url->host, empty($this->url->port)?80:$this->url->port, $errno, $errstr, 5);
+
+ if(!$this->fp)
+ throw new PublisherException("cannot connect to DAV server: $errno -> $errstr");
+
+ $this->checkConnection();
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/target/Fax.class.php b/modules/cms/generator/target/Fax.class.php
@@ -0,0 +1,57 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+namespace cms\generator\target;
+
+use logger\Logger;
+use util\exception\PublisherException;
+use util\exception\UIException;
+
+
+/**
+ * Publishing a file over fax. Who says that this is not possible?
+ *
+ * @author Jan Dankert
+ */
+class Fax extends Target
+{
+ public function open()
+ {
+ Logger::debug("Dialing ...");
+ }
+
+ public function put($source, $dest, $time)
+ {
+ Logger::debug("düüüüüüüüüüüükrrrkkrkrkrkkrkrkrkr");
+ // very, very funny, right?
+ }
+
+ public function close()
+ {
+ Logger::debug("Hanging up ...");
+ }
+
+ protected static function acceptsSchemes()
+ {
+ return ['fax'];
+ }
+
+ public function __construct($targetUrl)
+ {
+ }
+}
+// ok, this class was a joke.+
\ No newline at end of file
diff --git a/modules/cms/generator/target/Ftp.class.php b/modules/cms/generator/target/Ftp.class.php
@@ -0,0 +1,178 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+namespace cms\generator\target;
+
+use logger\Logger;
+use util\exception\PublisherException;
+use util\exception\UIException;
+
+
+/**
+ * FTP-Target.
+ *
+ * @author Jan Dankert
+ */
+class Ftp extends Target
+{
+ private $connection;
+
+ public static function acceptsSchemes() {
+ return ['ftp'];
+ }
+
+ // Aufbauen der Verbindung
+ public function open()
+ {
+ //global $conf;
+ //$conf_ftp = $conf['publish']['ftp'];
+ $ftp = $this->url;
+
+ // Die projektspezifischen Werte gewinnen bei �berschneidungen mit den Default-Werten
+ //$ftp = array_merge($conf_ftp, $ftp);
+
+ $this->connection = $this->createConnection();
+
+ if (!$this->connection) {
+ Logger::error('Cannot connect to ' . $this->url->host . ':' . $this->url->port);
+ throw new PublisherException('Cannot connect to ' . $this->url->scheme . '-server: ' . $this->url->host . ':' . $this->url->port);
+ }
+
+ if (empty($this->url->user)) {
+ $ftp['user'] = 'anonymous';
+ $ftp['pass'] = 'openrat@openrat.de';
+ }
+
+ if (!ftp_login($this->connection, $this->url->user, $this->url->pass))
+ throw new PublisherException('Unable to login as user ' . $this->url->user);
+
+ $pasv = $this->url->fragment == 'passive';
+
+ if ( $pasv )
+ if (!ftp_pasv($this->connection, true))
+ throw new PublisherException('Cannot switch to FTP PASV mode');
+
+ if ( $this->url->query ) {
+ parse_str($this->url->query, $ftp_var);
+
+ if (isset($ftp_var['site'])) {
+ $site_commands = explode(',', $ftp_var['site']);
+ foreach ($site_commands as $cmd) {
+ if (!@ftp_site($this->connection, $cmd))
+ throw new PublisherException('unable to do SITE command: ' . $cmd);
+ }
+ }
+ }
+
+ $path = rtrim($this->url->path, '/');
+
+ if (!@ftp_chdir($this->connection, $path))
+ throw new PublisherException('unable CHDIR to directory: ' . $path);
+ }
+
+
+ /**
+ * Kopieren einer Datei vom lokalen System auf den FTP-Server.
+ *
+ * @param String Quelle
+ * @param String Ziel
+ * @param int FTP-Mode (BINARY oder ASCII)
+ */
+ public function put($source, $dest, $lastChangeDate)
+ {
+ $dest = $this->url->path . '/' . $dest;
+
+ //$this->log .= "Copying file: $source -> $dest ...\n";
+
+ $mode = FTP_BINARY;
+ $p = strrpos(basename($dest), '.'); // Letzten Punkt suchen
+
+ if ($p !== false) // Wennn letzten Punkt gefunden, dann dort aufteilen
+ {
+ $extension = substr(basename($dest), $p + 1);
+ $type = config('mime-types', $extension);
+ if (substr($type, 0, 5) == 'text/')
+ $mode = FTP_ASCII;
+ }
+
+ Logger::debug("FTP PUT target:$dest mode:" . (($mode == FTP_ASCII) ? 'ascii' : 'binary'));
+
+ if (!@ftp_put($this->connection, $dest, $source, $mode)) {
+ if (!$this->mkdirs(dirname($dest)))
+ return; // Fehler.
+
+ ftp_chdir($this->connection, $this->url->path);
+
+ if (!@ftp_put($this->connection, $dest, $source, $mode))
+ throw new PublisherException("FTP PUT failed.\n" .
+ "source : $source\n" .
+ "destination: $dest");
+
+ }
+ }
+
+
+ /**
+ * Private Methode zum rekursiven Anlegen von Verzeichnissen.
+ *
+ * @param String Pfad
+ * @return boolean true, wenn ok
+ */
+ private function mkdirs($strPath)
+ {
+ if (@ftp_chdir($this->connection, $strPath))
+ return true; // Verzeichnis existiert schon :)
+
+ $pStrPath = dirname($strPath);
+
+ if (!$this->mkdirs($pStrPath))
+ return false;
+
+ if (!@ftp_mkdir($this->connection, $strPath))
+ throw new PublisherException("failed to create remote directory: $strPath");
+
+ return true;
+ }
+
+
+ /**
+ * Schliessen der FTP-Verbindung.<br>
+ * Sollte unbedingt aufgerufen werden, damit keine unn�tigen Sockets aufbleiben.
+ */
+ public function close()
+ {
+ if (!@ftp_quit($this->connection)) {
+ // Closing not possible.
+ // Only logging. Maybe we could throw an Exception here?
+ Logger::warn('Failed to close FTP connection. Continueing...');
+ return;
+ }
+ }
+
+ protected function createConnection()
+ {
+ return ftp_connect($this->url->host, $this->url->port);
+ }
+
+ public static function isAvailable()
+ {
+ return function_exists('ftp_connect');
+ }
+}
+
+
+?>+
\ No newline at end of file
diff --git a/modules/cms/generator/target/Ftps.class.php b/modules/cms/generator/target/Ftps.class.php
@@ -0,0 +1,53 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+namespace cms\generator\target;
+
+use logger\Logger;
+use util\exception\PublisherException;
+use util\exception\UIException;
+
+
+/**
+ * Publishing via FTPS.
+ *
+ * @author Jan Dankert
+ */
+class Ftps extends Ftp
+{
+ public static function acceptsSchemes() {
+ return ['ftps'];
+ }
+
+ /**
+ * Creates a new connection.
+ *
+ * @param $ftp
+ * @return false|resource
+ */
+ protected function createConnection()
+ {
+ return ftp_ssl_connect($this->url->host, $this->url->port);
+ }
+
+
+ public static function isAvailable()
+ {
+ return function_exists('ftp_ssl_connect');
+
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/target/Local.class.php b/modules/cms/generator/target/Local.class.php
@@ -0,0 +1,152 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+namespace cms\generator\target;
+
+use logger\Logger;
+use util\exception\PublisherException;
+use util\exception\UIException;
+use util\FileUtils;
+use util\Url;
+
+
+/**
+ * Publishing to the local filesystem.
+ *
+ * @author Jan Dankert
+ */
+class Local extends Target
+{
+ /**
+ * @var string
+ */
+ private $localDestinationDirectory;
+
+ public static function acceptsSchemes() {
+ return ['file',''];
+ }
+
+
+ /**
+ * @param $url Url
+ */
+ public function open()
+ {
+ $confPublish = config('publish');
+
+ $targetDir = rtrim( $this->url->path,'/' );
+
+ if ( FileUtils::isAbsolutePath($targetDir) && $confPublish['filesystem']['per_project'] )
+ {
+ $this->localDestinationDirectory = FileUtils::toAbsolutePath([$targetDir]); // Projekteinstellung verwenden.
+ }
+ else
+ {
+ // Konfiguriertes Verzeichnis verwenden.
+ $this->localDestinationDirectory = FileUtils::toAbsolutePath([$confPublish['filesystem']['directory'],$targetDir]);
+ }
+
+
+ // Sofort pruefen, ob das Zielverzeichnis ueberhaupt beschreibbar ist.
+ if ( $this->localDestinationDirectory && $this->localDestinationDirectory[0] == '#')
+ $this->localDestinationDirectory = '';
+
+ }
+
+ /**
+ * Copying a file to local filesystem.
+ *
+ * @param String Quelle
+ * @param String Ziel
+ */
+ public function put($source, $dest, $lastChangeDate)
+ {
+ global $conf;
+
+ // Is the output directory writable?
+ if ( !is_writeable( $this->localDestinationDirectory ) )
+ throw new PublisherException('directory not writable: ' . $this->localDestinationDirectory);
+
+ $dest = $this->localDestinationDirectory.'/'.$dest;
+
+ // Is the destination writable?
+ if ( is_file($dest) && !is_writeable( $dest ) )
+ throw new PublisherException('file not writable: ' . $dest);
+
+ // Copy file to destination
+ if (!@copy( $source,$dest ));
+ {
+ // Create directories, if necessary.
+ $this->mkdirs( dirname($dest) );
+
+ if (!@copy( $source,$dest ))
+ throw new PublisherException( 'failed copying local file:' . "\n" .
+ 'source : ' . $source . "\n" .
+ 'destination: ' . $dest);
+
+ // Das Änderungsdatum der Datei auch in der Zieldatei setzen.
+ if ( $conf['publish']['set_modification_date'] )
+ if ( ! is_null($lastChangeDate) )
+ @touch( $dest,$lastChangeDate );
+
+ Logger::debug("published: $dest");
+ }
+
+ if (!empty($conf['security']['chmod']))
+ {
+ // CHMOD auf der Datei ausfuehren.
+ if ( ! @chmod($dest,octdec($conf['security']['chmod'])) )
+ throw new PublisherException('Unable to CHMOD file ' . $dest);
+ }
+
+ }
+
+
+
+ /**
+ * 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
+ */
+ private function mkdirs($path )
+ {
+ global $conf;
+
+ if ( is_dir($path) )
+ return; // Path exists
+
+ $parentPath = dirname($path);
+
+ $this->mkdirs($parentPath);
+
+ //
+ if ( ! @mkdir($path) )
+ throw new PublisherException( 'Cannot create directory: ' . $path);
+
+ // CHMOD auf dem Verzeichnis ausgef�hren.
+ if (!empty($conf['security']['chmod_dir']))
+ {
+ if ( ! @chmod($path,octdec($conf['security']['chmod_dir'])) )
+ throw new PublisherException('Unable to CHMOD directory: ' . $path);
+ }
+ }
+
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/target/NoTarget.class.php b/modules/cms/generator/target/NoTarget.class.php
@@ -0,0 +1,46 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+namespace cms\generator\target;
+
+use logger\Logger;
+use util\exception\PublisherException;
+use util\exception\UIException;
+
+
+/**
+ * Empty target.
+ *
+ * @author Jan Dankert
+ */
+class NoTarget extends Target
+{
+ public static function acceptsSchemes()
+ {
+ return ['null', 'example'];
+ }
+
+ public function put($source, $dest, $lastChangeDate)
+ {
+ // Do nothing.
+ }
+
+ public function __construct($targetUrl)
+ {
+
+ }
+}+
\ No newline at end of file
diff --git a/modules/cms/generator/target/README.md b/modules/cms/generator/target/README.md
@@ -0,0 +1,24 @@
+# Targets
+
+While publishing files and pages are pushed to a target.
+
+Possible publishing targets are
+- Local filesystem
+- FTP,FTPS
+- WebDAV
+- SCP
+- SFTP
+
+The corresponding scheme names are
+- `file`
+- `ftp`
+- `ftps`
+- `dav`
+- `scp`
+- `sftp`
+
+The target is selected by the scheme in the target url in the project properties.
+
+## Example
+
+`scp://user@host/var/www` is publishing all files via SCP to the SSH-Server on host 'host'. +
\ No newline at end of file
diff --git a/modules/cms/generator/target/SFtp.class.php b/modules/cms/generator/target/SFtp.class.php
@@ -0,0 +1,112 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+namespace cms\generator\target;
+
+use logger\Logger;
+use util\exception\PublisherException;
+use util\exception\UIException;
+
+
+/**
+ * Darstellen einer FTP-Verbindung, das beinhaltet
+ * das Login, das Kopieren von Dateien sowie praktische
+ * FTP-Funktionen
+ *
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.services
+ */
+class SFtp extends Scp
+{
+ /**
+ * @var resource
+ */
+ protected $sftpConnection;
+
+
+ public static function acceptsSchemes() {
+ return ['sftp'];
+ }
+
+ // Aufbauen der Verbindung
+ public function open()
+ {
+ global $conf;
+
+ //$conf_ftp = $conf['publish']['sftp'];
+
+ // Die projektspezifischen Werte gewinnen bei �berschneidungen mit den Default-Werten
+ //$sftp = array_merge($conf_ftp, $sftp);
+
+
+ $this->createConnection();
+
+ $this->sftpConnection = @ssh2_sftp($this->sshConnection);
+
+ if (! $this->sftpConnection)
+ throw new PublisherException("Could not initialize SFTP subsystem.");
+
+ }
+
+
+ /**
+ * Kopieren einer Datei vom lokalen System auf den SFTP-Server.
+ *
+ * @param String Quelle
+ * @param String Ziel
+ * @param int time)
+ */
+ public function put($source, $dest, $lastChangeDate)
+ {
+ $dest = $this->url->path . '/' . $dest;
+
+ $sftp = $this->sftpConnection;
+
+ $stream = @fopen("ssh2.sftp://$sftp$dest", 'w');
+
+ if (! $stream)
+ throw new PublisherException("Could not create SFTP-Stream on file: $dest");
+
+ $data_to_send = @file_get_contents($source);
+
+ if ($data_to_send === false)
+ throw new PublisherException("Could not open local file: $source");
+
+ if (@fwrite($stream, $data_to_send) === false)
+ throw new PublisherException("Could not send data from file: $source.");
+
+ @fclose($stream);
+ }
+
+
+ /**
+ * Schliessen der FTP-Verbindung.<br>
+ * Sollte unbedingt aufgerufen werden, damit keine unn�tigen Sockets aufbleiben.
+ */
+ public function close()
+ {
+ parent::close();
+ }
+
+
+ public static function isAvailable()
+ {
+ return parent::isAvailable() && function_exists('ssh2_sftp');
+ }
+}
+
diff --git a/modules/cms/generator/target/Scp.class.php b/modules/cms/generator/target/Scp.class.php
@@ -0,0 +1,104 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+namespace cms\generator\target;
+
+use logger\Logger;
+use util\exception\PublisherException;
+use util\exception\UIException;
+
+
+/**
+ * Darstellen einer FTP-Verbindung, das beinhaltet
+ * das Login, das Kopieren von Dateien sowie praktische
+ * FTP-Funktionen
+ *
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.services
+ */
+class Scp extends Target
+{
+ /**
+ * @var resource
+ */
+ protected $sshConnection;
+
+ public static function acceptsSchemes() {
+ return ['scp'];
+ }
+
+ // Aufbauen der Verbindung
+ public function open()
+ {
+ $this->sshConnection = $this->createConnection();
+ }
+
+
+
+ protected function createConnection() {
+
+ $sshConnection = @ssh2_connect($this->url->host,$this->url->port );
+
+ if (! $sshConnection)
+ throw new PublisherException("Could not connect to ".$this->url );
+
+
+ if (! @ssh2_auth_password($sshConnection, $this->url->user,$this->url->pass) )
+ throw new PublisherException("Could not authenticate");
+
+ $this->sshConnection = $sshConnection;
+
+ return $sshConnection;
+ }
+
+
+
+ /**
+ * Kopieren einer Datei vom lokalen System auf den FTP-Server.
+ *
+ * @param String Quelle
+ * @param String Ziel
+ * @param int FTP-Mode (BINARY oder ASCII)
+ */
+ public function put($source, $dest, $lastChangeDate)
+ {
+ $dest = $this->url->path . '/' . $dest;
+
+
+ ssh2_scp_send($this->sshConnection, $source, $dest, 0644);
+ }
+
+
+ /**
+ * Schliessen der FTP-Verbindung.<br>
+ * Sollte unbedingt aufgerufen werden, damit keine unn�tigen Sockets aufbleiben.
+ */
+ public function close()
+ {
+ ssh2_disconnect($this->sshConnection);
+ }
+
+
+ public static function isAvailable()
+ {
+ return function_exists('ssh2_connect');
+ }
+}
+
+
+?>+
\ No newline at end of file
diff --git a/modules/cms/generator/target/Target.class.php b/modules/cms/generator/target/Target.class.php
@@ -0,0 +1,79 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+namespace cms\generator\target;
+
+use logger\Logger;
+use util\exception\PublisherException;
+use util\exception\UIException;
+use util\Url;
+
+
+/**
+ * Superclass for publication targets.
+ *
+ * @author Jan Dankert
+ */
+abstract class Target
+{
+ /**
+ * @var Url
+ */
+ protected $url;
+
+ public function __construct( $targetUrl ) {
+ $this->url = new Url( $targetUrl );
+
+ $this->open();
+ }
+
+
+ public static function accepts( $scheme ) {
+ return in_array( $scheme, static::acceptsSchemes() );
+ }
+
+
+ /**
+ * For which types this target is reponsible?
+ *
+ * @return array
+ */
+ protected abstract static function acceptsSchemes();
+
+
+ public function open() {
+
+ }
+
+
+ public abstract function put($source, $dest, $timestamp);
+
+
+ /**
+ * Closes the connection.
+ */
+ public function close() {
+
+ }
+
+
+ public static function isAvailable() {
+
+ return true;
+ }
+
+}
diff --git a/modules/cms/macros/macro/SearchIndex.class.php b/modules/cms/macros/macro/SearchIndex.class.php
@@ -5,7 +5,7 @@ use cms\model\Folder;
use cms\model\Name;
use cms\model\Page;
use cms\model\Project;
-use cms\publish\PublishEdit;
+use cms\generator\PublishEdit;
use util\Macro;
diff --git a/modules/cms/model/BaseObject.class.php b/modules/cms/model/BaseObject.class.php
@@ -4,7 +4,7 @@
namespace cms\model;
use util\ArrayUtils;
-use cms\publish\Publish;
+use cms\generator\Publish;
use phpseclib\Math\BigInteger;
use util\text\variables\VariableResolver;
use util\YAML;
diff --git a/modules/cms/model/File.class.php b/modules/cms/model/File.class.php
@@ -19,8 +19,8 @@ namespace cms\model;
// Standard Mime-Type
-use cms\publish\filter\AbstractFilter;
-use cms\publish\PublishPublic;
+use cms\generator\filter\AbstractFilter;
+use cms\generator\PublishPublic;
use logger\Logger;
use util\cache\FileCache;
diff --git a/modules/cms/model/Folder.class.php b/modules/cms/model/Folder.class.php
@@ -2,7 +2,7 @@
namespace cms\model;
-use cms\publish\Publish;
+use cms\generator\Publish;
use Exception;
diff --git a/modules/cms/model/Page.class.php b/modules/cms/model/Page.class.php
@@ -16,11 +16,11 @@ namespace cms\model;
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-use cms\publish\PageContext;
+use cms\generator\PageContext;
use Exception;
use util\exception\GeneratorException;
use util\Mustache;
-use cms\publish\PublishPreview;use cms\publish\PublishPublic;
+use cms\generator\PublishPreview;use cms\generator\PublishPublic;
use http\Exception\RuntimeException;
use logger\Logger;
use util\cache\FileCache;
diff --git a/modules/cms/model/Pageelement.class.php b/modules/cms/model/Pageelement.class.php
@@ -17,7 +17,7 @@ namespace cms\model;
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
use cms\mustache\Mustache;
-use cms\publish\PublishPreview;use cms\publish\PublishPublic;
+use cms\generator\PublishPreview;use cms\generator\PublishPublic;
use logger\Logger;
use util\cache\FileCache;
diff --git a/modules/cms/model/Value.class.php b/modules/cms/model/Value.class.php
@@ -1,7 +1,7 @@
<?php
namespace cms\model;
use util\ArrayUtils;
-use cms\publish\Publish;
+use cms\generator\Publish;
use cms\macros\MacroRunner;
use \ObjectNotFoundException;
use logger\Logger;
diff --git a/modules/cms/publish/PageContext.class.php b/modules/cms/publish/PageContext.class.php
@@ -1,35 +0,0 @@
-<?php
-
-
-namespace cms\publish;
-
-
-/**
- * The page context, necessary for generating and publishing a page.
- */
-class PageContext
-{
-
- /**
- * The source page, links are generated from the view of this page.
- * @var int
- */
- public $sourceObjectId;
-
- /**
- * Language.
- * @var int
- */
- public $languageId;
-
- /**
- * Model.
- * @var int
- */
- public $modelId;
-
- public function __construct( $sourceObjectId = null )
- {
- $this->sourceObjectId = $sourceObjectId;
- }
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/Publish.class.php b/modules/cms/publish/Publish.class.php
@@ -1,41 +0,0 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-namespace cms\publish;
-
-use cms\model\BaseObject;
-
-/**
- * Strategy-baseclass for generating and publishing content.
- *
- * @author Jan Dankert
- */
-abstract class Publish
-{
- abstract public function isPublic();
-
- abstract public function linkToObject( BaseObject $from, BaseObject $to );
-
- abstract public function isSimplePreview();
-
- abstract public function copy($tmp_filename,$dest_filename,$lastChangeDate=null);
-
- abstract public function clean();
-
- abstract public function close();
-}
-
diff --git a/modules/cms/publish/PublishEdit.class.php b/modules/cms/publish/PublishEdit.class.php
@@ -1,49 +0,0 @@
-<?php
-
-namespace cms\publish;
-
-use cms\model\BaseObject;
-use cms\model\Link;
-use cms\model\Url;
-
-/**
- * @author Jan Dankert
- */
-
-class PublishEdit extends Publish
-{
- /**
- * @param $from \cms\model\BaseObject
- * @param $to \cms\model\BaseObject
- */
- public function linkToObject( BaseObject $from, BaseObject $to )
- {
- return '->'.$to;
- }
-
- public function isPublic()
- {
- return false;
- }
-
- public function copy($tmp_filename,$dest_filename,$lastChangeDate=null)
- {
- // nothing to do.
- }
-
- public function clean()
- {
- // nothing to do.
- }
-
- public function close()
- {
- // nothing to do.
- }
-
- public function isSimplePreview()
- {
- return true;
- }
-
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/PublishPreview.class.php b/modules/cms/publish/PublishPreview.class.php
@@ -1,132 +0,0 @@
-<?php
-
-namespace cms\publish;
-
-use cms\model\Alias;
-use cms\model\BaseObject;
-use cms\model\Link;
-use cms\model\Url;
-use util\exception\GeneratorException;
-
-/**
- * Created by PhpStorm.
- * User: dankert
- * Date: 10.08.18
- * Time: 23:47
- */
-
-class PublishPreview extends Publish
-{
- /**
- * @param $from \cms\model\BaseObject
- * @param $to \cms\model\BaseObject
- */
- public function linkToObject( BaseObject $from, BaseObject $to )
- {
-
- $param = array(
- 'oid' => '__OID__'.$to->objectid.'__',
- REQ_PARAM_MODEL_ID => $from->modelid ,
- REQ_PARAM_LANGUAGE_ID => $from->languageid );
-
- if ( $from->icons )
- $param['withIcons'] = '1';
-
-
- // Interne Verlinkungen in der Seitenvorschau
- switch( $to->typeid )
- {
- case BaseObject::TYPEID_FILE:
- case BaseObject::TYPEID_IMAGE:
- case BaseObject::TYPEID_TEXT:
- $inhalt = \util\Html::url('file','show',$to->objectid,$param);
- break;
- case BaseObject::TYPEID_PAGE:
- $inhalt = \util\Html::url('page','show',$to->objectid,$param);
- break;
-
- case BaseObject::TYPEID_LINK:
- $link = new Link( $to->objectid );
- $link->load();
-
- $linkedObject = new BaseObject( $link->linkedObjectId );
- $linkedObject->objectLoad();
-
- switch( $linkedObject->typeid )
- {
- case BaseObject::TYPEID_FILE:
- $inhalt = \util\Html::url('file','show',$link->linkedObjectId,$param);
- break;
-
- case BaseObject::TYPEID_PAGE:
- $inhalt = \util\Html::url('page','show',$link->linkedObjectId,$param);
- break;
- case BaseObject::TYPEID_URL:
- $inhalt = \util\Html::url('url','show',$link->linkedObjectId,$param);
- break;
- default:
- $inhalt = 'Unknown link type: '.$linkedObject->typeid;
- }
- break;
-
- case BaseObject::TYPEID_ALIAS:
- $alias = new Alias( $to->objectid );
- $alias->load();
- $alias->linkedObjectId;
-
- $linkedObject = new BaseObject( $alias->linkedObjectId );
- $linkedObject->objectLoad();
-
- switch( $linkedObject->typeid )
- {
- case BaseObject::TYPEID_FILE:
- $inhalt = \util\Html::url('file','show',$alias->linkedObjectId,$param);
- break;
-
- case BaseObject::TYPEID_PAGE:
- $inhalt = \util\Html::url('page','show',$alias->linkedObjectId,$param);
- break;
- default:
- $inhalt = 'Unknown link type: '.$linkedObject->typeid;
- }
- break;
-
- case BaseObject::TYPEID_URL:
- $url = new Url( $to->objectid );
- $url->load();
- $inhalt = $url->url;
-
- break;
- default:
- throw new GeneratorException('Unknown type '.$to->typeid.' in target '.$to->__toString() );
-
- }
-
- return $inhalt;
-
- }
-
- public function isPublic()
- {
- return false;
- }
-
- public function copy($tmp_filename,$dest_filename,$lastChangeDate=null)
- {
- // nothing to do.
- }
-
- public function clean()
- {
- // nothing to do.
- }
-
- public function close()
- {
- // nothing to do.
- }
- public function isSimplePreview()
- {
- return false;
- }
-}
diff --git a/modules/cms/publish/PublishPublic.class.php b/modules/cms/publish/PublishPublic.class.php
@@ -1,389 +0,0 @@
-<?php
-
-namespace cms\publish;
-
-use cms\model\BaseObject;
-use cms\model\File;
-use cms\model\Folder;
-use cms\model\Link;
-use cms\model\Page;
-use cms\model\Project;
-use cms\model\Url;
-use cms\publish\target\Dav;
-use cms\publish\target\Fax;
-use cms\publish\target\Ftp;
-use cms\publish\target\Ftps;
-use cms\publish\target\Local;
-use cms\publish\target\NoTarget;
-use cms\publish\target\Scp;
-use cms\publish\target\SFtp;
-use cms\publish\target\Target;
-use util\exception\PublisherException;
-use util\FileUtils;
-use logger\Logger;
-use util\exception\UIException;
-use util\Session;
-
-
-
-/**
- * User: dankert
- * Date: 10.08.18
- * Time: 23:47
- */
-
-class PublishPublic extends Publish
-{
- const SCHEMA_ABSOLUTE = 1;
- const SCHEMA_RELATIVE = 2;
-
- const MAX_RECURSIVE_COUNT = 10;
-
-
- /**
- * The target to which the file will be copied to.
- *
- * @var Target
- */
- private $target;
-
- private $localDestinationDirectory = '';
-
- /**
- * Enthaelt die gleichnamige Einstellung aus dem Projekt.
- * @var boolean
- */
- private $contentNegotiation = false;
-
- /**
- * Enthaelt die gleichnamige Einstellung aus dem Projekt.
- * @var boolean
- */
- private $cutIndex = false;
-
- /**
- * Enthaelt die gleichnamige Einstellung aus dem Projekt.
- * @var String
- */
- private $commandAfterPublish = '';
-
- /**
- * Enthaelt am Ende der Ver�ffentlichung ein Array mit den ver�ffentlichten Objekten.
- * @var Array
- */
- public $publishedObjects = array();
-
- /**
- * Enthaelt im Fehlerfall (wenn 'ok' auf 'false' steht) eine
- * Fehlermeldung.
- *
- * @var String
- */
- public $log = array();
-
- /**
- * Konstruktor.<br>
- * <br>
- * Oeffnet ggf. Verbindungen.
- *
- * @return Publish
- */
- public function __construct( $projectid )
- {
- $confPublish = config('publish');
-
- $project = Project::create( $projectid );
- $project->load();
-
- $this->linkSchema = ($project->linkAbsolute ? self::SCHEMA_ABSOLUTE : self::SCHEMA_RELATIVE);
-
- $targetScheme = parse_url( $project->target_dir,PHP_URL_SCHEME );
-
- $availableTargets = [ Local::class,Ftp::class,Ftps::class,Fax::class,SFtp::class,Scp::class,Dav::class ];
-
- /** @var Target $target */
- foreach($availableTargets as $target )
- {
- if ( $target::isAvailable() && $target::accepts( $targetScheme ))
- {
- $this->target = new $target( $project->target_dir );
- break;
- }
- }
-
- if ( empty( $this->target ) )
- throw new PublisherException('Cannot publish to the scheme '.$targetScheme );
-
- $this->contentNegotiation = ( $project->content_negotiation == '1' );
- $this->cutIndex = ( $project->cut_index == '1' );
-
- if ( $confPublish['command']['enable'] )
- {
- if ( $confPublish['command']['per_project'] && !empty($project->cmd_after_publish) )
- $this->commandAfterPublish = $project->cmd_after_publish;
- else
- $this->commandAfterPublish = @$confPublish['command']['command'];
- }
-
- // Im Systemkommando Variablen ersetzen
- $this->commandAfterPublish = str_replace('{name}' ,$project->name ,$this->commandAfterPublish);
- $this->commandAfterPublish = str_replace('{dir}' ,$this->localDestinationDirectory ,$this->commandAfterPublish);
- $this->commandAfterPublish = str_replace('{dirbase}',basename($this->localDestinationDirectory),$this->commandAfterPublish);
-
- if ( config('security','nopublish') )
- {
- $this->target = new NoTarget();
- Logger::warn('publishing is disabled.');
- }
- }
-
-
-
- /**
- * @var int
- */
- private $linkSchema;
-
- /**
- * @param $from \cms\model\BaseObject
- * @param $to \cms\model\BaseObject
- */
- public function linkToObject( BaseObject $from, BaseObject $to ) {
-
- $schema = $this->linkSchema;
-
- $counter = 0;
- while( $to->typeid == BaseObject::TYPEID_LINK )
- {
- if ( $counter++ > self::MAX_RECURSIVE_COUNT)
- throw new \LogicException("Too much redirects while following a link. Stopped at #".$to->objectid );
-
- $link = new Link( $to->objectid );
- $link->load();
-
- $to = new BaseObject( $link->linkedObjectId );
- $to->objectLoad();
- }
-
- switch( $to->typeid )
- {
- case BaseObject::TYPEID_FILE:
- case BaseObject::TYPEID_IMAGE:
- case BaseObject::TYPEID_TEXT:
-
- $f = new File( $to->objectid );
-
- $p = Project::create( $to->projectid )->load();
- $f->content_negotiation = $p->content_negotiation;
-
- $f->load();
- $filename = $f->filename();
- break;
-
- case BaseObject::TYPEID_PAGE:
-
- $p = new Page( $to->objectid );
- $p->languageid = $from->languageid;
- $p->modelid = $from->modelid;
- $p->cut_index = $from->cut_index;
- $p->content_negotiation = $from->content_negotiation;
- $p->withLanguage = $from->withLanguage;
- $p->withModel = $from->withModel;
- $p->load();
- $filename = $p->getFilename();
- break;
-
- case BaseObject::TYPEID_URL:
- $url = new Url( $to->objectid );
- $url->load();
- return $url->url;
- default:
- throw new \LogicException("Could not build a link to the unknown Type ".$to->typeid.':'.$to->getType() );
- }
-
-
- if ( $from->projectid != $to->projectid )
- {
- // Target object is in another project.
- // we have to use absolute URLs.
- $schema = self::SCHEMA_ABSOLUTE;
-
- // Target is in another Project. So we have to create an absolute URL.
- $targetProject = Project::create( $to->projectid )->load();
- $host = $targetProject->url;
-
- if ( ! strpos($host,'//' ) === FALSE ) {
- // No protocol in hostname. So we have to prepend the URL with '//'.
- $host = '//'.$host;
- }
- }
- else {
- $host = '';
- }
-
-
-
-
- if ( $schema == self::SCHEMA_RELATIVE )
- {
- $folder = new Folder( $from->getParentFolderId() );
- $folder->load();
- $fromPathFolders = $folder->parentObjectFileNames(false,true);
-
- $folder = new Folder($to->getParentFolderId() );
-
- $toPathFolders = $folder->parentObjectFileNames(false, true);
-
- // Shorten the relative URL
- // if the actual page is /path/folder1/page1
- // and the target page is /path/folder2/page2
- // we shorten the link from ../../path/folder2/page2
- // to ../folder2/page2
- foreach( $fromPathFolders as $folderId => $folderFileName ) {
- if ( count($toPathFolders) >= 1 && array_keys($toPathFolders)[0] == $folderId ) {
- unset( $fromPathFolders[$folderId] );
- unset( $toPathFolders [$folderId] );
- }else {
- break;
- }
-
- }
-
- if ( $fromPathFolders )
- $path = str_repeat( '../',count($fromPathFolders) );
- else
- $path = './'; // Just to clarify- this could be blank too.
-
- if ( $toPathFolders )
- $path .= implode('/',$toPathFolders).'/';
- }
- else {
- // Absolute Pfadangaben
- $folder = new Folder( $to->getParentFolderId() );
- $toPathFolders = $folder->parentObjectFileNames(false, true);
-
- $path = '/';
-
- if ( $toPathFolders )
- $path .= implode('/',$toPathFolders).'/';
- }
-
-
- $uri = $host . $path . $filename;
-
- if( !$uri )
- $uri = '.';
-
- return $uri;
- }
-
-
-
-
-
- /**
- * 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
- */
- public function copy( $tmp_filename,$dest_filename,$lastChangeDate=null )
- {
- $this->target->put($tmp_filename,$dest_filename,$lastChangeDate);
- }
-
-
-
-
- /**
- * Beenden des Ver�ffentlichungs-Vorganges.<br>
- * Eine vorhandene FTP-Verbindung wird geschlossen.<br>
- * Falls entsprechend konfiguriert, wird ein Systemkommando ausgef�hrt.
- */
- public function close()
- {
- $this->target->close();
-
- // Ausfuehren des Systemkommandos.
- if ( !empty($this->commandAfterPublish) )
- {
- $ausgabe = array();
- $rc = false;
- Logger::debug('Executing system command: '.Logger::sanitizeInput($this->commandAfterPublish) );
- $user = Session::getUser();
- putenv("CMS_USER_NAME=".$user->name );
- putenv("CMS_USER_ID=" .$user->userid);
- putenv("CMS_USER_MAIL=".$user->mail );
-
- exec( $this->commandAfterPublish,$ausgabe,$rc );
-
- if ( $rc != 0 ) // Wenn Returncode ungleich 0, dann Fehler melden.
- throw new PublisherException('System command failed - returncode is ' . $rc . "\n" .
- $ausgabe);
- 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.
- */
- public function clean()
- {
- if ( !empty($this->localDestinationDirectory) )
- $this->cleanFolder($this->localDestinationDirectory);
- }
-
-
-
- /**
- * Aufr�umen eines Verzeichnisses.<br><br>
- * Dateien, die l�nger existieren als der aktuelle Request alt ist, werden gel�scht.<br>
- *
- * @param String Verzeichnis
- */
- private function cleanFolder( $folderName )
- {
- $dh = opendir( $folderName );
-
- while( $file = readdir($dh) )
- {
- if ( $file != '.' && $file != '..')
- {
- $fullpath = $folderName.'/'.$file;
-
- // Wenn eine Datei beschreibbar und entsprechend alt
- // ist, dann entfernen
- if ( is_file($fullpath) &&
- is_writable($fullpath) &&
- filemtime($fullpath) < START_TIME )
- unlink($fullpath);
-
- // Bei Ordnern rekursiv absteigen
- if ( is_dir( $fullpath) )
- {
- $this->cleanFolder($fullpath);
- @rmdir($fullpath);
- }
- }
- }
- }
-
-
- public function isSimplePreview()
- {
- return false;
- }
-
- public function isPublic()
- {
- return true;
- }
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/README.md b/modules/cms/publish/README.md
@@ -1,5 +0,0 @@
-# Publishing
-
-The Publish objects are used for
-- creating links to other node objects.
-- copying the generated file to a live server.-
\ No newline at end of file
diff --git a/modules/cms/publish/filter/AbstractFilter.class.php b/modules/cms/publish/filter/AbstractFilter.class.php
@@ -1,10 +0,0 @@
-<?php
-
-
-namespace cms\publish\filter;
-
-
-abstract class AbstractFilter
-{
- public abstract function filter( $value );
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/filter/Base64DecodeFilter.class.php b/modules/cms/publish/filter/Base64DecodeFilter.class.php
@@ -1,13 +0,0 @@
-<?php
-
-
-namespace cms\publish\filter;
-
-
-class Base64DecodeFilter extends AbstractFilter
-{
- public function filter( $value )
- {
- return base64_decode( $value );
- }
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/filter/Base64EncodeFilter.class.php b/modules/cms/publish/filter/Base64EncodeFilter.class.php
@@ -1,13 +0,0 @@
-<?php
-
-
-namespace cms\publish\filter;
-
-
-class Base64EncodeFilter extends AbstractFilter
-{
- public function filter( $value )
- {
- return base64_encode( $value );
- }
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/filter/Csv2HtmlFilter.class.php b/modules/cms/publish/filter/Csv2HtmlFilter.class.php
@@ -1,42 +0,0 @@
-<?php
-
-
-namespace cms\publish\filter;
-
-
-class Csv2HtmlFilter extends AbstractFilter
-{
- public $withHeader = false;
- public $delimiter = ';';
- public $enclosure = '"';
-
- public function filter( $value )
- {
- $outputRow = function( $line, $cellTag) {
- return "<tr><$cellTag>".implode("</$cellTag><$cellTag>",str_getcsv( $line,$this->delimiter,$this->enclosure ))."</$cellTag></tr>";
-
- };
-
- $lines = explode("\n",$value );
-
- $out = '';
- $out .= '<table>';
-
- if ( $this->withHeader && $lines )
- {
- $out .= '<thead>';
- $out .= $outputRow( array_shift($lines),'th');
- $out .= '</thead>';
- }
-
-
- $out .= '<tbody>';
- foreach( $lines as $line )
- $out .= $outputRow( $line,'td');
- $out .= '</tbody>';
-
- $out .= '</table>';
-
- return $out;
- }
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/filter/JavascriptMinifierFilter.class.php b/modules/cms/publish/filter/JavascriptMinifierFilter.class.php
@@ -1,20 +0,0 @@
-<?php
-
-
-namespace cms\publish\filter;
-
-
-use util\JSqueeze;
-
-class JavascriptMinifierFilter extends AbstractFilter
-{
- public $singleLine = true;
- public $keepImportantComments = true;
- public $specialVarRx = false;
-
- public function filter( $value )
- {
- $jz = new JSqueeze();
- return $jz->squeeze( $value, (bool)$this->singleLine, (bool)$this->keepImportantComments, (bool)$this->specialVarRx );
- }
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/filter/LessFilter.class.php b/modules/cms/publish/filter/LessFilter.class.php
@@ -1,31 +0,0 @@
-<?php
-
-
-namespace cms\publish\filter;
-
-
-use \Less_Parser;
-
-class LessFilter extends AbstractFilter
-{
- public $sourceMap = false;
- public $indentation = ' ';
- public $compress = false;
- public $variables = array();
-
- public function filter($value)
- {
- $parser = new Less_Parser(array(
- 'sourceMap' => $this->sourceMap,
- 'indentation' => $this->indentation,
- 'outputSourceFiles' => false,
- 'compress' => (bool) $this->compress,
- ));
-
- $parser->parse($value);
-
- $parser->modifyVars( (array) $this->variables );
-
- return $parser->getCss();
- }
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/filter/README.md b/modules/cms/publish/filter/README.md
@@ -1,7 +0,0 @@
-# Filters
-
-Filters are executed by the CMS after generating a node object.
-
-## Example
-
-A script file is generated and before publishing it should be minified. This is done by the JavascriptMinifierFilter.-
\ No newline at end of file
diff --git a/modules/cms/publish/target/Dav.class.php b/modules/cms/publish/target/Dav.class.php
@@ -1,88 +0,0 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-namespace cms\publish\target;
-
-use logger\Logger;
-use util\exception\PublisherException;
-use util\exception\UIException;
-use util\Url;
-
-
-/**
- * Publishing a file over WebDAV.
- *
- * @author Jan Dankert
- */
-class Dav extends Target
-{
- /**
- * @var false|resource
- */
- private $fp;
-
- public function checkConnection()
- {
- $content = "HEAD / HTTP/1.1\r\n";
- $content .= "Host: ".$this->url->host."\r\n";
- $content .= "Connection: Close\r\n";
- $content .= "\r\n";
-
- fwrite($this->fp, $content );
- }
-
-
- public function put($source, $dest, $time)
- {
- $content = "PUT $dest HTTP/1.1\r\n";
- $content .= "Host: ".$this->url->host."\r\n";
- $content .= "Connection: Close\r\n";
- $content .= "\r\n";
-
- fwrite($this->fp, $content);
- fwrite($this->fp, file_get_contents($source));
- }
-
-
- public function mkcol( $dir ) {
- $content = "MKCOL $dir HTTP/1.1\r\n";
- $content .= "Host: ".$this->url->host."\r\n";
- $content .= "Connection: Close\r\n";
- $content .= "\r\n";
- fwrite($this->fp, $content);
- }
-
- public function close()
- {
- fclose($this->fp);
- }
-
- protected static function acceptsSchemes()
- {
- return ['dav'];
- }
-
- public function open()
- {
- $this->fp = fsockopen($this->url->host, empty($this->url->port)?80:$this->url->port, $errno, $errstr, 5);
-
- if(!$this->fp)
- throw new PublisherException("cannot connect to DAV server: $errno -> $errstr");
-
- $this->checkConnection();
- }
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/target/Fax.class.php b/modules/cms/publish/target/Fax.class.php
@@ -1,57 +0,0 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-namespace cms\publish\target;
-
-use logger\Logger;
-use util\exception\PublisherException;
-use util\exception\UIException;
-
-
-/**
- * Publishing a file over fax. Who says that this is not possible?
- *
- * @author Jan Dankert
- */
-class Fax extends Target
-{
- public function open()
- {
- Logger::debug("Dialing ...");
- }
-
- public function put($source, $dest, $time)
- {
- Logger::debug("düüüüüüüüüüüükrrrkkrkrkrkkrkrkrkr");
- // very, very funny, right?
- }
-
- public function close()
- {
- Logger::debug("Hanging up ...");
- }
-
- protected static function acceptsSchemes()
- {
- return ['fax'];
- }
-
- public function __construct($targetUrl)
- {
- }
-}
-// ok, this class was a joke.-
\ No newline at end of file
diff --git a/modules/cms/publish/target/Ftp.class.php b/modules/cms/publish/target/Ftp.class.php
@@ -1,178 +0,0 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-namespace cms\publish\target;
-
-use logger\Logger;
-use util\exception\PublisherException;
-use util\exception\UIException;
-
-
-/**
- * FTP-Target.
- *
- * @author Jan Dankert
- */
-class Ftp extends Target
-{
- private $connection;
-
- public static function acceptsSchemes() {
- return ['ftp'];
- }
-
- // Aufbauen der Verbindung
- public function open()
- {
- //global $conf;
- //$conf_ftp = $conf['publish']['ftp'];
- $ftp = $this->url;
-
- // Die projektspezifischen Werte gewinnen bei �berschneidungen mit den Default-Werten
- //$ftp = array_merge($conf_ftp, $ftp);
-
- $this->connection = $this->createConnection();
-
- if (!$this->connection) {
- Logger::error('Cannot connect to ' . $this->url->host . ':' . $this->url->port);
- throw new PublisherException('Cannot connect to ' . $this->url->scheme . '-server: ' . $this->url->host . ':' . $this->url->port);
- }
-
- if (empty($this->url->user)) {
- $ftp['user'] = 'anonymous';
- $ftp['pass'] = 'openrat@openrat.de';
- }
-
- if (!ftp_login($this->connection, $this->url->user, $this->url->pass))
- throw new PublisherException('Unable to login as user ' . $this->url->user);
-
- $pasv = $this->url->fragment == 'passive';
-
- if ( $pasv )
- if (!ftp_pasv($this->connection, true))
- throw new PublisherException('Cannot switch to FTP PASV mode');
-
- if ( $this->url->query ) {
- parse_str($this->url->query, $ftp_var);
-
- if (isset($ftp_var['site'])) {
- $site_commands = explode(',', $ftp_var['site']);
- foreach ($site_commands as $cmd) {
- if (!@ftp_site($this->connection, $cmd))
- throw new PublisherException('unable to do SITE command: ' . $cmd);
- }
- }
- }
-
- $path = rtrim($this->url->path, '/');
-
- if (!@ftp_chdir($this->connection, $path))
- throw new PublisherException('unable CHDIR to directory: ' . $path);
- }
-
-
- /**
- * Kopieren einer Datei vom lokalen System auf den FTP-Server.
- *
- * @param String Quelle
- * @param String Ziel
- * @param int FTP-Mode (BINARY oder ASCII)
- */
- public function put($source, $dest, $lastChangeDate)
- {
- $dest = $this->url->path . '/' . $dest;
-
- //$this->log .= "Copying file: $source -> $dest ...\n";
-
- $mode = FTP_BINARY;
- $p = strrpos(basename($dest), '.'); // Letzten Punkt suchen
-
- if ($p !== false) // Wennn letzten Punkt gefunden, dann dort aufteilen
- {
- $extension = substr(basename($dest), $p + 1);
- $type = config('mime-types', $extension);
- if (substr($type, 0, 5) == 'text/')
- $mode = FTP_ASCII;
- }
-
- Logger::debug("FTP PUT target:$dest mode:" . (($mode == FTP_ASCII) ? 'ascii' : 'binary'));
-
- if (!@ftp_put($this->connection, $dest, $source, $mode)) {
- if (!$this->mkdirs(dirname($dest)))
- return; // Fehler.
-
- ftp_chdir($this->connection, $this->url->path);
-
- if (!@ftp_put($this->connection, $dest, $source, $mode))
- throw new PublisherException("FTP PUT failed.\n" .
- "source : $source\n" .
- "destination: $dest");
-
- }
- }
-
-
- /**
- * Private Methode zum rekursiven Anlegen von Verzeichnissen.
- *
- * @param String Pfad
- * @return boolean true, wenn ok
- */
- private function mkdirs($strPath)
- {
- if (@ftp_chdir($this->connection, $strPath))
- return true; // Verzeichnis existiert schon :)
-
- $pStrPath = dirname($strPath);
-
- if (!$this->mkdirs($pStrPath))
- return false;
-
- if (!@ftp_mkdir($this->connection, $strPath))
- throw new PublisherException("failed to create remote directory: $strPath");
-
- return true;
- }
-
-
- /**
- * Schliessen der FTP-Verbindung.<br>
- * Sollte unbedingt aufgerufen werden, damit keine unn�tigen Sockets aufbleiben.
- */
- public function close()
- {
- if (!@ftp_quit($this->connection)) {
- // Closing not possible.
- // Only logging. Maybe we could throw an Exception here?
- Logger::warn('Failed to close FTP connection. Continueing...');
- return;
- }
- }
-
- protected function createConnection()
- {
- return ftp_connect($this->url->host, $this->url->port);
- }
-
- public static function isAvailable()
- {
- return function_exists('ftp_connect');
- }
-}
-
-
-?>-
\ No newline at end of file
diff --git a/modules/cms/publish/target/Ftps.class.php b/modules/cms/publish/target/Ftps.class.php
@@ -1,53 +0,0 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-namespace cms\publish\target;
-
-use logger\Logger;
-use util\exception\PublisherException;
-use util\exception\UIException;
-
-
-/**
- * Publishing via FTPS.
- *
- * @author Jan Dankert
- */
-class Ftps extends Ftp
-{
- public static function acceptsSchemes() {
- return ['ftps'];
- }
-
- /**
- * Creates a new connection.
- *
- * @param $ftp
- * @return false|resource
- */
- protected function createConnection()
- {
- return ftp_ssl_connect($this->url->host, $this->url->port);
- }
-
-
- public static function isAvailable()
- {
- return function_exists('ftp_ssl_connect');
-
- }
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/target/Local.class.php b/modules/cms/publish/target/Local.class.php
@@ -1,152 +0,0 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-namespace cms\publish\target;
-
-use logger\Logger;
-use util\exception\PublisherException;
-use util\exception\UIException;
-use util\FileUtils;
-use util\Url;
-
-
-/**
- * Publishing to the local filesystem.
- *
- * @author Jan Dankert
- */
-class Local extends Target
-{
- /**
- * @var string
- */
- private $localDestinationDirectory;
-
- public static function acceptsSchemes() {
- return ['file',''];
- }
-
-
- /**
- * @param $url Url
- */
- public function open()
- {
- $confPublish = config('publish');
-
- $targetDir = rtrim( $this->url->path,'/' );
-
- if ( FileUtils::isAbsolutePath($targetDir) && $confPublish['filesystem']['per_project'] )
- {
- $this->localDestinationDirectory = FileUtils::toAbsolutePath([$targetDir]); // Projekteinstellung verwenden.
- }
- else
- {
- // Konfiguriertes Verzeichnis verwenden.
- $this->localDestinationDirectory = FileUtils::toAbsolutePath([$confPublish['filesystem']['directory'],$targetDir]);
- }
-
-
- // Sofort pruefen, ob das Zielverzeichnis ueberhaupt beschreibbar ist.
- if ( $this->localDestinationDirectory && $this->localDestinationDirectory[0] == '#')
- $this->localDestinationDirectory = '';
-
- }
-
- /**
- * Copying a file to local filesystem.
- *
- * @param String Quelle
- * @param String Ziel
- */
- public function put($source, $dest, $lastChangeDate)
- {
- global $conf;
-
- // Is the output directory writable?
- if ( !is_writeable( $this->localDestinationDirectory ) )
- throw new PublisherException('directory not writable: ' . $this->localDestinationDirectory);
-
- $dest = $this->localDestinationDirectory.'/'.$dest;
-
- // Is the destination writable?
- if ( is_file($dest) && !is_writeable( $dest ) )
- throw new PublisherException('file not writable: ' . $dest);
-
- // Copy file to destination
- if (!@copy( $source,$dest ));
- {
- // Create directories, if necessary.
- $this->mkdirs( dirname($dest) );
-
- if (!@copy( $source,$dest ))
- throw new PublisherException( 'failed copying local file:' . "\n" .
- 'source : ' . $source . "\n" .
- 'destination: ' . $dest);
-
- // Das Änderungsdatum der Datei auch in der Zieldatei setzen.
- if ( $conf['publish']['set_modification_date'] )
- if ( ! is_null($lastChangeDate) )
- @touch( $dest,$lastChangeDate );
-
- Logger::debug("published: $dest");
- }
-
- if (!empty($conf['security']['chmod']))
- {
- // CHMOD auf der Datei ausfuehren.
- if ( ! @chmod($dest,octdec($conf['security']['chmod'])) )
- throw new PublisherException('Unable to CHMOD file ' . $dest);
- }
-
- }
-
-
-
- /**
- * 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
- */
- private function mkdirs($path )
- {
- global $conf;
-
- if ( is_dir($path) )
- return; // Path exists
-
- $parentPath = dirname($path);
-
- $this->mkdirs($parentPath);
-
- //
- if ( ! @mkdir($path) )
- throw new PublisherException( 'Cannot create directory: ' . $path);
-
- // CHMOD auf dem Verzeichnis ausgef�hren.
- if (!empty($conf['security']['chmod_dir']))
- {
- if ( ! @chmod($path,octdec($conf['security']['chmod_dir'])) )
- throw new PublisherException('Unable to CHMOD directory: ' . $path);
- }
- }
-
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/target/NoTarget.class.php b/modules/cms/publish/target/NoTarget.class.php
@@ -1,46 +0,0 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-namespace cms\publish\target;
-
-use logger\Logger;
-use util\exception\PublisherException;
-use util\exception\UIException;
-
-
-/**
- * Empty target.
- *
- * @author Jan Dankert
- */
-class NoTarget extends Target
-{
- public static function acceptsSchemes()
- {
- return ['null', 'example'];
- }
-
- public function put($source, $dest, $lastChangeDate)
- {
- // Do nothing.
- }
-
- public function __construct($targetUrl)
- {
-
- }
-}-
\ No newline at end of file
diff --git a/modules/cms/publish/target/README.md b/modules/cms/publish/target/README.md
@@ -1,24 +0,0 @@
-# Targets
-
-While publishing files and pages are pushed to a target.
-
-Possible publishing targets are
-- Local filesystem
-- FTP,FTPS
-- WebDAV
-- SCP
-- SFTP
-
-The corresponding scheme names are
-- `file`
-- `ftp`
-- `ftps`
-- `dav`
-- `scp`
-- `sftp`
-
-The target is selected by the scheme in the target url in the project properties.
-
-## Example
-
-`scp://user@host/var/www` is publishing all files via SCP to the SSH-Server on host 'host'. -
\ No newline at end of file
diff --git a/modules/cms/publish/target/SFtp.class.php b/modules/cms/publish/target/SFtp.class.php
@@ -1,112 +0,0 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-namespace cms\publish\target;
-
-use logger\Logger;
-use util\exception\PublisherException;
-use util\exception\UIException;
-
-
-/**
- * Darstellen einer FTP-Verbindung, das beinhaltet
- * das Login, das Kopieren von Dateien sowie praktische
- * FTP-Funktionen
- *
- * @author $Author$
- * @version $Revision$
- * @package openrat.services
- */
-class SFtp extends Scp
-{
- /**
- * @var resource
- */
- protected $sftpConnection;
-
-
- public static function acceptsSchemes() {
- return ['sftp'];
- }
-
- // Aufbauen der Verbindung
- public function open()
- {
- global $conf;
-
- //$conf_ftp = $conf['publish']['sftp'];
-
- // Die projektspezifischen Werte gewinnen bei �berschneidungen mit den Default-Werten
- //$sftp = array_merge($conf_ftp, $sftp);
-
-
- $this->createConnection();
-
- $this->sftpConnection = @ssh2_sftp($this->sshConnection);
-
- if (! $this->sftpConnection)
- throw new PublisherException("Could not initialize SFTP subsystem.");
-
- }
-
-
- /**
- * Kopieren einer Datei vom lokalen System auf den SFTP-Server.
- *
- * @param String Quelle
- * @param String Ziel
- * @param int time)
- */
- public function put($source, $dest, $lastChangeDate)
- {
- $dest = $this->url->path . '/' . $dest;
-
- $sftp = $this->sftpConnection;
-
- $stream = @fopen("ssh2.sftp://$sftp$dest", 'w');
-
- if (! $stream)
- throw new PublisherException("Could not create SFTP-Stream on file: $dest");
-
- $data_to_send = @file_get_contents($source);
-
- if ($data_to_send === false)
- throw new PublisherException("Could not open local file: $source");
-
- if (@fwrite($stream, $data_to_send) === false)
- throw new PublisherException("Could not send data from file: $source.");
-
- @fclose($stream);
- }
-
-
- /**
- * Schliessen der FTP-Verbindung.<br>
- * Sollte unbedingt aufgerufen werden, damit keine unn�tigen Sockets aufbleiben.
- */
- public function close()
- {
- parent::close();
- }
-
-
- public static function isAvailable()
- {
- return parent::isAvailable() && function_exists('ssh2_sftp');
- }
-}
-
diff --git a/modules/cms/publish/target/Scp.class.php b/modules/cms/publish/target/Scp.class.php
@@ -1,104 +0,0 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-namespace cms\publish\target;
-
-use logger\Logger;
-use util\exception\PublisherException;
-use util\exception\UIException;
-
-
-/**
- * Darstellen einer FTP-Verbindung, das beinhaltet
- * das Login, das Kopieren von Dateien sowie praktische
- * FTP-Funktionen
- *
- * @author $Author$
- * @version $Revision$
- * @package openrat.services
- */
-class Scp extends Target
-{
- /**
- * @var resource
- */
- protected $sshConnection;
-
- public static function acceptsSchemes() {
- return ['scp'];
- }
-
- // Aufbauen der Verbindung
- public function open()
- {
- $this->sshConnection = $this->createConnection();
- }
-
-
-
- protected function createConnection() {
-
- $sshConnection = @ssh2_connect($this->url->host,$this->url->port );
-
- if (! $sshConnection)
- throw new PublisherException("Could not connect to ".$this->url );
-
-
- if (! @ssh2_auth_password($sshConnection, $this->url->user,$this->url->pass) )
- throw new PublisherException("Could not authenticate");
-
- $this->sshConnection = $sshConnection;
-
- return $sshConnection;
- }
-
-
-
- /**
- * Kopieren einer Datei vom lokalen System auf den FTP-Server.
- *
- * @param String Quelle
- * @param String Ziel
- * @param int FTP-Mode (BINARY oder ASCII)
- */
- public function put($source, $dest, $lastChangeDate)
- {
- $dest = $this->url->path . '/' . $dest;
-
-
- ssh2_scp_send($this->sshConnection, $source, $dest, 0644);
- }
-
-
- /**
- * Schliessen der FTP-Verbindung.<br>
- * Sollte unbedingt aufgerufen werden, damit keine unn�tigen Sockets aufbleiben.
- */
- public function close()
- {
- ssh2_disconnect($this->sshConnection);
- }
-
-
- public static function isAvailable()
- {
- return function_exists('ssh2_connect');
- }
-}
-
-
-?>-
\ No newline at end of file
diff --git a/modules/cms/publish/target/Target.class.php b/modules/cms/publish/target/Target.class.php
@@ -1,79 +0,0 @@
-<?php
-// OpenRat Content Management System
-// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-namespace cms\publish\target;
-
-use logger\Logger;
-use util\exception\PublisherException;
-use util\exception\UIException;
-use util\Url;
-
-
-/**
- * Superclass for publication targets.
- *
- * @author Jan Dankert
- */
-abstract class Target
-{
- /**
- * @var Url
- */
- protected $url;
-
- public function __construct( $targetUrl ) {
- $this->url = new Url( $targetUrl );
-
- $this->open();
- }
-
-
- public static function accepts( $scheme ) {
- return in_array( $scheme, static::acceptsSchemes() );
- }
-
-
- /**
- * For which types this target is reponsible?
- *
- * @return array
- */
- protected abstract static function acceptsSchemes();
-
-
- public function open() {
-
- }
-
-
- public abstract function put($source, $dest, $timestamp);
-
-
- /**
- * Closes the connection.
- */
- public function close() {
-
- }
-
-
- public static function isAvailable() {
-
- return true;
- }
-
-}
diff --git a/modules/util/Tree.class.php b/modules/util/Tree.class.php
@@ -369,7 +369,7 @@ class Tree
$value->pageid = $page->pageid;
$value->element = $element;
$value->languageid = $page->languageid;
- $value->publisher = new \cms\publish\PublishPreview();
+ $value->publisher = new \cms\generator\PublishPreview();
$value->load();
if (BaseObject::available($value->linkToObjectId)) {