/** * Build a logo based on the specified parameters. * * @param string The name of the logo to use. Pass [template] to build a logo for the current store design. * @param array Array of text for the logo. */ public function BuildLogo($logoName, $text=array()) { GetLib('logomaker/class.logomaker'); $logoName = basename($logoName); $originalLogoName = $logoName; $filePrefix = ''; if($logoName == "[template]") { $logoPath = ISC_BASE_PATH."/templates/".GetConfig('template')."/logo/"; $configFile = $logoPath.'config.php'; $logoName = GetConfig('template'); } else { $logoPath = ISC_BASE_PATH.'/templates/__logos/'; $configFile = $logoPath.$logoName . '_config.php'; } if(!file_exists($configFile)) { return false; } require $configFile; $className = $logoName .'_logo'; $tmpClass = new $className; $logoImage = $logoName.'.'.$tmpClass->FileType; $s = GetClass('ISC_ADMIN_SETTINGS'); $GLOBALS['ISC_NEW_CFG'] = array(); if (implode('', $text) == '') { $text = array(); } $fields = array(); foreach($text as $k => $textField) { $tmpClass->Text[$k] = $textField; $fields[] = $textField; } // reflect the text that was actually generated on the logo back into the store config, just incase the logo changed it somehow (ie. default values if blanks are provided) foreach ($tmpClass->Text as $textKey => $textValue) { $fields['ExtraText' . $textKey] = $textValue; } if(!empty($fields)) { $GLOBALS['ISC_NEW_CFG']['LogoFields'] = $fields; } $logoData = $tmpClass->GenerateLogo(); ClearTmpLogoImages(); $imageFile = 'website_logo.'.$tmpClass->FileType; file_put_contents(ISC_BASE_PATH . '/'.GetConfig('ImageDirectory').'/'.$imageFile, $logoData); $GLOBALS['ISC_NEW_CFG']['StoreLogo'] = $imageFile; $GLOBALS['ISC_NEW_CFG']['UsingLogoEditor'] = 1; $GLOBALS['ISC_NEW_CFG']['LogoType'] = 'image'; if($originalLogoName == "[template]") { $GLOBALS['ISC_NEW_CFG']['UsingTemplateLogo'] = 1; } else { $GLOBALS['ISC_NEW_CFG']['UsingTemplateLogo'] = 0; } $s->CommitSettings(); return $imageFile; }
private function PreviewLogo() { GetLib('logomaker/class.logomaker'); $logoPath = ISC_BASE_PATH . "/templates/" . GetConfig('template') . "/logo/"; $configFile = $logoPath . 'config.php'; $logoName = GetConfig('template'); if (!file_exists($configFile)) { $tags = array(); $tags[] = $this->MakeXMLTag('status', 0); $tags[] = $this->MakeXMLTag('message', 'Config file for ' . $logoName . ' doesn\'t exist'); $this->SendXMLHeader(); $this->SendXMLResponse($tags); die; } require $configFile; $className = $logoName . '_logo'; $tmpClass = new $className(); $logoImage = $logoName . '.' . $tmpClass->FileType; if (isset($_POST['ExtraText0'])) { $fields = array(); $name = 'ExtraText0'; $i = 0; while (isset($_POST[$name])) { if ($_POST[$name]) { $tmpClass->Text[$i] = $_POST[$name]; } $i++; $name = 'ExtraText' . $i; } } $logoData = $tmpClass->GenerateLogo(); ClearTmpLogoImages(); $imageFile = 'tmp_' . $logoName . '_' . rand(5, 10000) . '.png'; file_put_contents(ISC_BASE_PATH . '/cache/logos/' . $imageFile, $logoData); $tags = array(); $tags[] = $this->MakeXMLTag('status', 1); $tags[] = $this->MakeXMLTag('logoImage', $imageFile); $this->SendXMLHeader(); $this->SendXMLResponse($tags); die; }
/** * Build a logo based on the specified parameters. * * @param string The name of the logo to use. Pass [template] to build a logo for the current store design. * @param array Array of text for the logo. */ public function BuildLogo($logoName, $text = array()) { GetLib('logomaker/class.logomaker'); $logoName = basename($logoName); $originalLogoName = $logoName; $filePrefix = ''; if ($logoName == "[template]") { $logoPath = ISC_BASE_PATH . "/templates/" . GetConfig('template') . "/logo/"; $configFile = $logoPath . 'config.php'; $logoName = GetConfig('template'); } else { $logoPath = ISC_BASE_PATH . '/templates/__logos/'; $configFile = $logoPath . $logoName . '_config.php'; } if (!file_exists($configFile)) { return false; } require $configFile; $className = $logoName . '_logo'; $tmpClass = new $className(); $logoImage = $logoName . '.' . $tmpClass->FileType; $s = GetClass('ISC_ADMIN_SETTINGS'); $GLOBALS['ISC_NEW_CFG'] = array(); if ($text[0] == '') { $text[0] = GetConfig('StoreName'); } $fields = array(); foreach ($text as $k => $textField) { $tmpClass->Text[$k] = $textField; $fields[] = $textField; } if (count($fields) > 0) { $GLOBALS['ISC_NEW_CFG']['LogoFields'] = $fields; } $logoData = $tmpClass->GenerateLogo(); ClearTmpLogoImages(); $imageFile = 'website_logo.' . $tmpClass->FileType; file_put_contents(ISC_BASE_PATH . '/' . GetConfig('ImageDirectory') . '/' . $imageFile, $logoData); $GLOBALS['ISC_NEW_CFG']['StoreLogo'] = $imageFile; $GLOBALS['ISC_NEW_CFG']['UsingLogoEditor'] = 1; $GLOBALS['ISC_NEW_CFG']['LogoType'] = 'image'; if ($originalLogoName == "[template]") { $GLOBALS['ISC_NEW_CFG']['UsingTemplateLogo'] = 1; } else { $GLOBALS['ISC_NEW_CFG']['UsingTemplateLogo'] = 0; } $s->CommitSettings(); return $imageFile; }