/** * Get modules locales * @return array */ public function parseModules() { try { $modules = getModulesPaths(); foreach ($modules as $moduleName => $modulePath) { $language_dir = $modulePath . 'language/'; if (!file_exists($language_dir)) { // TODO: Спитати Марка чому в shop нема language =)) continue; } $locales = new \DirectoryIterator($language_dir); foreach ($locales as $locale) { if ($locale->isDir() && !$locale->isDot() && is_dir($language_dir . $locale->getBasename()) && isLocale($locale->getBasename())) { $objLang = new \MY_Lang(); $objLang->load($moduleName); $module_info = $module_dir . '/module_info.php'; $module_info = \get_mainsite_url($module_info); include $module_info; $menu_name = $com_info['menu_name'] ? $com_info['menu_name'] : $moduleName; self::$MODULES_LOCALES[$locale->getBasename()][] = array('module' => $moduleName, 'menu_name' => ucfirst($menu_name)); unset($com_info); } } } return self::$MODULES_LOCALES; } catch (Exception $exc) { return array(); } }
function mainsite_url($param = 'url') { echo get_mainsite_url($param); }
public static function getProductimg($product_id, $img_arr = array()) { $wpdb = rev_db_class::rev_db_instance(); $sql = "SELECT `image` FROM `" . DB_PREFIX . "product_image` WHERE `product_id` = " . $product_id; $query = $wpdb->get_results($sql); if (isset($query) && !empty($query)) { $query = $query[0]; } if (isset($query) && !empty($query)) { $get_mainsite_url = get_mainsite_url(); $img_path = $get_mainsite_url . 'image/'; if (isset($img_arr) && !empty($img_arr)) { $old_img = rev_image_url() . $query['image']; $pathinfo = pathinfo($old_img); $dirname = $pathinfo['dirname']; $basename = $pathinfo['basename']; $extension = $pathinfo['extension']; $basenameWE = $pathinfo['filename']; $height = $img_arr['height']; $width = $img_arr['width']; $newimagename = $basenameWE . '_' . $width . '_' . $height . '.' . $extension; $new_img = $dirname . '/' . $newimagename; $dnypath = str_replace($basename, '', $query['image']); $newimage = $img_path . $dnypath . $newimagename; $img = new Image($old_img); $img->resize($width, $height); $img->save($new_img); } else { $newimage = $img_path . $query['image']; } return $newimage; } else { return false; } }
/** * Get modules locales * @return array */ public function parseModules() { try { // _______________________________________________ if (!is_dir(self::$MODULES_PATH)) { return array(); } // _______________________________________________ $modules = new \DirectoryIterator(self::$MODULES_PATH); foreach ($modules as $module) { if ($module->isDir() && !$module->isDot() && is_dir(self::$MODULES_PATH . $module->getBasename() . '/language')) { $module_dir = self::$MODULES_PATH . $module->getBasename(); $language_dir = $module_dir . '/language/'; $locales = new \DirectoryIterator($language_dir); foreach ($locales as $locale) { if ($locale->isDir() && !$locale->isDot() && is_dir($language_dir . $locale->getBasename()) && isLocale($locale->getBasename())) { $objLang = new \MY_Lang(); $objLang->load($module->getBasename()); //___________________________ $module_info = $module_dir . '/module_info.php'; $module_info = \get_mainsite_url($module_info); //___________________________ include $module_info; $menu_name = $com_info['menu_name'] ? $com_info['menu_name'] : $module->getBasename(); self::$MODULES_LOCALES[$locale->getBasename()][] = array('module' => $module->getBasename(), 'menu_name' => ucfirst($menu_name)); unset($com_info); } } } } return self::$MODULES_LOCALES; } catch (Exception $exc) { return array(); } }
private function getLangDetails($code) { $details = array(); $site_url = get_mainsite_url(); $arrLangs = sdsconfig::getlanguages(); $language = sdsconfig::getlanguages(); if ($code == 'all') { $url = rev_module_url() . '/images/icon16.png'; $details = $language; } else { foreach ($arrLangs as $lang) { if ($lang['code'] == $code) { $details['image'] = $site_url . 'image/flags/' . $lang['image']; $details['language_id'] = $lang['language_id']; $details['name'] = $lang['name']; $details['code'] = $lang['code']; $details['locale'] = $lang['locale']; $details['directory'] = $lang['directory']; $details['filename'] = $lang['filename']; $details['sort_order'] = $lang['sort_order']; $details['status'] = $lang['status']; } } } return $details; }
/** * Make correct po-file langs paths * @param type $module_template * @param type $type * @param type $lang * @param type $returnArray * @return type */ public function makeCorrectPoPaths($module_template, $type, $lang, $returnArray = FALSE) { $url = dirname($this->poFileManager->getPoFileUrl($module_template, $type, $lang)); //______________________________________________________ $url = get_mainsite_url($url); //______________________________________________________ $paths = $this->input->post('paths'); $parsedLangs = FilesParser::getInstatce()->getParsedPathsLangs($url, $paths); $parsedLangs = $parsedLangs['parsed_langs']; $all_langs = array(); foreach ($parsedLangs as $key => $langsOne) { foreach ($langsOne as $origin => $paths) { if ($all_langs[$origin]) { array_push($all_langs[$origin], $paths); } else { $all_langs[$origin] = $paths; } } } $result = $this->poFileManager->toArray($module_template, $type, $lang); $currentLangs = $result['po_array']; if (!$currentLangs && !$returnArray) { return json_encode(array('error' => TRUE, 'data' => lang('Update and save translation file befor this action.', 'translator'))); } foreach ($all_langs as $origin => $paths) { if ($currentLangs[$origin]) { $needed_paths = array(); foreach ($paths as $path) { if (!is_array($path)) { $needed_paths[] = $path; } } $currentLangs[$origin]['links'] = $needed_paths; } } if ($returnArray) { return $currentLangs; } else { $this->setSession($module_template, $type, $lang); $can_edit_file = can_edit_file($module_template, $type); return \CMSFactory\assetManager::create()->setData('po_array', $currentLangs)->setData('page', 1)->setData('rows_count', ceil(count($currentLangs) / 11))->setData('can_edit_file', $can_edit_file)->fetchAdminTemplate('po_table', FALSE); } }