Wednesday, December 28, 2016

MIME Types

ExtensionKind of documentMIME Type
.aacAAC audio fileaudio/aac
.abwAbiWord documentapplication/x-abiword
.arcArchive document (multiple files embedded)application/octet-stream
.aviAVI: Audio Video Interleavevideo/x-msvideo
.azwAmazon Kindle eBook formatapplication/vnd.amazon.ebook
.binAny kind of binary dataapplication/octet-stream
.bzBZip archiveapplication/x-bzip
.bz2BZip2 archiveapplication/x-bzip2
.cshC-Shell scriptapplication/x-csh
.cssCascading Style Sheets (CSS)text/css
.csvComma-separated values (CSV)text/csv
.docMicrosoft Wordapplication/msword
.epubElectronic publication (EPUB)application/epub+zip
.gifGraphics Interchange Format (GIF)image/gif
.htm
.html
HyperText Markup Language (HTML)text/html
.icoIcon formatimage/x-icon
.icsiCalendar formattext/calendar
.jarJava Archive (JAR)application/java-archive
.jpeg
.jpg
JPEG imagesimage/jpeg
.jsJavaScript (ECMAScript)application/js
.jsonJSON formatapplication/json
.mid
.midi
Musical Instrument Digital Interface (MIDI)audio/midi
.mpegMPEG Videovideo/mpeg
.mpkgApple Installer Packageapplication/vnd.apple.installer+xml
.odpOpenDocuemnt presentation documentapplication/vnd.oasis.opendocument.presentation
.odsOpenDocuemnt spreadsheet documentapplication/vnd.oasis.opendocument.spreadsheet
.odtOpenDocument text documentapplication/vnd.oasis.opendocument.text
.ogaOGG audioaudio/ogg
.ogvOGG videovideo/ogg
.ogxOGGapplication/ogg
.pdfAdobe Portable Document Format (PDF)application/pdf
.pptMicrosoft PowerPointapplication/vnd.ms-powerpoint
.rarRAR archiveapplication/x-rar-compressed
.rtfRich Text Format (RTF)application/rtf
.shBourne shell scriptapplication/x-sh
.svgScalable Vector Graphics (SVG)image/svg+xml
.swfSmall web format (SWF) or Adobe Flash documentapplication/x-shockwave-flash
.tarTape Archive (TAR)application/x-tar
.tif
.tiff
Tagged Image File Format (TIFF)image/tiff
.ttfTrueType Fontapplication/x-font-ttf
.vsdMicrosft Visioapplication/vnd.visio
.wavWaveform Audio Formataudio/x-wav
.webaWEBM audioaudio/webm
.webmWEBM videovideo/webm
.webpWEBP imageimage/webp
.woffWeb Open Font Format (WOFF)application/x-font-woff
.xhtmlXHTMLapplication/xhtml+xml
.xlsMicrosoft Excelapplication/vnd.ms-excel
.xmlXMLapplication/xml
.xulXULapplication/vnd.mozilla.xul+xml
.zipZIP archiveapplication/zip
.3gp3GPP audio/video containervideo/3gpp
audio/3gpp if it doesn't contain video
.3g23GPP2 audio/video containervideo/3gpp2
audio/3gpp2 if it doesn't contain video
.7z7-zip archiveapplication/x-7z-compressed

Monday, November 28, 2016

Common Database Configuration File Locations

Please note that the information below is provided to assist you with changing the connection strings of the most commonly used database driven web applications and we cannot offer a guide on every possible software solution available.

Wordpress configuration file location : httpdocs/wp-config.php
/** MySQL database password */   
define('DB_PASSWORD', '** new password here **');
Joomla configuration file location : httpdocs/configuaration.php
var $password = '** new password here **';
Drupal configuration file location : httpdocs/sites/default/settings
$databases = array (  
'default' =>   
array (   
'default' => [  
array (   
'database' => 'database-name',   
'username' => 'database-username',  
'password' => '**new password here***',   
'host' => 'localhost',     
'port' => '',   
'driver' => 'mysql',  
'prefix' => '',
OSCommerce 2.2 Configuration file location : httpdocs/includes/configure.php & httpdocs/admin/includes/configure.php
define('DB_SERVER_PASSWORD', '** new password **');

The password needs to be changed in both files. 

Moodle 2 configuration file location : httpdocs/config.php
$CFG->dbpass = '** new password here **';
Magento configuration file location : httpdocs/app/etc/local.xml
<password><![CDATA[** new password here ** ]]></password>



courtesy:  https://www.names.co.uk/support/1304-common_database_configuration_file_locations.html  

Thursday, November 17, 2016

Check if SKU exist or not,

$sku = 'sku here';
$id = Mage::getModel('catalog/product')->getIdBySku($sku);
if ($id) {
   //sku exists
}
else {
   //sku does not exist
}
simple???

Thursday, September 15, 2016

layout in coding

$headBlock = $this->getLayout()->getBlock('head');
$headBlock->addJs('varien/product.js')
->addItem('js_css', 'calendar/calendar-win2k-1.css', null, null, 'can_load_calendar_js')
->addItem('js', 'calendar/calendar.js', null, null, 'can_load_calendar_js')
->addItem('js', 'calendar/calendar-setup.js', null, null, 'can_load_calendar_js')
->addItem('skin_js', 'js/bundle.js');
$this->renderLayout();

Wednesday, August 31, 2016

Find Browser using Javascript

            // Opera 8.0+
            var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
                // Firefox 1.0+
            var isFirefox = typeof InstallTrigger !== 'undefined';
                // At least Safari 3+: "[object HTMLElementConstructor]"
            var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
                // Internet Explorer 6-11
            var isIE = /*@cc_on!@*/false || !!document.documentMode;
                // Edge 20+
            var isEdge = !isIE && !!window.StyleMedia;
                // Chrome 1+
            var isChrome = !!window.chrome && !!window.chrome.webstore;
                // Blink engine detection
            var isBlink = (isChrome || isOpera) && !!window.CSS;
       
         if(isIE)
         {
            setTimeout(function(){
            a = parseInt(jQuery('.masonary div:nth-child(6)').css('left'));
                jQuery('div[id^=masonary]:nth-child(5n),div[id^=masonary]:nth-child(6n),div[id^=masonary]:nth-child(7n)').each(function(){
                    reala = jQuery(this).css('left');
                    calca = parseInt(reala) + (a/2);
                    jQuery(this).css('left',calca);
                });
            }, 1000);
         }
         else
         {
            setTimeout(function(){jQuery('#masonary51').addClass('masonary51');},200);
         }

Thursday, August 11, 2016

Overriding Magento blocks, models, helpers and controllers




worker
There is no project that uses framework as is. Every now and then there is a need to change something, to add something new or to override something already written. Due to many reasons it’s a bad habit and bad programming if core files are modified and it’s not recommended at all. Therefore Magento brought in an excellent way how to override/overwrite those files.
We already wrote how to override magento model classes, but there’s a need to modify helpers, blocks and controllers too, both on frontend and in admin.

Overriding Magento Blocks

Let’s start with overriding core tag blocks. Suppose that in Mage_Tag_Block_Product_List class some changes have to be done. What we would like to have here is to add our own file that will extend the original file with all of its methods. All the job that has to be done is to add the code below in the current module’s config.xml:
<config>
 <global>
  <blocks>
   <tag>
    <rewrite>
     <product_list>Inchoo_Tag_Block_Product_List</product_list>
    </rewrite>
   </tag>
  </blocks>
 </global>
</config>
As the class name says, a file has to be created in app/code/local/Inchoo/Tag/Block/Product/List.php and a class has to be defined:
class Inchoo_Tag_Block_Product_List extends Mage_Tag_Block_Product_List
{
// some code
}
Equivalent to the example above, the same rule can be applied for the blocks in adminhtml where we want to override Mage_Adminhtml_Block_Tag_Edit class.
<config>
 <global>
  <blocks>
   <adminhtml>
    <rewrite>
     <tag_edit>Inchoo_Tag_Block_Adminhtml_Tag_Edit</tag_edit>
    </rewrite>
   </adminhtml>
  </blocks>
 </global>
</config>
With the code above in config.xml an app/code/local/Inchoo/Tag/Block/Adminhtml/Tag/Edit.php file has to be created with the class definition:
class Inchoo_Tag_Block_Adminhtml_Tag_Edit extends Mage_Adminhtml_Block_Tag_Edit
{
// some code
}

Overriding Magento Helpers

Following the same principles magento helpers can be easiliy overriden too. Code for config.xml:
<config>
 <global>
  <helpers>
   <tag>
    <rewrite>
     <data>Inchoo_Tag_Helper_Data</data>
    </rewrite>
   </tag>
  </helpers>
 </global>
</config>
Next we have to create an app/code/local/Inchoo/Tag/Helper/Data.php file and to define the class:
class Inchoo_Tag_Helper_Data extends Mage_Tag_Helper_Data
{
// some code
}

Overriding Magento Models

We already wrote about overriding magento models, but what’s with resource and collection files? The same as core model file, resource and collection files can be overriden similary as other files. Files we are going to extend:
Mage_Tag_Model_Tag
Mage_Tag_Model_Resource_Tag
Mage_Tag_Model_Resource_Tag_Collection
Config.xml code:
<config>
 <global>
  <models>
   <tag>
    <rewrite>
     <!-- Model -->
     <tag>Inchoo_Tag_Model_Tag</tag>
    </rewrite>
   </tag>
   <tag_resource>
    <rewrite>
     <!-- Resource -->
     <tag>Inchoo_Tag_Model_Resource_Tag</tag>
     <!-- Collection -->
     <tag_collection>Inchoo_Tag_Model_Resource_Tag_Collection</tag_collection>
    </rewrite>
   </tag_resource>
  </models>
 </global>
</config>
Next we have to create those files:
app/code/local/Inchoo/Tag/Model/Tag.php
app/code/local/Inchoo/Tag/Model/Resource/Tag.php
app/code/local/Inchoo/Tag/Model/Resource/Tag/Collection.php.
Note: This is just an example with all three overrides in one place for easier presentation. In your own projects rewrite only those files (classes) that you need.

Overriding Magento Controllers

Overriding controllers in Magento is a bit different than the rest of the examples above where they don’t quite follow magento rewrite rules as we have seen in the previous examples. How woud it go if we would like to override controllers in Mage_Tag? Let’s take a look at the code that goes into the config.xml:
<config>
 <frontend>
  <routers>
   <tag>
    <args>
     <modules>
      <inchoo_tag before="Mage_Tag">Inchoo_Tag</inchoo_tag>
     </modules>
    </args>
   </tag>
  </routers>
 </frontend>
</config>
In the config node its child has to define whether we are changing the frontend or admin file and we define router node that will override core tag module with its arguments. In the bottom node goes the current module frontend name (inchoo_tag in my example) with the “before” or “after” attribute name with the value of which module is being overriden (Mage_Tag) and our own module name inside the tags (Inchoo_Tag).
If you noticed, there are no strict files defined. With this we have defined only the path that will look for the controller files by their names. So if we would like to override app/code/core/Mage/Tag/controllers/TagController.php a file with the same name will have to be created (app/code/local/Inchoo/Tag/controllers/TagController.php).
Class definition inside our new file:
require_once(Mage::getModuleDir('controllers','Mage_Tag').DS.'TagController.php');
 
class Inchoo_Tag_TagController extends Mage_Tag_TagController
{
// some code
}
Similar thing goes for adminhtml controllers. Config.xml code:
<config>
 <admin>
  <routers>
   <adminhtml>
    <args>
     <modules>
      <inchoo_tag before="Mage_Adminhtml">Inchoo_Tag_Adminhtml</inchoo_tag>
     </modules>
    </args>
   </adminhtml>
  </routers>
 </admin>
</config>
Create a file in app/code/local/Inchoo/Tag/controllers/Adminhtml/TagController.php and define the class:
require_once(Mage::getModuleDir('controllers','Mage_Adminhtml').DS.'TagController.php');
 
class Inchoo_Tag_Adminhtml_TagController extends Mage_Adminhtml_TagController
{
// some code
}
Now when we went through some magento rewrites it’s on you to write some astonishing code.
Happy coding!

courtesy : http://inchoo.net/magento/overriding-magento-blocks-models-helpers-and-controllers/