function actionIndex($params = '') { $objSearch = new SearchModel(); $searchQuery = !empty($params['searchQuery']) ? $params['searchQuery'] : ''; $searchOptions = array(); $searchResults = false; // load templates $objLayout = new LayoutModel(); $objTemplate = new TemplatesModel(); $layoutInfo = $objLayout->loadLayout(); $template = $objTemplate->loadTemplateFromKeyname('search'); // doing search? if (!empty($searchQuery)) { // add search options if (!empty($params['searchForType'])) { foreach ($params['searchForType'] as $typeSearch) { $searchOptions[] = array('type' => 'type', 'value' => $typeSearch); } } // do search $searchResults = $objSearch->performSearch($searchQuery, $searchOptions); } // assign to template $this->view->assign('searchQuery', $searchQuery); $this->view->assign('searchOptions', $searchOptions); $this->view->assign('searchResults', $searchResults); // render template $this->view->assign('content', $this->view->fetch('fromstring:' . $template['content'])); $this->view->assign('sidebar_left', $this->view->fetch('fromstring:' . $template['left_sidebar'])); $this->view->assign('sidebar_right', $this->view->fetch('fromstring:' . $template['right_sidebar'])); $this->view->assign('layout', $this->view->fetch('fromstring:' . $layoutInfo['code'])); $this->finish(); }
/** * Smarty {form} function plugin * * Type: function<br> * Name: form<br> * Purpose: generates form from database<br> * @author Nathan Gardner <*****@*****.**> */ function smarty_function_form($localparams, &$smarty) { global $params; if (!empty($localparams['identifier'])) { $objForm = new FormModel(); $objAuth = Authentication::getInstance(); $objTemplate = new TemplatesModel(); $objUser = new UserModel($objAuth->user_id); $userInfo = $objUser->getInfo(); $form_id = $objForm->getFormId($localparams['identifier']); if ($form_id) { $formInfo = $objForm->loadForm($form_id); $templateInfo = $objTemplate->loadTemplateFromKeyname('form'); // assign values if already submitted if (!empty($params['formSubmit']['fields']) && !empty($formInfo['fields'])) { foreach ($formInfo['fields'] as &$formField) { foreach ($params['formSubmit']['fields'] as $submittedId => $submittedValue) { if ($formField['id'] == $submittedId) { if ($formField['type'] == 'checkbox' || $formField['type'] == 'radio') { $formField['checked'] = 'checked'; } else { $formField['value'] = $submittedValue; } break; } } } } // assign error flag and message if invalid if (!empty($params['formErrors']) && !empty($formInfo['fields'])) { foreach ($params['formErrors'] as $formError) { foreach ($formInfo['fields'] as &$formField) { if ($formError['field_id'] == $formField['id']) { $formField['hasError'] = true; $formField['errorMsg'] = $formError['errorMsg']; break; } } } } // assign var to template if (!empty($params['formSubmitted'])) { $smarty->assign('formSubmitted', 1); } if (!empty($params['formErrors'])) { $smarty->assign('formErrors', $params['formErrors']); } $smarty->assign('formInfo', $formInfo); $output = $smarty->fetch('fromstring:' . $templateInfo['content']); } else { return 'Unknown form identifier'; } } else { return 'Must pass an identifier'; } return $output; }
function actionEditTemplate($params = '') { $objTemplates = new TemplatesModel(); $template_id = !empty($params['template_id']) ? intval($params['template_id']) : false; $group = !empty($params['group']) ? $params['group'] : false; if (!empty($params['dosave'])) { $saveData = array(); if (!empty($params['template_id'])) { $saveData = array(); $saveData['content'] = !empty($params['template_content']) ? $params['template_content'] : ''; $saveData['left_sidebar'] = !empty($params['template_left_sidebar']) ? $params['template_left_sidebar'] : ''; $saveData['right_sidebar'] = !empty($params['template_right_sidebar']) ? $params['template_right_sidebar'] : ''; $saveData['id'] = intval($params['template_id']); $template_id = $objTemplates->saveTemplate($saveData); if (!empty($params['ajaxsave'])) { $templateInfo = $objTemplates->loadTemplate($template_id); echo json_encode($templateInfo); return; } $this->messages[] = array('type' => 'success', 'message' => 'Template has been saved.'); } else { $this->messages[] = array('type' => 'Error', 'message' => 'Unknown template to save.'); } if ($params['submit'] == 'Save and Close') { $this->actionTemplates(array('group' => $group)); return; } } if (!empty($template_id)) { $templateInfo = $objTemplates->loadTemplate($template_id); $this->view->assign('templateInfo', $templateInfo); } $this->view->assign('group', $group); $this->view->assign('content', $this->view->fetch('tpl/templates/template.tpl')); $this->view->assign('messages', $this->messages); $this->finish(); }
function column_template($item) { $template_id = basename($item['template']); $template_name = TemplatesModel::getNameFromCache($template_id); if (!$template_name) { $template_name = '<span style="color:red;">' . __('Template missing', 'wplister') . '!</span>'; if ($template_id) { $template_name .= ' (' . $template_id . ')'; } return $template_name; } $edit_url = "admin.php?page=wplister-templates&action=edit"; $edit_url = add_query_arg('template', $item['template'], $edit_url); $edit_url = add_query_arg('return_to', 'listings', $edit_url); if (isset($_REQUEST['s'])) { $edit_url = add_query_arg('s', $_REQUEST['s'], $edit_url); } if (isset($_REQUEST['listing_status'])) { $edit_url = add_query_arg('listing_status', $_REQUEST['listing_status'], $edit_url); } return sprintf('<a href="%1$s" title="%2$s">%3$s</a>', $edit_url, __('Edit', 'wplister'), $template_name); }
/** ************************************************************************ * REQUIRED! This is where you prepare your data for display. This method will * usually be used to query the database, sort and filter the data, and generally * get it ready to be displayed. At a minimum, we should set $this->items and * $this->set_pagination_args(), although the following properties and methods * are frequently interacted with here... * * @uses $this->_column_headers * @uses $this->items * @uses $this->get_columns() * @uses $this->get_sortable_columns() * @uses $this->get_pagenum() * @uses $this->set_pagination_args() **************************************************************************/ function prepare_items() { // init model $templatesModel = new TemplatesModel(); // get all items $this->db_items = $templatesModel->getAll(); /** * First, lets decide how many records per page to show */ $per_page = $this->get_items_per_page('templates_per_page', 20); $data = $this->db_items; /** * REQUIRED. Finally, we build an array to be used by the class for column * headers. The $this->_column_headers property takes an array which contains * 3 other arrays. One for all columns, one for hidden columns, and one * for sortable columns. */ // $this->_column_headers = array($columns, $hidden, $sortable); $this->_column_headers = $this->get_column_info(); /** * Optional. You can handle your bulk actions however you see fit. In this * case, we'll handle them within our package just to keep things clean. */ $this->process_bulk_action(); /** * This checks for sorting input and sorts the data in our array accordingly. * */ function usort_reorder($a, $b) { $orderby = !empty($_REQUEST['orderby']) ? $_REQUEST['orderby'] : 'template_name'; //If no sort, default to title $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc'; //If no order, default to asc $result = strcmp($a[$orderby], $b[$orderby]); //Determine sort order return $order === 'asc' ? $result : -$result; //Send final sort direction to usort } usort($data, 'usort_reorder'); /** * REQUIRED for pagination. Let's figure out what page the user is currently * looking at. We'll need this later, so you should always include it in * your own package classes. */ $current_page = $this->get_pagenum(); /** * REQUIRED for pagination. Let's check how many items are in our data array. * In real-world use, this would be the total number of items in your database, * without filtering. We'll need this later, so you should always include it * in your own package classes. */ $total_items = count($data); /** * The WP_List_Table class does not handle pagination for us, so we need * to ensure that the data is trimmed to only the current page. We can use * array_slice() to */ $data = array_slice($data, ($current_page - 1) * $per_page, $per_page); /** * REQUIRED. Now we can add our *sorted* data to the items property, where * it can be used by the rest of the class. */ $this->items = $data; /** * REQUIRED. We also have to register our pagination options & calculations. */ $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page))); }
function column_template($item) { $template_id = basename($item['details']->template); $template_name = TemplatesModel::getNameFromCache($template_id); return sprintf('<a href="admin.php?page=wplister-templates&action=edit&template=%1$s" title="%2$s">%3$s</a>', $template_id, __('Edit', 'wplister'), $template_name); }
public function checkSetup($page = false) { global $pagenow; // check if safe mode is enabled $this->isPhpSafeMode(); // check if incomatible plugins are active $this->checkPlugins(); // check if a recent version of WooCommerce is installed $this->checkWooCommerce(); // check if cURL is loaded if (!$this->isCurlLoaded()) { return false; } // check for windows server // if ( $this->isWindowsServer() ) return false; $this->isWindowsServer($page); // create folders if neccessary if ($this->checkFolders()) { return false; } // check for updates $this->checkForUpdates(); // check if cron is working properly $this->checkCron(); // check if any sites need to be refreshed $this->checkSites(); // check database after migration // $this->checkDatabase(); // $this->checkDbForInvalidAccounts(); // check for multisite installation // if ( $this->checkMultisite() ) return false; $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : false; // setup wizard // if ( self::getOption('ebay_token') == '' ) { if ('1' == self::getOption('setup_next_step') && $current_tab != 'accounts') { $msg1 = __('You have not linked WP-Lister to your eBay account yet.', 'wplister'); $msg2 = __('To complete the setup procedure go to %s and follow the instructions.', 'wplister'); $accounts_page = get_option('wplister_enable_accounts_page') ? 'wplister-settings-accounts' : 'wplister-settings&tab=accounts'; $link = sprintf('<a href="admin.php?page=%s">%s</a>', $accounts_page, __('Account Settings', 'wplister')); $msg2 = sprintf($msg2, $link); $msg = "<b>{$msg1}</b></p><p>{$msg2}"; wple_show_message($msg, 'info'); } elseif ('2' == self::getOption('setup_next_step')) { $title = __('Setup - Step 2', 'wplister'); $msg1 = __('Before creating your first profile, we need to download certain information which are specific to the eBay site you selected.', 'wplister'); $msg2 = __('This includes shipping options, payment methods, your custom store categories as well as the whole eBay category tree, which might take a while.', 'wplister'); // old button // $button = '<a href="#" id="btn_update_ebay_data" onclick="return false;" class="button-primary">'.__('Update eBay details','wplister').'</a>'; // new button - use site_id of default (first) account $account = WPLE()->accounts[get_option('wplister_default_account_id')]; $button = '<a href="#" data-site_id="' . $account->site_id . '" data-account_id="' . $account->id . '" class="btn_update_ebay_data_for_site button-primary">' . __('Refresh eBay details', 'wplister') . '</a>'; $msg = "<p><b>{$title}</b></p><p>{$msg1}</p><p>{$msg2}</p>"; $msg .= $button; wple_show_message($msg, 'info'); // // remember when WP-Lister was connected to an eBay account for the first time // update_option( 'ignore_orders_before_ts', time() ); } elseif ('3' == self::getOption('setup_next_step')) { $tm = new TemplatesModel(); $templates = $tm->getAll(); if (sizeof($templates) > 0) { self::updateOption('setup_next_step', '4'); } else { $title = __('Setup - Step 3', 'wplister'); $msg1 = __('Create a default listing template.', 'wplister'); $msg2 = __('To create your first listing template click on %s.', 'wplister') . '<br>'; if (@$_GET['action'] == 'add_new_template') { $msg2 = __('Replace the default text according to your requirements and save your template to continue.', 'wplister'); } $link = '<a href="admin.php?page=wplister-templates&action=add_new_template">' . __('New Template', 'wplister') . '</a>'; $msg2 = sprintf($msg2, $link); $msg = "<p><b>{$title}</b></p><p><b>{$msg1}</b></p><p>{$msg2}</p>"; wple_show_message($msg, 'info'); } } elseif ('4' == self::getOption('setup_next_step')) { $pm = new ProfilesModel(); $profiles = $pm->getAll(); if (sizeof($profiles) > 0) { self::updateOption('setup_next_step', '0'); } else { $title = __('Setup - Step 4', 'wplister'); $msg1 = __('The final step: create your first listing profile.', 'wplister'); $msg2 = __('Click on %s and start defining your listing options.<br>After saving your profile, visit your Products page and select the products to list on eBay.', 'wplister'); $link = '<a href="admin.php?page=wplister-profiles&action=add_new_profile">' . __('New Profile', 'wplister') . '</a>'; $msg2 = sprintf($msg2, $link); $msg = "<b>{$msg1}</b></p><p>{$msg2}"; wple_show_message($msg, 'info'); } } elseif ('5' == self::getOption('setup_next_step')) { $title = __('Setup is complete.', 'wplister'); $msg1 = __('You are ready now to list your first items.', 'wplister'); $msg2 = __('Visit your Products page, select a few items and select "List on eBay" from the bulk actions menu.', 'wplister'); $msg = "<b>{$msg1}</b></p><p>{$msg2}"; wple_show_message($msg, 'info'); update_option('wplister_setup_next_step', '0'); } // db upgrade WPLE_UpgradeHelper::upgradeDB(); // check token expiration date self::checkToken(); // check if all db tables exist self::checkDatabaseTables($page); // // fetch user details if not done yet // if ( ( self::getOption('ebay_token') != '' ) && ( ! self::getOption('ebay_user') ) ) { // $this->initEC(); // $UserID = $this->EC->GetUser(); // $this->EC->closeEbay(); // } // // fetch user details if not done yet // if ( ( self::getOption('ebay_token') != '' ) && ( ! self::getOption('ebay_seller_profiles_enabled') ) ) { // $this->initEC(); // $this->EC->GetUserPreferences(); // $this->EC->closeEbay(); // } // // fetch token expiration date if not done yet // if ( ( self::getOption('ebay_token') != '' ) && ( ! self::getOption('ebay_token_expirationtime') ) ) { // $this->initEC(); // $expdate = $this->EC->GetTokenStatus(); // $this->EC->closeEbay(); // } }
public function getTemplatesList() { $templatesModel = new TemplatesModel(); $templates = $templatesModel->getAll(); return $templates; }
public function displayEditPage() { // get item $item = ListingsModel::getItem($_REQUEST['auction']); // unserialize details $this->initEC($item['account_id']); // $item['details'] = maybe_unserialize( $item['details'] ); // echo "<pre>";print_r($item);echo"</pre>";die(); // get ebay data $countries = EbayShippingModel::getEbayCountries(); // $template_files = $this->getTemplatesList(); $templatesModel = new TemplatesModel(); $templates = $templatesModel->getAll(); $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'item' => $item, 'countries' => $countries, 'template_files' => $templates, 'form_action' => 'admin.php?page=' . self::ParentMenuId . (isset($_REQUEST['paged']) ? '&paged=' . $_REQUEST['paged'] : '')); $this->display('listings_edit_page', array_merge($aData, $item)); }
function sendWebcastRegistrationAdmin($orderInfo) { $objEmailer = new Emailer(); $objLayout = new LayoutModel(); $objTemplate = new TemplatesModel(); $objSettings = Settings::getInstance(); $adminEmail = $objSettings->getEntry('admin', 'admin-email'); $layoutInfo = $objLayout->loadLayout(28); $template = $objTemplate->loadTemplateFromKeyname('email-webcastregistration-admin'); $this->view->assign('orderInfo', $orderInfo); $objEmailer->setFrom('*****@*****.**'); $objEmailer->addTo($adminEmail); $objEmailer->setSubject('WEBCAST PURCHASE'); // render template $this->view->assign('content', $this->view->fetch('fromstring:' . $template['content'])); $this->view->assign('sidebar_left', $this->view->fetch('fromstring:' . $template['left_sidebar'])); $this->view->assign('sidebar_right', $this->view->fetch('fromstring:' . $template['right_sidebar'])); $objEmailer->setBody($this->view->fetch('fromstring:' . $layoutInfo['code']), true); $objEmailer->sendMail(); return true; }
public function applyProfileToItem($profile, $item, $update_title = true) { global $wpdb; // get item data $id = $item['id']; $post_id = $item['post_id']; $status = WPLE_ListingQueryHelper::getStatus($id); $ebay_id = self::getEbayIDFromID($id); $post_title = get_the_title($item['post_id']); WPLE()->logger->info("applyProfileToItem() - listing_id: {$id} / post_id: {$post_id}"); // WPLE()->logger->callStack( debug_backtrace() ); // skip ended auctions - or not, if you want to relist them... // if ( $status == 'ended' ) return; // use parent title for single (split) variation if (ProductWrapper::isSingleVariation($post_id)) { $parent_id = ProductWrapper::getVariationParent($post_id); $post_title = get_the_title($parent_id); // check if parent product has a custom eBay title set if (get_post_meta($parent_id, '_ebay_title', true)) { $post_title = trim(get_post_meta($parent_id, '_ebay_title', true)); } // get variations $variations = ProductWrapper::getVariations($parent_id); // find this variation in all variations of this parent foreach ($variations as $var) { if ($var['post_id'] == $post_id) { // append attribute values to title $post_title = self::processSingleVariationTitle($post_title, $var['variation_attributes']); } } } // gather profile data $data = array(); $data['profile_id'] = $profile['profile_id']; $data['account_id'] = $profile['account_id']; $data['site_id'] = $profile['site_id']; $data['auction_type'] = $profile['type']; $data['listing_duration'] = $profile['listing_duration']; $data['template'] = $profile['details']['template']; $data['quantity'] = $profile['details']['quantity']; $data['date_created'] = date('Y-m-d H:i:s'); $data['profile_data'] = self::encodeObject($profile); // echo "<pre>";print_r($data);echo"</pre>";die(); // add prefix and suffix to product title if ($update_title) { // append space to prefix, prepend space to suffix // TODO: make this an option $title_prefix = trim($profile['details']['title_prefix']) . ' '; $title_suffix = ' ' . trim($profile['details']['title_suffix']); // custom post meta fields override profile values if (get_post_meta($post_id, 'ebay_title_prefix', true)) { $title_prefix = trim(get_post_meta($post_id, 'ebay_title_prefix', true)) . ' '; } if (get_post_meta($post_id, 'ebay_title_suffix', true)) { $title_prefix = trim(get_post_meta($post_id, 'ebay_title_suffix', true)) . ' '; } $data['auction_title'] = trim($title_prefix . $post_title . $title_suffix); // custom post meta title override if (get_post_meta($post_id, '_ebay_title', true)) { $data['auction_title'] = trim(get_post_meta($post_id, '_ebay_title', true)); } elseif (get_post_meta($post_id, 'ebay_title', true)) { $data['auction_title'] = trim(get_post_meta($post_id, 'ebay_title', true)); } // process attribute shortcodes in title - like [[attribute_Brand]] if (strpos($data['auction_title'], ']]') > 0) { $templatesModel = new TemplatesModel(); WPLE()->logger->info('auction_title before processing: ' . $data['auction_title'] . ''); $data['auction_title'] = $templatesModel->processAllTextShortcodes($item['post_id'], $data['auction_title'], 80); } WPLE()->logger->info('auction_title after processing : ' . $data['auction_title'] . ''); // trim title to 255 characters - longer titles will break $wpdb->update() if (strlen($data['auction_title']) > 255) { $data['auction_title'] = self::mb_substr($data['auction_title'], 0, 80); // eBay titles can not be longer than 80 characters } } // apply profile price $data['price'] = ProductWrapper::getPrice($post_id); $data['price'] = self::applyProfilePrice($data['price'], $profile['details']['start_price']); // fetch product stock if no quantity set in profile - and apply max_quantity limit if (intval($data['quantity']) == 0) { $max = isset($profile['details']['max_quantity']) && intval($profile['details']['max_quantity']) > 0 ? $profile['details']['max_quantity'] : PHP_INT_MAX; $data['quantity'] = min($max, intval(ProductWrapper::getStock($post_id))); // update listing quantity properly - using setListingQuantity() which regards current quantity_sold self::setListingQuantity($post_id, $data['quantity']); unset($data['quantity']); } // default new status is 'prepared' $data['status'] = 'prepared'; // except for already published items where it is 'changed' if (intval($ebay_id) > 0) { $data['status'] = 'changed'; } // ended items stay 'ended' and sold items stay sold if ($status == 'ended') { $data['status'] = 'ended'; } if ($status == 'sold') { $data['status'] = 'sold'; } if ($status == 'archived') { $data['status'] = 'archived'; } // locked items simply keep their status if (@$item['locked']) { $data['status'] = $status; } // but if apply_changes_to_all_locked checkbox is ticked, even locked published items will be marked as 'changed' if (@$item['locked'] && $status == 'published' && isset($_POST['wpl_e2e_apply_changes_to_all_locked'])) { $data['status'] = 'changed'; } // except for selected items which shouldn't be locked in the first place if ($status == 'selected') { $data['status'] = 'prepared'; } // and reselected items which have already been 'ended' if ($status == 'reselected') { $data['status'] = 'ended'; } // and items which have already been 'changed' and now had a new profile applied if ($status == 'changed_profile') { $data['status'] = 'changed'; } // debug if ($status != $data['status']) { WPLE()->logger->info('applyProfileToItem(' . $id . ') old status: ' . $status); WPLE()->logger->info('applyProfileToItem(' . $id . ') new status: ' . $data['status']); } // update auctions table $wpdb->update($this->tablename, $data, array('id' => $id)); // WPLE()->logger->info('updating listing ID '.$id); // WPLE()->logger->info('data: '.print_r($data,1)); // WPLE()->logger->info('sql: '.$wpdb->last_query); // WPLE()->logger->info('error: '.$wpdb->last_error); }
function ajax_wpl_duplicate_template() { // get template $template_id = urldecode($this->getValueFromPost('template_id')); if (!$template_id) { die('template not found.'); } $templatesModel = new TemplatesModel($template_id); $item = $templatesModel->getItem(); // echo "<pre>";print_r($templatesModel);echo"</pre>";die(); // set templates root folder $upload_dir = wp_upload_dir(); $templates_dir = $upload_dir['basedir'] . '/wp-lister/templates/'; // check folder name $dirname = strtolower(sanitize_file_name($this->getValueFromPost('template_name'))); if ($dirname == '') { echo "Could not create template. No template name was provided."; exit; } // tpl_dir is the full path to the duplicated template $tpl_dir = $templates_dir . $dirname; // src_tpl_dir is the full path to the original template $src_tpl_dir = $templates_dir . $template_id; // if folder exists, append '-1', '-2', .. '-99' if (is_dir($tpl_dir)) { for ($i = 1; $i < 100; $i++) { $new_tpl_dir = $tpl_dir . '-' . $i; if (!is_dir($new_tpl_dir)) { $tpl_dir = $new_tpl_dir; break; } } } // make new folder $result = @mkdir($tpl_dir); // handle errors if ($result === false) { echo "Could not create template folder: " . $tpl_dir; exit; } // destination files $file_html = $tpl_dir . '/template.html'; $file_css = $tpl_dir . '/style.css'; $file_header = $tpl_dir . '/header.php'; $file_footer = $tpl_dir . '/footer.php'; $file_functions = $tpl_dir . '/functions.php'; $file_config = $tpl_dir . '/config.json'; $tpl_html = $templatesModel->getHTML(); $tpl_css = $templatesModel->getCSS(); $tpl_header = $templatesModel->getHeader(); $tpl_footer = $templatesModel->getFooter(); $tpl_functions = $templatesModel->getFunctions(); $tpl_config = file_exists($src_tpl_dir . '/config.json') ? file_get_contents($src_tpl_dir . '/config.json') : false; $template_name = stripslashes($this->getValueFromPost('template_name')); $template_description = stripslashes($this->getValueFromPost('template_description')); $template_version = $item['template_version']; // add template header $header_css = "/* \n"; $header_css .= "Template: {$template_name}\n"; $header_css .= "Description: {$template_description}\n"; $header_css .= "Version: {$template_version}\n"; $header_css .= "*/\n"; $tpl_css = $header_css . $tpl_css; // update template files $result = file_put_contents($file_css, $tpl_css); $result = file_put_contents($file_functions, $tpl_functions); $result = file_put_contents($file_footer, $tpl_footer); $result = file_put_contents($file_header, $tpl_header); $result = file_put_contents($file_html, $tpl_html); if ($tpl_config) { $result = file_put_contents($file_config, $tpl_config); } // proper error handling if ($result === false) { echo "There was a problem duplicating your template."; } else { echo "success"; } exit; }
function column_template($item) { $template_id = basename($item['template']); $template_name = TemplatesModel::getNameFromCache($template_id); if (!$template_name) { $template_name = '<span style="color:red;">' . __('Template missing', 'wpla') . '!</span>'; if ($template_id) { $template_name .= ' (' . $template_id . ')'; } return $template_name; } return sprintf('<a href="admin.php?page=wpla-templates&action=edit&template=%1$s&return_to=listings" title="%2$s">%3$s</a>', $template_id, __('Edit', 'wpla'), $template_name); }
public function getPreviewHTML($template_id, $id = false) { // get item data if ($id) { $item = ListingsModel::getItem($id); } else { $item = WPLE_ListingQueryHelper::getItemForPreview(); } if (!$item) { return '<div style="text-align:center; margin-top:5em;">You need to prepare at least one listing in order to preview a listing template.</div>'; } // use latest post_content from product - moved to TemplatesModel // $post = get_post( $item['post_id'] ); // if ( ! empty($post->post_content) ) $item['post_content'] = $post->post_content; // load template if (!$template_id) { $template_id = $item['template']; } $template = new TemplatesModel($template_id); $html = $template->processItem($item, false, true); // return html return $html; }
function actionChangePassword($params = '') { $this->objAuthentication->requiresAccount(); $errorMsg = false; $changedpassword = false; if (!empty($params['changepassword'])) { $objUser = new UserModel(); if (!empty($params['orignal_pw']) && !empty($params['password']) && !empty($params['password2'])) { // verify old password $passwordMatch = $objUser->testPassword($this->objAuthentication->user_id, $params['orignal_pw']); if ($passwordMatch) { $objValidation = new Validator(); $objValidation->validatePassword($params['password']); $objValidation->passwordsMatch($params['password'], $params['password2']); if ($objValidation->hasError) { $errorMsg = $objValidation->getError(); if (is_array($errorMsg)) { $errorMsg = implode(', ', $errorMsg); } } else { $saveData = array(); $saveData['id'] = $this->objAuthentication->user_id; $saveData['password'] = $this->objAuthentication->encryptPassword($params['password']); $changedpassword = $objUser->save($saveData, 'users'); if ($changedpassword) { $objEmailer = new EmailSender(); $objEmailer->sendUserChangePassword($this->objAuthentication->user_id); } else { $errorMsg = 'Unable to change password.'; } } } else { $errorMsg = 'Current password incorrect.'; } } else { $errorMsg = 'Current password and new password are required.'; } } $objLayout = new LayoutModel(); $objTemplate = new TemplatesModel(); $layoutInfo = $objLayout->loadLayout(); $template = $objTemplate->loadTemplateFromKeyname('user-changepassword'); $this->view->assign('errorMsg', $errorMsg); $this->view->assign('changedpassword', $changedpassword); $this->view->assign('content', $this->view->fetch('fromstring:' . $template['content'])); $this->view->assign('sidebar_left', $this->view->fetch('fromstring:' . $template['left_sidebar'])); $this->view->assign('sidebar_right', $this->view->fetch('fromstring:' . $template['right_sidebar'])); $this->view->assign('layout', $this->view->fetch('fromstring:' . $layoutInfo['code'])); $this->finish(); }