本文整理汇总了PHP中CRM_Utils_Array::First方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Array::First方法的具体用法?PHP CRM_Utils_Array::First怎么用?PHP CRM_Utils_Array::First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Array
的用法示例。
在下文中一共展示了CRM_Utils_Array::First方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportCustom
/**
* @param $customSearchClass
* @param $formValues
* @param $order
*/
public static function exportCustom($customSearchClass, $formValues, $order)
{
$ext = CRM_Extension_System::singleton()->getMapper();
if (!$ext->isExtensionClass($customSearchClass)) {
require_once str_replace('_', DIRECTORY_SEPARATOR, $customSearchClass) . '.php';
} else {
require_once $ext->classToPath($customSearchClass);
}
$search = new $customSearchClass($formValues);
$includeContactIDs = FALSE;
if ($formValues['radio_ts'] == 'ts_sel') {
$includeContactIDs = TRUE;
}
$sql = $search->all(0, 0, $order, $includeContactIDs);
$columns = $search->columns();
$header = array_keys($columns);
$fields = array_values($columns);
$rows = array();
$dao = CRM_Core_DAO::executeQuery($sql);
$alterRow = FALSE;
if (method_exists($search, 'alterRow')) {
$alterRow = TRUE;
}
while ($dao->fetch()) {
$row = array();
foreach ($fields as $field) {
$unqualified_field = CRM_Utils_Array::First(array_slice(explode('.', $field), -1));
$row[$field] = $dao->{$unqualified_field};
}
if ($alterRow) {
$search->alterRow($row);
}
$rows[] = $row;
}
CRM_Core_Report_Excel::writeCSVFile(self::getExportFileName(), $header, $rows);
CRM_Utils_System::civiExit();
}
示例2: array_values
/**
* Returns all the rows in the given offset and rowCount.
*
* @param string $action
* The action being performed.
* @param int $offset
* The row number to start from.
* @param int $rowCount
* The number of rows to return.
* @param string $sort
* The sql string that describes the sort order.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return int
* the total number of rows for this action
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$includeContactIDs = FALSE;
if (($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) && $this->_formValues['radio_ts'] == 'ts_sel') {
$includeContactIDs = TRUE;
}
$sql = $this->_search->all($offset, $rowCount, $sort, $includeContactIDs);
// contact query object used for creating $sql
$contactQueryObj = NULL;
if (method_exists($this->_search, 'getQueryObj') && is_a($this->_search->getQueryObj(), 'CRM_Contact_BAO_Query')) {
$contactQueryObj = $this->_search->getQueryObj();
}
$dao = CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
$columns = $this->_search->columns();
$columnNames = array_values($columns);
$links = self::links($this->_key);
$permissions = array(CRM_Core_Permission::getPermission());
if (CRM_Core_Permission::check('delete contacts')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$alterRow = FALSE;
if (method_exists($this->_customSearchClass, 'alterRow')) {
$alterRow = TRUE;
}
$image = FALSE;
if (is_a($this->_search, 'CRM_Contact_Form_Search_Custom_Basic')) {
$image = TRUE;
}
// process the result of the query
$rows = array();
while ($dao->fetch()) {
$row = array();
$empty = TRUE;
// if contact query object present
// process pseudo constants
if ($contactQueryObj) {
$contactQueryObj->convertToPseudoNames($dao);
}
// the columns we are interested in
foreach ($columnNames as $property) {
// Get part of name after last . (if any)
$unqualified_property = CRM_Utils_Array::First(array_slice(explode('.', $property), -1));
$row[$property] = $dao->{$unqualified_property};
if (!empty($dao->{$unqualified_property})) {
$empty = FALSE;
}
}
if (!$empty) {
$contactID = isset($dao->contact_id) ? $dao->contact_id : NULL;
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $contactID;
$row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $contactID), ts('more'), FALSE, 'contact.custom.actions', 'Contact', $contactID);
$row['contact_id'] = $contactID;
if ($alterRow) {
$this->_search->alterRow($row);
}
if ($image) {
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($dao->contact_sub_type ? $dao->contact_sub_type : $dao->contact_type, FALSE, $contactID);
}
$rows[] = $row;
}
}
$this->buildPrevNextCache($sort);
return $rows;
}