Admin_ObjectController::previewAction PHP Метод

previewAction() публичный Метод

public previewAction ( )
    public function previewAction()
    {
        $id = $this->getParam("id");
        $key = "object_" . $id;
        $session = Tool\Session::getReadOnly("pimcore_objects");
        if ($session->{$key}) {
            $object = $session->{$key};
        } else {
            die("Preview not available, it seems that there's a problem with this object.");
        }
        $url = $object->getClass()->getPreviewUrl();
        // replace named variables
        $vars = get_object_vars($object);
        foreach ($vars as $key => $value) {
            if (!empty($value) && (is_string($value) || is_numeric($value))) {
                $url = str_replace("%" . $key, urlencode($value), $url);
            } else {
                if (strpos($url, "%" . $key) !== false) {
                    die("No preview available, please ensure that all fields which are required for the preview are filled correctly.");
                }
            }
        }
        // replace all remainaing % signs
        $url = str_replace("%", "%25", $url);
        $urlParts = parse_url($url);
        $this->redirect($urlParts["path"] . "?pimcore_object_preview=" . $id . "&_dc=" . time() . "&" . $urlParts["query"]);
    }