当前位置: 首页>>代码示例>>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;未经允许,请勿转载。