private function displayEditPage() { if ($this->requestAction() == 'add_new_template') { // add new template $template = false; $templatesModel = new TemplatesModel(); $item = $templatesModel->newItem(); $html = $templatesModel->getHTML(); $css = $templatesModel->getCSS(); $header = $templatesModel->getHeader(); $footer = $templatesModel->getFooter(); $functions = $templatesModel->getFunctions(); } else { // edit template $template = urldecode($_REQUEST['template']); $templatesModel = new TemplatesModel($template); $item = $templatesModel->getItem(); $html = $templatesModel->getHTML(); $css = $templatesModel->getCSS(); $header = $templatesModel->getHeader(); $footer = $templatesModel->getFooter(); $functions = $templatesModel->getFunctions(); } // init template - and run syntax check $templatesModel->initTemplate(true); // remove template header from stylesheet if (preg_match('/^\\/\\*.*^\\*\\//uUsm', $css, $matches)) { $css = str_replace($matches[0], '', $css); } // check for CDATA tag in html, header and footer if (strpos($html, '<![CDATA[') > 0) { $this->showMessage("Warning: Your template HTML code contains CDATA tags which can break the listing process. You should remove them as they don't fullfill any purpose in an eBay listing anyway.", 1); } if (strpos($header, '<![CDATA[') > 0) { $this->showMessage("Warning: Your template header contains CDATA tags which can break the listing process. You should remove them as they don't fullfill any purpose in an eBay listing anyway.", 1); } if (strpos($footer, '<![CDATA[') > 0) { $this->showMessage("Warning: Your template footer contains CDATA tags which can break the listing process. You should remove them as they don't fullfill any purpose in an eBay listing anyway.", 1); } $prepared_listings = WPLE_ListingQueryHelper::countItemsUsingTemplate($template, 'prepared'); $verified_listings = WPLE_ListingQueryHelper::countItemsUsingTemplate($template, 'verified'); $published_listings = WPLE_ListingQueryHelper::countItemsUsingTemplate($template, 'published'); // this turned out to be to ressource intensive with 10k listings: // $prepared_listings = WPLE_ListingQueryHelper::getAllPreparedWithTemplate( $template ); // $verified_listings = WPLE_ListingQueryHelper::getAllVerifiedWithTemplate( $template ); // $published_listings = WPLE_ListingQueryHelper::getAllPublishedWithTemplate( $template ); $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'item' => $item, 'html' => $html, 'css' => $css, 'header' => $header, 'footer' => $footer, 'functions' => $functions, 'template_location' => $item['template_path'], 'add_new_template' => $this->requestAction() == 'add_new_template' ? true : false, 'tpl_fields' => $templatesModel->fields, 'prepared_listings_count' => $prepared_listings, 'verified_listings_count' => $verified_listings, 'published_listings_count' => $published_listings, 'disable_wysiwyg_editor' => self::getOption('disable_wysiwyg_editor', 0), 'form_action' => 'admin.php?page=' . self::ParentMenuId . '-templates'); $this->display('templates_edit_page', $aData); }