protected function getData()
 {
     switch ($this->preset) {
         case 'pages':
             $data = self::getNodeTree();
             if (empty($data)) {
                 $url = 'admin/create/' . $this->type;
                 if ($parent_id = $this->getParentId()) {
                     $url .= '/' . $parent_id;
                 }
                 $url .= '?destination=CURRENT';
                 $r = new Redirect($url);
                 $r->send();
             }
             return $data;
         default:
             mcms::debug($this->ctx->get('preset'), $this->ctx);
     }
 }
 public static function OpenIDVerify($openid)
 {
     self::includeOpenID();
     $consumer = self::getConsumer();
     // Begin the OpenID authentication process.
     // No auth request means we can't begin OpenID.
     if (!($auth_request = $consumer->begin($openid))) {
         throw new RuntimeException(t('Не удалось соединиться с провайдером OpenID, ' . 'попробуйте повторить попытку позже.'));
         $r = new Redirect('auth/logout.rpc');
         $r->send();
     }
     $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
     if ($sreg_request) {
         $auth_request->addExtension($sreg_request);
     }
     $policy_uris = empty($_GET['policies']) ? null : $_GET['policies'];
     $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
     if ($pape_request) {
         $auth_request->addExtension($pape_request);
     }
     // Redirect the user to the OpenID server for authentication.
     // Store the token for this authentication so we can verify the
     // response.
     // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
     // form to send a POST request to the server.
     if ($auth_request->shouldSendRedirect()) {
         $redirect_url = $auth_request->redirectURL(self::getTrustRoot(), self::getReturnTo($openid));
         if (Auth_OpenID::isFailure($redirect_url)) {
             // If the redirect URL can't be built, display an error message.
             Logger::log("Could not redirect to server: " . $redirect_url->message);
         } else {
             // Send redirect.
             $r = new Redirect($redirect_url);
             $r->send();
         }
     } else {
         // Generate form markup and render it.
         $form_id = 'openid_message';
         $form_html = $auth_request->formMarkup(self::getTrustRoot(), self::getReturnTo($openid), false, array('id' => $form_id));
         // Display an error if the form markup couldn't be generated;
         // otherwise, render the HTML.
         if (Auth_OpenID::isFailure($form_html)) {
             Logger::log("Could not redirect to server: " . $form_html->message);
         } else {
             $page_contents = array("<html><head><title>", "OpenID transaction in progress", "</title></head>", "<body onload='document.getElementById(\"" . $form_id . "\").submit()'>", $form_html, "</body></html>");
             print implode("\n", $page_contents);
         }
     }
 }
Example #3
0
 /**
  * Перенаправление в контексте CMS.
  *
  * Позволяет перенаправлять используя относительные урлы (относительно папки,
  * в которой установлена CMS).
  *
  * @param mixed $url текст ссылки, массив или объект url.
  * @return void
  */
 public function redirect($url, $status = 301, Node $node = null)
 {
     $url1 = new url($url);
     if (empty($_GET['__cleanurls'])) {
         if (isset($url1->path)) {
             $url1->setarg('q', $url1->path);
             $url1->path = null;
         }
     } elseif (!isset($url1->path)) {
         $url1->path = $url1->arg('q');
         $url1->setarg('q', null);
     }
     $next = $url1->getAbsolute($this);
     if (null !== $node and $node->id) {
         if (!$node->published) {
             $mode = 'pending';
         } elseif ($node->isNew()) {
             $mode = 'created';
         } else {
             $mode = 'updated';
         }
         $url = new url($next);
         $url->setarg('pending', null);
         $url->setarg('created', null);
         $url->setarg('updated', null);
         if ('%ID' == $url->arg('id')) {
             $url->setarg('id', $node->id);
         } else {
             $url->setarg($mode, $node->id);
             $url->setarg('type', $node->class);
         }
         $next = $url->string();
     }
     $r = new Redirect($next, $status);
     $r->send();
 }