function SitefaqEditForm() { parent::MailForm(); global $page, $cgi; $this->extra = 'id="cms-edit-form"'; // get copy from repository loader_import('cms.Versioning.Rex'); $rex = new Rex($cgi->_collection); // default: database, database $_document = $rex->getCurrent($cgi->_key); $widgets = $rex->getStruct(); if (!$widgets) { $widgets = array(); } // edit widgets go here $this->widgets = array_merge($this->widgets, $widgets); foreach ($this->widgets as $k => $v) { if (isset($_document->{$k})) { $this->widgets[$k]->setValue($_document->{$k}); } } $w =& $this->addWidget('hidden', '_key'); $w =& $this->addWidget('hidden', '_collection'); $w =& $this->addWidget('hidden', '_return'); if ($rex->isVersioned) { $t =& $this->addWidget('textarea', 'changelog'); $t->alt = intl_get('Change Summary'); $t->rows = 3; $t->labelPosition = 'left'; $t->extra = 'id="changelog"'; } // submit buttons $w =& $this->addWidget('msubmit', 'submit_button'); $b =& $w->getButton(); $b->setValues(intl_get('Save')); $b =& $w->addButton('submit_button', intl_get('Cancel')); $b->extra = 'onclick="return cms_cancel (this.form)"'; $this->error_mode = 'all'; if ($rex->info['Collection']['singular']) { page_title(intl_get('Editing') . ' ' . $rex->info['Collection']['singular'] . ': ' . $_document->{$rex->key}); } else { page_title(intl_get('Editing Item') . ': ' . $_document->{$rex->key}); } // the SiteFAQ additions: if (appconf('user_anonymity')) { unset($this->widgets['name']); unset($this->widgets['email']); unset($this->widgets['url']); unset($this->widgets['ip']); unset($this->widgets['member_id']); } $admin_roles = session_admin_roles(); $this->widgets['assigned_to']->setValues(db_pairs('select username, concat(lastname, ", ", firstname, " (", username, ")") from sitellite_user where role in("' . join('", "', $admin_roles) . '") order by lastname, firstname, username')); if (!$_document->assigned_to) { $this->widgets['assigned_to']->setValue(session_username()); } }
function SiteblogEditForm() { parent::MailForm(); global $cgi; $refer = $_SERVER['HTTP_REFERER']; $this->parseSettings('inc/app/siteblog/forms/edit/settings.php'); $this->widgets['refer']->setValue($refer); //if add is true, we're creating a blog post, otherwise we're editing a blog post $add = isset($cgi->_key) && !empty($cgi->_key) ? false : true; $this->widgets['status']->setValues(array('Live', 'Not Live')); $cats = db_pairs('select id, title from siteblog_category where status = "on"'); if ($add) { page_title('Adding a Blog Post'); $this->widgets['author']->setValue(session_username()); unset($this->widgets['icategory']); $this->widgets['category']->setValues($cats); } else { loader_import('cms.Versioning.Rex'); $rex = new Rex('siteblog_post'); $document = $rex->getCurrent($cgi->_key); page_title('Editing a Blog Post'); //populate fields $this->widgets['subject']->setValue($document->subject); $this->widgets['author']->setValue($document->author); $this->widgets['status']->setValue($document->status); unset($this->widgets['category']); $catname = db_shift('select title from siteblog_category where id = ?', $document->category); $this->widgets['icategory']->setValue($catname); $this->widgets['oldcat']->setValue($document->category); $this->widgets['body']->setValue($document->body); } }
function categories() { $res = db_pairs('select id, title from siteblog_category order by title asc'); $cats = array('' => '- ALL -'); foreach ($res as $id => $title) { $cats[$id] = $title; } return $cats; }
function SitelliteExportForm() { parent::MailForm(__FILE__); $user = session_get_user(); $groups = array('' => '- All -'); foreach (db_pairs('select id, name from sitellite_form_type order by name asc') as $k => $v) { $groups[$k] = $v; } $this->widgets['group']->setValues($groups); page_title(intl_get('Export Contacts')); }
function SitelliteSendForm() { parent::MailForm(__FILE__); $user = session_get_user(); $this->widgets['from_email']->setValue($user->email); $this->widgets['from_name']->setValue($user->firstname . ' ' . $user->lastname); $groups = array('' => '- All -'); foreach (db_pairs('select id, name from sitellite_form_type order by name asc') as $k => $v) { $groups[$k] = $v; } $this->widgets['send_to']->setValues($groups); page_title(intl_get('Send Email')); }
function siteevent_filter_audience($audience) { if (strpos($audience, ',') !== false) { $ids = preg_split('/, ?/', $audience); } else { $ids = array($audience); } $audiences = db_pairs('select * from siteevent_audience'); $o = ''; $s = ''; foreach ($ids as $aud) { $o .= $s . $audiences[$aud]; $s = ', '; } return $o; }
// --> </script> <h1>SiteInvoice - New Invoice</h1> <form action="<?php echo site_prefix(); ?> /index/siteinvoice-create-action"> <p><strong>Invoice Name</strong> <input type="text" name="name" style="border: 2px inset #ddd; width: 200px" /></p> <p><strong>Client</strong> <select name="client" onchange="setClientCode (this.options[this.selectedIndex].value)"> <?php foreach (db_pairs('select id, name from siteinvoice_client order by name asc') as $key => $value) { echo '<option value="' . $key . '">' . $value . "</option>\n"; } ?> </select></p> <p><input type="checkbox" name="send_invoice" value="yes" checked="checked" style="width: 15px" /> Send invoice (uncheck to importing existing invoices).</p> <table border="0" cellpadding="1" cellspacing="0" width="800"> <tr> <td class="black"> <table cellpadding="0" cellspacing="1" width="100%"> <tr> <th width="10%" class="head">DATE</th> <th width="10%" class="head">ITEM NO.</th> <th width="50%" class="head">DESCRIPTION</th>
<ul> <?php loader_import('siteblog.Filters'); foreach (db_pairs('select id, title from siteblog_category order by title asc') as $id => $title) { $count = db_shift('select count(*) from siteblog_post where category = ?', $id); echo '<li><a href="' . site_prefix() . '/index/siteblog-topic-action/id.' . $id . '/title.' . siteblog_filter_link_title($title) . '">' . $title . ' (' . $count . ')</a></li>'; } ?> </ul>
$taxes += $invoices[$k]->taxes; $total += $invoices[$k]->total; $invoices[$k]->subtotal = number_format($invoices[$k]->subtotal, 2); $invoices[$k]->taxes = number_format($invoices[$k]->taxes, 2); $invoices[$k]->total = number_format($invoices[$k]->total, 2); } } else { foreach (array_keys($invoices) as $k) { $invoices[$k]->range = 0; if ($invoices[$k]->currency != $dc) { $invoices[$k]->e_total = number_format($invoices[$k]->total, 2); $invoices[$k]->subtotal = $exch->convert($invoices[$k]->currency, $dc, $invoices[$k]->subtotal, false); $invoices[$k]->taxes = $exch->convert($invoices[$k]->currency, $dc, $invoices[$k]->taxes, false); $invoices[$k]->total = $exch->convert($invoices[$k]->currency, $dc, $invoices[$k]->total, false); } else { $invoices[$k]->e_total = false; } $subtotal += $invoices[$k]->subtotal; $taxes += $invoices[$k]->taxes; $total += $invoices[$k]->total; $invoices[$k]->subtotal = number_format($invoices[$k]->subtotal, 2); $invoices[$k]->taxes = number_format($invoices[$k]->taxes, 2); $invoices[$k]->total = number_format($invoices[$k]->total, 2); } } $subtotal = number_format($subtotal, 2); $taxes = number_format($taxes, 2); $total = number_format($total, 2); template_simple_register('pager', $pg); echo template_simple('invoices.spt', array('invoices' => $invoices, 'clients' => db_pairs('select id, name from siteinvoice_client order by name asc'), 'client' => $cgi->client, 'status' => $cgi->status, 'subtotal' => $subtotal, 'taxes' => $taxes, 'total' => $total));
<?php if (!preg_match('/^[a-zA-Z0-9_]+$/', $parameters['table'])) { die('Invalid table'); } if (!preg_match('/^[a-zA-Z0-9_]+$/', $parameters['key'])) { die('Invalid key field'); } if (!preg_match('/^[a-zA-Z0-9_]+$/', $parameters['title'])) { die('Invalid title field'); } if ($parameters['add']) { db_execute(sprintf('insert into %s (%s, %s) values (null, ?)', $parameters['table'], $parameters['key'], $parameters['title']), $parameters['add']); } if ($parameters['del']) { db_execute(sprintf('delete from %s where %s = ?', $parameters['table'], $parameters['key']), $parameters['del']); } page_title(intl_get('Add/Remove Items')); $parameters['list'] = db_pairs('select * from ' . $parameters['table'] . ' order by ' . $parameters['title'] . ' asc'); $parameters['height'] = count($parameters['list']) * 24; if ($parameters['height'] > 400) { $parameters['height'] = 400; } echo template_simple('joiner.spt', $parameters);
<?php page_title(intl_get('All Pages')); $data = new StdClass(); $data->all = db_shift_array('select distinct id from sitewiki_page where id != "" order by id asc'); $bodies = db_pairs('select id, body from sitewiki_page where body regexp "(([A-Z][a-z0-9]+){2,})"'); $data->wanted = array(); foreach ($bodies as $id => $body) { preg_match_all('/(([A-Z][a-z0-9]+){2,})/s', $body, $regs, PREG_SET_ORDER); foreach ($regs as $reg) { if (!in_array($reg[1], $data->all) && !in_array($reg[1], $data->wanted)) { $data->wanted[$reg[1]] = $id; } } } ksort($data->wanted); $data->screen = 'all'; loader_import('sitewiki.Filters'); echo template_simple('all.spt', $data);
<?php global $cgi; // they can only submit a new headline if they're loggin-in. if (!session_valid()) { // send them back to login header('Location: /index/sitemember-app'); exit; } // if no category is selected, select category as step 1. if (!isset($cgi->category)) { page_title(intl_get('Submit a Story')); $categories = array('' => '-- SELECT --'); foreach (db_pairs('select * from digger_category order by category asc') as $k => $v) { $categories[$k] = $v; } echo template_simple('form_add_category.spt', array('categories' => $categories)); return; } class DiggerAddForm extends MailForm { function DiggerAddForm() { parent::MailForm(); $this->parseSettings('inc/app/digger/forms/add/settings.php'); page_title(intl_get('Submit a Story')); } function onSubmit($vals) { db_execute('INSERT INTO digger_linkstory (link, user, posted_on, score, title, category, status, description) VALUES (?, ?, NOW(), 0, ?, ?, "enabled", ?)', $vals['link'], session_username(), $vals['title'], $vals['category'], $vals['description']); header('Location: /index/digger-app');
if (!empty($parameters['poll'])) { $poll = $p->get($parameters['poll']); } else { $p->orderBy('date_added desc'); $p->limit(1); $poll = array_shift($p->find(array())); } /* if (! empty ($parameters['poll'])) { $poll = db_single ('select * from sitepoll_poll where id = ? and ' . $clause, $parameters['poll']); } else { $poll = db_single ('select * from sitepoll_poll where ' . $clause . ' order by date_added desc limit 1'); } */ $poll->voted = db_shift('select count(*) from sitepoll_vote where poll = ? and ua = ? and ip = ?', $poll->id, $_SERVER['HTTP_USER_AGENT'], $_SERVER['REMOTE_ADDR']); $votes = db_pairs('select choice, count(*) as votes from sitepoll_vote where poll = ? group by choice asc', $poll->id); $poll->options = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array(), 6 => array(), 7 => array(), 8 => array(), 9 => array(), 10 => array(), 11 => array(), 12 => array()); $total = 0; foreach ($poll->options as $k => $v) { if (empty($poll->{'option_' . $k})) { unset($poll->options[$k]); continue; } elseif (!empty($votes[$k])) { $poll->options[$k] = array('answer' => $poll->{'option_' . $k}, 'choice' => $k, 'votes' => $votes[$k], 'percent' => 0); $total += $votes[$k]; } else { $poll->options[$k] = array('answer' => $poll->{'option_' . $k}, 'choice' => $k, 'votes' => 0, 'percent' => 0); } } foreach ($poll->options as $k => $v) { if ($total == 0) {
/** * Returns a list of pages linking to the specified image. */ function imagechooser_links($image) { return db_pairs('select id, if(title != "", title, id) from sitellite_page where body like ? order by id asc', '%' . $image . '%'); }
/** * Fetches the title values for all approved items in the currently active * collection and language. */ function getTitles() { return db_pairs('select pkey, title from sitellite_translation where sitellite_status = "approved" and collection = ? and lang = ?', $this->collection, $this->lang); }