public function findallAction()
 {
     $data = parent::_findconfig();
     $timezones = DateTimeZone::listIdentifiers();
     if (empty($timezones)) {
         $locale = Zend_Registry::get("Zend_Locale");
         $timezones = $locale->getTranslationList('TimezoneToTerritory');
     }
     foreach ($timezones as $timezone) {
         $data["territories"][$timezone] = $timezone;
     }
     foreach (Core_Model_Language::getCountriesList() as $country) {
         $data["currencies"][$country->getCode()] = $country->getName() . " ({$country->getSymbol()})";
     }
     $countries = $countries = Zend_Registry::get('Zend_Locale')->getTranslationList('Territory', null, 2);
     asort($countries, SORT_LOCALE_STRING);
     $data["countries"] = $countries;
     $languages = array();
     foreach (Core_Model_Language::getLanguages() as $language) {
         $languages[$language->getCode()] = $language->getName();
     }
     if (!empty($languages) and count($languages) > 1) {
         $data["languages"] = $languages;
     }
     $this->_sendHtml($data);
 }
 public function findallAction()
 {
     $option = $this->getCurrentOptionValue();
     $currency = Core_Model_Language::getCurrentCurrency();
     $data = array("currency_symbol" => Core_Model_Language::getCurrentCurrency()->getSymbol(), "page_title" => $option->getTabbarName(), "format" => $currency->toCurrency(1, array("locale" => $currency->getLocale())));
     $this->_sendHtml($data);
 }
Beispiel #3
0
 protected function _prepareFiles()
 {
     $links = glob($this->_dst . '/src/com/' . $this->_formatted_bundle_name . '/' . $this->_formatted_name . '/*');
     $url = $this->getUrl();
     if (!$links) {
         return $this;
     }
     $links = array_merge(array($this->_dst . '/AndroidManifest.xml'), $links);
     foreach ($links as $link) {
         if (!is_dir($link)) {
             $this->__replace(array('siberian.app' => $this->_formatted_bundle_name . '.' . $this->_formatted_name), $link);
             if (strpos($link, 'CommonUtilities.java') !== false) {
                 $this->__replace(array('String SENDER_ID = ""' => 'String SENDER_ID = "' . Push_Model_Certificat::getAndroidSenderId() . '"', 'SERVEUR_URL = "http://www.siberiancms.com/";' => 'SERVEUR_URL = "' . $this->getUrl() . '";'), $link);
             }
         }
     }
     $name = str_replace(array('&', '/'), 'AND', $this->getApplication()->getName());
     $this->__replace(array('<name>Siberian</name>' => '<name>' . $name . '</name>'), $this->_dst . '/.project');
     $replacements = array('http://app.siberiancms.com' => $this->getApplication()->getUrl(null, array(), false, 'en'), '<string name="app_name">Siberian</string>' => '<string name="app_name">' . $name . '</string>');
     $this->__replace($replacements, $this->_dst . '/res/values/strings.xml');
     foreach (Core_Model_Language::getLanguageCodes() as $lang) {
         if ($lang != 'en') {
             $replacements = array('http://app.siberiancms.com' => $this->getApplication()->getUrl(null, array(), false, $lang), '<string name="app_name">Siberian</string>' => '<string name="app_name">' . $name . '</string>');
             $this->__replace($replacements, $this->_dst . '/res/values-' . $lang . '/strings.xml');
         }
     }
     return $this;
 }
Beispiel #4
0
 public function setPathInfo($pathInfo = null)
 {
     parent::setPathInfo($pathInfo);
     $path = $this->_pathInfo;
     $paths = explode('/', trim($path, '/'));
     $language = !empty($paths[0]) ? $paths[0] : '';
     if (in_array($language, Core_Model_Language::getLanguageCodes())) {
         $this->_language_code = $language;
         unset($paths[array_search($language, $paths)]);
         $paths = array_values($paths);
     }
     if (!$this->isInstalling()) {
         if (!empty($paths[0]) and $paths[0] == Application_Model_Application::OVERVIEW_PATH) {
             $this->_is_application = true;
             $this->_use_application_key = true;
             unset($paths[0]);
         }
         if (Application_Model_Application::getInstance()->getDomain() == $this->getHttpHost()) {
             $this->_is_application = true;
             $this->_use_application_key = false;
         }
     }
     $paths = array_diff($paths, Core_Model_Language::getLanguageCodes());
     $paths = array_values($paths);
     $this->_pathInfo = '/' . implode('/', $paths);
     return $this;
 }
Beispiel #5
0
 public function save()
 {
     $price = trim(str_replace(array(Core_Model_Language::getCurrencySymbol(), ' '), '', $this->getData('price')));
     $filter = new Zend_Filter_LocalizedToNormalized();
     $filter->setOptions(array('locale' => Zend_Registry::get('Zend_Locale')));
     $this->setData('price', $filter->filter($price));
     parent::save();
     return $this;
 }
Beispiel #6
0
 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 findallAction()
 {
     $languages = Core_Model_Language::getLanguages();
     $data = array();
     foreach ($languages as $lang) {
         if ($lang->getCode() == "en") {
             continue;
         }
         $data[] = array("id" => base64_encode($lang->getCode()), "code" => $lang->getCode(), "name" => $lang->getName());
     }
     $this->_sendHtml($data);
 }
 public function findallAction()
 {
     $data = array();
     if (Core_Model_Language::getCurrentLanguage() != Core_Model_Language::DEFAULT_LANGUAGE) {
         Core_Model_Translator::addModule("mcommerce");
         Core_Model_Translator::addModule("comment");
         $translations = array("OK", "Website", "Phone", "Locate", "Contact successfully added to your address book", "Unable to add the contact to your address book", "You must give the permission to the app to add a contact to your address book", "You already have this user in your contact", "The address you're looking for does not exists.", "An error occurred while loading. Please, try again later.", "An unexpected error occurred while calculating the route.", "Cart", "Proceed", "Next", "Payment", "Delivery", "My information", "Review", "Some mandatory fields are empty.", "Validate", "The payment has been cancelled, something wrong happened? Feel free to contact us.", "Map", "Invalid place", "Unable to calculate the route.", "No address to display on map.", "You must share your location to access this page.", "No place to display on map.", "An error occurred while loading places.", "Load More", "This section is unlocked for mobile users only", "You have gone offline", "Cancel", "Confirm", "View", "Offline content", "Don't close the app while downloading. This may take a while.", "Do you want to download all the contents now to access it when offline? If you do, we recommend you to use a WiFi connection.");
         foreach ($translations as $translation) {
             $data[$translation] = $this->_($translation);
         }
     }
     $this->_sendHtml($data);
 }
Beispiel #9
0
 protected function _initRequest()
 {
     Core_Model_Language::prepare();
     $frontController = $this->_front_controller;
     $this->_request = new Siberian_Controller_Request_Http();
     $this->_request->isInstalling(!Installer_Model_Installer::isInstalled());
     $this->_request->setPathInfo();
     $baseUrl = $this->_request->getScheme() . '://' . $this->_request->getHttpHost() . $this->_request->getBaseUrl();
     $this->_request->setBaseUrl($baseUrl);
     $frontController->setRequest($this->_request);
     Siberian_View::setRequest($this->_request);
     Core_Model_Default::setBaseUrl($this->_request->getBaseUrl());
 }
Beispiel #10
0
 public static function create($url = '', array $params = array(), $locale = null)
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     if ($request->getParam('overview') and !in_array('overview', array_values($params))) {
         $params['overview'] = 1;
     }
     $exclude = array();
     $setLocale = false;
     $encode = false;
     if (!empty($params['encode'])) {
         $encode = true;
         unset($params['encode']);
     }
     if (!is_null($locale) and in_array($locale, Core_Model_Language::getLanguageCodes())) {
         $request->addLanguageCode($locale);
     }
     $url = str_replace($request->getBaseUrl(), '', $url);
     $url = trim($url, '/');
     $url = explode('/', $url);
     $url = array_diff($url, $exclude);
     $count = count($url);
     if ($count == 0) {
         $url = array_fill(0, 3, '');
     }
     while ($count > 0 && $count++ < 3) {
         $url[] = 'index';
     }
     $url = array_values($url);
     $url = array('module' => $url[0], 'controller' => $url[1], 'action' => $url[2]);
     if (!empty($params)) {
         if (!empty($params['module'])) {
             unset($params['module']);
         }
         if (!empty($params['controller'])) {
             unset($params['controller']);
         }
         if (!empty($params['action'])) {
             unset($params['action']);
         }
         $url = array_merge($url, $params);
     }
     $reset = empty($params['keep_params']);
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $url = $router->assemble($url, 'default', $reset, false);
     $request->setLanguageCode(null);
     return $url;
 }
 public function findAction()
 {
     $previews = new Preview_Model_Preview();
     $data = array();
     if ($this->getRequest()->getParam("preview_id")) {
         $previews = $previews->findAll(array("aop.preview_id" => $this->getRequest()->getParam("preview_id")));
         $data_tmp = array();
         foreach ($previews as $preview) {
             if ($preview->getlibraryId()) {
                 $images = $preview->findImages();
                 $images_data = array();
                 foreach ($images as $image) {
                     $images_data[] = array("id" => $image->getImageId(), "link" => $image->getlink(), "new" => 0, "to_delete" => 0);
                 }
             }
             if ($preview->getPreviewId()) {
                 $data_tmp[$preview->getLanguageCode()] = array("title" => $preview->getTitle(), "description" => $preview->getDescription(), "language_code" => $preview->getLanguageCode(), "from_database" => 1, "images" => $images_data);
             }
         }
         if (!empty($data_tmp)) {
             $data["previews"] = $data_tmp;
         }
         $data["section_title_one"] = $this->_("Edit the preview");
     } else {
         $data["section_title_one"] = $this->_("Create a new preview");
         $option = new Application_Model_Option();
         $option_list = array();
         $options = $option->findAll(array(), 'position ASC');
         foreach ($options as $option) {
             $option_list[$option->getId()] = $option->getName();
         }
         $data["options"] = $option_list;
     }
     $data["section_title_two"] = $this->_("Preview images");
     $languages = Core_Model_Language::getLanguages();
     $language_list = array();
     foreach ($languages as $language) {
         $language_list[$language->getCode()] = $language->getName();
     }
     $data["languages"] = $language_list;
     $data["current_language"] = Core_Model_Language::getCurrentLanguage();
     $this->_sendHtml($data);
 }
 public function findAction()
 {
     $data = $data_csv = $data_all = array();
     if ($lang_id = $this->getRequest()->getParam("lang_id")) {
         $lang_id = base64_decode($lang_id);
         $lang_id = explode("_", strtolower($lang_id));
         if (count($lang_id) == 2) {
             $lang_id[1] = strtoupper($lang_id[1]);
         }
         $lang_id = implode("_", $lang_id);
         $data["section_title"] = $this->_("Edit the language: %s", Core_Model_Language::getLanguage($lang_id)->getName());
         $data["is_edit"] = true;
     } else {
         $data["section_title"] = $this->_("Create a new language");
         $data["is_edit"] = false;
     }
     $data["country_code"] = $lang_id;
     $locale = Zend_Registry::get("Zend_Locale");
     $languages = $locale->getTranslationList('language');
     $existing_languages = Core_Model_Language::getLanguageCodes();
     foreach ($languages as $k => $language) {
         if (!$locale->isLocale($k) or in_array($k, $existing_languages)) {
             unset($languages[$k]);
         }
     }
     asort($languages, SORT_LOCALE_STRING);
     $data["country_codes"] = $languages;
     $data_csv = $this->_parseCsv($lang_id);
     $data_xml = $this->_parseXml($lang_id);
     $data_all["translation_files"] = array_merge($data_csv["translation_files"], $data_xml["translation_files"]);
     $data_all["translation_files_data"] = array_merge($data_csv["translation_files_data"], $data_xml["translation_files_data"]);
     ksort($data_all["translation_files"]);
     $data["translation_files"] = $data_all["translation_files"];
     ksort($data_all["translation_files_data"]);
     $data["translation_files_data"] = $data_all["translation_files_data"];
     $data["info"] = array_merge($data_csv["info"], $data_xml["info"]);
     $this->_sendHtml($data);
 }
 public function deleteAction()
 {
     try {
         if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) {
             $preview = new Preview_Model_Preview();
             $preview->find($data["preview_id"]);
             if ($preview->getPreviewId()) {
                 $languages = Core_Model_Language::getLanguages();
                 foreach ($languages as $language) {
                     $preview->deleteTranslation($language->getCode());
                 }
             }
             $preview->delete();
             $data = array("success" => 1, "message" => $this->_("Your preview has been deleted successfully."));
             $this->_sendHtml($data);
         } else {
             throw new Exception($this->_("An error occurred while deleting your preview. Please try again later."));
         }
     } catch (Exception $e) {
         $data = array("error" => 1, "message" => $e->getMessage());
         $this->_sendHtml($data);
     }
 }
Beispiel #14
0
 public function setPathInfo($pathInfo = null)
 {
     parent::setPathInfo($pathInfo);
     $path = $this->_pathInfo;
     $paths = explode('/', trim($path, '/'));
     $language = !empty($paths[0]) ? $paths[0] : '';
     if (in_array($language, Core_Model_Language::getLanguageCodes())) {
         $this->_language_code = $language;
         unset($paths[0]);
         $paths = array_values($paths);
     }
     if (!$this->isInstalling()) {
         $paths = $this->_initApplication($paths);
         if (!$this->isApplication()) {
             $this->_initWhiteLabelEditor();
         }
     }
     // $paths = array_diff($paths, Core_Model_Language::getLanguageCodes());
     $paths = array_values($paths);
     $this->_pathInfo = '/' . implode('/', $paths);
     $detector = new Mobile_Detect();
     $this->_is_native = $detector->isNative();
     return $this;
 }
Beispiel #15
0
 public function formatPrice($price, $currency = null)
 {
     $price = preg_replace(array('/(,)/', '/[^0-9.]/'), array('.', ''), $price);
     if ($currency) {
         $currency = new Zend_Currency($currency);
     } else {
         $currency = Core_Model_Language::getCurrentCurrency();
     }
     return $currency->toCurrency($price);
 }
Beispiel #16
0
 protected function _initLocale()
 {
     $locale = new Zend_Locale();
     $locale_code = Core_Model_Language::DEFAULT_LOCALE;
     $is_installing = $this->getRequest()->isInstalling();
     if ($this->getRequest()->isApplication() && $this->getApplication()->getLocale()) {
         $locale_code = $this->getApplication()->getLocale();
     } else {
         if (!$is_installing) {
             $currency_code = System_Model_Config::getValueFor("system_currency");
             if ($currency_code) {
                 $currency = new Zend_Currency(null, $currency_code);
                 Core_Model_Language::setCurrentCurrency($currency);
             }
             $territory = System_Model_Config::getValueFor("system_territory");
             if ($territory) {
                 $locale_code = $locale->getLocaleToTerritory($territory);
             } else {
                 $locale_code = new Zend_Locale(Core_Model_Language::getCurrentLocale());
             }
         }
     }
     if (!$is_installing) {
         $timezone = System_Model_Config::getValueFor("system_timezone");
         if ($timezone) {
             date_default_timezone_set($timezone);
         }
     }
     $locale->setLocale($locale_code);
     Zend_Registry::set('Zend_Locale', $locale);
 }
Beispiel #17
0
 protected function _initLocale()
 {
     $locale = Core_Model_Language::DEFAULT_LOCALE;
     if ($this->getRequest()->isApplication()) {
         $locale = $this->getApplication()->getLocale();
     } else {
         $locale = new Zend_Locale(Core_Model_Language::getCurrentLocale());
     }
     Zend_Registry::set('Zend_Locale', new Zend_Locale($locale));
 }
 public function languagesAction()
 {
     $this->getLayout()->setHtml(implode(",", Core_Model_Language::getLanguageCodes()));
 }
 public function validateAction()
 {
     $data_translations = array("required" => $this->_("This field is required."), "remote" => $this->_("Please fix this field."), "email" => $this->_("Please enter a valid email address."), "url" => $this->_("Please enter a valid URL."), "date" => $this->_("Please enter a valid date."), "dateISO" => $this->_("Please enter a valid date (ISO)."), "number" => $this->_("Please enter a valid number."), "digits" => $this->_("Please enter only digits."), "creditcard" => $this->_("Please enter a valid credit card number."), "equalTo" => $this->_("Please enter the same value again."), "maxlength" => $this->_("Please enter no more than {0} characters."), "minlength" => $this->_("Please enter at least {0} characters."), "rangelength" => $this->_("Please enter a value between {0} and {1} characters long."), "range" => $this->_("Please enter a value between {0} and {1}."), "max" => $this->_("Please enter a value less than or equal to {0}."), "min" => $this->_("Please enter a value greater than or equal to {0}."));
     $datas = array("languagecode" => current(explode("_", Core_Model_Language::getCurrentLocale())), "translations" => $data_translations);
     die(json_encode($datas));
 }
Beispiel #20
0
    protected function _changeData()
    {
        // Créé les variables et ouvre le fichier
        $file = $this->_dst . '/Application/Objects/url.m';
        $newContent = '';
        $common = @fopen($file, 'r+');
        if (!$common) {
            throw new Exception('An error occured while processing the file ' . $file);
        }
        if (!($uri = parse_url($this->getApplication()->getUrl()))) {
            throw new Exception("An error occured while parsing the application's URL. Please check the URL and try again.");
        }
        if (empty($uri['scheme']) or empty($uri['host'])) {
            throw new Exception($this->_("An error occured while parsing the application's URL. Please check the URL and try again."));
        }
        $scheme = $uri['scheme'];
        $domain = $uri['host'];
        $path = ltrim(str_replace(Core_Model_Language::getLanguageCodes(), '', $uri['path']), '/');
        while ($data = fgets($common, 1024)) {
            if (stripos($data, 'scheme = @"') !== false) {
                $newContent .= '        scheme = @"' . $scheme . '";
';
            } else {
                if (stripos($data, 'domain = @"') !== false) {
                    $newContent .= '        domain = @"' . $domain . '";
';
                } else {
                    if (stripos($data, 'path = @"') !== false) {
                        $newContent .= '        path = @"' . $path . '";
';
                    } else {
                        $newContent .= $data;
                    }
                }
            }
        }
        fclose($common);
        // Met à jour le contenu du fichier
        $common = @fopen($file, 'w');
        fputs($common, $newContent);
        fclose($common);
        // Met à jour le contenu du fichier
        $common = @fopen($file, 'w');
        fputs($common, $newContent);
        fclose($common);
    }
Beispiel #21
0
 public function getCacheId()
 {
     return 'SOCIAL_FACEBOOK_' . Core_Model_Language::getCurrentLanguage() . sha1($this->getFbUser() . "-" . $this->_page);
 }
Beispiel #22
0
 public function createRecurring($token)
 {
     $params = array();
     $lines = $this->_order->getLines();
     $at_least_one_item_is_recurring = false;
     foreach ($lines as $k => $item) {
         if ($item->getIsRecurrent() == "1") {
             $k = 0;
             $unit_price_excl_tax = round($item->getPriceExclTax(), 2);
             $unit_price = round($unit_price_excl_tax * (1 + $this->_order->getTaxRate() / 100), 2);
             // prix TTC
             $tax_item = round($unit_price - $unit_price_excl_tax, 2);
             $params['DESC'] = $item->getName();
             $params['TAXAMT'] = !empty($params['TAXAMT']) ? $params['TAXAMT'] + $tax_item * $item->getQty() : $tax_item * $item->getQty();
             $params['AMT'] = round($item->getTotalPriceExclTax(), 2);
             $params["L_PAYMENTREQUEST_0_ITEMCATEGORY{$k}"] = 'Physical';
             $params["L_PAYMENTREQUEST_0_NAME{$k}"] = $item->getName();
             $params["L_PAYMENTREQUEST_0_QTY{$k}"] = $item->getQty();
             $params["L_PAYMENTREQUEST_0_TAXAMT{$k}"] = $tax_item;
             $params["L_PAYMENTREQUEST_0_AMT{$k}"] = round($item->getTotalPriceExclTax(), 2);
             $at_least_one_item_is_recurring = true;
         }
     }
     if (!empty($params)) {
         $frequency = $this->_order->getSubscription()->getPaymentFrequency();
         $date = $this->getNextPaymentDue($frequency);
         $params = array_merge($params, array('TOKEN' => $token, 'CURRENCYCODE' => Core_Model_Language::getCurrentCurrency()->getShortName(), 'PROFILESTARTDATE' => $date, 'BILLINGPERIOD' => $this->getPeriod($frequency), 'BILLINGFREQUENCY' => 1, 'EMAIL' => $this->_order->getAdminEmail()));
         $response = $this->request(self::CREATE_RECURRING_PAYMENTS_PROFILE, $params);
         if ($response) {
             return true;
         }
     }
     return !$at_least_one_item_is_recurring;
 }
Beispiel #23
0
 public function save()
 {
     $this->checkType();
     if (!$this->getIsDeleted()) {
         if (!$this->getPosition()) {
             $this->setPosition($this->findLastPosition($this->getValueId()));
         }
         if (!$this->getData('type')) {
             $this->setData('type', 'simple');
         }
         if ($this->getData('type') == 'simple') {
             $price = Core_Model_Language::normalizePrice($this->getData('price'));
             $this->setData('price', $price);
         }
         //MCommerce multi pictures
         $this->addPictures();
         $this->deletePictures();
         parent::save();
         if ($this->getNewCategoryIds()) {
             $this->getTable()->saveCategoryIds($this->getId(), $this->getNewCategoryIds());
         }
         $this->getType()->setProduct($this)->save();
     } else {
         parent::save();
     }
     return $this;
 }
Beispiel #24
0
 public function getCacheId()
 {
     return 'AGENDA_OVI_' . sha1($this->getValueId() . Core_Model_Language::getCurrentLanguage());
 }
Beispiel #25
0
 public function getCountryCode()
 {
     $code = $this->getData('country_code');
     if (is_null($code)) {
         $code = Core_Model_Language::getCurrentLocaleCode();
     }
     return $code;
 }
Beispiel #26
0
 protected function _initDesign()
 {
     if (!$this->_request->isInstalling()) {
         $request = $this->_request;
         $this->_prepareBlocks();
     }
     $locale = Zend_Registry::get('Zend_Locale');
     $lang = Core_Model_Language::getCurrentLanguage();
     $detect = new Mobile_Detect();
     $this->getPluginLoader()->addPrefixPath('Siberian_Application_Resource', 'Siberian/Application/Resource');
     if (!$this->_request->isInstalling()) {
         if ($this->_request->isApplication()) {
             $apptype = 'mobile';
         } else {
             $apptype = 'desktop';
         }
         if ($detect->isMobile() || $apptype == 'mobile') {
             $device_type = 'mobile';
         } else {
             $device_type = 'desktop';
         }
         $code = 'siberian';
     } else {
         $apptype = 'desktop';
         $device_type = 'desktop';
         $code = "installer";
     }
     $base_paths = array(APPLICATION_PATH . "/design/email/template/");
     define('APPLICATION_TYPE', $apptype);
     define('DEVICE_TYPE', $device_type);
     define('DEVICE_IS_IPHONE', $detect->isIphone() || $detect->isIpad());
     define('IS_APPLICATION', $detect->isApplication() && $this->_request->isApplication());
     Core_Model_Directory::setDesignPath("/app/design/{$apptype}/{$code}");
     define('DESIGN_CODE', $code);
     $resources = array('resources' => array('layout' => array('layoutPath' => APPLICATION_PATH . "/design/{$apptype}/{$code}/template/page")));
     $base_paths[] = APPLICATION_PATH . "/design/{$apptype}/{$code}/template/";
     $this->setOptions($resources);
     $this->bootstrap('View');
     $view = $this->getResource('View');
     $view->doctype('HTML5');
     foreach ($base_paths as $base_path) {
         $view->addBasePath($base_path);
     }
     Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNeverRender(true);
     Core_View_Default::setDevice($detect);
 }
Beispiel #27
0
 public function getPreview()
 {
     if (!$this->_preview) {
         $preview = new Preview_Model_Preview();
         $language = Core_Model_Language::getCurrentLanguage();
         $this->_preview = $preview->find(array("aop.option_id" => $this->getId(), "aopl.language_code" => $language));
     }
     return $this->_preview;
 }
Beispiel #28
0
 public static function getCountriesList()
 {
     if (is_null(self::$_countries_list)) {
         self::$_countries_list = array();
         $locale = Zend_Registry::get('Zend_Locale');
         $currency = new Zend_Currency();
         foreach (Zend_Locale::getTranslationList('Territory', null, 2) as $ter => $name) {
             $country_code = Zend_Locale::getLocaleToTerritory($ter);
             if (!is_null($country_code)) {
                 try {
                     $symbol = $currency->getSymbol($country_code);
                     if (!empty($symbol)) {
                         $countries[$country_code] = array('code' => $country_code, 'name' => $name, 'symbol' => $symbol);
                     }
                 } catch (Exception $e) {
                 }
             }
         }
         uasort($countries, 'cmp');
         foreach ($countries as $currency) {
             self::$_countries_list[] = new Core_Model_Default($currency);
         }
     }
     return self::$_countries_list;
 }
Beispiel #29
0
 protected function _prepareFiles()
 {
     //        $source = $this->_sources_dst.'/java/com/'.$this->_formatted_bundle_name.'/'.$this->_folder_name;
     $source = $this->_sources_dst . '/java/' . str_replace(".", "/", $this->_package_name);
     $links = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, 4096), RecursiveIteratorIterator::SELF_FIRST);
     $allowed_extensions = array("java", "xml");
     if (!$links) {
         return $this;
     }
     foreach ($links as $link) {
         if (!$link->isDir()) {
             $info = pathinfo($link->getPathName());
             $extension = $info["extension"];
             if (in_array($extension, $allowed_extensions)) {
                 if (strpos($link, 'CommonUtilities.java') !== false) {
                     $this->__replace(array('String SENDER_ID = ""' => 'String SENDER_ID = "' . Push_Model_Certificate::getAndroidSenderId() . '"', 'String APP_ID = ""' => 'String APP_ID = "' . $this->getApplication()->getId() . '"', 'SERVEUR_URL = "http://base.appsmobilecompany.com/";' => 'SERVEUR_URL = "' . $this->getUrl() . '";'), $link);
                 }
             }
         }
     }
     $replacements = array('com.appsmobilecompany.base' => $this->_package_name, '[ENCRYPT_KEY]' => $this->getDevice()->getKeyPass());
     $source = $this->_dst;
     $links = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, 4096), RecursiveIteratorIterator::SELF_FIRST);
     foreach ($links as $link) {
         if ($link->isDir()) {
             continue;
         }
         $this->__replace($replacements, $link->getRealPath());
     }
     $this->__replace($replacements, $this->_sources_dst . '/AndroidManifest.xml');
     $this->__replace($replacements, $this->_sources_dst . '/../../build.gradle');
     $name = str_replace("'", "\\'", $this->getApplication()->getName());
     // Retrieve the available languages
     $languages = Core_Model_Language::getLanguageCodes();
     // Check if all the available languages exist in the Android source
     foreach ($languages as $lang) {
         if ($lang == "en") {
             continue;
         }
         if (stripos($lang, "_") !== false) {
             $lang = explode("_", $lang);
             if (count($lang) == 2) {
                 $lang[1] = "r" . $lang[1];
             }
             $lang = implode("-", $lang);
         }
         // If not, create them out of the English one.
         if (!file_exists($this->_sources_dst . '/res/values-' . $lang . '/strings.xml')) {
             mkdir($this->_sources_dst . '/res/values-' . $lang, 0777);
             copy($this->_sources_dst . '/res/values/strings.xml', $this->_sources_dst . '/res/values-' . $lang . '/strings.xml');
         }
     }
     $replacements = array('http://localhost/overview' => $this->getApplication()->getUrl(null, array(), 'en', false), '<string name="app_name">Apps Mobile Company</string>' => '<string name="app_name"><![CDATA[' . $name . ']]></string>');
     $this->__replace($replacements, $this->_sources_dst . '/res/values/strings.xml');
     if ($fbk_app_id = $this->getApplication()->getFacebookId()) {
         $replacements_sharing = array('<!-- FACEBOOK -->' => '<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>');
         if ($this->getApplication()->getData("facebook_id")) {
             $replacements_sharing['<!-- FACEBOOK PROVIDER -->'] = '<provider android:authorities="com.facebook.app.FacebookContentProvider' . $fbk_app_id . '"
                                         android:name="com.facebook.FacebookContentProvider"
                                         android:exported="true" />';
         }
         $replacements_sharing_ids = array('[FACEBOOK_APP_ID]' => $fbk_app_id);
         $this->__replace($replacements_sharing_ids, $this->_sources_dst . '/res/values/sharings_id.xml');
         $this->__replace($replacements_sharing, $this->_sources_dst . '/AndroidManifest.xml');
     }
     foreach ($languages as $lang) {
         if ($lang == "en") {
             continue;
         }
         if (stripos($lang, "_") !== false) {
             $android_lang = explode("_", $lang);
             if (count($android_lang) == 2) {
                 $android_lang[1] = "r" . $android_lang[1];
             }
             $android_lang = implode("-", $android_lang);
         } else {
             $android_lang = $lang;
         }
         $replacements = array('http://localhost/overview' => $this->getApplication()->getUrl(null, array(), $lang, false), '<string name="app_name">SiberianCMS</string>' => '<string name="app_name"><![CDATA[' . $name . ']]></string>', '<string name="app_name">Apps Mobile Company</string>' => '<string name="app_name"><![CDATA[' . $name . ']]></string>');
         $this->__replace($replacements, $this->_sources_dst . "/res/values-{$android_lang}/strings.xml");
     }
     if (file_exists($this->_sources_dst . '/res/values-fr/strings.xml')) {
         $this->__replace($replacements, $this->_sources_dst . '/res/values-fr/strings.xml');
     }
     $version = explode(".", $this->getDevice()->getVersion());
     $version_code = !empty($version[0]) ? $version[0] : 1;
     $version_name = !empty($version[0]) && !empty($version[1]) ? $version[0] . "." . $version[1] : "1.0";
     if ($version_code != 1 || $version_name != "1.0") {
         $replacements = array("versionCode 1" => "versionCode {$version_code}", 'versionName "1.0"' => 'versionName "' . $version_name . '"');
         $this->__replace($replacements, $this->_sources_dst . "/../../build.gradle");
         $this->__replace($replacements, $this->_sources_dst . "/../../build.gradle.save");
     }
     return $this;
 }
Beispiel #30
0
 public function save()
 {
     $this->checkType();
     if (!$this->getPosition()) {
         $this->setPosition($this->findLastPosition($this->getValueId()));
     }
     if (!$this->getData('type')) {
         $this->setData('type', 'simple');
     }
     if ($this->getData('type') == 'simple') {
         $price = Core_Model_Language::normalizePrice($this->getData('price'));
         $this->setData('price', $price);
     }
     parent::save();
     if ($this->getNewCategoryIds()) {
         $this->getTable()->saveCategoryIds($this->getId(), $this->getNewCategoryIds());
     }
     $this->getType()->setProduct($this)->save();
     return $this;
 }