SproutCMS

This is the code documentation for the SproutCMS project

class Widgets

Provided functions for the display of widgets

Source code (63 results)

/skin/default/home.php   Highlighted file source

Line 9: use Sprout\Helpers\Widgets;
Line 68: <?php echo Widgets::renderArea('sidebar'); ?>

/skin/default/home.php   Highlighted file source

Line 9: use Sprout\Helpers\Widgets;
Line 68: <?php echo Widgets::renderArea('sidebar'); ?>

/skin/default/inner.php   Highlighted file source

Line 12: use Sprout\Helpers\Widgets;
Line 80: <?php echo Widgets::renderArea('sidebar'); ?>

/skin/default/inner.php   Highlighted file source

Line 12: use Sprout\Helpers\Widgets;
Line 80: <?php echo Widgets::renderArea('sidebar'); ?>

/skin/harbor/home.php   Highlighted file source

Line 9: use Sprout\Helpers\Widgets;

/skin/harbor/home.php   Highlighted file source

Line 9: use Sprout\Helpers\Widgets;

/sprout/Controllers/Admin/PageAdminController.php   Highlighted file source

Line 827: Pdb::insert('page_widgets', $update_fields);
Line 998: // Load widgets and collate rich text as page text
Line 1000: $widgets = [];
Line 1002: FROM ~page_widgets
Line 1008: $widgets[$widget['area_id']][] = $widget;
Line 1010: // Embedded rich text widgets
Line 1032: $widgets = [];
Line 1141: $view->widgets = $widgets;
Line 1294: // Collate POSTed widgets.
Line 1295: $new_widgets = [];
Line 1296: if (@count($_POST['widgets'])) {
Line 1297: foreach ($_POST['widgets'] as $area_name => $widgets) {
Line 1302: foreach ($widgets as $info) {
Line 1335: $new_widgets[] = [
Line 1349: // Compare new widgets with old ones -- if changed, need a new revision
Line 1351: FROM ~page_widgets
Line 1354: $old_widgets = Pdb::query($q, [$rev_id], 'arr');
Line 1355: if (count($new_widgets) != count($old_widgets)) {
Line 1358: foreach ($old_widgets as $key => $widget) {
Line 1359: if ($widget != @$new_widgets[$key]) {
Line 1398: foreach ($new_widgets as &$widget) {
Line 1627: // Widgets
Line 1628: Pdb::delete('page_widgets', ['page_revision_id' => $rev_id]);
Line 1630: foreach ($new_widgets as $widget) {
Line 1633: Pdb::insert('page_widgets', $update_fields);
Line 1722: // Do indexing on the page text, which is found in the embedded widgets
Line 2157: LEFT JOIN ~page_widgets AS widget ON rev.id = widget.page_revision_id
Line 2749: 'page_widgets' => 0,

/sprout/Controllers/Admin/PageAdminController.php   Highlighted file source

Line 827: Pdb::insert('page_widgets', $update_fields);
Line 998: // Load widgets and collate rich text as page text
Line 1000: $widgets = [];
Line 1002: FROM ~page_widgets
Line 1008: $widgets[$widget['area_id']][] = $widget;
Line 1010: // Embedded rich text widgets
Line 1032: $widgets = [];
Line 1141: $view->widgets = $widgets;
Line 1294: // Collate POSTed widgets.
Line 1295: $new_widgets = [];
Line 1296: if (@count($_POST['widgets'])) {
Line 1297: foreach ($_POST['widgets'] as $area_name => $widgets) {
Line 1302: foreach ($widgets as $info) {
Line 1335: $new_widgets[] = [
Line 1349: // Compare new widgets with old ones -- if changed, need a new revision
Line 1351: FROM ~page_widgets
Line 1354: $old_widgets = Pdb::query($q, [$rev_id], 'arr');
Line 1355: if (count($new_widgets) != count($old_widgets)) {
Line 1358: foreach ($old_widgets as $key => $widget) {
Line 1359: if ($widget != @$new_widgets[$key]) {
Line 1398: foreach ($new_widgets as &$widget) {
Line 1627: // Widgets
Line 1628: Pdb::delete('page_widgets', ['page_revision_id' => $rev_id]);
Line 1630: foreach ($new_widgets as $widget) {
Line 1633: Pdb::insert('page_widgets', $update_fields);
Line 1722: // Do indexing on the page text, which is found in the embedded widgets
Line 2157: LEFT JOIN ~page_widgets AS widget ON rev.id = widget.page_revision_id
Line 2749: 'page_widgets' => 0,

/sprout/Controllers/AdminAjaxController.php   Highlighted file source

Line 40: use Sprout\Helpers\Widgets;
Line 67: public function widgetSettings($widget_name)
Line 89: $widget = Widgets::instantiate($widget_name);
Line 206: $avail_widgets = $area->getWidgets();
Line 209: $widgets = array();
Line 210: foreach ($avail_widgets as $name) {
Line 211: $inst = Widgets::instantiate($name);
Line 212: $widgets[$inst->getFriendlyName()] = array(
Line 219: ksort($widgets);
Line 224: $view->widgets = $widgets;

/sprout/Controllers/AdminAjaxController.php   Highlighted file source

Line 40: use Sprout\Helpers\Widgets;
Line 67: public function widgetSettings($widget_name)
Line 89: $widget = Widgets::instantiate($widget_name);
Line 206: $avail_widgets = $area->getWidgets();
Line 209: $widgets = array();
Line 210: foreach ($avail_widgets as $name) {
Line 211: $inst = Widgets::instantiate($name);
Line 212: $widgets[$inst->getFriendlyName()] = array(
Line 219: ksort($widgets);
Line 224: $view->widgets = $widgets;

/sprout/Controllers/DbToolsController.php   Highlighted file source

Line 2919: // Render table of pages that need widgets replaced
Line 2924: 'Widgets' => 'widgets',

/sprout/Controllers/DbToolsController.php   Highlighted file source

Line 2919: // Render table of pages that need widgets replaced
Line 2924: 'Widgets' => 'widgets',

/sprout/Controllers/PageController.php   Highlighted file source

Line 48: use Sprout\Helpers\Widgets;
Line 151: $this->loadWidgets($conds_env, $page);
Line 277: // Get list of widgets and render their content
Line 279: $this->loadWidgets($conds_env, $page);
Line 280: $page_view->main_content = Widgets::renderArea('embedded');
Line 361: $text = ContentReplace::embedWidgets($text, 'page', $page_id);
Line 371: * @return array Environment which gets passed to {@see Widgets::checkDisplayConditions}
Line 382: * Loads the widgets from the database for this page.
Line 384: * @param array $page The page to load widgets from
Line 386: private function loadWidgets(array $conds_env, array $page)
Line 389: FROM ~page_widgets
Line 399: $result = Widgets::checkDisplayConditions($conds_env, $conditions);
Line 405: Widgets::add($widget['area_id'], $widget['type'], $settings, $widget['heading'], $widget['template']);
Line 440: // Collate widgets to produce page text

/sprout/Controllers/PageController.php   Highlighted file source

Line 48: use Sprout\Helpers\Widgets;
Line 151: $this->loadWidgets($conds_env, $page);
Line 277: // Get list of widgets and render their content
Line 279: $this->loadWidgets($conds_env, $page);
Line 280: $page_view->main_content = Widgets::renderArea('embedded');
Line 361: $text = ContentReplace::embedWidgets($text, 'page', $page_id);
Line 371: * @return array Environment which gets passed to {@see Widgets::checkDisplayConditions}
Line 382: * Loads the widgets from the database for this page.
Line 384: * @param array $page The page to load widgets from
Line 386: private function loadWidgets(array $conds_env, array $page)
Line 389: FROM ~page_widgets
Line 399: $result = Widgets::checkDisplayConditions($conds_env, $conditions);
Line 405: Widgets::add($widget['area_id'], $widget['type'], $settings, $widget['heading'], $widget['template']);
Line 440: // Collate widgets to produce page text

/sprout/Helpers/Admin.php   Highlighted file source

Line 24: * Sorter for widgets
Line 26: function _widgetSort($a, $b) {
Line 27: $a = Widgets::instantiate($a);
Line 28: $b = Widgets::instantiate($b);
Line 113: * Shows a UI for the list of widgets, for editing
Line 117: * @param array $curr_widgets A list of the widgets currently being used, in order, as db rows with keys:
Line 123: * @param boolean $enable_all Toggle whether all the widgets are enabled by default (defaults to true)
Line 125: public static function widgetList($field_name, WidgetArea $area, $curr_widgets, $enable_all = true)
Line 129: if ($curr_widgets == null) {
Line 130: $curr_widgets = [];
Line 138: foreach ($curr_widgets as $widget) {
Line 139: $inst = Widgets::instantiate($widget['type']);
Line 169: echo '<div class="widgets-sel"></div>';
Line 170: echo '<div class="widgets-empty">This area does not have any content blocks. Click the button below to add a content block:</div>';
Line 236: foreach ($tile['widgets'] as $widg => $name) {
Line 238: $inst = Widgets::instantiate($widg);

/sprout/Helpers/ContentReplace.php   Highlighted file source

Line 27: public static $preloaded_widgets = array();
Line 87: * Add some preloaded widgets, e.g. generated by a preview
Line 88: * @param array $widgets Format to match $_POST['widgets'] on
Line 93: public static function preloadWidgets(array $widgets, array $settings)
Line 95: foreach ($widgets as $area_name => $widget_list) {
Line 103: Widgets::add($area_id, $type, $widget_settings);
Line 104: self::$preloaded_widgets[] = array(
Line 115: * Replace embed code with the actual widgets.
Line 120: * @param string $widget_table The host table of the widgets, e.g. 'page'
Line 124: public static function embedWidgets($text, $widget_table, $widget_record)
Line 126: $widgets = self::$preloaded_widgets;
Line 149: // Replace preloaded widgets first
Line 151: foreach ($widgets as $widget) {
Line 162: $widgets = self::lookupWidgets($widget_table, $widget_record, $embeds);
Line 164: foreach ($widgets as $widget) {
Line 177: * @param string $widget_table The host table of the widgets, e.g. 'page'
Line 184: public static function lookupWidgets($widget_table, $widget_record, array $embed_keys)
Line 196: FROM ~{$widget_table}_widgets
Line 200: $widgets = array();
Line 203: $widgets[$row['embed_key']] = $row;
Line 205: return $widgets;
Line 212: * @param array $widget as per {@link lookupWidgets()}, has keys and values
Line 219: $rendered = Widgets::render(
Line 232: public static function removeWidgets($text)
Line 243: * Replace embed code with the actual widget. This is a tweaked version of embedWidgets, designed for email
Line 247: * @param string $widget_table The host table of the widgets, e.g. 'page'
Line 250: public static function emailWidgets($text, $widget_table, $widget_record, $pre_html, $post_html)
Line 257: return preg_replace_callback('!<p>(?:<code>)?\(\(WIDGET [a-zA-Z]*? ?([0-9A-Za-z]+)\)\)(?:</code>)?</p>!', array('Sprout\Helpers\ContentReplace', '_email_widgets'), $text);
Line 260: private static function _emailWidgets($matches)
Line 266: FROM ~{$widget_table}_widgets
Line 275: return Widgets::render(

/sprout/Helpers/ContentReplace.php   Highlighted file source

Line 27: public static $preloaded_widgets = array();
Line 87: * Add some preloaded widgets, e.g. generated by a preview
Line 88: * @param array $widgets Format to match $_POST['widgets'] on
Line 93: public static function preloadWidgets(array $widgets, array $settings)
Line 95: foreach ($widgets as $area_name => $widget_list) {
Line 103: Widgets::add($area_id, $type, $widget_settings);
Line 104: self::$preloaded_widgets[] = array(
Line 115: * Replace embed code with the actual widgets.
Line 120: * @param string $widget_table The host table of the widgets, e.g. 'page'
Line 124: public static function embedWidgets($text, $widget_table, $widget_record)
Line 126: $widgets = self::$preloaded_widgets;
Line 149: // Replace preloaded widgets first
Line 151: foreach ($widgets as $widget) {
Line 162: $widgets = self::lookupWidgets($widget_table, $widget_record, $embeds);
Line 164: foreach ($widgets as $widget) {
Line 177: * @param string $widget_table The host table of the widgets, e.g. 'page'
Line 184: public static function lookupWidgets($widget_table, $widget_record, array $embed_keys)
Line 196: FROM ~{$widget_table}_widgets
Line 200: $widgets = array();
Line 203: $widgets[$row['embed_key']] = $row;
Line 205: return $widgets;
Line 212: * @param array $widget as per {@link lookupWidgets()}, has keys and values
Line 219: $rendered = Widgets::render(
Line 232: public static function removeWidgets($text)
Line 243: * Replace embed code with the actual widget. This is a tweaked version of embedWidgets, designed for email
Line 247: * @param string $widget_table The host table of the widgets, e.g. 'page'
Line 250: public static function emailWidgets($text, $widget_table, $widget_record, $pre_html, $post_html)
Line 257: return preg_replace_callback('!<p>(?:<code>)?\(\(WIDGET [a-zA-Z]*? ?([0-9A-Za-z]+)\)\)(?:</code>)?</p>!', array('Sprout\Helpers\ContentReplace', '_email_widgets'), $text);
Line 260: private static function _emailWidgets($matches)
Line 266: FROM ~{$widget_table}_widgets
Line 275: return Widgets::render(

/sprout/Helpers/ImportCMS.php   Highlighted file source

Line 53: // Create pages and content widgets
Line 67: 'widgets' => @self::$old_widets[$old_id],
Line 141: Pdb::insert('page_widgets', $fields);
Line 170: ~page_widgets AS widget
Line 174: $widgets = Pdb::query($q, $params, 'arr');
Line 176: foreach ($widgets as $widget) {
Line 182: self::findOldWidgets($widget['page_revision_id'], $settings->text);
Line 184: Pdb::update('page_widgets', ['settings' => json_encode(['text' => $settings->text])], [['id', '=', $widget['id']]]);
Line 206: * Report pages that contain old widgets
Line 211: private static function findOldWidgets($rev_id, $html)

/sprout/Helpers/Page.php   Highlighted file source

Line 165: * Gets the embedded widgets (i.e. content blocks) for a page
Line 167: * @param string $include 'active' to only include active widgets,
Line 168: * 'all' to include disabled widgets as well
Line 171: public static function getContentWidgets($rev_id, $include)
Line 181: FROM ~page_widgets
Line 189: * Get the page text for a page id, in HTML format, with widgets and everything, ready to go
Line 233: $widgets = self::getContentWidgets($rev_id, 'active');
Line 234: foreach ($widgets as $widget) {
Line 235: $inst = Widgets::instantiate($widget['type']);
Line 293: * Only widgets on live revisions of active pages are checked.
Line 302: FROM ~page_widgets AS widget

/sprout/Helpers/Register.php   Highlighted file source

Line 24: * incl. widgets, search handlers, tabs, etc.
Line 394: * Register a widget "tile", which is shown when adding widgets (content blocks) to a page
Line 396: * If a tile already exists with that name, the widgets will be added to that tile
Line 404: * @param array $widgets Widgets to show as links, in format 'name' => 'label'
Line 406: public static function widgetTile($area_name, $name, $icon, $text, array $widgets)
Line 416: self::$widget_tiles[$area_name][$name]['widgets'] = array_merge(
Line 417: self::$widget_tiles[$area_name][$name]['widgets'],
Line 418: $widgets
Line 425: 'widgets' => $widgets,
Line 429: foreach ($widgets as $name => $label) {
Line 437: * Each tile has four keys, 'name', 'icon', 'text', and 'widgets'.
Line 500: * inner_html The "inside" HTML of widgets (richtext, blog content, etc)
Line 595: * Register a display condition (this is part of the Context Engine on widgets)

/sprout/Helpers/Register.php   Highlighted file source

Line 24: * incl. widgets, search handlers, tabs, etc.
Line 394: * Register a widget "tile", which is shown when adding widgets (content blocks) to a page
Line 396: * If a tile already exists with that name, the widgets will be added to that tile
Line 404: * @param array $widgets Widgets to show as links, in format 'name' => 'label'
Line 406: public static function widgetTile($area_name, $name, $icon, $text, array $widgets)
Line 416: self::$widget_tiles[$area_name][$name]['widgets'] = array_merge(
Line 417: self::$widget_tiles[$area_name][$name]['widgets'],
Line 418: $widgets
Line 425: 'widgets' => $widgets,
Line 429: foreach ($widgets as $name => $label) {
Line 437: * Each tile has four keys, 'name', 'icon', 'text', and 'widgets'.
Line 500: * inner_html The "inside" HTML of widgets (richtext, blog content, etc)
Line 595: * Register a display condition (this is part of the Context Engine on widgets)

/sprout/Helpers/Sprout.php   Highlighted file source

Line 175: * $inst = Sprout::instance($widget_class, 'Sprout\\Widgets\\Widget');

/sprout/Helpers/SproutVariable.php   Highlighted file source

Line 41: public $widgets;
Line 58: $this->widgets = new Widgets();

/sprout/Helpers/WidgetArea.php   Highlighted file source

Line 19: * Stores information about an individual widget area, including the names of all widgets
Line 27: private $widgets;
Line 57: $this->widgets = array();
Line 131: * Adds a widget to the list of widgets allowed for this area
Line 137: if (! in_array($widget_name, $this->widgets)) {
Line 138: $this->widgets[] = $widget_name;
Line 143: * Gets the list of allowed widgets
Line 145: public function getWidgets()
Line 147: return $this->widgets;
Line 152: * Adds a widget to the list of widgets allowed for this area
Line 158: Widgets::add($this->index, $widget_name, $settings);

/sprout/Helpers/Widgets.php   Highlighted file source

Line 23: * Provided functions for the display of widgets
Line 25: class Widgets
Line 30: * Add a widget to the list of widgets for a specific area
Line 50: * Remove a widget to the list of widgets for a specific area
Line 79: $class = 'Sprout\\Widgets\\' . $class;
Line 181: * Draw the widgets for a specific area
Line 187: * @return string HTML representing the rendered widgets
Line 214: * @deprecated Use {@see Widgets::renderArea} instead
Line 223: * Does the specified widget area have widgets?
Line 230: public static function hasWidgets($area_name)

/sprout/sprout_load.php   Highlighted file source

Line 53: Register::contentReplace('main_content', ['Sprout\\Widgets\\ImageGalleryWidget', 'contentReplace']);

/sprout/sprout_load.php   Highlighted file source

Line 53: Register::contentReplace('main_content', ['Sprout\\Widgets\\ImageGalleryWidget', 'contentReplace']);

/sprout/views/admin/page_edit.php   Highlighted file source

Line 348: Admin::widgetList($area->getName(), $area, @$widgets[$area_id], empty($page['redirect']));
Line 357: <!-- Widgets-->
Line 358: <div class="sidebar-widgets">
Line 382: Admin::widgetList($area->getName(), $area, @$widgets[$area_id], empty($page['redirect']));

/sprout/views/admin/page_edit.php   Highlighted file source

Line 348: Admin::widgetList($area->getName(), $area, @$widgets[$area_id], empty($page['redirect']));
Line 357: <!-- Widgets-->
Line 358: <div class="sidebar-widgets">
Line 382: Admin::widgetList($area->getName(), $area, @$widgets[$area_id], empty($page['redirect']));

/sprout/Widgets/ImageGalleryWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 22: use Sprout\Helpers\Widgets;
Line 333: $widget = Widgets::render(WidgetArea::ORIENTATION_EMAIL, 'Sprout\Widgets\ImageGalleryWidget', [

/sprout/Widgets/ImageGalleryWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 22: use Sprout\Helpers\Widgets;
Line 333: $widget = Widgets::render(WidgetArea::ORIENTATION_EMAIL, 'Sprout\Widgets\ImageGalleryWidget', [

/sprout/Widgets/MapWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;

/sprout/Widgets/MapWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;

/sprout/Widgets/Widget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 19: * Base class for widgets
Line 42: * Array of default settings for new widgets
Line 131: * Run after import of settings, allows extending widgets to clean up settings which may
Line 185: * Most widgets show content using a category selection box; the URL should in that
Line 200: * Most widgets show content using a category selection box; in that case

/sprout/Widgets/Widget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 19: * Base class for widgets
Line 42: * Array of default settings for new widgets
Line 131: * Run after import of settings, allows extending widgets to clean up settings which may
Line 185: * Most widgets show content using a category selection box; the URL should in that
Line 200: * Most widgets show content using a category selection box; in that case

A total of 325 lines in 63 files were found