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
  • AdvancedSliderHomepageWidget
  • AuthFormWidget
  • BannerWidget
  • ButtonsBlockHomepageWidget
  • CallBackWidget
  • CarouselHomepageWidget
  • CartWidget
  • CatalogFilterSidebarWidget
  • CatalogRubricsHomepageWidget
  • ConsultantWidget
  • ContactsBlockWidget
  • CurrencyWidget
  • EventCalendarWidget
  • FAQHomepageWidget
  • FAQSidebarWidget
  • FavoriteProductsSidebarWidget
  • FeedbackHomepageWidget
  • GuestbookWidget
  • HomepageWidget
  • HomepageWidgetArea
  • HouseCatalogSearchWidget
  • HTMLBlockHomepageWidget
  • HTMLBlockSidebarWidget
  • NewsHomepageWidget
  • NewsSidebarWidget
  • PageMenuWidget
  • PhotoAlbumHomepageWidget
  • PhotoGalleryHomepageWidget
  • PhotoGalleryWidget
  • PollSidebarWidget
  • PriceListWidget
  • PublicationWidget
  • SearchWidget
  • SeparateHomepageWidget
  • SeparateSidebarWidget
  • SidebarWidget
  • SidebarWidgetArea
  • SliderHomepageWidget
  • SpecialCatalogHomepageWidget
  • SpecialCatalogSidebarWidget
  • SubscribeWidget
  • SubsectionMenuWidget
  • TextAnonsWidget
  • TextBlockHomepageWidget
  • TextBlockSidebarWidget
  • WeatherSidebarWidget
  • WebylonWidget
  • WebylonWidgetArea
  • WidgetAdmin
  • WidgetSortCMSActionDecorator
  • YandexMapsHomepageWidget
  • YandexMapsWidget
 1 <?php
 2 
 3 /**
 4  * Виджет "Часто задаваемы вопросы" для боковой колонки
 5  * Показывает список последних вопросов из выбранного холдера или секции или из всех
 6  *
 7  * @package widgets
 8  * @author  menedem
 9  */
10 class FAQSidebarWidget extends SidebarWidget {
11     static $db = array(
12         'QuestionsCount' => 'Int',
13     );
14     
15     static $defaults = array(
16         'QuestionsCount' => 3,
17     );
18     
19     static $has_one = array(
20         'Holder' => 'SiteTree'
21     );  
22     
23     public $needObjects = array(
24         'FaqHolder' => 'Page'
25     );
26     
27     function getCMSFields() {
28         if (!$this->canCreate()) {
29             return $this->getFailCMSFields();
30         }
31         $fields = parent::getCMSFields();       
32         $holders = array();
33         if ($faqHolders = DataObject::get('FaqHolder')) {
34             foreach($faqHolders as $faqHolder) {
35                 $holders[$faqHolder->ID] = $faqHolder->Title;
36                 foreach($faqHolder->Children() as $section) {
37                     $holders[$section->ID] = "-- {$section->Title}";
38                 }
39             }
40         }
41         $fields->replaceField('HolderID', new DropdownField('HolderID', $this->fieldLabel('Holder'), $holders, "", null, _t('Widgets.All', 'All')));
42 
43         return $fields;
44     }
45     
46     function QuestionsList() {
47         $questionsCount = $this->QuestionsCount;
48         if (!$questionsCount) {
49             $questionsCount = 3;
50         }
51         $where = "`Published` = 1";
52         if ($this->HolderID && ($holder = $this->Holder()) && $holder->ID) {
53             if (is_a($holder, 'FaqHolder')) {
54                 $where .= " AND `FaqHolderID` = {$holder->ID}";
55             } else {
56                 $where .= " AND `SectionID` = {$holder->ID}";
57             }
58         }
59         return DataObject::get('FaqQuestion', $where, "", '', $questionsCount);
60     }
61     
62     function hasContent() {
63         if ($this->QuestionsList()) {
64             return true;
65         }
66         return false;
67     }
68     
69     function getMoreLink() {
70         if ($this->HolderID && $this->Holder()) {
71             return $this->Holder()->Link();
72         }
73         return false;
74     }
75 }
76 
[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