Pobranie plików dla podanych obiektów (np. news, categorywidget itp.)
@param array $objects
@return array indeksowane po nazwie md5
1718
public function getFileList($objects)
    {
        //błąd
        if (!is_array($objects)) {
            return [];
        }
        //zwrot meta plików
        return (new \Cms\Orm\CmsFileQuery)->whereObject()->equals($objects)
                ->findPairs('name', 'original');
    }
551446
protected function createObjects($rows)
    {
        $models = [];

        foreach ($rows as $key => $row) {
            $models[$key] = $this->createObject($row);
        }

        return $models;
    }
1012280
public static function byObjectJoinedOriginal($object = null, $objectId = null)
    {
        //zapytanie o pliki po obiektach i id
        return (new self)
                ->joinLeft('cms_file', 'cms_file', 'original_file')
                ->on('cms_file_original_id', 'id')
                ->whereObject()->equals($object)
                ->andFieldObjectId()->equals($objectId)
                //posortowane po kolejności
                ->orderAscOrder()
                //sortowanie po ID, jeśli ordery są NULL
                ->orderAscId();
    }
858175
protected function checkUnsupportedTypes(array $objects)
    {
        if ($this->supportedTypes !== null) {
            $unsupportedTypes = array_diff(TypedUtils::uniqueTypes($objects), $this->supportedTypes);
            if (count($unsupportedTypes) > 0) {
                throw new Exception(sprintf(
                    'Encountered unsupported types %s (supported: %s)',
                    implode(', ', $unsupportedTypes),
                    count($this->supportedTypes) > 0 ? implode(', ', $this->supportedTypes) : '*none*'
                ));
            }
        }
    }
484458
private function _render(array $matches)
    {
        //wyszukiwanie szablonu
        if (null === $template = $this->view->getTemplateByPath($matches[1])) {
            //brak szablonu
            return;
        }
        //rekurencyjne zastąpienie (gdyż wstawienia mogą być zagnieżdżone)
        return preg_replace_callback('/\{\'([a-zA-Z\-\/]+)\'\}/', [&$this, '_render'], file_get_contents($template));
    }
403251
private function buildSubjects(array $objects)
    {
        $subjects = [];

        foreach ($objects as $object) {
            $subject = SubjectIdentity::fromObject($object);
            $id = SharingUtils::getCacheId($subject);

            if (!\array_key_exists($id, $this->cacheSubjectSharing)
                    && $this->hasIdentityPermissible()
                    && $this->hasSharingVisibility($subject)
                    && $this->hasSubjectConfig($subject->getType())) {
                $subjects[$id] = $subject;
                $this->cacheSubjectSharing[$id] = false;
            }
        }

        return $subjects;
    }
1188528
public function &fetchAllIdArray($id = null)
    {
        $list = array();

        while ($row = $this->fetch(PDO::FETCH_ASSOC)) {
            if ($id) {
                if (!isset($row[$id])) {
                    throw new PDOException("Zwrócone wartości nie mają klucza '$id', przykład ".json_encode($row), PDOException::CODENOTFOUND);
                }

                $list[$row[$id]] = $row;
            } else {
                $list[] = $row;
            }
        }

        return $list;
    }
1026223
public static function byObject($object = null, $objectId = null)
    {
        //zapytanie o pliki po obiektach i id
        return (new self)
                ->whereObject()->equals($object)
                ->andFieldObjectId()->equals($objectId)
                //posortowane po kolejności
                ->orderAscOrder()
                //sortowanie po ID, jeśli ordery są NULL
                ->orderAscId();
    }
700141
public static function daily($object, $objectId, $year, $month)
    {
        $days = date('t', strtotime($year . '-' . $month . '01 00:00:00'));
        $statArray = [];
        $month = str_pad($month, 2, '0', STR_PAD_LEFT);
        //pobieranie wierszy
        foreach (self::getRows($object, $objectId, $year, $month, true, null) as $stat) {
            $stat->day = str_pad($stat->day, 2, '0', STR_PAD_LEFT);
            $statArray[$stat->year . '-' . $month . '-' . $stat->day] = $stat->count;
        }
        $stats = [];
        //układanie wierszy w kubełkach dni
        for ($i = 1; $i <= $days; $i++) {
            $day = str_pad($i, 2, '0', STR_PAD_LEFT);
            $count = 0;
            if (isset($statArray[$year . '-' . $month . '-' . $day])) {
                $count = $statArray[$year . '-' . $month . '-' . $day];
            }
            $stats[$year . '-' . $month . '-' . $day] = $count;
        }
        return $stats;
    }
170931
private function getClass($array, &$objects)
    {
        foreach ($array as $el) {
            if (is_object($el)) {
                $objects = $array;

                $class = get_class($el);
            } else {
                if (is_array($el)) {
                    $class = $this->getClass($el, $objects);
                }
            }
        }

        return $class;
    }
255017
public function sortObjects($objects)
    {
        $collection = new HierarchicalCollection($objects, false);
        $collection->sortTree();

        return $collection->all();
    }
295214
public function create(array $objects) {
        $requests = [];

        foreach ($objects as $object) {
            $requests[] = [
                'method' => 'cmdb.object.create',
                'params' => $object
            ];
        }

        $result = $this->api->batchRequest($requests);

        $objectIDs = [];

        foreach ($result as $object) {
            $objectIDs[] = $object['id'];
        }

        return $objectIDs;
    }
1164999
public function encodeUrl(array $params = [])
    {
        //pusty url
        $url = '';
        //aplikacja rout
        foreach ($this->getRoutes() as $route) {
            /* @var $route \Mmi\Mvc\RouterConfigRoute */
            $result = (new RouterMatcher)->tryRouteForParams($route, array_merge($route->default, $params));
            //dopasowano routę
            if ($result['applied']) {
                $url = '/' . $result['url'];
                $matched = $result['matched'];
                break;
            }
        }
        //czyszczenie dopasowanych z routy
        foreach (isset($matched) ? $matched : [] as $match => $value) {
            unset($params[$match]);
        }
        //usuwanie kontrolera jeśli index
        if (isset($params['controller']) && $params['controller'] == 'index') {
            unset($params['controller']);
        }
        //usuwanie akcji jeśli index
        if (isset($params['action']) && $params['action'] == 'index') {
            unset($params['action']);
        }
        //jeśli puste parametry
        if (empty($params)) {
            return $url;
        }
        //budowanie zapytania
        return $url . ($url == '/' ? '?' : '/?') . http_build_query($params);
    }
346721
protected function parseAsObjectActions(array $actions)
    {
        $objectActions = [];
        foreach ($actions as $action) {
            $action = $this->parseActionRenderables($action, true);

            if (isset($action['ident'])) {
                if ($action['ident'] === 'view' && !$this->isObjViewable()) {
                    $action['active'] = false;
                } elseif ($action['ident'] === 'create' && !$this->isObjCreatable()) {
                    $action['active'] = false;
                } elseif ($action['ident'] === 'edit' && !$this->isObjEditable()) {
                    $action['active'] = false;
                } elseif ($action['ident'] === 'delete' && !$this->isObjDeletable()) {
                    $action['active'] = false;
                }
            }

            if ($action['actions']) {
                $action['actions']    = $this->parseAsObjectActions($action['actions']);
                $action['hasActions'] = !!array_filter($action['actions'], function ($action) {
                    return $action['active'];
                });
            }

            $objectActions[] = $action;
        }

        return $objectActions;
    }
736476
public final function toArrayPut()
    {
        $data = [];
        //iteracja po danych
        foreach ($this as $key => $value) {
            //znaleziono w read only
            if (false !== in_array($key, $this->_readOnlyFields)) {
                continue;
            }
            //znaleziono w read only po zamianach
            if (false !== ($replaceKey = array_search($key, $this->_replacementFields))) {
                $key = $replaceKey;
            }
            $data[$key] = $value;
        }
        return $data;
    }
54974
public function importFileMeta(array $files)
    {
        //iteracja po plikach (ta sama nazwa "name")
        foreach ($files as $importData) {
            //brak id
            if (!isset($importData['name']) || !isset($importData['id'])) {
                return;
            }
            //sprawdzanie istnienia pliku
            if (null === $file = (new \Cms\Orm\CmsFileQuery)->findPk($importData['id'])) {
                $file = new \Cms\Orm\CmsFileRecord;
            }
            //identyfikatory niezgodne
            if ($file->name && $file->name != $importData['name']) {
                continue;
            }
            //ustawienie danych rekordu rekordu
            $file->setFromArray($importData);
            //poprawny zapis
            if (!$file->save()) {
                return;
            }
        }
        //zwrot ostatniego pliku (potrzebny jest dowolny)
        return $file;
    }
903035
public function setFromArray(array $row = [])
    {
        $joinedRows = [];
        foreach ($row as $key => $value) {
            //przyjęcie pól z joinów
            if (false !== strpos($key, '__')) {
                $keyParts = explode('__', $key);
                $joinedRows[$keyParts[0]][$keyParts[1]][$keyParts[2]] = $value;
                continue;
            }
            $field = \Mmi\Orm\Convert::underscoreToCamelcase($key);
            if (property_exists($this, $field)) {
                $this->$field = $value;
                continue;
            }
            $this->setOption($field, $value);
        }
        //podpięcie joinów pod główny rekord
        foreach ($joinedRows as $alias => $tables) {
            foreach ($tables as $tableName => $fields) {
                $recordClass = \Mmi\Orm\DbConnector::getRecordNameByTable($tableName);
                $record = new $recordClass;
                $record->setFromArray($fields)
                    ->clearModified();
                $this->_joined[$alias] = $record;
            }
        }
        //wypełniony
        $this->_filled = true;
        return $this;
    }