YaWK  24.1
Yet another WebKit
YAWK\widget Class Reference

Widgets are small, useful tools that you can include everywhere in your website. More...

+ Inheritance diagram for YAWK\widget:

Public Member Functions

 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...
 

Static Public Member Functions

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...
 

Public Attributes

 $data
 
 $date_publish
 
 $date_unpublish
 
 $folder
 
 $id
 
 $marginBottom
 
 $marginTop
 
 $name
 
 $pageID
 
 $position
 
 $published
 
 $sort
 
 $widgetTitle
 
 $widgetType
 

Detailed Description

Widgets are small, useful tools that you can include everywhere in your website.

Widgets are small, useful tools that you can include everywhere on your website.

YaWK comes with a lot of widgets for different purposes. As an example, you can add SocialMedia buttons, Facebook Boxes, Likebuttons or other things like a simple contant and many other small utilities for typical daily needs of nearly every web project. Check out the files in system/widgets to get a clue about how widget's file structure is organized. You miss a widget? Dont worry. It is easy to create your own - or copy and modify an existing one to make it fit your needs. If you want to get deeper into the widget system of YaWK, read the following docs.

Class covers both, backend & frontend functionality. See Methods Summary for Details!

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

Definition at line 21 of file widget.php.

Member Function Documentation

◆ getAllSettingsIntoArray()

static YAWK\widget::getAllSettingsIntoArray (   $db,
  $widgetID 
)
static

Returns an array with all widget settings data.

Parameters
object$dbDatabase Object
Returns
array|bool

TODO: IMPLEMENT GET WIDGET SETTINGS ARRRAY for issue #61

Definition at line 127 of file widget.php.

128  {
129  /* @param $db \YAWK\db */
130  if ($res = $db->query("SELECT * FROM {widget_settings} WHERE widgetID = '".$widgetID."' ORDER by sortation"))
131  {
132  $settingsArray = array();
133  while ($row = $res->fetch_assoc())
134  { // fill array
135  $settingsArray[] = $row;
136  }
137  }
138  else
139  { // q failed, throw error
140  \YAWK\sys::setSyslog($db, 39, 1, "failed to get widget settings array of widget ID $widgetID", 0, 0, 0, 0);
141  // \YAWK\alert::draw("warning", "Warning!", "Fetch database error: getSettingsArray failed.","","4800");
142  return false;
143  }
144  return $settingsArray;
145  }

References $db, and $res.

◆ getAllWidgetTypes()

static YAWK\widget::getAllWidgetTypes (   $db)
static

Return all widget types as associative array.

Parameters
object$dbdatabase
Returns
array return all widgets types from database

Definition at line 1211 of file widget.php.

1212  {
1213  $row = $db->query("SELECT * FROM {widget_types} ORDER BY name");
1214  while ($res = mysqli_fetch_assoc($row))
1215  {
1216  $widgetTypes[] = $res;
1217  }
1218  if (is_array($widgetTypes) && (!empty($widgetTypes))){
1219  return $widgetTypes;
1220  }
1221  else
1222  {
1223  \YAWK\sys::setSyslog($db, 39, 1, "failed to get list of widget types. $widgetTypes is empty or not set.", 0, 0, 0, 0);
1224  return false;
1225  }
1226  }
$widgetTypes
Definition: widget-new.php:113

References $db, $res, and $widgetTypes.

◆ getCurrentWidgetPath()

static YAWK\widget::getCurrentWidgetPath (   $db)
static

return current widget path

Parameters
object$dbdatabase
Returns
string full path to widgets folder

Definition at line 115 of file widget.php.

116  {
117  return "" . \YAWK\sys::getDirPrefix($db) . "/system/widgets/";
118  }
static getDirPrefix($db)
if yawk is installed into a subdirectory, use this to get this prefix directory
Definition: sys.php:1104

References $db, and YAWK\sys\getDirPrefix().

◆ getFacebookLikeBox()

static YAWK\widget::getFacebookLikeBox ( )
static

return the facebook likebox widget

Definition at line 909 of file widget.php.

910  {
911  include 'system/widgets/fb_like/fb_like.php';
912  }

◆ getHeading()

YAWK\widget::getHeading (   $heading,
  $subtext 
)

Get widget heading and subtext, return headline.

Parameters
string$headingThe Heading
string$subtextThe Subtext
Returns
string|bool return the correct headline

Definition at line 669 of file widget.php.

670  {
671  // if a heading is set and not empty
672  if (isset($heading) && (!empty($heading)))
673  {
674  // if subtext is set, add <small> subtext to string
675  if (isset($subtext) && (!empty($subtext)))
676  { // build a headline with heading and subtext
677  $subtext = "<small>$subtext</small>";
678  return "<h2>$heading&nbsp;" . "$subtext</h2>";
679  }
680  else
681  { // build just a headline - without subtext
682  return "<h2>$heading</h2>"; // draw just the heading
683  }
684  }
685  else
686  { // leave empty if it's not set
687  return null;
688  }
689  }
$subtext
Definition: jplayer.php:19
$heading
Definition: jplayer.php:18

References $heading, and $subtext.

Referenced by YAWK\WIDGETS\BLOG\WIDGET\blogWidget\drawBlogWidget(), YAWK\WIDGETS\GALLERY\IMAGES\gallery\drawImageGallery(), YAWK\WIDGETS\LOGINBOX\LOGIN\loginbox\drawLoginBox(), YAWK\WIDGETS\GOOGLE\MAPS\googleMaps\embed(), YAWK\WIDGETS\INSTAGRAM\POSTING\instagram\embed(), YAWK\WIDGETS\SUBMENU\EMBED\submenu\init(), YAWK\WIDGETS\FACEBOOK\LIKEPAGE\fbLikePage\init(), YAWK\WIDGETS\FACEBOOK\POSTING\fbPosting\init(), YAWK\WIDGETS\FACEBOOK\VIDEO\fbVideo\init(), YAWK\WIDGETS\PINTEREST\FOLLOW\pinterestFollow\init(), YAWK\WIDGETS\PINTEREST\PIN\pinterestPin\init(), YAWK\WIDGETS\PINTEREST\PROFILE\pinterestProfile\init(), YAWK\WIDGETS\PLYR\PLAYER\plyr\init(), YAWK\WIDGETS\PREZI\EMBED\prezi\init(), YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar\init(), YAWK\WIDGETS\SPOTIFY\EMBED\spotify\init(), YAWK\WIDGETS\TWITCH\EMBED\twitch\init(), YAWK\WIDGETS\TWITTER\GRID\twitterGrid\init(), YAWK\WIDGETS\TWITTER\TIMELINE\twitterTimeline\init(), YAWK\WIDGETS\TWITTER\TWEET\twitterTweet\init(), YAWK\WIDGETS\TWITTER\BUTTON\twitterTweetButton\init(), and YAWK\WIDGETS\EXAMPLE\DEMO\example\showHeading().

◆ getLoginBox()

static YAWK\widget::getLoginBox ( )
static

return the user login box widget

Definition at line 901 of file widget.php.

902  {
903  return include 'system/widgets/loginbox/loginbox.php';
904  }

◆ getWidgetSettingsArray()

YAWK\widget::getWidgetSettingsArray (   $db)

Get widget settings and return it as array.

Parameters
object$dbdatabase
Returns
array|bool returns array with widget settings or null

Definition at line 69 of file widget.php.

70  {
71  // $_GET['widgetID'] will be generated in \YAWK\widget\loadWidgets($db, $position)
72  if (isset($_GET['widgetID']))
73  {
74  // widget ID
75  $this->id = $_GET['widgetID'];
76  // data array
77  $this->data = array();
78 
79  // get widget settings from db
80  $res = $db->query("SELECT property, value FROM {widget_settings}
81  WHERE widgetID = '".$this->id."'
82  AND activated = '1'");
83  // get data in loop
84  while($row = mysqli_fetch_assoc($res))
85  { // set widget properties and values into this data array
86  $this->data[$row['property']] = $row['value'];
87  } // end while fetch row (fetch widget settings)
88 
89  // check if data array is set
90  if (is_array($this->data))
91  { // ok, return widget settings array
92  return ($this->data);
93  }
94  else
95  { // widget settings could not be retrieved
96  echo "Error: this data object is empty - unable to load widget settings of widget ID: ".$this->id."";
97  echo "<pre>";
98  print_r($this);
99  echo "</pre>";
100  }
101  }
102  else
103  { // no widget ID requested - do nothing.
104  return null;
105  }
106  return null;
107  }
print $_GET['id']
Definition: page-edit.php:357

References $_GET, $db, and $res.

Referenced by YAWK\WIDGETS\BLOG\WIDGET\blogWidget\__construct(), YAWK\WIDGETS\BUBBLUS\MINDMAP\bubblus\__construct(), YAWK\WIDGETS\CHATURBATE\STREAM\chaturbate\__construct(), YAWK\WIDGETS\CLOCK\CURRENT\clock\__construct(), YAWK\WIDGETS\CONTENTANIMATOR\ANIMATE\contentAnimator\__construct(), YAWK\WIDGETS\CULTURALBROADCASTING\STREAM\culturalBroadcastingArchive\__construct(), YAWK\WIDGETS\CUSTOM_HTML\CODE\customHtml\__construct(), YAWK\WIDGETS\EMBED_PAGE\PAGE\embedPage\__construct(), YAWK\WIDGETS\EXAMPLE\DEMO\example\__construct(), YAWK\WIDGETS\FACEBOOK\EVENTS\fbEvents\__construct(), YAWK\WIDGETS\FACEBOOK\LIKEBUTTON\fbLikeButton\__construct(), YAWK\WIDGETS\FACEBOOK\LIKEPAGE\fbLikePage\__construct(), YAWK\WIDGETS\FACEBOOK\POSTING\fbPosting\__construct(), YAWK\WIDGETS\FACEBOOK\VIDEO\fbVideo\__construct(), YAWK\WIDGETS\FUCKADBLOCK\BLOCK\fuckadblock\__construct(), YAWK\WIDGETS\GALLERY\IMAGES\gallery\__construct(), YAWK\WIDGETS\GOOGLE\ANALYTICS\googleAnalytics\__construct(), YAWK\WIDGETS\GOOGLE\MAPS\googleMaps\__construct(), YAWK\WIDGETS\INSTAGRAM\POSTING\instagram\__construct(), YAWK\WIDGETS\LOGINBOX\LOGIN\loginbox\__construct(), YAWK\WIDGETS\NEWSLETTER\SUBSCRIBE\newsletter\__construct(), YAWK\WIDGETS\PINTEREST\FOLLOW\pinterestFollow\__construct(), YAWK\WIDGETS\PINTEREST\PIN\pinterestPin\__construct(), YAWK\WIDGETS\PINTEREST\PROFILE\pinterestProfile\__construct(), YAWK\WIDGETS\PLYR\PLAYER\plyr\__construct(), YAWK\WIDGETS\PREZI\EMBED\prezi\__construct(), YAWK\WIDGETS\SOCIALBAR\DISPLAY\socialBar\__construct(), YAWK\WIDGETS\SOUNDCLOUD\PLAYER\soundcloud\__construct(), YAWK\WIDGETS\SPOTIFY\EMBED\spotify\__construct(), YAWK\WIDGETS\SUBMENU\EMBED\submenu\__construct(), YAWK\WIDGETS\TWITCH\EMBED\twitch\__construct(), YAWK\WIDGETS\TWITTER\GRID\twitterGrid\__construct(), YAWK\WIDGETS\TWITTER\TIMELINE\twitterTimeline\__construct(), YAWK\WIDGETS\TWITTER\TWEET\twitterTweet\__construct(), YAWK\WIDGETS\TWITTER\BUTTON\twitterTweetButton\__construct(), YAWK\WIDGETS\YOUTUBE\VIDEO\youtube\__construct(), and YAWK\WIDGETS\BOOKING\FORM\bookingWidget\__construct().

◆ loadWidgetsOfPage()

static YAWK\widget::loadWidgetsOfPage (   $db,
  $page 
)
static

Returns an array of all widgets that are linked with given page->id.

Parameters
object$dbdatabase
object$pagethe current page object
Returns
array return all widgets that are connected with this page

Definition at line 1182 of file widget.php.

1183  {
1184  if (isset($page->id) && (is_numeric($page->id)))
1185  {
1186  $row = $db->query("SELECT cw.id,cw.published,cw.widgetType,cw.pageID,cw.sort,cw.position, cw.date_publish, cw.date_unpublish, cw.widgetTitle, cwt.name, cwt.folder
1187  FROM {widgets} as cw
1188  JOIN {widget_types} as cwt on cw.widgetType = cwt.id
1189  WHERE (cw.pageID = '" . $page->id . "' OR cw.pageID = '0')
1190  ORDER BY cw.sort");
1191 
1192  // create list of widgets as associative array and return it
1193  while ($result = mysqli_fetch_assoc($row)){
1194  $list[] = $result;
1195  }
1196  if (isset($list) && (is_array($list))){
1197  return $list;
1198  }
1199  else {
1200  return false;
1201  }
1202  }
1203  }
$result
Definition: email-send.php:137
$page
Definition: pages.php:355

References $db, $page, and $result.

Referenced by YAWK\backend\drawWidgetsOnPageBox().

◆ printObject()

YAWK\widget::printObject ( )

Print all object data.

(for development and testing purpose)

Reimplemented in YAWK\WIDGETS\INSTAGRAM\POSTING\instagram, YAWK\WIDGETS\GOOGLE\MAPS\googleMaps, YAWK\WIDGETS\GOOGLE\ANALYTICS\googleAnalytics, YAWK\WIDGETS\GALLERY\IMAGES\gallery, YAWK\WIDGETS\EXAMPLE\DEMO\example, and YAWK\WIDGETS\BLOG\WIDGET\blogWidget.

Definition at line 57 of file widget.php.

58  { // output data to screen
59  echo "<pre>";
60  print_r($this);
61  echo "</pre>";
62  }

Member Data Documentation

◆ $data

YAWK\widget::$data
  • Parameters
    arraywidget settings data array placeholder

Definition at line 50 of file widget.php.

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

◆ $date_publish

YAWK\widget::$date_publish
  • Parameters
    stringdate when widget publishing starts

Definition at line 42 of file widget.php.

◆ $date_unpublish

YAWK\widget::$date_unpublish
  • Parameters
    stringdate when widget publishing ends

Definition at line 44 of file widget.php.

◆ $folder

YAWK\widget::$folder
  • Parameters
    stringfoldername of this widget

Definition at line 48 of file widget.php.

◆ $id

YAWK\widget::$id
  • Parameters
    intwidget ID

Definition at line 26 of file widget.php.

◆ $marginBottom

YAWK\widget::$marginBottom
  • Parameters
    intmargin from bottom in px

Definition at line 38 of file widget.php.

◆ $marginTop

YAWK\widget::$marginTop
  • Parameters
    intmargin from top in px

Definition at line 36 of file widget.php.

◆ $name

YAWK\widget::$name
  • Parameters
    stringwidget name

Definition at line 28 of file widget.php.

◆ $pageID

YAWK\widget::$pageID
  • Parameters
    intID of the page where this widget should appear

Definition at line 40 of file widget.php.

◆ $position

YAWK\widget::$position
  • Parameters
    stringtemplate position to appear

Definition at line 32 of file widget.php.

◆ $published

YAWK\widget::$published
  • Parameters
    int0|1 published or not

Definition at line 24 of file widget.php.

◆ $sort

YAWK\widget::$sort
  • Parameters
    intorder sortation number

Definition at line 30 of file widget.php.

◆ $widgetTitle

YAWK\widget::$widgetTitle
  • Parameters
    stringtitle to identify the widget

Definition at line 46 of file widget.php.

◆ $widgetType

YAWK\widget::$widgetType
  • Parameters
    intwidget type number

Definition at line 34 of file widget.php.


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