Generate a Facebook recommend button (which is a like button,
but with a different action / label)

@param array $params Various Facebook URL parameters
@param bool $useFacebookPageAsUrl
@return string
548553
public function facebookRecommendButton(
        array $params = array(), $useFacebookPageAsUrl = false
    ) {
        $this->_needsFacebookInit = true;
        $params['action'] = 'recommend';
        return $this->facebookLikeButton($params, $useFacebookPageAsUrl);
    }
1190260
public function url(string $name, array $params = []): string
    {
        return $this->core->router->generate($name, $params);
    }
20597
public function runPage($page, $useAjax = true)
    {
        $this->page = $page;

        /*
         * If the page doesn't refer any layout, create the fallback layout.
         * Otherwise load the layout specified in the page.
         */
        if (!$page->layout) {
            $layout = Layout::initFallback($this->theme);
        }
        elseif (($layout = Layout::loadCached($this->theme, $page->layout)) === null) {
            throw new CmsException(Lang::get('cms::lang.layout.not_found_name', ['name'=>$page->layout]));
        }

        $this->layout = $layout;

        /*
         * The 'this' variable is reserved for default variables.
         */
        $this->vars['this'] = [
            'page'        => $this->page,
            'layout'      => $this->layout,
            'theme'       => $this->theme,
            'param'       => $this->router->getParameters(),
            'controller'  => $this,
            'environment' => App::environment(),
            'session'     => App::make('session'),
        ];

        /*
         * Check for the presence of validation errors in the session.
         */
        $this->vars['errors'] = (Config::get('session.driver') && Session::has('errors'))
            ? Session::get('errors')
            : new \Illuminate\Support\ViewErrorBag;

        /*
         * Handle AJAX requests and execute the life cycle functions
         */
        $this->initCustomObjects();

        $this->initComponents();

        /*
         * Give the layout and page an opportunity to participate
         * after components are initialized and before AJAX is handled.
         */
        if ($this->layoutObj) {
            CmsException::mask($this->layout, 300);
            $this->layoutObj->onInit();
            CmsException::unmask();
        }

        CmsException::mask($this->page, 300);
        $this->pageObj->onInit();
        CmsException::unmask();

        /**
         * @event cms.page.init
         * Provides an opportunity to return a custom response from Controller->runPage() before AJAX handlers are executed
         *
         * Example usage:
         *
         *     Event::listen('cms.page.init', function ((\Cms\Classes\Controller) $controller, (\Cms\Classes\Page) $page) {
         *         return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
         *     });
         *
         * Or
         *
         *     $CmsController->bindEvent('page.init', function ((\Cms\Classes\Page) $page) {
         *         return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
         *     });
         *
         */
        if ($event = $this->fireSystemEvent('cms.page.init', [$page])) {
            return $event;
        }

        /*
         * Execute AJAX event
         */
        if ($useAjax && $ajaxResponse = $this->execAjaxHandlers()) {
            return $ajaxResponse;
        }

        /*
         * Execute postback handler
         */
        if (
            $useAjax &&
            ($handler = post('_handler')) &&
            $this->verifyCsrfToken() &&
            ($handlerResponse = $this->runAjaxHandler($handler)) &&
            $handlerResponse !== true
        ) {
            return $handlerResponse;
        }

        /*
         * Execute page lifecycle
         */
        if ($cycleResponse = $this->execPageCycle()) {
            return $cycleResponse;
        }

        /**
         * @event cms.page.beforeRenderPage
         * Fires after AJAX handlers are dealt with and provides an opportunity to modify the page contents
         *
         * Example usage:
         *
         *     Event::listen('cms.page.beforeRenderPage', function ((\Cms\Classes\Controller) $controller, (\Cms\Classes\Page) $page) {
         *         return 'Custom page contents';
         *     });
         *
         * Or
         *
         *     $CmsController->bindEvent('page.beforeRenderPage', function ((\Cms\Classes\Page) $page) {
         *         return 'Custom page contents';
         *     });
         *
         */
        if ($event = $this->fireSystemEvent('cms.page.beforeRenderPage', [$page])) {
            $this->pageContents = $event;
        }
        else {
            /*
             * Render the page
             */
            CmsException::mask($this->page, 400);
            $this->loader->setObject($this->page);
            $template = $this->twig->loadTemplate($this->page->getFilePath());
            $this->pageContents = $template->render($this->vars);
            CmsException::unmask();
        }

        /*
         * Render the layout
         */
        CmsException::mask($this->layout, 400);
        $this->loader->setObject($this->layout);
        $template = $this->twig->loadTemplate($this->layout->getFilePath());
        $result = $template->render($this->vars);
        CmsException::unmask();

        return $result;
    }
406555
protected function addFacebook()
	{
		// Get default Site Name
		$sitename = $this->getConfig('title.sitename');

		// Get value for title tag
		$title = $this->renderTitle();

		// Get value of description
		$description = ($this->description) ? $this->description : $this->getConfig('description');

		// Get Default values in config file
		$admins = $this->getConfig('facebook.admins');
		$page_id = $this->getConfig('facebook.page_id');
		$app_id = $this->getConfig('facebook.app_id');
		$image = $this->getConfig('facebook.image');

		// Check if option is active
		if ($this->getConfig('facebook.active'))
		{
			// Don't override a value set manually
			if (!array_key_exists('fb:page_id', $this->meta['property']))
			{
				$this->addOneMeta('property', 'fb:page_id', $page_id);
			}

			// Don't override a value set manually
			if (!array_key_exists('fb:app_id', $this->meta['property']))
			{
				$this->addOneMeta('property', 'fb:app_id', $app_id);
			}

			// Don't override a value set manually
			if (!array_key_exists('fb:admins', $this->meta['property']))
			{
				$this->addOneMeta('property', 'fb:admins', $admins);
			}

			// Don't override a value set manually + check if file exists
			if (File::isFile(public_path($image)) && !array_key_exists('og:image', $this->meta['property']))
			{
				$this->addOneMeta('property', 'og:image', $image);
			}

			// Don't override a value set manually
			if (!array_key_exists('og:url', $this->meta['property']))
			{
				$this->addOneMeta('property', 'og:url', URL::current());
			}

			// Don't override a value set manually
			if (!array_key_exists('og:type', $this->meta['property']))
			{
				$this->addOneMeta('property', 'og:type', 'website');
			}

			// Don't override a value set manually
			if (!array_key_exists('og:site_name', $this->meta['property']))
			{
				$this->addOneMeta('property', 'og:site_name', $sitename);
			}

			// Don't override a value set manually
			if (!array_key_exists('og:title', $this->meta['property']))
			{
				$this->addOneMeta('property', 'og:title', $title);
			}

			// Don't override a value set manually
			if (!array_key_exists('og:description', $this->meta['property']))
			{
				$this->addOneMeta('property', 'og:description', $description);
			}
		}

		// Option is inactive
		else
		{
			$this->killFacebook();
		}
	}
1290428
static function PageUrl(Page $page, array $params = array(), $fragment = '')
    {
        $siteUrl = $page->GetSite()->GetUrl();
        $pageUrl = $page->GetUrl();
        if ($pageUrl == 'index.html') {
            $url = $siteUrl;
        }
        else {
            $url = Path::Combine($siteUrl, $pageUrl);
        }

        $oblParams = self::GatherParams($url);
        $urlObl = self::AttachObligatoryParams($url, $oblParams, $params);

        $urlAllParams = self::AttachMoreParams($urlObl, $oblParams, $params);
        return $fragment ? $urlAllParams . '#' . $fragment : $urlAllParams;
    }
765379
function hot_favorites( $page = 1, $count = 20 )
	{
		$params = array();
		$params['count'] = $count;
		$params['page'] = $page;
		return $this->oauth->get( 'suggestions/favorites/hot', $params);
	}
400218
private function executeFacebookRequest($method, $endpoint, array $parameters = [], $token = null)
    {
        if (is_callable($this->logCallback)) {
            //used only for debugging:
            call_user_func($this->logCallback, 'Facebook API request', func_get_args());
        }

        if (!$token) {
            $token = $this->appToken;
        }

        switch ($method) {
            case 'GET':
                $response = $this->fb->get($endpoint, $token);
                break;
            case 'POST':
                $response = $this->fb->post($endpoint, $parameters, $token);
                break;
            case 'DELETE':
                $response = $this->fb->delete($endpoint, $parameters, $token);
                break;
            default:
                throw new \Exception("Facebook driver exception, please add support for method: " . $method);
                break;
        }

        if (is_callable($this->logCallback)) {
            call_user_func($this->logCallback, 'Facebook API response', $response->getDecodedBody());
        }

        return $response;
    }
959278
public static function authorizeUrl($params = null)
    {
        if (!$params) {
            $params = array();
        }

        $params['client_id'] = self::_getConnectParam('client_id', $params);
        $params['redirect_uri'] = self::_getConnectParam('redirect_uri', $params);
        if (!array_key_exists('response_type', $params)) {
            $params['response_type'] = 'code';
        }
        $query = Util\Util::urlEncode($params);

        return Sumup::$connectBase . '/authorize?' . $query;
    }
1270021
public function getFacebookLikeButton($parameters = array())
    {
        // default values, you can override the values by setting them
        $parameters = $parameters + array(
            'url' => null,
            'locale' => 'en_US',
            'send' => false,
            'width' => 60,
            'showFaces' => false,
            'layout' => 'box_count',
        );

        return $this->container->get('dacorp.socialBarHelper')->facebookButton($parameters);
    }
1205526
private function renderPage($layoutFile = null, $params = null)
    {
        $this->setNode($this->getObject());

        $application = $this->getApplication();
        // Rendering subcontent
        if (null !== $contentSet = $this->getObject()->getContentSet()) {
            $bbUserToken = $application->getBBUserToken();
            $revisionRepo = $application->getEntityManager()->getRepository('BackBee\ClassContent\Revision');
            if (null !== $bbUserToken && null !== $revision = $revisionRepo->getDraft($contentSet, $bbUserToken)) {
                $contentSet->setDraft($revision);
            }

            $layout = $this->getObject()->getLayout();
            $zones = $layout->getZones();
            $zoneIndex = 0;

            foreach ($contentSet->getData() as $content) {
                if (array_key_exists($zoneIndex, $zones)) {
                    $zone = $zones[$zoneIndex];
                    $isMain = null !== $zone && property_exists($zone, 'mainZone') && true === $zone->mainZone;
                    $this->container()->add($this->render($content, $this->getMode(), array(
                        'class' => 'rootContentSet',
                        'isRoot' => true,
                        'indexZone' => $zoneIndex++,
                        'isMainZone' => $isMain,
                    ), null, $this->_ignoreIfRenderModeNotAvailable));
                }
            }
        }

        // Check for a valid layout file
        $this->templateFile = $layoutFile;
        if (null === $this->templateFile) {
            $this->templateFile = $this->getLayoutFile($this->getCurrentPage()->getLayout());
        }

        if (!$this->isValidTemplateFile($this->templateFile, true)) {
            throw new RendererException(
                sprintf('Unable to read layout %s.', $this->templateFile), RendererException::LAYOUT_ERROR
            );
        }

        $application->info(sprintf('Rendering page `%s`.', $this->getObject()->getNormalizeUri()));

        return $this->renderTemplate(false, true);
    }
930031
public function findPageByParameters($parameters)
    {
        if (!empty($parameters['id']) && !preg_match('/^ref_/', $parameters['id'])) {
            $page = $this->entityManager->getRepository('VictoireCoreBundle:View')->findOneBy([
                'id' => $parameters['id'],
            ]);

            $this->checkPageValidity($page, $parameters);
        } else {
            if (isset($parameters['id']) && isset($parameters['locale'])) {
                //if locale is missing, we add append locale
                if (preg_match('/^ref_[0-9]*$/', $parameters['id'])) {
                    $parameters['id'] .= '_'.$parameters['locale'];
                }
            }
            $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters);
            if ($viewReference === null && !empty($parameters['viewId'])) {
                $parameters['templateId'] = $parameters['viewId'];
                unset($parameters['viewId']);
                $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters);
            }

            if ($viewReference instanceof ViewReference) {
                $page = $this->findPageByReference($viewReference);
            } else {
                throw new ViewReferenceNotFoundException($parameters);
            }
            $page->setReference($viewReference, $viewReference->getLocale());
        }

        return $page;
    }
22587
public function query_db($pagesize, $useinitialsbar = true) {

        $joins = array();
        $params = array();

        // Set up filtering.
        if (!empty($this->filterparams->courseid)) {
            $joins[] = "courseid = :courseid";
            $params['courseid'] = $this->filterparams->courseid;
        }

        if (!empty($this->filterparams->date)) {
            $joins[] = "timecreated > :date";
            $params['date'] = $this->filterparams->date;
        }

        if (isset($this->filterparams->anonymous)) {
            $joins[] = "anonymous = :anon";
            $params['anon'] = $this->filterparams->anonymous;
        }

        $selector = implode(' AND ', $joins);

        $total = $this->filterparams->logreader->get_events_select_count($selector, $params);
        $this->pagesize($pagesize, $total);
        $this->rawdata = $this->filterparams->logreader->get_events_select($selector, $params, $this->filterparams->orderby,
                $this->get_page_start(), $this->get_page_size());

        // Set initial bars.
        if ($useinitialsbar) {
            $this->initialbars($total > $pagesize);
        }

        // Update list of users and courses list which will be displayed on log page.
        $this->update_users_and_courses_used();
    }
477656
private function PageRule(Page $page, array $params)
    {
        $lhs = $page->GetUrl();
        foreach ($params as $param)
        {
            $lhs = str_replace('{' . $param . '}', self::PARAM_PATTERN, $lhs);
        }
        
        $rhs = 'index.php';
        $idx = 1;
        
        foreach ($params as $param)
        {
            $rhs .= $idx > 1 ? '&' : '?';
            $rhs .= $param . '=$' . $idx;
            ++$idx;
        }
        $rhs .= '&' . self::PAGE_URL_PARAM . '=' . $page->GetUrl();
        $rule = new RewriteRule($lhs, $rhs);
        $rule->AddFlag(new CommandFlag(FlagType::Qsa()));
        $rule->AddFlag(new CommandFlag(FlagType::L()));
        return $rule;
    }
1165078
public function getPagerUrl($params = [])
    {
        $urlParams = [];
        $urlParams['_current'] = false;
        $urlParams['_escape']  = true;
        $urlParams['_query']   = $params;

        $path = $this->getUrl($this->getPath(), $urlParams);
        if ($this->getEntity()) {
            $path = $this->getEntity()->getUrl($urlParams);
        } elseif ($this->getRequest()->getControllerName() == 'search') {
            $url = ObjectManager::getInstance()->get('Mirasvit\Blog\Model\Url');
            $urlParams['_current'] = true;
            $path = $url->getSearchUrl($urlParams);
        }

        return $path;
    }
1084173
private function get_suggest( $page ) {
		$suggestions = array();

		foreach ( $this->settings as $setting ) {
			$suggestions = array_merge( $suggestions, $setting->get_suggestions( $page ) );
		}

		return $suggestions;
	}
507470
public function getAbsoluteUrl(array $params = array())
	{
		if ( !is_object($this->urlBuilder) ) {
			throw new PageException(
				'The url builder of a page not set, have you used @page-url annotation?',
				PageException::TYPE_MISSING_URL_BUILDER
			);
		}

		return $this->urlBuilder->build($params);
	}
693143
public function getFacebookPages()
    {
        // Returns null if they haven't connected to Facebook
        if ($this->isConnectedToFacebook() !== true) {
            return null;
        }

        $response = Facebook::load()->get('/me/accounts', $this->data('access_token'));
        
        $chunks = [];
        $edges = [];

        // Load data through pagination
        for ($i = 0; $i <= 100; $i++) {
            if ($i === 0) {
                $edges[0] = $response->getGraphEdge();
            } else {
                $edges[$i] = Facebook::load()->next($edges[$i-1]);
            }

            $metaData = $edges[$i]->getMetaData();
            
            $chunks[$i] = $edges[$i]->asArray();

            if ( ! isset($metaData['paging']['next'])) {
                break;
            }
        }

        $pages = [];
        foreach ($chunks as $chunk) {
            foreach ($chunk as $page) {
                $pages[$page['id']] = $page;
            }
        }
        
        // Returns the list of pages.
        return collect($pages);
    }