本文整理汇总了PHP中city::newInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP city::newInstance方法的具体用法?PHP city::newInstance怎么用?PHP city::newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类city
的用法示例。
在下文中一共展示了city::newInstance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareData
/**
* Return an array with all data necessary for do the action (ADD OR EDIT)
* @param <type> $is_add
* @return array
*/
public function prepareData($is_add)
{
$aItem = array();
if ($is_add) {
// ADD
$userId = null;
if ($this->is_admin) {
if (Params::getParam('userId') != '') {
$userId = Params::getParam('userId');
}
} else {
$userId = Session::newInstance()->_get('userId');
if ($userId == '') {
$userId = NULL;
}
}
if ($this->is_admin) {
$active = 'ACTIVE';
} else {
if (osc_moderate_items() > 0) {
// HAS TO VALIDATE
if (!osc_is_web_user_logged_in()) {
// NO USER IS LOGGED, VALIDATE
$active = 'INACTIVE';
} else {
// USER IS LOGGED
if (osc_logged_user_item_validation()) {
//USER IS LOGGED, BUT NO NEED TO VALIDATE
$active = 'ACTIVE';
} else {
// USER IS LOGGED, NEED TO VALIDATE, CHECK NUMBER OF PREVIOUS ITEMS
$user = User::newInstance()->findByPrimaryKey(osc_logged_user_id());
if ($user['i_items'] < osc_moderate_items()) {
$active = 'INACTIVE';
} else {
$active = 'ACTIVE';
}
}
}
} else {
if (osc_moderate_items() == 0) {
if (osc_is_web_user_logged_in() && osc_logged_user_item_validation()) {
$active = 'ACTIVE';
} else {
$active = 'INACTIVE';
}
} else {
$active = 'ACTIVE';
}
}
}
if ($userId != null) {
$data = User::newInstance()->findByPrimaryKey($userId);
$aItem['contactName'] = $data['s_name'];
$aItem['contactEmail'] = $data['s_email'];
Params::setParam('contactName', $data['s_name']);
Params::setParam('contactEmail', $data['s_email']);
} else {
$aItem['contactName'] = Params::getParam('contactName');
$aItem['contactEmail'] = Params::getParam('contactEmail');
}
$aItem['active'] = $active;
$aItem['userId'] = $userId;
} else {
// EDIT
$aItem['secret'] = Params::getParam('secret');
$aItem['idItem'] = Params::getParam('id');
$userId = Params::getParam('userId');
if ($userId != null) {
$data = User::newInstance()->findByPrimaryKey($userId);
$aItem['contactName'] = $data['s_name'];
$aItem['contactEmail'] = $data['s_email'];
Params::setParam('contactName', $data['s_name']);
Params::setParam('contactEmail', $data['s_email']);
} else {
$aItem['contactName'] = Params::getParam('contactName');
$aItem['contactEmail'] = Params::getParam('contactEmail');
}
}
// get params
$aItem['catId'] = Params::getParam('catId');
$aItem['countryId'] = Params::getParam('countryId');
$aItem['country'] = Params::getParam('country');
$aItem['region'] = Params::getParam('region');
$aItem['regionId'] = Params::getParam('regionId');
$aItem['city'] = Params::getParam('city');
$aItem['cityId'] = Params::getParam('cityId');
$aItem['price'] = Params::getParam('price') != '' ? Params::getParam('price') : null;
$aItem['cityArea'] = Params::getParam('cityArea');
$aItem['address'] = Params::getParam('address');
$aItem['currency'] = Params::getParam('currency');
$aItem['showEmail'] = Params::getParam('showEmail') != '' ? 1 : 0;
$aItem['title'] = Params::getParam('title');
$aItem['description'] = Params::getParam('description');
$aItem['photos'] = Params::getFiles('photos');
//.........这里部分代码省略.........