/**
 * global function used to access language-strings. returns warning-string if key does not exist
 * @param string $msgId name of the language-string to return
 * @param array $msgArgs any parameters for printf if you have
 * @parma bool $safe true if you want no error to be thrown
 * @return string
 */
function __($msgId, $msgArgs = NULL, $safe = false)
{
    if (null == $GLOBALS['__cachedLocaleComponent']) {
        $GLOBALS['__cachedLocaleComponent'] = classRegistry::getObject('LocaleComponent');
    }
    if ($safe) {
        return $GLOBALS['__cachedLocaleComponent']->safeGetString($msgId, $msgArgs);
    }
    return $GLOBALS['__cachedLocaleComponent']->getString($msgId, $msgArgs);
}
 /**
  * load dbo-class, give dbconfig to class
  * 
  * @param string $connName name of the connection to use
  */
 protected function setupDbo($connName)
 {
     require_once ROOT . 'config' . DS . 'database.php';
     if (!class_exists('DATABASE_CONFIG')) {
         throw new Exception('Incorrect config/database.php');
     }
     $dbvars = get_class_vars('DATABASE_CONFIG');
     if (empty($dbvars[$connName])) {
         throw new DatabaseConnectException("Cant find configdata for database-connection '{$connName}'");
     }
     $dboname = 'dbo_' . $dbvars[$connName]['driver'];
     if (!class_exists($dboname)) {
         require_once LIB . 'dbo' . DS . $dboname . '.php';
     }
     //for evil people modifying the connection-parameters
     $connHandle = $connName . implode('|', $dbvars[$connName]);
     $this->dboClass = classRegistry::getObject($dboname, $connHandle);
     $this->dboClass->setConfig($dbvars[$connName]);
 }
/**
 * return class-handle of a utility-class
 * You always get the same object, singleton-alike.
 *
 * @param string $name name of the utility
 * @return object class-handle
 */
function getUtil($name)
{
    if (file_exists(LIB . 'utilities' . DS . strtolower($name) . '.php')) {
        require_once LIB . 'utilities' . DS . strtolower($name) . '.php';
    } else {
        require_once APP . 'utilities' . DS . strtolower($name) . '.php';
    }
    $classname = $name . 'Utility';
    return classRegistry::getObject($classname);
}
 /**
  * returns initialized class of other helpers. you have to take care of initialization order!
  *
  * @param string $name name of helper you need access to
  * @return object
  */
 function getHelper($name)
 {
     $classname = ucfirst(strtolower($name)) . 'Helper';
     if (!classRegistry::hasObject($classname)) {
         throw new RuntimeException("Helper {$name} not initialized yet. Wrong initialization order?");
     }
     return classRegistry::getObject($classname);
 }
/**
 * return class-handle of a utility-class
 * You always get the same object, singleton-alike.
 *
 * @param string $name name of the utility
 * @return object class-handle
 */
function getUtil($name)
{
    require_once APP . 'models' . DS . strtolower($name) . '.php';
    $classname = $name . 'Utility';
    return classRegistry::getObject($classname);
}
 protected function _initHelper($name)
 {
     $name = strtolower($name);
     $classname = ucfirst(strtolower($name)) . 'Helper';
     $h = classRegistry::getObject($classname);
     $h->view = $this;
     $h->action = $this->action;
     $h->params = $this->controller->params;
     $h->base = $this->base;
     $h->basePath = $this->basePath;
     $h->vars = $this->controller->viewVars;
     return $h;
 }
Beispiel #7
0
 function onBeforeDisplayContent(&$article, &$params)
 {
     if (!class_exists('cmsFramework') || !class_exists('Sanitize')) {
         return;
     }
     // Make sure this is a Joomla article page
     $option = Sanitize::getString($_REQUEST, 'option', '');
     $view = Sanitize::getString($_REQUEST, 'view', '');
     $layout = Sanitize::getString($_REQUEST, 'layout', '');
     $id = Sanitize::getInt($_REQUEST, 'id');
     if (!($option == 'com_content' && $view == 'article' && $id)) {
         return;
     }
     /**
      * Retrieve $listing array from memory 
      */
     $Config = Configure::read('JreviewsSystem.Config');
     $title = trim(Sanitize::getString($Config, 'type_metatitle'));
     $this->cms_version >= 1.6 and $params->set('page_title', $article->title);
     // Fixes J16 bug that uses cat menu title as page title
     $keywords = trim(Sanitize::getString($Config, 'type_metakey'));
     $description = trim(Sanitize::getString($Config, 'type_metadesc'));
     $listing = classRegistry::getObject('listing', 'jreviewsplugin');
     // Has all the data that's also available in the detail.thtml theme file so you can create any sort of conditionals with it
     $crumbs = classRegistry::getObject('crumbs', 'jreviewsplugin');
     if ($title != '' || $keywords != '' || $description != '') {
         if ($listing && is_array($listing)) {
             // Get and process all tags
             $tags = plgContentJreviews::extractTags($title . $keywords . $description);
             $tags_array = array();
             foreach ($tags as $tag) {
                 switch ($tag) {
                     case 'title':
                         $tags_array['{title}'] = Sanitize::stripAll($listing['Listing'], 'title');
                         break;
                     case 'section':
                         $tags_array['{section}'] = Sanitize::stripAll($listing['Section'], 'title');
                         break;
                     case 'category':
                         $tags_array['{category}'] = Sanitize::stripAll($listing['Category'], 'title');
                         break;
                     case 'metakey':
                         $tags_array['{metakey}'] = Sanitize::stripAll($listing['Listing'], 'metakey');
                         break;
                     case 'metadesc':
                         $tags_array['{metadesc}'] = Sanitize::stripAll($listing['Listing'], 'metadesc');
                         break;
                     case 'summary':
                         $tags_array['{summary}'] = Sanitize::htmlClean(Sanitize::stripAll($listing['Listing'], 'summary'));
                         break;
                     case 'description':
                         $tags_array['{description}'] = Sanitize::htmlClean(Sanitize::stripAll($listing['Listing'], 'description'));
                         break;
                     default:
                         if (substr($tag, 0, 3) == 'jr_' && isset($listing['Field']['pairs'][$tag])) {
                             $fields = $listing['Field']['pairs'];
                             $tags_array['{' . $tag . '}'] = isset($fields[$tag]['text']) ? html_entity_decode(implode(", ", $fields[$tag]['text']), ENT_QUOTES, 'utf-8') : '';
                         }
                         break;
                 }
             }
             # Process title
             $title != '' and $title = str_replace('&', '&', str_replace(array_keys($tags_array), $tags_array, $title)) and cmsFramework::meta('title', $title);
             $title != '' and $this->cms_version >= 1.6 and $params->set('page_title', $title);
             # Process description
             $description != '' and $description = str_replace('&', '&', str_replace(array_keys($tags_array), $tags_array, $description)) and cmsFramework::meta('description', $description);
             $description != '' and $this->cms_version >= 1.6 and $article->metadesc = htmlspecialchars($description, ENT_QUOTES, 'utf-8');
             # Process keywords
             $keywords != '' and $keywords = mb_strtolower(str_replace('&', '&', str_replace(array_keys($tags_array), $tags_array, $keywords)), 'utf-8') and cmsFramework::meta('keywords', $keywords);
             $keywords != '' and $this->cms_version >= 1.6 and $article->metakey = htmlspecialchars($keywords, ENT_QUOTES, 'utf-8');
         }
     } elseif (isset($article->parameters) && $article->parameters->get('show_page_title') && $article->parameters->get('num_leading_articles') == '' && $article->parameters->get('filter_type') == '') {
         $title = $article->parameters->get('page_title');
         $title != '' and $params->set('page_title', $title);
     }
     if ($crumbs && !empty($crumbs)) {
         cmsFramework::setPathway($crumbs);
     }
     $this->facebookOpenGraph($listing, compact('title', 'keywords', 'description'));
 }
 /**
  * loads all models this controller needs
  */
 function _constructClasses()
 {
     if (!is_array($this->uses)) {
         throw new InvalidArgumentException('$uses must be an array');
     }
     //models
     require_once LIB . 'model.php';
     foreach ($this->uses as $u) {
         $this->{$u} = getModel($u);
     }
     //components
     if (!is_array($this->components)) {
         throw new InvalidArgumentException('$components must be an array');
     }
     require_once LIB . 'component.php';
     foreach ($this->components as $comname) {
         require_once APP . 'controllers' . DS . 'components' . DS . strtolower($comname);
         $classname = $comname . 'Component';
         $this->{$comname} = classRegistry::getObject($classname);
         $this->{$comname}->startup($this);
     }
 }
 /**
  * construct all helpers we found in our helpers property
  */
 protected function constructHelpers()
 {
     if ($this->didConstructHelpers) {
         return;
     }
     require_once LIB . 'helper.php';
     foreach ($this->helpers as $name) {
         $name = strtolower($name);
         $classname = ucfirst(strtolower($name)) . 'Helper';
         $h = classRegistry::getObject($classname);
         $h->action = $this->action;
         $h->params = $this->controller->params;
         $h->base = $this->base;
         $h->basePath = $this->basePath;
         $h->vars = $this->controller->viewVars;
         $this->helperClasses[$name] = $h;
     }
     $this->didConstructHelpers = true;
 }