本文整理汇总了PHP中CRM_Core_Action::replace方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Action::replace方法的具体用法?PHP CRM_Core_Action::replace怎么用?PHP CRM_Core_Action::replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Action
的用法示例。
在下文中一共展示了CRM_Core_Action::replace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildPermissionLinks
/**
* This function return all voter links with respecting permissions.
*
* @param int $surveyId
* @param bool $enclosedInUL
* @param string $extraULName
* @return array|string
* $url array of permissioned links
*/
public static function buildPermissionLinks($surveyId, $enclosedInUL = FALSE, $extraULName = 'more')
{
$menuLinks = array();
if (!$surveyId) {
return $menuLinks;
}
static $voterLinks = array();
if (empty($voterLinks)) {
$permissioned = FALSE;
if (CRM_Core_Permission::check('manage campaign') || CRM_Core_Permission::check('administer CiviCampaign')) {
$permissioned = TRUE;
}
if ($permissioned || CRM_Core_Permission::check("reserve campaign contacts")) {
$voterLinks['reserve'] = array('name' => 'reserve', 'url' => 'civicrm/survey/search', 'qs' => 'sid=%%id%%&reset=1&op=reserve', 'title' => ts('Reserve Respondents'));
}
if ($permissioned || CRM_Core_Permission::check("interview campaign contacts")) {
$voterLinks['release'] = array('name' => 'interview', 'url' => 'civicrm/survey/search', 'qs' => 'sid=%%id%%&reset=1&op=interview&force=1', 'title' => ts('Interview Respondents'));
}
if ($permissioned || CRM_Core_Permission::check("release campaign contacts")) {
$voterLinks['interview'] = array('name' => 'release', 'url' => 'civicrm/survey/search', 'qs' => 'sid=%%id%%&reset=1&op=release&force=1', 'title' => ts('Release Respondents'));
}
}
if (CRM_Core_Permission::check('access CiviReport')) {
$reportID = self::getReportID($surveyId);
if ($reportID) {
$voterLinks['report'] = array('name' => 'report', 'url' => "civicrm/report/instance/{$reportID}", 'qs' => 'reset=1', 'title' => ts('View Survey Report'));
}
}
$ids = array('id' => $surveyId);
foreach ($voterLinks as $link) {
if (!empty($link['qs']) && !CRM_Utils_System::isNull($link['qs'])) {
$urlPath = CRM_Utils_System::url(CRM_Core_Action::replace($link['url'], $ids), CRM_Core_Action::replace($link['qs'], $ids));
$menuLinks[] = sprintf('<a href="%s" class="action-item crm-hover-button" title="%s">%s</a>', $urlPath, CRM_Utils_Array::value('title', $link), $link['title']);
}
}
if ($enclosedInUL) {
$extraLinksName = strtolower($extraULName);
$allLinks = '';
CRM_Utils_String::append($allLinks, '</li><li>', $menuLinks);
$allLinks = "{$extraULName} <ul id='panel_{$extraLinksName}_xx' class='panel'><li>{$allLinks}</li></ul>";
$menuLinks = "<span class='btn-slide crm-hover-button' id={$extraLinksName}_xx>{$allLinks}</span>";
}
return $menuLinks;
}
示例2: alterDisplay
/**
* Alter display of rows.
*
* Iterate through the rows retrieved via SQL and make changes for display purposes,
* such as rendering contacts as links.
*
* @param array $rows
* Rows generated by SQL, with an array for each row.
*/
public function alterDisplay(&$rows)
{
$entryFound = FALSE;
$activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$viewLinks = FALSE;
$context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'report');
$actUrl = '';
if (CRM_Core_Permission::check('access CiviCRM')) {
$viewLinks = TRUE;
$onHover = ts('View Contact Summary for this Contact');
$onHoverAct = ts('View Activity Record');
}
foreach ($rows as $rowNum => $row) {
// if we have an activity type, format the View Activity link for use in various columns
if ($viewLinks && array_key_exists('civicrm_activity_activity_type_id', $row)) {
// Check for target contact id(s) and use the first contact id in that list for view activity link if found,
// else use source contact id
if (!empty($rows[$rowNum]['civicrm_contact_contact_target_id'])) {
$targets = explode(';', $rows[$rowNum]['civicrm_contact_contact_target_id']);
$cid = $targets[0];
} else {
$cid = $rows[$rowNum]['civicrm_contact_contact_source_id'];
}
$actActionLinks = CRM_Activity_Selector_Activity::actionLinks($row['civicrm_activity_activity_type_id'], CRM_Utils_Array::value('civicrm_activity_source_record_id', $rows[$rowNum]), FALSE, $rows[$rowNum]['civicrm_activity_id']);
$actLinkValues = array('id' => $rows[$rowNum]['civicrm_activity_id'], 'cid' => $cid, 'cxt' => $context);
$actUrl = CRM_Utils_System::url($actActionLinks[CRM_Core_Action::VIEW]['url'], CRM_Core_Action::replace($actActionLinks[CRM_Core_Action::VIEW]['qs'], $actLinkValues), TRUE);
}
if (array_key_exists('civicrm_contact_contact_source', $row)) {
if ($value = $row['civicrm_contact_contact_source_id']) {
if ($viewLinks) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_contact_source_link'] = $url;
$rows[$rowNum]['civicrm_contact_contact_source_hover'] = $onHover;
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_contact_contact_assignee', $row)) {
$assigneeNames = explode(';', $row['civicrm_contact_contact_assignee']);
if ($value = $row['civicrm_contact_contact_assignee_id']) {
$assigneeContactIds = explode(';', $value);
$link = array();
if ($viewLinks) {
foreach ($assigneeContactIds as $id => $value) {
if (isset($value) && isset($assigneeNames[$id])) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$assigneeNames[$id]}</a>";
}
}
$rows[$rowNum]['civicrm_contact_contact_assignee'] = implode('; ', $link);
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_contact_contact_target', $row)) {
$targetNames = explode(';', $row['civicrm_contact_contact_target']);
if ($value = $row['civicrm_contact_contact_target_id']) {
$targetContactIds = explode(';', $value);
$link = array();
if ($viewLinks) {
foreach ($targetContactIds as $id => $value) {
if (isset($value) && isset($targetNames[$id])) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$targetNames[$id]}</a>";
}
}
$rows[$rowNum]['civicrm_contact_contact_target'] = implode('; ', $link);
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_activity_type_id', $row)) {
if ($value = $row['civicrm_activity_activity_type_id']) {
$rows[$rowNum]['civicrm_activity_activity_type_id'] = $activityType[$value];
if ($viewLinks) {
$rows[$rowNum]['civicrm_activity_activity_type_id_link'] = $actUrl;
$rows[$rowNum]['civicrm_activity_activity_type_id_hover'] = $onHoverAct;
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_status_id', $row)) {
if ($value = $row['civicrm_activity_status_id']) {
$rows[$rowNum]['civicrm_activity_status_id'] = $activityStatus[$value];
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_details', $row) && $this->_outputMode == 'html') {
if ($value = $row['civicrm_activity_details']) {
$fullDetails = $rows[$rowNum]['civicrm_activity_details'];
//.........这里部分代码省略.........
示例3: formLink
/**
* given a set of links and a mask, return the html action string for
* the links associated with the mask
*
* @param array $links the set of link items
* @param int $mask the mask to be used. a null mask means all items
* @param array $values the array of values for parameter substitution in the link items
*
* @return string the html string
* @access public
* @static
*/
function formLink(&$links, $mask, $values)
{
$url = array();
foreach ($links as $m => $link) {
if (!$mask || $mask & $m) {
$extra = CRM_Utils_Array::value('extra', $link, '');
$url[] = sprintf('<a href="%s" ' . $extra . '>%s</a>', CRM_Utils_System::url($link['url'], CRM_Core_Action::replace($link['qs'], $values)), $link['name']);
}
}
$result = '';
CRM_Utils_String::append($result, ' | ', $url);
return $result;
}
示例4: alterDisplay
function alterDisplay(&$rows)
{
// custom code to alter rows
$entryFound = FALSE;
$activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$volunteerRoles = CRM_Volunteer_BAO_Need::buildOptions('role_id', 'create');
$viewLinks = FALSE;
$seperator = CRM_CORE_DAO::VALUE_SEPARATOR;
$context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'report');
if (CRM_Core_Permission::check('access CiviCRM')) {
$viewLinks = TRUE;
$onHover = ts('View Contact Summary for this Contact', array('domain' => 'org.civicrm.volunteer'));
$onHoverAct = ts('View Activity Record', array('domain' => 'org.civicrm.volunteer'));
}
foreach ($rows as $rowNum => $row) {
if (array_key_exists('civicrm_contact_contact_source', $row)) {
if ($value = $row['civicrm_activity_assignment_contact_id']) {
if ($viewLinks) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_contact_source_link'] = $url;
$rows[$rowNum]['civicrm_contact_contact_source_hover'] = $onHover;
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_contact_contact_assignee', $row)) {
$assigneeNames = explode($seperator, $row['civicrm_contact_contact_assignee']);
if ($value = $row['civicrm_activity_assignment_contact_id']) {
$assigneeContactIds = explode($seperator, $value);
$link = array();
if ($viewLinks) {
foreach ($assigneeContactIds as $id => $value) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$assigneeNames[$id]}</a>";
}
$rows[$rowNum]['civicrm_contact_contact_assignee'] = implode('; ', $link);
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_contact_contact_target', $row)) {
$targetNames = explode($seperator, $row['civicrm_contact_contact_target']);
if ($value = $row['civicrm_activity_target_contact_id']) {
$targetContactIds = explode($seperator, $value);
$link = array();
if ($viewLinks) {
foreach ($targetContactIds as $id => $value) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$targetNames[$id]}</a>";
}
$rows[$rowNum]['civicrm_contact_contact_target'] = implode('; ', $link);
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_activity_type_id', $row)) {
if ($value = $row['civicrm_activity_activity_type_id']) {
$rows[$rowNum]['civicrm_activity_activity_type_id'] = $activityType[$value];
if ($viewLinks) {
// Check for assignee contact id(s) (since they are the volunteer and use the first contact id in that list for view activity link if found,
// else use source contact id
if (!empty($rows[$rowNum]['civicrm_activity_assignment_contact_id'])) {
$targets = explode($seperator, $rows[$rowNum]['civicrm_activity_assignment_contact_id']);
$cid = $targets[0];
} else {
$cid = $rows[$rowNum]['civicrm_activity_source_contact_id'];
}
$actionLinks = CRM_Activity_Selector_Activity::actionLinks($row['civicrm_activity_activity_type_id'], CRM_Utils_Array::value('civicrm_activity_source_record_id', $rows[$rowNum]), FALSE, $rows[$rowNum]['civicrm_activity_id']);
$linkValues = array('id' => $rows[$rowNum]['civicrm_activity_id'], 'cid' => $cid, 'cxt' => $context);
$url = CRM_Utils_System::url($actionLinks[CRM_Core_Action::VIEW]['url'], CRM_Core_Action::replace($actionLinks[CRM_Core_Action::VIEW]['qs'], $linkValues), TRUE);
$rows[$rowNum]['civicrm_activity_activity_type_id_link'] = $url;
$rows[$rowNum]['civicrm_activity_activity_type_id_hover'] = $onHoverAct;
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_status_id', $row)) {
if ($value = $row['civicrm_activity_status_id']) {
$rows[$rowNum]['civicrm_activity_status_id'] = $activityStatus[$value];
$entryFound = TRUE;
}
}
if (array_key_exists('role_role', $row)) {
if ($value = $row['role_role']) {
$rows[$rowNum]['role_role'] = $volunteerRoles[$value];
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_activity_date_time', $row)) {
$rows[$rowNum]['civicrm_activity_activity_date_time'] = CRM_Utils_Date::customFormat($row['civicrm_activity_activity_date_time']);
// Display overdue marker
if (array_key_exists('civicrm_activity_status_id', $row) && CRM_Utils_Date::overdue($rows[$rowNum]['civicrm_activity_activity_date_time']) && $activityStatus[$row['civicrm_activity_status_id']] != 'Completed') {
$rows[$rowNum]['class'] = "status-overdue";
$entryFound = TRUE;
}
}
$entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'activity', 'List all activities for this ') ? TRUE : $entryFound;
if (!$entryFound) {
break;
//.........这里部分代码省略.........
示例5: buildPermissionLinks
static function buildPermissionLinks($surveyId)
{
$menuLinks = array();
if (!$surveyId) {
return $menuLinks;
}
static $voterLinks = array();
if (empty($voterLinks)) {
require_once 'CRM/Core/Permission.php';
$permissioned = false;
if (CRM_Core_Permission::check('manage campaign') || CRM_Core_Permission::check('administer CiviCampaign')) {
$permissioned = true;
}
if ($permissioned || CRM_Core_Permission::check("reserve campaign contacts")) {
$voterLinks['reserve'] = array('name' => 'reserve', 'url' => 'civicrm/survey/search', 'qs' => 'sid=%%id%%&reset=1&op=reserve&force=1', 'title' => ts('Reserve Respondents'));
}
if ($permissioned || CRM_Core_Permission::check("interview campaign contacts")) {
$voterLinks['release'] = array('name' => 'interview', 'url' => 'civicrm/survey/search', 'qs' => 'sid=%%id%%&reset=1&op=interview&force=1', 'title' => ts('Interview Respondents'));
}
if ($permissioned || CRM_Core_Permission::check("release campaign contacts")) {
$voterLinks['interview'] = array('name' => 'release', 'url' => 'civicrm/survey/search', 'qs' => 'sid=%%id%%&reset=1&op=release&force=1', 'title' => ts('Release Respondents'));
}
}
require_once 'CRM/Core/Action.php';
$ids = array('id' => $surveyId);
foreach ($voterLinks as $link) {
if (CRM_Utils_Array::value('qs', $link) && !CRM_Utils_System::isNull($link['qs'])) {
$urlPath = CRM_Utils_System::url(CRM_Core_Action::replace($link['url'], $ids), CRM_Core_Action::replace($link['qs'], $ids));
$menuLinks[] = sprintf('<a href="%s" class="action-item" title="%s">%s</a>', $urlPath, CRM_Utils_Array::value('title', $link), $link['title']);
}
}
return $menuLinks;
}