public function __construct(array $info) { foreach ($info['incidents'] as &$incident) { $incident = new Incident($incident); } parent::__construct($info); }
public function __construct(array $info) { foreach ($info['services'] as &$service) { $service = new Service($service); } parent::__construct($info); }
public function __construct(array $info) { foreach ($info['updates'] as &$update) { $update = new Message($update); } parent::__construct($info); }
/** * Set up the information about this game. * * @param array $info */ public function __construct(array $info) { // set bans if (!isset($info['bannedChampions'])) { // no bans in this game $info['bannedChampions'] = []; } $rawBans = $info['bannedChampions']; $bans = []; foreach ($rawBans as $value) { $ban = new Ban($value); $bans[$ban->pickTurn] = $ban; } $info['bannedChampions'] = $bans; // set observer if (isset($info['observers'])) { $info['observers'] = new Observer($info['observers']); } // set participants if (!isset($info['participants'])) { $info['participants'] = []; } $rawParticipants = $info['participants']; $participants = []; foreach ($rawParticipants as $value) { $participant = new CurrentGameParticipant($value); $participants[$participant->summonerId] = $participant; } $info['participants'] = $participants; parent::__construct($info); }
public function __construct(array $info) { if (isset($info['stats'])) { $info['stats'] = new AggregateStats($info['stats']); } parent::__construct($info); }
public function __construct(array $info) { foreach ($info['translations'] as &$translation) { $translation = new Translation($translation); } parent::__construct($info); }
public function service() { $onlineUserManager = new OnlineUsersManager($this->config, $this->args); $customer = $this->getCustomer(); if ($this->getUserLevel() !== UserGroups::$GUEST) { //add to online users table $customerEmail = $customer->getEmail(); $newAdded = $onlineUserManager->addOnlineUser($this->getUserLevel(), $customer) > 0; if ($newAdded) { $customerMessagesAfterLoginManager = CustomerMessagesAfterLoginManager::getInstance($this->config, $this->args); $customerAfterLoginMessagesDtos = $customerMessagesAfterLoginManager->getCustomerMessages($customer->getEmail()); $customerMessagesAfterLoginManager->incrementCustomerMessagesShowedCount($customerAfterLoginMessagesDtos); $customerAfterLoginMessagesDtosToArray = AbstractDto::dtosToArray($customerAfterLoginMessagesDtos); } //check user alerts $winUid = $_REQUEST['win_uid']; $customerAlertListManager = CustomerAlertListManager::getInstance($this->config, $this->args); $registeredCustomerAlertsDtosToArray = $customerAlertListManager->getRegisteredCustomerAlerts($customer, $winUid); $customerAlertsManager = CustomerAlertsManager::getInstance($this->config, $this->args); $customerMessagesDtos = $customerAlertsManager->getCustomerAlertsByCustomerLogin($customerEmail, $winUid); $customerMessagesToPhpArray = AbstractDto::dtosToArray($customerMessagesDtos); } else { //add guest in online users table $guest_online_table_id = $_COOKIE['guest_online_table_id']; if ($guest_online_table_id) { $onlineUser = $onlineUserManager->selectByPK($guest_online_table_id); if (isset($onlineUser)) { $onlineUserManager->updateOnlineUserAttributes($onlineUser); } else { $newId = $onlineUserManager->addOnlineUser($this->getUserLevel(), null); if (isset($newId)) { $this->setcookie('guest_online_table_id', $newId); } } } else { $newId = $onlineUserManager->addOnlineUser($this->getUserLevel(), null); if (isset($newId)) { $this->setcookie('guest_online_table_id', $newId); } } } $jsonArr = array('status' => "ok"); if (!empty($registeredCustomerAlertsDtosToArray)) { $jsonArr['alerts'] = $registeredCustomerAlertsDtosToArray; } if (!empty($customerAfterLoginMessagesDtosToArray)) { $jsonArr['customer_after_login_messages'] = $customerAfterLoginMessagesDtos; } if (!empty($customerMessagesToPhpArray)) { $jsonArr['messages'] = $customerMessagesToPhpArray; } echo json_encode($jsonArr); return true; }
/** * Set up the timeline. * * @param array $info */ public function __construct(array $info) { if (isset($info['frames'])) { $frames = []; foreach ($info['frames'] as $key => $frame) { $frames[$key] = new TimelineFrame($frame); } $info['frames'] = $frames; } parent::__construct($info); }
/** * Set up the information about this Participant. * * @param array $info */ public function __construct(array $info) { // player stats if (isset($info['stats'])) { $info['stats'] = new Stats($info['stats']); } // timeline - this is optional for matches api if (isset($info['timeline'])) { $info['timeline'] = new ParticipantTimeline($info['timeline']); } parent::__construct($info); }
/** * Set up the information about this team. * * @param array $info */ public function __construct(array $info) { // set teams (match api) if (isset($info['bans'])) { $rawBans = $info['bans']; $bans = []; foreach ($rawBans as $key => $rawBan) { $bans[$key] = new Ban($rawBan); } $info['bans'] = $bans; } parent::__construct($info); }
/** * Set up the frame. * * @param array $info */ public function __construct(array $info) { if (isset($info['participantFrames'])) { $pFrames = []; foreach ($info['participantFrames'] as $key => $frame) { $pFrames[intval($key)] = new TimelineParticipantFrame($frame); } $info['participantFrames'] = $pFrames; } if (isset($info['events'])) { $events = []; foreach ($info['events'] as $key => $event) { $events[$key] = new TimelineFrameEvent($event); } $info['events'] = $events; } parent::__construct($info); }
/** * Set up the information about this match. * * @param array $info */ public function __construct(array $info) { // set participants if (!isset($info['participants'])) { // solo game $info['participants'] = []; } $rawParticipants = $info['participants']; $participants = []; foreach ($rawParticipants as $rawParticipant) { $participant = new Participant($rawParticipant); $participants[$participant->participantId] = $participant; } $info['participants'] = $participants; // set identities if (!isset($info['participantIdentities'])) { // solo game $info['participantIdentities'] = []; } $rawrParticipantIds = $info['participantIdentities']; $participantIds = []; foreach ($rawrParticipantIds as $rawParticipantID) { $identity = new ParticipantIdentity($rawParticipantID); $participantIds[$identity->participantId] = $identity; } $info['participantIdentities'] = $participantIds; // set teams (only for match api) if (!isset($info['teams'])) { // no teams $info['teams'] = []; } $rawTeams = $info['teams']; $teams = []; foreach ($rawTeams as $key => $rawTeam) { $match = new MatchTeam($rawTeam); $teams[$key] = $match; } $info['teams'] = $teams; if (isset($info['timeline'])) { $info['timeline'] = new MatchTimeline($info['timeline']); } parent::__construct($info); }
public function getRegisteredCustomerAlerts($customerDto, $winUid) { $alerts_array = array(); //company pending questions about item availability $customerType = UserManager::getCustomerTypeFromDto($customerDto); if ($customerType === UserGroups::$COMPANY) { $companyId = $customerDto->getId(); $companyItemCheckListDtos = $this->companyItemCheckListManager->getCompanyQuestionsFromCustomers($companyId, $winUid); if (!empty($companyItemCheckListDtos)) { $alerts_array["check_items_availability"] = AbstractDto::dtosToArray($companyItemCheckListDtos); foreach ($companyItemCheckListDtos as $dto) { $dto = $this->companyItemCheckListManager->selectByPK($dto->getId()); $sentToCompanyUid = $dto->getSentToCompanyUid(); if (empty($sentToCompanyUid)) { $sentToCompanyUid = $winUid; } else { $sentToCompanyUid .= ',' . $winUid; } $this->companyItemCheckListManager->setSentToCompanyFieldValue($dto->getId(), $sentToCompanyUid); } } } //company replies about item availability for customers $customerEmail = $customerDto->getEmail(); $companyRespondedItemAvailabilityDtos = $this->companyItemCheckListManager->getCustomerSentQuestionsResponses($customerEmail, $winUid); if (!empty($companyRespondedItemAvailabilityDtos)) { $alerts_array["responded_items_availability"] = AbstractDto::dtosToArray($companyRespondedItemAvailabilityDtos); foreach ($companyRespondedItemAvailabilityDtos as $dto) { $dto = $this->companyItemCheckListManager->selectByPK($dto->getId()); $responseSentToCustomerUid = $dto->getResponseSentToCustomerUid(); if (empty($responseSentToCustomerUid)) { $responseSentToCustomerUid = $winUid; } else { $responseSentToCustomerUid .= ',' . $winUid; } $this->companyItemCheckListManager->setResponseSentToCustomerFieldValue($dto->getId(), $responseSentToCustomerUid); } } return $alerts_array; }
/** * Set up the information about this game. * * @param array $info */ public function __construct(array $info) { if (!isset($info['fellowPlayers'])) { // solo game $info['fellowPlayers'] = []; } $fellowPlayers = $info['fellowPlayers']; $players = []; foreach ($fellowPlayers as $key => $value) { $player = new Player($value); $players[$key] = $player; } $info['fellowPlayers'] = $players; // put the stats in its own Dto if (!isset($info['stats'])) { // no stats? $info['stats'] = []; } $stats = new Stats($info['stats']); $info['stats'] = $stats; parent::__construct($info); }
/** * Set up the information about this Participant. * * @param array $info */ public function __construct(array $info) { // player masteries if (isset($info['masteries'])) { $rawMasteries = $info['masteries']; $masteries = []; foreach ($rawMasteries as $m) { $mastery = new Mastery($m); $masteries[$mastery->masteryId] = $mastery; } $info['masteries'] = $masteries; } // player runes if (isset($info['runes'])) { $rawRunes = $info['runes']; $runes = []; foreach ($rawRunes as $r) { $rune = new Rune($r); $runes[$rune->runeId] = $rune; } $info['runes'] = $runes; } parent::__construct($info); }
public function load() { $this->setDescriptionTagValue('Companies that are registered in pcstore.am and their products are listed.'); $this->setTitleTagValue('Pcstore Company List'); $this->setKeywordsTagValue('Companies that are registered in pcstore.am and their products are listed.'); $companyManager = CompanyManager::getInstance($this->config, $this->args); $serviceCompanyManager = ServiceCompanyManager::getInstance($this->config, $this->args); $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args); $serviceCompaniesPriceListManager = ServiceCompaniesPriceListManager::getInstance($this->config, $this->args); $show_only_last_hours_values = array(0, 10, 24, 72, 168); $ph_all = $this->getPhrase(461); $ph_last = $this->getPhrase(456); $ph_hours = $this->getPhrase(455); $ph_days = $this->getPhrase(459); $ph_week = $this->getPhrase(460); $ph_updated = $this->getPhrase(457); $show_only_last_hours_names_phrase_ids_array = array(461, "`456` 10 `455` `457`", "`456` 24 `455` `457`", "`456` 3 `459` `457`", "`456` `460` `457`"); $show_only_last_hours_names = array($ph_all, $ph_last . ' 10 ' . $ph_hours . ' ' . $ph_updated, $ph_last . ' 24 ' . $ph_hours . ' ' . $ph_updated, $ph_last . ' 3 ' . $ph_days . ' ' . $ph_updated, $ph_last . ' ' . $ph_week . ' ' . $ph_updated); $show_only_last_hours_selected = 0; if (isset($_REQUEST['show_only_last_hours_selected'])) { $show_only_last_hours_selected = intval($_REQUEST['show_only_last_hours_selected']); } $this->addParam("show_only_last_hours_values", $show_only_last_hours_values); $this->addParam("show_only_last_hours_names", $show_only_last_hours_names); $this->addParam("show_only_last_hours_names_phrase_ids_array", $show_only_last_hours_names_phrase_ids_array); $this->addParam("show_only_last_hours_selected", $show_only_last_hours_selected); $searchText = ""; if (isset($_REQUEST['search_text'])) { $searchText = $this->secure($_REQUEST['search_text']); } $this->addParam("search_text", $searchText); $userLevel = $this->getUserLevel(); $userId = $this->getUserId(); $companiesList = array(); $allServiceCompaniesWithBranches = $serviceCompanyManager->getAllServiceCompaniesWithBranches(); foreach ($allServiceCompaniesWithBranches as $serviceCompanyDto) { $serviceCompanyDto->setShowPrice(1); } if ($userLevel == UserGroups::$USER) { $serviceCompanyDealersManager = ServiceCompanyDealersManager::getInstance($this->config, $this->args); $userserviceCompaniesIdsArray = $serviceCompanyDealersManager->getUserCompaniesIdsArray($userId); foreach ($allServiceCompaniesWithBranches as $serviceCompanyDto) { if (in_array($serviceCompanyDto->getId(), $userserviceCompaniesIdsArray)) { $serviceCompanyDto->setShowPrice(1); } else { $serviceCompanyDto->setShowPrice(0); } } } if ($userLevel == UserGroups::$COMPANY || $userLevel == UserGroups::$SERVICE_COMPANY) { $companiesList = $companyManager->getAllCompaniesByPriceHours($show_only_last_hours_selected, $searchText); } if ($userLevel == UserGroups::$USER) { $companiesList = $companyManager->getUserCompaniesJoindWithFullInfo($userId, $show_only_last_hours_selected, $searchText); } if ($userLevel == UserGroups::$ADMIN) { $companiesList = $companyManager->getAllCompaniesByPriceHours($show_only_last_hours_selected, $searchText, true, true); } $this->addParam('allCompanies', $companiesList); $this->addParam('allServiceCompanies', $allServiceCompaniesWithBranches); $allNonHiddenCompanies = $companyManager->getAllCompanies(); $this->addParam('allNonHiddenCompanies', $allNonHiddenCompanies); $this->addParam('allCompaniesDtosToArray', json_encode(AbstractDto::dtosToArray($companiesList, array("id" => "id", "name" => "name", "rating" => "rating")))); $this->addParam('allServiceCompaniesDtosToArray', json_encode(AbstractDto::dtosToArray($allServiceCompaniesWithBranches, array("id" => "id", "name" => "name")))); // $this->addParam('userLevel', $userLevel); // $this->addParam('userGroupsUser', UserGroups::$USER); $companyBranchesManager = CompanyBranchesManager::getInstance($this->config, $this->args); $serviceCompanyBranchesManager = ServiceCompanyBranchesManager::getInstance($this->config, $this->args); $cids = $this->getCompanyIdsArray($companiesList); $scids = $this->getCompanyIdsArray($allServiceCompaniesWithBranches); $companiesBranchesDtos = $companyBranchesManager->getCompaniesBranches($cids); $serviceCompaniesBranchesDtos = $serviceCompanyBranchesManager->getServiceCompaniesBranches($scids); $this->addParam('allCompaniesBranchesDtosToArray', json_encode(AbstractDto::dtosToArray($companiesBranchesDtos))); $this->addParam('allServiceCompaniesBranchesDtosToArray', json_encode(AbstractDto::dtosToArray($serviceCompaniesBranchesDtos))); $this->addParam("companiesPriceListManager", $companiesPriceListManager); $this->addParam("serviceCompaniesPriceListManager", $serviceCompaniesPriceListManager); $companiesZippedPricesByDaysNumber = $companiesPriceListManager->getCompaniesZippedPricesByDaysNumber($cids, 360); $serviceCompaniesZippedPricesByDaysNumber = $serviceCompaniesPriceListManager->getCompaniesZippedPricesByDaysNumber($cids, 360); $groupCompaniesZippedPricesByCompanyId = $this->groupCompaniesZippedPricesByCompanyId($companiesZippedPricesByDaysNumber); $groupServiceCompaniesZippedPricesByCompanyId = $this->groupServiceCompaniesZippedPricesByCompanyId($serviceCompaniesZippedPricesByDaysNumber); $this->addParam("groupCompaniesZippedPricesByCompanyId", $groupCompaniesZippedPricesByCompanyId); $this->addParam("groupServiceCompaniesZippedPricesByCompanyId", $groupServiceCompaniesZippedPricesByCompanyId); }
public function service() { $action = $_REQUEST['action']; $params = array(); switch ($action) { case 'delete_user': $this->deleteUser($_REQUEST['user_id']); break; case 'delete_all_unnecessary_items_pictures': $ret = $this->deleteAllUnnecessaryItemsPictures(); $params = array('removed_items_ids' => implode(',', $ret)); break; case 'set_item_spec': $itemId = $_REQUEST['item_id']; $shortSpec = $_REQUEST['short_spec']; $fullSpec = $_REQUEST['full_spec']; require_once CLASSES_PATH . "/managers/ItemManager.class.php"; $itemManager = ItemManager::getInstance($this->config, $this->args); $itemManager->updateTextField($itemId, 'short_description', $shortSpec); $itemManager->updateTextField($itemId, 'full_description', $fullSpec); break; case 'get_item_spec': $itemId = $_REQUEST['item_id']; require_once CLASSES_PATH . "/managers/ItemManager.class.php"; $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($itemId); $params['short_spec'] = $itemDto->getShortDescription(); $params['full_spec'] = $itemDto->getFullDescription(); break; case 'get_camera_1_snap': $url = $this->getCmsVar('pcstore_camera_1_url'); $login = $this->getCmsVar('pcstore_camera_1_login'); $pass = $this->getCmsVar('pcstore_camera_1_pass'); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, $login . ':' . $pass); $img = curl_exec($ch); header("Content-Type: image/jpeg"); echo $img; exit; case 'filter_emails': require_once CLASSES_PATH . "/managers/EmailSenderManager.class.php"; require_once CLASSES_PATH . "/managers/UninterestingEmailsManager.class.php"; $emails = $_REQUEST['emails']; $emailsArray = EmailSenderManager::getEmailsFromText($emails); $uninterestingEmailsManager = UninterestingEmailsManager::getInstance($this->config, $this->args); $filteredEmailsArray = $uninterestingEmailsManager->removeUninterestingEmailsFromList($emailsArray); $params['count'] = count($filteredEmailsArray); $params['emails'] = implode(';', $filteredEmailsArray); break; case 'is_price_values_ready': $companyId = intval($_REQUEST['company_id']); require_once CLASSES_PATH . "/managers/PriceTextsManager.class.php"; $priceTextsManager = PriceTextsManager::getInstance($this->config, $this->args); $companyPriceValuesReady = $priceTextsManager->isCompanyPriceValuesReady($companyId); $params['ready'] = $companyPriceValuesReady ? '1' : '0'; break; case 'delete_price_values_column': $companyId = intval($_REQUEST['company_id']); $sheetIndex = intval($_REQUEST['sheet_index']); $priceIndex = intval($_REQUEST['price_index']); $columnLetter = $this->secure($_REQUEST['column_letter']); require_once CLASSES_PATH . "/managers/PriceValuesManager.class.php"; $priceValuesManager = PriceValuesManager::getInstance($this->config, $this->args); $priceValuesManager->moveColumnValuesToLastColumn($companyId, $priceIndex, $sheetIndex, $columnLetter); break; case 'delete_customer_amessage_after_login': $pk = intval($_REQUEST['id']); require_once CLASSES_PATH . "/managers/CustomerMessagesAfterLoginManager.class.php"; $customerMessagesAfterLoginManager = CustomerMessagesAfterLoginManager::getInstance($this->config, $this->args); $customerMessagesAfterLoginManager->deleteByPK($pk); break; case 'preview_customer_message': $pk = intval($_REQUEST['id']); require_once CLASSES_PATH . "/managers/CustomerMessagesAfterLoginManager.class.php"; $customerMessagesAfterLoginManager = CustomerMessagesAfterLoginManager::getInstance($this->config, $this->args); $dto = $customerMessagesAfterLoginManager->selectByPK($pk); $params = AbstractDto::dtoToArray($dto); break; case 'delete_old_hidden_items': $monthsNumber = intval($_REQUEST['months_number']); require_once CLASSES_PATH . "/managers/ItemManager.class.php"; $itemManager = ItemManager::getInstance($this->config, $this->args); $params['count'] = $itemManager->deleteOldHiddenItemsByMonthsNumber($monthsNumber); break; case 'update_companies_price_text': $company_id = intval($_REQUEST['company_id']); $companyManager = CompanyManager::getInstance($this->config, $this->args); if ($company_id == 0) { $allCompanies = $companyManager->getAllCompanies(true, true); } else { $allCompanies[] = $companyManager->selectByPK($company_id); } $cidsArray = array(); foreach ($allCompanies as $c) { $cidsArray[] = $c->getId(); } $this->updateCompanyPriceText(implode(',', $cidsArray)); break; case 'deploy_latest_pcstore_changes': $protocol = "http://"; if (isset($_SERVER["HTTPS"])) { $protocol = "https://"; } $content = file_get_contents($protocol . HTTP_HOST . '/8350e5a3e24c153df2275c9f80692773.php'); $params['message'] = $content; break; } $this->ok($params); }
/** * @param array $info */ public function __construct(array $info) { $aggregatedStats = $info['aggregatedStats']; $info['aggregatedStats'] = new AggregateStats($aggregatedStats); parent::__construct($info); }
public function service() { $action = $_REQUEST['action']; $importItemsTempManager = ImportItemsTempManager::getInstance($this->config, $this->args); switch ($action) { case 'step_1_unbind_price_row': $price_item_id = $_REQUEST['price_item_id']; $importItemsTempManager->setMatchedItemId($price_item_id, 0); $importItemsTempManager->updateTextField($price_item_id, 'short_spec', ''); $importItemsTempManager->updateTextField($price_item_id, 'full_spec', ''); $this->ok(); break; case 'step_1_link_stock_item_to_price_item': $price_item_id = $_REQUEST['price_item_id']; $stock_item_id = $_REQUEST['stock_item_id']; $importItemsTempManager->setMatchedItemId($price_item_id, $stock_item_id); $itemManager = ItemManager::getInstance($this->config, $this->args); $stockItem = $itemManager->selectByPK($stock_item_id); $importItemsTempManager->updateTextField($price_item_id, 'short_spec', $stockItem->getShortDescription()); $importItemsTempManager->updateTextField($price_item_id, 'full_spec', $stockItem->getFullDescription()); $this->ok(); break; case 'edit_cell_value': $cell_value = $_REQUEST['cell_value']; $field_name = $_REQUEST['field_name']; $pk_value = $_REQUEST['pk_value']; $importItemsTempManager->updateTextField($pk_value, $importItemsTempManager->getFieldKeyByFieldName($field_name), $cell_value); $dto = $importItemsTempManager->selectByPK($pk_value); $this->ok(array('cell_value' => $dto->{$field_name})); break; case 'import': $new_items_row_ids = $this->secure($_REQUEST['new_items_row_ids']); if (!empty($new_items_row_ids)) { $new_items_row_ids = explode(',', $new_items_row_ids); } else { $new_items_row_ids = array(); } $changed_rows_ids = $this->secure($_REQUEST['changed_rows_ids']); if (!empty($changed_rows_ids)) { $changed_rows_ids = explode(',', $changed_rows_ids); } else { $changed_rows_ids = array(); } list($newItemsCount, $updatedItemsCount) = $importItemsTempManager->importToItemsTable($this->getCustomerLogin(), $this->secure($_REQUEST['company_id']), $new_items_row_ids, $changed_rows_ids); $this->ok(array('new_items_count' => $newItemsCount, 'updated_items_count' => $updatedItemsCount)); break; case 'find_similar_items': $searchText = $this->secure($_REQUEST['search_text']); $itemManager = ItemManager::getInstance($this->config, $this->args); $itemsDtos = $itemManager->findSimillarItems($searchText, 10); $dtosToJSON = AbstractDto::dtosToJSON($itemsDtos); $this->ok(array('items' => $dtosToJSON)); break; case 'get_item_cat_spec': $item_id = intval($_REQUEST['item_id']); if ($item_id > 0) { $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($item_id); $this->ok(array('short_description' => $itemDto->getShortDescription(), 'full_description' => $itemDto->getFullDescription(), 'categories_ids' => $itemDto->getCategoriesIds())); } else { $this->ok(array('short_description' => '', 'full_description' => '', 'categories_ids' => '')); } break; case 'upload_new_item_picture': $row_id = intval($_REQUEST['row_id']); $this->uploadNewIntemPicture($row_id); break; default: break; } }
public function service() { $action = $_REQUEST['action']; $itemManager = ItemManager::getInstance($this->config, $this->args); switch ($action) { case 'find_similar_items': $requestedItemId = $this->secure($_REQUEST['item_id']); $itemDto = $itemManager->selectByPK($requestedItemId); $allItemsMappedArray = $itemManager->getAllItemsTitleAndModelAndBrandMappedArray(); unset($allItemsMappedArray[$itemDto->getId()]); $mostSimillarItemsMappedArray = $this->getItemsSimillarityPercentArrayFromList($itemDto, $allItemsMappedArray); $limit = 30; $items = array(); $limitCounter = 0; foreach ($mostSimillarItemsMappedArray as $itemId => $percent) { $itemDataArray = $allItemsMappedArray[$itemId]; $itemTitle = $itemDataArray[0]; $itemCompanyName = $itemDataArray[3]; $itemPicturesCount = $itemDataArray[4]; $items[] = array($itemId, $itemTitle, $itemCompanyName, $itemPicturesCount); $limitCounter++; if ($limitCounter >= $limit) { break; } } $this->ok(array('items' => $items)); break; case 'get_item_attributes': $itemId = $this->secure($_REQUEST['item_id']); $itemDto = $itemManager->selectByPK($itemId); $this->ok(array('item' => AbstractDto::dtoToArray($itemDto))); break; case 'copy_item_pictures': $source_item_id = $this->secure($_REQUEST['source_item_id']); $target_item_id = $this->secure($_REQUEST['target_item_id']); $sourceItemDto = $itemManager->selectByPK($source_item_id); $targetItemDto = $itemManager->selectByPK($target_item_id); $itemDto = $itemManager->copyItemPictures($sourceItemDto, $targetItemDto); $this->ok(); break; case 'copy_item_short_spec': $source_item_id = $this->secure($_REQUEST['source_item_id']); $target_item_id = $this->secure($_REQUEST['target_item_id']); $sourceItemDto = $itemManager->selectByPK($source_item_id); $targetItemDto = $itemManager->selectByPK($target_item_id); $itemDto = $itemManager->copyItemShortDescription($sourceItemDto, $targetItemDto); $this->ok(); break; case 'copy_item_full_spec': $source_item_id = $this->secure($_REQUEST['source_item_id']); $target_item_id = $this->secure($_REQUEST['target_item_id']); $sourceItemDto = $itemManager->selectByPK($source_item_id); $targetItemDto = $itemManager->selectByPK($target_item_id); $itemDto = $itemManager->copyItemFullDescription($sourceItemDto, $targetItemDto); $this->ok(); break; case 'copy_item_model': $source_item_id = $this->secure($_REQUEST['source_item_id']); $target_item_id = $this->secure($_REQUEST['target_item_id']); $sourceItemDto = $itemManager->selectByPK($source_item_id); $targetItemDto = $itemManager->selectByPK($target_item_id); $itemDto = $itemManager->copyItemModel($sourceItemDto, $targetItemDto); $this->ok(); break; default: break; } }
public function load() { $dbStructureManager = DbStructureManager::getInstance($this->config, $this->args); $tablesNames = $dbStructureManager->getTablesNames(); $tablesNamesArrayUf = self::convertToUserFriendlyNamesArray($tablesNames); array_unshift($tablesNames, 0); array_unshift($tablesNamesArrayUf, 'Select Table...'); $table_name = $this->secure($_REQUEST['table_name']); if (!empty($_REQUEST['page'])) { $page = intval($this->secure($_REQUEST['page'])); } else { $page = 1; } if (isset($_REQUEST['order_by_field_name'])) { $order_by_field_name = $this->secure($_REQUEST['order_by_field_name']); } if (isset($_REQUEST['order_by_asc_desc'])) { $order_by_asc_desc = strtolower($this->secure($_REQUEST['order_by_asc_desc'])); } $searchText = ""; if (isset($_REQUEST['search_text'])) { $searchText = $_REQUEST['search_text']; } if (isset($_REQUEST['search_column_name'])) { $searchColumnName = $_REQUEST['search_column_name']; } $table_view_per_page_options = explode(',', $this->getCmsVar('table_view_per_page_options')); if (!empty($_REQUEST['rows_per_page'])) { $rows_per_page = intval($this->secure($_REQUEST['rows_per_page'])); } else { $rows_per_page = intval($table_view_per_page_options[1]); } //$confirm_on_change_enable = $this->secure($_REQUEST['confirm_on_change_enable']); $this->addParam('table_view_per_page_options', $table_view_per_page_options); $this->addParam('all_table_names', $tablesNames); $this->addParam('all_table_names_uf', $tablesNamesArrayUf); $this->addParam('table_name', $table_name); $this->addParam('table_name_uf', self::generateUserFriendlyName($table_name)); $this->addParam('rows_per_page', $rows_per_page); $this->addParam('page', $page); $this->addParam('search_text', $searchText); $this->addParam('search_column', $searchColumnName); $tableMapperClassName = $this->generateTableMapperClassName($table_name); if (!empty($tableMapperClassName)) { $tableMapper = call_user_func(array($tableMapperClassName, 'getInstance')); if ($tableMapper->getTableName() === $table_name) { //$tableManagerClassName = $this->generateTableManagerClassName($table_name); //$tableManager = & call_user_func(array($tableManagerClassName, 'getInstance'), $this->config, $this->args); $tableColumns = $dbStructureManager->getTableColumns($table_name); $tableColumnsNamesMapArray = $this->getColumnNamesArray($tableColumns); $tableColumnsNamesArray = array_keys($tableColumnsNamesMapArray); if (!isset($order_by_field_name) || !in_array($order_by_field_name, $tableColumnsNamesArray)) { $order_by_field_name = ''; } if (!isset($order_by_asc_desc) || $order_by_asc_desc != 'asc' && $order_by_asc_desc != 'desc') { $order_by_asc_desc = 'asc'; } $this->addParam('order_by_asc_desc', $order_by_asc_desc); $order_by_asc_desc_options = array('asc' => 'Ascending', 'desc' => 'Descending'); $this->addParam('order_by_asc_desc_options', $order_by_asc_desc_options); $rowsCountWithoutLimit = $tableMapper->getAllByFiltersCount($searchText, $searchColumnName); $lastPage = intval($rowsCountWithoutLimit / $rows_per_page) + 1; if ($page > $lastPage) { $page = $lastPage; } $selectAllByFilters = $tableMapper->selectAllByFilters(($page - 1) * $rows_per_page, $rows_per_page, $order_by_field_name, $order_by_asc_desc, $searchText, $searchColumnName); $tableColumnsNamesMapArrayUserFriendly = self::convertToUserFriendlyNamesArray($tableColumnsNamesMapArray); $this->addParam('tableColumnsNamesArray', $tableColumnsNamesMapArrayUserFriendly); array_unshift($tableColumnsNamesMapArrayUserFriendly, 'Default order'); $this->addParam('tableColumnsNamesArrayForSorting', $tableColumnsNamesMapArrayUserFriendly); $this->addParam('table_exists', true); $this->addParam('order_by_field_name', $order_by_field_name); $this->addParam('rowDtos', AbstractDto::dtosToArray($selectAllByFilters)); $this->addParam('tableColumns', $tableColumns); $this->addParam('tableColumnsNamesJoined', implode(',', $tableColumnsNamesArray)); $this->addParam('totalRowsCount', $rowsCountWithoutLimit); $this->addParam('allPagesArray', range(1, $lastPage)); $this->addParam('table_pk_name', $tableMapper->getPKFieldName()); } } }