本文整理汇总了PHP中Topxia\Common\ArrayToolkit::parts方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayToolkit::parts方法的具体用法?PHP ArrayToolkit::parts怎么用?PHP ArrayToolkit::parts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topxia\Common\ArrayToolkit
的用法示例。
在下文中一共展示了ArrayToolkit::parts方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction(Request $request)
{
$conditions = $request->query->all();
$conditions = ArrayToolkit::parts($conditions, array('nickname'));
$paginator = new Paginator($this->get('request'), $this->getUserService()->searchUserCount($conditions), 20);
$users = $this->getUserService()->searchUsers($conditions, array('id', 'ASC'), $paginator->getOffsetCount(), $paginator->getPerPageCount());
$inviteInformations = array();
foreach ($users as $key => $user) {
$invitedRecords = $this->getInviteRecordService()->findRecordsByInviteUserId($user['id']);
$payingUserCount = 0;
$coinAmountTotalPrice = 0;
$amountTotalPrice = 0;
$totalPrice = 0;
$totalCoinAmount = 0;
$totalAmount = 0;
foreach ($invitedRecords as $keynum => $invitedRecord) {
$coinAmountTotalPrice = $this->getOrderService()->analysisCoinAmount(array('userId' => $invitedRecord['invitedUserId'], 'coinAmount' => 0, 'status' => 'paid', 'paidStartTime' => $invitedRecord['inviteTime']));
$amountTotalPrice = $this->getOrderService()->analysisAmount(array('userId' => $invitedRecord['invitedUserId'], 'amount' => 0, 'status' => 'paid', 'paidStartTime' => $invitedRecord['inviteTime']));
$tempPrice = $this->getOrderService()->analysisTotalPrice(array('userId' => $invitedRecord['invitedUserId'], 'status' => 'paid', 'paidStartTime' => $invitedRecord['inviteTime']));
if ($coinAmountTotalPrice || $amountTotalPrice) {
$payingUserCount = $payingUserCount + 1;
}
$totalCoinAmount = $totalCoinAmount + $coinAmountTotalPrice;
$totalAmount = $totalAmount + $amountTotalPrice;
$totalPrice = $totalPrice + $tempPrice;
}
$inviteInformations[] = array('id' => $user['id'], 'nickname' => $user['nickname'], 'payingUserCount' => $payingUserCount, 'payingUserTotalPrice' => $totalPrice, 'coinAmountPrice' => $totalCoinAmount, 'amountPrice' => $totalAmount, 'count' => count($invitedRecords));
}
return $this->render('TopxiaAdminBundle:Invite:index.html.twig', array('paginator' => $paginator, 'inviteInformations' => $inviteInformations));
}
示例2: createMoneyCard
public function createMoneyCard(array $moneyCardData)
{
$batch = ArrayToolkit::parts($moneyCardData, array('money', 'cardPrefix', 'cardLength', 'number', 'note', 'deadline'));
$batch['money'] = (int) $batch['money'];
$batch['cardLength'] = (int) $batch['cardLength'];
$batch['number'] = (int) $batch['number'];
if ($batch['money'] <= 0) {
throw $this->createServiceException('ERROR! Money Value Less Than Zero!');
}
if ($batch['cardLength'] <= 0) {
throw $this->createServiceException('ERROR! CardLength Less Than Zero!');
}
if ($batch['number'] <= 0) {
throw $this->createServiceException('ERROR! Card Number Less Than Zero!');
}
$batch['rechargedNumber'] = 0;
$batch['userId'] = $this->getCurrentUser()->id;
$batch['createdTime'] = time();
$moneyCardIds = $this->makeRands($batch['cardLength'], $batch['number'], $batch['cardPrefix'], $moneyCardData['passwordLength']);
if (!$this->getMoneyCardDao()->isCardIdAvaliable($moneyCardIds)) {
throw $this->createServiceException('卡号有重复,生成失败,请重新生成!');
}
$batch = $this->getMoneyCardBatchDao()->addBatch($batch);
$moneyCards = array();
foreach ($moneyCardIds as $cardid => $cardPassword) {
$moneyCards[] = array('cardId' => $cardid, 'password' => $cardPassword, 'deadline' => $moneyCardData['deadline'], 'cardStatus' => 'normal', 'batchId' => $batch['id']);
}
$this->getMoneyCardDao()->addMoneyCard($moneyCards);
$this->getLogService()->info('money_card_batch', 'create', "创建新批次充值卡,卡号前缀为({$batch['cardPrefix']}),批次为({$batch['id']})");
return $batch;
}
示例3: modifyUserInfoAction
public function modifyUserInfoAction(Request $request)
{
$formData = $request->request->all();
$user = $this->getCurrentUser();
if (empty($user)) {
return $this->createMessageResponse('error', '用户未登录,不能购买。');
}
$course = $this->getCourseService()->getCourse($formData['targetId']);
if (empty($course)) {
return $this->createMessageResponse('error', '课程不存在,不能购买。');
}
$userInfo = ArrayToolkit::parts($formData, array('truename', 'mobile', 'qq', 'company', 'weixin', 'weibo', 'idcard', 'gender', 'job', 'intField1', 'intField2', 'intField3', 'intField4', 'intField5', 'floatField1', 'floatField2', 'floatField3', 'floatField4', 'floatField5', 'dateField1', 'dateField2', 'dateField3', 'dateField4', 'dateField5', 'varcharField1', 'varcharField2', 'varcharField3', 'varcharField4', 'varcharField5', 'varcharField10', 'varcharField6', 'varcharField7', 'varcharField8', 'varcharField9', 'textField1', 'textField2', 'textField3', 'textField4', 'textField5', 'textField6', 'textField7', 'textField8', 'textField9', 'textField10'));
$userInfo = $this->getUserService()->updateUserProfile($user['id'], $userInfo);
$coinSetting = $this->setting("coin");
if (isset($coinSetting["coin_enabled"]) && $coinSetting["coin_enabled"] == 1 && isset($coinSetting["price_type"]) && $coinSetting["price_type"] == "Coin" && $course['coinPrice'] == 0 || $course['price'] == 0) {
$formData['amount'] = 0;
$formData['totalPrice'] = 0;
$formData['priceType'] = empty($coinSetting["priceType"]) ? 'RMB' : $coinSetting["priceType"];
$formData['coinRate'] = empty($coinSetting["coinRate"]) ? 1 : $coinSetting["coinRate"];
$formData['coinAmount'] = 0;
$order = $this->getCourseOrderService()->createOrder($formData);
if ($order['status'] == 'paid') {
return $this->redirect($this->generateUrl('course_show', array('id' => $order['targetId'])));
}
}
return $this->redirect($this->generateUrl('order_show', array('targetId' => $formData['targetId'], 'targetType' => 'course')));
}
示例4: createOrder
public function createOrder($order)
{
if (!ArrayToolkit::requireds($order, array('userId', 'title', 'amount', 'targetType', 'targetId', 'payment'))) {
throw $this->createServiceException('创建订单失败:缺少参数。');
}
$order = ArrayToolkit::parts($order, array('userId', 'title', 'amount', 'targetType', 'targetId', 'payment', 'note', 'snPrefix', 'data', 'couponCode', 'coinAmount', 'coinRate', 'priceType', 'totalPrice', 'coupon', 'couponDiscount', 'discountId', 'discount'));
$orderUser = $this->getUserService()->getUser($order['userId']);
if (empty($orderUser)) {
throw $this->createServiceException("订单用户(#{$order['userId']})不存在,不能创建订单。");
}
if (!in_array($order['payment'], array('none', 'alipay', 'alipaydouble', 'tenpay', 'coin'))) {
throw $this->createServiceException('创建订单失败:payment取值不正确。');
}
$order['sn'] = $this->generateOrderSn($order);
unset($order['snPrefix']);
if (!empty($order['couponCode'])) {
$couponInfo = $this->getCouponService()->checkCouponUseable($order['couponCode'], $order['targetType'], $order['targetId'], $order['amount']);
if ($couponInfo['useable'] != 'yes') {
throw $this->createServiceException("优惠码不可用");
}
}
unset($order['couponCode']);
$order['amount'] = number_format($order['amount'], 2, '.', '');
if (intval($order['amount'] * 100) == 0) {
$order['payment'] = 'none';
}
$order['status'] = 'created';
$order['createdTime'] = time();
$order = $this->getOrderDao()->addOrder($order);
$this->_createLog($order['id'], 'created', '创建订单');
return $order;
}
示例5: updateTag
public function updateTag($id, array $fields)
{
$tag = $this->getTag($id);
if (empty($tag)) {
throw $this->createServiceException("标签(#{$id})不存在,更新失败!");
}
$fields = ArrayToolkit::parts($fields, array('name'));
$this->filterTagFields($fields, $tag);
$this->getLogService()->info('tag', 'update', "编辑标签{$fields['name']}(#{$id})");
return $this->getTagDao()->updateTag($id, $fields);
}
示例6: get
public function get(Application $app, Request $request)
{
$conditions = ArrayToolkit::parts($request->query->all(), array('categoryId'));
$sort = $request->query->get('sort', 'published');
$start = $request->query->get('start', 0);
$limit = $request->query->get('limit', 10);
$total = $this->getArticleService()->searchArticlesCount($conditions);
$start = $start == -1 ? rand(0, $total - 1) : $start;
$articles = $this->getArticleService()->searchArticles($conditions, $sort, $start, $limit);
return $this->wrap($this->filter($articles), $total);
}
示例7: createAttribute
public function createAttribute($attribute)
{
$attribute = ArrayToolkit::parts($attribute, array('name', 'categoryId', 'attrType', 'attrValues'));
if (!ArrayToolkit::requireds($attribute, array('name', 'categoryId', 'attrType'))) {
throw $this->createServiceException("缺少必要参数,,添加属性失败");
}
$this->_filterAttributeFields($attribute);
$attribute = $this->getAttributeDao()->addAttribute($attribute);
// $this->getLogService()->info('attribute', 'create', "添加栏目 {$attribute['name']}(#{$attribute['id']})", $attribute);
return $attribute;
}
示例8: get
public function get(Application $app, Request $request)
{
$conditions = ArrayToolkit::parts($request->query->all(), array());
$sort = $request->query->get('sort', 'created');
$start = $request->query->get('start', 0);
$limit = $request->query->get('limit', 10);
$total = $this->getThreadService()->searchThreadCount($conditions);
$start = $start == -1 ? rand(0, $total - 1) : $start;
$threads = $this->getThreadService()->searchThreads($conditions, $sort, $start, $limit);
return $this->wrap($this->filter($threads), $total);
}
示例9: createProduct
public function createProduct($fields)
{
if (!ArrayToolkit::requireds($fields, array('name'))) {
throw $this->createServiceException('缺少必要字段,创建课程失败!');
}
$fields = ArrayToolkit::parts($fields, array('name', 'price', 'categoryId', 'userId'));
$fields['productDetail'] = !empty($fields['productDetail']) ? $this->purifyHtml($fields['productDetail']) : '';
$fields['userId'] = $this->getCurrentUser()->id;
$fields['createdTime'] = time();
$product = $this->getCourseDao()->addProduct(ProductSerialize::serialize($fields));
return $product;
}
示例10: createGift
public function createGift($gift)
{
if (!ArrayToolkit::requireds($gift, array('giftName'))) {
throw $this->createServiceException('缺少必要字段,添加礼品失败!');
}
$gift = ArrayToolkit::parts($gift, array('giftName', 'points', 'detail'));
$gift['detail'] = !empty($gift['detail']) ? $this->purifyHtml($gift['detail']) : '';
$gift['createdTime'] = time();
$gift = $this->getGiftDao()->addGift($gift);
$gift = $this->getGift($gift['id']);
// $this->getLogService()->info('gift', 'create', "添加礼品《{$gift['giftName']}》(#{$gift['id']})");
return $gift;
}
示例11: userAvatarAction
public function userAvatarAction(Request $request)
{
$defaultSetting = $this->getSettingService()->get('default', array());
if ($request->getMethod() == 'POST') {
$userDefaultSetting = $request->request->all();
$userDefaultSetting = ArrayToolkit::parts($userDefaultSetting, array('defaultAvatar'));
$defaultSetting = array_merge($defaultSetting, $userDefaultSetting);
$this->getSettingService()->set('default', $defaultSetting);
$this->getLogService()->info('system', 'update_settings', "更新头像设置", $userDefaultSetting);
$this->setFlashMessage('success', '头像设置已保存!');
}
return $this->render('TopxiaAdminBundle:System:user-avatar.html.twig', array('defaultSetting' => $defaultSetting));
}
示例12: indexAction
public function indexAction(Request $request)
{
$sensitiveWordSetting = $this->getSettingService()->get("sensitiveWord", array());
if ($request->getMethod() == 'POST') {
$fields = $request->request->all();
$sensitiveWordSetting = ArrayToolkit::parts($fields, array("enabled", "ignoreWord", "wordReplace", "firstLevel", "secondLevel"));
$keywords = explode("\r\n", $sensitiveWordSetting["secondLevel"]);
$keywordFilter = new KeywordFilter();
$keywordFilter->addKeywords($keywords);
$this->getSettingService()->set("sensitiveWord", $sensitiveWordSetting);
}
return $this->render('TopxiaAdminBundle:SensitiveWord:index.html.twig', array("sensitiveWordSetting" => $sensitiveWordSetting));
}
示例13: modifyUserInfoAction
public function modifyUserInfoAction(Request $request)
{
$formData = $request->request->all();
$user = $this->getCurrentUser();
if (empty($user)) {
return $this->createMessageResponse('error', '用户未登录,不能购买。');
}
$course = $this->getCourseService()->getCourse($formData['targetId']);
if (empty($course)) {
return $this->createMessageResponse('error', '课程不存在,不能购买。');
}
$userInfo = ArrayToolkit::parts($formData, array('truename', 'mobile', 'qq', 'company', 'weixin', 'weibo', 'idcard', 'gender', 'job', 'intField1', 'intField2', 'intField3', 'intField4', 'intField5', 'floatField1', 'floatField2', 'floatField3', 'floatField4', 'floatField5', 'dateField1', 'dateField2', 'dateField3', 'dateField4', 'dateField5', 'varcharField1', 'varcharField2', 'varcharField3', 'varcharField4', 'varcharField5', 'varcharField10', 'varcharField6', 'varcharField7', 'varcharField8', 'varcharField9', 'textField1', 'textField2', 'textField3', 'textField4', 'textField5', 'textField6', 'textField7', 'textField8', 'textField9', 'textField10'));
$userInfo = $this->getUserService()->updateUserProfile($user['id'], $userInfo);
//判断用户是否为VIP
$vipStatus = $courseVip = null;
if ($this->isPluginInstalled('Vip') && $this->setting('vip.enabled')) {
$courseVip = $course['vipLevelId'] > 0 ? $this->getLevelService()->getLevel($course['vipLevelId']) : null;
if ($courseVip) {
$vipStatus = $this->getVipService()->checkUserInMemberLevel($user['id'], $courseVip['id']);
if ($vipStatus == 'ok') {
$formData['becomeUseMember'] = true;
}
}
}
//免费课程,直接加入并进入课时
$coinSetting = $this->setting("coin");
$courseSetting = $this->getSettingService()->get('course', array());
$coinEnable = isset($coinSetting["coin_enabled"]) && $coinSetting["coin_enabled"] == 1;
//$userInfoEnable = isset($courseSetting['buy_fill_userinfo']) && $courseSetting['buy_fill_userinfo'] == 1;
if ($coinEnable && isset($coinSetting['price_type']) && $coinSetting['price_type'] == "Coin" && $course['coinPrice'] == 0 || (!isset($coinSetting['price_type']) || $coinSetting['price_type'] == "RMB") && $course['price'] == 0 || $vipStatus == 'ok') {
$data = array("price" => 0, "remark" => '');
$this->getCourseMemberService()->becomeStudentAndCreateOrder($user["id"], $course['id'], $data);
if (isset($formData['lessonId'])) {
return $this->redirect($this->generateUrl('course_learn', array('id' => $course['id'])) . '#lesson/' . $formData['lessonId']);
} else {
return $this->redirect($this->generateUrl('course_show', array('id' => $course['id'])));
}
}
if (isset($coinSetting["coin_enabled"]) && $coinSetting["coin_enabled"] == 1 && isset($coinSetting["price_type"]) && $coinSetting["price_type"] == "Coin" && $course['coinPrice'] == 0 || $course['price'] == 0 || $vipStatus == 'ok') {
$formData['amount'] = 0;
$formData['totalPrice'] = 0;
$formData['priceType'] = empty($coinSetting["priceType"]) ? 'RMB' : $coinSetting["priceType"];
$formData['coinRate'] = empty($coinSetting["coinRate"]) ? 1 : $coinSetting["coinRate"];
$formData['coinAmount'] = 0;
$order = $this->getCourseOrderService()->createOrder($formData);
if ($order['status'] == 'paid') {
return $this->redirect($this->generateUrl('course_show', array('id' => $order['targetId'])));
}
}
return $this->redirect($this->generateUrl('order_show', array('targetId' => $formData['targetId'], 'targetType' => 'course')));
}
示例14: courseAvatarAction
public function courseAvatarAction(Request $request)
{
$defaultSetting = $this->getSettingService()->get('default', array());
if ($request->getMethod() == 'POST') {
$defaultSetting = $request->request->all();
$courseDefaultSetting = ArrayToolkit::parts($defaultSetting, array('defaultCoursePicture'));
$default = $this->getSettingService()->get('default', array());
$defaultSetting = array_merge($default, $courseDefaultSetting);
$this->getSettingService()->set('default', $defaultSetting);
$this->getLogService()->info('system', 'update_settings', "更新课程默认图片设置", $defaultSetting);
$this->setFlashMessage('success', '课程默认图片设置已保存!');
}
return $this->render('TopxiaAdminBundle:System:course-avatar.html.twig', array('defaultSetting' => $defaultSetting, 'hasOwnCopyright' => false));
}
示例15: updateHomework
public function updateHomework($id, array $fields)
{
$Homework = $this->getHomework($id);
if (empty($Homework)) {
throw $this->createNoteFoundException("作业(#{$id})不存在,更新作业失败!");
}
$fields = ArrayToolkit::parts($fields, array('id', 'content'));
if (empty($fields)) {
throw $this->createServiceException('参数不正确,更新作业失败!');
}
$this->_filterHomeworkFields($fields);
$fields['update_at'] = $_SERVER['REQUEST_TIME'];
$this->getLogService()->info('Homework', 'update', "编辑作业 {$fields['content']}(#{$id})", $fields);
return $this->getHomeworkDao()->updateHomework($id, $fields);
}