/** * Display block */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('Zgoodies:marqueeblock:', "{$blockinfo['bid']}::", ACCESS_OVERVIEW)) { return; } if (!ModUtil::available('Zgoodies')) { return; } $vars = BlockUtil::varsFromContent($blockinfo['content']); $lang = ZLanguage::getLanguageCode(); // block title if (isset($vars['block_title'][$lang]) && !empty($vars['block_title'][$lang])) { $blockinfo['title'] = $vars['block_title'][$lang]; } // marquee content if (isset($vars['marquee_content'][$lang]) && !empty($vars['marquee_content'][$lang])) { $vars['marquee_content_lang'] = $vars['marquee_content'][$lang]; } if (!isset($vars['marquee_content'])) { $vars['marquee_content_lang'] = ''; } $this->view->assign('vars', $vars); $this->view->assign('bid', $blockinfo['bid']); $blockinfo['content'] = $this->view->fetch('blocks/' . $vars['block_template']); if (isset($vars['block_wrap']) && !$vars['block_wrap']) { if (empty($blockinfo['title'])) { return $blockinfo['content']; } else { return '<h4>' . DataUtil::formatForDisplayHTML($blockinfo['title']) . '</h4>' . "\n" . $blockinfo['content']; } } return BlockUtil::themeBlock($blockinfo); }
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); }
/** * 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 .= " <a href=\"{$url}\">" . __('Edit sub-categories') . '</a>'; } if ($assign) { $view->assign($assign, $html); } else { return $html; } }
/** * 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; } }
/** * 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); } } }
/** * 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; }
/** * Constructor. * * @param KernelInterface $kernel * @param RouterInterface $router The route generator * @param EngineInterface $templatingService * @param MarkdownExtra $parser */ public function __construct(KernelInterface $kernel, RouterInterface $router, EngineInterface $templatingService, MarkdownExtra $parser) { $this->kernel = $kernel; $this->router = $router; $this->templatingService = $templatingService; $this->parser = $parser; $this->locale = \ZLanguage::getLanguageCode(); }
/** * Retrieve an HTML unordered list of the categories assigned to a specified item. * * The assigned categories are retrieved from $item['__CATEGORIES__'] (DBUtil) or $item['Categories'] (Doctrine). * However, if we are using Doctrine 2, the categories are passed as param. * * Available attributes: * - item (array) The item from which to retrieve the assigned categories. * or * - categories (object) The item's categories. * - doctrine2 (boolean) true or false if using doctrine2 or not. * * Example: * * <samp>{assignedcategorieslist item=$myVar}</samp> * <samp>{assignedcategorieslist categories=$myCategories doctrine2=true}</samp> * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the {@link Zikula_View} object. * * @return string The HTML code for an unordered list containing the item's * assigned categories. If no categories are assigned to the * item, then the list will contain a single list-item (<li>) * with a message to that effect. */ function smarty_function_assignedcategorieslist($params, Zikula_View $view) { if (isset($params['doctrine2']) && (bool) $params['doctrine2'] == true) { if (!isset($params['categories'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assignedcategorieslist', 'categories'))); return false; } } elseif (!isset($params['item'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assignedcategorieslist', 'item'))); return false; } $lang = ZLanguage::getLanguageCode(); $result = "<ul>\n"; if (isset($params['doctrine2']) && (bool) $params['doctrine2'] == true) { if (count($params['categories']) > 0) { foreach ($params['categories'] as $category) { $name = $category->getCategory()->getName(); $display_name = $category->getCategory()->getDisplayName(); $result .= "<li>\n"; if (isset($display_name[$lang]) && !empty($display_name[$lang])) { $result .= $display_name[$lang]; } elseif (isset($name) && !empty($name)) { $result .= $name; } $result .= "</li>\n"; } } else { $result .= '<li>' . DataUtil::formatForDisplay(__('No assigned categories.')) . '</li>'; } } else { if (isset($params['item']['Categories']) && !empty($params['item']['Categories'])) { $categories = $params['item']['Categories']; } elseif (isset($params['item']['__CATEGORIES__']) && !empty($params['item']['__CATEGORIES__'])) { $categories = $params['item']['__CATEGORIES__']; } else { $categories = array(); } if (!empty($categories)) { foreach ($categories as $property => $category) { if (isset($category['Category'])) { $category = $category['Category']; } $result .= "<li>\n"; if (isset($category['display_name'][$lang])) { $result .= $category['display_name'][$lang]; } elseif (isset($category['name'])) { $result .= $category['name']; } $result .= "</li>\n"; } } else { $result .= '<li>' . DataUtil::formatForDisplay(__('No assigned categories.')) . '</li>'; } } $result .= "</ul>\n"; return $result; }
public function initialize(Zikula_Form_View $view) { $this->contentId = (int) FormUtil::getPassedValue('cid', isset($this->args['cid']) ? $this->args['cid'] : -1); $this->language = ZLanguage::getLanguageCode(); $content = ModUtil::apiFunc('Content', 'Content', 'getContent', array('id' => $this->contentId, 'language' => $this->language, 'translate' => false)); if ($content === false) { return $this->view->registerError(null); } $this->contentType = ModUtil::apiFunc('Content', 'Content', 'getContentType', $content); if ($this->contentType === false) { return $this->view->registerError(null); } $this->pageId = $content['pageId']; if ((bool) $this->getVar('inheritPermissions', false) === true) { if (!ModUtil::apiFunc('Content', 'page', 'checkPermissionForPageInheritance', array('pageId' => $this->pageId, 'level' => ACCESS_EDIT))) { throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission()); } } else { if (!SecurityUtil::checkPermission('Content:page:', $this->pageId . '::', ACCESS_EDIT)) { throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission()); } } $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId, 'includeContent' => false, 'filter' => array('checkActive' => false))); if ($page === false) { return $this->view->registerError(null); } if ($this->language == $page['language']) { return $this->view->registerError(LogUtil::registerError($this->__f('Sorry, you cannot translate an item to the same language as it\'s default language ("%1$s"). Change the current site language ("%2$s") to some other language on the <a href="%3$s">localisation settings</a> page.<br /> Another way is to add, for instance, <strong>&lang=de</strong> to the url for changing the current site language to German and after that the item can be translated to German.', array($page['language'], $this->language, ModUtil::url('Settings', 'admin', 'multilingual'))))); } $translationInfo = ModUtil::apiFunc('Content', 'Content', 'getTranslationInfo', array('contentId' => $this->contentId)); if ($translationInfo === false) { return $this->view->registerError(null); } PageUtil::setVar('title', $this->__("Translate content item") . ' : ' . $page['title']); $templates = $this->contentType['plugin']->getTranslationTemplates(); $this->view->assign('translationtemplates', $templates); $this->view->assign('page', $page); $this->view->assign('data', $content['data']); $this->view->assign('isTranslatable', $content['isTranslatable']); $this->view->assign('translated', isset($content['translated']) ? $content['translated'] : array()); $this->view->assign('translationInfo', $translationInfo); $this->view->assign('translationStep', $this->contentId); $this->view->assign('language', $this->language); $this->view->assign('contentType', $this->contentType); Content_Util::contentAddAccess($this->view, $this->pageId); if (!$this->view->isPostBack() && FormUtil::getPassedValue('back', 0)) { $this->backref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; } if ($this->backref != null) { $returnUrl = $this->backref; } else { $returnUrl = ModUtil::url('Content', 'admin', 'editpage', array('pid' => $this->pageId)); } ModUtil::apiFunc('PageLock', 'user', 'pageLock', array('lockName' => "contentTranslateContent{$this->contentId}", 'returnUrl' => $returnUrl)); return true; }
/** * Get Singleton instance. * * @param string $locale Locale. * * @return ZI18n object instance. */ public static function getInstance($locale = null) { if (!isset($locale)) { $locale = ZLanguage::getLanguageCode(); } if (!isset(self::$instance[$locale])) { self::$instance[$locale] = new self(new ZLocale($locale)); } return self::$instance[$locale]; }
/** * Gets all the notes created in the noteboard * @author: Albert Pérez Monfort (aperezm@xtec.cat) * @param: args $tema: it is used for filter the notes of a topyc * $nid: if only a note is showed * @return: And array with the items information */ public function getall($args) { $tema = FormUtil::getPassedValue('tema', isset($args['tema']) ? $args['tema'] : null, 'POST'); $nid = FormUtil::getPassedValue('nid', isset($args['nid']) ? $args['nid'] : null, 'POST'); $marked = FormUtil::getPassedValue('marked', isset($args['marked']) ? $args['marked'] : null, 'POST'); $public = FormUtil::getPassedValue('public', isset($args['public']) ? $args['public'] : null, 'POST'); $sv = FormUtil::getPassedValue('sv', isset($args['sv']) ? $args['sv'] : null, 'POST'); $numitems = (isset($args['numitems'])) ? $args['numitems'] : '-1'; if (!ModUtil::func('IWmain', 'user', 'checkSecurityValue', array('sv' => $sv))) { // Security check if (!SecurityUtil::checkPermission('IWnoteboard::', '::', ACCESS_READ)) { return LogUtil::registerPermissionError(); } } $pntable = DBUtil::getTables(); $c = $pntable['IWnoteboard_column']; if (!isset($nid)) { $time = time(); if ($tema > 0) { $where = "$c[caduca] > $time AND $c[tid]=$tema"; } elseif ($tema == '-1') { $where = "$c[caduca] > $time AND $c[tid]=0"; } else { $where = "$c[caduca] > $time"; } $orderby = "$c[edited] desc, $c[data] desc, $c[nid] desc"; } else { $registre = ModUtil::apiFunc('IWnoteboard', 'user', 'get', array('nid' => $nid)); if ($registre == false) { LogUtil::registerError($this->__('The note has not been found')); return System::redirect(ModUtil::url('IWnoteboard', 'user', 'main')); } $where = "$c[nid]=$nid"; $orderby = ''; } if (isset($marked) && $marked == 1) { $where .= " AND $c[marca] like '%$" . UserUtil::getVar('uid') . "$%'"; } if (isset($public) && $public == 1) { $where .= " AND $c[public] = 1"; } if (ModUtil::getVar('IWnoteboard', 'multiLanguage') == 1) { $where .= " AND ($c[lang]='" . ZLanguage::getLanguageCode() . "' OR $c[lang] = '')"; } // get the objects from the db $items = DBUtil::selectObjectArray('IWnoteboard', $where, $orderby, '-1', $numitems, 'nid'); // Check for an error with the database code, and if so set an appropriate // error message and return if ($items === false) { return LogUtil::registerError($this->__('Error! Could not load items.')); } // Return the items return $items; }
/** * This method provides a item detail view. * * @param string $tpl Name of alternative template (to be used instead of the default template). * @param boolean $raw Optional way to display a template instead of fetching it (required for standalone output). * * @return mixed Output. */ public function display() { $legacyControllerType = $this->request->query->filter('lct', 'user', FILTER_SANITIZE_STRING); System::queryStringSetVar('type', $legacyControllerType); $this->request->query->set('type', $legacyControllerType); $controllerHelper = new MUVideo_Util_Controller($this->serviceManager); // parameter specifying which type of objects we are treating $objectType = 'movie'; $utilArgs = array('controller' => 'movie', 'action' => 'display'); $permLevel = $legacyControllerType == 'admin' ? ACCESS_ADMIN : ACCESS_READ; $this->throwForbiddenUnless(SecurityUtil::checkPermission($this->name . ':' . ucwords($objectType) . ':', '::', $permLevel), LogUtil::getErrorMsgPermission()); $entityClass = $this->name . '_Entity_' . ucwords($objectType); $repository = $this->entityManager->getRepository($entityClass); $repository->setControllerArguments(array()); $idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $objectType)); // retrieve identifier of the object we wish to view $idValues = $controllerHelper->retrieveIdentifier($this->request, array(), $objectType, $idFields); $hasIdentifier = $controllerHelper->isValidIdentifier($idValues); $this->throwNotFoundUnless($hasIdentifier, $this->__('Error! Invalid identifier received.')); $selectionArgs = array('ot' => $objectType, 'id' => $idValues); $entity = ModUtil::apiFunc($this->name, 'selection', 'getEntity', $selectionArgs); $this->throwNotFoundUnless($entity != null, $this->__('No such item.')); unset($idValues); $entity->initWorkflow(); // build ModUrl instance for display hooks; also create identifier for permission check $currentUrlArgs = $entity->createUrlArgs(); $instanceId = $entity->createCompositeIdentifier(); $currentUrlArgs['id'] = $instanceId; // TODO remove this $currentUrlObject = new Zikula_ModUrl($this->name, 'movie', 'display', ZLanguage::getLanguageCode(), $currentUrlArgs); $this->throwForbiddenUnless(SecurityUtil::checkPermission($this->name . ':' . ucwords($objectType) . ':', $instanceId . '::', $permLevel), LogUtil::getErrorMsgPermission()); $viewHelper = new MUVideo_Util_View($this->serviceManager); $templateFile = $viewHelper->getViewTemplate($this->view, $objectType, 'display', array()); // set cache id $component = $this->name . ':' . ucwords($objectType) . ':'; $instance = $instanceId . '::'; $accessLevel = ACCESS_READ; if (SecurityUtil::checkPermission($component, $instance, ACCESS_COMMENT)) { $accessLevel = ACCESS_COMMENT; } if (SecurityUtil::checkPermission($component, $instance, ACCESS_EDIT)) { $accessLevel = ACCESS_EDIT; } $this->view->setCacheId($objectType . '|' . $instanceId . '|a' . $accessLevel); // assign output data to view object. $this->view->assign($objectType, $entity)->assign('currentUrlObject', $currentUrlObject)->assign($repository->getAdditionalTemplateParameters('controllerAction', $utilArgs)); // initialize $youtubeId = ''; // we get the id from the url $youtubeId = explode('=', $entity['urlOfYoutube']); // assign to template $this->view->assign('youtubeId', $youtubeId[1]); // fetch and return the appropriate template return $viewHelper->processTemplate($this->view, $objectType, 'display', array(), $templateFile); }
/** * Zikula_View function to get the site's language. * * Available parameters: * - assign if set, the language will be assigned to this variable * * Example * <html lang="{lang}"> * * @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 The language, null if params['assign'] is true. */ function smarty_function_lang($params, Zikula_View $view) { $assign = isset($params['assign']) ? $params['assign'] : null; $fs = isset($params['fs']) ? $params['fs'] : false; $result = $fs ? ZLanguage::transformFS(ZLanguage::getLanguageCode()) : ZLanguage::getLanguageCode(); if ($assign) { $view->assign($assign, $result); return; } return $result; }
function __construct($registryId = null, $parentId = null) { if (!empty($parentId)) { $this->parentId = $parentId; } else { $parentIdCategory = \CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/Global'); $this->parentId = $parentIdCategory['id']; } $this->registryId = $registryId; $this->lang = \ZLanguage::getLanguageCode(); }
/** * add a new admin message * This is a standard function that is called whenever an administrator * wishes to create a new module item * @author Mark West * @return string HTML output string */ function Admin_Messages_admin_new() { // Security check if (!SecurityUtil::checkPermission('Admin_Messages::', '::', ACCESS_ADD)) { return LogUtil::registerPermissionError(); } // Create output object $view = Zikula_View::getInstance('Admin_Messages', false); // Assign the default language $view->assign('language', ZLanguage::getLanguageCode()); // Return the output that has been generated by this function return $view->fetch('admin_messages_admin_new.htm'); }
public function isNecessary() { if (version_compare(ZIKULACORE_CURRENT_INSTALLED_VERSION, UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION, '<')) { throw new AbortStageException(__f('The current installed version of Zikula is reporting (%1$s). You must upgrade to version (%2$s) before you can use this upgrade.', array(ZIKULACORE_CURRENT_INSTALLED_VERSION, UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION))); } // make sure selected language is installed if (!in_array(\ZLanguage::getLanguageCode(), \ZLanguage::getInstalledLanguages())) { \System::setVar('language_i18n', 'en'); \System::setVar('language', 'eng'); \System::setVar('locale', 'en'); \ZLanguage::setLocale('en'); } return true; }
/** * Smarty function to displaya modules online manual * * Admin * {adminonlinemanual} * * @see function.admincategorymenu.php::smarty_function_admincategoreymenu() * @param array $params All attributes passed to this function from the template * @param object $smarty Reference to the Smarty object * @param int xhtml if set, the link to the navtabs.css will be xhtml compliant * @return string the results of the module function */ function smarty_function_adminonlinemanual($params, $smarty) { LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('adminonlinemanual')), E_USER_DEPRECATED); $lang = ZLanguage::transformFS(ZLanguage::getLanguageCode()); $modinfo = ModUtil::getInfoFromName(ModUtil::getName()); $modpath = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules'; $file = DataUtil::formatForOS("{$modpath}/{$modinfo['directory']}/lang/{$lang}/manual.html"); $man_link = ''; if (is_readable($file)) { PageUtil::addVar('javascript', 'zikula.ui'); $man_link = '<div style="margin-top: 20px; text-align:center">[ <a id="online_manual" href="' . $file . '">' . __('Online manual') . '</a> ]</div>' . "\n"; $man_link .= '<script type="text/javascript">var online_manual = new Zikula.UI.Window($(\'online_manual\'),{resizable: true})</script>' . "\n"; } return $man_link; }
/** * Add default pagevar settings to every page * @param GetResponseEvent $event */ public function setDefaultPageVars(GetResponseEvent $event) { if (!$event->isMasterRequest()) { return; } // set some defaults $this->pageVars->set('lang', \ZLanguage::getLanguageCode()); $this->pageVars->set('langdirection', \ZLanguage::getDirection()); $this->pageVars->set('title', \System::getVar('defaultpagetitle')); $this->pageVars->set('meta.charset', \ZLanguage::getDBCharset()); $this->pageVars->set('meta.description', \System::getVar('defaultmetadescription')); $this->pageVars->set('meta.keywords', \System::getVar('metakeywords')); $schemeAndHost = $event->getRequest()->getSchemeAndHttpHost(); $baseUrl = $event->getRequest()->getBaseUrl(); $this->pageVars->set('homepath', $schemeAndHost . $baseUrl); }
public function initialize(Zikula_Form_View $view) { $this->pageId = (int) FormUtil::getPassedValue('pid', -1); $this->language = ZLanguage::getLanguageCode(); if (!SecurityUtil::checkPermission('Content:page:', $this->pageId . '::', ACCESS_EDIT)) { throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission()); } $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId, 'includeContent' => false, 'filter' => array('checkActive' => false), 'translate' => false)); if ($page === false) { return $this->view->registerError(null); } // if trying to translate a page into the same language report error and redirect to page list if (!strcmp($this->language, $page['language'])) { return $this->view->registerError(LogUtil::registerError( $this->__f('Sorry, you cannot translate an item to the same language as it\'s default language ("%1$s"). Change the current site language ("%2$s") to some other language on the <a href="%3$s">localisation settings</a> page.<br /> Another way is to add, for instance, <strong>&lang=de</strong> to the url for changing the current site language to German and after that the item can be translated to German.', array($page['language'], $this->language, ModUtil::url('Settings', 'admin', 'multilingual'))), null, ModUtil::url('Content', 'admin', 'main'))); } PageUtil::setVar('title', $this->__("Translate page") . ' : ' . $page['title']); $this->view->assign('page', $page); $this->view->assign('translated', $page['translated']); $this->view->assign('language', $this->language); Content_Util::contentAddAccess($this->view, $this->pageId); if (!$this->view->isPostBack() && FormUtil::getPassedValue('back',0)) { $this->backref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; } if ($this->backref != null) { $returnUrl = $this->backref; } else { $returnUrl = ModUtil::url('Content', 'admin', 'editPage', array('pid' => $this->pageId)); } ModUtil::apiFunc('PageLock', 'user', 'pageLock', array('lockName' => "contentTranslatePage{$this->pageId}", 'returnUrl' => $returnUrl)); return true; }
protected function createRecords($pid = -1, $lvl = 0) { $sql = "SELECT * FROM " . $this->tablePrefix . "_ce_contentitems WHERE mc_parent_id={$pid} ORDER BY mc_id"; $pid = $pid == -1 ? 0 : $pid; $this->recordLevels[$pid] = $lvl; $result = DBUtil::executeSQL($sql); $pages = DBUtil::marshallObjects($result); $fieldmap = $this->getFieldMap(); $i = 0; foreach ($pages as $page) { // correct values to Content appropriate types $page['mc_parent_id'] = $page['mc_parent_id'] == -1 ? 0 : $page['mc_parent_id']; $page['mc_status'] = $page['mc_status'] - 1; // remap fieldnames $currentRecordCount = $this->recordCount; foreach ($fieldmap as $newfield => $oldfield) { $this->records[$currentRecordCount][$newfield] = $page[$oldfield]; } $this->records[$currentRecordCount]['language'] = ZLanguage::getLanguageCode(); $this->records[$currentRecordCount]['layouttype'] = 'Column1'; $this->records[$currentRecordCount]['position'] = $i; $this->records[$currentRecordCount]['level'] = $this->recordLevels[$page['mc_parent_id']]; $this->records[$currentRecordCount]['setleft'] = ++$this->structureIndex; //0; //++$left; // create contenttype items $this->records[$currentRecordCount]['useheader'] = true; // this could loop and create multiple contentitems if needed $this->records[$currentRecordCount]['contentitems'] = array(0 => array('contenttype' => 'Html', 'areaIndex' => '1', 'inputType' => 'text', 'data' => $page['mc_text'])); $this->recordCount++; $i++; // position index // create recursive records for all child pages $this->createRecords($page['mc_id'], $lvl + 1); $this->records[$currentRecordCount]['setright'] = ++$this->structureIndex; //1; //++$left; } //return count($pages); }
public function getPageContent($args) { $pageId = (int) $args['pageId']; $editing = (array_key_exists('editing', $args) ? $args['editing'] : false); $language = (array_key_exists('language', $args) ? $args['language'] : ZLanguage::getLanguageCode()); $expandContent = (array_key_exists('expandContent', $args) ? $args['expandContent'] : true); $translate = (array_key_exists('translate', $args) ? $args['translate'] : true); $contentList = $this->contentGetContent('page', $pageId, $editing, $language, $translate); $content = array(); foreach ($contentList as $c) { if (isset($c['plugin'])) { $c['title'] = $c['plugin']->getTitle(); $c['isTranslatable'] = $c['plugin']->isTranslatable(); // dup line 127? $output = ''; if ($expandContent) { $output = $c['plugin']->displayStart(); if ($editing) { $output .= $c['plugin']->displayEditing(); } else { $output .= $c['plugin']->display(); } $output .= $c['plugin']->displayEnd(); } $c['output'] = $output; $c['plugin']->destroyView(); // save memory } else { $c['title'] = $this->__('disabled plugin'); $c['isTranslatable'] = false; $c['output'] = $this->__f('Disabled: Inaccessible plugin output (%1$s, %2$s).', array($c['module'], $c['type'])); } $content[$c['areaIndex']][] = $c; } return $content; }
public function initialize(Zikula_Form_View $view) { if (!SecurityUtil::checkPermission('Content:page:', '::', ACCESS_EDIT)) { throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission()); } // Include categories only when 2nd category enabled in settings $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', array('editing' => true, 'filter' => array('checkActive' => false, 'expandedPageIds' => SessionUtil::getVar('contentExpandedPageIds', array())), 'enableEscape' => true, 'translate' => false, 'includeLanguages' => true, 'includeCategories' => $this->getVar('categoryUsage') < 3, 'orderBy' => 'setLeft')); if ($pages === false) { return $this->view->registerError(null); } // Get categories names if enabled if ($this->getVar('$categoryUsage') < 4) { $lang = ZLanguage::getLanguageCode(); $categories = array(); foreach ($pages as $page) { $cat = CategoryUtil::getCategoryByID($page['categoryId']); $categories[$page['id']] = array(); $categories[$page['id']][] = isset($cat['display_name'][$lang]) ? $cat['display_name'][$lang] : $cat['name']; if (isset($page['categories']) && is_array($page['categories'])) { foreach ($page['categories'] as $pageCat) { $cat = CategoryUtil::getCategoryByID($pageCat['categoryId']); $categories[$page['id']][] = isset($cat['display_name'][$lang]) ? $cat['display_name'][$lang] : $cat['name']; } } } $this->view->assign('categories', $categories); } PageUtil::setVar('title', $this->__('Page list and content structure')); $csssrc = ThemeUtil::getModuleStylesheet('admin', 'admin.css'); PageUtil::addVar('stylesheet', $csssrc); $this->view->assign('pages', $pages); $this->view->assign('multilingual', ModUtil::getVar(ModUtil::CONFIG_MODULE, 'multilingual')); $this->view->assign('enableVersioning', $this->getVar('enableVersioning')); $this->view->assign('language', ZLanguage::getLanguageCode()); Content_Util::contentAddAccess($this->view, null); return true; }
public function getAllForms($args) { $user = (isset($args['user'])) ? $args['user'] : null; $fid = (isset($args['fid'])) ? $args['fid'] : null; $sv = (isset($args['sv'])) ? $args['sv'] : null; if (!ModUtil::func('IWmain', 'user', 'checkSecurityValue', array('sv' => $sv))) { // Security check if (!SecurityUtil::checkPermission('IWforms::', "::", ACCESS_READ)) { throw new Zikula_Exception_Forbidden(); } } $pntable = DBUtil::getTables(); $c = $pntable['IWforms_definition_column']; $where = ''; if ($user != null) $where .= "$c[active]=1"; if ($fid != null) $where .= " AND $c[fid]=$fid"; // get user lang $lang = ZLanguage::getLanguageCode(); if (!isset($args['allLangs'])) { $where .= ($where == '') ? "$c[lang]='$lang' OR $c[lang] = ''" : " AND ($c[lang]='$lang' OR $c[lang] = '')"; } $orderby = "$c[formName]"; $items = DBUtil::selectObjectArray('IWforms_definition', $where, $orderby, '-1', '-1', 'fid'); // Check for an error with the database code, and if so set an appropriate // error message and return if ($items === false) { return LogUtil::registerError($this->__('Error! Could not load items.')); } // Return the items return $items; }
/** * Display a calendar input control. * * Display a calendar input control consisting of a calendar image, an optional * hidden input field, and associated javascript to render a pop-up calendar. * This function displays a javascript (jscalendar) calendar control. * * Available attributes: * - objectname (string) The name of the object the field will be placed in * - htmlname: (string) The html fieldname under which the date value will be submitted * - dateformat: (string) The dateformat to use for displaying the chosen date * - ifformat: (string) Format of the date field sent in the form (optional - defaults to dateformat) * - defaultstring (string) The String to display before a value has been selected * - defaultdate: (string) The Date the calendar should to default to (format: Y/m/d) * - hidden: (bool) If set, a hidden input field will be generated to hold the selected date * - display: (bool) If set, a <span> is generated to display the selected date (when date is added in a hidden field) * - class: (string) The class to apply to the html elements * - time: (bool) If set, show time selection * * Example: * * <samp>{calendarinput objectname='myobject' htmlname='from' dateformat='%Y-%m-%d' defaultdate='2005/12/31'}</samp> * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the {@link Zikula_View} object. * * @return string The HTML and Javascript code to display a calendar control. */ function smarty_function_calendarinput($params, Zikula_View $view) { if (!isset($params['objectname'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pncalendarinput', 'objectname'))); return false; } if (!isset($params['htmlname'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pncalendarinput', 'htmlname'))); return false; } if (!isset($params['dateformat'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pncalendarinput', 'dateformat'))); return false; } $ifformat = isset($params['ifformat']) ? $params['ifformat'] : $params['dateformat']; $inctime = isset($params['time']) ? (bool) $params['time'] : false; $validformats = array('%Y-%m-%d', '%Y-%m-%d %H:%M'); if (!in_array($ifformat, $validformats)) { $ifformat = $inctime ? '%Y-%m-%d %H:%M' : '%Y-%m-%d'; } // start of old pncalendarinit // pagevars make an extra pncalendarinit obsolete, they take care about the fact // that the styles/jsvascript do not get loaded multiple times static $firstTime = true; if ($firstTime) { $lang = ZLanguage::transformFS(ZLanguage::getLanguageCode()); // map of the jscalendar supported languages $map = array('ca' => 'ca_ES', 'cz' => 'cs_CZ', 'da' => 'da_DK', 'de' => 'de_DE', 'el' => 'el_GR', 'en-us' => 'en_US', 'es' => 'es_ES', 'fi' => 'fi_FI', 'fr' => 'fr_FR', 'he' => 'he_IL', 'hr' => 'hr_HR', 'hu' => 'hu_HU', 'it' => 'it_IT', 'ja' => 'ja_JP', 'ko' => 'ko_KR', 'lt' => 'lt_LT', 'lv' => 'lv_LV', 'nl' => 'nl_NL', 'no' => 'no_NO', 'pl' => 'pl_PL', 'pt' => 'pt_BR', 'ro' => 'ro_RO', 'ru' => 'ru_RU', 'si' => 'si_SL', 'sk' => 'sk_SK', 'sv' => 'sv_SE', 'tr' => 'tr_TR'); if (isset($map[$lang])) { $lang = $map[$lang]; } $headers[] = 'javascript/jscalendar/calendar.js'; if (file_exists("javascript/jscalendar/lang/calendar-{$lang}.utf8.js")) { $headers[] = "javascript/jscalendar/lang/calendar-{$lang}.utf8.js"; } $headers[] = 'javascript/jscalendar/calendar-setup.js'; PageUtil::addVar('stylesheet', 'javascript/jscalendar/calendar-win2k-cold-2.css'); PageUtil::addVar('javascript', $headers); } $firstTime = false; // end of old pncalendarinit if (!isset($params['defaultstring'])) { $params['defaultstring'] = null; } if (!isset($params['defaultdate'])) { $params['defaultdate'] = null; } $html = ''; $fieldKey = $params['htmlname']; if ($params['objectname']) { $fieldKey = $params['objectname'] . '[' . $params['htmlname'] . ']'; } $triggerName = 'trigger_' . $params['htmlname']; $displayName = 'display_' . $params['htmlname']; if (isset($params['class']) && !empty($params['class'])) { $params['class'] = ' class="' . DataUtil::formatForDisplay($params['class']) . '"'; } else { $params['class'] = ''; } if (isset($params['display']) && $params['display']) { $html .= '<span id="' . $displayName . '"' . $params['class'] . '>' . $params['defaultstring'] . '</span> '; } if (isset($params['hidden']) && $params['hidden']) { $html .= '<input type="hidden" name="' . $fieldKey . '" id="' . $params['htmlname'] . '" value="' . $params['defaultdate'] . '" />'; } $html .= '<img class="z-calendarimg" src="' . System::getBaseUrl() . 'javascript/jscalendar/img.gif" id="' . $triggerName . '" style="cursor: pointer;" title="' . DataUtil::formatForDisplay(__('Date selector')) . '" alt="' . DataUtil::formatForDisplay(__('Date selector')) . '" />'; $i18n = ZI18n::getInstance(); $html .= "<script type=\"text/javascript\">\n // <![CDATA[\n Calendar.setup(\n {"; //$html .= 'ifFormat : "%Y-%m-%d %H:%M:00",'; // universal format, don't change this! $html .= 'ifFormat : "' . $ifformat . '",'; $html .= 'inputField : "' . $params['htmlname'] . '",'; $html .= 'displayArea : "' . $displayName . '",'; $html .= 'daFormat : "' . $params['dateformat'] . '",'; $html .= 'button : "' . $triggerName . '",'; $html .= 'defaultDate : "' . $params['defaultdate'] . '",'; $html .= 'firstDay : "' . $i18n->locale->getFirstweekday() . '",'; $html .= 'align : "Tl",'; if (isset($params['defaultdate']) && $params['defaultdate']) { $d = strtotime($params['defaultdate']); $d = date('Y/m/d', $d); $html .= 'date : "' . $d . '",'; } if ($inctime) { $html .= 'showsTime : true,'; $html .= 'timeFormat : "' . $i18n->locale->getTimeformat() . '",'; } $html .= "singleClick : true });\n // ]]>\n </script>"; return $html; }
public function makeDisplayName($name) { return serialize(array(ZLanguage::getLanguageCode() => $name)); }
/** * Render event handler. * * @param Zikula_Form_View $view Reference to Zikula_Form_View object. * * @return string The rendered output */ public function render(Zikula_Form_View $view) { static $firstTime = true; $i18n = ZI18n::getInstance(); if (!empty($this->defaultValue) && !$view->isPostBack()) { $d = strtolower($this->defaultValue); $now = getdate(); $date = null; if ($d == 'now') { $date = time(); } elseif ($d == 'today') { $date = mktime(0, 0, 0, $now['mon'], $now['mday'], $now['year']); } elseif ($d == 'monthstart') { $date = mktime(0, 0, 0, $now['mon'], 1, $now['year']); } elseif ($d == 'monthend') { $daysInMonth = date('t'); $date = mktime(0, 0, 0, $now['mon'], $daysInMonth, $now['year']); } elseif ($d == 'yearstart') { $date = mktime(0, 0, 0, 1, 1, $now['year']); } elseif ($d == 'yearend') { $date = mktime(0, 0, 0, 12, 31, $now['year']); } elseif ($d == 'custom') { $date = strtotime($this->initDate); } if ($date != null) { $this->text = DateUtil::getDatetime($date, $this->ifFormat, false); } else { $this->text = __('Unknown date'); } } if ($view->isPostBack() && !empty($this->text)) { $date = strtotime($this->text); $this->text = DateUtil::getDatetime($date, $this->ifFormat, false); } if ($firstTime) { $lang = ZLanguage::transformFS(ZLanguage::getLanguageCode()); // map of the jscalendar supported languages $map = array('ca' => 'ca_ES', 'cz' => 'cs_CZ', 'da' => 'da_DK', 'de' => 'de_DE', 'el' => 'el_GR', 'en-us' => 'en_US', 'es' => 'es_ES', 'fi' => 'fi_FI', 'fr' => 'fr_FR', 'he' => 'he_IL', 'hr' => 'hr_HR', 'hu' => 'hu_HU', 'it' => 'it_IT', 'ja' => 'ja_JP', 'ko' => 'ko_KR', 'lt' => 'lt_LT', 'lv' => 'lv_LV', 'nl' => 'nl_NL', 'no' => 'no_NO', 'pl' => 'pl_PL', 'pt' => 'pt_BR', 'ro' => 'ro_RO', 'ru' => 'ru_RU', 'si' => 'si_SL', 'sk' => 'sk_SK', 'sv' => 'sv_SE', 'tr' => 'tr_TR'); if (isset($map[$lang])) { $lang = $map[$lang]; } $headers[] = 'javascript/jscalendar/calendar.js'; if (file_exists("javascript/jscalendar/lang/calendar-{$lang}.utf8.js")) { $headers[] = "javascript/jscalendar/lang/calendar-{$lang}.utf8.js"; } $headers[] = 'javascript/jscalendar/calendar-setup.js'; PageUtil::addVar('stylesheet', 'javascript/jscalendar/calendar-win2k-cold-2.css'); PageUtil::addVar('javascript', $headers); } $firstTime = false; $result = ''; if ($this->useSelectionMode) { $hiddenInputField = str_replace(array('type="text"', ' *'), array('type="hidden"', ''), parent::render($view)); $result .= '<div>' . $hiddenInputField . '<span id="' . $this->id . 'cal" style="background-color: #ff8; cursor: default" onmouseover="this.style.backgroundColor=\'#ff0\';" onmouseout="this.style.backgroundColor=\'#ff8\';">'; if ($this->text) { $result .= DataUtil::formatForDisplay(DateUtil::getDatetime(DateUtil::parseUIDate($this->text, $this->ifFormat), $this->daFormat)); } else { $result .= __('Select date'); } $result .= '</span></div>'; if ($this->mandatory && $this->mandatorysym) { $result .= '<span class="z-form-mandatory-flag">*</span>'; } } else { $result .= '<span class="z-form-date" style="white-space: nowrap">'; $result .= parent::render($view); $txt = __('Select date'); $result .= " <img id=\"{$this->id}_img\" src=\"javascript/jscalendar/img.gif\" style=\"vertical-align: middle\" class=\"clickable\" alt=\"{$txt}\" /></span>"; } // build jsCalendar script options $result .= "<script type=\"text/javascript\">\n // <![CDATA[\n Calendar.setup(\n {\n inputField : \"{$this->id}\","; if ($this->includeTime) { $this->initDate = str_replace('-', ',', $this->initDate); $result .= "\n ifFormat : \"" . $this->ifFormat . "\",\n showsTime : true,\n timeFormat : \"" . $i18n->locale->getTimeformat() . "\",\n singleClick : false,"; } else { $result .= "\n ifFormat : \"" . $this->ifFormat . "\","; } if ($this->useSelectionMode) { $result .= "\n displayArea : \"{$this->id}cal\",\n daFormat : \"{$this->daFormat}\",\n align : \"Bl\",\n singleClick : true,"; } else { $result .= "\n button : \"{$this->id}_img\","; } $result .= "\n firstDay: " . $i18n->locale->getFirstweekday() . "\n }\n );\n // ]]>\n </script>"; return $result; }
private function _createdefaultcategory($regpath = '/__SYSTEM__/Modules/Global') { // get the language $lang = ZLanguage::getLanguageCode(); // get the category path for which we're going to insert our place holder category $rootcat = CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules'); $qCat = CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/Ephemerides'); if (!$qCat) { // create placeholder for all our migrated categories $cat = new Categories_DBObject_Category(); $cat->setDataField('parent_id', $rootcat['id']); $cat->setDataField('name', 'Ephemerides'); $cat->setDataField('display_name', array($lang => $this->__('Ephemerides'))); $cat->setDataField('display_desc', array($lang => $this->__('Ephemerides'))); if (!$cat->validate('admin')) { return false; } $cat->insert(); $cat->update(); } // get the category path for which we're going to insert our upgraded categories $rootcat = CategoryUtil::getCategoryByPath($regpath); if ($rootcat) { // create an entry in the categories registry $registry = new Categories_DBObject_Registry(); $registry->setDataField('modname', 'Ephemerides'); $registry->setDataField('table', 'ephem'); $registry->setDataField('property', 'Main'); $registry->setDataField('category_id', $rootcat['id']); $registry->insert(); } else { return false; } return true; }
/** * Get homepage URL for Zikula. * * @return string Homepage URL for Zikula. */ public static function getHomepageUrl() { // check the use of friendly url setup $shorturls = self::getVar('shorturls', false); $langRequired = ZLanguage::isRequiredLangParam(); $expectEntrypoint = !self::getVar('shorturlsstripentrypoint'); $entryPoint = self::getVar('entrypoint'); if ($shorturls) { $result = self::getBaseUrl(); if ($expectEntrypoint) { $result .= "{$entryPoint}"; } if ($langRequired) { $result .= (preg_match('#/$#', $result) ? '' : '/') . ZLanguage::getLanguageCode(); } } else { $result = self::getVar('entrypoint', 'index.php'); if (ZLanguage::isRequiredLangParam()) { $result .= '?lang=' . ZLanguage::getLanguageCode(); } } return $result; }
public function handleCommand(Zikula_Form_View $view, &$args) { $url = null; if ($args['commandName'] == 'save' || $args['commandName'] == 'translate') { if (!$this->view->isValid()) { return false; } $contentData = $this->view->getValues(); $message = null; if (!$this->contentType['plugin']->isValid($contentData['data'], $message)) { $errorPlugin = $this->view->getPluginById('error'); $errorPlugin->message = $message; return false; } $this->contentType['plugin']->loadData($contentData['data']); if (strtolower($this->contentType['name']) == 'html') { // special hook for Html Contenttype must be processed here. $hook = new Zikula_ValidationHook('content.ui_hooks.htmlcontenttype.validate_edit', new Zikula_Hook_ValidationProviders()); $this->notifyHooks($hook); if ($hook->getValidators()->hasErrors()) { return $this->view->registerError($this->__('Error validating hooked content.')); } } $ok = ModUtil::apiFunc('Content', 'Content', 'updateContent', array( 'content' => $contentData + $contentData['content'], 'searchableText' => $this->contentType['plugin']->getSearchableText(), 'id' => $this->contentId)); if ($ok === false) { return $this->view->registerError(null); } if (strtolower($this->contentType['name']) == 'html') { // special hook for Html Contenttype must be processed here. // 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.htmlcontenttype.process_edit', $this->contentId, $objectUrl)); } if ($args['commandName'] == 'translate') { $url = ModUtil::url('Content', 'admin', 'translatecontent', array( 'cid' => $this->contentId, 'back' => 1)); } } else if ($args['commandName'] == 'delete') { if (strtolower($contentData['type'] == 'html')) { // special hook for Html Contenttype must be processed here. $hook = new Zikula_ValidationHook('content.ui_hooks.htmlcontenttype.validate_delete', new Zikula_Hook_ValidationProviders()); $this->notifyHooks($hook); if ($hook->getValidators()->hasErrors()) { return $this->view->registerError($this->__('Error validating hooked content.')); } } $ok = ModUtil::apiFunc('Content', 'Content', 'deleteContent', array('contentId' => $this->contentId)); if ($ok === false) { return $this->view->registerError(null); } if (strtolower($contentData['type'] == 'html')) { // special hook for Html Contenttype must be processed here. // notify any hooks they may now commit the as the original form has been committed. $this->notifyHooks(new Zikula_ProcessHook('content.ui_hooks.htmlcontenttype.process_delete', $this->contentId)); } } else if ($args['commandName'] == 'cancel') { } if ($url == null) { $url = $this->backref; } if (empty($url)) { $url = ModUtil::url('Content', 'admin', 'editpage', array('pid' => $this->pageId)); } ModUtil::apiFunc('PageLock', 'user', 'releaseLock', array('lockName' => "contentContent{$this->contentId}")); return $this->view->redirect($url); }
function simpledisplay($args) { // security check if (!SecurityUtil::checkPermission('AddressBook::', '::', ACCESS_READ)) { return LogUtil::registerPermissionError(); } $ot = FormUtil::getPassedValue('ot', isset($args['ot']) ? $args['ot'] : 'address', 'GET'); $id = (int) FormUtil::getPassedValue('id', isset($args['id']) ? $args['id'] : null, 'GET'); $category = FormUtil::getPassedValue('category', 0); $private = FormUtil::getPassedValue('private', 0); unset($args); $lang = ZLanguage::getLanguageCode(); if (!$id) { return z_exit($this->__f('Error! Invalid id [%s] received.', $id)); } // get the details $object = new AddressBook_DBObject_Address(); $data = $object->get($id); // get the custom fields $cus_where = ""; $cus_sort = "cus_pos ASC"; $cus_Array = new AddressBook_DBObject_CustomfieldArray(); $customfields = $cus_Array->get($cus_where, $cus_sort); foreach ($customfields as $key => $customfield) { if (isset($customfield['name1']) && $customfield['name1'] && $lang != 'en') { $customfields[$key]['name'] = $customfield['name1']; } } // Labels $addressbook_labels = DBUtil::selectObjectArray('addressbook_labels'); $ablabels = array(); foreach ($addressbook_labels as $addressbook_label) { if (isset($addressbook_label['name1']) && $addressbook_label['name1'] && $lang != 'en') { $addressbook_label['name'] = $addressbook_label['name1']; } $ablabels[$addressbook_label['id']] = $addressbook_label; } $this->view->assign('address', $data); $this->view->assign('customfields', $customfields); $this->view->assign('ot', $ot); $this->view->assign('category', $category); $this->view->assign('private', $private); $this->view->assign('preferences', ModUtil::getVar('AddressBook')); $this->view->assign('lang', $lang); $this->view->assign('ablabels', $ablabels); return $this->view->fetch('user_simpledisplay.tpl'); }