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

  • DashboardAdmin
  • DashboardPlugin
  • SiteInfo
  • WebylonNews
  1 <?php
  2 /**
  3  * Abstract class for dashboard plugins.
  4  * 
  5  * @package Dashboard
  6  */
  7 
  8 abstract class DashboardPlugin extends ViewableData {
  9     /**
 10      * @var $position = The position of this plugin on the dashboard. 
 11      *                  Value must be contained in DashboardPlugin::$positions
 12      */
 13     static $position = "snippet";
 14 
 15     /**
 16      * @var $sort = Index of where the plugin will appear in a given position.
 17      */
 18     static $sort = 0;
 19 
 20     /**
 21      * @var $positions = A lookup for the available positions of a plugin on the dashboard.
 22      */
 23     static $positions = array('left','alerts','snippet','full_width');
 24     
 25     /**
 26      * @var $disabled_plugins = A list of plugins that should not be included on the dashboard.
 27      *                          By default, all DashboardPlugin subclasses are included.
 28      */
 29     private static $disabled_plugins = array();
 30      
 31     /**
 32      * @var $icon = Path to the icon that is embedded in the plugin heading
 33      */
 34     static $icon;
 35 
 36     /**
 37      * @var $Title = Title of the plugin on dashboard view
 38      */
 39     static $title;
 40 
 41     /**
 42      * @var $link = A link for more info embdedded in the header
 43      */  
 44     static $link;
 45   
 46     /**
 47      * @var $link_text = Text for the more info link
 48      */  
 49     static $link_text = "View All";
 50   
 51     /**
 52      * @var $limit_count = Limiter to set how many items should be displayed
 53      */  
 54     static $limit_count;
 55   
 56     /**
 57      * @var $caption = Short caption to appear at the top of your plugin
 58      */  
 59     static $caption;
 60   
 61     /**
 62      * @var $null_message = Short message to return if no data is returned
 63      */  
 64     static $null_message;
 65   
 66     /**
 67      * @var $edit_link = URL for edit button, if it exists
 68      */  
 69     static $edit_link;
 70   
 71     /**
 72      * @var $edit_popup = Boolean value of whether an edit link should generate a popup
 73      */  
 74     static $edit_popup = FALSE;
 75 
 76     /**
 77      * Sets a plugin class as disabled, so it will not appear on the dashboard.
 78      *
 79      * @return void
 80      */
 81     public static function disable($plugin) {
 82         if(!in_array($plugin, self::$disabled_plugins))
 83             self::$disabled_plugins[] = $plugin;
 84     }
 85   
 86     /**
 87      * Getter for $disabled_plugins
 88      *
 89      * @return array
 90      */
 91     public static function get_disabled_plugins() {
 92         return self::$disabled_plugins;
 93     }
 94     
 95     /**
 96      * Simple function to convert Title of Plugin to PluginClass.TITLEOFPLUGIN
 97      *
 98      * @return string
 99      */  
100     private function toLangVar($str) {
101         $str = str_replace(" ", "", $str);
102         return get_class($this).".".strtoupper(ereg_replace("[^A-Za-z]", "", $str));
103     }
104   
105     /**
106      * Returns an inline style for the icon. Used on dashboard template.
107      *
108      * @return string
109      */
110     public function IconCSS() {
111         if($icon = $this->stat('icon'))
112             return "style='background-image:url($icon); padding-left: 30px;'";
113         return false;
114     }
115 
116     /**
117      * Uses toLangVar() to translate a given property
118      *
119      * @return string
120      */  
121     private function getTranslatedProperty($property) {
122         if($val = $this->stat($property))
123             return _t($this->toLangVar($val),$val);
124     }
125 
126     /**
127      * Translates the $title property
128      *
129      * @return string
130      */    
131     public function getTitle() {
132         return $this->getTransLatedProperty('title');
133     }
134  
135     /**
136      * Translates the $link_text property
137      *
138      * @return string
139      */      
140     public function getLinkText() {
141         return $this->getTranslatedProperty('link_text');
142     }
143 
144     /**
145      * Getter for the $link property. Useful on templates, which don't have access to static vars.
146      *
147      * @return string
148      */      
149     public function getLink() {
150         return $this->stat('link');
151     }
152 
153     /**
154      * Getter for the $caption property. Allows you to add a quick caption to the top of your dash item
155      *
156      * @return string
157      */      
158     public function getCaption() {
159         return $this->stat('caption');
160     }
161 
162     /**
163      * Getter for the $caption property. Allows you to add a quick caption to the top of your dash item
164      *
165      * @return string
166      */      
167     public function getNullMessage() {
168         return $this->stat('null_message');
169     }
170 
171     /**
172      * Getter for the $edit_link property. Allows you to set the base url for an edit link 
173      *
174      * @return string
175      */      
176     public function getEditLink() {
177         return $this->stat('edit_link');
178     }
179 
180     /**
181      * Getter for the $edit_popup. Sets whether the edit link will be in a popup
182      *
183      * @return string
184      */      
185     public function getEditPopup() {
186         return $this->stat('edit_popup');
187     }
188 
189     /**
190      * For rendering the plugin. Assumes template name of plugin class name.
191      *
192      * @return string
193      */
194     public function forTemplate() {
195         switch($this->stat('position')) {
196             case 'left':
197                 $genericTemplate = 'Generic_Left';
198                 break;
199             case 'alerts':
200                 $genericTemplate = 'Generic_Alert';
201                 break;
202             case 'snippet':
203                 $genericTemplate = 'Generic_Snippet_List';
204                 break;
205             case 'full_width':
206                 $genericTemplate = 'Generic_Full_Width';
207                 break;
208         }
209 
210         return $this->renderWith(array($genericTemplate,get_class($this)));
211     }
212 
213 }
[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