/** * This function build the middle page part taken it has three columns. * * @author Kalmer Piiskop * @param string $parameters['content'] * the content * @param string $parameters['currentSupporterLogos'] * the current supporter logos * @param User|boolean $parameters['user'] * the user or <code>FALSE</code> * @param string $parameters['id'] * the ID of the original object (optional) * @param string $parameters['type'] * the type of the original object * @param integer $parameters['idOfLanguage'] * the ID of the language * @param integer $parameters['idOfPageNews'] * the ID of the page news * @param boolean $parameters['isError'] * are we in the error state? * @param boolean $parameters['isIntro'] * is it the intro? * @param string $parameters['login'] * If the user is logged in then we display his/her link and the * options for logging in otherwise. * @param string[string] $parameters['outerNews'] * the outer news, either <code>first</code>, <code>second</code> or * <code>remaining</code> * @param string[string] $parameters['menus'] * the menus * @param Page $parameters['page'] * the page * @param PageNews|PageNews[integer] $parameters['pageNews'] * the page news * @param mixed $parameters['rss'] * the result of the RSS query * @param string $parameters['suffix'] * the suffix * @param integer $parameters['width'] * the width * @uses ALBUMS for Facebook things * @uses ALIAS_OF_PAGE for the page form * @uses ALIAS_OF_REQUISITES for the requisites form * @uses CACHE_FOLDER for the cache * @uses DOMAIN for addressing * @uses FB_API_KEY for Facebook's things * @uses FB_BADGE for the Facebook's badge * @uses IMAGES_FOLDER for accessing images * @uses O_FOLDER for common files * @uses LABEL_SHOW_PAGE_FORM_UPDATE for the label for showing the form * for updating the page * @uses LABEL_HIDE_PAGE_FORM_UPDATE for the label for hiding the form for * updating the page * @uses SystemMenuItemView for menus * @uses Model for translations * @uses NESTED_SET_MENU_MAIN_BUTTONS for main buttons * @uses OFFLINE for checkings whether we use the * internet connection * @uses PageNews for managing page news * @uses PageNewsView for managing page news * @uses Pic for images * @uses RSS_FEED for the outer news feed * @uses View for managing errors */ function buildNormal($parameters) { \PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array(new ErrorView(), 'raiseError')); $tpl = new \HTML_Template_IT(sprintf('%1$s/../assets/tpl/%2$u', dirname(__FILE__), $parameters['width'])); $tpl->loadTemplatefile('body.tpl'); if ($parameters['width'] > 899 && $parameters['width'] < 1301 || $parameters['width'] > 1799) { $bestPlayers = BodyView::buildBestPlayers(array('suffix' => $parameters['suffix'], 'width' => $parameters['width'])); } $idsOfNews = array(); require_once O_FOLDER . 'View.php'; if (isset($parameters['pageNews'])) { if (is_array($parameters['pageNews'])) { foreach ($parameters['pageNews'] as $idNews => $contentONews) { require_once O_FOLDER . 'uudised/PageNews.php'; $builtNews = PageNews::buildNewsContent(array('pageNews' => $contentONews, 'user' => $parameters['user'], 'width' => $parameters['width'])); } $idsOfNews = array_keys($parameters['pageNews']); } else { require_once O_FOLDER . 'uudised/PageNews.php'; $builtNews = PageNews::buildNewsContent(array('pageNews' => $parameters['pageNews'], 'user' => $parameters['user'], 'width' => $parameters['width'])); if ($parameters['pageNews']->getIdOfPageNews() > 0) { $idsOfNews[] = $parameters['pageNews']->getIdOfPageNews(); } } } else { $idOfPage = $parameters['page']->getId(); $title = $parameters['page']->translate(array('block' => 'title')); // echo ' 1096: <pre>';print_r($_SESSION);echo '</pre>'; $tpl->setCurrentBlock('page-content'); $tpl->setVariable(array('ADMINISTRATION-FOR-PAGE' => $parameters['page']->getTypeOfObject() === 'Page' && $parameters['page']->getId() != 0 ? View::buildButtonOfObject(array('alias' => ALIAS_OF_PAGE, 'buildNavigation' => TRUE, 'buildTarget' => TRUE, 'classes' => 'HandleForOpening', 'display' => is_object($parameters['user']) && $parameters['user']->isAllowed('u', $parameters['page']) ? 'inline' : 'none', 'forShow' => sprintf(LABEL_SHOW_PAGE_FORM_UPDATE, $title), 'forHide' => sprintf(LABEL_HIDE_PAGE_FORM_UPDATE, $title), 'highSlidable' => TRUE, 'id' => $idOfPage, 'idOfDiv' => 'Page' . $parameters['page']->getId(), 'insertionAddition' => '', 'longLabel' => TRUE, 'post' => '§AMPERSAND§draggable=true', 'type' => 'Page', 'width' => $parameters['width'])) : '', 'CONTENT-OF-USER-PAGE' => $parameters['page']->getTypeOfObject() === 'Page' && ID_OF_OPENING_PAGE != $idOfPage || $parameters['page']->getTypeOfObject() != 'Page' ? $parameters['content'] : '', 'DOMAIN-FOR-FACEBOOK' => DOMAIN, 'ID-OF-PAGE-IN-CONTENT' => $idOfPage, 'SLUG-FOR-FACEBOOK' => $parameters['page']->getSlug())); $tpl->parseCurrentBlock(); if ((!isset($parameters['isError']) || !$parameters['isError']) && $parameters['page']->getTypeOfObject() === 'Page' && sizeOf($parameters['page']->getNewsArray()) > 0) { $newsArray = $parameters['page']->getNewsArray(); if (isset($_GET['displayAllNews'])) { require_once O_FOLDER . 'uudised/PageNewsView.php'; $newsList = PageNewsView::buildNews(array('doWeDisplayAll' => FALSE, 'pageNews' => $newsArray, 'width' => $parameters['width'])); $idsOfNews = array_keys($newsArray['ids']); } else { if (sizeOf($parameters['page']->getCurrentNews()) > 0) { $currentNews = $parameters['page']->getCurrentNews(); require_once O_FOLDER . 'uudised/PageNewsView.php'; $newsList = PageNewsView::buildNews(array('doWeDisplayAll' => FALSE, 'pageNews' => $currentNews, 'width' => $parameters['width'])); $idsOfNews = array_keys($currentNews); if (sizeOf($currentNews) != sizeOf($parameters['page']->newsArray)) { $tpl->setCurrentBlock('all-news'); $tpl->setVariable(array('ID-OF-PAGE' => $parameters['page']->getId())); $tpl->parseCurrentBlock(); } } else { $newsArray = $parameters['page']->getNewsArray(); require_once O_FOLDER . 'uudised/PageNewsView.php'; $newsList = PageNewsView::buildNews(array('doWeDisplayAll' => FALSE, 'pageNews' => $newsArray, 'width' => $parameters['width'])); $idsOfNews = array_keys($newsArray['ids']); } } } } if (sizeOf($idsOfNews) > 0) { $tpl->setCurrentBlock('ids-of-news'); $tpl->setVariable(array('IDS-OF-NEWS' => implode(',', $idsOfNews))); $tpl->parseCurrentBlock(); } /* require_once dirname(__FILE__) . '/../pildid/Pic.php'; $images = Pic :: getImages(); $pathToRoot = Support :: getPathToRootDir(); foreach ($images as $idx => $img) { $picAddress = sprintf( '%1$s../originals/assets/images/gallery/%2$s/%3$s', $pathToRoot, // 1 $img['nimi'], // 2 $img['name'] // 3 ); if (is_readable($picAddress)) { $info = getimagesize($picAddress); switch ($info[2]) { case IMAGETYPE_GIF : { $pathToDerivative = sprintf( '%1$sgallery/%2$s/%3$s.120.gif', $this->pathToImages, // 1 $img['nimi'], // 2 $img['name'] // 3 ); break; } case IMAGETYPE_JPEG : { $pathToDerivative = sprintf( '%1$sgallery/%2$s/%3$s.120.jpg', $this->pathToImages, // 1 $img['nimi'], // 2 $img['name'] // 3 ); break; } case IMAGETYPE_PNG : { $pathToDerivative = sprintf( '%1$sgallery/%2$s/%3$s.120.png', $this->pathToImages, // 1 $img['nimi'], // 2 $img['name'] // 3 ); break; } default : { } } $tpl->setCurrentBlock('image'); $tpl->setVariable(array ( 'CAPTION-OF-IMAGE' => $img['caption'], 'ID-OF-EVENT' => $img['idEvent'], 'IMAGE' => $pathToDerivative, 'INDEX-OF-IMAGE' => $idx, 'NAME-OF-EVENT' => $img['nimi'], 'WIDTH' => $info[0], 'HEIGHT' => $info[1] )); $tpl->parseCurrentBlock(); } } */ if ($parameters['width'] > 320) { $page = new Page(); $pages = $page->getListOfTypePage(array('forAutocompletion' => FALSE)); // echo ' 1519: <pre>';print_r($psages); echo '</pre>'; require_once O_FOLDER . 'Support.php'; $sortedPages = Support::multiSort($pages, array('title' => TRUE, 'id' => TRUE)); foreach ($sortedPages as $page) { $pageToHandle = new Page(NULL, $page['id']); // echo ' 1528: <pre>';print_r(debug_print_backtrace()); echo '</pre>'; if (is_object($parameters['user']) && $parameters['user']->isAllowed('r', $pageToHandle) && $pageToHandle->isCompetitionPage()) { require_once 'puu/SystemMenuItem.php'; $menuEl = new SystemMenuItem(); require_once 'Slug.php'; $slug = new Slug(); $slug->setSlugOfSlug($pageToHandle->getSlug()); $slug->setSlugAccordingToSlug(); $menuEl->pageID = $slug->getIdOfSlug(); $menuEl->setTypeOfBoundObject('page'); $atLeastOneActive = $menuEl->setAttributes(FALSE, $page['id']); } } if (isset($_GET['page']) && $_GET['page'] == 1 && !isset($_GET['news']) && !OFFLINE) { $pathToRoot = Support::getPathToRootDir(); foreach ($images as $idx => $img) { $picAddress = sprintf('%1$s../originals/assets/images/gallery/%2$s/%3$s', $pathToRoot, $img['nimi'], $img['name']); if (is_readable($picAddress)) { $info = getimagesize($picAddress); switch ($info[2]) { case IMAGETYPE_GIF: $pathToDerivative = sprintf('%1$s%2$sgallery/%3$s/%4$s.367.gif', DOMAIN, IMAGES_FOLDER, $img['nimi'], $img['name']); break; case IMAGETYPE_JPEG: $pathToDerivative = sprintf('%1$s%2$sgallery/%3$s/%4$s.367.jpg', DOMAIN, IMAGES_FOLDER, $img['nimi'], $img['name']); break; case IMAGETYPE_PNG: $pathToDerivative = sprintf('%1$s%2$sgallery/%3$s/%4$s.367.png', DOMAIN, IMAGES_FOLDER, $img['nimi'], $img['name']); break; default: } $tpl->setCurrentBlock('image-in-gallery-in-news'); $tpl->setVariable(array('INDEX-OF-IMAGE-IN-GALLERY' => $idx, 'IMAGE-IN-GALLERY' => $pathToDerivative, 'ID-OF-EVENT-IN-GALLERY' => $img['idEvent'], 'NAME-OF-EVENT' => $img['nimi'], 'CAPTION-OF-IMAGE-IN-GALLERY' => $img['caption'])); $tpl->parseCurrentBlock(); } } $tpl->setCurrentBlock('gallery-in-news'); $tpl->setVariable(array('BEGINNING-OF-URL-FOR-GALLERY' => DOMAIN)); $tpl->parseCurrentBlock(); } } $bestPlayers = ''; if (!isset($parameters['isError']) || !$parameters['isError']) { if ($parameters['width'] > 899 && $parameters['width'] < 1301 || $parameters['width'] > 1799) { $bestPlayers = BodyView::buildBestPlayers(array('suffix' => $parameters['suffix'], 'width' => $parameters['width'])); } } require_once O_FOLDER . 'rekvisiidid/RequisitesView.php'; $tpl->setCurrentBlock('normal'); $tpl->setVariable(array('BADGE-IN-NORMAL' => FB_BADGE, 'BEST-PLAYERS-IN-NORMAL' => $bestPlayers, 'CURRENT-SUPPORTER-LOGOS' => isset($parameters['currentSupporterLogos']) ? $parameters['currentSupporterLogos'] : '', 'FACEBOOK-API-KEY' => FB_API_KEY, 'FIRST-OUTER-NEWS' => isset($parameters['isError']) && $parameters['isError'] || !isset($parameters['outerNews']['first']) ? '' : $parameters['outerNews']['first'], 'SECOND-OUTER-NEWS' => isset($parameters['isError']) && $parameters['isError'] || !isset($parameters['outerNews']['second']) ? '' : $parameters['outerNews']['second'], 'REMAINING-OUTER-NEWS' => isset($parameters['isError']) && $parameters['isError'] ? '' : (isset($parameters['outerNews']['remaining']) ? $parameters['outerNews']['remaining'] : $parameters['rss']), 'ID-OF-NEWS' => isset($parameters['idOfPageNews']) ? $parameters['idOfPageNews'] : '', 'LANGUAGES-IN-NORMAL' => isset($parameters['type']) ? BodyView::buildLanguageMenu(array('id' => isset($parameters['id']) ? $parameters['id'] : NULL, 'type' => $parameters['type'], 'suffix' => $parameters['suffix'], 'width' => $parameters['width'])) : '', 'LOGGED-IN' => $parameters['login'], 'MENU-LOGGED-IN-NORMAL' => isset($menus['loggedIn']) ? $menus['loggedIn'] : '', 'NEWS' => isset($builtNews) ? $builtNews : '', 'NEWS-LIST' => isset($newsList) ? $newsList : '', 'LOCATION-IN-NORMAL' => DOMAIN, 'MAIN-BUTTONS' => SystemMenuItemView::buildWrapperForMainButtons(array('menu' => $parameters['menus']['mainButtons'], 'width' => $parameters['width'])), 'MENU-WITH-PRIORITY-LEVEL-2' => isset($parameters['menus']['forMainAdministrator']) ? $parameters['menus']['forMainAdministrator'] : '', 'MENU-WITH-PRIORITY-LEVEL-OPEN' => isset($parameters['menus']['forRegisteredUser']) ? $parameters['menus']['forRegisteredUser'] : '', 'MENU-WITH-PRIORITY-PUBLIC' => isset($parameters['menus']['public']) ? $parameters['menus']['public'] : '', 'NESTED-SETS-IN-CURRENT-SUPPORTER-LOGOS' => NESTED_SET_SUPPORTERS, 'REQUISITES-IN-NORMAL' => \o\RequisitesView::buildRequisites(array('user' => $parameters['user'], 'width' => $parameters['width'])), 'USERNAME-IN-FACEBOOK-NORMAL' => ALBUMS)); $tpl->parseCurrentBlock(); return $tpl->get('normal'); }