Exemple #1
0
    public function pageLock($args)
    {
        $lockName = $args['lockName'];
        $returnUrl = (array_key_exists('returnUrl', $args) ? $args['returnUrl'] : null);
        $ignoreEmptyLock = (array_key_exists('ignoreEmptyLock', $args) ? $args['ignoreEmptyLock'] : false);

        $uname = UserUtil::getVar('uname');

        $lockedHtml = '';

        if (!empty($lockName) || !$ignoreEmptyLock) {
            PageUtil::AddVar('javascript', 'zikula.ui');
            PageUtil::AddVar('javascript', 'system/PageLock/javascript/pagelock.js');
            PageUtil::AddVar('stylesheet', ThemeUtil::getModuleStylesheet('pagelock'));

            $lockInfo = ModUtil::apiFunc('pagelock', 'user', 'requireLock',
                    array('lockName'      => $lockName,
                    'lockedByTitle' => $uname,
                    'lockedByIPNo'  => $_SERVER['REMOTE_ADDR']));

            $hasLock = $lockInfo['hasLock'];

            if (!$hasLock) {
                $view = Zikula_View::getInstance('pagelock');
                $view->assign('lockedBy', $lockInfo['lockedBy']);
                $lockedHtml = $view->fetch('PageLock_lockedwindow.tpl');
            }
        } else {
            $hasLock = true;
        }

        $html = "<script type=\"text/javascript\">/* <![CDATA[ */ \n";

        if (!empty($lockName)) {
            if ($hasLock) {
                $html .= "document.observe('dom:loaded', PageLock.UnlockedPage);\n";
            } else {
                $html .= "document.observe('dom:loaded', PageLock.LockedPage);\n";
            }
        }

        $lockedHtml = str_replace("\n", "", $lockedHtml);
        $lockedHtml = str_replace("\r", "", $lockedHtml);

        // Use "PageLockLifetime*2/3" to add a good margin to lock timeout when pinging

        // disabled due to #2556 and #2745
        // $returnUrl = DataUtil::formatForDisplayHTML($returnUrl);

        $html .= "
PageLock.LockName = '$lockName';
PageLock.ReturnUrl = '$returnUrl';
PageLock.PingTime = " . (PageLockLifetime*2/3) . ";
PageLock.LockedHTML = '" . $lockedHtml . "';
 /* ]]> */</script>";

        PageUtil::addVar('header', $html);

        return true;
    }
/**
 * AddressBook
 *
 * @copyright (c) AddressBook Development Team
 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
 * @package AddressBook
 */
function smarty_function_AddressShowGmap($params, &$smarty)
{
    $dom = ZLanguage::getModuleDomain('AddressBook');
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $directions = '';
    if (isset($params['directions'])) {
        $directions = '<a href="http://maps.google.com/maps?f=d&daddr=' . $params['lat_long'];
        if (isset($params['zoomlevel'])) {
            $directions .= '&z=' . $params['zoomlevel'];
        }
        $directions .= '" target="_blank">' . __('Get directions to this location', $dom) . '</a>';
    }
    if (!empty($directions)) {
        $directions = '<div>' . $directions . '</div>';
    }
    include_once 'modules/AddressBook/lib/vendor/GMaps/GoogleMapV3.php';
    $map_id = 'googlemap';
    if (isset($params['mapid'])) {
        $map_id .= $params['mapid'];
    }
    $app_id = 'ZikulaAddressBook';
    $map = new GoogleMapAPI($map_id, $app_id);
    if (isset($params['maptype'])) {
        $map->setMapType($params['maptype']);
        // hybrid, satellite, terrain, roadmap
    }
    if (isset($params['zoomlevel'])) {
        $map->setZoomLevel($params['zoomlevel']);
    }
    $map->setTypeControlsStyle('dropdown');
    $map->setWidth(isset($params['width']) && $params['width'] ? $params['width'] : '100%');
    $map->setHeight(isset($params['height']) && $params['height'] ? $params['height'] : '400px');
    // handle one (center) point
    if (isset($params['lat_long'])) {
        $arrLatLong = explode(',', $params['lat_long']);
        $map->setCenterCoords($arrLatLong[1], $arrLatLong[0]);
        $map->addMarkerByCoords($arrLatLong[1], $arrLatLong[0], $params['title'], $params['html'], $params['tooltip'], $params['icon'], $params['iconshadow']);
    }
    // API key
    if (isset($params['api_key'])) {
        $map->setApiKey($params['api_key']);
    }
    // handle array of points
    if (isset($params['points'])) {
        foreach ($params['points'] as $point) {
            $arrLatLong = explode(',', $point['lat_long']);
            $map->addMarkerByCoords($arrLatLong[1], $arrLatLong[0], $point['title'], $point['html'], $point['tooltip'], $point['icon'], $point['iconshadow']);
        }
    }
    // load the map
    $map->enableOnLoad();
    if ($assign) {
        $result = $map->getHeaderJS() . $map->getMapJS() . $directions . $map->printMap() . $map->printOnLoad();
        $smarty->assign($assign, $result);
    } else {
        PageUtil::addVar('rawtext', $map->getHeaderJS());
        PageUtil::addVar('rawtext', $map->getMapJS());
        return $directions . $map->printMap() . $map->printOnLoad();
    }
}
 /**
  * This function generate 
  *
  * @return RedirectResponse
  */
 public function managerAction(Request $request, $obj_reference = null, $mode = 'info')
 {
     // Permission check
     if (!$this->get('kaikmedia_gallery_module.access_manager')->hasPermission()) {
         throw new AccessDeniedException();
     }
     $gallerySettings = ['mode' => $mode, 'obj_reference' => $obj_reference];
     $masterRequest = $this->get('request_stack')->getMasterRequest();
     $gallerySettings['obj_name'] = $masterRequest->attributes->get('_zkModule');
     /*
     $addMediaForm = $this->createForm(
             new AddMediaType(), null , ['allowed_mime_types' => $this->get('kaikmedia_gallery_module.settings_manager')->getAllowedMimeTypesForObject($gallerySettings['obj_name']),
                                   'isXmlHttpRequest' => $request->isXmlHttpRequest()]
             
     );
     */
     //$gallerySettings['mediaTypes'] = $this->get('kaikmedia_gallery_module.media_handlers_manager')->getSupportedMimeTypes();
     $gallerySettings['settings'] = $this->get('kaikmedia_gallery_module.settings_manager')->getSettingsArray();
     \PageUtil::addVar('javascript', "@KaikmediaGalleryModule/Resources/public/js/Kaikmedia.Gallery.settings.js");
     \PageUtil::addVar('javascript', "@KaikmediaGalleryModule/Resources/public/js/Kaikmedia.Gallery.mediaItem.js");
     \PageUtil::addVar('javascript', "@KaikmediaGalleryModule/Resources/public/js/Kaikmedia.Gallery.Manager.js");
     \PageUtil::addVar('stylesheet', "@KaikmediaGalleryModule/Resources/public/css/gallery.manager.css");
     \PageUtil::addVar('stylesheet', "@KaikmediaGalleryModule/Resources/public/css/gallery.mediaItem.css");
     $request->attributes->set('_legacy', true);
     // forces template to render inside old theme
     return $this->render('KaikmediaGalleryModule:Plugin:manager.html.twig', array('gallerySettings' => $gallerySettings));
 }
/**
 * Smarty function to display the category menu for admin links. This also adds the
 * navtabs.css to the page vars array for stylesheets.
 *
 * Admin
 * {admincategorymenu}
 *
 * @see          function.admincategorymenu.php::smarty_function_admincategoreymenu()
 * @param        array       $params      All attributes passed to this function from the template
 * @param        object      $view        Reference to the Zikula_View object
 * @return       string      the results of the module function
 */
function smarty_function_admincategorymenu($params, $view)
{
    PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('Admin'));
    $modinfo = ModUtil::getInfoFromName($view->getTplVar('toplevelmodule'));
    $acid = ModUtil::apiFunc('AdminModule', 'admin', 'getmodcategory', array('mid' => $modinfo['id']));
    return ModUtil::func('AdminModule', 'admin', 'categorymenu', array('acid' => $acid));
}
 public function pageAddVar($name, $value = null)
 {
     if (in_array($name, array('stylesheet', 'javascript'))) {
         $value = explode(',', $value);
     }
     \PageUtil::addVar($name, $value);
 }
Exemple #6
0
/**
 * Smarty function to wrap Zikula_Form_View generated form controls with suitable form tags.
 *
 * @param array            $params  Parameters passed in the block tag.
 * @param string           $content Content of the block.
 * @param Zikula_Form_View $view    Reference to Zikula_Form_View object.
 *
 * @return string The rendered output.
 */
function smarty_block_form($params, $content, $view)
{
    if ($content) {
        PageUtil::addVar('stylesheet', 'system/Theme/style/form/style.css');
        $action = htmlspecialchars(System::getCurrentUri());
        $classString = '';
        if (isset($params['cssClass'])) {
            $classString = "class=\"{$params['cssClass']}\" ";
        }
        $enctype = array_key_exists('enctype', $params) ? $params['enctype'] : null;
        // if enctype is not set directly, check whenever upload plugins were used;
        // if so - set proper enctype for file upload
        if (is_null($enctype)) {
            $uploadPlugins = array_filter($view->plugins, function ($plugin) {
                return $plugin instanceof Zikula_Form_Plugin_UploadInput;
            });
            if (!empty($uploadPlugins)) {
                $enctype = 'multipart/form-data';
            }
        }
        $encodingHtml = !is_null($enctype) ? " enctype=\"{$enctype}\"" : '';
        $view->postRender();
        $formId = $view->getFormId();
        $out = "\n<form id=\"{$formId}\" {$classString}action=\"{$action}\" method=\"post\"{$encodingHtml}>\n    {$content}\n    <div>\n        {$view->getStateHTML()}\n        {$view->getStateDataHTML()}\n        {$view->getIncludesHTML()}\n        {$view->getCsrfTokenHtml()}\n        <input type=\"hidden\" name=\"__formid\" id=\"form__id\" value=\"{$formId}\" />\n        <input type=\"hidden\" name=\"FormEventTarget\" id=\"FormEventTarget\" value=\"\" />\n        <input type=\"hidden\" name=\"FormEventArgument\" id=\"FormEventArgument\" value=\"\" />\n        <script type=\"text/javascript\">\n        <!--\n            function FormDoPostBack(eventTarget, eventArgument)\n            {\n                var f = document.getElementById('{$formId}');\n                if (!f.onsubmit || f.onsubmit()) {\n                    f.FormEventTarget.value = eventTarget;\n                    f.FormEventArgument.value = eventArgument;\n                    f.submit();\n                }\n            }\n        // -->\n        </script>\n    </div>\n</form>\n";
        return $out;
    }
}
/**
 * Smarty function to display the category menu for admin links. This also adds the
 * navtabs.css to the page vars array for stylesheets.
 *
 * Admin
 * {admincategorymenu}
 *
 * @see          function.admincategorymenu.php::smarty_function_admincategorymenu()
 * @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 results of the module function
 */
function smarty_function_admincategorymenu($params, \Zikula_View $view)
{
    PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('ZikulaAdminModule'));
    $modinfo = ModUtil::getInfoFromName($view->getTplVar('toplevelmodule'));
    $acid = ModUtil::apiFunc('ZikulaAdminModule', 'admin', 'getmodcategory', array('mid' => $modinfo['id']));
    $path = array('_controller' => 'ZikulaAdminModule:Admin:categorymenu', 'acid' => $acid);
    $subRequest = $view->getRequest()->duplicate(array(), null, $path);
    return $view->getContainer()->get('http_kernel')->handle($subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST)->getContent();
}
Exemple #8
0
 function display()
 {
     if (ModUtil::available('BBCode') && $this->codeFilter == 'bbcode') {
         $code = '[code]' . $this->text . '[/code]';
         PageUtil::addVar('stylesheet', 'modules/BBCode/style/style.css');
         return ModUtil::apiFunc('BBCode', 'User', 'transform', array('message' => $code));
     } else {
         return $this->transformCode($this->text, true);
     }
 }
Exemple #9
0
 /**
  * Sends an event via the EventDispatcher to allow other code to extend the toolbar.
  *
  * @param EventDispatcher $dispatcher Core event manager.
  */
 function __construct(EventDispatcher $dispatcher)
 {
     $this->dispatcher = $dispatcher;
     \PageUtil::addVar('javascript', 'prototype');
     \PageUtil::addVar('javascript', 'javascript/debugtoolbar/main.js');
     \PageUtil::addVar('stylesheet', 'style/debugtoolbar.css');
     // allow modules and plugins to extend the toolbar
     $event = new GenericEvent($this);
     $this->dispatcher->dispatch('debugtoolbar.init', $event);
 }
Exemple #10
0
 /**
  * Sends an event via the EventManager to allow other code to extend the toolbar.
  *
  * @param Zikula_EventManager $eventManager Core event manager.
  */
 public function __construct(Zikula_EventManager $eventManager)
 {
     $this->eventManager = $eventManager;
     PageUtil::addVar('javascript', 'prototype');
     PageUtil::addVar('javascript', 'javascript/debugtoolbar/main.js');
     PageUtil::addVar('stylesheet', 'style/debugtoolbar.css');
     // allow modules and plugins to extend the toolbar
     $event = new Zikula_Event('debugtoolbar.init', $this);
     $this->eventManager->notify($event);
 }
/**
 * Smarty function to provide easy access to a stylesheet.
 *
 * This function provides an easy way to include a stylesheet. The function will add the stylesheet
 * file to the 'stylesheet' pagevar by default
 *
 * This plugin is obsolete since Zikula 1.1.0. The stylesheets are loaded automatically whenever a module
 * or block is loaded. We keep this file for the sake of backwards compatibility so that themes do not break.
 *
 * @param array  $params  All attributes passed to this function from the template.
 * @param object &$smarty Reference to the Smarty object.
 *
 * @return void But Add Js header if admin
 */
function smarty_function_modulestylesheet($params, &$smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('modulestylesheet')), E_USER_DEPRECATED);
    // do nothing unless we are admin
    if (SecurityUtil::checkPermission('::', '::', ACCESS_ADMIN)) {
        PageUtil::addVar('javascript', 'javascript/ajax/prototype.js');
        PageUtil::addVar('header', '<script type="text/javascript">/* <![CDATA[ */ Event.observe(window, "load", function() { alert("' . __('You can safely remove the modulestylesheet plugin from your theme. It is obsolete since Zikula 1.1.0. The adding of stylesheet files has been automated and does not need user interference. This note is shown to Administrators only.') . '");}); /* ]]> */</script>');
    }
    return;
}
/**
 * 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 ($varname != 'header' && $varname != 'footer') {
            throw new Zikula_Exception_Fatal(__f('Invalid page variable name: \'%1$s\'.', array($varname)));
        }
        PageUtil::addVar($varname, $content);
    }
}
function smarty_function_ms_greyboxheader($params, &$smarty)
{
    PageUtil::addVar('stylesheet', 'modules/mediashare/pnincludes/greybox/gb_styles.css');
    $script = '<script type="text/javascript">
                   var GB_ROOT_DIR = "' . pnGetBaseURL() . 'modules/mediashare/greybox/";
               </script>';
    PageUtil::addVar('rawtext', $script);
    PageUtil::addVar('javascript', 'modules/mediashare/pnincludes/greybox/AJS.js');
    PageUtil::addVar('javascript', 'modules/mediashare/pnincludes/greybox/AJS_fx.js');
    PageUtil::addVar('javascript', 'modules/mediashare/pnincludes/greybox/gb_scripts.js');
}
/**
 * Smarty function to wrap MUBoard_Form_View generated form controls with suitable form tags.
 *
 * @param array            $params  Parameters passed in the block tag.
 * @param string           $content Content of the block.
 * @param Zikula_Form_View $view    Reference to Zikula_Form_View object.
 *
 * @return string The rendered output.
 */
function smarty_block_muboardform($params, $content, $view)
{
    if ($content) {
        PageUtil::addVar('stylesheet', 'system/Theme/style/form/style.css');
        $encodingHtml = array_key_exists('enctype', $params) ? " enctype=\"{$params['enctype']}\"" : '';
        $action = htmlspecialchars(System::getCurrentUri());
        $classString = '';
        if (isset($params['cssClass'])) {
            $classString = "class=\"{$params['cssClass']}\" ";
        }
        $request = new Zikula_Request_Http();
        $id = $request->getGet()->filter('id', 0, FILTER_SANITIZE_NUMBER_INT);
        $forumid = $request->getGet()->filter('forum', 0, FILTER_SANITIZE_NUMBER_INT);
        // we check if the entrypoint is part of the url
        $stripentrypoint = ModUtil::getVar('ZConfig', 'shorturlsstripentrypoint');
        // get url name
        $tables = DBUtil::getTables();
        $modcolumn = $tables['modules_column'];
        $module = 'MUBoard';
        $where = "{$modcolumn['name']} = '" . DataUtil::formatForStore($module) . "'";
        $module = DBUtil::selectObject('modules', $where);
        $urlname = $module['url'];
        if (ModUtil::getVar('ZConfig', 'shorturls') == 0) {
            if (strpos($action, "func=display") !== false) {
                $action = 'index.php?module=' . $urlname . '&amp;type=user&amp;func=edit&amp;ot=posting&amp;answer=1';
            }
            if (strpos($action, "func=edit&ot=posting") !== false && $forumid > 0) {
                $action = 'index.php?module=' . $urlname . '&amp;type=user&amp;func=edit&amp;ot=posting&amp;forum' . $forumid;
            }
        } else {
            if (strpos($action, $urlname . "/posting/id.") !== false) {
                if ($stripentrypoint == 1) {
                    $action = $urlname . '/edit/ot/posting/answer/1';
                } elseif ($stripentrypoint == 0) {
                    $action = 'index.php/' . $urlname . '/edit/ot/posting/answer/1';
                }
            }
            if (strpos($action, "edit/ot/posting/forum/") !== false && $forumid > 0) {
                if ($stripentrypoint == 1) {
                    $action = $urlname . '/edit/ot/posting/forum/' . $forumid;
                } elseif ($stripentrypoint == 0) {
                    $action = 'index.php/' . $urlname . '/edit/ot/posting/forum/' . $forumid;
                }
            }
        }
        $view->postRender();
        $formId = $view->getFormId();
        $out = "\n        <form id=\"{$formId}\" {$classString}action=\"{$action}\" method=\"post\"{$encodingHtml}>\n        {$content}\n        <div>\n        {$view->getStateHTML()}\n        {$view->getStateDataHTML()}\n        {$view->getIncludesHTML()}\n        {$view->getCsrfTokenHtml()}\n        <input type=\"hidden\" name=\"__formid\" id=\"form__id\" value=\"{$formId}\" />\n        <input type=\"hidden\" name=\"FormEventTarget\" id=\"FormEventTarget\" value=\"\" />\n        <input type=\"hidden\" name=\"FormEventArgument\" id=\"FormEventArgument\" value=\"\" />\n        <script type=\"text/javascript\">\n        <!--\n        function FormDoPostBack(eventTarget, eventArgument)\n        {\n        var f = document.getElementById('{$formId}');\n        if (!f.onsubmit || f.onsubmit())\n        {\n        f.FormEventTarget.value = eventTarget;\n        f.FormEventArgument.value = eventArgument;\n        f.submit();\n    }\n    }\n    // -->\n    </script>\n    </div>\n    </form>\n    ";
        return $out;
    }
}
/**
 * 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);
    }
}
/**
 * Smarty function to displaya modules online manual
 *
 * Admin
 * {adminonlinemanual}
 *
 * @see          function.admincategorymenu.php::smarty_function_admincategoreymenu()
 * @param        array       $params      All attributes passed to this function from the template
 * @param        object      $smarty     Reference to the Smarty object
 * @param        int         xhtml        if set, the link to the navtabs.css will be xhtml compliant
 * @return       string      the results of the module function
 */
function smarty_function_adminonlinemanual($params, $smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('adminonlinemanual')), E_USER_DEPRECATED);
    $lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
    $modinfo = ModUtil::getInfoFromName(ModUtil::getName());
    $modpath = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules';
    $file = DataUtil::formatForOS("{$modpath}/{$modinfo['directory']}/lang/{$lang}/manual.html");
    $man_link = '';
    if (is_readable($file)) {
        PageUtil::addVar('javascript', 'zikula.ui');
        $man_link = '<div style="margin-top: 20px; text-align:center">[ <a id="online_manual" href="' . $file . '">' . __('Online manual') . '</a> ]</div>' . "\n";
        $man_link .= '<script type="text/javascript">var online_manual = new Zikula.UI.Window($(\'online_manual\'),{resizable: true})</script>' . "\n";
    }
    return $man_link;
}
Exemple #17
0
 /**
  * Display an error
  * This function displays a generic error form
  * The template used is based on the error type passed
  *
  * @param string $args['type'] error type '404' or 'module'
  * @param string $args['message'] custom error message
  *
  * @return string HTML string
  */
 public function main($args)
 {
     $type = FormUtil::getPassedValue('errtype', isset($args['type']) ? $args['type'] : LogUtil::getErrorType(), 'GET');
     $exception = isset($args['exception']) ? $args['exception'] : null;
     $message = isset($args['message']) ? $args['message'] : '';
     // perform any error specific tasks
     $protocol = System::serverGetVar('SERVER_PROTOCOL');
     switch ($type) {
         case 301:
             header("{$protocol} 301 Moved Permanently");
             break;
         case 403:
             header("{$protocol} 403 Access Denied");
             break;
         case 404:
             header("{$protocol} 404 Not Found");
             break;
         case 500:
             header("{$protocol} 500 Internal Server Error");
         default:
     }
     // load the stylesheet
     PageUtil::addVar('stylesheet', 'system/Errors/style/style.css');
     $this->view->setCaching(Zikula_View::CACHE_DISABLED);
     // assign the document info
     $this->view->assign('reportlevel', System::getVar('reportlevel'))->assign('currenturi', System::getCurrentUri())->assign('localreferer', System::localReferer())->assign('sitename', System::getVar('sitename'))->assign('reportlevel', System::getVar('reportlevel'))->assign('funtext', System::getVar('funtext'));
     $messages = LogUtil::getErrorMessages();
     // show the detailed error message for admins only
     if (System::isDevelopmentMode() || SecurityUtil::checkPermission('::', '::', ACCESS_ADMIN)) {
         $message ? $messages[] = $message : null;
     }
     $trace = array();
     if (System::isDevelopmentMode() && $exception instanceof Exception) {
         $line = $exception->getLine();
         $file = $exception->getFile();
         $trace = array(0 => '#0 ' . $this->__f('Exception thrown in %1$s, line %2$s.', array($file, $line)));
         $trace += explode("\n", $exception->getTraceAsString());
     }
     // assign the list of registered errors
     // and the trace (if development mode is enabled)
     $this->view->assign('messages', $messages)->assign('trace', $trace);
     // return the template output
     if ($this->view->template_exists($template = "errors_user_{$type}.tpl")) {
         return $this->view->fetch($template);
     } else {
         return $this->view->fetch('errors_user_main.tpl');
     }
 }
Exemple #18
0
 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return string The rendered output
  */
 public function render(Zikula_Form_View $view)
 {
     static $firstTime = true;
     if ($firstTime) {
         PageUtil::addVar('stylesheet', 'javascript/picky_color/picky_color.css');
         PageUtil::addVar('javascript', 'javascript/picky_color/picky_color.js');
     }
     $firstTime = false;
     $dom = ZLanguage::getModuleDomain('Reviews');
     $result = parent::render($view);
     if ($this->readOnly) {
         return $result;
     }
     $result .= "<script type=\"text/javascript\">\n            /* <![CDATA[ */\n                var namePicky = new PickyColor({\n                    field: '" . $this->getId() . "',\n                    color: '" . DataUtil::formatForDisplay($this->text) . "',\n                    colorWell: '" . $this->getId() . "',\n                    closeText: '" . __('Close', $dom) . "'\n                })\n            /* ]]> */\n            </script>";
     return $result;
 }
Exemple #19
0
/**
 * Smarty function to wrap Zikula_Form_View generated form controls with suitable form tags.
 *
 * @param array            $params  Parameters passed in the block tag.
 * @param string           $content Content of the block.
 * @param Zikula_Form_View $view    Reference to Zikula_Form_View object.
 *
 * @return string The rendered output.
 */
function smarty_block_form($params, $content, $view)
{
    if ($content) {
        PageUtil::addVar('stylesheet', 'system/Theme/style/form/style.css');
        $encodingHtml = array_key_exists('enctype', $params) ? " enctype=\"{$params['enctype']}\"" : '';
        $action = htmlspecialchars(System::getCurrentUri());
        $classString = '';
        if (isset($params['cssClass'])) {
            $classString = "class=\"{$params['cssClass']}\" ";
        }
        $view->postRender();
        $formId = $view->getFormId();
        $out = "\n<form id=\"{$formId}\" {$classString}action=\"{$action}\" method=\"post\"{$encodingHtml}>\n    {$content}\n    <div>\n        {$view->getStateHTML()}\n        {$view->getStateDataHTML()}\n        {$view->getIncludesHTML()}\n        {$view->getCsrfTokenHtml()}\n        <input type=\"hidden\" name=\"__formid\" id=\"form__id\" value=\"{$formId}\" />\n        <input type=\"hidden\" name=\"FormEventTarget\" id=\"FormEventTarget\" value=\"\" />\n        <input type=\"hidden\" name=\"FormEventArgument\" id=\"FormEventArgument\" value=\"\" />\n        <script type=\"text/javascript\">\n        <!--\n            function FormDoPostBack(eventTarget, eventArgument)\n            {\n                var f = document.getElementById('{$formId}');\n                if (!f.onsubmit || f.onsubmit())\n                {\n                    f.FormEventTarget.value = eventTarget;\n                    f.FormEventArgument.value = eventArgument;\n                    f.submit();\n                }\n            }\n        // -->\n        </script>\n    </div>\n</form>\n";
        return $out;
    }
}
/**
 * Zikula_View function to add a value to a multicontent page variable
 *
 * This function obtains a page-specific variable from the Zikula system.
 *
 * Available parameters:
 *   - name:     The name of the page variable to set
 *   - value:    The value of the page variable to set, comma separated list is possible
 *               for stylesheet and javascript variables
 *
 * Zikula doesn't impose any restriction on the page variable's name except for duplicate
 * and reserved names. As of this writing, the list of reserved names consists of
 * <ul>
 * <li>title</li>
 * <li>stylesheet</li>
 * <li>javascript</li>
 * <li>body</li>
 * <li>header</li>
 * <li>footer</li>
 * </ul>
 * 
 * In addition, if your system is operating in legacy compatibility mode, then
 * the variable 'rawtext' is reserved, and maps to 'header'. (When not operating in
 * legacy compatibility mode, 'rawtext' is not reserved and will not be rendered
 * to the page output by the page variable output filter.)
 *
 * Examples
 *   {pageaddvar name='javascript' value='path/to/myscript.js'}
 *   {pageaddvar name='javascript' value='path/to/myscript.js,path/to/another/script.js'}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string
 */
function smarty_function_pageaddvar($params, Zikula_View $view)
{
    $name = isset($params['name']) ? $params['name'] : null;
    $value = isset($params['value']) ? $params['value'] : null;
    if (!$name) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pageaddvar', 'name')));
        return false;
    }
    if (!$value) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pageaddvar', 'value')));
        return false;
    }
    if (in_array($name, array('stylesheet', 'javascript'))) {
        $value = explode(',', $value);
    }
    PageUtil::addVar($name, $value);
}
/**
 * Zikula_View function to add a single page variable value
 *
 * This function sets a page-specific variable from the Zikula system. Only single value pagevars are supported by
 * this insert!
 *
 * Available parameters:
 *   - var:   The name of the single value page variable to set
 *   - value: The value of the page variable to set
 *
 * Zikula doesn't impose any restriction on the page variable's name except for duplicate
 * and reserved names. As of this writing, the list of supported names consists of
 * <ul>
 * <li>title</li>
 * <li>stylesheet</li>
 * <li>javascript</li>
 * <li>body</li>
 * <li>header</li>
 * <li>footer</li>
 * </ul>
 *
 * In addition, if your system is operating in legacy compatibility mode, then
 * the variable 'rawtext' is reserved, and maps to 'header'. (When not operating in
 * legacy compatibility mode, 'rawtext' is not reserved and will not be rendered
 * to the page output by the page variable output filter.)
 *
 * Example
 *   {insert name='pageaddvar' var='javascript' value='path/to/myscript.js'}
 *   {insert name='pageaddvar' var='title' value=$mytitle}
 *
 * Note that $mytitle must be already assigned to the Zikula_View instance
 * before fetch the cached template.
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string
 */
function smarty_insert_pageaddvar($params, $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('insert name="pageaddvar" var="stylesheet" value="path/to/file.css"', 'pageaddvar name="stylesheet" value="path/to/file.css"')), E_USER_DEPRECATED);
    $var = isset($params['var']) ? $params['var'] : null;
    $value = isset($params['value']) ? $params['value'] : null;
    if (!$var) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('insert.pageaddvar', 'var')));
        return false;
    }
    if (!$value) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('insert.pageaddvar', 'value')));
        return false;
    }
    if (in_array($var, array('stylesheet', 'javascript'))) {
        $value = explode(',', $value);
    }
    PageUtil::addVar($var, $value);
    return;
}
Exemple #22
0
 function render(Zikula_Form_View $view)
 {
     $scripts = array('javascript/ajax/prototype.js', 'modules/Content/javascript/ajax.js');
     PageUtil::addVar('javascript', $scripts);
     $output = "<div class=\"z-formrow\">";
     $output .= parent::render($view);
     $output .= "</div>";
     $descr = array();
     $contentTypes = ModUtil::apiFunc('Content', 'Content', 'getContentTypes');
     foreach ($contentTypes as $type) {
         $descr[] = "\"{$type['module']}:{$type['name']}\" : \"" . htmlspecialchars($type['description']) . '"';
     }
     $descr = '<script type="text/javascript">/* <![CDATA[ */ var contentDescriptions = {' . implode(', ', $descr) . '} /* ]]> */</script>';
     $descr0 = count($contentTypes) > 0 ? $contentTypes[0]['description'] : '';
     $descr0 = htmlspecialchars($descr0);
     $output .= "<div class=\"z-formrow\" id=\"{$this->id}_descr\">{$descr0}</div>";
     $output .= $descr;
     return $output;
 }
Exemple #23
0
 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return string The rendered output
  */
 public function render(Zikula_Form_View $view)
 {
     static $firstTime = true;
     if ($firstTime) {
         PageUtil::addVar('javascript', 'prototype');
         PageUtil::addVar('javascript', 'Zikula.UI');
         // imageviewer
         PageUtil::addVar('javascript', 'modules/Reviews/javascript/Reviews_finder.js');
         PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('Reviews'));
     }
     $firstTime = false;
     if (!SecurityUtil::checkPermission('Reviews:' . ucwords($this->objectType) . ':', '::', ACCESS_COMMENT)) {
         return false;
     }
     $categorisableObjectTypes = array('review');
     $catIds = array();
     if (in_array($this->objectType, $categorisableObjectTypes)) {
         // fetch selected categories to reselect them in the output
         // the actual filtering is done inside the repository class
         $catIds = ModUtil::apiFunc('Reviews', 'category', 'retrieveCategoriesFromRequest', array('ot' => $this->objectType));
     }
     $this->selectedItemId = $this->text;
     $entityClass = 'Reviews_Entity_' . ucwords($this->objectType);
     $serviceManager = ServiceUtil::getManager();
     $entityManager = $serviceManager->getService('doctrine.entitymanager');
     $repository = $entityManager->getRepository($entityClass);
     $sort = $repository->getDefaultSortingField();
     $sdir = 'asc';
     // convenience vars to make code clearer
     $where = '';
     $sortParam = $sort . ' ' . $sdir;
     $entities = $repository->selectWhere($where, $sortParam);
     $view = Zikula_View::getInstance('Reviews', false);
     $view->assign('objectType', $this->objectType)->assign('items', $entities)->assign('selectedId', $this->selectedItemId);
     // assign category properties
     $properties = null;
     if (in_array($this->objectType, $categorisableObjectTypes)) {
         $properties = ModUtil::apiFunc('Reviews', 'category', 'getAllProperties', array('ot' => $this->objectType));
     }
     $view->assign('properties', $properties)->assign('catIds', $catIds);
     return $view->fetch('external/' . $this->objectType . '/select.tpl');
 }
Exemple #24
0
 /**
  * bbsmiles
  * returns a html snippet with buttons for inserting bbsmiles into a text
  *
  * @param    $args['textfieldid']  id of the textfield for inserting smilies
  */
 public function bbsmiles($args)
 {
     if (!isset($args['textfieldid']) || empty($args['textfieldid'])) {
         return LogUtil::registerArgsError();
     }
     // if we have more than one textarea we need to distinguish them, so we simply use
     // a counter stored in a session var until we find a better solution
     $counter = SessionUtil::getVar('bbsmile_counter', 0);
     $counter++;
     SessionUtil::setVar('bbsmile_counter', $counter);
     $this->view->assign('counter', $counter);
     $this->view->assign('textfieldid', $args['textfieldid']);
     PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('BBSmile'));
     $templatefile = DataUtil::formatForOS(ModUtil::getName()) . '.tpl';
     if ($this->view->template_exists($templatefile)) {
         return $this->view->fetch($templatefile);
     }
     $this->view->add_core_data();
     return $this->view->fetch('bbsmile_user_bbsmiles.tpl');
 }
Exemple #25
0
 /**
  * Display hook for view.
  *
  * @param Zikula_Hook $hook The hook.
  *
  * @return void
  */
 public function uiView(Zikula_DisplayHook $hook)
 {
     // Input from the hook
     $callermodname = $hook->getCaller();
     $callerobjectid = $hook->getId();
     // Check permissions
     if (!SecurityUtil::checkPermission('Ephemerides::', "::", ACCESS_READ)) {
         return;
     }
     // Get items
     $items = ModUtil::apiFunc('Ephemerides', 'user', 'gettoday', $args);
     // create the output object
     $view = Zikula_View::getInstance('Ephemerides', false, null, true);
     $view->assign('areaid', $hook->getAreaId());
     $view->assign('items', $items);
     $template = 'ephemerides_user_display.tpl';
     // Add style
     PageUtil::addVar('stylesheet', 'modules/Ephemerides/style/style.css');
     $response = new Zikula_Response_DisplayHook('provider.ephemerides.ui_hooks.ephemeride', $view, $template);
     $hook->setResponse($response);
 }
function smarty_function_mediashare_rss($params, $smarty)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    if (!isset($params['title'])) {
        $smarty->trigger_error(__f('Missing [%1$s] in \'%2$s\'', array('title', 'mediashare_rss'), $dom));
        return false;
    }
    if (!isset($params['urlParam']) && !isset($params['urlValue'])) {
        $smarty->trigger_error(__f('Missing [%1$s] in \'%2$s\'', array('urlParam & urlValue', 'mediashare_rss'), $dom));
        return false;
    }
    $url = DataUtil::formatForDisplay(pnModUrl('mediashare', 'user', 'xmllist', array($params['urlParam'] => $params['urlValue'], 'order' => 'created', 'orderdir' => 'desc')));
    $title = $params['title'];
    $link = "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"{$title}\" href=\"{$url}\"/>\n";
    PageUtil::addVar('rawtext', $link);
    $imageUrl = DataUtil::formatForDisplay('modules/mediashare/pnimages/rss.gif');
    if ($params['mode'] == 'text') {
        $html = "<span class=\"rss\">[<a href=\"{$url}\">RSS</a>]</span>";
    } else {
        $html = "<a href=\"{$url}\"><img src=\"{$imageUrl}\" alt=\"{$title}\" title=\"{$title}\" class=\"clickable\"/></a>";
    }
    return $html;
}
Exemple #27
0
/**
 * Zikula_View function to add a value to a multicontent page variable
 *
 * This function obtains a page-specific variable from the Zikula system.
 *
 * Available parameters:
 *   - name: The name of the page variable to set.
 *   - value: The value of the page variable to set, comma separated list is possible
 *      for stylesheet and javascript variables.
 *   - raw: If raw is set to true then value is treated as a single string and not split (Default: false).
 *   - lang: The laguage code to set via polyfill.
 *   - features: The feature(s) to load via polyfill.
 *
 * Zikula doesn't impose any restriction on the page variable's name except for duplicate
 * and reserved names. As of this writing, the list of reserved names consists of
 * <ul>
 * <li>title</li>
 * <li>stylesheet</li>
 * <li>javascript</li>
 * <li>body</li>
 * <li>header</li>
 * <li>footer</li>
 * </ul>
 *
 * In addition, if your system is operating in legacy compatibility mode, then
 * the variable 'rawtext' is reserved, and maps to 'header'. (When not operating in
 * legacy compatibility mode, 'rawtext' is not reserved and will not be rendered
 * to the page output by the page variable output filter.)
 *
 * Examples
 *   {pageaddvar name='javascript' value='jquery'}
 *   {pageaddvar name='javascript' value='path/to/myscript.js'}
 *   {pageaddvar name='javascript' value='path/to/myscript.js,path/to/another/script.js'}
 *   {pageaddvar name='jsgettext' value='module_news_js:News'}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string
 */
function smarty_function_pageaddvar($params, Zikula_View $view)
{
    $name = isset($params['name']) ? $params['name'] : null;
    $value = isset($params['value']) ? $params['value'] : null;
    $raw = isset($params['raw']) ? $params['raw'] : false;
    if ($value == 'polyfill') {
        $features = isset($params['features']) ? $params['features'] : 'forms';
    } else {
        $features = null;
    }
    if (!$name) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pageaddvar', 'name')));
        return false;
    }
    if (!$value) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pageaddvar', 'value')));
        return false;
    }
    if (in_array($name, array('stylesheet', 'javascript')) && !$raw) {
        $value = explode(',', $value);
    }
    PageUtil::addVar($name, $value, $features);
}
Exemple #28
0
 public function initialize(Zikula_Form_View $view)
 {
     if (!SecurityUtil::checkPermission('Content:page:', '::', ACCESS_EDIT)) {
         throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
     }
     // Include categories only when 2nd category enabled in settings
     $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', array('editing' => true, 'filter' => array('checkActive' => false, 'expandedPageIds' => SessionUtil::getVar('contentExpandedPageIds', array())), 'enableEscape' => true, 'translate' => false, 'includeLanguages' => true, 'includeCategories' => $this->getVar('categoryUsage') < 3, 'orderBy' => 'setLeft'));
     if ($pages === false) {
         return $this->view->registerError(null);
     }
     // Get categories names if enabled
     if ($this->getVar('$categoryUsage') < 4) {
         $lang = ZLanguage::getLanguageCode();
         $categories = array();
         foreach ($pages as $page) {
             $cat = CategoryUtil::getCategoryByID($page['categoryId']);
             $categories[$page['id']] = array();
             $categories[$page['id']][] = isset($cat['display_name'][$lang]) ? $cat['display_name'][$lang] : $cat['name'];
             if (isset($page['categories']) && is_array($page['categories'])) {
                 foreach ($page['categories'] as $pageCat) {
                     $cat = CategoryUtil::getCategoryByID($pageCat['categoryId']);
                     $categories[$page['id']][] = isset($cat['display_name'][$lang]) ? $cat['display_name'][$lang] : $cat['name'];
                 }
             }
         }
         $this->view->assign('categories', $categories);
     }
     PageUtil::setVar('title', $this->__('Page list and content structure'));
     $csssrc = ThemeUtil::getModuleStylesheet('admin', 'admin.css');
     PageUtil::addVar('stylesheet', $csssrc);
     $this->view->assign('pages', $pages);
     $this->view->assign('multilingual', ModUtil::getVar(ModUtil::CONFIG_MODULE, 'multilingual'));
     $this->view->assign('enableVersioning', $this->getVar('enableVersioning'));
     $this->view->assign('language', ZLanguage::getLanguageCode());
     Content_Util::contentAddAccess($this->view, null);
     return true;
 }
/**
 * Display a calendar input control.
 *
 * Display a calendar input control consisting of a calendar image, an optional
 * hidden input field, and associated javascript to render a pop-up calendar.
 * This function displays a javascript (jscalendar) calendar control.
 *
 * Available attributes:
 *   - objectname       (string)    The name of the object the field will be placed in
 *   - htmlname:        (string)    The html fieldname under which the date value will be submitted
 *   - dateformat:      (string)    The dateformat to use for displaying the chosen date
 *   - ifformat:        (string)    Format of the date field sent in the form (optional - defaults to dateformat)
 *   - defaultstring    (string)    The String to display before a value has been selected
 *   - defaultdate:     (string)    The Date the calendar should to default to (format: Y/m/d)
 *   - hidden:          (bool)      If set, a hidden input field will be generated to hold the selected date
 *   - display:         (bool)      If set, a <span> is generated to display the selected date (when date is added in a hidden field)
 *   - class:           (string)    The class to apply to the html elements
 *   - time:            (bool)      If set, show time selection
 *
 * Example:
 *
 * <samp>{calendarinput objectname='myobject' htmlname='from' dateformat='%Y-%m-%d' defaultdate='2005/12/31'}</samp>
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the {@link Zikula_View} object.
 *
 * @return string The HTML and Javascript code to display a calendar control.
 */
function smarty_function_calendarinput($params, Zikula_View $view)
{
    if (!isset($params['objectname'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pncalendarinput', 'objectname')));
        return false;
    }
    if (!isset($params['htmlname'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pncalendarinput', 'htmlname')));
        return false;
    }
    if (!isset($params['dateformat'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pncalendarinput', 'dateformat')));
        return false;
    }
    $ifformat = isset($params['ifformat']) ? $params['ifformat'] : $params['dateformat'];
    $inctime = isset($params['time']) ? (bool) $params['time'] : false;
    $validformats = array('%Y-%m-%d', '%Y-%m-%d %H:%M');
    if (!in_array($ifformat, $validformats)) {
        $ifformat = $inctime ? '%Y-%m-%d %H:%M' : '%Y-%m-%d';
    }
    // start of old pncalendarinit
    // pagevars make an extra pncalendarinit obsolete, they take care about the fact
    // that the styles/jsvascript do not get loaded multiple times
    static $firstTime = true;
    if ($firstTime) {
        $lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
        // map of the jscalendar supported languages
        $map = array('ca' => 'ca_ES', 'cz' => 'cs_CZ', 'da' => 'da_DK', 'de' => 'de_DE', 'el' => 'el_GR', 'en-us' => 'en_US', 'es' => 'es_ES', 'fi' => 'fi_FI', 'fr' => 'fr_FR', 'he' => 'he_IL', 'hr' => 'hr_HR', 'hu' => 'hu_HU', 'it' => 'it_IT', 'ja' => 'ja_JP', 'ko' => 'ko_KR', 'lt' => 'lt_LT', 'lv' => 'lv_LV', 'nl' => 'nl_NL', 'no' => 'no_NO', 'pl' => 'pl_PL', 'pt' => 'pt_BR', 'ro' => 'ro_RO', 'ru' => 'ru_RU', 'si' => 'si_SL', 'sk' => 'sk_SK', 'sv' => 'sv_SE', 'tr' => 'tr_TR');
        if (isset($map[$lang])) {
            $lang = $map[$lang];
        }
        $headers[] = 'javascript/jscalendar/calendar.js';
        if (file_exists("javascript/jscalendar/lang/calendar-{$lang}.utf8.js")) {
            $headers[] = "javascript/jscalendar/lang/calendar-{$lang}.utf8.js";
        }
        $headers[] = 'javascript/jscalendar/calendar-setup.js';
        PageUtil::addVar('stylesheet', 'javascript/jscalendar/calendar-win2k-cold-2.css');
        PageUtil::addVar('javascript', $headers);
    }
    $firstTime = false;
    // end of old pncalendarinit
    if (!isset($params['defaultstring'])) {
        $params['defaultstring'] = null;
    }
    if (!isset($params['defaultdate'])) {
        $params['defaultdate'] = null;
    }
    $html = '';
    $fieldKey = $params['htmlname'];
    if ($params['objectname']) {
        $fieldKey = $params['objectname'] . '[' . $params['htmlname'] . ']';
    }
    $triggerName = 'trigger_' . $params['htmlname'];
    $displayName = 'display_' . $params['htmlname'];
    if (isset($params['class']) && !empty($params['class'])) {
        $params['class'] = ' class="' . DataUtil::formatForDisplay($params['class']) . '"';
    } else {
        $params['class'] = '';
    }
    if (isset($params['display']) && $params['display']) {
        $html .= '<span id="' . $displayName . '"' . $params['class'] . '>' . $params['defaultstring'] . '</span>&nbsp;';
    }
    if (isset($params['hidden']) && $params['hidden']) {
        $html .= '<input type="hidden" name="' . $fieldKey . '" id="' . $params['htmlname'] . '" value="' . $params['defaultdate'] . '" />';
    }
    $html .= '<img class="z-calendarimg" src="' . System::getBaseUrl() . 'javascript/jscalendar/img.gif" id="' . $triggerName . '" style="cursor: pointer;" title="' . DataUtil::formatForDisplay(__('Date selector')) . '"  alt="' . DataUtil::formatForDisplay(__('Date selector')) . '" />';
    $i18n = ZI18n::getInstance();
    $html .= "<script type=\"text/javascript\">\n              // <![CDATA[\n              Calendar.setup(\n              {";
    //$html .= 'ifFormat    : "%Y-%m-%d %H:%M:00",'; // universal format, don't change this!
    $html .= 'ifFormat    : "' . $ifformat . '",';
    $html .= 'inputField  : "' . $params['htmlname'] . '",';
    $html .= 'displayArea : "' . $displayName . '",';
    $html .= 'daFormat    : "' . $params['dateformat'] . '",';
    $html .= 'button      : "' . $triggerName . '",';
    $html .= 'defaultDate : "' . $params['defaultdate'] . '",';
    $html .= 'firstDay    : "' . $i18n->locale->getFirstweekday() . '",';
    $html .= 'align       : "Tl",';
    if (isset($params['defaultdate']) && $params['defaultdate']) {
        $d = strtotime($params['defaultdate']);
        $d = date('Y/m/d', $d);
        $html .= 'date : "' . $d . '",';
    }
    if ($inctime) {
        $html .= 'showsTime  : true,';
        $html .= 'timeFormat : "' . $i18n->locale->getTimeformat() . '",';
    }
    $html .= "singleClick : true });\n              // ]]>\n              </script>";
    return $html;
}
Exemple #30
0
 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return string The rendered output
  */
 public function render(Zikula_Form_View $view)
 {
     static $firstTime = true;
     $i18n = ZI18n::getInstance();
     if (!empty($this->defaultValue) && !$view->isPostBack()) {
         $d = strtolower($this->defaultValue);
         $now = getdate();
         $date = null;
         if ($d == 'now') {
             $date = time();
         } elseif ($d == 'today') {
             $date = mktime(0, 0, 0, $now['mon'], $now['mday'], $now['year']);
         } elseif ($d == 'monthstart') {
             $date = mktime(0, 0, 0, $now['mon'], 1, $now['year']);
         } elseif ($d == 'monthend') {
             $daysInMonth = date('t');
             $date = mktime(0, 0, 0, $now['mon'], $daysInMonth, $now['year']);
         } elseif ($d == 'yearstart') {
             $date = mktime(0, 0, 0, 1, 1, $now['year']);
         } elseif ($d == 'yearend') {
             $date = mktime(0, 0, 0, 12, 31, $now['year']);
         } elseif ($d == 'custom') {
             $date = strtotime($this->initDate);
         }
         if ($date != null) {
             $this->text = DateUtil::getDatetime($date, $this->ifFormat, false);
         } else {
             $this->text = __('Unknown date');
         }
     }
     if ($view->isPostBack() && !empty($this->text)) {
         $date = strtotime($this->text);
         $this->text = DateUtil::getDatetime($date, $this->ifFormat, false);
     }
     if ($firstTime) {
         $lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
         // map of the jscalendar supported languages
         $map = array('ca' => 'ca_ES', 'cz' => 'cs_CZ', 'da' => 'da_DK', 'de' => 'de_DE', 'el' => 'el_GR', 'en-us' => 'en_US', 'es' => 'es_ES', 'fi' => 'fi_FI', 'fr' => 'fr_FR', 'he' => 'he_IL', 'hr' => 'hr_HR', 'hu' => 'hu_HU', 'it' => 'it_IT', 'ja' => 'ja_JP', 'ko' => 'ko_KR', 'lt' => 'lt_LT', 'lv' => 'lv_LV', 'nl' => 'nl_NL', 'no' => 'no_NO', 'pl' => 'pl_PL', 'pt' => 'pt_BR', 'ro' => 'ro_RO', 'ru' => 'ru_RU', 'si' => 'si_SL', 'sk' => 'sk_SK', 'sv' => 'sv_SE', 'tr' => 'tr_TR');
         if (isset($map[$lang])) {
             $lang = $map[$lang];
         }
         $headers[] = 'javascript/jscalendar/calendar.js';
         if (file_exists("javascript/jscalendar/lang/calendar-{$lang}.utf8.js")) {
             $headers[] = "javascript/jscalendar/lang/calendar-{$lang}.utf8.js";
         }
         $headers[] = 'javascript/jscalendar/calendar-setup.js';
         PageUtil::addVar('stylesheet', 'javascript/jscalendar/calendar-win2k-cold-2.css');
         PageUtil::addVar('javascript', $headers);
     }
     $firstTime = false;
     $result = '';
     if ($this->useSelectionMode) {
         $hiddenInputField = str_replace(array('type="text"', '&nbsp;*'), array('type="hidden"', ''), parent::render($view));
         $result .= '<div>' . $hiddenInputField . '<span id="' . $this->id . 'cal" style="background-color: #ff8; cursor: default" onmouseover="this.style.backgroundColor=\'#ff0\';" onmouseout="this.style.backgroundColor=\'#ff8\';">';
         if ($this->text) {
             $result .= DataUtil::formatForDisplay(DateUtil::getDatetime(DateUtil::parseUIDate($this->text, $this->ifFormat), $this->daFormat));
         } else {
             $result .= __('Select date');
         }
         $result .= '</span></div>';
         if ($this->mandatory && $this->mandatorysym) {
             $result .= '<span class="z-form-mandatory-flag">*</span>';
         }
     } else {
         $result .= '<span class="z-form-date" style="white-space: nowrap">';
         $result .= parent::render($view);
         $txt = __('Select date');
         $result .= " <img id=\"{$this->id}_img\" src=\"javascript/jscalendar/img.gif\" style=\"vertical-align: middle\" class=\"clickable\" alt=\"{$txt}\" /></span>";
     }
     // build jsCalendar script options
     $result .= "<script type=\"text/javascript\">\n            // <![CDATA[\n            Calendar.setup(\n            {\n                inputField : \"{$this->id}\",";
     if ($this->includeTime) {
         $this->initDate = str_replace('-', ',', $this->initDate);
         $result .= "\n                    ifFormat : \"" . $this->ifFormat . "\",\n                    showsTime      :    true,\n                    timeFormat     :    \"" . $i18n->locale->getTimeformat() . "\",\n                    singleClick    :    false,";
     } else {
         $result .= "\n                    ifFormat : \"" . $this->ifFormat . "\",";
     }
     if ($this->useSelectionMode) {
         $result .= "\n                    displayArea :    \"{$this->id}cal\",\n                    daFormat    :    \"{$this->daFormat}\",\n                    align       :    \"Bl\",\n                    singleClick :    true,";
     } else {
         $result .= "\n                    button : \"{$this->id}_img\",";
     }
     $result .= "\n                    firstDay: " . $i18n->locale->getFirstweekday() . "\n                }\n            );\n            // ]]>\n            </script>";
     return $result;
 }