Пример #1
0
 /**
  * Adds a table footer to the html.
  */
 protected function addHtmlTableFooter()
 {
     $modelTable = $this->entityArray->getModelTable();
     $this->html .= '<tr>';
     $newButtonUrl = \Pvik\Core\Path::relativePath('~' . \Pvik\Core\Config::$config['PvikAdminTools']['Url']) . 'tables/' . strtolower($modelTable->getModelTableName()) . ':new';
     if ($this->newButtonPresetValues != null) {
         $newButtonUrl .= '/';
         $first = true;
         foreach ($this->newButtonPresetValues as $key => $value) {
             if ($first) {
                 $first = false;
             } else {
                 $newButtonUrl .= ':';
             }
             $newButtonUrl .= strtolower($key) . ':' . $value;
         }
     }
     $newButtonUrl .= '/';
     if ($this->buttonRedirectBack != null) {
         $newButtonUrl .= '?redirect-back-url=' . urlencode($this->buttonRedirectBack);
     }
     for ($index = 0; $index < $this->columns; $index++) {
         if ($index + 1 == $this->columns) {
             // last column
             $this->html .= '<td class="options">[';
             $this->html .= '<a href="' . $newButtonUrl . '">new</a>';
             $this->html .= ']</td>';
         } else {
             $this->html .= '<td>';
             $this->html .= '</td>';
         }
     }
     $this->html .= '</tr>';
 }
Пример #2
0
 /**
  * Returns a EntityArray from cache or database by the primary keys.
  * @param array $keys
  * @return EntityArray 
  */
 public function loadByPrimaryKeys(array $keys)
 {
     // convert to array
     $list = new EntityArray();
     $list->setModelTable($this);
     $loadKeys = array();
     foreach ($keys as $key) {
         if (!empty($key)) {
             // search in cache
             $item = $this->getCache()->loadByPrimaryKey($key);
             // mark for loading later
             if ($item == null) {
                 array_push($loadKeys, $key);
             } else {
                 $list->append($item);
             }
         }
     }
     if (!empty($loadKeys)) {
         // now load every data we didn't find in the cache
         $loadedItems = $this->selectByPrimaryKeys($loadKeys);
         foreach ($loadedItems as $loadedItem) {
             $list->append($loadedItem);
         }
     }
     return $list;
 }