using mac's spotlight for .tpl and .php

Author Message

*- pike

Sunday 21 October 2007 4:52:12 am

Hi

I had to do much textchanges throughout a ezp site. I was using BBEdit's "find in files", but it took ages for each string. So I wanted to use Mac's "spotlight" - which does content indexing. Alas, it didn't index php and tpl files. Now it does, and here's what I did:

I read these:
http://www.macosxhints.com/article.php?story=20050514182520714
http://www.macosxhints.com/article.php?story=2005052015041510
And set to work.

For PHP first.

check if php is a recognized extension. open a terminal and type

mdimport -n -d1 myfile.php

where myfile.php actually exists. This returns something like

Import 'myfile.php' type 'public.php-script' no mdimporter

This says two things:
- the extension "php" is mapped to "public.php-script"
- there is nothing indexing "public.php-script"

To fix the second thing, let's add public.php-script to

/System/Library/Spotlight/RichText.mdimporter

if you've installed Apples Developer Tools, you'd better add it to

/Library/Spotlight/SourceCode.mdimporter

Find that file, rightclick, "show package contents". Open "info.plist",
and to the LSItemContentTypes, add one entry for "public.php-script".
Save it. In the terminal, type

mdimport -r /System/Library/Spotlight/RichText.mdimporter

which will return with

Asking the server to index files of type: ....

Now perform a spotlight search for "print" and watch php files roll in.

---

Now for tpl. Check if tpl is a recognized extension. open a terminal and type

 mdimport -n -d1 myfile.tpl

where myfile. tpl actually exists. This returns something like

Import 'myfile. tpl' type 'dyn.456fhj8679fhgjhdf' no mdimporter

This says two things:
- the extension "tpl" is mapped to "dyn.456fhj8679fhgjhdf"
- there is nothing indexing "dyn.456fhj8679fhgjhdf"

To fix the first thing, we have to add a UTI for extension ".tpl"
To do this, I downloaded http://www.lexa.ru/andyt/MyUTIs.bundle.zip,
unzipped it, rightclicked, "show package contents". Open "info.plist",
and added one entry for extension ".tpl", mapping it to "no.ez.template".

Then, I put the bundle in my Applications folder and rebooted.
After rebooting, I opened a terminal and typed

mdimport -n -d1 myfile.tpl

This returns something like

Import 'myfile. tpl' type 'no.ez.template' no mdimporter

This says two things:
- the extension "tpl" is now mapped to "no.ez.template"
- there is nothing indexing "no.ez.template" yet

As with the php example, I edited

/System/Library/Spotlight/RichText.mdimporter

I opened "info.plist", and to the LSItemContentTypes, added one entry for "no.ez.template". Then I went to the terminal and typed

mdimport -r /System/Library/Spotlight/RichText.mdimporter

And in spotlight, I did a search for

i18n(-php)

.. and waited for the templates to roll in ..

wow :-)
*-pike

---------------
The class eZContentObjectTreeNode does.

Ole Morten Halvorsen

Monday 22 October 2007 2:44:08 am

Cool! Thanks for the tip. Spotlight is supposedly faster in Leopard so this will be even more useful in the a week or so :)

Ole M.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 07:25:07
Script start
Timing: Jan 19 2025 07:25:07
Module start 'layout'
Timing: Jan 19 2025 07:25:07
Module start 'content'
Timing: Jan 19 2025 07:25:09
Module end 'content'
Timing: Jan 19 2025 07:25:09
Script end

Main resources:

Total runtime1.4123 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 589.2500152.6250
Module start 'layout' 0.00660.0029 741.875039.4453
Module start 'content' 0.00961.4014 781.3203521.1641
Module end 'content' 1.41090.0014 1,302.484412.1563
Script end 1.4123  1,314.6406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2164160.0002
Check MTime0.00120.0843160.0001
Mysql Total
Database connection0.00130.091110.0013
Mysqli_queries1.355395.9612540.0251
Looping result0.00050.0375520.0000
Template Total1.379097.620.6895
Template load0.00250.176520.0012
Template processing1.376597.462520.6883
Template load and register function0.00030.022210.0003
states
state_id_array0.00070.051510.0007
state_identifier_array0.00140.095720.0007
Override
Cache load0.00200.1393600.0000
Sytem overhead
Fetch class attribute can translate value0.00090.060920.0004
Fetch class attribute name0.00220.154520.0011
XML
Image XML parsing0.00030.019620.0001
class_abstraction
Instantiating content class attribute0.00000.000620.0000
General
dbfile0.00070.0492100.0001
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
19content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
13content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 44
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs