/**
  * @param int $amount
  * @return array
  */
 protected function getGoogleFonts($amount = 30)
 {
     if ($apiKey = SiteDesigner::current_site_designer()->GoogleFontAPI) {
         $fontFile = Director::baseFolder() . '/' . SITEDESIGNER_MODULE . '/fonts/google-web-fonts.txt';
         /**
          * Total time the file will be cached in seconds, set to a week
          */
         $cacheTime = 86400 * 7;
         if (file_exists($fontFile) && $cacheTime < filemtime($fontFile)) {
             $content = json_decode(file_get_contents($fontFile));
         } else {
             $url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' . $apiKey;
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
             curl_setopt($ch, CURLOPT_HEADER, false);
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_REFERER, $url);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             $fontContent = curl_exec($ch);
             curl_close($ch);
             $fp = fopen($fontFile, 'w');
             fwrite($fp, $fontContent);
             fclose($fp);
             $content = json_decode($fontContent);
         }
         if (!empty($content->items)) {
             if ($amount == 'all') {
                 $googleFontsArray = $content->items;
             } else {
                 $googleFontsArray = array_slice($content->items, 0, $amount);
             }
         } else {
             return false;
         }
         $googleFontsDropdownArray = [];
         foreach ($googleFontsArray as $item) {
             $variants = ':' . implode(',', $item->variants);
             $googleFontsDropdownArray[$item->family . $variants] = $item->family;
         }
         return $googleFontsDropdownArray;
     }
     return false;
 }
 /**
  * Create Designer with defaults from language file.
  *
  * @return SiteConfig
  */
 public static function make_site_designer()
 {
     /** @var SiteDesigner $config */
     $config = SiteDesigner::create();
     $config->write();
     return $config;
 }
 /**
  * Save the current sites {@link SiteConfig} into the database
  *
  * @param array $data
  * @param Form $form
  * @return String
  */
 public function save_sitedesigner($data, $form)
 {
     $siteDesigner = SiteDesigner::current_site_designer();
     $form->saveInto($siteDesigner);
     try {
         $siteDesigner->write();
     } catch (ValidationException $ex) {
         $form->sessionMessage($ex->getResult()->message(), 'bad');
         return $this->getResponseNegotiator()->respond($this->request);
     }
     $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.')));
     return $this->getResponseNegotiator()->respond($this->request);
 }