Beispiel #1
0
 /**
  * Returns the manifest data as an array.
  *
  * @param   AppConfiguration    $configuration      The configuration to create the manifest from.
  *
  * @return  array
  */
 public function get(AppConfiguration $configuration)
 {
     $manifest = [];
     if (($backgroundColor = $configuration->getBackgroundColor()) !== null) {
         $manifest["background_color"] = $backgroundColor;
     }
     if (($description = $configuration->getDescription()) !== null) {
         $manifest["description"] = $description;
     }
     if (($direction = $configuration->getDirection()) !== null) {
         $manifest["dir"] = $direction;
     }
     if (($display = $configuration->getDisplay()) !== null) {
         $manifest["display"] = $display;
     }
     if (count($icons = $configuration->getIcons()) > 0) {
         $manifest["icons"] = [];
         foreach ($icons as $icon) {
             $manifest["icons"][] = $this->getImageData($icon);
         }
     }
     if (($language = $configuration->getLanguage()) !== null) {
         $manifest["lang"] = $language;
     }
     if (($name = $configuration->getName()) !== null) {
         $manifest["name"] = $name;
     }
     if (($orientation = $configuration->getOrientation()) !== null) {
         $manifest["orientation"] = $orientation;
     }
     if (($scope = $configuration->getScope()) !== null) {
         $manifest["scope"] = $scope;
     }
     if (count($screenshots = $configuration->getScreenshots()) > 0) {
         $manifest["screenshots"] = [];
         foreach ($screenshots as $screenshot) {
             $manifest["screenshots"][] = $this->getImageData($screenshot);
         }
     }
     if (($shortName = $configuration->getShortName()) !== null) {
         $manifest["short_name"] = $shortName;
     }
     if (($startUrl = $configuration->getStartUrl()) !== null) {
         $manifest["start_url"] = $startUrl;
     }
     if (($themeColor = $configuration->getThemeColor()) !== null) {
         $manifest["theme_color"] = $themeColor;
     }
     return $manifest;
 }
Beispiel #2
0
 private function getAppleTags(AppConfiguration $configuration)
 {
     $tags = [];
     // format-detection
     // https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html#//apple_ref/doc/uid/TP40008193-SW5
     $tags[] = ["meta", "name" => "format-detection", "content" => "telephone=no"];
     // Application name
     if (($shortName = $configuration->getShortName()) !== null) {
         $tags[] = ["meta", "name" => "apple-mobile-web-app-title", "content" => $shortName];
     }
     // Icons
     // https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html#//apple_ref/doc/uid/TP40002051-CH3-SW4
     foreach ($configuration->getIcons() as $icon) {
         if (in_array($icon->getPlatform(), [null, AppConfiguration::PLATFORM_IOS])) {
             $sizes = array_map(function (array $size) {
                 return "{$size[0]}x{$size[1]}";
             }, $icon->getSizes());
             $tags[] = ["link", "rel" => "apple-touch-icon", "href" => $icon->getSrc(), "sizes" => count($sizes) > 0 ? implode(" ", $sizes) : null];
         }
     }
     // apple-mobile-web-app-capable
     // apple-mobile-web-app-status-bar-style
     // https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html
     if ($configuration->getDisplay() == AppConfiguration::DISPLAY_FULLSCREEN || $configuration->getDisplay() == AppConfiguration::DISPLAY_STANDALONE) {
         $tags[] = ["meta", "name" => "apple-mobile-web-app-capable", "content" => "yes"];
         $tags[] = ["meta", "name" => "apple-mobile-web-app-status-bar-style", "content" => $configuration->getDisplay() == AppConfiguration::DISPLAY_FULLSCREEN ? "black-translucent" : "default"];
     }
     return $tags;
 }