Beispiel #1
0
 /**
  * Get the instance of a placeholder
  * If the class for placeholder is not founded
  * then use the "Simple" placeholder class
  *
  * @param  string $name - the suffic of class (name of placeholder)
  * @param  string $namespace - the HTML or 'plain'
  *
  * @return string
  * @since 1.0
  */
 public function getInstance($name, $namespace)
 {
     $name = strtolower($name);
     $namespace = strtolower($namespace);
     if (empty($name) || empty($namespace)) {
         Jerror::throwError('The name or namespace of placeholder is missing');
     }
     /*
      * Try to get class of placeholder.
      * If 'class' is not determined then use the $name as name of class of placeholder
      */
     $pdata = !empty(self::$placeholders[$name]) ? self::$placeholders[$name] : array();
     $class = empty($pdata['class']) ? $name : $pdata['class'];
     if (isset(self::$_instances[$namespace][$class])) {
         return self::$_instances[$namespace][$class];
     }
     $path = 'migur' . DS . 'library' . DS . 'mailer' . DS . 'document' . DS . $namespace . DS . 'renderer' . DS . 'placeholder' . DS;
     if (!JLoader::import($path . $class, JPATH_LIBRARIES)) {
         $class = 'simple';
         if (!JLoader::import($path . $class, JPATH_LIBRARIES)) {
             JError::raiseError(500, 'File or class not found for ' . $class . ', ' . $namespace);
         }
     }
     $className = ucfirst($namespace) . 'Placeholder' . ucfirst($class);
     $obj = new $className();
     self::$_instances[$namespace][$class] = $obj;
     return $obj;
 }