function smarty_function_mediashare_breadcrumb($params, &$smarty)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    if (!isset($params['albumId'])) {
        $smarty->trigger_error(__f('Missing [%1$s] in \'%2$s\'', array('albumId', 'mediashare_breadcrumb'), $dom));
        return false;
    }
    $mode = isset($params['mode']) ? $params['mode'] : 'view';
    $breadcrumb = pnModAPIFunc('mediashare', 'user', 'getAlbumBreadcrumb', array('albumId' => (int) $params['albumId']));
    if ($breadcrumb === false) {
        $smarty->trigger_error(LogUtil::getErrorMessagesText());
        return false;
    }
    $urlType = $mode == 'edit' ? 'edit' : 'user';
    $url = pnModUrl('mediashare', $urlType, 'view', array('aid' => 0));
    $result = "<div class=\"mediashare-breadcrumb\">";
    $first = true;
    foreach ($breadcrumb as $album) {
        $url = DataUtil::formatForDisplay(pnModUrl('mediashare', $urlType, 'view', array('aid' => $album['id'])));
        $result .= ($first ? '' : ' &raquo; ') . "<a href=\"{$url}\">" . htmlspecialchars($album['title']) . "</a>";
        $first = false;
    }
    $result .= "</div>";
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $result);
    }
    return $result;
}
Exemple #2
0
 /**
  * Initialize form handler.
  *
  * This method takes care of all necessary initialisation of our data and form states.
  *
  * @return boolean False in case of initialization errors, otherwise true.
  */
 public function initialize(Zikula_Form_View $view)
 {
     $dom = ZLanguage::getModuleDomain($this->name);
     // permission check
     if (!SecurityUtil::checkPermission('MUBoard::', '::', ACCESS_ADMIN)) {
         return $view->registerError(LogUtil::registerPermissionError());
     }
     // retrieve module vars
     $modVars = ModUtil::getVar('MUBoard');
     // initialise list entries for the 'number images' setting
     $modVars['numberImagesItems'] = array(array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3'));
     // initialise list entries for the 'number files' setting
     $modVars['numberFilesItems'] = array(array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3'));
     // initialise list entries for the 'sorting postings' setting
     $modVars['sortingCategoriesItems'] = array(array('value' => 'descending', 'text' => __('Descending', $dom)), array('value' => 'ascending', 'text' => __('Ascending', $dom)));
     // initialise list entries for the 'sorting postings' setting
     $modVars['sortingPostingsItems'] = array(array('value' => 'descending', 'text' => __('Descending', $dom)), array('value' => 'ascending', 'text' => __('Ascending', $dom)));
     // initialise list entries for the 'icon set' setting
     $modVars['iconSetItems'] = array(array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3'));
     // initialise list entries for the 'template' setting
     $modVars['templateItems'] = array(array('value' => 'normal', 'text' => 'Normal'), array('value' => 'jquery', 'text' => 'jQuery'));
     // assign all module vars
     $this->view->assign('config', $modVars);
     // custom initialisation aspects
     $this->initializeAdditions();
     // everything okay, no initialization errors occured
     return true;
 }
Exemple #3
0
 public function __construct(RouterInterface $router, SecurityManager $securityManager, TranslatorInterface $translator)
 {
     $this->router = $router;
     $this->securityManager = $securityManager;
     $this->domain = \ZLanguage::getModuleDomain('CmfcmfMediaModule');
     $this->translator = $translator;
 }
/**
 * Zikula_View function to create  manual link.
 *
 * This function creates a manual link from some parameters.
 *
 * Available parameters:
 *   - manual:    name of manual file, manual.html if not set
 *   - chapter:   an anchor in the manual file to jump to
 *   - newwindow: opens the manual in a new window using javascript
 *   - width:     width of the window if newwindow is set, default 600
 *   - height:    height of the window if newwindow is set, default 400
 *   - title:     name of the new window if newwindow is set, default is modulename
 *   - class:     class for use in the <a> tag
 *   - assign:    if set, the results ( array('url', 'link') are assigned to the corresponding variable instead of printed out
 *
 * Example
 * {manuallink newwindow=1 width=400 height=300 title=rtfm }
 *
 * @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
 */
function smarty_function_manuallink($params, Zikula_View $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('manuallink')), E_USER_DEPRECATED);
    $userlang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
    $stdlang = System::getVar('language_i18n');
    $title = isset($params['title']) ? $params['title'] : 'Manual';
    $manual = isset($params['manual']) ? $params['manual'] : 'manual.html';
    $chapter = isset($params['chapter']) ? '#' . $params['chapter'] : '';
    $class = isset($params['class']) ? 'class="' . $params['class'] . '"' : '';
    $width = isset($params['width']) ? $params['width'] : 600;
    $height = isset($params['height']) ? $params['height'] : 400;
    $modname = ModUtil::getName();
    $possibleplaces = array("modules/{$modname}/docs/{$userlang}/manual/{$manual}", "modules/{$modname}/docs/{$stdlang}/manual/{$manual}", "modules/{$modname}/docs/en/manual/{$manual}", "modules/{$modname}/docs/{$userlang}/{$manual}", "modules/{$modname}/docs/{$stdlang}/{$manual}", "modules/{$modname}/docs/lang/en/{$manual}");
    foreach ($possibleplaces as $possibleplace) {
        if (file_exists($possibleplace)) {
            $url = $possibleplace . $chapter;
            break;
        }
    }
    if (isset($params['newwindow'])) {
        $link = "<a {$class} href='#' onclick=\"window.open( '" . DataUtil::formatForDisplay($url) . "' , '" . DataUtil::formatForDisplay($modname) . "', 'status=yes,scrollbars=yes,resizable=yes,width={$width},height={$height}'); picwin.focus();\">" . DataUtil::formatForDisplayHTML($title) . "</a>";
    } else {
        $link = "<a {$class} href=\"" . DataUtil::formatForDisplay($url) . "\">" . DataUtil::formatForDisplayHTML($title) . "</a>";
    }
    if (isset($params['assign'])) {
        $ret = array('url' => $url, 'link' => $link);
        $view->assign($params['assign'], $ret);
        return;
    } else {
        return $link;
    }
}
Exemple #5
0
/**
 * Content needle
 * @param $args['nid'] needle id
 * @return array()
 */
function content_needleapi_content($args)
{
    $dom = ZLanguage::getModuleDomain('Content');
    // Get arguments from argument array
    $nid = $args['nid'];
    unset($args);
    // cache the results
    static $cache;
    if (!isset($cache)) {
        $cache = array();
    }
    if (!empty($nid)) {
        if (!isset($cache[$nid])) {
            // not in cache array
            if (ModUtil::available('Content')) {
                $contentpage = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $nid, 'includeContent' => false));
                if ($contentpage != false) {
                    $cache[$nid] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('Content', 'user', 'view', array('pid' => $nid))) . '" title="' . DataUtil::formatForDisplay($contentpage['title']) . '">' . DataUtil::formatForDisplay($contentpage['title']) . '</a>';
                } else {
                    $cache[$nid] = '<em>' . DataUtil::formatForDisplay(__('Unknown id', $dom)) . '</em>';
                }
            } else {
                $cache[$nid] = '<em>' . DataUtil::formatForDisplay(__('Content not available', $dom)) . '</em>';
            }
        }
        $result = $cache[$nid];
    } else {
        $result = '<em>' . DataUtil::formatForDisplay(__('No needle id', $dom)) . '</em>';
    }
    return $result;
}
Exemple #6
0
 /**
  * Setup internal properties.
  *
  * @param $bundle
  *
  * @return void
  */
 protected function _configureBase($bundle = null)
 {
     $this->systemBaseDir = realpath('.');
     if (null !== $bundle) {
         $this->name = $bundle->getName();
         $this->domain = ZLanguage::getModuleDomain($this->name);
         $this->baseDir = $bundle->getPath();
         $versionClass = $bundle->getVersionClass();
         $this->version = new $versionClass($bundle);
     } else {
         $className = $this->getReflection()->getName();
         $separator = false === strpos($className, '_') ? '\\' : '_';
         $parts = explode($separator, $className);
         $this->name = $parts[0];
         $this->baseDir = $this->libBaseDir = realpath(dirname($this->reflection->getFileName()) . '/../..');
         if (realpath("{$this->baseDir}/lib/" . $this->name)) {
             $this->libBaseDir = realpath("{$this->baseDir}/lib/" . $this->name);
         }
         $versionClass = "{$this->name}\\{$this->name}Version";
         $versionClassOld = "{$this->name}_Version";
         $versionClass = class_exists($versionClass) ? $versionClass : $versionClassOld;
         $this->version = new $versionClass();
     }
     $this->modinfo = array('directory' => $this->name, 'type' => ModUtil::getModuleBaseDir($this->name) == 'system' ? ModUtil::TYPE_SYSTEM : ModUtil::TYPE_MODULE);
     if ($this->modinfo['type'] == ModUtil::TYPE_MODULE) {
         $this->domain = ZLanguage::getModuleDomain($this->name);
     }
 }
/**
 * Content
 *
 * @copyright (C) 2007-2010, Content Development Team
 * @link http://github.com/zikula-modules/Content
 * @license See license.txt
 */
function smarty_function_contentcolumncount($params, $view)
{
    $dom = ZLanguage::getModuleDomain('Content');
    // input is layout name
    $layout = isset($params['layout']) ? $params['layout'] : '';
    $columnCount = 1;
    // assume 1 if no match can be found
    // now start simple matching with a regular expression on the layout name. No science here.
    // Looking for the first numbers in the string and stops with text again. Then take the highest single digit.
    // Examples:
    // layout			columnCount
    // ---------------------------------
    // column21212		2
    // column2d2575		2
    // column3d502525	3
    // column23andtext	3
    //
    if (preg_match('/[1-9]+/', $layout, $matches)) {
        // found first set of numbers
        $matchSplit = str_split($matches[0]);
        rsort($matchSplit);
        $columnCount = $matchSplit[0];
    }
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $columnCount);
    } else {
        return $columnCount;
    }
}
/**
 * Content
 *
 * @copyright (C) 2007-2010, Content Development Team
 * @link http://github.com/zikula-modules/Content
 * @license See license.txt
 */
function smarty_function_contentcodeeditor($params, $view)
{
    $dom = ZLanguage::getModuleDomain('Content');
    $inputId = $params['inputId'];
    $inputType = isset($params['inputType']) ? $params['inputType'] : null;
    // Get reference to optional radio button that enables the editor (a hack for the HTML plugin).
    // It would have been easier just to read a $var in the template, but this won't work with a
    // Forms plugin - you would just get the initial value from when the page was loaded
    $htmlRadioButton = isset($params['htmlradioid']) ? $view->getPluginById($params['htmlradioid']) : null;
    $textRadioButton = isset($params['textradioid']) ? $view->getPluginById($params['textradioid']) : null;
    $html = '';
    $useBBCode = $textRadioButton == null && $inputType == 'text' && !$view->isPostBack() || $textRadioButton != null && $textRadioButton->checked;
    if ($useBBCode && ModUtil::available('BBCode')) {
        $html = "<div class=\"z-formrow\"><em class=\"z-sub\">";
        $html .= ModUtil::func('BBCode', 'User', 'bbcodes', array('textfieldid' => $inputId, 'images' => 0));
        $html .= "</em></div>";
    } else {
        if ($useBBCode && !ModUtil::available('BBCode')) {
            $html = "<div class=\"z-formrow\"><em class=\"z-sub\">";
            $html .= '(' . __("Please install the BBCode module to enable BBCodes display.", $dom) . ')';
            $html .= "</em></div>";
        }
    }
    return $html;
}
Exemple #9
0
 /**
  * Performs all validation rules.
  *
  * @return mixed either array with error information or true on success
  */
 public function validateAll()
 {
     $errorInfo = array('message' => '', 'code' => 0, 'debugArray' => array());
     $dom = ZLanguage::getModuleDomain('MUBoard');
     if (!$this->isValidInteger('userid')) {
         $errorInfo['message'] = __f('Error! Field value may only contain digits (%s).', array('userid'), $dom);
         return $errorInfo;
     }
     if (!$this->isNumberNotEmpty('userid')) {
         $errorInfo['message'] = __f('Error! Field value must not be 0 (%s).', array('userid'), $dom);
         return $errorInfo;
     }
     if (!$this->isNumberNotLongerThan('userid', 11)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('userid', 11), $dom);
         return $errorInfo;
     }
     if (!$this->isValidInteger('numberPostings')) {
         $errorInfo['message'] = __f('Error! Field value may only contain digits (%s).', array('numberPostings'), $dom);
         return $errorInfo;
     }
     /* if (!$this->isNumberNotEmpty('numberPostings')) {
            $errorInfo['message'] = __f('Error! Field value must not be 0 (%s).', array('numberPostings'), $dom);
            return $errorInfo;
        }*/
     if (!$this->isNumberNotLongerThan('numberPostings', 11)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('numberPostings', 11), $dom);
         return $errorInfo;
     }
     if (!$this->isValidDateTime('lastVisit')) {
         $errorInfo['message'] = __f('Error! Field value must be a valid datetime (%s).', array('lastVisit'), $dom);
         return $errorInfo;
     }
     return true;
 }
Exemple #10
0
/**
 * Update operation.
 * @param object $entity The treated object.
 * @param array  $params Additional arguments.
 *
 * @return bool False on failure or true if everything worked well.
 */
function Reviews_operation_update(&$entity, $params)
{
    $dom = ZLanguage::getModuleDomain('Reviews');
    // initialise the result flag
    $result = false;
    $objectType = $entity['_objectType'];
    $currentState = $entity['workflowState'];
    // get attributes read from the workflow
    if (isset($params['nextstate']) && !empty($params['nextstate'])) {
        // assign value to the data object
        $entity['workflowState'] = $params['nextstate'];
        if ($params['nextstate'] == 'archived') {
            // bypass validator (for example an end date could have lost it's "value in future")
            $entity['_bypassValidation'] = true;
        }
    }
    // get entity manager
    $serviceManager = ServiceUtil::getManager();
    $entityManager = $serviceManager->getService('doctrine.entitymanager');
    // save entity data
    try {
        //$this->entityManager->transactional(function($entityManager) {
        $entityManager->persist($entity);
        $entityManager->flush();
        //});
        $result = true;
    } catch (\Exception $e) {
        LogUtil::registerError($e->getMessage());
    }
    // return result of this operation
    return $result;
}
Exemple #11
0
 /**
  * Performs all validation rules.
  *
  * @return mixed either array with error information or true on success
  */
 public function validateAll()
 {
     $errorInfo = array('message' => '', 'code' => 0, 'debugArray' => array());
     $dom = ZLanguage::getModuleDomain('MUBoard');
     if (!$this->isStringNotLongerThan('title', 255)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('title', 255), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotEmpty('title')) {
         $errorInfo['message'] = __f('Error! Field value must not be empty (%s).', array('title'), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotLongerThan('description', 2000)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('description', 2000), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotEmpty('description')) {
         $errorInfo['message'] = __f('Error! Field value must not be empty (%s).', array('description'), $dom);
         return $errorInfo;
     }
     if (!$this->isValidInteger('pos')) {
         $errorInfo['message'] = __f('Error! Field value may only contain digits (%s).', array('pos'), $dom);
         return $errorInfo;
     }
     /* if (!$this->isNumberNotEmpty('pos')) {
            $errorInfo['message'] = __f('Error! Field value must not be 0 (%s).', array('pos'), $dom);
            return $errorInfo;
        }*/
     if (!$this->isNumberNotLongerThan('pos', 3)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('pos', 3), $dom);
         return $errorInfo;
     }
     return true;
 }
function mediashare_source_browserapi_addMediaItem($args)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    if (!isset($args['albumId'])) {
        return LogUtil::registerError(__f('Missing [%1$s] in \'%2$s\'', array('albumId', 'source_browserapi.addMediaItem'), $dom));
    }
    $uploadFilename = $args['uploadFilename'];
    // FIXME Required because the globals??
    //pnModAPILoad('mediashare', 'edit');
    // For OPEN_BASEDIR reasons we move the uploaded file as fast as possible to an accessible place
    // MUST remember to remove it afterwards!!!
    // Create and check tmpfilename
    $tmpDir = pnModGetVar('mediashare', 'tmpDirName');
    if (($tmpFilename = tempnam($tmpDir, 'Upload_')) === false) {
        return LogUtil::registerError(__f("Unable to create a temporary file in '%s'", $tmpDir, $dom) . ' - ' . __('(uploading image)', $dom));
    }
    if (is_uploaded_file($uploadFilename)) {
        if (move_uploaded_file($uploadFilename, $tmpFilename) === false) {
            unlink($tmpFilename);
            return LogUtil::registerError(__f('Unable to move uploaded file from \'%1$s\' to \'%2$s\'', array($uploadFilename, $tmpFilename), $dom) . ' - ' . __('(uploading image)', $dom));
        }
    } else {
        if (!copy($uploadFilename, $tmpFilename)) {
            unlink($tmpFilename);
            return LogUtil::registerError(__f('Unable to copy the file from \'%1$s\' to \'%2$s\'', array($uploadFilename, $tmpFilename), $dom) . ' - ' . __('(adding image)', $dom));
        }
    }
    $args['mediaFilename'] = $tmpFilename;
    $result = pnModAPIFunc('mediashare', 'edit', 'addMediaItem', $args);
    unlink($tmpFilename);
    return $result;
}
Exemple #13
0
 /**
  * Setup the current instance of the Zikula_View class and return it back to the module.
  *
  * @param string       $moduleName Module name.
  * @param string       $pluginName Plugin name.
  * @param integer|null $caching    Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
  * @param string       $cache_id   Cache Id.
  *
  * @return Zikula_View_Plugin instance.
  */
 public static function getPluginInstance($moduleName, $pluginName, $caching = null, $cache_id = null)
 {
     $serviceManager = ServiceUtil::getManager();
     $serviceId = strtolower(sprintf('zikula.renderplugin.%s.%s', $moduleName, $pluginName));
     if (!$serviceManager->has($serviceId)) {
         $view = new self($serviceManager, $moduleName, $pluginName, $caching);
         $serviceManager->set($serviceId, $view);
     } else {
         return $serviceManager->get($serviceId);
     }
     if (!is_null($caching)) {
         $view->caching = $caching;
     }
     if (!is_null($cache_id)) {
         $view->cache_id = $cache_id;
     }
     if ($moduleName === null) {
         $moduleName = $view->toplevelmodule;
     }
     if (!array_key_exists($moduleName, $view->module)) {
         $view->module[$moduleName] = ModUtil::getInfoFromName($moduleName);
         //$instance->modinfo = ModUtil::getInfoFromName($module);
         $view->_addPluginsDir($moduleName);
     }
     // for {gt} template plugin to detect gettext domain
     if ($view->module[$moduleName]['type'] == ModUtil::TYPE_MODULE || $view->module[$moduleName]['type'] == ModUtil::TYPE_SYSTEM) {
         $view->domain = ZLanguage::getModulePluginDomain($view->module[$moduleName]['name'], $view->getPluginName());
     } elseif ($view->module[$moduleName]['type'] == ModUtil::TYPE_CORE) {
         $view->domain = ZLanguage::getSystemPluginDomain($view->getPluginName());
     }
     return $view;
 }
function smarty_function_iwqvuserassignmentactionmenulinks($params, &$smarty) {
    $dom = ZLanguage::getModuleDomain('IWqv');
    // set some defaults
    if (!isset($params['start'])) {
        $params['start'] = '[';
    }
    if (!isset($params['end'])) {
        $params['end'] = ']';
    }
    if (!isset($params['separator'])) {
        $params['separator'] = ' | ';
    }
    if (!isset($params['class'])) {
        $params['class'] = 'pn-sub';
    }
    
    $html = '';

    if ($params['viewas'] == 'teacher') {
        if (SecurityUtil::checkPermission('IWqv::', "::", ACCESS_ADD)) {
            $html = "<span class=\"" . $params['class'] . "\">" . $params['start'] . " ";
            $html .= "<a onclick=\"iwqvPreviewAssignment('" . $params['url'] . "?skin=" . $params['skin'] . "&lang=" . $params['lang'] . "')\" href=\"javascript:void(0);\">" . __('preview', $dom) . "</a>";
            if (isset($params['hidecorrect']) && $params['hidecorrect'] == false)
                $html .= $params['separator'] . "<a onclick=\"iwqvShowAssignment(" . $params['qvid'] . ", '" . $params['viewas'] . "')\" href=\"javascript:void(0);\">" . __('correct', $dom) . "</a>";
            $html .= $params['separator'] . "<a onclick=\"iwqvEditAssignment(" . $params['qvid'] . ")\" href=\"javascript:void(0);\">" . __('edit', $dom) . "</a>";

            if (SecurityUtil::checkPermission('IWqv::', "::", ACCESS_DELETE)) {
                if (isset($params['hidecorrect']) && $params['hidecorrect'] == false)
                    $html .= $params['separator'] . "<a onclick=\"iwqvDeleteAssignment(" . $params['qvid'] . ")\" href=\"javascript:void(0);\">" . __('delete', $dom) . "</a>";
            }
            $html .= $params['end'] . "</span>\n";
        }
    }
    return $html;
}
/**
 * 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();
    }
}
/**
 * Zikula_View function to display a drop down list of languages
 *
 * Available parameters:
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *   - name:     Name for the control
 *   - id:       ID for the control
 *   - selected: Selected value
 *   - installed: if set only show languages existing in languages folder
 *   - all:      show dummy entry '_ALL' on top of the list with empty value
 *
 * Example
 *   {html_select_languages name=language selected=en}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @deprecated smarty_function_html_select_locales()
 * @return string The value of the last status message posted, or void if no status message exists.
 */
function smarty_function_html_select_languages($params, Zikula_View $view)
{
    if (!isset($params['name']) || empty($params['name'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('html_select_languages', 'name')));
        return false;
    }
    require_once $view->_get_plugin_filepath('function', 'html_options');
    $params['output'] = array();
    $params['values'] = array();
    if (isset($params['all']) && $params['all']) {
        $params['values'][] = '';
        $params['output'][] = DataUtil::formatForDisplay(__('All'));
        unset($params['all']);
    }
    if (isset($params['installed']) && $params['installed']) {
        $languagelist = ZLanguage::getInstalledLanguageNames();
        unset($params['installed']);
    } else {
        $languagelist = ZLanguage::languageMap();
    }
    $params['output'] = array_merge($params['output'], DataUtil::formatForDisplay(array_values($languagelist)));
    $params['values'] = array_merge($params['values'], DataUtil::formatForDisplay(array_keys($languagelist)));
    $assign = isset($params['assign']) ? $params['assign'] : null;
    unset($params['assign']);
    $html_result = smarty_function_html_options($params, $view);
    if (!empty($assign)) {
        $view->assign($assign, $html_result);
    } else {
        return $html_result;
    }
}
Exemple #17
0
 /**
  *
  */
 public function moduleSearch($args)
 {
     $dom = ZLanguage::getModuleDomain('MUBoard');
     $searchsubmit = $this->request->getPost()->filter('searchsubmit', 'none', FILTER_SANITIZE_STRING);
     $searchoptions = $this->request->getPost()->filter('searchoptions', 'all', FILTER_SANITIZE_STRING);
     $searchplace = $this->request->getPost()->filter('searchplace', 'title', FILTER_SANITIZE_STRING);
     $resultorder = $this->request->getPost()->filter('resultorder', 'none', FILTER_SANITIZE_STRING);
     $kind = $this->request->query->filter('kind', 'none', FILTER_SANITIZE_STRING);
     // user has not entered a string and there is 'none' as kind of search
     if ($searchsubmit == 'none' && $kind == 'none') {
         // return search form template
         return $this->searchRedirect();
     } else {
         if ($searchsubmit != 'none' && $kind == 'none') {
             $searchstring = $this->request->getPost()->filter('searchstring', '', FILTER_SANITIZE_STRING);
             if ($searchstring == '') {
                 $url = ModUtil::url($this->name, 'search', 'modulesearch');
                 return LogUtil::registerError(__('You have to enter a string!', $dom), null, $url);
             } else {
                 $args['searchstring'] = $searchstring;
                 $args['searchoptions'] = $searchoptions;
                 $args['searchplace'] = $searchplace;
                 $args['resultorder'] = $resultorder;
                 $args['kind'] = $kind;
             }
         }
         if ($searchsubmit == 'none' && $kind != 'none') {
             $args['kind'] = $kind;
         }
     }
     return ModUtil::apiFunc($this->name, 'search', 'moduleSearch', $args);
 }
Exemple #18
0
 public function getDataFromInputPostProcess($data = null)
 {
     if (!$data) {
         $data =& $this->_objData;
     }
     if (!$data) {
         return $data;
     }
     if (isset($data['status'])) {
         $data['status'] = 'A';
     } else {
         $data['status'] = 'I';
     }
     if (!isset($data['is_locked'])) {
         $data['is_locked'] = 0;
     }
     if (!isset($data['is_leaf'])) {
         $data['is_leaf'] = 0;
     }
     $languages = ZLanguage::getInstalledLanguages();
     foreach ($languages as $lang) {
         if (!isset($data['display_name'][$lang]) || !$data['display_name'][$lang]) {
             $data['display_name'][$lang] = $data['name'];
         }
     }
     $this->_objData = $data;
     return $data;
 }
Exemple #19
0
    /**
     * Render and display the specified legal document, or redirect to the specified custom URL if it exists.
     *
     * If a custom URL for the legal document exists, as specified by the module variable identified by $customUrlKey, then
     * this function will redirect the user to that URL.
     *
     * If no custom URL exists, then this function will render and return the appropriate template for the legal document, as
     * specified by $documentName. If the legal document
     *
     * @param string $documentName      The "name" of the document, as specified by the names of the user and text template
     *                                      files in the format 'legal_user_documentname.tpl' and 'legal_text_documentname.tpl'.
     * @param string $accessInstanceKey The string used in the instance_right part of the permission access key for this document.
     * @param string $activeFlagKey     The string used to name the module variable that indicates whether this legal document is
     *                                      active or not; typically this is a constant from {@link Legal_Constant}, such as
     *                                      {@link Legal_Constant::MODVAR_LEGALNOTICE_ACTIVE}.
     * @param string $customUrlKey      The string used to name the module variable that contains a custom static URL for the
     *                                      legal document; typically this is a constant from {@link Legal_Constant}, such as
     *                                      {@link Legal_Constant::MODVAR_TERMS_URL}.
     *
     * @return string HTML output string
     *
     * @throws Zikula_Exception_Forbidden Thrown if the user does not have the appropriate access level for the function.
     */
    private function renderDocument($documentName, $accessInstanceKey, $activeFlagKey, $customUrlKey)
    {
        // Security check
        if (!SecurityUtil::checkPermission($this->name . '::' . $accessInstanceKey, '::', ACCESS_OVERVIEW)) {
            throw new Zikula_Exception_Forbidden();
        }

        if (!$this->getVar($activeFlagKey)) {
            return $this->view->fetch('legal_user_policynotactive.tpl');
        } else {
            $customUrl = $this->getVar($customUrlKey, '');
            if (empty($customUrl)) {
                // work out the template path
                $template = "legal_user_{$documentName}.tpl";

                // get the current users language
                $languageCode = ZLanguage::transformFS(ZLanguage::getLanguageCode());

                if (!$this->view->template_exists("{$languageCode}/legal_text_{$documentName}.tpl")) {
                    $languageCode = 'en';
                }

                return $this->view->assign('languageCode', $languageCode)
                        ->fetch($template);
            } else {
                $this->redirect($customUrl);
            }
        }
    }
Exemple #20
0
 public function handleCommand(Zikula_Form_View $view, &$args)
 {
     if (!SecurityUtil::checkPermission('Content:page:', '::', ACCESS_ADD)) {
         throw new Zikula_Exception_Forbidden($this->__('Error! You have not been granted access to create pages.'));
     }
     if ($args['commandName'] == 'create') {
         $pageData = $this->view->getValues();
         $validators = $this->notifyHooks(new Zikula_ValidationHook('content.ui_hooks.pages.validate_edit', new Zikula_Hook_ValidationProviders()))->getValidators();
         if (!$validators->hasErrors() && $this->view->isValid()) {
             $id = ModUtil::apiFunc('Content', 'Page', 'newPage', array('page' => $pageData, 'pageId' => $this->pageId, 'location' => $this->location));
             if ($id === false) {
                 return false;
             }
             // notify any hooks they may now commit the as the original form has been committed.
             $objectUrl = new Zikula_ModUrl('Content', 'user', 'view', ZLanguage::getLanguageCode(), array('pid' => $this->pageId));
             $this->notifyHooks(new Zikula_ProcessHook('content.ui_hooks.pages.process_edit', $this->pageId, $objectUrl));
         } else {
             return false;
         }
         $url = ModUtil::url('Content', 'admin', 'editPage', array('pid' => $id));
     } else {
         if ($args['commandName'] == 'cancel') {
             $id = null;
             $url = ModUtil::url('Content', 'admin', 'main');
         }
     }
     return $this->view->redirect($url);
 }
/**
* Smarty modifier to get the respective status text
*
* Example
*   <!--[$article.published_status|news_getstatustext]-->
* 
* @author       Mateo Tibaquira [mateo]
* @since        17/11/2009
* @param        int      $status       The status to transform
* @return       string   the modified output
*/
function smarty_modifier_news_getstatustext($status)
{
    $dom    = ZLanguage::getModuleDomain('News');
    $output = __('Unknown status', $dom);

    switch ($status)
    {
        case 0:
            $output = __('Published', $dom);
            break;

        case 1:
            $output = __('Rejected', $dom);
            break;

        case 2:
            $output = __('Pending Review', $dom);
            break;

        case 3:
            $output = __('Archived', $dom);
            break;

        case 4:
            $output = __('Draft', $dom);
            break;
    }

    return $output;
}
 /**
  * Post constructor hook.
  *
  * @return void
  */
 public function setup()
 {
     $this->view = \Zikula_View::getInstance(self::MODULENAME, false);
     // set caching off
     $this->_em = \ServiceUtil::get('doctrine.entitymanager');
     $this->domain = \ZLanguage::getModuleDomain(self::MODULENAME);
 }
/**
 * User category selector.
 *
 * Available parameters:
 *   - btnText:  If set, the results are assigned to the corresponding variable instead of printed out
 *   - cid:      category ID
 *
 * Example
 * {selector_user_category cid="1" assign="category"}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string HTML code of the selector.
 */
function smarty_function_selector_user_category($params, Zikula_View $view)
{
    $field = isset($params['field']) ? $params['field'] : 'id';
    $selectedValue = isset($params['selectedValue']) ? $params['selectedValue'] : 0;
    $defaultValue = isset($params['defaultValue']) ? $params['defaultValue'] : 0;
    $defaultText = isset($params['defaultText']) ? $params['defaultText'] : '';
    $lang = isset($params['lang']) ? $params['lang'] : ZLanguage::getLanguageCode();
    $name = isset($params['name']) ? $params['name'] : 'defautlselectorname';
    $recurse = isset($params['recurse']) ? $params['recurse'] : true;
    $relative = isset($params['relative']) ? $params['relative'] : true;
    $includeRoot = isset($params['includeRoot']) ? $params['includeRoot'] : false;
    $includeLeaf = isset($params['includeLeaf']) ? $params['includeLeaf'] : true;
    $all = isset($params['all']) ? $params['all'] : false;
    $displayPath = isset($params['displayPath']) ? $params['displayPath'] : false;
    $attributes = isset($params['attributes']) ? $params['attributes'] : null;
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $editLink = isset($params['editLink']) ? $params['editLink'] : true;
    $submit = isset($params['submit']) ? $params['submit'] : false;
    $multipleSize = isset($params['multipleSize']) ? $params['multipleSize'] : 1;
    $doReplaceRootCat = false;
    $userCats = ModUtil::apiFunc('ZikulaCategoriesModule', 'user', 'getusercategories', array('returnCategory' => 1, 'relative' => $relative));
    $html = CategoryUtil::getSelector_Categories($userCats, $field, $selectedValue, $name, $defaultValue, $defaultText, $submit, $displayPath, $doReplaceRootCat, $multipleSize);
    if ($editLink && $allowUserEdit && UserUtil::isLoggedIn() && SecurityUtil::checkPermission('ZikulaCategoriesModule::', "{$category['id']}::", ACCESS_EDIT)) {
        $url = ModUtil::url('ZikulaCategoriesModule', 'user', 'edituser');
        $html .= "&nbsp;&nbsp;<a href=\"{$url}\">" . __('Edit sub-categories') . '</a>';
    }
    if ($assign) {
        $view->assign($assign, $html);
    } else {
        return $html;
    }
}
 public function __construct(EntityManagerInterface $entityManager, RequestStack $requestStack, EngineInterface $renderEngine)
 {
     $this->entityManager = $entityManager;
     $this->requestStack = $requestStack;
     $this->renderEngine = $renderEngine;
     $this->domain = \ZLanguage::getModuleDomain('CmfcmfMediaModule');
 }
Exemple #25
0
 /**
  * Check if an upload file meets all validation criteria.
  *
  * @param array $file Reference to data of uploaded file.
  *
  * @return boolean true if file is valid else false
  */
 protected function validateFileUpload($file)
 {
     $dom = ZLanguage::getModuleDomain('MUBoard');
     // check if a file has been uploaded properly without errors
     if (!is_array($file) || is_array($file) && $file['error'] != '0') {
         if (is_array($file)) {
             return $this->handleError($file);
         }
         return LogUtil::registerError(__('Error! No file found.', $dom));
     }
     // extract file extension
     $fileName = $file['name'];
     $extensionarr = explode('.', $fileName);
     $extension = strtolower($extensionarr[count($extensionarr) - 1]);
     // validate extension
     $isValidExtension = $this->isAllowedFileExtension($objectType, $fieldName, $extension);
     if ($isValidExtension === false) {
         return LogUtil::registerError(__('Error! This file type is not allowed. Please choose another file format.', $dom));
     }
     // validate image file
     $imgInfo = array();
     $isImage = in_array($extension, $this->imageFileTypes);
     if ($isImage) {
         $imgInfo = getimagesize($file['tmp_name']);
         if (!is_array($imgInfo) || !$imgInfo[0] || !$imgInfo[1]) {
             return LogUtil::registerError(__('Error! This file type seems not to be a valid image.', $dom));
         }
     }
     return true;
 }
Exemple #26
0
 /**
  * Update Config
  */
 public function updateconfig()
 {
     // Confirm the forms authorisation key
     $this->checkCsrfToken();
     // Security check
     $this->throwForbiddenUnless(SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN));
     // retrieve the associative preferences array
     $prefs = FormUtil::getPassedValue('preferences', null, 'POST');
     $languages = ZLanguage::getInstalledLanguages();
     // now for each perference entry, set the appropriate module variable
     foreach ($languages as $language) {
         ModUtil::setVar('AddressBook', 'abtitle_' . $language, isset($prefs['abtitle_' . $language]) ? $prefs['abtitle_' . $language] : '');
         ModUtil::setVar('AddressBook', 'abmetatitle_' . $language, isset($prefs['abmetatitle_' . $language]) ? $prefs['abmetatitle_' . $language] : '');
         ModUtil::setVar('AddressBook', 'abmetadescription_' . $language, isset($prefs['abmetadescription_' . $language]) ? $prefs['abmetadescription_' . $language] : '');
         ModUtil::setVar('AddressBook', 'abmetakeyword_' . $language, isset($prefs['abmetakeyword_' . $language]) ? $prefs['abmetakeyword_' . $language] : '');
         ModUtil::setVar('AddressBook', 'custom_tab_' . $language, isset($prefs['custom_tab_' . $language]) ? $prefs['custom_tab_' . $language] : '');
     }
     ModUtil::setVar('AddressBook', 'globalprotect', isset($prefs['globalprotect']) ? $prefs['globalprotect'] : 0);
     ModUtil::setVar('AddressBook', 'allowprivate', isset($prefs['allowprivate']) ? $prefs['allowprivate'] : 0);
     ModUtil::setVar('AddressBook', 'use_prefix', isset($prefs['use_prefix']) ? $prefs['use_prefix'] : 0);
     ModUtil::setVar('AddressBook', 'use_img', isset($prefs['use_img']) ? $prefs['use_img'] : 0);
     ModUtil::setVar('AddressBook', 'images_dir', isset($prefs['images_dir']) ? $prefs['images_dir'] : 'userdata/Addressbook');
     ModUtil::setVar('AddressBook', 'images_manager', isset($prefs['images_manager']) ? $prefs['images_manager'] : 'kcfinder');
     ModUtil::setVar('AddressBook', 'google_api_key', isset($prefs['google_api_key']) ? $prefs['google_api_key'] : '');
     ModUtil::setVar('AddressBook', 'google_zoom', isset($prefs['google_zoom']) ? $prefs['google_zoom'] : 15);
     ModUtil::setVar('AddressBook', 'itemsperpage', $prefs['itemsperpage'] > 1 ? $prefs['itemsperpage'] : 30);
     ModUtil::setVar('AddressBook', 'addressbooktype', isset($prefs['addressbooktype']) ? $prefs['addressbooktype'] : 1);
     ModUtil::setVar('AddressBook', 'showabcfilter', isset($prefs['showabcfilter']) ? $prefs['showabcfilter'] : 0);
     // redirect back to to main admin page
     LogUtil::registerStatus($this->__('Done! Configuration saved.'));
     return System::redirect(ModUtil::url('AddressBook', 'admin', 'main'));
 }
Exemple #27
0
 /**
  * modify block settings
  */
 public function modify($blockinfo)
 {
     // get variable values from database
     $vars = BlockUtil::varsFromContent($blockinfo['content']);
     // installed languages
     $languages = ZLanguage::getInstalledLanguageNames();
     // set default values - block
     if (!isset($vars['block_template'])) {
         $vars['block_template'] = 'marquee.tpl';
     }
     if (!isset($vars['block_title']) || !is_array($vars['block_title'])) {
         $vars['block_title'] = array();
     }
     foreach (array_keys($languages) as $lang) {
         if (!array_key_exists($lang, $vars['block_title'])) {
             $vars['block_title'][$lang] = '';
         }
     }
     if (!isset($vars['block_wrap'])) {
         $vars['block_wrap'] = true;
     }
     // set default values - content
     if (!isset($vars['marquee_content']) || !is_array($vars['marquee_content'])) {
         $vars['marquee_content'] = array();
     }
     foreach (array_keys($languages) as $lang) {
         if (!array_key_exists($lang, $vars['marquee_content'])) {
             $vars['marquee_content'][$lang] = '';
         }
     }
     if (!isset($vars['marquee_content_editor'])) {
         $vars['marquee_content_editor'] = true;
     }
     if (!isset($vars['marquee_duration'])) {
         $vars['marquee_duration'] = 15000;
     }
     if (!isset($vars['marquee_gap'])) {
         $vars['marquee_gap'] = 200;
     }
     if (!isset($vars['marquee_delayBeforeStart'])) {
         $vars['marquee_delayBeforeStart'] = 0;
     }
     if (!isset($vars['marquee_direction'])) {
         $vars['marquee_direction'] = 'left';
     }
     if (!isset($vars['marquee_duplicated'])) {
         $vars['marquee_duplicated'] = true;
     }
     if (!isset($vars['marquee_pauseOnHover'])) {
         $vars['marquee_pauseOnHover'] = true;
     }
     if (!isset($vars['marquee_pauseOnCycle'])) {
         $vars['marquee_pauseOnCycle'] = false;
     }
     $this->view->assign('vars', $vars);
     $this->view->assign('bid', $blockinfo['bid']);
     $this->view->assign('languages', $languages);
     return $this->view->fetch('blocks/marquee_modify.tpl');
 }
Exemple #28
0
 /**
  * Performs the actual search processing.
  */
 public function search($args)
 {
     ModUtil::dbInfoLoad('Search');
     $dbtables = DBUtil::getTables();
     $pageTable = $dbtables['content_page'];
     $pageColumn = $dbtables['content_page_column'];
     $contentTable = $dbtables['content_content'];
     $contentColumn = $dbtables['content_content_column'];
     $contentSearchTable = $dbtables['content_searchable'];
     $contentSearchColumn = $dbtables['content_searchable_column'];
     $translatedPageTable = $dbtables['content_translatedpage'];
     $translatedPageColumn = $dbtables['content_translatedpage_column'];
     $sessionId = session_id();
     // check whether we need to search also in translated content
     $multilingual = System::getVar('multilingual');
     $currentLanguage = ZLanguage::getLanguageCode();
     $searchWhereClauses = array();
     $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($pageColumn['title']), $pageColumn['language']) . ')';
     if ($multilingual) {
         $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($translatedPageColumn['title']), $translatedPageColumn['language']) . ')';
     }
     $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($contentSearchColumn['text']), $contentSearchColumn['language']) . ')';
     // add default filters
     $whereClauses = array();
     $whereClauses[] = '(' . implode(' OR ', $searchWhereClauses) . ')';
     $whereClauses[] = $pageColumn['active'] . ' = 1';
     $whereClauses[] = "({$pageColumn['activeFrom']} IS NULL OR {$pageColumn['activeFrom']} <= NOW())";
     $whereClauses[] = "({$pageColumn['activeTo']} IS NULL OR {$pageColumn['activeTo']} >= NOW())";
     $whereClauses[] = $contentColumn['active'] . ' = 1';
     $whereClauses[] = $contentColumn['visiblefor'] . (UserUtil::isLoggedIn() ? ' <= 1' : ' >= 1');
     $titleFields = $pageColumn['title'];
     $additionalJoins = '';
     if ($multilingual) {
         // if searching in non-default languages, we need the translated title
         $titleFields .= ', ' . $translatedPageColumn['title'] . ' AS translatedTitle';
         // join also the translation table if required
         $additionalJoins = "LEFT OUTER JOIN {$translatedPageTable} ON {$translatedPageColumn['pageId']} = {$pageColumn['id']} AND {$translatedPageColumn['language']} = '{$currentLanguage}'";
         // prevent content snippets in other languages
         $whereClauses[] = $contentSearchColumn['language'] . ' = \'' . $currentLanguage . '\'';
     }
     $where = implode(' AND ', $whereClauses);
     $sql = "\n            SELECT DISTINCT {$titleFields},\n            {$contentSearchColumn['text']} AS description,\n            {$pageColumn['id']} AS pageId,\n            {$pageColumn['cr_date']} AS createdDate\n            FROM {$pageTable}\n            JOIN {$contentTable}\n            ON {$contentColumn['pageId']} = {$pageColumn['id']}\n            JOIN {$contentSearchTable}\n            ON {$contentSearchColumn['contentId']} = {$contentColumn['id']}\n            {$additionalJoins}\n            WHERE {$where}\n        ";
     $result = DBUtil::executeSQL($sql);
     if (!$result) {
         return LogUtil::registerError($this->__('Error! Could not load items.'));
     }
     $objectArray = DBUtil::marshallObjects($result);
     foreach ($objectArray as $object) {
         $pageTitle = $object['page_title'];
         if ($object['translatedTitle'] != '') {
             $pageTitle = $object['translatedTitle'];
         }
         $searchItemData = array('title' => $pageTitle, 'text' => $object['description'], 'extra' => $object['pageId'], 'created' => $object['createdDate'], 'module' => 'Content', 'session' => $sessionId);
         if (!\DBUtil::insertObject($searchItemData, 'search_result')) {
             return \LogUtil::registerError($this->__('Error! Could not save the search results.'));
         }
     }
     return true;
 }
Exemple #29
0
    /**
     * Retrieves default configuration array for HTML Purifier.
     *
     * @return array HTML Purifier default configuration settings.
     */
    private static function _getpurifierdefaultconfig()
    {
        $purifierDefaultConfig = HTMLPurifier_Config::createDefault();
        $purifierDefaultConfigValues = $purifierDefaultConfig->def->defaults;

        $config = array();

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

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

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

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

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

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

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

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

        return $config;
    }
Exemple #30
0
 /**
  * Collect available actions for this entity.
  */
 protected function prepareItemActions()
 {
     if (!empty($this->_actions)) {
         return;
     }
     $currentType = FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
     $currentFunc = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING);
     $dom = ZLanguage::getModuleDomain('Reviews');
     if ($currentType == 'admin') {
         if (in_array($currentFunc, array('main', 'view'))) {
             $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'display', 'arguments' => array('ot' => 'review', 'id' => $this['id'], 'slug' => $this->slug)), 'icon' => 'preview', 'linkTitle' => __('Open preview page', $dom), 'linkText' => __('Preview', $dom));
             $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'display', 'arguments' => array('ot' => 'review', 'id' => $this['id'], 'slug' => $this->slug)), 'icon' => 'display', 'linkTitle' => str_replace('"', '', $this->getTitleFromDisplayPattern()), 'linkText' => __('Details', $dom));
         }
         if (in_array($currentFunc, array('main', 'view', 'display'))) {
             $component = 'Reviews:Review:';
             $instance = $this->id . '::';
             if (SecurityUtil::checkPermission($component, $instance, ACCESS_EDIT)) {
                 $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'edit', 'arguments' => array('ot' => 'review', 'id' => $this['id'])), 'icon' => 'edit', 'linkTitle' => __('Edit', $dom), 'linkText' => __('Edit', $dom));
                 $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'edit', 'arguments' => array('ot' => 'review', 'astemplate' => $this['id'])), 'icon' => 'saveas', 'linkTitle' => __('Reuse for new item', $dom), 'linkText' => __('Reuse', $dom));
             }
             if (SecurityUtil::checkPermission($component, $instance, ACCESS_DELETE)) {
                 $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'delete', 'arguments' => array('ot' => 'review', 'id' => $this['id'])), 'icon' => 'delete', 'linkTitle' => __('Delete', $dom), 'linkText' => __('Delete', $dom));
             }
         }
         if ($currentFunc == 'display') {
             $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'view', 'arguments' => array('ot' => 'review')), 'icon' => 'back', 'linkTitle' => __('Back to overview', $dom), 'linkText' => __('Back to overview', $dom));
         }
     }
     if ($currentType == 'user') {
         if (in_array($currentFunc, array('main', 'view'))) {
             if (ModUtil::getVar('Reviews', 'addcategorytitletopermalink') == 1 && ModUtil::getVar('Reviews', 'enablecategorization') == 1) {
                 $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'display', 'arguments' => array('ot' => 'review', 'id' => $this['id'], 'slug' => $this->slug)), 'icon' => 'display', 'linkTitle' => str_replace('"', '', $this->getTitleFromDisplayPattern()), 'linkText' => __('Details', $dom));
             } else {
                 $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'display', 'arguments' => array('ot' => 'review', 'id' => $this['id'], 'slug' => $this->slug)), 'icon' => 'display', 'linkTitle' => str_replace('"', '', $this->getTitleFromDisplayPattern()), 'linkText' => __('Details', $dom));
             }
         }
         /* if (in_array($currentFunc, array('main', 'view', 'display'))) {
             $component = 'Reviews:Review:';
            $instance = $this->id . '::';
            if (SecurityUtil::checkPermission($component, $instance, ACCESS_EDIT)) {
            $this->_actions[] = array(
                    'url' => array('type' => 'user', 'func' => 'edit', 'arguments' => array('ot' => 'review', 'id' => $this['id'])),
                    'icon' => 'edit',
                    'linkTitle' => __('Edit', $dom),
                    'linkText' => __('Edit', $dom)
            );
            $this->_actions[] = array(
                    'url' => array('type' => 'user', 'func' => 'edit', 'arguments' => array('ot' => 'review', 'astemplate' => $this['id'])),
                    'icon' => 'saveas',
                    'linkTitle' => __('Reuse for new item', $dom),
                    'linkText' => __('Reuse', $dom)
            );
            }
            } */
         if ($currentFunc == 'display') {
             $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'view', 'arguments' => array('ot' => 'review')), 'icon' => 'back', 'linkTitle' => __('Back to overview', $dom), 'linkText' => __('Back to overview', $dom));
         }
     }
 }