public function pjActionGetSms() { $this->setAjax(true); if ($this->isXHR() && $this->isLoged() && $this->isAdmin()) { $pjSmsModel = pjSmsModel::factory(); if (isset($_GET['q']) && !empty($_GET['q'])) { $q = $pjSmsModel->escapeStr($_GET['q']); $q = str_replace(array('%', '_'), array('\\%', '\\_'), $q); $pjSmsModel->where("(t1.number LIKE '%{$q}%' OR t1.text LIKE '%{$q}%')"); } $column = 'created'; $direction = 'DESC'; if (isset($_GET['direction']) && isset($_GET['column']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC'))) { $column = $_GET['column']; $direction = strtoupper($_GET['direction']); } $total = $pjSmsModel->findCount()->getData(); $rowCount = isset($_GET['rowCount']) && (int) $_GET['rowCount'] > 0 ? (int) $_GET['rowCount'] : 10; $pages = ceil($total / $rowCount); $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? intval($_GET['page']) : 1; $offset = ((int) $page - 1) * $rowCount; if ($page > $pages) { $page = $pages; } $data = $pjSmsModel->orderBy("{$column} {$direction}")->limit($rowCount, $offset)->findAll()->getData(); pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction')); } exit; }
public function pjActionGetMerchant() { $this->setAjax(true); if ($this->isXHR()) { $pjMerchantModel = pjMerchantModel::factory()->where('user_id', $_SESSION['admin_user']['id']); $column = 'merchant_name'; $direction = 'ASC'; if (isset($_GET['direction']) && isset($_GET['column']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC'))) { $column = $_GET['column']; $direction = strtoupper($_GET['direction']); } $total = $pjMerchantModel->findCount()->getData(); $rowCount = isset($_GET['rowCount']) && (int) $_GET['rowCount'] > 0 ? (int) $_GET['rowCount'] : 10; $pages = ceil($total / $rowCount); $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? intval($_GET['page']) : 1; $offset = ((int) $page - 1) * $rowCount; if ($page > $pages) { $page = $pages; } $data = array(); $data = $pjMerchantModel->select('t1.merchant_id, t1.merchant_name, t1.merchant_address')->orderBy("{$column} {$direction}")->limit($rowCount, $offset)->findAll()->getData(); pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction')); } exit; }
public function afterFilter() { parent::afterFilter(); if ($this->isLoged() && !in_array(@$_GET['action'], array('pjActionLogin'))) { $this->appendJs('index.php?controller=pjAdmin&action=pjActionMessages', PJ_INSTALL_URL, true); } }
public function pjActionGetWTime() { $this->setAjax(true); if ($this->isXHR()) { if (isset($_POST['date']) && !empty($_POST['date'])) { $date = pjUtil::formatDate($_POST['date'], $this->option_arr['o_date_format']); $wt_arr = pjAppController::getWorkingTime($date, $_POST['location_id'], $_POST['type']); } else { $date = '1981-02-01'; $wt_arr = array('start_hour' => 0, 'end_hour' => 23); $this->_set('p_hour', 0); $this->_set('p_minute', 0); $this->_set('d_hour', 0); $this->_set('d_minute', 0); } $this->tpl['date'] = $date; $this->tpl['wt_arr'] = $wt_arr; } }
public function pjActionGetVoucher() { $this->setAjax(true); if ($this->isXHR()) { $pjVoucherModel = pjVoucherModel::factory()->where('user_id', $_SESSION['admin_user']['id']); if (isset($_GET['q']) && !empty($_GET['q'])) { $q = pjObject::escapeString($_GET['q']); $pjVoucherModel->where('t1.code LIKE', "%{$q}%"); } $column = 'code'; $direction = 'ASC'; if (isset($_GET['direction']) && isset($_GET['column']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC'))) { $column = $_GET['column']; $direction = strtoupper($_GET['direction']); } $total = $pjVoucherModel->findCount()->getData(); $rowCount = isset($_GET['rowCount']) && (int) $_GET['rowCount'] > 0 ? (int) $_GET['rowCount'] : 10; $pages = ceil($total / $rowCount); $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? intval($_GET['page']) : 1; $offset = ((int) $page - 1) * $rowCount; if ($page > $pages) { $page = $pages; } $data = array(); $data = $pjVoucherModel->select('t1.*')->orderBy("{$column} {$direction}")->limit($rowCount, $offset)->findAll()->getData(); foreach ($data as $k => $v) { if ($v['type'] == 'percent') { $v['discount'] = $v['discount'] . '%'; } else { $v['discount'] = pjUtil::formatCurrencySign($v['discount'], $this->option_arr['o_currency']); } $v['datetime_valid'] = ''; switch ($v['valid']) { case 'fixed': $v['datetime_valid'] = date($this->option_arr['o_date_format'], strtotime($v['date_from'])) . ' ' . __('lblFrom', true) . ' ' . date($this->option_arr['o_time_format'], strtotime($v['time_from'])) . ' ' . __('lblTo', true) . ' ' . date($this->option_arr['o_time_format'], strtotime($v['time_to'])); break; case 'period': $v['datetime_valid'] = __('lblFrom', true) . ' ' . date($this->option_arr['o_date_format'], strtotime($v['date_from'])) . ' ' . __('lblTo', true) . ' ' . date($this->option_arr['o_date_format'], strtotime($v['date_to'])); break; case 'recurring': $days = __('voucher_days', true, false); $v['datetime_valid'] = __('lblEvery', true) . ' ' . $days[$v['every']] . ' ' . __('lblFrom', true) . ' ' . date($this->option_arr['o_time_format'], strtotime($v['time_from'])) . ' ' . __('lblTo', true) . ' ' . date($this->option_arr['o_time_format'], strtotime($v['time_to'])); break; } $data[$k] = $v; } pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction')); } exit; }
myLabel.txn_type = <?php echo pjAppController::jsonEncode(__('plugin_paypal_txn_type', true)); ?> ; myLabel.gross = <?php echo pjAppController::jsonEncode(__('plugin_paypal_mc_gross', true)); ?> ; myLabel.currency = <?php echo pjAppController::jsonEncode(__('plugin_paypal_mc_currency', true)); ?> ; myLabel.email = <?php echo pjAppController::jsonEncode(__('plugin_paypal_payer_email', true)); ?> ; myLabel.dt = <?php echo pjAppController::jsonEncode(__('plugin_paypal_dt', true)); ?> ; myLabel.btn_view = <?php echo pjAppController::jsonEncode(__('plugin_paypal_btn_view', true)); ?> ; myLabel.btn_close = <?php echo pjAppController::jsonEncode(__('plugin_paypal_btn_close', true)); ?> ; </script> <?php }
public function pjActionDeleteDate() { $this->setAjax(true); if ($this->isXHR()) { $response = array(); if (pjDateModel::factory()->setAttributes(array('id' => $_GET['id']))->erase()->getAffectedRows() == 1) { $response['code'] = 200; } else { $response['code'] = 100; } pjAppController::jsonResponse($response); } exit; }
public function pjActionUpdate() { $this->checkLogin(); if ($this->isCountryReady()) { if (isset($_POST['country_update'])) { pjCountryModel::factory()->where('id', $_POST['id'])->limit(1)->modifyAll($_POST); if (isset($_POST['i18n'])) { pjMultiLangModel::factory()->updateMultiLang($_POST['i18n'], $_POST['id'], 'pjCountry'); } pjUtil::redirect(PJ_INSTALL_URL . "index.php?controller=pjCountry&action=pjActionIndex&err=PCY01"); } else { $arr = pjCountryModel::factory()->find($_GET['id'])->getData(); if (count($arr) === 0) { pjUtil::redirect(PJ_INSTALL_URL . "index.php?controller=pjCountry&action=pjActionIndex&err=PCY08"); } $arr['i18n'] = pjMultiLangModel::factory()->getMultiLang($arr['id'], 'pjCountry'); $this->set('arr', $arr); $locale_arr = pjLocaleModel::factory()->select('t1.*, t2.file')->join('pjLocaleLanguage', 't2.iso=t1.language_iso', 'left')->where('t2.file IS NOT NULL')->orderBy('t1.sort ASC')->findAll()->getData(); $lp_arr = array(); foreach ($locale_arr as $item) { $lp_arr[$item['id'] . "_"] = $item['file']; //Hack for jquery $.extend, to prevent (re)order of numeric keys in object } $this->set('lp_arr', $locale_arr); $this->set('locale_str', pjAppController::jsonEncode($lp_arr)); $this->appendJs('jquery.validate.min.js', PJ_THIRD_PARTY_PATH . 'validate/'); $this->appendJs('jquery.multilang.js', PJ_FRAMEWORK_LIBS_PATH . 'pj/js/'); $this->appendJs('jquery.tipsy.js', PJ_THIRD_PARTY_PATH . 'tipsy/'); $this->appendCss('jquery.tipsy.css', PJ_THIRD_PARTY_PATH . 'tipsy/'); $this->appendJs('pjCountry.js', $this->getConst('PLUGIN_JS_PATH')); $this->appendJs('index.php?controller=pjAdmin&action=pjActionMessages', PJ_INSTALL_URL, true); } } else { $this->set('status', 2); } }
public function pjActionSecureGetUpdate() { $this->setAjax(true); if ($this->isXHR() && $this->isLoged()) { $data = array(); if (isset($_GET['module'])) { switch ($_GET['module']) { case 'plugin': if (isset($GLOBALS['CONFIG']['plugins'])) { if (!is_array($GLOBALS['CONFIG']['plugins'])) { $GLOBALS['CONFIG']['plugins'] = array($GLOBALS['CONFIG']['plugins']); } foreach ($GLOBALS['CONFIG']['plugins'] as $plugin) { $data = array_merge($data, self::pjActionGetUpdates(PJ_PLUGINS_PATH . $plugin . '/config/updates', array('plugin' => $plugin))); } } break; case 'script': $data = self::pjActionGetUpdates(); break; } } $total = count($data); $rowCount = $total; $pages = 1; $page = 1; $offset = 0; pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction')); } exit; }
public function pjActionGetClient() { $this->setAjax(true); if ($this->isXHR()) { $pjClientModel = pjClientModel::factory()->where('user_id', $_SESSION['admin_user']['id']); if (isset($_GET['q']) && !empty($_GET['q'])) { $q = pjObject::escapeString($_GET['q']); $pjClientModel->where('t1.c_email LIKE', "%{$q}%"); $pjClientModel->orWhere('t1.c_name LIKE', "%{$q}%"); } if (isset($_GET['status']) && !empty($_GET['status']) && in_array($_GET['status'], array('T', 'F'))) { $pjClientModel->where('t1.status', $_GET['status']); } $column = 'c_name'; $direction = 'ASC'; if (isset($_GET['direction']) && isset($_GET['column']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC'))) { $column = $_GET['column']; $direction = strtoupper($_GET['direction']); } $total = $pjClientModel->findCount()->getData(); $rowCount = isset($_GET['rowCount']) && (int) $_GET['rowCount'] > 0 ? (int) $_GET['rowCount'] : 10; $pages = ceil($total / $rowCount); $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? intval($_GET['page']) : 1; $offset = ((int) $page - 1) * $rowCount; if ($page > $pages) { $page = $pages; } $data = array(); $data = $pjClientModel->select("t1.id, t1.c_email, t1.c_name, t1.status, (SELECT COUNT(TO.client_id) FROM `" . pjOrderModel::factory()->getTable() . "` AS `TO` WHERE `TO`.client_id=t1.id) AS cnt_orders")->orderBy("{$column} {$direction}")->limit($rowCount, $offset)->findAll()->getData(); pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction')); } exit; }
public function pjActionDeleteImage() { $this->setAjax(true); if ($this->isXHR()) { $response = array(); $pjProductModel = pjProductModel::factory(); $arr = $pjProductModel->find($_GET['id'])->getData(); if (!empty($arr)) { if (!empty($arr['image'])) { @unlink(PJ_INSTALL_PATH . $arr['image']); } $data = array(); $data['image'] = ':NULL'; $pjProductModel->reset()->where(array('id' => $_GET['id']))->limit(1)->modifyAll($data); $response['code'] = 200; } else { $response['code'] = 100; } pjAppController::jsonResponse($response); } }
public function pjActionCancel() { $this->setLayout('pjActionCancel'); $pjOrderModel = pjOrderModel::factory(); if (isset($_POST['order_cancel'])) { $order_arr = $pjOrderModel->reset()->join('pjClient', "t2.id=t1.client_id", 'left outer')->select('t1.*, t2.c_title, t2.c_email, t2.c_name, t2.c_phone, t2.c_company, t2.c_address_1, t2.c_address_2, t2.c_country, t2.c_state, t2.c_city, t2.c_zip, t2.c_notes')->find($_POST['id'])->getData(); if (count($order_arr) > 0) { $sql = "UPDATE `" . $pjOrderModel->getTable() . "` SET status = 'cancelled' WHERE SHA1(CONCAT(`id`, `created`, '" . PJ_SALT . "')) = '" . $_POST['hash'] . "'"; $pjOrderModel->reset()->execute($sql); pjAppController::addOrderDetails($order_arr, $this->getLocaleId()); pjFront::pjActionConfirmSend($this->option_arr, $order_arr, PJ_SALT, 'cancel'); pjUtil::redirect($_SERVER['PHP_SELF'] . '?controller=pjFront&action=pjActionCancel&err=200'); } } else { if (isset($_GET['hash']) && isset($_GET['id'])) { $arr = $pjOrderModel->reset()->join('pjClient', "t2.id=t1.client_id", 'left outer')->join('pjMultiLang', "t3.model='pjCountry' AND t3.foreign_id=t1.d_country_id AND t3.field='name' AND t3.locale='" . $this->getLocaleId() . "'", 'left outer')->join('pjMultiLang', "t4.model='pjCountry' AND t4.foreign_id=t1.location_id AND t4.field='name' AND t4.locale='" . $this->getLocaleId() . "'", 'left outer')->join('pjClient', "t2.id=t1.client_id", 'left outer')->select('t1.*, t3.content as d_country, t4.content as location, t2.c_title, t2.c_email, t2.c_name, t2.c_phone, t2.c_company, t2.c_address_1, t2.c_address_2, t2.c_country, t2.c_state, t2.c_city, t2.c_zip, t2.c_notes')->find($_GET['id'])->getData(); if (count($arr) == 0) { $this->set('status', 2); } else { if ($arr['status'] == 'cancelled') { $this->set('status', 4); } else { $hash = sha1($arr['id'] . $arr['created'] . PJ_SALT); if ($_GET['hash'] != $hash) { $this->set('status', 3); } else { pjAppController::addOrderDetails($arr, $this->getLocaleId()); $this->set('arr', $arr); } } } } elseif (!isset($_GET['err'])) { $this->set('status', 1); } } }
function __encode($key) { echo pjAppController::jsonEncode(__($key, true)); }
public function pjActionSave() { $this->setAjax(true); if ($this->isXHR() && $this->isLoged() && $this->isOneAdminReady()) { if (isset($_GET['id']) && (int) $_GET['id'] > 0 && isset($_POST['column'], $_POST['value'])) { pjOneAdminModel::factory()->set('id', $_GET['id'])->modify(array($_POST['column'] => $_POST['value'])); pjAppController::jsonResponse(array('status' => 'OK', 'code' => 201, 'text' => 'Item have been updated.')); } else { $insert_id = pjOneAdminModel::factory(array('name' => 'Script name', 'url' => 'http://www.example.com/'))->insert()->getInsertId(); if ($insert_id !== false && (int) $insert_id > 0) { pjAppController::jsonResponse(array('status' => 'OK', 'code' => 200, 'text' => 'Item have been saved.', 'id' => $insert_id)); } pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 100, 'text' => 'Item have not been saved')); } } exit; }
public function pjActionTerm() { $this->checkLogin(); if ($this->isAdmin()) { $arr = pjOptionModel::factory()->where('t1.foreign_id', $this->getForeignId())->orderBy('t1.order ASC')->findAll()->getData(); $arr['i18n'] = pjMultiLangModel::factory()->getMultiLang(1, 'pjOption'); $this->set('arr', $arr); $locale_arr = pjLocaleModel::factory()->select('t1.*, t2.file')->join('pjLocaleLanguage', 't2.iso=t1.language_iso', 'left')->where('t2.file IS NOT NULL')->orderBy('t1.sort ASC')->findAll()->getData(); $lp_arr = array(); foreach ($locale_arr as $item) { $lp_arr[$item['id'] . "_"] = $item['file']; } $this->set('lp_arr', $locale_arr); $this->set('locale_str', pjAppController::jsonEncode($lp_arr)); $this->appendJs('jquery.multilang.js', PJ_FRAMEWORK_LIBS_PATH . 'pj/js/'); $this->appendJs('jquery.tipsy.js', PJ_THIRD_PARTY_PATH . 'tipsy/'); $this->appendCss('jquery.tipsy.css', PJ_THIRD_PARTY_PATH . 'tipsy/'); $this->appendJs('pjAdminOptions.js'); } }
<?php $category = '<select name="category_id[]" id="category_id" multiple="multiple" size="5" class="pj-form-field required w300">'; foreach ($tpl['category_arr'] as $v) { $category .= sprintf('<option value="%u">%s</option>', $v['id'], stripslashes($v['name'])); } $category .= '</select>'; $extra = '<select name="extra_id[]" id="extra_id" multiple="multiple" size="5" class="pj-form-field w300">'; foreach ($tpl['extra_arr'] as $v) { $extra .= sprintf('<option value="%u">%s</option>', $v['id'], stripslashes($v['name'])); } $extra .= '</select>'; pjAppController::jsonResponse(compact('category', 'extra'));
public function pjActionGetCoords() { $this->setAjax(true); if ($this->isXHR()) { $data = pjAppController::getCoords($_POST['i18n'][$this->getLocaleId()]['address']); if (is_array($data['lat']) && $data['lat'][0] == 'NULL' && is_array($data['lng']) && $data['lng'][0] == 'NULL') { $data = array(); } pjAppController::jsonResponse($data); } exit; }
public function pjActionSaveLocale() { $this->setAjax(true); if ($this->isXHR()) { $response = array(); if (isset($_GET['id']) && (int) $_GET['id'] > 0) { pjLocaleModel::factory()->where('id', $_GET['id'])->limit(1)->modifyAll(array($_POST['column'] => $_POST['value'])); $response['code'] = 201; } else { $pjLocaleModel = pjLocaleModel::factory(); $arr = $pjLocaleModel->select('t1.sort')->orderBy('t1.sort DESC')->limit(1)->findAll()->getData(); $sort = 1; if (count($arr) === 1) { $sort = (int) $arr[0]['sort'] + 1; } $lang = pjLocaleLanguageModel::factory()->where(sprintf("t1.iso NOT IN (SELECT `language_iso` FROM `%s`)", $pjLocaleModel->getTable()))->where('t1.file IS NOT NULL')->orderBy('t1.title ASC')->limit(1)->findAll()->getDataPair(null, 'iso'); $insert_id = pjLocaleModel::factory(array('sort' => $sort, 'is_default' => '0', 'language_iso' => @$lang[0]))->insert()->getInsertId(); if ($insert_id !== false && (int) $insert_id > 0) { $response['code'] = 200; $response['id'] = $insert_id; $locale_id = NULL; $arr = $pjLocaleModel->reset()->findAll()->getData(); foreach ($arr as $locale) { if ($locale['language_iso'] == 'en') { $locale_id = $locale['id']; break; } } if (is_null($locale_id) && count($arr) > 0) { $locale_id = $arr[0]['id']; } if (!is_null($locale_id)) { $sql = sprintf("INSERT INTO `%1\$s` (`foreign_id`, `model`, `locale`, `field`, `content`)\n\t\t\t\t\t\t\tSELECT t1.foreign_id, t1.model, :insert_id, t1.field, t1.content\n\t\t\t\t\t\t\tFROM `%1\$s` AS t1\n\t\t\t\t\t\t\tWHERE t1.locale = :locale", pjMultiLangModel::factory()->getTable()); pjMultiLangModel::factory()->prepare($sql)->exec(array('insert_id' => $insert_id, 'locale' => (int) $locale_id)); $this->pjActionUpdateFieldsIndex(); } } else { $response['code'] = 100; } } pjAppController::jsonResponse($response); } exit; }
public function pjActionGetClient() { $this->setAjax(true); if ($this->isXHR()) { $client_arr = pjClientModel::factory()->find($_GET['id'])->getData(); pjAppController::jsonResponse($client_arr); } exit; }
public function getCoords($str) { if (!is_array($str)) { $_address = preg_replace('/\\s+/', '+', $str); $_address = urlencode($_address); } else { $address = array(); $address[] = $str['d_zip']; $address[] = $str['d_address_1']; $address[] = $str['d_city']; $address[] = $str['d_state']; foreach ($address as $k => $v) { $tmp = preg_replace('/\\s+/', '+', $v); $address[$k] = $tmp; } $_address = join(",+", $address); } $api = sprintf("https://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false", $_address); $pjHttp = new pjHttp(); $pjHttp->request($api); $response = $pjHttp->getResponse(); $geoObj = pjAppController::jsonDecode($response); $data = array(); if ($geoObj->status == 'OK') { $data['lat'] = $geoObj->results[0]->geometry->location->lat; $data['lng'] = $geoObj->results[0]->geometry->location->lng; } else { $data['lat'] = array('NULL'); $data['lng'] = array('NULL'); } return $data; }
public function pjActionGetUser() { $this->setAjax(true); if ($this->isXHR()) { $pjUserModel = pjUserModel::factory()->where('t1.user_id', $_SESSION['admin_user']['id'])->orWhere('t1.id', $_SESSION['admin_user']['id']); if (isset($_GET['q']) && !empty($_GET['q'])) { $q = pjObject::escapeString($_GET['q']); $pjUserModel->where('t1.email LIKE', "%{$q}%"); $pjUserModel->orWhere('t1.name LIKE', "%{$q}%"); } if (isset($_GET['status']) && !empty($_GET['status']) && in_array($_GET['status'], array('T', 'F'))) { $pjUserModel->where('t1.status', $_GET['status']); } $column = 'name'; $direction = 'ASC'; if (isset($_GET['direction']) && isset($_GET['column']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC'))) { $column = $_GET['column']; $direction = strtoupper($_GET['direction']); } $total = $pjUserModel->findCount()->getData(); $rowCount = isset($_GET['rowCount']) && (int) $_GET['rowCount'] > 0 ? (int) $_GET['rowCount'] : 10; $pages = ceil($total / $rowCount); $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? intval($_GET['page']) : 1; $offset = ((int) $page - 1) * $rowCount; if ($page > $pages) { $page = $pages; } $data = array(); $data = $pjUserModel->select('t1.id, t1.email, t1.name, t1.created, t1.status, t1.is_active, t1.role_id, t2.role')->join('pjRole', 't2.id=t1.role_id', 'left')->orderBy("{$column} {$direction}")->limit($rowCount, $offset)->findAll()->getData(); foreach ($data as $k => $v) { $v['created'] = date($this->option_arr['o_date_format'], strtotime($v['created'])) . ', ' . date($this->option_arr['o_time_format'], strtotime($v['created'])); $data[$k] = $v; } pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction')); } exit; }
?> ", btn_cancel: "<?php __('gridBtnCancel', false, true); ?> ", btn_delete: "<?php __('gridBtnDelete', false, true); ?> " }); } if (jQuery_1_8_2.multilang !== undefined) { jQuery_1_8_2.extend(jQuery_1_8_2.multilang.messages, { tooltip: "<?php __('multilangTooltip', false, true); ?> " }); } if (fdApp !== undefined) { fdApp = jQuery_1_8_2.extend(fdApp, { locale: { button: <?php echo pjAppController::jsonEncode(__('buttons', true)); ?> } }); }
public function pjActionUpdate() { $this->checkLogin(); if ($this->isAdmin() || $this->isEditor()) { if (isset($_POST['extra_update'])) { pjExtraModel::factory()->where('id', $_POST['id'])->limit(1)->modifyAll($_POST); if (isset($_POST['i18n'])) { pjMultiLangModel::factory()->updateMultiLang($_POST['i18n'], $_POST['id'], 'pjExtra', 'data'); } pjUtil::redirect(PJ_INSTALL_URL . "index.php?controller=pjAdminExtras&action=pjActionIndex&err=AE01"); } else { $arr = pjExtraModel::factory()->find($_GET['id'])->getData(); if (count($arr) === 0) { pjUtil::redirect(PJ_INSTALL_URL . "index.php?controller=pjAdminExtras&action=pjActionIndex&err=AE08"); } $arr['i18n'] = pjMultiLangModel::factory()->getMultiLang($arr['id'], 'pjExtra'); $this->set('arr', $arr); $locale_arr = pjLocaleModel::factory()->select('t1.*, t2.file')->join('pjLocaleLanguage', 't2.iso=t1.language_iso', 'left')->where('t2.file IS NOT NULL')->orderBy('t1.sort ASC')->findAll()->getData(); $lp_arr = array(); foreach ($locale_arr as $item) { $lp_arr[$item['id'] . "_"] = $item['file']; } $this->set('lp_arr', $locale_arr); $this->set('locale_str', pjAppController::jsonEncode($lp_arr)); $this->appendJs('jquery.validate.min.js', PJ_THIRD_PARTY_PATH . 'validate/'); $this->appendJs('jquery.multilang.js', PJ_FRAMEWORK_LIBS_PATH . 'pj/js/'); $this->appendJs('jquery.tipsy.js', PJ_THIRD_PARTY_PATH . 'tipsy/'); $this->appendCss('jquery.tipsy.css', PJ_THIRD_PARTY_PATH . 'tipsy/'); $this->appendJs('pjAdminExtras.js'); } } else { $this->set('status', 2); } }
public function pjActionGet() { $this->setAjax(true); if ($this->isXHR() && $this->isLoged() && $this->isAdmin()) { $column = 'created'; $direction = 'DESC'; if (isset($_GET['direction']) && isset($_GET['column']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC'))) { $column = $_GET['column']; $direction = strtoupper($_GET['direction']); } $data = $id = $created = $type = array(); if ($handle = opendir(PJ_WEB_PATH . 'backup')) { $i = 0; while (false !== ($entry = readdir($handle))) { preg_match('/(database-backup|files-backup)-(\\d{10})\\.(sql|zip)/', $entry, $m); if (isset($m[2])) { $id[$i] = $entry; $created[$i] = date($this->option_arr['o_date_format'] . ", H:i", $m[2]); $type[$i] = $m[1] == 'database-backup' ? 'database' : 'files'; $data[$i]['id'] = $id[$i]; $data[$i]['created'] = $created[$i]; $data[$i]['type'] = $type[$i]; $i++; } } closedir($handle); } switch ($column) { case 'created': array_multisort($created, $direction == 'ASC' ? SORT_ASC : SORT_DESC, $id, SORT_DESC, $type, SORT_ASC, $data); break; case 'type': array_multisort($type, $direction == 'ASC' ? SORT_ASC : SORT_DESC, $id, SORT_DESC, $created, SORT_DESC, $data); break; case 'id': array_multisort($id, $direction == 'ASC' ? SORT_ASC : SORT_DESC, $type, SORT_ASC, $created, SORT_DESC, $data); break; } $total = count($data); $rowCount = isset($_GET['rowCount']) && (int) $_GET['rowCount'] > 0 ? (int) $_GET['rowCount'] : 10; $pages = ceil($total / $rowCount); $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? intval($_GET['page']) : 1; $offset = ((int) $page - 1) * $rowCount; if ($page > $pages) { $page = $pages; } pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction')); } exit; }