示例#1
0
/**
 * Zikula_View function to create a zikula.orgpatible URL for a specific module function.
 *
 * This function returns a module URL string if successful. Unlike the API
 * function ModURL, this is already sanitized to display, so it should not be
 * passed to the safetext modifier.
 *
 * Available parameters:
 *   - modname:  The well-known name of a module for which to create the URL (required)
 *   - type:     The type of function for which to create the URL; currently one of 'user' or 'admin' (default is 'user')
 *   - func:     The actual module function for which to create the URL (default is 'main')
 *   - fragment: The fragement to target within the URL
 *   - ssl:      See below
 *   - fqurl:    Make a fully qualified URL
 *   - forcelongurl: Do not create a short URL (forced)
 *   - forcelang (boolean|string) Force the inclusion of the $forcelang or default system language in the generated url
 *   - append:   (optional) A string to be appended to the URL
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *   - all remaining parameters are passed to the module function
 *
 * Example
 * Create a URL to the News 'view' function with parameters 'sid' set to 3
 *   <a href="{modurl modname='News' type='user' func='display' sid='3'}">Link</a>
 *
 * Example SSL
 * Create a secure https:// URL to the News 'view' function with parameters 'sid' set to 3
 * ssl - set to constant null,true,false NOTE: $ssl = true not $ssl = 'true'  null - leave the current status untouched, true - create a ssl url, false - create a non-ssl url
 *   <a href="{modurl modname='News' type='user' func='display' sid='3' ssl=true}">Link</a>
 *
 * @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 URL.
 */
function smarty_function_modurl($params, Zikula_View $view)
{
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $append = isset($params['append']) ? $params['append'] : '';
    $fragment = isset($params['fragment']) ? $params['fragment'] : null;
    $fqurl = isset($params['fqurl']) ? $params['fqurl'] : null;
    $forcelongurl = isset($params['forcelongurl']) ? (bool) $params['forcelongurl'] : false;
    if (isset($params['func']) && $params['func']) {
        $func = $params['func'];
    } else {
        if (System::isLegacyMode()) {
            $func = 'main';
            LogUtil::log(__f('{modurl} - %1$s is a required argument, you must specify it explicitly in %2$s', array('func', $view->template)), E_USER_DEPRECATED);
        } else {
            $view->trigger_error(__f('{modurl} - %1$s is a required argument, you must specify it explicitly in %2$s', array('func', $view->template)));
            return false;
        }
    }
    if (isset($params['type']) && $params['type']) {
        $type = $params['type'];
    } else {
        if (System::isLegacyMode()) {
            $type = 'user';
            LogUtil::log(__f('{modurl} - %1$s is a required argument, you must specify it explicitly in %2$s', array('type', $view->template)), E_USER_DEPRECATED);
        } else {
            $view->trigger_error(__f('{modurl} - %1$s is a required argument, you must specify it explicitly in %2$s', array('type', $view->template)));
            return false;
        }
    }
    $modname = isset($params['modname']) ? $params['modname'] : null;
    $ssl = isset($params['ssl']) ? (bool) $params['ssl'] : null;
    $forcelang = isset($params['forcelang']) && $params['forcelang'] ? $params['forcelang'] : false;
    // avoid passing these to ModUtil::url
    unset($params['modname']);
    unset($params['type']);
    unset($params['func']);
    unset($params['fragment']);
    unset($params['ssl']);
    unset($params['fqurl']);
    unset($params['assign']);
    unset($params['append']);
    unset($params['forcelang']);
    unset($params['forcelongurl']);
    if (!$modname) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modurl', 'modname')));
        return false;
    }
    $result = ModUtil::url($modname, $type, $func, $params, $ssl, $fragment, $fqurl, $forcelongurl, $forcelang);
    if ($append && is_string($append)) {
        $result .= $append;
    }
    if ($assign) {
        $view->assign($assign, $result);
    } else {
        return DataUtil::formatForDisplay($result);
    }
}
/**
 * render plugin for fetching a particular module object
 *
 * Examples
 *   {selectmodobject module="AutoCustomer" objecttype="customer" id=4 assign="myCustomer"}
 *   {selectmodobject module="AutoCocktails" objecttype="recipe" id=12 assign="myRecipe"}
 *   {selectmodobject recordClass="AutoCocktails_Model_Recipe" id=12 assign="myRecipe"}
 *
 * Parameters:
 *  module      Name of the module storing the desired object (in DBObject mode)
 *  objecttype  Name of object type (in DBObject mode)
 *  recordClass Class name of an doctrine record. (in Doctrine mode)
 *  id          Identifier of desired object
 *  prefix      Optional prefix for class names (defaults to PN) (in DBObject mode)
 *  assign      Name of the returned object
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return void
 */
function smarty_function_selectmodobject($params, Zikula_View $view)
{
    if (isset($params['recordClass']) && !empty($params['recordClass'])) {
        $doctrineMode = true;
    } else {
        // DBObject checks
        if (!isset($params['module']) || empty($params['module'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'module')));
        }
        if (!isset($params['objecttype']) || empty($params['objecttype'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'objecttype')));
        }
        if (!isset($params['prefix'])) {
            $params['prefix'] = 'PN';
        }
        $doctrineMode = false;
    }
    if (!isset($params['id']) || empty($params['id']) || !is_numeric($params['id'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'id')));
    }
    if (!isset($params['assign']) || empty($params['assign'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'assign')));
    }
    // load object depending on mode: doctrine or dbobject
    if (!$doctrineMode) {
        if (!ModUtil::available($params['module'])) {
            $view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobject')));
        }
        ModUtil::dbInfoLoad($params['module']);
        $classname = "{$params['module']}_DBObject_" . StringUtil::camelize($params['objecttype']);
        if (!class_exists($classname) && System::isLegacyMode()) {
            // BC check for PNObject old style.
            // load the object class corresponding to $params['objecttype']
            if (!($class = Loader::loadClassFromModule($params['module'], $params['objecttype'], false, false, $params['prefix']))) {
                z_exit(__f('Unable to load class [%s] for module [%s]', array(DataUtil::formatForDisplay($params['objecttype']), DataUtil::formatForDisplay($params['module']))));
            }
        }
        // intantiate object model
        $object = new $class();
        $idField = $object->getIDField();
        // assign object data
        // this performs a new database select operation
        // while the result will be saved within the object, we assign it to a local variable for convenience
        $objectData = $object->get(intval($params['id']), $idField);
        if (!is_array($objectData) || !isset($objectData[$idField]) || !is_numeric($objectData[$idField])) {
            $view->trigger_error(__('Sorry! No such item found.'));
        }
    } else {
        $objectData = Doctrine_Core::getTable($params['recordClass'])->find($params['id']);
        if ($objectData === false) {
            $view->trigger_error(__('Sorry! No such item found.'));
        }
    }
    $view->assign($params['assign'], $objectData);
}
示例#3
0
 /**
  * Constructor.
  *
  * @param mixed $payload Application data.
  * @param mixed $message Response status/error message, may be string or array.
  * @param array $options Options.
  */
 public function __construct($payload, $message = null, array $options = array())
 {
     $this->payload = $payload;
     $this->messages = (array) $message;
     $this->options = $options;
     if ($this->newCsrfToken) {
         if (System::isLegacyMode()) {
             $this->authid = SecurityUtil::generateAuthKey(ModUtil::getName());
         }
         $this->csrfToken = SecurityUtil::generateCsrfToken();
     }
 }
示例#4
0
 /**
  * Constructor.
  *
  * @param mixed $payload Application data.
  * @param mixed $message Response status/error message, may be string or array.
  * @param array $options Options.
  */
 public function __construct($payload, $message = null, array $options = array())
 {
     $this->payload = $payload;
     $this->messages = (array) $message;
     $this->options = $options;
     if ($this->newCsrfToken) {
         $this->csrfToken = \SecurityUtil::generateCsrfToken();
     }
     if (\System::isLegacyMode()) {
         $this->authid = \SecurityUtil::generateAuthKey(\ModUtil::getName());
     }
     parent::__construct('', $this->statusCode);
 }
/**
 * Zikula_View function to add the contents of a block to either the header or footer multicontent page variable
 *
 * This function adds the content of the block to either the end of the <head> portion of the page (using 'header') or to
 * a position just prior to the closing </body> tag (using 'footer').
 *
 * Available parameters:
 *   - name:     The name of the page variable to set, either 'header' or 'footer'; optional, default is 'header'
 *
 * Examples:
 *
 *  This inline stylesheet will appear in the page's <head> section just before the closing </head>:
 * <code>
 *   {pageaddvarblock name='header'}
 *   <style type="text/css">
 *       p { font-size: 1.5em; }
 *   </style>
 *   {/pageaddvarblock}
 * </code>
 *
 *  This inline script will appear in the page's <body> section just before the closing </body>:
 * <code>
 *   {pageaddvarblock name='footer'}
 *   <script language="javascript" type="text/javascript">
 *       alert ('The closing </body> tag is coming.');
 *   </style>
 *   {/pageaddvarblock}
 * </code>
 *
 * @param array       $params  All attributes passed to this function from the template.
 * @param string      $content The content of the block.
 * @param Zikula_View $view    Reference to the Zikula_View object.
 *
 * @return string
 */
function smarty_block_pageaddvarblock($params, $content, Zikula_View $view)
{
    if ($content) {
        $varname = isset($params['name']) ? $params['name'] : 'header';
        if (System::isLegacyMode() && $varname == 'rawtext') {
            LogUtil::log(__f('Warning! The page variable %1$s is deprecated. Please use %2$s instead.', array('rawtext', 'header')), E_USER_DEPRECATED);
            $varname = 'header';
        }
        if ($varname != 'header' && $varname != 'footer') {
            throw new Zikula_Exception_Fatal(__f('Invalid page variable name: \'%1$s\'.', array($varname)));
        }
        PageUtil::addVar($varname, $content);
    }
}
 /**
  * Add all default assets to every page (scripts and stylesheets)
  * @param GetResponseEvent $event
  */
 public function setDefaultPageAssets(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $basePath = $event->getRequest()->getBasePath();
     // add default javascripts to jsAssetBag
     $this->addJquery($basePath);
     $this->jsAssetBag->add([$basePath . '/' . $this->params['zikula.javascript.bootstrap.min.path'] => AssetBag::WEIGHT_BOOTSTRAP_JS, $basePath . '/javascript/helpers/bootstrap-zikula.js' => AssetBag::WEIGHT_BOOTSTRAP_ZIKULA, $basePath . '/web/html5shiv/dist/html5shiv.js' => AssetBag::WEIGHT_HTML5SHIV]);
     $this->addFosJsRouting($basePath);
     // add default stylesheets to cssAssetBag
     $this->addBootstrapCss($basePath);
     $this->cssAssetBag->add([$basePath . '/style/core.css' => 1]);
     // Add legacy stylesheet
     if (\System::isLegacyMode('1.4.0')) {
         $this->cssAssetBag->add([$basePath . '/style/legacy.css' => 2]);
     }
 }
示例#7
0
 /**
  * Return a hash structure mapping uid to username.
  *
  * @param array   $where        Array of field values to filter by (optional, default=array()).
  * @param array   $orderBy      Array fields to sort by (optional, default=array()).
  * @param integer $limitOffset  The select-limit offset (optional, default=null).
  * @param integer $limitNumRows The number of rows to fetch (optional, default=null).
  * @param string  $assocKey     The associative key to apply (optional) (default='uid').
  *
  * @deprecated since 1.3.0
  *
  * @return array An array mapping uid to username.
  */
 public static function getUsers($where = array(), $orderBy = array(), $limitOffset = null, $limitNumRows = null, $assocKey = 'uid')
 {
     // first check for string based parameters and use dbutil if found
     if (System::isLegacyMode() && (is_string($where) || is_string($orderBy))) {
         if ($where == array()) {
             $where = '';
         }
         if ($orderBy == array()) {
             $orderBy = '';
         }
         return DBUtil::selectObjectArray('users', $where, $orderBy, $limitOffset, $limitNumRows, $assocKey);
     }
     // we've now ruled out BC parameters
     $em = \ServiceUtil::get('doctrine.entitymanager');
     $users = $em->getRepository('ZikulaUsersModule:UserEntity')->findBy($where, $orderBy, $limitNumRows, $limitOffset);
     $items = array();
     foreach ($users as $user) {
         $items[$user[$assocKey]] = $user->toArray();
     }
     return $items;
 }
示例#8
0
 /**
  * Get available admin panel links.
  *
  * @return array An array of admin links.
  */
 public function getlinks()
 {
     $links = array();
     // assign variables from input
     $startnum = (int) FormUtil::getPassedValue('startnum', null, 'GET');
     $letter = FormUtil::getPassedValue('letter', null, 'GET');
     if (SecurityUtil::checkPermission('Extensions::', '::', ACCESS_ADMIN)) {
         $links[] = array('url' => ModUtil::url('Extensions', 'admin', 'view'), 'text' => $this->__('Modules list'), 'class' => 'z-icon-es-view', 'links' => array(array('url' => ModUtil::url('Extensions', 'admin', 'view'), 'text' => $this->__('All')), array('url' => ModUtil::url('Extensions', 'admin', 'view', array('state' => ModUtil::STATE_UNINITIALISED)), 'text' => $this->__('Not installed')), array('url' => ModUtil::url('Extensions', 'admin', 'view', array('state' => ModUtil::STATE_INACTIVE)), 'text' => $this->__('Inactive')), array('url' => ModUtil::url('Extensions', 'admin', 'view', array('state' => ModUtil::STATE_ACTIVE)), 'text' => $this->__('Active')), array('url' => ModUtil::url('Extensions', 'admin', 'view', array('state' => ModUtil::STATE_MISSING)), 'text' => $this->__('Files missing')), array('url' => ModUtil::url('Extensions', 'admin', 'view', array('state' => ModUtil::STATE_UPGRADED)), 'text' => $this->__('New version uploaded')), array('url' => ModUtil::url('Extensions', 'admin', 'view', array('state' => ModUtil::STATE_INVALID)), 'text' => $this->__('Invalid structure'))));
         $links[] = array('url' => ModUtil::url('Extensions', 'admin', 'viewPlugins'), 'text' => $this->__('Plugins list'), 'class' => 'z-icon-es-gears', 'links' => array(array('url' => ModUtil::url('Extensions', 'admin', 'viewPlugins'), 'text' => $this->__('All')), array('url' => ModUtil::url('Extensions', 'admin', 'viewPlugins', array('state' => PluginUtil::NOTINSTALLED)), 'text' => $this->__('Not installed')), array('url' => ModUtil::url('Extensions', 'admin', 'viewPlugins', array('state' => PluginUtil::DISABLED)), 'text' => $this->__('Inactive')), array('url' => ModUtil::url('Extensions', 'admin', 'viewPlugins', array('state' => PluginUtil::ENABLED)), 'text' => $this->__('Active'))));
         $links[] = array('url' => ModUtil::url('Extensions', 'admin', 'viewPlugins', array('systemplugins' => true)), 'text' => $this->__('System Plugins'), 'class' => 'z-icon-es-gears', 'links' => array(array('url' => ModUtil::url('Extensions', 'admin', 'viewPlugins', array('systemplugins' => true)), 'text' => $this->__('All')), array('url' => ModUtil::url('Extensions', 'admin', 'viewPlugins', array('systemplugins' => true, 'state' => PluginUtil::NOTINSTALLED)), 'text' => $this->__('Not installed')), array('url' => ModUtil::url('Extensions', 'admin', 'viewPlugins', array('systemplugins' => true, 'state' => PluginUtil::DISABLED)), 'text' => $this->__('Inactive')), array('url' => ModUtil::url('Extensions', 'admin', 'viewPlugins', array('systemplugins' => true, 'state' => PluginUtil::ENABLED)), 'text' => $this->__('Active'))));
         $legacyHooks = DBUtil::selectObjectArray('hooks');
         if (System::isLegacyMode() && $legacyHooks) {
             $links[] = array('url' => ModUtil::url('Extensions', 'admin', 'legacyhooks', array('id' => 0)), 'text' => $this->__('Legacy hooks'), 'class' => 'z-icon-es-hook');
         }
         $links[] = array('url' => ModUtil::url('Extensions', 'admin', 'modifyconfig'), 'text' => $this->__('Settings'), 'class' => 'z-icon-es-config');
         //$filemodules = ModUtil::apiFunc('Extensions', 'admin', 'getfilemodules');
         //ModUtil::apiFunc('Extensions', 'admin', 'regenerate', array('filemodules' => $filemodules));
         // get a list of modules needing upgrading
         $newmods = ModUtil::apiFunc('Extensions', 'admin', 'listmodules', array('state' => ModUtil::STATE_UPGRADED));
         if ($newmods) {
             $links[] = array('url' => ModUtil::url('Extensions', 'admin', 'upgradeall'), 'text' => $this->__('Upgrade All'), 'class' => 'z-icon-es-config');
         }
     }
     return $links;
 }
示例#9
0
 * SimplePieFeed class.
 */
class SimplePieFeed extends SimplePie
{
    /**
     * Class constructor.
     *
     * @param string  $feed_url       The URL to the feed (optional).
     * @param integer $cache_duration The duration (in seconds) that the feed contents will be retained in cache.
     */
    public function __construct($feed_url = null, $cache_duration = null, $cache_dir = null)
    {
        parent::__construct();
        if (isset($cache_dir)) {
            $this->set_cache_location($cache_dir);
        } else {
            $this->set_cache_location(CacheUtil::getLocalDir('feeds'));
        }
        if (isset($cache_duration)) {
            $this->set_cache_duration($cache_duration);
        }
        if (isset($feed_url)) {
            $this->set_feed_url($feed_url);
        }
    }
}
if (System::isLegacyMode()) {
    class ZFeeds extends SimplePieFeed
    {
    }
}
示例#10
0
 /**
  * Internal procedure for managing legacy script paths.
  *
  * @param string $script Script path to check.
  *
  * @return string Verified script path
  */
 private static function handleLegacy($script)
 {
     // Handle legacy references to non-minimised scripts.
     if (strpos($script, 'javascript/livepipe/') === 0) {
         $script = 'livepipe';
     } elseif (strpos($script, 'javascript/ajax/') === 0) {
         switch ($script) {
             case 'javascript/ajax/validation.js':
                 $script = 'validation';
                 break;
             case 'javascript/ajax/unittest.js':
                 $script = 'javascript/ajax/unittest.min.js';
                 break;
             case 'javascript/ajax/prototype.js':
             case 'javascript/ajax/builder.js':
             case 'javascript/ajax/controls.js':
             case 'javascript/ajax/dragdrop.js':
             case 'javascript/ajax/effects.js':
             case 'javascript/ajax/slider.js':
             case 'javascript/ajax/sound.js':
                 $script = 'prototype';
                 break;
         }
         if (strpos($script, 'javascript/ajax/scriptaculous') === 0) {
             $script = 'prototype';
         }
     } elseif (System::isLegacyMode() && (strpos($script, 'system/') === 0 || strpos($script, 'modules/') === 0)) {
         // check for customized javascripts
         $custom = str_replace(array('javascript/', 'pnjavascript/'), '', $script);
         $custom = str_replace(array('modules', 'system'), 'config/javascript', $custom);
         if (file_exists($custom)) {
             $script = $custom;
         }
     }
     return $script;
 }
示例#11
0
文件: Theme.php 项目: rmaiwald/core
 /**
  * Define all our plugin directories.
  *
  * @return void
  */
 private function _plugin_dirs()
 {
     // add theme specific plugins directories, if they exist
     if (is_dir('themes/' . $this->directory . '/Resources/views/plugins')) {
         $this->addPluginDir('themes/' . $this->directory . '/Resources/views/plugins');
         return;
     }
     if (is_dir('themes/' . $this->directory . '/plugins')) {
         $this->addPluginDir('themes/' . $this->directory . '/plugins');
     }
     if (System::isLegacyMode()) {
         // load the usemodules configuration if exists
         $usemod_conf = 'themes/' . $this->directory . '/templates/config/usemodules.txt';
         // load the config file
         if (is_readable($usemod_conf) && is_file($usemod_conf)) {
             $additionalmodules = file($usemod_conf);
             if (is_array($additionalmodules)) {
                 foreach ($additionalmodules as $addmod) {
                     $this->_add_plugins_dir(trim($addmod));
                 }
             }
         }
     }
 }
示例#12
0
文件: View.php 项目: Silwereth/core
 /**
  * Add core data to the template.
  *
  * This function adds some basic data to the template depending on the
  * current user and the Zikula settings.  There is no need to call this as it's
  * invoked automatically on instanciation.
  *
  * In legacy mode 'coredata' will contain the module vars, but not when disabled.
  * This is just for BC legacy - to access module vars there is a 'modvars' property
  * assigned to all templates.
  *
  * @return Zikula_View
  */
 public function add_core_data()
 {
     if (!isset($this->serviceManager['zikula_view.coredata'])) {
         $this->serviceManager['zikula_view.coredata'] = new ArrayObject(array());
     }
     $core = $this->serviceManager['zikula_view.coredata'];
     $core['version_num'] = Zikula_Core::VERSION_NUM;
     $core['version_id'] = Zikula_Core::VERSION_ID;
     $core['version_sub'] = Zikula_Core::VERSION_SUB;
     $core['logged_in'] = UserUtil::isLoggedIn();
     $core['language'] = $this->language;
     // add userdata
     $core['user'] = UserUtil::getVars(SessionUtil::getVar('uid'));
     if (System::isLegacyMode()) {
         // add modvars of current modules
         foreach ($this->module as $module => $dummy) {
             if (!empty($module)) {
                 $core[$module] = ModUtil::getVar($module);
             }
         }
         // add mod vars of all modules supplied as parameter
         $modulenames = func_get_args();
         foreach ($modulenames as $modulename) {
             // if the modulename is empty do nothing
             if (!empty($modulename) && !is_array($modulename) && !array_key_exists($modulename, $this->module)) {
                 // check if user wants to have config
                 if ($modulename == ModUtil::CONFIG_MODULE) {
                     $ZConfig = ModUtil::getVar(ModUtil::CONFIG_MODULE);
                     foreach ($ZConfig as $key => $value) {
                         // gather all config vars
                         $core['ZConfig'][$key] = $value;
                     }
                 } else {
                     $core[$modulename] = ModUtil::getVar($modulename);
                 }
             }
         }
         $this->assign('pncore', $core);
     }
     // Module vars
     parent::assign('coredata', $core);
     return $this;
 }
示例#13
0
 /**
  * Call system hooks.
  *
  * Implements 'core.postinit' event.
  *
  * This is just here for legacy systeminit hooks.
  *
  * @param Zikula_Event $event The event handler.
  *
  * @return void
  */
 public function systemHooks(Zikula_Event $event)
 {
     if (!System::isInstalling() && System::isLegacyMode()) {
         // call system init hooks
         $systeminithooks = FormUtil::getPassedValue('systeminithooks', 'yes', 'GETPOST');
         if (SecurityUtil::checkPermission('::', '::', ACCESS_ADMIN) && (isset($systeminithooks) && $systeminithooks == 'no')) {
             // omit system hooks if requested by an administrator
         } else {
             ModUtil::callHooks('zikula', 'systeminit', 0, array('module' => 'zikula'));
         }
     }
 }
示例#14
0
 /**
  * Loads a single plugin.
  *
  * @param string $name   Plugin's name.
  * @param array  $config Plugin's config.
  *
  * @return integer The plugin's id.
  */
 public function loadPlugin($name, $config = array())
 {
     if ($this->isLoaded($name)) {
         return $this->_loaded[$name];
     }
     $plugins = $this->getPluginsAvailable();
     if (isset($plugins[$name]) && !empty($plugins[$name]) && class_exists($plugins[$name])) {
         $class = $plugins[$name];
         $this->addCommon($config);
         $obj = new $class($config);
         $this->_plg[] = $obj;
         end($this->_plg);
         $key = key($this->_plg);
         $obj = $this->_plg[$key];
         $obj->setID($key);
         $this->_registerPlugin($key);
         $this->_loaded[$name] = $key;
         return key(end($this->_plg));
     } elseif (System::isLegacyMode()) {
         return $this->loadPluginLegacy();
     }
     return false;
 }
/**
 * render plugin for fetching a list of module objects
 *
 * Examples
 *   {selectmodobjectarray module="AutoCustomer" objecttype="customer" assign="myCustomers"}
 *   {selectmodobjectarray module="AutoCocktails" objecttype="recipe" orderby="name desc" assign="myRecipes"}
 *   {selectmodobjectarray recordClass="AutoCocktails_Model_Recipe" orderby="name desc" assign="myRecipes"}
 *
 * Parameters:
 *  module      Name of the module storing the desired object (in DBObject mode)
 *  objecttype  Name of object type (in DBObject mode)
 *  recordClass Class name of an doctrine record. (in Doctrine mode)
 *  useArrays   true to fetch arrays and false to fetch objects (default is true) (in Doctrine mode)
 *  where       Filter value
 *  orderby     Sorting field and direction
 *  pos         Start offset
 *  num         Amount of selected objects
 *  prefix      Optional prefix for class names (defaults to PN) (in DBObject mode)
 *  assign      Name of the returned object
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return void
 */
function smarty_function_selectmodobjectarray($params, Zikula_View $view)
{
    if (isset($params['recordClass']) && !empty($params['recordClass'])) {
        $doctrineMode = true;
    } else {
        // DBObject checks
        if (!isset($params['module']) || empty($params['module'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobjectarray', 'module')));
        }
        if (!isset($params['objecttype']) || empty($params['objecttype'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobjectarray', 'objecttype')));
        }
        if (!isset($params['prefix'])) {
            $params['prefix'] = 'PN';
        }
        $doctrineMode = false;
    }
    if (!isset($params['assign'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobjectarray', 'assign')));
    }
    // load object depending on mode: doctrine or dbobject
    if (!$doctrineMode) {
        if (!ModUtil::available($params['module'])) {
            $view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobjectarray')));
        }
        ModUtil::dbInfoLoad($params['module']);
        $classname = "{$params['module']}_DBObject_" . StringUtil::camelize($params['objecttype']) . 'Array';
        if (!class_exists($classname) && System::isLegacyMode()) {
            // BC check for PNObjectArray old style.
            // load the object class corresponding to $params['objecttype']
            if (!($class = Loader::loadArrayClassFromModule($params['module'], $params['objecttype'], false, $params['prefix']))) {
                z_exit(__f('Error! Cannot load module array class %1$s for module %2$s.', array(DataUtil::formatForDisplay($params['module']), DataUtil::formatForDisplay($params['objecttype']))));
            }
        }
        // instantiate the object-array
        $objectArray = new $class();
        // convenience vars to make code clearer
        $where = $sort = '';
        if (isset($params['where']) && !empty($params['where'])) {
            $where = $params['where'];
        }
        // TODO: add FilterUtil support here in 2.0
        if (isset($params['orderby']) && !empty($params['orderby'])) {
            $sort = $params['orderby'];
        }
        $pos = 1;
        if (isset($params['pos']) && !empty($params['pos']) && is_numeric($params['pos'])) {
            $pos = $params['pos'];
        }
        $num = 10;
        if (isset($params['num']) && !empty($params['num']) && is_numeric($params['num'])) {
            $num = $params['num'];
        }
        // get() returns the cached object fetched from the DB during object instantiation
        // get() with parameters always performs a new select
        // while the result will be saved in the object, we assign in to a local variable for convenience.
        $objectData = $objectArray->get($where, $sort, $pos - 1, $num);
    } else {
        $query = Doctrine_Core::getTable($params['recordClass'])->createQuery();
        if (isset($params['where']) && !empty($params['where'])) {
            if (is_array($params['where'])) {
                $query->where($params['where'][0], $params['where'][1]);
            } else {
                $query->where($params['where']);
            }
        }
        if (isset($params['orderby']) && !empty($params['orderby'])) {
            $query->orderBy($params['orderby']);
        }
        $pos = 0;
        if (isset($params['pos']) && !empty($params['pos']) && is_numeric($params['pos'])) {
            $pos = $params['pos'];
        }
        $num = 10;
        if (isset($params['num']) && !empty($params['num']) && is_numeric($params['num'])) {
            $num = $params['num'];
        }
        $query->offset($pos);
        $query->limit($num);
        if (isset($params['useArrays']) && !$params['useArrays']) {
            $objectData = $query->execute();
        } else {
            $objectData = $query->fetchArray();
        }
    }
    $view->assign($params['assign'], $objectData);
}
示例#16
0
 /**
  * Add var.
  *
  * Adds a new vaule to a page variable. In the case of a single
  * page variable, this functions acts exactly like PageUtil::setVar.
  *
  * @param string $varname  The name of the page variable.
  * @param mixed  $value    The new value.
  * @param string $features The feature(s) to load via polyfill.
  *
  * @see    PageUtil::setVar
  * @return boolean true On success, false of the page variable is not registered.
  */
 public static function addVar($varname, $value, $features = 'forms')
 {
     global $_pageVars;
     if (System::isLegacyMode()) {
         switch ($varname) {
             case 'rawtext':
                 LogUtil::log(__f('Warning! The page variable %1$s is deprecated. Please use %2$s instead.', array('rawtext', 'header')), E_USER_DEPRECATED);
                 $varname = 'header';
                 break;
         }
     }
     // check for $_pageVars sanity
     if (!isset($_pageVars)) {
         $_pageVars = array();
     } elseif (!is_array($_pageVars)) {
         return false;
     }
     if (!isset($_pageVars[$varname])) {
         return false;
     }
     if (is_array($value)) {
         $value = array_unique($value);
     }
     $value = self::resolveSymfonyAsset($value);
     // @todo Remove in 1.5.0.
     $value = self::fixJQueryThemesPath($value);
     $event = new \Zikula\Core\Event\GenericEvent($varname, array(), $value);
     $value = EventUtil::getManager()->dispatch('pageutil.addvar_filter', $event)->getData();
     if ($_pageVars[$varname]['multivalue']) {
         if (is_array($value)) {
             if (in_array('polyfill', $value)) {
                 $features = explode(' ', $features);
                 foreach ($features as $feature) {
                     PageUtil::addVar('polyfill_features', $feature);
                 }
                 $_pageVars[$varname]['contents'] = array_merge($_pageVars[$varname]['contents'], $value);
             } else {
                 $_pageVars[$varname]['contents'] = array_merge($_pageVars[$varname]['contents'], $value);
             }
         } else {
             $_pageVars[$varname]['contents'][] = $value;
         }
         // make values unique
         $_pageVars[$varname]['contents'] = array_unique($_pageVars[$varname]['contents']);
     } else {
         $_pageVars[$varname]['contents'] = $value;
     }
     return true;
 }
示例#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;
    }
}
示例#18
0
    /**
     * Encode data in JSON and return.
     *
     * This functions can add a new authid if requested to do so (default).
     * If the supplied args is not an array, it will be converted to an
     * array with 'data' as key.
     * Authid field will always be named 'authid'. Any other field 'authid'
     * will be overwritten!
     * Script execution stops here
     *
     * @param mixed   $args         String or array of data.
     * @param boolean $createauthid Create a new authid and send it back to the calling javascript.
     * @param boolean $xjsonheader  Send result in X-JSON: header for prototype.js.
     * @param boolean $statusmsg    Include statusmsg in output.
     * @param string  $code         Optional error code, default '200 OK'.
     *
     * @deprecated since 1.3.0
     *
     * @return void
     */
    public static function output($args, $createauthid = false, $xjsonheader = false, $statusmsg = true, $code = '200 OK')
    {
        if (!System::isLegacyMode()) {
            $response = new Zikula_Response_Ajax($args);
            echo $response;
            System::shutDown();
        }
        // Below for reference - to be deleted.

        // check if an error message is set
        $msgs = LogUtil::getErrorMessagesText('<br />');

        if ($msgs != false && !empty($msgs)) {
            self::error($msgs);
        }

        $data = !is_array($args) ? array('data' => $args) : $args;

        if ($statusmsg === true) {
            // now check if a status message is set
            $msgs = LogUtil::getStatusMessagesText('<br />');
            $data['statusmsg'] = $msgs;
        }

        if ($createauthid === true) {
            $data['authid'] = SecurityUtil::generateAuthKey(ModUtil::getName());
        }

        // convert the data to UTF-8 if not already encoded as such
        // Note: this isn't strict test but relying on the site language pack encoding seems to be a good compromise
        if (ZLanguage::getEncoding() != 'utf-8') {
            $data = DataUtil::convertToUTF8($data);
        }

        $output = json_encode($data);

        header("HTTP/1.0 $code");
        header('Content-type: application/json');
        if ($xjsonheader == true) {
            header('X-JSON:(' . $output . ')');
        }
        echo $output;
        System::shutdown();
    }
示例#19
0
 /**
  * Creates an object array selector.
  *
  * @param string  $modname        Module name.
  * @param string  $objectType     Object type.
  * @param string  $name           Select field name.
  * @param string  $field          Value field.
  * @param string  $displayField   Display field.
  * @param string  $where          Where clause.
  * @param string  $sort           Sort clause.
  * @param string  $selectedValue  Selected value.
  * @param string  $defaultValue   Value for "default" option.
  * @param string  $defaultText    Text for "default" option.
  * @param string  $allValue       Value for "all" option.
  * @param string  $allText        Text for "all" option.
  * @param string  $displayField2  Second display field.
  * @param boolean $submit         Submit on choose.
  * @param boolean $disabled       Add Disabled attribute to select.
  * @param string  $fieldSeparator Field seperator if $displayField2 is given.
  * @param integer $multipleSize   Size for multiple selects.
  *
  * @return string The rendered output.
  */
 public static function getSelector_ObjectArray($modname, $objectType, $name, $field = '', $displayField = 'name', $where = '', $sort = '', $selectedValue = '', $defaultValue = 0, $defaultText = '', $allValue = 0, $allText = '', $displayField2 = null, $submit = true, $disabled = false, $fieldSeparator = ', ', $multipleSize = 1)
 {
     if (!$modname) {
         return z_exit(__f('Invalid %1$s passed to %2$s.', array('modname', 'HtmlUtil::getSelector_ObjectArray')));
     }
     if (!$objectType) {
         return z_exit(__f('Invalid %1$s passed to %2$s.', array('objectType', 'HtmlUtil::getSelector_ObjectArray')));
     }
     if (!ModUtil::dbInfoLoad($modname)) {
         return __f('Unavailable/Invalid %1$s [%2$s] passed to %3$s.', array('modulename', $modname, 'HtmlUtil::getSelector_ObjectArray'));
     }
     if (!SecurityUtil::checkPermission("{$objectType}::", '::', ACCESS_OVERVIEW)) {
         return __f('Security check failed for %1$s [%2$s] passed to %3$s.', array('modulename', $modname, 'HtmlUtil::getSelector_ObjectArray'));
     }
     $cacheKey = md5("{$modname}|{$objectType}|{$where}|{$sort}");
     if (isset($cache[$cacheKey])) {
         $dataArray = $cache[$cacheKey];
     } else {
         $classname = "{$modname}_DBObject_" . StringUtil::camelize($objectType) . 'Array';
         if (!class_exists($classname) && System::isLegacyMode()) {
             // BC check for PNObject old style.
             $classname = Loader::loadClassFromModule($modname, $objectType, true);
             if (!$classname) {
                 return __f('Unable to load class [%1$s] for module [%2$s].', array($objectType, $modname));
             }
         }
         $class = new $classname();
         //$dataArray = $class->get($where, $sort, -1, -1, '', false, $distinct);
         $dataArray = $class->get($where, $sort, -1, -1, '', false);
         $cache[$cacheKey] = $dataArray;
         if (!$field) {
             $field = $class->_objField;
         }
     }
     $data2 = array();
     foreach ($dataArray as $object) {
         $val = $object[$field];
         $disp = $object[$displayField];
         if ($displayField2) {
             $disp .= $fieldSeparator . $object[$displayField2];
         }
         $data2[$val] = $disp;
     }
     return self::getSelector_Generic($name, $data2, $selectedValue, $defaultValue, $defaultText, $allValue, $allText, $submit, $disabled, $multipleSize);
 }
示例#20
0
    /**
     * add a plugins dir to _plugin_dir array
     *
     * This function takes  module name and adds two path two the plugins_dir array
     * when existing
     *
     * @param string $module Well known module name.
     *
     * @return void
     */
    protected function _add_plugins_dir($module)
    {
        if (empty($module)) {
            return;
        }

        $modinfo = ModUtil::getInfoFromName($module);
        if (!$modinfo) {
            return;
        }

        $modpath = ($modinfo['type'] == ModUtil::TYPE_SYSTEM) ? 'system' : 'modules';
        $this->addPluginDir("$modpath/$modinfo[directory]/templates/plugins");

        if (System::isLegacyMode() && $modpath == 'modules') {
            $this->addPluginDir("$modpath/$modinfo[directory]/pntemplates/plugins");
        }
    }
示例#21
0
文件: ModUtil.php 项目: rmaiwald/core
 /**
  * Generate a module function URL.
  *
  * If the module is non-API compliant (type 1) then
  * a) $func is ignored.
  * b) $type=admin will generate admin.php?module=... and $type=user will generate index.php?name=...
  *
  * @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 array of arguments to put on the URL.
  * @param boolean|null $ssl     Set to constant null,true,false $ssl = true not $ssl = 'true'  null - leave the current status untouched,
  *                                     true - create a ssl url, false - create a non-ssl url.
  * @param string         $fragment     The framgment to target within the URL.
  * @param boolean|null   $fqurl        Fully Qualified URL. True to get full URL, eg for Redirect, else gets root-relative path unless SSL.
  * @param boolean        $forcelongurl Force ModUtil::url to not create a short url even if the system is configured to do so.
  * @param boolean|string $forcelang    Force the inclusion of the $forcelang or default system language in the generated url.
  *
  * @return string Absolute URL for call.
  */
 public static function url($modname, $type = null, $func = null, $args = array(), $ssl = null, $fragment = null, $fqurl = null, $forcelongurl = false, $forcelang = false)
 {
     // define input, all numbers and booleans to strings
     $modname = isset($modname) ? (string) $modname : '';
     $modname = static::convertModuleName($modname);
     // note - when this legacy is to be removed, change method signature $type = null to $type making it a required argument.
     if (!$type) {
         if (System::isLegacyMode()) {
             $type = 'user';
             LogUtil::log('ModUtil::url() - $type is a required argument, you must specify it explicitly.', E_USER_DEPRECATED);
         } else {
             throw new UnexpectedValueException('ModUtil::url() - $type is a required argument, you must specify it explicitly.');
         }
     }
     // note - when this legacy is to be removed, change method signature $func = null to $func making it a required argument.
     if (!$func) {
         if (System::isLegacyMode()) {
             $func = 'main';
             LogUtil::log('ModUtil::url() - $func is a required argument, you must specify it explicitly.', E_USER_DEPRECATED);
         } else {
             throw new UnexpectedValueException('ModUtil::url() - $func is a required argument, you must specify it explicitly.');
         }
     }
     // 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 "ZikulaExtensionsModule".  Please update your ModUtil::url() or {modurl} calls with $module = "ZikulaExtensionsModule".'));
         $modname = 'ZikulaExtensionsModule';
     }
     // Try to generate the url using Symfony routing.
     $url = self::symfonyRoute($modname, $type, $func, $args, $ssl, $fragment, $fqurl, $forcelang);
     if ($url !== false) {
         return $url;
     }
     $request = \ServiceUtil::get('request');
     if ($request->attributes->has('_route_params')) {
         // If this attribute is set, a Symfony route has been matched. We need to generate full urls in that case.
         $fqurl = true;
     }
     //get the module info
     $modinfo = self::getInfo(self::getIDFromName($modname));
     // set the module name to the display name if this is present
     if (isset($modinfo['url']) && !empty($modinfo['url'])) {
         $modname = rawurlencode($modinfo['url']);
     }
     $entrypoint = System::getVar('entrypoint');
     $host = System::serverGetVar('HTTP_HOST');
     if (empty($host)) {
         return false;
     }
     $baseuri = System::getBaseUri();
     $https = System::serverGetVar('HTTPS');
     $shorturls = System::getVar('shorturls');
     $shorturlsstripentrypoint = System::getVar('shorturlsstripentrypoint');
     $shorturlsdefaultmodule = System::getVar('shorturlsdefaultmodule');
     // Don't encode URLs with escaped characters, like return urls.
     foreach ($args as $v) {
         if (!is_array($v)) {
             if (strpos($v, '%') !== false) {
                 $shorturls = false;
                 break;
             }
         } else {
             foreach ($v as $vv) {
                 if (is_array($vv)) {
                     foreach ($vv as $vvv) {
                         if (!is_array($vvv) && strpos($vvv, '%') !== false) {
                             $shorturls = false;
                             break;
                         }
                     }
                 } elseif (strpos($vv, '%') !== false) {
                     $shorturls = false;
                     break;
                 }
             }
             break;
         }
     }
     // Setup the language code to use
     if (is_array($args) && isset($args['lang'])) {
         if (in_array($args['lang'], ZLanguage::getInstalledLanguages())) {
             $language = $args['lang'];
         }
         unset($args['lang']);
     }
     if (!isset($language)) {
         $language = ZLanguage::getLanguageCode();
     }
     $language = $forcelang && in_array($forcelang, ZLanguage::getInstalledLanguages()) ? $forcelang : $language;
     // Only produce full URL when HTTPS is on or $ssl is set
     $siteRoot = '';
     if (isset($https) && $https == 'on' || $ssl != null || $fqurl == true) {
         $protocol = 'http' . ($https == 'on' && $ssl !== false || $ssl === true ? 's' : '');
         $secureDomain = System::getVar('secure_domain');
         $siteRoot = $protocol . '://' . ($secureDomain != '' ? $secureDomain : $host . $baseuri) . '/';
     }
     // Only convert type=user. Exclude links that append a theme parameter
     if ($shorturls && $type == 'user' && $forcelongurl == false) {
         if (isset($args['theme'])) {
             $theme = $args['theme'];
             unset($args['theme']);
         }
         // Module-specific Short URLs
         $url = self::apiFunc($modinfo['name'], 'user', 'encodeurl', array('modname' => $modname, 'type' => $type, 'func' => $func, 'args' => $args));
         if (empty($url)) {
             // depending on the settings, we have generic directory based short URLs:
             // [language]/[module]/[function]/[param1]/[value1]/[param2]/[value2]
             // [module]/[function]/[param1]/[value1]/[param2]/[value2]
             $vars = '';
             foreach ($args as $k => $v) {
                 if (is_array($v)) {
                     foreach ($v as $k2 => $w) {
                         if (is_numeric($w) || !empty($w)) {
                             // we suppress '', but allow 0 as value (see #193)
                             $vars .= '/' . $k . '[' . $k2 . ']/' . $w;
                             // &$k[$k2]=$w
                         }
                     }
                 } elseif (is_numeric($v) || !empty($v)) {
                     // we suppress '', but allow 0 as value (see #193)
                     $vars .= "/{$k}/{$v}";
                     // &$k=$v
                 }
             }
             $url = $modname . ($vars || $func != 'main' ? "/{$func}{$vars}" : '');
         }
         if ($modinfo && $shorturlsdefaultmodule && $shorturlsdefaultmodule == $modinfo['name']) {
             $pattern = '/^' . preg_quote($modinfo['url'], '/') . '\\//';
             $url = preg_replace($pattern, '', $url);
         }
         if (isset($theme)) {
             $url = rawurlencode($theme) . '/' . $url;
         }
         // add language param to short url
         if (ZLanguage::isRequiredLangParam() || $forcelang) {
             $url = "{$language}/" . $url;
         }
         if (!$shorturlsstripentrypoint) {
             $url = "{$entrypoint}/{$url}" . (!empty($query) ? '?' . $query : '');
         } else {
             $url = "{$url}" . (!empty($query) ? '?' . $query : '');
         }
     } else {
         // Regular stuff
         $urlargs = "module={$modname}&type={$type}&func={$func}";
         // add lang param to URL
         if (ZLanguage::isRequiredLangParam() || $forcelang) {
             $urlargs .= "&lang={$language}";
         }
         $url = "{$entrypoint}?{$urlargs}";
         if (!is_array($args)) {
             return false;
         } else {
             foreach ($args as $key => $value) {
                 if (is_array($value)) {
                     foreach ($value as $l => $w) {
                         if (is_numeric($w) || !empty($w)) {
                             // we suppress '', but allow 0 as value (see #193)
                             if (is_array($w)) {
                                 foreach ($w as $m => $n) {
                                     if (is_numeric($n) || !empty($n)) {
                                         $n = strpos($n, '%') !== false ? $n : urlencode($n);
                                         $url .= "&{$key}" . "[{$l}][{$m}]={$n}";
                                     }
                                 }
                             } else {
                                 $w = strpos($w, '%') !== false ? $w : urlencode($w);
                                 $url .= "&{$key}" . "[{$l}]={$w}";
                             }
                         }
                     }
                 } elseif (is_numeric($value) || !empty($value)) {
                     // we suppress '', but allow 0 as value (see #193)
                     $value = strpos($value, '%') !== false ? $value : urlencode($value);
                     $url .= "&{$key}={$value}";
                 }
             }
         }
     }
     if (isset($fragment)) {
         $url .= '#' . $fragment;
     }
     return $siteRoot . $url;
 }
示例#22
0
    /**
     * Display the block
     *
     * @param        row           blockinfo array
     */
    public function display($blockinfo)
    {
        // security check
        if (!SecurityUtil::checkPermission('Languageblock::', "$blockinfo[title]::", ACCESS_OVERVIEW)) {
            return;
        }

        // if the site's not an ML site don't display the block
        if (!System::getVar('multilingual')) {
            return;
        }

        $currentlanguage = ZLanguage::getLanguageCode();
        $languages = ZLanguage::getInstalledLanguages();

        // Get current content
        $vars = BlockUtil::varsFromContent($blockinfo['content']);
        $vars['bid'] = $blockinfo['bid'];
        // Defaults
        if (empty($vars['format'])) {
            $vars['format'] = 2;
        }

        if (empty($vars['fulltranslation'])) {
            $vars['fulltranslation'] = 1;
        }

        if ($vars['fulltranslation'] == 2) {
            foreach ($languages as $code) {
                // bind all languages, we'll need them later.
                ZLanguage::setLocale($code);
                ZLanguage::bindCoreDomain();
            }
            ZLanguage::setLocale($currentlanguage);
        }

        if (!isset($vars['languages']) || empty($vars['languages']) || !is_array($vars['languages'])) {
            $vars['languages'] = $this->getAvailableLanguages($vars['fulltranslation']);
        }

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

        // assign the block vars
        $this->view->assign($vars);

        $this->view->assign('currentlanguage', $currentlanguage);

        // set a block title
        if (empty($blockinfo['title'])) {
            $blockinfo['title'] = $this->__('Choose a language');
        }

        // prepare vars for ModUtil::url
        $module = FormUtil::getPassedValue('module', null, 'GET', FILTER_SANITIZE_STRING);
        $type = FormUtil::getPassedValue('type', null, 'GET', FILTER_SANITIZE_STRING);
        $func = FormUtil::getPassedValue('func', null, 'GET', FILTER_SANITIZE_STRING);
        $get = $_GET;
        if (isset($get['module'])) {
            unset($get['module']);
        }
        if (isset($get['type'])) {
            unset($get['type']);
        }
        if (isset($get['func'])) {
            unset($get['func']);
        }
        if (isset($get['lang'])) {
            unset($get['lang']);
        }

        if (System::isLegacyMode()) {
            if (!isset($type)) {
                $type = 'user';
            }
            if (!isset($func)) {
                $func = 'main';
            }
        }

        // make homepage calculations
        $shorturls = System::getVar('shorturls', false);

        if ($shorturls) {
            $homepage = System::getBaseUrl().System::getVar('entrypoint', 'index.php');
            $forcefqdn = true;
        } else {
            $homepage = System::getVar('entrypoint', 'index.php');
            $forcefqdn = false;
        }

        // build URLS

        $urls = array();
        foreach ($languages as $code) {
            if (isset($module) && isset($type) && isset($func)) {
                $thisurl = ModUtil::url($module, $type, $func, $get, null, null, $forcefqdn, !$shorturls, $code);
            } else {
                $thisurl = ($shorturls ? $code : "$homepage?lang=$code");
            }

            $codeFS = ZLanguage::transformFS($code);

            $flag = '';
            if ($vars['format']) {
                $flag = "images/flags/flag-$codeFS.png";
                if (!file_exists($flag)) {
                    $flag = '';
                }
                $flag = (($flag && $shorturls) ? System::getBaseUrl() . $flag : $flag);
            }

            if ($vars['fulltranslation'] == 2) {
                ZLanguage::setLocale($code);
            }

            $urls[] = array('code' => $code, 'name' => ZLanguage::getLanguageName($code), 'url' => $thisurl, 'flag' => $flag);

            if ($vars['fulltranslation'] == 2) {
                ZLanguage::setLocale($currentlanguage);
            }
        }
        usort($urls, '_blocks_thelangblock_sort');

        $this->view->assign('urls', $urls);

        // get the block content from the template then end the templating
        $blockinfo['content'] = $this->view->fetch('blocks_block_thelang.tpl');

        // return the block to the theme
        return BlockUtil::themeBlock($blockinfo);
    }
示例#23
0
 /**
  * Carry out hook operations for module.
  *
  * @param string  $hookobject The object the hook is called for - one of 'item', 'category' or 'module'.
  * @param string  $hookaction The action the hook is called for - one of 'new', 'create', 'modify', 'update', 'delete', 'transform', 'display', 'modifyconfig', 'updateconfig'.
  * @param integer $hookid     The id of the object the hook is called for (module-specific).
  * @param array   $extrainfo  Extra information for the hook, dependent on hookaction.
  * @param boolean $implode    Implode collapses all display hooks into a single string.
  *
  * @deprecated since 1.3.0
  *
  * @return string|array String output from GUI hooks, extrainfo array for API hooks.
  */
 public static function callHooks($hookobject, $hookaction, $hookid, $extrainfo = array(), $implode = true)
 {
     if (!System::isLegacyMode()) {
         return null;
     }
     if (!isset(self::$cache['modulehooks'])) {
         self::$cache['modulehooks'] = array();
     }
     if (!isset($hookaction)) {
         return null;
     }
     if (isset($extrainfo['module']) && (self::available($extrainfo['module']) || strtolower($hookobject) == 'module' || strtolower($extrainfo['module']) == 'zikula')) {
         $modname = $extrainfo['module'];
     } else {
         $modname = self::getName();
     }
     if (self::isOO($modname)) {
         LogUtil::log(__('OO module types may not make use of this legacy API'), Zikula_AbstractErrorHandler::ERR);
         return null;
     }
     $lModname = strtolower($modname);
     if (!isset(self::$cache['modulehooks'][$lModname])) {
         // Get database info
         $tables = DBUtil::getTables();
         $cols = $tables['hooks_column'];
         $where = "WHERE {$cols['smodule']} = '" . DataUtil::formatForStore($modname) . "'";
         $orderby = "{$cols['sequence']} ASC";
         $hooks = DBUtil::selectObjectArray('hooks', $where, $orderby);
         self::$cache['modulehooks'][$lModname] = $hooks;
     }
     $gui = false;
     $output = array();
     // Call each hook
     foreach (self::$cache['modulehooks'][$lModname] as $modulehook) {
         if (!isset($extrainfo['tmodule']) || isset($extrainfo['tmodule']) && $extrainfo['tmodule'] == $modulehook['tmodule']) {
             if ($modulehook['action'] == $hookaction && $modulehook['object'] == $hookobject) {
                 if (isset($modulehook['tarea']) && $modulehook['tarea'] == 'GUI') {
                     $gui = true;
                     if (self::available($modulehook['tmodule'], $modulehook['ttype']) && self::load($modulehook['tmodule'], $modulehook['ttype'])) {
                         $hookArgs = array('objectid' => $hookid, 'extrainfo' => $extrainfo, 'modulehook' => $modulehook);
                         $output[$modulehook['tmodule']] = self::func($modulehook['tmodule'], $modulehook['ttype'], $modulehook['tfunc'], $hookArgs);
                     }
                 } else {
                     if (isset($modulehook['tmodule']) && self::available($modulehook['tmodule'], $modulehook['ttype']) && self::loadApi($modulehook['tmodule'], $modulehook['ttype'])) {
                         $hookArgs = array('objectid' => $hookid, 'extrainfo' => $extrainfo, 'modulehook' => $modulehook);
                         $extrainfo = self::apiFunc($modulehook['tmodule'], $modulehook['ttype'], $modulehook['tfunc'], $hookArgs);
                     }
                 }
             }
         }
     }
     // check what type of information we need to return
     $hookaction = strtolower($hookaction);
     if ($gui || $hookaction == 'display' || $hookaction == 'new' || $hookaction == 'modify' || $hookaction == 'modifyconfig') {
         if ($implode || empty($output)) {
             $output = implode("\n", $output);
         }
         return $output;
     }
     return $extrainfo;
 }
示例#24
0
    /**
     * Add var.
     *
     * Adds a new vaule to a page variable. In the case of a single
     * page variable, this functions acts exactly like PageUtil::setVar.
     *
     * @param string $varname The name of the page variable.
     * @param mixed  $value   The new value.
     *
     * @see    PageUtil::setVar
     * @return boolean true On success, false of the page variable is not registered.
     */
    public static function addVar($varname, $value)
    {
        global $_pageVars;

        if (System::isLegacyMode()) {
            switch ($varname) {
                case 'rawtext':
                    LogUtil::log(__f('Warning! The page variable %1$s is deprecated. Please use %2$s instead.', array('rawtext', 'header')), E_USER_DEPRECATED);
                    $varname = 'header';
                    break;
            }
        }
        
        // check for $_pageVars sanity
        if (!isset($_pageVars)) {
            $_pageVars = array();
        } elseif (!is_array($_pageVars)) {
            return false;
        }

        if (!isset($_pageVars[$varname])) {
            return false;
        }

        if (is_array($value)) {
            $value = array_unique($value);
        }

        $event = new Zikula_Event('pageutil.addvar_filter', $varname, array(), $value);
        $value = EventUtil::getManager()->notify($event)->getData();

        if ($_pageVars[$varname]['multivalue']) {
            if (is_array($value)) {
                $_pageVars[$varname]['contents'] = array_merge($_pageVars[$varname]['contents'], $value);
            } else {
                $_pageVars[$varname]['contents'][] = $value;
            }
            // make values unique
            $_pageVars[$varname]['contents'] = array_unique($_pageVars[$varname]['contents']);
        } else {
            $_pageVars[$varname]['contents'] = $value;
        }

        return true;
    }
示例#25
0
 /**
  * Initialise Zikula.
  *
  * Carries out a number of initialisation tasks to get Zikula up and
  * running.
  *
  * @param integer $stage Stage to load.
  *
  * @return boolean True initialisation successful false otherwise.
  */
 public function init($stage = self::STAGE_ALL)
 {
     $coreInitEvent = new Zikula_Event('core.init', $this);
     // store the load stages in a global so other API's can check whats loaded
     $this->stage = $this->stage | $stage;
     if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
         ModUtil::flushCache();
         System::flushCache();
         $this->eventManager->notify(new Zikula_Event('core.preinit', $this));
     }
     // Initialise and load configuration
     if ($stage & self::STAGE_CONFIG) {
         if (System::isLegacyMode()) {
             require_once 'lib/legacy/Compat.php';
         }
         // error reporting
         if (!System::isInstalling()) {
             // this is here because it depends on the config.php loading.
             $event = new Zikula_Event('setup.errorreporting', null, array('stage' => $stage));
             $this->eventManager->notify($event);
         }
         // initialise custom event listeners from config.php settings
         $coreInitEvent->setArg('stage', self::STAGE_CONFIG);
         $this->eventManager->notify($coreInitEvent);
     }
     // Check that Zikula is installed before continuing
     if (System::getVar('installed') == 0 && !System::isInstalling()) {
         System::redirect(System::getBaseUrl() . 'install.php?notinstalled');
         System::shutDown();
     }
     if ($stage & self::STAGE_DB) {
         try {
             $dbEvent = new Zikula_Event('core.init', $this, array('stage' => self::STAGE_DB));
             $this->eventManager->notify($dbEvent);
         } catch (PDOException $e) {
             if (!System::isInstalling()) {
                 header('HTTP/1.1 503 Service Unavailable');
                 require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
                 System::shutDown();
             } else {
                 return false;
             }
         }
     }
     if ($stage & self::STAGE_TABLES) {
         // Initialise dbtables
         ModUtil::dbInfoLoad('Extensions', 'Extensions');
         ModUtil::initCoreVars();
         ModUtil::dbInfoLoad('Settings', 'Settings');
         ModUtil::dbInfoLoad('Theme', 'Theme');
         ModUtil::dbInfoLoad('Users', 'Users');
         ModUtil::dbInfoLoad('Groups', 'Groups');
         ModUtil::dbInfoLoad('Permissions', 'Permissions');
         ModUtil::dbInfoLoad('Categories', 'Categories');
         if (!System::isInstalling()) {
             ModUtil::registerAutoloaders();
         }
         $coreInitEvent->setArg('stage', self::STAGE_TABLES);
         $this->eventManager->notify($coreInitEvent);
     }
     if ($stage & self::STAGE_SESSIONS) {
         SessionUtil::requireSession();
         $coreInitEvent->setArg('stage', self::STAGE_SESSIONS);
         $this->eventManager->notify($coreInitEvent);
     }
     // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
     // start block
     if ($stage & self::STAGE_LANGS) {
         $lang = ZLanguage::getInstance();
     }
     if ($stage & self::STAGE_DECODEURLS) {
         System::queryStringDecode();
         $coreInitEvent->setArg('stage', self::STAGE_DECODEURLS);
         $this->eventManager->notify($coreInitEvent);
     }
     if ($stage & self::STAGE_LANGS) {
         $lang->setup();
         $coreInitEvent->setArg('stage', self::STAGE_LANGS);
         $this->eventManager->notify($coreInitEvent);
     }
     // end block
     if ($stage & self::STAGE_MODS) {
         // Set compression on if desired
         if (System::getVar('UseCompression') == 1) {
             //ob_start("ob_gzhandler");
         }
         ModUtil::load('SecurityCenter');
         $coreInitEvent->setArg('stage', self::STAGE_MODS);
         $this->eventManager->notify($coreInitEvent);
     }
     if ($stage & self::STAGE_THEME) {
         // register default page vars
         PageUtil::registerVar('title');
         PageUtil::setVar('title', System::getVar('defaultpagetitle'));
         PageUtil::registerVar('keywords', true);
         PageUtil::registerVar('stylesheet', true);
         PageUtil::registerVar('javascript', true);
         PageUtil::registerVar('jsgettext', true);
         PageUtil::registerVar('body', true);
         PageUtil::registerVar('header', true);
         PageUtil::registerVar('footer', true);
         $theme = Zikula_View_Theme::getInstance();
         // set some defaults
         // Metadata for SEO
         $this->serviceManager['zikula_view.metatags']['description'] = System::getVar('defaultmetadescription');
         $this->serviceManager['zikula_view.metatags']['keywords'] = System::getVar('metakeywords');
         $coreInitEvent->setArg('stage', self::STAGE_THEME);
         $this->eventManager->notify($coreInitEvent);
     }
     // check the users status, if not 1 then log him out
     if (UserUtil::isLoggedIn()) {
         $userstatus = UserUtil::getVar('activated');
         if ($userstatus != Users_Constant::ACTIVATED_ACTIVE) {
             UserUtil::logout();
             // TODO - When getting logged out this way, the existing session is destroyed and
             //        then a new one is created on the reentry into index.php. The message
             //        set by the registerStatus call below gets lost.
             LogUtil::registerStatus(__('You have been logged out.'));
             System::redirect(ModUtil::url('Users', 'user', 'login'));
         }
     }
     if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) {
         $this->eventManager->notify(new Zikula_Event('core.postinit', $this, array('stages' => $stage)));
     }
 }
示例#26
0
 /**
  * Execute SQL, check for errors and return result. Uses Doctrine's DBAL to generate DB-portable paging code.
  *
  * @param string  $sql          The SQL statement to execute.
  * @param integer $limitOffset  The lower limit bound (optional) (default=-1).
  * @param integer $limitNumRows The upper limit bound (optional) (default=-1).
  * @param boolean $exitOnError  Whether to exit on error (default=true) (optional).
  * @param boolean $verbose      Whether to be verbose (default=true) (optional).
  *
  * @return mixed     The result set of the successfully executed query or false on error.
  * @throws Exception No SQL statment.
  */
 public static function executeSQL($sql, $limitOffset = -1, $limitNumRows = -1, $exitOnError = true, $verbose = true)
 {
     if (!$sql) {
         throw new Exception(__('No SQL statement to execute'));
     }
     $connection = Doctrine_Manager::getInstance()->getCurrentConnection();
     if (!$connection && System::isInstalling()) {
         return false;
     }
     try {
         if ($limitNumRows > 0) {
             $tStr = strtoupper(substr(trim($sql), 0, 7));
             // Grab first 7 chars to allow syntax like "(SELECT" which may happen with UNION statements
             if (strpos($tStr, 'SELECT') === false) {
                 // TODO D [use normal Select instead of showing an error message if paging is desired for something different than SELECTs] (Guite)
                 throw new Exception(__('Paging parameters can only be used for SELECT statements'));
             }
             if ($limitOffset > 0) {
                 $sql = $connection->modifyLimitQuery($sql, $limitNumRows, $limitOffset);
             } else {
                 $sql = $connection->modifyLimitQuery($sql, $limitNumRows);
             }
         }
         $stmt = $connection->prepare($sql);
         //$stmt->setHydrationMode(Doctrine::HYDRATE_RECORD);
         if ($stmt->execute()) {
             $result = $stmt;
         }
         if ($result) {
             // catch manual SQL which requires cache flushes
             $tab = null;
             $sql = strtolower(trim(preg_replace("/\\s+/", " ", $sql)));
             if (strpos($sql, 'update') === 0) {
                 list(, $tab, ) = explode(' ', $sql);
             }
             if (strpos($sql, 'delete') === 0) {
                 list(, , $tab, ) = explode(' ', $sql);
             }
             if ($tab && strpos($tab, 'session_info') === false) {
                 self::flushCache($tab);
             }
             if (System::isLegacyMode()) {
                 return new Zikula_Adapter_AdodbStatement($result);
             } else {
                 return $result;
             }
         }
     } catch (Exception $e) {
         echo 'Error in DBUtil::executeSQL: ' . $sql . '<br />' . $e->getMessage() . '<br />';
         if (System::isDevelopmentMode() && SecurityUtil::checkPermission('.*', '.*', ACCESS_ADMIN)) {
             echo nl2br($e->getTraceAsString());
         }
         if ($exitOnError) {
             System::shutDown();
         }
     }
     return false;
 }
示例#27
0
 /**
  * Generate auth key.
  *
  * @param string $modname Module name.
  *
  * @deprecated since 1.3.0
  *
  * @return string An encrypted key for use in authorisation of operations.
  */
 public static function generateAuthKey($modname = '')
 {
     // Ugly hack for Zikula_Response_Ajax which for BC reasons needs to add authid to response
     // So when this method is called by Zikula_Response_Ajax  or Zikula_Response_Ajax_Error class
     // do not mark it as deprecated.
     $trace = debug_backtrace(false);
     if (!isset($trace[1]['class']) || !in_array($trace[1]['class'], array('Zikula_Response_Ajax', 'Zikula_Response_Ajax_Error'))) {
         LogUtil::log(__f('Warning! Static call %1$s is deprecated. Please use %2$s instead.', array('SecurityUtil::generateAuthKey()', 'SecurityUtil::generateCsrfToken()')), E_USER_DEPRECATED);
     }
     // since we need sessions for authorisation keys we should check
     // if a session exists and if not create one
     SessionUtil::requireSession();
     if (empty($modname)) {
         $modname = ModUtil::getName();
     }
     // Remove from 1.4
     if (System::isLegacyMode() && $modname == 'Modules') {
         LogUtil::log(__('Warning! "Modules" module has been renamed to "Extensions".  Please update any generateAuthKey calls in PHP or templates.'));
         $modname = 'ZikulaExtensionsModule';
     }
     // get the module info
     $modinfo = ModUtil::getInfoFromName($modname);
     $modname = strtolower($modinfo['name']);
     // get the array of randomed values per module
     // and generate the one of the current module if doesn't exist
     $rand_arr = SessionUtil::getVar('rand');
     if (!isset($rand_arr[$modname])) {
         $rand_arr[$modname] = RandomUtil::getString(32, 40, false, true, true, false, true, true, false);
         SessionUtil::setVar('rand', $rand_arr);
     }
     $key = $rand_arr[$modname] . $modname;
     if (System::getVar('keyexpiry') > 0) {
         $timestamp = time();
         $authid = sha1($key . $timestamp) . $timestamp;
     } else {
         $authid = sha1($key);
     }
     // Return encrypted key
     return $authid;
 }
示例#28
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;
    }
}
示例#29
0
/**
 * Zikula_View function to display menulinks in an unordered list
 *
 * Example
 * {modulelinks data=$links id='listid' class='navbar navbar-default' itemclass='z-ml-item' first='z-ml-first' last='z-ml-last'}
 *
 * Available parameters:
 *  links     Array with menulinks (text, url, title, id, class, disabled) (optional)
 *  modname   Module name to display links for (optional)
 *  type      Function type where the getLinks-function is located (optional)
 *  menuid    ID for the unordered list (optional)
 *  menuclass Class for the unordered list (optional)
 *  itemclass Array with menulinks (text, url, title, class, disabled) (optional)
 *  first     Class for the first element (optional)
 *  last      Class for the last element (optional)
 *  seperator Link seperator (optional)
 *  class     CSS class (optional).
 *  returnAsArray     return results as array, not as formatted html - MUST set assign
 *
 * @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_modulelinks($params, Zikula_View $view)
{
    $menuLinks = isset($params['links']) ? $params['links'] : '';
    $menuId = isset($params['menuid']) ? $params['menuid'] : '';
    $menuClass = isset($params['menuclass']) ? $params['menuclass'] : 'navbar navbar-default navbar-modulelinks navbar-modulelinks-main';
    $menuItemClass = isset($params['itemclass']) ? $params['itemclass'] : '';
    $menuItemFirst = isset($params['first']) ? $params['first'] : '';
    $menuItemLast = isset($params['last']) ? $params['last'] : '';
    $returnAsArray = isset($params['returnAsArray']) ? (bool) $params['returnAsArray'] : false;
    if (empty($menuLinks)) {
        if (!isset($params['modname']) || !ModUtil::available($params['modname'])) {
            $params['modname'] = ModUtil::getName();
        }
        // check our module name
        if (!ModUtil::available($params['modname'])) {
            $view->trigger_error('modulelinks: ' . __f("Error! The '%s' module is not available.", DataUtil::formatForDisplay($params['modname'])));
            return false;
        }
        $params['type'] = isset($params['type']) ? $params['type'] : 'admin';
        // get the menu links
        // try the Core-2.0 way first, then try the legacy way.
        $menuLinks = $view->getContainer()->get('zikula.link_container_collector')->getLinks($params['modname'], $params['type']);
        if (empty($menuLinks)) {
            $menuLinks = ModUtil::apiFunc($params['modname'], $params['type'], 'getLinks', $params);
        }
    }
    // return if there are no links to print or template has requested to returnAsArray
    if (!$menuLinks || $returnAsArray && isset($params['assign'])) {
        if (isset($params['assign'])) {
            $view->assign($params['assign'], $menuLinks);
        }
        return '';
    }
    $html = '';
    if (!empty($menuLinks)) {
        $html = '<ul';
        $html .= !empty($menuId) ? ' id="' . $menuId . '"' : '';
        $html .= !empty($menuClass) ? ' class="' . $menuClass . '"' : '';
        $html .= '>';
        $i = 1;
        $size = count($menuLinks);
        foreach ($menuLinks as $menuitem) {
            $class = array();
            $class[] = $size == 1 ? 'z-ml-single' : '';
            $class[] = $i == 1 && $size > 1 ? $menuItemFirst : '';
            $class[] = $i == $size && $size > 1 ? $menuItemLast : '';
            $class[] = !empty($menuItemClass) ? $menuItemClass : '';
            $class[] = isset($menuitem['disabled']) && $menuitem['disabled'] == true ? 'z-ml-disabled' : '';
            $class = trim(implode(' ', $class));
            $i++;
            if (System::isLegacyMode() && !empty($class) && isset($menuitem['class'])) {
                if ($menuitem['class'] == 'z-icon-es-add') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'plus';
                } elseif ($menuitem['class'] == 'z-icon-es-back') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'arrow-left';
                } elseif ($menuitem['class'] == 'z-icon-es-cancel') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'times';
                } elseif ($menuitem['class'] == 'z-icon-es-config') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'wrench';
                } elseif ($menuitem['class'] == 'z-icon-es-copy') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'files-o';
                } elseif ($menuitem['class'] == 'z-icon-es-cubes') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'th';
                } elseif ($menuitem['class'] == 'z-icon-es-cut') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'scissors';
                } elseif ($menuitem['class'] == 'z-icon-es-delete') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'trash-o';
                } elseif ($menuitem['class'] == 'z-icon-es-display') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'eye';
                } elseif ($menuitem['class'] == 'z-icon-es-edit') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'pencil-square-o';
                } elseif ($menuitem['class'] == 'z-icon-es-error') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'exclamation-triangle';
                } elseif ($menuitem['class'] == 'z-icon-es-export') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'upload';
                } elseif ($menuitem['class'] == 'z-icon-es-gears') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'gears';
                } elseif ($menuitem['class'] == 'z-icon-es-filter') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'filter';
                } elseif ($menuitem['class'] == 'z-icon-es-group') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'users';
                } elseif ($menuitem['class'] == 'z-icon-es-help') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'info';
                } elseif ($menuitem['class'] == 'z-icon-es-home') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'home';
                } elseif ($menuitem['class'] == 'z-icon-es-hook') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'paperclip';
                } elseif ($menuitem['class'] == 'z-icon-es-import') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'download';
                } elseif ($menuitem['class'] == 'z-icon-es-info') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'info';
                } elseif ($menuitem['class'] == 'z-icon-es-locale') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'globe';
                } elseif ($menuitem['class'] == 'z-icon-es-locked') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'lock';
                } elseif ($menuitem['class'] == 'z-icon-es-log') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'archive';
                } elseif ($menuitem['class'] == 'z-icon-es-mail') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'inbox';
                } elseif ($menuitem['class'] == 'z-icon-es-new') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'file-o';
                } elseif ($menuitem['class'] == 'z-icon-es-ok') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'check';
                } elseif ($menuitem['class'] == 'z-icon-es-options') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'th-list';
                } elseif ($menuitem['class'] == 'z-icon-es-preview') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'cog';
                } elseif ($menuitem['class'] == 'z-icon-es-print') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'print';
                } elseif ($menuitem['class'] == 'z-icon-es-profile') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'user';
                } elseif ($menuitem['class'] == 'z-icon-es-regenerate') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'refresh';
                } elseif ($menuitem['class'] == 'z-icon-es-remove') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'times';
                } elseif ($menuitem['class'] == 'z-icon-es-save') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'floppy-o';
                } elseif ($menuitem['class'] == 'z-icon-es-saveas') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'floppy-o';
                } elseif ($menuitem['class'] == 'z-icon-es-search') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'search';
                } elseif ($menuitem['class'] == 'z-icon-es-url') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'globe';
                } elseif ($menuitem['class'] == 'z-icon-es-user') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'user';
                } elseif ($menuitem['class'] == 'z-icon-es-view') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'eye';
                } elseif ($menuitem['class'] == 'z-icon-es-warning') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'exclamation-triangle';
                } elseif ($menuitem['class'] == 'z-icon-es-rss') {
                    $menuitem['class'] = null;
                    $menuitem['icon'] = 'rss-square';
                }
            }
            $active = '';
            if (!empty($menuitem['url']) && System::getBaseUrl() . $menuitem['url'] === System::getCurrentUrl()) {
                $active = 'active ';
            }
            $dropdown = '';
            if (isset($menuitem['links'])) {
                $dropdown = 'dropdown';
            }
            $html .= '<li';
            $html .= !empty($menuitem['id']) ? ' id="' . $menuitem['id'] . '"' : '';
            $html .= ' class="' . $active . $dropdown;
            $html .= !empty($class) ? $class : '';
            $html .= '">';
            $attr = !empty($menuitem['title']) ? ' title="' . $menuitem['title'] . '"' : '';
            $attr .= !empty($menuitem['class']) ? ' class="' . $menuitem['class'] . '"' : '';
            if (isset($menuitem['disabled']) && $menuitem['disabled'] == true) {
                $html .= '<a ' . $attr . '>' . $menuitem['text'] . '</a>';
            } elseif (!empty($menuitem['url'])) {
                $icon = '';
                if (!empty($menuitem['icon'])) {
                    $icon = '<span class="fa fa-' . $menuitem['icon'] . '"></span> ';
                }
                $html .= '<a href="' . DataUtil::formatForDisplay($menuitem['url']) . '"' . $attr . ' style="display: inline-block;">' . $icon . $menuitem['text'] . '</a>';
                if (isset($menuitem['links'])) {
                    $html .= '<a href="#" class="dropdown-toggle" data-toggle="dropdown" style="text-decoration: none;">&nbsp;<b class="caret"></b></a>';
                }
            } else {
                $html .= '<span' . $attr . '>' . $menuitem['text'] . '</span>';
            }
            if (isset($menuitem['links'])) {
                $html .= '<ul class="dropdown-menu">';
                foreach ($menuitem['links'] as $submenuitem) {
                    $html .= '<li>';
                    if (isset($submenuitem['url'])) {
                        $html .= '<a href="' . DataUtil::formatForDisplay($submenuitem['url']) . '">' . $submenuitem['text'] . '</a>';
                    } else {
                        $html .= $submenuitem['text'];
                    }
                    $html .= '</li>';
                }
                $html .= '</ul>';
            }
            $html .= '</li>';
        }
        $html .= '</ul>';
    }
    if (isset($params['assign'])) {
        $view->assign($params['assign'], $html);
    } else {
        return $html;
    }
}
示例#30
0
 /**
  * Load event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  * @param array            &$params Parameters passed from the Smarty plugin function.
  *
  * @return void
  */
 public function load(Zikula_Form_View $view, &$params)
 {
     if ($this->showEmptyValue != 0) {
         $this->addItem('- - -', 0);
     }
     // switch between doctrine and dbobject mode
     if ($this->recordClass) {
         $q = Doctrine::getTable($this->recordClass)->createQuery();
         if ($this->where) {
             if (is_array($this->where)) {
                 $q->where($this->where[0], $this->where[1]);
             } else {
                 $q->where($this->where);
             }
         }
         if ($this->orderby) {
             $q->orderBy($this->orderby);
         }
         if ($this->pos >= 0) {
             $q->offset($this->pos);
         }
         if ($this->num > 0) {
             $q->limit($this->num);
         }
         $rows = $q->execute();
         foreach ($rows as $row) {
             $itemLabel = $row[$this->displayField];
             if (!empty($this->displayFieldTwo)) {
                 $itemLabel .= ' (' . $row[$this->displayFieldTwo] . ')';
             }
             $this->addItem($itemLabel, $row[$this->idField]);
         }
     } else {
         ModUtil::dbInfoLoad($this->module);
         // load the object class corresponding to $this->objecttype
         $class = "{$this->module}_DBObject_" . StringUtil::camelize($this->objecttype) . 'Array';
         if (!class_exists($class) && System::isLegacyMode()) {
             if (!($class = Loader::loadArrayClassFromModule($this->module, $this->objecttype, false, $this->prefix))) {
                 z_exit(__f('Unable to load class [%s] for module [%s]', array(DataUtil::formatForDisplay($this->objecttype, $this->module))));
             }
         }
         // instantiate the object-array
         $objectArray = new $class();
         // get() returns the cached object fetched from the DB during object instantiation
         // get() with parameters always performs a new select
         // while the result will be saved in the object, we assign in to a local variable for convenience.
         $objectData = $objectArray->get($this->where, $this->orderby, $this->pos, $this->num);
         foreach ($objectData as $obj) {
             $itemLabel = $obj[$this->displayField];
             if (!empty($this->displayFieldTwo)) {
                 $itemLabel .= ' (' . $obj[$this->displayFieldTwo] . ')';
             }
             $this->addItem($itemLabel, $obj[$this->idField]);
         }
     }
     parent::load($view, $params);
 }