本文整理汇总了PHP中CRM_Core_BAO_File::paperIconAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_File::paperIconAttachment方法的具体用法?PHP CRM_Core_BAO_File::paperIconAttachment怎么用?PHP CRM_Core_BAO_File::paperIconAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_File
的用法示例。
在下文中一共展示了CRM_Core_BAO_File::paperIconAttachment方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDisplayValueCommon
//.........这里部分代码省略.........
$display .= $display ? ', ' . $option[$data] : $option[$data];
}
} else {
$display = CRM_Utils_Array::value($value, $option);
}
break;
case 'Select':
if (is_array($value)) {
$display = NULL;
foreach ($value as $data) {
$display .= $display ? ', ' . $option[$data] : $option[$data];
}
} else {
$display = CRM_Utils_Array::value($value, $option);
}
break;
case 'CheckBox':
case 'AdvMulti-Select':
case 'Multi-Select':
if (is_array($value)) {
$checkedData = $value;
} else {
$checkedData = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($value, 1, -1));
if ($html_type == 'CheckBox') {
$newData = array();
foreach ($checkedData as $v) {
$v = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $v);
$newData[] = $v;
}
$checkedData = $newData;
}
}
$v = array();
foreach ($checkedData as $key => $val) {
$v[] = CRM_Utils_Array::value($val, $option);
}
if (!empty($v)) {
$display = implode(', ', $v);
}
break;
case 'Select Date':
if (is_array($value)) {
foreach ($value as $key => $val) {
$display[$key] = CRM_Utils_Date::customFormat($val);
}
} else {
// remove time element display if time is not set
if (empty($option['attributes']['time_format'])) {
$value = substr($value, 0, 10);
}
$display = CRM_Utils_Date::customFormat($value);
}
break;
case 'Select State/Province':
case 'Multi-Select State/Province':
case 'Select Country':
case 'Multi-Select Country':
if (strstr($html_type, 'State/Province')) {
$option = CRM_Core_PseudoConstant::stateProvince(FALSE, FALSE);
} else {
$option = CRM_Core_PseudoConstant::country(FALSE, FALSE);
}
// process multi-select state/country field values
if (!is_array($value)) {
$value = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
}
$display = NULL;
foreach ($value as $data) {
$display .= $display && !empty($option[$data]) ? ', ' . $option[$data] : $option[$data];
}
break;
case 'File':
// In the context of displaying a profile, show file/image
if ($contactID && $value) {
$url = self::getFileURL($contactID, $fieldID, $value);
if ($url) {
$display = $url['file_url'];
}
} elseif ($value) {
$icons = CRM_Core_BAO_File::paperIconAttachment('*', $value);
$display = $icons[$value];
}
break;
case 'TextArea':
if (empty($value)) {
$display = '';
} else {
$display = is_array($value) ? nl2br(implode(', ', $value)) : nl2br($value);
}
break;
case 'Link':
case 'Text':
if (empty($value)) {
$display = '';
} else {
$display = is_array($value) ? implode(', ', $value) : $value;
}
}
return $display ? $display : $value;
}
示例2: buildNoteTree
/**
* Recursive function to get all descendent notes of the note with given ID.
*
* @param int $parentId
* ID of the note to start from.
* @param int $maxDepth
* Maximum number of levels to descend into the tree; if not given, will include all descendents.
* @param bool $snippet
* If TRUE, returned values will be pre-formatted for display in a table of notes.
* @param array $tree
* (Reference) Variable to store all found descendents.
* @param int $depth
* Depth of current iteration within the descendent tree (used for comparison against maxDepth).
*
* @return array
* Nested associative array beginning with direct children of given note.
*/
private static function buildNoteTree($parentId, $maxDepth = 0, $snippet = FALSE, &$tree = array(), $depth = 0)
{
if ($maxDepth && $depth > $maxDepth) {
return FALSE;
}
// get direct children of given parentId note
$note = new CRM_Core_DAO_Note();
$note->entity_table = 'civicrm_note';
$note->entity_id = $parentId;
$note->orderBy('modified_date asc');
$note->find();
while ($note->fetch()) {
// foreach child, call this function, unless the child is private/hidden
if (!self::getNotePrivacyHidden($note)) {
CRM_Core_DAO::storeValues($note, $tree[$note->id]);
// get name of user that created this note
$contact = new CRM_Contact_DAO_Contact();
$createdById = $note->contact_id;
$contact->id = $createdById;
$contact->find();
$contact->fetch();
$tree[$note->id]['createdBy'] = $contact->display_name;
$tree[$note->id]['createdById'] = $createdById;
$tree[$note->id]['modified_date'] = CRM_Utils_Date::customFormat($tree[$note->id]['modified_date']);
// paper icon view for attachments part
$paperIconAttachmentInfo = CRM_Core_BAO_File::paperIconAttachment('civicrm_note', $note->id);
$tree[$note->id]['attachment'] = $paperIconAttachmentInfo ? implode('', $paperIconAttachmentInfo) : '';
if ($snippet) {
$tree[$note->id]['note'] = nl2br($tree[$note->id]['note']);
$tree[$note->id]['note'] = smarty_modifier_mb_truncate($tree[$note->id]['note'], 80, '...', TRUE);
CRM_Utils_Date::customFormat($tree[$note->id]['modified_date']);
}
self::buildNoteTree($note->id, $maxDepth, $snippet, $tree[$note->id]['child'], $depth + 1);
}
}
return $tree;
}
示例3: array
/**
* Return an array of all custom values associated with an entity.
*
* @param int $entityID Identification number of the entity
* @param string $entityType Type of entity that the entityID corresponds to, specified
* as a string with format "'<EntityName>'". Comma separated
* list may be used to specify OR matches. Allowable values
* are enumerated types in civicrm_custom_group.extends field.
* Optional. Default value assumes entityID references a
* contact entity.
* @param array $fieldIDs optional list of fieldIDs that we want to retrieve. If this
* is set the entityType is ignored
*
* @return array $fields Array of custom values for the entity with key=>value
* pairs specified as civicrm_custom_field.id => custom value.
* Empty array if no custom values found.
* @access public
* @static
*/
public static function &getEntityValues($entityID, $entityType = NULL, $fieldIDs = NULL, $formatMultiRecordField = FALSE)
{
if (!$entityID) {
// adding this here since an empty contact id could have serious repurcussions
// like looping forever
CRM_Core_Error::fatal('Please file an issue with the backtrace');
return NULL;
}
$cond = array();
if ($entityType) {
$cond[] = "cg.extends IN ( '{$entityType}' )";
}
if ($fieldIDs && is_array($fieldIDs)) {
$fieldIDList = implode(',', $fieldIDs);
$cond[] = "cf.id IN ( {$fieldIDList} )";
}
if (empty($cond)) {
$cond[] = "cg.extends IN ( 'Contact', 'Individual', 'Household', 'Organization' )";
}
$cond = implode(' AND ', $cond);
// first find all the fields that extend this type of entity
$query = "\nSELECT cg.table_name,\n cg.id as groupID,\n cg.is_multiple,\n cf.column_name,\n cf.id as fieldID,\n cf.data_type as fieldDataType\nFROM civicrm_custom_group cg,\n civicrm_custom_field cf\nWHERE cf.custom_group_id = cg.id\nAND cg.is_active = 1\nAND cf.is_active = 1\nAND {$cond}\n";
$dao = CRM_Core_DAO::executeQuery($query);
$select = $fields = $isMultiple = array();
while ($dao->fetch()) {
if (!array_key_exists($dao->table_name, $select)) {
$fields[$dao->table_name] = array();
$select[$dao->table_name] = array();
}
$fields[$dao->table_name][] = $dao->fieldID;
$select[$dao->table_name][] = "{$dao->column_name} AS custom_{$dao->fieldID}";
$isMultiple[$dao->table_name] = $dao->is_multiple ? TRUE : FALSE;
$file[$dao->table_name][$dao->fieldID] = $dao->fieldDataType;
}
$result = array();
foreach ($select as $tableName => $clauses) {
$query = "SELECT id, " . implode(', ', $clauses) . " FROM {$tableName} WHERE entity_id = {$entityID}";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
foreach ($fields[$tableName] as $fieldID) {
$fieldName = "custom_{$fieldID}";
if ($isMultiple[$tableName]) {
if ($formatMultiRecordField) {
if ($file[$tableName][$fieldID] == 'File') {
if ($fileid = $dao->{$fieldName}) {
$fileurl = CRM_Core_BAO_File::paperIconAttachment($tableName, $entityID);
$result["{$dao->id}"]["{$fieldID}"] = $fileurl[$dao->{$fieldName}];
}
} else {
$result["{$dao->id}"]["{$fieldID}"] = $dao->{$fieldName};
}
} else {
$result["{$fieldID}_{$dao->id}"] = $dao->{$fieldName};
}
} else {
if ($file[$tableName][$fieldID] == 'File') {
if ($fileid = $dao->{$fieldName}) {
$fileurl = CRM_Core_BAO_File::paperIconAttachment($tableName, $entityID);
$result[$fieldID] = $fileurl[$dao->{$fieldName}];
}
} else {
$result[$fieldID] = $dao->{$fieldName};
}
}
}
}
}
return $result;
}
示例4: getDisplayValueCommon
//.........这里部分代码省略.........
foreach ($checkedData as $key => $val) {
if ($html_type == 'CheckBox') {
if ($val) {
$p[] = $key;
$v[] = CRM_Utils_Array::value($key, $option);
}
} else {
$p[] = $val;
$v[] = CRM_Utils_Array::value($val, $option);
}
}
if (!empty($v)) {
$display = implode(', ', $v);
}
break;
case 'Select Date':
if (is_array($value)) {
foreach ($value as $key => $val) {
$display[$key] = CRM_Utils_Date::customFormat($val);
}
} else {
// remove time element display if time is not set
if (empty($option['attributes']['time_format'])) {
$value = substr($value, 0, 10);
}
$display = CRM_Utils_Date::customFormat($value);
}
break;
case 'Select State/Province':
if (empty($value)) {
$display = '';
} else {
$display = CRM_Core_PseudoConstant::stateProvince($value);
}
break;
case 'Multi-Select State/Province':
if (is_array($value)) {
$checkedData = $value;
} else {
$checkedData = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($value, 1, -1));
}
$states = CRM_Core_PseudoConstant::stateProvince();
$display = NULL;
foreach ($checkedData as $stateID) {
if ($display) {
$display .= ', ';
}
$display .= $states[$stateID];
}
break;
case 'Select Country':
if (empty($value)) {
$display = '';
} else {
$display = CRM_Core_PseudoConstant::country($value);
}
break;
case 'Multi-Select Country':
if (is_array($value)) {
$checkedData = $value;
} else {
$checkedData = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($value, 1, -1));
}
$countries = CRM_Core_PseudoConstant::country();
$display = NULL;
foreach ($checkedData as $countryID) {
if ($display) {
$display .= ', ';
}
$display .= $countries[$countryID];
}
break;
case 'File':
// In the context of displaying a profile, show file/image
if ($contactID && $value) {
$url = self::getFileURL($contactID, $fieldID, $value);
if ($url) {
$display = $url['file_url'];
}
} elseif ($value) {
$icons = CRM_Core_BAO_File::paperIconAttachment('*', $value);
$display = $icons[$value];
}
break;
case 'TextArea':
if (empty($value)) {
$display = '';
} else {
$display = nl2br($value);
}
break;
case 'Link':
if (empty($value)) {
$display = '';
} else {
$display = $value;
}
}
return $display ? $display : $value;
}
示例5: formatDisplayValue
/**
* Lower-level logic for rendering a custom field value
*
* @param string|array $value
* @param array $field
* @param int|null $entityId
*
* @return string
*/
private static function formatDisplayValue($value, $field, $entityId = NULL)
{
if (self::isSerialized($field) && !is_array($value)) {
$value = CRM_Utils_Array::explodePadded($value);
}
// CRM-12989 fix
if ($field['html_type'] == 'CheckBox') {
CRM_Utils_Array::formatArrayKeys($value);
}
$display = is_array($value) ? implode(', ', $value) : (string) $value;
switch ($field['html_type']) {
case 'Select':
case 'Autocomplete-Select':
case 'Radio':
case 'Select Country':
case 'Select State/Province':
case 'CheckBox':
case 'AdvMulti-Select':
case 'Multi-Select':
case 'Multi-Select State/Province':
case 'Multi-Select Country':
if ($field['data_type'] == 'ContactReference' && $value) {
$display = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'display_name');
} elseif (is_array($value)) {
$v = array();
foreach ($value as $key => $val) {
$v[] = CRM_Utils_Array::value($val, $field['options']);
}
$display = implode(', ', $v);
} else {
$display = CRM_Utils_Array::value($value, $field['options'], '');
}
break;
case 'Select Date':
$customFormat = NULL;
// FIXME: Are there any legitimate reasons why $value would be an array?
// Or should we throw an exception here if it is?
$value = is_array($value) ? CRM_Utils_Array::first($value) : $value;
$actualPHPFormats = CRM_Core_SelectValues::datePluginToPHPFormats();
$format = CRM_Utils_Array::value('date_format', $field);
if ($format) {
if (array_key_exists($format, $actualPHPFormats)) {
$customTimeFormat = (array) $actualPHPFormats[$format];
switch (CRM_Utils_Array::value('time_format', $field)) {
case 1:
$customTimeFormat[] = 'g:iA';
break;
case 2:
$customTimeFormat[] = 'G:i';
break;
default:
// if time is not selected remove time from value
$value = substr($value, 0, 10);
}
$customFormat = implode(" ", $customTimeFormat);
}
}
$display = CRM_Utils_Date::processDate($value, NULL, FALSE, $customFormat);
break;
case 'File':
// In the context of displaying a profile, show file/image
if ($value) {
if ($entityId) {
$url = self::getFileURL($entityId, $field['id']);
if ($url) {
$display = $url['file_url'];
}
} else {
// In other contexts show a paperclip icon
if (CRM_Utils_Rule::integer($value)) {
$icons = CRM_Core_BAO_File::paperIconAttachment('*', $value);
$display = $icons[$value];
} else {
//CRM-18396, if filename is passed instead
$display = $value;
}
}
}
break;
case 'TextArea':
$display = nl2br($display);
break;
case 'Text':
if ($field['data_type'] == 'Money' && isset($value)) {
//$value can also be an array(while using IN operator from search builder or api).
foreach ((array) $value as $val) {
$disp[] = CRM_Utils_Money::format($val);
}
$display = implode(', ', $disp);
}
break;
//.........这里部分代码省略.........
示例6: summary
/**
* @return array
*/
public function summary()
{
$this->initialize();
$summary = array();
foreach ($this->_partialQueries as $partialQuery) {
/** @var $partialQuery CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery */
$summary[$partialQuery->getName()] = array();
}
// now iterate through the table and add entries to the relevant section
$sql = "SELECT * FROM {$this->_tableName}";
if ($this->_table) {
$sql .= " {$this->toLimit($this->_limitRowClause)} ";
}
$dao = CRM_Core_DAO::executeQuery($sql);
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
$roleIds = CRM_Event_PseudoConstant::participantRole();
while ($dao->fetch()) {
$row = array();
foreach ($this->_tableFields as $name => $dontCare) {
if ($name != 'activity_type_id') {
$row[$name] = $dao->{$name};
} else {
$row['activity_type'] = CRM_Utils_Array::value($dao->{$name}, $activityTypes);
}
}
if (isset($row['participant_role'])) {
$participantRole = explode(CRM_Core_DAO::VALUE_SEPARATOR, $row['participant_role']);
$viewRoles = array();
foreach ($participantRole as $v) {
$viewRoles[] = $roleIds[$v];
}
$row['participant_role'] = implode(', ', $viewRoles);
}
if (!empty($row['file_ids'])) {
$fileIds = explode(',', $row['file_ids']);
$fileHtml = '';
foreach ($fileIds as $fileId) {
$paperclip = CRM_Core_BAO_File::paperIconAttachment('*', $fileId);
if ($paperclip) {
$fileHtml .= implode('', $paperclip);
}
}
$row['fileHtml'] = $fileHtml;
}
$summary[$dao->table_name][] = $row;
}
$summary['Count'] = array();
foreach (array_keys($summary) as $table) {
$summary['Count'][$table] = CRM_Utils_Array::value($table, $this->_foundRows);
if ($summary['Count'][$table] >= self::LIMIT) {
$summary['addShowAllLink'][$table] = TRUE;
} else {
$summary['addShowAllLink'][$table] = FALSE;
}
}
return $summary;
}
示例7: browse
/**
* called when action is browse.
*/
public function browse()
{
$note = new CRM_Core_DAO_Note();
$note->entity_table = 'civicrm_contact';
$note->entity_id = $this->_contactId;
$note->orderBy('modified_date desc');
//CRM-4418, handling edit and delete separately.
$permissions = array($this->_permission);
if ($this->_permission == CRM_Core_Permission::EDIT) {
//previously delete was subset of edit
//so for consistency lets grant delete also.
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$values = array();
$links = self::links();
$action = array_sum(array_keys($links)) & $mask;
$note->find();
while ($note->fetch()) {
if (!CRM_Core_BAO_Note::getNotePrivacyHidden($note)) {
CRM_Core_DAO::storeValues($note, $values[$note->id]);
$values[$note->id]['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $note->id, 'cid' => $this->_contactId), ts('more'), FALSE, 'note.selector.row', 'Note', $note->id);
$contact = new CRM_Contact_DAO_Contact();
$contact->id = $note->contact_id;
$contact->find();
$contact->fetch();
$values[$note->id]['createdBy'] = $contact->display_name;
$values[$note->id]['comment_count'] = CRM_Core_BAO_Note::getChildCount($note->id);
// paper icon view for attachments part
$paperIconAttachmentInfo = CRM_Core_BAO_File::paperIconAttachment('civicrm_note', $note->id);
$values[$note->id]['attachment'] = $paperIconAttachmentInfo;
}
}
$this->assign('notes', $values);
$commentLinks = self::commentLinks();
$action = array_sum(array_keys($commentLinks)) & $mask;
$commentAction = CRM_Core_Action::formLink($commentLinks, $action, array('id' => $note->id, 'pid' => $note->entity_id, 'cid' => $note->entity_id), ts('more'), FALSE, 'note.comment.action', 'Note', $note->id);
$this->assign('commentAction', $commentAction);
$this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('note', $this->_contactId);
}