示例#1
0
 /**
  * Displays all of the other modules that he user has permission to
  * as well as putting them into the correct Category. From there you can
  * either configure the module or configure the permissions that the
  * module provides.
  *
  * @return string
  */
 public function indexSection()
 {
     $this->setTitle(t('Module Manager'));
     $this->setOutputType(self::_OT_CONTENT_INDEX);
     // Gather all modules
     $categories = array();
     foreach (Module::getModules() as $module) {
         $aclRule = $module . '_global';
         if ($this->_acl->resourceExists($aclRule) && $this->_acl->check($aclRule)) {
             $tmpModule = new Module($module);
             $details = $tmpModule->getDetails();
             // Check which controller the icon/button should link to.
             if ($tmpModule->controllerExists('config')) {
                 $details['cntrlr'] = 'config';
             } else {
                 if ($tmpModule->controllerExists('index')) {
                     $details['cntrlr'] = 'index';
                 } else {
                     continue;
                 }
             }
             // Build correct category name
             $category = trim($tmpModule->category) ? zula_strtolower($tmpModule->category) : t('Unknown');
             $categories[$category][] = $details;
         }
     }
     foreach ($categories as $cat => $mod) {
         usort($categories[$cat], array($this, 'sort'));
     }
     ksort($categories);
     // Output main view
     $this->_theme->addJsFile('general.js');
     $this->addAsset('js/filter.js');
     $view = $this->loadView('index/main.html');
     $view->assign(array('categories' => $categories));
     return $view->getOutput();
 }
示例#2
0
 /**
  * Replaces a tag in a string, but also checks if that tag is assigned first.
  * This function allows for an array as the tag, in the case it will then
  * ... 'Follow' the assigned tags array down the tree until it finds the value
  * it needs.
  *
  * @param string $tag
  * @param string $content
  * @param bool $langTag	If set to true, the tags case will not be touched
  * @return string
  */
 protected function replaceTag($tag, $content, $langTag = false)
 {
     if (is_array($tag)) {
         $strTag = implode('.', $tag);
         foreach ($tag as $val) {
             if ($this->caseSensitive === false) {
                 $val = zula_strtolower($val);
             }
             if (!isset($tmpTagValue) && isset($this->assignedTags[$val])) {
                 $tmpTagValue =& $this->assignedTags[$val];
             } else {
                 if (isset($tmpTagValue)) {
                     if (array_key_exists($val, $tmpTagValue)) {
                         $tmpTagValue =& $tmpTagValue[$val];
                     } else {
                         throw new View_TagNotAssigned('view tag "' . $strTag . '" could not be replaced for view "' . $this->viewPath . '" tag has no assigned value');
                     }
                 } else {
                     throw new View_TagNotAssigned('view tag "' . $strTag . '" could not be replaced for view "' . $this->viewPath . '" tag has no assigned value');
                 }
             }
         }
         $value = $tmpTagValue;
         $tag = $strTag;
     } else {
         $strTag = $langTag === false && $this->caseSensitive === false ? zula_strtolower($tag) : $tag;
         if (array_key_exists($strTag, $this->assignedTags)) {
             $value = $this->assignedTags[$strTag];
         } else {
             throw new View_TagNotAssigned('view tag "' . $tag . '" could not be replaced for view "' . $this->viewPath . '" tag has no assigned value');
         }
     }
     if (is_array($value)) {
         throw new View_InvalidTagValue('tag "' . $tag . '" wants to get replaced with an array');
     } else {
         return str_replace('{' . $tag . '}', $value, $content);
     }
 }
示例#3
0
/**
 * Common way of cleaning a string for things like
 * Article title and names for URLS etc etc
 *
 * @param string $string
 * @return string
 */
function zula_clean($string)
{
    static $transliteration = null;
    if (!is_array($transliteration)) {
        $transFile = Registry::get('zula')->getDir('zula') . '/transliteration.ini';
        if (is_file($transFile) && is_readable($transFile)) {
            $transliteration = parse_ini_file($transFile);
        }
    }
    $string = str_replace(array_keys($transliteration), array_values($transliteration), $string);
    $clean = zula_strtolower(preg_replace('#[^A-Z0-9_\\-.!]#i', '-', $string));
    return trim(preg_replace('#-{2,}#', '-', $clean), '- ');
}