本文整理汇总了PHP中CRM_Utils_String::unstupifyUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_String::unstupifyUrl方法的具体用法?PHP CRM_Utils_String::unstupifyUrl怎么用?PHP CRM_Utils_String::unstupifyUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_String
的用法示例。
在下文中一共展示了CRM_Utils_String::unstupifyUrl方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultValues
/**
* Set default values for the form.
*
* Note that in edit/view mode the default values are retrieved from the database
*/
public function setDefaultValues()
{
$defaults = $this->_values;
if ($this->_action & CRM_Core_Action::ADD) {
if (array_key_exists('TagsAndGroups', $this->_editOptions)) {
// set group and tag defaults if any
if ($this->_gid) {
$defaults['group'][] = $this->_gid;
}
if ($this->_tid) {
$defaults['tag'][$this->_tid] = 1;
}
}
if ($this->_contactSubType) {
$defaults['contact_sub_type'] = $this->_contactSubType;
}
} else {
foreach ($defaults['email'] as $dontCare => &$val) {
if (isset($val['signature_text'])) {
$val['signature_text_hidden'] = $val['signature_text'];
}
if (isset($val['signature_html'])) {
$val['signature_html_hidden'] = $val['signature_html'];
}
}
if (!empty($defaults['contact_sub_type'])) {
$defaults['contact_sub_type'] = $this->_oldSubtypes;
}
}
// set defaults for blocks ( custom data, address, communication preference, notes, tags and groups )
foreach ($this->_editOptions as $name => $label) {
if (!in_array($name, array('Address', 'Notes'))) {
$className = 'CRM_Contact_Form_Edit_' . $name;
$className::setDefaultValues($this, $defaults);
}
}
//set address block defaults
CRM_Contact_Form_Edit_Address::setDefaultValues($defaults, $this);
if (!empty($defaults['image_URL'])) {
list($imageWidth, $imageHeight) = getimagesize(CRM_Utils_String::unstupifyUrl($defaults['image_URL']));
list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
$this->assign('imageWidth', $imageWidth);
$this->assign('imageHeight', $imageHeight);
$this->assign('imageThumbWidth', $imageThumbWidth);
$this->assign('imageThumbHeight', $imageThumbHeight);
$this->assign('imageURL', $defaults['image_URL']);
}
//set location type and country to default for each block
$this->blockSetDefaults($defaults);
$this->_preEditValues = $defaults;
return $defaults;
}
示例2: preProcess
/**
* Heart of the viewing process.
*
* The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess()
{
// process url params
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->assign('id', $this->_id);
$qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
//validate the qfKey
if (!CRM_Utils_Rule::qfKey($qfKey)) {
$qfKey = NULL;
}
$this->assign('searchKey', $qfKey);
// retrieve the group contact id, so that we can get contact id
$gcid = CRM_Utils_Request::retrieve('gcid', 'Positive', $this);
if (!$gcid) {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
} else {
$this->_contactId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_GroupContact', $gcid, 'contact_id');
}
if (!$this->_contactId) {
CRM_Core_Error::statusBounce(ts('We could not find a contact id.'), CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
}
// ensure that the id does exist
if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'id') != $this->_contactId) {
CRM_Core_Error::statusBounce(ts('A Contact with that ID does not exist: %1', array(1 => $this->_contactId)), CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
}
$this->assign('contactId', $this->_contactId);
// see if we can get prev/next positions from qfKey
$navContacts = array('prevContactID' => NULL, 'prevContactName' => NULL, 'nextContactID' => NULL, 'nextContactName' => NULL, 'nextPrevError' => 0);
if ($qfKey) {
$pos = CRM_Core_BAO_PrevNextCache::getPositions("civicrm search {$qfKey}", $this->_contactId, $this->_contactId);
$found = FALSE;
if (isset($pos['prev'])) {
$navContacts['prevContactID'] = $pos['prev']['id1'];
$navContacts['prevContactName'] = $pos['prev']['data'];
$found = TRUE;
}
if (isset($pos['next'])) {
$navContacts['nextContactID'] = $pos['next']['id1'];
$navContacts['nextContactName'] = $pos['next']['data'];
$found = TRUE;
}
$context = CRM_Utils_Array::value('context', $_GET);
if (!$found) {
// seems like we did not find any contacts
// maybe due to bug CRM-9096
// however we should account for 1 contact results (which dont have prev next)
if (!$pos['foundEntry']) {
$navContacts['nextPrevError'] = 1;
}
} elseif ($context) {
$this->assign('context', $context);
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Search Results'), 'url' => CRM_Utils_System::url("civicrm/contact/search/{$context}", array('qfKey' => $qfKey)))));
}
}
$this->assign($navContacts);
$path = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('View Contact'), 'url' => $path)));
if ($image_URL = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'image_URL')) {
//CRM-7265 --time being fix.
$config = CRM_Core_Config::singleton();
$image_URL = str_replace('https://', 'http://', $image_URL);
if (Civi::settings()->get('enableSSL')) {
$image_URL = str_replace('http://', 'https://', $image_URL);
}
list($imageWidth, $imageHeight) = getimagesize(CRM_Utils_String::unstupifyUrl($image_URL));
list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
$this->assign("imageWidth", $imageWidth);
$this->assign("imageHeight", $imageHeight);
$this->assign("imageThumbWidth", $imageThumbWidth);
$this->assign("imageThumbHeight", $imageThumbHeight);
$this->assign("imageURL", $image_URL);
}
// also store in session for future use
$session = CRM_Core_Session::singleton();
$session->set('view.id', $this->_contactId);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->assign('action', $this->_action);
// check logged in user permission
self::checkUserPermission($this);
list($displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl) = self::getContactDetails($this->_contactId);
$this->assign('displayName', $displayName);
$this->set('contactType', $contactType);
// note: there could still be multiple subtypes. We just trimming the outer separator.
$this->set('contactSubtype', trim($contactSubtype, CRM_Core_DAO::VALUE_SEPARATOR));
// add to recently viewed block
$isDeleted = (bool) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'is_deleted');
$recentOther = array('imageUrl' => $contactImageUrl, 'subtype' => $contactSubtype, 'isDeleted' => $isDeleted);
if (CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$this->_contactId}");
}
if ($session->get('userID') != $this->_contactId && CRM_Core_Permission::check('delete contacts') && !$isDeleted) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/delete', "reset=1&delete=1&cid={$this->_contactId}");
}
CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactId}"), $this->_contactId, $contactType, $this->_contactId, $displayName, $recentOther);
$this->assign('isDeleted', $isDeleted);
//.........这里部分代码省略.........
示例3: getValues
//.........这里部分代码省略.........
// when sending email, we call the same function to get custom field
// values etc, i.e. emulating a profile
$fieldType = CRM_Utils_Array::value('field_type', $field);
if ($htmlType == 'File') {
$entityId = $cid;
if (!$cid && $fieldType == 'Activity' && !empty($componentWhere[0][2])) {
$entityId = $componentWhere[0][2];
}
$fileURL = CRM_Core_BAO_CustomField::getFileURL($entityId, $cfID, NULL, $absolute, $additionalWhereClause);
$params[$index] = $values[$index] = $fileURL['file_url'];
} else {
$customVal = NULL;
if (isset($dao) && property_exists($dao, 'data_type') && ($dao->data_type == 'Int' || $dao->data_type == 'Boolean')) {
$customVal = (int) $details->{$name};
} elseif (isset($dao) && property_exists($dao, 'data_type') && $dao->data_type == 'Float') {
$customVal = (double) $details->{$name};
} elseif (!CRM_Utils_System::isNull(explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name}))) {
$customVal = $details->{$name};
}
//CRM-4582
if (CRM_Utils_System::isNull($customVal)) {
continue;
}
$params[$index] = $customVal;
$values[$index] = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options);
if ($field['data_type'] == 'ContactReference') {
$params[$index] = $values[$index];
}
if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $cfID, 'is_search_range')) {
$customFieldName = "{$name}_from";
}
}
} elseif ($name == 'image_URL') {
list($width, $height) = getimagesize(CRM_Utils_String::unstupifyUrl($details->{$name}));
list($thumbWidth, $thumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($width, $height);
$image_URL = '<img src="' . $details->{$name} . '" height= ' . $thumbHeight . ' width= ' . $thumbWidth . ' />';
$values[$index] = "<a href='#' onclick='contactImagePopUp(\"{$details->{$name}}\", {$width}, {$height});'>{$image_URL}</a>";
} elseif (in_array($name, array('birth_date', 'deceased_date', 'membership_start_date', 'membership_end_date', 'join_date'))) {
$values[$index] = CRM_Utils_Date::customFormat($details->{$name});
$params[$index] = CRM_Utils_Date::isoToMysql($details->{$name});
} else {
$dao = '';
if ($index == 'Campaign') {
$dao = 'CRM_Campaign_DAO_Campaign';
} elseif ($index == 'Contribution Page') {
$dao = 'CRM_Contribute_DAO_ContributionPage';
}
if ($dao) {
$value = CRM_Core_DAO::getFieldValue($dao, $details->{$name}, 'title');
} else {
$value = $details->{$name};
}
$values[$index] = $value;
}
}
}
} elseif (strpos($name, '-') !== FALSE) {
list($fieldName, $id, $type) = CRM_Utils_System::explode('-', $name, 3);
if (!in_array($fieldName, $multipleFields)) {
if ($id == 'Primary') {
// fix for CRM-1543
// not sure why we'd every use Primary location type id
// we need to fix the source if we are using it
// $locationTypeName = CRM_Contact_BAO_Contact::getPrimaryLocationType( $cid );
$locationTypeName = 1;
} else {
示例4: setDefaultsValues
//.........这里部分代码省略.........
if ($this->_activityId) {
CRM_Core_BAO_UFGroup::setComponentDefaults($activityFields, $this->_activityId, 'Activity', $this->_defaults, TRUE);
}
} else {
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_id, $this->_fields, $this->_defaults, TRUE);
}
}
//set custom field defaults
if ($this->_multiRecordProfile) {
foreach ($this->_multiRecordFields as $key => $field) {
$fieldIds[] = CRM_Core_BAO_CustomField::getKeyID($key);
}
$defaultValues = array();
if ($this->_multiRecord && $this->_multiRecord == CRM_Core_Action::UPDATE) {
$defaultValues = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_id, NULL, $fieldIds, TRUE);
if ($this->_recordExists == TRUE) {
$defaultValues = $defaultValues[$this->_recordId];
} else {
$defaultValues = NULL;
}
}
if (!empty($defaultValues)) {
foreach ($defaultValues as $key => $value) {
$name = "custom_{$key}";
$htmlType = $this->_multiRecordFields[$name]['html_type'];
if ($htmlType != 'File') {
if (isset($value)) {
CRM_Core_BAO_CustomField::setProfileDefaults($key, $name, $this->_defaults, $this->_id, $this->_mode, $value);
} else {
$this->_defaults[$name] = "";
}
}
if ($htmlType == 'File') {
$entityId = $this->_id;
if (CRM_Utils_Array::value('field_type', $field) == 'Activity' && $this->_activityId) {
$entityId = $this->_activityId;
}
$url = CRM_Core_BAO_CustomField::getFileURL($entityId, $key);
if ($url) {
$customFiles[$name]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
$deleteExtra = ts("Are you sure you want to delete attached file?");
$fileId = $url['file_id'];
$deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$entityId}&fid={$key}&action=delete");
$text = ts("Delete Attached File");
$customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&confirmed=1'; else return false;\">{$text}</a>";
// also delete the required rule that we've set on the form element
$this->removeFileRequiredRules($name);
}
}
}
}
} else {
foreach ($this->_fields as $name => $field) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$htmlType = $field['html_type'];
if ((!isset($this->_defaults[$name]) || $htmlType == 'File') && CRM_Utils_Array::value('field_type', $field) != 'Activity') {
CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, $this->_id, $this->_mode);
}
if ($htmlType == 'File') {
$entityId = $this->_id;
if (CRM_Utils_Array::value('field_type', $field) == 'Activity' && $this->_activityId) {
$entityId = $this->_activityId;
}
$url = CRM_Core_BAO_CustomField::getFileURL($entityId, $customFieldID);
if ($url) {
$customFiles[$field['name']]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
$deleteExtra = ts("Are you sure you want to delete attached file?");
$fileId = $url['file_id'];
$deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$entityId}&fid={$customFieldID}&action=delete");
$text = ts("Delete Attached File");
$customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&confirmed=1'; else return false;\">{$text}</a>";
// also delete the required rule that we've set on the form element
$this->removeFileRequiredRules($field['name']);
}
}
}
}
}
if (isset($customFiles)) {
$this->assign('customFiles', $customFiles);
}
if ($this->_multiRecordProfile) {
$this->setDefaults($this->_defaults);
return;
}
if (!empty($this->_defaults['image_URL'])) {
list($imageWidth, $imageHeight) = getimagesize(CRM_Utils_String::unstupifyUrl($this->_defaults['image_URL']));
list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
$this->assign("imageWidth", $imageWidth);
$this->assign("imageHeight", $imageHeight);
$this->assign("imageThumbWidth", $imageThumbWidth);
$this->assign("imageThumbHeight", $imageThumbHeight);
$this->assign("imageURL", $this->_defaults['image_URL']);
$this->removeFileRequiredRules('image_URL');
}
if (array_key_exists('contact_sub_type', $this->_defaults) && !empty($this->_defaults['contact_sub_type'])) {
$this->_defaults['contact_sub_type'] = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($this->_defaults['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR));
}
$this->setDefaults($this->_defaults);
}
示例5: getImageURL
/**
* Return formatted image icon
*
* @param string $imageURL
* Contact's image url
*
* @return string $url
*/
public static function getImageURL($imageURL)
{
// retrieve image name from $imageURL
$imageURL = CRM_Utils_String::unstupifyUrl($imageURL);
parse_str(parse_url($imageURL, PHP_URL_QUERY), $query);
$path = CRM_Core_Config::singleton()->customFileUploadDir . $query['photo'];
$mimeType = 'image/' . strtolower(pathinfo($path, PATHINFO_EXTENSION));
return self::getFileURL($path, $mimeType);
}