Exemplo n.º 1
0
 public function output(PMDataNode $data)
 {
     $pm = new Pagemill($data->fork());
     //$pm->setVariableArray($this->settings);
     $db = Typeframe::Database();
     if (!isset($this->settings['driver'])) {
         //return '<div class="error"><p>Please provide a "driver" attribute on the pm:driver plugin.</p></div>';
         return '';
     }
     // Blank driver attributes count as nothing too.
     if (!$this->settings['driver']) {
         return '';
     }
     // I need to lookup this driver as a page and ensure it's a valid driver.
     $driver = (int) $this->settings['driver'];
     $rs = $db->prepare('SELECT uri, nickname, driver FROM #__page WHERE driver != "" AND pageid = ?');
     $rs->execute($driver);
     if (!$rs->recordcount()) {
         // No records found... just silently fail.
         return '';
     }
     $data = $rs->fetch_array();
     $pm->setVariable('link', TYPEF_WEB_DIR . $data['uri']);
     $pm->setVariable('title', $data['nickname']);
     $pm->setVariable('driver', $data['driver']);
     return $pm->writeText('<pm:include template="/plugins/driver.html" />');
 }
Exemplo n.º 2
0
Arquivo: Debug.php Projeto: ssrsfs/blg
 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     Typeframe::Timestamp('Starting debug output');
     $debug = new Pagemill_Data();
     $timestamps = Typeframe::GetTimestamps();
     $tdata = array();
     if ($timestamps) {
         $begin = $timestamps[0]->time();
         foreach ($timestamps as $t) {
             //$dump .= "{$t->action()}: " . ($t->time() - $begin) . "<br/>";
             $tdata[] = array('action' => $t->action(), 'time' => $t->time() - $begin);
         }
     }
     $debug['timestamps'] = $tdata;
     $debug['memory_used'] = memory_get_usage();
     $debug['memory_used_real'] = memory_get_usage(true);
     $debug['includes'] = get_included_files();
     $debug['querycount'] = Dbi_Source::QueryCount();
     $debug['templates'] = Pagemill::ProcessedTemplates();
     // TODO: Get template files
     $debug['data'] = $data;
     $this->_recurseTines($debug);
     $include = new Typeframe_Tag_Include('include', array('template' => '/pagemill/tag/debug.html'));
     $include->process($debug, $stream);
 }
Exemplo n.º 3
0
 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     $file = $data->parseVariables($this->getAttribute('file'));
     if (!isset(self::$_includeCache[$file])) {
         $pm = new Pagemill($data);
         $tree = $pm->parseFile($file, $this->doctype());
         self::$_includeCache[$file] = $tree;
     } else {
         $tree = self::$_includeCache[$file];
     }
     // Unlike most tags, we don't want to use append/detach here
     // because the tree might be a fragment.
     //$this->appendChild($tree);
     $tree->parent = $this->parent;
     $tree->process($data, $stream);
     //$tree->detach();
     $tree->parent = null;
 }
Exemplo n.º 4
0
 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     // TODO: Implement
     return;
     // setup pagemill
     $pm = new Pagemill($node->fork());
     // add settings
     $this->attributes['id'] = isset($this->attributes['id']) ? $this->attributes['id'] : 'newsarticle-' . rand(0, 9) . rand(0, 9) . rand(0, 9);
     $this->attributes['include_comments'] = isset($this->attributes['include_comments']) ? $this->attributes['include_comments'] : 'true';
     $this->attributes['include_comments'] = 'true' == $this->attributes['include_comments'];
     // Make the string into a boolean.
     $this->attributes['category'] = isset($this->attributes['category']) ? $this->attributes['category'] : '__any';
     $pm->setVariableArray($this->attributes);
     // get most recent article; use settings for category id
     $articles = new News_Article_Factory();
     $categoryid = News::GetCategoryId(true);
     $articles->setCategoryId($categoryid);
     $articles->setPubDate();
     $articles->setLimit(1);
     $article = $articles->get();
     if ($article->exists()) {
         // add some stuff to it
         $url = TYPEF_WEB_DIR . (@$this->attributes['news_page_base'] ? $this->attributes['news_page_base'] : News::GetCategoryUri($article->get('categoryid'))) . '/' . ($article->get('encodedtitle') ? $article->get('encodedtitle') : $article->get('newsid'));
         $article->set('url', $url);
         if (!trim($article->get('title'))) {
             $article->set('title', '[untitled]');
         }
         // add to template
         $pm->setVariable('article', $article);
         // included for backwards compatibility (?)
         $pm->setVariable('newsid', $article->get('newsid'));
         // update the view count for this article
         $article->incrementViews();
     }
     // @todo retrieve all the comments also
     if ($this->attributes['include_comments']) {
     }
     // output the result
     //return $pm->writeText('<pm:include template="/news/article.plug.html" />');
     $this->pluginTemplate = '/news/article.plug.html';
     parent::output($data, $stream);
 }
Exemplo n.º 5
0
Arquivo: Html.php Projeto: ssrsfs/blg
 public function output(\Pagemill_Data $data, \Pagemill_Stream $stream)
 {
     $this->name = 'html';
     $pm = new Pagemill($data);
     $skin = $data->parseVariables($this->getAttribute('skin'));
     $oldskin = null;
     if ($skin) {
         $oldskin = Typeframe_Skin::Current();
         Typeframe_Skin::Set($skin);
     } else {
         $skin = Typeframe_Skin::Current();
     }
     if (file_exists(TYPEF_DIR . '/skins/' . $skin . '/skin.html')) {
         $skinTree = $pm->parseFile(TYPEF_DIR . '/skins/' . $skin . '/skin.html');
     } else {
         $skinTree = $pm->parseFile(TYPEF_DIR . '/skins/default/skin.html');
     }
     $skinTree->process($data, $stream);
     if (!is_null($oldskin)) {
         Typeframe_Skin::Set($oldskin);
     }
 }
Exemplo n.º 6
0
<?php

/**
 * Export config names and values to PHP scripts.
 * This command will create source/scripts/define.d/[package name].php for each
 * package.
 */
$dir = scandir(TYPEF_SOURCE_DIR . '/registry');
foreach ($dir as $file) {
    if (substr($file, 0, 1) !== '.' && is_file(TYPEF_SOURCE_DIR . '/registry/' . $file)) {
        $defines = array();
        $xml = simplexml_load_file(TYPEF_SOURCE_DIR . '/registry/' . $file);
        $configs = $xml->xpath('//config');
        foreach ($configs as $config) {
            $items = $config->xpath('item');
            foreach ($items as $item) {
                if ($item['name']) {
                    $defines[] = array('name' => (string) $item['name'], 'caption' => (string) $item['caption'], 'default' => (string) $item['default']);
                }
            }
        }
        $package = substr($file, 0, -8);
        echo "Writing {$package}.php...\n";
        $pm = new Pagemill();
        $pm->setVariable('defines', $defines);
        $source = $pm->writeFile(TYPEF_SOURCE_DIR . '/cli/tfadmin/define.tpl', true);
        $source = str_replace(array('&lt;', '&gt;', '&quot;', '&apos;'), array('<', '>', '"', "'"), $source);
        file_put_contents(TYPEF_SOURCE_DIR . '/scripts/define.d/' . $package . '.php', $source);
    }
}
Exemplo n.º 7
0
Arquivo: reset.php Projeto: ssrsfs/blg
 $users = new Model_User();
 $users->where('email = ?', $_REQUEST['email']);
 if (1 == $users->getTotal()) {
     // get userid, resetkey, and set to expire in 1 day
     $user = $users->getFirst();
     $userid = $user->get('userid');
     $resetkey = randomID();
     $expire = date('Y-m-d H:i:s', time() + 86400);
     // create an entry in the password reset table
     $reset = Model_UserReset::Create();
     $reset->set('userid', $userid);
     $reset->set('resetkey', $resetkey);
     $reset->set('expire', $expire);
     $reset->save();
     // construct e-mail body
     $mm = new Pagemill($pm->root()->fork());
     $mm->setVariable('username', $user->get('username'));
     $mm->setVariable('reseturl', sprintf('http://%s%s/password?userid=%d&resetkey=%s', $_SERVER['HTTP_HOST'], TYPEF_WEB_DIR, $userid, $resetkey));
     $body = str_replace('&amp;', '&', $mm->writeString('<pm:include template="/users/reset.eml" />', true));
     // e-mail the user so they can reset their password
     $mailer = new Mailer();
     $mailer->Configure();
     $mailer->IsHTML(true);
     $mailer->AddAddress($_POST['email']);
     $mailer->Subject = 'Request to Reset Password for ' . TYPEF_TITLE;
     $mailer->Body = $body;
     $mailer->Send();
     $pm->setVariable('reset_email_sent', true);
     Typeframe::Log('Request to reset password for ' . $_POST['email']);
 } else {
     $pm->setVariable('reset_email_failed', true);
Exemplo n.º 8
0
        $xlate['allownull'] = $column['Null'] == 'NO' ? false : true;
        $xlate['defaultvalue'] = $column['Default'];
        $columns[] = $xlate;
    }
    $rsIndexes = Typeframe::Database()->execute('SHOW INDEX IN ' . $tableName);
    $indexes = array();
    foreach ($rsIndexes as $index) {
        $name = strtolower($index['Key_name']);
        if (!isset($indexes[$name])) {
            $indexes[$name] = array();
            $indexes[$name]['name'] = $name;
            $indexes[$name]['unique'] = $index['Non_unique'] == 0 ? true : false;
            $indexes[$name]['columns'] = array();
        }
        $indexes[$name]['columns'][] = array('name' => $index['Column_name']);
    }
    $classMill = new Pagemill();
    $classMill->setVariable('class', $className);
    $classMill->setVariable('table', $shortName);
    $classMill->setVariable('prefix', $prefix);
    $classMill->setVariable('columns', $columns);
    $classMill->setVariable('indexes', array_values($indexes));
    //$source = html_entity_decode($classMill->writeFile(dirname(__FILE__) . '/model.tmpl'));
    $source = $classMill->writeFile(dirname(__FILE__) . '/model.tmpl', true);
    //$source = html_entity_decode($stream->peek(), ENT_QUOTES | ENT_XML1);
    $source = str_replace(array('&lt;', '&gt;', '&quot;', '&apos;'), array('<', '>', '"', "'"), $source);
    echo "Writing {$className}.php for {$tableName}...\n";
    $fh = fopen(TYPEF_SOURCE_DIR . '/classes/BaseModel/' . $className . '.php', 'w');
    fwrite($fh, $source . "\n");
    fclose($fh);
}
Exemplo n.º 9
0
Arquivo: index.php Projeto: ssrsfs/blg
     } else {
         if (@$submission[$r['fieldname']]['value'] == @$r['fieldvalue']) {
             $sendTo[] = array('name' => $r['name'], 'email' => $r['email']);
         }
     }
 }
 if (count($sendTo)) {
     $replyTo = array();
     if ($mailform['replyto']) {
         foreach ($submission as $field) {
             if ($field['type'] == 'email') {
                 $replyTo[] = $field['value'];
             }
         }
     }
     $mm = new Pagemill();
     $mm->setVariable('submission', $submission);
     $mm->setVariable('referrer', $log['referrer']);
     $body = $mm->writeString('<pm:include template="/mailform/submission.eml" />', true);
     $mail = new Mailer();
     $mail->Configure();
     $mail->IsHTML(true);
     foreach ($sendTo as $s) {
         $mail->AddAddress($s['email'], $s['name']);
     }
     foreach ($replyTo as $r) {
         $mail->AddReplyTo($r);
     }
     $attachmentSize = 0;
     foreach ($submission as $field) {
         if ($field['type'] == 'file' || $field['type'] == 'image') {
Exemplo n.º 10
0
 public function output(Pagemill_Data $data, Pagemill_Stream $stream, $content = null)
 {
     if (!$this->insidePlugin()) {
         $content = self::Cache();
         $name = $this->getAttribute('name');
         $type = $this->getAttribute('type');
         if ($type == 'html') {
             // Parse short URL attributes
             $urled = @$content[$name];
             $urled = preg_replace('/(<[^>]*? href=")~\\//', '$1' . TYPEF_WEB_DIR . '/', $urled);
             $urled = preg_replace('/(<[^>]*? src=")~\\//', '$1' . TYPEF_WEB_DIR . '/', $urled);
             @($content[$name] = $urled);
         }
         if ($type == 'model') {
             if (!empty($content[$name])) {
                 $model = $content[$name];
                 if ((string) $model != '') {
                     $model = explode(':', $model);
                     if (class_exists($model[0])) {
                         $record = $model[0]::Get($model[1]);
                         $content[$name] = $record;
                     }
                 }
             } else {
                 $content[$name] = null;
             }
         }
         if ($this->getAttribute('scope') == 'global') {
             Typeframe::Pagemill()->set($name, @$content[$name]);
         } else {
             $data->set($name, @$content[$name]);
         }
     }
     //$inner = $this->inner($data);
     if (count($this->children()) > 0) {
         foreach ($this->children() as $child) {
             $child->process($data, $stream);
         }
     } else {
         $output = '';
         if ($this->getAttribute('noop')) {
             $output = '';
         } else {
             if ($type == 'html') {
                 $pm = new Pagemill($data);
                 $output = $pm->writeString('<pm:codeblock elements="*" attributes="*">@{' . $name . '}@</pm:codeblock>', true);
             } else {
                 if ($type == 'image') {
                     // Only display something if something is filled in, ie: no broken images.
                     if (@$content[$name] && is_readable(TYPEF_DIR . '/files/public/content/' . @$content[$name])) {
                         // Allow any other attribute to transparently pass to the image.
                         $atts = '';
                         foreach ($this->attributes() as $k => $v) {
                             switch ($k) {
                                 case 'name':
                                 case 'label':
                                 case 'type':
                                 case 'src':
                                     break;
                                 default:
                                     $atts .= " {$k}=\"{$v}\"";
                             }
                         }
                         $output = '<img src="' . TYPEF_WEB_DIR . '/files/public/content/' . $content[$name] . '"' . $atts . '/>';
                     } else {
                         $output = '';
                     }
                 } else {
                     if ($type == 'link') {
                         if (!$content[$name] && @$this->getAttribute('ignoreblank') == true) {
                             return '';
                         }
                         $linktitle = @$this->getAttribute('linktitle') ? $this->getAttribute('linktitle') : 'Click Here';
                         $linkstyle = @$this->getAttribute('linkstyle') ? $this->getAttribute('linkstyle') : '';
                         $output = '<a href="' . $content[$name] . '" style="' . $linkstyle . '">' . $linktitle . '</a>';
                     } else {
                         if ($type == 'checkbox' || $type == 'select') {
                             // Checkbox and select types are primarily for configurable template logic and do not have default output.
                             $output = '';
                         } else {
                             $output = $content[$name];
                         }
                     }
                 }
             }
         }
         $stream->puts($output);
     }
 }
Exemplo n.º 11
0
Arquivo: index.php Projeto: ssrsfs/blg
     $pm->setVariable('typef_require_approval', true);
 } elseif (TYPEF_REQUIRE_CONFIRMATION) {
     // set flag in template
     $pm->setVariable('typef_require_confirmation', true);
     // get userid, confirmkey, and set to expire in 3 days
     $userid = $user->get('userid');
     $confirmkey = randomID();
     $expire = date('Y-m-d H:i:s', time() + 259200);
     // create an entry in the user confirmation table
     $user_confirm = Model_UserConfirm::Create();
     $user_confirm->set('confirmkey', $confirmkey);
     $user_confirm->set('userid', $userid);
     $user_confirm->set('expire', $expire);
     $user_confirm->save();
     // construct e-mail body
     $mm = new Pagemill($pm->root()->fork());
     $mm->setVariable('username', $user->get('username'));
     $mm->setVariable('confirmurl', sprintf('http://%s%s/confirm?userid=%d&confirmkey=%s', $_SERVER['HTTP_HOST'], TYPEF_WEB_DIR, $userid, $confirmkey));
     $body = str_replace('&amp;', '&', $mm->writeString('<pm:include template="/users/register/confirmation.eml" />', true));
     // e-mail the user so they can confirm their registration
     $mailer = new Mailer();
     $mailer->Configure();
     $mailer->IsHTML(true);
     $mailer->AddAddress($_POST['email']);
     $mailer->Subject = 'Your Account Confirmation from ' . TYPEF_TITLE;
     $mailer->Body = $body;
     $mailer->Send();
 } else {
     // if confirmation is not required, log the user in immediately
     Typeframe::User()->login($_POST['username'], $_POST['password']);
     Typeframe::Redirect('Registration complete.  Welcome!', TYPEF_WEB_DIR . '/', 1);
Exemplo n.º 12
0
    if ($letsdothis == 'n') {
        echo "Alright... :( bye bye\n";
        die;
    } elseif ($letsdothis == 'y') {
        $valid = true;
    }
}
/*
$modelnick = "Test Model";
$fields = array();
$fields['id'] = array('required' => 'false', 'type' => 'hidden');
$fields['name'] = array('required' => 'false', 'type' => 'text');
$fields['value'] = array('required' => 'false', 'type' => 'textarea');
$fields['idate'] = array('required' => 'false', 'type' => 'calendar');
*/
$pm = new Pagemill();
$pm->setVariable('fields', $fields);
$pm->setVariable('model', $modelname);
$pm->setVariable('primarykey', $primarykey);
$pm->setVariable('applicationname', $applicationname);
$pm->setVariable('modelnick', $modelnick);
if (!is_dir(TYPEF_SOURCE_DIR . "/controllers/admin/{$applicationname}/")) {
    mkdir(TYPEF_SOURCE_DIR . "/controllers/admin/{$applicationname}/");
}
if (!is_dir(TYPEF_SOURCE_DIR . "/templates/admin/{$applicationname}/")) {
    mkdir(TYPEF_SOURCE_DIR . "/templates/admin/{$applicationname}/");
}
file_put_contents(TYPEF_SOURCE_DIR . "/controllers/admin/{$applicationname}/add.php", str_replace(array('&lt;', '&gt;', '&quot;', '&apos;'), array('<', '>', '"', "'"), $pm->writeFile(__DIR__ . '/scaffold/controllers/admin/add.tpl', true)));
file_put_contents(TYPEF_SOURCE_DIR . "/controllers/admin/{$applicationname}/edit.php", str_replace(array('&lt;', '&gt;', '&quot;', '&apos;'), array('<', '>', '"', "'"), $pm->writeFile(__DIR__ . '/scaffold/controllers/admin/edit.tpl', true)));
file_put_contents(TYPEF_SOURCE_DIR . "/controllers/admin/{$applicationname}/delete.php", str_replace(array('&lt;', '&gt;', '&quot;', '&apos;'), array('<', '>', '"', "'"), $pm->writeFile(__DIR__ . '/scaffold/controllers/admin/delete.tpl', true)));
file_put_contents(TYPEF_SOURCE_DIR . "/controllers/admin/{$applicationname}/index.php", str_replace(array('&lt;', '&gt;', '&quot;', '&apos;'), array('<', '>', '"', "'"), $pm->writeFile(__DIR__ . '/scaffold/controllers/admin/index.tpl', true)));