Ejemplo n.º 1
0
    /**
     * display theme changing user interface
     */
    public function main()
    {
        // check if theme switching is allowed
        if (!System::getVar('theme_change')) {
            LogUtil::registerError($this->__('Notice: Theme switching is currently disabled.'));
            $this->redirect(ModUtil::url('Users', 'user', 'main'));
        }

        if (!SecurityUtil::checkPermission('Theme::', '::', ACCESS_COMMENT)) {
            return LogUtil::registerPermissionError();
        }

        // get our input
        $startnum = FormUtil::getPassedValue('startnum', isset($args['startnum']) ? $args['startnum'] : 1, 'GET');

        // we need this value multiple times, so we keep it
        $itemsperpage = $this->getVar('itemsperpage');

        // get some use information about our environment
        $currenttheme = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));

        // get all themes in our environment
        $allthemes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_USER);

        $previewthemes = array();
        $currentthemepic = null;
        foreach ($allthemes as $key => $themeinfo) {
            $themename = $themeinfo['name'];
            if (file_exists($themepic = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/images/preview_medium.png')) {
                $themeinfo['previewImage'] = $themepic;
                $themeinfo['largeImage'] = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/images/preview_large.png';
            } else {
                $themeinfo['previewImage'] = 'system/Theme/images/preview_medium.png';
                $themeinfo['largeImage'] = 'system/Theme/images/preview_large.png';
            }
            if ($themename == $currenttheme['name']) {
                $currentthemepic = $themepic;
                unset($allthemes[$key]);
            } else {
                $previewthemes[$themename] = $themeinfo;
            }
        }

        $previewthemes = array_slice($previewthemes, $startnum-1, $itemsperpage);

        $this->view->setCaching(Zikula_View::CACHE_DISABLED);

        $this->view->assign('currentthemepic', $currentthemepic)
                   ->assign('currenttheme', $currenttheme)
                   ->assign('themes', $previewthemes)
                   ->assign('defaulttheme', ThemeUtil::getInfo(ThemeUtil::getIDFromName(System::getVar('Default_Theme'))));

        // assign the values for the pager plugin
        $this->view->assign('pager', array('numitems' => sizeof($allthemes),
                                           'itemsperpage' => $itemsperpage));

        // Return the output that has been generated by this function
        return $this->view->fetch('theme_user_main.tpl');
    }
Ejemplo n.º 2
0
    /**
     * Retrieves default configuration array for HTML Purifier.
     *
     * @return array HTML Purifier default configuration settings.
     */
    private static function _getpurifierdefaultconfig()
    {
        $purifierDefaultConfig = HTMLPurifier_Config::createDefault();
        $purifierDefaultConfigValues = $purifierDefaultConfig->def->defaults;

        $config = array();

        foreach ($purifierDefaultConfigValues as $key => $val) {
            $keys = explode(".", $key, 2);

            $config[$keys[0]][$keys[1]] = $val;
        }

        $charset = ZLanguage::getEncoding();
        if (strtolower($charset) != 'utf-8') {
            // set a different character encoding with iconv
            $config['Core']['Encoding'] = $charset;
            // Note that HTML Purifier's support for non-Unicode encodings is crippled by the
            // fact that any character not supported by that encoding will be silently
            // dropped, EVEN if it is ampersand escaped.  If you want to work around
            // this, you are welcome to read docs/enduser-utf8.html in the full package for a fix,
            // but please be cognizant of the issues the "solution" creates (for this
            // reason, I do not include the solution in this document).
        }

        // determine doctype of current theme
        // supported doctypes include:
        //
        // HTML 4.01 Strict
        // HTML 4.01 Transitional
        // XHTML 1.0 Strict
        // XHTML 1.0 Transitional (default)
        // XHTML 1.1
        //
        // TODO - we need a new theme field for doctype declaration
        // for now we will use non-strict modes
        $currentThemeID = ThemeUtil::getIDFromName(UserUtil::getTheme());
        $themeInfo = ThemeUtil::getInfo($currentThemeID);
        $useXHTML = (isset($themeInfo['xhtml']) && $themeInfo['xhtml']) ? true : false;

        // as XHTML 1.0 Transitional is the default, we only set HTML (for now)
        if (!$useXHTML) {
            $config['HTML']['Doctype'] = 'HTML 4.01 Transitional';
        }

        // allow nofollow and imageviewer to be used as document relationships in the rel attribute
        // see http://htmlpurifier.org/live/configdoc/plain.html#Attr.AllowedRel
        $config['Attr']['AllowedRel'] = array('nofollow' => true, 'imageviewer' => true, 'lightbox' => true);

        // allow Youtube by default
        $config['Filter']['YouTube'] = false; // technically deprecated in favour of HTML.SafeEmbed and HTML.Object

        // general enable for embeds and objects
        $config['HTML']['SafeObject'] = true;
        $config['Output']['FlashCompat'] = true;
        $config['HTML']['SafeEmbed'] = true;

        return $config;
    }
/**
 * Zikula_View function to include module specific javascripts
 *
 * Available parameters:
 *  - modname     module name (if not set, the current module is assumed)
 *                if modname="" than we will look into the main javascript folder
 *  - script      name of the external javascript file (mandatory)
 *  - modonly     javascript will only be included when the the current module is $modname
 *  - onload      function to be called with onLoad handler in body tag, makes sense with assign set only, see example #2
 *  - assign      if set, the tag and the script filename are returned
 *
 * Example: {modulejavascript modname=foobar script=module_admin_config.js modonly=1 }
 * Output:  <script type="text/javascript" src="modules/foobar/javascript/module_admin_config.js">
 *
 * Example: {modulejavascript modname=foobar script=module_admin_config.js modonly=1 onload="dosomething()" assign=myjs }
 * Output: nothing, but assigns a variable containing several values:
 *      $myjs.scriptfile = "modules/foobar/javascript/module_admin_config.js"
 *      $myjs.tag = "<script type=\"text/javascript\" src=\"modules/foobar/javascript/module_admin_config.js\"></script>"
 *      $myjs.onload = "onLoad=\"dosomething()\"";
 *      Possible code in master.tpl would be:
 *
 *      ...
 *      { $myjs.tag }
 *      </head>
 *      <body { $myjs.onload } >
 *      ...
 *
 *      which results in
 *
 *      ...
 *      <script type="text/javascript" src="modules/foobar/javascript/module_admin_config.js"></script>
 *      </head>
 *      <body onLoad="dosomething()" >
 *      ...
 *
 *      if foobar is the current module.
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string The tag.
 */
function smarty_function_modulejavascript($params, Zikula_View $view)
{
    // check if script is set (mandatory)
    if (!isset($params['script'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modulejavascript', 'script')));
        return false;
    }
    // check if modname is set and if not, if $modonly is set
    if (!isset($params['modname'])) {
        if (isset($params['modonly'])) {
            // error - we want $modonly only with $modname
            $view->trigger_error(__f('Error! in %1$s: parameter \'%2$s\' only supported together with \'%3$s\' set.', array('modulejavascript', 'modonly', 'modname')));
            return;
        }
        // we use the current module name
        $params['modname'] = ModUtil::getName();
    }
    if (isset($params['modonly']) && $params['modname'] != ModUtil::getName()) {
        // current module is not $modname - do nothing and return silently
        return;
    }
    // if modname is empty, we will search the main javascript folder
    if ($params['modname'] == '') {
        $searchpaths = array('javascript', 'javascript/ajax');
    } else {
        // theme directory
        $theme = DataUtil::formatForOS(UserUtil::getTheme());
        $osmodname = DataUtil::formatForOS($params['modname']);
        $themepath = "themes/{$theme}/Resources/public/js/{$osmodname}";
        // module directory
        $modinfo = ModUtil::getInfoFromName($params['modname']);
        $osmoddir = DataUtil::formatForOS($modinfo['directory']);
        $modpath = "modules/{$osmoddir}/Resources/public/js";
        $syspath = "system/{$osmoddir}/Resources/public/js";
        $searchpaths = array($themepath, $modpath, $syspath);
    }
    $osscript = DataUtil::formatForOS($params['script']);
    // search for the javascript
    $scriptsrc = '';
    foreach ($searchpaths as $path) {
        if (is_readable("{$path}/{$osscript}")) {
            $scriptsrc = "{$path}/{$osscript}";
            break;
        }
    }
    // if no module javascript has been found then return no content
    $tag = empty($scriptsrc) ? '' : '<script type="text/javascript" src="' . $scriptsrc . '"></script>';
    // onLoad event handler used?
    $onload = isset($params['onload']) ? 'onLoad="' . $params['onload'] . '"' : '';
    if (isset($params['assign'])) {
        $return = array();
        $return['scriptfile'] = $scriptsrc;
        $return['tag'] = $tag;
        $return['onload'] = $onload;
        $view->assign($params['assign'], $return);
    } else {
        return $tag;
    }
}
Ejemplo n.º 4
0
/**
 * Smarty function to display the theme info
 *
 * Example
 * {themeinfo}
 *
 * @see          function.themeinfo.php::smarty_function_themeinfo()
 * @param        array       $params      All attributes passed to this function from the template
 * @param        object      $smarty     Reference to the Smarty object
 * @return       string      the themeinfo
 */
function smarty_function_themeinfo($params, $smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('themeinfo', '$themeinfo')), E_USER_DEPRECATED);
    $thistheme = UserUtil::getTheme();
    $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($thistheme));
    $themecredits = '<!-- ' . __f('Theme: %1$s by %2$s - %3$s', array(DataUtil::formatForDisplay($themeinfo['display']), DataUtil::formatForDisplay($themeinfo['author']), DataUtil::formatForDisplay($themeinfo['contact']))) . ' -->';
    return $themecredits;
}
Ejemplo n.º 5
0
/**
 * Zikula_View function to the current users theme
 *
 * Available parameters:
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string The variables content.
 */
function smarty_function_usergettheme($params, Zikula_View $view)
{
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $result = UserUtil::getTheme();
    if ($assign) {
        $view->assign($assign, $result);
    } else {
        return $result;
    }
}
 public function __construct()
 {
     $themeName = \UserUtil::getTheme();
     $theme = \ThemeUtil::getTheme($themeName);
     if (null !== $theme && is_readable($path = $theme->getConfigPath() . '/overrides.yml')) {
         // bundle type theme
         $this->overrideMap = Yaml::parse(file_get_contents($path));
     } elseif (is_readable("themes/{$themeName}/templates/overrides.yml")) {
         // pre-1.4.0 style theme
         $this->_overrideMap = Yaml::parse(file_get_contents("themes/{$themeName}/templates/overrides.yml"));
     }
 }
Ejemplo n.º 7
0
 /**
  * Initialize form handler.
  *
  * This method takes care of all necessary initialisation of our data and form states.
  *
  * @return boolean False in case of initialization errors, otherwise true.
  */
 public function initialize(Zikula_Form_View $view)
 {
     $this->inlineUsage = UserUtil::getTheme() == 'Printer' ? true : false;
     $this->idPrefix = $this->request->getGet()->filter('idp', '', FILTER_SANITIZE_STRING);
     // initialise redirect goal
     $this->returnTo = $this->request->getGet()->filter('returnTo', null, FILTER_SANITIZE_STRING);
     // store current uri for repeated creations
     $this->repeatReturnUrl = System::getCurrentURI();
     $this->permissionComponent = $this->name . ':' . $this->objectTypeCapital . ':';
     $entityClass = $this->name . '_Entity_' . ucfirst($this->objectType);
     $objectTemp = new $entityClass();
     $this->idFields = $objectTemp->get_idFields();
     // retrieve identifier of the object we wish to view
     $this->idValues = MUBoard_Util_Controller::retrieveIdentifier($this->request, array(), $this->objectType, $this->idFields);
     $hasIdentifier = MUBoard_Util_Controller::isValidIdentifier($this->idValues);
     $entity = null;
     $this->mode = $hasIdentifier ? 'edit' : 'create';
     if ($this->mode == 'edit') {
         if (!SecurityUtil::checkPermission($this->permissionComponent, '::', ACCESS_EDIT)) {
             // set an error message and return false
             return LogUtil::registerPermissionError();
         }
         $entity = $this->initEntityForEdit();
         if ($this->hasPageLockSupport === true && ModUtil::available('PageLock')) {
             // try to guarantee that only one person at a time can be editing this entity
             /*  ModUtil::apiFunc('PageLock', 'user', 'pageLock',
                 array('lockName'  => $this->name . $this->objectTypeCapital . $this->createCompositeIdentifier(),
                         'returnUrl' => $this->getRedirectUrl(null, $entity))); */
         }
     } else {
         if (!SecurityUtil::checkPermission($this->permissionComponent, '::', ACCESS_ADD)) {
             return LogUtil::registerPermissionError();
         }
         $entity = $this->initEntityForCreation($entityClass);
     }
     $this->view->assign('mode', $this->mode)->assign('inlineUsage', $this->inlineUsage);
     // We set text field to empty if entity class is posting
     if ($this->request->query->filter('ot', 'category', FILTER_SANITIZE_STRING) == 'posting' && $this->request->query->filter('func', 'main', FILTER_SANITIZE_STRING) == 'display') {
         $entity['text'] = '';
     }
     $entityData = $entity->toArray();
     // assign data to template as array (makes translatable support easier)
     $this->view->assign($this->objectTypeLower, $entityData);
     // save entity reference for later reuse
     $this->entityRef = $entity;
     $this->initializeAdditions();
     // everything okay, no initialization errors occured
     return true;
 }
Ejemplo n.º 8
0
/**
 * Smarty function build module header in user content page.
 *
 * {moduleheader}
 *
 * Available parameters:
 *  modname    Module name to display header for (optional, defaults to current module)
 *  type       Type for module links (defaults to 'user')
 *  title      Title to display in header (optional, defaults to module name)
 *  titlelink  Link to attach to title (optional, defaults to none)
 *  setpagetitle If set to true, {pagesetvar} is used to set page title
 *  insertstatusmsg If set to true, {insert name='getstatusmsg'} is put in front of template
 *  menufirst  If set to true, menu is first, then title
 *  putimage   If set to true, module image is also displayed next to title
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string A formatted string containing navigation for the module admin panel.
 */
function smarty_function_moduleheader($params, $view)
{
    if (!isset($params['modname']) || !ModUtil::available($params['modname'])) {
        $params['modname'] = ModUtil::getName();
    }
    if (empty($params['modname'])) {
        return false;
    }
    $type = isset($params['type']) ? $params['type'] : 'user';
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $menufirst = isset($params['menufirst']) ? $params['menufirst'] : false;
    $putimage = isset($params['putimage']) ? $params['putimage'] : false;
    $setpagetitle = isset($params['setpagetitle']) ? $params['setpagetitle'] : false;
    $insertstatusmsg = isset($params['insertstatusmsg']) ? $params['insertstatusmsg'] : false;
    $cutlenght = isset($params['cutlenght']) ? $params['cutlenght'] : 20;
    if ($putimage) {
        $image = isset($params['image']) ? $params['image'] : ModUtil::getModuleImagePath($params['modname']);
    } else {
        $image = '';
    }
    if (!isset($params['title'])) {
        $modinfo = ModUtil::getInfoFromName($params['modname']);
        if (isset($modinfo['displayname'])) {
            $params['title'] = $modinfo['displayname'];
        } else {
            $params['title'] = ModUtil::getName();
        }
    }
    $titlelink = isset($params['titlelink']) ? $params['titlelink'] : false;
    $renderer = Zikula_View::getInstance('Theme');
    $renderer->setCaching(Zikula_View::CACHE_DISABLED);
    $renderer->assign('userthemename', UserUtil::getTheme());
    $renderer->assign('modname', $params['modname']);
    $renderer->assign('type', $params['type']);
    $renderer->assign('title', $params['title']);
    $renderer->assign('titlelink', $titlelink);
    $renderer->assign('truncated', mb_strlen($params['title']) > $cutlenght);
    $renderer->assign('titletruncated', mb_substr($params['title'], 0, $cutlenght) . '...');
    $renderer->assign('setpagetitle', $setpagetitle);
    $renderer->assign('insertstatusmsg', $insertstatusmsg);
    $renderer->assign('menufirst', $menufirst);
    $renderer->assign('image', $image);
    if ($assign) {
        $view->assign($assign, $renderer->fetch('moduleheader.tpl'));
    } else {
        return $renderer->fetch('moduleheader.tpl');
    }
}
Ejemplo n.º 9
0
 /**
  * Save combined pagevars.
  *
  * @param array  $files     Files.
  * @param string $ext       Extention.
  * @param string $cache_dir Cache directory.
  *
  * @return array Array of file with combined pagevars file and remote files
  */
 private static function save($files, $ext, $cache_dir)
 {
     $themevars = ModUtil::getVar('ZikulaThemeModule');
     $lifetime = $themevars['cssjscombine_lifetime'];
     $hash = md5(serialize($files) . UserUtil::getTheme());
     $cachedFile = "{$cache_dir}/{$hash}_{$ext}.php";
     $cachedFileUri = "{$hash}_{$ext}.php";
     if (is_readable($cachedFile) && ($lifetime == -1 || filemtime($cachedFile) + $lifetime > time())) {
         return System::getBaseUri() . '/jcss.php?f=' . $cachedFileUri;
     }
     switch ($ext) {
         case 'css':
             $ctype = 'text/css';
             break;
         case 'js':
             $ctype = 'text/javascript';
             break;
         default:
             $ctype = 'text/plain';
             break;
     }
     $includedFiles = array();
     $outputFiles = array();
     $contents = array();
     $dest = fopen($cachedFile, 'w');
     foreach ($files as $file) {
         if (!empty($file)) {
             // skip remote files from combining
             if (is_file($file)) {
                 self::readfile($contents, $file, $ext);
                 $includedFiles[] = $file;
             } else {
                 $outputFiles[] = $file;
             }
         }
     }
     array_unshift($contents, "/* --- Combined file written: " . DateUtil::getDateTime() . " */\n\n");
     array_unshift($contents, "/* --- Combined files:\n" . implode("\n", $includedFiles) . "\n*/\n\n");
     $contents = implode('', $contents);
     // optional minify
     if ($themevars['cssjsminify'] && $ext == 'css') {
         // Remove comments.
         $contents = trim(preg_replace('/\\/\\*.*?\\*\\//s', '', $contents));
         // Compress whitespace.
         $contents = preg_replace('/\\s+/', ' ', $contents);
         // Additional whitespace optimisation -- spaces around certain tokens is not required by CSS
         $contents = preg_replace('/\\s*(;|\\{|\\}|:|,)\\s*/', '\\1', $contents);
     }
     global $ZConfig;
     $signingKey = md5(serialize($ZConfig['DBInfo']['databases']['default']));
     $signature = md5($contents . $ctype . $lifetime . $themevars['cssjscompress'] . $signingKey);
     $data = array('contents' => $contents, 'ctype' => $ctype, 'lifetime' => $lifetime, 'gz' => $themevars['cssjscompress'], 'signature' => $signature);
     fwrite($dest, serialize($data));
     fclose($dest);
     $combined = System::getBaseUri() . '/jcss.php?f=' . $cachedFileUri;
     array_unshift($outputFiles, $combined);
     return $outputFiles;
 }
Ejemplo n.º 10
0
 /**
  * Constructor.
  *
  * @param Zikula_ServiceManager $serviceManager ServiceManager.
  * @param string                $moduleName     Module name ("zikula" for system plugins).
  * @param integer|null          $caching        Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
  */
 public function __construct(Zikula_ServiceManager $serviceManager, $moduleName = '', $caching = null)
 {
     $this->serviceManager = $serviceManager;
     $this->eventManager = $this->serviceManager->get('event_dispatcher');
     $this->request = \ServiceUtil::get('request');
     // set the error reporting level
     $this->error_reporting = isset($GLOBALS['ZConfig']['Debug']['error_reporting']) ? $GLOBALS['ZConfig']['Debug']['error_reporting'] : E_ALL;
     $this->error_reporting &= ~E_USER_DEPRECATED;
     $this->allow_php_tag = true;
     // get variables from input
     $module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING);
     $type = FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
     $func = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING);
     // set vars based on the module structures
     $this->homepage = PageUtil::isHomepage();
     $this->type = strtolower(!$this->homepage ? $type : System::getVar('starttype'));
     $this->func = strtolower(!$this->homepage ? $func : System::getVar('startfunc'));
     // Initialize the module property with the name of
     // the topmost module. For Hooks, Blocks, API Functions and others
     // you need to set this property to the name of the respective module!
     $this->toplevelmodule = ModUtil::getName();
     if (!$moduleName) {
         $moduleName = $this->toplevelmodule;
     }
     $this->modinfo = ModUtil::getInfoFromName($moduleName);
     $this->module = array($moduleName => $this->modinfo);
     // initialise environment vars
     $this->language = ZLanguage::getLanguageCode();
     $this->baseurl = System::getBaseUrl();
     $this->baseuri = System::getBaseUri();
     // system info
     $this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
     $this->theme = $theme = $this->themeinfo['directory'];
     $themeBundle = ThemeUtil::getTheme($this->themeinfo['name']);
     //---- Plugins handling -----------------------------------------------
     // add plugin paths
     switch ($this->modinfo['type']) {
         case ModUtil::TYPE_MODULE:
             $mpluginPathNew = "modules/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             $mpluginPath = "modules/" . $this->modinfo['directory'] . "/templates/plugins";
             break;
         case ModUtil::TYPE_SYSTEM:
             $mpluginPathNew = "system/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             $mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
             break;
         default:
             $mpluginPathNew = "system/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             $mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
     }
     // add standard plugin search path
     $this->plugins_dir = array();
     $this->addPluginDir('config/plugins');
     // Official override
     $this->addPluginDir('lib/legacy/viewplugins');
     // Core plugins
     $this->addPluginDir(isset($themeBundle) ? $themeBundle->getRelativePath() . '/plugins' : "themes/{$theme}/plugins");
     // Theme plugins
     $this->addPluginDir('plugins');
     // Smarty core plugins
     $this->addPluginDir($mpluginPathNew);
     // Plugins for current module
     $this->addPluginDir($mpluginPath);
     // Plugins for current module
     // check if the 'type' parameter in the URL is admin or adminplugin
     $legacyControllerType = FormUtil::getPassedValue('lct', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
     if ($type === 'admin' || $type === 'adminplugin' || $legacyControllerType === 'admin') {
         // include plugins of the Admin module to the plugins_dir array
         if (!$this instanceof Zikula_View_Theme) {
             $this->addPluginDir('system/AdminModule/Resources/views/plugins');
         } else {
             $this->load_filter('output', 'admintitle');
         }
     }
     // theme plugins module overrides
     $themePluginsPath = isset($themeBundle) ? $themeBundle->getRelativePath() . '/modules/$moduleName/plugins' : "themes/{$theme}/templates/modules/{$moduleName}/plugins";
     $this->addPluginDir($themePluginsPath);
     //---- Cache handling -------------------------------------------------
     if ($caching && in_array((int) $caching, array(0, 1, 2))) {
         $this->caching = (int) $caching;
     } else {
         $this->caching = (int) ModUtil::getVar('ZikulaThemeModule', 'render_cache');
     }
     $this->compile_id = '';
     $this->cache_id = '';
     // template compilation
     $this->compile_dir = CacheUtil::getLocalDir('view_compiled');
     $this->compile_check = ModUtil::getVar('ZikulaThemeModule', 'render_compile_check');
     $this->force_compile = ModUtil::getVar('ZikulaThemeModule', 'render_force_compile');
     // template caching
     $this->cache_dir = CacheUtil::getLocalDir('view_cache');
     $this->cache_lifetime = ModUtil::getVar('ZikulaThemeModule', 'render_lifetime');
     $this->expose_template = ModUtil::getVar('ZikulaThemeModule', 'render_expose_template') == true ? true : false;
     // register resource type 'z' this defines the way templates are searched
     // during {include file='my_template.tpl'} this enables us to store selected module
     // templates in the theme while others can be kept in the module itself.
     $this->register_resource('z', array('Zikula_View_Resource', 'z_get_template', 'z_get_timestamp', 'z_get_secure', 'z_get_trusted'));
     // set 'z' as default resource type
     $this->default_resource_type = 'z';
     // process some plugins specially when Render cache is enabled
     if (!$this instanceof Zikula_View_Theme && $this->caching) {
         $this->register_nocache_plugins();
     }
     // register the 'nocache' block to allow dynamic zones caching templates
     $this->register_block('nocache', array('Zikula_View_Resource', 'block_nocache'), false);
     // For ajax requests we use the short urls filter to 'fix' relative paths
     if ($this->serviceManager->get('zikula')->getStage() & Zikula_Core::STAGE_AJAX && System::getVar('shorturls')) {
         $this->load_filter('output', 'shorturls');
     }
     // register prefilters
     $this->register_prefilter('z_prefilter_add_literal');
     $this->register_prefilter('z_prefilter_gettext_params');
     //$this->register_prefilter('z_prefilter_notifyfilters');
     // assign some useful settings
     $this->assign('homepage', $this->homepage)->assign('modinfo', $this->modinfo)->assign('module', $moduleName)->assign('toplevelmodule', $this->toplevelmodule)->assign('type', $this->type)->assign('func', $this->func)->assign('lang', $this->language)->assign('themeinfo', $this->themeinfo)->assign('themepath', isset($themeBundle) ? $themeBundle->getRelativePath() : $this->baseurl . 'themes/' . $theme)->assign('baseurl', $this->baseurl)->assign('baseuri', $this->baseuri)->assign('moduleBundle', ModUtil::getModule($moduleName))->assign('themeBundle', $themeBundle);
     if (isset($themeBundle)) {
         $stylePath = $themeBundle->getRelativePath() . "/Resources/public/css";
         $javascriptPath = $themeBundle->getRelativePath() . "/Resources/public/js";
         $imagePath = $themeBundle->getRelativePath() . "/Resources/public/images";
         $imageLangPath = $themeBundle->getRelativePath() . "/Resources/public/images/" . $this->language;
     } else {
         $stylePath = $this->baseurl . "themes/{$theme}/style";
         $javascriptPath = $this->baseurl . "themes/{$theme}/javascript";
         $imagePath = $this->baseurl . "themes/{$theme}/images";
         $imageLangPath = $this->baseurl . "themes/{$theme}/images/" . $this->language;
     }
     $this->assign('stylepath', $stylePath)->assign('scriptpath', $javascriptPath)->assign('imagepath', $imagePath)->assign('imagelangpath', $imageLangPath);
     // for {gt} template plugin to detect gettext domain
     if ($this->modinfo['type'] == ModUtil::TYPE_MODULE) {
         $this->domain = ZLanguage::getModuleDomain($this->modinfo['name']);
     }
     // make render object available to modifiers
     parent::assign('zikula_view', $this);
     // add ServiceManager, EventManager and others to all templates
     parent::assign('serviceManager', $this->serviceManager);
     parent::assign('eventManager', $this->eventManager);
     parent::assign('zikula_core', $this->serviceManager->get('zikula'));
     parent::assign('request', $this->request);
     $modvars = ModUtil::getModvars();
     // Get all modvars from any modules that have accessed their modvars at least once.
     // provide compatibility 'alias' array keys
     // @todo remove after v1.4.0
     if (isset($modvars['ZikulaAdminModule'])) {
         $modvars['Admin'] = $modvars['ZikulaAdminModule'];
     }
     if (isset($modvars['ZikulaBlocksModule'])) {
         $modvars['Blocks'] = $modvars['ZikulaBlocksModule'];
     }
     if (isset($modvars['ZikulaCategoriesModule'])) {
         $modvars['Categories'] = $modvars['ZikulaCategoriesModule'];
     }
     if (isset($modvars['ZikulaExtensionsModule'])) {
         $modvars['Extensions'] = $modvars['ZikulaExtensionsModule'];
     }
     if (isset($modvars['ZikulaGroupsModule'])) {
         $modvars['Groups'] = $modvars['ZikulaGroupsModule'];
     }
     if (isset($modvars['ZikulaMailerModule'])) {
         $modvars['Mailer'] = $modvars['ZikulaMailerModule'];
     }
     if (isset($modvars['ZikulaPageLockModule'])) {
         $modvars['PageLock'] = $modvars['ZikulaPageLockModule'];
     }
     if (isset($modvars['ZikulaPermissionsModule'])) {
         $modvars['Permissions'] = $modvars['ZikulaPermissionsModule'];
     }
     if (isset($modvars['ZikulaSearchModule'])) {
         $modvars['Search'] = $modvars['ZikulaSearchModule'];
     }
     if (isset($modvars['ZikulaSecurityCenterModule'])) {
         $modvars['SecurityCenter'] = $modvars['ZikulaSecurityCenterModule'];
     }
     if (isset($modvars['ZikulaSettingsModule'])) {
         $modvars['Settings'] = $modvars['ZikulaSettingsModule'];
     }
     if (isset($modvars['ZikulaThemeModule'])) {
         $modvars['Theme'] = $modvars['ZikulaThemeModule'];
     }
     if (isset($modvars['ZikulaUsersModule'])) {
         $modvars['Users'] = $modvars['ZikulaUsersModule'];
     }
     // end compatibility aliases
     parent::assign('modvars', $modvars);
     $this->add_core_data();
     // metadata for SEO
     if (!$this->serviceManager->hasParameter('zikula_view.metatags')) {
         $this->serviceManager->setParameter('zikula_view.metatags', new ArrayObject(array()));
     }
     parent::assign('metatags', $this->serviceManager->getParameter('zikula_view.metatags'));
     if (isset($themeBundle) && $themeBundle->isTwigBased()) {
         // correct asset urls when smarty output is wrapped by twig theme
         $this->load_filter('output', 'asseturls');
     }
     $event = new \Zikula\Core\Event\GenericEvent($this);
     $this->eventManager->dispatch('view.init', $event);
 }
Ejemplo n.º 11
0
 /**
  * Get the modules stylesheet from several possible sources.
  *
  * @param string $modname    The modules name (optional, defaults to top level module).
  * @param string $stylesheet The stylesheet file (optional).
  *
  * @return string Path of the stylesheet file, relative to PN root folder.
  */
 public static function getModuleStylesheet($modname = '', $stylesheet = '')
 {
     // default for the module
     if (empty($modname)) {
         $modname = ModUtil::getName();
     }
     $modname = preg_match('/\\w+Module$/', $modname) ? $modname : $modname . 'Module';
     // default for the style sheet
     if (empty($stylesheet)) {
         $stylesheet = ModUtil::getVar($modname, 'modulestylesheet');
         if (empty($stylesheet)) {
             $stylesheet = 'style.css';
         }
     }
     $osstylesheet = DataUtil::formatForOS($stylesheet);
     $osmodname = DataUtil::formatForOS($modname);
     // config directory
     $configstyledir = 'config/style';
     $configpath = "{$configstyledir}/{$osmodname}";
     // theme directory
     $theme = DataUtil::formatForOS(UserUtil::getTheme());
     $themepath = "themes/{$theme}/Resources/public/css/{$osmodname}";
     // module directory
     $modinfo = ModUtil::getInfoFromName($modname);
     $osmoddir = DataUtil::formatForOS($modinfo['directory']);
     $modpath = "modules/{$osmoddir}/Resources/public/css";
     $syspath = "system/{$osmoddir}/Resources/public/css";
     // search for the style sheet
     $csssrc = '';
     foreach (array($configpath, $themepath, $modpath, $syspath) as $path) {
         if (is_readable("{$path}/{$osstylesheet}")) {
             $csssrc = "{$path}/{$osstylesheet}";
             break;
         }
     }
     return $csssrc;
 }
Ejemplo n.º 12
0
/**
 * Zikula_View function to provide easy access to an image
 *
 * This function provides an easy way to include an image. The function will return the
 * full source path to the image. It will as well provite the width and height attributes
 * if none are set.
 *
 * Available parameters:
 *   - src            The file name of the image
 *   - modname        The well-known name of a module (default: the current module)
 *   - width, height  If set, they will be passed. If none is set, they are obtained from the image
 *   - alt            If not set, an empty string is being assigned
 *   - title          If set it will be passed as a title attribute
 *   - assign         If set, the results are assigned to the corresponding variable instead of printed out
 *   - optional       If set then the plugin will not return an error if an image is not found
 *   - default        If set then a default image is used should the requested image not be found (Note: full path required)
 *   - set            If modname is 'core' then the set parameter is set to define the directory in /images/
 *   - nostoponerror  If set and error ocurs (image not found or src is no image), do not trigger_error, but return false and fill pnimg_error instead
 *   - retval         If set indicated the field to return instead the array of values (src, width, etc.)
 *   - fqurl          If set the image path is absolute, if not relative
 *   - all remaining parameters are passed to the image tag
 *
 * Example: {img src="heading.png" }
 * Output:  <img src="modules/Example/images/en/heading.png" alt="" width="261" height="69"  />
 *
 * Example: {img src="heading.png" width="100" border="1" alt="foobar" }
 * Output:  <img src="modules/Example/images/en/heading.png" width="100" border="1" alt="foobar"  />
 *
 * Example {img src=xhtml11.png modname=core set=powered}
 * <img src="/Theme/images/powered/xhtml11.png" alt="" width="88" height="31"  />
 *
 * If the parameter assign is set, the results are assigned as an array. The components of
 * this array are the same as the attributes of the img tag; additionally an entry 'imgtag' is
 * set to the complete image tag.
 *
 * Example:
 * {img src="heading.png" assign="myvar"}
 * {$myvar.src}
 * {$myvar.width}
 * {$myvar.imgtag}
 *
 * Output:
 * modules/Example/images/en/heading.gif
 * 261
 * <img src="modules/Example/images/en/heading.gif" alt="" width="261" height="69"  />
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string|void The img tag, null if $params['nostoponerror'] true and there is an error.
 */
function smarty_function_img($params, Zikula_View $view)
{
    $nostoponerror = (isset($params['nostoponerror'])) ? true : false;

    if (!isset($params['src'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('img', 'src')));
        if ($nostoponerror == true) {
            return;
        } else {
            return false;
        }
    }

    // default for the module
    $modname = isset($params['modname']) ? $params['modname'] : $view->toplevelmodule;

    // if the module name is 'core' then we require an image set
    if ($modname == 'core') {
        if (!isset($params['set'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('img', 'set')));
            if ($nostoponerror == true) {
                return;
            } else {
                return false;
            }
        }
        $osset = DataUtil::formatForOS($params['set']);
        if (System::isLegacyMode() && (strpos($osset, 'icons/') !== false || strpos($osset, 'global/') !== false) && strpos($params['src'], '.gif')) {
            LogUtil::log(__f('Core image %s does not exist, please use the png format (called from %s).', array($params['src'], $view->getTemplatePath())), E_DEPRECATED);
            $params['src'] = str_replace('.gif', '.png', $params['src']);
        }
    }

    // default for the optional flag
    $optional = isset($params['optional']) ? $params['optional'] : true;

    // always provide an alt attribute.
    // if none is set, assign an empty one.
    $params['alt'] = isset($params['alt']) ? $params['alt'] : '';

    if (!isset($params['title'])) {
        $params['title'] = '';
    }

    // prevent overwriting surrounding titles (#477)
    if (empty($params['title'])) {
        unset($params['title']);
    }

    // language
    $lang =  ZLanguage::transformFS(ZLanguage::getLanguageCode());

    // theme directory
    $theme         = DataUtil::formatForOS(UserUtil::getTheme());
    $osmodname     = DataUtil::formatForOS($modname);
    $themelangpath = "themes/$theme/templates/modules/$osmodname/images/$lang";
    $themepath     = "themes/$theme/templates/modules/$osmodname/images";
    $corethemepath = "themes/$theme/images";

    // module directory
    $modinfo       = ModUtil::getInfoFromName($modname);
    $osmoddir      = DataUtil::formatForOS($modinfo['directory']);
    $moduleDir     = ($modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules');
    if ($modname == 'core') {
        $modpath        = "images/$osset";
    } else {
        $modlangpath    = "$moduleDir/$osmoddir/images/$lang";
        $modpath        = "$moduleDir/$osmoddir/images";
        $modlangpathOld = "$moduleDir/$osmoddir/pnimages/$lang";
        $modpathOld     = "$moduleDir/$osmoddir/pnimages";
    }
    $ossrc = DataUtil::formatForOS($params['src']);

    // form the array of paths
    if ($modname == 'core') {
        $paths = array($themepath, $corethemepath, $modpath);
    } else {
        $paths = array($themelangpath, $themepath, $corethemepath, $modlangpath, $modpath, $modlangpathOld, $modpathOld);
    }

    // search for the image
    $imgsrc = '';
    foreach ($paths as $path) {
        if (is_readable("$path/$ossrc")) {
            $imgsrc = "$path/$ossrc";
            break;
        }
    }

    if ($imgsrc == '' && isset($params['default'])) {
        $imgsrc = $params['default'];
    }

    if ($imgsrc == '') {
        if ($optional) {
            $view->trigger_error(__f("%s: Image '%s' not found", array('img', DataUtil::formatForDisplay($params['src']))));
            if ($nostoponerror == true) {
                return;
            } else {
                return false;
            }
        }
        return;
    }

    // If neither width nor height is set, get these parameters.
    // If one of them is set, we do NOT obtain the real dimensions.
    // This way it is easy to scale the image to a certain dimension.
    if (!isset($params['width']) && !isset($params['height'])) {
        if (!($_image_data = @getimagesize($imgsrc))) {
            $view->trigger_error(__f("%s: Image '%s' is not a valid image file", array('pnimg', DataUtil::formatForDisplay($params['src']))));
            if ($nostoponerror == true) {
                return;
            } else {
                return false;
            }
        }
        $params['width']  = $_image_data[0];
        $params['height'] = $_image_data[1];
    }

    $basepath = (isset($params['fqurl']) && $params['fqurl']) ? System::getBaseUrl() : System::getBaseUri();
    $params['src'] = $basepath . '/' . $imgsrc;

    $retval = isset($params['retval']) ? $params['retval'] : null;

    unset($params['modname']);
    $assign = null;
    if (isset($params['assign'])) {
        $assign = $params['assign'];
        unset($params['assign']);
    }
    unset($params['retval']);
    if (isset($params['altml'])) {
        // legacy
        unset($params['altml']);
    }
    if (isset($params['titleml'])) {
        // legacy
        unset($params['titleml']);
    }
    unset($params['optional']);
    unset($params['default']);
    unset($params['set']);
    unset($params['nostoponerror']);
    unset($params['fqurl']);

    $imgtag = '<img ';
    foreach ($params as $key => $value) {
        $imgtag .= $key . '="' .$value  . '" ';
    }
    $imgtag .= '/>';

    if (!empty($retval) && isset($params[$retval])) {
        return $params[$retval];
    } else if (!empty($assign)) {
        $params['imgtag'] = $imgtag;
        $view->assign($assign, $params);
    } else {
        return $imgtag;
    }
}
Ejemplo n.º 13
0
    /**
     * Get the templateset stylesheet from several possible sources
     *
     * @access public
     * @param  string $path    the templateset/css path
     * @return string path of the stylesheet file, relative to Zikula root folder
     */
    public function getStylesheet($args = array())
    {
        // default for the style sheet
        if (!isset($args['path']) || empty($args['path'])) {
            $defaultcss  = $this->getVar('css', 'style.css');
            $args['path'] = 'Standard/' . $defaultcss;
        }

        $ospath = DataUtil::formatForOS($args['path']);

        // config directory
        $configpath = "config/templates/EZComments";

        // theme directory
        $theme = DataUtil::formatForOS(UserUtil::getTheme());
        $themepath = "themes/$theme/templates/modules/EZComments";

        // module directory
        $modpath = "modules/EZComments/templates";

        // search for the style sheet
        $csssrc = '';
        foreach (array($configpath, $themepath, $modpath) as $basepath) {
            if (!file_exists("$basepath/$ospath") || !is_readable("$basepath/$ospath")) {
                continue;
            }
            $csssrc = "$basepath/$ospath";
            break;
        }
        return $csssrc;
    }
Ejemplo n.º 14
0
 /**
  * Initialise scribite for requested areas.
  *
  * @param array $args Text area: 'area', Module name: 'modulename'.
  *
  * @return string
  */
 public static function loader($args)
 {
     $dom = ZLanguage::getModuleDomain('Scribite');
     // Argument checks
     if (!isset($args['areas'])) {
         return LogUtil::registerError(__('Error! Scribite_Api_User::loader() "area" argument was empty.', $dom));
     }
     if (!isset($args['modulename'])) {
         $args['modulename'] = ModUtil::getName();
     }
     $module = $args['modulename'];
     // Security check if user has COMMENT permission for scribite and module
     if (!SecurityUtil::checkPermission('Scribite::', "{$module}::", ACCESS_COMMENT)) {
         return;
     }
     // check for editor argument, if none given the default editor will be used
     if (!isset($args['editor']) || empty($args['editor'])) {
         // get default editor from config
         $defaulteditor = ModUtil::getVar('Scribite', 'DefaultEditor');
         if ($defaulteditor == '-') {
             return;
             // return if no default is set and no arg is given
             // id given editor doesn't exist use default editor
         } else {
             $args['editor'] = $defaulteditor;
         }
     }
     // check if editor argument exists, load default if not given
     if (ModUtil::apiFunc('Scribite', 'user', 'getEditors', array('editorname' => $args['editor']))) {
         // set some general parameters
         $zBaseUrl = rtrim(System::getBaseUrl(), '/');
         $zikulaThemeBaseURL = "{$zBaseUrl}/themes/" . DataUtil::formatForOS(UserUtil::getTheme());
         $zikulaBaseURI = rtrim(System::getBaseUri(), '/');
         $zikulaBaseURI = ltrim($zikulaBaseURI, '/');
         $zikulaRoot = rtrim($_SERVER['DOCUMENT_ROOT'], '/');
         // prepare view instance
         $view = Zikula_View::getInstance('Scribite');
         $view->setCaching(false);
         $view->assign(ModUtil::getVar('Scribite'));
         $view->assign('modname', $args['modulename']);
         $view->assign('zBaseUrl', $zBaseUrl);
         $view->assign('zikulaBaseURI', $zikulaBaseURI);
         $view->assign('zikulaRoot', $zikulaRoot);
         $view->assign('editor_dir', $args['editor']);
         $view->assign('zlang', ZLanguage::getLanguageCode());
         // check for modules installed providing plugins and load specific javascripts
         if (ModUtil::available('photoshare')) {
             PageUtil::AddVar('javascript', 'modules/photoshare/javascript/findimage.js');
         }
         if (ModUtil::available('mediashare')) {
             PageUtil::AddVar('javascript', 'modules/mediashare/javascript/finditem.js');
         }
         if (ModUtil::available('pagesetter')) {
             PageUtil::AddVar('javascript', 'modules/pagesetter/javascript/findpub.js');
         }
         if (ModUtil::available('folder')) {
             PageUtil::AddVar('javascript', 'modules/folder/javascript/selector.js');
         }
         if (ModUtil::available('MediaAttach')) {
             PageUtil::AddVar('javascript', 'modules/MediaAttach/javascript/finditem.js');
         }
         if (ModUtil::available('Files')) {
             PageUtil::AddVar('javascript', 'modules/Files/javascript/getFiles.js');
         }
         // main switch for choosen editor
         switch ($args['editor']) {
             case 'xinha':
                 // get xinha config if editor is active
                 // get plugins for xinha
                 $xinha_listplugins = ModUtil::getVar('Scribite', 'xinha_activeplugins');
                 if ($xinha_listplugins != '') {
                     $xinha_listplugins = unserialize($xinha_listplugins);
                     /* if (in_array('ExtendedFileManager', $xinha_listplugins)) {
                        $view->assign('EFMConfig', true);
                        } else { */
                     $view->assign('EFMConfig', false);
                     //}
                     $xinha_listplugins = '\'' . DataUtil::formatForDisplay(implode('\', \'', $xinha_listplugins)) . '\'';
                 }
                 // prepare areas for xinha
                 if ($args['areas'][0] == "all") {
                     $modareas = 'all';
                 } elseif ($args['areas'][0] == "PagEd") {
                     $modareas = 'PagEd';
                 } else {
                     $modareas = '\'' . DataUtil::formatForDisplay(implode('\', \'', $args['areas'])) . '\'';
                 }
                 // load Prototype
                 PageUtil::AddVar('javascript', 'prototype');
                 // set parameters
                 $view->assign('modareas', $modareas);
                 $view->assign('xinha_listplugins', $xinha_listplugins);
                 // end xinha
                 break;
                 // openwysiwyg deprecated @4.3.0
                 //                case 'openwysiwyg':
                 //                    // get openwysiwyg config if editor is active
                 //                    // prepare areas for openwysiwyg
                 //                    if ($args['areas'][0] == "all") {
                 //                        $modareas = 'all';
                 //                    } else {
                 //                        $modareas = $args['areas'];
                 //                    }
                 //
                 //                    // set parameters
                 //                    $view->assign('modareas', $modareas);
                 //
                 //                    // end openwysiwyg
                 //                    break;
             // openwysiwyg deprecated @4.3.0
             //                case 'openwysiwyg':
             //                    // get openwysiwyg config if editor is active
             //                    // prepare areas for openwysiwyg
             //                    if ($args['areas'][0] == "all") {
             //                        $modareas = 'all';
             //                    } else {
             //                        $modareas = $args['areas'];
             //                    }
             //
             //                    // set parameters
             //                    $view->assign('modareas', $modareas);
             //
             //                    // end openwysiwyg
             //                    break;
             case 'nicedit':
                 // get nicEditor config if editor is active
                 // prepare areas for nicEditor
                 if ($args['areas'][0] == "all") {
                     $modareas = 'all';
                 } else {
                     $modareas = $args['areas'];
                 }
                 // set parameters
                 $view->assign('modareas', $modareas);
                 // end nicEditor
                 break;
             case 'yui':
                 // set body class for YUI Editor
                 PageUtil::SetVar('body', 'class="yui-skin-sam"');
                 // get YUI mode from config
                 $yui_type = ModUtil::getVar('Scribite', 'yui_type');
                 // type switch
                 if ($yui_type == 'Simple') {
                     // load scripts for YUI simple mode
                     PageUtil::AddVar('stylesheet', 'http://yui.yahooapis.com/2.9.0/build/assets/skins/sam/skin.css');
                     PageUtil::AddVar('javascript', 'http://yui.yahooapis.com/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js');
                     PageUtil::AddVar('javascript', 'http://yui.yahooapis.com/2.9.0/build/element/element-min.js');
                     PageUtil::AddVar('javascript', 'http://yui.yahooapis.com/2.9.0/build/container/container_core-min.js');
                     PageUtil::AddVar('javascript', 'http://yui.yahooapis.com/2.9.0/build/editor/simpleeditor-min.js');
                 } else {
                     // load scripts for YUI Editor full mode
                     PageUtil::AddVar('stylesheet', 'http://yui.yahooapis.com/2.9.0/build/assets/skins/sam/skin.css');
                     PageUtil::AddVar('javascript', 'http://yui.yahooapis.com/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js');
                     PageUtil::AddVar('javascript', 'http://yui.yahooapis.com/2.9.0/build/element/element-min.js');
                     PageUtil::AddVar('javascript', 'http://yui.yahooapis.com/2.9.0/build/container/container_core-min.js');
                     PageUtil::AddVar('javascript', 'http://yui.yahooapis.com/2.9.0/build/menu/menu-min.js');
                     PageUtil::AddVar('javascript', 'http://yui.yahooapis.com/2.9.0/build/button/button-min.js');
                     PageUtil::AddVar('javascript', 'http://yui.yahooapis.com/2.9.0/build/editor/editor-min.js');
                 }
                 // prepare areas for YUI
                 if ($args['areas'][0] == "all") {
                     $modareas = 'all';
                 } else {
                     $modareas = $args['areas'];
                 }
                 // set parameters
                 $view->assign('modareas', $modareas);
                 // end yui
                 break;
             case 'ckeditor':
                 // get CKEditor config if editor is active
                 // prepare areas
                 if ($args['areas'][0] == "all") {
                     $modareas = 'all';
                 } else {
                     $modareas = $args['areas'];
                 }
                 // check for allowed html
                 $AllowableHTML = System::getVar('AllowableHTML');
                 $disallowedhtml = array();
                 while (list($key, $access) = each($AllowableHTML)) {
                     if ($access == 0) {
                         $disallowedhtml[] = DataUtil::formatForDisplay($key);
                     }
                 }
                 // load Prototype
                 PageUtil::AddVar('javascript', 'javascript/ajax/prototype.js');
                 // set parameters
                 $view->assign('modareas', $modareas);
                 $view->assign('disallowedhtml', $disallowedhtml);
                 // end ckeditor
                 break;
             case 'markitup':
                 // get markitup config if editor is active
                 // prepare areas
                 if ($args['areas'][0] == "all") {
                     $modareas = 'all';
                 } else {
                     $modareas = $args['areas'];
                 }
                 // check for allowed html
                 $AllowableHTML = System::getVar('AllowableHTML');
                 $disallowedhtml = array();
                 while (list($key, $access) = each($AllowableHTML)) {
                     if ($access == 0) {
                         $disallowedhtml[] = DataUtil::formatForDisplay($key);
                     }
                 }
                 // set parameters
                 $view->assign('modareas', $modareas);
                 $view->assign('disallowedhtml', $disallowedhtml);
                 // end markitup
                 break;
             case 'tiny_mce':
                 // get TinyMCE config if editor is active
                 // get plugins for tiny_mce
                 $tinymce_listplugins = ModUtil::getVar('Scribite', 'tinymce_activeplugins');
                 if ($tinymce_listplugins != '') {
                     $tinymce_listplugins = unserialize($tinymce_listplugins);
                     $tinymce_listplugins = DataUtil::formatForDisplay(implode(',', $tinymce_listplugins));
                 }
                 // prepare areas for tiny_mce
                 if ($args['areas'][0] == "all") {
                     $modareas = 'all';
                 } elseif ($args['areas'][0] == "PagEd") {
                     $modareas = 'PagEd';
                 } else {
                     $modareas = DataUtil::formatForDisplay(implode(',', $args['areas']));
                 }
                 // check for allowed html
                 $AllowableHTML = System::getVar('AllowableHTML');
                 $disallowedhtml = array();
                 while (list($key, $access) = each($AllowableHTML)) {
                     if ($access == 0) {
                         $disallowedhtml[] = DataUtil::formatForDisplay($key);
                     }
                 }
                 // pass disallowed html
                 $disallowedhtml = implode(',', $disallowedhtml);
                 // set parameters
                 $view->assign('modareas', $modareas);
                 $view->assign('tinymce_listplugins', $tinymce_listplugins);
                 $view->assign('disallowedhtml', $disallowedhtml);
                 // end tiny_mce
                 break;
         }
         // view output
         // 1. check if special template is required (from direct module call)
         if (isset($args['tpl']) && $view->template_exists($args['tpl'])) {
             $templatefile = $args['tpl'];
             // 2. check if a module specific template exists
         } elseif ($view->template_exists('editorheaders/' . $args['editor'] . '_' . $args['modulename'] . '.tpl')) {
             $templatefile = 'editorheaders/' . $args['editor'] . '_' . $args['modulename'] . '.tpl';
             // 3. if none of the above load default template
         } else {
             $templatefile = 'editorheaders/' . $args['editor'] . '.tpl';
         }
         $output = $view->fetch($templatefile);
         // end main switch
         return $output;
     }
 }
Ejemplo n.º 15
0
    /**
     * Get the modules stylesheet from several possible sources.
     *
     * @param string $modname    The modules name (optional, defaults to top level module).
     * @param string $stylesheet The stylesheet file (optional).
     *
     * @return string Path of the stylesheet file, relative to PN root folder.
     */
    public static function getModuleStylesheet($modname = '', $stylesheet = '')
    {
        // default for the module
        if (empty($modname)) {
            $modname = ModUtil::getName();
        }

        // default for the style sheet
        if (empty($stylesheet)) {
            $stylesheet = ModUtil::getVar($modname, 'modulestylesheet');
            if (empty($stylesheet)) {
                $stylesheet = 'style.css';
            }
        }

        $osstylesheet = DataUtil::formatForOS($stylesheet);
        $osmodname = DataUtil::formatForOS($modname);

        // config directory
        $configstyledir = 'config/style';
        $configpath = "$configstyledir/$osmodname";

        // theme directory
        $theme = DataUtil::formatForOS(UserUtil::getTheme());
        $themepath = "themes/$theme/style/$osmodname";

        // module directory
        $modinfo = ModUtil::getInfoFromName($modname);
        $osmoddir = DataUtil::formatForOS($modinfo['directory']);
        $modpath = "modules/$osmoddir/style";
        $syspath = "system/$osmoddir/style";
        $modpathOld = "modules/$osmoddir/pnstyle";
        $syspathOld = "system/$osmoddir/pnstyle";

        // search for the style sheet
        $csssrc = '';
        foreach (array($configpath, $themepath, $modpath, $syspath, $modpathOld, $syspathOld) as $path) {
            if (is_readable("$path/$osstylesheet")) {
                $csssrc = "$path/$osstylesheet";
                break;
            }
        }
        return $csssrc;
    }
Ejemplo n.º 16
0
    public function display($blockinfo)
    {
        // check if the module is available
        if (!ModUtil::available('Theme')) {
            return;
        }

        // check if theme switching is allowed
        if (!System::getVar('theme_change')) {
            return;
        }

        // security check
        if (!SecurityUtil::checkPermission( "Themeswitcherblock::", "$blockinfo[title]::", ACCESS_READ)) {
            return;
        }

        // Get variables from content block
        $vars = BlockUtil::varsFromContent($blockinfo['content']);

        // Defaults
        if (empty($vars['format'])) {
            $vars['format'] = 1;
        }

        // get some use information about our environment
        $currenttheme = UserUtil::getTheme();

        // get all themes in our environment
        $themes = ThemeUtil::getAllThemes();

        // get some use information about our environment
        $currenttheme = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));

        // get all themes in our environment
        $themes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_USER);

        $previewthemes = array();
        $currentthemepic = null;
        foreach ($themes as $themeinfo) {
            $themename = $themeinfo['name'];
            if (file_exists($themepic = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/images/preview_small.png')) {
                $themeinfo['previewImage'] = $themepic;
            } else {
                $themeinfo['previewImage'] = 'system/Theme/images/preview_small.png';
            }
            $previewthemes[$themename] = $themeinfo;
            if ($themename == $currenttheme['name']) {
                $currentthemepic = $themeinfo['previewImage'];
            }
        }

        $this->view->assign($vars)
                   ->assign('currentthemepic', $currentthemepic)
                   ->assign('currenttheme', $currenttheme)
                   ->assign('themes', $previewthemes);

        $blockinfo['content'] = $this->view->fetch('theme_block_themeswitcher.tpl');

        return BlockUtil::themeBlock($blockinfo);
    }
Ejemplo n.º 17
0
/**
 * Zikula_View function to provide easy access to an image
 *
 * This function provides an easy way to include an image. The function will return the
 * full source path to the image. It will as well provite the width and height attributes
 * if none are set.
 *
 * Available parameters:
 *   - src            The file name of the image
 *   - modname        The well-known name of a module (default: the current module)
 *   - modplugin      The name of the plugin in the passed module
 *   - sysplugin      The name of the system plugin
 *   - width, height  If set, they will be passed. If none is set, they are obtained from the image
 *   - alt            If not set, an empty string is being assigned
 *   - title          If set it will be passed as a title attribute
 *   - assign         If set, the results are assigned to the corresponding variable instead of printed out
 *   - optional       If set then the plugin will not return an error if an image is not found
 *   - default        If set then a default image is used should the requested image not be found (Note: full path required)
 *   - set            If modname is 'core' then the set parameter is set to define the directory in /images/
 *   - nostoponerror  If set and error ocurs (image not found or src is no image), do not trigger_error, but return false
 *   - retval         If set indicated the field to return instead the array of values (src, width, etc.)
 *   - fqurl          If set the image path is absolute, if not relative
 *   - all remaining parameters are passed to the image tag
 *
 * Example: {img src='heading.png'}
 * Output:  <img src="modules/Example/images/en/heading.png" alt="" width="261" height="69" />
 *
 * Example: {img src='heading.png' width='100' border='1' __alt='foobar'}
 * Output:  <img src="modules/Example/images/en/heading.png" width="100" border="1" alt="foobar" />
 *
 * Example: {img src='xhtml11.png' modname='core' set='powered'}
 * Output:  <img src="themes/Theme/images/powered/xhtml11.png" alt="" width="88" height="31" />
 *
 * Example: {img src='iconX.png' modname='ModName' modplugin='Plug1' set='icons'}
 * Output:  <img src="modules/ModName/plugins/Plug1/images/icons/iconX.png" alt="" width="16" height="16" />
 *
 * Example: {img src='iconY.png' sysplugin='Plug2' set='icons/small'}
 * Output:  <img src="plugins/Plug2/images/icons/small/iconY.png" alt="" width="16" height="16" />
 *
 * If the parameter assign is set, the results are assigned as an array. The components of
 * this array are the same as the attributes of the img tag; additionally an entry 'imgtag' is
 * set to the complete image tag.
 *
 * Example:
 * {img src="heading.png" assign="myvar"}
 * {$myvar.src}
 * {$myvar.width}
 * {$myvar.imgtag}
 *
 * Output:
 * modules/Example/images/en/heading.gif
 * 261
 * <img src="modules/Example/images/en/heading.gif" alt="" width="261" height="69"  />
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string|void The img tag, null if $params['nostoponerror'] true and there is an error.
 */
function smarty_function_img($params, Zikula_View $view)
{
    $nostoponerror = isset($params['nostoponerror']) && $params['nostoponerror'] ? true : false;
    if (!isset($params['src']) || !$params['src']) {
        if (!$nostoponerror) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('img', 'src')));
            return;
        } else {
            return false;
        }
    }
    // process the image location
    $modname = isset($params['modname']) ? $params['modname'] : $view->toplevelmodule;
    $modplugin = isset($params['modplugin']) ? $params['modplugin'] : null;
    $sysplugin = isset($params['sysplugin']) ? $params['sysplugin'] : null;
    // process the image set
    $set = isset($params['set']) ? $params['set'] : null;
    $osset = DataUtil::formatForOS($set);
    // if the module name is 'core'
    if ($modname == 'core') {
        if (System::isLegacyMode() && (strpos($osset, 'icons/') !== false || strpos($osset, 'global/') !== false) && strpos($params['src'], '.gif')) {
            LogUtil::log(__f('Core image %s does not exist, please use the png format (called from %s).', array($params['src'], $view->getTemplatePath())), E_USER_DEPRECATED);
            $params['src'] = str_replace('.gif', '.png', $params['src']);
        }
    }
    // always provide an alt attribute.
    // if none is set, assign an empty one.
    $params['alt'] = isset($params['alt']) ? $params['alt'] : '';
    // prevent overwriting surrounding titles (#477)
    if (isset($params['title']) && empty($params['title'])) {
        unset($params['title']);
    }
    // language
    $lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
    if ($sysplugin) {
        $osplugdir = DataUtil::formatForOS($sysplugin);
        $pluglangpath = "plugins/{$osplugdir}/images/{$lang}";
        $plugpath = "plugins/{$osplugdir}/images";
        // form the array of paths
        $paths = array($pluglangpath, $plugpath);
    } else {
        // module directory
        if ($modname != 'core') {
            $modinfo = ModUtil::getInfoFromName($modname);
            $osmoddir = DataUtil::formatForOS($modinfo['directory']);
            $moduleDir = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules';
        }
        if ($modplugin) {
            $osmodplugdir = DataUtil::formatForOS($modplugin);
            $modpluglangpath = "{$moduleDir}/{$osmoddir}/plugins/{$osmodplugdir}/Resources/public/images/{$lang}";
            $modplugpath = "{$moduleDir}/{$osmoddir}/plugins/{$osmodplugdir}/Resources/public/images";
            $modpluglangpathOld = "{$moduleDir}/{$osmoddir}/plugins/{$osmodplugdir}/images/{$lang}";
            $modplugpathOld = "{$moduleDir}/{$osmoddir}/plugins/{$osmodplugdir}/images";
            // form the array of paths
            $paths = array($modpluglangpath, $modplugpath, $modpluglangpathOld, $modplugpathOld);
        } else {
            // theme directory
            $ostheme = DataUtil::formatForOS(UserUtil::getTheme());
            $theme = ThemeUtil::getTheme($ostheme);
            $themePath = null === $theme ? '' : $theme->getRelativePath() . '/Resources/public/images';
            $themepath = $themePath;
            $corethemepath = "themes/{$ostheme}/images";
            if ($modname == 'core') {
                $modpath = "images";
                $paths = array($themepath, $corethemepath, $modpath);
            } else {
                $osmodname = DataUtil::formatForOS($modname);
                $themelangpath = "{$themePath}/{$lang}";
                $themelangpathOld = "themes/{$ostheme}/templates/modules/{$osmodname}/images/{$lang}";
                $themepathOld = "themes/{$ostheme}/templates/modules/{$osmodname}/images";
                $module = ModUtil::getModule($modinfo['name']);
                $moduleBasePath = null === $module ? '' : $module->getRelativePath() . '/Resources/public/images';
                $modlangpath = "{$moduleBasePath}/{$lang}";
                $modpath = $moduleBasePath;
                $modlangpathOld = "{$moduleDir}/{$osmoddir}/images/{$lang}";
                $modpathOld = "{$moduleDir}/{$osmoddir}/images";
                $modlangpathOld2 = "{$moduleDir}/{$osmoddir}/pnimages/{$lang}";
                $modpathOld2 = "{$moduleDir}/{$osmoddir}/pnimages";
                // form the array of paths
                if (preg_match('/^admin.(png|gif|jpg)$/', $params['src'])) {
                    // special processing for modules' admin icon
                    $paths = array($modlangpath, $modpath, $modlangpathOld, $modpathOld, $modlangpathOld, $modpathOld, $modlangpathOld2, $modpathOld2);
                } else {
                    $paths = array($themelangpath, $themepath, $themelangpathOld, $themepathOld, $corethemepath, $modlangpath, $modpath, $modlangpathOld, $modpathOld, $modlangpathOld2, $modpathOld2);
                }
            }
        }
    }
    $ossrc = DataUtil::formatForOS($params['src']);
    // search for the image
    $imgsrc = '';
    foreach ($paths as $path) {
        $fullpath = $path . ($osset ? "/{$osset}/" : '/') . $ossrc;
        if (is_readable($fullpath)) {
            $imgsrc = $fullpath;
            break;
        }
    }
    if ($imgsrc == '' && isset($params['default'])) {
        $imgsrc = $params['default'];
    }
    // default for the optional flag
    $optional = isset($params['optional']) ? $params['optional'] : true;
    if ($imgsrc == '') {
        if ($optional) {
            if (!$nostoponerror) {
                $view->trigger_error(__f("%s: Image '%s' not found", array('img', DataUtil::formatForDisplay(($set ? "{$set}/" : '') . $params['src']))));
                return;
            } else {
                return false;
            }
        }
        return;
    }
    // If neither width nor height is set, get these parameters.
    // If one of them is set, we do NOT obtain the real dimensions.
    // This way it is easy to scale the image to a certain dimension.
    if (!isset($params['width']) && !isset($params['height'])) {
        if (!($_image_data = @getimagesize($imgsrc))) {
            if (!$nostoponerror) {
                $view->trigger_error(__f("%s: Image '%s' is not a valid image file", array('img', DataUtil::formatForDisplay(($set ? "{$set}/" : '') . $params['src']))));
                return;
            } else {
                return false;
            }
        }
        $params['width'] = $_image_data[0];
        $params['height'] = $_image_data[1];
    }
    $basepath = isset($params['fqurl']) && $params['fqurl'] ? System::getBaseUrl() : System::getBaseUri();
    $params['src'] = $basepath . '/' . $imgsrc;
    $retval = isset($params['retval']) ? $params['retval'] : null;
    $assign = isset($params['assign']) ? $params['assign'] : null;
    unset($params['modname']);
    unset($params['retval']);
    unset($params['assign']);
    if (isset($params['altml'])) {
        // legacy
        unset($params['altml']);
    }
    if (isset($params['titleml'])) {
        // legacy
        unset($params['titleml']);
    }
    unset($params['optional']);
    unset($params['default']);
    unset($params['set']);
    unset($params['nostoponerror']);
    unset($params['fqurl']);
    $imgtag = '<img ';
    foreach ($params as $key => $value) {
        $imgtag .= $key . '="' . $value . '" ';
    }
    $imgtag .= '/>';
    if (!empty($retval) && isset($params[$retval])) {
        return $params[$retval];
    } elseif (!empty($assign)) {
        $params['imgtag'] = $imgtag;
        $view->assign($assign, $params);
    } else {
        return $imgtag;
    }
}
Ejemplo n.º 18
0
 /**
  * Get the modules stylesheet from several possible sources.
  *
  * @param string $modname    The modules name (optional, defaults to top level module).
  * @param string $stylesheet The stylesheet file (optional).
  *
  * @return string Path of the stylesheet file, relative to PN root folder.
  */
 public static function getModuleStylesheet($modname = '', $stylesheet = '')
 {
     // default for the module
     if (empty($modname)) {
         $modname = ModUtil::getName();
     }
     // default for the style sheet
     if (empty($stylesheet)) {
         $stylesheet = ModUtil::getVar($modname, 'modulestylesheet');
         if (empty($stylesheet)) {
             $stylesheet = 'style.css';
         }
     }
     $module = ModUtil::getModule($modname);
     $osstylesheet = DataUtil::formatForOS($stylesheet);
     $osmodname = DataUtil::formatForOS($modname);
     $paths = array();
     // config directory
     $configstyledir = 'config/style';
     $paths[] = "{$configstyledir}/{$osmodname}";
     // theme directory
     $themeName = DataUtil::formatForOS(UserUtil::getTheme());
     $theme = self::getTheme($themeName);
     if ($theme) {
         $bundleRelativePath = substr($theme->getPath(), strpos($theme->getPath(), 'themes'), strlen($theme->getPath()));
         $bundleRelativePath = str_replace('\\', '/', $bundleRelativePath);
     }
     $paths[] = null === $theme ? "themes/{$themeName}/style/{$osmodname}" : $bundleRelativePath . '/Resources/css/' . $theme->getName();
     // module directory
     $modinfo = ModUtil::getInfoFromName($modname);
     $osmoddir = DataUtil::formatForOS($modinfo['directory']);
     if ($module) {
         $dir = ModUtil::getModuleBaseDir($modname);
         $bundleRelativePath = substr($module->getPath(), strpos($module->getPath(), $dir), strlen($module->getPath()));
         $bundleRelativePath = str_replace('\\', '/', $bundleRelativePath);
         $paths[] = $bundleRelativePath . "/Resources/public/css";
     }
     $paths[] = "modules/{$osmoddir}/style";
     $paths[] = "system/{$osmoddir}/style";
     // search for the style sheet
     $csssrc = '';
     foreach ($paths as $path) {
         if (is_readable("{$path}/{$osstylesheet}")) {
             $csssrc = "{$path}/{$osstylesheet}";
             break;
         }
     }
     return $csssrc;
 }
Ejemplo n.º 19
0
 /**
  * Display a block based on the current theme.
  *
  * @param array $blockinfo Block info.
  *
  * @return string The rendered output.
  */
 public static function themeBlock($blockinfo)
 {
     static $themeinfo, $themedir, $upb, $downb;
     if (!isset($blockinfo['bid'])) {
         $blockinfo['bid'] = '';
     }
     if (!isset($blockinfo['title'])) {
         $blockinfo['title'] = '';
     }
     if (UserUtil::isLoggedIn() && ModUtil::getVar('ZikulaBlocksModule', 'collapseable') == 1 && isset($blockinfo['collapsable']) && $blockinfo['collapsable'] == '1') {
         if (!isset($themeinfo)) {
             $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
             $themedir = DataUtil::formatForOS($themeinfo['directory']);
         }
         // check for collapsable menus being enabled, and setup the collapsable menu image.
         if (!isset($upb)) {
             if (file_exists('themes/' . $themedir . '/images/upb.png')) {
                 $upb = '<img src="themes/' . $themedir . '/images/upb.png" alt="-" />';
             } elseif (file_exists('themes/' . $themedir . '/images/14_layer_raiselayer.png')) {
                 $upb = '<img src="themes/' . $themedir . '/images/14_layer_raiselayer.png" alt="-" />';
             } else {
                 $upb = '<img src="images/icons/extrasmall/14_layer_raiselayer.png" alt="-" />';
             }
         }
         if (!isset($downb)) {
             if (file_exists('themes/' . $themedir . '/images/downb.png')) {
                 $downb = '<img src="themes/' . $themedir . '/images/downb.png" alt="+" />';
             } elseif (file_exists('themes/' . $themedir . '/images/14_layer_lowerlayer.png')) {
                 $downb = '<img src="themes/' . $themedir . '/images/14_layer_lowerlayer.png" alt="+" />';
             } else {
                 $downb = '<img src="images/icons/extrasmall/14_layer_lowerlayer.png" alt="+" />';
             }
         }
         $checkUserBlock = self::checkUserBlock($blockinfo);
         if ($checkUserBlock) {
             if (!empty($blockinfo['title'])) {
                 $blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('ZikulaBlocksModule', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $upb . '</a>';
             }
         } else {
             $blockinfo['content'] = '';
             if (!empty($blockinfo['title'])) {
                 $blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('ZikulaBlocksModule', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $downb . '</a>';
             }
         }
         // end collapseable menu config
     } else {
         $blockinfo['minbox'] = '';
     }
     // try twig theme first (note: theme is already set by this point)
     $container = ServiceUtil::getManager();
     $twigBasedThemeBlock = $container->get('zikula_core.common.theme_engine')->wrapBcBlockInTheme($blockinfo);
     if ($twigBasedThemeBlock) {
         return $twigBasedThemeBlock;
     }
     // theme is not twig based revert to smarty
     return Zikula_View_Theme::getInstance()->themesidebox($blockinfo);
 }
Ejemplo n.º 20
0
    /**
     * Constructor.
     *
     * @param Zikula_ServiceManager $serviceManager ServiceManager.
     * @param string                $moduleName     Module name ("zikula" for system plugins).
     * @param integer|null          $caching        Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
     */
    public function __construct(Zikula_ServiceManager $serviceManager, $moduleName = '', $caching = null)
    {
        $this->serviceManager = $serviceManager;
        $this->eventManager = $this->serviceManager->getService('zikula.eventmanager');
        $this->request = $this->serviceManager->getService('request');

        // set the error reporting level
        $this->error_reporting = isset($GLOBALS['ZConfig']['Debug']['error_reporting']) ? $GLOBALS['ZConfig']['Debug']['error_reporting'] : E_ALL;
        $this->allow_php_tag = true;

        // get variables from input
        $module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING);
        $type   = FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
        $func   = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING);

        // set vars based on the module structures
        $this->homepage = empty($module) ? true : false;
        $this->type = strtolower(!$this->homepage ? $type : System::getVar('starttype'));
        $this->func = strtolower(!$this->homepage ? $func : System::getVar('startfunc'));

        // Initialize the module property with the name of
        // the topmost module. For Hooks, Blocks, API Functions and others
        // you need to set this property to the name of the respective module!
        $this->toplevelmodule = ModUtil::getName();

        if (!$moduleName) {
            $moduleName = $this->toplevelmodule;
        }
        $this->modinfo = ModUtil::getInfoFromName($moduleName);
        $this->module  = array($moduleName => $this->modinfo);

        // initialise environment vars
        $this->language = ZLanguage::getLanguageCode();
        $this->baseurl = System::getBaseUrl();
        $this->baseuri = System::getBaseUri();

        // system info
        $this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
        $this->theme = $theme = $this->themeinfo['directory'];

        //---- Plugins handling -----------------------------------------------
        // add plugin paths
        switch ($this->modinfo['type'])
        {
            case ModUtil::TYPE_MODULE :
                $mpluginPath = "modules/" . $this->modinfo['directory'] . "/templates/plugins";
                $mpluginPathOld = "modules/" . $this->modinfo['directory'] . "/pntemplates/plugins";
                break;
            case ModUtil::TYPE_SYSTEM :
                $mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
                $mpluginPathOld = "system/" . $this->modinfo['directory'] . "/pntemplates/plugins";
                break;
            default:
                $mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
                $mpluginPathOld = "system/" . $this->modinfo['directory'] . "/pntemplates/plugins";
        }

        // add standard plugin search path
        $this->plugins_dir = array();
        $this->addPluginDir('config/plugins'); // Official override
        $this->addPluginDir('lib/viewplugins'); // Core plugins
        $this->addPluginDir("themes/$theme/plugins"); // Theme plugins
        $this->addPluginDir('plugins'); // Smarty core plugins
        $this->addPluginDir($mpluginPath); // Plugins for current module

        // check if the 'type' parameter in the URL is admin and if yes,
        // include system/Admin/templates/plugins to the plugins_dir array
        if ($type === 'admin') {
            if (!$this instanceof Zikula_View_Theme) {
                $this->addPluginDir('system/Admin/templates/plugins');
            } else {
                $this->load_filter('output', 'admintitle');
            }
        }

        // adds legacy plugin paths if needed
        if (System::isLegacyMode()) {
            $this->addPluginDir('lib/legacy/plugins'); // Core legacy plugins
            $this->addPluginDir($mpluginPathOld); // Module plugins (legacy paths)
            $this->addPluginDir("themes/$theme/templates/modules/$moduleName/plugins"); // Module override in themes
        }

        //---- Cache handling -------------------------------------------------
        if ($caching && in_array((int)$caching, array(0, 1, 2))) {
            $this->caching = (int)$caching;
        } else {
            $this->caching = (int)ModUtil::getVar('Theme', 'render_cache');
        }

        // write actions should not be cached or weird things happen
        if (isset($_POST) && count($_POST) != 0) {
            $this->caching = Zikula_View::CACHE_DISABLED;
        }

        $this->compile_id  = '';
        $this->cache_id    = '';

        // template compilation
        $this->compile_dir    = CacheUtil::getLocalDir('view_compiled');
        $this->compile_check  = ModUtil::getVar('Theme', 'render_compile_check');
        $this->force_compile  = ModUtil::getVar('Theme', 'render_force_compile');
        // template caching
        $this->cache_dir      = CacheUtil::getLocalDir('view_cache');
        $this->cache_lifetime = ModUtil::getVar('Theme', 'render_lifetime');

        $this->expose_template = (ModUtil::getVar('Theme', 'render_expose_template') == true) ? true : false;

        // register resource type 'z' this defines the way templates are searched
        // during {include file='my_template.tpl'} this enables us to store selected module
        // templates in the theme while others can be kept in the module itself.
        $this->register_resource('z', array('Zikula_View_Resource',
                                            'z_get_template',
                                            'z_get_timestamp',
                                            'z_get_secure',
                                            'z_get_trusted'));

        // set 'z' as default resource type
        $this->default_resource_type = 'z';

        // process some plugins specially when Render cache is enabled
        if (!$this instanceof Zikula_View_Theme && $this->caching) {
            $this->register_nocache_plugins();
        }

        // register the 'nocache' block to allow dynamic zones caching templates
        $this->register_block('nocache', array('Zikula_View_Resource', 'block_nocache'), false);

        // For ajax requests we use the short urls filter to 'fix' relative paths
        if (($this->serviceManager->getService('zikula')->getStage() & Zikula_Core::STAGE_AJAX) && System::getVar('shorturls')) {
            $this->load_filter('output', 'shorturls');
        }

        // register prefilters
        $this->register_prefilter('z_prefilter_add_literal');

        if ($GLOBALS['ZConfig']['System']['legacy_prefilters']) {
            $this->register_prefilter('z_prefilter_legacy');
        }

        $this->register_prefilter('z_prefilter_gettext_params');
        //$this->register_prefilter('z_prefilter_notifyfilters');

        // assign some useful settings
        $this->assign('homepage', $this->homepage)
             ->assign('modinfo', $this->modinfo)
             ->assign('module', $moduleName)
             ->assign('toplevelmodule', $this->toplevelmodule)
             ->assign('type', $this->type)
             ->assign('func', $this->func)
             ->assign('lang', $this->language)
             ->assign('themeinfo', $this->themeinfo)
             ->assign('themepath', $this->baseurl . 'themes/' . $theme)
             ->assign('baseurl', $this->baseurl)
             ->assign('baseuri', $this->baseuri);

        if (System::isLegacyMode()) {
            $this->assign('stylepath', $this->baseurl . 'themes/' . $theme . '/style')
                 ->assign('scriptpath', $this->baseurl . 'themes/' . $theme . '/javascript')
                 ->assign('imagepath', $this->baseurl . 'themes/' . $theme . '/images')
                 ->assign('imagelangpath', $this->baseurl . 'themes/' . $theme . '/images/' . $this->language);
        }

        // for {gt} template plugin to detect gettext domain
        if ($this->modinfo['type'] == ModUtil::TYPE_MODULE) {
            $this->domain = ZLanguage::getModuleDomain($this->modinfo['name']);
        }

        // make render object available to modifiers
        parent::assign('zikula_view', $this);

        // add ServiceManager, EventManager and others to all templates
        parent::assign('serviceManager', $this->serviceManager);
        parent::assign('eventManager', $this->eventManager);
        parent::assign('zikula_core', $this->serviceManager->getService('zikula'));
        parent::assign('request', $this->request);
        parent::assign('modvars', ModUtil::getModvars()); // Get all modvars from any modules that have accessed their modvars at least once.

        $this->add_core_data();

        // metadata for SEO
        if (!isset($this->serviceManager['zikula_view.metatags'])) {
            $this->serviceManager['zikula_view.metatags'] = new ArrayObject(array());
        }

        parent::assign('metatags', $this->serviceManager['zikula_view.metatags']);

        $event = new Zikula_Event('view.init', $this);
        $this->eventManager->notify($event);
    }
Ejemplo n.º 21
0
/**
 * get the user's theme
 * This function will return the current theme for the user.
 * Order of theme priority:
 *  - page-specific
 *  - category
 *  - user
 *  - system
 *
 * @deprecated
 * @see UserUtil::getTheme()
 *
 * @public
 * @return string the name of the user's theme
 **/
function pnUserGetTheme($force = false)
{
    LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'UserUtil::getTheme()')), E_USER_DEPRECATED);
    return UserUtil::getTheme($force);
}
Ejemplo n.º 22
0
/**
 * Zikula_View outputfilter to add page variables and additional header global into page header
 *
 * By default this output filter places page variable output immediately prior to the closing
 * head tag (</head>). The output can, optionally, be placed anywhere in the template by adding
 * the HTML comment <!-- pagevars --> to the page template. Note that this must always be in
 * the header for the output to function correctly.
 *
 * @param string      $source Output source.
 * @param Zikula_View $view   Reference to Zikula_View instance.
 *
 * @return string
 */
function smarty_outputfilter_pagevars($source, $view)
{
    $return = '';
    $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
    $cssjscombine = ModUtil::getVar('ZikulaThemeModule', 'cssjscombine', false);
    $type = $view->getRequest()->get('type');
    $zkType = $view->getRequest()->attributes->get('_zkType');
    $isAdminController = $type == 'admin' || $zkType == 'admin';
    // get list of stylesheets and scripts from JCSSUtil
    $jcss = JCSSUtil::prepareJCSS($cssjscombine, $view->cache_dir, $themeinfo, $isAdminController);
    if (is_array($jcss['stylesheets']) && !empty($jcss['stylesheets'])) {
        foreach ($jcss['stylesheets'] as $stylesheet) {
            if (empty($stylesheet)) {
                continue;
            }
            // check if the stylesheets is in the additional_header array
            if ($themeinfo['xhtml']) {
                $return .= '<link rel="stylesheet" href="' . DataUtil::formatForDisplay($stylesheet) . '" type="text/css" />' . "\n";
            } else {
                $return .= '<link rel="stylesheet" href="' . DataUtil::formatForDisplay($stylesheet) . '" type="text/css">' . "\n";
            }
        }
    }
    // get inline js config and print it just before any script tag
    $jsConfig = JCSSUtil::getJSConfig();
    if (!empty($jsConfig)) {
        $return .= $jsConfig;
    }
    if (is_array($jcss['javascripts']) && !empty($jcss['javascripts'])) {
        foreach ($jcss['javascripts'] as $j => $javascript) {
            if (empty($javascript)) {
                unset($jcss['javascripts'][$j]);
                continue;
            }
            // check if the javascript is in the additional_header array
            $return .= '<script type="text/javascript" src="' . DataUtil::formatForDisplay($javascript) . '"></script>' . "\n";
        }
    }
    $headerContent = PageUtil::getVar('header');
    if (is_array($headerContent) && !empty($headerContent)) {
        $return .= implode("\n", $headerContent) . "\n";
    }
    // if we've got some page vars to add the header wrap the output in
    // suitable identifying comments when in development mode
    $return = trim($return);
    if (!empty($return) && System::getVar('development') != 0) {
        $return = "<!-- zikula pagevars -->\n" . $return . "\n<!-- /zikula pagevars -->";
    }
    // get any body page vars
    $bodyvars = PageUtil::getVar('body');
    if (!empty($bodyvars)) {
        $bodyattribs = '<body ' . @implode(' ', $bodyvars) . '>';
        $source = str_replace('<body>', $bodyattribs, $source);
    }
    // get any footer page vars
    $footervars = PageUtil::getVar('footer');
    if (!empty($footervars)) {
        $footersource = @implode("\n", $footervars) . "\n</body>";
        $source = str_replace('</body>', $footersource, $source);
    }
    // replace the string in the template source
    if (stripos($source, '<!-- pagevars -->')) {
        $source = str_replace('<!-- pagevars -->', $return, $source);
    } else {
        $headPos = stripos($source, '</head>');
        if ($headPos !== false) {
            if ($headPos == strripos($source, '</head>')) {
                // Position of the first </head> matches the last </head> so str_replace is safe
                $source = str_replace('</head>', $return . "\n</head>", $source);
            } else {
                // Position of the first </head> does not match the last </head> so str_replace is NOT safe
                // There was probably a {zdebug} tag opening a _dbgconsole.
                // Need to use preg_replace so we can limit to the first.
                preg_replace('#</head>#i', $return . "\n</head>", $source, 1);
            }
        }
    }
    // return the modified source
    return $source;
}
Ejemplo n.º 23
0
 /**
  * Get Theme instance.
  *
  * @param string       $themeName Theme name.
  * @param integer|null $caching   Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
  * @param string       $cache_id  Cache Id.
  *
  * @return Zikula_View_Theme This instance.
  */
 public static function getInstance($themeName = '', $caching = null, $cache_id = null)
 {
     if (!$themeName) {
         $themeName = UserUtil::getTheme();
     }
     $serviceId = 'zikula.theme';
     $serviceManager = ServiceUtil::getManager();
     if (!$serviceManager->has($serviceId)) {
         $themeInstance = new self($serviceManager, $themeName);
         $serviceManager->set($serviceId, $themeInstance);
     } else {
         $themeInstance = $serviceManager->get($serviceId);
     }
     if (!is_null($caching)) {
         $themeInstance->caching = $caching;
     }
     if (!is_null($cache_id)) {
         $themeInstance->cache_id = $cache_id;
     }
     return $themeInstance;
 }
Ejemplo n.º 24
0
 /**
  * Constructor.
  *
  * @param ContainerBuilder $container ServiceManager.
  * @param string           $moduleName     Module name ("zikula" for system plugins).
  * @param integer|null     $caching        Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
  */
 public function __construct(ContainerBuilder $container, $moduleName = '', $caching = null)
 {
     $this->container = $container;
     $this->dispatcher = $this->container->get('event_dispatcher');
     $this->request = $this->container->get('request');
     // set the error reporting level
     $this->error_reporting = isset($container['error_reporting']) ? $container['error_reporting'] : E_ALL;
     $this->allow_php_tag = true;
     // get variables from input
     $module = $this->request->attributes->get('_module', null);
     $type = $this->request->attributes->get('_controller', 'user');
     $func = $this->request->attributes->get('_action', 'index');
     // set vars based on the module structures
     $this->homepage = empty($module) ? true : false;
     $this->type = strtolower(!$this->homepage ? $type : System::getVar('starttype'));
     $this->func = strtolower(!$this->homepage ? $func : System::getVar('startfunc'));
     // Initialize the module property with the name of
     // the topmost module. For Hooks, Blocks, API Functions and others
     // you need to set this property to the name of the respective module!
     $this->toplevelmodule = ModUtil::getName();
     if (!$moduleName) {
         $moduleName = $this->toplevelmodule;
     }
     $this->modinfo = ModUtil::getInfoFromName($moduleName);
     $this->module = array($moduleName => $this->modinfo);
     // initialise environment vars
     $this->language = ZLanguage::getLanguageCode();
     $this->baseurl = System::getBaseUrl();
     $this->baseuri = System::getBaseUri();
     // system info
     $this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
     $this->theme = $this->themeinfo['directory'];
     //---- Plugins handling -----------------------------------------------
     // add plugin paths
     switch ($this->modinfo['type']) {
         case ModUtil::TYPE_MODULE:
             $mpluginPath = "modules/" . $this->modinfo['directory'] . "/Resources/views/plugins";
             break;
         case ModUtil::TYPE_SYSTEM:
             $mpluginPath = "system/" . $this->modinfo['directory'] . "/Rsources/views/plugins";
             break;
         default:
             $mpluginPath = "system/" . $this->modinfo['directory'] . "/Rsources/views/plugins";
     }
     // add standard plugin search path
     $this->plugins_dir = array();
     $this->addPluginDir('config/Resources/plugins');
     // Official override
     $this->addPluginDir('config/plugins');
     // Official override
     $this->addPluginDir(ZIKULA_ROOT . '/../src/legacy/viewplugins');
     // Core plugins
     $this->addPluginDir("themes/{$this->theme}/Resources/views/plugins");
     // Theme plugins
     $this->addPluginDir(SMARTY_DIR . 'plugins');
     // Smarty core plugins
     $this->addPluginDir($mpluginPath);
     // Plugins for current module
     // check if the 'type' parameter in the URL is admin and if yes,
     // include system/Admin/templates/plugins to the plugins_dir array
     if ($type === 'admin') {
         if (!$this instanceof Zikula_View_Theme) {
             $this->addPluginDir('system/AdminModule/Resources/views/plugins');
         } else {
             $this->load_filter('output', 'admintitle');
         }
     }
     //---- Cache handling -------------------------------------------------
     if ($caching && in_array((int) $caching, array(0, 1, 2))) {
         $this->caching = (int) $caching;
     } else {
         $this->caching = (int) ModUtil::getVar('Theme', 'render_cache');
     }
     $this->compile_id = '';
     $this->cache_id = '';
     // template compilation
     $this->compile_dir = CacheUtil::getLocalDir('view_compiled');
     $this->compile_check = ModUtil::getVar('Theme', 'render_compile_check');
     $this->force_compile = ModUtil::getVar('Theme', 'render_force_compile');
     // template caching
     $this->cache_dir = CacheUtil::getLocalDir('view_cache');
     $this->cache_lifetime = ModUtil::getVar('Theme', 'render_lifetime');
     $this->expose_template = ModUtil::getVar('Theme', 'render_expose_template') == true ? true : false;
     // register resource type 'z' this defines the way templates are searched
     // during {include file='my_template.tpl'} this enables us to store selected module
     // templates in the theme while others can be kept in the module itself.
     $this->register_resource('z', array('Zikula_View_Resource', 'z_get_template', 'z_get_timestamp', 'z_get_secure', 'z_get_trusted'));
     // set 'z' as default resource type
     $this->default_resource_type = 'z';
     // process some plugins specially when Render cache is enabled
     if (!$this instanceof Zikula_View_Theme && $this->caching) {
         $this->register_nocache_plugins();
     }
     // register the 'nocache' block to allow dynamic zones caching templates
     $this->register_block('nocache', array('Zikula_View_Resource', 'block_nocache'), false);
     // For ajax requests we use the short urls filter to 'fix' relative paths
     if ($this->container->get('zikula')->getStage() & \Zikula\Core\Core::STAGE_AJAX && System::getVar('shorturls')) {
         $this->load_filter('output', 'shorturls');
     }
     // register prefilters
     $this->register_prefilter('z_prefilter_add_literal');
     $this->register_prefilter('z_prefilter_gettext_params');
     // assign some useful settings
     $this->assign('homepage', $this->homepage)->assign('modinfo', $this->modinfo)->assign('module', $moduleName)->assign('toplevelmodule', $this->toplevelmodule)->assign('type', $this->type)->assign('func', $this->func)->assign('lang', $this->language)->assign('themeinfo', $this->themeinfo)->assign('themepath', $this->baseurl . 'themes/' . $this->theme)->assign('baseurl', $this->baseurl)->assign('baseuri', $this->baseuri);
     // for {gt} template plugin to detect gettext domain
     if ($this->modinfo['type'] == ModUtil::TYPE_MODULE) {
         $this->domain = ZLanguage::getModuleDomain($this->modinfo['name']);
     }
     // make render object available to modifiers
     parent::assign('zikula_view', $this);
     // add ServiceManager, EventManager and others to all templates
     parent::assign('container', $this->container);
     parent::assign('dispatcher', $this->dispatcher);
     parent::assign('zikula_core', $this->container->get('zikula'));
     parent::assign('request', $this->request);
     parent::assign('modvars', ModUtil::getModvars());
     // Get all modvars from any modules that have accessed their modvars at least once.
     $this->add_core_data();
     // metadata for SEO
     if (!isset($this->container['zikula_view.metatags'])) {
         $this->container['zikula_view.metatags'] = new ArrayObject(array());
     }
     parent::assign('metatags', $this->container['zikula_view.metatags']);
     $event = new GenericEvent($this);
     $this->dispatcher->dispatch('view.init', $event);
 }
Ejemplo n.º 25
0
    /**
     * Display a block based on the current theme.
     *
     * @param array $blockinfo Block info.
     *
     * @return string The rendered output.
     */
    public static function themeBlock($blockinfo)
    {
        static $themeinfo, $themedir, $upb, $downb;

        if (!isset($blockinfo['bid'])) {
            $blockinfo['bid'] = '';
        }
        if (!isset($blockinfo['title'])) {
            $blockinfo['title'] = '';
        }

        if (UserUtil::isLoggedIn() && ModUtil::getVar('Blocks', 'collapseable') == 1 && isset($blockinfo['collapsable']) && ($blockinfo['collapsable'] == '1')) {
            if (!isset($themeinfo)) {
                $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
                $themedir = DataUtil::formatForOS($themeinfo['directory']);
            }

            // check for collapsable menus being enabled, and setup the collapsable menu image.
            if (!isset($upb)) {
                if (file_exists('themes/' . $themedir . '/images/upb.png')) {
                    $upb = '<img src="themes/' . $themedir . '/images/upb.png" alt="-" />';
                } elseif (file_exists('themes/' . $themedir . '/images/14_layer_raiselayer.png')) {
                    $upb = '<img src="themes/' . $themedir . '/images/14_layer_raiselayer.png" alt="-" />';
                } else {
                    $upb = '<img src="images/icons/extrasmall/14_layer_raiselayer.png" alt="-" />';
                }
            }
            if (!isset($downb)) {
                if (file_exists('themes/' . $themedir . '/images/downb.png')) {
                    $downb = '<img src="themes/' . $themedir . '/images/downb.png" alt="+" />';
                } elseif (file_exists('themes/' . $themedir . '/images/14_layer_lowerlayer.png')) {
                    $downb = '<img src="themes/' . $themedir . '/images/14_layer_lowerlayer.png" alt="+" />';
                } else {
                    $downb = '<img src="images/icons/extrasmall/14_layer_lowerlayer.png" alt="+" />';
                }
            }

            if (self::checkUserBlock($blockinfo) == '1') {
                if (!empty($blockinfo['title'])) {
                    $blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('Blocks', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $upb . '</a>';
                }
            } else {
                $blockinfo['content'] = '';
                if (!empty($blockinfo['title'])) {
                    $blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('Blocks', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $downb . '</a>';
                }
            }
            // end collapseable menu config
        } else {
            $blockinfo['minbox'] = '';
        }

        return Zikula_View_Theme::getInstance()->themesidebox($blockinfo);
    }
Ejemplo n.º 26
0
     if (preg_match("/^admin_.*?\\." . $phpEx . "\$/", $file)) {
         // Begin PNphpBB2 Module
         //			include('./' . $file);
         include $phpbb_root_path . "admin/" . $file;
         // End PNphpBB2 Module
     }
 }
 @closedir($dir);
 unset($setmodules);
 // Begin PNphpBB2 Module
 //	include('./page_header_admin.'.$phpEx);
 include $phpbb_root_path . 'admin/page_header_admin.' . $phpEx;
 // End PNphpBB2 Module
 // Begin PNphpBB2 Module
 if (UserUtil::isLoggedIn() && System::getVar('theme_change') != 1) {
     $batheme = UserUtil::getTheme();
 } else {
     $batheme = System::getVar('Default_Theme');
 }
 $fthemepath = $phpbb_theme['template_name'];
 // End PNphpBB2 Module
 $template->set_filenames(array("body" => "admin/index_navigate.tpl"));
 $template->assign_vars(array("U_FORUM_INDEX" => append_sid("index.{$phpEx}", false, 'user'), "U_ADMIN_INDEX" => append_sid("admin.{$phpEx}?pane=right"), "THEME_IMAGES" => file_exists("modules/ZphpBB2/vendor/phpBB2/templates/{$fthemepath}/images/" . $batheme) ? $batheme . '/' : '', "L_FORUM_INDEX" => $lang['Main_index'], "L_ADMIN_INDEX" => $lang['Admin_Index'], "L_PREVIEW_FORUM" => $lang['Preview_forum']));
 // Begin PNphpBB2 Module
 // 	ksort($module);
 ksort($phpbb_module);
 // End PNphpBB2 Module
 // Begin PNphpBB2 Module
 //	while( list($cat, $action_array) = each($module) )
 while (list($cat, $action_array) = each($phpbb_module)) {
     $cat = !empty($lang[$cat]) ? $lang[$cat] : preg_replace("/_/", " ", $cat);
Ejemplo n.º 27
0
 /**
  * Run a module function.
  *
  * @param string  $modname    The name of the module.
  * @param string  $type       The type of function to run.
  * @param string  $func       The specific function to run.
  * @param array   $args       The arguments to pass to the function.
  * @param boolean $api        Whether or not to execute an API (or regular) function.
  * @param string  $instanceof Perform instanceof checking of target class.
  *
  * @throws Zikula_Exception_NotFound If method was not found.
  * @throws InvalidArgumentException  If the controller is not an instance of the class specified in $instanceof.
  *
  * @return mixed.
  */
 public static function exec($modname, $type = 'user', $func = 'main', $args = array(), $api = false, $instanceof = null)
 {
     // define input, all numbers and booleans to strings
     $modname = isset($modname) ? (string) $modname : '';
     $ftype = $api ? 'api' : '';
     $loadfunc = $api ? 'ModUtil::loadApi' : 'ModUtil::load';
     // validate
     if (!System::varValidate($modname, 'mod')) {
         return null;
     }
     // Remove from 1.4
     if (System::isLegacyMode() && $modname == 'Modules') {
         LogUtil::log(__('Warning! "Modules" module has been renamed to "Extensions".  Please update your ModUtil::func() and ModUtil::apiFunc() calls.'));
         $modname = 'Extensions';
     }
     $modinfo = self::getInfo(self::getIDFromName($modname));
     $path = $modinfo['type'] == self::TYPE_SYSTEM ? 'system' : 'modules';
     $controller = null;
     $modfunc = null;
     $loaded = call_user_func_array($loadfunc, array($modname, $type));
     if (self::isOO($modname)) {
         $result = self::getCallable($modname, $type, $func, $api);
         if ($result) {
             $modfunc = $result['callable'];
             $controller = $modfunc[0];
             if (!is_null($instanceof)) {
                 if (!$controller instanceof $instanceof) {
                     throw new InvalidArgumentException(__f('%1$s must be an instance of $2$s', array(get_class($controller), $instanceof)));
                 }
             }
         }
     }
     $modfunc = $modfunc ? $modfunc : "{$modname}_{$type}{$ftype}_{$func}";
     $eventManager = EventUtil::getManager();
     if ($loaded) {
         $preExecuteEvent = new Zikula_Event('module_dispatch.preexecute', $controller, array('modname' => $modname, 'modfunc' => $modfunc, 'args' => $args, 'modinfo' => $modinfo, 'type' => $type, 'api' => $api));
         $postExecuteEvent = new Zikula_Event('module_dispatch.postexecute', $controller, array('modname' => $modname, 'modfunc' => $modfunc, 'args' => $args, 'modinfo' => $modinfo, 'type' => $type, 'api' => $api));
         if (is_callable($modfunc)) {
             $eventManager->notify($preExecuteEvent);
             // Check $modfunc is an object instance (OO) or a function (old)
             if (is_array($modfunc)) {
                 if ($modfunc[0] instanceof Zikula_AbstractController) {
                     $reflection = call_user_func(array($modfunc[0], 'getReflection'));
                     $subclassOfReflection = new ReflectionClass($reflection->getParentClass());
                     if ($subclassOfReflection->hasMethod($modfunc[1])) {
                         // Don't allow front controller to access any public methods inside the controller's parents
                         throw new Zikula_Exception_NotFound();
                     }
                     $modfunc[0]->preDispatch();
                 }
                 $postExecuteEvent->setData(call_user_func($modfunc, $args));
                 if ($modfunc[0] instanceof Zikula_AbstractController) {
                     $modfunc[0]->postDispatch();
                 }
             } else {
                 $postExecuteEvent->setData($modfunc($args));
             }
             return $eventManager->notify($postExecuteEvent)->getData();
         }
         // get the theme
         if (ServiceUtil::getManager()->getService('zikula')->getStage() & Zikula_Core::STAGE_THEME) {
             $theme = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
             if (file_exists($file = 'themes/' . $theme['directory'] . '/functions/' . $modname . "/{$type}{$ftype}/{$func}.php") || file_exists($file = 'themes/' . $theme['directory'] . '/functions/' . $modname . "/pn{$type}{$ftype}/{$func}.php")) {
                 include_once $file;
                 if (function_exists($modfunc)) {
                     EventUtil::notify($preExecuteEvent);
                     $postExecuteEvent->setData($modfunc($args));
                     return EventUtil::notify($postExecuteEvent)->getData();
                 }
             }
         }
         if (file_exists($file = "config/functions/{$modname}/{$type}{$ftype}/{$func}.php") || file_exists($file = "config/functions/{$modname}/pn{$type}{$ftype}/{$func}.php")) {
             include_once $file;
             if (is_callable($modfunc)) {
                 $eventManager->notify($preExecuteEvent);
                 $postExecuteEvent->setData($modfunc($args));
                 return $eventManager->notify($postExecuteEvent)->getData();
             }
         }
         if (file_exists($file = "{$path}/{$modname}/{$type}{$ftype}/{$func}.php") || file_exists($file = "{$path}/{$modname}/pn{$type}{$ftype}/{$func}.php")) {
             include_once $file;
             if (is_callable($modfunc)) {
                 $eventManager->notify($preExecuteEvent);
                 $postExecuteEvent->setData($modfunc($args));
                 return $eventManager->notify($postExecuteEvent)->getData();
             }
         }
         // try to load plugin
         // This kind of eventhandler should
         // 1. Check $event['modfunc'] to see if it should run else exit silently.
         // 2. Do something like $result = {$event['modfunc']}({$event['args'});
         // 3. Save the result $event->setData($result).
         // 4. $event->setNotify().
         // return void
         // This event means that no $type was found
         $event = new Zikula_Event('module_dispatch.type_not_found', null, array('modfunc' => $modfunc, 'args' => $args, 'modinfo' => $modinfo, 'type' => $type, 'api' => $api), false);
         $eventManager->notify($event);
         if ($preExecuteEvent->isStopped()) {
             return $preExecuteEvent->getData();
         }
         return false;
     }
     // Issue not found exception for controller requests
     if (!System::isLegacyMode() && !$api) {
         throw new Zikula_Exception_NotFound(__f('The requested controller action %s_Controller_%s::%s() could not be found', array($modname, $type, $func)));
     }
 }
Ejemplo n.º 28
0
 /**
  * Initialize form handler.
  *
  * This method takes care of all necessary initialisation of our data and form states.
  *
  * @param Zikula_Form_View $view The form view instance.
  *
  * @return boolean False in case of initialization errors, otherwise true.
  */
 public function initialize(Zikula_Form_View $view)
 {
     $this->inlineUsage = UserUtil::getTheme() == 'Printer' ? true : false;
     $this->idPrefix = $this->request->query->filter('idp', '', FILTER_SANITIZE_STRING);
     // initialise redirect goal
     $this->returnTo = $this->request->query->filter('returnTo', null, FILTER_SANITIZE_STRING);
     // store current uri for repeated creations
     $this->repeatReturnUrl = System::getCurrentURI();
     $this->permissionComponent = $this->name . ':' . $this->objectTypeCapital . ':';
     $entityClass = $this->name . '_Entity_' . ucfirst($this->objectType);
     $this->idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $this->objectType));
     // retrieve identifier of the object we wish to view
     $controllerHelper = new Reviews_Util_Controller($this->view->getServiceManager());
     $this->idValues = $controllerHelper->retrieveIdentifier($this->request, array(), $this->objectType, $this->idFields);
     $hasIdentifier = $controllerHelper->isValidIdentifier($this->idValues);
     $entity = null;
     $this->mode = $hasIdentifier ? 'edit' : 'create';
     if ($this->mode == 'edit') {
         if (!SecurityUtil::checkPermission($this->permissionComponent, $this->createCompositeIdentifier() . '::', ACCESS_EDIT)) {
             return LogUtil::registerPermissionError();
         }
         $entity = $this->initEntityForEdit();
         if (!is_object($entity)) {
             return LogUtil::registerError($this->__('No such item.'));
         }
         if ($this->hasPageLockSupport === true && ModUtil::available('PageLock')) {
             // try to guarantee that only one person at a time can be editing this entity
             ModUtil::apiFunc('PageLock', 'user', 'pageLock', array('lockName' => $this->name . $this->objectTypeCapital . $this->createCompositeIdentifier(), 'returnUrl' => $this->getRedirectUrl(null)));
         }
     } else {
         if (!SecurityUtil::checkPermission($this->permissionComponent, '::', ACCESS_EDIT)) {
             return LogUtil::registerPermissionError();
         }
         $entity = $this->initEntityForCreation();
     }
     $this->view->assign('mode', $this->mode)->assign('inlineUsage', $this->inlineUsage);
     // save entity reference for later reuse
     $this->entityRef = $entity;
     if ($this->hasCategories === true) {
         $this->initCategoriesForEdit();
     }
     $workflowHelper = new Reviews_Util_Workflow($this->view->getServiceManager());
     $actions = $workflowHelper->getActionsForObject($entity);
     if ($actions === false || !is_array($actions)) {
         return LogUtil::registerError($this->__('Error! Could not determine workflow actions.'));
     }
     // assign list of allowed actions to the view for further processing
     $this->view->assign('actions', $actions);
     // everything okay, no initialization errors occured
     return true;
 }
Ejemplo n.º 29
0
 /**
  * Find the path of the file by searching overrides and the module location.
  *
  * @param string $file   Name of file to find (can include relative path).
  * @param string $module Module name.
  *
  * @return mixed string of path or bool false
  */
 public static function _findpath($file, $module = null)
 {
     // if no module specified, default to calling module
     if (empty($module)) {
         $module = ModUtil::getName();
     }
     // Get module info
     $modinfo = ModUtil::getInfoFromName($module);
     if (!$modinfo) {
         throw new \Exception(__f('%1$s: The specified module [%2$s] does not exist.', array('Zikula_Workflow_Util', $module)));
     }
     $moduledir = $modinfo['directory'];
     // determine which folder to look in (system or modules)
     if ($modinfo['type'] == ModUtil::TYPE_SYSTEM) {
         // system module
         $modulepath = "system/{$moduledir}";
     } elseif ($modinfo['type'] == ModUtil::TYPE_MODULE) {
         // non system module
         $modulepath = "modules/{$moduledir}";
     } else {
         throw new \Exception(__f('%s: Unsupported module type.', 'Zikula_Workflow_Util'));
     }
     // ensure module is active
     if (!$modinfo['state'] == 3) {
         throw new \Exception(__f('%1$s: The module [%2$s] is not active.', array('Zikula_Workflow_Util', $module)));
     }
     $themedir = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
     $themedir = $themedir['directory'];
     $themepath = DataUtil::formatForOS("themes/{$themedir}/workflows/{$moduledir}/{$file}");
     $configpath = DataUtil::formatForOS("config/workflows/{$moduledir}/{$file}");
     $modulepath = DataUtil::formatForOS("{$modulepath}/workflows/{$file}");
     // find the file in themes or config (for overrides), else module dir
     if (is_readable($themepath)) {
         return $themepath;
     } elseif (is_readable($configpath)) {
         return $configpath;
     } elseif (is_readable($modulepath)) {
         return $modulepath;
     }
     return false;
 }
Ejemplo n.º 30
0
    $nav_links = array();
}
$nav_links_html = '';
$nav_link_proto = '<link rel="%s" href="%s" title="%s" />' . "\n";
while (list($nav_item, $nav_array) = @each($nav_links)) {
    if (!empty($nav_array['url'])) {
        $nav_links_html .= sprintf($nav_link_proto, $nav_item, append_sid($nav_array['url']), $nav_array['title']);
    } else {
        // We have a nested array, used for items like <link rel='chapter'> that can occur more than once.
        while (list(, $nested_array) = each($nav_array)) {
            $nav_links_html .= sprintf($nav_link_proto, $nav_item, $nested_array['url'], $nested_array['title']);
        }
    }
}
// Begin PNphpBB2 Module - Batpuppy PNTheme
$theme_name = UserUtil::isLoggedIn() && System::getVar('theme_change') != 1 ? UserUtil::getTheme() : System::getVar('Default_Theme');
$fthemepath = $phpbb_theme['template_name'];
$imagepath = $phpbb_root_path . "templates/" . $phpbb_theme['template_name'] . "/images/";
$logosize[3] = "width=\"137\" height=\"47\"";
$minisize = "width=\"13\" height=\"13\"";
if (@is_dir($imagepath . $theme_name)) {
    if (is_file($imagepath . $theme_name . "/logo_phpBB_med.gif")) {
        $logosize = getimagesize($imagepath . $theme_name . "/logo_phpBB_med.gif");
    }
    if (@is_file($imagepath . $theme_name . "/icon_mini_faq.gif")) {
        $minisize = getimagesize($imagepath . $theme_name . "/icon_mini_faq.gif");
    }
} else {
    if (@is_file($imagepath . "/logo_phpBB_med.gif")) {
        $logosize = getimagesize($imagepath . "/logo_phpBB_med.gif");
    }