Skip to content

Commit

Permalink
removed modAction and modRestClient to get Quip work in 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
zahlenhexe committed Mar 16, 2023
1 parent 0414fb9 commit 062e66f
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 34 deletions.
4 changes: 2 additions & 2 deletions assets/components/quip/js/sections/thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Quip.page.Thread = function(config) {
text: _('quip.back_to_threads')
,id: 'quip-btn-back'
,handler: function() {
location.href = '?a='+MODx.request.a+'&action=home';
MODx.loadPage('home', 'namespace=quip');
}
,scope: this
}]
Expand All @@ -36,4 +36,4 @@ Quip.page.Thread = function(config) {
Quip.page.Thread.superclass.constructor.call(this,config);
};
Ext.extend(Quip.page.Thread,MODx.Component);
Ext.reg('quip-page-thread',Quip.page.Thread);
Ext.reg('quip-page-thread',Quip.page.Thread);
14 changes: 7 additions & 7 deletions assets/components/quip/js/widgets/comments.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Quip.grid.Comments = function(config) {
Ext.applyIf(config,{
url: Quip.config.connector_url
,baseParams: {
action: 'mgr/comment/getList'
action: 'mgr/comment/getlist'
,thread: config.thread || null
,family: config.family || null
}
Expand Down Expand Up @@ -162,7 +162,7 @@ Ext.extend(Quip.grid.Comments,MODx.grid.Grid,{
MODx.Ajax.request({
url: this.config.url
,params: {
action: 'mgr/comment/approveMultiple'
action: 'mgr/comment/approvemultiple'
,comments: cs
}
,listeners: {
Expand All @@ -181,7 +181,7 @@ Ext.extend(Quip.grid.Comments,MODx.grid.Grid,{
MODx.Ajax.request({
url: this.config.url
,params: {
action: 'mgr/comment/unapproveMultiple'
action: 'mgr/comment/unapprovemultiple'
,comments: cs
}
,listeners: {
Expand All @@ -201,7 +201,7 @@ Ext.extend(Quip.grid.Comments,MODx.grid.Grid,{
MODx.Ajax.request({
url: this.config.url
,params: {
action: 'mgr/comment/deleteMultiple'
action: 'mgr/comment/deletemultiple'
,comments: cs
}
,listeners: {
Expand All @@ -220,7 +220,7 @@ Ext.extend(Quip.grid.Comments,MODx.grid.Grid,{
MODx.Ajax.request({
url: this.config.url
,params: {
action: 'mgr/comment/undeleteMultiple'
action: 'mgr/comment/undeletemultiple'
,comments: cs
}
,listeners: {
Expand All @@ -240,7 +240,7 @@ Ext.extend(Quip.grid.Comments,MODx.grid.Grid,{
MODx.Ajax.request({
url: this.config.url
,params: {
action: 'mgr/comment/removeMultiple'
action: 'mgr/comment/removemultiple'
,comments: cs
}
,listeners: {
Expand Down Expand Up @@ -475,4 +475,4 @@ Quip.window.UpdateComment = function(config) {
Quip.window.UpdateComment.superclass.constructor.call(this,config);
};
Ext.extend(Quip.window.UpdateComment,MODx.Window);
Ext.reg('quip-window-comment-update',Quip.window.UpdateComment);
Ext.reg('quip-window-comment-update',Quip.window.UpdateComment);
4 changes: 2 additions & 2 deletions assets/components/quip/js/widgets/notifications.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Ext.extend(Quip.grid.Notification,MODx.grid.Grid,{
MODx.Ajax.request({
url: this.config.url
,params: {
action: 'mgr/thread/notification/removeMultiple'
action: 'mgr/thread/notification/removemultiple'
,notifications: cs
}
,listeners: {
Expand Down Expand Up @@ -197,4 +197,4 @@ Quip.window.CreateNotification = function(config) {
Quip.window.CreateNotification.superclass.constructor.call(this,config);
};
Ext.extend(Quip.window.CreateNotification,MODx.Window);
Ext.reg('quip-window-notification-create',Quip.window.CreateNotification);
Ext.reg('quip-window-notification-create',Quip.window.CreateNotification);
12 changes: 6 additions & 6 deletions assets/components/quip/js/widgets/threads.panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Quip.panel.Threads = function(config) {
,cls: 'main-wrapper'
,preventRender: true
,baseParams: {
action: 'mgr/comment/getUnapproved'
action: 'mgr/comment/getunapproved'
}
}]
},{
Expand Down Expand Up @@ -71,7 +71,7 @@ Quip.grid.Thread = function(config) {
this.ident = config.ident || Ext.id();
Ext.applyIf(config,{
url: Quip.config.connector_url
,baseParams: { action: 'mgr/thread/getList' }
,baseParams: { action: 'mgr/thread/getlist' }
,fields: ['name','comments','unapproved_comments','pagetitle','url','perm']
,paging: true
,autosave: false
Expand Down Expand Up @@ -188,7 +188,7 @@ Ext.extend(Quip.grid.Thread,MODx.grid.Grid,{
return cs;
}
,manageThread: function() {
location.href = '?a='+MODx.request.a+'&action=thread&thread='+this.menu.record.name;
MODx.loadPage('thread', 'namespace=quip');
}
,truncateThread: function() {
MODx.msg.confirm({
Expand All @@ -213,7 +213,7 @@ Ext.extend(Quip.grid.Thread,MODx.grid.Grid,{
,text: _('quip.thread_truncate_selected_confirm')
,url: this.config.url
,params: {
action: 'mgr/thread/truncateMultiple'
action: 'mgr/thread/truncatemultiple'
,threads: cs
}
,listeners: {
Expand Down Expand Up @@ -248,7 +248,7 @@ Ext.extend(Quip.grid.Thread,MODx.grid.Grid,{
,text: _('quip.thread_remove_selected_confirm')
,url: this.config.url
,params: {
action: 'mgr/thread/removeMultiple'
action: 'mgr/thread/removemultiple'
,threads: cs
}
,listeners: {
Expand Down Expand Up @@ -307,4 +307,4 @@ Ext.extend(Quip.grid.Thread,MODx.grid.Grid,{
}
}
});
Ext.reg('quip-grid-thread',Quip.grid.Thread);
Ext.reg('quip-grid-thread',Quip.grid.Thread);
105 changes: 105 additions & 0 deletions core/components/quip/controllers/index.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
/**
* Quip
*
* Copyright 2010-11 by Shaun McCormick <[email protected]>
*
* This file is part of Quip, a simple commenting component for MODx Revolution.
*
* Quip 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.
*
* Quip 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
* Quip; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*
* @package quip
*/

require_once dirname(dirname(__FILE__)) . '/model/quip/quip.class.php';

//class QuipHomeManagerController extends QuipManagerController {

class QuipIndexManagerController extends modExtraManagerController {
/** @var Quip $quip */
public $quip;
public function initialize() {
$this->quip = new Quip($this->modx);

$this->addCss($this->quip->config['cssUrl'].'mgr.css');
$this->addJavascript($this->quip->config['jsUrl'].'quip.js');
$this->addHtml('<script type="text/javascript">
Ext.onReady(function() {
Quip.config = '.$this->modx->toJSON($this->quip->config).';
Quip.config.connector_url = "'.$this->quip->config['connectorUrl'].'";
});
</script>');

$this->checkForApproval();
$this->checkForRejection();
return parent::initialize();
}


public function process(array $scriptProperties = array()) {

}
public function getLanguageTopics() {
return array('quip:default');
}
public function getPageTitle() { return $this->modx->lexicon('quip'); }
public function checkPermissions() { return true;}


public function loadCustomCssJs() {
$this->addJavascript($this->quip->config['jsUrl'].'widgets/comments.grid.js');
$this->addJavascript($this->quip->config['jsUrl'].'widgets/threads.panel.js');
$this->addLastJavascript($this->quip->config['jsUrl'].'sections/home.js');
}
public function getTemplateFile() { return $this->quip->config['templatesPath'].'home.tpl'; }
public function checkForApproval() {
if (!empty($_REQUEST['quip_approve'])) {
/** @var quipComment $comment */
$comment = $this->modx->getObject('quipComment',$_REQUEST['quip_approve']);
if ($comment && $comment->approve()) {
$commentArray = $comment->toArray();
$commentArray['createdon'] = strftime('%b %d, %Y',strtotime($comment->get('createdon')));
$this->modx->regClientStartupHTMLBlock('<script type="text/javascript">
Ext.onReady(function() {
MODx.msg.status({
title: "'.$this->modx->lexicon('quip.comment_approved').'"
,message: "'.$this->modx->lexicon('quip.comment_approved_msg',$commentArray).'"
,delay: 5
});
});
</script>');
}
}
}
public function checkForRejection() {
if (!empty($_REQUEST['quip_reject'])) {
/** @var quipComment $comment */
$comment = $this->modx->getObject('quipComment',$_REQUEST['quip_reject']);
if ($comment && $comment->reject()) {
$commentArray = $comment->toArray();
$commentArray['createdon'] = strftime('%b %d, %Y',strtotime($comment->get('createdon')));
$this->modx->regClientStartupHTMLBlock('<script type="text/javascript">
Ext.onReady(function() {
MODx.msg.status({
title: "'.$this->modx->lexicon('quip.comment_deleted').'"
,message: "'.$this->modx->lexicon('quip.comment_deleted_msg',$commentArray).'"
,delay: 5
});
});
</script>');
}
}
}
}

66 changes: 64 additions & 2 deletions core/components/quip/controllers/thread.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,72 @@
*
* @package quip
*/
class QuipThreadManagerController extends QuipManagerController {
require_once dirname(dirname(__FILE__)) . '/model/quip/quip.class.php';

class QuipThreadManagerController extends modExtraManagerController {
/** @var Quip $quip */
public $quip;
public function initialize() {
$this->quip = new Quip($this->modx);

$this->addCss($this->quip->config['cssUrl'].'mgr.css');
$this->addJavascript($this->quip->config['jsUrl'].'quip.js');
$this->addHtml('<script type="text/javascript">
Ext.onReady(function() {
Quip.config = '.$this->modx->toJSON($this->quip->config).';
Quip.config.connector_url = "'.$this->quip->config['connectorUrl'].'";
});
</script>');

$this->checkForApproval();
$this->checkForRejection();
return parent::initialize();
}
public function process(array $scriptProperties = array()) {

}
public function getLanguageTopics() {
return array('quip:default');
}
public function checkPermissions() { return true;}

public function checkForApproval() {
if (!empty($_REQUEST['quip_approve'])) {
/** @var quipComment $comment */
$comment = $this->modx->getObject('quipComment',$_REQUEST['quip_approve']);
if ($comment && $comment->approve()) {
$commentArray = $comment->toArray();
$commentArray['createdon'] = strftime('%b %d, %Y',strtotime($comment->get('createdon')));
$this->modx->regClientStartupHTMLBlock('<script type="text/javascript">
Ext.onReady(function() {
MODx.msg.status({
title: "'.$this->modx->lexicon('quip.comment_approved').'"
,message: "'.$this->modx->lexicon('quip.comment_approved_msg',$commentArray).'"
,delay: 5
});
});
</script>');
}
}
}
public function checkForRejection() {
if (!empty($_REQUEST['quip_reject'])) {
/** @var quipComment $comment */
$comment = $this->modx->getObject('quipComment',$_REQUEST['quip_reject']);
if ($comment && $comment->reject()) {
$commentArray = $comment->toArray();
$commentArray['createdon'] = strftime('%b %d, %Y',strtotime($comment->get('createdon')));
$this->modx->regClientStartupHTMLBlock('<script type="text/javascript">
Ext.onReady(function() {
MODx.msg.status({
title: "'.$this->modx->lexicon('quip.comment_deleted').'"
,message: "'.$this->modx->lexicon('quip.comment_deleted_msg',$commentArray).'"
,delay: 5
});
});
</script>');
}
}
}
public function getPageTitle() { return $this->modx->lexicon('quip'); }
public function loadCustomCssJs() {
Expand All @@ -34,4 +96,4 @@ public function loadCustomCssJs() {
$this->addLastJavascript($this->quip->config['jsUrl'].'sections/thread.js');
}
public function getTemplateFile() { return $this->quip->config['templatesPath'].'thread.tpl'; }
}
}
Loading

1 comment on commit 062e66f

@a2life
Copy link

@a2life a2life commented on 062e66f Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you have missed one more correction on getList, on line modxcms#9 at notifications.grid.js

Please sign in to comment.