예제 #1
0
 public function testPopulateFromRequestAll()
 {
     $arguments = array('backgroundColor' => 'rgb(0,0,0)', 'backgroundImageFileID' => 50, 'backgroundRepeat' => 'repeat-y', 'linkColor' => 'rgb(20,20,20)', 'textColor' => 'rgb(30,30,30)', 'baseFontSize' => '15px', 'marginTop' => '5px', 'marginRight' => '10px', 'marginBottom' => '15px', 'marginLeft' => '20px', 'paddingTop' => '25px', 'paddingRight' => '30px', 'paddingBottom' => '35px', 'paddingLeft' => '40px', 'borderWidth' => '3px', 'borderStyle' => 'dotted', 'borderColor' => 'rgb(40,40,40)', 'borderRadius' => '4px', 'alignment' => 'right', 'rotate' => '-3', 'boxShadowBlur' => '45px', 'boxShadowColor' => 'rgb(50,50,50)', 'boxShadowHorizontal' => '50px', 'boxShadowVertical' => '55px', 'boxShadowSpread' => '60px', 'customClass' => 'testclass');
     $r = Request::create('http://www.foo.com', 'POST', $arguments);
     $set = StyleSet::populateFromRequest($r);
     $this->assertInstanceOf('\\Concrete\\Core\\StyleCustomizer\\Inline\\StyleSet', $set);
     $this->assertEquals('rgb(0,0,0)', $set->getBackgroundColor());
     $this->assertEquals(50, $set->getBackgroundImageFileID());
     $this->assertEquals('repeat-y', $set->getBackgroundRepeat());
     $this->assertEquals('rgb(20,20,20)', $set->getLinkColor());
     $this->assertEquals('rgb(30,30,30)', $set->getTextColor());
     $this->assertEquals('15px', $set->getBaseFontSize());
     $this->assertEquals('5px', $set->getMarginTop());
     $this->assertEquals('10px', $set->getMarginRight());
     $this->assertEquals('15px', $set->getMarginBottom());
     $this->assertEquals('20px', $set->getMarginLeft());
     $this->assertEquals('25px', $set->getPaddingTop());
     $this->assertEquals('30px', $set->getPaddingRight());
     $this->assertEquals('35px', $set->getPaddingBottom());
     $this->assertEquals('40px', $set->getPaddingLeft());
     $this->assertEquals('3px', $set->getBorderWidth());
     $this->assertEquals('dotted', $set->getBorderStyle());
     $this->assertEquals('rgb(40,40,40)', $set->getBorderColor());
     $this->assertEquals('4px', $set->getBorderRadius());
     $this->assertEquals('right', $set->getAlignment());
     $this->assertEquals('-3', $set->getRotate());
     $this->assertEquals('45px', $set->getBoxShadowBlur());
     $this->assertEquals('rgb(50,50,50)', $set->getBoxShadowColor());
     $this->assertEquals('50px', $set->getBoxShadowHorizontal());
     $this->assertEquals('55px', $set->getBoxShadowVertical());
     $this->assertEquals('60px', $set->getBoxShadowSpread());
     $this->assertEquals('testclass', $set->getCustomClass());
 }
예제 #2
0
 public function testPageStyles()
 {
     $ps = new \Concrete\Core\StyleCustomizer\Inline\StyleSet();
     $ps->setBackgroundColor('#ffffff');
     $ps->save();
     $psx = \Concrete\Core\StyleCustomizer\Inline\StyleSet::getByID(1);
     $this->assertInstanceOf('\\Concrete\\Core\\StyleCustomizer\\Inline\\StyleSet', $psx);
     $this->assertEquals(1, $psx->getID());
     $this->assertEquals('#ffffff', $psx->getBackgroundColor());
 }
예제 #3
0
 public function getPageThemeGridFrameworkSelectedDeviceHideClassesForDisplay(StyleSet $set, Page $page)
 {
     $classes = array();
     if (!$page->isEditMode()) {
         if ($set->getHideOnExtraSmallDevice()) {
             $classes[] = $this->getPageThemeGridFrameworkHideOnExtraSmallDeviceClass();
         }
         if ($set->getHideOnSmallDevice()) {
             $classes[] = $this->getPageThemeGridFrameworkHideOnSmallDeviceClass();
         }
         if ($set->getHideOnMediumDevice()) {
             $classes[] = $this->getPageThemeGridFrameworkHideOnMediumDeviceClass();
         }
         if ($set->getHideOnLargeDevice()) {
             $classes[] = $this->getPageThemeGridFrameworkHideOnLargeDeviceClass();
         }
     }
     return $classes;
 }
예제 #4
0
파일: design.php 프로젝트: ceko/concrete5-1
 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();
     }
 }
예제 #5
0
 /**
  * @return string
  */
 public function getContainerClass()
 {
     $classes = array($this->getCustomStyleClass());
     if (is_object($this->set)) {
         if ($this->set->getCustomClass()) {
             $classes[] = $this->set->getCustomClass();
         }
         if (is_object($this->theme) && ($gf = $this->theme->getThemeGridFrameworkObject())) {
             $classes = array_merge($gf->getPageThemeGridFrameworkSelectedDeviceHideClassesForDisplay($this->set, $this->area->getAreaCollectionObject()), $classes);
         }
     }
     return implode(' ', $classes);
 }
예제 #6
0
 /**
  * @return string
  */
 public function getContainerClass()
 {
     $class = 'ccm-custom-style-';
     $txt = Core::make('helper/text');
     $class .= strtolower($txt->filterNonAlphaNum($this->arHandle));
     if (is_object($this->set)) {
         $return = $this->set->getClass($this->theme);
         if ($return) {
             $class .= ' ' . $return;
         }
     }
     return $class;
 }
 public function importPageAreas(Page $page, \SimpleXMLElement $px)
 {
     foreach ($px->area as $ax) {
         if (isset($ax->blocks)) {
             foreach ($ax->blocks->block as $bx) {
                 if ($bx['type'] != '') {
                     // we check this because you might just get a block node with only an mc-block-id, if it's an alias
                     $bt = BlockType::getByHandle((string) $bx['type']);
                     if (!is_object($bt)) {
                         throw new \Exception(t('Invalid block type handle: %s', strval($bx['type'])));
                     }
                     $btc = $bt->getController();
                     $btc->import($page, (string) $ax['name'], $bx);
                 } else {
                     if ($bx['mc-block-id'] != '') {
                         // we find that block in the master collection block pool and alias it out
                         $bID = array_search((string) $bx['mc-block-id'], ContentImporter::getMasterCollectionTemporaryBlockIDs());
                         if ($bID) {
                             $mc = Page::getByID($page->getMasterCollectionID(), 'RECENT');
                             $block = Block::getByID($bID, $mc, (string) $ax['name']);
                             $block->alias($page);
                             if ($block->getBlockTypeHandle() == BLOCK_HANDLE_LAYOUT_PROXY) {
                                 // we have to go get the blocks on that page in this layout.
                                 $btc = $block->getController();
                                 $arLayout = $btc->getAreaLayoutObject();
                                 $columns = $arLayout->getAreaLayoutColumns();
                                 foreach ($columns as $column) {
                                     $area = $column->getAreaObject();
                                     $blocks = $area->getAreaBlocksArray($mc);
                                     foreach ($blocks as $_b) {
                                         $_b->alias($page);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (isset($ax->style)) {
             $area = \Area::get($page, (string) $ax['name']);
             $set = StyleSet::import($ax->style);
             $page->setCustomStyleSet($area, $set);
         }
     }
 }
예제 #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();
        }
    }
예제 #9
0
 protected function importAdditionalData($b, $blockNode)
 {
     $controller = $b->getController();
     $arLayout = $controller->getAreaLayoutObject();
     $columns = $arLayout->getAreaLayoutColumns();
     $layoutArea = $b->getBlockAreaObject();
     $arLayout->setAreaObject($b->getBlockAreaObject());
     $page = $b->getBlockCollectionObject();
     $i = 0;
     foreach ($blockNode->arealayout->columns->column as $columnNode) {
         $column = $columns[$i];
         $as = new SubArea($column->getAreaLayoutColumnDisplayID(), $layoutArea->getAreaHandle(), $layoutArea->getAreaID());
         $as->load($page);
         $column->setAreaID($as->getAreaID());
         $area = $column->getAreaObject();
         if ($columnNode->style) {
             $set = StyleSet::import($columnNode->style);
             $page->setCustomStyleSet($area, $set);
         }
         foreach ($columnNode->block as $bx) {
             $bt = \BlockType::getByHandle($bx['type']);
             if (!is_object($bt)) {
                 throw new \Exception(t('Invalid block type handle: %s', strval($bx['type'])));
             }
             $btc = $bt->getController();
             $btc->import($page, $area->getAreaHandle(), $bx);
         }
         ++$i;
     }
 }
예제 #10
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();
     }
 }
예제 #11
0
 public function getAreaCustomStyle($area, $force = false)
 {
     $areac = $area->getAreaCollectionObject();
     if ($areac instanceof Stack) {
         // this fixes the problem of users applying design to the main area on the page, and then that trickling into any
         // stacks that have been added to other areas of the page.
         return null;
     }
     $result = null;
     $styles = $this->vObj->getCustomAreaStyles();
     $areaHandle = $area->getAreaHandle();
     if ($force || isset($styles[$areaHandle])) {
         $pss = isset($styles[$areaHandle]) ? StyleSet::getByID($styles[$areaHandle]) : null;
         $result = new AreaCustomStyle($pss, $area, $this->getCollectionThemeObject());
     }
     return $result;
 }
예제 #12
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;
 }
예제 #13
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();
     }
 }
 /**
  * @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;
 }
예제 #15
0
 public function getCustomStyle($force = false)
 {
     if ($this->getCustomStyleSetID() > 0 || $force) {
         $csr = StyleSet::getByID($this->getCustomStyleSetID());
         $theme = $this->c->getCollectionThemeObject();
         switch ($this->getBlockTypeHandle()) {
             case BLOCK_HANDLE_LAYOUT_PROXY:
                 $bs = new CoreAreaLayoutCustomStyle($csr, $this, $theme);
                 break;
             default:
                 $bs = new CustomStyle($csr, $this, $theme);
                 break;
         }
         return $bs;
     }
 }
예제 #16
0
파일: Block.php 프로젝트: jkoudys/concrete5
 public function setCustomStyleSet(StyleSet $set)
 {
     $db = Loader::db();
     $c = $this->getBlockCollectionObject();
     $cvID = $c->getVersionID();
     $db->Replace('CollectionVersionBlockStyles', array('cID' => $this->getBlockCollectionID(), 'cvID' => $cvID, 'arHandle' => $this->getAreaHandle(), 'bID' => $this->bID, 'issID' => $set->getID()), array('cID', 'cvID', 'bID', 'arHandle'), true);
     $this->issID = $set->getID();
 }
예제 #17
0
 public function getAreaCustomStyle($area, $force = false)
 {
     $db = Loader::db();
     $areac = $area->getAreaCollectionObject();
     if ($areac instanceof Stack) {
         // this fixes the problem of users applying design to the main area on the page, and then that trickling into any
         // stacks that have been added to other areas of the page.
         return false;
     }
     $styles = $this->vObj->getCustomAreaStyles();
     $issID = $styles[$area->getAreaHandle()];
     if ($issID > 0 || $force) {
         if ($issID) {
             $pss = StyleSet::getByID($issID);
         }
         $pss = new AreaCustomStyle($pss, $area->getAreaHandle());
         return $pss;
     }
 }
 /**
  * {@inheritDoc}
  */
 public function isHiddenOnDevice($class)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'isHiddenOnDevice', array($class));
     return parent::isHiddenOnDevice($class);
 }
예제 #19
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;
 }
예제 #20
0
 public function import($page, $arHandle, \SimpleXMLElement $blockNode)
 {
     $db = Database::connection();
     // handle the adodb stuff
     $args = $this->getImportData($blockNode, $page);
     $blockData = array();
     $bt = BlockType::getByHandle($this->btHandle);
     $b = $page->addBlock($bt, $arHandle, $args);
     $bName = (string) $blockNode['name'];
     $bFilename = (string) $blockNode['custom-template'];
     if ($bName) {
         $blockData['bName'] = $bName;
     }
     if ($bFilename) {
         $blockData['bFilename'] = $bFilename;
     }
     if (count($blockData)) {
         $b->updateBlockInformation($blockData);
     }
     if ($page->isMasterCollection() && $blockNode['mc-block-id'] != '') {
         ContentImporter::addMasterCollectionBlockID($b, (string) $blockNode['mc-block-id']);
     }
     // now we insert stuff that isn't part of the btTable
     // we have to do this this way because we need a bID
     $this->importAdditionalData($b, $blockNode);
     // now we handle the styles
     if (isset($blockNode->style)) {
         $set = StyleSet::import($blockNode->style);
         $b->setCustomStyleSet($set);
     }
     // now we handle block caching
     $cache = (int) $blockNode['cache-output'];
     if ($cache) {
         $b->setCustomCacheSettings(true, $blockNode['cache-output-on-post'], $blockNode['cache-output-for-registered-users'], $blockNode['cache-output-lifetime']);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function export(\SimpleXMLElement $node)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'export', array($node));
     return parent::export($node);
 }