コード例 #1
0
ファイル: ImportHandler.php プロジェクト: sintattica/atk
 /**
  * Transforms the $importerrors array into displayable HTML.
  *
  * @todo make this use templates
  *
  * @param array $importerrors A special array with arrays in it
  *                            $importerrors[0] are general errors, other than that
  *                            the numbers stand for recordnumbers
  *
  * @return string HTML table with the errors
  */
 public function _getErrors($importerrors)
 {
     if (is_array($importerrors)) {
         $content = "\n<table>";
         $errorCount = 0;
         foreach ($importerrors as $record => $errors) {
             ++$errorCount;
             if ($errorCount > Config::getGlobal('showmaximporterrors', 50)) {
                 break;
             }
             if ($record == 0 && Tools::atk_value_in_array($errors)) {
                 $content .= '<tr><td colSpan=2>';
                 foreach ($errors as $error) {
                     if (!empty($error)) {
                         $content .= '<span class="error">' . Tools::atktext($error['msg']) . $error['spec'] . '</span><br />';
                     }
                 }
                 $content .= '</td></tr>';
             } else {
                 if (Tools::atk_value_in_array($errors)) {
                     $content .= '<tr><td valign="top" class="error">';
                     $content .= "<b>Record {$record}:</b>&nbsp;";
                     $content .= '</td><td valign="top" class="error">';
                     $counter = 0;
                     for ($counter = 0; $counter < count($errors) && $counter < Config::getGlobal('showmaximporterrors', 50); ++$counter) {
                         $content .= $this->m_node->text($errors[$counter]['msg']) . $errors[$counter]['spec'] . '<br />';
                     }
                     $content .= '</td></tr>';
                 }
             }
         }
         $content .= '</tr></table><br />';
     }
     return $content;
 }
コード例 #2
0
ファイル: ManyToManyRelation.php プロジェクト: sintattica/atk
 /**
  * Returns a displayable string for this value.
  *
  * @param array $record The record that holds the value for this attribute
  * @param string $mode The display mode ("view" for viewpages, or "list"
  *                       for displaying in recordlists, "edit" for
  *                       displaying in editscreens, "add" for displaying in
  *                       add screens. "csv" for csv files. Applications can
  *                       use additional modes.
  *
  * @return string a displayable string for this value
  */
 public function display($record, $mode)
 {
     $result = '';
     if ($this->createDestination() && Tools::atk_value_in_array($record[$this->fieldName()])) {
         $recordset = [];
         $remotekey = $this->getRemoteKey();
         for ($i = 0; $i < count($record[$this->fieldName()]); ++$i) {
             $rec = $record[$this->fieldName()][$i][$remotekey];
             if (!is_array($rec)) {
                 $selector = $this->m_destInstance->m_table . '.' . $this->m_destInstance->primaryKeyField() . "= '{$rec}'";
                 $rec = $this->m_destInstance->select($selector)->includes($this->m_destInstance->descriptorFields())->getFirstRow();
                 $descr = $this->m_destInstance->descriptor($rec);
             } else {
                 $descr = $this->m_destInstance->descriptor($rec);
             }
             if ($this->hasFlag(self::AF_MANYTOMANY_DETAILVIEW) && $this->m_destInstance->allowed('view')) {
                 $descr = Tools::href(Tools::dispatch_url($this->m_destination, 'view', array('atkselector' => $this->getDestination()->primaryKey($rec))), $descr, SessionManager::SESSION_NESTED);
             }
             $recordset[] = $descr;
         }
         if (!in_array($mode, array('csv', 'plain'))) {
             $result = '<ul><li>' . implode('<li>', $recordset) . '</ul>';
         } else {
             $result = implode(', ', $recordset);
         }
     } else {
         if (!in_array($mode, array('csv', 'plain'))) {
             $result = $this->text('none');
         }
     }
     return $result;
 }
コード例 #3
0
ファイル: RecordListCache.php プロジェクト: sintattica/atk
 /**
  * Wether or not to use caching
  * We don't cache when we are ordering or searching on a recordlist.
  *
  * @return bool Wether or not to use caching
  */
 public function noCaching()
 {
     return $this->m_postvars['atkorderby'] || $this->m_postvars['atksearch'] && Tools::atk_value_in_array($this->m_postvars['atksearch']) || $this->m_postvars['atksmartsearch'] && Tools::atk_value_in_array($this->m_postvars['atksmartsearch']);
 }