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


PHP Tools::atkGetCharset方法代码示例

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


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

示例1: render

 /**
  * Creates a special Recordlist that can be used for exporting to files or to make it printable.
  *
  * @param Node $node The node to use as definition for the columns.
  * @param array $recordset The records to render
  * @param string $sol String to use at start of each row
  * @param string $sof String to use at start of each field
  * @param string $eof String to use at end of each field
  * @param string $eol String to use at end of each row
  * @param int $type 0=Render rows in simple html tabl; 1= raw export
  * @param string $compression Compression technique (bzip / gzip)
  * @param array $suppressList List of attributes from $node that should be ignored
  * @param array $outputparams Key-Value parameters for output. Currently existing:
  *                             filename - the name of the file (without extension .csv)
  * @param string $mode The mode that is passed to attributes' display() method
  *                             (for overrides). Defaults to 'list'.
  * @param bool $titlerow Should titlerow be rendered or not
  * @param bool $decode Should data be decoded or not (for exports)
  * @param string $fsep String to use between fields
  * @param string $rfeplace String for replacing line feeds in recordset field values (null = do not replace)
  *
  * @return string|null
  */
 public function render($node, $recordset, $sol, $sof, $eof, $eol, $type = 0, $compression = '', $suppressList = '', $outputparams = [], $mode = 'list', $titlerow = true, $decode = false, $fsep = '', $rfeplace = null)
 {
     $this->setNode($node);
     $this->m_mode = $mode;
     // example      html         csv
     // $sol     = '<tr>'         or  ''
     // $sof     = '<td>'         or  '"'
     // $eof     = '</td>'        or  '"'
     // $eol     = '</tr>'        or  '\r\n'
     // $fsep    = ''             or  ';'
     //$empty  om lege tabelvelden op te vullen;
     // stuff for the totals row..
     $output = '';
     $empty = '';
     if ($type == '0') {
         $empty = '&nbsp;';
     }
     if ($titlerow) {
         $output .= $sol;
         // display a headerrow with titles.
         // Since we are looping the attriblist anyway, we also check if there
         // are totalisable collumns.
         foreach (array_keys($this->m_node->m_attribList) as $attribname) {
             $p_attrib = $this->m_node->m_attribList[$attribname];
             $musthide = is_array($suppressList) && count($suppressList) > 0 && in_array($attribname, $suppressList);
             if (!$this->isHidden($p_attrib) && !$musthide) {
                 $output .= $sof . $this->eolreplace($p_attrib->label(), $rfeplace) . $eof . $fsep;
             }
         }
         if ($fsep) {
             // remove separator at the end of line
             $output = substr($output, 0, -strlen($fsep));
         }
         $output .= $eol;
     }
     // Display the values
     for ($i = 0, $_i = count($recordset); $i < $_i; ++$i) {
         $output .= $sol;
         foreach (array_keys($this->m_node->m_attribList) as $attribname) {
             $p_attrib = $this->m_node->m_attribList[$attribname];
             $musthide = is_array($suppressList) && count($suppressList) > 0 && in_array($attribname, $suppressList);
             if (!$this->isHidden($p_attrib) && !$musthide) {
                 // An <attributename>_display function may be provided in a derived
                 // class to display an attribute.
                 $funcname = $p_attrib->m_name . '_display';
                 if (method_exists($this->m_node, $funcname)) {
                     $value = $this->eolreplace($this->m_node->{$funcname}($recordset[$i], $this->m_mode), $rfeplace);
                 } else {
                     // otherwise, the display function of the particular attribute
                     // is called.
                     $value = $this->eolreplace($p_attrib->display($recordset[$i], $this->m_mode), $rfeplace);
                 }
                 if (Tools::atkGetCharset() != '' && $decode) {
                     $value = Tools::atk_html_entity_decode(htmlentities($value, ENT_NOQUOTES), ENT_NOQUOTES);
                 }
                 $output .= $sof . ($value == '' ? $empty : $value) . $eof . $fsep;
             }
         }
         if ($fsep) {
             // remove separator at the end of line
             $output = substr($output, 0, -strlen($fsep));
         }
         $output .= $eol;
     }
     // html requires table tags
     if ($type == '0') {
         $output = '<table border="1" cellspacing="0" cellpadding="2">' . $output . '</table>';
     }
     Tools::atkdebug(Tools::atk_html_entity_decode($output));
     // To a File
     if (!array_key_exists('filename', $outputparams)) {
         $outputparams['filename'] = 'achievo';
     }
     if ($this->m_exportcsv) {
         $ext = $type == '0' ? 'html' : 'csv';
         $exporter = new FileExport();
         $exporter->export($output, $outputparams['filename'], $ext, $ext, $compression);
//.........这里部分代码省略.........
开发者ID:sintattica,项目名称:atk,代码行数:101,代码来源:CustomRecordList.php

示例2: getValidatedRecords

 /**
  * Get the validated records.
  *
  * @param string $file The import csv file
  *
  * @return array with importerrors and validatedrecs
  */
 public function getValidatedRecords($file)
 {
     $enclosure = $this->m_postvars['enclosure'];
     $delimiter = $this->m_postvars['delimiter'];
     $columncount = $this->m_postvars['columncount'];
     $skipfirstrow = $this->m_postvars['skipfirstrow'];
     $allFields = $this->m_postvars['allFields'];
     $col_map = $this->m_postvars['col_map'];
     $allFieldsValues = $this->getAllFieldsValues($col_map);
     $initial_values = $this->m_importNode->initial_values();
     $validatedrecs = [];
     $validatedrecs['add'] = [];
     $validatedrecs['update'] = [];
     $importerrors = [];
     $importerrors[0] = [];
     $importerrors[0] = array_merge($importerrors[0], $this->checkImport($col_map, $initial_values));
     $allfielderror = $this->checkAllFields($allFields, $allFieldsValues);
     if ($allfielderror) {
         $importerrors[0][] = $allfielderror;
     }
     if (count($importerrors[0]) > 0) {
         // don't start importing if even the minimum requirements haven't been met
         return array('importerrors' => &$importerrors, 'validatedrecs' => array());
     }
     static $mb_converting_exists = null;
     if (!isset($mb_converting_exists)) {
         $mb_converting_exists = function_exists('mb_convert_encoding');
         Tools::atkdebug('Checking function_exists("mb_convert_encoding")');
     }
     static $atkCharset = null;
     if (!isset($atkCharset)) {
         $atkCharset = Tools::atkGetCharset();
         Tools::atkdebug('setting atkcharset static!');
     }
     //copy the csv in a record and add it to the db
     $fp = fopen($file, 'r');
     if ($skipfirstrow == '1') {
         $line = fgets($fp);
     }
     for ($line = fgets($fp), $counter = 1; $line !== false; $line = fgets($fp), $counter++) {
         Tools::atkdebug("Validating record nr. {$counter}");
         //if we have an empty line, pass it
         if (trim($line) == '') {
             continue;
         }
         //large import are a problem for the maximum execution time, so we want to set for each
         //loop of the for-loop an maximum execution time
         set_time_limit(60);
         Tools::atkdebug('set_time_limit(60)');
         if ($atkCharset != '' && $mb_converting_exists) {
             $line = mb_convert_encoding($line, $atkCharset);
         }
         $data = $this->fgetcsvfromline($line, $columncount, $delimiter, $enclosure);
         $rec = $initial_values;
         for ($i = 0, $_i = count($col_map); $i < $_i; ++$i) {
             if ($col_map[$i] != '-') {
                 if (!in_array($col_map[$i], $allFields)) {
                     // column is mapped
                     $value = $this->_getAttributeValue($col_map[$i], $allFields, $data[$i], $importerrors, $counter, $rec);
                 } else {
                     //this is the allField
                     $value = $allFieldsValues[$col_map[$i]];
                 }
                 $this->addToRecord($rec, $col_map[$i], $value);
             }
         }
         $this->validateRecord($rec, $validatedrecs, $importerrors, $counter);
     }
     // close file
     @fclose($fp);
     return array('importerrors' => &$importerrors, 'validatedrecs' => &$validatedrecs);
 }
开发者ID:sintattica,项目名称:atk,代码行数:79,代码来源:ImportHandler.php

示例3: refreshAttribute

 /**
  * Re-render / refresh the attribute with the given name.
  *
  * @param string $name attribute name
  */
 public function refreshAttribute($name)
 {
     if ($this->isInitial()) {
         return;
     }
     $offset = count($this->getNode()->getPage()->getLoadScripts());
     $error = [];
     $editArray = array('fields' => array());
     $this->m_node->getAttribute($name)->addToEditArray($this->getMode(), $editArray, $this->getRecord(), $error, $this->getFieldPrefix());
     $scriptCode = '';
     foreach ($editArray['fields'] as $field) {
         $element = str_replace('.', '_', $this->getNode()->atkNodeUri() . '_' . $field['id']);
         $value = Json::encode(Tools::atk_iconv(Tools::atkGetCharset(), 'UTF-8', $field['html']));
         // Json::encode excepts string in UTF-8
         $scriptCode .= "if (\$('{$element}')) { \$('{$element}').update({$value}); } ";
     }
     $this->getNode()->getPage()->register_loadscript($scriptCode, $offset);
 }
开发者ID:sintattica,项目名称:atk,代码行数:23,代码来源:EditFormModifier.php

示例4: partial_refresh

 /**
  * Partial method to refresh  the add/edit field for this attribute.
  *
  * @param string $mode add/edit mode
  *
  * @return string HTML the output needed to refresh the attribute.
  */
 public function partial_refresh($mode)
 {
     $record = $this->m_ownerInstance->updateRecord();
     $fieldprefix = $this->m_ownerInstance->m_postvars['atkfp'];
     $arr = array('fields' => array());
     $defaults =& $record;
     $error = [];
     $this->addToEditArray($mode, $arr, $defaults, $error, $fieldprefix);
     $script = '';
     foreach ($arr['fields'] as $field) {
         //Json::encode expect string in in ASCII or UTF-8 format, so convert data to UTF-8
         $value = Tools::atk_iconv(Tools::atkGetCharset(), 'UTF-8', $field['html']);
         $script .= "\$('" . str_replace('.', '_', $this->m_ownerInstance->atkNodeUri() . '_' . $field['id']) . "').update(" . Json::encode($value) . ");\r\n";
     }
     return '<script type="text/javascript">' . $script . '</script>';
 }
开发者ID:sintattica,项目名称:atk,代码行数:23,代码来源:Attribute.php


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