當前位置: 首頁>>代碼示例>>PHP>>正文


PHP X2Model::autoPopulateFields方法代碼示例

本文整理匯總了PHP中X2Model::autoPopulateFields方法的典型用法代碼示例。如果您正苦於以下問題:PHP X2Model::autoPopulateFields方法的具體用法?PHP X2Model::autoPopulateFields怎麽用?PHP X2Model::autoPopulateFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在X2Model的用法示例。


在下文中一共展示了X2Model::autoPopulateFields方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionExportModelRecords

 /**
  * An AJAX called function which exports data to a CSV via pagination.
  * This is a generalized version of the Contacts export.
  * @param int $page The page of the data provider to export
  */
 public function actionExportModelRecords($page, $model)
 {
     X2Model::$autoPopulateFields = false;
     $file = $this->safePath($_SESSION['modelExportFile']);
     $staticModel = X2Model::model(str_replace(' ', '', $model));
     $fields = $staticModel->getFields();
     $fp = fopen($file, 'a+');
     // Load data provider based on export criteria
     $excludeHidden = !isset($_GET['includeHidden']) || $_GET['includeHidden'] === 'false';
     if ($page == 0 && $excludeHidden && isset($_SESSION['exportModelCriteria']) && $_SESSION['exportModelCriteria'] instanceof CDbCriteria) {
         // Save hidden condition in criteria
         $hiddenConditions = $staticModel->getHiddenCondition();
         $_SESSION['exportModelCriteria']->addCondition($hiddenConditions);
     }
     $dp = new CActiveDataProvider($model, array('criteria' => isset($_SESSION['exportModelCriteria']) ? $_SESSION['exportModelCriteria'] : array(), 'pagination' => array('pageSize' => 100)));
     // Flip through to the right page.
     $pg = $dp->getPagination();
     $pg->setCurrentPage($page);
     $dp->setPagination($pg);
     $records = $dp->getData();
     $pageCount = $dp->getPagination()->getPageCount();
     // Retrieve specified export delimeter and enclosure
     $delimeter = isset($_GET['delimeter']) ? $_GET['delimeter'] : ',';
     $enclosure = isset($_GET['enclosure']) ? $_GET['enclosure'] : '"';
     // We need to set our data to be human friendly, so loop through all the
     // records and format any date / link / visibility fields.
     foreach ($records as $record) {
         foreach ($fields as $field) {
             $fieldName = $field->fieldName;
             if ($field->type == 'date' || $field->type == 'dateTime') {
                 if (is_numeric($record->{$fieldName})) {
                     $record->{$fieldName} = Formatter::formatLongDateTime($record->{$fieldName});
                 }
             } elseif ($field->type == 'link') {
                 $name = $record->{$fieldName};
                 if (!empty($field->linkType)) {
                     list($name, $id) = Fields::nameAndId($name);
                 }
                 if (!empty($name)) {
                     $record->{$fieldName} = $name;
                 }
             } elseif ($fieldName == 'visibility') {
                 switch ($record->{$fieldName}) {
                     case 0:
                         $record->{$fieldName} = 'Private';
                         break;
                     case 1:
                         $record->{$fieldName} = 'Public';
                         break;
                     case 2:
                         $record->{$fieldName} = 'User\'s Groups';
                         break;
                     default:
                         $record->{$fieldName} = 'Private';
                 }
             }
         }
         // Enforce metadata to ensure accuracy of column order, then export.
         $combinedMeta = array_combine($_SESSION['modelExportMeta'], $_SESSION['modelExportMeta']);
         $recordAttributes = $record->attributes;
         if ($model === 'Actions') {
             // Export descriptions with Actions
             $actionText = $record->actionText;
             if ($actionText) {
                 $actionDescription = $actionText->text;
                 $recordAttributes = array_merge($recordAttributes, array('actionDescription' => $actionDescription));
             }
         }
         if ($_SESSION['includeTags']) {
             $tags = $record->getTags();
             $recordAttributes = array_merge($recordAttributes, array('tags' => implode(',', $tags)));
         }
         $tempAttributes = array_intersect_key($recordAttributes, $combinedMeta);
         $tempAttributes = array_merge($combinedMeta, $tempAttributes);
         fputcsv($fp, $tempAttributes, $delimeter, $enclosure);
     }
     unset($dp);
     fclose($fp);
     if ($page + 1 < $pageCount) {
         echo $page + 1;
     }
 }
開發者ID:xl602,項目名稱:X2CRM,代碼行數:87,代碼來源:AdminController.php

示例2: __construct

 public function __construct($owner = null)
 {
     X2Model::$autoPopulateFields = false;
     parent::__construct($owner);
 }
開發者ID:tymiles003,項目名稱:X2CRM,代碼行數:5,代碼來源:X2GridView.php


注:本文中的X2Model::autoPopulateFields方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。