public function doWidget() { $oListTag = new TagWriter('div'); $oListTag->addToParameter('class', 'ui-tree'); $oListTag->setParameter('data-widget-session', $this->sPersistentSessionKey); $oListTag->setParameter('data-widget-type', $this->getModuleName()); return $oListTag->parse(); }
public function doWidget() { if (!$this->oInternalWidget instanceof WidgetModule) { return TagWriter::quickTag('form', array(), $this->oInternalWidget); } return $this->oInternalWidget->doWidget(); }
public function doWidget() { $oElement = $this->getElementType(); if ($oElement === null) { return null; } if (!$oElement instanceof TagWriter) { $oElement = new TagWriter($oElement); } $oElement->setParameter('data-widget-type', $this->getModuleName()); $oElement->setParameter('data-widget-session', $this->sPersistentSessionKey); if ($this->sInputName !== null) { $oElement->setParameter('name', $this->sInputName); } return $oElement->parse(); }
public function renderFile() { $bCleanup = Manager::usePath() === self::DO_CLEANUP; $aReferences = ReferenceQuery::create()->find(); self::checkReferences($aReferences, $bCleanup); if (count(self::$REFERENCES_WITHOUT_FROM) === 0 && count(self::$REFERENCES_WITHOUT_TO) === 0) { if (!$bCleanup) { print TranslationPeer::getString('test_references.references_are_ok', null, null, array('count' => count($aReferences))); } else { print TranslationPeer::getString('test_references.wrong_references_removed'); print TagWriter::quickTag('p', array(), TagWriter::quickTag('a', array('href' => LinkUtil::link(array('test_references'), 'FileManager')), TranslationPeer::getString('test_references.test_again'))); } } else { if (count(self::$REFERENCES_WITHOUT_FROM) > 0) { print TagWriter::quickTag('p', array(), count(self::$REFERENCES_WITHOUT_FROM) . TranslationPeer::getString('test_references.loose_from_references_found')); foreach (self::$REFERENCES_WITHOUT_FROM as $oReference) { print TagWriter::quickTag('p', array(), $oReference->getFromModelName() . '/' . $oReference->getFromId()); } } if (count(self::$REFERENCES_WITHOUT_TO) > 0) { print TagWriter::quickTag('p', array(), count(self::$REFERENCES_WITHOUT_TO) . TranslationPeer::getString('test_references.loose_to_references_found')); foreach (self::$REFERENCES_WITHOUT_TO as $oReference) { print TagWriter::quickTag('p', array(), $oReference->getToModelName() . '/' . $oReference->getToId()); } } print TagWriter::quickTag('p', array(), TagWriter::quickTag('a', array('href' => LinkUtil::link(array('test_references', self::DO_CLEANUP), 'FileManager')), TranslationPeer::getString('test_references.remove_loose_ends'))); } }
public static function getReferences($aReferences) { if (count($aReferences) === null) { return null; } $aResult = array(); foreach ($aReferences as $oReference) { if ($oReference->getFromModelName() === 'LanguageObject') { $oReferencedFromObject = $oReference->getFrom(); if ($oReferencedFromObject) { $oContentObject = $oReferencedFromObject->getContentObject(); $aResult[$oReferencedFromObject->getId()]['title'] = TranslationPeer::getString('reference.used_in_page'); $aResult[$oReferencedFromObject->getId()]['page_name'] = $oContentObject->getPage()->getName(); $aResult[$oReferencedFromObject->getId()]['container_name'] = $oContentObject->getContainerName(); $aResult[$oReferencedFromObject->getId()]['edit_link'] = TagWriter::quickTag('a', array('href' => LinkUtil::link(array('content', $oContentObject->getPageId(), 'edit', $oContentObject->getId()), 'AdminManager')), 'edit')->render(); } else { // delete reference if getFrom() === null $oReference->delete(); } } else { $aResult[$oReference->getFromId()]['title'] = TranslationPeer::getString('reference.used_in_object'); $aResult[$oReference->getFromId()]['object_class'] = $oReference->getFromModelName(); $aResult[$oReference->getFromId()]['object_id'] = $oReference->getFromId(); } } return $aResult; }
public function renderBackend() { $oTemplate = $this->constructTemplate('config'); // Display options $aDisplayOptions = array(); foreach (self::$DISPLAY_OPTIONS as $sDisplayMode) { $aDisplayOptions[$sDisplayMode] = TranslationPeer::getString('journal.display_mode.' . $sDisplayMode, null, StringUtil::makeReadableName($sDisplayMode)); } $oTemplate->replaceIdentifier('display_options', TagWriter::optionsFromArray($aDisplayOptions, null, null, array())); // Journal pages and journal options $aJournalOptions = array(); foreach (PageQuery::create()->filterByPageType('journal')->orderByName()->find() as $oPage) { $aJournalOptions['page' . self::PAGE_SEPARATOR . $oPage->getId()] = TranslationPeer::getString('wns.journal.journal_page_name', null, null, array('name' => $oPage->getLinkText())); } foreach (JournalQuery::create()->orderByName()->find() as $oJournal) { $aJournalOptions[$oJournal->getId()] = TranslationPeer::getString('wns.journal.journal_name', null, null, array('name' => $oJournal->getName())); } $oTemplate->replaceIdentifier('journal_options', TagWriter::optionsFromArray($aJournalOptions)); return $oTemplate; }
public function renderDetail(Documentation $oDocumentation = null) { if (self::$DOCUMENTATION_PARTS == null) { self::$DOCUMENTATION_PARTS = DocumentationPartQuery::create()->filterByDocumentationId($oDocumentation->getId())->filterByIsPublished(true)->orderBySort()->find(); } if ($oDocumentation) { $sName = $oDocumentation->getName(); $sEmbedUrl = $oDocumentation->getYoutubeUrl(); $sDescription = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($oDocumentation->getDescription())); } else { $sName = TranslationPeer::getString('documentations.uncategorized'); $sEmbedUrl = null; $sDescription = null; } $oTemplate = $this->constructTemplate('documentation'); // render video if exists if ($sEmbedUrl != null) { $this->embedVideo($oTemplate, $sEmbedUrl); } $oTemplate->replaceIdentifier('documentation_name', $sName); $oTemplate->replaceIdentifier('description', $sDescription); // render parts $oPartTmpl = $this->constructTemplate('part'); $sLinkToSelf = LinkUtil::linkToSelf(); $bRequiresQuicklinks = count(self::$DOCUMENTATION_PARTS) > 1; $oPartLinkPrototype = $this->constructTemplate('part_link'); foreach (self::$DOCUMENTATION_PARTS as $sKey => $mPart) { if ($mPart === true) { $mPart = DocumentationPartQuery::create()->filterByKey($sKey)->findOne(); } $bIsOverview = false; if ($mPart instanceof DocumentationPart) { //Internal documentation $sBody = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($mPart->getBody())); $sLinkText = $mPart->getName(); $sTitle = $mPart->getTitle(); $sImageUrl = null; if ($mPart->getDocument()) { $sImageUrl = $mPart->getDocument()->getDisplayUrl(); if (RichtextUtil::$USE_ABSOLUTE_LINKS) { $sImageUrl = LinkUtil::absoluteLink($sImageUrl); } } $sKey = $mPart->getKey(); $bIsOverview = $mPart->getIsOverview(); $sExternalLink = null; } else { //External documentation $aData = DocumentationProviderTypeModule::dataForPart($sKey, Session::language()); $sBody = new Template($aData['content'], null, true); $sLinkText = $aData['title']; $sTitle = null; $sImageUrl = null; $sExternalLink = $aData['url']; } // Add quick links if ($bRequiresQuicklinks) { $oPartLink = clone $oPartLinkPrototype; $oPartLink->replaceIdentifier('href', $sLinkToSelf . '#' . $sKey); $oPartLink->replaceIdentifier('link_text', $sLinkText); if ($sTitle != null) { $oPartLink->replaceIdentifier('title', $sTitle); } $oTemplate->replaceIdentifierMultiple('part_links', $oPartLink, null, Template::NO_NEW_CONTEXT); } // Add documentation part $oPartTemplate = clone $oPartTmpl; $oPartTemplate->replaceIdentifier('name', $sLinkText); $oPartTemplate->replaceIdentifier('anchor', $sKey); $oPartTemplate->replaceIdentifier('href_top', $sLinkToSelf . "#top_of_page"); $oPartTemplate->replaceIdentifier('external_link', $sExternalLink); if ($sImageUrl) { $oPartTemplate->replaceIdentifier('image', TagWriter::quickTag('img', array('class' => !$bIsOverview ? 'image_float' : "image_fullwidth", 'src' => $sImageUrl, 'alt' => 'Bildschirmfoto von ' . $sLinkText))); $oPartTemplate->replaceIdentifier('margin_left_class', $bIsOverview ? '' : ' margin_left_class'); } $oPartTemplate->replaceIdentifier('content', $sBody); $oTemplate->replaceIdentifierMultiple('part', $oPartTemplate); } return $oTemplate; }
private function addPartLink($oPart) { if (!self::$DOCUMENTATION_PAGE) { self::$DOCUMENTATION_PAGE = PageQuery::create()->filterByIdentifier(DocumentationFilterModule::PARENT_PAGE_IDENTIFIER)->findOne(); } if (!self::$DOCUMENTATION_PAGE) { return; } $sLink = LinkUtil::absoluteLink(LinkUtil::link(array_merge(self::$DOCUMENTATION_PAGE->getFullPathArray(), array($oPart->getDocumentation()->getKey())), 'FrontendManager'), null, 'auto'); return TagWriter::quickTag('a', array('target' => 'documentation', 'href' => $sLink . '#' . $oPart->getKey()), $oPart->getName()); }
public static function quickTag($sTagName = 'div', $aParameters = array(), $sContent = '') { $oTagWriter = new TagWriter($sTagName, $aParameters, $sContent); return $oTagWriter->parse(); }
/** * Does the actual parsing of the tag to produce valid XHTML output. The default implementation uses a TagWriter to produce the tag contents, passing it the name, parameters and parsed children (as string). * * If a parse callback is set, it relies on its implementation to return valid output given the parsed children. * Most callbacks will want to use TagWriter as well but transform the output a bit before doing so. */ public function __toString() { $sParsedChildren = ""; foreach ($this->aChildren as $mChild) { if ($mChild instanceof HtmlTag) { $sParsedChildren .= $mChild->__toString(false); } else { $sParsedChildren .= Template::htmlEncode($mChild); } } $sResult = ""; if ($this->mParseCallback === null) { $oTagWriter = new TagWriter($this->sName, $this->aParameters, $sParsedChildren); $sResult = $oTagWriter->parse(true)->render(); } else { $sResult = call_user_func($this->mParseCallback, $this, $sParsedChildren); } return $sResult; }
/** * displayNewsletterList() * @param int/array subscriber group ids * @param boolean detail view link type * * Description $bDisplayFileLink * • true > render link to original newsletter view of get_file/display_newsletter/ analog to alternative view linked in newsletter * • false: display database "newsletter_body" only in normal page view * * @return Template */ private function displayNewsletterList($mSubscriberGroupId, $bDisplayFileLink = true) { $oQuery = NewsletterQuery::create()->distinct()->filterApprovedForLanguage(Session::language())->orderByCreatedAt(Criteria::DESC); if ($mSubscriberGroupId) { $oQuery->joinNewsletterMailing()->useQuery('NewsletterMailing')->filterBySubscriberGroupId($mSubscriberGroupId)->endUse(); } $aRecentNewsletters = $oQuery->limit(10)->find(); $bHasNewsletters = count($aRecentNewsletters) > 0; $oTemplate = $this->constructTemplate('newsletter_display_list'); if ($bHasNewsletters === false) { $oTemplate->replaceIdentifier('newsletter_item', TagWriter::quickTag('p', array('class' => 'no_result_message'), TranslationPeer::getString('wns.newsletter.no_newsletter_available'))); } if ($bDisplayFileLink) { $oItemPrototype = $this->constructTemplate('newsletter_list_item_file_module'); } else { $this->setNewsletter($mSubscriberGroupId); $oItemPrototype = $this->constructTemplate('newsletter_list_item'); } $oPage = FrontendManager::$CURRENT_PAGE; foreach ($aRecentNewsletters as $oNewsletter) { $oItemTemplate = clone $oItemPrototype; $oItemTemplate->replaceIdentifier('subject', $oNewsletter->getSubject()); if ($bDisplayFileLink) { $oItemTemplate->replaceIdentifier('newsletter_link', $oNewsletter->getDisplayLink()); } else { if ($oNewsletter === self::$NEWSLETTER) { $oItemTemplate->replaceIdentifier('class_active', ' class="active"', null, Template::NO_HTML_ESCAPE); } $oItemTemplate->replaceIdentifier('newsletter_link', LinkUtil::link($oPage->getFullPathArray(array(self::IDENTIFIER_DETAIL, $oNewsletter->getId())))); } $oItemTemplate->replaceIdentifier('date', $oNewsletter->getLastSent()); $oItemTemplate->replaceIdentifier('template_name', $oNewsletter->getTemplateName()); $oItemTemplate->replaceIdentifier('language_id', $oNewsletter->getLanguageId()); $oTemplate->replaceIdentifierMultiple('newsletter_item', $oItemTemplate); } return $oTemplate; }
/** * Used as a callback to calculate the value of `page_link` identifiers in the template. * @param TemplateIdentifier $oTemplateIdentifier The TemplateIdentifier whose name is “page_link” * @return Template the Template containing a link * used in fillAttributes to replace page_link identifiers * - get a page by name * - get a page by id * - get a page by identifier string * - get nearest neighbor page {@link PageQuery::findOneByName()} */ public static function replacePageLinkIdentifier($oTemplateIdentifier) { $oPage = null; $sIdentifier = $oTemplateIdentifier->getParameter('identifier'); if ($sIdentifier !== null) { $oPage = PageQuery::create()->findOneByIdentifier($sIdentifier); } else { $iId = $oTemplateIdentifier->getParameter('id'); if ($iId !== null) { $oPage = PageQuery::create()->findPk($iId); } else { $sName = $oTemplateIdentifier->getParameter('name'); if ($sName !== null) { if ($oTemplateIdentifier->hasParameter('nearest_neighbour')) { $oPage = self::$CURRENT_PAGE->getPageOfName($sName); } else { $oPage = PageQuery::create()->findOneByName($sName); } } } } if ($oPage === null) { return null; } // hack to be able to display another name than the page_name, thanks to sl if ($oTemplateIdentifier->hasParameter('href_only')) { return LinkUtil::link($oPage->getLink()); } if (self::$CURRENT_PAGE !== null && self::$CURRENT_PAGE->getId() == $oPage->getId()) { return TagWriter::quickTag('span', array('class' => "meta_navigation {$oPage->getName()}", 'title' => $oPage->getPageTitle()), $oPage->getLinkText()); } return TagWriter::quickTag('a', array('class' => "meta_navigation {$oPage->getName()}", 'href' => LinkUtil::link($oPage->getLink()), 'title' => $oPage->getPageTitle()), $oPage->getLinkText()); }
/** * renderRecentCommentsWidget() * * description: renders a comments teaser list * change limit count by overwriting the config param "recent_comments_limit" in your site/config/config.yml * @return Template object */ private function renderRecentCommentsWidget() { $oTemplate = $this->constructTemplate('widget_recent_comments'); $oItemPrototype = $this->constructTemplate('widget_recent_comment_item'); $iLimit = Settings::getSetting('journal', 'recent_comments_limit', 3); $oQuery = JournalCommentQuery::create()->excludeUnverified()->mostRecentFirst()->limit($iLimit)->useJournalEntryQuery()->filterByJournalId($this->aJournalIds)->endUse()->groupByJournalEntryId(); foreach ($oQuery->find() as $oComment) { $oCommentTemplate = clone $oItemPrototype; if ($oEntry = $oComment->getJournalEntry()) { $oCommentTemplate->replaceIdentifier('title', $oEntry->getTitle()); $oDetailLink = TagWriter::quickTag('a', array('rel' => 'internal', 'class' => 'read_more', 'href' => LinkUtil::link($oEntry->getLink($this->oPage)) . '#comments'), TranslationPeer::getString('journal_entry_teaser.read_more')); $oCommentTemplate->replaceIdentifier('link_to_detail', $oDetailLink); } $oCommentTemplate->replaceIdentifier('name', $oComment->getUsername()); $oCommentTemplate->replaceIdentifier('date', $oComment->getCreatedAtLocalized()); $oCommentTemplate->replaceIdentifier('text_stripped', StringUtil::truncate(strip_tags($oComment->getText()), 45)); $oCommentTemplate->replaceIdentifier('text', $oComment->getText()); $oTemplate->replaceIdentifierMultiple('comments', $oCommentTemplate); } return $oTemplate; }
public function adminGetContainers() { $oTemplate = $this->oPage->getTemplate(); foreach ($oTemplate->identifiersMatching('container', Template::$ANY_VALUE) as $oIdentifier) { $oInheritedFrom = null; $sContainerName = $oIdentifier->getValue(); if (BooleanParser::booleanForString($oIdentifier->getParameter('inherit'))) { $oInheritedFrom = $this->oPage; $iInheritedObjectCount = 0; while ($iInheritedObjectCount === 0 && ($oInheritedFrom = $oInheritedFrom->getParent()) !== null) { $iInheritedObjectCount = $oInheritedFrom->countObjectsForContainer($sContainerName); } } $sInheritedFrom = $oInheritedFrom ? $oInheritedFrom->getName() : ''; $aTagParams = array('class' => 'template-container template-container-' . $sContainerName, 'data-container-name' => $sContainerName, 'data-container-string' => TranslationPeer::getString('container_name.' . $sContainerName, null, $sContainerName), 'data-inherited-from' => $sInheritedFrom); $oContainerTag = TagWriter::quickTag('ol', $aTagParams); $mInnerTemplate = new Template(TemplateIdentifier::constructIdentifier('content'), null, true); //Replace container info //…name $mInnerTemplate->replaceIdentifierMultiple('content', TagWriter::quickTag('div', array('class' => 'template-container-description'), TranslationPeer::getString('wns.page.template_container', null, null, array('container' => TranslationPeer::getString('template_container.' . $sContainerName, null, $sContainerName)), true))); //…additional info $mInnerTemplate->replaceIdentifierMultiple('content', TagWriter::quickTag('div', array('class' => 'template-container-info'))); //…tag $mInnerTemplate->replaceIdentifierMultiple('content', $oContainerTag); //Replace actual container $oTemplate->replaceIdentifier($oIdentifier, $mInnerTemplate); } $bUseParsedCss = Settings::getSetting('admin', 'use_parsed_css_in_config', true); $oStyle = null; if ($bUseParsedCss) { $sTemplateName = $this->oPage->getTemplateNameUsed() . Template::$SUFFIX; $sCacheKey = 'parsed-css-' . $sTemplateName; $oCssCache = new Cache($sCacheKey, DIRNAME_PRELOAD); $sCssContents = ""; if (!$oCssCache->entryExists() || $oCssCache->isOutdated(ResourceFinder::create(array(DIRNAME_TEMPLATES, $sTemplateName)))) { $oIncluder = new ResourceIncluder(); foreach ($oTemplate->identifiersMatching('addResourceInclude', Template::$ANY_VALUE) as $oIdentifier) { $oIncluder->addResourceFromTemplateIdentifier($oIdentifier); } foreach ($oIncluder->getAllIncludedResources() as $sIdentifier => $aResource) { if ($aResource['resource_type'] === ResourceIncluder::RESOURCE_TYPE_CSS && !isset($aResource['ie_condition']) && !isset($aResource['frontend_specific'])) { if (isset($aResource['media'])) { $sCssContents .= "@media {$aResource['media']} {"; } if (isset($aResource['file_resource'])) { $sCssContents .= file_get_contents($aResource['file_resource']->getFullPath()); } else { // Absolute link, requires fopen wrappers $sCssContents .= file_get_contents($aResource['location']); } if (isset($aResource['media'])) { $sCssContents .= "}"; } } } $oParser = new Sabberworm\CSS\Parser($sCssContents, Sabberworm\CSS\Settings::create()->withDefaultCharset(Settings::getSetting("encoding", "browser", "utf-8"))); $oCss = $oParser->parse(); $this->cleanupCSS($oCss); $sCssContents = Template::htmlEncode($oCss->render(Sabberworm\CSS\OutputFormat::createCompact())); $oCssCache->setContents($sCssContents); } else { $sCssContents = $oCssCache->getContentsAsString(); } $oStyle = new HtmlTag('style'); $oStyle->addParameters(array('scoped' => 'scoped')); $oStyle->appendChild($sCssContents); } $sTemplate = $oTemplate->render(); $sTemplate = substr($sTemplate, strpos($sTemplate, '<body') + 5); $sTemplate = substr($sTemplate, strpos($sTemplate, '>') + 1); $sTemplate = substr($sTemplate, 0, strpos($sTemplate, '</body')); $oParser = new TagParser("<body>{$sTemplate}</body>"); $oTag = $oParser->getTag(); $this->cleanupContainerStructure($oTag); if ($bUseParsedCss) { $oTag->appendChild($oStyle); } $sResult = $oTag->__toString(); $sResult = substr($sResult, strpos($sResult, '<body>') + 6); $sResult = substr($sResult, 0, strrpos($sResult, '</body>')); return array('html' => $sResult, 'css_parsed' => $bUseParsedCss); }
public function testTemplateObjectReplace() { $oTestTemplate = new Template('{{test}}', null, true); $oTagWriter = new TagWriter('a'); $oTestTemplate->replaceIdentifier('test', $oTagWriter->parse()); $this->assertSame("<a></a>", $oTestTemplate->render()); }
public function textTagParseCallback($oHtmlTag, $sParsedChildren) { if ($oHtmlTag->getName() === 'text') { return $sParsedChildren; } if ($oHtmlTag->getName() === 'img') { if (preg_match("%display_document/(\\d+)%", $oHtmlTag->getParameter('src'), $aMatches)) { $aParameters = $oHtmlTag->getParameters(); $this->addTrackReference($aMatches[1], "Document"); return TemplateIdentifier::constructIdentifier('image', $aMatches[1], $aParameters); } } if ($oHtmlTag->getName() === 'a') { if ($sParsedChildren === '') { return ''; } $bHasMatched = preg_match("%/" . preg_quote(Manager::getPrefixForManager('FileManager'), "%") . "/([^/]+)/(\\d+)((\\D.+)?)\$%", $oHtmlTag->getParameter('href'), $aMatches) === 1; if ($bHasMatched) { $sFileMethod = $aMatches[1]; $iId = $aMatches[2]; $sAdditional = $aMatches[3]; $sIdentifier = 'file_link'; $sModel = 'Document'; if ($sFileMethod === 'external_link_proxy') { $sIdentifier = 'external_link'; $sModel = 'Link'; } else { if ($sFileMethod === 'internal_link_proxy') { $sIdentifier = 'internal_link'; $sModel = 'Page'; } } $this->addTrackReference($iId, $sModel); return TemplateIdentifier::constructIdentifier($sIdentifier, "{$iId}{$sAdditional}", array_merge($oHtmlTag->getParameters(), array('link_text' => $sParsedChildren))); } else { if (strpos($oHtmlTag->getParameter('href'), "mailto:") === 0) { return TemplateIdentifier::constructIdentifier("mailto_link", substr($oHtmlTag->getParameter('href'), strlen("mailto:")), array("link_text" => $sParsedChildren)); } } } $oTagWriter = new TagWriter($oHtmlTag->getName(), $oHtmlTag->getParameters(), $sParsedChildren); $oTagTemplate = $oTagWriter->parse(true); $oTagTemplate->bKillIdentifiersBeforeRender = false; return $oTagTemplate->render(); }
public function getMessage($sName) { if (!isset($this->aMessages[$sName])) { return null; } $aMessageAttribs = $this->aMessages[$sName]; $aParameters = array(); if (isset($aMessageAttribs[self::STRING_PARAMETERS_KEY])) { $aParameters = $aMessageAttribs[self::STRING_PARAMETERS_KEY]; } $sStringKey = "flash.{$sName}"; if (isset($aMessageAttribs[self::STRING_KEY_KEY])) { $sStringKey = $aMessageAttribs[self::STRING_KEY_KEY]; } $sClassName = 'error_display'; if (isset($aMessageAttribs[self::CLASS_NAME_KEY])) { $sClassName = $aMessageAttribs[self::CLASS_NAME_KEY]; } $sTagName = 'span'; if (isset($aMessageAttribs[self::TAG_NAME_KEY])) { $sTagName = $aMessageAttribs[self::TAG_NAME_KEY]; } $oTag = new TagWriter($sTagName, array('class' => $sClassName), TranslationPeer::getString($sStringKey, null, null, $aParameters)); return $oTag->parse(); }
protected function getFieldCode($iFormId) { if ($this->sType === 'textarea') { return TagWriter::quickTag($this->sType, array('id' => $this->getFormObjectId($iFormId), 'name' => $this->sName, 'class' => $this->sClassName), $this->getCurrentValue()); } $sType = $this->sType; $sTagName = 'input'; if (strpos($sType, '-') !== false) { list($sTagName, $sType) = explode('-', $sType); } $aArgs = array('value' => $this->getCurrentValue(), 'id' => $this->getFormObjectId($iFormId), 'name' => $this->sName, 'type' => $sType, 'class' => $this->sClassName); $sContents = null; if ($sType === 'textarea') { $sTagName = 'textarea'; unset($aArgs['type']); } if ($sTagName !== 'input') { $sContents = $this->getCurrentValue(); unset($aArgs['value']); } return TagWriter::quickTag($sTagName, $aArgs, $sContents); }
public function getDetail() { // display error info if ($this->iError) { $oTemplate = $this->constructTemplate('error_message'); $oTemplate->replaceIdentifier('error_title', StringPeer::getString('webdav.error_message') . ' ' . $this->sErrorLocation); $oTemplate->replacePstring("error_details", array('dir_name' => $this->sWebdavBaseDirPath), 'webdav.error_' . $this->iError); return $oTemplate; } // display module info if ($this->sFilePath === null) { $oTemplate = $this->constructTemplate('module_info'); if (count($this->aFiles) > 0) { $oTemplate->replaceIdentifier('edit_or_create_message', StringPeer::getString('webdav.choose_or_create')); } $oTemplate->replaceIdentifier('create_link', TagWriter::quickTag('a', array('class' => 'edit_related_link highlight', 'href' => LinkUtil::link('webdav', null, array('action' => 'create'))), StringPeer::getString('webdav.create'))); $oTemplate->replaceIdentifier('user_backend_link', TagWriter::quickTag('a', array('class' => 'edit_related_link highlight', 'href' => LinkUtil::link('users')), StringPeer::getString('module.backend.users'))); return $oTemplate; } $oTemplate = $this->constructTemplate('detail'); $oTemplate->replaceIdentifier('module_info_link', TagWriter::quickTag('a', array('title' => StringPeer::getString('module_info'), 'class' => 'info', 'href' => LinkUtil::link('webdav', null, array('get_module_info' => 'true'))))); if ($this->sFilePath === self::NEW_DIR_IDENTIFIER) { $aDirPermissionsGroupIds = array(); } else { $aDirPermissionsGroupIds = DirectoryPermissionPeer::getPermissionGroupIdsByFileName($this->sFilePath); $oDeleteTemplate = $this->constructTemplate("delete_button", true); $oDeleteTemplate->replacePstring("delete_item", array('name' => $this->sFilePath)); $oTemplate->replaceIdentifier("delete_button", $oDeleteTemplate, null, Template::LEAVE_IDENTIFIERS); // show users with usergroups $oUsersWithGroups = UserPeer::getUsersWithRights($aDirPermissionsGroupIds); $oUsersTemplate = $this->constructTemplate('detail_users'); if (count($oUsersWithGroups) > 0) { foreach ($oUsersWithGroups as $oUser) { $oUsersTemplate->replaceIdentifierMultiple('users', TagWriter::quickTag('a', array('class' => 'highlight', 'title' => StringPeer::getString('user.edit'), 'class' => 'webdav_files', 'href' => LinkUtil::link(array('users', $oUser->getId()), null, array('check_userkind' => true))), $oUser->getFullName() . ' [Benutzername:' . $oUser->getUserName() . ']')); } } else { $oUsersTemplate->replaceIdentifier('users', TagWriter::quickTag('div', array('class' => 'webdav_files'), StringPeer::getString('webdav.no_users_with_permission_message'))); } $oUsersTemplate->replaceIdentifier('user_backend_link', TagWriter::quickTag('a', array('class' => 'edit_related_link', 'href' => LinkUtil::link('users', null, array('check_userkind' => 'true'))), StringPeer::getString('user.edit'))); $oTemplate->replaceIdentifier("users_with_permission", $oUsersTemplate); $sServerPath = LinkUtil::absoluteLink(substr($this->sWebdavBaseDirPath, strrpos($this->sWebdavBaseDirPath, '/')) . '/' . $this->sFilePath); $oTemplate->replaceIdentifier("server_address", $sServerPath); // show files in current dir $aDirFiles = array_keys(ResourceFinder::getFolderContents($this->sWebdavBaseDirPath . '/' . $this->sFilePath)); if (count($aDirFiles) > 0) { $oFilesTemplate = $this->constructTemplate("detail_files"); $sWebDavDirPath = $this->sWebdavBaseDirPath . '/' . $this->sFilePath . '/'; foreach ($aDirFiles as $i => $sFilePath) { $iFileSize = filesize($sWebDavDirPath . $sFilePath); $sFileSize = DocumentUtil::getDocumentSize($iFileSize); if (substr($sFileSize, 0, 1) == '0') { $sFileSize = 'unknown'; } $oFilesTemplate->replaceIdentifierMultiple('files', TagWriter::quickTag('div', array('class' => 'webdav_files'), $sFilePath . ' [' . $sFileSize . ']')); } $oTemplate->replaceIdentifier('detail_files', $oFilesTemplate); } } $oTemplate->replaceIdentifier('name', $this->sFilePath); $oTemplate->replaceIdentifier('file_path_old', $this->sFilePath); if (isset($_POST['file_path'])) { $this->sFilePath = $_POST['file_path']; } $oTemplate->replaceIdentifier('file_path', $this->sFilePath === self::NEW_DIR_IDENTIFIER ? '' : $this->sFilePath); $oTemplate->replaceIdentifier('file_path_readonly', $this->sFilePath != self::NEW_DIR_IDENTIFIER ? ' readonly="readonly"' : '', null, Template::NO_HTML_ESCAPE); $aGroups = GroupPeer::getAll(); $oTemplate->replaceIdentifier('group_options', TagWriter::optionsFromObjects($aGroups, 'getId', 'getName', $aDirPermissionsGroupIds, array())); $oTemplate->replaceIdentifier('group_backend_link', TagWriter::quickTag('a', array('class' => 'edit_related_link highlight', 'href' => LinkUtil::link('groups')), StringPeer::getString('group.edit'))); return $oTemplate; }