Example #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" />');
 }
Example #2
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);
 }
Example #3
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);
    }
}
Example #4
0
File: reset.php Project: ssrsfs/blg
 $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);
 }
Example #5
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);
}
Example #6
0
File: index.php Project: ssrsfs/blg
         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') {
             $fullname = TYPEF_DIR . '/files/public/mailform/' . $field['value'];
Example #7
0
File: index.php Project: ssrsfs/blg
 } 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);
     return;
Example #8
0
        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)));
file_put_contents(TYPEF_SOURCE_DIR . "/templates/admin/{$applicationname}/add.html", str_replace(array('&lt;', '&gt;', '&quot;', '&apos;'), array('<', '>', '"', "'"), $pm->writeFile(__DIR__ . '/scaffold/templates/admin/add.html', true)));