示例#1
0
 /**
  * Renderize a view
  * <b>Note:</b> if the layout is set inside a view it will
  * overrive the layout set as parameter
  *
  * @param string $view
  * @param string $layout = null
  * @param boolean $return = false
  * @access public
  * @return void | string
  */
 public function render($view, $layout = null, $return = false)
 {
     $view = preg_replace('/\\.php$/i', '', $view);
     if ($layout) {
         $this->layout = $layout;
     }
     ob_start();
     require_once "views/{$view}.php";
     $body = ob_get_contents();
     ob_clean();
     if ($this->layout) {
         if (file_exists("views/layout/{$this->layout}.php")) {
             $js = '';
             $css = '';
             $widgets = array();
             if ($this->js) {
                 $js = array_map(create_function('$path', 'return "<script src=\\"{$path}\\" type=\\"text/javascript\\"></script>";'), $this->js);
                 $js = implode(PHP_EOL, $js);
             }
             if ($this->css) {
                 $css = array_map(create_function('$path', 'return "<link href=\\"{$path}\\" rel=\\"stylesheet\\" type=\\"text/css\\" />";'), $this->css);
                 $css = implode(PHP_EOL, $css);
             }
             if (count($this->widget->getWidgets()) > 0) {
                 $widgets = array();
                 foreach ($this->widget->getWidgets() as $widget) {
                     foreach ($widget['files'] as $file) {
                         if (preg_match('/\\.js$/i', $file)) {
                             $widgets[] = '<script src="' . URL::baseUrl() . $file . '" type="text/javascript"></script>';
                         } elseif (preg_match('/\\.css$/i', $file)) {
                             $widgets[] = '<link href="' . URL::baseUrl() . $file . '" rel="stylesheet" type="text/css" />';
                         }
                     }
                 }
                 $widgets = implode(PHP_EOL, $widgets);
             } else {
                 $widgets = '';
             }
             require_once "views/layout/{$this->layout}.php";
             $body = ob_get_contents();
             ob_clean();
         }
     }
     if ($return) {
         ob_end_clean();
         return $body;
     } else {
         print $body;
         ob_end_flush();
     }
 }
 /**
  * Creates a Widget object
  * @return ViewWidget
  */
 public function getWidget()
 {
     $sAction = $this->getRequest()->getVal('action', 'view');
     if (!in_array($sAction, array('view', 'historysubmit'))) {
         return null;
     }
     $oCurrentTitle = $this->getTitle();
     if ($oCurrentTitle->quickUserCan('universalexport-export') === false) {
         return null;
     }
     $aCurrentQueryParams = $this->getRequest()->getValues();
     $sTitle = isset($aCurrentQueryParams['title']) ? $aCurrentQueryParams['title'] : "";
     $sSpecialPageParameter = BsCore::sanitize($sTitle, '', BsPARAMTYPE::STRING);
     $oSpecialPage = SpecialPage::getTitleFor('UniversalExport', $sSpecialPageParameter);
     if (isset($aCurrentQueryParams['title'])) {
         unset($aCurrentQueryParams['title']);
     }
     $aModules = array();
     wfRunHooks('BSUniversalExportGetWidget', array($this, &$aModules, $oSpecialPage, $oCurrentTitle, $aCurrentQueryParams));
     if (empty($aModules)) {
         return null;
     }
     $sList = '';
     foreach ($aModules as $oModuleView) {
         if ($oModuleView instanceof ViewBaseElement) {
             $sList .= $oModuleView->execute();
         } else {
             wfDebugLog('BS::UniversalExport', 'getWidget: Invalid view.');
         }
     }
     $oWidgetView = new ViewWidget();
     $oWidgetView->setId('universalexport')->setTitle(wfMessage('bs-universalexport-widget-title')->plain())->setBody($sList)->setTooltip(wfMessage('bs-universalexport-widget-tooltip')->plain());
     return $oWidgetView;
 }
 /**
  * Callback for WidgetListHelper. Adds the WhoIsOnline Widget to the list if Keyword is found.
  * @return ViewWidget.
  */
 public function onWidgetListKeyword($oTitle)
 {
     wfProfileIn('BS::' . __METHOD__);
     $oWidgetView = new ViewWidget();
     $oWidgetView->setId('bs-extendedsearch-mlt')->setTitle(wfMessage('bs-extendedsearch-morelikethis')->plain())->setBody(ExtendedSearchBase::getInstance($this)->getViewMoreLikeThis($oTitle)->execute())->setTooltip(wfMessage('bs-extendedsearch-morelikethis')->plain())->setAdditionalBodyClasses(array('bs-nav-links', 'bs-extendedsearch-portlet'));
     //For correct margin and fontsize
     wfProfileOut('BS::' . __METHOD__);
     return $oWidgetView;
 }
 /**
  * Callback for WidgetListHelper. Adds the WhoIsOnline Widget to the list if Keyword is found.
  * @return ViewWidget.
  */
 public function onWidgetListKeyword()
 {
     wfProfileIn('BS::' . __METHOD__);
     $oWidgetView = new ViewWidget();
     $oWidgetView->setId('bs-whoisonline')->setTitle(wfMessage('bs-whoisonline-widget-title')->plain())->setBody($this->getPortlet(false, BsConfig::get('MW::WhoIsOnline::LimitCount'))->execute())->setTooltip(wfMessage('bs-whoisonline-widget-title')->plain())->setAdditionalBodyClasses(array('bs-nav-links', 'bs-whoisonline-portlet'));
     //For correct margin and fontsize
     wfProfileOut('BS::' . __METHOD__);
     return $oWidgetView;
 }
 /**
  * Renders widget view of SmartList. Called by MW::WidgetBar::DefaultWidgets.
  * @param BsEvent $oEvent The Event object
  * @param array $aWidgets An array of widgets. Add your Widget to this array.
  * @return bool allow other hooked methods to be executed. always true
  */
 public function onBSWidgetBarGetDefaultWidgets(&$aViews, $oUser, $oTitle)
 {
     $aArgs = array();
     $aArgs['count'] = (int) BsConfig::get('MW::SmartList::Count');
     $aArgs['namespaces'] = implode(',', BsConfig::get('MW::SmartList::Namespaces'));
     $aArgs['categories'] = implode(',', BsConfig::get('MW::SmartList::Categories'));
     $aArgs['categoryMode'] = 'OR';
     $aArgs['showMinorChanges'] = BsConfig::get('MW::SmartList::ShowMinorChanges');
     $aArgs['period'] = BsConfig::get('MW::SmartList::Period');
     $aArgs['mode'] = 'recentchanges';
     $aArgs['showOnlyNewArticles'] = BsConfig::get('MW::SmartList::ShowOnlyNewArticles');
     $aArgs['heading'] = wfMessage('bs-smartlist-recent-changes')->plain();
     $aArgs['trim'] = BsConfig::get('MW::SmartList::Trim');
     $aArgs['showtext'] = BsConfig::get('MW::SmartList::ShowText');
     $aArgs['trimtext'] = BsConfig::get('MW::SmartList::TrimText');
     $aArgs['order'] = BsConfig::get('MW::SmartList::Order');
     $aArgs['sort'] = BsConfig::get('MW::SmartList::Sort');
     $aArgs['showns'] = BsConfig::get('MW::SmartList::ShowNamespace');
     $sCustomList = $this->getCustomList($aArgs);
     $sHeading = wfMessage('bs-smartlist-recent-changes')->plain();
     $oWidgetView = new ViewWidget();
     $oWidgetView->setId('smartlist')->setTitle($sHeading)->setBody($sCustomList)->setTooltip($sHeading)->setAdditionalBodyClasses(array('bs-nav-links'));
     //For correct margin and fontsize
     $aViews['SMARTLIST'] = $oWidgetView;
     return true;
 }
 /**
  * Creates a Widget and returns it
  * @return ViewWidget
  */
 public function onWidgetListKeyword()
 {
     $oCurrentUser = $this->getUser();
     if ($oCurrentUser->isAnon()) {
         return null;
     }
     $iCount = BsConfig::get('MW::WatchList::WidgetLimit');
     $sOrder = BsConfig::get('MW::WatchList::WidgetSortOdr');
     //Validation
     $oValidationICount = BsValidator::isValid('IntegerRange', $iCount, array('fullResponse' => true, 'lowerBoundary' => 1, 'upperBoundary' => 30));
     if ($oValidationICount->getErrorCode()) {
         $iCount = 10;
     }
     if (!in_array($sOrder, array('pagename', 'time'))) {
         $sOrder = 'pagename';
     }
     $oUserSidebarView = new ViewWidget();
     $oUserSidebarView->setTitle(wfMessage('bs-watchlist-title-sidebar')->plain())->setAdditionalBodyClasses(array('bs-nav-links'));
     //For correct margin and fontsize
     $oWatchList = $this->fetchWatchlist($oCurrentUser, $iCount, 30, $sOrder);
     $sWatchListWikiText = $oWatchList->execute();
     if (empty($sWatchListWikiText)) {
         return $oUserSidebarView;
     }
     $oUserSidebarView->setBody($this->mCore->parseWikiText($sWatchListWikiText, $this->getTitle(), true), $this->getTitle());
     return $oUserSidebarView;
 }
 /**
  * Creates a Widget view object for the BlueSpice Skin.
  * @param array &$aViews List of Widget view objects from the BlueSpice Skin.
  */
 private function addWidgetView(&$aViews)
 {
     $iCount = BsConfig::get('MW::PagesVisited::WidgetLimit');
     $aNamespaces = BsConfig::get('MW::PagesVisited::WidgetNS');
     $sSortOrder = BsConfig::get('MW::PagesVisited::WidgetSortOdr');
     //Validation
     $oValidationICount = BsValidator::isValid('IntegerRange', $iCount, array('fullResponse' => true, 'lowerBoundary' => 1, 'upperBoundary' => 30));
     if ($oValidationICount->getErrorCode()) {
         $iCount = 10;
     }
     $iCurrentNamespaceId = $this->getTitle()->getNamespace();
     // TODO RBV (04.07.11 15:02): Rework method -> implode() is a workaround for legacy code.
     $oListView = $this->makePagesVisitedWikiList($iCount, implode(',', $aNamespaces), $iCurrentNamespaceId, 30, $sSortOrder);
     $sOut = $oListView->execute();
     if (!$oListView instanceof ViewTagError) {
         $sOut = $this->mCore->parseWikiText($sOut, $this->getTitle());
     }
     $oWidgetView = new ViewWidget();
     $oWidgetView->setTitle(wfMessage('bs-pagesvisited-widget-title')->plain())->setBody($sOut)->setAdditionalBodyClasses(array('bs-nav-links'));
     //For correct margin and fontsize
     $aViews[] = $oWidgetView;
 }
 /**
  * Creates a Widget and returns it
  * @return ViewWidget
  */
 public function onWidgetListKeyword()
 {
     $sTitle = wfMessage('bs-wantedarticle-tag-default-title')->plain();
     $aWishList = $this->getTitleListFromTitle($this->getDataSourceTemplateArticle()->getTitle());
     $sSort = BsConfig::get('MW::WantedArticle::Sort');
     switch ($sSort) {
         case 'title':
             $aTitleList = $this->sortWishListByTitle($aWishList);
             break;
         case 'time':
         default:
             $aTitleList = $this->getDefaultTitleList($aWishList);
     }
     if (BsConfig::get('MW::WantedArticle::Order') == 'DESC') {
         $aTitleList = array_reverse($aTitleList);
     }
     $iIncludeLimit = BsConfig::get('MW::WantedArticle::IncludeLimit');
     $iCount = count($aTitleList);
     $iCount = $iCount > $iIncludeLimit ? $iIncludeLimit : $iCount;
     $aWikiCodeList = array();
     $oTitle = null;
     $sWishTitle = '';
     for ($i = 0; $i < $iCount; $i++) {
         $oTitle = $aTitleList[$i];
         $sWishTitle = BsStringHelper::shorten($oTitle->getPrefixedText(), array('max-length' => 30, 'position' => 'middle'));
         $aWikiCodeList[] = '*' . BsLinkProvider::makeEscapedWikiLinkForTitle($oTitle, $sWishTitle);
     }
     $sBody = $this->mCore->parseWikiText(implode("\n", $aWikiCodeList), $this->getTitle());
     $oWidgetView = new ViewWidget();
     $oWidgetView->setTitle($sTitle)->setBody($sBody)->setTooltip($sTitle)->setAdditionalBodyClasses(array('bs-nav-links'));
     //For correct margin and fontsize
     return $oWidgetView;
 }