public function initialize() { $this->editAction = $this->modx->getObject('modAction', array('namespace' => 'core', 'controller' => 'resource/update')); $this->defaultSortField = $this->modx->getOption('articles.default_article_sort_field', null, 'createdon'); if ($this->getParentContainer()) { $settings = $this->container->getContainerSettings(); if ($this->modx->getOption('commentsEnabled', $settings, true)) { $quipCorePath = $this->modx->getOption('quip.core_path', null, $this->modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/quip/'); if ($this->modx->addPackage('quip', $quipCorePath . 'model/')) { $this->commentsEnabled = true; } } } return parent::initialize(); }
/** * Import comments into Quip * * @param Article $article * @param SimpleXMLElement $item * @return boolean */ public function importComments(Article $article, SimpleXMLElement $item) { $settings = $this->container->getContainerSettings(); $threadKey = 'article-b' . $this->container->get('id') . '-' . $article->get('id'); /** @var quipThread $thread */ $thread = $this->modx->newObject('quipThread'); $thread->fromArray(array('createdon' => $article->get('publishedon'), 'moderated' => $this->modx->getOption('commentsModerated', $settings, 1), 'moderator_group' => $this->modx->getOption('commentsModeratorGroup', $settings, 'Administrator'), 'moderators' => $this->modx->getOption('commentsModerators', $settings, ''), 'resource' => $article->get('id'), 'idprefix' => 'qcom')); $thread->set('name', $threadKey); if (!$this->debug) { $thread->save(); } /** @var SimpleXMLElement $wp */ $wp = $item->children('wp', true); $idMap = array(); /** @var SimpleXMLElement $commentXml */ foreach ($wp->comment as $commentXml) { $commentId = (int) $this->getXPath($commentXml, 'wp:comment_id'); $commentParent = (int) $this->getXPath($commentXml, 'wp:comment_parent'); /** @var SimpleXMLElement $commentWp */ $commentWp = $commentXml->children('wp', true); /** @var quipComment $comment */ $comment = $this->modx->newObject('quipComment'); $comment->fromArray(array('thread' => $threadKey, 'parent' => array_key_exists($commentParent, $idMap) ? $idMap[$commentParent] : 0, 'author' => $this->matchCreator((string) $commentWp->comment_author), 'body' => $this->parseContent((string) $commentWp->comment_content), 'createdon' => (string) $commentWp->comment_date, 'approved' => (bool) $commentWp->comment_approved, 'name' => (string) $commentWp->comment_author, 'email' => (string) $commentWp->comment_author_email, 'website' => (string) $commentWp->comment_author_url, 'ip' => (string) $commentWp->comment_author_IP, 'resource' => $article->get('id'), 'idprefix' => 'qcom'), '', true); if (!$this->debug) { $comment->save(); } $idMap[$commentId] = $comment->get('id'); } return true; }
public function loadCustomCssJs() { $this->prepareResource(); $managerUrl = $this->context->getOption('manager_url', MODX_MANAGER_URL, $this->modx->_userConfig); $articlesAssetsUrl = $this->modx->getOption('articles.assets_url', null, $this->modx->getOption('assets_url', null, MODX_ASSETS_URL) . 'components/articles/'); $connectorUrl = $articlesAssetsUrl . 'connector.php'; $articlesJsUrl = $articlesAssetsUrl . 'js/'; $this->resourceArray['articles_container_settings'] = $this->resource->getContainerSettings(); $this->resourceArray['isfolder'] = true; $this->addJavascript($managerUrl . 'assets/modext/util/datetime.js'); $this->addJavascript($managerUrl . 'assets/modext/widgets/element/modx.panel.tv.renders.js'); $this->addJavascript($managerUrl . 'assets/modext/widgets/resource/modx.grid.resource.security.js'); $this->addJavascript($managerUrl . 'assets/modext/widgets/resource/modx.panel.resource.tv.js'); $this->addJavascript($managerUrl . 'assets/modext/widgets/resource/modx.panel.resource.js'); $this->addJavascript($managerUrl . 'assets/modext/sections/resource/create.js'); $this->addJavascript($articlesJsUrl . 'articles.js'); $this->addJavascript($articlesJsUrl . 'container/container.common.js'); $this->addJavascript($articlesJsUrl . 'container/container.articles.grid.js'); $this->addLastJavascript($articlesJsUrl . 'container/create.js'); $this->addHtml(' <script type="text/javascript"> // <![CDATA[ Articles.assets_url = "' . $articlesAssetsUrl . '"; Articles.connector_url = "' . $connectorUrl . '"; MODx.config.publish_document = "' . $this->canPublish . '"; MODx.onDocFormRender = "' . $this->onDocFormRender . '"; MODx.ctx = "' . $this->resource->get('context_key') . '"; Ext.onReady(function() { MODx.load({ xtype: "articles-page-articles-container-create" ,resource: "' . $this->resource->get('id') . '" ,record: ' . $this->modx->toJSON($this->resourceArray) . ' ,publish_document: "' . $this->canPublish . '" ,canSave: ' . ($this->canSave ? 1 : 0) . ' ,canEdit: ' . ($this->canEdit ? 1 : 0) . ' ,canCreate: ' . ($this->canCreate ? 1 : 0) . ' ,canDuplicate: ' . ($this->canDuplicate ? 1 : 0) . ' ,canDelete: ' . ($this->canDelete ? 1 : 0) . ' ,show_tvs: ' . (!empty($this->tvCounts) ? 1 : 0) . ' ,mode: "create" }); }); // ]]> </script>'); /* load RTE */ $this->loadRichTextEditor(); }
/** * Import comments into Quip * * @param SimpleXMLElement $entry * @return boolean */ public function importComment(SimpleXMLElement $entry) { $settings = $this->container->getContainerSettings(); $dc = $entry->children('thr', true)->attributes(); $url = (string) $dc['href']; if (empty($this->hrefMap[$url])) { return false; } $articleId = $this->hrefMap[$url]; if ($this->debug) { $article = $this->modx->newObject('Article'); $article->set('id', 1); } else { /** @var Article $article */ $article = $this->modx->getObject('Article', $articleId); if (empty($article)) { return false; } } $threadKey = 'article-b' . $this->container->get('id') . '-' . $article->get('id'); /** @var quipThread $thread */ $thread = $this->modx->newObject('quipThread'); $thread->fromArray(array('createdon' => $article->get('publishedon'), 'moderated' => $this->modx->getOption('commentsModerated', $settings, 1), 'moderator_group' => $this->modx->getOption('commentsModeratorGroup', $settings, 'Administrator'), 'moderators' => $this->modx->getOption('commentsModerators', $settings, ''), 'resource' => $article->get('id'), 'idprefix' => 'qcom')); $thread->set('name', $threadKey); if (!$this->debug) { $thread->save(); } $email = (string) $entry->author->email; if ($email == '*****@*****.**') { $email = ''; } $commentId = (string) $entry->id; $creator = $this->matchCreator((string) $entry->author->name); if (empty($creator) && !empty($email)) { $creator = $this->matchCreator($email, 1, 'email'); } /** @var quipComment $comment */ $comment = $this->modx->newObject('quipComment'); $comment->fromArray(array('thread' => $threadKey, 'parent' => 0, 'author' => $creator, 'body' => (string) $entry->content, 'createdon' => strftime('%Y-%m-%d %H:%M:%S', strtotime((string) $entry->published)), 'approved' => strftime('%Y-%m-%d %H:%M:%S', strtotime((string) $entry->published)), 'name' => (string) $entry->author->name, 'email' => $email, 'website' => (string) $entry->author->uri, 'ip' => '', 'resource' => $article->get('id'), 'idprefix' => 'qcom'), '', true); $this->commentMap[$commentId] = $comment->get('id'); if (!$this->debug) { $comment->save(); } return true; }
public function loadCustomCssJs() { $managerUrl = $this->context->getOption('manager_url', MODX_MANAGER_URL, $this->modx->_userConfig); $articlesAssetsUrl = $this->modx->getOption('articles.assets_url', null, $this->modx->getOption('assets_url', null, MODX_ASSETS_URL) . 'components/articles/'); $quipAssetsUrl = $this->modx->getOption('quip.assets_url', null, $this->modx->getOption('assets_url', null, MODX_ASSETS_URL) . 'components/quip/'); $connectorUrl = $articlesAssetsUrl . 'connector.php'; $articlesJsUrl = $articlesAssetsUrl . 'js/'; $this->addJavascript($managerUrl . 'assets/modext/util/datetime.js'); $this->addJavascript($managerUrl . 'assets/modext/widgets/element/modx.panel.tv.renders.js'); $this->addJavascript($managerUrl . 'assets/modext/widgets/resource/modx.grid.resource.security.js'); $this->addJavascript($managerUrl . 'assets/modext/widgets/resource/modx.panel.resource.tv.js'); $this->addJavascript($managerUrl . 'assets/modext/widgets/resource/modx.panel.resource.js'); $this->addJavascript($managerUrl . 'assets/modext/sections/resource/update.js'); $this->addJavascript($articlesJsUrl . 'articles.js'); $this->addJavascript($articlesJsUrl . 'container/container.common.js'); $this->addJavascript($articlesJsUrl . 'container/container.articles.grid.js'); $this->addJavascript($articlesJsUrl . 'container/articles.import.window.js'); $this->addLastJavascript($articlesJsUrl . 'container/update.js'); $this->addCss($quipAssetsUrl . 'css/mgr.css'); $this->addJavascript($quipAssetsUrl . 'js/quip.js'); $this->addJavascript($quipAssetsUrl . 'js/widgets/comments.grid.js'); $this->addHtml('<script type="text/javascript"> Ext.onReady(function() { Quip.config = ' . $this->modx->toJSON(array()) . '; Quip.config.connector_url = "' . $quipAssetsUrl . 'connector.php"; Quip.request = ' . $this->modx->toJSON($_GET) . '; }); </script>'); $settings = $this->resource->getContainerSettings(); $this->resourceArray['articles_container_settings'] = $settings; $this->addHtml(' <script type="text/javascript"> // <![CDATA[ Articles.assets_url = "' . $articlesAssetsUrl . '"; Articles.connector_url = "' . $connectorUrl . '"; Articles.commentsEnabled = ' . ($this->modx->getOption('commentsEnabled', $settings, true) ? 1 : 0) . '; MODx.config.publish_document = "' . $this->canPublish . '"; MODx.onDocFormRender = "' . $this->onDocFormRender . '"; MODx.ctx = "' . $this->resource->get('context_key') . '"; Ext.onReady(function() { MODx.load({ xtype: "articles-page-container-update" ,resource: "' . $this->resource->get('id') . '" ,record: ' . $this->modx->toJSON($this->resourceArray) . ' ,publish_document: "' . $this->canPublish . '" ,preview_url: "' . $this->previewUrl . '" ,locked: ' . ($this->locked ? 1 : 0) . ' ,lockedText: "' . $this->lockedText . '" ,canSave: ' . ($this->canSave ? 1 : 0) . ' ,canEdit: ' . ($this->canEdit ? 1 : 0) . ' ,canCreate: ' . ($this->canCreate ? 1 : 0) . ' ,canDuplicate: ' . ($this->canDuplicate ? 1 : 0) . ' ,canDelete: ' . ($this->canDelete ? 1 : 0) . ' ,show_tvs: ' . (!empty($this->tvCounts) ? 1 : 0) . ' ,mode: "update" }); }); // ]]> </script>'); /* load RTE */ $this->loadRichTextEditor(); }