예제 #1
2
 public function __construct(Application $app, $config, Block $b, Page $c, Area $a)
 {
     parent::__construct();
     $p = new \Permissions($b);
     $this->permissions = $p;
     $this->block = $b;
     $this->page = $c;
     $this->area = $a;
     $this->setAttribute('data-block-menu', 'block-menu-b' . $b->getBlockID());
     $this->setAttribute('class', 'ccm-edit-mode-block-menu');
     $btw = $b->getBlockTypeObject();
     $btOriginal = $btw;
     $bID = $b->getBlockID();
     $aID = $a->getAreaID();
     $heightPlus = 20;
     $btHandle = $btw->getBlockTypeHandle();
     $editInline = false;
     if ($btw->supportsInlineEdit()) {
         $editInline = true;
     }
     if ($btw->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) {
         $_bi = $b->getInstance();
         $_bo = Block::getByID($_bi->getOriginalBlockID());
         $btOriginal = BlockType::getByHandle($_bo->getBlockTypeHandle());
         $btHandle = $btOriginal->getBlockTypeHandle();
         $heightPlus = 80;
         if ($btOriginal->supportsInlineEdit()) {
             $editInline = true;
         }
     }
     $canDesign = $p->canEditBlockDesign() && $config->get('concrete.design.enable_custom') == true;
     $canModifyGroups = $p->canEditBlockPermissions() && $config->get('concrete.permissions.model') != 'simple' && !$a->isGlobalArea();
     $canEditName = $p->canEditBlockName();
     $canEditCacheSettings = $p->canEditBlockCacheSettings();
     $canEditCustomTemplate = $p->canEditBlockCustomTemplate();
     $canScheduleGuestAccess = $config->get('concrete.permissions.model') != 'simple' && $p->canGuestsViewThisBlock() && $p->canScheduleGuestAccess() && !$a->isGlobalArea();
     $canAliasBlockOut = $c->isMasterCollection() && !$a->isGlobalArea();
     if ($canAliasBlockOut) {
         $ct = Type::getByID($c->getPageTypeID());
     }
     $isAlias = $b->isAlias();
     $u = new \User();
     $numChildren = !$isAlias ? $b->getNumChildren() : 0;
     if ($isAlias) {
         $deleteMessage = t('Do you want to delete this block?');
     } elseif ($numChildren) {
         $deleteMessage = t('Do you want to delete this block? This item is an original. If you delete it, you will delete all blocks aliased to it');
     } else {
         $deleteMessage = t('Do you want to delete this block?');
     }
     if ($btOriginal->getBlockTypeHandle() == BLOCK_HANDLE_STACK_PROXY) {
         if (is_object($_bo)) {
             $bi = $_bo->getInstance();
         } else {
             $bi = $b->getInstance();
         }
         $stack = \Stack::getByID($bi->stID);
         if (is_object($stack)) {
             $sp = new \Permissions($stack);
             if ($sp->canWrite()) {
                 $this->addItem(new LinkItem(\URL::to('/dashboard/blocks/stacks', 'view_details', $stack->getCollectionID()), t('Manage Stack Contents')));
             }
         }
     } else {
         if ($p->canEditBlock() && $b->isEditable()) {
             if ($editInline) {
                 if ($b->getBlockTypeHandle() == BLOCK_HANDLE_LAYOUT_PROXY) {
                     $this->addItem(new LinkItem('javascript:void(0)', t('Edit Layout'), ['data-menu-action' => 'edit_inline', 'data-area-enable-grid-container' => $a->isGridContainerEnabled(), 'data-area-grid-maximum-columns' => $a->getAreaGridMaximumColumns()]));
                 } else {
                     $this->addItem(new LinkItem('javascript:void(0)', t('Edit Block'), ['data-menu-action' => 'edit_inline', 'data-area-enable-grid-container' => $a->isGridContainerEnabled(), 'data-area-grid-maximum-columns' => $a->getAreaGridMaximumColumns()]));
                 }
             } else {
                 $this->addItem(new LinkItem('javascript:void(0)', t('Edit Block'), ['data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/edit'), 'dialog-title' => t('Edit %s', t($btOriginal->getBlockTypeName())), 'dialog-width' => $btOriginal->getBlockTypeInterfaceWidth(), 'dialog-height' => $btOriginal->getBlockTypeInterfaceHeight() + $heightPlus]));
             }
         }
     }
     if ($b->getBlockTypeHandle() != BLOCK_HANDLE_LAYOUT_PROXY && $b->getBlockTypeHandle() != BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY) {
         $this->addItem(new LinkItem('javascript:void(0)', t('Copy to Clipboard'), ['data-menu-action' => 'block_scrapbook', 'data-token' => $app->make('token')->generate('tools/clipboard/to')]));
     }
     if ($p->canDeleteBlock()) {
         $this->addItem(new LinkItem('javascript:void(0)', t('Delete'), ['data-menu-action' => 'delete_block', 'data-menu-delete-message' => $deleteMessage]));
     }
     if ($b->getBlockTypeHandle() != BLOCK_HANDLE_LAYOUT_PROXY) {
         if ($canDesign || $canEditCustomTemplate || $canEditName || $canEditCacheSettings) {
             $this->addItem(new DividerItem());
             if ($canDesign || $canEditCustomTemplate) {
                 $this->addItem(new LinkItem('#', t('Design & Custom Template'), ['data-menu-action' => 'block_design']));
             }
             if ($b->getBlockTypeHandle() != BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY && ($canEditName || $canEditCacheSettings)) {
                 $this->addItem(new LinkItem('#', t('Advanced'), ['dialog-title' => t('Advanced Block Settings'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/cache'), 'dialog-width' => 500, 'dialog-height' => 320]));
             }
         }
     }
     if ($b->getBlockTypeHandle() != BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY && ($canModifyGroups || $canScheduleGuestAccess || $canAliasBlockOut)) {
         $this->addItem(new DividerItem());
         if ($canModifyGroups) {
             $this->addItem(new LinkItem('#', t('Permissions'), ['dialog-title' => t('Block Permissions'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/permissions/list'), 'dialog-width' => 350, 'dialog-height' => 450]));
         }
         if ($canScheduleGuestAccess) {
             $this->addItem(new LinkItem('#', t('Schedule Guest Access'), ['dialog-title' => t('Schedule Guest Access'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/permissions/guest_access'), 'dialog-width' => 500, 'dialog-height' => 320]));
         }
         if ($canAliasBlockOut) {
             $this->addItem(new LinkItem('#', t('Setup on Child Pages'), ['dialog-title' => t('Setup on Child Pages'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/aliasing'), 'dialog-width' => 500, 'dialog-height' => 'auto']));
         }
     }
 }
 public function execute(ActionInterface $action)
 {
     // Grab the target item for the page's page type.
     $subject = $action->getSubject();
     $target = $action->getTarget();
     if ($subject->getType()) {
         $mapper = new PageType();
         $targetItemList = new TargetItemList($target->getBatch(), $mapper);
         $item = new Item($subject->getType());
         $targetItem = $targetItemList->getSelectedTargetItem($item);
         if (!$targetItem instanceof IgnoredTargetItem) {
             if ($targetItem instanceof UnmappedTargetItem) {
                 $action->getTarget()->addMessage(new Message(t('Page Type <strong>%s</strong> does not exist.', $item->getIdentifier())));
             } else {
                 $targetPageType = Type::getByID($targetItem->getItemID());
                 if (is_object($targetPageType)) {
                     $composerMapper = new ComposerOutputContent();
                     $composerTargetItemList = new TargetItemList($target->getBatch(), $composerMapper);
                     $items = $composerMapper->getPageTypeComposerOutputContentItems($targetPageType);
                     foreach ($items as $item) {
                         $targetItem = $composerTargetItemList->getSelectedTargetItem($item);
                         if ($targetItem instanceof UnmappedTargetItem) {
                             $action->getTarget()->addMessage(new Message(t('Mapped page type %s contains unmapped composer output block in %s area.', $targetPageType->getPageTypeDisplayName(), $item->getBlock()->getAreaHandle())));
                         }
                     }
                 }
             }
         }
     }
 }
예제 #3
0
 public function submit()
 {
     if ($this->token->validate('submit')) {
         $displayOrder = 0;
         if (is_array($this->post('frequent'))) {
             foreach ($this->post('frequent') as $ptID) {
                 $pt = Type::getByID($ptID);
                 if (is_object($pt)) {
                     $data = array('ptIsFrequentlyAdded' => 1, 'ptDisplayOrder' => $displayOrder);
                     $pt->update($data);
                     ++$displayOrder;
                 }
             }
         }
         if (is_array($this->post('infrequent'))) {
             foreach ($this->post('infrequent') as $ptID) {
                 $pt = Type::getByID($ptID);
                 if (is_object($pt)) {
                     $data = array('ptIsFrequentlyAdded' => 0, 'ptDisplayOrder' => $displayOrder);
                     $pt->update($data);
                     ++$displayOrder;
                 }
             }
         }
     } else {
         $this->error->add($this->token->getErrorMessage());
     }
     $er = new \Concrete\Core\Application\EditResponse($this->error);
     $er->setMessage(t('Order Saved.'));
     $er->outputJSON();
 }
예제 #4
0
 public function validatePageTypeRequest(Request $request)
 {
     $e = parent::validatePageTypeRequest($request);
     $type = PageType::getByID($request->request->get('ptID'));
     if (!$type instanceof PageType) {
         $e->add(t('You must choose the type of page these page types are published beneath.'));
     }
     return $e;
 }
예제 #5
0
 public function getItemsFromRequest($array)
 {
     $items = array();
     foreach ($array as $id) {
         $t = \Concrete\Core\Page\Type\Type::getByID($id);
         if (is_object($t)) {
             $type = new \PortlandLabs\Concrete5\MigrationTool\Entity\Export\PageType();
             $type->setItemId($t->getPageTypeID());
             $items[] = $type;
         }
     }
     return $items;
 }
예제 #6
0
 public function submit()
 {
     $e = $this->app->make('error');
     $pagetype = Type::getByID($this->request->request->get('ptID'));
     if (is_object($pagetype)) {
         $configuredTarget = $pagetype->getPageTypePublishTargetObject();
         $cParentID = $configuredTarget->getPageTypePublishTargetConfiguredTargetParentPageID();
         if (!$cParentID) {
             $cParentID = $this->request->request->get('cParentID');
         }
     }
     $parent = Page::getByID($cParentID);
     $template = null;
     if ($this->request->request->get('ptComposerPageTemplateID')) {
         $template = Template::getByID($this->request->request->get('ptComposerPageTemplateID'));
     }
     if (!is_object($template)) {
         $template = $pagetype->getPageTypeDefaultPageTemplateObject();
     }
     if (is_object($pagetype)) {
         $validator = $pagetype->getPageTypeValidatorObject();
         $e->add($validator->validateCreateDraftRequest($template));
         $e->add($validator->validatePublishLocationRequest($parent));
         if ($this->request->request('addPageComposeAction') == 'publish') {
             $e->add($validator->validatePublishDraftRequest());
         }
     }
     $pr = new EditResponse();
     $pr->setError($e);
     if (!$e->has()) {
         $d = $pagetype->createDraft($template);
         $d->setPageDraftTargetParentPageID($cParentID);
         $saver = $pagetype->getPageTypeSaverObject();
         $saver->saveForm($d);
         if ($this->request->request('addPageComposeAction') == 'publish' || $this->request->request('addPageComposeAction') == 'schedule') {
             $publishDateTime = false;
             if ($this->request->request->get('addPageComposeAction') == 'schedule') {
                 $dateTime = new DateTime();
                 $publishDateTime = $dateTime->translate('check-in-scheduler');
             }
             $pagetype->publish($d, $publishDateTime);
             $pr->setAdditionalDataAttribute('cParentID', $cParentID);
             $pr->setMessage(t('Page Added Successfully.'));
         } else {
             $pr->setRedirectURL($d->getCollectionLink(true));
         }
     }
     $pr->outputJSON();
 }
예제 #7
0
    public function submit()
    {
        $pagetype = Type::getByID($this->request->request->get('ptID'));
        if (is_object($pagetype)) {
            $configuredTarget = $pagetype->getPageTypePublishTargetObject();
            $cParentID = $configuredTarget->getPageTypePublishTargetConfiguredTargetParentPageID();
            if (!$cParentID) {
                $cParentID = $this->request->request->get('cParentID');
            }
        }
        list($e, $pagetype, $parent) = $this->checkPermissions(
            $this->request->request->get('ptID'),
            $cParentID
        );

        if ($this->request->request->get('ptComposerPageTemplateID')) {
            $template = Template::getByID($this->request->request->get('ptComposerPageTemplateID'));
        }
        if (!is_object($template)) {
            $template = $pagetype->getPageTypeDefaultPageTemplateObject();
        }

        if (is_object($pagetype)) {
            $validator = $pagetype->getPageTypeValidatorObject();
            $e->add($validator->validateCreateDraftRequest($template));
            if ($this->request->request('addPageComposeAction') == 'publish') {
                $e->add($validator->validatePublishDraftRequest());
            }
        }

        $pr = new EditResponse();
        $pr->setError($e);

        if (!$e->has()) {
            $d = $pagetype->createDraft($template);
            $d->setPageDraftTargetParentPageID($cParentID);
            $pagetype->savePageTypeComposerForm($d);
            if ($this->request->request('addPageComposeAction') == 'publish') {
                $pagetype->publish($d);
                $pr->setAdditionalDataAttribute('cParentID', $cParentID);
                $pr->setMessage(t('Page Added Successfully.'));
            } else {
                $pr->setRedirectURL($d->getCollectionLink(true));
            }
        }

        $pr->outputJSON();
    }
예제 #8
0
파일: add_blog.php 프로젝트: baardev/lbtb
 protected function loadblogSections()
 {
     $blogSectionList = new ProBlogList();
     $blogSectionList->filterByBlogSection(1);
     $blogSectionList->sortBy('cvName', 'asc');
     $tmpSections = $blogSectionList->get();
     $sections = array();
     foreach ($tmpSections as $_c) {
         $pt = CollectionType::getByID($_c->getCollectionTypeID());
         $cmp = new \Permissions($pt);
         $pp = $cmp->canAddPageType();
         if ($pp) {
             $this->pt = $pt;
             $sections[$_c->getCollectionID()] = $_c->getCollectionName();
         }
     }
     $this->sections = $sections;
     $this->set('sections', $this->sections);
 }
예제 #9
0
 public function submit()
 {
     if ($this->validateAction()) {
         $cp = $this->permissions;
         $c = $this->page;
         $nvc = $c->getVersionToModify();
         if ($this->permissions->canEditPageTheme()) {
             $pl = false;
             if ($_POST['pThemeID']) {
                 $pl = PageTheme::getByID($_POST['pThemeID']);
             }
             $data = array();
             if (is_object($pl)) {
                 $nvc->setTheme($pl);
             }
         }
         if (!$c->isGeneratedCollection()) {
             if ($_POST['pTemplateID'] && $cp->canEditPageTemplate()) {
                 // now we have to check to see if you're allowed to update this page to this page type.
                 // We do this by checking to see whether the PARENT page allows you to add this page type here.
                 // if this is the home page then we assume you are good
                 $template = PageTemplate::getByID($_POST['pTemplateID']);
                 $proceed = true;
                 $pagetype = $c->getPageTypeObject();
                 if (is_object($pagetype)) {
                     $templates = $pagetype->getPageTypePageTemplateObjects();
                     if (!in_array($template, $templates)) {
                         $proceed = false;
                     }
                 }
                 if ($proceed) {
                     $data['pTemplateID'] = $_POST['pTemplateID'];
                     $nvc->update($data);
                 }
             }
             if ($cp->canEditPageType()) {
                 $ptID = $c->getPageTypeID();
                 if ($ptID != $_POST['ptID']) {
                     // the page type has changed.
                     if ($_POST['ptID']) {
                         $type = Type::getByID($_POST['ptID']);
                         if (is_object($type)) {
                             $nvc->setPageType($type);
                         }
                     } else {
                         $nvc->setPageType(null);
                     }
                 }
             }
         }
         $r = new PageEditResponse();
         $r->setPage($c);
         if ($this->request->request->get('sitemap')) {
             $r->setMessage(t('Page updated successfully.'));
             if ($this->permissions->canApprovePageVersions() && Config::get('concrete.misc.sitemap_approve_immediately')) {
                 $pkr = new ApprovePageRequest();
                 $u = new User();
                 $pkr->setRequestedPage($this->page);
                 $v = Version::get($this->page, "RECENT");
                 $pkr->setRequestedVersionID($v->getVersionID());
                 $pkr->setRequesterUserID($u->getUserID());
                 $response = $pkr->trigger();
                 $u->unloadCollectionEdit();
             }
         } else {
             $r->setRedirectURL(\URL::to($c));
         }
         $r->outputJSON();
     }
 }
예제 #10
0
 /**
  * Returns the Collection Type handle.
  *
  * @return string
  */
 public function getPageTypeHandle()
 {
     if (!isset($this->ptHandle)) {
         $this->ptHandle = false;
         if ($this->ptID) {
             $pt = Type::getByID($this->ptID);
             if (is_object($pt)) {
                 $this->ptHandle = $pt->getPageTypeHandle();
             }
         }
     }
     return $this->ptHandle;
 }
예제 #11
0
파일: add_blog.php 프로젝트: baardev/lbtb
 /**
  * render Add Blog dialog
  */
 public function render()
 {
     $this->requireAsset('redactor');
     $this->requireAsset('core/file-manager');
     $blogify = Loader::helper('blogify');
     $settings = $blogify->getBlogSettings();
     $blogSectionList = new PageList();
     $blogSectionList->filter(false, "ak_blog_section = 1");
     $blogSectionList->sortBy('cvName', 'asc');
     $tmpSections = $blogSectionList->get();
     $sections = array();
     foreach ($tmpSections as $_c) {
         $pt = CollectionType::getByID($_c->getCollectionTypeID());
         $cmp = new \Permissions($pt);
         $pp = $cmp->canAddPageType();
         if ($pp) {
             $sections[$_c->getCollectionID()] = $_c->getCollectionName();
         }
     }
     $ctArray = PageTemplate::getList('');
     $pageTemplates = array();
     foreach ($ctArray as $ct) {
         $pms = new AddSubpagePageKey($ct);
         $pp = $pms->validate();
         if ($pp) {
             $pageTemplates[$ct->getPageTemplateID()] = $ct->getPageTemplateName();
         }
     }
     if ($_REQUEST['postID']) {
         $keys = array_keys($sections);
         $keys[] = -1;
         $current_page = Page::getByID($_REQUEST['postID']);
         $date = $current_page->getCollectionDatePublic();
         $canonical_parent_id = $blogify->getCanonicalParent($date, $current_page);
         $cParentID = $canonical_parent_id;
         if (in_array($canonical_parent_id, $keys)) {
             $this->blog = $current_page;
         }
     }
     if (is_object($this->blog)) {
         $blogTitle = $this->blog->getCollectionName();
         $blogDescription = $this->blog->getCollectionDescription();
         $blogDate = $this->blog->getCollectionDatePublic();
         $ptID = $this->blog->getPageTemplateID();
         $blogBody = '';
         $eb = $this->blog->getBlocks('Main');
         foreach ($eb as $b) {
             if ($b->getBlockTypeHandle() == 'content' || $b->getBlockTypeHandle() == 'core_page_type_composer_control_output') {
                 $blogBody = $b->getInstance()->getContent();
             }
         }
         echo "<div class=\"alert alert-success\"><span class=\"tooltip icon edit\"></span> " . t('You are now editing') . " <b><u>{$blogTitle}</u></b></div>";
         $task = 'editthis';
         $buttonText = t('Update Blog Entry');
         $title = 'Update';
     } else {
         $task = 'addthis';
         $buttonText = t('Add Blog Entry');
         $title = 'Add';
     }
     Loader::PackageElement('tools/add_blog', 'problog', array('blog' => $this->blog, 'blogTitle' => $blogTitle, 'blogDescription' => $blogDescription, 'blogBody' => $blogBody, 'sections' => $sections, 'pageTemplates' => $pageTemplates, 'buttonText' => $buttonText, 'ptID' => $ptID, 'settings' => $settings));
 }