当前位置: 首页>>代码示例>>PHP>>正文


PHP FileUtil::exportCSV方法代码示例

本文整理汇总了PHP中FileUtil::exportCSV方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::exportCSV方法的具体用法?PHP FileUtil::exportCSV怎么用?PHP FileUtil::exportCSV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileUtil的用法示例。


在下文中一共展示了FileUtil::exportCSV方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: exportaTaula

    /**
     * Exporta els registres de la taula seleccionada a un fitxer csv
     *      
     * 
     * @return void (carrega la plantilla per importar/exportar taules)
     */
    public function exportaTaula() {
        // Security check
        //$this->checkCsrfToken();
        $this->throwForbiddenUnless(SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_ADMIN));
        if ($this->request->isPost()) {
            $taula = $this->request->request->get('taula_exp', false);
        }
        if (is_null($taula)) {
            LogUtil::registerError(__('L\'exportació de dades no és possible. No s\'ha especificat cap taula.'));            
        } else {
            $titlerow = DBUtil::getColumnsArray($taula);
            $datarows = DBUtil::selectObjectArray($taula);

            $date = date('_Ymd_Hi');
            FileUtil::exportCSV($datarows, $titlerow, ';', '"', $taula . $date . '.csv');
        
        }
        // Després de exportCSV no executa aquest redirect
        //return system::redirect(ModUtil::url('Llicencies', 'admin', 'ieTables#tabs-2'));
        $this->redirect(ModUtil::url('llicencies', 'admin', 'ieTables'));
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:27,代码来源:Admin.php

示例2: exporter


//.........这里部分代码省略.........
            $colnames = array();

            //get all user fields
            if (ModUtil::available('Profile')) {
                $userfields = ModUtil::apiFunc('Profile', 'user', 'getallactive');

                foreach ($userfields as $item) {
                    $colnames[] = $item['prop_attribute_name'];
                }
            }

            // title fields
            if ($titles == 1) {
                $titlerow = array('id', 'uname');

                //titles for optional data
                if ($email == 1) {
                    array_push($titlerow, 'email');
                }
                if ($regDate == 1) {
                    array_push($titlerow, 'user_regdate');
                }
                if ($lastLogin == 1) {
                    array_push($titlerow, 'lastlogin');
                }
                if ($groups == 1) {
                    array_push($titlerow, 'groups');
                }

                array_merge($titlerow, $colnames);
            } else {
                $titlerow = array();
            }

            //get all users
            $users = ModUtil::apiFunc($this->name, 'user', 'getAll');

            // get all groups
            $allgroups = ModUtil::apiFunc('Groups', 'user', 'getall');
            $groupnames = array();
            foreach ($allgroups as $groupitem) {
                $groupnames[$groupitem['gid']] = $groupitem['name'];
            }

            // data for csv
            $datarows = array();

            //loop every user gettin user id and username and all user fields and push onto result array.
            foreach ($users as $user) {
                $uservars = UserUtil::getVars($user['uid']);

                $result = array();

                array_push($result, $uservars['uid'], $uservars['uname']);

                //checks for optional data
                if ($email == 1) {
                    array_push($result, $uservars['email']);
                }
                if ($regDate == 1) {
                    array_push($result, $uservars['user_regdate']);
                }
                if ($lastLogin == 1) {
                    array_push($result, $uservars['lastlogin']);
                }

                if ($groups == 1) {
                    $usergroups = ModUtil::apiFunc('Groups', 'user', 'getusergroups',
                                            array('uid'   => $uservars['uid'],
                                                  'clean' => true));

                    $groupstring = "";

                    foreach ($usergroups as $group) {
                        $groupstring .= $groupnames[$group] . chr(124);
                    }

                    $groupstring = rtrim($groupstring, chr(124));


                    array_push($result, $groupstring);
                }

                foreach ($colnames as $colname) {
                    array_push($result, $uservars['__ATTRIBUTES__'][$colname]);
                }

                array_push($datarows, $result);
            }

            //export the csv file
            FileUtil::exportCSV($datarows, $titlerow, $delimiter, '"', $exportFile);
        }

        if (SecurityUtil::checkPermission('Groups::', '::', ACCESS_READ)) {
            $this->view->assign('groups', '1');
        }

        return $this->view->fetch('users_admin_export.tpl');
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:101,代码来源:Admin.php

示例3: exportidslogAction

 /**
  * @Route("/exportidslog")
  *
  * Export ids log.
  *
  * @param Request $request
  *
  * @return Response symfony response object
  *
  * @throws AccessDeniedException Thrown if the user doesn't have admin access to the module
  */
 public function exportidslogAction(Request $request)
 {
     // Security check
     if (!SecurityUtil::checkPermission('ZikulaSecurityCenterModule::', '::', ACCESS_EDIT)) {
         throw new AccessDeniedException();
     }
     // get input values
     $confirmed = (int) $request->request->get('confirmed', isset($args['confirmed']) ? $args['confirmed'] : 0);
     if ($confirmed == 1) {
         // export the titles ?
         $exportTitles = $request->request->get('exportTitles', isset($args['exportTitles']) ? $args['exportTitles'] : null);
         $exportTitles = !isset($exportTitles) || $exportTitles !== '1' ? false : true;
         // name of the exported file
         $exportFile = $request->request->get('exportFile', isset($args['exportFile']) ? $args['exportFile'] : null);
         if (!isset($exportFile) || $exportFile == '') {
             $exportFile = 'idslog.csv';
         }
         if (!strrpos($exportFile, '.csv')) {
             $exportFile .= '.csv';
         }
         // delimeter
         $delimiter = $request->request->get('delimiter', isset($args['delimiter']) ? $args['delimiter'] : null);
         if (!isset($delimiter) || $delimiter == '') {
             $delimiter = 1;
         }
         switch ($delimiter) {
             case 1:
                 $delimiter = ",";
                 break;
             case 2:
                 $delimiter = ";";
                 break;
             case 3:
                 $delimiter = ":";
                 break;
             case 4:
                 $delimiter = chr(9);
         }
         // titles
         if ($exportTitles == 1) {
             $titles = array($this->__('Name'), $this->__('Tag'), $this->__('Value'), $this->__('Page'), $this->__('User Name'), $this->__('IP'), $this->__('Impact'), $this->__('PHPIDS filters used'), $this->__('Date'));
         } else {
             $titles = array();
         }
         // get data
         $item_params = array('sorting' => array('date' => 'DESC'));
         $items = ModUtil::apiFunc('ZikulaSecurityCenterModule', 'admin', 'getAllIntrusions', $item_params);
         $objData = array();
         foreach ($items as $item) {
             $dta = $item->toArray();
             $dta['username'] = $dta['user']['uname'];
             $dta['filters'] = unserialize($dta['filters']);
             $dta['date'] = $dta['date']->format('Y-m-d H:i:s');
             unset($dta['user']);
             $objData[] = $dta;
         }
         $data = array();
         $find = array("\r\n", "\n");
         $replace = array("", "");
         foreach ($objData as $key => $idsdata) {
             $filtersused = '';
             foreach ($objData[$key]['filters'] as $filter) {
                 $filtersused .= $filter['id'] . " ";
             }
             $datarow = array($objData[$key]['name'], $objData[$key]['tag'], htmlspecialchars(str_replace($find, $replace, $objData[$key]['value']), ENT_COMPAT, 'UTF-8', false), htmlspecialchars($objData[$key]['page'], ENT_COMPAT, 'UTF-8', false), $objData[$key]['username'], $objData[$key]['ip'], $objData[$key]['impact'], $filtersused, $objData[$key]['date']);
             array_push($data, $datarow);
         }
         // export the csv file
         \FileUtil::exportCSV($data, $titles, $delimiter, '"', $exportFile);
     }
     // fetch output from template
     return new Response($this->view->fetch('Admin/exportidslog.tpl'));
 }
开发者ID:rmaiwald,项目名称:core,代码行数:84,代码来源:AdminController.php

示例4: exportToCsv

    public function exportToCsv($args){
        $optFields = $args['optFields'];        
        $d = date('_Ymd_Hi') ;
        $filename  = $args['filename'];//="")?$args['filename']:"exportUsers" .  $d. '.csv';
        $delimiter = isset($args['delimiter'])?$args['delimiter'] : ';';
        $titlerow = array();
        $groups = false;
        $titlerow[] ="uname";
        $sql = "SELECT uid, uname";
        foreach ($optFields as $key => $value) {
            if ($value) {
                if ($key != "export_groups") $sql .= ",". $key; 
                // generate CSV header line
                switch ($key) {
                    case "activated" :
                        $titlerow[] ="activated";
                        break;
                    case "email":
                        $titlerow[] ="email";
                        break;
                    case "iw_nom":
                        $titlerow[] ="firstname";
                        break;
                    case "iw_cognom1":
                        $titlerow[] ="lastname1";
                        break;
                    case "iw_cognom2":
                        $titlerow[] ="lastname2";
                        break;
                    case "iw_naixement":
                        $titlerow[] ="birthdate";
                        break;
                    case "iw_sex":
                        $titlerow[] ="gender";
                        break;
                    case "export_groups":
                        $titlerow[] ="in";
                        $groups = true;
                        break;                    
                }
            }
        }
        $sql.= " FROM users, IWusers WHERE uid = iw_uid";
        // Get users info
        $rs = DBUtil::executeSQL($sql);
        $rsm = DBUtil::marshallObjects($rs);
        // Get groups from every user
//        if ($groups) {
        foreach ($rsm as $key => $user){
            if ($groups) {
                // Get all groups
                $rsm[$key]['in'] = UserUtil::getGroupListForUser($user['uid'], "|"); 
            }
            // Remove uid field
            array_splice($rsm[$key], 0, 1);
        }
        $result = array();
        FileUtil::exportCSV($rsm, $titlerow, $delimiter, '"', $filename);
        return true; //$result;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:60,代码来源:Admin.php

示例5: exportGtafEntities

 /**
  * Exporta un csv amb tota la informació de les entitats-gtaf/grups d'entitats-gtaf que té Sirius
  * 
  *
  * @return void Retorna a la funció *gtafEntitiesGest* amb els missatges d'execució
  */
 public function exportGtafEntities() {
     if (!SecurityUtil::checkPermission('Cataleg::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     $case = FormUtil::getPassedValue('case',null,'GET');
     if ($case == 'entities') {
         $taula = 'cataleg_gtafEntities';
         $fitxer = 'exportaGtafEntitats.csv';
     } elseif ($case == 'groups') {
         $taula = 'cataleg_gtafGroups';
         $fitxer = 'exportaGtafGrups.csv';
     } else {
         LogUtil::registerError($this->__('La petició no és vàlida'));
         return system::redirect(ModUtil::url('Cataleg', 'admin', 'gtafEntitiesGest'));
     }
     $titlerow = DBUtil::getColumnsArray($taula);
     $datarows = DBUtil::selectObjectArray($taula);
     FileUtil::exportCSV($datarows, $titlerow, ';', '"', $fitxer);
     return system::redirect(ModUtil::url('Cataleg', 'admin', 'gtafEntitiesGest'));
 }
开发者ID:projectesIF,项目名称:Sirius,代码行数:26,代码来源:Admin.php

示例6: exportidslog


//.........这里部分代码省略.........
        // Security check
        if (!SecurityUtil::checkPermission('SecurityCenter::', '::', ACCESS_EDIT)) {
            return LogUtil::registerPermissionError();
        }

        // get input values
        $confirmed = (int)FormUtil::getPassedValue('confirmed', (isset($args['confirmed']) ? $args['confirmed'] : 0), 'POST');

        if ($confirmed == 1) {

            // export the titles ?
            $exportTitles = FormUtil::getPassedValue('exportTitles', (isset($args['exportTitles']) ? $args['exportTitles'] : null), 'POST');
            $exportTitles = (!isset($exportTitles) || $exportTitles !== '1') ? false : true;

            // name of the exported file
            $exportFile = FormUtil::getPassedValue('exportFile', (isset($args['exportFile']) ? $args['exportFile'] : null), 'POST');
            if (!isset($exportFile) || $exportFile == '') {
                $exportFile = 'idslog.csv';
            }
            if (!strrpos($exportFile, '.csv')) {
                $exportFile .= '.csv';
            }

            // delimeter
            $delimiter = FormUtil::getPassedValue('delimiter', (isset($args['delimiter']) ? $args['delimiter'] : null), 'POST');
            if (!isset($delimiter) || $delimiter == '') {
                $delimiter = 1;
            }
            switch ($delimiter) {
                case 1:
                    $delimiter = ",";
                    break;
                case 2:
                    $delimiter = ";";
                    break;
                case 3:
                    $delimiter = ":";
                    break;
                case 4:
                    $delimiter = chr(9);
            }

            // titles
            if ($exportTitles == 1) {
                $titles = array(
                        $this->__('Name'),
                        $this->__('Tag'),
                        $this->__('Value'),
                        $this->__('Page'),
                        $this->__('User Name'),
                        $this->__('IP'),
                        $this->__('Impact'),
                        $this->__('PHPIDS filters used'),
                        $this->__('Date')
                );
            } else {
                $titles = array();
            }


            // actual data
            $sort = 'ids_date DESC';
            $class = 'SecurityCenter_DBObject_IntrusionArray';
            $objArray = new $class();
            $objData = $objArray->get('', $sort);

            $data = array();
            $find = array("\r\n", "\n");
            $replace = array("", "");

            foreach ($objData as $key => $idsdata) {
                $objData[$key]['filters'] = unserialize($objData[$key]['filters']);

                $filtersused = '';
                foreach ($objData[$key]['filters'] as $filter) {
                    $filtersused .= $filter['id'] . " ";
                }

                $datarow = array(
                        $objData[$key]['name'],
                        $objData[$key]['tag'],
                        htmlspecialchars(str_replace($find, $replace, $objData[$key]['value']), ENT_COMPAT, 'UTF-8', false),
                        htmlspecialchars($objData[$key]['page'], ENT_COMPAT, 'UTF-8', false),
                        $objData[$key]['username'],
                        $objData[$key]['ip'],
                        $objData[$key]['impact'],
                        $filtersused,
                        $objData[$key]['date']
                );

                array_push($data, $datarow);
            }

            // export the csv file
            FileUtil::exportCSV($data, $titles, $delimiter, '"', $exportFile);
        }

        // fetch output from template
        return $this->view->fetch('securitycenter_admin_exportidslog.tpl');
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:101,代码来源:Admin.php


注:本文中的FileUtil::exportCSV方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。