Sorts the list of fields by view mode ordering.

Fields might have different orderings for each view mode.

@param string $viewMode View mode slug to use for sorting
@param int $dir either SORT_DESC or SORT_ASC
@return \Field\Collection\FieldCollection
191078
public function sortByViewMode($viewMode, $dir = SORT_ASC)
    {
        $items = [];
        $sorted = $this->sortBy(function ($field) use ($viewMode) {
            if (isset($field->metadata->view_modes[$viewMode])) {
                return $field->metadata->view_modes[$viewMode]['ordering'];
            }

            return 0;
        }, $dir);

        foreach ($sorted as $item) {
            $items[] = $item;
        }

        return new FieldCollection($items);
    }
231738
protected function getThumbnailParams($viewMode = null)
    {
        $result = [
            'mode' => 'crop',
            'ext' => 'png'
        ];

        if ($viewMode) {
            if ($viewMode == self::VIEW_MODE_LIST) {
                $result['width'] = 75;
                $result['height'] = 75;
            }
            else {
                $result['width'] = 165;
                $result['height'] = 165;
            }
        }

        return $result;
    }
1214027
public function byFieldValue(
        string $field,
        string $order
    ): SortBy {
        $this->sortsBy[] = [
            'type' => self::TYPE_FIELD,
            'field' => Item::getPathByField($field),
            'order' => $order,
        ];

        return $this;
    }
1172322
public function getFields( $dir = null ) {
        $inherit = false;
        if ($dir !== false && !is_a($dir, 'Cetera\\Catalog') && (int)$dir && $dir > 0) $dir = Catalog::getById($dir); 
        if (is_a($dir, 'Cetera\\Catalog'))
		{
            while ($dir->inheritFields && !$dir->isRoot()) $dir = $dir->getParent();
            if (!$dir->inheritFields) {
                $r = DbConnection::getDbConnection()->fetchAll('SELECT * FROM types_fields_catalogs WHERE type_id=? and catalog_id=?',[$this->id,$dir->id]);
                $inherit = array();
                foreach ($r as $f) $inherit[$f['field_id']] = $f;
            }
        }   
        
        $res = $this->_get_fields();
        
        if ($inherit && count($inherit)) {
            foreach ($res as $key => $val) {
            
                if (isset($inherit[$val['field_id']])) {
                     if ($inherit[$val['field_id']]['force_hide'])
                         $res[$key]['shw'] = 0; 
                     if ($inherit[$val['field_id']]['force_show'])
                         $res[$key]['shw'] = 1; 
                }            
            
            }
        }
        
        return $res;
         
    }
591408
public function create($rateMode)
    {
        $rateMode = (array) $rateMode;

        if (!isset($rateMode[1])) {
            $rateMode[1] = $rateMode[0];
        }

        return new Mode($rateMode[0], $rateMode[1]);
    }
748081
protected function listFolderItems($folder, $filter, $sortBy)
    {
        $filter = $filter !== self::FILTER_EVERYTHING ? $filter : null;

        return MediaLibrary::instance()->listFolderContents($folder, $sortBy, $filter);
    }
478535
public function showAction(Request $request, $folderId)
    {
        /** @var EntityManager $em */
        $em = $this->getDoctrine()->getManager();
        $session = $request->getSession();

        // Check when user switches between thumb -and list view
        $viewMode = $request->query->get('viewMode');
        if ($viewMode && $viewMode == 'list-view') {
            $session->set('media-list-view', true);
        } elseif ($viewMode && $viewMode == 'thumb-view') {
            $session->remove('media-list-view');
        }

        /* @var MediaManager $mediaManager */
        $mediaManager = $this->get('kunstmaan_media.media_manager');

        /* @var Folder $folder */
        $folder = $em->getRepository('KunstmaanMediaBundle:Folder')->getFolder($folderId);

        $adminListConfigurator = new MediaAdminListConfigurator($em, $mediaManager, $folder, $request);
        $adminList = $this->get('kunstmaan_adminlist.factory')->createList($adminListConfigurator);
        $adminList->bindRequest($request);

        $sub = new Folder();
        $sub->setParent($folder);
        $subForm = $this->createForm(FolderType::class, $sub, array('folder' => $sub));

        $emptyForm = $this->createEmptyForm();

        $editForm = $this->createForm(FolderType::class, $folder, array('folder' => $folder));

        if ($request->isMethod('POST')) {
            $editForm->handleRequest($request);
            if ($editForm->isValid()) {
                $em->getRepository('KunstmaanMediaBundle:Folder')->save($folder);

                $this->addFlash(
                    FlashTypes::SUCCESS,
                    $this->get('translator')->trans('media.folder.show.success.text', array(
                        '%folder%' => $folder->getName(),
                    ))
                );

                return new RedirectResponse(
                    $this->generateUrl(
                        'KunstmaanMediaBundle_folder_show',
                        array('folderId' => $folderId)
                    )
                );
            }
        }

        return array(
            'foldermanager' => $this->get('kunstmaan_media.folder_manager'),
            'mediamanager' => $this->get('kunstmaan_media.media_manager'),
            'subform' => $subForm->createView(),
            'emptyform' => $emptyForm->createView(),
            'editform' => $editForm->createView(),
            'folder' => $folder,
            'adminlist' => $adminList,
            'type' => null,
        );
    }
737241
public function orderBy(string $field, int $direction = self::ASCENDING): DocumentSelector
    {
        return $this->sortBy($this->sortBy + [$field => $direction]);
    }
1071381
private static function add_view($path, $mode, mvc\view $view)
  {
    if ( !isset(self::$loaded_views[$mode][$path]) ){
      self::$loaded_views[$mode][$path] = $view;
    }
    return self::$loaded_views[$mode][$path];
  }
1171992
public function sort($field, $direction = self::SORT_DESC) {
		if(empty($this->data['sorts'])) {
			$this->data['sorts'] = array();
		}
		$this->data['sorts'][] = array(
			'field' => $field,
			'direction' => $direction
		);
		return $this;
	}
711784
public void setArrayMode( int arrayMode ) {
      if( arrayMode == MODE_OBJECT_ARRAY ) {
         this.arrayMode = arrayMode;
      } else if( arrayMode == MODE_SET ) {
         this.arrayMode = arrayMode;
         this.collectionType = Set.class;
      } else {
         this.arrayMode = MODE_LIST;
         this.enclosedType = DEFAULT_COLLECTION_TYPE;
      }
   }
749840
public function listPages($listMode = PageOrder::LIST_ALL)
    {
        $retArray = array();
        if ($listMode == PageOrder::LIST_INACTIVE || $listMode == PageOrder::LIST_ALL) {
            foreach ($this->inactivePages as $page) {
                $retArray[] = $page;
            }
        }
        if ($listMode == PageOrder::LIST_ALL || $listMode == PageOrder::LIST_ACTIVE) {
            foreach ($this->activePages as $page) {
                $retArray[] = $page;
            }
        }

        return $retArray;

    }
1070412
public function dirReCreate($dir, $mode = 0755)
    {
        $this->dirDelete($dir);

        $this->dirCreate($dir, $mode);
    }
667404
function orderBy($column, $dir = null) {
		if (null !== $dir && '' !== $dir) {
			$dir = strtoupper($dir);
			if ($dir !== self::ASC && $dir !== self::DESC) {
				throw new RuntimeException("$dir is not a valid sorting direction.");
			}
			$column .= ' ' . $dir;
		}
		$this->orders[] = trim($column);
		return $this;
	}
236568
public function viewMode($slug = null)
    {
        if ($slug === null) {
            return ViewModeRegistry::current();
        }

        return ViewModeRegistry::uses($slug);
    }
1047232
public void setPaginationMode(final PaginationMode paginationMode) {
		getOrCreateComponentModel().paginationMode = PaginationMode.SERVER.equals(paginationMode) ? PaginationMode.DYNAMIC
				: paginationMode;
	}
666980
public function setMultipleMode($multipleMode)
    {
        $this->multipleMode = $multipleMode;

        if ($multipleMode) {
            $this->operator = FilterConfig::OPERATOR_IN;
        }

        return $this;
    }