Example #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 = 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();
     }
 }
Example #2
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();
     }
 }
 /**
  * @return CoreStyleSet
  */
 public function publish()
 {
     $o = new CoreStyleSet();
     $o->setBackgroundColor($this->styleSet->getBackgroundColor());
     $filename = $this->styleSet->getBackgroundImage();
     if ($filename) {
         $inspector = \Core::make('import/value_inspector');
         $result = $inspector->inspect($filename);
         $fID = $result->getReplacedValue();
         if ($fID) {
             $o->setBackgroundImageFileID($fID);
         }
     }
     $o->setBackgroundRepeat($this->styleSet->getBackgroundRepeat());
     $o->setBorderWidth($this->styleSet->getBorderWidth());
     $o->setBorderColor($this->styleSet->getBorderColor());
     $o->setBorderStyle($this->styleSet->getBorderStyle());
     $o->setBorderRadius($this->styleSet->getBorderRadius());
     $o->setBaseFontSize($this->styleSet->getBaseFontSize());
     $o->setAlignment($this->styleSet->getAlignment());
     $o->setTextColor($this->styleSet->getTextColor());
     $o->setLinkColor($this->styleSet->getLinkColor());
     $o->setPaddingTop($this->styleSet->getPaddingTop());
     $o->setPaddingBottom($this->styleSet->getPaddingBottom());
     $o->setPaddingLeft($this->styleSet->getPaddingLeft());
     $o->setPaddingRight($this->styleSet->getPaddingRight());
     $o->setMarginTop($this->styleSet->getMarginTop());
     $o->setMarginBottom($this->styleSet->getMarginBottom());
     $o->setMarginLeft($this->styleSet->getMarginLeft());
     $o->setMarginRight($this->styleSet->getMarginRight());
     $o->setRotate($this->styleSet->getRotate());
     $o->setBoxShadowHorizontal($this->styleSet->getBoxShadowHorizontal());
     $o->setBoxShadowVertical($this->styleSet->getBoxShadowVertical());
     $o->setBoxShadowSpread($this->styleSet->getBoxShadowSpread());
     $o->setBoxShadowBlur($this->styleSet->getBoxShadowBlur());
     $o->setBoxShadowColor($this->styleSet->getBoxShadowColor());
     $o->setCustomClass($this->styleSet->getCustomClass());
     $o->setHideOnExtraSmallDevice($this->styleSet->getHideOnExtraSmallDevice());
     $o->setHideOnSmallDevice($this->styleSet->getHideOnSmallDevice());
     $o->setHideOnMediumDevice($this->styleSet->getHideOnMediumDevice());
     $o->setHideOnLargeDevice($this->styleSet->getHideOnLargeDevice());
     $o->save();
     return $o;
 }
 /**
  * {@inheritDoc}
  */
 public function setBorderColor($borderColor)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setBorderColor', array($borderColor));
     return parent::setBorderColor($borderColor);
 }
Example #5
0
 /**
  * If the request contains any fields that are valid to save as a style set, we return the style set object
  * pre-save. If it's not (e.g. there's a background repeat but no actual background image, empty strings, etc...)
  * then we return null.
  * return \Concrete\Core\StyleCustomizer\Inline\StyleSet|null
  * @param Request $request
  */
 public static function populateFromRequest(Request $request)
 {
     $r = $request->request->all();
     $set = new StyleSet();
     $return = false;
     if (trim($r['backgroundColor']) != '') {
         $set->setBackgroundColor($r['backgroundColor']);
         $set->setBackgroundRepeat($r['backgroundRepeat']);
         $return = true;
     }
     $fID = intval($r['backgroundImageFileID']);
     if ($fID > 0) {
         $set->setBackgroundImageFileID($fID);
         $set->setBackgroundRepeat($r['backgroundRepeat']);
         $return = true;
     }
     if (isset($r['hideOnDevice'])) {
         if (isset($r['hideOnDevice'][GridFramework::DEVICE_CLASSES_HIDE_ON_EXTRA_SMALL]) && $r['hideOnDevice'][GridFramework::DEVICE_CLASSES_HIDE_ON_EXTRA_SMALL] == 1) {
             $set->setHideOnExtraSmallDevice(true);
             $return = true;
         }
         if (isset($r['hideOnDevice'][GridFramework::DEVICE_CLASSES_HIDE_ON_SMALL]) && $r['hideOnDevice'][GridFramework::DEVICE_CLASSES_HIDE_ON_SMALL] == 1) {
             $set->setHideOnSmallDevice(true);
             $return = true;
         }
         if (isset($r['hideOnDevice'][GridFramework::DEVICE_CLASSES_HIDE_ON_MEDIUM]) && $r['hideOnDevice'][GridFramework::DEVICE_CLASSES_HIDE_ON_MEDIUM] == 1) {
             $set->setHideOnMediumDevice(true);
             $return = true;
         }
         if (isset($r['hideOnDevice'][GridFramework::DEVICE_CLASSES_HIDE_ON_LARGE]) && $r['hideOnDevice'][GridFramework::DEVICE_CLASSES_HIDE_ON_LARGE] == 1) {
             $set->setHideOnLargeDevice(true);
             $return = true;
         }
     }
     if (trim($r['linkColor']) != '') {
         $set->setLinkColor($r['linkColor']);
         $return = true;
     }
     if (trim($r['textColor']) != '') {
         $set->setTextColor($r['textColor']);
         $return = true;
     }
     if (trim($r['baseFontSize']) && trim($r['baseFontSize']) != '0px') {
         $set->setBaseFontSize($r['baseFontSize']);
         $return = true;
     }
     if (trim($r['marginTop']) && trim($r['marginTop']) != '0px') {
         $set->setMarginTop($r['marginTop']);
         $return = true;
     }
     if (trim($r['marginRight']) && trim($r['marginRight']) != '0px') {
         $set->setMarginRight($r['marginRight']);
         $return = true;
     }
     if (trim($r['marginBottom']) && trim($r['marginBottom']) != '0px') {
         $set->setMarginBottom($r['marginBottom']);
         $return = true;
     }
     if (trim($r['marginLeft']) && trim($r['marginLeft']) != '0px') {
         $set->setMarginLeft($r['marginLeft']);
         $return = true;
     }
     if (trim($r['paddingTop']) && trim($r['paddingTop']) != '0px') {
         $set->setPaddingTop($r['paddingTop']);
         $return = true;
     }
     if (trim($r['paddingRight']) && trim($r['paddingRight']) != '0px') {
         $set->setPaddingRight($r['paddingRight']);
         $return = true;
     }
     if (trim($r['paddingBottom']) && trim($r['paddingBottom']) != '0px') {
         $set->setPaddingBottom($r['paddingBottom']);
         $return = true;
     }
     if (trim($r['paddingLeft']) && trim($r['paddingLeft']) != '0px') {
         $set->setPaddingLeft($r['paddingLeft']);
         $return = true;
     }
     if (trim($r['borderWidth']) && trim($r['borderWidth']) != '0px') {
         $set->setBorderWidth($r['borderWidth']);
         $set->setBorderStyle($r['borderStyle']);
         $set->setBorderColor($r['borderColor']);
         $set->setBorderRadius($r['borderRadius']);
         $return = true;
     }
     if (trim($r['alignment']) != '') {
         $set->setAlignment($r['alignment']);
         $return = true;
     }
     if ($r['rotate']) {
         $set->setRotate($r['rotate']);
         $return = true;
     }
     if (trim($r['boxShadowHorizontal']) && trim($r['boxShadowHorizontal']) != '0px' || trim($r['boxShadowVertical']) && trim($r['boxShadowVertical']) != '0px') {
         $set->setBoxShadowBlur($r['boxShadowBlur']);
         $set->setBoxShadowColor($r['boxShadowColor']);
         $set->setBoxShadowHorizontal($r['boxShadowHorizontal']);
         $set->setBoxShadowVertical($r['boxShadowVertical']);
         $set->setBoxShadowSpread($r['boxShadowSpread']);
         $return = true;
     }
     if ($r['customClass']) {
         $set->setCustomClass($r['customClass']);
         $return = true;
     }
     if ($return) {
         return $set;
     }
     return null;
 }
Example #6
0
 /**
  * If the request contains any fields that are valid to save as a style set, we return the style set object
  * pre-save. If it's not (e.g. there's a background repeat but no actual background image, empty strings, etc...)
  * then we return null.
  * return \Concrete\Core\StyleCustomizer\Inline\StyleSet|null
  * @param Request $request
  */
 public static function populateFromRequest(Request $request)
 {
     $r = $request->request->all();
     $set = new StyleSet();
     $return = false;
     if (trim($r['backgroundColor']) != '') {
         $set->setBackgroundColor($r['backgroundColor']);
         $set->setBackgroundRepeat($r['backgroundRepeat']);
         $return = true;
     }
     $fID = intval($r['backgroundImageFileID']);
     if ($fID > 0) {
         $set->setBackgroundImageFileID($fID);
         $set->setBackgroundRepeat($r['backgroundRepeat']);
         $return = true;
     }
     if (trim($r['linkColor']) != '') {
         $set->setLinkColor($r['linkColor']);
         $return = true;
     }
     if (trim($r['textColor']) != '') {
         $set->setTextColor($r['textColor']);
         $return = true;
     }
     if (trim($r['baseFontSize']) && trim($r['baseFontSize']) != '0px') {
         $set->setBaseFontSize($r['baseFontSize']);
         $return = true;
     }
     if (trim($r['marginTop']) && trim($r['marginTop']) != '0px') {
         $set->setMarginTop($r['marginTop']);
         $return = true;
     }
     if (trim($r['marginRight']) && trim($r['marginRight']) != '0px') {
         $set->setMarginRight($r['marginRight']);
         $return = true;
     }
     if (trim($r['marginBottom']) && trim($r['marginBottom']) != '0px') {
         $set->setMarginBottom($r['marginBottom']);
         $return = true;
     }
     if (trim($r['marginLeft']) && trim($r['marginLeft']) != '0px') {
         $set->setMarginLeft($r['marginLeft']);
         $return = true;
     }
     if (trim($r['paddingTop']) && trim($r['paddingTop']) != '0px') {
         $set->setPaddingTop($r['paddingTop']);
         $return = true;
     }
     if (trim($r['paddingRight']) && trim($r['paddingRight']) != '0px') {
         $set->setPaddingRight($r['paddingRight']);
         $return = true;
     }
     if (trim($r['paddingBottom']) && trim($r['paddingBottom']) != '0px') {
         $set->setPaddingBottom($r['paddingBottom']);
         $return = true;
     }
     if (trim($r['paddingLeft']) && trim($r['paddingLeft']) != '0px') {
         $set->setPaddingLeft($r['paddingLeft']);
         $return = true;
     }
     if (trim($r['borderWidth']) && trim($r['borderWidth']) != '0px') {
         $set->setBorderWidth($r['borderWidth']);
         $set->setBorderStyle($r['borderStyle']);
         $set->setBorderColor($r['borderColor']);
         $set->setBorderRadius($r['borderRadius']);
         $return = true;
     }
     if (trim($r['alignment']) != '') {
         $set->setAlignment($r['alignment']);
         $return = true;
     }
     if ($r['rotate']) {
         $set->setRotate($r['rotate']);
         $return = true;
     }
     if (trim($r['boxShadowHorizontal']) && trim($r['boxShadowHorizontal']) != '0px' || trim($r['boxShadowVertical']) && trim($r['boxShadowVertical']) != '0px') {
         $set->setBoxShadowBlur($r['boxShadowBlur']);
         $set->setBoxShadowColor($r['boxShadowColor']);
         $set->setBoxShadowHorizontal($r['boxShadowHorizontal']);
         $set->setBoxShadowVertical($r['boxShadowVertical']);
         $set->setBoxShadowSpread($r['boxShadowSpread']);
         $return = true;
     }
     if ($r['customClass']) {
         $set->setCustomClass($r['customClass']);
         $return = true;
     }
     if ($return) {
         return $set;
     }
     return null;
 }