/**
  * This is always going to get the first instance of the module type unless
  * there is a title.
  *
  * @param   string  $module  The module name
  * @param   string  $title   Module title
  * @param   string  $style   Display style
  * @return  string
  */
 protected function byName($module, $title, $style = 'none')
 {
     $moduleinstance = $module . JStringNormalise::toCamelCase($title);
     if (!isset(self::$mods[$moduleinstance])) {
         self::$mods[$moduleinstance] = '';
         $document = \Document::instance();
         $renderer = $document->loadRenderer('module');
         $params = array('style' => $style);
         $mod = \Module::byName($module, $title);
         // If the module without the mod_ isn't found, try it with mod_.
         // This allows people to enter it either way in the content
         if (!isset($mod)) {
             $name = 'mod_' . $module;
             $mod = \Module::byName($name, $title);
         }
         ob_start();
         echo $renderer->render($mod, $params);
         self::$mods[$moduleinstance] = ob_get_clean();
     }
     return self::$mods[$moduleinstance];
 }
Exemple #2
0
 /**
  * Helper wrapper method for toCamelCase
  *
  * @param   string  $input  The string input (ASCII only).
  *
  * @return string  The camel case string.
  *
  * @see     JUserHelper::toCamelCase()
  * @since   3.4
  */
 public function toCamelCase($input)
 {
     return JStringNormalise::toCamelCase($input);
 }
Exemple #3
0
 /**
  * Convert string into css class name
  *
  * @param   string  $input  string
  *
  * @return  string
  */
 protected function toVariable($input)
 {
     // Should simply be (except there's a bug in J)
     // JStringNormalise::toVariable($event->className);
     $input = trim($input);
     // Remove dashes and underscores, then convert to camel case.
     $input = JStringNormalise::toSpaceSeparated($input);
     $input = JStringNormalise::toCamelCase($input);
     // Remove leading digits.
     $input = preg_replace('#^[\\d\\.]*#', '', $input);
     // Lowercase the first character.
     $first = JString::substr($input, 0, 1);
     $first = JString::strtolower($first);
     // Replace the first character with the lowercase character.
     $input = JString::substr_replace($input, $first, 0, 1);
     return $input;
 }
Exemple #4
0
 /**
  * Method to set an object property.
  *
  * When using getters/setters, it is worth noting that this method will
  * automatically call the getter after a property has been set to prime
  * and/or update the object cache.
  *
  * @param   string   $property   The property name.
  * @param   mixed    $value      The property value.
  * @param   boolean  $useMethod  True to use an available getter method, false otherwise.
  * @param   boolean  $useCache   True to try to load the data from cache, false otherwise.
  *
  * @return  void
  *
  * @since   12.1
  */
 protected function setProperty($property, $value, $useMethod = true, $useCache = true)
 {
     // Check if we should use the setter method.
     if ($useMethod) {
         // Get the property setter.
         $method = 'set' . JStringNormalise::toCamelCase($property);
         // Check for a setter method for the property.
         // Check that the property is not named "property" which would be recursive.
         if (in_array($method, $this->methods) && $method !== 'setProperty') {
             // Set the value using the setter.
             $this->{$method}($value);
             // Check if we should use cache.
             if ($useCache) {
                 // Load the property, not from cache.
                 $value = $this->getProperty($property, true, false);
                 // Store the value in cache.
                 $this->store($this->getStoreId($property), $value, false);
             }
             return;
         }
     }
     // Set the value.
     $this->properties[$property] = $value;
 }