/**
  * Sets an entire array of search paths for templates or resources.
  *
  * @access protected
  * @param string $type The type of path to set, typically 'template'.
  * @param string|array $path The new set of search paths.  If null or
  * false, resets to the current directory only.
  */
 function _setPath($type, $path)
 {
     $option = JRequest::getCmd('option');
     $app = JFactory::getApplication();
     $extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
     if (!count($extensions)) {
         return parent::_setPath($type, $path);
     }
     // clear out the prior search dirs
     $this->_path[$type] = array();
     // actually add the user-specified directories
     $this->_addPath($type, $path);
     // add extensions paths
     if (strtolower($type) == 'template') {
         foreach ($extensions as $e => $extension) {
             $JLGPATH_EXTENSION = JPATH_COMPONENT_SITE . DS . 'extensions' . DS . $extension;
             // set the alternative template search dir
             if (isset($app)) {
                 if ($app->isAdmin()) {
                     $this->_addPath('template', $JLGPATH_EXTENSION . DS . 'admin' . DS . 'views' . DS . $this->getName() . DS . 'tmpl');
                 } else {
                     $this->_addPath('template', $JLGPATH_EXTENSION . DS . 'views' . DS . $this->getName() . DS . 'tmpl');
                 }
                 // always add the fallback directories as last resort
                 $option = preg_replace('/[^A-Z0-9_\\.-]/i', '', $option);
                 $fallback = JPATH_BASE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . $option . DS . $extension . DS . $this->getName();
                 $this->_addPath('template', $fallback);
             }
         }
     }
 }