示例#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;
    }
示例#2
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;
 }
示例#3
0
 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;
 }
示例#4
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;
 }
示例#5
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;
    }
示例#6
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;
    }
示例#7
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;
    }
示例#8
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;
 }
示例#9
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;
    }
示例#10
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');
 }
示例#11
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');
    }