Esempio n. 1
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. 2
0
 public function testPopulateFromRequestSome()
 {
     $arguments = array('backgroundColor' => 'rgb(0,0,0)');
     $r = Request::create('http://www.foo.com', 'POST', $arguments);
     $set = StyleSet::populateFromRequest($r);
     $this->assertInstanceOf('\\Concrete\\Core\\StyleCustomizer\\Inline\\StyleSet', $set);
     $style = new CustomStyle($set, '100', 'Test');
     $this->assertEquals('.ccm-custom-style-container.ccm-custom-style-test-100{background-color:rgb(0,0,0)}', $style->getCSS());
     $arguments = array('backgroundColor' => '', 'backgroundImageFileID' => 10);
     $r = Request::create('http://www.foo.com', 'POST', $arguments);
     $set = StyleSet::populateFromRequest($r);
     $this->assertInstanceOf('\\Concrete\\Core\\StyleCustomizer\\Inline\\StyleSet', $set);
 }
Esempio n. 3
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();
     }
 }