Beispiel #1
0
 private function _recurseInput(Pagemill_Node $node, Pagemill_Stream $stream, array $elements, array $attributes, Pagemill_Data $data)
 {
     if (is_a($node, 'Pagemill_Tag_Template')) {
         foreach ($node->children() as $c) {
             $this->_recurseInput($c, $stream, $elements, $attributes, $data);
         }
     } else {
         if (is_a($node, 'Pagemill_Tag')) {
             if (in_array('*', $elements) || in_array($node->name(), $elements)) {
                 if (is_a($node, 'Pagemill_Tag_Comment')) {
                     /*$stream->puts('<!--');
                     		foreach ($node->children() as $child) {
                     			$child->rawOutput($stream, false);
                     		}
                     		$stream->puts('-->');*/
                 } else {
                     if (is_a($node, 'Pagemill_Tag_Html_Script')) {
                         $node->process($data, $stream);
                     } else {
                         if ($node->name() == 'img') {
                             $img = new Typeframe_Tag_Timg('img', $node->attributes(), $this);
                             $img->process($data, $stream);
                         } else {
                             $stream->puts('<' . $node->name());
                             foreach ($node->attributes() as $k => $v) {
                                 if (in_array('*', $attributes) || in_array($node->name() . '.*', $attributes) || in_array($node->name() . ".{$k}", $attributes)) {
                                     if ($k == 'src' || $k == 'href') {
                                         $v = $data->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($v));
                                     }
                                     $stream->puts(' ' . $k . '="' . htmlentities($v) . '"');
                                 }
                             }
                             if (count($node->children()) == 0) {
                                 if ($node->collapse) {
                                     $stream->puts('/>');
                                 } else {
                                     $stream->puts('></' . $node->name() . '>');
                                 }
                             } else {
                                 $stream->puts('>');
                                 foreach ($node->children() as $c) {
                                     $this->_recurseInput($c, $stream, $elements, $attributes, $data);
                                 }
                                 $stream->puts('</' . $node->name() . '>');
                             }
                         }
                     }
                 }
             } else {
                 // Tag is not in element whitelist
                 // Recurse through its children and return content without unpermitted tags
                 foreach ($node->children() as $c) {
                     $this->_recurseInput($c, $stream, $elements, $attributes, $data);
                 }
             }
         } else {
             $node->rawOutput($stream);
         }
     }
 }
Beispiel #2
0
 public function output(\Pagemill_Data $data, \Pagemill_Stream $stream)
 {
     $data = $data->fork();
     $url = Typeframe::CurrentPage()->uri();
     if (substr($url, -1) == '/') {
         $url = substr($url, 0, -1);
     }
     $dirs = explode('/', substr($url, strlen(TYPEF_WEB_DIR)));
     $this->pluginTemplate = '/breadcrumbs/breadcrumbs.plug.html';
     $data['breadcrumbs'] = array();
     $currentUrl = TYPEF_WEB_DIR;
     $start = $data->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($this->getAttribute('start')));
     while (count($dirs) > 0) {
         $currentUrl .= '/' . array_shift($dirs);
         $currentUrl = preg_replace('/\\/+/', '/', $currentUrl);
         if ($start && strpos($currentUrl, $start) === false) {
             continue;
         }
         if (isset($_SESSION['breadcrumbs'][$currentUrl])) {
             $bc = $_SESSION['breadcrumbs'][$currentUrl];
             $bc['url'] = $currentUrl . ($bc['query'] ? '?' . $bc['query'] : '');
             $data['breadcrumbs'][] = $bc;
         } else {
             $response = Typeframe::Registry()->responseAt($currentUrl);
             if ($currentUrl == $response->page()->uri()) {
                 if ($response->application()->name() != '403' && $response->application()->name() != '404') {
                     $settings = $response->page()->settings();
                     if (!empty($settings['nickname'])) {
                         $title = $settings['nickname'];
                     } else {
                         $title = $response->page()->title();
                     }
                     $bc = array('title' => $title, 'query' => '');
                     $_SESSION['breadcrumbs'][$currentUrl] = $bc;
                     $bc['url'] = $currentUrl;
                     $data['breadcrumbs'][] = $bc;
                 }
             }
         }
     }
     parent::output($data, $stream);
     return;
 }
Beispiel #3
0
<?php

$file = isset($_REQUEST['file']) ? $_REQUEST['file'] : '';
if ($file && file_exists(TYPEF_DIR . $file) && is_file(TYPEF_DIR . $file)) {
    header('Content-type: text/css');
    $dir = dirname($file);
    $md5 = md5($file) . '.css';
    $dst = TYPEF_DIR . '/files/cache/lessphp/' . $md5;
    lessc::ccompile(TYPEF_DIR . $file, $dst);
    $css = SimpleCss::LoadFile($dst, TYPEF_WEB_DIR . $dir);
    $code = $css->toString();
    preg_match_all('/url\\(\\"([\\w\\W\\s\\S]*?)"\\)/', $code, $matches);
    if (isset($matches[1])) {
        foreach ($matches[1] as $url) {
            $url = Typeframe_Attribute_Url::ConvertShortUrlToExpression($url);
            $url = Typeframe::Pagemill()->data()->parseVariables($url);
            $code = str_replace($matches[1], $url, $code);
        }
    }
    echo $code;
    exit;
} else {
    http_response_code(404);
    Typeframe::SetPageTemplate('/404.html');
    Typeframe::CurrentPage()->stop();
}
Beispiel #4
0
 private static function _GetStylesheetsFromElement(SimpleXMLElement $xml, array &$stylesheets)
 {
     $els = $xml->xpath('//link[@rel="stylesheet"]|//pm:include');
     foreach ($els as $e) {
         if ($e->getName() == 'link') {
             // stylesheet
             $converted = Typeframe::Pagemill()->data()->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression((string) $e['href']));
             if ($converted) {
                 $stylesheets[] = $converted;
             }
         } else {
             if ($e->getName() == 'include') {
                 // include
                 $inc = Pagemill_SimpleXmlElement::LoadFile(Typeframe_Skin::TemplatePath($e['template']));
                 self::_GetStylesheetsFromElement($inc, $stylesheets);
             }
         }
     }
 }
Beispiel #5
0
            }
            $mail->Subject = $mailform['subject'] ? $mailform['subject'] : 'Mailform Submission';
            $mail->Body = $body;
            if (!$mail->Send()) {
                throw new Exception($mail->ErrorInfo);
            }
        }
        $pm->setVariable('response', $mailform['response']);
        $pm->setVariable('referer', @$_SERVER['HTTP_REFERER']);
        if ($mailform['redirect']) {
            if (requestIsAjax()) {
                header('Content-Type: text/json');
                $response = array('status' => 'ok', 'redirect' => $pm->data()->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($mailform['redirect'])));
                echo json_encode($response);
                exit;
            } else {
                Typeframe::Redirect('Submission received.', $pm->data()->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($mailform['redirect'])));
            }
        } else {
            Typeframe::SetPageTemplate('/mailform/completed.html');
        }
    } else {
        $pm->setVariable('errors', $formHandler->errors());
        if (requestIsAjax()) {
            header('Content-Type: text/json');
            $response = array('status' => 'error', 'errors' => $formHandler->errors());
            echo json_encode($response);
            exit;
        }
    }
}
Beispiel #6
0
 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     $data = $data->fork();
     $data->setArray($this->attributes());
     $navigation = new Model_Nav();
     $navigation->where('plugid = ?', $this->attributes['plugid']);
     $navigation->where('parent = 0');
     $items = array();
     foreach ($navigation->select() as $item) {
         $item['link'] = $data->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($item['link']));
         $items[] = $this->get_tree_down($item);
     }
     $data->set('navigation', $items);
     $this->pluginTemplate = '/navigation/navigation.plug.html';
     parent::output($data, $stream);
 }