public function execute() { $plugin_id = waRequest::get('id', null); $plugins_count = 0; if ($plugin_id) { $plugins = $this->getConfig()->getPlugins(); $plugins_count = count($plugins); if (isset($plugins[$plugin_id])) { /** * @var photosPlugin $plugin */ $plugin = waSystem::getInstance()->getPlugin($plugin_id); waSystem::pushActivePlugin($plugin_id, 'photos'); $namespace = 'photos_' . $plugin_id; $params = array(); $params['id'] = $plugin_id; $params['namespace'] = $namespace; $params['title_wrapper'] = '%s'; $params['description_wrapper'] = '<br><span class="hint">%s</span>'; $params['control_wrapper'] = '<div class="name">%s</div><div class="value">%s %s</div>'; $settings_controls = $plugin->getControls($params); $this->getResponse()->setTitle(_w(sprintf('Plugin %s settings', $plugin->getName()))); $this->view->assign('plugin_info', $plugins[$plugin_id]); $this->view->assign('plugin_id', $plugin_id); $this->view->assign('settings_controls', $settings_controls); waSystem::popActivePlugin(); } } $this->view->assign('plugins_count', $plugins_count); }
public function execute() { try { $app_settings_model = new waAppSettingsModel(); if (waRequest::post('cancel')) { wa()->getStorage()->set('shop/discountcard', ''); } else { if ($discountcard_number = waRequest::post('discountcard')) { $model = new shopDiscountcardsPluginModel(); if ($app_settings_model->get(shopDiscountcardsPlugin::$plugin_id, 'binding_customer')) { $contact_id = wa()->getUser()->getId(); $discountcard = $model->getByField(array('contact_id' => $contact_id, 'discountcard' => $discountcard_number)); if (empty($discountcard)) { $discountcard = $model->getByField(array('contact_id' => 0, 'discountcard' => $discountcard_number)); } } else { $discountcard = $model->getByField('discountcard', $discountcard_number); } if ($discountcard) { wa()->getStorage()->set('shop/discountcard', $discountcard['discountcard']); } else { throw new waException('Дисконтная карта не найдена'); } } else { throw new waException('Укажите номер дисконтной карты'); } } } catch (Exception $ex) { $this->setError($ex->getMessage()); } }
public function execute() { $photo_id = waRequest::get('photo_id', null, waRequest::TYPE_INT); $size = waRequest::get('size', null, waRequest::TYPE_STRING); $album = null; $photo_model = new photosPhotoModel(); $photo = $photo_model->getById($photo_id); if (!$photo) { throw new waException(_w("Unknown photo")); } $photo['frontend_link'] = photosFrontendPhoto::getLink($photo, $album); $sizes = $this->getConfig()->getSizes(); $contexts = array(); foreach ($sizes as $sz) { $contexts[$sz]['html'] = photosPhoto::getEmbedImgHtml($photo, $sz); $contexts[$sz]['url'] = photosPhoto::getPhotoUrl($photo, $sz, true); } if (!$size || !isset($contexts[$size])) { $size = $sizes[0]; } $domains = photosPhoto::getDomains(null, $photo); if (count($domains) <= 1) { $domains = array(); } $this->view->assign('photo', $photo); $this->view->assign('sizes', $sizes); $this->view->assign('size', $size); $this->view->assign('contexts', $contexts); $this->view->assign('original_domain', wa()->getRootUrl(true)); $this->view->assign('domains', $domains); }
public function execute() { $name = basename(waRequest::get('file', 'export.csv')); $profile = waRequest::get('profile', 0, waRequest::TYPE_INT); $file = wa()->getTempPath('csv/download/' . $profile . '/' . $name); waFiles::readFile($file, $name); }
public function execute() { $query = trim(waRequest::post('q'), ' /'); $hash = '/search/' . $query; $collection = new photosCollection($hash); if ($query == 'rate>0') { $collection->orderBy('p.rate DESC, p.id'); } $this->template = 'templates/actions/photo/PhotoList.html'; $count = $this->getConfig()->getOption('photos_per_page'); $photos = $collection->getPhotos("*,thumb,thumb_crop,thumb_middle,thumb_big,tags,edit_rights", 0, $count); $photos = photosCollection::extendPhotos($photos); $frontend_link = $query == 'rate>0' ? photosCollection::getFrontendLink('favorites', false) : photosCollection::getFrontendLink($hash, false); /** * @event search_frontend_link * @param string $query * @return array of bool|string if false - default frontend_link isn't overridden, if string - override default frontend link */ $res = wa()->event('search_frontend_link', $query); foreach ($res as $r) { if (is_string($r)) { $frontend_link = $r; break; } } $config = $this->getConfig(); $this->view->assign('sidebar_width', $config->getSidebarWidth()); $this->view->assign('big_size', $config->getSize('big')); $this->view->assign('frontend_link', $frontend_link); $this->view->assign('photos', $photos); $this->view->assign('title', $query == 'rate>0' ? _w('Rated') : $collection->getTitle()); $this->view->assign('total_count', $collection->count()); $this->view->assign('sort_method', $query == 'rate>0' ? 'rate' : 'upload_datetime'); $this->view->assign('hash', $hash); }
public function execute() { parent::execute(); $this->view->assign('my_nav_selected', 'profile'); $user = wa()->getUser(); $user_info = array(); foreach ($this->form->fields as $id => $field) { if (!in_array($id, array('password', 'password_confirm'))) { if ($id === 'photo') { $user_info[$id] = array('name' => _ws('Photo'), 'value' => '<img src="' . $user->getPhoto() . '">'); } else { $user_info[$id] = array('name' => $this->form->fields[$id]->getName(null, true), 'value' => $user->get($id, 'html')); } } } $this->view->assign('user_info', $user_info); // Set up layout and template from theme $this->setThemeTemplate('my.profile.html'); if (!waRequest::isXMLHttpRequest()) { $this->setLayout(new photosDefaultFrontendLayout()); $this->getResponse()->setTitle(_w('My account') . ' — ' . _w('My profile')); $this->layout->assign('breadcrumbs', $this->getBreadcrumbs()); $this->layout->assign('nofollow', true); } }
public function execute() { try { $discountcard = waRequest::post('discountcard', array()); $model = new shopDiscountcardsPluginModel(); if (!empty($discountcard['id'])) { $model->updateById($discountcard['id'], $discountcard); $discountcard = $model->getById($discountcard['id']); } elseif (empty($discountcard['discountcard'])) { throw new waException('Ошибка: Не указан номер дисконтной карты'); } else { if ($model->getByField('discountcard', $discountcard['discountcard'])) { throw new waException('Ошибка: Номер дисконтной карты не уникален'); } $id = $model->insert($discountcard); $discountcard = $model->getById($id); } if (!empty($discountcard['contact_id'])) { $contact = new waContact($discountcard['contact_id']); $discountcard['contact_name'] = $contact->get('name'); } $discountcard['amount'] = shop_currency($discountcard['amount']); $this->response = $discountcard; } catch (Exception $ex) { $this->setError($ex->getMessage()); } }
public function getHash() { $order_ids = waRequest::post('order_id', null, waRequest::TYPE_ARRAY_INT); if ($order_ids !== null) { if ($order_ids) { return 'id/' . implode(',', $order_ids); } else { return null; } } $filter_params = waRequest::post('filter_params', null); if ($filter_params === null) { return null; } $hash = ''; if ($filter_params) { if (count($filter_params) == 1) { $k = key($filter_params); $v = $filter_params[$k]; if (is_array($v)) { $v = implode("||", $v); } if ($k == 'storefront') { $k = 'params.' . $k; if (substr($v, -1) == '*') { $v = substr($v, 0, -1); } } $hash = "search/{$k}={$v}"; } } return $hash; }
public function saveAction() { $plugin_id = waRequest::get('id'); if (!$plugin_id) { throw new waException(_ws("Can't save plugin settings: unknown plugin id")); } $namespace = $this->getAppId() . '_' . $plugin_id; /** * @var shopPlugin $plugin */ $plugin = waSystem::getInstance()->getPlugin($plugin_id); $settings = (array) $this->getRequest()->post($namespace); $files = waRequest::file($namespace); $settings_defenitions = $plugin->getSettings(); foreach ($files as $name => $file) { if (isset($settings_defenitions[$name])) { $settings[$name] = $file; } } try { $response = $plugin->saveSettings($settings); $response['message'] = _w('Saved'); $this->displayJson($response); } catch (Exception $e) { $this->setError($e->getMessage()); $this->displayJson(array(), $e->getMessage()); } }
public function execute() { $this->init(); $type = waRequest::param('type'); $this->hash = waRequest::param('hash'); if ($type == 'tag') { $this->view->assign('criteria', 'by-tag'); $this->view->assign('tag', waRequest::param('tag')); } else { if ($type == 'favorites') { $this->view->assign('criteria', 'favorites'); } } if (in_array($type, array('author', 'search', 'tag', 'favorites', 'id'))) { waRequest::setParam('disable_sidebar', true); $template = 'search.html'; } else { $template = 'home.html'; if (!file_exists($this->getTheme()->getPath() . '/' . $template)) { $template = 'view-thumbs.html'; // for backward compatibility reason } } if ($type != 'all' && $type != 'favorites') { waRequest::setParam('nofollow', true); } $layout = $this->getLayout(); if ($layout) { $layout->assign('hash', $this->hash); } $this->setThemeTemplate($template); $this->finite(); }
public function execute() { $lazy = !is_null(waRequest::get('lazy')); if (!$lazy) { $this->setLayout(new photosDefaultFrontendLayout()); } else { $this->setTemplate('FrontendPhotos'); } $photos_per_page = wa('photos')->getConfig()->getOption('photos_per_page'); $limit = $photos_per_page; $page = 1; if ($lazy) { $offset = max(0, waRequest::get('offset', 0, waRequest::TYPE_INT)); } else { $page = max(1, waRequest::get('page', 1, waRequest::TYPE_INT)); $offset = ($page - 1) * $photos_per_page; } $c = new photosCollection('publicgallery/myphotos'); $photos = $c->getPhotos('*', $offset, $limit); $photos = photosCollection::extendPhotos($photos); $v = wa()->getVersion(); wa('photos')->getResponse()->addJs('js/lazy.load.js?v=' . $v, true); wa('photos')->getResponse()->addJs('js/frontend.photos.js?v=' . $v, true); $storage = wa()->getStorage(); $current_auth = $storage->read('auth_user_data'); $current_auth_source = $current_auth ? $current_auth['source'] : null; $this->view->assign('current_auth', $current_auth, true); $adapters = wa()->getAuthAdapters(); $total_count = $c->count(); $this->view->assign(array('photos' => $photos, 'page' => $page, 'offset' => $offset, 'photos_per_page' => $photos_per_page, 'total_photos_count' => $total_count, 'lazy_load' => $lazy, 'image_upload_url' => wa()->getRouteUrl('photos/frontend/imageUpload'), 'pages_count' => floor($total_count / $photos_per_page) + 1, 'current_auth_source' => $current_auth_source, 'adapters' => $adapters)); }
public function execute() { $name = rtrim(waRequest::post('name'), '/'); $domain_model = new siteDomainModel(); $data = array(); if (!preg_match('!^[a-z0-9/\\._-]+$!i', $name)) { $data['title'] = $name; $idna = new waIdna(); $name = $idna->encode($name); } $data['name'] = $name; $this->response['id'] = $domain_model->insert($data); $this->log('site_add'); // add default routing $path = $this->getConfig()->getPath('config', 'routing'); if (file_exists($path)) { $routes = (include $path); } else { $routes = array(); } if (!isset($routes[$name])) { $routes[$name]['site'] = array('url' => '*', 'app' => 'site'); waUtils::varExportToFile($routes, $path); } }
public function execute() { // only allowed to global admin if (!wa()->getUser()->getRights('webasyst', 'backend')) { throw new waRightsException('Access denied.'); } $collection = new contactsCollection('users/all'); $group = null; $memberIds = array(); if ($id = waRequest::get('id')) { $group_model = new waGroupModel(); $group = $group_model->getById($id); } if ($group) { $user_groups_model = new waUserGroupsModel(); $memberIds = $user_groups_model->getContactIds($id); } $users = $collection->getContacts('id,name'); // array(id => array(id=>...,name=>...)) $members = array(); foreach ($memberIds as $mid) { if (isset($users[$mid])) { $members[$mid] = $users[$mid]; unset($users[$mid]); } } usort($members, array($this, '_cmp')); usort($users, array($this, '_cmp')); $this->view->assign('group', $group); $this->view->assign('notIncluded', $users); $this->view->assign('members', $members); }
public function execute() { $photo_id = $this->post('id', true); if (!is_array($photo_id)) { if (strpos($photo_id, ',') !== false) { $photo_id = array_map('intval', explode(',', $photo_id)); } else { $photo_id = array($photo_id); } } $album_id = waRequest::post('album_id', ''); if (!$album_id) { $album_id = array(); } if (!is_array($album_id)) { if (strpos($album_id, ',') !== false) { $album_id = explode(',', $album_id); } else { $album_id = array($album_id); } } $album_id = array_map('trim', $album_id); $album_photos_model = new photosAlbumPhotosModel(); $photo_rights_model = new photosPhotoRightsModel(); $allowed_photo_id = $photo_rights_model->filterAllowedPhotoIds($photo_id, true); if ($allowed_photo_id) { $album_photos_model->deletePhotos($album_id, $allowed_photo_id); $this->response = true; } else { throw new waAPIException('access_denied', 403); } }
public function execute() { $this->setLayout(new shopBackendLayout()); $status = waRequest::get('status'); $tab = waRequest::get('tab'); $model = new waModel(); $cities = $model->query("SELECT * FROM shop_deliveryshop_city ORDER BY city ASC")->fetchAll(); $city['data'] = $cities; $city['new'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_city WHERE status='new'")->fetchField(); $city['completed'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_city WHERE status='completed'")->fetchField(); $city['flag-white'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_city WHERE status='flag-white'")->fetchField(); $city['refunded'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_city WHERE status='refunded'")->fetchField(); $city['all'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_city")->fetchField(); foreach ($city['data'] as $key => &$c) { if (is_numeric($c['region'])) { $c['region'] = $model->query("SELECT name FROM wa_region WHERE code='" . $c['region'] . "' AND country_iso3='rus'")->fetchField(); } if ($status && $status != $c['status'] && $tab == 'shop') { unset($city['data'][$key]); } } $pvz['data'] = $model->query("SELECT * FROM shop_deliveryshop_pvz ORDER BY city ASC")->fetchAll(); $pvz['new'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_pvz WHERE status='new'")->fetchField(); $pvz['completed'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_pvz WHERE status='completed'")->fetchField(); $pvz['flag-white'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_pvz WHERE status='flag-white'")->fetchField(); $pvz['refunded'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_pvz WHERE status='refunded'")->fetchField(); $pvz['all'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_pvz")->fetchField(); $this->view->assign('cities', $city); $this->view->assign('pvz', $pvz); }
public function execute() { $order_id = waRequest::request('order_id', 0, 'int'); $id = waRequest::request('id', 0, 'int'); $to = waRequest::request('to'); $nm = new shopNotificationModel(); $n = $nm->getById($id); if (!$n) { $this->errors = sprintf_wp('%s entry not found', _w('Notification')); return; } $om = new shopOrderModel(); $o = $om->getById($order_id); if (!$o) { $this->errors = _w('Order not found'); return; } shopHelper::workupOrders($o, true); $opm = new shopOrderParamsModel(); $o['params'] = $opm->get($order_id); try { $contact = $o['contact_id'] ? new shopCustomer($o['contact_id']) : wa()->getUser(); $contact->getName(); } catch (Exception $e) { $contact = new shopCustomer(wa()->getUser()->getId()); } $cm = new shopCustomerModel(); $customer = $cm->getById($contact->getId()); if (!$customer) { $customer = $cm->getEmptyRow(); } $workflow = new shopWorkflow(); // send notifications shopNotifications::sendOne($id, array('order' => $o, 'customer' => $contact, 'status' => $workflow->getStateById($o['state_id'])->getName()), $to); }
public function execute() { $cache = null; if ($cache_time = $this->getConfig()->getOption('cache_time')) { //$cache = new waSerializeCache('pages/'.$domain.$url.'page'); } $page = array(); if ($cache && $cache->isCached()) { $page = $cache->get(); } else { $site = new siteFrontend(); if (waRequest::param('error')) { $page = array(); } else { $page = $site->getPage(waRequest::param('url', '')); } if ($page && $cache) { $cache->set($page); } } if (!waRequest::isXMLHttpRequest()) { $this->setLayout(new siteFrontendLayout()); } try { $this->executeAction(new siteFrontendAction($page)); } catch (Exception $e) { if (waSystemConfig::isDebug()) { echo $e; } else { waSystem::setActive('site'); $this->executeAction(new siteFrontendAction($e)); } } }
public function execute() { $settings = waRequest::post('settings', array(), waRequest::TYPE_ARRAY); if (strlen($error = logsHelper::setPhpLogSetting(ifset($settings['php_log'], false)))) { $this->errors[] = $error; } }
protected function step() { $image_model = new shopProductImagesModel(); $create_thumbnails = waRequest::post('create_thumbnails'); $chunk_size = 50; if ($create_thumbnails) { $chunk_size = 10; } $sizes = wa('shop')->getConfig()->getImageSizes(); $images = $image_model->getAvailableImages($this->data['offset'], $chunk_size); foreach ($images as $i) { if ($this->data['product_id'] != $i['product_id']) { sleep(0.2); $this->data['product_id'] = $i['product_id']; $this->data['product_count'] += 1; } try { $path = shopImage::getThumbsPath($i); if (!waFiles::delete($path)) { throw new waException(sprintf(_w('Error when delete thumbnails for image %d'), $i['id'])); } if ($create_thumbnails) { shopImage::generateThumbs($i, $sizes); } $this->data['image_count'] += 1; // image count - count of successful progessed images } catch (Exception $e) { $this->error($e->getMessage()); } $this->data['offset'] += 1; } }
public function execute() { $this->getResponse()->addJs("js/jquery.pageless2.js?v=" . wa()->getVersion(), true); $this->view->assign('site_theme_url', wa()->getDataUrl('themes', true, 'site') . '/' . waRequest::param('theme', 'default') . '/'); $this->view->assign('action', $action = waRequest::param('action', 'default')); waRequest::setParam('action', $action); $params = waRequest::param(); /** * @event frontend_action_default * @event frontend_action_post * @event frontend_action_page * @event frontend_action_error * @param array[string]mixed $params request params * @return array[string][string]string $return['%plugin_id%'] * @return array[string][string]string $return['%plugin_id%'][nav_before] * @return array[string][string]string $return['%plugin_id%'][footer] * @return array[string][string]string $return['%plugin_id%'][head] * @return array[string][string]string $return['%plugin_id%'][sidebar] */ $this->view->assign('settlement_one_blog', isset($params['blog_id']) && $params['blog_url_type'] == $params['blog_id']); $this->view->assign('frontend_action', $res = wa()->event('frontend_action_' . $action, $params)); if (!$this->view->getVars('links')) { $this->view->assign('links', array()); } $this->setThemeTemplate('index.html'); }
protected function getId() { if (!empty($this->params['limited_own_profile'])) { return wa()->getUser()->getId(); } return (int) waRequest::get('id'); }
public function execute() { $photo_id = waRequest::get('photo_id', array(), waRequest::TYPE_ARRAY_INT); if (!$photo_id) { throw new waException(_w('Empty photo list')); } $photo_model = new photosPhotoModel(); // dialog for one photo if (count($photo_id) == 1) { $photo_id = current($photo_id); $photo = $photo_model->getById($photo_id); $photo_right_model = new photosPhotoRightsModel(); if (!$photo_right_model->checkRights($photo, true)) { $rights = array(0 => array('group_id' => 0, 'photo_id' => null)); } else { $rights = $photo_right_model->getByField('photo_id', $photo_id, 'group_id'); } } else { // dialog for several selected photos // dummies for correct template randering $photo = array('status' => 1); $rights = array(0 => array('group_id' => 0, 'photo_id' => null)); $allowed_photo_id = (array) $photo_model->filterByField($photo_id, 'status', 1); $this->view->assign('photo_count', count($photo_id)); $this->view->assign('disable_submit', count($allowed_photo_id) != count($photo_id)); } $groups_model = new waGroupModel(); $groups = $groups_model->getAll('id', true); $this->view->assign('groups', $groups); $this->view->assign('photo', $photo); $this->view->assign('rights', $rights); }
public function execute() { if (!$this->getUser()->getRights('shop', 'settings')) { throw new waRightsException(_w('Access denied')); } $model = new shopTypeModel(); $data = array(); $data['id'] = waRequest::post('id', 0, waRequest::TYPE_INT); switch (waRequest::post('source', 'custom')) { case 'custom': $data['name'] = waRequest::post('name'); $data['icon'] = waRequest::post('icon_url', false, waRequest::TYPE_STRING_TRIM); if (empty($data['icon'])) { $data['icon'] = waRequest::post('icon', 'icon.box', waRequest::TYPE_STRING_TRIM); } if (!empty($data['id'])) { $model->updateById($data['id'], $data); } else { $data['sort'] = $model->select('MAX(sort)+1 as max_sort')->fetchField('max_sort'); $data['id'] = $model->insert($data); } break; case 'template': $data = $model->insertTemplate(waRequest::post('template'), true); break; } if ($data) { $data['icon_html'] = shopHelper::getIcon($data['icon'], 'icon.box'); $data['name_html'] = '<span class="js-type-icon">' . $data['icon_html'] . '</span> <span class="js-type-name">' . htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8') . '</span>'; } $this->response = $data; }
public function execute() { $path = null; $photo_rights_model = new photosPhotoRightsModel(); $photo_id = waRequest::get('photo_id', null, waRequest::TYPE_INT); if ($photo_rights_model->checkRights($photo_id, true)) { $photo_model = new photosPhotoModel(); if ($photo = $photo_model->getById($photo_id)) { if (waRequest::get('original')) { $path = photosPhoto::getOriginalPhotoPath($photo); } else { $path = photosPhoto::getPhotoPath($photo); } } } if ($path) { if ($attach = waRequest::get('attach') ? true : false) { $response = $this->getResponse(); $response->addHeader('Expires', 'tomorrow'); $response->addHeader('Cache-Control', ($photo['status'] == 1 ? 'public' : 'private') . ', max-age=' . 86400 * 30); } waFiles::readFile($path, $attach ? null : basename($photo['name'] . '.' . $photo['ext']), true, !$attach); } else { throw new waException(_w("Photo not found"), 404); } }
public function execute() { $path = rtrim(waRequest::post('path'), ' /'); $path = wa()->getDataPath($path, true); if (!file_exists($path)) { throw new waException("File not found", 404); } $files = array(); $dh = opendir($path); $names = array(); while (($f = readdir($dh)) !== false) { if ($f !== '.' && $f !== '..' && is_file($path . '/' . $f)) { $t = filemtime($path . '/' . $f); $name = htmlspecialchars($f); $files[$name] = array('file' => $name, 'type' => $this->getType($f), 'size' => filesize($path . '/' . $f), 'timestamp' => $t, 'datetime' => waDateTime::format('humandatetime', $t)); $names[] = $name; } } natcasesort($names); $sorted_files = array(); foreach ($names as $name) { $sorted_files[] =& $files[$name]; } closedir($dh); $this->response = $sorted_files; }
public function execute() { $hash = $this->get('hash'); $collection = new photosCollection($hash); $offset = waRequest::get('offset', 0, 'int'); if ($offset < 0) { throw new waAPIException('invalid_param', 'Param offset must be greater than or equal to zero'); } $limit = waRequest::get('limit', 100, 'int'); if ($limit < 0) { throw new waAPIException('invalid_param', 'Param limit must be greater than or equal to zero'); } if ($limit > 1000) { throw new waAPIException('invalid_param', 'Param limit must be less or equal 1000'); } $photos = $collection->getPhotos('*,thumb', $offset, $limit); foreach ($photos as &$p) { if (isset($p['thumb']['url'])) { $p['image_url'] = $p['thumb']['url']; unset($p['thumb']); } } unset($p); $this->response['count'] = $collection->count(); $this->response['offset'] = $offset; $this->response['limit'] = $limit; $this->response['photos'] = array_values($photos); }
public function execute() { $extended = false; $this->view->assign('action', 'update'); $update_counter = 0; $messages = installerMessage::getInstance()->handle(waRequest::get('msg')); $this->view->assign('error', false); $app = null; try { $app_list = installerHelper::getApps($messages, $update_counter); $slug = waRequest::get('slug'); $vendor = waRequest::get('vendor'); $edition = waRequest::get('edition'); foreach ($app_list as $info) { if ($info['slug'] == $slug && $info['vendor'] == $vendor && $info['edition'] == $edition) { $app = $info; break; } } if (!$app) { throw new waException(_w('Application not found')); } } catch (Exception $ex) { $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL); $this->redirect(array('module' => 'apps', 'msg' => $msg)); } $this->view->assign('identity_hash', installerHelper::getHash()); $this->view->assign('messages', $messages); $this->view->assign('update_counter', $update_counter); $this->view->assign('app', $app); $this->view->assign('title', sprintf(_w('Application "%s"'), $app['name'])); }
public function execute() { $id = $this->get('id', true); $page_model = new sitePageModel(); $page = $page_model->getById($id); if ($page) { $data = waRequest::post(); $keys = array('name', 'title', 'content', 'status'); $update = array(); foreach ($keys as $k) { if (isset($data[$k])) { $update[$k] = $data[$k]; } } $r = true; if ($update || !empty($data['params'])) { if ($update) { $r = $page_model->update($id, $update); } if (!empty($data['params'])) { $page_model->setParams($id, $data['params']); } } if ($r) { $method = new sitePageGetInfoMethod(); $this->response = $method->getResponse(true); } else { throw new waAPIException('server_error', 500); } } else { throw new waAPIException('invalid_param', 'Page not found', 404); } }
/** * Return current theme * * @return waTheme */ public function getTheme() { if ($this->theme == null) { $this->theme = new waTheme(waRequest::getTheme()); } return $this->theme; }
public function execute() { $parent_id = waRequest::get('parent_id'); $category_model = new shopCategoryModel(); $cats = $category_model->getTree($parent_id, waRequest::get('depth', null, 'int')); $stack = array(); $result = array(); foreach ($cats as $c) { $c['categories'] = array(); // Number of stack items $l = count($stack); // Check if we're dealing with different levels while ($l > 0 && $stack[$l - 1]['depth'] >= $c['depth']) { array_pop($stack); $l--; } // Stack is empty (we are inspecting the root) if ($l == 0) { // Assigning the root node $i = count($result); $result[$i] = $c; $stack[] =& $result[$i]; } else { // Add node to parent $i = count($stack[$l - 1]['categories']); $stack[$l - 1]['categories'][$i] = $c; $stack[] =& $stack[$l - 1]['categories'][$i]; } } $this->response = $result; $this->response['_element'] = 'category'; }