/** * Render a template html. * * @param string $template path of the template * @param array $params parameters to pass to the template (using extract function) * @param boolean $echo if true echo the content else return it * * @return string|void if echo */ public function render($template, $params = array(), $echo = false) { if (!is_file($template)) { throw new \InvalidArgumentException('The $template parameter must be a valid file path.'); } /* * Template system to add in wordpress * $path = locate_template('facebook-awd/'.$template, false, false); if(empty($path)) $path = dirname(__FILE__) . '/inc/templates/'.$template; */ $ptd = null; extract($params); if (!$ptd) { $ptd = $this->container->getPtd(); } ob_start(); include $template; $content = ob_get_contents(); ob_end_clean(); if ($echo) { echo $content; } return $content; }
/** * Get the parent identifier * * @return string */ public function getParent() { if (!$this->container) { return null; } return $this->container->getSlug(); }
/** * Determine the current provider that match the current request. * * @return FacebookRedirectLoginHelper */ protected function determineCurrentProvider() { $providers = $this->container->get($this->container->getSlug() . '.providers'); foreach ($providers as $provider) { if ($provider instanceof FacebookSignedRequestFromInputHelper) { /* if ($origin == 'https://apps.facebook.com' && $provider instanceof FacebookCanvasLoginHelper) { } if ($origin == 'https://apps.facebook.com' && $provider instanceof FacebookCanvasLoginHelper) { } */ //choose between canvas and page tab. //if this provider is a pagetab helper, without page data, pass it to the canvas. if ($provider instanceof FacebookPageTabHelper && !$provider->getPageId()) { continue; } $rs = $provider->getRawSignedRequest(); if ($rs) { return $provider; } } //this provider should always be default as last in the array if ($provider instanceof FacebookRedirectLoginHelper) { return $provider; } } }