public function componentSettings() { $articles = array(); $categories = array(); $_path_handle = opendir(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'fixtures' . DS); while ($article_name = readdir($_path_handle)) { if (mb_strpos($article_name, '.') === false) { if (mb_strpos($article_name, '%3A') !== false) { $article_elements = explode('%3A', $article_name); $category = array_shift($article_elements); $categories[mb_strtolower($category)] = $category; } else { $category = ''; } $articles[$article_name] = array('exists' => Article::doesArticleExist(urldecode($article_name)), 'category' => mb_strtolower($category)); } } ksort($articles, SORT_STRING); $this->articles = $articles; $this->categories = $categories; }
public static function createNew($name, $content, $scope = null, $options = array()) { $user_id = framework\Context::getUser() instanceof User ? framework\Context::getUser()->getID() : 0; $article = new Article(); $article->setName($name); $article->setContent($content); if (!isset($options['noauthor'])) { $article->setAuthor($user_id); } else { $article->setAuthor(0); } if ($scope !== null) { $article->setScope($scope); } $article->doSave($options); return $article->getID(); }
/** * Adds "notify once" settings for necessary articles * * @param \thebuggenie\modules\publish\entities\Article $article * @param array|\thebuggenie\core\entities\User $users */ protected function _markArticleSent(Article $article, $users) { foreach ($users as $user) { if ($user->getNotificationSetting(self::NOTIFY_ITEM_ONCE, false, 'mailing')->isOn()) { $user->setNotificationSetting(self::NOTIFY_ITEM_ONCE . '_article_' . $article->getID(), true, 'mailing')->save(); } } }
protected function _parse_insert_template($matches) { switch ($matches[1]) { case 'CURRENTMONTH': return date('m'); case 'CURRENTMONTHNAMEGEN': case 'CURRENTMONTHNAME': return date('F'); case 'CURRENTDAY': return date('d'); case 'CURRENTDAYNAME': return date('l'); case 'CURRENTYEAR': return date('Y'); case 'CURRENTTIME': return date('H:i'); case 'NUMBEROFARTICLES': return 0; case 'PAGENAME': return framework\Context::getResponse()->getPage(); case 'NAMESPACE': return 'None'; case 'TOC': return isset($this->options['included']) ? '' : '{{TOC}}'; case 'SITENAME': case 'SITETAGLINE': return \thebuggenie\core\framework\Settings::getSiteHeaderName(); default: $details = explode('|', $matches[1]); $template_name = array_shift($details); if (substr($template_name, 0, 1) == ':') { $template_name = substr($template_name, 1); } $template_name = Article::doesArticleExist($template_name) ? $template_name : 'Template:' . $template_name; $template_article = Articles::getTable()->getArticleByName($template_name); $parameters = array(); if (count($details)) { foreach ($details as $parameter) { $param = explode('=', $parameter); if (count($param) == 2) { $parameters[$param[0]] = $param[1]; } else { $parameters[] = $parameter; } } } if ($template_article instanceof Article) { return tbg_parse_text($template_article->getContent(), false, null, array('included' => true, 'parameters' => $parameters)); } else { return $matches[0]; } } }
public function runFindArticles(framework\Request $request) { $this->articlename = $request['articlename']; if ($this->articlename) { list($this->resultcount, $this->articles) = Article::findArticlesByContentAndProject($this->articlename, framework\Context::getCurrentProject(), 10); } }
public function componentAttachedfile() { if ($this->mode == 'issue' && !isset($this->issue)) { $this->issue = entities\Issue::getB2DBTable()->selectById($this->issue_id); } elseif ($this->mode == 'article' && !isset($this->article)) { $this->article = \thebuggenie\modules\publish\entities\Article::getByName($this->article_name); } $this->file_id = $this->file->getID(); }
public function listen_quicksearchDropdownFoundItems(framework\Event $event) { $searchterm = $event->getSubject(); list($resultcount, $articles) = Article::findArticlesByContentAndProject($searchterm, framework\Context::getCurrentProject()); framework\ActionComponent::includeComponent('publish/quicksearch_dropdown_founditems', array('searchterm' => $searchterm, 'articles' => $articles, 'resultcount' => $resultcount)); }
public function runDetachFile(framework\Request $request) { try { $file = entities\File::getB2DBTable()->selectById((int) $request['file_id']); switch ($request['mode']) { case 'issue': $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']); if ($issue instanceof entities\Issue && $issue->canRemoveAttachments() && (int) $request->getParameter('file_id', 0)) { $issue->detachFile($file); return $this->renderJSON(array('file_id' => $request['file_id'], 'attachmentcount' => count($issue->getFiles()) + count($issue->getLinks()), 'message' => framework\Context::getI18n()->__('The attachment has been removed'))); } $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('You can not remove items from this issue'))); case 'article': $article = \thebuggenie\modules\publish\entities\Article::getByID($request['article_id']); if ($article instanceof \thebuggenie\modules\publish\entities\Article && $article->canEdit() && (int) $request->getParameter('file_id', 0)) { $article->detachFile($file); return $this->renderJSON(array('file_id' => $request['file_id'], 'attachmentcount' => count($article->getFiles()), 'message' => framework\Context::getI18n()->__('The attachment has been removed'))); } $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('You can not remove items from this issue'))); } } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => $this->getI18n()->__('An error occurred when removing the file'))); } $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('Invalid mode'))); }