Exemple #1
0
    public function initialize(Zikula_Form_View $view)
    {
        $this->pageId = FormUtil::getPassedValue('pid', isset($this->args['pid']) ? $this->args['pid'] : null);

        if (!SecurityUtil::checkPermission('Content:page:', '::', ACCESS_ADD)) {
            throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
        }
        if (!SecurityUtil::checkPermission('Content:page:', $this->pageId . '::', ACCESS_EDIT)) {
            throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
        }

        $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId, 'filter' => array('checkActive' => false), 'includeContent' => false));
        if ($page === false) {
            throw new Zikula_Exception_Fatal($this->__('Page not found'));
        }

        // Only allow subpages if edit access on parent page
        if (!SecurityUtil::checkPermission('Content:page:', $page['id'] . '::', ACCESS_EDIT)) {
            throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
        }

        PageUtil::setVar('title', $this->__('Clone page') . ' : ' . $page['title']);

        $this->view->assign('page', $page);
        Content_Util::contentAddAccess($this->view, $this->pageId);

        return true;
    }
 public function pageSetVar($name, $value = null)
 {
     if (in_array($name, array('stylesheet', 'javascript'))) {
         $value = explode(',', $value);
     }
     \PageUtil::setVar($name, $value);
 }
Exemple #3
0
 public function initialize(Zikula_Form_View $view)
 {
     $this->pageId = FormUtil::getPassedValue('pid', isset($this->args['pid']) ? $this->args['pid'] : null);
     $offset = (int) FormUtil::getPassedValue('offset');
     if ((bool) $this->getVar('inheritPermissions', false) === true) {
         if (!ModUtil::apiFunc('Content', 'page', 'checkPermissionForPageInheritance', array('pageId' => $this->pageId, 'level' => ACCESS_EDIT))) {
             throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
         }
     } else {
         if (!SecurityUtil::checkPermission('Content:page:', $this->pageId . '::', ACCESS_EDIT)) {
             throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
         }
     }
     $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId, 'editing' => false, 'filter' => array('checkActive' => false), 'enableEscape' => true, 'translate' => false, 'includeContent' => false, 'includeCategories' => false));
     if ($page === false) {
         return $this->view->registerError(null);
     }
     $versionscnt = ModUtil::apiFunc('Content', 'History', 'getPageVersionsCount', array('pageId' => $this->pageId));
     $versions = ModUtil::apiFunc('Content', 'History', 'getPageVersions', array('pageId' => $this->pageId, 'offset' => $offset));
     if ($versions === false) {
         return $this->view->registerError(null);
     }
     $this->view->assign('page', $page);
     $this->view->assign('versions', $versions);
     Content_Util::contentAddAccess($this->view, $this->pageId);
     // Assign the values for the smarty plugin to produce a pager
     $this->view->assign('numitems', $versionscnt);
     PageUtil::setVar('title', $this->__("Page history") . ' : ' . $page['title']);
     if (!$this->view->isPostBack() && FormUtil::getPassedValue('back', 0)) {
         $this->backref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
     }
     return true;
 }
 public function initialize(Zikula_Form_View $view)
 {
     $this->contentId = (int) FormUtil::getPassedValue('cid', isset($this->args['cid']) ? $this->args['cid'] : -1);
     $this->language = ZLanguage::getLanguageCode();
     $content = ModUtil::apiFunc('Content', 'Content', 'getContent', array('id' => $this->contentId, 'language' => $this->language, 'translate' => false));
     if ($content === false) {
         return $this->view->registerError(null);
     }
     $this->contentType = ModUtil::apiFunc('Content', 'Content', 'getContentType', $content);
     if ($this->contentType === false) {
         return $this->view->registerError(null);
     }
     $this->pageId = $content['pageId'];
     if ((bool) $this->getVar('inheritPermissions', false) === true) {
         if (!ModUtil::apiFunc('Content', 'page', 'checkPermissionForPageInheritance', array('pageId' => $this->pageId, 'level' => ACCESS_EDIT))) {
             throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
         }
     } else {
         if (!SecurityUtil::checkPermission('Content:page:', $this->pageId . '::', ACCESS_EDIT)) {
             throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
         }
     }
     $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId, 'includeContent' => false, 'filter' => array('checkActive' => false)));
     if ($page === false) {
         return $this->view->registerError(null);
     }
     if ($this->language == $page['language']) {
         return $this->view->registerError(LogUtil::registerError($this->__f('Sorry, you cannot translate an item to the same language as it\'s default language ("%1$s"). Change the current site language ("%2$s") to some other language on the <a href="%3$s">localisation settings</a> page.<br /> Another way is to add, for instance, <strong>&amp;lang=de</strong> to the url for changing the current site language to German and after that the item can be translated to German.', array($page['language'], $this->language, ModUtil::url('Settings', 'admin', 'multilingual')))));
     }
     $translationInfo = ModUtil::apiFunc('Content', 'Content', 'getTranslationInfo', array('contentId' => $this->contentId));
     if ($translationInfo === false) {
         return $this->view->registerError(null);
     }
     PageUtil::setVar('title', $this->__("Translate content item") . ' : ' . $page['title']);
     $templates = $this->contentType['plugin']->getTranslationTemplates();
     $this->view->assign('translationtemplates', $templates);
     $this->view->assign('page', $page);
     $this->view->assign('data', $content['data']);
     $this->view->assign('isTranslatable', $content['isTranslatable']);
     $this->view->assign('translated', isset($content['translated']) ? $content['translated'] : array());
     $this->view->assign('translationInfo', $translationInfo);
     $this->view->assign('translationStep', $this->contentId);
     $this->view->assign('language', $this->language);
     $this->view->assign('contentType', $this->contentType);
     Content_Util::contentAddAccess($this->view, $this->pageId);
     if (!$this->view->isPostBack() && FormUtil::getPassedValue('back', 0)) {
         $this->backref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
     }
     if ($this->backref != null) {
         $returnUrl = $this->backref;
     } else {
         $returnUrl = ModUtil::url('Content', 'admin', 'editpage', array('pid' => $this->pageId));
     }
     ModUtil::apiFunc('PageLock', 'user', 'pageLock', array('lockName' => "contentTranslateContent{$this->contentId}", 'returnUrl' => $returnUrl));
     return true;
 }
Exemple #5
0
 public function initialize(Zikula_Form_View $view)
 {
     $this->pageId = (int) FormUtil::getPassedValue('pid', isset($this->args['pid']) ? $this->args['pid'] : -1);
     if ((bool) $this->getVar('inheritPermissions', false) === true) {
         if (!ModUtil::apiFunc('Content', 'page', 'checkPermissionForPageInheritance', array('pageId' => $this->pageId, 'level' => ACCESS_EDIT))) {
             throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
         }
     } else {
         if (!SecurityUtil::checkPermission('Content:page:', $this->pageId . '::', ACCESS_EDIT)) {
             throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
         }
     }
     $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId, 'editing' => true, 'filter' => array('checkActive' => false), 'enableEscape' => false, 'translate' => false, 'includeContent' => true, 'includeCategories' => true));
     if ($page === false) {
         return $this->view->registerError(null);
     }
     // load the category registry util
     $mainCategory = CategoryRegistryUtil::getRegisteredModuleCategory('Content', 'content_page', $this->getVar('categoryPropPrimary'), 30);
     $secondCategory = CategoryRegistryUtil::getRegisteredModuleCategory('Content', 'content_page', $this->getVar('categoryPropSecondary'));
     $multilingual = ModUtil::getVar(ModUtil::CONFIG_MODULE, 'multilingual');
     if ($page['language'] == ZLanguage::getLanguageCode()) {
         $multilingual = false;
     }
     PageUtil::setVar('title', $this->__("Edit page") . ' : ' . $page['title']);
     $pagelayout = ModUtil::apiFunc('Content', 'Layout', 'getLayout', array('layout' => $page['layout']));
     if ($pagelayout === false) {
         return $this->view->registerError(null);
     }
     $layouts = ModUtil::apiFunc('Content', 'Layout', 'getLayouts');
     if ($layouts === false) {
         return $this->view->registerError(null);
     }
     $layoutTemplate = $page['layoutEditTemplate'];
     $this->view->assign('layoutTemplate', $layoutTemplate);
     $this->view->assign('mainCategory', $mainCategory);
     $this->view->assign('secondCategory', $secondCategory);
     $this->view->assign('page', $page);
     $this->view->assign('multilingual', $multilingual);
     $this->view->assign('layouts', $layouts);
     $this->view->assign('pagelayout', $pagelayout);
     $this->view->assign('enableVersioning', $this->getVar('enableVersioning'));
     $this->view->assign('categoryUsage', $this->getVar('categoryUsage'));
     Content_Util::contentAddAccess($this->view, $this->pageId);
     if (!$this->view->isPostBack() && FormUtil::getPassedValue('back', 0)) {
         $this->backref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
     }
     if ($this->backref != null) {
         $returnUrl = $this->backref;
     } else {
         $returnUrl = ModUtil::url('Content', 'admin', 'main');
     }
     ModUtil::apiFunc('PageLock', 'user', 'pageLock', array('lockName' => "contentPage{$this->pageId}", 'returnUrl' => $returnUrl));
     return true;
 }
Exemple #6
0
 public function initialize(Zikula_Form_View $view)
 {
     $offset = (int) FormUtil::getPassedValue('offset');
     $versionscnt = ModUtil::apiFunc('Content', 'History', 'getDeletedPagesCount');
     $versions = ModUtil::apiFunc('Content', 'History', 'getDeletedPages', array('offset' => $offset));
     if ($versions === false) {
         return $this->view->registerError(null);
     }
     // Assign the values for the smarty plugin to produce a pager
     $this->view->assign('numitems', $versionscnt);
     foreach ($versions as &$version) {
         $version['data'] = unserialize($version['data']);
     }
     $this->view->assign('versions', $versions);
     PageUtil::setVar('title', $this->__("Restore deleted pages"));
     return true;
 }
/**
 * Zikula_View function to set page variable
 *
 * This function obtains a page-specific variable from the Zikula system.
 *
 * Available parameters:
 *   - name:     The name of the page variable to set
 *   - value:    The value of the page variable to set
 *
 * Zikula doesn't impose any restriction on the page variable's name except for duplicate
 * and reserved names. As of this writing, the list of reserved names consists of
 * <ul>
 * <li>title</li>
 * <li>stylesheet</li>
 * <li>javascript</li>
 * <li>body</li>
 * <li>header</li>
 * <li>footer</li>
 * </ul>
 * 
 * In addition, if your system is operating in legacy compatibility mode, then
 * the variable 'rawtext' is reserved, and maps to 'header'. (When not operating in
 * legacy compatibility mode, 'rawtext' is not reserved and will not be rendered
 * to the page output by the page variable output filter.)
 *
 * Example
 *   {pagesetvar name="title" value="mytitle"}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string
 */
function smarty_function_pagesetvar($params, Zikula_View $view)
{
    $name = isset($params['name']) ? $params['name'] : null;
    $value = isset($params['value']) ? $params['value'] : null;
    if (!$name) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pagesetvar', 'name')));
        return false;
    }
    if (!$value) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pagesetvar', 'value')));
        return false;
    }
    if (in_array($name, array('stylesheet', 'javascript'))) {
        $value = explode(',', $value);
    }
    PageUtil::setVar($name, $value);
}
Exemple #8
0
    public function initialize(Zikula_Form_View $view)
    {
        $this->pageId = (int) FormUtil::getPassedValue('pid', -1);
        $this->language = ZLanguage::getLanguageCode();

        if (!SecurityUtil::checkPermission('Content:page:', $this->pageId . '::', ACCESS_EDIT)) {
            throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
        }

        $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId, 'includeContent' => false, 'filter' => array('checkActive' => false), 'translate' => false));
        if ($page === false) {
            return $this->view->registerError(null);
        }

        // if trying to translate a page into the same language report error and redirect to page list
        if (!strcmp($this->language, $page['language'])) {
            return $this->view->registerError(LogUtil::registerError(
                $this->__f('Sorry, you cannot translate an item to the same language as it\'s default language ("%1$s"). Change the current site language ("%2$s") to some other language on the <a href="%3$s">localisation settings</a> page.<br /> Another way is to add, for instance, <strong>&amp;lang=de</strong> to the url for changing the current site language to German and after that the item can be translated to German.', array($page['language'], $this->language, ModUtil::url('Settings', 'admin', 'multilingual'))),
                null,
                ModUtil::url('Content', 'admin', 'main')));
        }

        PageUtil::setVar('title', $this->__("Translate page") . ' : ' . $page['title']);

        $this->view->assign('page', $page);
        $this->view->assign('translated', $page['translated']);
        $this->view->assign('language', $this->language);
        Content_Util::contentAddAccess($this->view, $this->pageId);

        if (!$this->view->isPostBack() && FormUtil::getPassedValue('back',0)) {
            $this->backref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
        }

        if ($this->backref != null) {
            $returnUrl = $this->backref;
        } else {
            $returnUrl = ModUtil::url('Content', 'admin', 'editPage', array('pid' => $this->pageId));
        }
        ModUtil::apiFunc('PageLock', 'user', 'pageLock',
                     array('lockName' => "contentTranslatePage{$this->pageId}",
                           'returnUrl' => $returnUrl));

        return true;
    }
Exemple #9
0
    public function initialize(Zikula_Form_View $view)
    {
        $this->pageId = FormUtil::getPassedValue('pid', isset($this->args['pid']) ? $this->args['pid'] : null);
        $this->location = FormUtil::getPassedValue('loc', isset($this->args['loc']) ? $this->args['loc'] : null);

        if (!SecurityUtil::checkPermission('Content:page:', '::', ACCESS_ADD)) {
            throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
        }

        // Only allow subpages if edit access on parent page
        if (!SecurityUtil::checkPermission('Content:page:', $this->pageId . '::', ACCESS_EDIT)) {
            throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
        }

        if ($this->pageId != null) {
            $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId, 'includeContent' => false, 'filter' => array('checkActive' => false)));
            if ($page === false) {
                return $this->view->registerError(null);
            }
        } else {
            $page = null;
        }

        $layouts = ModUtil::apiFunc('Content', 'Layout', 'getLayouts');
        if ($layouts === false) {
            return $this->view->registerError(null);
        }

        PageUtil::setVar('title', $this->__('Add new page'));

        $this->view->assign('layouts', $layouts);
        $this->view->assign('page', $page);
        $this->view->assign('location', $this->location);
        if ($this->location == 'sub') {
            $this->view->assign('locationLabel', $this->__('Located below:'));
        } else {
            $this->view->assign('locationLabel', $this->__('Located after:'));
        }
        Content_Util::contentAddAccess($this->view, $this->pageId);

        return true;
    }
Exemple #10
0
    public function initialize(Zikula_Form_View $view)
    {
        $this->pageId = FormUtil::getPassedValue('pid', isset($this->args['pid']) ? $this->args['pid'] : null);
        $this->contentAreaIndex = FormUtil::getPassedValue('cai', isset($this->args['cai']) ? $this->args['cai'] : null);
        $this->position = FormUtil::getPassedValue('pos', isset($this->args['pos']) ? $this->args['pos'] : 0);
        $this->contentId = FormUtil::getPassedValue('cid', isset($this->args['cid']) ? $this->args['cid'] : null);
        $this->above = FormUtil::getPassedValue('above', isset($this->args['above']) ? $this->args['above'] : 0);

        if ($this->contentId != null) {
            $content = ModUtil::apiFunc('Content', 'Content', 'getContent', array('id' => $this->contentId));
            if ($content === false) {
                return $this->view->registerError(null);
            }
            $this->pageId = $content['pageId'];
            $this->contentAreaIndex = $content['areaIndex'];
            $this->position = ($this->above ? $content['position'] : $content['position'] + 1);
        }

        if (!SecurityUtil::checkPermission('Content:page:', $this->pageId . '::', ACCESS_EDIT)) {
            throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
        }
        if ($this->pageId == null) {
            return $this->view->setErrorMsg($this->__("Missing page ID (pid) in URL"));
        }

        if ($this->contentAreaIndex == null) {
            return $this->view->setErrorMsg($this->__("Missing content area index (cai) in URL"));
        }

        $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId, 'filter' => array('checkActive' => false)));
        if ($page === false) {
            return $this->view->registerError(null);
        }

        PageUtil::setVar('title', $this->__("Add new content to page") . ' : ' . $page['title']);

        $this->view->assign('page', $page);
        $this->view->assign('htmlBody', 'admin/newcontent.tpl');
        Content_Util::contentAddAccess($this->view, $this->pageId);

        return true;
    }
/**
 * Zikula_View function to set page variable
 *
 * This function obtains a page-specific variable from the Zikula system.
 *
 * Available parameters:
 *   - name:     The name of the page variable to set
 *   - value:    The value of the page variable to set
 *
 * Zikula doesn't impose any restriction on the page variable's name except for duplicate
 * and reserved names. As of this writing, the list of reserved names consists of
 * <ul>
 * <li>title</li>
 * <li>stylesheet</li>
 * <li>javascript</li>
 * <li>body</li>
 * <li>header</li>
 * <li>footer</li>
 * </ul>
 *
 * In addition, if your system is operating in legacy compatibility mode, then
 * the variable 'rawtext' is reserved, and maps to 'header'. (When not operating in
 * legacy compatibility mode, 'rawtext' is not reserved and will not be rendered
 * to the page output by the page variable output filter.)
 *
 * Example
 *   {pagesetvar name="title" value="mytitle"}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string
 */
function smarty_function_pagesetvar($params, Zikula_View $view)
{
    $name = isset($params['name']) ? $params['name'] : null;
    $value = isset($params['value']) ? $params['value'] : null;
    if (!$name) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pagesetvar', 'name')));
        return false;
    }
    if (!$value) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pagesetvar', 'value')));
        return false;
    }
    // handle Clip which is manually loading a Theme's stylesheets
    if ($name == 'stylesheet' && false !== strpos($value, 'system/Theme/style/')) {
        $value = str_replace('system/Theme/style/', 'system/ThemeModule/Resources/public/css/', $value);
    }
    if (in_array($name, array('stylesheet', 'javascript'))) {
        $value = explode(',', $value);
    }
    PageUtil::setVar($name, $value);
}
Exemple #12
0
 public function initialize(Zikula_Form_View $view)
 {
     if (!SecurityUtil::checkPermission('Content:page:', '::', ACCESS_EDIT)) {
         throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
     }
     // Include categories only when 2nd category enabled in settings
     $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', array('editing' => true, 'filter' => array('checkActive' => false, 'expandedPageIds' => SessionUtil::getVar('contentExpandedPageIds', array())), 'enableEscape' => true, 'translate' => false, 'includeLanguages' => true, 'includeCategories' => $this->getVar('categoryUsage') < 3, 'orderBy' => 'setLeft'));
     if ($pages === false) {
         return $this->view->registerError(null);
     }
     // Get categories names if enabled
     if ($this->getVar('$categoryUsage') < 4) {
         $lang = ZLanguage::getLanguageCode();
         $categories = array();
         foreach ($pages as $page) {
             $cat = CategoryUtil::getCategoryByID($page['categoryId']);
             $categories[$page['id']] = array();
             $categories[$page['id']][] = isset($cat['display_name'][$lang]) ? $cat['display_name'][$lang] : $cat['name'];
             if (isset($page['categories']) && is_array($page['categories'])) {
                 foreach ($page['categories'] as $pageCat) {
                     $cat = CategoryUtil::getCategoryByID($pageCat['categoryId']);
                     $categories[$page['id']][] = isset($cat['display_name'][$lang]) ? $cat['display_name'][$lang] : $cat['name'];
                 }
             }
         }
         $this->view->assign('categories', $categories);
     }
     PageUtil::setVar('title', $this->__('Page list and content structure'));
     $csssrc = ThemeUtil::getModuleStylesheet('admin', 'admin.css');
     PageUtil::addVar('stylesheet', $csssrc);
     $this->view->assign('pages', $pages);
     $this->view->assign('multilingual', ModUtil::getVar(ModUtil::CONFIG_MODULE, 'multilingual'));
     $this->view->assign('enableVersioning', $this->getVar('enableVersioning'));
     $this->view->assign('language', ZLanguage::getLanguageCode());
     Content_Util::contentAddAccess($this->view, null);
     return true;
 }
Exemple #13
0
 /**
  * Initialise Zikula.
  *
  * Carries out a number of initialisation tasks to get Zikula up and
  * running.
  *
  * @param integer $stage Stage to load.
  *
  * @return boolean True initialisation successful false otherwise.
  */
 public function init($stage = self::STAGE_ALL)
 {
     $coreInitEvent = new Zikula_Event('core.init', $this);
     // store the load stages in a global so other API's can check whats loaded
     $this->stage = $this->stage | $stage;
     if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
         ModUtil::flushCache();
         System::flushCache();
         $this->eventManager->notify(new Zikula_Event('core.preinit', $this));
     }
     // Initialise and load configuration
     if ($stage & self::STAGE_CONFIG) {
         if (System::isLegacyMode()) {
             require_once 'lib/legacy/Compat.php';
         }
         // error reporting
         if (!System::isInstalling()) {
             // this is here because it depends on the config.php loading.
             $event = new Zikula_Event('setup.errorreporting', null, array('stage' => $stage));
             $this->eventManager->notify($event);
         }
         // initialise custom event listeners from config.php settings
         $coreInitEvent->setArg('stage', self::STAGE_CONFIG);
         $this->eventManager->notify($coreInitEvent);
     }
     // Check that Zikula is installed before continuing
     if (System::getVar('installed') == 0 && !System::isInstalling()) {
         System::redirect(System::getBaseUrl() . 'install.php?notinstalled');
         System::shutDown();
     }
     if ($stage & self::STAGE_DB) {
         try {
             $dbEvent = new Zikula_Event('core.init', $this, array('stage' => self::STAGE_DB));
             $this->eventManager->notify($dbEvent);
         } catch (PDOException $e) {
             if (!System::isInstalling()) {
                 header('HTTP/1.1 503 Service Unavailable');
                 require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
                 System::shutDown();
             } else {
                 return false;
             }
         }
     }
     if ($stage & self::STAGE_TABLES) {
         // Initialise dbtables
         ModUtil::dbInfoLoad('Extensions', 'Extensions');
         ModUtil::initCoreVars();
         ModUtil::dbInfoLoad('Settings', 'Settings');
         ModUtil::dbInfoLoad('Theme', 'Theme');
         ModUtil::dbInfoLoad('Users', 'Users');
         ModUtil::dbInfoLoad('Groups', 'Groups');
         ModUtil::dbInfoLoad('Permissions', 'Permissions');
         ModUtil::dbInfoLoad('Categories', 'Categories');
         if (!System::isInstalling()) {
             ModUtil::registerAutoloaders();
         }
         $coreInitEvent->setArg('stage', self::STAGE_TABLES);
         $this->eventManager->notify($coreInitEvent);
     }
     if ($stage & self::STAGE_SESSIONS) {
         SessionUtil::requireSession();
         $coreInitEvent->setArg('stage', self::STAGE_SESSIONS);
         $this->eventManager->notify($coreInitEvent);
     }
     // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
     // start block
     if ($stage & self::STAGE_LANGS) {
         $lang = ZLanguage::getInstance();
     }
     if ($stage & self::STAGE_DECODEURLS) {
         System::queryStringDecode();
         $coreInitEvent->setArg('stage', self::STAGE_DECODEURLS);
         $this->eventManager->notify($coreInitEvent);
     }
     if ($stage & self::STAGE_LANGS) {
         $lang->setup();
         $coreInitEvent->setArg('stage', self::STAGE_LANGS);
         $this->eventManager->notify($coreInitEvent);
     }
     // end block
     if ($stage & self::STAGE_MODS) {
         // Set compression on if desired
         if (System::getVar('UseCompression') == 1) {
             //ob_start("ob_gzhandler");
         }
         ModUtil::load('SecurityCenter');
         $coreInitEvent->setArg('stage', self::STAGE_MODS);
         $this->eventManager->notify($coreInitEvent);
     }
     if ($stage & self::STAGE_THEME) {
         // register default page vars
         PageUtil::registerVar('title');
         PageUtil::setVar('title', System::getVar('defaultpagetitle'));
         PageUtil::registerVar('keywords', true);
         PageUtil::registerVar('stylesheet', true);
         PageUtil::registerVar('javascript', true);
         PageUtil::registerVar('jsgettext', true);
         PageUtil::registerVar('body', true);
         PageUtil::registerVar('header', true);
         PageUtil::registerVar('footer', true);
         $theme = Zikula_View_Theme::getInstance();
         // set some defaults
         // Metadata for SEO
         $this->serviceManager['zikula_view.metatags']['description'] = System::getVar('defaultmetadescription');
         $this->serviceManager['zikula_view.metatags']['keywords'] = System::getVar('metakeywords');
         $coreInitEvent->setArg('stage', self::STAGE_THEME);
         $this->eventManager->notify($coreInitEvent);
     }
     // check the users status, if not 1 then log him out
     if (UserUtil::isLoggedIn()) {
         $userstatus = UserUtil::getVar('activated');
         if ($userstatus != Users_Constant::ACTIVATED_ACTIVE) {
             UserUtil::logout();
             // TODO - When getting logged out this way, the existing session is destroyed and
             //        then a new one is created on the reentry into index.php. The message
             //        set by the registerStatus call below gets lost.
             LogUtil::registerStatus(__('You have been logged out.'));
             System::redirect(ModUtil::url('Users', 'user', 'login'));
         }
     }
     if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) {
         $this->eventManager->notify(new Zikula_Event('core.postinit', $this, array('stages' => $stage)));
     }
 }
Exemple #14
0
 /**
  * View sitemap
  *
  * @return Renderer
  */
 public function sitemap($args)
 {
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('Content:page:', '::', ACCESS_READ), LogUtil::getErrorMsgPermission());
     $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', array('orderBy' => 'setLeft', 'makeTree' => true, 'filter' => array('checkInMenu' => true)));
     if ($pages === false) {
         return false;
     }
     if ($this->getVar('overrideTitle')) {
         PageUtil::setVar('title', $this->__('Sitemap'));
     }
     $this->view->assign('pages', $pages);
     Content_Util::contentAddAccess($this->view, null);
     $tpl = FormUtil::getPassedValue('tpl', '', 'GET');
     if ($tpl == 'xml') {
         $this->view->display('user/sitemap.xml');
         return true;
     }
     // Register a page variable breadcrumbs with the Content page hierarchy as array of array(url, title)
     if ((bool) $this->getVar('registerBreadcrumbs', false) === true) {
         // first include self, then loop over parents until root is reached
         $modInfo = $this->getModInfo();
         $breadcrumbs[] = array('url' => ModUtil::url('Content', 'user', 'sitemap'), 'title' => $modInfo['displayname'] . ' ' . $this->__('Sitemap'));
         PageUtil::registerVar('breadcrumbs', false, $breadcrumbs);
     }
     return $this->view->fetch('user/sitemap.tpl');
 }
Exemple #15
0
    /**
     * display item
     *
     * @author Mark West
     * @param 'sid'         The article ID
     * @param 'objectid'    generic object id maps to sid if present
     * @param 'page'        the starting page when pagebreak is used in the article
     * @param 'title'       article title, when sid is not used
     * @param 'year'        article year, when sid is not used
     * @param 'monthnum'    article monthnum, when sid is not used
     * @param 'monthname'   article monthname, when sid is not used
     * @param 'day'         article day, when sid is not used
     * @return string HTML string
     */
    public function display($args)
    {
        // Get parameters from whatever input we need
        $sid = (int)FormUtil::getPassedValue('sid', null, 'REQUEST');
        $objectid = (int)FormUtil::getPassedValue('objectid', null, 'REQUEST');
        $page = (int)FormUtil::getPassedValue('page', 1, 'REQUEST');
        $title = FormUtil::getPassedValue('title', null, 'REQUEST');
        $year = FormUtil::getPassedValue('year', null, 'REQUEST');
        $monthnum = FormUtil::getPassedValue('monthnum', null, 'REQUEST');
        $monthname = FormUtil::getPassedValue('monthname', null, 'REQUEST');
        $day = FormUtil::getPassedValue('day', null, 'REQUEST');

        // User functions of this type can be called by other modules
        extract($args);

        // At this stage we check to see if we have been passed $objectid, the
        // generic item identifier
        if ($objectid) {
            $sid = $objectid;
        }

        // Validate the essential parameters
        if ((empty($sid) || !is_numeric($sid)) && (empty($title))) {
            return LogUtil::registerArgsError();
        }
        if (!empty($title)) {
            unset($sid);
        }

        // Set the default page number
        if ($page < 1 || !is_numeric($page)) {
            $page = 1;
        }

        // increment the read count
        if ($page == 1) {
            if (isset($sid)) {
                ModUtil::apiFunc('News', 'user', 'incrementreadcount', array('sid' => $sid));
            } else {
                ModUtil::apiFunc('News', 'user', 'incrementreadcount', array('title' => $title));
            }
        }

        // Get the news story
        if (!SecurityUtil::checkPermission('News::', "::", ACCESS_ADD)) {
            if (isset($sid)) {
                $item = ModUtil::apiFunc('News', 'user', 'get', array('sid' => $sid,
                            'status' => 0));
            } else {
                $item = ModUtil::apiFunc('News', 'user', 'get', array('title' => $title,
                            'year' => $year,
                            'monthname' => $monthname,
                            'monthnum' => $monthnum,
                            'day' => $day,
                            'status' => 0));
                $sid = $item['sid'];
                System::queryStringSetVar('sid', $sid);
            }
        } else {
            if (isset($sid)) {
                $item = ModUtil::apiFunc('News', 'user', 'get', array('sid' => $sid));
            } else {
                $item = ModUtil::apiFunc('News', 'user', 'get', array('title' => $title,
                            'year' => $year,
                            'monthname' => $monthname,
                            'monthnum' => $monthnum,
                            'day' => $day));
                $sid = $item['sid'];
                System::queryStringSetVar('sid', $sid);
            }
        }

        if ($item === false) {
            return LogUtil::registerError($this->__('Error! No such article found.'), 404);
        }

        // For caching reasons you must pass a cache ID
        $accesslevel = ACCESS_READ;
        if (SecurityUtil::checkPermission('News::', "::", ACCESS_COMMENT)) $accesslevel = ACCESS_COMMENT;
        if (SecurityUtil::checkPermission('News::', "::", ACCESS_EDIT)) $accesslevel = ACCESS_EDIT;
        $pagedir = ($page>1) ? '|pg'. $page : '';
        $this->view->setCacheId($sid .'|a'. $accesslevel . $pagedir);

        // Explode the story into an array of seperate pages
        $allpages = explode('<!--pagebreak-->', $item['bodytext']);

        // Set the item bodytext to be the required page
        // nb arrays start from zero, pages from one
        $item['bodytext'] = $allpages[$page - 1];
        $numpages = count($allpages);
        unset($allpages);

        // If the pagecount is greater than 1 and we're not on the frontpage
        // don't show the hometext
        if ($numpages > 1 && $page > 1) {
            $item['hometext'] = '';
        }

        // $info is array holding raw information.
        // Used below and also passed to the theme - jgm
        $info = ModUtil::apiFunc('News', 'user', 'getArticleInfo', $item);

        // $links is an array holding pure URLs to specific functions for this article.
        // Used below and also passed to the theme - jgm
        $links = ModUtil::apiFunc('News', 'user', 'getArticleLinks', $info);

        // $preformat is an array holding chunks of preformatted text for this article.
        // Used below and also passed to the theme - jgm
        $preformat = ModUtil::apiFunc('News', 'user', 'getArticlePreformat', array('info' => $info,
                    'links' => $links));

        // set the page title
        if ($numpages <= 1) {
            PageUtil::setVar('title', $info['title']);
        } else {
            PageUtil::setVar('title', $info['title'] . ' :: ' . $this->__f('page %s', $page));
        }

        // Assign the story info arrays
        $this->view->assign(array('info' => $info,
            'links' => $links,
            'preformat' => $preformat,
            'page' => $page));

        $modvars = $this->getVars();
        $this->view->assign('lang', ZLanguage::getLanguageCode());
        $this->view->assign('catimagepath', $this->getVar('catimagepath'));

        // get more articletitles in the categories of this article
        if ($modvars['enablecategorization'] && $modvars['enablemorearticlesincat']) {
            // check how many articles to display
            if ($modvars['morearticlesincat'] > 0 && !empty($info['categories'])) {
                $morearticlesincat = $modvars['morearticlesincat'];
            } elseif ($modvars['morearticlesincat'] == 0 && is_array($info['attributes']) && array_key_exists('morearticlesincat', $info['attributes'])) {
                $morearticlesincat = $info['attributes']['morearticlesincat'];
            } else {
                $morearticlesincat = 0;
            }
            if ($morearticlesincat > 0) {
                // get the categories registered for News
                $catregistry = CategoryRegistryUtil::getRegisteredModuleCategories('News', 'news');
                foreach (array_keys($catregistry) as $property) {
                    $catFilter[$property] = $info['categories'][$property]['id'];
                }
                // get matching news articles
                $morearticlesincat = ModUtil::apiFunc('News', 'user', 'getall', array('numitems' => $morearticlesincat,
                            'status' => 0,
                            'filterbydate' => true,
                            'category' => $catFilter,
                            'catregistry' => $catregistry,
                            'query' => array(array('sid', '!=', $sid))));
            }
        } else {
            $morearticlesincat = 0;
        }
        $this->view->assign('morearticlesincat', $morearticlesincat);

        // Now lets assign the informatation to create a pager for the review
        $this->view->assign('pager', array('numitems' => $numpages,
            'itemsperpage' => 1));

        // Return the output that has been generated by this function
        return $this->view->fetch('user/article.tpl');
    }
Exemple #16
0
 /**
  * @param string $name
  * @param string $value
  */
 public function pageSetVar($name, $value)
 {
     if (empty($name) || empty($value)) {
         throw new \InvalidArgumentException(__('Empty argument at') . ':' . __FILE__ . '::' . __LINE__);
     }
     \PageUtil::setVar($name, $value);
 }
Exemple #17
0
<?php

// some needed variables common for all called files from site index.php
// include this at the front of each of them
include_once 'modules/ZphpBB2/lib/ZphpBB2/Util.php';
define('IN_PHPBB', true);
global $phpbb_root_path;
$phpbb_root_path = 'modules/ZphpBB2/vendor/phpBB2/';
global $minmax;
$minmax = FormUtil::getPassedValue('minmax', 0, 'GETPOST');
# ZphpBB2
if ($minmax == 1) {
    PageUtil::registerVar('sitemaxstate', false, 1);
    #ZphpBB2: to be available in theme, to mimic maximized forum
}
// to prevent errors when included from function
global $template;
// SEO
$page_title = ModUtil::getVar('ZphpBB2', 'page_title', '');
if ($page_title) {
    PageUtil::setVar('title', $page_title);
}
$page_description = ModUtil::getVar('ZphpBB2', 'page_description', '');
if ($page_description) {
    PageUtil::setVar('description', $page_description);
}
$page_robots = ModUtil::getVar('ZphpBB2', 'page_robots', '');
if ($page_robots) {
    $sm = ServiceUtil::getManager();
    $sm['zikula_view.metatags']['robots'] = $page_robots;
}
Exemple #18
0
 /**
  * Initialise Zikula.
  *
  * Carries out a number of initialisation tasks to get Zikula up and
  * running.
  *
  * @param integer             $stage Stage to load.
  * @param Zikula_Request_Http $request
  *
  * @return boolean True initialisation successful false otherwise.
  */
 public function init($stage = self::STAGE_ALL, Request $request)
 {
     $GLOBALS['__request'] = $request;
     // hack for pre 1.5.0 - drak
     $coreInitEvent = new GenericEvent($this);
     // store the load stages in a global so other API's can check whats loaded
     $this->stage = $this->stage | $stage;
     if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
         ModUtil::flushCache();
         System::flushCache();
         $args = !System::isInstalling() ? array('lazy' => true) : array();
         $this->dispatcher->dispatch('core.preinit', new GenericEvent($this, $args));
     }
     // Initialise and load configuration
     if ($stage & self::STAGE_CONFIG) {
         // for BC only. remove this code in 2.0.0
         if (!System::isInstalling()) {
             $this->dispatcher->dispatch('setup.errorreporting', new GenericEvent(null, array('stage' => $stage)));
         }
         // initialise custom event listeners from config.php settings
         $coreInitEvent->setArgument('stage', self::STAGE_CONFIG);
         /***************************************************
          * NOTE: this event is monitored by
          * \Zikula\Bundle\CoreInstallerBundle\EventListener\InstallUpgradeCheckListener
          * to see if install or upgrade is needed
          ***************************************************/
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_DB) {
         try {
             $dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
             $this->dispatcher->dispatch('core.init', $dbEvent);
         } catch (PDOException $e) {
             if (!System::isInstalling()) {
                 header('HTTP/1.1 503 Service Unavailable');
                 require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
                 System::shutDown();
             } else {
                 return false;
             }
         }
     }
     if ($stage & self::STAGE_TABLES) {
         // Initialise dbtables
         ModUtil::dbInfoLoad('ZikulaExtensionsModule', 'ZikulaExtensionsModule');
         ModUtil::initCoreVars();
         ModUtil::dbInfoLoad('ZikulaSettingsModule', 'ZikulaSettingsModule');
         ModUtil::dbInfoLoad('ZikulaThemeModule', 'ZikulaThemeModule');
         ModUtil::dbInfoLoad('ZikulaUsersModule', 'ZikulaUsersModule');
         ModUtil::dbInfoLoad('ZikulaGroupsModule', 'ZikulaGroupsModule');
         ModUtil::dbInfoLoad('ZikulaPermissionsModule', 'ZikulaPermissionsModule');
         ModUtil::dbInfoLoad('ZikulaCategoriesModule', 'ZikulaCategoriesModule');
         // Add AutoLoading for non-symfony 1.3 modules in /modules
         if (!System::isInstalling()) {
             ModUtil::registerAutoloaders();
         }
         $coreInitEvent->setArgument('stage', self::STAGE_TABLES);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_SESSIONS) {
         //            SessionUtil::requireSession();
         $coreInitEvent->setArgument('stage', self::STAGE_SESSIONS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
     // start block
     if ($stage & self::STAGE_LANGS) {
         $lang = ZLanguage::getInstance();
     }
     if ($stage & self::STAGE_DECODEURLS) {
         System::queryStringDecode($request);
         $coreInitEvent->setArgument('stage', self::STAGE_DECODEURLS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_LANGS) {
         $lang->setup($request);
         $coreInitEvent->setArgument('stage', self::STAGE_LANGS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // end block
     if ($stage & self::STAGE_MODS) {
         if (!System::isInstalling()) {
             ModUtil::load('ZikulaSecurityCenterModule');
         }
         $coreInitEvent->setArgument('stage', self::STAGE_MODS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_THEME) {
         // register default page vars
         PageUtil::registerVar('polyfill_features', true);
         PageUtil::registerVar('title');
         PageUtil::setVar('title', System::getVar('defaultpagetitle'));
         PageUtil::registerVar('keywords', true);
         PageUtil::registerVar('stylesheet', true);
         PageUtil::registerVar('javascript', true);
         PageUtil::registerVar('jsgettext', true);
         PageUtil::registerVar('body', true);
         PageUtil::registerVar('header', true);
         PageUtil::registerVar('footer', true);
         // set some defaults
         // Metadata for SEO
         $this->container->setParameter('zikula_view.metatags', array('description' => System::getVar('defaultmetadescription'), 'keywords' => System::getVar('metakeywords')));
         $coreInitEvent->setArgument('stage', self::STAGE_THEME);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // check the users status, if not 1 then log him out
     if (!System::isInstalling() && UserUtil::isLoggedIn()) {
         $userstatus = UserUtil::getVar('activated');
         if ($userstatus != Users_Constant::ACTIVATED_ACTIVE) {
             UserUtil::logout();
             // TODO - When getting logged out this way, the existing session is destroyed and
             //        then a new one is created on the reentry into index.php. The message
             //        set by the registerStatus call below gets lost.
             LogUtil::registerStatus(__('You have been logged out.'));
             System::redirect(ModUtil::url('ZikulaUsersModule', 'user', 'login'));
         }
     }
     if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) {
         $this->dispatcher->dispatch('core.postinit', new GenericEvent($this, array('stages' => $stage)));
     }
 }
Exemple #19
0
 /**
  * Initialise Zikula.
  *
  * Carries out a number of initialisation tasks to get Zikula up and
  * running.
  *
  * @param integer $stage Stage to load.
  *
  * @return boolean True initialisation successful false otherwise.
  */
 public function onInit(GetResponseEvent $event)
 {
     if ($event->getRequestType() === HttpKernelInterface::SUB_REQUEST) {
         return;
     }
     $this->dispatcher = $event->getDispatcher();
     $this->stage = $stage = self::STAGE_ALL;
     $coreInitEvent = new GenericEvent($this);
     $coreInitEvent['request'] = $event->getRequest();
     // store the load stages in a global so other API's can check whats loaded
     $this->dispatcher->dispatch(CoreEvents::PREINIT, new GenericEvent($this));
     //        // Initialise and load configuration
     //        if ($stage & self::STAGE_CONFIG) {
     //            // error reporting
     //            if (!\System::isInstalling()) {
     //                // this is here because it depends on the config.php loading.
     //                $event = new GenericEvent(null, array('stage' => $stage));
     //                $this->dispatcher->dispatch(CoreEvents::ERRORREPORTING, $event);
     //            }
     //
     //            // initialise custom event listeners from config.php settings
     //            $coreInitEvent->setArg('stage', self::STAGE_CONFIG);
     //            $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     //        }
     //        // Check that Zikula is installed before continuing
     //        if (\System::getVar('installed') == 0 && !\System::isInstalling()) {
     //            $response = new RedirectResponse(\System::getBaseUrl().'install.php?notinstalled');
     //            $response->send();
     //            \System::shutdown();
     //        }
     if ($stage & self::STAGE_DB) {
         try {
             $dbEvent = new GenericEvent();
             $this->dispatcher->dispatch('doctrine.init_connection', $dbEvent);
             $dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
             $this->dispatcher->dispatch(CoreEvents::INIT, $dbEvent);
         } catch (\PDOException $e) {
             if (!\System::isInstalling()) {
                 header('HTTP/1.1 503 Service Unavailable');
                 require_once \System::getSystemErrorTemplate('dbconnectionerror.tpl');
                 \System::shutDown();
             } else {
                 return false;
             }
         }
     }
     if ($stage & self::STAGE_TABLES) {
         // Initialise dbtables
         \ModUtil::initCoreVars();
         \ModUtil::dbInfoLoad('SettingsModule', 'SettingsModule');
         \ModUtil::dbInfoLoad('ThemeModule', 'ThemeModule');
         \ModUtil::dbInfoLoad('UsersModule', 'UsersModule');
         \ModUtil::dbInfoLoad('GroupsModule', 'GroupsModule');
         \ModUtil::dbInfoLoad('PermissionsModule', 'PermissionsModule');
         \ModUtil::dbInfoLoad('CategoriesModule', 'CategoriesModule');
         if (!\System::isInstalling()) {
             \ModUtil::registerAutoloaders();
         }
         $coreInitEvent->setArg('stage', self::STAGE_TABLES);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     if ($stage & self::STAGE_SESSIONS) {
         \SessionUtil::requireSession();
         $coreInitEvent->setArg('stage', self::STAGE_SESSIONS);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
     // start block
     if ($stage & self::STAGE_LANGS) {
         $lang = \ZLanguage::getInstance();
     }
     if ($stage & self::STAGE_DECODEURLS) {
         \System::queryStringDecode();
         $coreInitEvent->setArg('stage', self::STAGE_DECODEURLS);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     if ($stage & self::STAGE_LANGS) {
         $lang->setup();
         $coreInitEvent->setArg('stage', self::STAGE_LANGS);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     // end block
     if ($stage & self::STAGE_MODS) {
         // Set compression on if desired
         if (\System::getVar('UseCompression') == 1) {
             //ob_start("ob_gzhandler");
         }
         \ModUtil::load('SecurityCenter');
         $coreInitEvent->setArg('stage', self::STAGE_MODS);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     if ($stage & self::STAGE_THEME) {
         // register default page vars
         \PageUtil::registerVar('title');
         \PageUtil::setVar('title', \System::getVar('defaultpagetitle'));
         \PageUtil::registerVar('keywords', true);
         \PageUtil::registerVar('stylesheet', true);
         \PageUtil::registerVar('javascript', true);
         \PageUtil::registerVar('jsgettext', true);
         \PageUtil::registerVar('body', true);
         \PageUtil::registerVar('header', true);
         \PageUtil::registerVar('footer', true);
         $theme = \Zikula_View_Theme::getInstance();
         // set some defaults
         // Metadata for SEO
         $this->container['zikula_view.metatags']['description'] = \System::getVar('defaultmetadescription');
         $this->container['zikula_view.metatags']['keywords'] = \System::getVar('metakeywords');
         $coreInitEvent->setArg('stage', self::STAGE_THEME);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     // check the users status, if not 1 then log him out
     if (\UserUtil::isLoggedIn()) {
         $userstatus = \UserUtil::getVar('activated');
         if ($userstatus != UsersConstant::ACTIVATED_ACTIVE) {
             \UserUtil::logout();
             // TODO - When getting logged out this way, the existing session is destroyed and
             //        then a new one is created on the reentry into index.php. The message
             //        set by the registerStatus call below gets lost.
             \LogUtil::registerStatus(__('You have been logged out.'));
             $response = new RedirectResponse(\ModUtil::url('Users', 'user', 'login'));
             $response->send();
             exit;
         }
     }
     if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) {
         $this->dispatcher->dispatch(CoreEvents::POSTINIT, new GenericEvent($this, array('stages' => $stage)));
     }
     $this->dispatcher->dispatch('frontcontroller.predispatch', new GenericEvent());
 }
Exemple #20
0
    /**
     * View sitemap
     *
     * @return Renderer
     */
    public function sitemap($args)
    {
        $this->throwForbiddenUnless(SecurityUtil::checkPermission('Content:page:', '::', ACCESS_READ), LogUtil::getErrorMsgPermission());

        $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', array(
            'orderBy' => 'setLeft',
            'makeTree' => true,
            'filter' => array('checkInMenu' => true)));
        if ($pages === false)
            return false;

        if ($this->getVar('overrideTitle')) {
            PageUtil::setVar('title', $this->__('Sitemap'));
        }

        $this->view->assign('pages', $pages);
        Content_Util::contentAddAccess($this->view, null);

        $tpl = FormUtil::getPassedValue('tpl', '', 'GET');
        if ($tpl == 'xml') {
            $this->view->display('user/sitemap.xml');
            return true;
        }

        return $this->view->fetch('user/sitemap.tpl');
    }
Exemple #21
0
 /**
  * Initialise Zikula.
  *
  * Carries out a number of initialisation tasks to get Zikula up and
  * running.
  *
  * @param integer             $stage Stage to load.
  * @param Zikula_Request_Http $request
  *
  * @return boolean True initialisation successful false otherwise.
  */
 public function init($stage = self::STAGE_ALL, Request $request)
 {
     $GLOBALS['__request'] = $request;
     // hack for pre 1.5.0 - drak
     $coreInitEvent = new GenericEvent($this);
     // store the load stages in a global so other API's can check whats loaded
     $this->stage = $this->stage | $stage;
     if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
         ModUtil::flushCache();
         System::flushCache();
         $args = !System::isInstalling() ? array('lazy' => true) : array();
         $this->dispatcher->dispatch('core.preinit', new GenericEvent($this, $args));
     }
     // Initialise and load configuration
     if ($stage & self::STAGE_CONFIG) {
         // for BC only. remove this code in 2.0.0
         if (!System::isInstalling()) {
             $this->dispatcher->dispatch('setup.errorreporting', new GenericEvent(null, array('stage' => $stage)));
         }
         // initialise custom event listeners from config.php settings
         $coreInitEvent->setArgument('stage', self::STAGE_CONFIG);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // create several booleans to test condition of request regrading install/upgrade
     $installed = $this->getContainer()->getParameter('installed');
     if ($installed) {
         self::defineCurrentInstalledCoreVersion($this->getContainer());
     }
     $requiresUpgrade = $installed && version_compare(ZIKULACORE_CURRENT_INSTALLED_VERSION, self::VERSION_NUM, '<');
     // can't use $request->get('_route') to get any of the following
     // all these routes are hard-coded in xml files
     $uriContainsInstall = strpos($request->getRequestUri(), '/install') !== false;
     $uriContainsUpgrade = strpos($request->getRequestUri(), '/upgrade') !== false;
     $uriContainsDoc = strpos($request->getRequestUri(), '/installdoc') !== false;
     $uriContainsWdt = strpos($request->getRequestUri(), '/_wdt') !== false;
     $uriContainsProfiler = strpos($request->getRequestUri(), '/_profiler') !== false;
     $uriContainsRouter = strpos($request->getRequestUri(), '/js/routing?callback=fos.Router.setData') !== false;
     $doNotRedirect = $uriContainsProfiler || $uriContainsWdt || $uriContainsRouter || $request->isXmlHttpRequest();
     // check if Zikula Core is not installed
     if (!$installed && !$uriContainsDoc && !$uriContainsInstall && !$doNotRedirect) {
         $this->container->get('router')->getContext()->setBaseUrl($request->getBasePath());
         // compensate for sub-directory installs
         $url = $this->container->get('router')->generate('install');
         $response = new RedirectResponse($url);
         $response->send();
         System::shutDown();
     }
     // check if Zikula Core requires upgrade
     if ($requiresUpgrade && !$uriContainsDoc && !$uriContainsUpgrade && !$doNotRedirect) {
         $this->container->get('router')->getContext()->setBaseUrl($request->getBasePath());
         // compensate for sub-directory installs
         $url = $this->container->get('router')->generate('upgrade');
         $response = new RedirectResponse($url);
         $response->send();
         System::shutDown();
     }
     if (!$installed || $requiresUpgrade || $this->getContainer()->hasParameter('upgrading')) {
         System::setInstalling(true);
     }
     if ($stage & self::STAGE_DB) {
         try {
             $dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
             $this->dispatcher->dispatch('core.init', $dbEvent);
         } catch (PDOException $e) {
             if (!System::isInstalling()) {
                 header('HTTP/1.1 503 Service Unavailable');
                 require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
                 System::shutDown();
             } else {
                 return false;
             }
         }
     }
     if ($stage & self::STAGE_TABLES) {
         // Initialise dbtables
         ModUtil::dbInfoLoad('ZikulaExtensionsModule', 'ZikulaExtensionsModule');
         ModUtil::initCoreVars();
         ModUtil::dbInfoLoad('ZikulaSettingsModule', 'ZikulaSettingsModule');
         ModUtil::dbInfoLoad('ZikulaThemeModule', 'ZikulaThemeModule');
         ModUtil::dbInfoLoad('ZikulaUsersModule', 'ZikulaUsersModule');
         ModUtil::dbInfoLoad('ZikulaGroupsModule', 'ZikulaGroupsModule');
         ModUtil::dbInfoLoad('ZikulaPermissionsModule', 'ZikulaPermissionsModule');
         ModUtil::dbInfoLoad('ZikulaCategoriesModule', 'ZikulaCategoriesModule');
         // Add AutoLoading for non-symfony 1.3 modules in /modules
         if (!System::isInstalling()) {
             ModUtil::registerAutoloaders();
         }
         $coreInitEvent->setArgument('stage', self::STAGE_TABLES);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_SESSIONS) {
         //            SessionUtil::requireSession();
         $coreInitEvent->setArgument('stage', self::STAGE_SESSIONS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
     // start block
     if ($stage & self::STAGE_LANGS) {
         $lang = ZLanguage::getInstance();
     }
     if ($stage & self::STAGE_DECODEURLS) {
         System::queryStringDecode($request);
         $coreInitEvent->setArgument('stage', self::STAGE_DECODEURLS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_LANGS) {
         $lang->setup($request);
         $coreInitEvent->setArgument('stage', self::STAGE_LANGS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // end block
     if ($stage & self::STAGE_MODS) {
         if (!System::isInstalling()) {
             ModUtil::load('ZikulaSecurityCenterModule');
         }
         $coreInitEvent->setArgument('stage', self::STAGE_MODS);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     if ($stage & self::STAGE_THEME) {
         // register default page vars
         PageUtil::registerVar('polyfill_features', true);
         PageUtil::registerVar('title');
         PageUtil::setVar('title', System::getVar('defaultpagetitle'));
         PageUtil::registerVar('keywords', true);
         PageUtil::registerVar('stylesheet', true);
         PageUtil::registerVar('javascript', true);
         PageUtil::registerVar('jsgettext', true);
         PageUtil::registerVar('body', true);
         PageUtil::registerVar('header', true);
         PageUtil::registerVar('footer', true);
         // set some defaults
         // Metadata for SEO
         $this->container->setParameter('zikula_view.metatags', array('description' => System::getVar('defaultmetadescription'), 'keywords' => System::getVar('metakeywords')));
         $coreInitEvent->setArgument('stage', self::STAGE_THEME);
         $this->dispatcher->dispatch('core.init', $coreInitEvent);
     }
     // check the users status, if not 1 then log him out
     if (!System::isInstalling() && UserUtil::isLoggedIn()) {
         $userstatus = UserUtil::getVar('activated');
         if ($userstatus != Users_Constant::ACTIVATED_ACTIVE) {
             UserUtil::logout();
             // TODO - When getting logged out this way, the existing session is destroyed and
             //        then a new one is created on the reentry into index.php. The message
             //        set by the registerStatus call below gets lost.
             LogUtil::registerStatus(__('You have been logged out.'));
             System::redirect(ModUtil::url('ZikulaUsersModule', 'user', 'login'));
         }
     }
     if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) {
         $this->dispatcher->dispatch('core.postinit', new GenericEvent($this, array('stages' => $stage)));
     }
 }
Exemple #22
0
    public function initialize(Zikula_Form_View $view)
    {
        $this->contentId = (int) FormUtil::getPassedValue('cid', isset($this->args['cid']) ? $this->args['cid'] : -1);

        $content = ModUtil::apiFunc('Content', 'Content', 'getContent', array(
            'id' => $this->contentId,
            'translate' => false,
            'view' => $this->view));
        if ($content === false) {
            return $this->view->registerError(null);
        }
        $this->pageId = $content['pageId'];

        if (!SecurityUtil::checkPermission('Content:page:', $this->pageId . '::', ACCESS_EDIT)) {
            throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
        }

        if (isset($content['plugin'])) {
            $this->contentType['plugin'] = $content['plugin'];
            $this->contentType['module'] = $content['plugin']->getModule();
            $this->contentType['name'] = $content['plugin']->getName();
            $this->contentType['title'] = $content['plugin']->getTitle();
            $this->contentType['description'] = $content['plugin']->getDescription();
            $this->contentType['adminInfo'] = $content['plugin']->getAdminInfo();
            $this->contentType['isActive'] = $content['plugin']->isActive();
        } else {
            $this->contentType['name'] = $this->__('Unknown');
            $this->contentType['title'] = $this->__('Unknown plugin - requires upgrade');
            $this->contentType['description'] = $this->__('Disabled plugin - requires upgrade');
            $this->contentType['adminInfo'] = $this->__('Disabled plugin - requires upgrade');
            $this->contentType['isActive'] = false;
        }

        if ($this->contentType === false) {
            return $this->view->registerError(null);
        }

        $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array(
            'id' => $this->pageId,
            'includeContent' => false,
            'filter' => array('checkActive' => false)));
        if ($page === false) {
            return $this->view->registerError(null);
        }

        $editTemplate = "file:" . getcwd() . "/modules/Content/templates/contenttype/blank.tpl";
        if (isset($content['plugin'])) {
            $this->contentType['plugin']->setView($view);
            $this->contentType['plugin']->startEditing();
            $editTemplate = $this->contentType['plugin']->getEditTemplate();
        }

        $multilingual = ModUtil::getVar(ModUtil::CONFIG_MODULE, 'multilingual');
        if ($page['language'] == ZLanguage::getLanguageCode()) {
            $multilingual = false;
        }

        PageUtil::setVar('title', $this->__("Edit content item") . ' : ' . $page['title']);

        $this->view->assign('contentTypeTemplate', $editTemplate);

        $this->view->assign('page', $page);
        $this->view->assign('visiblefors', array(
            array('text' => $this->__('public (all)'),
                'value' => '1'),
            array('text' => $this->__('only logged in members'),
                'value' => '0'),
            array('text' => $this->__('only not logged in people'),
                'value' => '2')));
        $this->view->assign('content', $content);
        $this->view->assign('data', $content['data']);
        $this->view->assign('contentType', $this->contentType);
        $this->view->assign('multilingual', $multilingual);
        $this->view->assign('enableVersioning',  $this->getVar('enableVersioning'));
        Content_Util::contentAddAccess($this->view, $this->pageId);

        if (!$this->view->isPostBack() && FormUtil::getPassedValue('back', 0)) {
            $this->backref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
        }
        if ($this->backref != null) {
            $returnUrl = $this->backref;
        } else {
            $returnUrl = ModUtil::url('Content', 'admin', 'editpage', array('pid' => $this->pageId));
        }
        ModUtil::apiFunc('PageLock', 'user', 'pageLock', array(
            'lockName' => "contentContent{$this->contentId}",
            'returnUrl' => $returnUrl));

        return true;
    }
Exemple #23
0
 /**
  * This method provides a generic item detail view.
  *
  * @param string  $ot           Treated object type.
  * @param string  $tpl          Name of alternative template (for alternative display options, feeds and xml output)
  * @param boolean $raw          Optional way to display a template instead of fetching it (needed for standalone output)
  * @return mixed Output.
  */
 public function display($args)
 {
     // DEBUG: permission check aspect starts
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('MUBoard::', '::', ACCESS_READ));
     // DEBUG: permission check aspect ends
     // parameter specifying which type of objects we are treating
     $objectType = isset($args['ot']) && !empty($args['ot']) ? $args['ot'] : $this->request->getGet()->filter('ot', 'category', FILTER_SANITIZE_STRING);
     $utilArgs = array('controller' => 'user', 'action' => 'display');
     if (!in_array($objectType, MUBoard_Util_Controller::getObjectTypes('controllerAction', $utilArgs))) {
         $objectType = MUBoard_Util_Controller::getDefaultObjectType('controllerAction', $utilArgs);
     }
     $repository = $this->entityManager->getRepository('MUBoard_Entity_' . ucfirst($objectType));
     $idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $objectType));
     // retrieve identifier of the object we wish to view
     $idValues = MUBoard_Util_Controller::retrieveIdentifier($this->request, $args, $objectType, $idFields);
     $hasIdentifier = MUBoard_Util_Controller::isValidIdentifier($idValues);
     // check for unique permalinks (without id)
     $hasSlug = false;
     $slugTitle = '';
     if ($hasIdentifier === false) {
         $entityClass = 'MUBoard_Entity_' . ucfirst($objectType);
         $objectTemp = new $entityClass();
         $hasSlug = $objectTemp->get_hasUniqueSlug();
         if ($hasSlug) {
             $slugTitle = isset($args['title']) && !empty($args['title']) ? $args['title'] : $this->request->getGet()->filter('title', '', FILTER_SANITIZE_STRING);
             $hasSlug = !empty($slugTitle);
         }
     }
     $hasIdentifier |= $hasSlug;
     $this->throwNotFoundUnless($hasIdentifier, $this->__('Error! Invalid identifier received.'));
     $entity = ModUtil::apiFunc($this->name, 'selection', 'getEntity', array('ot' => $objectType, 'id' => $idValues, 'slug' => $slugTitle));
     $this->throwNotFoundUnless($entity != null, $this->__('No such item.'));
     // we take the children postings of the parent issue
     if ($objectType == 'posting') {
         $postingid = $entity['id'];
         $postingsWhere = 'tbl.parent = \'' . DataUtil::formatForStore($postingid) . '\'';
         $order = ModUtil::getVar($this->name, 'sortingPostings');
         if ($order == 'descending') {
             $sdir = 'desc';
         } else {
             $sdir = 'asc';
         }
         $selectionArgs = array('ot' => 'posting', 'where' => $postingsWhere, 'orderBy' => 'createdDate' . ' ' . $sdir);
         // the current offset which is used to calculate the pagination
         $currentPage = (int) (isset($args['pos']) && !empty($args['pos'])) ? $args['pos'] : $this->request->getGet()->filter('pos', 1, FILTER_VALIDATE_INT);
         // the number of items displayed on a page for pagination
         $resultsPerPage = (int) (isset($args['num']) && !empty($args['num'])) ? $args['num'] : $this->request->getGet()->filter('num', 0, FILTER_VALIDATE_INT);
         if ($resultsPerPage == 0) {
             $csv = (int) (isset($args['usecsv']) && !empty($args['usecsv'])) ? $args['usecsv'] : $this->request->getGet()->filter('usecsvext', 0, FILTER_VALIDATE_INT);
             $resultsPerPage = $csv == 1 ? 999999 : $this->getVar('pagesize', 10);
         }
         $selectionArgs['currentPage'] = $currentPage;
         $selectionArgs['resultsPerPage'] = $resultsPerPage;
         list($entities, $objectCount) = ModUtil::apiFunc($this->name, 'selection', 'getEntitiesPaginated', $selectionArgs);
         // we check if the user may see the form to answer to posting
         $mayEdit = MUBoard_Util_Controller::mayEdit($id);
         $this->view->assign('mayEdit', $mayEdit);
     }
     if ($objectType == 'forum') {
         $forumid = $entity['id'];
         $parentWhere = 'tbl.parent_id IS NULL';
         $parentWhere .= ' AND ';
         $parentWhere .= 'tbl.forum = \'' . DataUtil::formatForStore($forumid) . '\'';
         $order = ModUtil::getVar($this->name, 'sortingPostings');
         if ($order == 'descending') {
             $sdir = 'desc';
         } else {
             $sdir = 'asc';
         }
         $selectionArgs = array('ot' => 'posting', 'where' => $parentWhere, 'orderBy' => 'createdDate' . ' ' . $sdir);
         // the current offset which is used to calculate the pagination
         $currentPage = (int) (isset($args['pos']) && !empty($args['pos'])) ? $args['pos'] : $this->request->getGet()->filter('pos', 1, FILTER_VALIDATE_INT);
         // the number of items displayed on a page for pagination
         $resultsPerPage = (int) (isset($args['num']) && !empty($args['num'])) ? $args['num'] : $this->request->getGet()->filter('num', 0, FILTER_VALIDATE_INT);
         if ($resultsPerPage == 0) {
             $csv = (int) (isset($args['usecsv']) && !empty($args['usecsv'])) ? $args['usecsv'] : $this->request->getGet()->filter('usecsvext', 0, FILTER_VALIDATE_INT);
             $resultsPerPage = $csv == 1 ? 999999 : $this->getVar('pagesize', 10);
         }
         $selectionArgs['currentPage'] = $currentPage;
         $selectionArgs['resultsPerPage'] = $resultsPerPage;
         list($entities, $objectCount) = ModUtil::apiFunc($this->name, 'selection', 'getEntitiesPaginated', $selectionArgs);
     }
     // build ModUrl instance for display hooks
     $currentUrlArgs = array('ot' => $objectType);
     foreach ($idFields as $idField) {
         $currentUrlArgs[$idField] = $idValues[$idField];
     }
     // add a call to the posting
     if ($objectType == 'posting') {
         MUBoard_Util_Model::addView($idValues);
     }
     // get actual time
     $nowtime = DateUtil::getDatetime();
     // set sessionvar with calling time
     SessionUtil::setVar('muboardonline', $nowtime);
     $currentUrlObject = new Zikula_ModUrl($this->name, 'user', 'display', ZLanguage::getLanguageCode(), $currentUrlArgs);
     $type = $this->request->getGet()->filter('type', 'admin', FILTER_SANITIZE_STRING);
     $func = $this->request->getGet()->filter('func', 'view', FILTER_SANITIZE_STRING);
     $editPostings = ModUtil::getVar($this->name, 'editPostings');
     // assign output data to view object.
     $this->view->assign($objectType, $entity)->assign('postings', $entities)->assign('currentUrlObject', $currentUrlObject)->assign('func', $func)->assign('editPostings', $editPostings)->assign($repository->getAdditionalTemplateParameters('controllerAction', $utilArgs));
     $this->view->assign('currentPage', $currentPage)->assign('pager', array('numitems' => $objectCount, 'itemsperpage' => $resultsPerPage));
     $dom = ZLanguage::getModuleDomain($this->name);
     // we set Pagetitle
     $sitename = ModUtil::getVar('ZConfig', 'sitename');
     if ($objectType == 'category') {
         $titletobject = __('Forum - Category: ', $dom);
     }
     if ($objectType == 'forum') {
         $titletobject = __('Forum - Category: ', $dom) . ' ' . $entity['category']['title'] . ' - ' . __('Forum: ', $dom);
     }
     if ($objectType == 'posting') {
         $titletobject = 'Forum: ' . ' ' . $entity['forum']['title'] . ' - ' . __('Issue: ', $dom);
     }
     PageUtil::setVar('title', $sitename . ' - ' . $titletobject . ' ' . $entity['title']);
     // we set description
     if ($objectType == 'category' || $objectType == 'forum') {
         $descriptionobject = $entity['description'];
     }
     if ($objectType == 'posting') {
         $descriptionobject = $entity['text'];
         $descriptionobject = substr($descriptionobject, 0, 160) . '...';
     }
     PageUtil::setVar('description', $descriptionobject);
     // fetch and return the appropriate template
     return MUBoard_Util_View::processTemplate($this->view, 'user', $objectType, 'display', $args);
 }