/** * Set the name of the captcha * * @param string $captcha The captcha name. * @return object Koch_Formelement_Captcha (THIS is not Koch_Formelement_Captcha_$captcha ) */ public function setCaptcha($captcha = null) { // if no captcha is given, take the one definied in configuration if ($captcha == null) { $config = Clansuite_CMS::getInjector()->instantiate('Koch\\Config'); $captcha = $config['antispam']['captchatype']; unset($config); } $this->captcha = mb_strtolower($captcha); return $this; }
public function setEditor($editor = null) { /** * if no editor is given, take the one definied in the general configuration. * the expected config setting is [editor] type. * if the configuration value is not given, use "ckeditor" as fallback. */ if ($editor == null) { $config = Clansuite_CMS::getInjector()->instantiate('Koch\\Config'); $editor = isset($config['editor']['type']) ? $config['editor']['type'] : 'ckeditor'; unset($config); } $this->editor = mb_strtolower($editor); return $this; }
/** * @var object Instance of Koch_HttpRequest Object. */ public function __construct() { $this->request = Clansuite_CMS::getInjector()->instantiate('Koch_HttpRequest'); // Load Recaptcha Library include_once ROOT_LIBRARIES . 'recaptcha/recaptchalib.php'; /** * Fetch publickey from config * * [recaptcha] * public_key = "" * private_key = "" */ $config = Clansuite_CMS::getInjector()->instantiate('Koch\\Config'); $this->publicKey = $config['recaptcha']['public_key']; $this->privateKey = $config['recaptcha']['private_key']; unset($config); }
public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response) { /** * maintenance mode must be enabled in configuration */ if ($this->config['maintenance']['maintenance'] == 1) { return; } /** * @todo b) create override of maintenance mode, in case it's an admin user? */ // fetch renderer $smarty = Koch_Renderer_Factory::getRenderer('smarty', Clansuite_CMS::getInjector()); // fetch maintenance template $html = $smarty->fetch(ROOT_THEMES . 'core/view/smarty/maintenance.tpl', true); // output $response->setContent($html); $response->flush(); exit; }
/** * Render the actions of the rows * * @return string Returns the html-code for the actions */ private static function renderTableBatchActions() { $_BatchActions = self::getDatagrid()->getBatchActions(); $html = ''; if (count($_BatchActions) > 0 && self::getDatagrid()->isEnabled('BatchActions')) { $config = null; $config = Clansuite_CMS::getInjector()->instantiate('Clansuite_Config')->toArray(); $html .= '<tr>'; $html .= '<td class="DatagridBatchActions"><input type="checkbox" class="DatagridSelectAll" /></td>'; $html .= '<td colspan=' . (self::getDatagrid()->getColumnCount() - 1) . '>'; $html .= '<select name="action" id="BatchActionId">'; $html .= '<option value="' . $config['defaults']['action'] . '">' . _('(Choose an action)') . '</option>'; foreach ($_BatchActions as $BatchAction) { $html .= '<option value="' . $BatchAction['Action'] . '">' . $BatchAction['Name'] . '</option>'; } $html .= '</select>'; $html .= '<input class="ButtonOrange" type="submit" value="' . _('Execute') . '" />'; $html .= '</td>'; $html .= '</tr>'; } return $html; }
/** * Gather Module Informations from Manifest Files * * @staticvar array $modulesinfo * @param mixed array|string $module array with modulenames or one modulename * @return moduleinformations (self::$modulesinfo) */ public static function loadModuleInformations($module = null) { // Init vars $module_directories = array(); $number_of_modules = 0; /** * either fetch the module requested via parameter $module * fetch all modules */ if ($module === null) { $module_directories = self::getModuleDirectories(); } else { // cast string to array $module_directories[] = ROOT_MOD . $module; } foreach ($module_directories as $modulepath) { /** * create array with pieces of information about a module */ // 1) get the modulename, by stripping off the path info $modulename = str_replace(ROOT_MOD, '', $modulepath); self::$modulesinfo[$modulename]['name'] = $modulename; self::$modulesinfo[$modulename]['id'] = $number_of_modules; self::$modulesinfo[$modulename]['path'] = $modulepath; self::$modulesinfo[$modulename]['core'] = self::isACoreModule($modulename); // active - based on /configuration/modules.config.php self::$modulesinfo[$modulename]['active'] = self::isModuleActive($modulename); // hasMenu / ModuleNavigation self::$modulesinfo[$modulename]['menu'] = is_file($modulepath . DIRECTORY_SEPARATOR . $modulename . '.menu.php'); // hasInfo $module_infofile = $modulepath . DIRECTORY_SEPARATOR . $modulename . '.info.php'; $config_object = Clansuite_CMS::getInjector()->instantiate('Koch\\Config'); if (is_file($module_infofile) === true) { #Koch_Debug::firebug($module_infofile); self::$modulesinfo[$modulename]['info'] = $config_object->readConfig($module_infofile); } else { // create file in DEV MODE // if the info file for a module does not exists yet, create it $config_object->writeConfig($module_infofile); } // hasRoutes // hasConfig $config = self::readModuleConfig($modulename); if ($config[$modulename] !== null) { self::$modulesinfo[$modulename]['config'] = $config[$modulename]; // properties if (isset($config['properties'])) { self::$modulesinfo[$modulename]['settings'] = $config['properties']; } // acl if (isset($config['properties_acl'])) { self::$modulesinfo[$modulename]['acl'] = $config['properties_acl']; } } /*else { $modules[$modulename]['config'] = $config; }*/ // hasLanguages self::$modulesinfo[$modulename]['languages'] = self::getLanguageInfosForModule($modulepath); // take some stats: increase the module counter self::$modulesinfo['yy_summary']['counter'] = ++$number_of_modules; } ksort(self::$modulesinfo); #Koch_Debug::printR(self::$modulesinfo); return self::$modulesinfo; }
/** * Google Analytics Plugin * Generate XHTML 1.1 valid Google Analytics code * * Name: google_analytics<br> * Date: 26.Mai 2010.<br> * * Examples: * <pre> * {googleanalytics code=UA-xxxxxx-x type=jquery} * </pre> * * @link http://code.google.com/intl/de-DE/apis/analytics/docs/tracking/asyncMigrationExamples.html * * @param array $params code parameter required * @param Smarty $smarty * @return string */ function smarty_function_googleanalytics($params, $smarty) { // get the google analytics code to insert it later on into the script if (empty($params['code'])) { // fallback to config, if nothing was given $config = Clansuite_CMS::getInjector('Koch_Config'); $google_id = $config->getConfigValue('googleanalytics_id'); if (empty($google_id) == false) { } else { // no code provided via smarty function nor config trigger_error("google_analytics: the parameter 'code' is missing. please specifiy your GA urchin id."); return; } } else { $google_id = $params['code']; } /** * Determine the type of script to include * a) async = asynchronous script snippet * b) jquery = jquery loaded and cached snippet */ if (empty($params['type'])) { trigger_error("google_analytics: the parameter 'type' is missing. please specifiy your 'async' or 'jquery'."); return; } if ('async' == $params['type']) { // asynchronous ga script $return = ' <script type="text/javascript"> // <![CDATA[ <!-- asynchronous push --> var _gaq = _gaq || []; _gaq.push([\'_setAccount\', \'' . $google_id . '\']); _gaq.push([\'_trackPageview\']); <!-- ga object call by inserting it into the page --> (function() { var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true; ga.src = (\'https:\'== document.location.protocol ? \'https://ssl\':\'http://www\') + \'.google-analytics.com/ga.js\'; var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s); })(); // ]]> </script>'; } if ('jquery' == $params['type']) { // asynchronous and cached loading via jquery ajax $return = ' <script type="text/javascript"> // <![CDATA[ $(document).ready(function(){$.ajax({ type: \'GET\', url: \'http://www.google-analytics.com/ga.js\', dataType: \'script\', cache: true, success: function() { var pageTracker = _gat._getTracker(\'' . $google_id . '\'); pageTracker._trackPageview(); } }); }); // ]]> </script>'; } return $return; }
/** * Constructor */ public function __construct() { // initializing $config = Clansuite_CMS::getClansuiteConfig(); self::setFrontendPath(ROOT_THEMES_FRONTEND); self::setBackendPath(ROOT_THEMES_BACKEND); self::setFrontendTheme($config['template']['frontend_theme']); self::setBackendTheme($config['template']['backend_theme']); self::addBrowser('default', 'Standard Browser (Mozilla)', true, ''); }
/** * Creates the User-Object and the $session['user'] Array * * @param $user_id The ID of the User. * @param $email The email of the User. * @param $nick The nick of the User. */ public function createUserSession($user_id = '', $email = '', $nick = '') { // Initialize the User Object $this->user = null; /** * Get User via DB Queries * * 1) user_id * 2) email * 3) nick */ if (empty($user_id) === false) { // Get the user from the user_id $this->user = Doctrine_Query::create()->from('CsUsers u')->leftJoin('u.CsOptions o')->where('u.user_id = ?')->fetchOne(array($user_id), Doctrine::HYDRATE_ARRAY); } elseif (empty($email) === false) { // Get the user from the email $this->user = Doctrine_Query::create()->from('CsUsers u')->leftJoin('u.CsOptions o')->where('u.email = ?')->fetchOne(array($email), Doctrine::HYDRATE_ARRAY); } elseif (empty($nick) === false) { // Get the user from the nick $this->user = Doctrine_Query::create()->from('CsUsers u')->leftJoin('u.CsOptions o')->where('u.nick = ?')->fetchOne(array($nick), Doctrine::HYDRATE_ARRAY); } /** * Check if this user is activated, * else reset cookie, session and redirect */ if (is_array($this->user) and $this->user['activated'] == 0) { $this->logoutUser(); // redirect Clansuite_CMS::getInjector()->instantiate('Koch_HttpResponse')->redirect('/account/activation_email', 5, 403, _('Your account is not yet activated.')); } /** * Create $_SESSION['user'] array, containing user data */ if (is_array($this->user)) { /** * Transfer User Data into Session */ #Koch_Debug::firebug($_SESSION); #Koch_Debug::firebug($this->config); $_SESSION['user']['authed'] = 1; $_SESSION['user']['user_id'] = $this->user['user_id']; $_SESSION['user']['passwordhash'] = $this->user['passwordhash']; $_SESSION['user']['email'] = $this->user['email']; $_SESSION['user']['nick'] = $this->user['nick']; $_SESSION['user']['disabled'] = $this->user['disabled']; $_SESSION['user']['activated'] = $this->user['activated']; /** * SetLanguage * * At this position the language might already by set by * the language_via_get filter. the language value set via GET * precedes over the user config and the general config * the full order is * a) language_via_get filter * a) user['language'] from database / personal user setting * b) standard language / fallback as defined by $this->config['locale']['locale'] */ if (false === isset($_SESSION['user']['language_via_url'])) { if (false === empty($this->user['language'])) { $_SESSION['user']['language'] = $this->user['language']; } else { $_SESSION['user']['language'] = $this->config['locale']['default']; } } /** * Frontend-Theme * * first take standard theme as defined by $config->theme * @todo remove $_REQUEST, frontend theme is selectable via frontend */ if (false === isset($_REQUEST['theme'])) { $_SESSION['user']['frontend_theme'] = !empty($this->user['frontend_theme']) ? $this->user['frontend_theme'] : $this->config['template']['frontend_theme']; } /** * Backend-Theme */ if (empty($this->user['backend_theme']) === false) { $_SESSION['user']['backend_theme'] = $this->user['backend_theme']; } else { $_SESSION['user']['backend_theme'] = $this->config['template']['backend_theme']; } /** * Permissions * * Get Group & Rights of user_id */ /** User-Datensatz beinhaltet ein CsGroups-Array user => Array ( [user_id] => 1 ... [CsGroups] => Array ( [0] => Array ( [group_id] => 3 ... [role_id] => 5 ) ) ) */ // Initialize User Session Arrays $_SESSION['user']['group'] = ''; $_SESSION['user']['rights'] = ''; if (false === empty($this->user['CsGroups'])) { $_SESSION['user']['group'] = $this->user['CsGroups'][0]['group_id']; $_SESSION['user']['role'] = $this->user['CsGroups'][0]['role_id']; $_SESSION['user']['rights'] = Koch\ACL::createRightSession($_SESSION['user']['role'], $this->user['user_id']); } #Koch_Debug::firebug($_SESSION); } else { // this resets the $_SESSION['user'] array GuestUser::instantiate(); #Koch\Debug\Debug::printR($_SESSION); } }
/** * Generates a customized query for this entity/repository * * 1) $this->queryBuilder will contain a full select * 2) sorting is added * 3) search is added * 4) pagination limiting is is added * * var_dump($this->queryBuilder->getDQL()); * * @see $this->queryBuilder */ private function assembleQuery() { // get the "finder" method to use on the repository #$methodname = $this->getRepositoryMethodName(); // call repository method with variable methodname #$this->query = $this->getDoctrineRepository()->$methodname(); /** * get QueryBuilder so that we can append (sorting, search etc) to the Query */ $this->queryBuilder = Clansuite_CMS::getEntityManager()->createQueryBuilder()->select('a')->from($this->getDoctrineEntityName(), 'a'); $this->addSortingToQuery(); $this->addSearchToQuery(); $query = $this->addPaginationLimitToQuery(); return $query; }
/** * Name: loadmodule * Type: function * Purpose: This TAG inserts the a certain module and its widget. * * Static Function to Call variable Methods from templates via * {load_module name= sub= params=} * Parameters: name, sub, action, params, items * * Example: * {load_module name="quotes" action="widget_quotes"} * * @param array $params as described above (emmail, size, rating, defaultimage) * @param Smarty $smarty * @return string */ function smarty_function_load_module($params, $smarty) { // debug display for the incomming parameters of a specific load_module request /*if ($params['name'] == 'news') { Koch_Debug::firebug($params); }*/ // Init incomming Variables $module = isset($params['name']) ? (string) mb_strtolower($params['name']) : ''; $submodule = isset($params['sub']) ? (string) mb_strtolower($params['sub']) : ''; $action = isset($params['action']) ? (string) $params['action'] : ''; $items = isset($params['items']) ? (int) $params['items'] : null; // WATCH it, this resets the incomming parameters array #$params = isset( $params['params'] ) ? (string) $params['params'] : ''; $module_classname = 'clansuite_module_'; // Construct the variable module_name if (isset($submodule) and mb_strlen($submodule) > 0) { // like "clansuite_module_admin_news" $module_classname .= $module . '_' . $submodule; } else { // like "clansuite_module_news" $module_classname .= $module; } #Koch_Debug::firebug($module_classname); // Check if class was loaded if (class_exists($module_classname, false) === false) { // Load class, if not already loaded if (\Koch\View\Helper\Widget::loadModul($module_classname) === false) { return '<br/>Module missing or misspelled: <strong>' . $module_classname . '</strong>'; } } // Instantiate Class $controller = new $module_classname(Clansuite_CMS::getInjector()->instantiate('Koch_HttpRequest'), Clansuite_CMS::getInjector()->instantiate('Koch_HttpResponse')); $controller->setView($smarty); #$controller->setModel($module); /** * Get the Ouptut of the Object->Method Call */ if (method_exists($controller, $action)) { // exceptional handling of parameters and output for adminmenu if ($module_classname == 'clansuite_module_menu_admin') { $parameters = array(); // Build a Parameter Array from Parameter String like: param|param|etc if (empty($params['params'])) { $parameters = null; } else { $parameters = explode('\\|', $params['params']); } return $controller->{$action}($parameters); } // call $controller->{$action}($items); /** * Output the template of a widget * * The template is fetched from the module or from the various theme folders! * You can also set an alternative widgettemplate inside the widget itself * via setTemplate() method. * * The order of template detection is determined by the $smarty->template_dir array. * @see $smarty->template_dir */ // build template name $template = $action . '.tpl'; // for a look at the detection order uncomment the next line #Koch_Debug::printR($smarty->template_dir); if ($smarty->templateExists('modules' . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . $action . '.tpl')) { // $smarty->template_dir[s]..modules\news\widget_news.tpl return $smarty->fetch('modules' . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . $action . '.tpl'); } elseif ($smarty->templateExists('modules' . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'smarty' . DIRECTORY_SEPARATOR . $action . '.tpl')) { // $smarty->template_dir[s]..modules\news\view\widget_news.tpl return $smarty->fetch('modules' . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'smarty' . DIRECTORY_SEPARATOR . $action . '.tpl'); } elseif ($smarty->templateExists($module . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'smarty' . DIRECTORY_SEPARATOR . $action . '.tpl')) { // $smarty->template_dir[s]..\news\view\smarty\widget_news.tpl return $smarty->fetch($module . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'smarty' . DIRECTORY_SEPARATOR . $action . '.tpl'); } elseif ($smarty->templateExists($template)) { // $smarty->template_dir[s].. $template return $smarty->fetch($template); } else { return trigger_error('Error! Failed to load Widget-Template for <br /> ' . $module_classname . ' -> ' . $action . '(' . $items . ')'); } } else { return trigger_error('Error! Failed to load Widget: <br /> ' . $module_classname . ' -> ' . $action . '(' . $items . ')'); } }