public function stopQuery() { $query = $this->currentQuery; $query['time'] = microtime(true) - $this->start; $zevent = new GenericEvent(null, $query); \EventUtil::dispatch('log.sql', $zevent); }
/** * Post-Process the basic object validation with class specific logic. * * Subclasses can define appropriate implementations. * * @param string $type Controller type. * @param array $data Data to be used for validation. * * @return boolean */ public function validatePostProcess($type = 'user', $data = null) { EventUtil::dispatch('dbobject.validatepostprocess', new \Zikula\Core\Event\GenericEvent($this)); return true; }
/** * Unregister all subscribers from the system. * * This cascades to remove all event handlers, sorting data and update bindings table. * * @param array $bundles Module's bundles object. * * @return void */ public static function unregisterSubscriberBundles(array $bundles) { $hookManager = ServiceUtil::getManager()->get('hook_dispatcher'); foreach ($bundles as $bundle) { $hookManager->unregisterSubscriberBundle($bundle); $event = new \Zikula\Core\Event\GenericEvent($bundle, array('areaid' => $hookManager->getAreaId($bundle->getArea()))); EventUtil::dispatch('installer.subscriberbundle.uninstalled', $event); } }
/** * Filter results for a given getTheme() type. * * @param string $themeName Theme name. * @param string $type Event type. * * @return string Theme name */ private static function _getThemeFilterEvent($themeName, $type) { $event = new GenericEvent(null, array('type' => $type), $themeName); return EventUtil::dispatch('user.gettheme', $event)->getData(); }
/** * Executed following a Doctrine statement exec query. * * @param Doctrine_Event $event The Doctrine event instance. * * @return void */ public function postStmtExecute(Doctrine_Event $event) { $event->end(); $zevent = new GenericEvent(null, array('time' => $event->getElapsedSecs(), 'query' => $event->getQuery())); EventUtil::dispatch('log.sql', $zevent); }
/** * @Route("/moduleservices/{moduleName}", options={"zkNoBundlePrefix" = 1}) * @Method("GET") * * Display services available to the module * * @param $moduleName * @internal param GenericEvent $event * @throws AccessDeniedException Thrown if the user doesn't have admin permissions over the module * * @return Response */ public function moduleServicesAction($moduleName) { if (!SecurityUtil::checkPermission($moduleName . '::', '::', ACCESS_ADMIN)) { throw new AccessDeniedException(); } // notify EVENT here to gather any system service links $event = new GenericEvent(null, array('modname' => $moduleName)); \EventUtil::dispatch('module_dispatch.service_links', $event); $sublinks = $event->getData(); $this->view->assign('sublinks', $sublinks); $this->view->assign('currentmodule', $moduleName); return new Response($this->view->fetch('Admin/HookUi/moduleservices.tpl')); }
/** * Get module class. * * @param string $modname Module name. * @param string $type Type. * @param boolean $api Whether or not to get the api class. * @param boolean $force Whether or not to force load. * * @return boolean|string Class name. */ public static function getClass($modname, $type, $api = false, $force = false) { // do not cache this process - drak if ($api) { $result = self::loadApi($modname, $type); } else { $result = self::load($modname, $type); } if (!$result) { return false; } $modinfo = self::getInfo(self::getIDFromName($modname)); $className = $api ? ucwords($modname) . '\\Api\\' . ucwords($type) . 'Api' : ucwords($modname) . '\\Controller\\' . ucwords($type) . 'Controller'; // allow overriding the OO class (to override existing methods using inheritance). $event = new GenericEvent(null, array('modname', 'modinfo' => $modinfo, 'type' => $type, 'api' => $api), $className); EventUtil::dispatch('module_dispatch.custom_classname', $event); if ($event->isPropagationStopped()) { $className = $event->getData(); } // check the modules state if (!$force && !self::available($modname)) { return false; } if (class_exists($className)) { return $className; } return false; }
/** * Format a variable for HTML display. This method is recursive array safe. * * @param string $var The variable to format. * * @return string The formatted variable. */ public static function formatForDisplayHTML($var) { // This search and replace finds the text 'x@y' and replaces // it with HTML entities, this provides protection against // email harvesters // // Note that the use of \024 and \022 are needed to ensure that // this does not break HTML tags that might be around either // the username or the domain name static $search = array('/([^\\024])@([^\\022])/se'); static $replace = array('"&#" . sprintf("%03d", ord("\\1")) . ";@&#" . sprintf("%03d", ord("\\2")) . ";";'); static $allowedtags = null; static $outputfilter; static $event; if (!$event) { $event = new GenericEvent(); } if (!isset($allowedtags)) { $allowedHTML = array(); $allowableHTML = System::getVar('AllowableHTML'); if (is_array($allowableHTML)) { foreach ($allowableHTML as $k => $v) { if ($k == '!--') { if ($v != 0) { $allowedHTML[] = "{$k}.*?--"; } } else { switch ($v) { case 0: break; case 1: $allowedHTML[] = "/?{$k}\\s*/?"; break; case 2: $allowedHTML[] = "/?\\s*{$k}" . "(\\s+[\\w:]+\\s*=\\s*(\"[^\"]*\"|'[^']*'))*" . '\\s*/?'; break; } } } } if (count($allowedHTML) > 0) { $allowedtags = '~<\\s*(' . implode('|', $allowedHTML) . ')\\s*>~is'; } else { $allowedtags = ''; } } if (!isset($outputfilter)) { if (ModUtil::available('SecurityCenterModule') && !System::isInstalling()) { $outputfilter = System::getVar('outputfilter'); } else { $outputfilter = 0; } } if (is_array($var)) { foreach ($var as $k => $v) { $var[$k] = self::formatForDisplayHTML($v); } } else { // Run additional filters if ($outputfilter > 0) { $event->setData($var)->setArgument('filter', $outputfilter); $var = EventUtil::dispatch('system.outputfilter', $event)->getData(); } // Preparse var to mark the HTML that we want if (!empty($allowedtags)) { $var = preg_replace($allowedtags, "\\1", $var); } // Encode email addresses $var = preg_replace($search, $replace, $var); // Fix html entities $var = htmlspecialchars($var); // Fix the HTML that we want $var = preg_replace_callback('#\\022([^\\024]*)\\024#', create_function('$m', 'return DataUtil::formatForDisplayHTML_callback($m);'), $var); // Fix entities if required if (System::getVar('htmlentities')) { $var = preg_replace('/&([a-z#0-9]+);/i', "&\\1;", $var); } } return $var; }
/** * Post-Process the basic object validation with class specific logic. * * Subclasses can define appropriate implementations. * * @param string $type Controller type. * @param array $data Data to be used for validation. * * @return boolean */ public function validatePostProcess($type = 'user', $data = null) { // empty function, should be implemented by child classes. EventUtil::dispatch('dbobjectarray.validatepostprocess', new \Zikula\Core\Event\GenericEvent($this)); return true; }
/** * Format a variable for HTML display. This method is recursive array safe. * * @param string $var The variable to format. * * @return string The formatted variable. */ public static function formatForDisplayHTML($var) { static $allowedtags = null; static $outputfilter; static $event; if (!$event) { $event = new \Zikula\Core\Event\GenericEvent(); } if (!isset($allowedtags)) { $allowedHTML = array(); $allowableHTML = System::getVar('AllowableHTML'); if (is_array($allowableHTML)) { foreach ($allowableHTML as $k => $v) { if ($k == '!--') { if ($v != 0) { $allowedHTML[] = "{$k}.*?--"; } } else { switch ($v) { case 0: break; case 1: $allowedHTML[] = "/?{$k}\\s*/?"; break; case 2: $allowedHTML[] = "/?\\s*{$k}" . "(\\s+[\\w:]+\\s*=\\s*(\"[^\"]*\"|'[^']*'))*" . '\\s*/?'; break; } } } } if (count($allowedHTML) > 0) { $allowedtags = '~<\\s*(' . implode('|', $allowedHTML) . ')\\s*>~is'; } else { $allowedtags = ''; } } if (!isset($outputfilter)) { if (ModUtil::available('ZikulaSecurityCenterModule') && !System::isInstalling()) { $outputfilter = System::getVar('outputfilter', 0); } else { $outputfilter = 0; } } if (is_array($var)) { foreach ($var as $k => $v) { $var[$k] = self::formatForDisplayHTML($v); } } else { // Run additional filters if ($outputfilter > 0) { $event->setData($var)->setArg('filter', $outputfilter); $var = EventUtil::dispatch('system.outputfilter', $event)->getData(); } // Preparse var to mark the HTML that we want if (!empty($allowedtags)) { $var = preg_replace($allowedtags, "\\1", $var); } // Fix html entities $var = htmlspecialchars($var); // Fix the HTML that we want $var = preg_replace_callback('#\\022([^\\024]*)\\024#', create_function('$m', 'return DataUtil::formatForDisplayHTML_callback($m);'), $var); // Fix entities if required if (System::getVar('htmlentities')) { $var = preg_replace('/&([a-z#0-9]+);/i', "&\\1;", $var); } } return $var; }