PATH:
home
/
letacommog
/
letaweb
/
admin
/
api
<?php class EcommerceManager extends BaseManager { public function checkEditorInstall() { $this->ajaxSuccess(Ecommerce::isEnabled()); } public function actionRemoveFunction() { $pages = BPages::model()->findAll("file_name in ('shop', 'productview','cart','checkout','account')"); foreach($pages as $page) { $page->delete(); } BProduct::model()->deleteAll(); BProduct_Image::model()->deleteAll(); BProduct_Tag::model()->deleteAll(); BProduct_Product_Categories::model()->deleteAll(); BProductReview::model()->deleteAll(); BOrder::model()->deleteAll(); BOrderComment::model()->deleteAll(); BOrderItem::model()->deleteAll(); BOrderTotal::model()->deleteAll(); BCustomer::model()->deleteAll(); BCustomer_Activity::model()->deleteAll(); BCustomer_Group::model()->deleteAll(); BCustomer_Online::model()->deleteAll(); BCoupon::model()->deleteAll(); BCoupon_Category::model()->deleteAll(); BCoupon_History::model()->deleteAll(); BCoupon_Product::model()->deleteAll(); BGeoZone::model()->deleteAll(); BZones_to_Geo_Zone::model()->deleteAll(); BProduct_Categories::model()->deleteAll(); BTaxClass::model()->deleteAll(); BAddress::model()->deleteAll(); BCartItem::model()->deleteAll(); $this->ajaxSuccess(1); } protected function importSql($sqlPath) { $pdo = Yii::app()->dba->getPdoInstance(); try { if (file_exists($sqlPath)) { $csql = ""; $sqlStream = file_get_contents($sqlPath); $sqlStream = rtrim($sqlStream); $newStream = preg_replace_callback("/\((.*)\)/", create_function('$matches', 'return str_replace(";"," $$$ ",$matches[0]);'), $sqlStream); $sqlArray = explode(';', $newStream); foreach ($sqlArray as $value) { if (!empty($value)) { $sql = str_replace(' $$$ ', ';', $value).';'; $sql = str_replace('{{{%site_id%}}}', Yii::app()->site->model->id, $sql).';'; $csql = $sql; $pdo->exec($sql); } } //echo "succeed to import the sql data!"; return true; } else { throw new Exception('file doesn\'t exists'); } } catch (PDOException $e) { throw new Exception($e->getMessage(). " ". $newStream); // exit; } } public function actionInstall() { //$install_script_directory = isset(Yii::app()->params['install_script_directory']) ? Yii::app()->params['install_script_directory'] : ''; $basePath = Yii::getPathOfAlias('application.classes.commerce.install'); $dir = $basePath.DIRECTORY_SEPARATOR; $pages = array( array('name'=>'shop', 'display_name'=>'Shop', 'file_name'=>'shop','system_page'=>1, 'title'=>'Shop','no_display'=>0), array('name'=>'productdetail', 'display_name'=>'Single Product', 'file_name'=>'productview','system_page'=>1, 'title'=>'Single Product','no_display'=>1), array('name'=>'cart', 'display_name'=>'Cart', 'file_name'=>'cart','system_page'=>1, 'title'=>'Cart','no_display'=>1), array('name'=>'checkout', 'display_name'=>'Checkout', 'file_name'=>'checkout','system_page'=>1, 'title'=>'Cart','no_display'=>1), array('name'=>'account', 'display_name'=>'Account', 'file_name'=>'account','system_page'=>1, 'title'=>'Cart','no_display'=>1), ); $id = BPages::model()->getMaxId() + 1; foreach($pages as $page) { $page['id'] = $id; $page['site_id'] = Yii::app()->site->model->id; $page['inline_id'] = BPages::model()->getMaxInlineId() + 1; $this->getDbConnection()->createCommand()->insert(BPages::model()->tablename(), $page); $id++; } $sql_script_dir = $dir.DIRECTORY_SEPARATOR.'sql_scripts'; $data_files = scandir($sql_script_dir); foreach($data_files as $file) { $file_name = $sql_script_dir.DIRECTORY_SEPARATOR.$file; if(is_file($file_name) ) { $this->importSql($file_name); } } /* $struct_files = scandir($sql_script_dir.DIRECTORY_SEPARATOR.'structs'); foreach($struct_files as $file) { $file_name = $sql_script_dir.DIRECTORY_SEPARATOR.'structs'.DIRECTORY_SEPARATOR.$file; if(is_file($file_name) ) { $this->executeScript($file_name); } } $data_files = scandir($sql_script_dir.DIRECTORY_SEPARATOR.$page_language); foreach($data_files as $file) { $file_name = $sql_script_dir.DIRECTORY_SEPARATOR.$page_language.DIRECTORY_SEPARATOR.$file; if(is_file($file_name) ) { $this->executeScript($file_name); } } $view_script_dir = $sql_script_dir = $dir.DIRECTORY_SEPARATOR.'views'; $files = scandir($view_script_dir); foreach($files as $file) { $file_name = $view_script_dir.DIRECTORY_SEPARATOR.$file; if(is_file($file_name) ) { $name = explode('.', $file)[0]; $contents = file_get_contents($file_name); $this->pageObj->writeFile('views',$name, $contents); } } */ /*$css_script_dir = $sql_script_dir = $dir.DIRECTORY_SEPARATOR.'css'; $files = scandir($css_script_dir); foreach($files as $file) { $file_name = $css_script_dir.DIRECTORY_SEPARATOR.$file; if(is_file($file_name) ) { $name = explode('.', $file)[0]; $ext = explode('.', $file)[1] $contents = file_get_contents($file_name); $this->pageObj->writeToEndFile('css',$name, $content, '.'.$ext); } }*/ $this->ajaxSuccess(1); } public function actiongetDefaultCurrency() { $key = 'DEFAULT_CURRENCY'; $rs = BConfigurations::model()->find("name=:key", array(':key'=>"'".$key."'")); if(isset($rs)) { $default_currency = $rs->value; $currencies = Currencies::model()->findByPk($default_currency); if(isset($currencies)) { $this->ajaxSuccess($this->ar_toObject($currencies)); } else { $this->ajaxSuccess("USD"); } } else { $this->ajaxSuccess("USD"); } } function getStylesList() { $name = $_REQUEST['name']; $tablename = $name; $module = new SqlliteModule($this->pageObj); $db = $module->getDbConnection(); $c = $db->createCommand() ->select('*') ->from($tablename); if(isset($_REQUEST['page'])) { $page = $_REQUEST['page']; $c = $c->where('page=NULL or page=:page', array(':page'=>$page)); } $s = $c->queryAll(); $this->ajaxSuccess($s); } public function getOptionset() { $id = $_REQUEST['id']; $m = new SqlliteModule($this->pageObj); $db = $m->getDbConnection(); $command = $db->createCommand(); $options = $command->select('*')->from('options')->where('set_id=:id', array(':id'=>$id))->queryAll(); for($i = 0;$i < sizeof($options);$i++) { $command = $db->createCommand(); $options[$i]['items'] = $command->select('*')->from('options_items')->where('option_id=:id', array(':id'=>$options[$i]['id']))->queryAll(); } $this->ajaxSuccess($options); } public function actiongetCurrencyList() { $currencies= cmm_currency::$currencies; if(!isset($currencies)) { cmm_currency::load(); $currencies= cmm_currency::$currencies; } $result = array(); foreach ($currencies as $currency) { $result[$currency['code']] = $currency->attributes; } $this->ajaxSuccess($result); } public function actiongetWeightList() { $this->ajaxSuccess(cmm_weight::$classes); } public function actiongetLengthList() { $this->ajaxSuccess(cmm_length::$classes); } public function actiongetpaymentModuleList() { $payment = new mod_payment(); $result = array(); $options = $payment->options(); if(is_array($options)) { foreach ($options as $module) { foreach ($module['options'] as $option) { $result[] = array("id"=>$module['id'].':'.$option['id'], "title"=>$module['title'].' ('.$option['name'].')'); } } } $this->ajaxSuccess($result); } public function actiongetshippingModuleList() { $shipping = new mod_shipping(); $result = array(); $options = $shipping->options(); if(is_array($options)) { foreach ($options as $module) { foreach ($module['options'] as $option) { $result[] = array("id"=>$module['id'].':'.$option['id'], "title"=>$module['title'].' ('.$option['name'].')'); } } } $this->ajaxSuccess($result); } public function actiongetorder_totalModuleList() { $order_total = new mod_order_total(); $result = array(); $modules = $order_total->modules; if(is_array($modules)) { foreach ($modules as $module) { if($module->id != 'ot_subtotal') $result[] = array("id"=>$module->id, "title"=>$module->name); } } $this->ajaxSuccess($result); } } ?>
[+]
..
[-] SettingsManager.php
[edit]
[-] BaseManager.php
[edit]
[+]
settings
[-] BlogManager.php
[edit]
[+]
blog
[-] AssetManager.php
[edit]
[+]
customize
[-] ContentManager.php
[edit]
[+]
content
[-] CustomizeManager.php
[edit]
[-] EcommerceManager.php
[edit]