Add thickbox parameter to filter links (All, Publish, Trash etc.)
@param array $views Default links
183953
public function addFilterUrlParams($views)
    {
        foreach ($views as $index => $view) {
            $views[$index] = preg_replace("/(?<=href=(\"|'))[^\"']+(?=(\"|'))/", '${0}&is_thickbox=true',  $views[$index]);
        }

        return $views;
    }
1164977
private static function addRoute($view) {
        $uri = RouteController::$currentRoute['uri'];
        $method = RouteController::$currentRoute['method'];
        $module = RouteController::$currentRoute['module'];
        $current_controller = 'modules' . DS . $module . DS . RouteController::$currentRoute['controller'];
        $current_action = RouteController::$currentRoute['action'];
        $args = RouteController::$currentRoute['args'];

        $route = [
            'Route' => $uri,
            'Method' => $method,
            'Module' => $module,
            'Controller' => $current_controller,
            'Action' => $current_action,
            'View' => '',
            'Args' => $args,
        ];

        if ($view) {
            $route['View'] = 'modules/' . RouteController::$currentRoute['module'] . '/Views/' . $view;
        }

        self::$debugbar->addCollector(new MessagesCollector('routes'));
        self::$debugbar['routes']->info($route);
    }
876874
protected function _setViewParams( MW_View_Interface $view, array &$tags = array(), &$expire = null )
	{
		if( !isset( $this->_cache ) )
		{
			$attrMap = array();
			$manager = MShop_Factory::createManager( $this->_getContext(), 'attribute' );

			$search = $manager->createSearch( true );
			$expr = array(
				$search->compare( '==', 'attribute.domain', 'product' ),
				$search->getConditions(),
			);
			$search->setConditions( $search->combine( '&&', $expr ) );

			$sort = array(
				$search->sort( '+', 'attribute.type.code' ),
				$search->sort( '+', 'attribute.position' ),
			);
			$search->setSortations( $sort );
			$search->setSlice( 0, 1000 );

			/** @todo Make referenced domains configurable */
			$attributes = $manager->searchItems( $search, array( 'text', 'media' ) );

			foreach( $attributes as $id => $item ) {
				$attrMap[ $item->getType() ][$id] = $item;
			}

			$this->_addMetaItem( $attributes, 'attribute', $this->_expire, $this->_tags );
			$this->_addMetaList( array_keys( $attributes ), 'attribute', $this->_expire );

			// Delete cache when attributes are added or deleted even in "tag-all" mode
			$this->_tags[] = 'attribute';


			$view->attributeMap = $attrMap;

			$this->_cache = $view;
		}

		$expire = $this->_expires( $this->_expire, $expire );
		$tags = array_merge( $tags, $this->_tags );

		return $this->_cache;
	}
949037
public function render($view, array $data = null)
	{
		// Sanitize variables already in the template.
		foreach (get_object_vars($this) as $key => $value) {
			if (!in_array($key, $this->unguarded)) {
				$this->$key = $this->scrub($value);
			}
		}

		// Also sanitize any variables we are passing in to the template
		$data = $this->scrub($data);

		return parent::render($view, $data);
	}
396197
protected function bulkSend(array $records): void
    {
        try {
            $params = [
                'body' => [],
            ];

            foreach ($records as $record) {
                $params['body'][] = [
                    'index' => [
                        '_index' => $record['_index'],
                        '_type'  => $record['_type'],
                    ],
                ];
                unset($record['_index'], $record['_type']);

                $params['body'][] = $record;
            }

            $responses = $this->client->bulk($params);

            if ($responses['errors'] === true) {
                throw new ElasticsearchRuntimeException('Elasticsearch returned error for one of the records');
            }
        } catch (Throwable $e) {
            if (! $this->options['ignore_error']) {
                throw new RuntimeException('Error sending messages to Elasticsearch', 0, $e);
            }
        }
    }
521505
protected function makeView($view)
    {
        if( Auth::check() ) {
            $this->addParameter( 'activeUser', Auth::user() );
        }

        return View::make( $view, $this->parameters );
    }
1103893
private function addFormElements(array &$form, array $values) {
    $form['filter_controls'] = [
      '#markup' => '
          <div class="container controls-wrapper hidden-sm hidden-md hidden-lg">
          <a href="#" class="btn btn-link transparent-blue add-filters">' . $this->t('Add filters') . '</a>
          <a href="#" class="btn btn-link transparent-blue close-filters hidden">' . $this->t('Close filters') . '</a>
          </div>',
    ];

    $form['selects'] = [
      '#type' => 'container',
      '#attributes' => [
        'class' => [
          'container',
          'selects-container',
          'hidden-xs',
        ],
      ],
    ];

    $form['selects']['location'] = [
      '#type' => 'select',
      '#title' => $this->t('Location'),
      '#options' => $this->getLocationOptions(),
      '#prefix' => '<hr/>',
      '#default_value' => isset($values['location']) ? $values['location'] : 'All',
      '#ajax' => [
        'callback' => [$this, 'rebuildAjaxCallback'],
        'wrapper' => 'schedules-search-form-wrapper',
        'event' => 'change',
        'method' => 'replace',
        'effect' => 'fade',
        'progress' => [
          'type' => 'throbber',
        ],
      ],
    ];

    $form['selects']['program'] = [
      '#type' => 'select',
      '#title' => $this->t('Program'),
      '#options' => $this->getProgramOptions(),
      '#default_value' => isset($values['program']) ? $values['program'] : 'all',
      '#ajax' => [
        'callback' => [$this, 'rebuildAjaxCallback'],
        'wrapper' => 'schedules-search-form-wrapper',
        'event' => 'change',
        'method' => 'replace',
        'effect' => 'fade',
        'progress' => [
          'type' => 'throbber',
        ],
      ],
    ];

    $form['selects']['category'] = [
      '#type' => 'select',
      '#title' => $this->t('Sub-Program'),
      '#options' => $this->getCategoryOptions(),
      '#default_value' => isset($values['category']) ? $values['category'] : 'all',
      '#ajax' => [
        'callback' => [$this, 'rebuildAjaxCallback'],
        'wrapper' => 'schedules-search-form-wrapper',
        'event' => 'change',
        'method' => 'replace',
        'effect' => 'fade',
        'progress' => [
          'type' => 'throbber',
        ],
      ],
    ];

    $form['selects']['class'] = [
      '#type' => 'select',
      '#title' => $this->t('Class'),
      '#options' => $this->getClassOptions(),
      '#default_value' => isset($values['class']) ? $values['class'] : 'all',
      '#ajax' => [
        'callback' => [$this, 'rebuildAjaxCallback'],
        'wrapper' => 'schedules-search-form-wrapper',
        'event' => 'change',
        'method' => 'replace',
        'effect' => 'fade',
        'progress' => [
          'type' => 'throbber',
        ],
      ],
    ];

    $form['selects']['date'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Date'),
      '#default_value' => isset($values['date']) ? $values['date'] : '',
      '#attributes' => [
        'class' => ['openy-schedule-datepicker'],
      ],
      '#ajax' => [
        'callback' => [$this, 'rebuildAjaxCallback'],
        'wrapper' => 'schedules-search-form-wrapper',
        'event' => 'change',
        'method' => 'replace',
        'effect' => 'fade',
        'progress' => [
          'type' => 'throbber',
        ],
        // Do not focus current input element after ajax finish.
        'disable-refocus' => TRUE,
      ],
    ];

    $form['selects']['time'] = [
      '#type' => 'select',
      '#title' => $this->t('Start Time:'),
      '#options' => $this->getTimeOptions(),
      '#default_value' => isset($values['time']) ? $values['time'] : 'all',
      '#ajax' => [
        'callback' => [$this, 'rebuildAjaxCallback'],
        'wrapper' => 'schedules-search-form-wrapper',
        'event' => 'change',
        'method' => 'replace',
        'effect' => 'fade',
        'progress' => [
          'type' => 'throbber',
        ],
      ],
    ];

    $form['selects']['display'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Weekly View'),
      '#default_value' => isset($values['display']) ? $values['display'] : 0,
      '#title_display' => 'before',
      '#ajax' => [
        'callback' => [$this, 'rebuildAjaxCallback'],
        'wrapper' => 'schedules-search-form-wrapper',
        'event' => 'change',
        'method' => 'replace',
        'effect' => 'fade',
        'progress' => [
          'type' => 'throbber',
        ],
      ],
    ];

    // If on Weekly View, default and disable time field.
    if (isset($values['display']) && $values['display']) {
      $form['selects']['time']['#disabled'] = TRUE;
      $form['selects']['time']['#default_value'] = 'all';
    }

    $form['selects']['button'] = [
      '#type' => 'button',
      '#prefix' => '<div class="actions-wrapper hidden-xs hidden-sm hidden-md hidden-lg">',
      '#suffix' => '</div>',
      '#attributes' => [
        'class' => [
          'btn',
          'blue',
        ]
      ],
      '#value' => $this->t('Apply filters'),
      '#ajax' => [
        'callback' => [$this, 'rebuildAjaxCallback'],
        'method' => 'replace',
        'event' => 'click',
      ],
    ];

    $form['filters'] = [
      '#type' => 'container',
      '#prefix' => '<div class="filters-main-wrapper hidden-sm"><div class="container filters-container">',
      '#suffix' => '</div></div>',
      '#attributes' => [
        'class' => [
          'container',
          'filters-container',
        ],
      ],
      '#markup' => '',
      '#weight' => 99,
      'filters' => self::buildFilters($values),
    ];

    $form['alerts'] = [
      views_embed_view('header_alerts', 'specific_alerts_block', $values['location']),
    ];
    $form['alerts']['#prefix'] = '<div class="alerts-wrapper cleafix"><div class="container"><div class="row"><div class="col-xs-12">';
    $form['alerts']['#suffix'] = '</div></div></div></div>';
    $form['alerts']['#weight'] = 100;
  }
646113
protected function _initView($view) {
        $baseUrl = \GemsEscort::getInstance()->basepath->getBasePath();

        // Make sure we can use jQuery
        \MUtil_JQuery::enableView($view);

        // Now add the scrollTo plugin so we can scroll to today
        $view->headScript()->appendFile($baseUrl . '/gems/js/jquery.scrollTo.min.js');

        /*
         * And add some initialization:
         *  - Hide all tokens initially (accessability, when no javascript they should be visible)
         *  - If there is a day labeled today, scroll to it (prevents errors when not visible)
         */
        $view->headScript()->appendFile($baseUrl . '/gems/js/trafficlight.js');
    }
1334448
public function render($view, $params = array()) {
        $viewPath = $this->viewPath;
        $viewPath = rtrim($viewPath, '/').'/';
        extract($params);
        if (is_file($view)) {
            require_once($view);
        } else if (is_file($viewPath.str_replace(':', '/', $view))) {
            require_once($viewPath.str_replace(':', '/', $view));
        } else {
            echo $view;
        }
    }
814514
public function thickbox() {
		?>

		<script type="text/javascript">

			jQuery(document).ready(function ($) {

				$(document).on('click', '#ibd-wp-notifications-template-tags-<?php echo self::$count; ?>', function (e) {
					var tag = jQuery("#ibd-wp-notifications-add-tag-value-<?php echo self::$count; ?>").val();
					if (tag.length == 0 || tag == -1) {
						alert("<?php echo esc_js($this->translations['mustSelectItem']); ?>");
						return;
					}
					window.send_to_editor(tag);
					tb_remove();
				});
			});
		</script>

		<div id="ibd-wp-notifications-select-tag-<?php echo self::$count; ?>" style="display: none">
			<div class="wrap">
				<div>
					<p><?php echo $this->translations['selectTemplateTag']; ?></p>

					<label for="ibd-wp-notifications-add-tag-value-<?php echo self::$count; ?>"><?php echo $this->translations['templateTag']; ?></label><br>

					<select id="ibd-wp-notifications-add-tag-value-<?php echo self::$count; ?>">
						<option value="-1"><?php echo $this->translations['selectATag']; ?></option>

						<?php foreach ( $this->manager->get_listeners() as $listener ): ?>
							<option value="<?php echo esc_attr( "{" . $listener->get_tag() . "}" ); ?>">
								<?php echo $listener; ?>
							</option>
						<?php endforeach; ?>
					</select>
				</div>

				<div style="padding: 15px 15px 15px 0">
					<input type="button" class="button-primary" id="ibd-wp-notifications-template-tags-<?php echo self::$count; ?>" value="<?php echo esc_attr( $this->translations['insertTag'] ); ?>" />
					&nbsp;&nbsp;&nbsp;
					<a class="button" style="color:#bbb;" href="#" onclick="tb_remove(); return false;">
						<?php echo $this->translations['cancel']; ?>
					</a>
				</div>
			</div>
		</div>

		<?php
	}
911602
public function load($view, $args = array())
    {
        $view = ltrim($view, '/');

        $segments = explode('/', str_replace('.', '/', $view));

        // Pop file from segments.
        $view = array_pop($segments);

        // Custom directory path.
        $pathOfView = app('path.base').'/'.implode('/', $segments);

        // Add temporary path with a hint type.
        $this->view->addNamespace('custom', $pathOfView);

        return $this->of('custom::'.$view, $args);
    }
1058517
protected function initializeView(ViewInterface $view): void
    {
        $view->assignMultiple([
            'view' => $this->browserState->get('view'),
            'sortBy' => $this->browserState->get('sortBy'),
            'sortDirection' => $this->browserState->get('sortDirection'),
            'filter' => $this->browserState->get('filter'),
            'activeTag' => $this->browserState->get('activeTag'),
            'activeAssetCollection' => $this->browserState->get('activeAssetCollection'),
            'assetSources' => $this->assetSources,
            'variantsTabFeatureEnabled' => $this->settings['features']['variantsTab']['enable']
        ]);
    }
461901
private function fixParams(array $params)
    {
        $qualityOverride = false;

        foreach ($params as $key => $value) {
            if ($key === 'xmethod') {
                $params['method'] = $value;
                unset($params['xmethod']);
            } elseif ($key === 'backgroundcolor' && !preg_match('/^\#[0-9A-Za-z]{6}$/', $value)) {
                $params['backgroundcolor'] = '';
            } elseif ($key === 'compression') {
                if (!$qualityOverride) {
                    $params['quality'] = 0;
                }
                $params['quality'] = $params['quality'] + $value * 10;
                $qualityOverride = true;
                unset($params['compression']);
            } elseif ($key === 'filtertype') {
                if (!$qualityOverride) {
                    $params['quality'] = 0;
                }
                $params['quality'] = $params['quality'] + $value;
                $qualityOverride = true;
                unset($params['filtertype']);
            }
        }

        return $params;
    }
540698
public function compose(View $view)
    {
        $view->with('tagsRatios', $this->prepareRatios(
            $this->cachedTags()->load(['posts'])
        ));
    }
296881
public function setTemplateInheritorsCssToUpdate(View $view)
    {
        if (!($view instanceof Template)) {
            return;
        }
        foreach ($view->getInheritors() as $inheritor) {
            $inheritor->setCssUpToDate(false);
            $this->uow->persist($inheritor);
            $this->setTemplateInheritorsCssToUpdate($inheritor);
        }
    }
1328496
private function renderView($links)
	{
		$defaults = $this->defaults;

		return View::make($this->view, compact('links', 'defaults'))->render();
	}
1093023
private function queryAddFilterByParameter(array $values): string
    {
        $filters = [];
        foreach ($values as $name => $value) {
            if (!\in_array($name, $this->fieldsFilterable, true)) {
                throw new \InvalidArgumentException(\sprintf(
                    'Parameter %s is not available for filtering in repository %s',
                    $name,
                    $this->name
                ));
            }
            $filters[] = $name.':'.\rawurldecode($value);
        }

        return \implode(',', $filters);
    }