YaWK  24.1
Yet another WebKit
YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar Class Reference

Social Bar display icons with links to your social network accounts. More...

+ Inheritance diagram for YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar:

Public Member Functions

 __construct ($db)
 Load all widget settings from database and fill object. More...
 
 drawSocialBar ()
 Draw social bar. More...
 
 filterUrl ($url)
 Filter and sanitize any socialBar URL. More...
 
 init ()
 Init example widget and call a function for demo purpose. More...
 
 setSocialBarElements ()
 Set an array with all social button elements. More...
 
- Public Member Functions inherited from YAWK\widget
 getHeading ($heading, $subtext)
 Get widget heading and subtext, return headline. More...
 
 getWidgetSettingsArray ($db)
 Get widget settings and return it as array. More...
 
 printObject ()
 Print all object data. More...
 

Public Attributes

 $socialBarAlign = 'horizontal'
 
 $socialBarClass = ''
 
 $socialBarElements = ''
 
 $socialBarFacebookIcon = ''
 
 $socialBarFacebookUrl = ''
 
 $socialBarGooglePlusIcon = ''
 
 $socialBarGooglePlusUrl = ''
 
 $socialBarHeading = ''
 
 $socialBarInstagramIcon = ''
 
 $socialBarInstagramUrl = ''
 
 $socialBarLinkColor = ''
 
 $socialBarLinkedInIcon = ''
 
 $socialBarLinkedInUrl = ''
 
 $socialBarLinkTarget = ''
 
 $socialBarLinkTitle = ''
 
 $socialBarMarkup = ''
 
 $socialBarPinterestIcon = ''
 
 $socialBarPinterestUrl = ''
 
 $socialBarSize = 'H2'
 
 $socialBarSubtext = ''
 
 $socialBarTumblrIcon = ''
 
 $socialBarTumblrUrl = ''
 
 $socialBarTwitterIcon = ''
 
 $socialBarTwitterUrl = ''
 
 $socialBarXingIcon = ''
 
 $socialBarXingUrl = ''
 
 $socialBarYouTubeIcon = ''
 
 $socialBarYouTubeUrl = ''
 
 $widget = ''
 
- Public Attributes inherited from YAWK\widget
 $data
 
 $date_publish
 
 $date_unpublish
 
 $folder
 
 $id
 
 $marginBottom
 
 $marginTop
 
 $name
 
 $pageID
 
 $position
 
 $published
 
 $sort
 
 $widgetTitle
 
 $widgetType
 

Additional Inherited Members

- Static Public Member Functions inherited from YAWK\widget
static getAllSettingsIntoArray ($db, $widgetID)
 Returns an array with all widget settings data. More...
 
static getAllWidgetTypes ($db)
 Return all widget types as associative array. More...
 
static getCurrentWidgetPath ($db)
 return current widget path More...
 
static getFacebookLikeBox ()
 return the facebook likebox widget More...
 
static getLoginBox ()
 return the user login box widget More...
 
static loadWidgetsOfPage ($db, $page)
 Returns an array of all widgets that are linked with given page->id. More...
 

Detailed Description

Social Bar display icons with links to your social network accounts.

Social Bar - display icons with links to your social network accounts

Embed Links to Twitter, Facebook, Instagram, Pinterest, YouTube and more. You can set any font awesome icon (or any other icon set that you have loaded in the assets section before). If a link is set, the corresponding icon will be drawn.

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Version
1.0.0

Definition at line 17 of file socialBar.php.

Constructor & Destructor Documentation

◆ __construct()

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::__construct (   $db)

Load all widget settings from database and fill object.

Parameters
object$dbDatabase Object

Load all widget settings on object init.

Definition at line 83 of file socialBar.php.

85  {
86  // load this widget settings from db
87  $this->widget = new \YAWK\widget();
88  $settings = $this->widget->getWidgetSettingsArray($db);
89  foreach ($settings as $property => $value) {
90  $this->$property = $value;
91  }
if(isset($_POST['save'])) $settings
$value

References $db, $settings, $value, and YAWK\widget\getWidgetSettingsArray().

Member Function Documentation

◆ drawSocialBar()

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::drawSocialBar ( )

Draw social bar.

Set settings and draw social bar

Definition at line 172 of file socialBar.php.

174  {
175  // check if social bar elements array is set
176  if (isset($this->socialBarElements) && (is_array($this->socialBarElements)))
177  { // walk through elements
178  echo "<div class=\"row\">";
179  echo "<div class=\"col-md-12\">";
180  // markup <H2, H3, H4, P... start>
181  echo "<".$this->socialBarSize.">";
182  foreach ($this->socialBarElements AS $element => $data)
183  { // only if url is set...
184  if (!empty($data['url']))
185  {
186  // filter url before output
187  $data['url'] = $this->filterUrl($data['url']);
188 
189  // check if color is set
190  if (isset($data['color']) && (!empty($data['color'])))
191  { // set css style tag
192  $this->socialBarLinkColor = " style=\"color:#$data[color];\"";
193  }
194  else
195  { // no link color - no css markup
196  $this->socialBarLinkColor = '';
197  }
198 
199  // set title
200  if (isset($this->socialBarLinkTitle) && (!empty($this->socialBarLinkTitle)))
201  {
202  $title = " title=\"".$this->socialBarLinkTitle." $element\"";
203  }
204  else
205  {
206  $title = '';
207  }
208 
209  // check alignment
210  if (isset($this->socialBarAlign) && (!empty($this->socialBarAlign)))
211  { // if alignment is set to vertical
212  if ($this->socialBarAlign === 'vertical')
213  { // generate linebreak markup
214  $lineBreak = "<br>";
215  }
216  else
217  { // no linebreak, two blank spaces instead
218  $lineBreak = '&nbsp;&nbsp;';
219  }
220  }
221  else
222  { // no alignment set - two blank spaces are default
223  $lineBreak = '&nbsp;&nbsp;';
224  }
225 
226  // check if icon is set
227  if (isset($data['icon']) && (!empty($data['icon'])))
228  {
229  // check social bar element class
230  if (isset($this->socialBarClass) && (!empty($this->socialBarClass)))
231  { // set css class for this element
232  $cssClass = " ".$this->socialBarClass."";
233  }
234  else
235  { // no class required, leave empty
236  $cssClass = '';
237  }
238 
239  // draw social button
240  echo "<a href=\"$data[url]\"".$this->socialBarLinkColor."$title target=\"$this->socialBarLinkTarget\"><i class=\"$data[icon]".$cssClass."\"></i></a>".$lineBreak."";
241  }
242  else
243  {
244  // check social bar element class
245  if (isset($this->socialBarClass) && (!empty($this->socialBarClass)))
246  { // set css class for this element
247  $cssClass = " class=\"".$this->socialBarClass."\"";
248  }
249  else
250  { // no class required, leave empty
251  $cssClass = '';
252  }
253 
254  // draw textlink
255  echo "<a href=\"$data[url]\" title=\"$this->socialBarLinkTitle\" target=\"$this->socialBarLinkTarget\"".$cssClass.">$data[url]</a>".$lineBreak."";
256  }
257  }
258  }
259  echo "</".$this->socialBarSize.">";
260  echo "</div>";
261  echo "</div>";
262  }
filterUrl($url)
Filter and sanitize any socialBar URL.
Definition: socialBar.php:152

References YAWK\widget\$data, and YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar\filterUrl().

Referenced by YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar\init().

◆ filterUrl()

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::filterUrl (   $url)

Filter and sanitize any socialBar URL.

filter, sanitize and strip tags from URLs

Definition at line 152 of file socialBar.php.

154  { // check if url is set and not empty
155  if (isset($url) && (!empty($url)))
156  {
157  // remove illegal chars from url
158  $url = filter_var($url, FILTER_SANITIZE_URL);
159  // strip html tags
160  $url = strip_tags($url);
161  return $url;
162  }
163  else
164  { // nothing to return
165  return null;
166  }
$url
Definition: user-new.php:101

References $url.

Referenced by YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar\drawSocialBar().

◆ init()

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::init ( )

Init example widget and call a function for demo purpose.

Example Widget Init

Definition at line 97 of file socialBar.php.

99  { // call any function or method you have previously defined in this class
100  echo $this->getHeading($this->socialBarHeading, $this->socialBarSubtext);
101  $this->setSocialBarElements();
102  $this->drawSocialBar();
103 
setSocialBarElements()
Set an array with all social button elements.
Definition: socialBar.php:109
getHeading($heading, $subtext)
Get widget heading and subtext, return headline.
Definition: widget.php:669

References YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar\drawSocialBar(), YAWK\widget\getHeading(), and YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar\setSocialBarElements().

◆ setSocialBarElements()

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::setSocialBarElements ( )

Set an array with all social button elements.

Helper function that set an array with all social elements. Need to be called before drawSocialBar();

Definition at line 109 of file socialBar.php.

111  { // for every widget data setting create an element with data
112  foreach ($this->widget->data AS $element => $data)
113  { // if element is a URL
114  if (strpos($element, 'Url'))
115  { // get name of this social element
116  $substring = substr("$element", 9);
117  $substring = substr("$substring", 0, -3);
118  // store url property in array
119  $this->socialBarElements[$substring]['url'] = $data;
120  }
121  // if element is an icon
122  else if (strpos($element, 'Icon'))
123  { // get name of this social element
124  $substring = substr("$element", 9);
125  $substring = substr("$substring", 0, -4);
126  // store icon property in array
127  $this->socialBarElements[$substring]['icon'] = $data;
128  }
129  // if element is a color
130  else if (strpos($element, 'Color'))
131  { // get name of this social element
132  $substring = substr("$element", 9);
133  $substring = substr("$substring", 0, -5);
134  // store icon property in array
135  $this->socialBarElements[$substring]['color'] = $data;
136  }
137  }
138  // check if social array is set and not empty
139  if (is_array($this->socialBarElements) && (!empty($this->socialBarElements)))
140  { // all good, return social bar data array
142  }
143  else
144  { // no data here
145  return false;
146  }

References YAWK\widget\$data, and YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar\$socialBarElements.

Referenced by YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar\init().

Member Data Documentation

◆ $socialBarAlign

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarAlign = 'horizontal'
Parameters
stringSocial Bar Alignment (horizontal or vertical

Definition at line 74 of file socialBar.php.

◆ $socialBarClass

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarClass = ''
Parameters
stringSocial Bar CSS Class

Definition at line 76 of file socialBar.php.

◆ $socialBarElements

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarElements = ''
Parameters
arraySocial Bar Elements

Definition at line 70 of file socialBar.php.

Referenced by YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar\setSocialBarElements().

◆ $socialBarFacebookIcon

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarFacebookIcon = ''
Parameters
stringFacebook Icon

Definition at line 44 of file socialBar.php.

◆ $socialBarFacebookUrl

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarFacebookUrl = ''
Parameters
stringFacebook URL

Definition at line 26 of file socialBar.php.

◆ $socialBarGooglePlusIcon

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarGooglePlusIcon = ''
Parameters
stringGoogle Plus Icon

Definition at line 60 of file socialBar.php.

◆ $socialBarGooglePlusUrl

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarGooglePlusUrl = ''
Parameters
stringGoogle Plus URL

Definition at line 42 of file socialBar.php.

◆ $socialBarHeading

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarHeading = ''
Parameters
stringTitle that will be shown above widget

Definition at line 22 of file socialBar.php.

◆ $socialBarInstagramIcon

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarInstagramIcon = ''
Parameters
stringInstagram Icon

Definition at line 48 of file socialBar.php.

◆ $socialBarInstagramUrl

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarInstagramUrl = ''
Parameters
stringInstagram URL

Definition at line 30 of file socialBar.php.

◆ $socialBarLinkColor

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarLinkColor = ''
Parameters
stringSocial Bar Link Color

Definition at line 68 of file socialBar.php.

◆ $socialBarLinkedInIcon

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarLinkedInIcon = ''
Parameters
stringLinkedIn Icon

Definition at line 56 of file socialBar.php.

◆ $socialBarLinkedInUrl

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarLinkedInUrl = ''
Parameters
stringLinkedIn URL

Definition at line 38 of file socialBar.php.

◆ $socialBarLinkTarget

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarLinkTarget = ''
Parameters
stringSocial Bar Link Target

Definition at line 64 of file socialBar.php.

◆ $socialBarLinkTitle

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarLinkTitle = ''
Parameters
stringSocial Bar Link Target

Definition at line 66 of file socialBar.php.

◆ $socialBarMarkup

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarMarkup = ''
Parameters
stringSocial Bar Html Markup

Definition at line 62 of file socialBar.php.

◆ $socialBarPinterestIcon

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarPinterestIcon = ''
Parameters
stringPinterest Icon

Definition at line 50 of file socialBar.php.

◆ $socialBarPinterestUrl

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarPinterestUrl = ''
Parameters
stringPinterest URL

Definition at line 32 of file socialBar.php.

◆ $socialBarSize

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarSize = 'H2'
Parameters
stringSocial Bar Size

Definition at line 72 of file socialBar.php.

◆ $socialBarSubtext

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarSubtext = ''
Parameters
stringSubtext will be displayed beside title

Definition at line 24 of file socialBar.php.

◆ $socialBarTumblrIcon

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarTumblrIcon = ''
Parameters
stringTumblr Icon

Definition at line 54 of file socialBar.php.

◆ $socialBarTumblrUrl

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarTumblrUrl = ''
Parameters
stringTumblr URL

Definition at line 36 of file socialBar.php.

◆ $socialBarTwitterIcon

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarTwitterIcon = ''
Parameters
stringTwitter Icon

Definition at line 52 of file socialBar.php.

◆ $socialBarTwitterUrl

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarTwitterUrl = ''
Parameters
stringTwitter URL

Definition at line 34 of file socialBar.php.

◆ $socialBarXingIcon

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarXingIcon = ''
Parameters
stringXing Icon

Definition at line 58 of file socialBar.php.

◆ $socialBarXingUrl

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarXingUrl = ''
Parameters
stringXing URL

Definition at line 40 of file socialBar.php.

◆ $socialBarYouTubeIcon

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarYouTubeIcon = ''
Parameters
stringYouTube Icon

Definition at line 46 of file socialBar.php.

◆ $socialBarYouTubeUrl

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$socialBarYouTubeUrl = ''
Parameters
stringYouTube URL

Definition at line 28 of file socialBar.php.

◆ $widget

YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar::$widget = ''
Parameters
objectglobal widget object data

Definition at line 20 of file socialBar.php.


The documentation for this class was generated from the following file: