当前位置: 首页>>代码示例>>PHP>>正文


PHP Region::EditRegion方法代码示例

本文整理汇总了PHP中Region::EditRegion方法的典型用法代码示例。如果您正苦于以下问题:PHP Region::EditRegion方法的具体用法?PHP Region::EditRegion怎么用?PHP Region::EditRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Region的用法示例。


在下文中一共展示了Region::EditRegion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: LayoutRegionEdit

 /**
  * Edit Region on a layout
  * @return <XiboAPIResponse>
  */
 public function LayoutRegionEdit()
 {
     if (!$this->user->PageAuth('layout')) {
         return $this->Error(1, 'Access Denied');
     }
     $layoutId = $this->GetParam('layoutId', _INT);
     $regionId = $this->GetParam('regionId', _STRING);
     $width = $this->GetParam('width', _INT);
     $height = $this->GetParam('height', _INT);
     $top = $this->GetParam('top', _INT);
     $left = $this->GetParam('left', _INT);
     $name = $this->GetParam('name', _STRING);
     // Does the user have permissions to view this region?
     if (!$this->user->LayoutAuth($layoutId)) {
         return $this->Error(1, 'Access Denied');
     }
     // Create a region object
     Kit::ClassLoader('region');
     $region = new Region();
     // Region Assignment needs the Owner Id
     $ownerId = $region->GetOwnerId($layoutId, $regionId);
     $regionAuth = $this->user->RegionAssignmentAuth($ownerId, $layoutId, $regionId, true);
     if (!$regionAuth->edit) {
         return $this->Error(1, 'Access Denied');
     }
     // Edit the region
     if (!($regionId = $region->EditRegion($layoutId, $regionId, $width, $height, $top, $left, $name = ''))) {
         return $this->Error($region->GetErrorNumber(), $region->GetErrorMessage());
     }
     return $this->Respond($this->ReturnId('success', true));
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:35,代码来源:rest.class.php

示例2: upgrade

 /**
  * Upgrade a Layout between schema versions
  * @param int $layoutId
  * @param int $resolutionId
  * @param int $scaleContent
  * @return bool
  */
 public function upgrade($layoutId, $resolutionId, $scaleContent)
 {
     // Get the Layout XML
     $this->SetDomXml($layoutId);
     // Get the Schema Versions
     $layoutVersion = (int) $this->DomXml->documentElement->getAttribute('schemaVersion');
     $width = (int) $this->DomXml->documentElement->getAttribute('width');
     $height = (int) $this->DomXml->documentElement->getAttribute('height');
     $color = $this->DomXml->documentElement->getAttribute('bgcolor');
     $version = Config::Version('XlfVersion');
     // Get some more info about the layout
     try {
         $dbh = PDOConnect::init();
         $sth = $dbh->prepare('SELECT backgroundImageId FROM `layout` WHERE layoutId = :layoutId');
         $sth->execute(array('layoutId' => $layoutId));
         // Look up the bg image from the media id given
         if (!($row = $sth->fetch())) {
             $this->ThrowError(__('Unable to get the Layout information'));
         }
     } catch (Exception $e) {
         Debug::LogEntry('error', $e->getMessage());
         if (!$this->IsError()) {
             $this->SetError(1, __('Unknown Error'));
         }
         return false;
     }
     Debug::Audit('Updating layoutId: ' . $layoutId . ' from version: ' . $layoutVersion . ' to: ' . $version);
     // Upgrade
     $this->delayFinalise = true;
     // Set the background
     $this->SetBackground($layoutId, $resolutionId, $color, $row['backgroundImageId']);
     // Get the Layout XML again (now that we have set the background)
     $this->SetDomXml($layoutId);
     // Get the Width and Height back out
     $updatedWidth = (int) $this->DomXml->documentElement->getAttribute('width');
     $updatedHeight = (int) $this->DomXml->documentElement->getAttribute('height');
     // Work out the ratio
     $ratio = min($updatedWidth / $width, $updatedHeight / $height);
     // Get all the regions.
     foreach ($this->GetRegionList($layoutId) as $region) {
         // New region object each time, because the region stores the layout xml
         $regionObject = new Region();
         $regionObject->delayFinalise = $this->delayFinalise;
         // Work out a new width and height
         $newWidth = $region['width'] * $ratio;
         $newHeight = $region['height'] * $ratio;
         $newTop = $region['top'] * $ratio;
         $newLeft = $region['left'] * $ratio;
         $regionObject->EditRegion($layoutId, $region['regionid'], $newWidth, $newHeight, $newTop, $newLeft, $region['name']);
         if ($scaleContent == 1) {
             Debug::Audit('Updating the scale of media in regionId ' . $region['regionid']);
             // Also update the width, height and font-size on each media item
             foreach ($regionObject->GetMediaNodeList($layoutId, $region['regionid']) as $mediaNode) {
                 // Run some regular expressions over each, to adjust the values by the ratio we have calculated.
                 // widths
                 $mediaId = $mediaNode->getAttribute('id');
                 $lkId = $mediaNode->getAttribute('lkid');
                 $mediaType = $mediaNode->getAttribute('type');
                 // Create a media module to handle all the complex stuff
                 $tmpModule = ModuleFactory::load($mediaType, $layoutId, $region['regionid'], $mediaId, $lkId);
                 // Get the XML
                 $mediaXml = $tmpModule->asXml();
                 // Replace widths
                 $mediaXml = preg_replace_callback('/width:(.*?)/', function ($matches) use($ratio) {
                     return "width:" . $matches[1] * $ratio;
                 }, $mediaXml);
                 // Replace heights
                 $mediaXml = preg_replace_callback('/height:(.*?)/', function ($matches) use($ratio) {
                     return "height:" . $matches[1] * $ratio;
                 }, $mediaXml);
                 // Replace fonts
                 $mediaXml = preg_replace_callback('/font-size:(.*?)px;/', function ($matches) use($ratio) {
                     return "font-size:" . $matches[1] * $ratio . "px;";
                 }, $mediaXml);
                 // Save this new XML
                 $tmpModule->SetMediaXml($mediaXml);
             }
         }
     }
     $this->delayFinalise = false;
     $this->SetValid($layoutId);
     return true;
 }
开发者ID:taphier,项目名称:xibo-cms,代码行数:90,代码来源:layout.data.class.php


注:本文中的Region::EditRegion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。