openrat-cms

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

commit f130594a5ee2629c187dbab42553a755bcc4501a
parent 89682b98b7aa67f2d06016988fe5a14c0f58729c
Author: Jan Dankert <devnull@localhost>
Date:   Fri, 20 Jul 2018 00:20:52 +0200

Fixes: Laden von URLs, die weitere Parameter wie languageid und modelid enthalten.

Diffstat:
modules/cms-core/action/PageAction.class.php | 12+++++++-----
modules/cms-core/model/Page.class.php | 3++-
modules/cms-core/model/Project.class.php | 4++--
modules/cms-core/model/Value.class.php | 9+++++----
modules/cms-macros/macro/LastChanges.class.php | 9++++++---
modules/cms-ui/themes/default/html/views/page/edit.php | 4++--
modules/cms-ui/themes/default/html/views/page/edit.tpl.src.xml | 2+-
modules/cms-ui/themes/default/script/openrat.js | 1+
modules/cms-ui/themes/default/script/openrat.min.js | 2+-
modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.js | 2+-
modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.min.js | 2+-
modules/template-engine/components/html/link/Link.class.php | 50+++++++++++++++++++++++++++++++++++---------------
modules/util/Macro.class.php | 7++++++-
13 files changed, 70 insertions(+), 37 deletions(-)

diff --git a/modules/cms-core/action/PageAction.class.php b/modules/cms-core/action/PageAction.class.php @@ -506,21 +506,23 @@ class PageAction extends ObjectAction if ( $value->element->isWritable() ) { $list[$id] = array(); - $list[$id]['name'] = $value->element->name; + $list[$id]['name'] = $value->element->name; $list[$id]['pageelementid' ] = $this->page->objectid.'_'.$id; - $list[$id]['desc'] = $value->element->desc; - $list[$id]['type'] = $value->element->type; + $list[$id]['desc'] = $value->element->desc; + $list[$id]['languageid'] = $this->page->languageid; + $list[$id]['modelid' ] = $this->page->modelid; + $list[$id]['type'] = $value->element->type; $list[$id]['archive_count'] = intval($value->getCountVersions()); if ( $list[$id]['archive_count'] > 0 ) - $list[$id]['archive_url'] = Html::url( 'pageelement','archive',$this->page->id,array('elementid'=>$id) ); + $list[$id]['archive_url'] = Html::url( 'pageelement','archive',$this->page->id,array(REQ_PARAM_ELEMENT_ID=>$id,REQ_PARAM_LANGUAGE_ID=>$this->page->languageid,REQ_PARAM_MODEL_ID=>$this->page->modelid) ); // Inhalt anzeigen $list[$id]['value'] = $value->value; } } - $this->setTemplateVar('preview_url',Html::url('page','show',$this->page->objectid,array('withIcons'=>'1',REQ_PARAM_LANGUAGE_ID=>$this->page->languageid,REQ_PARAM_MODEL_ID=>$this->page->modelid) ) ); + $this->setTemplateVar('preview_url',Html::url('page','show',$this->page->objectid,array('withIcons'=>'1',REQ_PARAM_LANGUAGE_ID=>$this->page->languageid,REQ_PARAM_MODEL_ID=>$this->page->modelid,REQ_PARAM_EMBED=>'1') ) ); $this->setTemplateVar('properties',$this->page->getProperties() ); $this->setTemplateVar('el',$list); } diff --git a/modules/cms-core/model/Page.class.php b/modules/cms-core/model/Page.class.php @@ -164,7 +164,8 @@ class Page extends BaseObject $param = array( 'oid' => '__OID__'.$objectid.'__', REQ_PARAM_MODEL_ID => $this->modelid , - REQ_PARAM_LANGUAGE_ID => $this->languageid ); + REQ_PARAM_LANGUAGE_ID => $this->languageid , + REQ_PARAM_EMBED => '1' ); if ( $this->icons ) $param['withIcons'] = '1'; diff --git a/modules/cms-core/model/Project.class.php b/modules/cms-core/model/Project.class.php @@ -922,8 +922,8 @@ SQL // Variablen setzen. $sql->setInt( 'projectid', $this->projectid ); - $language = Session::getProjectLanguage(); - $sql->setInt( 'languageid', $language->languageid ); + $languageid = $this->getDefaultLanguageId(); + $sql->setInt( 'languageid', $languageid ); return $sql->getAll(); } diff --git a/modules/cms-core/model/Value.class.php b/modules/cms-core/model/Value.class.php @@ -1079,7 +1079,7 @@ SQL // Wenn Inhalt leer, dann versuchen, den Inhalt der Default-Sprache zu laden. if ( $inhalt == '' && $conf['content']['language']['use_default_language'] ) { - $project = \Session::getProject(); + $project = new Project($this->page->projectid); $this->languageid = $project->getDefaultLanguageId(); $this->load(); $inhalt = $this->text; @@ -1220,7 +1220,8 @@ SQL if ( class_exists($className) ) { - $macro = new $className; + /** @var \Macro $macro */ + $macro = new $className; $macro->page = &$this->page; if ( method_exists( $macro,'execute' ) ) @@ -1397,7 +1398,7 @@ SQL case 'edit_url': $raw = true; $db = \Session::getDatabase(); - $inhalt = Html::url('index','object',$this->page->objectid,array('dbid'=>$db->id)); + $inhalt = Html::url('page',null,$this->page->objectid,array('dbid'=>$db->id)); break; case 'edit_fullurl': $raw = true; @@ -1408,7 +1409,7 @@ SQL 'modelid' =>$this->page->modelid, 'languageid'=>$this->page->languageid, 'elementid' =>$this->element->elementid ); - $inhalt .= '/'.basename(Html::url('index','object',$this->page->objectid,$params)); + $inhalt .= '/'.basename(Html::url('page',null,$this->page->objectid,$params)); break; case 'lastch_user_username': $user = $this->page->lastchangeUser; diff --git a/modules/cms-macros/macro/LastChanges.class.php b/modules/cms-macros/macro/LastChanges.class.php @@ -18,6 +18,7 @@ use cms\model\Folder; use cms\model\Link; use cms\model\Page; +use cms\model\Project; /** @@ -51,8 +52,6 @@ class LastChanges extends Macro // function execute() { - $project = Session::getProject(); - if ( $this->folderid === 'self' ) { $page = $this->getPage(); @@ -67,7 +66,11 @@ class LastChanges extends Macro $changes = $f->getLastChanges(); } else - $changes = $project->getLastChanges(); + { + $project = new Project( $this->page->projectid ); + $changes = $project->getLastChanges(); + } + $count = 0; diff --git a/modules/cms-ui/themes/default/html/views/page/edit.php b/modules/cms-ui/themes/default/html/views/page/edit.php @@ -24,7 +24,7 @@ <?php foreach($el as $list_key=>$list_value){ ?><?php extract($list_value) ?> <tr class="data"> <td class="clickable"> - <a title="<?php echo $desc ?>" target="_self" date-name="<?php echo $name ?>" name="<?php echo $name ?>" data-type="open" data-action="pageelement" data-method="<?php echo OR_METHOD ?>" data-id="<?php echo $pageelementid ?>" href="javascript:void(0);"> + <a title="<?php echo $desc ?>" target="_self" date-name="<?php echo $name ?>" name="<?php echo $name ?>" data-type="open" data-action="pageelement" data-method="<?php echo OR_METHOD ?>" data-id="<?php echo $pageelementid ?>" data-extra="{'languageid':'<?php echo $languageid ?>','modelid':'<?php echo $modelid ?>'}" href="<?php echo Html::url('pageelement','',$pageelementid,array('languageid'=>$languageid,'modelid'=>$modelid)) ?>"> <img class="image-icon image-icon--element" title="" src="./modules/cms-ui/themes/default/images/icon/element/<?php echo $type ?>.svg" /> <span class="text"><?php echo nl2br(encodeHtml(htmlentities($name))); ?></span> @@ -41,7 +41,7 @@ </tr> <?php } ?> </table> - <fieldset class="<?php echo '1'?" open":"" ?><?php echo '1'?" show":"" ?>"><legend><div class="arrow-right closed" /><div class="arrow-down open" /><?php echo lang('menu_page_show') ?></legend><div> + <fieldset class="<?php echo '1'?" open":" closed" ?><?php echo '1'?" show":"" ?>"><legend><div class="arrow arrow-right on-closed"></div><div class="arrow arrow-down on-open"></div><?php echo lang('menu_page_show') ?></legend><div> <div> <iframe name="preview" src="<?php echo $preview_url ?>"></iframe> diff --git a/modules/cms-ui/themes/default/html/views/page/edit.tpl.src.xml b/modules/cms-ui/themes/default/html/views/page/edit.tpl.src.xml @@ -21,7 +21,7 @@ <list list="el" extract="true"> <row class="data"> <column class="clickable"> - <link type="open" title="var:desc" name="var:name" action="pageelement" id="var:pageelementid"> + <link type="open" title="var:desc" name="var:name" action="pageelement" id="var:pageelementid" var1="languageid" value1="var:languageid" var2="modelid" value2="var:modelid"> <image elementtype="var:type" align="left"></image> <text var="name"></text> </link> diff --git a/modules/cms-ui/themes/default/script/openrat.js b/modules/cms-ui/themes/default/script/openrat.js @@ -689,6 +689,7 @@ function createUrl(action,subaction,id,extraid,embed) if ( typeof extraid === 'string') { + extraid = extraid.replace(/'/g,'"'); // Replace ' with ". jQuery.each(jQuery.parseJSON(extraid), function(name, value) { if(name=='action'||name=='subaction'||name=='id') return; diff --git a/modules/cms-ui/themes/default/script/openrat.min.js b/modules/cms-ui/themes/default/script/openrat.min.js @@ -5,6 +5,6 @@ else if(Notification.permission!=='denied'){Notification.requestPermission(funct else{r.moveStart('character',e.length+n.length+i.length)};r.select()} else if(typeof a.selectionStart!='undefined'){var d=a.selectionStart,s=a.selectionEnd,n=a.value.substring(d,s);a.value=a.value.substr(0,d)+e+n+i+a.value.substr(s);var o;if(n.length==0){o=d+e.length} else{o=d+e.length+n.length+i.length};a.selectionStart=o;a.selectionEnd=o} -else{o=a.value.length;var n=prompt('Text');a.value=a.value.substr(0,o)+e+n+i+a.value.substr(o)}};function createUrl(t,e,i,a,o){var n='./';n+='?action='+t;if(e!=null)n+='&subaction='+e;n+='&id='+i;if(o)n+='&embed=1';if(typeof a==='string'){jQuery.each(jQuery.parseJSON(a),function(t,e){if(t=='action'||t=='subaction'||t=='id')return;n=n+'&'+t+'='+e})} +else{o=a.value.length;var n=prompt('Text');a.value=a.value.substr(0,o)+e+n+i+a.value.substr(o)}};function createUrl(t,e,i,a,o){var n='./';n+='?action='+t;if(e!=null)n+='&subaction='+e;n+='&id='+i;if(o)n+='&embed=1';if(typeof a==='string'){a=a.replace(/'/g,'"');jQuery.each(jQuery.parseJSON(a),function(t,e){if(t=='action'||t=='subaction'||t=='id')return;n=n+'&'+t+'='+e})} else if(typeof a==='object'){jQuery.each(a,function(t,e){if(t=='action'||t=='subaction'||t=='id')return;n=n+'&'+t+'='+e})} else{};return n};function resizeWorkbenchContainer(t){};function resizeWorkbench(){};function resizeTabs(t){};function help(t,e,i){var a=$(t).closest('div.panel').find('li.action.active').attr('data-action'),n=$(t).closest('div.panel').find('li.action.active').attr('data-method');window.open(e+a+'/'+n+i,'OpenRat_Help','location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes')};function notify(t,e){var i=$('<div class="notice '+t+'"><div class="text">'+e+'</div></div>');$('#noticebar').prepend(i);$(i).fadeIn().click(function(){$(this).fadeOut('fast',function(){$(this).remove()})})}; \ No newline at end of file diff --git a/modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.js b/modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.js @@ -63,7 +63,7 @@ jQuery.fn.orLinkify = function() else if ( type == 'open' ) { - openNewAction( $(this).attr('data-name'),$(this).attr('data-action'),$(this).attr('data-id'),0); + openNewAction( $(this).attr('data-name'),$(this).attr('data-action'),$(this).attr('data-id'),$(this).attr('data-extra')); } else { diff --git a/modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.min.js b/modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.min.js @@ -7,5 +7,5 @@ else if(t=='external'){window.open($(this).attr('data-url'),' _blank')} else if(t=='popup'){window.open($(this).attr('data-url'),'Popup','location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes')} else if(t=='help'){help(this,$(this).attr('data-url'),$(this).attr('data-suffix'))} else if(t=='fullscreen'){fullscreen(this)} -else if(t=='open'){openNewAction($(this).attr('data-name'),$(this).attr('data-action'),$(this).attr('data-id'),0)} +else if(t=='open'){openNewAction($(this).attr('data-name'),$(this).attr('data-action'),$(this).attr('data-id'),$(this).attr('data-extra'))} else{alert('Fatal: Cannot open link: '+$(this).html())}})})}; \ No newline at end of file diff --git a/modules/template-engine/components/html/link/Link.class.php b/modules/template-engine/components/html/link/Link.class.php @@ -3,6 +3,7 @@ namespace template_engine\components; use Html; +use JSON; /** * Erzeugt einen HTML-Link. @@ -105,7 +106,13 @@ class LinkComponent extends Component echo ' data-id="' . $this->htmlvalue($this->id) . '"'; else echo ' data-id="<?php echo OR_ID ?>"'; - + + $json = new JSON(); + $arrayvalues = array(); + foreach( $this->getExtraParamArray() as $varname => $varvalue ) + $arrayvalues[ $this->htmlvalue($varname) ] = $this->htmlvalue($varvalue); + echo ' data-extra="'.str_replace('"',"'",str_replace(array("\t", "\r", "\n"),'',$json->encode($arrayvalues))).'"'; + switch ($this->type) { case 'post': @@ -136,19 +143,11 @@ class LinkComponent extends Component echo "&quot;,"; echo '&quot;'.REQ_PARAM_TOKEN . "&quot;:&quot;" . '<?php echo token() ?>' . "&quot;,"; - - if (! empty($this->var1)) - echo "&quot;var1&quot;:&quot;" . $this->htmlvalue($this->value1) . "&quot;,"; - if (! empty($this->var2)) - echo "&quot;var2&quot;:&quot;" . $this->htmlvalue($this->value2) . "&quot;,"; - if (! empty($this->var3)) - echo "&quot;var3&quot;:&quot;" . $this->htmlvalue($this->value3) . "&quot;,"; - if (! empty($this->var4)) - echo "&quot;var4&quot;:&quot;" . $this->htmlvalue($this->value4) . "&quot;,"; - if (! empty($this->var5)) - echo "&quot;var5&quot;:&quot;" . $this->htmlvalue($this->value5) . "&quot;,"; - - echo "&quot;none&quot;:&quot;0&quot;}\""; + + foreach( $this->getExtraParamArray() as $varname => $varvalue ) + echo "&quot;".$this->htmlvalue($varname)."&quot;:&quot;" . $this->htmlvalue($varvalue) . "&quot;,"; + + echo "&quot;none&quot;:&quot;0&quot;}\""; break; @@ -158,7 +157,15 @@ class LinkComponent extends Component break; default: - echo ' href="<?php echo Html::url('.$this->value($this->action).','.$this->value($this->subaction).','.$this->value($this->id).') ?>"'; + echo ' href="<?php echo Html::url('.$this->value($this->action).','.$this->value($this->subaction).','.$this->value($this->id); + + $arrayvalues = array(); + foreach( $this->getExtraParamArray() as $varname => $varvalue ) + $arrayvalues[] = $this->value($varname) . '=>'.$this->value($varvalue); + + echo ',array('.implode(',',$arrayvalues).')'; + + echo ') ?>"'; } echo '>'; @@ -169,5 +176,18 @@ class LinkComponent extends Component echo '</a> '; } + + + private function getExtraParamArray() + { + $vars = array(); + if (! empty($this->var1)) $vars[$this->var1] = $this->value1; + if (! empty($this->var2)) $vars[$this->var2] = $this->value2; + if (! empty($this->var3)) $vars[$this->var3] = $this->value3; + if (! empty($this->var4)) $vars[$this->var4] = $this->value4; + if (! empty($this->var5)) $vars[$this->var5] = $this->value5; + + return $vars; + } } ?> diff --git a/modules/util/Macro.class.php b/modules/util/Macro.class.php @@ -16,6 +16,7 @@ // 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\model\Page; +use cms\model\Project; /** @@ -28,6 +29,9 @@ use cms\model\Page; */ class Macro { + /** + * @var \cms\model\Project Projekt + */ var $project; var $output = ''; var $objectid = 0; @@ -103,13 +107,14 @@ class Macro */ public function getRootObjectId() { - $project = Session::getProject(); + $project = new Project( $this->page->projectid); return $project->getRootObjectId(); } /** * DO NOT USE. + * @deprecated */ public function folderid() {