Webylon 3.2 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • AdditionalMenuWidget_Item
  • AdvancedSliderHomepageWidget_Item
  • AssetManagerFolder
  • BannerWidget_Item
  • BaseObjectDecorator
  • BookingOrder
  • BookingPaymentMethod
  • BookingService
  • Boolean
  • ButtonsBlockHomepageWidget_Item
  • CarouselHomepageWidget_Item
  • CatalogFilter
  • CatalogRubricsHomepageWidget_CatalogDecorator
  • ClientEmailOrderNotification
  • ClientVKOrderNotification
  • ComponentSet
  • Currency
  • DatabaseAdmin
  • DataObject
  • DataObjectDecorator
  • DataObjectLog
  • DataObjectSet
  • DataObjectSet_Iterator
  • Date
  • DB
  • DBField
  • Decimal
  • DocumentItem
  • DocumentPage_File
  • Double
  • Enum
  • ErrorPageSubsite
  • FileDataObjectTrackingDecorator
  • FileImportDecorator
  • Float
  • FlowerGarden_Size
  • ForeignKey
  • Hierarchy
  • HouseCatalogProductDecorator
  • HTMLText
  • HTMLVarchar
  • Import1CLog
  • Import1CLog_File
  • Import1CLog_Item
  • Import1CLog_Task
  • ImportCatalog1C_PriceType
  • ImportCatalog1C_ProductProp
  • Int
  • ManagerEmailOrderNotification
  • Material3D_File
  • MediawebPage_File
  • MediawebPage_Photo
  • MobileContentDecorator
  • Money
  • MonumentGalleryItem
  • MonumentPhotoGallery
  • MultiEnum
  • MySQLDatabase
  • MySQLQuery
  • Notification
  • OrderDataObject
  • OrderDecorator
  • OrderHandlersDecorator
  • OrderItemDecorator
  • OrderItemVariationDecorator
  • Orders1CExchange_OrdersDecorator
  • OrderService
  • OrderServiceOrder
  • PageIcon
  • PageWidgets
  • Payment
  • PaymentMethodShippingDecorator
  • PaymentOrderExtension
  • Percentage
  • Person
  • PhotoAlbumItem
  • PhotoAlbumProductLinkDecorator
  • PhotoAlbumWidgetLinkDecorator
  • PhotoGalleryHomepageWidget_Item
  • PortraitType
  • PrimaryKey
  • Product3DDecorator
  • ProductCatalogCatalogLinkedDecorator
  • ProductImportLog
  • ProductImportLog_Item
  • ProductParam
  • ProductParamValue
  • ProductVariation
  • RatePeriod
  • RealtyImportLog
  • RealtyImportLog_Item
  • RedirectEntry
  • RoomOrder
  • RoomOrderPerson
  • RoomRate
  • RoomService
  • RoomServiceOrder
  • SberbankPaymentDecorator
  • SeoOpenGraphPageDecorator
  • ServiceOrder
  • ShippingMethodPaymentDecorator
  • ShopCountry
  • SimpleOrderCatalogDecorator
  • SimpleOrderProductDecorator
  • SiteConfigWidgets
  • SiteTreeDecorator
  • SiteTreeImportDecorator
  • SliderHomepageWidget_Item
  • SMSCOrderNotification
  • SMSOrderNotification
  • SortableDataObject
  • SQLMap
  • SQLMap_Iterator
  • SQLQuery
  • SS_Database
  • SS_Datetime
  • SS_Query
  • StringField
  • SubsiteDomain
  • Text
  • TextAnonsWidget_Item
  • Texture3D_File
  • Time
  • Varchar
  • Versioned
  • Versioned_Version
  • VideoCategory
  • VideoEntry
  • VKNotificationQueue
  • WebylonWidget_Item
  • YaMoneyPaymentDecorator
  • Year

Interfaces

  • CompositeDBField
  • CurrentPageIdentifier
  • DataObjectInterface
  1 <?php
  2 // Значение параметра категории (ProductParam) у конкретного товара
  3 class ProductParamValue extends DataObject {
  4     static $db = array(
  5         'Value' => 'Varchar(255)',
  6         'TechTitle' => 'Varchar(50)', // копия из ProductParam для упрощения запросов
  7     );
  8     
  9     static $has_one = array(
 10         'Product' => 'Product',
 11         'ProductParam' => 'ProductParam',
 12         'ProductVariation' => 'ProductVariation',
 13     );
 14 
 15     static $indexes = array(
 16         'TitleValue' => '(TechTitle,Value)',
 17         'ProductTitle' => '(ProductID,TechTitle)',
 18     );  
 19     
 20     function getCMSFields() {
 21         $fields = parent::getCMSFields();
 22         $fields->replaceField('ProductParamID', new HiddenField('ProductParamID', 'ProductParamID'));       
 23         if (!Catalog::$use_variations) {
 24             $fields->removeByName('ProductVariationID');
 25         }
 26         
 27         return $fields;
 28     }   
 29     
 30     function onBeforeWrite() {
 31         parent::onBeforeWrite();
 32         
 33         if ($this->ProductParamID && $this->ProductParam()) {
 34             $this->TechTitle = $this->ProductParam()->TechTitle;
 35             if ($this->ProductParam()->ParamForVariation && ($variation = $this->ProductVariation())) {
 36                 $this->ProductID = $variation->ProductID;
 37             }
 38         }
 39     }
 40     
 41     function ParamTitle() {
 42         return $this->ProductParam()->Title;
 43     }
 44     
 45 }
 46 
 47 /**
 48  * Поле для редактирования значения параметра
 49  *
 50  * @author dvp, menedem
 51  */
 52 class ProductParamValue_ValueField extends TextField {
 53 
 54     function __construct($name, $param, $productID, $relation="ProductID") {
 55         $name .= "_{$param->ID}_{$productID}_{$relation}";      
 56         $value = false;
 57         if ($v = DataObject::get_one('ProductParamValue', "ProductParamID = {$param->ID} AND {$relation} = {$productID}")) {
 58             $value = $v->Value;
 59         }
 60         parent::__construct($name, $param->Title, $value);
 61     }
 62 
 63     function saveInto(DataObject $record) {
 64        if (!preg_match('/(\w+)_(\d+)_(\d+)_(\w+)/', $this->name, $matches))
 65             user_error("ProductParamValue_ValueField::saveInto() $this->name has invalid format");
 66         
 67         $fieldName = $matches[1];
 68         $paramID = $matches[2];
 69         $productID = $matches[3];
 70         $relation = $matches[4];
 71 
 72         $saveDest = $record->$fieldName();
 73 
 74         if (!$saveDest)
 75             user_error("ProductParamValue_ValueField::saveInto() Field '$fieldName' not found on $record->class.$record->ID", E_USER_ERROR);
 76 
 77         $paramValue = DataObject::get_one('ProductParamValue', "ProductParamID = {$paramID} AND {$relation} = {$productID}");
 78         if (!$paramValue) {
 79             $paramValue = new ProductParamValue();
 80             $paramValue->ProductParamID = $paramID;
 81             $paramValue->{$relation} = $productID;          
 82             $paramValue->write();
 83         }
 84         $paramValue->Value = $this->value;
 85         $paramValue->write();
 86     }
 87 }
 88 
 89 /**
 90  * Поле для редактирования значения параметра
 91  *
 92  * @author dvp, menedem
 93  */
 94 class ProductParamValue_MultiValueField extends DropdownField {
 95 
 96     function __construct($name, $param, $productID, $relation="ProductID") {
 97         $name .= "_{$param->ID}_{$productID}_{$relation}";      
 98         $value = false;
 99         if ($v = DataObject::get_one('ProductParamValue', "ProductParamID = {$param->ID} AND {$relation} = {$productID}")) {
100             $value = $v->Value;
101         }
102         parent::__construct($name, $param->Title, $param->PossibleValuesList(), $value);
103     }
104 
105     function saveInto(DataObject $record) {
106         if (!preg_match('/(\w+)_(\d+)_(\d+)_(\w+)/', $this->name, $matches))
107             user_error("ProductParamValue_ValueField::saveInto() $this->name has invalid format");
108         
109         $fieldName = $matches[1];
110         $paramID = $matches[2];
111         $productID = $matches[3];
112         $relation = $matches[4];
113 
114         $saveDest = $record->$fieldName();
115 
116         if (!$saveDest)
117             user_error("ProductParamValue_ValueField::saveInto() Field '$fieldName' not found on $record->class.$record->ID", E_USER_ERROR);
118 
119         $paramValue = DataObject::get_one('ProductParamValue', "ProductParamID = {$paramID} AND {$relation} = {$productID}");
120         if (!$paramValue) {
121             $paramValue = new ProductParamValue();
122             $paramValue->ProductParamID = $paramID;
123             $paramValue->{$relation} = $productID;          
124             $paramValue->write();
125         }
126         $paramValue->Value = $this->value;
127         $paramValue->write();
128     }
129 }
130 
131 /**
132  * Поле для редактирования значения параметра
133  *
134  * @author dvp, menedem
135  */
136 class ProductParamValue_MultiValueSetField extends CheckboxSetField {
137 
138     function __construct($name, $param, $productID, $relation="ProductID") {
139         $name .= "_{$param->ID}_{$productID}_{$relation}";
140         $values = array();
141         if ($allParamValues = DataObject::get('ProductParamValue', "ProductParamID = {$param->ID} AND {$relation} = {$productID}")) {
142             $values = $allParamValues->map('Value', 'Value');
143         }
144         parent::__construct($name, $param->Title, $param->PossibleValuesList(), $values); //, $param->Value
145     }
146 
147     function saveInto(DataObject $record) {     
148         if (!preg_match('/(\w+)_(\d+)_(\d+)_(\w+)/', $this->name, $matches))
149             user_error("ProductParamValue_ValueField::saveInto() $this->name has invalid format");
150         
151         $fieldName = $matches[1];
152         $paramID = $matches[2];
153         $productID = $matches[3];
154         $relation = $matches[4];
155 
156         $saveDest = $record->$fieldName();
157         
158         if (!$saveDest)
159             user_error("ProductParamValue_ValueField::saveInto() Field '$fieldName' not found on $record->class.$record->ID", E_USER_ERROR);
160         
161         $allParamValues = DataObject::get('ProductParamValue', "ProductParamID = {$paramID} AND {$relation} = {$productID}");
162         $IDs = ($allParamValues) ? $allParamValues->map('ID', 'ID'): array();
163         foreach($this->value as $value) {
164             $paramValue = DataObject::get_one('ProductParamValue', "ProductParamID = {$paramID} AND {$relation} = {$productID} AND Value = '{$value}'");
165             if (!$paramValue) {
166                 $paramValue = new ProductParamValue();
167                 $paramValue->ProductParamID = $paramID;
168                 $paramValue->{$relation} = $productID;
169                 $paramValue->Value = $value;
170                 $paramValue->write();
171             } else {
172                 unset($IDs[$paramValue->ID]);
173             }
174         }
175         if (count($IDs)) {
176             foreach($IDs as $ID) {
177                 DataObject::delete_by_id('ProductParamValue', $ID);
178             }
179         }
180     }
181 }
182 
183 /**
184  * Поле для редактирования значения параметра
185  *
186  * @author dvp, menedem
187  */
188 class ProductParamValue_BoolValueField extends DropdownField {
189 
190     function __construct($name, $param, $productID, $relation="ProductID") {
191         $name .= "_{$param->ID}_{$productID}_{$relation}";      
192         $value = false;
193         if ($v = DataObject::get_one('ProductParamValue', "ProductParamID = {$param->ID} AND {$relation} = {$productID}")) {
194             $value = $v->Value;
195         }
196         $map = array(
197             0 => _t('Boolean.NO'),
198             1 => _t('Boolean.YES'),
199         );      
200         parent::__construct($name, $param->Title, $map, $value);
201     }
202 
203     function saveInto(DataObject $record) {
204          if (!preg_match('/(\w+)_(\d+)_(\d+)_(\w+)/', $this->name, $matches))
205             user_error("ProductParamValue_ValueField::saveInto() $this->name has invalid format");
206         
207         $fieldName = $matches[1];
208         $paramID = $matches[2];
209         $productID = $matches[3];
210         $relation = $matches[4];
211 
212         $saveDest = $record->$fieldName();
213 
214         if (!$saveDest)
215             user_error("ProductParamValue_ValueField::saveInto() Field '$fieldName' not found on $record->class.$record->ID", E_USER_ERROR);
216 
217         $paramValue = DataObject::get_one('ProductParamValue', "ProductParamID = {$paramID} AND {$relation} = {$productID}");
218         if (!$paramValue) {
219             $paramValue = new ProductParamValue();
220             $paramValue->ProductParamID = $paramID;
221             $paramValue->{$relation} = $productID;          
222             $paramValue->write();
223         }
224         $paramValue->Value = $this->value;
225         $paramValue->write();
226     }
227 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.2 API Docs API documentation generated by ApiGen 2.8.0