public function execute() { $action = waRequest::param('action', 'default'); $disable_sidebar = waRequest::param('disable_sidebar', false); $this->view->assign('action', $action); $this->view->assign('breadcrumbs', waRequest::param('breadcrumbs', array())); if (!$this->getResponse()->getTitle()) { $title = waRequest::param('title') ? waRequest::param('title') : wa()->accountName(); $this->getResponse()->setTitle($title); } $this->view->assign('nofollow', waRequest::param('nofollow', false)); $this->view->assign('disable_sidebar', $disable_sidebar); /** * Include plugins js and css * @event frontend_assets * @return array[string][string]string $return[%plugin_id%] Extra header data (css/js/meta) */ $this->view->assign('frontend_assets', wa()->event('frontend_assets')); /** * @event frontend_layout * @return array[string][string]string $return[%plugin_id%]['header'] Header menu section * @return array[string][string]string $return[%plugin_id%]['footer'] Footer section */ $this->view->assign('frontend_layout', wa()->event('frontend_layout')); /** * @event frontend_sidebar * @return array[string][string]string $return[%plugin_id%]['menu'] Sidebar menu item * @return array[string][string]string $return[%plugin_id%]['section'] Sidebar section item */ $this->view->assign('frontend_sidebar', wa()->event('frontend_sidebar')); $this->setThemeTemplate('index.html'); }
public function execute() { $this->init(); $url = trim(waRequest::param('url', '', waRequest::TYPE_STRING_TRIM), '/'); if (!$url) { throw new waException(_w('Page not found', 404)); } $this->route($url); if (!$this->album) { throw new waException(_w('Page not found', 404)); } $this->album = photosFrontendAlbum::escapeFields($this->album); // retrieve user params $album_params_model = new photosAlbumParamsModel(); $params = $album_params_model->get($this->album['id']); $params = photosPhoto::escape($params); $this->album += $params; // "childcrumbs" - list of childs (sub-albums). Use in 'plain' template $childcrumbs = $this->album_model->getChildcrumbs($this->album['id'], true); waRequest::setParam('breadcrumbs', $this->album_model->getBreadcrumbs($this->album['id'], true)); waRequest::setParam('nofollow', $this->album['status'] <= 0 ? true : false); waRequest::setParam('disable_sidebar', true); $this->setThemeTemplate('album.html'); $this->view->assign('album', $this->album); $this->view->assign('childcrumbs', $childcrumbs); $this->getResponse()->addJs('js/common.js?v=' . wa()->getVersion(), true); $this->finite(); }
public function dispatch() { $env = $this->system->getEnv(); if ($env == 'frontend') { $module = 'frontend'; } else { $module = waRequest::get($this->options['module'], $this->system->getEnv()); } $module = waRequest::param('module', $module); $action = waRequest::param('action', waRequest::get($this->options['action'])); $plugin = waRequest::param('plugin', $env == 'backend' ? waRequest::get('plugin', '') : ''); // event init if (!waRequest::request('background_process')) { if (method_exists($this->system->getConfig(), 'onInit')) { $this->system->getConfig()->onInit(); } } if ($this->system->getEnv() == 'backend') { if ($widget = waRequest::get('widget')) { $this->executeWidget($widget, $action); } else { $this->execute($plugin, $module, $action); } } else { $this->execute($plugin, $module, $action); } }
public function execute() { $this->setLayout(new shopFrontendLayout()); $product_model = new shopProductModel(); $product = $product_model->getByField('url', waRequest::param('product_url')); if (!$product) { throw new waException('Product not found', 404); } $product = new shopProduct($product); $this->getBreadcrumbs($product, true); $reviews_model = new shopProductReviewsModel(); $reviews = $reviews_model->getFullTree($product['id'], 0, null, 'datetime DESC', array('escape' => true)); $config = wa()->getConfig(); $this->view->assign(array('product' => $product, 'reviews' => $reviews, 'reviews_count' => $reviews_model->count($product['id']), 'reply_allowed' => true, 'auth_adapters' => $adapters = wa()->getAuthAdapters(), 'request_captcha' => $config->getGeneralSettings('require_captcha'), 'require_authorization' => $config->getGeneralSettings('require_authorization'))); $storage = wa()->getStorage(); $current_auth = $storage->read('auth_user_data'); $current_auth_source = $current_auth ? $current_auth['source'] : shopProductReviewsModel::AUTH_GUEST; $this->view->assign('current_auth_source', $current_auth_source); $this->view->assign('current_auth', $current_auth, true); /** * @event frontend_product * @param shopProduct $product * @return array[string][string]string $return[%plugin_id%]['menu'] html output * @return array[string][string]string $return[%plugin_id%]['cart'] html output * @return array[string][string]string $return[%plugin_id%]['block_aux'] html output * @return array[string][string]string $return[%plugin_id%]['block'] html output */ $this->view->assign('frontend_product', wa()->event('frontend_product', $product, array('menu', 'cart', 'block_aux', 'block'))); $this->setThemeTemplate('reviews.html'); }
public function execute() { $type = waRequest::param(0); $types = array('sms', 'payment', 'shipping'); $id = waRequest::param(1); $params = waRequest::param(); $pattern = '/^[a-z][a-z0-9]*$/'; if (empty($type) || empty($params) || isset($params['help']) || !in_array($type, $types) || !preg_match($pattern, $id)) { $help = <<<HELP Usage: php wa.php createSystemPlugin type plugin_id [parameters] type - Plugin type: shipping, payment, or sms plugin_id - Plugin id (string in lower case) Optional parameters: -name (Plugin name; if comprised of several words, enclose in quotes; e.g., 'My plugin') -version (Plugin version; e.g., 1.0.0) -vendor (Numerical vendor id) -settings (Supports user settings) Example: php wa.php createSystemPlugin shipping myshipping -name 'My shipping' -version 1.0.0 -vendor 123456 HELP; print $help . "\n"; } else { $plugin_path = wa()->getConfig()->getPath('plugins') . '/' . $type . '/' . $id; $this->create($type, $id, $plugin_path, $params); } }
public function execute() { $blog_id = wa()->getRequest()->param('blog_url_type'); if ($blog_id <= 0) { $blog_id = waRequest::request('blog_id', 0, 'int'); } $this->setLayout(new blogFrontendLayout()); // Get contact id and name as post author if (wa()->getUser()->get('is_user')) { $post_contact_id = wa()->getUser()->getId(); $post_contact_name = wa()->getUser()->getName(); } else { foreach (blogHelper::getAuthors($blog_id) as $post_contact_id => $post_contact_name) { break; } } // Prepare empty fake post data $post_model = new blogPostModel(); $post = $post_model->prepareView(array(array('id' => 0, 'blog_id' => $blog_id, 'contact_id' => $post_contact_id, 'contact_name' => $post_contact_name, 'datetime' => date('Y-m-d H:i:s'), 'title' => '%replace-with-real-post-title%', 'status' => 'published', 'text' => '<div class="replace-with-real-post-text"></div>' . $this->getScripts(), 'comments_allowed' => 0) + $post_model->getEmptyRow())); $post = array_merge($post[0], array('comments' => array(), 'comment_link' => '', 'link' => '')); $this->getResponse()->setTitle(_w('Preview')); $this->getResponse()->setMeta('keywords', ''); $this->getResponse()->setMeta('description', ''); $current_auth = wa()->getStorage()->read('auth_user_data'); $current_auth_source = $current_auth ? $current_auth['source'] : null; $this->view->assign(array('realtime_preview' => true, 'frontend_post' => array(), 'errors' => array(), 'form' => array(), 'show_comments' => false, 'request_captcha' => false, 'require_authorization' => false, 'theme' => waRequest::param('theme', 'default'), 'current_auth_source' => $current_auth_source, 'current_auth' => $current_auth, true, 'auth_adapters' => wa()->getAuthAdapters(), 'post' => $post)); }
public function execute() { $f = waRequest::param('f'); $fid = waRequest::param('fid', waRequest::post('fid')); $prefix = waRequest::param('prefix', waRequest::post('prefix', 'options')); $full_parent = waRequest::param('parent', waRequest::post('parent', null)); $parent = explode('.', $full_parent); $parent = $parent[0]; $new_field = false; if ($f && $f instanceof waContactField) { $ftype = $f->getType(); if ($ftype == 'Select') { if ($f instanceof waContactBranchField) { $ftype = 'branch'; } else { if ($f instanceof waContactRadioSelectField) { $ftype = 'radio'; } } } } else { $ftype = strtolower(waRequest::param('ftype', waRequest::post('ftype', 'string'))); $f = self::getField($fid, $ftype); $new_field = true; } $ftype = strtolower($ftype); $this->view->assign('f', $f); $this->view->assign('fid', $fid); $this->view->assign('ftype', $ftype); $this->view->assign('prefix', $prefix); $this->view->assign('parent', $parent); $this->view->assign('uniqid', 'fe_' . uniqid()); $this->view->assign('new_field', $new_field); }
public function execute() { $e = $this->getRequest()->param('exception'); if ($e && $e instanceof Exception) { /** * @var Exception $e */ $code = $e->getCode(); if (!$code) { $code = 500; } $message = $e->getMessage(); } else { $code = 404; $message = _ws("Page not found"); } $this->getResponse()->setStatus($code); $this->getResponse()->setTitle(htmlentities($code . '. ' . $message, ENT_QUOTES, 'utf-8')); $this->view->assign('error_code', $code); $this->view->assign('error_message', $message); if ($code == 404) { $this->setLayout(new blogFrontendLayout()); } $this->setThemeTemplate('error.html', waRequest::param('theme', 'default')); }
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() { $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'); }
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() { $app_id = waRequest::param(0); $params = waRequest::param(); if (empty($app_id) || isset($params['help'])) { $help = <<<HELP Usage: php wa.php createApp [app_id] [parameters] app_id - App id (string in lower case) Optional parameters: -name (App name; if comprised of several words, enclose in quotes; e.g., 'My app') -version (App version; e.g., 1.0.0) -vendor (Numerical vendor id) -frontend (Has frontend) -themes (Supports design themes) -plugins (Supports plugins) -cli (Has CLI handlers) -api (Has API) Example: php wa.php createApp myapp -name 'My app' -version 1.0.0 -vendor 123456 -frontend -themes -plugins -cli -api HELP; print $help . "\n"; } else { $errors = array(); if (!empty($params['version']) && !preg_match('@^[\\d]+(\\.\\d+)*$@', $params['version'])) { $errors[] = 'Invalid version format'; } if ($errors) { print "ERROR:\n"; print implode("\n", $errors); } else { $app_path = wa()->getAppPath(null, $app_id); $this->create($app_id, $app_path, $params); } } }
public function dispatch() { if ($this->system->getEnv() == 'frontend') { $module = 'frontend'; } else { $module = waRequest::get($this->options['module'], $this->system->getEnv()); } $module = waRequest::param('module', $module); $action = waRequest::param('action', waRequest::get($this->options['action'])); $plugin = waRequest::param('plugin', waRequest::get('plugin', '')); // event init if (!waRequest::request('background_process')) { if (method_exists($this->system->getConfig(), 'onInit')) { $this->system->getConfig()->onInit(); } } if ($widget = waRequest::param('widget')) { $this->executeWidget($widget, $action); } elseif ($this->system->getEnv() == 'backend') { $url = explode("/", $this->system->getConfig()->getRequestUrl(true)); if (isset($url[2]) && isset($url[3]) && $url[2] == 'widgets') { $this->executeWidget($url[3], $action); } else { $this->execute($plugin, $module, $action); } } else { $this->execute($plugin, $module, $action); } }
public function execute() { // Setting the frontend layout // Задаём лайаут для фронтенда $this->setLayout(new guestbook2FrontendLayout()); // Setting the theme template // Задаём шаблон темы $this->setThemeTemplate('guestbook.html'); // if a POST request has been received then write a new record to the database // Если пришёл POST-запрос, то нужно записать в БД новую запись if (waRequest::method() == 'post') { $this->add(); } // Creating a model instance for retrieving data from the database // Создаем экземпляр модели для получения данных из БД $model = new guestbook2Model(); // Retrieving the record count per page from the app's settings // Получаем количество записей на одной странице из настроек приложения $limit = $this->getConfig()->getOption('records_per_page'); // Current page // Текущая страница $page = waRequest::param('page'); if (!$page) { $page = 1; } $this->view->assign('page', $page); // Calculating offset // Вычисляем смещение $offset = ($page - 1) * $limit; // Retrieving all records from the database // Получаем записи гостевой книги из БД $records = $model->getRecords($offset, $limit); // Total record count // Всего записей $records_count = $model->countAll(); $pages_count = ceil($records_count / $limit); $this->view->assign('pages_count', $pages_count); // Preparing records for being passed to the theme template // Подготавливаем записи для передачи в шаблон темы foreach ($records as &$r) { if ($r['contact_id']) { $r['name'] = htmlspecialchars($r['contact_name']); // getting contact photo URL // получаем URL на фотографию контакта $r['photo_url'] = waContact::getPhotoUrl($r['contact_id'], $r['photo'], 20); } else { $r['name'] = htmlspecialchars($r['name']); } $r['text'] = nl2br(htmlspecialchars($r['text'])); } unset($r); // Passing records to the template // Передаем записи в шаблон $this->view->assign('records', $records); // URL portion for links to pages // Часть урла для ссылок на страницы $this->view->assign('url', wa()->getRouteUrl('/frontend')); }
public function execute() { $code = waRequest::param('code'); $encoded_order_id = waRequest::param('id'); $order_id = shopHelper::decodeOrderId($encoded_order_id); if (!$order_id) { // fall back to non-encoded id $order_id = $encoded_order_id; $encoded_order_id = shopHelper::encodeOrderId($order_id); } if (!$order_id || $order_id != substr($code, 16, -16)) { throw new waException(_w('Order not found'), 404); } // When user is authorized, check if order belongs to him. // When it does, redirect to plain order page. if (wa()->getUser()->isAuth()) { $om = new shopOrderModel(); $order = $om->getOrder($order_id); if (!$order) { throw new waException(_w('Order not found'), 404); } if ($order['contact_id'] == wa()->getUser()->getId()) { $this->redirect(wa()->getRouteUrl('/frontend/myOrder', array('id' => $order_id))); } } // Check auth code $opm = new shopOrderParamsModel(); $params = $opm->get($order_id); if (ifset($params['auth_code']) !== $code || empty($params['auth_pin'])) { throw new waException(_w('Order not found'), 404); } // Check auth pin and show order page if pin is correct $pin = waRequest::request('pin', wa()->getStorage()->get('shop/pin/' . $order_id)); if ($pin && $pin == $params['auth_pin']) { wa()->getStorage()->set('shop/pin/' . $order_id, $pin); parent::execute(); if (!waRequest::isXMLHttpRequest()) { $this->layout->assign('breadcrumbs', self::getBreadcrumbs()); } return; } // // No pin or pin is incorrect: show form to enter pin // $this->view->assign('wrong_pin', !!$pin); $this->view->assign('pin_required', true); $this->view->assign('encoded_order_id', $encoded_order_id); $this->view->assign('my_nav_selected', 'orders'); // Set up layout and template from theme $this->setThemeTemplate('my.order.html'); if (!waRequest::isXMLHttpRequest()) { $this->setLayout(new shopFrontendLayout()); $this->getResponse()->setTitle(_w('Order') . ' ' . $encoded_order_id); $this->view->assign('breadcrumbs', self::getBreadcrumbs()); $this->layout->assign('nofollow', true); } }
public function execute() { $search = new shopIndexSearch(); if (waRequest::param(0)) { $search->indexProduct(waRequest::param(0)); } else { $product_model = new shopProductModel(); $n = $product_model->countAll(); $limit = 100; $i = 0; $product_model->exec("TRUNCATE TABLE shop_search_index"); while ($i < $n) { echo $i . "/" . $n . "\n"; $sql = "SELECT p.*, t.name type_name FROM " . $product_model->getTableName() . " p\n LEFT JOIN shop_type t ON p.type_id = t.id\n LIMIT " . $i . ", " . $limit; $products = $product_model->query($sql)->fetchAll('id'); $product_ids = array_keys($products); // get skus $sql = "SELECT * FROM shop_product_skus WHERE product_id IN (i:id)"; $data = $product_model->query($sql, array('id' => $product_ids)); foreach ($data as $row) { $products[$row['product_id']]['skus'][] = $row; } // get tags $sql = "SELECT pt.product_id, t.name FROM shop_product_tags pt\n JOIN shop_tag t ON pt.tag_id = t.id WHERE pt.product_id IN (i:id)"; $data = $product_model->query($sql, array('id' => $product_ids)); foreach ($data as $row) { $products[$row['product_id']]['tags'][] = $row['name']; } // get features $sql = "SELECT pf.product_id, fv.value FROM shop_product_features pf\n JOIN shop_feature f ON pf.feature_id = f.id AND f.type = 'varchar'\n JOIN shop_feature_values_varchar fv ON pf.feature_value_id = fv.id WHERE pf.product_id IN (i:id)"; $data = $product_model->query($sql, array('id' => $product_ids)); foreach ($data as $row) { $products[$row['product_id']]['features'][] = $row['value']; } $sql = "SELECT pf.product_id, fv.value FROM shop_product_features pf\n JOIN shop_feature f ON pf.feature_id = f.id AND f.type = 'double'\n JOIN shop_feature_values_double fv ON pf.feature_value_id = fv.id WHERE pf.product_id IN (i:id)"; $data = $product_model->query($sql, array('id' => $product_ids)); foreach ($data as $row) { $products[$row['product_id']]['features'][] = $row['value']; } $sql = "SELECT pf.product_id, fv.value FROM shop_product_features pf\n JOIN shop_feature f ON pf.feature_id = f.id AND f.type = 'text'\n JOIN shop_feature_values_text fv ON pf.feature_value_id = fv.id WHERE pf.product_id IN (i:id)"; $data = $product_model->query($sql, array('id' => $product_ids)); foreach ($data as $row) { $products[$row['product_id']]['features'][] = $row['value']; } // get skus $sql = "SELECT * FROM shop_product_skus WHERE product_id IN (i:id)"; $data = $product_model->query($sql, array('id' => $product_ids)); foreach ($data as $row) { $products[$row['product_id']]['skus'][] = $row; } foreach ($products as $p) { $search->indexProduct($p, false); } $i += $limit; } } }
public function display() { $plugin_model = new shopPluginModel(); if (waRequest::param('payment_id') && is_array(waRequest::param('payment_id'))) { $methods = $plugin_model->getById(waRequest::param('payment_id')); } else { $methods = $plugin_model->listPlugins('payment'); } $shipping = $this->getSessionData('shipping'); if ($shipping) { $disabled = shopHelper::getDisabledMethods('payment', $shipping['id']); } else { $disabled = array(); } $currencies = wa('shop')->getConfig()->getCurrencies(); $selected = null; foreach ($methods as $key => $m) { $method_id = $m['id']; if (in_array($method_id, $disabled)) { unset($methods[$key]); continue; } $plugin = shopPayment::getPlugin($m['plugin'], $m['id']); $plugin_info = $plugin->info($m['plugin']); $methods[$key]['icon'] = $plugin_info['icon']; $custom_fields = $this->getCustomFields($method_id, $plugin); $custom_html = ''; foreach ($custom_fields as $c) { $custom_html .= '<div class="wa-field">' . $c . '</div>'; } $methods[$key]['custom_html'] = $custom_html; $allowed_currencies = $plugin->allowedCurrency(); if ($allowed_currencies !== true) { $allowed_currencies = (array) $allowed_currencies; if (!array_intersect($allowed_currencies, array_keys($currencies))) { $methods[$key]['error'] = sprintf(_w('Payment procedure cannot be processed because required currency %s is not defined in your store settings.'), implode(', ', $allowed_currencies)); } } if (!$selected && empty($methods[$key]['error'])) { $selected = $method_id; } } $view = wa()->getView(); $view->assign('checkout_payment_methods', $methods); $view->assign('payment_id', $this->getSessionData('payment', $selected)); $checkout_flow = new shopCheckoutFlowModel(); $step_number = shopCheckout::getStepNumber('payment'); // IF no errors $checkout_flow->add(array('step' => $step_number)); // ELSE // $checkout_flow->add(array( // 'step' => $step_number, // 'description' => ERROR MESSAGE HERE // )); }
public function execute() { $page = array(); if ($id = waRequest::param('page_id')) { $page = $this->getPageModel()->get($id); foreach ($page as $k => $v) { if ($k != 'content' && $k != 'title') { $page[$k] = htmlspecialchars($v); } } } if (!$page) { $this->getResponse()->setStatus(404); $this->getResponse()->setTitle('404. ' . _ws("Page not found")); $this->view->assign('error_code', 404); $this->view->assign('error_message', _ws("Page not found")); $this->setThemeTemplate('error.html'); } else { $breadcrumbs = array(); $parents = array(); $p = $page; $root_url = wa()->getAppUrl(null, true); $root_page_id = $p['id']; while ($p['parent_id']) { $p = $this->getPageModel()->select('id, parent_id, name, title, url, full_url')->where("id = ?", $p['parent_id'])->fetch(); $parents[] = $p; $breadcrumbs[] = array('name' => $p['name'], 'url' => $root_url . $p['full_url']); $root_page_id = $p['id']; } $this->view->assign('root_page_id', $root_page_id); if ($this->layout) { $this->layout->assign('root_page_id', $root_page_id); } $this->view->assign('page_parents', array_reverse($parents)); if ($this->layout && $breadcrumbs) { $this->layout->assign('breadcrumbs', array_reverse($breadcrumbs)); } $this->getResponse()->setTitle($page['title']); $this->getResponse()->setMeta(array('keywords' => isset($page['keywords']) ? $page['keywords'] : '', 'description' => isset($page['description']) ? $page['description'] : '')); $this->view->assign('page', $page); try { $this->view->assign('wa_theme_url', $this->getThemeUrl()); $page['content'] = $this->view->fetch('string:' . $page['content']); } catch (SmartyCompilerException $e) { $message = preg_replace('/"[a-z0-9]{32,}"/', " of content Site page with id {$page['id']}", $e->getMessage()); throw new SmartyCompilerException($message, $e->getCode()); } if ($this->layout) { $this->layout->assign('page_id', $page['id']); } $this->view->assign('page', $page); $this->setThemeTemplate('page.html'); } }
public function execute() { if (wa()->getEnv() == 'frontend' && ($currency = waRequest::get("currency"))) { if ($this->getConfig()->getCurrencies(array($currency))) { wa()->getStorage()->set('shop/currency', $currency); wa()->getStorage()->remove('shop/cart'); } $url = $this->getConfig()->getCurrentUrl(); $url = preg_replace('/[\\?&]currency=' . $currency . '/i', '', $url); $this->redirect($url); } // save referer // @todo: save keywords for referers from search if (wa()->getEnv() == 'frontend' && ($ref = waRequest::server('HTTP_REFERER'))) { // check $ref domain $ref_parts = parse_url($ref); if ($ref_parts['host'] != waRequest::server('HTTP_HOST')) { wa()->getStorage()->set('shop/referer', waRequest::server('HTTP_REFERER')); } } $this->view->assign('action', waRequest::param('action', 'default')); $this->setThemeTemplate('index.html'); /** * @event frontend_head * @return array[string]string $return[%plugin_id%] html output */ $this->view->assign('frontend_head', wa()->event('frontend_head')); /** * @event frontend_header * @return array[string]string $return[%plugin_id%] html output */ $this->view->assign('frontend_header', wa()->event('frontend_header')); if (!$this->view->getVars('frontend_nav')) { /** * @event frontend_nav * @return array[string]string $return[%plugin_id%] html output for navigation section */ $this->view->assign('frontend_nav', wa()->event('frontend_nav')); } /** * @event frontend_footer * @return array[string]string $return[%plugin_id%] html output */ $this->view->assign('frontend_footer', wa()->event('frontend_footer')); $this->view->assign('currencies', $this->getConfig()->getCurrencies()); // set globals $params = waRequest::param(); foreach ($params as $k => $v) { if (in_array($k, array('url', 'module', 'action', 'meta_keywords', 'meta_description', 'private', 'url_type', 'type_id', 'payment_id', 'shipping_id', 'currency', 'stock_id'))) { unset($params[$k]); } } $this->view->getHelper()->globals($params); }
private function renderTemplate($assign, $template) { $theme = waRequest::param('theme', 'default'); $theme_path = wa()->getDataPath('themes', true) . '/' . $theme; if (!file_exists($theme_path) || !file_exists($theme_path . '/theme.xml')) { $theme_path = wa()->getAppPath() . '/themes/' . $theme; } $view = wa()->getView(array('template_dir' => $theme_path)); $view->assign($assign); return $view->fetch($template); }
public function execute() { $app_id = waRequest::param(0); $params = waRequest::param(); if (empty($app_id) || isset($params['help'])) { print "Usage: php wa.php APP_ID[ -name APP_NAME][ -version APP_VERSION][ -frontend[ -themes]][ -plugins][ -cli][ -api[ API_VERSION]]\n"; } else { $app_path = wa()->getAppPath(null, $app_id); $this->create($app_id, $app_path, $params); } }
protected function getParameters() { $app_id = strtolower(waRequest::param(0)); $layout = strtolower(waRequest::param(1)); if (!wa()->appExists($app_id)) { $this->dieWithErrors(array('App ' . $app_id . ' does not exist')); } if (!preg_match('~^[a-z][a-z0-9_]*$~', $layout)) { $this->dieWithErrors(array('Incorrect layout name: ' . $layout)); } return array($app_id, $layout); }
public function execute() { $params = waRequest::request(); $params['result'] = true; $module_id = waRequest::param('module_id'); $result = waShipping::execCallback($params, $module_id); if (!empty($result['template'])) { $this->template = $result['template']; } $this->view->assign('params', $params); $this->view->assign('result', $result); }
public function execute() { $f = waRequest::param('f'); $fid = waRequest::param('fid'); $parent = waRequest::param('parent'); $css_class = waRequest::param('css_class'); $new_field = false; if (!$f instanceof waContactField) { $new_field = true; $f = new waContactStringField($fid, '', array('app_id' => 'shop')); } $prefix = 'options'; if ($parent) { $prefix .= '[' . $parent . '][fields]'; } static $ftypes = null; if ($ftypes === null) { $ftypes = array('NameSubfield' => _w('Text (input)'), 'Email' => _w('Text (input)'), 'Address' => _w('Address'), 'Text' => _w('Text (textarea)'), 'String' => _w('Text (input)'), 'Select' => _w('Select'), 'Phone' => _w('Text (input)'), 'IM' => _w('Text (input)'), 'Url' => _w('Text (input)'), 'Date' => _w('Date'), 'Composite' => _w('Composite field group'), 'Checkbox' => _w('Checkbox')); } $form = waContactForm::loadConfig(array('_default_value' => $f), array('namespace' => "{$prefix}[{$fid}]")); // Get default value $default_value = null; if (!$new_field && $f->getParameter('_disabled')) { $settings = wa('shop')->getConfig()->getCheckoutSettings(); if (!isset($settings['contactinfo'])) { $settings = wa('shop')->getConfig()->getCheckoutSettings(true); } $fields_config = ifset($settings['contactinfo']['fields'], array()); if ($parent) { if (!empty($fields_config[$parent]['fields'][$fid]['hidden'])) { $default_value = ifset($fields_config[$parent]['fields'][$fid]['value']); } } else { if (!empty($fields_config[$fid]['hidden'])) { $default_value = ifset($fields_config[$fid]['value']); } } if ($default_value !== null) { $form->setValue('_default_value', $default_value); } } $this->view->assign('f', $f); $this->view->assign('fid', $fid); $this->view->assign('form', $form); $this->view->assign('parent', $parent); $this->view->assign('prefix', $prefix); $this->view->assign('uniqid', 'f' . uniqid()); $this->view->assign('new_field', $new_field); $this->view->assign('tr_classes', $css_class); $this->view->assign('default_value', $default_value); $this->view->assign('ftypes', $ftypes); }
public function execute() { $count = $this->getConfig()->getOption('photos_per_page'); $padding_count = 2; $direction = waRequest::get('direction', 1, waRequest::TYPE_INT); $album = waRequest::param('album'); $hash = waRequest::param('hash'); $url = waRequest::param('url'); $album = waRequest::param('album'); if (!$url) { throw new waException(_w('Page not found', 404)); } if ($album && $album['status'] <= 0) { $album['full_url'] = photosCollection::frontendAlbumHashToUrl($hash); } $photo_model = new photosPhotoModel(); $photo = $photo_model->getByField('url', $url); $real_count = $count; if ($photo) { $c = new photosCollection($hash); $offset = $c->getPhotoOffset($photo); if ($direction > 0) { $offset += 1; // next photos } else { $offset -= $real_count; // prev photos if ($offset < 0) { $real_count += $offset; $offset = 0; } } $photo_stream = $c->getPhotos('*,thumb,thumb_crop,tags', $offset, $real_count); $photo_stream = photosCollection::extendPhotos($photo_stream); foreach ($photo_stream as &$item) { $item['thumb_custom'] = array('url' => photosPhoto::getPhotoUrlTemplate($item)); $item['full_url'] = photosFrontendPhoto::getLink(array('url' => $item['url']), $album ? $album : $hash); } unset($item); $real_count = count($photo_stream); if ($real_count < $count) { if ($direction > 0) { $photo_stream = array_merge($photo_stream, array_pad(array(), $padding_count, null)); } else { $photo_stream = array_merge(array_pad(array(), $padding_count, null), $photo_stream); } } $renderer = new photosPhotoHtmlRenderer($this->getTheme()); echo $renderer->getPhotoStream($photo_stream, null); } exit; }
public function execute() { $om = new shopOrderModel(); $encoded_order_id = waRequest::param('id'); $code = waRequest::param('code'); $order_id = shopHelper::decodeOrderId($encoded_order_id); if (!$order_id) { // fall back to non-encoded id $order_id = $encoded_order_id; $encoded_order_id = shopHelper::encodeOrderId($order_id); } $order = $om->getOrder($order_id); if (!$order) { throw new waException(_w('Order not found'), 404); } elseif (!$this->isAuth($order, $code)) { if ($code && $order_id != substr($code, 16, -16)) { throw new waException(_w('Order not found'), 404); } else { $redirect = array('id' => $order_id); if (!empty($code)) { $redirect['code'] = $code; } $url = $code ? '/frontend/myOrderByCode' : '/frontend/myOrder'; $this->redirect(wa()->getRouteUrl($url, $redirect)); } } elseif ($code && $order['contact_id'] == wa()->getUser()->getId()) { $redirect = array('id' => $order_id, 'form_type' => waRequest::param('form_type'), 'form_id' => waRequest::param('form_id')); $this->redirect(wa()->getRouteUrl('/frontend/myOrderPrintform', $redirect)); } $order_params_model = new shopOrderParamsModel(); $order['params'] = $order_params_model->get($order['id']); $order['id_str'] = $encoded_order_id; switch (waRequest::param('form_type')) { case 'payment': if (empty($order['params']['payment_id']) || !($payment = shopPayment::getPlugin(null, $order['params']['payment_id']))) { throw new waException(_w('Printform not found'), 404); } $form_id = waRequest::param('form_id'); $params = null; if (strpos($form_id, '.')) { $form = explode('.', $form_id, 2); $form_id = array_shift($form); $params = array_shift($form); } print $payment->displayPrintForm(ifempty($form_id, $payment->getId()), shopPayment::getOrderData($order, $payment), intval($params)); exit; break; default: throw new waException(_w('Printform not found'), 404); break; } }
protected function afterAuth() { if (waRequest::get('return')) { $url = $this->getStorage()->get('auth_referer'); if ($url) { $this->getStorage()->del('auth_referer'); $this->redirect($url); } } $this->getStorage()->del('auth_referer'); $url = waRequest::param('secure') ? $this->getConfig()->getCurrentUrl() : wa()->getRouteUrl('/frontend/my'); $this->redirect($url); }
public function pages($parent_id = 0, $with_params = true) { if (is_bool($parent_id)) { $with_params = $parent_id; $parent_id = 0; } try { $domain_model = new siteDomainModel(); $domain = $domain_model->getByName(waSystem::getInstance()->getRouting()->getDomain(null, true)); $page_model = new sitePageModel(); $exclude_ids = waRequest::param('_exclude'); $sql = "SELECT id, parent_id, name, title, full_url, url, create_datetime, update_datetime FROM " . $page_model->getTableName() . ' WHERE domain_id = i:domain_id AND route = s:route AND status = 1' . ($exclude_ids ? " AND id NOT IN (:ids)" : '') . ' ORDER BY sort'; $pages = $page_model->query($sql, array('domain_id' => $domain['id'], 'ids' => $exclude_ids, 'route' => wa()->getRouting()->getRoute('url')))->fetchAll('id'); if ($with_params) { $page_params_model = new sitePageParamsModel(); $data = $page_params_model->getByField('page_id', array_keys($pages), true); foreach ($data as $row) { $pages[$row['page_id']][$row['name']] = $row['value']; } } // get current rool url $url = $this->wa->getAppUrl(null, true); foreach ($pages as &$page) { $page['url'] = $url . $page['full_url']; if (!isset($page['title']) || !$page['title']) { $page['title'] = $page['name']; } foreach ($page as $k => $v) { if ($k != 'content') { $page[$k] = htmlspecialchars($v); } } } unset($page); // make tree foreach ($pages as $page_id => $page) { if ($page['parent_id'] && isset($pages[$page['parent_id']])) { $pages[$page['parent_id']]['childs'][] =& $pages[$page_id]; } } foreach ($pages as $page_id => $page) { if ($page['parent_id']) { unset($pages[$page_id]); } } return $pages; } catch (Exception $e) { return array(); } }
public function execute() { $plugin_id = waRequest::param('plugin_id', 0, 'int'); if (!$plugin_id) { throw new waException('Plugin not found', 404); } $plugin = shopShipping::getPlugin(null, $plugin_id); $action = waRequest::param('action_id'); $method = $action . 'Action'; if (!$action || !method_exists($plugin, $method)) { throw new waException('Action not found', 404); } $plugin->{$method}(); }
public function execute() { $url = waRequest::param('url'); $domain = waRequest::server('HTTP_HOST'); $model = new waModel(); // $main_domain = $model->query("SELECT value FROM wa_app_settings WHERE app_id = 'webasyst' AND name = 'url'")->fetchField(); $app_settings_model = new waAppSettingsModel(); $main_domain = trim(str_replace(array('https', 'http', '://'), '', $app_settings_model->get('webasyst', 'url')), "/"); $data = $model->query("\nSELECT\n shop_deliveryshop_city_description.*\n, shop_deliveryshop_city.city\n, shop_deliveryshop_city.region\nFROM\n shop_deliveryshop_city_description\nLEFT JOIN\n shop_deliveryshop_city ON shop_deliveryshop_city_description.cityCode = shop_deliveryshop_city.cityCode\nLEFT JOIN\n wa_region ON wa_region.code = shop_deliveryshop_city.region AND wa_region.country_iso3='rus'\nWHERE\n (url = '{$url}' OR city = '{$url}')\nAND\n domain IN ('{$domain}', '{$main_domain}')\nLIMIT 1\n ")->fetchAssoc(); // Уменьшаем стоимость доставки на сумму указанную в настройках плагина $delivery_compensation = $model->query("SELECT price FROM shop_deliveryshop_delivery WHERE domain = '" . $domain . "'")->fetchField(); $delivery_compensation = intval($delivery_compensation); $delivery_price = intval($data['delivery_price']); $courier_price = intval($data['courier_price']); if ($delivery_price > $delivery_compensation) { $data['delivery_price'] = (int) (($delivery_price - $delivery_compensation) / 50) * 50; //Уменьшаем до ближайшего полтинника } else { $data['delivery_price'] = 0; } if ($courier_price > $delivery_compensation) { $data['courier_price'] = (int) (($courier_price - $delivery_compensation) / 50) * 50; //Уменьшаем до ближайшего полтинника } else { $data['courier_price'] = 0; } foreach (array('meta_title' => $main_domain, 'meta_description' => '', 'meta_keywords' => '', 'delivery_time' => '', 'courier_time' => '') as $key => $value) { $data[$key] = isset($data[$key]) ? $data[$key] : $value; } wa()->getResponse()->setTitle($data['meta_title']); wa()->getResponse()->setMeta('description', $data['meta_description']); wa()->getResponse()->setMeta('keywords', $data['meta_keywords']); $city_code = isset($data['cityCode']) ? $data['cityCode'] : 0; $pvz = $model->query("\nSELECT\n shop_deliveryshop_pvz.*\nFROM\n shop_deliveryshop_pvz\nWHERE\n cityCode = {$city_code}\nAND\n status = 'completed'\nAND\n (domain IN ('{$domain}', '{$main_domain}') OR domain IS NULL)\n")->fetchAll(); //$site_model = new siteDomainModel(); //$domain_id = $site_model->getByName($domain); $domain_id = $model->query("SELECT id FROM site_domain WHERE name = '" . $domain . "'")->fetchField(); $template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $domain_id . '.html', false, 'shop', true); if (!file_exists($template_path)) { $template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', false, 'shop', true); } if (!file_exists($template_path)) { $template_path = wa()->getAppPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', 'shop'); } $this->view->assign('data', $data); $this->view->assign('pvz', $pvz); $this->view->assign('page', array('id' => null, 'name' => '', 'content' => $this->view->fetch($template_path))); $this->setThemeTemplate('page.html'); waSystem::popActivePlugin(); }