Esempio n. 1
0
 /**
  * @param string $subject
  *  The subject. May contain variable references to memebrs
  *  of the $fields array.
  * @param string $view
  *  The name of a view
  * @param array $fields
  *  The fields referenced in the subject and/or view
  * @param array $optoins
  *  Array of options. Can include:
  *  "html" => Defaults to false. Whether to send as HTML email.
  *  "name" => A human-readable name in addition to the address.
  *  "from" => An array of email_address => human_readable_name
  */
 function sendMessage($subject, $view, $fields = array(), $options = array())
 {
     if (!isset($options['from'])) {
         $url_parts = parse_url(Pie_Request::baseUrl());
         $domain = $url_parts['host'];
         $options['from'] = array("email_bot@" . $domain => $domain);
     } else {
         if (!is_array($options['from'])) {
             throw new Pie_Exception_WrongType(array('field' => '$options["from"]', 'type' => 'array'));
         }
     }
     // Set up the default mail transport
     $tr = new Zend_Mail_Transport_Sendmail('-f' . $this->address);
     Zend_Mail::setDefaultTransport($tr);
     $mail = new Zend_Mail();
     $from_name = reset($options['from']);
     $mail->setFrom(key($options['from']), $from_name);
     if (isset($options['name'])) {
         $mail->addTo($this->address, $options['name']);
     } else {
         $mail->addTo($this->address);
     }
     $subject = Pie::expandString($subject, $fields);
     $body = Pie::view($view, $fields);
     $mail->setSubject($subject);
     if (empty($options['html'])) {
         $mail->setBodyText($body);
     } else {
         $mail->setBodyHtml($body);
     }
     $mail->send();
     return true;
 }
Esempio n. 2
0
function users_before_pie_init()
{
    $facebook_apps = Pie_Config::get('users', 'facebookApps', array());
    foreach ($facebook_apps as $app_id => $fb_info) {
        if (isset($fb_info['url'])) {
            $subpath = isset($fb_info['subpath']) ? $fb_info['subpath'] : '';
            Pie_Config::set('pie', 'proxies', Pie_Request::baseUrl(true) . $subpath, $fb_info['url']);
        }
    }
}
Esempio n. 3
0
 static function init()
 {
     if (Pie_Config::get('pie', 'session', 'appendSuffix', false) or isset($_GET[self::name()])) {
         if (self::id()) {
             $s = '?' . self::name() . '=' . self::id();
             $suffix = Pie_Uri::suffix();
             $base_url = Pie_Request::baseUrl();
             $suffix[$base_url] = isset($suffix[$base_url]) ? $suffix[$base_url] . $s : $s;
             Pie_Uri::suffix($suffix);
         }
     }
     self::$inited = true;
 }
Esempio n. 4
0
function pie_addScriptLines()
{
    $app = Pie_Config::expect('pie', 'app');
    $uri = Pie_Dispatcher::uri();
    $proxies_json = json_encode(Pie_Config::get('pie', 'proxies', array()));
    $uri_json = json_encode($uri->toArray());
    $url = Pie_Request::url();
    $url_json = json_encode($url);
    $proxy_url_json = json_encode(Pie_Uri::url($url));
    $base_url = json_encode(Pie_Request::baseUrl());
    Pie_Response::addScriptLine(<<<EOT
// pie {{
\t\tPie.info = {
\t\t\t"proxies": {$proxies_json},
\t\t\t"uri": {$uri_json},
\t\t\t"url": {$url_json},
\t\t\t"proxyUrl": {$proxy_url_json},
\t\t\t"baseUrl": {$base_url}
\t\t};
EOT
);
    $uris = Pie_Config::get('pie', 'javascript', 'uris', array());
    $urls = array();
    foreach ($uris as $u) {
        $urls["{$u}"] = Pie_Uri::url("{$u}");
    }
    $urls_json = json_encode($urls);
    Pie_Response::addScriptLine("\t\tPie.urls = {$urls_json};");
    // Export more variables to inline js
    $app = Pie_Config::expect('pie', 'app');
    $app_json = json_encode($app);
    Pie_Response::addScriptLine("\t\tPie.app = {$app_json};\n" . "// }} pie");
    $snf = Pie_Config::get('pie', 'session', 'nonceField', 'nonce');
    $nonce = isset($_SESSION[$snf]) ? $_SESSION[$snf] : null;
    if ($nonce) {
        $nonce_json = json_encode($nonce);
        Pie_Response::addScriptLine("\t\tPie.nonce = {$nonce_json};");
    }
}
Esempio n. 5
0
 /**
  * The current theme url applied to all "src" attributes (except for iframes)
  * rendered by Pie_Html.
  * @return string|null
  *  The theme url that is currently at the end of the cascade, i.e. was pushed last.
  */
 static function themeUrl()
 {
     return Pie_Config::get('pie', 'theme_url', Pie_Request::baseUrl());
 }
Esempio n. 6
0
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title><?php 
echo $title;
?>
</title>
	<link rel="shortcut icon" href="<?php 
echo Pie_Request::baseUrl();
?>
/favicon.ico" type="image/x-icon">
	
	<?php 
echo Pie_Response::stylesheets("\n\t");
?>
 
	<?php 
echo Pie_Response::scripts("\n\t");
?>
 
	<style type="text/css">
		<?php 
echo Pie_Response::stylesInline();
?>
 
	</style>
	<!--[if lt IE 7]>
		<?php 
// echo Pie_Html::tag('script', array('src' => 'js/unitpngfix.js'))
Esempio n. 7
0
 /**
  * @param string $pattern
  * @param array $fields
  * @param string $controller
  *  
  * @return string|false
  *  Returns false if even one field doesn't match.
  *  Otherwise, returns the URL that would be routed to this uri.
  */
 protected function matchRoute($pattern, $fields, $controller = true)
 {
     $segments = explode('/', $pattern);
     $segments2 = array();
     $pattern_fields = array();
     foreach ($segments as $s) {
         if (!isset($s[0]) or $s[0] != '$') {
             // A literal segment
             $segments2[] = $s;
             continue;
         }
         $k = substr($s, 1);
         $k_parts = explode('.', $k, 2);
         if (count($k_parts) > 1) {
             $k1 = reset($k_parts);
             $k2 = '.' . end($k_parts);
         } else {
             $k1 = $k;
             $k2 = '';
         }
         if (!array_key_exists($k1, $this->fields)) {
             return false;
         }
         $segments2[] = urlencode($this->fields[$k1] . $k2);
         $pattern_fields[$k1] = $this->fields[$k1];
     }
     // Test if all the fields match
     foreach ($fields as $name => $value) {
         if (!isset($this->fields[$name]) or $this->fields[$name] != $value) {
             return false;
         }
     }
     // Test field matches the other way
     $combined_fields = array_merge($pattern_fields, $fields);
     foreach ($this->fields as $name => $value) {
         if (!isset($combined_fields[$name]) or $combined_fields[$name] != $value) {
             return false;
         }
     }
     $url = Pie_Request::baseUrl($controller) . '/' . implode('/', $segments2);
     return $url;
 }