コード例 #1
0
ファイル: InlineStyleSet.php プロジェクト: ceko/concrete5-1
 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
ファイル: 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();
     }
 }
コード例 #3
0
ファイル: design.php プロジェクト: JeRoNZ/concrete5-1
    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();
        }
    }