本文整理汇总了PHP中getCurrentURL函数的典型用法代码示例。如果您正苦于以下问题:PHP getCurrentURL函数的具体用法?PHP getCurrentURL怎么用?PHP getCurrentURL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getCurrentURL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initialize
protected function _initialize()
{
header("X-AUTHOR:ITBOYE.COM");
// 获取配置
$this->getConfig();
if (!defined('APP_VERSION')) {
//定义版本
if (defined("APP_DEBUG") && APP_DEBUG) {
define("APP_VERSION", time());
} else {
define("APP_VERSION", C('APP_VERSION'));
}
}
C('SHOW_PAGE_TRACE', false);
//设置不显示trace
$this->refreshWxaccount();
$debug = true;
// $debug = false;
if ($debug) {
$this->getDebugUser();
} else {
$url = getCurrentURL();
$this->getWxuser($url);
}
if (empty($this->userinfo) || $this->userinfo['subscribed'] == 0) {
$this->display("Error:please_subscribe");
exit;
}
$this->assign("userinfo", $this->userinfo);
$this->assign("wxaccount", $this->wxaccount);
//TODO: 商城模板切换
$this->themeType = "style1";
}
示例2: CPerformanceStat
function CPerformanceStat()
{
$this->timer_total = new CTimer();
$this->timer_total->start();
$this->timer_lock = new CTimer();
$this->timer_db = new CTimer();
$this->timer_include = new CTimer();
$this->request_url = getCurrentURL();
}
示例3: addTechnorati
function addTechnorati()
{
$title = urlencode($title);
$docUrl = urlencode(getCurrentURL());
$url = "http://www.technorati.com/faves?add={$docUrl}";
$image = loader::load("image");
$bookmarkimage = $image->displayImageWithAlt("technorati.png", "Bookmark this page on StumbleUpon", null, null, $url, "_blank", true);
return $bookmarkimage;
}
示例4: getAbsoluteStartPage
function getAbsoluteStartPage()
{
global $us;
$urlParts = getCurrentURL();
$parts = parse_url($us->getProperty('badgerStartPage'));
$urlParts['path'] = BADGER_ROOT . '/' . $parts['path'];
if (isset($parts['query'])) {
$urlParts['query'] = $parts['query'];
} else {
unset($urlParts['query']);
}
if (isset($parts['fragment'])) {
$urlParts['fragment'] = $parts['fragment'];
} else {
unset($urlParts['fragment']);
}
return buildURL($urlParts);
}
示例5: _initialize
protected function _initialize()
{
parent::_initialize();
C('SHOW_PAGE_TRACE', false);
$this->refreshWxaccount();
$debug = false;
if ($debug) {
// $this->getDebugUser();
} else {
$url = getCurrentURL();
$this->getWxuser($url);
}
if (empty($this->userinfo)) {
$this->error("无法获取到用户信息!");
exit;
}
$this->getCurrentUser();
$this->assign("userinfo", $this->userinfo);
$this->perUserMaxTicket = 2;
//每天$perUserMaxTicket票同一ip
$this->assign("perUserMaxTicket", $this->perUserMaxTicket);
$this->group = I('get.group', 0);
$this->assign("group", $this->group);
}
示例6: pay
/**
* 微信支付页面
*/
public function pay()
{
//订单ID
$ids = I('get.id', 0);
//
$ids = rtrim($ids, "-");
$ids_arr = explode("-", $ids);
if (count($ids_arr) == 0) {
$this->error("参数错误!");
}
$map = array();
$map['id'] = array('in', $ids_arr);
$result = apiCall(OrdersInfoViewApi::QUERY_NO_PAGING, array($map));
//TODO: 判断订单状态是否为待支付
// dump($result['status']);
if ($result['status']) {
$order_list = $result['info'];
$payConfig = C('WXPAY_CONFIG');
$payConfig['jsapicallurl'] = getCurrentURL();
//dump($payConfig);
addWeixinLog($payConfig, "配置信息");
$items = array();
$total_fee = 0;
$total_express = 0.0;
$body = "";
$attach = "";
foreach ($order_list as $order) {
$trade_no = $order['orderid'];
$total_fee += $order['price'];
$order_express = 0;
$products = $this->getProducts($order[id]);
foreach ($products as $vo) {
if ($order_express < $vo['post_price']) {
$order_express = $vo['post_price'];
}
if (empty($body)) {
$body = $vo['name'];
}
}
$total_express += $order_express;
$attach .= $order['id'] . '_';
array_push($items, $item);
}
$dnotNeedPostPrice = C('DNOT_NEED_POST_PRICE');
$dnotNeedPostPrice = floatval($dnotNeedPostPrice);
if (floatval($total_fee) >= $dnotNeedPostPrice * 100.0) {
$total_express = 0;
}
// dump($total_fee);
// dump($total_express);
$total_fee = $total_fee + $total_express;
if ($total_fee <= 0) {
$this->error("支付金额不能小于0!");
}
if (APP_DEBUG) {
// $total_fee = 1;
}
if (empty($body)) {
$body = date("Y-m-d", time()) . "购买商品";
}
$body = mb_substr($body, 0, 31, 'utf-8');
//测试时
$this->setWxpayConfig($payConfig, $trade_no, $body, $total_fee, $attach);
//dump($payConfig);
$this->assign("total_express", $total_express);
$this->assign("ids", I('get.id', 0));
$this->assign("total_fee", $total_fee);
$this->theme($this->themeType)->display();
} else {
$this->error("支付失败!");
}
}
示例7: isset
if ($userPass->inputNewPassword == $adminPass->inputNewPassword) {
$error .= $locale['074'] . "<br /><br />\n";
$error_pass = "1";
}
$email = isset($_POST['email']) ? stripinput(trim($_POST['email'])) : "";
if ($email == "") {
$error .= $locale['076b'] . "<br /><br />\n";
$error_mail = "1";
} elseif (!preg_match("/^[-0-9A-Z_\\.]{1,50}@([-0-9A-Z_\\.]+\\.){1,50}([0-9A-Z]){2,4}\$/i", $email)) {
$error .= $locale['076'] . "<br /><br />\n";
$error_mail = "1";
}
$rows = dbrows(dbquery("SELECT user_id FROM " . $db_prefix . "users"));
if ($error == "") {
if ($rows == 0) {
$siteurl = getCurrentURL();
$url = parse_url($siteurl);
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('sitename', 'PHP-Fusion Powered Website')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('siteurl', '" . $siteurl . "')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('site_protocol', '" . $url['scheme'] . "')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('site_host', '" . $url['host'] . "')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('site_port', '" . (isset($url['port']) ? $url['port'] : "") . "')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('site_path', '" . (isset($url['path']) ? $url['path'] : "") . "')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('sitebanner', 'images/php-fusion-logo.png')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('sitebanner1', '')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('sitebanner2', '')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('siteemail', '" . $email . "')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('siteusername', '" . $username . "')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('siteintro', '<div style=\\'text-align:center\\'>" . $locale['230'] . "</div>')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('description', '')");
$result = dbquery("INSERT INTO " . $db_prefix . "settings (settings_name, settings_value) VALUES ('keywords', '')");
示例8: displayForm
function displayForm($formframe, $entry = "", $mainform = "", $done_dest = "", $button_text = "", $settings = "", $titleOverride = "", $overrideValue = "", $overrideMulti = "", $overrideSubMulti = "", $viewallforms = 0, $profileForm = 0, $printall = 0, $screen = null)
{
include_once XOOPS_ROOT_PATH . '/modules/formulize/include/functions.php';
include_once XOOPS_ROOT_PATH . '/modules/formulize/include/extract.php';
formulize_benchmark("Start of formDisplay.");
if ($titleOverride == "formElementsOnly") {
$titleOverride = "all";
$formElementsOnly = true;
}
if (!is_numeric($titleOverride) and $titleOverride != "" and $titleOverride != "all") {
// we can pass in a text title for the form, and that will cause the $titleOverride "all" behaviour to be invoked, and meanwhile we will use this title for the top of the form
$passedInTitle = $titleOverride;
$titleOverride = "all";
}
//syntax:
//displayform($formframe, $entry, $mainform)
//$formframe is the id of the form OR title of the form OR name of the framework. Can also be an array. If it is an array, then flag 'formframe' is the $formframe variable, and flag 'elements' is an array of all the elements that are to be displayed.
//the array option is intended for displaying only part of a form at a time
//$entry is the numeric entry to display in the form -- if $entry is the word 'proxy' then it is meant to force a new form entry when the form is a single-entry form that the user already may have an entry in
//$mainform is the starting form to use, if this is a framework (can be specified by form id or by handle)
//$done_dest is the URL to go to after the form has been submitted
//Steps:
//1. identify form or framework
//2. if framework, check for unified display options
//3. if entry specified, then get data for that entry
//4. drawform with data if necessary
global $xoopsDB, $xoopsUser, $myts;
global $sfidsDrawn;
if (!is_array($sfidsDrawn)) {
$sfidsDrawn = array();
}
$groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS);
$original_entry = $entry;
// flag used to tell whether the function was called with an actual entry specified, ie: we're supposed to be editing this entry, versus the entry being set by coming back form a sub_form or other situation.
$mid = getFormulizeModId();
$currentURL = getCurrentURL();
/* Alter currentURL if necessary.
* Display list of entries screen on-click of form buttons "Save and Leave" and "Leave Page".
*/
if (isset($_GET['sid'])) {
$curr_screen = xoops_getmodulehandler('screen', 'formulize')->get($_GET['sid']);
if ($curr_screen->getVar('type') == 'form') {
$currentURL = $_SERVER['PHP_SELF'] . "?fid=" . $curr_screen->form_id();
}
} elseif (isset($_GET['ve']) && isset($_GET['fid'])) {
$currentURL = $_SERVER['PHP_SELF'] . "?fid=" . $_GET['fid'];
}
// identify form or framework
$elements_allowed = "";
// if a screen object is passed in, select the elements for display based on the screen's settings
if ($screen and is_a($screen, "formulizeFormScreen")) {
$elements_allowed = $screen->getVar("formelements");
}
if (is_array($formframe)) {
$elements_allowed = $formframe['elements'];
$printViewPages = isset($formframe['pages']) ? $formframe['pages'] : "";
$printViewPageTitles = isset($formframe['pagetitles']) ? $formframe['pagetitles'] : "";
$formframetemp = $formframe['formframe'];
unset($formframe);
$formframe = $formframetemp;
}
list($fid, $frid) = getFormFramework($formframe, $mainform);
if ($_POST['deletesubsflag']) {
// if deletion of sub entries requested
foreach ($_POST as $k => $v) {
if (strstr($k, "delbox")) {
$subs_to_del[] = $v;
}
}
if (count($subs_to_del) > 0) {
deleteFormEntries($subs_to_del, intval($_POST['deletesubsflag']));
// deletesubsflag will be the sub form id
sendNotifications($_POST['deletesubsflag'], "delete_entry", $subs_to_del, $mid, $groups);
}
}
if ($_POST['parent_form']) {
// if we're coming back from a subform
$entry = $_POST['parent_entry'];
$fid = $_POST['parent_form'];
}
if ($_POST['go_back_form']) {
// we just received a subform submission
$entry = $_POST['sub_submitted'];
$fid = $_POST['sub_fid'];
$go_back['form'] = $_POST['go_back_form'];
$go_back['entry'] = $_POST['go_back_entry'];
}
// set $entry in the case of a form_submission where we were editing an entry (just in case that entry is not what is used to call this function in the first place -- ie: we're on a subform and the mainform has no entry specified, or we're clicking submit over again on a single-entry form where we started with no entry)
$entrykey = "entry" . $fid;
if ((!$entry or $entry == "proxy") and $_POST[$entrykey]) {
// $entrykey will only be set when *editing* an entry, not on new saves
$entry = $_POST[$entrykey];
}
// this is probably not necessary any more, due to architecture changes in Formulize 3
// formulize_newEntryIds is set when saving data
if (!$entry and isset($GLOBALS['formulize_newEntryIds'][$fid])) {
$entry = $GLOBALS['formulize_newEntryIds'][$fid][0];
}
$member_handler =& xoops_gethandler('member');
$gperm_handler =& xoops_gethandler('groupperm');
//.........这里部分代码省略.........
示例9: constructElement
function constructElement($form_ele_id, $ele_value, $entry, $isDisabled = false, $screen = null)
{
if (strstr(getCurrentURL(), "printview.php")) {
$isDisabled = true;
// disabled all elements if we're on the printable view
}
global $xoopsUser, $xoopsModuleConfig, $separ, $myts;
$myts =& MyTextSanitizer::getInstance();
// $form_ele_id contains the ele_id of the current link select box, but we have to remove "ele_" from the front of it.
//print "form_ele_id: $form_ele_id<br>"; // debug code
if (strstr($form_ele_id, "de_")) {
// display element uses a slightly different element name so it can be distinguished on subsequent page load from regular elements...THIS IS NOT TRUE/NECESSARY ANYMORE SINCE FORMULIZE 3, WHERE ALL ELEMENTS ARE DISPLAY ELEMENTS
$true_ele_id = str_replace("de_" . $this->_ele->getVar('id_form') . "_" . $entry . "_", "", $form_ele_id);
$displayElementInEffect = true;
} else {
$true_ele_id = str_replace("ele_", "", $form_ele_id);
$displayElementInEffect = false;
}
// added July 6 2005.
if (!$xoopsModuleConfig['delimeter']) {
// assume that we're accessing a form from outside the Formulize module, therefore the Formulize delimiter setting is not available, so we have to query for it directly.
global $xoopsDB;
$delimq = q("SELECT conf_value FROM " . $xoopsDB->prefix("config") . ", " . $xoopsDB->prefix("modules") . " WHERE " . $xoopsDB->prefix("modules") . ".mid=" . $xoopsDB->prefix("config") . ".conf_modid AND " . $xoopsDB->prefix("modules") . ".dirname=\"formulize\" AND " . $xoopsDB->prefix("config") . ".conf_name=\"delimeter\"");
$delimSetting = $delimq[0]['conf_value'];
} else {
$delimSetting = $xoopsModuleConfig['delimeter'];
}
$customElementHasData = false;
$id_form = $this->_ele->getVar('id_form');
$ele_caption = $this->_ele->getVar('ele_caption', 'e');
$ele_caption = preg_replace('/\\{SEPAR\\}/', '', $ele_caption);
// $ele_caption = stripslashes($ele_caption);
// next line commented out to accomodate passing of ele_value from index.php
// $ele_value = $this->_ele->getVar('ele_value');
$ele_type = $this->_ele->getVar('ele_type');
// call the text sanitizer, first try to convert HTML chars, and if there were no conversions, then do a textarea conversion to automatically make links clickable
$ele_caption = trans($ele_caption);
$htmlCaption = htmlspecialchars_decode($myts->undoHtmlSpecialChars($ele_caption));
// do twice, because we need to handle &lt; and other stupid stuff...do first time through XOOPS myts just because it might be doing a couple extra things that are useful...can probably just use PHP's own filter twice, not too big a deal
if ($htmlCaption == $ele_caption) {
$ele_caption = $myts->displayTarea($ele_caption);
} else {
$ele_caption = $htmlCaption;
}
$ele_caption = $this->formulize_replaceCurlyBracketVariables($ele_caption, $entry, $id_form);
// ele_desc added June 6 2006 -- jwe
$ele_desc = $this->_ele->getVar('ele_desc', "f");
// the f causes no stupid reformatting by the ICMS core to take place
// determine the entry owner
if ($entry != "new") {
$owner = getEntryOwner($entry, $id_form);
} else {
$owner = $xoopsUser ? $xoopsUser->getVar('uid') : 0;
}
// setup the previous entry UI if necessary -- this is an option that can be specified for certain screens
$previousEntryUI = "";
if ($screen and $ele_type != "derived") {
if ($screen->getVar('paraentryform') > 0) {
$previousEntryUI = $this->formulize_setupPreviousEntryUI($screen, $true_ele_id, $ele_type, $owner, $displayElementInEffect, $entry, $this->_ele->getVar('ele_handle'), $this->_ele->getVar('id_form'));
}
}
$form_handler = xoops_getmodulehandler('forms', 'formulize');
$formObject = $form_handler->get($id_form);
switch ($ele_type) {
case 'derived':
if ($entry != "new") {
$form_ele = new xoopsFormLabel($this->_ele->getVar('ele_caption'), formulize_numberFormat($ele_value[5], $this->_ele->getVar('ele_handle')));
$form_ele->setDescription(html_entity_decode($ele_desc, ENT_QUOTES));
} else {
$form_ele = new xoopsFormLabel($this->_ele->getVar('ele_caption'), _formulize_VALUE_WILL_BE_CALCULATED_AFTER_SAVE);
$form_ele->setDescription(html_entity_decode($ele_desc, ENT_QUOTES));
}
break;
case 'ib':
if (get_magic_quotes_gpc()) {
$ele_value[0] = stripslashes($ele_value[0]);
}
if (trim($ele_value[0]) == "") {
$ele_value[0] = $ele_caption;
}
if (strstr($ele_value[0], "\$value=") or strstr($ele_value[0], "\$value =")) {
$form_id = $id_form;
$entry_id = $entry;
$entryData = $this->formulize_getCachedEntryData($id_form, $entry);
$creation_datetime = display($entryData, "creation_datetime");
$evalResult = eval($ele_value[0]);
if ($evalResult === false) {
$ele_value[0] = _formulize_ERROR_IN_LEFTRIGHT;
} else {
$ele_value[0] = $value;
// value is supposed to be the thing set in the eval'd code
}
}
$ele_value[0] = $this->formulize_replaceCurlyBracketVariables($ele_value[0], $entry, $id_form);
$form_ele = $ele_value;
// an array, item 0 is the contents of the break, item 1 is the class of the table cell (for when the form is table rendered)
break;
case 'text':
$ele_value[2] = stripslashes($ele_value[2]);
// $ele_value[2] = $myts->displayTarea($ele_value[2]); // commented by jwe 12/14/04 so that info displayed for viewing in a form box does not contain HTML formatting
//.........这里部分代码省略.........
示例10: render
function render($ele_value, $caption, $markupName, $isDisabled, $element, $entry_id)
{
$id_form = $element->getVar('id_form');
$ele_value[2] = stripslashes($ele_value[2]);
$ele_value[2] = getTextboxDefault($ele_value[2], $id_form, $entry_id);
//if placeholder value is set
if ($ele_value[11]) {
$placeholder = $ele_value[2];
$ele_value[2] = "";
}
if (!strstr(getCurrentURL(), "printview.php")) {
// nmc 2007.03.24 - added
$form_ele = new XoopsFormText($caption, $markupName, $ele_value[0], $ele_value[1], $ele_value[2]);
} else {
// nmc 2007.03.24 - added
$form_ele = new XoopsFormLabel($caption, $ele_value[2]);
// nmc 2007.03.24 - added
}
//if placeholder value is set
if ($ele_value[11]) {
$form_ele->setExtra("placeholder='" . $placeholder . "'");
}
$ele_value = $element->getVar('ele_value');
return $form_ele;
}
示例11: __getCurrentURL
function __getCurrentURL()
{
return getCurrentURL();
}
示例12: getCurrentURL
<?php
/**
* The template part for displaying the Side Nav.
*
* @package WGI Informer
*/
?>
<?php
/* Get the current url */
$currentURL = getCurrentURL();
/* Get the division this page belongs to */
$page_div = getPageDivision();
/* Load a few pieces of information for a user from their profile */
$user_profile_id = get_current_user_id();
// Get the user ID
$user_profile_division = strtolower(preg_replace('/&/i', 'and', preg_replace('/\\s/i', '-', get_user_meta($user_profile_id, 'division', true))));
// Get the user division, replace "&" with "and", replace space with "-"
$user_profile_photo = get_user_meta($user_profile_id, 'profile_photo', true);
// Get link to photo
$user_profile_data = get_userdata($user_profile_id);
// Get user data
$user_profile_name = $user_profile_data->display_name;
// Get user's name
$user_profile_email = $user_profile_data->user_email;
// Get user's email
?>
<nav id="main-nav" class="side-nav main-navigation" role="navigation">
<div class="side-nav_top <?php
示例13: generateValidationCode
function generateValidationCode($caption, $markupName, $element, $entry_id)
{
$validationCode = array();
$isDisabled = false;
if (strstr(getCurrentURL(), "printview.php")) {
$isDisabled = true;
// disabled all elements if we're on the printable view
}
if ($element->getVar('ele_req') and !$isDisabled) {
$eltname = $markupName;
$eltcaption = $caption;
$eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption);
$eltmsg = str_replace('"', '\\"', stripslashes($eltmsg));
$validationCode[] = "selection = true;\n";
$validationCode[] = "checkboxes = \$('[jquerytag={$eltname}]:checked');\n";
// need to use this made up attribute here, because there is no good way to select the checkboxes using the name or anything else that XOOPS/Impress is giving us!!
$validationCode[] = "if(checkboxes.length == 0) { window.alert(\"{$eltmsg}\");\n \$('[jquerytag={$eltname}]').focus();\n return false;\n }\n";
}
if ($isDisabled) {
$isDisabled = false;
// disabled stuff handled here in element, so don't invoke generic disabled handling below (which is only for textboxes and their variations)
}
return $validationCode;
}
示例14: goBack
function goBack($num = 1)
{
$num = $num + 1;
//Pad number to avoid redirecting to self
if (count($_SESSION['history'] >= $num)) {
$location = '';
for ($i = 0; $i < $num; $i++) {
$location = array_pop($_SESSION['history']);
}
header("Location: " . $location . "\r\n");
} elseif (isLoggedIn()) {
header("Location: " . getCurrentURL($_SESSION['userObj']->start_page) . "\r\n");
} else {
header("Location: " . getCurrentURL('login.php') . "\r\n");
}
exit;
}
示例15: tagManager
function tagManager($form, &$form_state)
{
$team = getCurrentTeam();
$form_state['TID'] = $TID = $team['TID'];
if (teamIsIneligible($TID)) {
drupal_set_message('Your team does not have permission to access this page.', 'error');
drupal_goto($_SERVER['HTTP_REFERER']);
}
$currentURL = getCurrentURL();
// if browser didn't end up here by coming from the current page
if ($currentURL != getAjaxURL() && (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != $currentURL)) {
switchTagEditMode(false);
// be sure to start with just viewing the tags
if (!empty(drupal_get_query_parameters())) {
// clear any other drupal_query_parameters
drupal_goto(parseURLAlias($_SERVER['QUERY_STRING']));
}
}
$markup = "<h1>Team {$team['number']} Outreach Settings</h1>";
$editMode = checkTagEditMode();
// create the wrapper-div used by AJAX
$form['tags'] = array('#prefix' => '<div id="tags-div">', '#suffix' => '</div>');
$tableHeader = '<table><tr><td><div class="help tooltip2"><h2>Outreach Tags</h2><span id="helptext"; class="helptext tooltiptext2">Outreach Tags are used to tag similar outreaches.</span></div></td><td><div align="right">';
$form['tags']['tableHeader'] = array('#markup' => $tableHeader);
// only show edit button if in "view mode" and the user has proper permissions
if (!$editMode && hasPermissionForTeam('manageOutreachTags', $TID)) {
$form['tags']['buttons'] = array('#type' => 'image_button', '#src' => '/images/icons/editWhite.png', '#attributes' => array('class' => array('editIcon')), '#limit_validation_errors' => array(), '#submit' => array('switchTagEditMode'));
}
// finish off the title and buttons table, then start the table for the tags themselves
$tableHeader2 = '</div></td></tr></table>';
$tableHeader2 .= '<table class="infoTable"><tr><th>Tag Name</th>';
if (!$editMode) {
$tableHeader2 .= '<th style="text-align:center">Matched Outreaches</th>';
} else {
$tableHeader2 .= '<th></th><th></th>';
}
$form['tags']['tableHeader2'] = array('#markup' => $tableHeader2);
$tags = dbGetOutreachTagsForTeam($TID);
if (!$editMode) {
// if in "view" mode (aka not acting as a form)
$tableContents = '';
$tableContents .= '</tr>';
if (!empty($tags)) {
foreach ($tags as $OTID => $tagName) {
// display the name
$tableContents .= '<tr><td>' . $tagName . '</td>';
// show the number of matching outreaches (which can be clicked on to search the outreach form by tags)
$numMatched = dbGetOutreachMatchingTags(array($tagName), $TID, true);
// "true" indicates only a count is returned
$tableContents .= "<td style=\"text-align:center\"><a href=\"?q=outreach&tag={$OTID}\">{$numMatched}</a></td></tr>";
}
} else {
$tableContents = '<tr><td colspan="2" style="text-align:center"><em>[None]</em></td></tr>';
}
$form['tags']['tableContents'] = array('#markup' => $tableContents);
} else {
// -------------------------------- in "edit" mode
$i = 0;
if (!empty($tags)) {
foreach ($tags as $OTID => $tagName) {
$i++;
$form['tags']["tagName-{$i}"] = array('#prefix' => '<tr><td colspan="2">', '#type' => 'textfield', '#maxlength' => 50, '#default_value' => $tagName, '#suffix' => '</td>');
$numMatching = dbGetOutreachMatchingTags(array(dbGetTagName($OTID)), $TID, true);
$confirmBoxJS = '';
if ($numMatching > 0) {
$confirmBoxJS = "if(!confirm('This tag matches {$numMatching} outreach(es). Are you sure you want to delete it?')){return false;}";
}
$form['tags']["deleteBttn-{$i}"] = array('#prefix' => "<td><a href=\"?q=deleteTag/{$OTID}/{$TID}\">", '#markup' => "<button onclick=\"{$confirmBoxJS}\" type=\"button\"><img src=\"/images/icons/trashWhite.png\" class=\"trashIcon\"></button>", '#suffix' => '</a></td></tr>');
$form_state["OTID-{$i}"] = $OTID;
}
// end of foreach
}
// end of if
$form_state['numTags'] = $i;
// initialize the 'numNewRows' variable
if (empty($form_state['numNewRows'])) {
$form_state['numNewRows'] = 1;
}
$x;
// PHP is weird and makes you declare a variable before the loop
// create the empty row for creating new tags
for ($x = 1; $x <= $form_state['numNewRows']; $x++) {
// have to be sure to not overwrite anything
// create row to allow entry of a new tag
$form['tags']["newTagName-{$x}"] = array('#prefix' => '<tr><td>', '#type' => 'textfield', '#maxlength' => 50, '#suffix' => '</td>');
// if this is the last row (and not the only row), add a "-" button
if ($form_state['numNewRows'] > 1 && $x == $form_state['numNewRows']) {
$form['tags']["newRemoveBttn-{$x}"] = array('#prefix' => '<td>', '#type' => 'submit', '#submit' => array('removeTagRow'), '#value' => '-', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyTagRows_callback', 'wrapper' => 'tags-div'), '#suffix' => '</td>');
} else {
// add a placeholder instead of the "-" button
$form['tags']["removeBttnPlaceHolder-{$x}"] = array('#markup' => '<td></td>');
}
// if this is the last row, add a "+" button
if ($x == $form_state['numNewRows']) {
$form['tags']["newAddBttn-{$x}"] = array('#prefix' => '<td>', '#type' => 'submit', '#submit' => array('addTagRow'), '#value' => '+', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyTagRows_callback', 'wrapper' => 'tags-div'), '#suffix' => '</td>');
} else {
// add a placeholder instead of the "+" button
$form['tags']["addBttnPlaceHolder-{$x}"] = array('#markup' => '<td></td>');
}
$for['tags']["rowFooter-{$x}"] = array('#markup' => '</tr>');
//.........这里部分代码省略.........