public function save() { $value_changed = $this->getValue() != $this->getOrigValue(); if (stripos($this->getValue(), "image/png;base64") !== false) { $data = substr($this->getValue(), strpos($this->getValue(), ",") + 1); $data = str_replace(' ', '+', $data); $data = base64_decode($data); $ext = $this->getCode() == "favicon" ? ".ico" : ".png"; $filename = $this->getCode() . $ext; $filepath = Core_Model_Directory::getBasePathTo("images/default"); if (!is_dir($filepath)) { mkdir($filepath, 0777, true); } if (!is_writable($filepath)) { throw new Exception($this->_("The folder /images/default is not writable.")); } file_put_contents("{$filepath}/{$filename}", $data); $this->setValue("/images/default/{$this->getCode()}.{$ext}"); } parent::save(); if ($this->getCode() == "system_timezone" && $value_changed) { $config = new self(); $config->find("system_territory", "code"); $value = $this->getValue(); $territories = Zend_Registry::get("Zend_Locale")->getTranslationList('TerritoryToTimezone'); $territory = $value && !empty($territories[$value]) ? $territories[$value] : null; $data = array("code" => "system_territory", "value" => $territory); $config->addData($data)->save(); } }
public function copyTo($option) { if ($this->getEventType() == 'cstm') { $custom_event = new Event_Model_Event_Custom(); $custom_events = $custom_event->findAll(array('agenda_id' => $this->getId())); $this->setId(null)->setValueId($option->getId())->save(); foreach ($custom_events as $custom_event) { $custom_event->setId(null)->setAgendaId($this->getId()); if ($image_url = $custom_event->getPictureUrl()) { $file = pathinfo($image_url); $filename = $file['basename']; $relativePath = $option->getImagePathTo(); $folder = Core_Model_Directory::getBasePathTo(Application_Model_Application::PATH_IMAGE . '/' . $relativePath); if (!is_dir($folder)) { mkdir($folder, 0777, true); } $img_src = Core_Model_Directory::getBasePathTo($image_url); $img_dst = $folder . '/' . $filename; if (@copy($img_src, $img_dst)) { $custom_event->setPicture($relativePath . '/' . $filename); } } $custom_event->save(); } } else { $this->setId(null)->setValueId($option->getId())->save(); } return $this; }
public function apkisgeneratedAction() { $appName = $this->getRequest()->getParam('app_name'); $apk_base_path = Core_Model_Directory::getBasePathTo("var/tmp/applications/android/{$appName}/Siberian/app/build/outputs/apk/app-release.apk"); $apk_path = Core_Model_Directory::getPathTo("var/tmp/applications/android/{$appName}/Siberian/app/build/outputs/apk/app-release.apk"); $apk_is_generated = false; $link = $this->getUrl() . $apk_path; $link = str_replace("//", "/", $link); if (file_exists($apk_base_path)) { if (time() - filemtime($apk_base_path) <= 600) { $apk_is_generated = true; } } $user = new Backoffice_Model_User(); try { $user = $user->findAll(null, "user_id ASC", array("limit" => "1"))->current(); $sender = System_Model_Config::getValueFor("support_email"); $support_name = System_Model_Config::getValueFor("support_name"); $layout = $this->getLayout()->loadEmail('application', 'download_source'); $subject = $this->_('Android APK Generation'); $layout->getPartial('content_email')->setLink($link); $layout->getPartial('content_email')->setApkStatus($apk_is_generated); $content = $layout->render(); $mail = new Zend_Mail('UTF-8'); $mail->setBodyHtml($content); $mail->setFrom($sender, $support_name); $mail->addTo($user->getEmail()); $mail->setSubject($subject); $mail->send(); } catch (Exception $e) { $logger = Zend_Registry::get("logger"); $logger->sendException("Fatal Error Sending the APK Generation Email: \n" . print_r($e, true), "apk_generation_"); } die('ok'); }
protected function _cpFolder() { $formatted_name = Core_Model_Lib_String::format($this->getApplication()->getName(), true); if (!$formatted_name) { $formatted_name = $this->getApplication()->getId(); $zip_name = $formatted_name; } else { $zip_name = $formatted_name; $formatted_name .= "-" . $this->getApplication()->getId(); } $src = Core_Model_Directory::getBasePathTo(self::SOURCE_FOLDER); if ($this->getDevice()->getExcludeAds()) { $src .= " No Ads"; } $dst = Core_Model_Directory::getBasePathTo(self::DEST_FOLDER); $dst = sprintf($dst, $formatted_name); // Supprime le dossier s'il existe puis le créé if (is_dir($dst)) { Core_Model_Directory::delete($dst); } mkdir($dst, 0775, true); // Copie les sources Core_Model_Directory::duplicate($src, $dst); $this->_zipname = $zip_name . '_ios_source'; $this->_dst = $dst . '/Apps Mobile Company'; $this->_base_dst = $dst; return $this; }
public function getColorizedImage($image_id, $color) { $color = str_replace('#', '', $color); $id = md5(implode('+', array($image_id, $color))); $url = ''; $image = new Media_Model_Library_Image(); if (is_numeric($image_id)) { $image->find($image_id); if (!$image->getId()) { return $url; } if (!$image->getCanBeColorized()) { $color = null; } $path = $image->getLink(); $path = Media_Model_Library_Image::getBaseImagePathTo($path); } else { if (!Zend_Uri::check($image_id) and stripos($image_id, Core_Model_Directory::getBasePathTo()) === false) { $path = Core_Model_Directory::getBasePathTo($image_id); } else { $path = $image_id; } } try { $image = new Core_Model_Lib_Image(); $image->setId($id)->setPath($path)->setColor($color)->colorize(); $url = $image->getUrl(); } catch (Exception $e) { $url = ''; } return $url; }
public function copyTo($option) { $old_weblink_id = $this->getId(); $this->setId(null)->setValueId($option->getId()); if ($image_url = $this->getCoverUrl()) { $file = pathinfo($image_url); $filename = $file['basename']; $relativePath = $option->getRelativePath(); $folder = Core_Model_Directory::getBasePathTo(Application_Model_Application::PATH_IMAGE . '/' . $relativePath); if (!is_dir($folder)) { mkdir($folder, 0777, true); } $img_src = Core_Model_Directory::getBasePathTo($image_url); $img_dst = $folder . '/' . $filename; if (@copy($img_src, $img_dst)) { $this->setImage($relativePath . '/' . $filename); } } $this->save(); $link = new Weblink_Model_Weblink_Link(); $links = $link->findAll(array('weblink_id' => $old_weblink_id)); foreach ($links as $link) { $link->setId(null)->setWeblinkId($this->getId())->save(); } return $this; }
public function uploadAction() { if ($code = $this->getRequest()->getPost("code")) { try { if (empty($_FILES) || empty($_FILES['file']['name'])) { throw new Exception("No file has been sent"); } $path = Core_Model_Directory::getPathTo(System_Model_Config::IMAGE_PATH); $base_path = Core_Model_Directory::getBasePathTo(System_Model_Config::IMAGE_PATH); if (!is_dir($base_path)) { mkdir($base_path, 0777, true); } $adapter = new Zend_File_Transfer_Adapter_Http(); $adapter->setDestination($base_path); if ($adapter->receive()) { $file = $adapter->getFileInfo(); $config = new System_Model_Config(); $config->find($code, "code"); $config->setValue($path . DS . $file['file']['name'])->save(); $message = sprintf("Your %s has been successfully saved", $code); $this->_sendHtml(array("success" => 1, "message" => $this->_($message))); } else { $messages = $adapter->getMessages(); if (!empty($messages)) { $message = implode("\n", $messages); } else { $message = $this->_("An error occurred during the process. Please try again later."); } throw new Exception($message); } } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } } }
public static function getBaseImagePathTo($path = '') { if (!empty($path) and substr($path, 0, 1) != '/') { $path = '/' . $path; } return Core_Model_Directory::getBasePathTo(self::PATH . $path); }
public function setMessage($message) { $this->_message = $message; if ($certificate = Push_Model_Certificate::getiOSCertificat($message->getAppId())) { $this->__certificate = Core_Model_Directory::getBasePathTo($certificate); } return $this; }
public function colorize1Action() { if ($this->getRequest()->getParam('id') || $this->getRequest()->getParam('url') || $this->getRequest()->getParam('path') and $color = $this->getRequest()->getParam('color')) { $cache = Zend_Registry::get('cache'); $id = $this->getRequest()->getParam('id'); // $cache_id = 'colorized_image_'.sha1($id.':'.$color); // $cache->remove($cache_id); // $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('colorized_image'));die; // if (($img = $cache->load($cache_id)) === false) { if ($this->getRequest()->getParam('id')) { $image = new Media_Model_Library_Image(); $image->find($id); $path = $image->getLink(); $image_path = Media_Model_Library_Image::getBaseImagePathTo($path); } else { if ($this->getRequest()->getParam('url')) { $url = $this->getRequest()->getParam('url'); $path = Core_Model_Directory::getTmpDirectory(true) . '/' . $url; $image_path = $path; } else { if ($this->getRequest()->getParam('path')) { $path = $this->getRequest()->getParam('path'); $path = Core_Model_Directory::getBasePathTo(base64_decode($path)); if (!is_file($path)) { die; } $image_path = $path; } } } $color = $color; $rgb = $this->toRgb($color); list($width, $height) = getimagesize($image_path); $new_img = imagecreatefromstring(file_get_contents($image_path)); for ($x = 0; $x < $width; $x++) { for ($y = 0; $y < $height; $y++) { $colors = imagecolorat($new_img, $x, $y); $current_rgb = imagecolorsforindex($new_img, $colors); $color = imagecolorallocatealpha($new_img, $rgb['red'], $rgb['green'], $rgb['blue'], $current_rgb['alpha']); imagesetpixel($new_img, $x, $y, $color); } } imagesavealpha($new_img, true); ob_start(); @imagepng($new_img); $contents = ob_get_contents(); ob_end_clean(); imagedestroy($new_img); // $cache->save($contents, $cache_id, array('colorized_image')); $img = $contents; // } // Zend_Debug::dump($img); die; $this->getResponse()->setHeader('Content-Type', 'image/png'); $this->getLayout()->setHtml($img); die; } }
public function getPictureUrl() { $url = null; if ($this->getPicture()) { if (file_exists(Core_Model_Directory::getBasePathTo(Application_Model_Application::getImagePath() . $this->getPicture()))) { $url = Application_Model_Application::getImagePath() . $this->getPicture(); } } return $url; }
public static function addModule($module_name) { $current_language = Core_Model_Language::getCurrentLanguage(); if (file_exists(Core_Model_Directory::getBasePathTo("/languages/{$current_language}/{$module_name}.csv"))) { self::$_translator->addTranslation(array('content' => Core_Model_Directory::getBasePathTo("/languages/{$current_language}/{$module_name}.csv"), 'locale' => $current_language)); } if (file_exists(Core_Model_Directory::getBasePathTo("/languages/{$current_language}/emails/{$module_name}.csv"))) { self::$_translator->addTranslation(array('content' => Core_Model_Directory::getBasePathTo("/languages/{$current_language}/emails/{$module_name}.csv"), 'locale' => $current_language)); } }
public function deleteTranslation($language_code) { $library_id = $this->findLibraryIdByLanguageCode($language_code); $this->setLibraryId($library_id); $images = $this->findImages(); foreach ($images as $image) { if (!@unlink(Core_Model_Directory::getBasePathTo($image->getLink()))) { throw new Exception($this->_("Unable to delete the file %s", $image->getLink())); } } $this->deleteLanguageData($language_code); }
public static function getBaseImagePathTo($path = '', $app_id = null) { if (!empty($path) and substr($path, 0, 1) != '/') { $path = '/' . $path; } if (!is_null($app_id)) { $path = sprintf(self::APPLICATION_PATH . $path, $app_id); } else { $path = self::PATH . $path; } return Core_Model_Directory::getBasePathTo($path); }
protected function _initHtaccess() { $old_htaccess = Core_Model_Directory::getBasePathTo('htaccess.txt'); $new_htaccess = Core_Model_Directory::getBasePathTo('.htaccess'); if (!file_exists($new_htaccess) and is_readable($old_htaccess) and is_writable(Core_Model_Directory::getBasePathTo())) { $content = file_get_contents($old_htaccess); $content = str_replace('# ${RewriteBase}', 'RewriteBase ' . Core_Model_Directory::getPathTo(), $content); $htaccess = fopen($new_htaccess, 'w'); fputs($htaccess, $content); fclose($htaccess); } }
public function uploadAction() { if (!empty($_FILES)) { try { $path = '/var/apps/iphone/certificates/'; $base_path = Core_Model_Directory::getBasePathTo($path); $filename = uniqid() . '.pem'; $app_id = $this->getRequest()->getParam('app_id'); if (!is_dir($base_path)) { mkdir($base_path, 0775, true); } $adapter = new Zend_File_Transfer_Adapter_Http(); $adapter->setDestination($base_path); $adapter->setValidators(array('Extension' => array('pem', 'case' => false))); $adapter->getValidator('Extension')->setMessages(array('fileExtensionFalse' => $this->_("Extension not allowed, \\'%s\\' only", '%extension%'))); $files = $adapter->getFileInfo(); foreach ($files as $file => $info) { if (!$adapter->isUploaded($file)) { throw new Exception($this->_('An error occurred during process. Please try again later.')); } else { if (!$adapter->isValid($file)) { if (count($adapter->getMessages()) == 1) { $erreur_message = $this->_('Error : <br/>'); } else { $erreur_message = $this->_('Errors : <br/>'); } foreach ($adapter->getMessages() as $message) { $erreur_message .= '- ' . $message . '<br/>'; } throw new Exception($erreur_message); } else { $adapter->addFilter(new Zend_Filter_File_Rename(array('target' => $base_path . $filename, 'overwrite' => true))); $adapter->receive($file); } } } $certificat = new Push_Model_Certificate(); $certificat->find(array('type' => 'ios', 'app_id' => $app_id)); if (!$certificat->getId()) { $certificat->setType('ios')->setAppId($app_id); } $certificat->setPath($path . $filename)->save(); $datas = array('success' => 1, 'files' => 'eeeee', 'message_success' => $this->_('Info successfully saved'), 'message_button' => 0, 'message_timeout' => 2); } catch (Exception $e) { $datas = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($datas)); } }
public static function checkPermissions() { $errors = array(); $base_path = Core_Model_Directory::getBasePathTo('/'); if (is_file($base_path . 'htaccess.txt') and !file_exists($base_path . ".htaccess")) { if (!is_writable($base_path)) { $errors[] = 'The root directory /'; } if (!is_writable($base_path . 'htaccess.txt')) { $errors[] = '/htaccess.txt'; } } $paths = array('var', 'var/cache', 'var/session', 'var/tmp'); foreach ($paths as $path) { if (!is_dir($base_path . $path)) { @mkdir($base_path . $path, 0777); } if (!is_writable($base_path . $path)) { $errors[] = $path; } } // if(!is_writable($base_path.'app/modules')) { // $errors[] = '/app/modules and all of its subfolders'; // } // // $paths = array('app/design/desktop/siberian/layout', 'app/design/desktop/siberian/template'); // foreach($paths as $path) { // if(!is_writable($base_path.$path)) { // $errors[] = '/app/design/desktop/siberian and all of its subfolders'; // break; // } // } // // $paths = array('app/design/mobile/siberian/layout', 'app/design/mobile/siberian/template'); // foreach($paths as $path) { // if(!is_writable($base_path.$path)) { // $errors[] = '/app/design/mobile/siberian and all of its subfolders'; // break; // } // } $paths = array("app/configs"); foreach ($paths as $path) { if (!is_writable($base_path . $path)) { $errors[] = $path; } } return $errors; }
public static function checkPermissions() { $errors = array(); $base_path = Core_Model_Directory::getBasePathTo('/'); if (is_file($base_path . 'htaccess.txt')) { if (!is_writable($base_path)) { $errors[] = 'The root directory /'; } if (!is_writable($base_path . 'htaccess.txt')) { $errors[] = '/htaccess.txt'; } } $paths = array('var/cache', 'var/session', 'var/tmp'); foreach ($paths as $path) { if (!is_file($base_path . $path)) { // the folder does not exist, create it mkdir($base_path . $path, 0777, true); } if (!is_writable($base_path . $path)) { $errors[] = '/var and all of its subfolders'; break; } } if (!is_writable($base_path . 'app/modules')) { $errors[] = '/app/modules and all of its subfolders'; } $paths = array('app/design/desktop/siberian/layout', 'app/design/desktop/siberian/template'); foreach ($paths as $path) { if (!is_writable($base_path . $path)) { $errors[] = '/app/design/desktop/siberian and all of its subfolders'; break; } } $paths = array('app/design/mobile/siberian/layout', 'app/design/mobile/siberian/template'); foreach ($paths as $path) { if (!is_writable($base_path . $path)) { $errors[] = '/app/design/mobile/siberian and all of its subfolders'; break; } } $paths = array("app/design/email", "images", "app/configs", "app/configs/app.sample.ini"); foreach ($paths as $path) { if (!is_writable($base_path . $path)) { $errors[] = $path; } } return $errors; }
public static function prepare() { $territories = Zend_Locale::getTranslationList('language'); $directories = new DirectoryIterator(Core_Model_Directory::getBasePathTo('languages')); foreach ($directories as $directory) { $dir_name = $directory->getFileName(); if (!$directory->isDot() and isset($territories[$dir_name])) { $locale = Zend_Locale::getLocaleToTerritory($dir_name); self::$_languages[$directory->getFileName()] = new Core_Model_Default(array('code' => $directory->getFileName(), 'name' => ucfirst($territories[$dir_name]), 'locale' => $locale)); self::$_language_codes[] = $directory->getFileName(); } } self::$_languages[self::DEFAULT_LANGUAGE] = new Core_Model_Default(array('code' => self::DEFAULT_LANGUAGE, 'name' => ucfirst($territories[self::DEFAULT_LANGUAGE]), 'locale' => self::DEFAULT_LOCALE)); self::$_language_codes[] = self::DEFAULT_LANGUAGE; asort(self::$_languages); }
protected function _cpFolder() { $src = Core_Model_Directory::getBasePathTo(self::SOURCE_FOLDER); $dst = Core_Model_Directory::getBasePathTo(self::DEST_FOLDER); // Supprime le dossier s'il existe puis le créé if (is_dir($dst)) { Core_Model_Directory::delete($dst); } mkdir($dst, 0775, true); // Copie les sources Core_Model_Directory::duplicate($src, $dst); $this->_zipname = 'ios_source'; $this->_dst = $dst . '/Siberian'; $this->_base_dst = $dst; return $this; }
public function prepare($name) { $this->_name = $name; $this->findByName($name); if (!$this->getId()) { $this->setName($name)->setVersion(self::DEFAULT_VERSION); $this->_isInstalled = false; } else { $this->_isInstalled = true; } $this->_basePath = Core_Model_Directory::getBasePathTo("app/modules/{$name}"); $versions = array(); $installer = array("version" => "0.0.0"); if (is_dir("{$this->_basePath}/db")) { $max_version = "0.0.0"; $files = new DirectoryIterator("{$this->_basePath}/db"); if (!$this->isInstalled()) { foreach ($files as $file) { if ($file->isDot() or !preg_match("/^(database)([0-9.]*)(install.php)\$/", $file->getFilename())) { continue; } $version = str_replace(array('database.', '.install.php'), '', $file); if (version_compare($version, $installer["version"]) > 0) { $installer = array("version" => $version, "path" => $file->getPathName()); } } } foreach ($files as $file) { if ($file->isDot() or !preg_match("/^(database)(([0-9.]*)|(.template\\.))(php)\$/", $file->getFilename())) { continue; } $version = str_replace(array('database.', '.php'), '', $file->getFilename()); if (version_compare($version, $installer["version"]) > 0) { $this->_dbFiles[$version] = $file->getPathName(); $versions[] = $version; } } if (!empty($installer["path"])) { $this->_dbFiles[$installer["version"]] = $installer["path"]; $versions[] = $installer["version"]; } uksort($this->_dbFiles, "version_compare"); usort($versions, "version_compare"); } $this->_lastVersion = !empty($versions) ? end($versions) : self::DEFAULT_VERSION; return $this; }
public function saveFile($file) { $path = Core_Model_Directory::getTmpDirectory(true) . "/" . $file; $new_name = null; if (file_exists($path)) { $path_parts = pathinfo($path); $extension = $path_parts["extension"]; $new_name = uniqid() . "." . $extension; $base_path = Core_Model_Directory::getBasePathTo("images/application/" . $this->getAppId() . "/messages/"); if (!dir($base_path)) { mkdir($base_path, 0777, true); } rename($path, $base_path . $new_name); $message_file = new Message_Model_Application_File(); $message_file->setMessageId($this->getId())->setFile($new_name)->save(); } return $new_name; }
public function colorizeAction() { if ($this->getRequest()->getParam('id') || $this->getRequest()->getParam('url') || $this->getRequest()->getParam('path') and $color = $this->getRequest()->getParam('color')) { $params = array('id', 'url', 'path', 'color'); $path = ''; foreach ($params as $param) { $id[] = $this->getRequest()->getParam($param); } $id = md5(implode('+', $id)); if ($image_id = $this->getRequest()->getParam('id')) { $image = new Media_Model_Library_Image(); $image->find($image_id); if (!$image->getCanBeColorized()) { $color = null; } $path = $image->getLink(); $path = Media_Model_Library_Image::getBaseImagePathTo($path, $image->getAppId()); } else { if ($url = $this->getRequest()->getParam('url')) { $path = Core_Model_Directory::getTmpDirectory(true) . '/' . $url; } else { if ($path = $this->getRequest()->getParam('path')) { $path = base64_decode($path); if (!Zend_Uri::check($path)) { $path = Core_Model_Directory::getBasePathTo($path); if (!is_file($path)) { die; } } } } } $image = new Core_Model_Lib_Image(); $image->setId($id)->setPath($path)->setColor($color)->colorize(); ob_start(); @imagepng($image->getResources()); $contents = ob_get_contents(); ob_end_clean(); imagedestroy($image->getResources()); $this->getResponse()->setHeader('Content-Type', 'image/png'); $this->getLayout()->setHtml($contents); } }
public function copyTo($new_library_id, $option) { $images = $this->getImages(); foreach ($images as $image) { $file = pathinfo($image->getLink()); $filename = $file['basename']; $relativePath = $option->getImagePathTo(); $folder = Core_Model_Directory::getBasePathTo(Application_Model_Application::PATH_IMAGE . $relativePath); if (!is_dir($folder)) { mkdir($folder, 0777, true); } $img_src = Core_Model_Directory::getBasePathTo($image->getLink()); $img_dst = $folder . '/' . $filename; if (@copy($img_src, $img_dst)) { $image->setLink($relativePath . '/' . $filename); } $image->setId(null)->setLibraryId($new_library_id)->save(); } }
public function copyTo($option) { $this->setId(null)->setValueId($option->getId()); if ($image_url = $this->getCoverUrl()) { $file = pathinfo($image_url); $filename = $file['basename']; $relativePath = $option->getImagePathTo(); $folder = Core_Model_Directory::getBasePathTo(Application_Model_Application::PATH_IMAGE . '/' . $relativePath); if (!is_dir($folder)) { mkdir($folder, 0777, true); } $img_src = Core_Model_Directory::getBasePathTo($image_url); $img_dst = $folder . '/' . $filename; if (@copy($img_src, $img_dst)) { $this->setCover($relativePath . '/' . $filename); } } $this->save(); return $this; }
public function sendException($message, $log_prefix = "error_", $show_500_page = true) { $this->_writers = array(); $filename = $log_prefix . uniqid() . '.log'; $writer = new Zend_Log_Writer_Stream(Core_Model_Directory::getBasePathTo('var/log/' . $filename)); $this->addWriter($writer); $this->crit($message); if ($show_500_page) { if (APPLICATION_ENV == "production") { header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); header("Location: /errors/500.php?log=" . $filename); } else { header("Content-Type: text/plain"); echo "Error log: {$filename}" . PHP_EOL . PHP_EOL; echo "Stack Trace:" . PHP_EOL . PHP_EOL; print_r($message); } die; } return $this; }
<?php $media_library = new Media_Model_Library(); $media_library->setName("Code Scan")->save(); $icon_id = null; $files_icon = new DirectoryIterator(Core_Model_Directory::getBasePathTo("images/library/code_scan")); foreach ($files_icon as $file) { if ($file->isDot()) { continue; } $icon = new Media_Model_Library_Image(); $icon_data = array("library_id" => $media_library->getId(), "link" => "/code_scan/" . $file->getFilename(), "can_be_colorized" => 1); $icon->setData($icon_data)->save(); if ($icon_id == null) { $icon_id = $icon->getId(); } } $option_data = array("code" => "code_scan", "name" => "Code Scan", "model" => "Codescan_Model_Codescan", "library_id" => $media_library->getId(), "icon_id" => $icon_id, "desktop_uri" => "codescan/application/", "mobile_uri" => "codescan/mobile_view/", "position" => 150); $option = new Application_Model_Option(); $option->setData($option_data)->save();
public function getBackgroundImageTablet($base = false) { return $base ? Core_Model_Directory::getBasePathTo(self::PATH_IMAGE . $this->getData('background_image_tablet')) : Core_Model_Directory::getPathTo($this->getData('background_image_tablet')); }
public function deletepostAction() { $id = $this->getRequest()->getParam("id"); $html = ''; try { $promotion = new Promotion_Model_Promotion(); $promotion->find($id); if ($promotion->getUnlockBy() == "qrcode") { $image_name = $promotion->getId() . "-qrpromotion_qrcode.png"; $file = Core_Model_Directory::getBasePathTo("/images/application/" . $this->getApplication()->getId() . "/application/qrpromotion/" . $image_name); if (file_exists($file)) { unlink($file); } } $promotion->delete(); $html = array('promotion_id' => $id, 'success' => 1, 'success_message' => $this->_('Discount successfully deleted'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'url' => '/promotion/admin/list'); } $this->getLayout()->setHtml(Zend_Json::encode($html)); }
protected function _parseCsv($lang_id) { $data = $translation_files_data = $translation_files = array(); $user_translation_dir = Core_Model_Directory::getBasePathTo("languages" . DS . $lang_id . DS); $default_base_path = Core_Model_Directory::getBasePathTo("languages/default"); $files = new DirectoryIterator($default_base_path); foreach ($files as $file) { if ($file->isDot()) { continue; } $pathinfo = pathinfo($file); if (empty($pathinfo["extension"]) or $pathinfo["extension"] != "csv") { continue; } $translation_files[$file->getFilename()] = $file->getFilename(); $resource = fopen($file->getRealPath(), "r"); $translation_files_data[$file->getFilename()] = array(); while ($content = fgetcsv($resource, 1024, ";", '"')) { $translation_files_data[$file->getFilename()][$content[0]] = null; } fclose($resource); if (!is_file($user_translation_dir . $file->getFilename())) { continue; } $resource = fopen($user_translation_dir . $file->getFilename(), "r"); while ($content = fgetcsv($resource, 1024, ";", '"')) { $translation_files_data[$file->getFilename()][$content[0]] = $content[1]; asort($translation_files_data[$file->getFilename()]); } fclose($resource); } $data["translation_files"] = $translation_files; $data["translation_files_data"] = $translation_files_data; $data["info"] = array(); return $data; }