Gallery content type translation
@param  {Array} content      List of files
@param  {String} contentType Content type name
@return {Object}             The gallery content type data object
425048
function gallery (content, contentType) {
  let output = {}
  const allFiles = content.filter(each => each.dir.includes(`/${contentType}`))
  const index = allFiles.filter(each => each.base === 'index.md')[0]
  index.attr.forEach(each => {
    Object.keys(each).forEach(key => {
      output[key] = Object.assign({ title: each[key] }, allFiles.filter(file => file.name === key)[0])
    })
  })
  return output
}
209091
def from_content_type(cls, content_type):
		
		name = content_type
		options = {}
		if ';' in content_type:
			name, options_str = content_type.split(';', 1)
			for part in options_str.split(';'):
				part = part.strip()
				if '=' in part:
					key, value = part.split('=')
				else:
					key, value = (part, None)
				options[key] = value
		# old style compatibility
		if name.endswith('+zlib'):
			options['compression'] = 'zlib'
			name = name[:-5]
		return cls(name, charset=options.get('charset', 'UTF-8'), compression=options.get('compression'))
299483
public static List<CmsResource> getGalleries(int galleryTypeId, CmsObject cms) {

        List<CmsResource> galleries = new ArrayList<CmsResource>();
        try {
            // get the galleries of the current site
            galleries = cms.readResources("/", CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireType(galleryTypeId));
        } catch (CmsException e) {
            // error reading resources with filter
            LOG.error(e.getLocalizedMessage(), e);
        }

        // if the current site is NOT the root site - add all other galleries from the system path
        if (!cms.getRequestContext().getSiteRoot().equals("")) {
            List<CmsResource> systemGalleries = null;
            try {
                // get the galleries in the /system/ folder
                systemGalleries = cms.readResources(
                    CmsWorkplace.VFS_PATH_SYSTEM,
                    CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireType(galleryTypeId));
            } catch (CmsException e) {
                // error reading resources with filter
                LOG.error(e.getLocalizedMessage(), e);
            }

            if ((systemGalleries != null) && (systemGalleries.size() > 0)) {
                // add the found system galleries to the result
                galleries.addAll(systemGalleries);
            }
        }

        // return the found galleries
        return galleries;
    }
924958
protected function sortContentTypeList(array &$contentTypes, $orderby, $sort = 'asc')
    {
        switch ($orderby) {
            case 'name':
                if ($sort === 'asc' || $sort === null) {
                    usort(
                        $contentTypes,
                        function (APIContentType $contentType1, APIContentType $contentType2) {
                            return strcasecmp($contentType1->identifier, $contentType2->identifier);
                        }
                    );
                } elseif ($sort === 'desc') {
                    usort(
                        $contentTypes,
                        function (APIContentType $contentType1, APIContentType $contentType2) {
                            return strcasecmp($contentType1->identifier, $contentType2->identifier) * -1;
                        }
                    );
                } else {
                    throw new BadRequestException('wrong value for sort parameter');
                }
                break;
            case 'lastmodified':
                if ($sort === 'asc' || $sort === null) {
                    usort(
                        $contentTypes,
                        function ($timeObj3, $timeObj4) {
                            $timeObj3 = strtotime($timeObj3->modificationDate->format('Y-m-d H:i:s'));
                            $timeObj4 = strtotime($timeObj4->modificationDate->format('Y-m-d H:i:s'));

                            return $timeObj3 > $timeObj4;
                        }
                    );
                } elseif ($sort === 'desc') {
                    usort(
                        $contentTypes,
                        function ($timeObj3, $timeObj4) {
                            $timeObj3 = strtotime($timeObj3->modificationDate->format('Y-m-d H:i:s'));
                            $timeObj4 = strtotime($timeObj4->modificationDate->format('Y-m-d H:i:s'));

                            return $timeObj3 < $timeObj4;
                        }
                    );
                } else {
                    throw new BadRequestException('wrong value for sort parameter');
                }
                break;
            default:
                throw new BadRequestException('wrong value for orderby parameter');
                break;
        }
    }
10498
def get_mapper_by_content_type(self, content_type):
        

        content_type = util.strip_charset(content_type)
        return self._get_mapper(content_type)
29386
public static int contentTypeToFlickrContentTypeId(JinxConstants.ContentType contentType) {
        if (contentType == null) {
            return -1;
        }
        int ret;
        switch (contentType) {
            case photo:
                ret = 1;
                break;
            case screenshot:
                ret = 2;
                break;
            case other:
                ret = 3;
                break;
            case photos_and_screenshots:
                ret = 4;
                break;
            case screenshots_and_other:
                ret = 5;
                break;
            case photos_and_other:
                ret = 6;
                break;
            case all:
                ret = 7;
                break;
            default:
                ret = -1;
                break;
        }
        return ret;
    }
828591
function() {
			var content = '', files = [];
			if (this.$element[0].files === undefined) {
				files[0] = {
					'name' : this.$element[0] && this.$element[0].value
				};
			} else {
				files = this.$element[0].files;
			}

			for (var i = 0; i < files.length; i++) {
				content += files[i].name.split("\\").pop() + ', ';
			}

			if (content !== '') {
				this.$elementFilestyle.find(':text').val(content.replace(/\, $/g, ''));
			} else {
				this.$elementFilestyle.find(':text').val('');
			}
			
			return files;
		}
71486
function() {
			var map = this.getContentTypesMap();
			var types = [];
			for (var type in map) {
				if (Object.prototype.hasOwnProperty.call(map, type)) {
					types.push(map[type]);
				}
			}
			return types;
		}
1325880
private Map<String, CmsGalleryTypeInfo> readGalleryInfosByTypeBeans(List<CmsResourceTypeBean> resourceTypes) {

        Map<String, CmsGalleryTypeInfo> galleryTypeInfos = new HashMap<String, CmsGalleryTypeInfo>();
        for (CmsResourceTypeBean typeBean : resourceTypes) {
            try {
                if (!typeBean.isDeactivated()) {
                    addGalleriesForType(galleryTypeInfos, typeBean.getType());
                }
            } catch (CmsLoaderException e1) {
                logError(e1);
            }
        }
        return galleryTypeInfos;
    }
1114986
function() {
		var allContentItems = [];

		var addChildren = function( contentItem ) {
			allContentItems.push( contentItem );

			if( contentItem.contentItems instanceof Array ) {
				for( var i = 0; i < contentItem.contentItems.length; i++ ) {
					addChildren( contentItem.contentItems[ i ] );
				}
			}
		};

		addChildren( this.root );

		return allContentItems;
	}
968505
function inlineLocalContent() {
      // inline local javascript
      filecontent = filecontent.replace(sre, function(matched, src) {
        if (!incfiles[src]) {
          return matched; // This file wasn't available
        }
        return matched.replace(srcre, '') + '\n' + incfiles[src];
      });
      // now inline local css
      filecontent = filecontent.replace(cre, function(matched, src) {
        var tag;
        if (!incfiles[src]) {
          return matched;
        }
        if (matched.toLowerCase().search('stylesheet') === -1) {
          return matched;
        }
        tag = matched.replace(hrefre, ''); // remove href attribute
        tag = tag.replace(crerel, ''); // remove rel attribute
        tag = tag.replace(cretag, '<style'); // change link to style
        tag = tag.replace(creend, '>'); // remove possible self-closing in style tag
        return tag + '\n' + incfiles[src] + '\n</style>';
      });
      //console.log(filecontent);
      resolve(filecontent);
    }
721239
private function visitContentTypeInfoList(ContentTypeInfoList $contentTypeInfoList): string
    {
        $this->outputGenerator->reset();
        $this->outputGenerator->startDocument($contentTypeInfoList);
        $this->contentTypeInfoListValueObjectVisitor->visit($this->outputVisitor, $this->outputGenerator, $contentTypeInfoList);

        return $this->outputGenerator->endDocument($contentTypeInfoList);
    }
396364
function (content) {
            var contentType = content.contentType;

            if (contentType && contentType in this.contentProcessors) {
                return this.processContent(this.contentProcessors[contentType].processContent(content));
            }
            return content.value || "";
        }
436878
public final B contentType(MediaType contentType) {
        requireNonNull(contentType, "contentType");
        autoDetectedContentType(false);
        getOrCreateHeaders().contentType(contentType);
        return self();
    }
727087
function getContentPath(modelId,contentId) {
	//console.log('getContentPath:');
	modelId = modelId.toString();
	contentId = contentId.toString();
	//console.log(modelId);
	//console.log(contentId);
	var path = '';
	path += 'files/model/';
	for(var i=0; i<String(modelId).length; i++) {
		path += modelId.charAt(i)+'/';
	}
	path += 'content/';
	for(i=0; i<String(contentId).length; i++) {
		path += contentId.charAt(i)+'/';
	}
	return path;
}
182895
function contentType (str) {
  // TODO: should this even be in this module?
  if (!str || typeof str !== 'string') {
    return false
  }

  var mime = str.indexOf('/') === -1
    ? exports.lookup(str)
    : str

  if (!mime) {
    return false
  }

  // TODO: use content-type or other module
  if (mime.indexOf('charset') === -1) {
    var charset = exports.charset(mime)
    if (charset) mime += '; charset=' + charset.toLowerCase()
  }

  return mime
}
658264
function (content) {
      var fileContent = self._readFileSync();

      fileContent.instances = fileContent.instances || {};
      fileContent.instances[this._id] = _.assign(fileContent.instances[this._id] || {}, content);
      self._writeFileSync(fileContent);
    }