Exemple #1
0
 /**
  * Handles an error.
  *
  * @param integer $errno      Number of the error.
  * @param string  $errstr     Error message.
  * @param string  $errfile    Filename where the error occurred.
  * @param integer $errline    Line of the error.
  * @param string  $errcontext Context of the error.
  *
  * @return boolean
  */
 public function handler($errno, $errstr, $errfile = '', $errline = 0, $errcontext = null)
 {
     $this->setupHandler($errno, $errstr, $errfile, $errline, $errcontext);
     // Notify all loggers
     $this->eventManager->notify($this->event->setArgs(array('trace' => $this->trace, 'type' => $this->type, 'errno' => $this->errno, 'errstr' => $this->errstr, 'errfile' => $this->errfile, 'errline' => $this->errline, 'errcontext' => $this->errcontext)));
     if ($this->isPHPError() && System::isDevelopmentMode() && $this->showPHPErrorHandler()) {
         // allow PHP to return error
         $this->resetHandler();
         return false;
     }
     if (!$this->isDisplayErrorTemplate()) {
         // prevent PHP from handling the event after we return
         $this->resetHandler();
         return true;
     }
     // obey reporing level
     if (abs($this->getType()) > $this->serviceManager['log.display_level']) {
         return false;
     }
     // unless in development mode, exit.
     if (!$this->serviceManager['log.display_template']) {
         return false;
     }
     // if we get this far, display template
     echo ModUtil::func('Errors', 'user', 'system', array('type' => $this->errno, 'message' => $this->errstr, 'file' => $this->errfile, 'line' => $this->errline));
     Zikula_View_Theme::getInstance()->themefooter();
     System::shutDown();
 }
Exemple #2
0
 /**
  * Sets a theme variable.
  *
  * @param string $name  Variable name.
  * @param mixed  $value Value to set.
  *
  * @return void
  */
 public static function setVar($name, $value)
 {
     // if no variable name is present does nothing
     if (!$name) {
         return;
     }
     Zikula_View_Theme::getInstance()->assign($name, $value);
 }
Exemple #3
0
 /**
  * Clear all compiled and cache directories.
  *
  * This function simply calls the theme and renderer modules to refresh the entire site.
  *
  * @return boolean true.
  */
 public function clearallcompiledcaches()
 {
     Zikula_View_Theme::getInstance()->clear_all_cache();
     Zikula_View_Theme::getInstance()->clear_compiled();
     Zikula_View_Theme::getInstance()->clear_cssjscombinecache();
     Zikula_View::getInstance()->clear_all_cache();
     Zikula_View::getInstance()->clear_compiled();
     return true;
 }
 /**
  * Event: 'frontcontroller.predispatch'.
  *
  * @param Zikula_Event $event
  *
  * @return void
  */
 public function sessionExpired(Zikula_Event $event)
 {
     if (SessionUtil::hasExpired()) {
         // Session has expired, display warning
         header('HTTP/1.0 403 Access Denied');
         echo ModUtil::apiFunc('Users', 'user', 'expiredsession');
         Zikula_View_Theme::getInstance()->themefooter();
         System::shutdown();
     }
 }
Exemple #5
0
 /**
  * Clear cache for given item. Can be called from other modules to clear an item cache.
  *
  * @param $args['ot']   the treated object type
  * @param $args['item'] the actual object
  */
 public function clearItemCache(array $args = array())
 {
     if (!isset($args['ot']) || !isset($args['item'])) {
         return;
     }
     $objectType = $args['ot'];
     $item = $args['item'];
     $controllerHelper = new Reviews_Util_Controller($this->serviceManager);
     $utilArgs = array('api' => 'cache', 'action' => 'clearItemCache');
     if (!in_array($objectType, $controllerHelper->getObjectTypes('controllerAction', $utilArgs))) {
         return;
     }
     if ($item && !is_array($item) && !is_object($item)) {
         $item = ModUtil::apiFunc($this->name, 'selection', 'getEntity', array('ot' => $objectType, 'id' => $item, 'useJoins' => false, 'slimMode' => true));
     }
     if (!$item) {
         return;
     }
     // create full identifier (considering composite keys)
     $idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $objectType));
     $instanceId = '';
     foreach ($idFields as $idField) {
         if (!empty($instanceId)) {
             $instanceId .= '_';
         }
         $instanceId .= $item[$idField];
     }
     // Clear View_cache
     $cacheIds = array();
     $cacheIds[] = 'main';
     $cacheIds[] = 'view';
     $cacheIds[] = $instanceId;
     $view = Zikula_View::getInstance('Reviews');
     foreach ($cacheIds as $cacheId) {
         $view->clear_cache(null, $cacheId);
     }
     // Clear Theme_cache
     $cacheIds = array();
     $cacheIds[] = 'homepage';
     // for homepage (can be assigned in the Settings module)
     $cacheIds[] = 'Reviews/user/main';
     // main function
     $cacheIds[] = 'Reviews/user/view/' . $objectType;
     // view function (list views)
     $cacheIds[] = 'Reviews/user/display/' . $objectType . '|' . $instanceId;
     // display function (detail views)
     $theme = Zikula_View_Theme::getInstance();
     $theme->clear_cacheid_allthemes($cacheIds);
 }
 public function renderTheme(FilterResponseEvent $event)
 {
     if ($event->getRequestType() !== HttpKernel::MASTER_REQUEST) {
         return;
     }
     $response = $event->getResponse();
     if ($response instanceof RedirectResponse || $response instanceof PlainResponse || $response instanceof AbstractBaseResponse) {
         // dont theme redirects, plain responses or Ajax responses
         return;
     }
     $content = $response->getContent();
     $code = $response->getStatusCode();
     $themedContent = \Zikula_View_Theme::getInstance()->themefooter($content);
     $themeResponse = new Response($themedContent, $code);
     $event->setResponse($themeResponse);
 }
/**
 * BlankTheme plugin to display the user navigation submenu.
 *
 * Available parameters:
 *  - id           (string) ID of the wrapper div (default: 'nav_main')
 *  - current      (string) Current screen ID (.ini current value or module name) (optional)
 *  - currentclass (string) CSS class name of the current tab, list item (default: 'current')
 *  - span         (bool)   Flag to enable SPAN wrappers on the links text, useful for sliding doors (default: false)
 *
 * Example:
 *  {bt_usersublinks id='nav' current='home' currentclass='myActiveClass'}
 *
 * @author Mateo Tibaquirá
 * @since  19/06/11
 *
 * @param array             $params All parameters passed to this function from the template.
 * @param Zikula_View_Theme &$view  Reference to the View_Theme object.
 *
 * @return string User submenu output.
 */
function smarty_function_bt_usersublinks($params, Zikula_View_Theme &$view)
{
    $dom = ZLanguage::getThemeDomain('BlankTheme');

    $id = isset($params['id']) ? $params['id'] : 'nav_sub';
    if (!isset($params['current'])) {
        $current = $view->getTplVar('current') ? $view->getTplVar('current') : $view->getToplevelmodule();
    } else {
        $current = $params['current'];
    }
    $currentclass = isset($params['currentclass']) ? $params['currentclass'] : 'current';
    $span = isset($params['span']) ? (bool)$params['span'] : false;

    $currentsub = $current.'-'.$view->getTplVar('type').'-'.$view->getTplVar('func');

    /*** Build the submenu-array ***/
    $menu = array();

    // dummy example links
    $menu['home'][] = array(
                          '',                       // page id : current-type-func
                          __('Home Sublink', $dom), // translatable title
                          '',                       // translatable description
                          '#'                       // link
                      );

    $menu['home'][] = array(
                          '',
                          __('Second Sublink', $dom),
                          '',
                          '#'
                      );

    // render the submenu
    $output = '';

    if (isset($menu[$current])) {
        $output .= '<div id="'.$id.'"><ul>';
        foreach ($menu[$current] as $option) {
            $output .= bt_usersublinks_drawmenu($option, $currentsub, $currentclass, $span);
        }
        $output .= '</ul></div>';
    }

    return $output;
}
Exemple #8
0
function cronShutdown() {
    Zikula_View_Theme::getInstance()->clear_all_cache();
    Zikula_View_Theme::getInstance()->clear_compiled();
    Zikula_View_Theme::getInstance()->clear_cssjscombinecache();
    Zikula_View::getInstance()->clear_all_cache();
    Zikula_View::getInstance()->clear_compiled();

    System::shutdown();

}
Exemple #9
0
 /**
  * Update block settings
  *
  * @param array $blockInfo blockinfo array
  *
  * @return array $blockinfo
  */
 public function update($blockInfo)
 {
     $vars = BlockUtil::varsFromContent($blockInfo['content']);
     // write back the new contents
     $blockInfo['content'] = BlockUtil::varsToContent($vars);
     // clear the block cache
     $this->view->clear_cache(null, $blockInfo['bkey'] . '/bid' . $blockInfo['bid']);
     // and clear the theme cache
     Zikula_View_Theme::getInstance()->clear_cache();
     return $blockInfo;
 }
Exemple #10
0
 /**
  * Initialise Zikula.
  *
  * Carries out a number of initialisation tasks to get Zikula up and
  * running.
  *
  * @param integer $stage Stage to load.
  *
  * @return boolean True initialisation successful false otherwise.
  */
 public function onInit(GetResponseEvent $event)
 {
     if ($event->getRequestType() === HttpKernelInterface::SUB_REQUEST) {
         return;
     }
     $this->dispatcher = $event->getDispatcher();
     $this->stage = $stage = self::STAGE_ALL;
     $coreInitEvent = new GenericEvent($this);
     $coreInitEvent['request'] = $event->getRequest();
     // store the load stages in a global so other API's can check whats loaded
     $this->dispatcher->dispatch(CoreEvents::PREINIT, new GenericEvent($this));
     //        // Initialise and load configuration
     //        if ($stage & self::STAGE_CONFIG) {
     //            // error reporting
     //            if (!\System::isInstalling()) {
     //                // this is here because it depends on the config.php loading.
     //                $event = new GenericEvent(null, array('stage' => $stage));
     //                $this->dispatcher->dispatch(CoreEvents::ERRORREPORTING, $event);
     //            }
     //
     //            // initialise custom event listeners from config.php settings
     //            $coreInitEvent->setArg('stage', self::STAGE_CONFIG);
     //            $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     //        }
     //        // Check that Zikula is installed before continuing
     //        if (\System::getVar('installed') == 0 && !\System::isInstalling()) {
     //            $response = new RedirectResponse(\System::getBaseUrl().'install.php?notinstalled');
     //            $response->send();
     //            \System::shutdown();
     //        }
     if ($stage & self::STAGE_DB) {
         try {
             $dbEvent = new GenericEvent();
             $this->dispatcher->dispatch('doctrine.init_connection', $dbEvent);
             $dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
             $this->dispatcher->dispatch(CoreEvents::INIT, $dbEvent);
         } catch (\PDOException $e) {
             if (!\System::isInstalling()) {
                 header('HTTP/1.1 503 Service Unavailable');
                 require_once \System::getSystemErrorTemplate('dbconnectionerror.tpl');
                 \System::shutDown();
             } else {
                 return false;
             }
         }
     }
     if ($stage & self::STAGE_TABLES) {
         // Initialise dbtables
         \ModUtil::initCoreVars();
         \ModUtil::dbInfoLoad('SettingsModule', 'SettingsModule');
         \ModUtil::dbInfoLoad('ThemeModule', 'ThemeModule');
         \ModUtil::dbInfoLoad('UsersModule', 'UsersModule');
         \ModUtil::dbInfoLoad('GroupsModule', 'GroupsModule');
         \ModUtil::dbInfoLoad('PermissionsModule', 'PermissionsModule');
         \ModUtil::dbInfoLoad('CategoriesModule', 'CategoriesModule');
         if (!\System::isInstalling()) {
             \ModUtil::registerAutoloaders();
         }
         $coreInitEvent->setArg('stage', self::STAGE_TABLES);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     if ($stage & self::STAGE_SESSIONS) {
         \SessionUtil::requireSession();
         $coreInitEvent->setArg('stage', self::STAGE_SESSIONS);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
     // start block
     if ($stage & self::STAGE_LANGS) {
         $lang = \ZLanguage::getInstance();
     }
     if ($stage & self::STAGE_DECODEURLS) {
         \System::queryStringDecode();
         $coreInitEvent->setArg('stage', self::STAGE_DECODEURLS);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     if ($stage & self::STAGE_LANGS) {
         $lang->setup();
         $coreInitEvent->setArg('stage', self::STAGE_LANGS);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     // end block
     if ($stage & self::STAGE_MODS) {
         // Set compression on if desired
         if (\System::getVar('UseCompression') == 1) {
             //ob_start("ob_gzhandler");
         }
         \ModUtil::load('SecurityCenter');
         $coreInitEvent->setArg('stage', self::STAGE_MODS);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     if ($stage & self::STAGE_THEME) {
         // register default page vars
         \PageUtil::registerVar('title');
         \PageUtil::setVar('title', \System::getVar('defaultpagetitle'));
         \PageUtil::registerVar('keywords', true);
         \PageUtil::registerVar('stylesheet', true);
         \PageUtil::registerVar('javascript', true);
         \PageUtil::registerVar('jsgettext', true);
         \PageUtil::registerVar('body', true);
         \PageUtil::registerVar('header', true);
         \PageUtil::registerVar('footer', true);
         $theme = \Zikula_View_Theme::getInstance();
         // set some defaults
         // Metadata for SEO
         $this->container['zikula_view.metatags']['description'] = \System::getVar('defaultmetadescription');
         $this->container['zikula_view.metatags']['keywords'] = \System::getVar('metakeywords');
         $coreInitEvent->setArg('stage', self::STAGE_THEME);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     // check the users status, if not 1 then log him out
     if (\UserUtil::isLoggedIn()) {
         $userstatus = \UserUtil::getVar('activated');
         if ($userstatus != UsersConstant::ACTIVATED_ACTIVE) {
             \UserUtil::logout();
             // TODO - When getting logged out this way, the existing session is destroyed and
             //        then a new one is created on the reentry into index.php. The message
             //        set by the registerStatus call below gets lost.
             \LogUtil::registerStatus(__('You have been logged out.'));
             $response = new RedirectResponse(\ModUtil::url('Users', 'user', 'login'));
             $response->send();
             exit;
         }
     }
     if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) {
         $this->dispatcher->dispatch(CoreEvents::POSTINIT, new GenericEvent($this, array('stages' => $stage)));
     }
     $this->dispatcher->dispatch('frontcontroller.predispatch', new GenericEvent());
 }
Exemple #11
0
 /**
  * Initialise Zikula.
  *
  * Carries out a number of initialisation tasks to get Zikula up and
  * running.
  *
  * @param integer $stage Stage to load.
  *
  * @return boolean True initialisation successful false otherwise.
  */
 public function init($stage = self::STAGE_ALL)
 {
     $coreInitEvent = new Zikula_Event('core.init', $this);
     // store the load stages in a global so other API's can check whats loaded
     $this->stage = $this->stage | $stage;
     if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
         ModUtil::flushCache();
         System::flushCache();
         $this->eventManager->notify(new Zikula_Event('core.preinit', $this));
     }
     // Initialise and load configuration
     if ($stage & self::STAGE_CONFIG) {
         if (System::isLegacyMode()) {
             require_once 'lib/legacy/Compat.php';
         }
         // error reporting
         if (!System::isInstalling()) {
             // this is here because it depends on the config.php loading.
             $event = new Zikula_Event('setup.errorreporting', null, array('stage' => $stage));
             $this->eventManager->notify($event);
         }
         // initialise custom event listeners from config.php settings
         $coreInitEvent->setArg('stage', self::STAGE_CONFIG);
         $this->eventManager->notify($coreInitEvent);
     }
     // Check that Zikula is installed before continuing
     if (System::getVar('installed') == 0 && !System::isInstalling()) {
         System::redirect(System::getBaseUrl() . 'install.php?notinstalled');
         System::shutDown();
     }
     if ($stage & self::STAGE_DB) {
         try {
             $dbEvent = new Zikula_Event('core.init', $this, array('stage' => self::STAGE_DB));
             $this->eventManager->notify($dbEvent);
         } catch (PDOException $e) {
             if (!System::isInstalling()) {
                 header('HTTP/1.1 503 Service Unavailable');
                 require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
                 System::shutDown();
             } else {
                 return false;
             }
         }
     }
     if ($stage & self::STAGE_TABLES) {
         // Initialise dbtables
         ModUtil::dbInfoLoad('Extensions', 'Extensions');
         ModUtil::initCoreVars();
         ModUtil::dbInfoLoad('Settings', 'Settings');
         ModUtil::dbInfoLoad('Theme', 'Theme');
         ModUtil::dbInfoLoad('Users', 'Users');
         ModUtil::dbInfoLoad('Groups', 'Groups');
         ModUtil::dbInfoLoad('Permissions', 'Permissions');
         ModUtil::dbInfoLoad('Categories', 'Categories');
         if (!System::isInstalling()) {
             ModUtil::registerAutoloaders();
         }
         $coreInitEvent->setArg('stage', self::STAGE_TABLES);
         $this->eventManager->notify($coreInitEvent);
     }
     if ($stage & self::STAGE_SESSIONS) {
         SessionUtil::requireSession();
         $coreInitEvent->setArg('stage', self::STAGE_SESSIONS);
         $this->eventManager->notify($coreInitEvent);
     }
     // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
     // start block
     if ($stage & self::STAGE_LANGS) {
         $lang = ZLanguage::getInstance();
     }
     if ($stage & self::STAGE_DECODEURLS) {
         System::queryStringDecode();
         $coreInitEvent->setArg('stage', self::STAGE_DECODEURLS);
         $this->eventManager->notify($coreInitEvent);
     }
     if ($stage & self::STAGE_LANGS) {
         $lang->setup();
         $coreInitEvent->setArg('stage', self::STAGE_LANGS);
         $this->eventManager->notify($coreInitEvent);
     }
     // end block
     if ($stage & self::STAGE_MODS) {
         // Set compression on if desired
         if (System::getVar('UseCompression') == 1) {
             //ob_start("ob_gzhandler");
         }
         ModUtil::load('SecurityCenter');
         $coreInitEvent->setArg('stage', self::STAGE_MODS);
         $this->eventManager->notify($coreInitEvent);
     }
     if ($stage & self::STAGE_THEME) {
         // register default page vars
         PageUtil::registerVar('title');
         PageUtil::setVar('title', System::getVar('defaultpagetitle'));
         PageUtil::registerVar('keywords', true);
         PageUtil::registerVar('stylesheet', true);
         PageUtil::registerVar('javascript', true);
         PageUtil::registerVar('jsgettext', true);
         PageUtil::registerVar('body', true);
         PageUtil::registerVar('header', true);
         PageUtil::registerVar('footer', true);
         $theme = Zikula_View_Theme::getInstance();
         // set some defaults
         // Metadata for SEO
         $this->serviceManager['zikula_view.metatags']['description'] = System::getVar('defaultmetadescription');
         $this->serviceManager['zikula_view.metatags']['keywords'] = System::getVar('metakeywords');
         $coreInitEvent->setArg('stage', self::STAGE_THEME);
         $this->eventManager->notify($coreInitEvent);
     }
     // check the users status, if not 1 then log him out
     if (UserUtil::isLoggedIn()) {
         $userstatus = UserUtil::getVar('activated');
         if ($userstatus != Users_Constant::ACTIVATED_ACTIVE) {
             UserUtil::logout();
             // TODO - When getting logged out this way, the existing session is destroyed and
             //        then a new one is created on the reentry into index.php. The message
             //        set by the registerStatus call below gets lost.
             LogUtil::registerStatus(__('You have been logged out.'));
             System::redirect(ModUtil::url('Users', 'user', 'login'));
         }
     }
     if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) {
         $this->eventManager->notify(new Zikula_Event('core.postinit', $this, array('stages' => $stage)));
     }
 }
Exemple #12
0
/**
 * Clear the Zikula cache.
 *
 * This function clear the zikula cache.
 *
 * @return void
 */
function upgrade_clear_caches()
{
    Zikula_View_Theme::getInstance()->clear_all_cache();
    Zikula_View_Theme::getInstance()->clear_compiled();
    Zikula_View_Theme::getInstance()->clear_cssjscombinecache();
    Zikula_View::getInstance()->clear_all_cache();
    Zikula_View::getInstance()->clear_compiled();
}
Exemple #13
0
    public function update($blockinfo)
    {
        // Get current content
        $vars = BlockUtil::varsFromContent($blockinfo['content']);

        // alter the corresponding variable
        $vars['format'] = FormUtil::getPassedValue('format', 1, 'POST');

        // write back the new contents
        $blockinfo['content'] = BlockUtil::varsToContent($vars);

        // clear the block cache
        $this->view->clear_cache('theme_block_themeswitcher.tpl');

        // and clear the theme cache
        Zikula_View_Theme::getInstance()->clear_cache();

        return $blockinfo;
    }
Exemple #14
0
 public function __construct($theme)
 {
     parent::__construct(ServiceUtil::getManager(), $theme);
     LogUtil::log(__f('Warning! Class %1$s is deprecated. Please use %2$s instead.', array(__CLASS__ , 'Zikula_View_Theme')), E_USER_DEPRECATED);
 }
Exemple #15
0
    }
}
switch (true) {
    case $return === true:
        // prevent rendering of the theme.
        System::shutDown();
        break;
    case $httpCode == 403:
        if (!UserUtil::isLoggedIn()) {
            $url = ModUtil::url('Users', 'user', 'login', array('returnpage' => urlencode(System::getCurrentUri())));
            LogUtil::registerError(LogUtil::getErrorMsgPermission(), $httpCode, $url);
            System::shutDown();
        }
        // there is no break here deliberately.
    // there is no break here deliberately.
    case $return === false:
        if (!LogUtil::hasErrors()) {
            LogUtil::registerError(__f('Could not load the \'%1$s\' module at \'%2$s\'.', array($module, $func)), $httpCode, null);
        }
        echo ModUtil::func('Errors', 'user', 'main', array('message' => $message, 'exception' => $e));
        break;
    case $httpCode == 200:
        echo $return;
        break;
    default:
        LogUtil::registerError(__f('The \'%1$s\' module returned an error in \'%2$s\'.', array($module, $func)), $httpCode, null);
        echo ModUtil::func('Errors', 'user', 'main', array('message' => $message, 'exception' => $e));
        break;
}
Zikula_View_Theme::getInstance()->themefooter();
System::shutdown();
Exemple #16
0
 /**
  * Display a block based on the current theme.
  *
  * @param array $blockinfo Block info.
  *
  * @return string The rendered output.
  */
 public static function themeBlock($blockinfo)
 {
     static $themeinfo, $themedir, $upb, $downb;
     if (!isset($blockinfo['bid'])) {
         $blockinfo['bid'] = '';
     }
     if (!isset($blockinfo['title'])) {
         $blockinfo['title'] = '';
     }
     if (UserUtil::isLoggedIn() && ModUtil::getVar('ZikulaBlocksModule', 'collapseable') == 1 && isset($blockinfo['collapsable']) && $blockinfo['collapsable'] == '1') {
         if (!isset($themeinfo)) {
             $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
             $themedir = DataUtil::formatForOS($themeinfo['directory']);
         }
         // check for collapsable menus being enabled, and setup the collapsable menu image.
         if (!isset($upb)) {
             if (file_exists('themes/' . $themedir . '/images/upb.png')) {
                 $upb = '<img src="themes/' . $themedir . '/images/upb.png" alt="-" />';
             } elseif (file_exists('themes/' . $themedir . '/images/14_layer_raiselayer.png')) {
                 $upb = '<img src="themes/' . $themedir . '/images/14_layer_raiselayer.png" alt="-" />';
             } else {
                 $upb = '<img src="images/icons/extrasmall/14_layer_raiselayer.png" alt="-" />';
             }
         }
         if (!isset($downb)) {
             if (file_exists('themes/' . $themedir . '/images/downb.png')) {
                 $downb = '<img src="themes/' . $themedir . '/images/downb.png" alt="+" />';
             } elseif (file_exists('themes/' . $themedir . '/images/14_layer_lowerlayer.png')) {
                 $downb = '<img src="themes/' . $themedir . '/images/14_layer_lowerlayer.png" alt="+" />';
             } else {
                 $downb = '<img src="images/icons/extrasmall/14_layer_lowerlayer.png" alt="+" />';
             }
         }
         $checkUserBlock = self::checkUserBlock($blockinfo);
         if ($checkUserBlock) {
             if (!empty($blockinfo['title'])) {
                 $blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('ZikulaBlocksModule', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $upb . '</a>';
             }
         } else {
             $blockinfo['content'] = '';
             if (!empty($blockinfo['title'])) {
                 $blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('ZikulaBlocksModule', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $downb . '</a>';
             }
         }
         // end collapseable menu config
     } else {
         $blockinfo['minbox'] = '';
     }
     // try twig theme first (note: theme is already set by this point)
     $container = ServiceUtil::getManager();
     $twigBasedThemeBlock = $container->get('zikula_core.common.theme_engine')->wrapBcBlockInTheme($blockinfo);
     if ($twigBasedThemeBlock) {
         return $twigBasedThemeBlock;
     }
     // theme is not twig based revert to smarty
     return Zikula_View_Theme::getInstance()->themesidebox($blockinfo);
 }
Exemple #17
0
    /**
     * update block settings
     *
     * @param  array $blockinfo a blockinfo structure
     * @return       $blockinfo  the modified blockinfo structure
     */
    public function update($blockinfo)
    {
        $vars['displaymodules'] = FormUtil::getPassedValue('displaymodules');
        $vars['style']          = FormUtil::getPassedValue('style');
        $vars['stylesheet']     = FormUtil::getPassedValue('stylesheet');

        // Defaults
        if (empty($vars['displaymodules'])) {
            $vars['displaymodules'] = 0;
        }
        if (empty($vars['style'])) {
            $vars['style'] = 1;
        }
        if (empty($vars['template'])) {
            $vars['template'] = 'menu';
        }

        // User links
        $content = array();
        $c = 1;

        $linkname   = FormUtil::getPassedValue('linkname');
        $linkurl    = FormUtil::getPassedValue('linkurl');
        $linkdesc   = FormUtil::getPassedValue('linkdesc');
        $linkdelete = FormUtil::getPassedValue('linkdelete');
        $linkinsert = FormUtil::getPassedValue('linkinsert');

        if (isset($linkname)) {
            foreach ($linkname as $v) {
                if (empty($linkdelete[$c])) {
                    $content[] = "$linkurl[$c]|$linkname[$c]|$linkdesc[$c]";
                }
                if (!empty($linkinsert[$c])) {
                    $content[] = '||';
                }
                $c++;
            }
        }

        $new_linkname = FormUtil::getPassedValue('new_linkname');
        $new_linkurl  = FormUtil::getPassedValue('new_linkurl');
        $new_linkdesc = FormUtil::getPassedValue('new_linkdesc');
        $new_linkinsert = (bool)FormUtil::getPassedValue('new_linkinsert');

        if ($new_linkname) {
            $content[] = $new_linkurl . '|' . $new_linkname . '|' . $new_linkdesc;
            if ($new_linkinsert) {
                $content[] = '||';
            }
        }
        $vars['content'] = implode('LINESPLIT', $content);

        $blockinfo['content'] = BlockUtil::varsToContent($vars);

        // clear the block cache
        $this->view->clear_cache('blocks_block_menu.tpl');

        // and clear the theme cache
        Zikula_View_Theme::getInstance()->clear_cache();

        return($blockinfo);
    }
/**
 * BlankTheme plugin to centralize important outputs.
 *
 * Available parameters:
 *  - section (string) Name of the output section to return.
 *  - noempty (bool)   Flag to disable the "bt-empty" CSS class for the classesinnerpage section.
 *
 * Example:
 *  {bt_htmloutput section='head'}
 *  {bt_htmloutput section='topnavlinks'}
 *
 * @author Mateo Tibaquirá
 * @since  05/07/08
 *
 * @param array             $params All parameters passed to this function from the template.
 * @param Zikula_View_Theme &$view  Reference to the View_Theme object.
 *
 * @return string Output of the requested section.
 */
function smarty_function_bt_htmloutput($params, Zikula_View_Theme &$view)
{
    $dom = ZLanguage::getThemeDomain('BlankTheme');

    // section parameter check
    if (!isset($params['section']) || empty($params['section'])) {
        return '';
    }

    // blanktheme vars
    $body      = $view->getTplVar('body');
    $layout    = $view->getTplVar('layout');
    $btconfig  = $view->getTplVar('btconfig');
    $btcssbody = $view->getTplVar('btcssbody');

    // check for the current variable
    if ($view->getTplVar('current')) {
        $current = $view->getTplVar('current');
    } else {
        $current = $view->getToplevelmodule();
        $view->assign('current', $current);
    }

    // process the respective output
    $output = '';

    switch ($params['section'])
    {
        case 'topnavlinks':
            // build the menu list
            // option: {id, translatable link text, link}
            $menu = array();
            if (UserUtil::isLoggedIn()) {
                if ($view->getTplVar('type') != 'admin' && SecurityUtil::checkPermission('::', '::', ACCESS_ADMIN)) {
                    $menu[] = array('admin', __('Admin', $dom), ModUtil::url('Admin', 'admin', 'adminpanel'));
                }
                $profileModule = System::getVar('profilemodule', '');
                if (!empty($profileModule) && ModUtil::available($profileModule)) {
                    $menu[] = array('account', __('Your account', $dom), ModUtil::url($profileModule, 'user', 'main'));
                }
                $menu[] = array('logout', __('Log out', $dom), ModUtil::url('Users', 'user', 'logout'));
            } else {
                $menu[] = array('register', __('Register', $dom), ModUtil::url('Users', 'user', 'register'));
                $menu[] = array('login', __('Login', $dom), ModUtil::url('Users', 'user', 'login'));
            }
            // render the menu
            $count   = count($menu) - 1;
            $output  = '<div id="bt_topnavlinks"><ul>';
            foreach ($menu as $k => $option) {
                $class = '';
                if (count($menu) == 1) {
                    $class = 'unique';
                } elseif ($k == 0) {
                    $class = 'first';
                } elseif ($k == $count) {
                    $class = 'last';
                }
                $output .= '<li '.($class ? ' class="bt_'.$class.'"' : '').'>';
                if (!empty($option[2])) {
                    $output .= '<a title="'. DataUtil::formatForDisplay($option[1]). '" href="'.DataUtil::formatForDisplay($option[2]).'"><span>'. DataUtil::formatForDisplay($option[1]). '</span></a>';
                } else {
                    $output .= '<span>'. DataUtil::formatForDisplay($option[1]). '</span>';
                }
                $output .= '</li>';
            }
            $output .= '</ul></div>';
            break;

        case 'fontresize':
            if ($btconfig['fontresize'] != '1') {
                break;
            }
            // font resize based in the efa script
            PageUtil::addVar('javascript', $view->getScriptpath().'/efa/efa_fontsize_packed.js');
            //PageUtil::addVar('javascript', $view->getScriptpath().'/efa/efa_fontsize.js');
            $output = '<script type="text/javascript">
                         // <![CDATA[
                         if (efa_fontSize) {
                           var efalang_zoomIn = "'.__('Increase font size', $dom).'";
                           var efalang_zoomReset = "'.__('Reset font size', $dom).'";
                           var efalang_zoomOut = "'.__('Decrease font size', $dom).'";
                           var efathemedir = "'.$view->getDirectory().'";
                           efa_fontSize.efaInit();
                           document.write(efa_fontSize.allLinks);
                         }
                         // ]]>
                       </script>
                       ';
            break;

        case 'head':
            // head stylesheets
            $output .= '<!--[if lte IE 7]>'
                      .'<link rel="stylesheet" href="'.$view->getStylepath().'/patch_'.$body.'.css" type="text/css" />'
//                    .'<link rel="stylesheet" href="'.$view->getThemepath().'/yaml/core/slim_iehacks.css" type="text/css" />'
                      .'<![endif]-->';
/*                    .'<!--[if lte IE 6]>'
//                    .'<script type="text/javascript" src="'.$view->getScriptpath().'/ie_minmax.js"></script>'
                      .'<style type="text/css">
                            img, div, a, input { behavior: url('.$view->getStylepath().'/iepngfix.htc) }
                        </style>'
//                    .'<script type="text/javascript" src="'.$view->getScriptpath().'/ie_pngfix_tilebg.js"></script>'
                      .'<![endif]-->
                       ';
*/
            break;

        case 'footer':
            // load the Theme styles in the very end of the page rendering
            // TODO pending review with PageUtil weight assignment (when implemented)
            if ($btconfig['optimize'] == '1') {
                // do not load the layout_* stylesheet and load the basic styles directly
                PageUtil::addVar('stylesheet', $view->getThemepath().'/yaml/core/slim_base.css');
                PageUtil::addVar('stylesheet', $view->getStylepath().'/basemod.css');
                PageUtil::addVar('stylesheet', $view->getStylepath().'/content.css');
                // TODO rtl-support load yaml/add-ons/rtl-support/core/base-rtl.css with the respective basemod-rtl.css and content-rtl.css
            } else {
                PageUtil::addVar('stylesheet', $view->getStylepath()."/layout_{$body}.css");
            }
            break;

        /* Body ID */
        case 'bodyid':
            if ($view->getToplevelmodule()) {
                $output = 'bt_'.$view->getToplevelmodule();

            } elseif (!empty($current)) {
                $output = 'bt_'.$current;

            } else {
                $output = 'bt_staticpage';
            }
            break;

        /* First CSS level */
        case 'classesbody':
            // add a first level of CSS classes like current language, type parameter and body template in use with a 'bt_' prefix
            if (!empty($current)) {
                $output .= 'bt_'.$current.' ';
            }
            if ($btcssbody && isset($btcssbody[$body]) && $btcssbody[$body]) {
                $output .= $btcssbody[$body].' ';
            }
            $output .= 'bt_'.$body.' bt_type_'.$view->getType().' bt_lang_'.$view->getLanguage();
            break;

        /* Second CSS level */
        case 'classespage':
            // add a second level of CSS classes
            // add the current layout and enabled zones
            $output .= 'bt_'.str_replace('_', ' bt_', $layout);
            // add the current function name
            $output .= ' bt_func_'.$view->getFunc();
            break;

        /* Third CSS level */
        case 'classesinnerpage':
            // add a customized third level of CSS classes like specific parameters for specific modules
            /*
            switch ($view->getToplevelmodule()) {
                case 'Pages':
                    switch ($view->getFunc()) {
                        case 'display':
                            // Example: add the current pageid in a CSS class (bt_pageid_PID)
                            // note: this only works when using normal urls, shortURLs uses the title field
                            $output .= ' bt_pageid_'.FormUtil::getPassedValue('pageid');
                            break;
                    }
                    break;
                case 'Content':
                    switch ($view->getFunc()) {
                        case 'view':
                            // Example: add the current page category id in a CSS class (bt_contentcatpage_CID)
                            // works for normal and shortURLs
                            if (System::getVar('shorturls')) {
                                $urlname = $view->getRequest()->getGet()->get('name');
                                $pageId = ModUtil::apiFunc('Content', 'Page', 'solveURLPath', compact('urlname'));
                            } else {
                                $pageId = $view->getRequest()->getGet()->get('pid');
                            }
                            $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $pageId));
                            $output .= ' bt_contentcatpage_'.$page['categoryId'];
                    }
                    break;
            }
            */
            if (!isset($params['noempty']) || !$params['noempty']) {
                $output = !empty($output) ? $output : 'bt-empty';
            }
            break;
    }

    return $output;
}
Exemple #19
0
 /**
  * Clears the cache for a specific cache_id's in all active themes.
  *
  * @param string $cache_ids Array of given cache ID's for which to clear theme cache.
  * @param string $themes    Array of theme objects for which to clear theme cache, defaults to all active themes.
  *
  * @return boolean True on success.
  */
 public function clear_cacheid_allthemes($cache_ids, $themes = null)
 {
     if ($cache_ids) {
         if (!is_array($cache_ids)) {
             $cache_ids = array($cache_ids);
         }
         if (!$themes) {
             $themes = ThemeUtil::getAllThemes();
         }
         $theme = Zikula_View_Theme::getInstance();
         foreach ($themes as $themearr) {
             foreach ($cache_ids as $cache_id) {
                 $theme->clear_cache(null, $cache_id, null, null, $themearr['directory']);
             }
         }
     }
     return true;
 }
Exemple #20
0
 /**
  * update block settings
  *
  * @param  array $blockinfo a blockinfo structure
  * @return       $blockinfo  the modified blockinfo structure
  */
 public function update($blockinfo)
 {
     // Get current content
     $vars = BlockUtil::varsFromContent($blockinfo['content']);
     // Read inputs
     $vars['format'] = $this->request->get('format');
     // Read inputs
     $vars['fulltranslation'] = $this->request->get('fulltranslation');
     // Scan for languages and save cached version
     $vars['languages'] = $this->getAvailableLanguages();
     // write back the new contents
     $blockinfo['content'] = BlockUtil::varsToContent($vars);
     // clear the block cache
     $this->view->clear_cache('Block/thelang.tpl');
     // and clear the theme cache
     \Zikula_View_Theme::getInstance()->clear_cache();
     return $blockinfo;
 }
Exemple #21
0
    /**
     * Display a block based on the current theme.
     *
     * @param array $blockinfo Block info.
     *
     * @return string The rendered output.
     */
    public static function themeBlock($blockinfo)
    {
        static $themeinfo, $themedir, $upb, $downb;

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

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

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

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

        return Zikula_View_Theme::getInstance()->themesidebox($blockinfo);
    }
Exemple #22
0
 /**
  * Clear cache for given item. Can be called from other modules to clear an item cache.
  *
  * @param $item - the item: array with data or id of the item
  */
 function clearItemCache($item)
 {
     if ($item && !is_array($item)) {
         $object = new AddressBook_DBObject_Address();
         $item = $object->get($item);
     }
     if ($item && isset($item['id']) && $item['id'] > 0) {
         // Clear View_cache
         $cache_ids = array();
         $cache_ids[] = 'display/id_' . $item['id'];
         $cache_ids[] = 'view/cat_0';
         $cache_ids[] = 'view/cat_' . $item['cat_id'];
         $view = Zikula_View::getInstance('AddressBook');
         foreach ($cache_ids as $cache_id) {
             $view->clear_cache(null, $cache_id);
         }
         // Clear Theme_cache
         $cache_ids = array();
         $cache_ids[] = 'AddressBook/user/display/id_' . $item['id'];
         // for given Id, according to new cache_id structure in Zikula 1.3.2.dev (1.3.3)
         //$cache_ids[] = 'homepage'; // for homepage (it can be adjustment in module settings)
         $cache_ids[] = 'AddressBook/user/view';
         // view function (contacts list)
         $cache_ids[] = 'AddressBook/user/main';
         // main function
         $theme = Zikula_View_Theme::getInstance();
         //if (Zikula_Core::VERSION_NUM > '1.3.2') {
         if (method_exists($theme, 'clear_cacheid_allthemes')) {
             $theme->clear_cacheid_allthemes($cache_ids);
         } else {
             // clear cache for current theme only
             foreach ($cache_ids as $cache_id) {
                 $theme->clear_cache(null, $cache_id);
             }
         }
     }
 }
/**
 * BlankTheme plugin to display the user navigation menu.
 *
 * Available parameters:
 *  - id           (string) ID of the wrapper div (default: 'nav_main')
 *  - current      (string) Current screen ID (.ini current value or module name) (optional)
 *  - currentclass (string) CSS class name of the current tab, list item (default: 'current')
 *  - span         (bool)   Flag to enable SPAN wrappers on the links text, useful for sliding doors (default: false)
 *  - desc         (bool)   Flag to put the parent links descriptions inside SPAN.bt_desc instead the link title (default: false)
 *
 * Example:
 *  {bt_userlinks id='myId' current='home' currentclass='myActiveClass'}
 *
 * @author Mateo Tibaquirá
 * @since  08/11/07
 *
 * @param array             $params All parameters passed to this function from the template.
 * @param Zikula_View_Theme &$view  Reference to the View_Theme object.
 *
 * @return string User menu output.
 */
function smarty_function_bt_userlinks($params, Zikula_View_Theme &$view)
{
    $dom = ZLanguage::getThemeDomain('BlankTheme');

    $id = isset($params['id']) ? $params['id'] : 'nav_main';
    if (!isset($params['current'])) {
        $current = $view->getTplVar('current') ? $view->getTplVar('current') : $view->getToplevelmodule();
    } else {
        $current = $params['current'];
    }
    $currentclass = isset($params['currentclass']) ? $params['currentclass'] : 'current';
    $span = isset($params['span']) ? (bool)$params['span'] : false;
    $desc = isset($params['desc']) ? (bool)$params['desc'] : false;

    /*** Build the menu-array ***/
    $menu   = array();
    $menu[] = array(
                  'home',                      // page id / module name
                  __('Home', $dom),            // translatable title
                  __('Go to home page', $dom), // translatable description
                  System::getHomepageUrl(),    // link
                  null                         // array of sublinks (optional)
              );

    if (ModUtil::available('News')) {
        $menu[] = array(
                      'News',
                      __('News', $dom),
                      __('Articles index', $dom),
                      ModUtil::url('News', 'user', 'main')
                  );
    }

    if (ModUtil::available('Pages')) {
        $menu[] = array(
                      'Pages',
                      __('Pages', $dom),
                      __('Content section', $dom),
                      ModUtil::url('Pages', 'user', 'main')
                  );
    }

    if (ModUtil::available('Dizkus')) {
        $menu[] = array(
                      'Dizkus',
                      __('Forums', $dom),
                      __('Discuss area', $dom),
                      ModUtil::url('Dizkus', 'user', 'main')
                  );
    }

    if (ModUtil::available('FAQ')) {
        $menu[] = array(
                      'FAQ',
                      __('FAQ', $dom),
                      __('Frequent questions', $dom),
                      ModUtil::url('FAQ', 'user', 'main')
                  );
    }

    if (ModUtil::available('Wikula')) {
        $menu[] = array(
                      'Wikula',
                      __('Wiki', $dom),
                      __('Documents', $dom),
                      ModUtil::url('Wikula', 'user', 'main')
                  );
    }

    if (ModUtil::available('TimeIt')) {
        $menu[] = array(
                      'TimeIt',
                      __('Calendar', $dom),
                      __('List of events', $dom),
                      ModUtil::url('TimeIt', 'user', 'main')
                  );
    }

    if (ModUtil::available('crpCalendar')) {
        $menu[] = array(
                      'crpCalendar',
                      __('Calendar', $dom),
                      __('List of events', $dom),
                      ModUtil::url('crpCalendar', 'user', 'main')
                  );
    }

    if (ModUtil::available('Formicula')) {
        $menu[] = array(
                      'Formicula',
                      __('Contact us', $dom),
                      __('Comment or suggest', $dom),
                      ModUtil::url('Formicula', 'user', 'main')
                  );
    }

    // render the menu
    $output  = '<div id="'.$id.'"><ul>';
    foreach ($menu as $option) {
        $output .= bt_userlinks_drawmenu($option, $current, $currentclass, $span, $desc);
    }
    $output .= '</ul></div>';

    return $output;
}
Exemple #24
0
    /**
     * update block configuration
     */
    public function update($blockinfo)
    {
        // Get current content
        $vars = BlockUtil::varsFromContent($blockinfo['content']);

        // check if import old menu
        $menutree_menus = FormUtil::getPassedValue('menutree_menus', 'null');

        if ($menutree_menus != 'null') {
            $vars['menutree_content'] = $this->_import_menu($menutree_menus);
        } else {
            $vars['menutree_content'] = FormUtil::getPassedValue('menutree_content', '', 'POST');
            $vars['menutree_content'] = DataUtil::urlsafeJsonDecode($vars['menutree_content']);
        }

        if (!$this->validate_menu($vars['menutree_content'])) {
            return LogUtil::registerError($this->__('Error! Could not save your changes.'));
        }

        // sort tree array according to lineno key
        uasort($vars['menutree_content'], array('Blocks_Block_Menutree','sort_menu'));

        // get other form data
        $menutree_data = FormUtil::getPassedValue('menutree');

        $vars['menutree_tpl'] = isset($menutree_data['tpl']) ? $menutree_data['tpl'] : '';
        if (empty($vars['menutree_tpl']) || !$this->view->template_exists($vars['menutree_tpl'])) {
            $vars['menutree_tpl'] = 'menutree/blocks_block_menutree_default.tpl';
        }

        $vars['menutree_stylesheet'] = isset($menutree_data['stylesheet']) ? $menutree_data['stylesheet'] : '';
        if (empty($vars['menutree_stylesheet']) || $vars['menutree_stylesheet'] == 'null' || !file_exists($vars['menutree_stylesheet'])) {
            $vars['menutree_stylesheet'] = '';
        }

        $vars['menutree_titles'] = isset($menutree_data['titles']) ? $menutree_data['titles'] : array();

        $vars['menutree_linkclass'] = isset($menutree_data['linkclass']) ? (bool)$menutree_data['linkclass'] : false;
        // if class list is provided - rebuild array and fill empty entries
        if ($vars['menutree_linkclass'] && isset($menutree_data['linkclasses'])) {
            foreach ((array)$menutree_data['linkclasses'] as $k => $class) {
                if (empty($class['name'])) {
                    unset($menutree_data['linkclasses'][$k]);
                } elseif (empty($class['title'])) {
                    $menutree_data['linkclasses'][$k]['title'] = $class['name'];
                }
            }
            $vars['menutree_linkclasses'] = $menutree_data['linkclasses'];
            if (count($vars['menutree_linkclasses']) < 1) {
                $vars['menutree_linkclass'] = false;
            }
        }

        $vars['menutree_maxdepth']     = isset($menutree_data['maxdepth']) ? (int)$menutree_data['maxdepth'] : 0;
        $vars['menutree_editlinks']    = isset($menutree_data['editlinks']) ? (bool)$menutree_data['editlinks'] : false;
        $vars['menutree_stripbaseurl'] = isset($menutree_data['stripbaseurl']) ? (bool)$menutree_data['stripbaseurl'] : false;

        $vars['menutree_titlesperms']   = isset($menutree_data['titlesperms']) && array_key_exists($menutree_data['titlesperms'],$this->_permlevels()) ? $menutree_data['titlesperms'] : 'ACCESS_EDIT';
        $vars['menutree_displayperms']  = isset($menutree_data['displayperms']) && array_key_exists($menutree_data['displayperms'],$this->_permlevels()) ? $menutree_data['displayperms'] : 'ACCESS_EDIT';
        $vars['menutree_settingsperms'] = isset($menutree_data['settingsperms']) && array_key_exists($menutree_data['settingsperms'],$this->_permlevels()) ? $menutree_data['settingsperms'] : 'ACCESS_EDIT';

        if (empty($vars['menutree_content'])) {
            unset($vars['menutree_content']);
        } else {
            // check langs and save current langs list and current default lang
            $tmp = current($vars['menutree_content']);
            $vars['oldlanguages'] = array_keys($tmp);
            $vars['olddefaultanguage'] = $vars['oldlanguages'][0];

            // strip base url - if needed
            if ($vars['menutree_stripbaseurl'] === true) {
                $baseurl = System::getBaseUrl();
                foreach ($vars['menutree_content'] as $itemid => $item) {
                    foreach ($item as $lang => $_item) {
                        // strip base url only when it occurs at the beginning of url and only once
                        if (strpos($_item['href'], $baseurl) === 0) {
                            $vars['menutree_content'][$itemid][$lang]['href'] = substr_replace($_item['href'], '', 0, strlen($baseurl));
                        }
                    }
                }
            }
        }

        // write back the new contents
        $blockinfo['content'] = BlockUtil::varsToContent($vars);

        // clear the block cache
        $this->view->clear_cache(null, $blockinfo['bkey'].'/bid'.$blockinfo['bid']);

        // and clear the theme cache
        Zikula_View_Theme::getInstance()->clear_cache();

        return $blockinfo;
    }
Exemple #25
0
    /**
     * update block settings
     *
     * @param  array $blockinfo a blockinfo structure
     * @return       $blockinfo  the modified blockinfo structure
     */
    public function update($blockinfo)
    {
        // list of vars that don't need to be saved
        $search_reserved_vars = array('authid', 'csrftoken', 'bid', 'title', 'positions', 'language', 'submit',
                                      'refresh', 'filter', 'type', 'functions', 'customargs');

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

        foreach ($_POST as $key => $value) {
            if (in_array($key, $search_reserved_vars)) {
                continue;
            }
            $vars[$key] = $value;
        }

        // write back the new contents
        $blockinfo['content'] = BlockUtil::varsToContent($vars);

        // clear the block cache
        $this->view->clear_cache('search_block_search.tpl');

        // and clear the theme cache
        Zikula_View_Theme::getInstance()->clear_cache();

        return($blockinfo);
    }
Exemple #26
0
    /**
     * Clear theme engine configurations
     *
     * Using this function, the admin can clear all theme engine configuration
     * copies created inside the temporary directory.
     */
    public function clear_config()
    {
        $csrftoken = FormUtil::getPassedValue('csrftoken');
        $this->checkCsrfToken($csrftoken);

        // Security check
        if (!SecurityUtil::checkPermission('Theme::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        $theme = Zikula_View_Theme::getInstance();
        $res   = $theme->clear_theme_config();

        if ($res) {
            LogUtil::registerStatus($this->__('Done! Deleted theme engine configurations.'));
        } else {
            LogUtil::registerError($this->__('Error! Failed to clear theme engine configurations.'));
        }

        $this->redirect(ModUtil::url('Theme', 'admin', 'modifyconfig'));
    }
Exemple #27
0
 /**
  * update block settings
  *
  * @param        array       $blockinfo     a blockinfo structure
  * @return       $blockinfo  the modified blockinfo structure
  */
 public function update($blockinfo)
 {
     $vars['displaymodules'] = FormUtil::getPassedValue('displaymodules');
     $vars['stylesheet'] = FormUtil::getPassedValue('stylesheet');
     $vars['template'] = FormUtil::getPassedValue('template');
     $vars['blocktitles'] = FormUtil::getPassedValue('blocktitles');
     // Defaults
     if (empty($vars['displaymodules'])) {
         $vars['displaymodules'] = 0;
     }
     if (empty($vars['template'])) {
         $vars['template'] = 'blocks_block_extmenu.tpl';
     }
     if (empty($vars['stylesheet'])) {
         $vars['stylesheet'] = 'extmenu.css';
     }
     // User links
     $content = array();
     $vars['links'] = FormUtil::getPassedValue('links');
     $vars['blockversion'] = 1;
     // Save links hierarchy
     $linksorder = FormUtil::getPassedValue('linksorder');
     $linksorder = json_decode($linksorder, true);
     if (is_array($linksorder) && !empty($linksorder)) {
         foreach ((array) $vars['links'] as $lang => $langlinks) {
             foreach ($langlinks as $linkid => $link) {
                 $vars['links'][$lang][$linkid]['parentid'] = $linksorder[$linkid]['parentid'];
                 $vars['links'][$lang][$linkid]['haschildren'] = $linksorder[$linkid]['haschildren'];
             }
         }
     }
     $blockinfo['content'] = BlockUtil::varsToContent($vars);
     // clear the block cache
     $this->view->clear_cache(null, $blockinfo['bkey'] . '/bid' . $blockinfo['bid']);
     // and clear the theme cache
     Zikula_View_Theme::getInstance()->clear_cache();
     return $blockinfo;
 }
 /**
  * Upgrade a module
  * @param int 'id' module id
  * @return bool true
  */
 public function upgradeAction()
 {
     $csrftoken = $this->request->get('csrftoken');
     $this->checkCsrfToken($csrftoken);
     $session = $this->request->getSession();
     $interactive_upgrade = $session->get('interactive_upgrade');
     $interactive_upgrade = empty($interactive_upgrade) ? false : true;
     if ($interactive_upgrade == false) {
         $id = (int) $this->request->query->get('id', null);
         $startnum = (int) $this->request->query->get('startnum', null);
         $letter = $this->request->query->get('letter', null);
         $state = $this->request->query->get('state', null);
         $session->set('modules_id', $id);
         $session->set('modules_startnum', $startnum);
         $session->set('modules_letter', $letter);
         $session->set('modules_state', $state);
         $activate = false;
     } else {
         $id = $session->get('modules_id');
         $startnum = $session->get('modules_startnum');
         $letter = $session->get('modules_letter');
         $state = $session->get('modules_state');
         $activate = (bool) $this->request->request->get('activate', null);
     }
     if (empty($id) || !is_numeric($id)) {
         return LogUtil::registerError($this->__('Error! No module ID provided.'), 404, ModUtil::url('Extensions', 'admin', 'view'));
     }
     // Upgrade module
     $res = ModUtil::apiFunc('ExtensionsModule', 'admin', 'upgrade', array('id' => $id, 'interactive_upgrade' => $interactive_upgrade));
     if (is_bool($res) && $res == true) {
         // Success
         $session->remove('modules_id');
         $session->remove('modules_startnum');
         $session->remove('modules_letter');
         $session->remove('modules_state');
         $session->set('interactive_upgrade', false);
         LogUtil::registerStatus($this->__('New version'));
         if ($activate == true) {
             if (ModUtil::apiFunc('ExtensionsModule', 'admin', 'setstate', array('id' => $id, 'state' => ModUtil::STATE_ACTIVE))) {
                 // Success
                 LogUtil::registerStatus($this->__('Activated'));
             }
         }
         // Clear the Zikula_View cached/compiled files and Themes cached/compiled/cssjs combination files
         $theme = \Zikula_View_Theme::getInstance('Theme');
         $theme->clear_compiled();
         $theme->clear_all_cache();
         $theme->clear_cssjscombinecache();
         $this->view->clear_compiled();
         $this->view->clear_all_cache();
         return $this->redirect(ModUtil::url('Extensions', 'admin', 'view', array('startnum' => $startnum, 'letter' => $letter, 'state' => $state)));
     } elseif (is_bool($res)) {
         return $this->redirect(ModUtil::url('Extensions', 'admin', 'view', array('startnum' => $startnum, 'letter' => $letter, 'state' => $state)));
     } else {
         return $res;
     }
 }
Exemple #29
0
    /**
     * Clear cache for given item. Can be called from other modules to clear an item cache.
     *
     * @param $item - the item: array with data or id of the item
     */
    public function clearItemCache($item)
    {
        if ($item && !is_array($item)) {
            $item = ModUtil::apiFunc('Pages', 'user', 'get', array('sid' => $item));
        }
        if ($item) {
            // Clear View_cache
            $cache_ids = array();
            $cache_ids[] = $item['sid'];
            $cache_ids[] = 'view';
            $cache_ids[] = 'main';
            $view = Zikula_View::getInstance('Pages');
            foreach ($cache_ids as $cache_id) {
                $view->clear_cache(null, $cache_id);
            }

            // Clear Theme_cache
            $cache_ids = array();
            $cache_ids[] = 'Pages/user/display/pageid_'.$item['pageid']; // for given page Id, according to new cache_id structure in Zikula 1.3.2.dev (1.3.3)
            $cache_ids[] = 'homepage'; // for homepage (it can be adjustment in module settings)
            $cache_ids[] = 'Pages/user/view'; // view function (pages list)
            $cache_ids[] = 'Pages/user/main'; // main function
            $theme = Zikula_View_Theme::getInstance();
            //if (Zikula_Core::VERSION_NUM > '1.3.2') {
            if (method_exists($theme, 'clear_cacheid_allthemes')) {
                $theme->clear_cacheid_allthemes($cache_ids);
            } else {
                // clear cache for current theme only
                foreach ($cache_ids as $cache_id) {
                    $theme->clear_cache(null, $cache_id);
                }
            }
        }
    }
Exemple #30
0
 /**
  * Disable or enable add the module wrapper.
  *
  * @param boolean $wrap False to disable wrapper, true to enable it.
  *
  * @return $this
  */
 public function setWrapper($wrap)
 {
     if ($this->modinfo['name'] == $this->toplevelmodule) {
         Zikula_View_Theme::getInstance()->themeinfo['system'] = !$wrap;
     }
     return $this;
 }