本文整理汇总了PHP中process_widget函数的典型用法代码示例。如果您正苦于以下问题:PHP process_widget函数的具体用法?PHP process_widget怎么用?PHP process_widget使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了process_widget函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processView
function processView()
{
if (empty($_REQUEST['planid'])) {
add_message('No plans selected for execution', 'error');
return;
}
if (empty($_REQUEST['personid'])) {
add_message('No persons selected for plan execution', 'error');
return;
}
$plans = array();
foreach ($_REQUEST['planid'] as $planid) {
$plans[] = $GLOBALS['system']->getDBObject('action_plan', $planid);
}
$refdate = process_widget('plan_reference_date', array('type' => 'date'));
foreach ($_REQUEST['personid'] as $personid) {
foreach ($plans as $plan) {
$plan->execute('person', (int) $personid, $refdate);
}
}
foreach ($plans as $plan) {
add_message('"' . $plan->getValue('name') . '" plan executed for ' . count($_REQUEST['personid']) . ' person(s)', 'success');
}
if (count($_REQUEST['personid']) == 1) {
redirect('persons', array('personid' => (int) reset($_REQUEST['personid'])));
}
}
示例2: processView
function processView()
{
$this->_family =& $GLOBALS['system']->getDBObject('family', $_REQUEST['familyid']);
$GLOBALS['system']->includeDBClass('person');
$this->_person = new Person();
if (array_get($_REQUEST, 'new_person_submitted')) {
$GLOBALS['system']->doTransaction('begin');
$this->_person = new Person();
$this->_person->processForm();
$this->_person->setValue('familyid', $this->_family->id);
if ($this->_person->create()) {
if (!empty($_POST['execute_plan'])) {
foreach ($_POST['execute_plan'] as $planid) {
$plan = $GLOBALS['system']->getDBObject('action_plan', $planid);
$plan->execute('person', $this->_person->id, process_widget('plan_reference_date', array('type' => 'date')));
}
}
$GLOBALS['system']->doTransaction('commit');
add_message('New family member added');
redirect('families', array('familyid' => $this->_family->id));
// exits
} else {
$GLOBALS['system']->doTransaction('rollback');
}
} else {
$this->_person->setValue('last_name', $this->_family->getValue('family_name'));
}
}
示例3: processView
function processView()
{
if (empty($_REQUEST['params_submitted'])) {
if (!empty($_SESSION['attendance'])) {
$this->age_bracket = array_get($_SESSION['attendance'], 'age_bracket');
$this->congregationids = array_get($_SESSION['attendance'], 'congregationids');
$this->groupid = array_get($_SESSION['attendance'], 'groupid');
$this->start_date = array_get($_SESSION['attendance'], 'start_date', date('Y-m-d', strtotime('-7 weeks')));
$this->end_date = array_get($_SESSION['attendance'], 'end_date');
} else {
$this->start_date = date('Y-m-d', strtotime('-7 weeks'));
}
} else {
$this->age_bracket = $_SESSION['attendance']['age_bracket'] = $_REQUEST['age_bracket'];
if ($this->age_bracket != '') {
$this->age_bracket = (int) $this->age_bracket;
}
if (!empty($_REQUEST['congregationid']) && is_array($_REQUEST['congregationid'])) {
foreach ($_REQUEST['congregationid'] as $congid) {
$this->congregationids[] = (int) $congid;
}
$_SESSION['attendance']['congregationids'] = $this->congregationids;
}
$this->groupid = $_SESSION['attendance']['groupid'] = array_get($_REQUEST, 'groupid');
$this->start_date = $_SESSION['attendance']['start_date'] = process_widget('start_date', array('type' => 'date'));
$this->end_date = $_SESSION['attendance']['end_date'] = process_widget('end_date', array('type' => 'date'));
}
// Make sure there are no empty congregation IDs, except the first one
for ($i = count($this->congregationids); $i > 0; $i--) {
if (empty($this->congregationids[$i])) {
unset($this->congregationids[$i]);
}
}
}
示例4: processView
function processView()
{
$this->_start_date = process_widget('start_date', array('type' => 'date'));
$this->_end_date = process_widget('end_date', array('type' => 'date'));
if (is_null($this->_end_date)) {
$this->_end_date = date('Y-m-d', strtotime(date('Y-m-01') . ' -1 day'));
}
if (is_null($this->_start_date)) {
$this->_start_date = date('Y-m-d', strtotime($this->_start_date . ' -3 months'));
}
}
示例5: processView
function processView()
{
$GLOBALS['system']->includeDBClass('service');
$this->_service_date = process_widget('service_date', array('type' => 'date'));
$this->_congregations = $GLOBALS['system']->getDBObjectData('congregation', array('!meeting_time' => ''));
if (empty($this->_congregations)) {
add_message("You need to set the 'code name' for some of your congregations before using this feature", 'failure');
$this->_congregations = NULL;
// mark that we neve had any even before processing
return;
}
$this->_dirs['populate'] = SERVICE_DOCS_TO_POPULATE_DIRS ? explode('|', SERVICE_DOCS_TO_POPULATE_DIRS) : '';
$this->_dirs['expand'] = SERVICE_DOCS_TO_EXPAND_DIRS ? explode('|', SERVICE_DOCS_TO_EXPAND_DIRS) : '';
if (empty($this->_dirs['populate']) && empty($this->_dirs['expand'])) {
add_message("You need to set a value for SERVICE_DOCS_TO_POPULATE_DIRS or SERVICE_DOCS_TO_EXPAND_DIRS in your system configuration before using this feature", 'failure');
$this->_dirs = NULL;
return;
}
// Convert relative path names to absolute, and warn of non-existent folders
$rootpath = DOCUMENTS_ROOT_PATH ? DOCUMENTS_ROOT_PATH : JETHRO_ROOT . '/files';
foreach (array('populate', 'expand') as $dirtype) {
foreach ($this->_dirs[$dirtype] as $i => &$dir) {
if (!is_dir($dir)) {
if (is_dir($rootpath . '/' . $dir)) {
$dir = $rootpath . '/' . $dir;
} else {
add_message("The folder " . $this->_cleanDirName($dir) . ' was not found and will not be used. Check your system config file.', 'warning');
unset($this->_dirs[$dirtype][$i]);
}
}
}
}
unset($dir);
// foreach by ref is dangerous.
if ($this->_service_date) {
switch (array_get($_REQUEST, 'action')) {
case 'initiate':
$this->processInitiate();
break;
case 'populate':
$this->processPopulate();
break;
case 'expand':
$this->processExpand();
break;
}
}
}
示例6: processView
function processView()
{
$this->editing = !empty($_REQUEST['editing']) && $GLOBALS['user_system']->havePerm(PERM_EDITSERVICE);
if (!empty($_REQUEST['congregationid'])) {
$this->congregationid = (int) $_REQUEST['congregationid'];
}
$this->date = process_widget('date', array('type' => 'date'));
if (empty($this->date) && !empty($_SESSION['service_date'])) {
$this->date = $_SESSION['service_date'];
}
if (empty($this->congregationid) && !empty($_SESSION['service_congregationid'])) {
$this->congregationid = $_SESSION['service_congregationid'];
}
if ($this->congregationid && $this->date) {
$_SESSION['service_date'] = $this->date;
$_SESSION['service_congregationid'] = $this->congregationid;
$this->service = NULL;
$serviceData = $GLOBALS['system']->getDBOBjectData('service', array('congregationid' => $this->congregationid, 'date' => $this->date), 'AND');
if (!empty($serviceData)) {
// SAVE RUN SHEET
$this->service = $GLOBALS['system']->getDBObject('service', key($serviceData));
if ($this->editing) {
$this->service->acquireLock('items');
}
if (!empty($_REQUEST['save_service']) && $GLOBALS['user_system']->havePerm(PERM_EDITSERVICE)) {
if (!$this->service->haveLock('items')) {
trigger_error("Your lock expired and your changes could not be saved");
return;
}
$newItems = array();
foreach (array_get($_POST, 'componentid', array()) as $rank => $compid) {
$newItem = array('componentid' => $compid, 'title' => $_POST['title'][$rank], 'personnel' => $_POST['personnel'][$rank], 'show_in_handout' => $_POST['show_in_handout'][$rank], 'length_mins' => $_POST['length_mins'][$rank], 'note' => trim($_POST['note'][$rank]), 'heading_text' => trim($_POST['heading_text'][$rank]));
$newItems[] = $newItem;
}
$this->service->saveItems($newItems);
$this->service->saveComments(process_widget('service_comments', array('type' => 'html')));
$this->service->releaseLock('items');
$this->editing = FALSE;
}
}
} else {
$this->date = date('Y-m-d', strtotime('Sunday'));
}
}
示例7: processView
function processView()
{
$this->_start_date = process_widget('start_date', array('type' => 'date'));
if (is_null($this->_start_date)) {
if (!empty($_SESSION['roster_start_date'])) {
$this->_start_date = $_SESSION['roster_start_date'];
} else {
$this->_start_date = date('Y-m-d');
}
}
$this->_end_date = process_widget('end_date', array('type' => 'date'));
if (is_null($this->_end_date)) {
if (!empty($_SESSION['roster_end_date'])) {
$this->_end_date = $_SESSION['roster_end_date'];
} else {
$this->_end_date = date('Y-m-d', strtotime('+' . ROSTER_WEEKS_DEFAULT . ' weeks'));
}
}
if (!empty($_REQUEST['viewid'])) {
$this->_view = $GLOBALS['system']->getDBObject('roster_view', (int) $_REQUEST['viewid']);
}
$_SESSION['roster_start_date'] = $this->_start_date;
$_SESSION['roster_end_date'] = $this->_end_date;
}
开发者ID:howardgrigg,项目名称:jethro-pmm,代码行数:24,代码来源:view_7_rosters__1_display_roster_assignments.class.php
示例8: processDatesInterface
static function processDatesInterface($prefix)
{
$res = NULL;
if (!empty($_POST[$prefix . 'date'])) {
$res = array();
$date_params = array('type' => 'date', 'allow_blank_year' => true);
foreach ($_POST[$prefix . 'date'] as $i => $d) {
$d['date'] = process_widget($prefix . 'dateval[' . $i . ']', $date_params);
if (empty($d['date'])) {
continue;
}
if (empty($d['typeid'])) {
$d['typeid'] = NULL;
}
if (empty($d['typeid']) && !strlen($d['note'])) {
add_message('The date "' . format_date($d['date']) . '" was not saved because no type or note was specified for it');
} else {
// we only save each dateval+type combo once. entries with notes win.
$res[] = $d;
}
}
}
return $res;
}
示例9: processFieldInterface
public function processFieldInterface($name, $prefix = '')
{
if (!$this->id || $this->haveLock()) {
$value = process_widget($prefix . $name, $this->fields[$name]);
if (!is_null($value)) {
$this->setValue($name, $value);
}
}
}
示例10: process_widget
function process_widget($name, $params, $index = NULL, $preserveEmpties = FALSE)
{
$testVal = $rawVal = array_get($_REQUEST, $name);
if (empty($testVal) && $params['type'] == 'date') {
$testVal = array_get($_REQUEST, $name . '_d');
}
if (is_array($testVal) && $params['type'] != 'bitmask' && array_get($params, 'allow_multiple', 0) == 0) {
if (!is_null($index)) {
$rawVal = $rawVal[$index];
} else {
$res = array();
foreach ($testVal as $i => $v) {
$x = process_widget($name, $params, $i);
if ($preserveEmpties || strlen($x)) {
$res[] = $x;
}
}
return $res;
}
}
$value = null;
switch ($params['type']) {
case 'phone':
if (array_get($params, 'allow_empty', TRUE) && empty($rawVal)) {
$value = '';
} else {
if (!is_valid_phone_number($rawVal, $params['formats'])) {
trigger_error('The phone number "' . $rawVal . '" is not valid and has not been set', E_USER_NOTICE);
$value = NULL;
} else {
$value = clean_phone_number($rawVal);
}
}
break;
case 'date':
if (isset($rawVal)) {
// might have an ISO8601 date
if (preg_match('/^(\\d\\d\\d\\d-\\d\\d-\\d\\d)$/', $rawVal)) {
return $rawVal;
}
}
if (FALSE === strpos($name, '[')) {
$subindex = NULL;
} else {
$subindex = substr($name, strpos($name, '[') + 1, strpos($name, ']') - strpos($name, '[') - 1);
$name = substr($name, 0, strpos($name, '['));
}
if (!isset($_REQUEST[$name . '_d'])) {
return NULL;
}
if (!is_null($subindex) && !isset($_REQUEST[$name . '_d'][$subindex])) {
return NULL;
}
foreach (array('y', 'm', 'd') as $comp) {
$comp_vals[$comp] = array_get($_REQUEST, $name . '_' . $comp, 0);
if (!is_null($index)) {
$comp_vals[$comp] = $comp_vals[$comp][$index];
}
if (!is_null($subindex)) {
$comp_vals[$comp] = $comp_vals[$comp][$subindex];
}
}
$value = sprintf('%04d-%02d-%02d', $comp_vals['y'], $comp_vals['m'], $comp_vals['d']);
if ($value == '0000-00-00') {
return NULL;
}
if ($value == '0000-01-00') {
return NULL;
}
if (array_get($params, 'allow_blank_year') && !(int) $comp_vals['y']) {
$value = substr($value, 4);
if (date('-m-d', strtotime('2000' . $value)) != $value) {
trigger_error('The date "' . $value . '" is not valid and has not been set', E_USER_NOTICE);
$value = NULL;
}
} else {
if (date('Y-m-d', strtotime($value)) != $value) {
trigger_error('The date "' . $value . '" is not valid and has not been set', E_USER_NOTICE);
$value = NULL;
}
}
break;
case 'bibleref':
if (!empty($rawVal)) {
require_once 'bible_ref.class.php';
$br = new bible_ref($rawVal);
if ($br->book) {
$value = $br->toCode();
}
}
break;
case 'bitmask':
// value is the bitwise-or of all submitted values
$value = 0;
if (isset($rawVal)) {
foreach ((array) $rawVal as $i) {
$value = $value | (int) $i;
}
}
break;
//.........这里部分代码省略.........
示例11: _processRuleDetails
function _processRuleDetails($field)
{
$res = array();
switch ($this->_field_details[$field]['type']) {
case 'datetime':
$res['from'] = process_widget('params_' . str_replace('.', '_', $field) . '_from', array('type' => 'date'));
$res['to'] = process_widget('params_' . str_replace('.', '_', $field) . '_to', array('type' => 'date'));
break;
case 'select':
case 'reference':
$res = $this->_removeEmpties(array_get($_POST, 'params_' . str_replace('.', '_', $field), array()));
break;
default:
$res = array_get($_POST, 'params_' . str_replace('.', '_', $field));
break;
}
return $res;
}
示例12: processNoteFieldWidgets
/**
* Process the interface for POPULATING fields within this note template
* (used when adding a note to a person)
*/
public function processNoteFieldWidgets()
{
$fields = $GLOBALS['system']->getDBObjectData('note_template_field', array('templateid' => $this->id), 'OR', 'rank');
foreach ($fields as $id => $details) {
if ($details['customfieldid']) {
$cf = $GLOBALS['system']->getDBObject('custom_field', $details['customfieldid']);
$this->_field_values[$id] = $cf->processWidget();
} else {
$params = unserialize($details['params']);
$params['type'] = $details['type'];
$this->_field_values[$id] = process_widget('template_field_' . $id, $params);
}
}
}
示例13: processView
public function processView()
{
if (!count(self::getCongregations())) {
add_message("You need to set the 'code name' for some of your congregations before using this feature", 'failure');
return;
}
$this->_service_date = process_widget('date', array('type' => 'date'));
if (empty($this->_service_date)) {
add_message("No date supplied");
return;
}
if (!in_array(array_get($_REQUEST, 'action'), array('populate', 'expand'))) {
add_message("Invalid action specified");
return;
}
$this->_action = $_REQUEST['action'];
if (empty($_REQUEST['filename'])) {
add_message("no filename supplied");
return;
}
$this->_filename = self::resolveFilename($this->_action, $_REQUEST['filename']);
if (!$this->_filename) {
add_message("Unkown template " . $_REQUEST['filename']);
return;
}
if (!empty($_REQUEST['replacements'])) {
$method = '_process' . ucfirst($this->_action) . '';
$this->{$method}();
} else {
$this->loadReplacements();
}
}
示例14: processView
function processView()
{
if (empty($_REQUEST['params_submitted']) && empty($_REQUEST['attendances_submitted'])) {
if (!empty($_SESSION['attendance'])) {
$this->_age_bracket = array_get($_SESSION['attendance'], 'age_bracket');
$this->_congregationids = array_get($_SESSION['attendance'], 'congregationids');
$this->_groupid = array_get($_SESSION['attendance'], 'groupid');
$this->_show_photos = array_get($_SESSION['attendance'], 'show_photos', FALSE);
}
// Default to last Sunday, unless today is Sunday
$this->_attendance_date = date('Y-m-d', date('D') == 'Sun' ? time() : strtotime('last Sunday'));
}
if (!empty($_REQUEST['params_submitted']) || !empty($_REQUEST['attendances_submitted'])) {
$this->_attendance_date = process_widget('attendance_date', array('type' => 'date'));
$this->_age_bracket = $_SESSION['attendance']['age_bracket'] = array_get($_REQUEST, 'age_bracket');
$this->_show_photos = $_SESSION['attendance']['show_photos'] = array_get($_REQUEST, 'show_photos', FALSE);
$status = NULL;
// TODO
if ($_REQUEST['for_type'] == 'congregationid') {
$cids = process_widget('congregationid', array('type' => 'reference', 'references' => 'congregation', 'multiple' => true));
foreach ($cids as $cid) {
if ($cid && !in_array($cid, $this->_congregationids)) {
$this->_congregationids[] = $cid;
$this->_record_sets[] = new Attendance_Record_Set($this->_attendance_date, $this->_age_bracket, $status, $cid, 0);
}
}
$_SESSION['attendance']['congregationids'] = $this->_congregationids;
$_SESSION['attendance']['groupid'] = null;
} else {
$this->_groupid = process_widget('groupid', array('type' => 'reference', 'references' => 'person_group', 'allow_empty' => false));
if ($this->_groupid) {
$this->_record_sets[] = new Attendance_Record_Set($this->_attendance_date, $this->_age_bracket, $status, NULL, $this->_groupid);
$_SESSION['attendance']['congregationids'] = array();
$_SESSION['attendance']['groupid'] = $this->_groupid;
}
}
if ($this->_show_photos) {
foreach ($this->_record_sets as $set) {
$set->show_photos = TRUE;
}
}
}
if (!empty($_REQUEST['attendances_submitted'])) {
// Process step 2
if ($_SESSION['enter_attendance_token'] == $_REQUEST['enter_attendance_token']) {
// Clear the token from the session on disk
$_SESSION['enter_attendance_token'] = NULL;
session_write_close();
session_start();
// Process the form
foreach ($this->_record_sets as $i => $set) {
if ($set->processForm($i)) {
$set->save();
if ((int) $set->congregationid) {
Headcount::save('congregation', $this->_attendance_date, $set->congregationid, $_REQUEST['headcount']['congregation'][$set->congregationid]);
} else {
Headcount::save('person_group', $this->_attendance_date, $set->groupid, $_REQUEST['headcount']['group'][$set->groupid]);
}
}
}
} else {
trigger_error('Could not save attendances - synchronizer token does not match. This probably means the request was duplicated somewhere along the line. If you see your changes below, they have been saved by the other request');
sleep(3);
// Give the other one time to finish before we load again
// Pretend we are back in step 2
$_POST['attendances_submitted'] = FALSE;
$_SESSION['enter_attendance_token'] = md5(time());
}
}
}
示例15: processView
function processView()
{
if (empty($_POST['personid'])) {
trigger_error("Cannot update persons, no person ID specified", E_USER_WARNING);
return;
}
foreach ($this->_allowedFields as $field) {
if (array_get($_POST, $field, '') == '') {
unset($_POST[$field]);
}
}
if (empty($_POST['date_typeid']) && count(array_intersect(array_keys($_POST), $this->_allowedFields)) == 0) {
add_message("Cannot update; no new values were specified", 'error');
if (!empty($_REQUEST['backto'])) {
parse_str($_REQUEST['backto'], $back);
unset($back['backto']);
redirect($back['view'], $back);
}
return;
}
if (!is_array($_POST['personid'])) {
$_REQUEST['personid'] = array($_REQUEST['personid']);
}
$GLOBALS['system']->includeDBClass('person');
$success = 0;
$GLOBALS['system']->setFriendlyErrors(TRUE);
foreach ($_REQUEST['personid'] as $personid) {
$this->_person = new Person((int) $personid);
foreach ($this->_allowedFields as $field) {
if (isset($_POST[$field])) {
$this->_person->setValue($field, $_POST[$field]);
}
}
if (!empty($_POST['date_typeid'])) {
$params = Person::getDateSubfieldParams();
$dateval = process_widget('date_val', $params['date']);
if (!$dateval) {
trigger_error("Invalid date value; cannot set date field");
return;
}
$this->_person->addDate($dateval, $_POST['date_typeid'], $_POST['date_note']);
}
if ($this->_person->validateFields() && $this->_person->save()) {
$success++;
}
}
if ($success == count($_REQUEST['personid'])) {
add_message('Fields updated for ' . count($_REQUEST['personid']) . ' persons');
} else {
if ($success > 0) {
add_message("Fields updated for {$success} persons; some persons could not be updated");
} else {
add_message('There was a problem updating the fields. Check your selected persons.');
}
}
if (!empty($_REQUEST['backto'])) {
parse_str($_REQUEST['backto'], $back);
unset($back['backto']);
redirect($back['view'], $back);
}
}