How to use ZendSearch with CodeIgniter 2.1.3? - codeigniter

I know that ZendSearch in Zend Framework 2 is similar with Zend Search Lucene in Zend Framework 1.12. I've tried to use Zend Search Lucene with CodeIgniter 2.1.3. The indexing and finding process work well, but it still give some errors (warnings) like this:
Warning: include(application/errors/error_php.php) [function.include]: failed to open stream: No such file or directory in C:\path\to\system\core\Exceptions.php on line 182
Warning: include() [function.include]: Failed opening 'application/errors/error_php.php' for inclusion (include_path='.;C:\php5\pear;application/libraries') in C:\path\to\system\core\Exceptions.php on line 182
Fatal error: require_once() [function.require]: Failed opening required 'Zend/Search/Lucene/Storage/File/Filesystem.php' (include_path='.;C:\php5\pear;application/libraries') in C:\path\to\application\libraries\Zend\Search\Lucene\Storage\Directory\Filesystem.php on line 349
That errors appear after I follow this article when I try to use Zend Search Lucene library in my codeigniter application. I doubt that the article and Zend Search Lucene is still valid when use with codeigniter 2.1.3 and now I want to use ZendSearch.
So, how to use ZendSearch with CodeIgniter 2.1.3?

You have the Zend Search Lucene Library for the Codeigniter.
For Lucene search first you have to create index and then create index doc on which the actual search operation perform.
$index = Zend_Search_Lucene::create($CI->base_index_path . '/index_folder');
$doc = new Zend_Search_Lucene_Document();
and then add fields like this from your DB tables:
$doc->addField(Zend_Search_Lucene_Field::Keyword('id', $object->id));
$index->addDocument($doc);
And finally use as below, $q is search parameter you want to search on this index.
$data['query'] = $q;
$query = "name:\"" . $q . "\" or full_desc:\"" . $q . "\"";
$query_result = $index->find($query);

Related

Laravel with SQLite returns error: "SQLSTATE[HY000]: General error: 1 no such function: SQRT"

I use a SQLite database for a Laravel 8 project. I get an error message when I try to query it.
Query: Model::selectRaw('col1,col2,col3,(6368 * SQRT(2*(1-cos(RADIANS(col1)))))')->get();
Error: SQLSTATE[HY000]: General error: 1 no such function: SQRT.
What am I doing wrong? Or is this query even possible with SQLite? Thank you for help!
According to my comment:
It is possible, you could use sqrt(). But you need to make sure that you have the math library enabled according to the docs: sqlite.org/lang_mathfunc.html#sqrt "but are only active if the amalgamation is compiled using the -DSQLITE_ENABLE_MATH_FUNCTIONS compile-time option."

Joomla - Fatal error: Class 'JParameter' not found

I'm trying to upgrade Joomla 2.5.22 to 3.5.1, and last time I checked the progress bar, it was 86 %. I looked away for a moment and when I came back to check I saw the below error message.
Fatal error: Class 'JParameter' not found in
/home/mywebsite/public_html/plugins/system/bigshotgoogleanalytics/bigshotgoogleanalytics.php on line 24
What is the cause of this error and how would it be fixed?
Joomla can't find JParameter Class, so you have to use
jimport( 'joomla.html.parameter' );
before using JParameter class
bigshotanalytics is one of those plugins that cause a blank page or, at best, a fatal error when updating Joomla. This is because of its old code. I suggest you move the tracking code to your template. You can also add the tracking code to a custom HTML module (after removing the encapsulating div through an override) and then assign the module to a position in your template (the position should be in the section of the HTML).
Now to answer your question, Joomla no longer uses JParameter - it uses JRegistry instead. So something like:
$jparameter = new JParameter('param1');
Should be changed to:
$jregistry= new JRegistry();
$jparameter = $jregistry->get('param1');

PHPWord + dompdf "Unable to load PDF Rendering library" and "dompdf_config.inc.php" problems

I'm using PHPWord (https://github.com/PHPOffice/PHPWord) to generate a Microsoft Word file (.docx) which I save to my system. This works perfectly and as expected. I also want to save an Adobe Acrobat version of that file (.pdf) to my system. For that I'm relying on PHPWord in conjunction with dompdf (https://github.com/dompdf/dompdf). That's where the trouble begins.
My PHP code is the following:
// first, save the completed .docx file that I've generated
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, "Word2007");
$objWriter->save($path_docx);
// second, set PHPWord PDF rendering variables
\PhpOffice\PhpWord\Settings::setPdfRendererPath("/var/www/html/vendor/dompdf/dompdf");
\PhpOffice\PhpWord\Settings::setPdfRendererName("DomPDF");
// third, load the .docx file which we just saved above
$phpWord = \PhpOffice\PhpWord\IOFactory::load($path_docx);
// fourth, save the new PDF file to the location of choice
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, "PDF");
$xmlWriter->save("/var/www/html/export/my-pdf-version-of-the-file.pdf");
When I run the code above I get the following error:
Fatal error: Uncaught exception 'PhpOffice\PhpWord\Exception\Exception' with message 'Unable to load PDF Rendering library' in /var/www/html/vendor/phpoffice/phpword/src/PhpWord/Writer/PDF/AbstractRenderer.php:94 Stack trace: #0 /var/www/html/vendor/phpoffice/phpword/src/PhpWord/Writer/PDF.php(65): PhpOffice\PhpWord\Writer\PDF\AbstractRenderer->__construct(Object(PhpOffice\PhpWord\PhpWord)) #1 /var/www/html/vendor/phpoffice/phpword/src/PhpWord/IOFactory.php(44): PhpOffice\PhpWord\Writer\PDF->__construct(Object(PhpOffice\PhpWord\PhpWord)) #2 /var/www/html/assets/core/phpword.php(593): PhpOffice\PhpWord\IOFactory::createWriter(Object(PhpOffice\PhpWord\PhpWord), 'PDF') #3 /var/www/html/export/index.php(94): exportOutline(Array) #4 {main} thrown in /var/www/html/vendor/phpoffice/phpword/src/PhpWord/Writer/PDF/AbstractRenderer.php on line 94
I began searching Google for errors similar to this and came upon this Stack Overflow post: PHPWord to PDF not able to load library. They suggested editing some code within the "/var/www/html/vendor/phpoffice/phpword/src/PhpWord/Writer/PDF/AbstractRenderer.php" file. The code snippet referenced in that post is the following:
public function __construct(PhpWord $phpWord)
{
parent::__construct($phpWord);
$includeFile = Settings::getPdfRendererPath() . '/' . $this->includeFile;
if (file_exists($includeFile)) {
/** #noinspection PhpIncludeInspection Dynamic includes */
require_once $includeFile;
} else {
debug($includeFile);
// #codeCoverageIgnoreStart
// Can't find any test case. Uncomment when found.
throw new Exception('Unable to load PDF Rendering library');
// #codeCoverageIgnoreEnd
}
}
They suggested I get rid of this portion of the code which appears on the 4th line above:
. '/' . $this->includeFile
When I implemented that solution, however, it didn't fix my problem. Frustrated, I then looked at the value generated for $includeFile within that snippet of code. For me, the value was "/var/www/html/vendor/dompdf/dompdf/dompdf_config.inc.php". Once I saw that it was trying to include a file called "dompdf_config.inc.php" I then searched my directory for the file. It wasn't at the referenced location nor anywhere in my system!
At that point I began searching Google again for that file name and ended up on this Stack Overflow post: I Can't Find dompdf_config.inc.php or dompdf_config.custom.inc.php for setting "DOMPDF_UNICODE_ENABLED" true. That post suggests that dompdf 0.7.0 no longer relies on that configuration file. At this point I begin thinking that PHPWord's current version (which I'm using) which relies on dompdf has not been updated to support the current version of dompdf (which I'm using). I simply don't know.
My questions:
Can someone confirm if it's true that PHPWord's current version does not play well with dompdf's current version?
If the current version of both are supposed to work together, then what am I doing wrong and how do I fix it?
Thank you in advance for all of your help!
Note: I should note that I've included PHPWord and dompdf in my project via composer; so all relevant files are located in "/var/www/html/vendor" as one would expect. Also, I can't rely on TCPDF nor MPDF (which are alternate PDF rendering engines) because they generate files that don't meet the formatting needs I require for my project.

How can I get "DOCUMENT_ROOT" in phpbb 3.1?

I have tried to use this
require $_SERVER['DOCUMENT_ROOT'] . '/lib/MyClass.php';
But I got this message
Illegal use of $_SERVER. You must use the request class or request_var() to access input data
I have attempted to use request_var(), but it doesn't work.
How can I get "DOCUMENT_ROOT" in phpbb 3.1 ?
I have found the next decision of this problem - use filter_input instead of $_SERVER.
require filter_input(INPUT_SERVER, 'DOCUMENT_ROOT') . '/lib/MyClass.php';

codeigniter image reader prob

Hi im making a image gallery in useing the following tutorial at
http://superdit.com/2010/06/27/basic-image-gallery-with-codeigniter/
i keep getting this error
wrong parameter count for strstr()
google'd and tried this and found i needed to remove a third parameter.
I removed the third parameter from line38 $ext = strrev(strstr(strrev($file), ".", TRUE));
now all errors are gone but the image uploading will not work any ideas why this is now failing ?????
Thanks Alan
hi I think that tutorial using PHP 5.3 so the strstr function has the third parameter

Resources