SproutCMS

This is the code documentation for the SproutCMS project

class Widget

Base class for widgets

Source code (57 results)

/config/sprout.php   Highlighted file source

Line 8: use Sprout\Helpers\WidgetArea;
Line 97: // The default widgets are listed in sprout/sprout_load.php
Line 98: // You can still add widgets in here if you really want though
Line 101: * Define the widget area: embedded
Line 103: $config['widget_areas'][1] = $area = new WidgetArea('embedded', 1);
Line 106: $area->setOrientation(WidgetArea::ORIENTATION_WIDE);
Line 111: * Define the widget area: sidebar
Line 113: $config['widget_areas'][2] = $area = new WidgetArea('sidebar', 2);
Line 116: $area->setOrientation(WidgetArea::ORIENTATION_TALL);
Line 121: * Define the widget area: email
Line 123: $config['widget_areas'][4] = $area = new WidgetArea('email', 4);
Line 126: $area->setOrientation(WidgetArea::ORIENTATION_EMAIL);

/skin/default/config/sprout.php   Highlighted file source

Line 35: * Image gallery widget
Line 154: $config['related_heading'] = '<h3 class="widget-title">SECTION</h3>';
Line 158: * Widget heading/title
Line 160: * Anywhere where the string TITLE is found, it will be replaced with the user given widget heading
Line 162: $config['widget_title'] = '<h2 class="widget-title">TITLE</h2>';
Line 220: * Widget wrapper templates
Line 222: * Your partial must contain HTML with the merge tag: {{widget}}
Line 223: * to be replaced with the actual widget's HTML
Line 225: $config['widget_templates'] = array(

/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/harbor/config/sprout.php   Highlighted file source

Line 35: * Image gallery widget
Line 154: $config['related_heading'] = '<h3 class="widget-title">SECTION</h3>';
Line 158: * Widget heading/title
Line 160: * Anywhere where the string TITLE is found, it will be replaced with the user given widget heading
Line 162: $config['widget_title'] = '<h2 class="widget-title">TITLE</h2>';
Line 214: * Widget wrapper templates
Line 216: * Your partial must contain HTML with the merge tag: {{widget}}
Line 217: * to be replaced with the actual widget's HTML
Line 219: $config['widget_templates'] = array(

/skin/harbor/home.php   Highlighted file source

Line 9: use Sprout\Helpers\Widgets;

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

Line 30: use Sprout\Helpers\RefineWidgetSelect;
Line 31: use Sprout\Helpers\RefineWidgetTextbox;
Line 67: $this->refine_bar->addWidget(new RefineWidgetSelect('type', 'Type', $types));
Line 68: $this->refine_bar->addWidget(new RefineWidgetTextbox('record_table', 'Table'));
Line 69: $this->refine_bar->addWidget(new RefineWidgetTextbox('record_id', 'Record ID'));
Line 70: $this->refine_bar->addWidget(new RefineWidgetTextbox('modified_editor', 'Editor'));

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

Line 19: use Sprout\Helpers\RefineWidgetSelect;
Line 20: use Sprout\Helpers\RefineWidgetTextbox;
Line 48: $this->refine_bar->addWidget(new RefineWidgetTextbox('name', 'Name'));
Line 49: $this->refine_bar->addWidget(new RefineWidgetTextbox('email', 'Email'));

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

Line 22: use Sprout\Helpers\RefineWidgetSelect;
Line 23: use Sprout\Helpers\RefineWidgetTextbox;
Line 58: $this->refine_bar->addWidget(new RefineWidgetTextbox('name', 'Name'));
Line 59: $this->refine_bar->addWidget(new RefineWidgetSelect('status', 'Status', array('Incomplete', 'Complete')));

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

Line 20: use Sprout\Helpers\RefineWidgetSelect;
Line 56: $this->refine_bar->addWidget(new RefineWidgetSelect('type', 'Type', $this->extra_page_types));

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

Line 43: use Sprout\Helpers\RefineWidgetSelect;
Line 44: use Sprout\Helpers\RefineWidgetTextbox;
Line 92: $this->refine_bar->addWidget(new RefineWidgetTextbox('name', 'Name'));
Line 93: $this->refine_bar->addWidget(new RefineWidgetSelect('type', 'Type', FileConstants::$type_names));
Line 94: $this->refine_bar->addWidget(new RefineWidgetTextbox('filename', 'Filename'));
Line 97: $this->refine_bar->addWidget(new RefineWidgetSelect('document_type', 'Document Type', Pdb::lookup('document_types')));

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

Line 32: use Sprout\Helpers\RefineWidgetSelect;
Line 83: $this->refine_bar->addWidget(new RefineWidgetSelect('_category_id', 'Category', $records));

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

Line 39: use Sprout\Helpers\RefineWidgetSelect;
Line 40: use Sprout\Helpers\RefineWidgetTextbox;
Line 157: * Defines the widgets for the refine bar
Line 202: $this->refine_bar->addWidget(new RefineWidgetSelect('_date_modified', 'Date modified', Constants::$recent_dates));
Line 203: $this->refine_bar->addWidget(new RefineWidgetSelect('_date_added', 'Date added', Constants::$recent_dates));
Line 204: $this->refine_bar->addWidget(new RefineWidgetTextbox('_all_tag', 'All the tags'));
Line 205: $this->refine_bar->addWidget(new RefineWidgetTextbox('_any_tag', 'Any of the tags'));
Line 216: * Initialises the refine bar if it isn't already set, with a search widget for the 'name' field if it exists
Line 217: * Most controllers which need a custom refine bar should call this before adding their own search widgets
Line 228: $this->refine_bar->addWidget(new RefineWidgetTextbox('name', 'Name'));

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

Line 56: use Sprout\Helpers\RefineWidgetTextbox;
Line 70: use Sprout\Helpers\WidgetArea;
Line 91: $this->refine_bar->addWidget(new RefineWidgetTextbox('name', 'Name'));
Line 94: $this->refine_bar->addWidget(new RefineWidgetTextbox('_keyword', 'Keyword search'));
Line 95: $this->refine_bar->addWidget(new RefineWidgetTextbox('_phrase', 'Exact phrase'));
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 1007: foreach ($wids as $widget) {
Line 1008: $widgets[$widget['area_id']][] = $widget;
Line 1010: // Embedded rich text widgets
Line 1011: if ($widget['area_id'] == 1 and $widget['type'] == 'RichText') {
Line 1012: $settings = json_decode($widget['settings'], true);
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 1298: $area = WidgetArea::findAreaByName($area_name);
Line 1302: foreach ($widgets as $info) {
Line 1306: if ($_POST['widget_deleted'][$area_name][$index] == '1') {
Line 1310: $settings = @$_POST['widget_settings_' . $index];
Line 1316: if (isset($_POST['widget_active'][$area_name][$index])) {
Line 1317: $active = (int) (bool) $_POST['widget_active'][$area_name][$index];
Line 1321: if (isset($_POST['widget_conds'][$area_name][$index])) {
Line 1322: $conditions = $_POST['widget_conds'][$area_name][$index];
Line 1326: if (isset($_POST['widget_heading'][$area_name][$index])) {
Line 1327: $heading = $_POST['widget_heading'][$area_name][$index];
Line 1331: if (isset($_POST['widget_template'][$area_name][$index])) {
Line 1332: $template = $_POST['widget_template'][$area_name][$index];
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 1399: if ($widget['area_id'] != 1 or $widget['type'] != 'RichText') continue;
Line 1400: $settings = json_decode($widget['settings'], true);
Line 1404: $widget['settings'] = json_encode($settings);
Line 1408: unset($widget);
Line 1627: // Widgets
Line 1628: Pdb::delete('page_widgets', ['page_revision_id' => $rev_id]);
Line 1630: foreach ($new_widgets as $widget) {
Line 1631: $update_fields = $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 2153: $q = "SELECT pages.id, pages.name, pages.active, widget.settings
Line 2157: LEFT JOIN ~page_widgets AS widget ON rev.id = widget.page_revision_id
Line 2158: AND widget.area_id = 1 AND widget.active = 1 AND widget.type = 'RichText'
Line 2159: ORDER BY widget.record_order";
Line 2749: 'page_widgets' => 0,
Line 2771: * Return JSON list of custom widget templates as defined by skin config
Line 2777: public function ajaxListWidgetTemplates()
Line 2779: $templates = Kohana::config('sprout.widget_templates');

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

Line 20: use Sprout\Helpers\RefineWidgetTextbox;
Line 63: $this->refine_bar->addWidget(new RefineWidgetTextbox('path_exact', 'Path exact match'));
Line 64: $this->refine_bar->addWidget(new RefineWidgetTextbox('path_contains', 'Path contains'));

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

Line 25: use Sprout\Helpers\RefineWidgetSelect;
Line 26: use Sprout\Helpers\RefineWidgetTextbox;
Line 61: $this->refine_bar->addWidget(new RefineWidgetTextbox('name', 'Name'));
Line 62: $this->refine_bar->addWidget(new RefineWidgetSelect('status', 'Status', Constants::$job_status));

/sprout/Controllers/AdminAjaxController.php   Highlighted file source

Line 40: use Sprout\Helpers\Widgets;
Line 44: * Handles processing of various admin AJAX methods including: widget settings; links; and categories.
Line 63: * Returns the HTML for the settings for an individual widget.
Line 65: * @param string $widget_name The name of the widget to get settings for.
Line 67: public function widgetSettings($widget_name)
Line 82: 'Error loading widget settings; '
Line 87: // Prep the widget
Line 89: $widget = Widgets::instantiate($widget_name);
Line 91: $settings = $widget->getDefaultSettings();
Line 93: $widget->importSettings($settings);
Line 98: $info_labels = $widget->getInfoLabels();
Line 105: Form::setData([$prefix => $widget->getSettings()]);
Line 113: $form = $widget->getSettingsForm();
Line 118: 'edit_url' => $widget->getEditUrl(),
Line 119: 'description' => Enc::html($widget->getFriendlyDesc()),
Line 129: * AJAX-loaded popup content for UI to manage widget display conditions
Line 133: public function widgetDispConds()
Line 141: 'url' => 'admin_ajax/widget_disp_cond_params',
Line 144: $view = new View('sprout/admin/widget_disp_conds');
Line 151: * Callback url for {@see Fb::conditionsList} for the widget display conditions
Line 161: public function widgetDispCondParams()
Line 204: $areas = Kohana::config('sprout.widget_areas');
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/PageController.php   Highlighted file source

Line 48: use Sprout\Helpers\Widgets;
Line 150: $conds_env = $this->widgetCondsEnvironment($page);
Line 151: $this->loadWidgets($conds_env, $page);
Line 277: // Get list of widgets and render their content
Line 278: $conds_env = $this->widgetCondsEnvironment($page);
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 368: * Return the environment which is provided to the widget display conditions logic
Line 371: * @return array Environment which gets passed to {@see Widgets::checkDisplayConditions}
Line 373: private function widgetCondsEnvironment(array $page)
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 394: foreach ($wids as $widget) {
Line 395: $settings = json_decode($widget['settings'], true);
Line 397: $conditions = json_decode($widget['conditions'], true);
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 116: * @param WidgetArea $area The area that is being edited
Line 117: * @param array $curr_widgets A list of the widgets currently being used, in order, as db rows with keys:
Line 122: * heading string HTML H2 rendered front-end within widget
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 127: Needs::fileGroup('widget_list');
Line 129: if ($curr_widgets == null) {
Line 130: $curr_widgets = [];
Line 133: $widget_list_id = 'wl-' . Enc::id($field_name);
Line 137: echo " var list = new widget_list('", Enc::js($field_name), "');\n";
Line 138: foreach ($curr_widgets as $widget) {
Line 139: $inst = Widgets::instantiate($widget['type']);
Line 142: if (!$enable_all) $widget['active'] = 0;
Line 145: 'type' => $widget['type'],
Line 147: 'settings' => $widget['settings'],
Line 148: 'conditions' => $widget['conditions'],
Line 149: 'active' => (bool)$widget['active'],
Line 150: 'heading' => @$widget['heading'],
Line 151: 'template' => @$widget['template'],
Line 154: echo " list.add_widget(", json_encode($add_opts), ");\n";
Line 157: echo " $('#{$widget_list_id}').bind('add-widget', function(e, widget_name, english_name) {\n";
Line 158: echo " list.add_widget({ type: widget_name, label: english_name, settings: '', active: true });\n";
Line 165: echo "<div id=\"{$widget_list_id}\" class=\"widget-list\">\n";
Line 167: echo "<div id=\"{$widget_list_id}\" class=\"widget-list all-collapsed\">\n";
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 172: echo "<input type=\"checkbox\" id=\"{$widget_list_id}--add-btn\" class=\"giant-popup-checkbox -vis-hidden\">";
Line 183: echo "<label for=\"{$widget_list_id}--add-btn\" class=\"button button-green button-regular button-block add-content-block-button\">Add content block";
Line 200: echo "<label for=\"{$widget_list_id}--add-btn\" class=\"giant-popup-close-button icon-before icon-close\">Close</label>";
Line 204: $tiles = Register::getWidgetTiles($area->getName());
Line 236: foreach ($tile['widgets'] as $widg => $name) {
Line 238: $inst = Widgets::instantiate($widg);
Line 241: echo '<li><a class="widget-list-new-widget" href="javascript:;" data-name="', Enc::html($widg), '" title="' . Enc::html($desc) . '">', Enc::html($name), '</a></li>';

/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 90: * @param array $settings Format to match $_POST['widget_settings']
Line 93: public static function preloadWidgets(array $widgets, array $settings)
Line 95: foreach ($widgets as $area_name => $widget_list) {
Line 96: foreach ($widget_list as $widget) {
Line 97: list($record_order, $type, $widget_id) = explode(',', $widget);
Line 98: $widget_settings = array();
Line 100: $widget_settings = $settings[$area_name][$record_order];
Line 102: $area_id = WidgetArea::findAreaByName($area_name)->getIndex();
Line 103: Widgets::add($area_id, $type, $widget_settings);
Line 104: self::$preloaded_widgets[] = array(
Line 106: 'settings' => $widget_settings,
Line 107: 'embed_key' => $widget_id
Line 115: * Replace embed code with the actual widgets.
Line 117: * Embed code is in the format ((WIDGET code))
Line 119: * @param string $text The text which contains the widget embed codes
Line 120: * @param string $widget_table The host table of the widgets, e.g. 'page'
Line 121: * @param int $widget_record The record id
Line 124: public static function embedWidgets($text, $widget_table, $widget_record)
Line 126: $widgets = self::$preloaded_widgets;
Line 128: Pdb::validateIdentifier($widget_table);
Line 129: $widget_record = (int) $widget_record;
Line 131: $widget_table = addslashes($widget_table);
Line 133: // Find widget references in text
Line 136: '!<p>(?:\s|&nbsp;|<code>)*\(\(WIDGET [a-zA-Z]*? ?([0-9A-Za-z]+)\)\)(?:\s|&nbsp;|</code>)*</p>!',
Line 143: // Map embed codes => widget refs
Line 149: // Replace preloaded widgets first
Line 151: foreach ($widgets as $widget) {
Line 152: if ($embed_key == $widget['embed_key']) {
Line 153: $text = self::embedWidget($text, $pattern, $widget);
Line 162: $widgets = self::lookupWidgets($widget_table, $widget_record, $embeds);
Line 164: foreach ($widgets as $widget) {
Line 165: if ($embed_key == $widget['embed_key']) {
Line 166: $text = self::embedWidget($text, $pattern, $widget);
Line 177: * @param string $widget_table The host table of the widgets, e.g. 'page'
Line 178: * @param int $widget_record The record id
Line 180: * @return array Keys are the widget reference codes, values are arrays
Line 184: public static function lookupWidgets($widget_table, $widget_record, array $embed_keys)
Line 186: Pdb::validateIdentifier($widget_table);
Line 187: $widget_record = (int) $widget_record;
Line 190: $conditions = ["{$widget_table}_id" => $widget_record];
Line 196: FROM ~{$widget_table}_widgets
Line 200: $widgets = array();
Line 203: $widgets[$row['embed_key']] = $row;
Line 205: return $widgets;
Line 209: * Embeds a widget into some text
Line 210: * @param string $text The text containing the widget embed
Line 211: * @param string $pattern The widget embed to replace
Line 212: * @param array $widget as per {@link lookupWidgets()}, has keys and values
Line 215: * @return string The text with the rendered widget
Line 217: public static function embedWidget($text, $pattern, array $widget)
Line 219: $rendered = Widgets::render(
Line 220: WidgetArea::ORIENTATION_WIDE,
Line 221: $widget['type'],
Line 222: $widget['settings']
Line 229: * Remove widget embed code from the specified HTML
Line 230: * Embed code is in the format ((WIDGET code))
Line 232: public static function removeWidgets($text)
Line 235: '!<p>(?:\s|&nbsp;|<code>)*\(\(WIDGET [a-zA-Z]*? ?([0-9A-Za-z]+)\)\)(?:\s|&nbsp;|</code>)*</p>!',
Line 243: * Replace embed code with the actual widget. This is a tweaked version of embedWidgets, designed for email
Line 245: * Embed code is in the format ((WIDGET code))
Line 247: * @param string $widget_table The host table of the widgets, e.g. 'page'
Line 248: * @param string $widget_record The record id
Line 250: public static function emailWidgets($text, $widget_table, $widget_record, $pre_html, $post_html)
Line 252: Pdb::validateIdentifier($widget_table);
Line 253: $widget_record = (int) $widget_record;
Line 255: self::$temp = array($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 262: list($widget_table, $widget_record, $pre_html, $post_html) = self::$temp;
Line 263: $widget_record = (int) $widget_record;
Line 266: FROM ~{$widget_table}_widgets
Line 267: WHERE {$widget_table}_id = ? AND embed_key = ?
Line 270: $widget = Pdb::query($q, [$widget_record, $matches[1]], 'row');
Line 275: return Widgets::render(
Line 276: WidgetArea::ORIENTATION_EMAIL,
Line 277: $widget['type'],
Line 278: json_decode($widget['settings'], true),

/sprout/Helpers/ImportCMS.php   Highlighted file source

Line 12: use Sprout\Helpers\WidgetArea;
Line 53: // Create pages and content widgets
Line 67: 'widgets' => @self::$old_widets[$old_id],
Line 129: // Widget area
Line 130: $area = WidgetArea::findAreaByName('embedded');
Line 132: // RichText widget
Line 141: Pdb::insert('page_widgets', $fields);
Line 162: $conditions[] = ['widget.page_revision_id', 'IN', self::$revision_ids];
Line 166: widget.id,
Line 167: widget.page_revision_id,
Line 168: widget.settings
Line 170: ~page_widgets AS widget
Line 174: $widgets = Pdb::query($q, $params, 'arr');
Line 176: foreach ($widgets as $widget) {
Line 177: $settings = json_decode($widget['settings']);
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)
Line 215: '/\(\(WIDGET [a-zA-Z]*? ?([0-9A-Za-z]+)\)\)/',

/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 236: $inst->importSettings(json_decode($widget['settings'], true));
Line 237: $inst->setTitle($widget['heading']);
Line 238: $widget_text = $inst->render(WidgetArea::ORIENTATION_WIDE);
Line 239: if (!$widget_text) continue;
Line 244: $text .= $widget_text;
Line 292: * Find pages with a given widget, and optionally the specified settings.
Line 293: * Only widgets on live revisions of active pages are checked.
Line 294: * @param string $class The class of the desired widget.
Line 299: public static function pagesWithWidget($widget_name, array $settings = [])
Line 301: $q = "SELECT page.id, widget.settings
Line 302: FROM ~page_widgets AS widget
Line 303: INNER JOIN ~page_revisions AS rev ON widget.page_revision_id = rev.id AND rev.status = 'live'
Line 305: WHERE widget.type = ?";
Line 307: return Pdb::query($q, [$widget_name], 'col');
Line 310: $res = Pdb::query($q, [$widget_name], 'pdo');
Line 313: $widget_settings = json_decode($row['settings'], true);
Line 314: $diff = array_diff_assoc($settings, $widget_settings);

/sprout/Helpers/RefineBar.php   Highlighted file source

Line 22: private $widgets = array();
Line 31: * Add a refine widget
Line 33: * @param RefineWidget $widget Refinement widget to add
Line 39: public function addWidget(RefineWidget $widget, $operator = null)
Line 41: $this->widgets[] = $widget;
Line 42: $this->groups[$this->curr_group][] = $widget;
Line 44: $this->field_ops[$widget->getName()] = $operator;
Line 63: foreach ($this->widgets as $widget) {
Line 64: unset ($get_fields[$widget->getName()]);
Line 79: foreach ($this->widgets as $widget) {
Line 80: $html = $widget->render();
Line 81: $label = Enc::html($widget->getLabel());
Line 121: * Returns true if any of the refine bar widgets refer to the specified field
Line 125: foreach ($this->widgets as $w) {
Line 147: * Return a list of search widgets, in groups

/sprout/Helpers/RefineWidget.php   Highlighted file source

Line 18: * Base class for widgets included in a {@see RefineBar}
Line 20: abstract class RefineWidget {
Line 50: * Returns the current value for this refine widget
Line 57: * Draws the widget.
Line 58: * @return string The HTML for the widget.

/sprout/Helpers/RefineWidgetAutocomplete.php   Highlighted file source

Line 17: * An autocomplete widget for the refine bar
Line 19: class RefineWidgetAutocomplete extends RefineWidget
Line 38: * Draws the widget.
Line 39: * @return string The HTML for the widget.

/sprout/Helpers/RefineWidgetDatepicker.php   Highlighted file source

Line 17: * A datepicker widget for the refine bar
Line 19: class RefineWidgetDatepicker extends RefineWidget
Line 38: * Draws the widget.
Line 39: * @return string The HTML for the widget.

/sprout/Helpers/RefineWidgetSelect.php   Highlighted file source

Line 17: * A textbox widget
Line 19: class RefineWidgetSelect extends RefineWidget
Line 30: * Draws the widget.
Line 31: * @return string The HTML for the widget.

/sprout/Helpers/RefineWidgetTextbox.php   Highlighted file source

Line 17: * A textbox widget
Line 19: class RefineWidgetTextbox extends RefineWidget
Line 23: * Draws the widget.
Line 24: * @return string The HTML for the widget.

/sprout/Helpers/Register.php   Highlighted file source

Line 24: * incl. widgets, search handlers, tabs, etc.
Line 40: private static $widget_tiles = [];
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 408: $area = WidgetArea::findAreaByName($area_name);
Line 411: if (!isset(self::$widget_tiles[$area_name])) {
Line 412: self::$widget_tiles[$area_name] = [];
Line 415: if (isset(self::$widget_tiles[$area_name][$name])) {
Line 416: self::$widget_tiles[$area_name][$name]['widgets'] = array_merge(
Line 417: self::$widget_tiles[$area_name][$name]['widgets'],
Line 418: $widgets
Line 421: self::$widget_tiles[$area_name][$name] = [
Line 425: 'widgets' => $widgets,
Line 429: foreach ($widgets as $name => $label) {
Line 430: $area->addWidget($name);
Line 436: * Return an array of widget tiles for a given widget area
Line 437: * Each tile has four keys, 'name', 'icon', 'text', and 'widgets'.
Line 441: public static function getWidgetTiles($area_name)
Line 443: if (!isset(self::$widget_tiles[$area_name])) {
Line 444: self::$widget_tiles[$area_name] = [];
Line 447: return self::$widget_tiles[$area_name];
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/TreenodeHasWidgetMatcher.php   Highlighted file source

Line 23: class TreenodeHasWidgetMatcher implements TreenodeMatcher
Line 31: * @param string $type The type of widget to search
Line 37: INNER JOIN ~page_widgets AS widget ON widget.page_revision_id = rev.id AND widget.active = 1
Line 38: WHERE widget.type = ?

/sprout/Helpers/WidgetArea.php   Highlighted file source

Line 19: * Stores information about an individual widget area, including the names of all widgets
Line 22: class WidgetArea
Line 27: private $widgets;
Line 49: * @param string $name The name of the widget area
Line 50: * @param int $index The numerical index of the widget area in the config file
Line 57: $this->widgets = array();
Line 62: * Returns the name of this widget area
Line 70: * Returns the nice name of this widget area
Line 79: * Sets the nice name of this widget area
Line 81: * @param string $name The nice name of the widget
Line 89: * Sets the orientation of the widget area
Line 99: * If true, the widget area is an 'embedding' area.
Line 107: * If the widget area is an embedding area
Line 115: * Gets the orientation of the widget area
Line 123: * Returns the index of this widget area
Line 131: * Adds a widget to the list of widgets allowed for this area
Line 133: * @param string $widget_name The name of the widget to add
Line 135: public function addWidget($widget_name)
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 154: * @param string $widget_name The name of the widget to add
Line 156: public function addDefault($widget_name, $settings)
Line 158: Widgets::add($this->index, $widget_name, $settings);
Line 163: * Returns the widget area which has the specified name.
Line 164: * Uses the widget areas defined in the sprout config.
Line 166: * @param string $name The name of the widget area to use.
Line 170: $areas = Kohana::config('sprout.widget_areas');

/sprout/Helpers/Widgets.php   Highlighted file source

Line 23: * Provided functions for the display of widgets
Line 25: class Widgets
Line 27: private static $widget_areas = array();
Line 30: * Add a widget to the list of widgets for a specific area
Line 32: * @param int $area_id The widget area to add the widget to
Line 33: * @param string $name The name of the widget to add
Line 34: * @param array $settings The widget settings to use
Line 35: * @param string $heading HTML H2 rendered front-end within widget
Line 41: $area = WidgetArea::findAreaByName($area_id);
Line 46: self::$widget_areas[$area_id][] = array($name, $settings, $heading, $template);
Line 50: * Remove a widget to the list of widgets for a specific area
Line 52: * @param int $area_id The widget area to add the widget to
Line 53: * @param string $name The name of the widget to remove
Line 58: $area = WidgetArea::findAreaByName($area_id);
Line 63: foreach (self::$widget_areas[$area_id] as $idx => $def) {
Line 64: if ($def[0] === $name) unset (self::$widget_areas[$area_id][$idx]);
Line 69: * Create an instance of a specific widget in memory
Line 71: * @param string $name The name of the widget to instantiate.
Line 72: * @return Widget The instance
Line 77: if (substr($class, -6) != 'Widget') $class .= 'Widget';
Line 79: $class = 'Sprout\\Widgets\\' . $class;
Line 82: throw new Exception("Unknown widget {$name}");
Line 90: * @param int $orientation See ORIENTATION_* constants in {@see WidgetArea}
Line 91: * @param string $name Class name of the widget
Line 92: * @param array $settings Widget settings (keys and values vary with widget subclass)
Line 93: * @param string $pre_html HTML to go before the rendered widget
Line 94: * @param string $post_html HTML to go after the rendered widget
Line 95: * @param string $heading String Optional HTML H2 rendered on front-end of given widget
Line 97: * @return string Front-end HTML of widget
Line 109: if ($orientation != WidgetArea::ORIENTATION_EMAIL and AdminAuth::isLoggedIn()) {
Line 114: $class = 'widget widget-' . Enc::id(str_replace('\\', '-', (isset($inst->classname) ? $inst->classname : $name)));
Line 115: if (!empty($infobox)) $class .= ' widget-hasinfobox';
Line 116: $class .= ' orientation-' . WidgetArea::$orientation_classes[$orientation];
Line 128: $heading_html = '<h2 class="widget-title">TITLE</h2>';
Line 130: if (!empty(Kohana::config('sprout.widget_title'))) {
Line 131: $heading_html = Kohana::config('sprout.widget_title');
Line 145: // Wrap widget HTML within template snippet
Line 148: $ret = str_replace('{{widget}}', $ret, $view->render());
Line 155: * Render extra widget info for admins
Line 159: $ret = '<div class="widget-infobox">';
Line 181: * Draw the widgets for a specific area
Line 183: * The available widget areas are defined in the {@link /config/sprout.php} file.
Line 186: * @param string $area_name The name of the widget area to draw.
Line 187: * @return string HTML representing the rendered widgets
Line 191: $area = WidgetArea::findAreaByName($area_name);
Line 197: if (empty(self::$widget_areas[$area_id])) {
Line 202: foreach (self::$widget_areas[$area_id] as $widget_details) {
Line 203: list($name, $settings, $heading, $template) = $widget_details;
Line 212: * Render a widget area, and output directly
Line 214: * @deprecated Use {@see Widgets::renderArea} instead
Line 223: * Does the specified widget area have widgets?
Line 225: * @param string $area_name The name of the widget area to query.
Line 230: public static function hasWidgets($area_name)
Line 232: $area = WidgetArea::findAreaByName($area_name);
Line 236: if (!empty(self::$widget_areas[$area_id])) return true;
Line 243: * Check whether the widget is allowed to be displayed

/sprout/Models/PageWidgetModel.php   Highlighted file source

Line 7: class PageWidgetModel extends Model
Line 42: return 'page_widgets';

/sprout/sprout_load.php   Highlighted file source

Line 17: use Sprout\Helpers\WidgetArea;
Line 53: Register::contentReplace('main_content', ['Sprout\\Widgets\\ImageGalleryWidget', 'contentReplace']);
Line 75: Register::widgetTile(
Line 86: Register::widgetTile(
Line 101: Register::widgetTile(
Line 112: Register::widgetTile(
Line 122: Register::widgetTile(
Line 128: 'RssFeedWidget' => 'RSS Feed',
Line 132: Register::widgetTile(
Line 143: Register::widgetTile(
Line 155: $area = WidgetArea::findAreaByName('email');
Line 157: $area->addWidget('HtmlCode');

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

Line 30: use Sprout\Helpers\WidgetArea;
Line 345: $areas = Kohana::config('sprout.widget_areas');
Line 348: Admin::widgetList($area->getName(), $area, @$widgets[$area_id], empty($page['redirect']));
Line 357: <!-- Widgets-->
Line 358: <div class="sidebar-widgets">
Line 360: $areas = Kohana::config('sprout.widget_areas');
Line 363: if ($area->getOrientation() == WidgetArea::ORIENTATION_EMAIL) continue;
Line 382: Admin::widgetList($area->getName(), $area, @$widgets[$area_id], empty($page['redirect']));

/sprout/views/map_widget.php   Highlighted file source

Line 12: initMapWidget(map_<?php echo Enc::js($unique); ?>,

/sprout/views/tinymce4/image_gallery.php   Highlighted file source

Line 253: // Use form values as data-attributes for Widget's settings
Line 254: var content = '<div class="sprout-editor--widget sprout-editor--gallery" data-id="' + cat + '"';

/sprout/Widgets/AdvancedSearchFormWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 23: class AdvancedSearchFormWidget extends Widget
Line 30: * Return the front-end view of this widget
Line 32: * @param int $orientation The orientation of the widget.

/sprout/Widgets/AudioWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 23: * Basically just a test widget
Line 25: class AudioWidget extends Widget
Line 32: * Return the front-end view of this widget
Line 34: * @param int $orientation The orientation of the widget.
Line 49: * Return the settings form for this widget

/sprout/Widgets/ChildrenGalleryWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 27: class ChildrenGalleryWidget extends Widget
Line 34: * Does the front-end rendering of this widget
Line 36: * @param int $orientation The orientation of the widget
Line 106: * Returns the settings for the article list widget
Line 107: * See {@link Widget::getSettingsForm} for full documentation

/sprout/Widgets/ChildrenPagesWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 23: class ChildrenPagesWidget extends Widget
Line 30: * Does the front-end rendering of this widget
Line 32: * @param int $orientation The orientation of the widget

/sprout/Widgets/FileListWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 20: use Sprout\Helpers\WidgetArea;
Line 24: * doc list widget
Line 26: class FileListWidget extends Widget
Line 34: * Returns the output of the doc list widget
Line 35: * See {@link Widget::render} for full documentation
Line 37: * @param int $orientation The orientation of the widget.
Line 53: if ($orientation == WidgetArea::ORIENTATION_TALL) {
Line 55: } else if ($orientation == WidgetArea::ORIENTATION_WIDE) {
Line 65: * Returns the settings for the doc list widget
Line 66: * See {@link Widget::getSettingsForm} for full documentation
Line 91: * Returns a URL for editing the contents of this widget
Line 92: * See {@link Widget::getEditUrl} for full documentation
Line 103: * Returns a label which describes the contents of this widget
Line 104: * See {@link Widget::get_info_label} for full documentation

/sprout/Widgets/HelloWorldWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 18: use Sprout\Helpers\WidgetArea;
Line 22: * Basically just a test widget
Line 24: class HelloWorldWidget extends Widget
Line 27: protected $friendly_desc = "This is a test widget";
Line 31: * Return the front-end view of this widget
Line 33: * @param int $orientation The orientation of the widget.
Line 39: if ($orientation == WidgetArea::ORIENTATION_TALL) {
Line 42: } else if ($orientation == WidgetArea::ORIENTATION_WIDE) {
Line 51: * Return the settings form for this widget

/sprout/Widgets/HtmlCodeWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 22: class HtmlCodeWidget extends Widget
Line 29: * Return the front-end view of this widget
Line 31: * @param int $orientation The orientation of the widget.
Line 40: * Return the settings form for this widget

/sprout/Widgets/ImageGalleryWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 21: use Sprout\Helpers\WidgetArea;
Line 22: use Sprout\Helpers\Widgets;
Line 28: class ImageGalleryWidget extends Widget
Line 62: // Whether this widget displays as grid or slider
Line 114: * Does the front-end rendering of this widget
Line 116: * @param int $orientation The orientation of the widget
Line 163: if ($orientation == WidgetArea::ORIENTATION_TALL) {
Line 219: $view = new View('sprout/gallery_widget_settings');
Line 266: * Returns a URL for editing the contents of this widget
Line 267: * See {@link Widget::getEditUrl} for full documentation
Line 277: * Returns a label which describes the contents of this widget
Line 278: * See {@link Widget::get_info_label} for full documentation
Line 293: * If this widget is not available, a string message should be returned
Line 294: * If this widget *is* available, NULL should be returned.
Line 314: $pattern = '<div class="sprout-editor--widget sprout-editor--gallery"';
Line 333: $widget = Widgets::render(WidgetArea::ORIENTATION_EMAIL, 'Sprout\Widgets\ImageGalleryWidget', [
Line 347: $html = preg_replace('/<div class="sprout-editor--widget sprout-editor--gallery" (.*?)<\/div>/s', $widget, $html, 1);

/sprout/Widgets/MapDirectionsWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 23: class MapDirectionsWidget extends Widget
Line 30: * Return the front-end view of this widget
Line 32: * @param int $orientation The orientation of the widget.
Line 56: * Return the settings form for this widget
Line 70: * Returns a label which describes the contents of this widget
Line 71: * See {@link Widget::get_info_label} for full documentation

/sprout/Widgets/MapWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 27: class MapWidget extends Widget
Line 54: * Return the front-end view of this widget
Line 56: * @param int $orientation The orientation of the widget.
Line 74: Needs::fileGroup('sprout/map_widget');
Line 76: $view = new View('sprout/map_widget');
Line 89: * Return the settings form for this widget
Line 117: * Returns a label which describes the contents of this widget
Line 118: * See {@link Widget::get_info_label} for full documentation

/sprout/Widgets/RelatedLinksWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 28: class RelatedLinksWidget extends Widget
Line 34: * Does the front-end rendering of this widget
Line 36: * @param int $orientation The orientation of the widget

/sprout/Widgets/RichTextWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 25: class RichTextWidget extends Widget
Line 32: * Return the front-end view of this widget
Line 34: * @param int $orientation The orientation of the widget; see e.g. {@see WidgetArea::ORIENTATION_WIDE}
Line 44: * Return the settings form for this widget

/sprout/Widgets/RssFeedWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 27: class RssFeedWidget extends Widget
Line 34: * Return the front-end view of this widget
Line 36: * @param int $orientation The orientation of the widget.
Line 60: * Return the settings form for this widget

/sprout/Widgets/SitemapWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 24: class SitemapWidget extends Widget
Line 31: * Does the front-end rendering of this widget
Line 33: * @param int $orientation The orientation of the widget

/sprout/Widgets/VideoPlaylistWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 29: class VideoPlaylistWidget extends Widget
Line 37: * Renders the front-end view of this widget
Line 39: * @param int $orientation The orientation of the widget.
Line 63: * Renders the admin settings form for this widget

/sprout/Widgets/VideoWidget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 21: * Basically just a test widget
Line 23: class VideoWidget extends Widget
Line 46: * Return the front-end view of this widget
Line 48: * @param int $orientation The orientation of the widget.
Line 66: * Return the settings form for this widget

/sprout/Widgets/Widget.php   Highlighted file source

Line 14: namespace Sprout\Widgets;
Line 19: * Base class for widgets
Line 21: abstract class Widget {
Line 32: protected $friendly_name = 'Widget';
Line 42: * Array of default settings for new widgets
Line 56: * @param array $settings The widget settings
Line 71: * Return the currently loaded settings for the widget
Line 73: * @return array The widget settings
Line 82: * Gets the english name of this widget
Line 90: * Gets the english name of this widget
Line 99: * Set widget title
Line 101: * @param string $str Widget title (heading)
Line 111: * Returns the title to use for the widget - should not contain HTML
Line 122: * Returns the default settings for the widget
Line 131: * Run after import of settings, allows extending widgets to clean up settings which may
Line 142: * This function should return the content of the widget that is used on the front-end of the website.
Line 145: * which has the class 'widget', and the class 'widget-[WIDGETNAME]' applied to it.
Line 149: * @param int $orientation The orientation of the widget.
Line 150: * Will be one of the constants defined in the {@see WidgetArea} class.
Line 157: * @tag widget-api
Line 163: * This function should return the content of the widget settings form.
Line 183: * displayed by this widget.
Line 185: * Most widgets show content using a category selection box; the URL should in that
Line 197: * This function should return a summary of what this widget's *content* is.
Line 198: * Don't specify the widget name; we already know that!
Line 200: * Most widgets show content using a category selection box; in that case
Line 214: * If this widget is not available, a string message should be returned
Line 215: * If this widget *is* available, NULL should be returned.

A total of 671 lines in 57 files were found