Esempio n. 1
0
 public function submit()
 {
     if ($this->validateAction() && $this->canAccess()) {
         $a = \Area::get($this->page, $_GET['arHandle']);
         $c = $this->page;
         if (is_object($a)) {
             $b = \Block::getByID($_GET['bID'], $c, $a);
             $p = new \Permissions($b);
             if ($p->canAdminBlock() && $c->isMasterCollection()) {
                 if (is_array($_POST['cIDs'])) {
                     foreach ($_POST['cIDs'] as $cID) {
                         $nc = \Page::getByID($cID);
                         if (!$b->isAlias($nc)) {
                             $bt = $b->getBlockTypeObject();
                             if ($bt->isCopiedWhenPropagated()) {
                                 $b->duplicate($nc, true);
                             } else {
                                 $b->alias($nc);
                             }
                         }
                     }
                 }
                 // now remove any items that WERE checked and now aren't
                 if (is_array($_POST['checkedCIDs'])) {
                     foreach ($_POST['checkedCIDs'] as $cID) {
                         if (!is_array($_POST['cIDs']) || !in_array($cID, $_POST['cIDs'])) {
                             $nc = \Page::getByID($cID, 'RECENT');
                             $nb = \Block::getByID($_GET['bID'], $nc, $a);
                             if (is_object($nb) && !$nb->isError()) {
                                 $nb->deleteBlock();
                             }
                             $nc->rescanDisplayOrder($_REQUEST['arHandle']);
                         }
                     }
                 }
                 $er = new EditResponse();
                 $er->setPage($this->page);
                 $er->setAdditionalDataAttribute('bID', $b->getBlockID());
                 $er->setAdditionalDataAttribute('aID', $a->getAreaID());
                 $er->setAdditionalDataAttribute('arHandle', $a->getAreaHandle());
                 $er->setMessage(t('Defaults updated.'));
                 $er->outputJSON();
             }
         }
     }
 }
Esempio n. 2
0
 public function submit()
 {
     if ($this->validateAction()) {
         $b = $this->getBlockToEdit();
         if ($this->permissions->canEditBlockName()) {
             $b->setName($this->request->request->get('bName'));
         }
         if ($this->permissions->canEditBlockCacheSettings()) {
             $b->resetCustomCacheSettings();
             if ($this->request->request->get('cbOverrideBlockTypeCacheSettings')) {
                 $b->setCustomCacheSettings($this->request->request->get('btCacheBlockOutput'), $this->request->request->get('btCacheBlockOutputOnPost'), $this->request->request->get('btCacheBlockOutputForRegisteredUsers'), $this->request->request->get('btCacheBlockOutputLifetime'));
             }
         }
         $pr = new EditResponse();
         $pr->setPage($this->page);
         $pr->setAdditionalDataAttribute('aID', $this->area->getAreaID());
         $pr->setAdditionalDataAttribute('arHandle', $this->area->getAreaHandle());
         $pr->setAdditionalDataAttribute('bID', $b->getBlockID());
         $pr->setMessage(t('Advanced block settings saved successfully.'));
         $pr->outputJSON();
     }
 }
Esempio n. 3
0
 public function delete()
 {
     if ($this->validateAction()) {
         $preset = Preset::getByID($this->request->request('arLayoutPresetID'));
         if (!is_object($preset)) {
             throw new Exception(t('Invalid layout preset object.'));
         }
         $preset->delete();
         $pr = new EditResponse();
         $pr->setAdditionalDataAttribute('arLayoutPresetID', $preset->getAreaLayoutPresetID());
         $pr->outputJSON();
     }
 }
Esempio n. 4
0
 public function submit()
 {
     if ($this->validateAction() && $this->canAccess()) {
         $b = $this->getBlockToEdit();
         $oldStyle = $b->getCustomStyle();
         if (is_object($oldStyle)) {
             $oldStyleSet = $oldStyle->getStyleSet();
         }
         $r = $this->request->request->all();
         $set = StyleSet::populateFromRequest($this->request);
         if (is_object($set)) {
             $set->save();
             $b->setCustomStyleSet($set);
         } else {
             if ($oldStyleSet) {
                 $b->resetCustomStyle();
             }
         }
         if (isset($r['enableBlockContainer'])) {
             if ($r['enableBlockContainer'] === '-1') {
                 $b->resetBlockContainerSettings();
             }
             if ($r['enableBlockContainer'] === '0' || $r['enableBlockContainer'] === '1') {
                 $b->setCustomContainerSettings($r['enableBlockContainer']);
             }
         }
         if ($this->permissions->canEditBlockCustomTemplate()) {
             $data = array();
             $data['bFilename'] = $r['bFilename'];
             $b->updateBlockInformation($data);
         }
         $pr = new EditResponse();
         $pr->setPage($this->page);
         $pr->setAdditionalDataAttribute('aID', $this->area->getAreaID());
         $pr->setAdditionalDataAttribute('arHandle', $this->area->getAreaHandle());
         $pr->setAdditionalDataAttribute('originalBlockID', $this->block->getBlockID());
         if (is_object($oldStyleSet)) {
             $pr->setAdditionalDataAttribute('oldIssID', $oldStyleSet->getID());
         }
         if (is_object($set)) {
             $pr->setAdditionalDataAttribute('issID', $set->getID());
             $style = new CustomStyle($set, $b, $this->page->getCollectionThemeObject());
             $css = $style->getCSS();
             if ($css !== '') {
                 $pr->setAdditionalDataAttribute('css', $style->getStyleWrapper($css));
             }
         }
         $pr->setAdditionalDataAttribute('bID', $b->getBlockID());
         $pr->setMessage(t('Design updated.'));
         $pr->outputJSON();
     }
 }
Esempio n. 5
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();
 }
Esempio n. 6
0
 public function submit()
 {
     if ($this->validateAction() && $this->canAccess()) {
         $a = $this->area;
         $oldStyle = $this->page->getAreaCustomStyle($a);
         if (is_object($oldStyle)) {
             $oldStyleSet = $oldStyle->getStyleSet();
         }
         $nvc = $this->page->getVersionToModify();
         $r = $this->request->request->all();
         $set = new StyleSet();
         $set->setBackgroundColor($r['backgroundColor']);
         $set->setBackgroundImageFileID(intval($r['backgroundImageFileID']));
         $set->setBackgroundRepeat($r['backgroundRepeat']);
         $set->setLinkColor($r['linkColor']);
         $set->setTextColor($r['textColor']);
         $set->setBaseFontSize($r['baseFontSize']);
         $set->setMarginTop($r['marginTop']);
         $set->setMarginRight($r['marginRight']);
         $set->setMarginBottom($r['marginBottom']);
         $set->setMarginLeft($r['marginLeft']);
         $set->setPaddingTop($r['paddingTop']);
         $set->setPaddingRight($r['paddingRight']);
         $set->setPaddingBottom($r['paddingBottom']);
         $set->setPaddingLeft($r['paddingLeft']);
         $set->setBorderWidth($r['borderWidth']);
         $set->setBorderStyle($r['borderStyle']);
         $set->setBorderColor($r['borderColor']);
         $set->setBorderRadius($r['borderRadius']);
         $set->setAlignment($r['alignment']);
         $set->setRotate($r['rotate']);
         $set->setBoxShadowBlur($r['boxShadowBlur']);
         $set->setBoxShadowColor($r['boxShadowColor']);
         $set->setBoxShadowHorizontal($r['boxShadowHorizontal']);
         $set->setBoxShadowVertical($r['boxShadowVertical']);
         $set->setBoxShadowSpread($r['boxShadowSpread']);
         $set->setCustomClass($r['customClass']);
         $set->save();
         $nvc->setCustomStyleSet($a, $set);
         $pr = new EditResponse();
         $pr->setPage($this->page);
         $pr->setAdditionalDataAttribute('aID', $this->area->getAreaID());
         $pr->setAdditionalDataAttribute('arHandle', $this->area->getAreaHandle());
         $pr->setAdditionalDataAttribute('issID', $set->getID());
         if (is_object($oldStyleSet)) {
             $pr->setAdditionalDataAttribute('oldIssID', $oldStyleSet->getID());
         }
         $style = new CustomStyle($set, $this->area->getAreaHandle());
         $pr->setAdditionalDataAttribute('css', $style->getCSS());
         $pr->setAdditionalDataAttribute('containerClass', $style->getContainerClass());
         $pr->setMessage(t('Design updated.'));
         $pr->outputJSON();
     }
 }
Esempio n. 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();
 }
Esempio n. 8
0
    public function submit()
    {
        if ($this->validateAction() && $this->canAccess()) {

            $a = $this->area;
            $oldStyle = $this->page->getAreaCustomStyle($a);
            if (is_object($oldStyle)) {
                $oldStyleSet = $oldStyle->getStyleSet();
            }

            $nvc = $this->page->getVersionToModify();

            $set = StyleSet::populateFromRequest($this->request);
            if (is_object($set)) {
                $set->save();
                $nvc->setCustomStyleSet($a, $set);
            } else if ($oldStyleSet) {
                $nvc->resetAreaCustomStyle($this->area);
            }

            $pr = new EditResponse();
            $pr->setPage($this->page);
            $pr->setAdditionalDataAttribute('aID', $this->area->getAreaID());
            $pr->setAdditionalDataAttribute('arHandle', $this->area->getAreaHandle());

            if (is_object($oldStyleSet)) {
                $pr->setAdditionalDataAttribute('oldIssID', $oldStyleSet->getID());
            }

            if (is_object($set)) {
                $pr->setAdditionalDataAttribute('issID', $set->getID());
                $style = new CustomStyle($set, $this->area->getAreaHandle());
                $css = $style->getCSS();
                if ($css !== '') {
                    $pr->setAdditionalDataAttribute('css', $style->getCSS());
                }
                $pr->setAdditionalDataAttribute('containerClass', $style->getContainerClass());
            }

            $pr->setMessage(t('Design updated.'));
            $pr->outputJSON();
        }
    }
Esempio n. 9
0
 public function submit()
 {
     if ($this->validateAction() && $this->canAccess()) {
         $b = $this->getBlockToEdit();
         $oldStyle = $b->getCustomStyle();
         if (is_object($oldStyle)) {
             $oldStyleSet = $oldStyle->getStyleSet();
         }
         $r = $this->request->request->all();
         $set = new StyleSet();
         $set->setBackgroundColor($r['backgroundColor']);
         $set->setBackgroundImageFileID(intval($r['backgroundImageFileID']));
         $set->setBackgroundRepeat($r['backgroundRepeat']);
         $set->setLinkColor($r['linkColor']);
         $set->setTextColor($r['textColor']);
         $set->setBaseFontSize($r['baseFontSize']);
         $set->setMarginTop($r['marginTop']);
         $set->setMarginRight($r['marginRight']);
         $set->setMarginBottom($r['marginBottom']);
         $set->setMarginLeft($r['marginLeft']);
         $set->setPaddingTop($r['paddingTop']);
         $set->setPaddingRight($r['paddingRight']);
         $set->setPaddingBottom($r['paddingBottom']);
         $set->setPaddingLeft($r['paddingLeft']);
         $set->setBorderWidth($r['borderWidth']);
         $set->setBorderStyle($r['borderStyle']);
         $set->setBorderColor($r['borderColor']);
         $set->setBorderRadius($r['borderRadius']);
         $set->setAlignment($r['alignment']);
         $set->setRotate($r['rotate']);
         $set->setBoxShadowBlur($r['boxShadowBlur']);
         $set->setBoxShadowColor($r['boxShadowColor']);
         $set->setBoxShadowHorizontal($r['boxShadowHorizontal']);
         $set->setBoxShadowVertical($r['boxShadowVertical']);
         $set->setBoxShadowSpread($r['boxShadowSpread']);
         $set->setCustomClass($r['customClass']);
         $set->save();
         $b->setCustomStyleSet($set);
         if ($this->permissions->canEditBlockCustomTemplate()) {
             $data = array();
             $data['bFilename'] = $r['bFilename'];
             $data['bName'] = $r['bName'];
             $b->updateBlockInformation($data);
         }
         $pr = new EditResponse();
         $pr->setPage($this->page);
         $pr->setAdditionalDataAttribute('aID', $this->area->getAreaID());
         $pr->setAdditionalDataAttribute('arHandle', $this->area->getAreaHandle());
         $pr->setAdditionalDataAttribute('originalBlockID', $this->block->getBlockID());
         $pr->setAdditionalDataAttribute('issID', $set->getID());
         if (is_object($oldStyleSet)) {
             $pr->setAdditionalDataAttribute('oldIssID', $oldStyleSet->getID());
         }
         $style = new CustomStyle($set, $b->getBlockID(), $this->area->getAreaHandle());
         $pr->setAdditionalDataAttribute('css', $style->getCSS());
         $pr->setAdditionalDataAttribute('bID', $b->getBlockID());
         $pr->setMessage(t('Design updated.'));
         $pr->outputJSON();
     }
 }
Esempio n. 10
0
 public function create_new()
 {
     $pr = new PageEditResponse();
     $ms = Section::getByID($this->request->request->get('section'));
     // we get the related parent id
     if ($this->page->isPageDraft()) {
         $cParentID = $this->page->getPageDraftTargetParentPageID();
     } else {
         $cParentID = $this->page->getCollectionParentID();
     }
     $cParent = \Page::getByID($cParentID);
     $cParentRelatedID = $ms->getTranslatedPageID($cParent);
     if ($cParentRelatedID > 0) {
         // we copy the page underneath it and store it
         $ct = \PageType::getByID($this->page->getPageTypeID());
         if ($this->page->isPageDraft()) {
             $ptp = new \Permissions($ct);
             if (!$ptp->canAddPageType()) {
                 throw new \Exception(t('You do not have permission to add a page of this type.'));
             }
         }
         $newParent = \Page::getByID($cParentRelatedID);
         $cp = new \Permissions($newParent);
         if ($cp->canAddSubCollection($ct)) {
             if ($this->page->isPageDraft()) {
                 $targetParent = \Page::getByPath(\Config::get('concrete.paths.drafts'));
             } else {
                 $targetParent = $newParent;
             }
             $newPage = $this->page->duplicate($targetParent);
             if (is_object($newPage)) {
                 if ($this->page->isPageDraft()) {
                     $newPage->setPageDraftTargetParentPageID($newParent->getCollectionID());
                     Section::relatePage($this->page, $newPage, $ms->getLocale());
                     $pr->setMessage(t('New draft created.'));
                 } else {
                     // grab the approved version and unapprove it
                     $v = Version::get($newPage, 'ACTIVE');
                     if (is_object($v)) {
                         $v->deny();
                     }
                     $pr->setMessage(t('Unapproved page created. You must publish this page before it is live.'));
                 }
                 $ih = Core::make('multilingual/interface/flag');
                 $icon = (string) $ih->getSectionFlagIcon($ms);
                 $pr->setAdditionalDataAttribute('name', $newPage->getCollectionName());
                 $pr->setAdditionalDataAttribute('link', $newPage->getCollectionLink());
                 $pr->setAdditionalDataAttribute('icon', $icon);
             }
         } else {
             throw new \Exception(t('You do not have permission to add this page to this section of the tree.'));
         }
     }
     $pr->outputJSON();
 }
Esempio n. 11
0
 public function create_new()
 {
     $pr = new PageEditResponse();
     $ms = Section::getByID($this->request->request->get('section'));
     // we get the related parent id
     $cParentID = $this->page->getCollectionParentID();
     $cParent = \Page::getByID($cParentID);
     $cParentRelatedID = $ms->getTranslatedPageID($cParent);
     if ($cParentRelatedID > 0) {
         // we copy the page underneath it and store it
         $newParent = \Page::getByID($cParentRelatedID);
         $ct = \PageType::getByID($this->page->getPageTypeID());
         $cp = new \Permissions($newParent);
         if ($cp->canAddSubCollection($ct) && $this->page->canMoveCopyTo($newParent)) {
             $newPage = $this->page->duplicate($newParent);
             if (is_object($newPage)) {
                 // grab the approved version and unapprove it
                 $v = Version::get($newPage, 'ACTIVE');
                 if (is_object($v)) {
                     $v->deny();
                     $pkr = new ApprovePageRequest();
                     $pkr->setRequestedPage($newPage);
                     $u = new \User();
                     $pkr->setRequestedVersionID($v->getVersionID());
                     $pkr->setRequesterUserID($u->getUserID());
                     $response = $pkr->trigger();
                     if (!$response instanceof Response) {
                         // we are deferred
                         $pr->setMessage(t('<strong>Request Saved.</strong> You must complete the workflow before this change is active.'));
                     } else {
                         $ih = Core::make('multilingual/interface/flag');
                         $icon = $ih->getSectionFlagIcon($ms);
                         $pr->setAdditionalDataAttribute('name', $newPage->getCollectionName());
                         $pr->setAdditionalDataAttribute('link', $newPage->getCollectionLink());
                         $pr->setAdditionalDataAttribute('icon', $icon);
                         $pr->setMessage(t('Page created.'));
                     }
                 }
             }
         } else {
             throw new \Exception(t('You do not have permission to add this page to this section of the tree.'));
         }
     }
     $pr->outputJSON();
 }
Esempio n. 12
0
 public function setAdditionalDataAttribute($key, $value)
 {
     return parent::setAdditionalDataAttribute($key, $value);
 }