opencart 2.3 version registry error - opencart

//init controllers:
ob_start();
require_once("index.php");
ob_get_contents();
ob_end_clean();
if(isset($_GET['import_id'])){
require_once('model/tool/profi_import.php');
$importClass = new ModelToolProfiImport($registry);
$import_id = (int)$_GET['import_id'];
$import_data = $importClass->getImport($import_id);
if(isset($_GET['part'])){
$parts = htmlspecialchars($_GET['part']);
}else{
$parts = '1_1';
}
$parts = explode("_",$parts);
$actual_part = $parts[0]-1;
$total_parts = $parts[1];
I have an like this import file.
But, 2.3 opencart version "Undefined variable: registry" give an error.
I need to change the which code. Please help me.

Related

Magento 2.3.3 dashboard keeps loading

I have installed latest version of magento in my localhost.
After login to admin panel dashboard keeps loading.
Here is the image-
Please help to solve this error.
First Go to magento root directory then :
vendor/magento/framework/view/element/tempalate/file/validator.php (dont exactly copy this url just follow this path)
open this file using any editor and change this line
$realPath = $this->fileDriver->getRealPath($path); //you can comment this out
with this one
$realPath = str_replace('\\','/',$this->fileDriver->getRealPath($path));
then goto to
app/etc/di.xml
and search for view_preprocessed
you will find a whole line like this :
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink
and change the Symlink with Copy
Magento 2.3
go to \lib\internal\Magento\Framework\View\Element\Template\File
go to the function isPathInDirectories and replace the function with following
protected function isPathInDirectories($path, $directories)
{
if (!is_array($directories)) {
$directories = (array)$directories;
}
//$realPath = $this->fileDriver->getRealPath($path);
$realPath = str_replace('\\','/',$this->fileDriver->getRealPath($path));
foreach ($directories as $directory) {
//$realDirectory = $this->fileDriver->getRealPath($directory);
$realDirectory = str_replace('\\','/',$this->fileDriver->getRealPath($directory));
if ($realDirectory && 0 === strpos($realPath, $realDirectory)) {
return true;
}
}
return false;
}
go to app/etc/di.xml then search for view_preprocessed
you will find a whole line like this :
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink and change to Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
#1. go to vendor/magento/framework/View/Element/Template/File/Validator.php#
#2. go to the function isPathInDirectories and replace the function with following:#
protected function isPathInDirectories($path, $directories)
{
if (!is_array($directories)) {
$directories = (array)$directories;
}
//$realPath = $this->fileDriver->getRealPath($path);
$realPath = str_replace('\\','/',$this->fileDriver->getRealPath($path));
foreach ($directories as $directory) {
//$realDirectory = $this->fileDriver->getRealPath($directory);
$realDirectory = str_replace('\\','/',$this->fileDriver->getRealPath($directory));
if ($realDirectory && 0 === strpos($realPath, $realDirectory)) {
return true;
}
}
return false;
}
#3. go to app/etc/di.xml then search for view_preprocessed
you will find a whole line like this :
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink and change to
Magento\Framework\App\View\Asset\MaterializationStrategy\Copy #

How to add hyperlink using templateprocessor (PHPWord Library)

I want to replace email variable into a hyperlink using template processor and I have used two way to solved this issue but didn't work and here is our below code for replacing email variable into hyperlink but when I used setValue or setComplexValue function for replacement value then document is corrupted.
We have tried below two scenarios for adding hyperlink but didn't work for us.
1. First Way
$pw = new \PhpOffice\PhpWord\PhpWord();
$section = $pw->addSection();
$textrun = $section->addTextRun();
$textrun->addTextBreak(2);
$section->addLink('mailto:demo1#gmail.com?subject=DEMO','demo1#gmail.com', array('color' => 'FF0000', 'underline' =>
\PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($pw, 'Word2007');
$fullXml = $objWriter->getWriterPart('Document')->write();
$templateProcessor->setValue($var, $this->getBodyBlock($fullXml));
2. Second Way
$pw = new \PhpOffice\PhpWord\PhpWord();
$section = $pw->addSection();
$convertResult = 'demo1#gmail.com';
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $convertResult, false,false);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($pw, 'Word2007');
$fullXml = $objWriter->getWriterPart('Document')->write();
$templateProcessor->setValue($var, $this->getBodyBlock($fullXml));
protected function getBodyBlock($string) {
if (preg_match('%(?i)(?<=<w:body>)[\s|\S]*?(?=</w:body>)%', $string, $regs)) {
return $regs[0];
} else {
return '';
}
}
Please help us thank in advance.

XSLT processing on IE11?

What has happened to the XSLT processing in IE11?
On IE8/9/10, you can use:
if (window.ActiveXObject) {
var xslt = new ActiveXObject("Msxml2.XSLTemplate");
....
}
On Chrome/Firefox/Safari, you can use:
else {
var xsltProcessor = new XSLTProcessor();
}
But on IE11, neither of these are supported. Does anyone know how this can be accomplished?
Try
if (window.ActiveXObject || "ActiveXObject" in window)
This worked for me working with IE11 and allowed me to instantiate ActiveX objects since the standard old check was being bypassed.
This works for me on Chrome/Edge/Firefox/IE11
function loadXMLDoc(filename) {
if (window.ActiveXObject || "ActiveXObject" in window) {
xhttp = new ActiveXObject("Msxml2.XMLHTTP");
} else {
xhttp = new XMLHttpRequest();
}
xhttp.open("GET", filename, false);
xhttp.send("");
return xhttp.responseXML;
}
if (window.ActiveXObject || "ActiveXObject" in window) {
ie();
} else {
xml = loadXMLDoc("input.xml");
xsl = loadXMLDoc("mmlctop2_0.xsl");
if (document.implementation && document.implementation.createDocument) {
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToDocument(xml, document);
var serializer = new XMLSerializer();
var transformed = serializer.serializeToString(resultDocument.documentElement);
alert(transformed);
}
}
// https://msdn.microsoft.com/en-us/library/ms753809(v=vs.85).aspx
function ie() {
var xslt = new ActiveXObject("Msxml2.XSLTemplate.3.0");
var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");
var xslProc;
xslDoc.async = false;
xslDoc.load("mmlctop2_0.xsl");
if (xslDoc.parseError.errorCode != 0) {
var myErr = xslDoc.parseError;
alert("You have error " + myErr.reason);
} else {
xslt.stylesheet = xslDoc;
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDoc.async = false;
xmlDoc.load("input.xml");
if (xmlDoc.parseError.errorCode != 0) {
var myErr = xmlDoc.parseError;
alert("You have error " + myErr.reason);
} else {
xslProc = xslt.createProcessor();
xslProc.input = xmlDoc;
xslProc.addParameter("param1", "Hello");
xslProc.transform();
alert(xslProc.output);
}
}
}
You could consider Saxon CE, an XSLT 2.0 processor implemented entirely in JavaScript. This would give you a consistent API across all browsers and would allow you to code using the more powerful XSLT 2.0 language rather than 1.0.
The reason if(window.ActiveXObject) fails in IE11 is because for some reason window.ActiveXObject has become falsy, even though it is still a function. I've taken to being more explicit in my feature detection:
if(window.ActiveXObject !== undefined){
...
}
This approach also covers the case of checking for attributes that are present but not set to a truthy value:
if(document.createElement("span").draggable !== undefined){
...
}
For me running site in a compatibility mode in IE - 11 solved the issue....
Note : This might not be a solution , but I was in a situation where one if my old site was using above mentioned code. But I'm not in a position to Re-code the site
You Can use ("ActiveXObject" in window) which will allow all the IE browsers to come inside the if condition .
Exp :-
if ("ActiveXObject" in window) {
// Internet Explorer For all versions like IE8 , IE9 , IE10 or IE11 etc
}else{
// code for Mozilla, Firefox, Opera, etc.
}

vTiger - How to use module field in another module

I'm newbie in vtiger. I'm trying to insert the field "Service Name" from Services module in TroubleTicket module, but up to now I wasn't able to do it.
Generally speaking, is it possible to insert a field in a Module from another module? If so, how is it supposed to be done?
You can use this Code, Put this under your vTiger root directory and call it from browser.
<?php
$Vtiger_Utils_Log = true;
include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');
$module = Vtiger_Module::getInstance('HelpDesk');
if($module) {
$blockInstance = Vtiger_Block::getInstance('LBL_TICKET_INFORMATION', $module);
if($blockInstance) {
$fieldInstance = Vtiger_Field::getInstance('Service1', $module);
if(!$fieldInstance) {
$fieldInstance = new Vtiger_Field();
$fieldInstance->name = 'Service1';
$fieldInstance->label = 'Service Name';
$fieldInstance->uitype = 10;
$fieldInstance->typeofdata = 'V~O';
$blockInstance->addField($fieldInstance);
$fieldInstance->setRelatedModules(Array('Services'));
}
}
}
?>

drupal template.php not using tpl file

I have a code which works on one server but not on the other. Basically we have written a template file which should be used if URL is discussion_forum but it shows page not found.
/* discussion forum templates */
$querystring=$_GET['q'];
echo $querystring; // THIS PRINTS page-not-found
$querystring=explode('&',$_GET['q']);
if(!isset ($vars['node']) && $querystring[0]=='discussion-forum'){
$vars['template_files'] = array();
$vars['template_files'][] = 'page-discussion_forum';
}
if (!isset ($vars['node']) && $querystring[0]=='discussion_forum_answer') {
$_SESSION['question_id']=$querystring[1];
$vars['template_files'] = array();
$vars['template_files'][] = 'page-discussion_forum_answer';
}
if(!isset ($vars['node']) && $querystring[0]=='discussion_forum_search'){
$vars['template_files'] = array();
$vars['template_files'][] = 'page-discussion_forum_search';
}
when I give page-not-found in place of discussion-forum in $querystring[0]=='discussion-forum'. It shows the the page properly. Don't know whats happening here. Its working fine on other servers.
To add custom tpl I usually add the theme suggestions in the preprocess node.
$vars['theme_hook_suggestions'][] = 'node____'.$vars['view_mode'];
So yours should be
function THEME_preprocess_node(&$vars, $hook)
$vars['theme_hook_suggestions'][] = 'page-discussion_forum_search';
}
It would help if you identify which version of drupal are you using because some of these things change between versions.