private function save(ProductFile $productFile) { $response = new ActionResponse(); $response->setHeader("Cache-Control", "no-cache, must-revalidate"); $response->setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); $validator = $this->buildValidator((int) $this->request->get('ID')); if ($validator->isValid()) { foreach ($this->application->getLanguageArray(true) as $lang) { if ($this->request->isValueSet('title_' . $lang)) { $productFile->setValueByLang('title', $lang, $this->request->get('title_' . $lang)); } if ($this->request->isValueSet('description_' . $lang)) { $productFile->setValueByLang('description', $lang, $this->request->get('description_' . $lang)); } } // Use title as description if no description was provided $defaultLang = $this->application->getDefaultLanguageCode(); if (!$this->request->isValueSet('description_' . $defaultLang) || $this->request->get('description_' . $defaultLang) == '') { $productFile->setValueByLang('description', $defaultLang, $this->request->get('title_' . $defaultLang)); } $productFile->allowDownloadDays->set((int) $this->request->get('allowDownloadDays')); $productFile->allowDownloadCount->set((int) $this->request->get('allowDownloadCount')); $productFile->isEmbedded->set($this->request->get('isEmbedded') != false); $productFile->isPublic->set($this->request->get('isPublic') != false); $productFile->save(); $response->set('status', 'success'); $response->set('productFile', $productFile->toArray()); } else { $response->set('status', 'failure'); $response->set('errors', $validator->getErrorList()); } return $response; }
/** * Handles LiveCart update process */ public function update() { $dir = ClassLoader::getRealPath('update') . '/' . $this->getCurrentVersion(); if (!is_dir($dir)) { return new RawResponse('Update directory not found'); } $progress = array(); $errors = array(); // load SQL dump file $sql = $dir . '/update.sql'; if (file_exists($sql)) { try { Installer::loadDatabaseDump(file_get_contents($sql), true, $this->request->get('force')); $progress['sql'] = true; } catch (Exception $e) { $errors['sql'] = $e->getMessage(); } } $this->application->getConfigContainer()->clearCache(); // execute custom update code $code = $dir . '/custom.php'; if (file_exists($code)) { ob_start(); if (!(include $code)) { $errors['code'] = ob_get_contents(); } else { $progress['code'] = true; } ob_end_clean(); } $response = new ActionResponse(); $response->set('progress', $progress); $response->set('errors', $errors); return $response; }
public function index() { $this->loadLanguageFile('User'); $response = new ActionResponse('email', $this->request->get('email')); $response->setHeader('NeedLogin', 1); return $response; }
/** * Individual settings section */ public function edit() { $this->config->updateSettings(); $defLang = $this->application->getDefaultLanguageCode(); $languages = $this->application->getLanguageArray(LiveCart::INCLUDE_DEFAULT); $sectionId = $this->request->get('id'); $values = $this->config->getSettingsBySection($sectionId); $validation = $this->getValidationRules($values); $form = $this->getForm($values, $validation); $types = $multiLingualValues = array(); if (!$values) { return new RawResponse(); } foreach ($values as $key => $value) { if ($this->config->isMultiLingual($key) && 'string' == $value['type'] || 'longtext' == $value['type']) { foreach ($languages as $lang) { $form->set($key . ($lang != $defLang ? '_' . $lang : ''), $this->config->getValueByLang($key, $lang)); } $multiLingualValues[$key] = true; } else { $form->set($key, $this->config->get($key)); } $types[$key] = $value['type']; } $response = new ActionResponse(); $response->set('form', $form); $response->set('title', $this->translate($this->config->getSectionTitle($sectionId))); $response->set('values', $values); $response->set('types', $types); $response->set('id', $sectionId); $response->set('sectionKey', array_pop(explode('.', $sectionId))); $response->set('layout', $this->config->getSectionLayout($sectionId)); $response->set('multiLingualValues', $multiLingualValues); return $response; }
public function lastViewed() { $response = new ActionResponse(); $response->set('randomToken', substr(md5(time() . mt_rand(1, 9999999999)), 0, 8)); $response->set('lastViewed', BackendToolbarItem::sanitizeItemArray(BackendToolbarItem::getUserToolbarItems(array(BackendToolbarItem::TYPE_PRODUCT, BackendToolbarItem::TYPE_USER, BackendToolbarItem::TYPE_ORDER), null, 'DESC'))); return $response; }
public function index() { $response = new ActionResponse(); $response->set('isCustomizationModeEnabled', $this->application->isCustomizationMode()); $response->set('isTranslationModeEnabled', $this->application->isTranslationMode()); return $response; }
/** * Main settings page */ public function index() { $f = new ARSelectFilter(); $f->setOrder(new ARFieldHandle('StaticPage', 'position')); $f->setOrder(new ARFieldHandle('StaticPage', 'parentID')); $s = ActiveRecordModel::getRecordSetArray('StaticPage', $f); $pages = array(); foreach ($s as $page) { $pointers[$page['ID']] = array('title' => $page['title_lang'], 'id' => $page['ID'], 'parentID' => $page['parentID']); } foreach ($pointers as $page) { if ($page['parentID'] && !empty($pointers[$page['parentID']])) { $root =& $pointers[$page['parentID']]; } else { $root =& $pages; } $root['children'][] =& $pointers[$page['id']]; } $response = new ActionResponse(); $response->set('pages', json_encode($pages)); $form = $this->getForm(); $page = StaticPage::getNewInstance(); $page->getSpecification()->setFormResponse($response, $form); $response->set('form', $form); $response->set('page', $page->toArray()); return $response; }
public function index() { // get filter to select manufacturers of active products only $rootCat = Category::getRootNode(); $f = new ARSelectFilter(); $productFilter = new ProductFilter($rootCat, $f); $ids = $counts = array(); foreach (ActiveRecordModel::getDataBySQL('SELECT DISTINCT(manufacturerID), COUNT(*) AS cnt FROM Product ' . $f->createString() . ' GROUP BY manufacturerID') as $row) { $ids[] = $row['manufacturerID']; $counts[$row['manufacturerID']] = $row['cnt']; } $f = new ARSelectFilter(new InCond(new ARFieldHandle('Manufacturer', 'ID'), $ids)); $f->mergeCondition(new NotEqualsCond(new ARFieldHandle('Manufacturer', 'name'), '')); $f->setOrder(new ARFieldHandle('Manufacturer', 'name')); $manufacturers = ActiveRecordModel::getRecordSetArray('Manufacturer', $f); foreach ($manufacturers as &$manufacturer) { $manufacturer['url'] = $this->getManufacturerFilterUrl($manufacturer); } $this->addBreadCrumb($this->translate('_manufacturers'), ''); $response = new ActionResponse(); $response->setReference('manufacturers', $manufacturers); $response->set('counts', $counts); $response->set('rootCat', $rootCat->toArray()); return $response; }
public function index() { $f = new ARSelectFilter(); $f->setOrder(new ARFieldHandle('NewsPost', 'position'), 'DESC'); $response = new ActionResponse('newsList', ActiveRecordModel::getRecordSetArray('NewsPost', $f)); $response->set('form', $this->buildForm()); return $response; }
public function index() { $response = new ActionResponse(); $response->set('id', $this->request->get('id')); $response->set('ajax', $this->request->get('ajax')); $response->set('description', HTTPStatusException::getCodeMeaning($this->request->get('id'))); return $response; }
public function index() { $category = Category::getInstanceByID($this->request->get('id'), Category::LOAD_DATA); $types = ProductRatingType::getCategoryRatingTypes($category)->toArray(); $response = new ActionResponse('typeList', $types); $response->set('form', $this->buildForm()); $response->set('id', $this->request->get('id')); return $response; }
public function edit() { $group = UserGroup::getInstanceByID((int) $this->request->get('id'), true); $form = $this->createUserGroupForm($group); $response = new ActionResponse(); $response->set('userGroup', $group->toArray()); $response->set('userGroupForm', $form); $group->getSpecification()->setFormResponse($response, $form); return $response; }
public function edit() { $tax = Tax::getInstanceByID((int) $this->request->get('id'), true); $form = $this->createTaxForm($tax); $form->setData($tax->toArray()); $response = new ActionResponse(); $response->set('tax', $tax->toArray()); $response->set('taxForm', $form); return $this->appendTaxRates($response, $tax->getID()); }
public function edit() { $class = ShippingClass::getInstanceByID((int) $this->request->get('id'), true); $form = $this->createClassForm($class); $form->setData($class->toArray()); $response = new ActionResponse(); $response->set('class', $class->toArray()); $response->set('classForm', $form); return $response; }
public function index() { $f = new ARSelectFilter(); $f->setOrder(new ARFieldHandle('EyeExamSchedule', 'doctorName'), 'ASC'); $f->setOrder(new ARFieldHandle('EyeExamSchedule', 'date'), 'DESC'); $f->setOrder(new ARFieldHandle('EyeExamSchedule', 'time'), 'ASC'); $arrEyeSchedule = ActiveRecordModel::getRecordSetArray('EyeExamSchedule', $f); $response = new ActionResponse('eyeExamList', self::loadFormattedReferences($arrEyeSchedule)); $response->set('form', $this->buildForm()); $curDate = date("Y-m-d"); $response->set('curDate', $curDate); return $response; }
public function index() { $product = Product::getInstanceById($this->request->get('id'), ActiveRecord::LOAD_DATA, array('Category')); $product->category->get()->getPathNodeSet(); $additional = $product->getAdditionalCategories(); foreach ($additional as $category) { $category->getPathNodeSet(); } $response = new ActionResponse('product', $product->toArray()); if ($additional) { $response->set('categories', ARSet::buildFromArray($additional)->toArray()); } return $response; }
public function index() { if (($zoneID = (int) $this->request->get('id')) <= 0) { $deliveryZoneArray = array('ID' => ''); $shippingServices = ShippingService::getByDeliveryZone(); } else { $deliveryZone = DeliveryZone::getInstanceByID($zoneID, true); $deliveryZoneArray = $deliveryZone->toArray(); $shippingServices = $deliveryZone->getShippingServices(); } $shippingServicesArray = array(); foreach ($shippingServices as $service) { $shippingServicesArray[$service->getID()] = $service->toArray(); $shippingServicesArray[$service->getID()]['rangeTypeString'] = $this->translate($service->rangeType->get() == 0 ? '_weight_based_rates' : '_subtotal_based_rates'); $shippingServicesArray[$service->getID()]['ratesCount'] = $service->getRates()->getTotalRecordCount(); } $form = $this->createShippingServiceForm(); $form->setData(array('rangeType' => 0)); $response = new ActionResponse(); $response->set('shippingServices', $shippingServicesArray); $response->set('newService', array('DeliveryZone' => $deliveryZoneArray)); $response->set('newRate', array('ShippingService' => array('DeliveryZone' => $deliveryZoneArray, 'ID' => ''))); $response->set('deliveryZone', $deliveryZoneArray); $response->set('defaultCurrencyCode', $this->application->getDefaultCurrency()->getID()); $response->set('form', $form); return $response; }
public function upload() { $request = $this->getRequest(); $theme = $request->get('theme'); $tfh = ThemeFile::getNewInstance($request->get('theme')); $res = $tfh->processFileUpload('file', $request->get('filename'), $request->get('orginalFileName')); $this->setLayout('iframeJs'); $response = new ActionResponse(); $response->set('theme', $theme); $response->set('result', json_encode($tfh->getFiles())); if (is_array($res)) { $response->set('highlightFileName', $res['filename']); } return $response; }
public function index() { $dir = getcwd(); @chdir('/'); $root = array('parent' => 0, 'ID' => getcwd(), 'name' => getcwd(), 'childrenCount' => 22); $response = new ActionResponse(); $response->set('directoryList', $this->getSubDirectories(getcwd())); $response->set('root', array(0 => $root)); $response->set('current', $dir); $this->setGridResponse($response); $response->set('offset', 0); $response->set('data', ''); //print_r($response->getData()); return $response; }
public function lastViewed() { $request = $this->getRequest(); $where = $request->get('where'); $response = new ActionResponse(); $response->set('randomToken', substr(md5(time() . mt_rand(1, 9999999999)), 0, 8)); $response->set('where', $where); $lastViewed = BackendToolbarItem::sanitizeItemArray(BackendToolbarItem::getUserToolbarItems(array(BackendToolbarItem::TYPE_PRODUCT, BackendToolbarItem::TYPE_USER, BackendToolbarItem::TYPE_ORDER), null, 'DESC')); $itemsByType = array(); foreach ($lastViewed as $item) { $itemsByType[$item['type']][] = $item; } $response->set('itemsByType', $itemsByType); return $response; }
public function index() { $order = CustomerOrder::getInstanceById($this->request->get('id')); $notes = $order->getNotes(); foreach ($notes as $note) { if (!$note->isRead->get() && !$note->isAdmin->get()) { $note->isRead->set(true); $note->save(); } } $response = new ActionResponse(); $response->set('form', $this->buildOrderNoteForm()); $response->set('order', $order->toArray()); $response->set('notes', $notes->toArray()); return $response; }
/** * Creates new relationship * * @role update */ public function add() { $productID = $this->request->get('relatedownerID'); $ownerID = $this->request->get('id'); $list = ActiveRecordModel::getInstanceById('ProductList', $ownerID, ActiveRecordModel::LOAD_DATA); $product = Product::getInstanceByID($productID, Product::LOAD_DATA, array('ProductImage')); if (!$list->contains($product)) { $list->addProduct($product); $response = new ActionResponse(); $response->set('product', $product->toArray()); $response->set('added', true); return $response; } else { return new JSONResponse(array('error' => $this->translate('_err_multiple'))); } }
public function index() { $category = Category::getInstanceById($this->request->get('id'), ActiveRecord::LOAD_DATA); $f = select(); $f->setOrder(f('CategoryRelationship.position')); $additional = $category->getRelatedRecordSet('CategoryRelationship', $f, array('Category_RelatedCategory')); $categories = array(); foreach ($additional as $cat) { $categories[] = $cat; $cat->relatedCategory->get()->load(); $cat->relatedCategory->get()->getPathNodeSet(); } $response = new ActionResponse('category', $category->toArray()); $response->set('categories', ARSet::buildFromArray($categories)->toArray()); return $response; }
/** * Displays category form (for creating a new category or modifying an existing one) * * @role !category * * @return ActionResponse */ public function form() { ClassLoader::import('application.LiveCartRenderer'); ClassLoader::import('application.model.presentation.CategoryPresentation'); $this->loadLanguageFile('backend/Settings'); $category = Category::getRootNode(); $form = $this->buildForm($category); $response = new ActionResponse("catalogForm", $form); $response->set('themes', array_merge(array(''), LiveCartRenderer::getThemeList())); $listStyles = array(); foreach (array('LIST', 'GRID', 'TABLE') as $style) { $listStyles[$style] = $this->translate($style); } $response->set('listStyles', array_merge(array(''), $listStyles)); $category->getSpecification()->setFormResponse($response, $form); return $response; }
public function redirect() { $id = $this->request->get('id'); $params = array(); if ($this->isAjax()) { $params['query'] = array('ajax' => 1); } $params['query'] = array('return' => $_SERVER['REQUEST_URI']); switch ($id) { case 401: return new ActionRedirectResponse('user', 'login', $params); default: $response = new ActionResponse('id', $id); $response->setStatusCode($this->request->get('id')); return $response; } }
public function view() { $this->loadLanguageFile('Frontend'); $page = StaticPage::getInstanceByHandle($this->request->get('handle')); if ($parent = $page->parent->get()) { while ($parent) { $parent->load(); $urlParams = array('controller' => 'staticPage', 'action' => 'view', 'handle' => $parent->handle->get()); $this->addBreadCrumb($parent->getValueByLang('title'), $this->router->createUrl($urlParams, true)); $parent = $parent->parent->get(); } } $pageArray = $page->toArray(); $this->addBreadCrumb($pageArray['title_lang'], ''); $response = new ActionResponse('page', $pageArray); $response->set('subPages', $page->getSubPageArray()); return $response; }
public function info() { $user = User::getInstanceById((int) $this->request->get('id'), ActiveRecord::LOAD_DATA, array('UserGroup')); $availableUserGroups = array('' => $this->translate('_default_user_group')); foreach (UserGroup::getRecordSet(new ARSelectFilter()) as $group) { $availableUserGroups[$group->getID()] = $group->name->get(); } $response = new ActionResponse(); $response->set('countries', array_merge(array('' => ''), $this->application->getEnabledCountries())); $form = self::createUserForm($this, $user, $response); $response->set('form', $form); $response->set('shippingAddressStates', State::getStatesByCountry($form->get('shippingAddress_countryID'))); $response->set('billingAddressStates', State::getStatesByCountry($form->get('billingAddress_countryID'))); $user->loadAddresses(); $response->set('someUser', $user->toArray()); $response->set('availableUserGroups', $availableUserGroups); BackendToolbarItem::registerLastViewedUser($user); return $response; }
public function edit() { $css = new EditedCssFile($this->request->get('file')); $response = new ActionResponse(); $tabid = $this->getRequest()->get('tabid'); $response->set('tabid', $this->getRequest()->get('tabid')); $response->set('id', $css->getFileName()); $response->set('file', $css->getFileName()); $response->set('form', $this->getForm($css)); $response->set('code', base64_encode($css->getCode())); $response->set('template', $css->toArray()); if ($tabid == '') { // client side does not do tab handling by itself (eg. opened in theme editor tab) $response->set('noTabHandling', true); // give css file filename part as tabid, because client side can instantiate more than one editors. $response->set('tabid', str_replace('.css', '', $css->getFileName())); } return $response; }
public function edit() { $review = ActiveRecordModel::getInstanceById('ProductReview', $this->request->get('id'), ProductReview::LOAD_DATA, array('Product')); //$manufacturer->getSpecification(); $response = new ActionResponse('review', $review->toArray()); $form = $this->buildForm($review); $form->setData($review->toArray()); // get ratings foreach ($review->getRelatedRecordSetArray('ProductRating', new ARSelectFilter()) as $rating) { $form->set('rating_' . $rating['ratingTypeID'], $rating['rating']); } $form->set('rating_', $review->rating->get()); //$manufacturer->getSpecification()->setFormResponse($response, $form); $response->set('form', $form); $response->set('ratingTypes', ProductRatingType::getProductRatingTypes($review->product->get())->toArray()); $options = range(1, $this->config->get('RATING_SCALE')); $response->set('ratingOptions', array_combine($options, $options)); return $response; }
public function edit() { $newsletter = ActiveRecordModel::getInstanceById('NewsletterMessage', $this->request->get('id'), ActiveRecordModel::LOAD_DATA); $form = $this->getForm(); $form->setData($newsletter->toArray()); $form->set('users', 1); $form->set('subscribers', 1); $response = new ActionResponse('form', $form); $groupsArray = array_merge(ActiveRecord::getRecordSetArray('UserGroup', select()), array(array('ID' => null, 'name' => $this->translate('Customers')))); usort($groupsArray, array($this, 'sortGroups')); $response->set('groupsArray', $groupsArray); $newsletterArray = $newsletter->toArray(); $text = strlen($newsletterArray['text']); $html = strlen($newsletterArray['html']); if ($text && $html) { $newsletterArray['format'] = self::FORMAT_HTML_TEXT; } else { if ($text) { $newsletterArray['format'] = self::FORMAT_TEXT; } else { if ($html) { $newsletterArray['format'] = self::FORMAT_HTML; } } } $response->set('newsletter', $newsletterArray); $response->set('sentCount', $newsletter->getSentCount()); $response->set('recipientCount', $this->getRecipientCount($form->getData())); return $response; }