本文整理汇总了PHP中Params::getParamsAsArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Params::getParamsAsArray方法的具体用法?PHP Params::getParamsAsArray怎么用?PHP Params::getParamsAsArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Params
的用法示例。
在下文中一共展示了Params::getParamsAsArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mdh_emailmagick_bump_me
/**
* Makes this plugin the first to be loaded.
* - Bumps this plugin at the top of the active_plugins stack.
*/
function mdh_emailmagick_bump_me()
{
if (OC_ADMIN) {
// @legacy : ALWAYS remove this if active.
if (osc_plugin_is_enabled("madhouse_utils/index.php")) {
Plugins::deactivate("madhouse_utils/index.php");
}
// Sanitize & get the {PLUGIN_NAME}/index.php.
$path = str_replace(osc_plugins_path(), '', osc_plugin_path(__FILE__));
if (osc_plugin_is_installed($path)) {
// Get the active plugins.
$plugins_list = unserialize(osc_active_plugins());
if (!is_array($plugins_list)) {
return false;
}
// Remove $path from the active plugins list
foreach ($plugins_list as $k => $v) {
if ($v == $path) {
unset($plugins_list[$k]);
}
}
// Re-add the $path at the beginning of the active plugins.
array_unshift($plugins_list, $path);
// Serialize the new active_plugins list.
osc_set_preference('active_plugins', serialize($plugins_list));
if (Params::getParam("page") === "plugins" && Params::getParam("action") === "enable" && Params::getParam("plugin") === $path) {
//osc_redirect_to(osc_admin_base_url(true) . "?page=plugins");
} else {
osc_redirect_to(osc_admin_base_url(true) . "?" . http_build_query(Params::getParamsAsArray("get")));
}
}
}
}
示例2: doModel
function doModel()
{
parent::doModel();
//specific things for this class
switch ($this->action) {
case 'edit':
if (Params::getParam("id") == '') {
$this->redirectTo(osc_admin_base_url(true) . "?page=emails");
}
$this->_exportVariableToView("email", $this->emailManager->findByPrimaryKey(Params::getParam("id")));
$this->doView("emails/frm.php");
break;
case 'edit_post':
$id = Params::getParam("id");
$s_internal_name = Params::getParam("s_internal_name");
$aFieldsDescription = array();
$postParams = Params::getParamsAsArray('', false);
$not_empty = false;
foreach ($postParams as $k => $v) {
if (preg_match('|(.+?)#(.+)|', $k, $m)) {
if ($m[2] == 's_title' && $v != '') {
$not_empty = true;
}
$aFieldsDescription[$m[1]][$m[2]] = $v;
}
}
if ($not_empty) {
foreach ($aFieldsDescription as $k => $_data) {
$this->emailManager->updateDescription($id, $k, $_data['s_title'], $_data['s_text']);
}
if (!$this->emailManager->internalNameExists($id, $s_internal_name)) {
if (!$this->emailManager->isIndelible($id)) {
$this->emailManager->updateInternalName($id, $s_internal_name);
}
osc_add_flash_ok_message(_m('The email/alert has been updated'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=emails");
}
osc_add_flash_error_message(_m('You can\'t repeat internal name'), 'admin');
} else {
osc_add_flash_error_message(_m('The email couldn\'t be updated, at least one title should not be empty'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . "?page=emails?action=edit&id=" . $id);
break;
default:
$this->_exportVariableToView("prefLocale", osc_current_admin_locale());
$this->_exportVariableToView("emails", $this->emailManager->listAll(1));
$this->doView("emails/index.php");
}
}
示例3: doModel
//.........这里部分代码省略.........
$userId = Params::getParam('id');
if (!is_array($userId)) {
osc_add_flash_error_message(_m("User id isn't in the correct format"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=users');
}
$userActions = new UserActions(true);
foreach ($userId as $id) {
$iUpdated += $userActions->disable($id);
}
if ($iUpdated == 0) {
$msg = _m('No users have been disabled');
} else {
$msg = sprintf(_mn('One user has been blocked', '%s users have been blocked', $iUpdated), $iUpdated);
}
osc_add_flash_ok_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=users');
break;
case 'delete':
//delete
$iDeleted = 0;
$userId = Params::getParam('id');
if (!is_array($userId)) {
osc_add_flash_error_message(_m("User id isn't in the correct format"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=users');
}
foreach ($userId as $id) {
$user = $this->userManager->findByPrimaryKey($id);
Log::newInstance()->insertLog('user', 'delete', $id, $user['s_email'], 'admin', osc_logged_admin_id());
if ($this->userManager->deleteUser($id)) {
$iDeleted++;
}
}
if ($iDeleted == 0) {
$msg = _m('No users have been deleted');
} else {
$msg = sprintf(_mn('One user has been deleted', '%s users have been deleted', $iDeleted), $iDeleted);
}
osc_add_flash_ok_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=users');
break;
case 'settings':
// calling the users settings view
$this->doView('users/settings.php');
break;
case 'settings_post':
// updating users
$iUpdated = 0;
$enabledUserValidation = Params::getParam('enabled_user_validation');
$enabledUserValidation = $enabledUserValidation != '' ? true : false;
$enabledUserRegistration = Params::getParam('enabled_user_registration');
$enabledUserRegistration = $enabledUserRegistration != '' ? true : false;
$enabledUsers = Params::getParam('enabled_users');
$enabledUsers = $enabledUsers != '' ? true : false;
$notifyNewUser = Params::getParam('notify_new_user');
$notifyNewUser = $notifyNewUser != '' ? true : false;
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUserValidation), array('s_name' => 'enabled_user_validation'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUserRegistration), array('s_name' => 'enabled_user_registration'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUsers), array('s_name' => 'enabled_users'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewUser), array('s_name' => 'notify_new_user'));
if ($iUpdated > 0) {
osc_add_flash_ok_message(_m("User settings have been updated"), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=users&action=settings');
break;
default:
// manage users view
// set default iDisplayLength
if (Params::getParam('iDisplayLength') == '') {
Params::setParam('iDisplayLength', 10);
}
$p_iPage = 1;
if (is_numeric(Params::getParam('iPage')) && Params::getParam('iPage') >= 1) {
$p_iPage = Params::getParam('iPage');
}
Params::setParam('iPage', $p_iPage);
$this->_exportVariableToView('iDisplayLength', Params::getParam('iDisplayLength'));
$this->_exportVariableToView('sSearch', Params::getParam('sSearch'));
require_once osc_admin_base_path() . 'ajax/users_processing.php';
$users_processing = new UsersProcessingAjax(Params::getParamsAsArray("get"));
$aData = $users_processing->result();
$page = (int) Params::getParam('iPage');
if (count($aData['aaData']) == 0 && $page != 1) {
$total = (int) $aData['iTotalDisplayRecords'];
$maxPage = ceil($total / (int) $aData['iDisplayLength']);
$url = osc_admin_base_url(true) . '?' . $_SERVER['QUERY_STRING'];
if ($maxPage == 0) {
$url = preg_replace('/&iPage=(\\d)+/', '&iPage=1', $url);
$this->redirectTo($url);
}
if ($page > 1) {
$url = preg_replace('/&iPage=(\\d)+/', '&iPage=' . $maxPage, $url);
$this->redirectTo($url);
}
}
$this->_exportVariableToView('aUsers', $aData);
$this->_exportVariableToView('locales', OSCLocale::newInstance()->listAllEnabled());
$this->doView("users/index.php");
break;
}
}
示例4: osc_esc_html
<div class="clear"></div>
</div>
</div>
<div class="form-actions">
<div class="wrapper">
<input id="show-filters" type="submit" value="<?php echo osc_esc_html( __('Apply filters') ); ?>" class="btn btn-submit" />
<a class="btn" href="<?php echo osc_admin_base_url(true).'?page=users'; ?>"><?php _e('Reset filters'); ?></a>
</div>
</div>
</form>
<h2 class="render-title"><?php _e('Manage users'); ?> <a href="<?php echo osc_admin_base_url(true) . '?page=users&action=create'; ?>" class="btn btn-mini"><?php _e('Add new'); ?></a></h2>
<div class="relative">
<div id="users-toolbar" class="table-toolbar">
<div class="float-right">
<form method="get" action="<?php echo osc_admin_base_url(true); ?>" class="inline nocsrf">
<?php foreach( Params::getParamsAsArray('get') as $key => $value ) { ?>
<?php if( $key != 'iDisplayLength' ) { ?>
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo osc_esc_html($value); ?>" />
<?php } } ?>
<select name="iDisplayLength" class="select-box-extra select-box-medium float-left" onchange="this.form.submit();" >
<option value="10"><?php printf(__('%d Users'), 10); ?></option>
<option value="25" <?php if( Params::getParam('iDisplayLength') == 25 ) echo 'selected'; ?> ><?php printf(__('%d Users'), 25); ?></option>
<option value="50" <?php if( Params::getParam('iDisplayLength') == 50 ) echo 'selected'; ?> ><?php printf(__('%d Users'), 50); ?></option>
<option value="100" <?php if( Params::getParam('iDisplayLength') == 100 ) echo 'selected'; ?> ><?php printf(__('%d Users'), 100); ?></option>
</select>
</form>
<form method="get" action="<?php echo osc_admin_base_url(true); ?>" id="shortcut-filters" class="inline nocsrf">
<input type="hidden" name="page" value="users" />
<a id="btn-display-filters" href="#" class="btn <?php if($withFilters) { echo 'btn-red'; } ?>"><?php _e('Show filters'); ?></a>
<input id="fUser" name="user" type="text" class="fUser input-text input-actions" value="<?php echo osc_esc_html(Params::getParam('user')); ?>" />
<input id="fUserId" name="userId" type="hidden" value="<?php echo osc_esc_html(Params::getParam('userId')); ?>" />
示例5: osc_update_search_url
/**
* Update the search url with new options
*
* @return string
*/
function osc_update_search_url($params, $delimiter = '&')
{
$request = Params::getParamsAsArray('get');
unset($request['osclass']);
if (isset($request['sCategory[0]'])) {
unset($request['sCategory']);
}
unset($request['sCategory[]']);
$merged = array_merge($request, $params);
return osc_base_url(true) . "?" . http_build_query($merged, '', $delimiter);
}
示例6: doModel
//.........这里部分代码省略.........
osc_add_flash_ok_message(_m('The comment has been disapproved'), 'admin');
} else {
if ($value == 'ENABLE') {
$iUpdated = $this->itemCommentManager->update(array('b_enabled' => 1), array('pk_i_id' => $id));
osc_add_hook("enable_comment", $id);
osc_add_flash_ok_message(_m('The comment has been enabled'), 'admin');
} else {
if ($value == 'DISABLE') {
$iUpdated = $this->itemCommentManager->update(array('b_enabled' => 0), array('pk_i_id' => $id));
osc_add_hook("disable_comment", $id);
osc_add_flash_ok_message(_m('The comment has been disabled'), 'admin');
}
}
}
}
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
case 'comment_edit':
$comment = ItemComment::newInstance()->findByPrimaryKey(Params::getParam('id'));
$this->_exportVariableToView('comment', $comment);
$this->doView('comments/frm.php');
break;
case 'comment_edit_post':
osc_csrf_check();
$msg = '';
if (!osc_validate_email(Params::getParam('authorEmail'), true)) {
$msg .= _m('Email is not correct') . "<br/>";
}
if (!osc_validate_text(Params::getParam('body'), 1, true)) {
$msg .= _m('Comment is required') . "<br/>";
}
if ($msg != '') {
osc_add_flash_error_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=comments&action=comment_edit&id=" . Params::getParam('id'));
}
$this->itemCommentManager->update(array('s_title' => Params::getParam('title'), 's_body' => Params::getParam('body'), 's_author_name' => Params::getParam('authorName'), 's_author_email' => Params::getParam('authorEmail')), array('pk_i_id' => Params::getParam('id')));
osc_run_hook('edit_comment', Params::getParam('id'));
osc_add_flash_ok_message(_m('Great! We just updated your comment'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
case 'delete':
osc_csrf_check();
$this->itemCommentManager->deleteByPrimaryKey(Params::getParam('id'));
osc_add_flash_ok_message(_m('The comment has been deleted'), 'admin');
osc_run_hook('delete_comment', Params::getParam('id'));
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
default:
require_once osc_lib_path() . "osclass/classes/datatables/CommentsDataTable.php";
// set default iDisplayLength
if (Params::getParam('iDisplayLength') != '') {
Cookie::newInstance()->push('listing_iDisplayLength', Params::getParam('iDisplayLength'));
Cookie::newInstance()->set();
} else {
// set a default value if it's set in the cookie
if (Cookie::newInstance()->get_value('listing_iDisplayLength') != '') {
Params::setParam('iDisplayLength', Cookie::newInstance()->get_value('listing_iDisplayLength'));
} else {
Params::setParam('iDisplayLength', 10);
}
}
$this->_exportVariableToView('iDisplayLength', Params::getParam('iDisplayLength'));
// Table header order by related
if (Params::getParam('sort') == '') {
Params::setParam('sort', 'date');
}
if (Params::getParam('direction') == '') {
Params::setParam('direction', 'desc');
}
$page = (int) Params::getParam('iPage');
if ($page == 0) {
$page = 1;
}
Params::setParam('iPage', $page);
$params = Params::getParamsAsArray();
$commentsDataTable = new CommentsDataTable();
$commentsDataTable->table($params);
$aData = $commentsDataTable->getData();
if (count($aData['aRows']) == 0 && $page != 1) {
$total = (int) $aData['iTotalDisplayRecords'];
$maxPage = ceil($total / (int) $aData['iDisplayLength']);
$url = osc_admin_base_url(true) . '?' . Params::getServerParam('QUERY_STRING', false, false);
if ($maxPage == 0) {
$url = preg_replace('/&iPage=(\\d)+/', '&iPage=1', $url);
$this->redirectTo($url);
}
if ($page > 1) {
$url = preg_replace('/&iPage=(\\d)+/', '&iPage=' . $maxPage, $url);
$this->redirectTo($url);
}
}
$this->_exportVariableToView('aData', $aData);
$this->_exportVariableToView('aRawRows', $commentsDataTable->rawRows());
$bulk_options = array(array('value' => '', 'data-dialog-content' => '', 'label' => __('Bulk actions')), array('value' => 'delete_all', 'data-dialog-content' => sprintf(__('Are you sure you want to %s the selected comments?'), strtolower(__('Delete'))), 'label' => __('Delete')), array('value' => 'activate_all', 'data-dialog-content' => sprintf(__('Are you sure you want to %s the selected comments?'), strtolower(__('Activate'))), 'label' => __('Activate')), array('value' => 'deactivate_all', 'data-dialog-content' => sprintf(__('Are you sure you want to %s the selected comments?'), strtolower(__('Deactivate'))), 'label' => __('Deactivate')), array('value' => 'disable_all', 'data-dialog-content' => sprintf(__('Are you sure you want to %s the selected comments?'), strtolower(__('Block'))), 'label' => __('Block')), array('value' => 'enable_all', 'data-dialog-content' => sprintf(__('Are you sure you want to %s the selected comments?'), strtolower(__('Unblock'))), 'label' => __('Unblock')));
$bulk_options = osc_apply_filter("comment_bulk_filter", $bulk_options);
$this->_exportVariableToView('bulk_options', $bulk_options);
$this->doView('comments/index.php');
break;
}
}
示例7: pop_ajax_load_more
function pop_ajax_load_more()
{
$array = Params::getParamsAsArray();
if ($array['_page'] == 'user') {
if ($array['_action'] == 'pub_profile') {
if ($array['username'] != '') {
$_user = User::newInstance()->findByUsername($array['username']);
$array['id'] = $_user['pk_i_id'];
}
$params['author'] = $array['id'];
$params['results_per_page'] = isset($array['_offset']) ? $array['_offset'] : osc_default_results_per_page_at_search();
$params['page'] = isset($array['iPage']) ? $array['iPage'] - 1 : 0;
}
if ($array['_action'] == 'items') {
$params['author'] = osc_logged_user_id();
$params['results_per_page'] = 10;
// core default
$params['page'] = isset($array['iPage']) ? $array['iPage'] - 1 : 0;
}
osc_query_item($params);
$result = View::newInstance()->_get('customItems');
echo _pop_print_listing_card($result);
exit;
}
if ($array['_page'] == 'search' || $array['_page'] == '') {
if (osc_rewrite_enabled()) {
if (REL_WEB_URL != '/') {
$base_url = str_replace(REL_WEB_URL, '', osc_base_url());
} else {
$base_url = osc_base_url();
}
$_SERVER['REQUEST_URI'] = preg_replace('|^' . $base_url . '|', '', osc_search_url(Params::getParamsAsArray()));
osc_add_hook('before_html', 'pop_ob_start_');
osc_add_hook('after_html', 'pop_ob_clean_');
osc_add_hook('after_search', 'pop_echo_pop_print_listing_card');
}
require_once osc_lib_path() . 'osclass/controller/search.php';
$do = new CWebSearch();
$do->doModel();
exit;
}
}
示例8: doModel
//.........这里部分代码省略.........
if ($enabled) {
$result = array('ok' => __('The subcategory has been enabled'));
} else {
$result = array('ok' => __('The subcategory has been disabled'));
}
$result['affectedIds'] = array(array('id' => $id));
echo json_encode($result);
break;
case 'delete_category':
osc_csrf_check(false);
$id = Params::getParam("id");
$error = 0;
$categoryManager = Category::newInstance();
$res = $categoryManager->deleteByPrimaryKey($id);
if ($res > 0) {
$message = __('The categories have been deleted');
} else {
$error = 1;
$message = __('An error occurred while deleting');
}
if ($error) {
$result = array('error' => $message);
} else {
$result = array('ok' => __("Saved"));
}
echo json_encode($result);
break;
case 'edit_category_post':
osc_csrf_check(false);
$id = Params::getParam("id");
$fields['i_expiration_days'] = Params::getParam("i_expiration_days") != '' ? Params::getParam("i_expiration_days") : 0;
$error = 0;
$has_one_title = 0;
$postParams = Params::getParamsAsArray();
foreach ($postParams as $k => $v) {
if (preg_match('|(.+?)#(.+)|', $k, $m)) {
if ($m[2] == 's_name') {
if ($v != "") {
$has_one_title = 1;
$aFieldsDescription[$m[1]][$m[2]] = $v;
$s_text = $v;
} else {
$aFieldsDescription[$m[1]][$m[2]] = NULL;
$error = 1;
}
} else {
$aFieldsDescription[$m[1]][$m[2]] = $v;
}
}
}
$l = osc_language();
if ($error == 0 || $error == 1 && $has_one_title == 1) {
$categoryManager = Category::newInstance();
$res = $categoryManager->updateByPrimaryKey(array('fields' => $fields, 'aFieldsDescription' => $aFieldsDescription), $id);
$categoryManager->updateExpiration($id, $fields['i_expiration_days']);
if (is_bool($res)) {
$error = 2;
}
}
if (Params::getParam('apply_changes_to_subcategories') == 1) {
$subcategories = $categoryManager->findSubcategories($id);
foreach ($subcategories as $subc) {
$categoryManager->updateExpiration($subc['pk_i_id'], $fields['i_expiration_days']);
}
}
if ($error == 0) {
示例9: doModel
//.........这里部分代码省略.........
$iUpdated += Preference::newInstance()->update(array('s_value' => $contactItemAttachment), array('s_name' => 'item_attachment'));
if ($iUpdated > 0) {
osc_add_flash_ok_message(_m("Listings' settings have been updated"), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=items&action=settings');
break;
case 'items_reported':
require_once osc_lib_path() . "osclass/classes/datatables/ItemsDataTable.php";
// set default iDisplayLength
if (Params::getParam('iDisplayLength') != '') {
Cookie::newInstance()->push('listing_iDisplayLength', Params::getParam('iDisplayLength'));
Cookie::newInstance()->set();
} else {
// set a default value if it's set in the cookie
if (Cookie::newInstance()->get_value('listing_iDisplayLength') != '') {
Params::setParam('iDisplayLength', Cookie::newInstance()->get_value('listing_iDisplayLength'));
} else {
Params::setParam('iDisplayLength', 10);
}
}
$this->_exportVariableToView('iDisplayLength', Params::getParam('iDisplayLength'));
// Table header order by related
if (Params::getParam('sort') == '') {
Params::setParam('sort', 'date');
}
if (Params::getParam('direction') == '') {
Params::setParam('direction', 'desc');
}
$page = (int) Params::getParam('iPage');
if ($page == 0) {
$page = 1;
}
Params::setParam('iPage', $page);
$params = Params::getParamsAsArray("get");
$itemsDataTable = new ItemsDataTable();
$itemsDataTable->tableReported($params);
$aData = $itemsDataTable->getData();
if (count($aData['aRows']) == 0 && $page != 1) {
$total = (int) $aData['iTotalDisplayRecords'];
$maxPage = ceil($total / (int) $aData['iDisplayLength']);
$url = osc_admin_base_url(true) . '?' . $_SERVER['QUERY_STRING'];
if ($maxPage == 0) {
$url = preg_replace('/&iPage=(\\d)+/', '&iPage=1', $url);
$this->redirectTo($url);
}
if ($page > 1) {
$url = preg_replace('/&iPage=(\\d)+/', '&iPage=' . $maxPage, $url);
$this->redirectTo($url);
}
}
$this->_exportVariableToView('aData', $aData);
$this->_exportVariableToView('aRawRows', $itemsDataTable->rawRows());
//calling the view...
$this->doView('items/reported.php');
break;
default:
// default
require_once osc_lib_path() . "osclass/classes/datatables/ItemsDataTable.php";
// set default iDisplayLength
if (Params::getParam('iDisplayLength') != '') {
Cookie::newInstance()->push('listing_iDisplayLength', Params::getParam('iDisplayLength'));
Cookie::newInstance()->set();
} else {
// set a default value if it's set in the cookie
if (Cookie::newInstance()->get_value('listing_iDisplayLength') != '') {
Params::setParam('iDisplayLength', Cookie::newInstance()->get_value('listing_iDisplayLength'));
示例10: doModel
function doModel()
{
//specific things for this class
switch ($this->action) {
case 'bulk_actions':
break;
case 'regions':
//Return regions given a countryId
$regions = Region::newInstance()->getByCountry(Params::getParam("countryId"));
echo json_encode($regions);
break;
case 'cities':
//Returns cities given a regionId
$cities = City::newInstance()->getByRegion(Params::getParam("regionId"));
echo json_encode($cities);
break;
case 'location':
// This is the autocomplete AJAX
$cities = City::newInstance()->ajax(Params::getParam("term"));
echo json_encode($cities);
break;
case 'alerts':
// Allow to register to an alert given (not sure it's used on admin)
$alert = Params::getParam("alert");
$email = Params::getParam("email");
$userid = Params::getParam("userid");
if ($alert != '' && $email != '') {
Alerts::newInstance()->insert(array('fk_i_user_id' => $userid, 's_email' => $email, 's_search' => $alert, 'e_type' => 'DAILY'));
echo "1";
return true;
}
echo '0';
return false;
break;
case 'runhook':
//Run hooks
$hook = Params::getParam("hook");
switch ($hook) {
case 'item_form':
$catId = Params::getParam("catId");
if ($catId != '') {
osc_run_hook("item_form", $catId);
} else {
osc_run_hook("item_form");
}
break;
case 'item_edit':
$catId = Params::getParam("catId");
$itemId = Params::getParam("itemId");
osc_run_hook("item_edit", $catId, $itemId);
break;
default:
if ($hook == '') {
return false;
} else {
osc_run_hook($hook);
}
break;
}
break;
case 'items':
// Return items (use external file oc-admin/ajax/item_processing.php)
require_once osc_admin_base_path() . 'ajax/items_processing.php';
$items_processing = new items_processing_ajax(Params::getParamsAsArray("get"));
break;
case 'custom':
// Execute via AJAX custom file
$ajaxfile = Params::getParam("ajaxfile");
if ($ajaxfile != '') {
require_once osc_admin_base_path() . $ajaxfile;
} else {
echo json_encode(array('error' => __('no action defined')));
}
break;
/******************************
** COMPLETE UPGRADE PROCESS **
******************************/
/******************************
** COMPLETE UPGRADE PROCESS **
******************************/
case 'upgrade':
// AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
$message = "";
$error = 0;
$remove_error_msg = "";
$sql_error_msg = "";
$rm_errors = 0;
$perms = osc_save_permissions();
osc_change_permissions();
/***********************
**** DOWNLOAD FILE ****
***********************/
if (Params::getParam('file') != '') {
$tmp = explode("/", Params::getParam('file'));
$filename = end($tmp);
$result = osc_downloadFile(Params::getParam('file'), $filename);
if ($result) {
// Everything is OK, continue
/**********************
***** UNZIP FILE *****
//.........这里部分代码省略.........
示例11: doModel
//.........这里部分代码省略.........
} else {
$result = array('ok' => __('The subcategory has been disabled'));
}
$result['affectedIds'] = array(array('id' => $id));
echo json_encode($result);
break;
case 'delete_category':
osc_csrf_check(false);
$id = Params::getParam("id");
$error = 0;
$categoryManager = Category::newInstance();
$res = $categoryManager->deleteByPrimaryKey($id);
if ($res > 0) {
$message = __('The categories have been deleted');
} else {
$error = 1;
$message = __('An error occurred while deleting');
}
if ($error) {
$result = array('error' => $message);
} else {
$result = array('ok' => __("Saved"));
}
echo json_encode($result);
break;
case 'edit_category_post':
osc_csrf_check(false);
$id = Params::getParam("id");
$fields['i_expiration_days'] = Params::getParam("i_expiration_days") != '' ? Params::getParam("i_expiration_days") : 0;
$fields['b_price_enabled'] = Params::getParam('b_price_enabled') != '' ? 1 : 0;
$apply_changes_to_subcategories = Params::getParam('apply_changes_to_subcategories') == 1 ? true : false;
$error = 0;
$has_one_title = 0;
$postParams = Params::getParamsAsArray();
foreach ($postParams as $k => $v) {
if (preg_match('|(.+?)#(.+)|', $k, $m)) {
if ($m[2] == 's_name') {
if ($v != "") {
$has_one_title = 1;
$aFieldsDescription[$m[1]][$m[2]] = $v;
$s_text = $v;
} else {
$aFieldsDescription[$m[1]][$m[2]] = NULL;
$error = 1;
}
} else {
$aFieldsDescription[$m[1]][$m[2]] = $v;
}
}
}
$l = osc_language();
if ($error == 0 || $error == 1 && $has_one_title == 1) {
$categoryManager = Category::newInstance();
$res = $categoryManager->updateByPrimaryKey(array('fields' => $fields, 'aFieldsDescription' => $aFieldsDescription), $id);
$categoryManager->updateExpiration($id, $fields['i_expiration_days'], $apply_changes_to_subcategories);
$categoryManager->updatePriceEnabled($id, $fields['b_price_enabled'], $apply_changes_to_subcategories);
if (is_bool($res)) {
$error = 2;
}
}
if ($error == 0) {
$msg = __("Category updated correctly");
} else {
if ($error == 1) {
if ($has_one_title == 1) {
$error = 4;
示例12: doModel
function doModel()
{
parent::doModel();
//specific things for this class
switch ($this->action) {
case 'add':
$this->_exportVariableToView("categories", $this->categoryManager->toTreeAll());
$this->_exportVariableToView("languages", OSCLocale::newInstance()->listAllEnabled());
$this->_exportVariableToView("category", array());
$this->doView("categories/frm.php");
break;
case 'add_post':
try {
// fields contain data of t_category
$fields['fk_i_parent_id'] = Params::getParam("fk_i_parent_id") != '' ? Params::getParam("fk_i_parent_id") : null;
$fields['i_expiration_days'] = Params::getParam("i_expiration_days") != '' ? Params::getParam("i_expiration_days") : 0;
$fields['i_position'] = Params::getParam("i_position") != '' ? Params::getParam("i_position") : 0;
$fields['b_enabled'] = Params::getParam("b_enabled") != '' ? 1 : 0;
$postParams = Params::getParamsAsArray();
foreach ($postParams as $k => $v) {
if (preg_match('|(.+?)#(.+)|', $k, $m)) {
$aFieldsDescription[$m[1]][$m[2]] = $v;
}
}
$this->categoryManager->insert($fields, $aFieldsDescription);
osc_add_flash_message(_m('The category has been added'), 'admin');
} catch (Exception $e) {
osc_add_flash_message(_m('The category could\'t be added') . $e->getMessage(), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=categories');
break;
case 'edit':
$this->_exportVariableToView("category", $this->categoryManager->findByPrimaryKey(Params::getParam("id")));
$this->_exportVariableToView("categories", $this->categoryManager->toTreeAll());
$this->_exportVariableToView("languages", OSCLocale::newInstance()->listAllEnabled());
$this->doView("categories/frm.php");
break;
case 'edit_post':
$id = Params::getParam("id");
$fields['fk_i_parent_id'] = Params::getParam("fk_i_parent_id") != '' ? Params::getParam("fk_i_parent_id") : null;
$fields['i_expiration_days'] = Params::getParam("i_expiration_days") != '' ? Params::getParam("i_expiration_days") : 0;
$fields['i_position'] = Params::getParam("i_position") != '' ? Params::getParam("i_position") : 0;
$fields['b_enabled'] = Params::getParam("b_enabled") != '' ? 1 : 0;
$postParams = Params::getParamsAsArray();
foreach ($postParams as $k => $v) {
if (preg_match('|(.+?)#(.+)|', $k, $m)) {
$aFieldsDescription[$m[1]][$m[2]] = $v;
}
}
try {
$this->categoryManager->updateByPrimaryKey($fields, $aFieldsDescription, $id);
osc_add_flash_message(_m('The category has been updated.'), 'admin');
} catch (Exception $e) {
osc_add_flash_message(_m('Error: ') . $e->getMessage(), 'admin');
}
if (!is_null($fields['fk_i_parent_id'])) {
$this->redirectTo(osc_admin_base_url(true) . '?page=categories&parentId=' . $fields['fk_i_parent_id']);
} else {
$this->redirectTo(osc_admin_base_url(true) . '?page=categories');
}
break;
case 'delete':
$id = Params::getParam("id");
try {
foreach ($id as $i) {
if (intval($i)) {
$this->categoryManager->deleteByPrimaryKey($i);
}
}
osc_add_flash_message(_m('The categories have been deleted'), 'admin');
} catch (Exception $e) {
osc_add_flash_message(_m('Error: ') . $e->getMessage(), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=categories');
break;
case 'enable':
$id = Params::getParam("id");
$enabled = Params::getParam("enabled") != '' ? Params::getParam("enabled") : 0;
try {
if ($id != '') {
$this->categoryManager->update(array('b_enabled' => $enabled), array('pk_i_id' => $id));
if ($enabled == 1) {
$msg = _m('The category has been enabled');
} else {
$msg = _m('The category has been disabled');
}
} else {
$msg = _m('There was a problem with this page. The ID for the category hasn\'t been set');
}
osc_add_flash_message($msg, 'admin');
} catch (Exception $e) {
osc_add_flash_message(_m('Error: ') . $e->getMessage(), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=categories');
break;
case 'enable_selected':
$ids = Params::getParam("id");
try {
if ($ids != '') {
foreach ($ids as $id) {
//.........这里部分代码省略.........
示例13: doModel
function doModel()
{
//specific things for this class
switch ($this->action) {
case 'bulk_actions':
break;
case 'regions':
//Return regions given a countryId
$regions = Region::newInstance()->getByCountry(Params::getParam("countryId"));
echo json_encode($regions);
break;
case 'cities':
//Returns cities given a regionId
$cities = City::newInstance()->getByRegion(Params::getParam("regionId"));
echo json_encode($cities);
break;
case 'location':
// This is the autocomplete AJAX
$cities = City::newInstance()->ajax(Params::getParam("term"));
echo json_encode($cities);
break;
case 'alerts':
// Allow to register to an alert given (not sure it's used on admin)
$alert = Params::getParam("alert");
$email = Params::getParam("email");
$userid = Params::getParam("userid");
if ($alert != '' && $email != '') {
Alerts::newInstance()->insert(array('fk_i_user_id' => $userid, 's_email' => $email, 's_search' => $alert, 'e_type' => 'DAILY'));
echo "1";
return true;
}
echo '0';
break;
case 'runhook':
//Run hooks
$hook = Params::getParam("hook");
switch ($hook) {
case 'item_form':
$catId = Params::getParam("catId");
if ($catId != '') {
osc_run_hook("item_form", $catId);
} else {
osc_run_hook("item_form");
}
break;
case 'item_edit':
$catId = Params::getParam("catId");
$itemId = Params::getParam("itemId");
osc_run_hook("item_edit", $catId, $itemId);
break;
default:
if ($hook == '') {
return false;
} else {
osc_run_hook($hook);
}
break;
}
break;
case 'items':
// Return items (use external file oc-admin/ajax/item_processing.php)
require_once osc_admin_base_path() . 'ajax/items_processing.php';
$items_processing = new items_processing_ajax(Params::getParamsAsArray("get"));
break;
case 'media':
// Return items (use external file oc-admin/ajax/media_processing.php)
require_once osc_admin_base_path() . 'ajax/media_processing.php';
$media_processing = new media_processing_ajax(Params::getParamsAsArray("get"));
break;
case 'categories_order':
// Save the order of the categories
$aIds = Params::getParam('list');
$orderParent = 0;
$orderSub = 0;
$catParent = 0;
$catManager = Category::newInstance();
foreach ($aIds as $id => $parent) {
if ($parent == 'root') {
if (!$catManager->update_order($id, $orderParent)) {
$error = 1;
}
// set parent category
$conditions = array('pk_i_id' => $id);
$array['fk_i_parent_id'] = DB_CONST_NULL;
if (!$catManager->update($array, $conditions) > 0) {
$error = 1;
}
$orderParent++;
} else {
if ($parent != $catParent) {
$catParent = $parent;
$orderSub = 0;
}
if (!$catManager->update_order($id, $orderSub)) {
$error = 1;
}
// set parent category
$conditions = array('pk_i_id' => $id);
$array['fk_i_parent_id'] = $catParent;
if (!$catManager->update($array, $conditions) > 0) {
//.........这里部分代码省略.........
示例14: doModel
function doModel()
{
parent::doModel();
//specific things for this class
switch ($this->action) {
case 'edit':
if (Params::getParam("id") == '') {
$this->redirectTo(osc_admin_base_url(true) . "?page=pages");
}
$form = count(Session::newInstance()->_getForm());
$keepForm = count(Session::newInstance()->_getKeepForm());
if ($form == 0 || $form == $keepForm) {
Session::newInstance()->_dropKeepForm();
}
$templates = osc_apply_filter('page_templates', WebThemes::newInstance()->getAvailableTemplates());
$this->_exportVariableToView('templates', $templates);
$this->_exportVariableToView("page", $this->pageManager->findByPrimaryKey(Params::getParam("id")));
$this->doView("pages/frm.php");
break;
case 'edit_post':
osc_csrf_check();
$id = Params::getParam("id");
$b_link = Params::getParam("b_link") != '' ? 1 : 0;
$s_internal_name = Params::getParam("s_internal_name");
$s_internal_name = osc_sanitizeString($s_internal_name);
$meta = Params::getParam('meta');
$this->pageManager->updateMeta($id, json_encode($meta));
$aFieldsDescription = array();
$postParams = Params::getParamsAsArray('', false);
$not_empty = false;
foreach ($postParams as $k => $v) {
if (preg_match('|(.+?)#(.+)|', $k, $m)) {
if ($m[2] == 's_title' && $v != '') {
$not_empty = true;
}
$aFieldsDescription[$m[1]][$m[2]] = $v;
}
}
Session::newInstance()->_setForm('aFieldsDescription', $aFieldsDescription);
if ($s_internal_name == '') {
osc_add_flash_error_message(_m('You have to set an internal name'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=pages&action=edit&id=" . $id);
}
if (!WebThemes::newInstance()->isValidPage($s_internal_name)) {
osc_add_flash_error_message(_m('You have to set a different internal name'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=pages&action=edit&id=" . $id);
}
Session::newInstance()->_setForm('s_internal_name', $s_internal_name);
if ($not_empty) {
foreach ($aFieldsDescription as $k => $_data) {
$this->pageManager->updateDescription($id, $k, $_data['s_title'], $_data['s_text']);
}
if (!$this->pageManager->internalNameExists($id, $s_internal_name)) {
if (!$this->pageManager->isIndelible($id)) {
$this->pageManager->updateInternalName($id, $s_internal_name);
$this->pageManager->updateLink($id, $b_link);
}
osc_run_hook('edit_page', $id);
Session::newInstance()->_clearVariables();
osc_add_flash_ok_message(_m('The page has been updated'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=pages");
}
osc_add_flash_error_message(_m("You can't repeat internal name"), 'admin');
} else {
osc_add_flash_error_message(_m("The page couldn't be updated, at least one title should not be empty"), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . "?page=pages&action=edit&id=" . $id);
break;
case 'add':
$form = count(Session::newInstance()->_getForm());
$keepForm = count(Session::newInstance()->_getKeepForm());
if ($form == 0 || $form == $keepForm) {
Session::newInstance()->_dropKeepForm();
}
$templates = osc_apply_filter('page_templates', WebThemes::newInstance()->getAvailableTemplates());
$this->_exportVariableToView('templates', $templates);
$this->_exportVariableToView("page", array());
$this->doView("pages/frm.php");
break;
case 'add_post':
osc_csrf_check();
$s_internal_name = Params::getParam("s_internal_name");
$b_link = Params::getParam("b_link") != '' ? 1 : 0;
$s_internal_name = osc_sanitizeString($s_internal_name);
$meta = Params::getParam('meta');
$aFieldsDescription = array();
$postParams = Params::getParamsAsArray('', false);
$not_empty = false;
foreach ($postParams as $k => $v) {
if (preg_match('|(.+?)#(.+)|', $k, $m)) {
if ($m[2] == 's_title' && $v != '') {
$not_empty = true;
}
$aFieldsDescription[$m[1]][$m[2]] = $v;
}
}
Session::newInstance()->_setForm('aFieldsDescription', $aFieldsDescription);
if ($s_internal_name == '') {
osc_add_flash_error_message(_m('You have to set an internal name'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=pages&action=add");
//.........这里部分代码省略.........
示例15: osc_base_url
}
?>
<?php
}
?>
</div>
<?php
}
?>
<form action="<?php
echo osc_base_url(true);
?>
" method="get" class="nocsrf">
<input type="hidden" name="page" value="search"/>
<?php
foreach (Params::getParamsAsArray() as $key => $value) {
if ($key != 'page' && $key != 'action') {
?>
<input type="hidden" name="<?php
echo osc_esc_html($key);
?>
" value="<?php
echo osc_esc_html($value);
?>
"/>
<?php
}
}
?>
<div class="plugin-hooks">
<?php