diff --git a/css/redactor.css b/css/redactor.css index e6123e23e60353cf93e5282574538fee093b7fec..6da01fbe384e31ca6d0275a2c6a8257b03a991a8 100644 --- a/css/redactor.css +++ b/css/redactor.css @@ -332,7 +332,7 @@ body .redactor_box_fullscreen { .redactor_toolbar:after { content: ""; display: table; - clear: both; + /* clear: both; */ } .redactor_toolbar.redactor-toolbar-overflow { overflow-y: auto; diff --git a/include/class.faq.php b/include/class.faq.php index 6ba85483048d105072dc1c9621cada147aad0f12..75398d5e29fedbcd9683e485f27aeba1decf52ec 100644 --- a/include/class.faq.php +++ b/include/class.faq.php @@ -158,10 +158,10 @@ class FAQ { return $this->_local; } function getLocalQuestion($lang=false) { - return $this->_getLocal('q', $lang); + return $this->_getLocal('question', $lang); } - function getLocalBodyWithImages($lang=false) { - return $this->_getLocal('a', $lang); + function getLocalAnswerWithImages($lang=false) { + return $this->_getLocal('answer', $lang); } function _getLocal($what, $lang=false) { if (!$lang) { @@ -169,7 +169,7 @@ class FAQ { } $translations = $this->getAllTranslations(); foreach ($translations as $t) { - if ($lang == $t->lang) { + if (0 === strcasecmp($lang, $t->lang)) { $data = $t->getComplex(); if (isset($data[$what])) return $data[$what]; @@ -177,6 +177,12 @@ class FAQ { } return $this->ht[$what]; } + function getLocalAttachments($lang=false) { + if (!$lang) { + $lang = Internationalization::getCurrentLanguage(); + } + return $this->attachments->getSeparates($lang); + } function updateTopics($ids){ @@ -212,11 +218,13 @@ class FAQ { // General attachments (for all languages) // --------------------- // Delete removed attachments. - $keepers = $vars['files']; - if (($attachments = $this->attachments->getSeparates())) { - foreach($attachments as $file) { - if($file['id'] && !in_array($file['id'], $keepers)) - $this->attachments->delete($file['id']); + if (isset($vars['files'])) { + $keepers = $vars['files']; + if (($attachments = $this->attachments->getSeparates())) { + foreach($attachments as $file) { + if($file['id'] && !in_array($file['id'], $keepers)) + $this->attachments->delete($file['id']); + } } } // Upload new attachments IF any. @@ -228,6 +236,10 @@ class FAQ { if ($langs) { $langs[] = $cfg->getPrimaryLanguage(); foreach ($langs as $lang) { + if (!isset($vars['files_'.$lang])) + // Not updating the FAQ + continue; + $keepers = $vars['files_'.$lang]; // Delete removed attachments. @@ -246,7 +258,7 @@ class FAQ { $this->attachments->deleteInlines(); $this->attachments->upload(Draft::getAttachmentIds($vars['answer'])); - if (!$this->saveTranslations($vars)) + if (isset($vars['trans']) && !$this->saveTranslations($vars)) return false; $this->reload(); @@ -260,13 +272,14 @@ class FAQ { foreach ($this->getAllTranslations() as $t) { $trans = @$vars['trans'][$t->lang]; - if (!array_filter($trans)); + if (!$trans || !array_filter($trans)); + // Not updating translations continue; // Content is not new and shouldn't be added below unset($vars['trans'][$t->lang]); - $content = array('q' => $trans['question'], - 'a' => Format::sanitize($trans['answer'])); + $content = array('question' => $trans['question'], + 'answer' => Format::sanitize($trans['answer'])); // Don't update content which wasn't updated if ($content == $t->getComplex()) @@ -281,8 +294,8 @@ class FAQ { // New translations (?) $tag = $this->getTranslateTag('q:a'); foreach ($vars['trans'] as $lang=>$parts) { - $content = array('q' => @$parts['question'], - 'a' => Format::sanitize(@$parts['answer'])); + $content = array('question' => @$parts['question'], + 'answer' => Format::sanitize(@$parts['answer'])); if (!array_filter($content)) continue; $t = CustomDataTranslation::create(array( @@ -303,7 +316,10 @@ class FAQ { function getAttachmentsLinks($separator=' ',$target='') { $str=''; - if(($attachments=$this->attachments->getSeparates())) { + $attachments = array_merge( + $this->attachments->getSeparates() ?: array(), + $this->getLocalAttachments()); + if ($attachments) { foreach($attachments as $attachment ) { /* The h key must match validation in file.php */ $hash=$attachment['key'].md5($attachment['id'].session_id().strtolower($attachment['key'])); diff --git a/include/client/faq.inc.php b/include/client/faq.inc.php index 2ccc475e0349e3e83e5a80eab71a0c9eba9ab156..29c45e4dca350058d0a6aa368b3f3217fa617353 100644 --- a/include/client/faq.inc.php +++ b/include/client/faq.inc.php @@ -10,12 +10,12 @@ $category=$faq->getCategory(); » <a href="faq.php?cid=<?php echo $category->getId(); ?>"><?php echo $category->getName(); ?></a> </div> <div style="width:700px;padding-top:2px;" class="pull-left"> -<strong style="font-size:16px;"><?php echo $faq->getQuestion() ?></strong> +<strong style="font-size:16px;"><?php echo $faq->getLocalQuestion() ?></strong> </div> <div class="pull-right flush-right" style="padding-top:5px;padding-right:5px;"></div> <div class="clear"></div> <p> -<?php echo Format::safe_html($faq->getAnswerWithImages()); ?> +<?php echo Format::safe_html($faq->getLocalAnswerWithImages()); ?> </p> <p> <?php diff --git a/include/staff/faq.inc.php b/include/staff/faq.inc.php index ce5959f2ce271f74af9259a257950f03bd6d7d06..4a9b7fb46c48dc271e1de021b2923a0425c670fd 100644 --- a/include/staff/faq.inc.php +++ b/include/staff/faq.inc.php @@ -19,8 +19,8 @@ if($faq){ if (strcasecmp($t->lang, $tag) === 0) { $trans = $t->getComplex(); $info['trans'][$tag] = array( - 'question' => $trans['q'], - 'answer' => Format::viewableImages($trans['a']), + 'question' => $trans['question'], + 'answer' => Format::viewableImages($trans['answer']), ); break; } @@ -51,7 +51,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <div> <b><?php echo __('Category Listing');?></b>: <span class="error">*</span> - <span class="faded"><?php echo __('FAQ category the question belongs to.');?></span> + <div class="faded"><?php echo __('FAQ category the question belongs to.');?></div> </div> <select name="category_id" style="width:350px;"> <option value="0"><?php echo __('Select FAQ Category');?> </option> @@ -71,16 +71,19 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <div class="error"><?php echo $errors['category_id']; ?></div> <?php -if ($topics = Topic::getAllHelpTopics()) { ?> +if ($topics = Topic::getAllHelpTopics()) { + if (!is_array(@$info['topics'])) + $info['topics'] = array(); +?> <div style="padding-top:9px"> <strong><?php echo __('Help Topics');?></strong>: - <?php echo __('Check all help topics related to this FAQ.');?> + <div class="faded"><?php echo __('Check all help topics related to this FAQ.');?></div> </div> <select multiple="multiple" name="topics[]" class="multiselect" id="help-topic-selection" style="width:350px;"> <?php while (list($topicId,$topic) = each($topics)) { ?> <option value="<?php echo $topicId; ?>" <?php - if (in_array($topicID, $info['topics'])) echo 'selected="selected"'; + if (in_array($topicId, $info['topics'])) echo 'selected="selected"'; ?>><?php echo $topic; ?></option> <?php } ?> </select> @@ -108,111 +111,78 @@ if ($topics = Topic::getAllHelpTopics()) { ?> </div> <ul class="tabs" style="margin-top:9px;"> - <li class="active"><a class="active" href="#article"><?php echo __('Article Content'); ?></a></li> + <li class="active"><a href="#article"><?php echo __('Article Content'); ?></a></li> <li><a href="#attachments"><?php echo __('Attachments') . sprintf(' (%d)', count($faq->attachments->getSeparates(''))); ?></a></li> <li><a href="#notes"><?php echo __('Internal Notes'); ?></a></li> </ul> <div class="tab_content" id="article"> -<?php if ($faq && ($langs = $cfg->getSecondaryLanguages())) { ?> - <div class="banner" style="margin-top:12px;"> - <span class="pull-left" style="padding-top:2px"> - <i class="icon-globe icon-large"></i> - <?php echo __('This content is translatable'); ?> - </span> - <span class="pull-right"> - <?php echo __('View'); ?>: - <select onchange="javascript: -$('option', this).each(function(){$($(this).val()).hide()}); -$($('option:selected', this).val()).show(); "> - <option value="#reference-text"><?php echo - Internationalization::getLanguageDescription($cfg->getPrimaryLanguage()); - ?> — <?php echo __('Primary'); ?></option> -<?php foreach ($langs as $tag) { ?> - <option value="#translation-<?php echo $tag; ?>"><?php echo - Internationalization::getLanguageDescription($tag); - ?></option> -<?php } ?> - </select> - </span> - </div> +<strong>Knowledgebase Article Content</strong><br/> +Here you can manage the question and answer for the article. Multiple +languages are available if enabled in the admin panel. +<div class="clear"></div> +<?php +$langs = Internationalization::getConfiguredSystemLanguages(); +if ($faq) { ?> + <ul class="vertical tabs left" style="margin-top:10px;"> + <li class="empty"><i class="icon-globe" title="This content is translatable"></i></li> +<?php foreach ($langs as $tag=>$i) { + list($lang, $locale) = explode('_', $tag); + ?> + <li class="<?php if ($tag == $cfg->getPrimaryLanguage()) echo "active"; + ?>"><a href="#lang-<?php echo $tag; ?>" title="<?php + echo Internationalization::getLanguageDescription($tag); + ?>"><span class="flag flag-<?php echo strtolower($locale ?: $info['flag'] ?: $lang); ?>"></span> + </a></li> <?php } ?> + </ul> +<?php +} ?> - <div id="reference-text"> +<?php foreach ($langs as $tag=>$i) { + $code = $i['code']; + if ($tag == $cfg->getPrimaryLanguage()) { + $namespace = $faq ? $faq->getId() : false; + $answer = $info['answer']; + $question = $info['question']; + $qname = 'question'; + $aname = 'answer'; + } + else { + $namespace = $faq->getId() . $code; + $answer = $info['trans'][$code]['answer']; + $question = $info['trans'][$code]['question']; + $qname = 'trans['.$code.'][question]'; + $aname = 'trans['.$code.'][answer]'; + } +?> + <div class="tab_content" style="margin-left:45px;<?php + if ($code != $cfg->getPrimaryLanguage()) echo "display:none;"; + ?>" id="lang-<?php echo $tag; ?>"> <div style="padding-top:9px;"> <b><?php echo __('Question');?> <span class="error">*</span> </b> <div class="error"><?php echo $errors['question']; ?></div> </div> - <input type="text" size="70" name="question" + <input type="text" size="70" name="<?php echo $qname; ?>" style="font-size:105%;display:block;width:98%" - value="<?php echo $info['question']; ?>"> + value="<?php echo $question; ?>"> <div style="margin-bottom:0.5em;margin-top:9px"> <b><?php echo __('Answer');?></b> <span class="error">*</span> <div class="error"><?php echo $errors['answer']; ?></div> </div> - <textarea name="answer" cols="21" rows="12" - style="width:98%;" class="richtext draft" <?php -list($draft, $attrs) = Draft::getDraftAndDataAttrs('faq', -is_object($faq) ? $faq->getId() : false, $info['answer']); -echo $attrs; ?>><?php echo $draft ?: $info['answer']; + <div> + <textarea name="<?php echo $aname; ?>" cols="21" rows="12" + class="richtext draft" <?php +list($draft, $attrs) = Draft::getDraftAndDataAttrs('faq', $namespace, $answer); +echo $attrs; ?>><?php echo $draft ?: $answer; ?></textarea> -<?php if (count($langs)) { - $lang = $cfg->getPrimaryLanguage(); ?> - <div style="padding-top:9px"> - <strong><?php echo sprintf(__( - /* %s is the name of a language */ 'Attachments for %s'), - Internationalization::getLanguageDescription($lang)); - ?></strong> - <div style="margin:0 0 3px"><em class="faded"><?php echo __( - 'These attachments are only available when article is rendered in this language.' - ); ?></em></div> </div> - <?php - print $faq_form->getField('attachments.'.$lang)->render(); ?> -<?php } ?> - </div> <!-- end of reference-text --> - -<?php if ($langs && $faq) { - foreach ($langs as $tag) { ?> - <div id="translation-<?php echo $tag; ?>" style="display:none" lang="<?php echo $tag; ?>"> - <div style="padding-top:9px;"> - <b><?php echo __('Question');?> - <span class="error">*</span> - </b> - <div class="error"><?php echo $errors['question']; ?></div> </div> - <input type="text" size="70" name="trans[<?php echo $tag; ?>][question]" - style="font-size:105%;display:block;width:98%" - value="<?php echo $info['trans'][$tag]['question']; ?>"> - <div style="margin-bottom:0.5em;margin-top:9px"> - <b><?php echo __('Answer');?></b> - <span class="error">*</span> - <div class="error"><?php echo $errors['answer']; ?></div> - </div> - <textarea name="trans[<?php echo $tag; ?>][answer]" cols="21" rows="12" - style="width:98%;" class="richtext draft" <?php -list($draft, $attrs) = Draft::getDraftAndDataAttrs('faq', $faq->getId().'.'.$tag, - $info['trans'][$tag]['answer']); -echo $attrs; ?>><?php echo $draft ?: $info['trans'][$tag]['answer']; - ?></textarea> - - <div style="padding-top:9px"> - <strong><?php echo sprintf(__('Attachments for %s'), - Internationalization::getLanguageDescription($tag)); - ?></strong> - <div style="margin:0 0 3px"><em class="faded"><?php echo __( - 'These attachments are only available when article is rendered in this language.' - ); ?></em></div> - </div> - <?php - print $faq_form->getField('attachments.'.$tag)->render(); ?> - </div> <!-- End of this language --> -<?php } ?> <?php } ?> </div> @@ -225,9 +195,31 @@ echo $attrs; ?>><?php echo $draft ?: $info['trans'][$tag]['answer']; </div> <?php print $faq_form->getField('attachments')->render(); ?> + +<?php if (count($langs) > 1) { + foreach ($langs as $lang=>$i) { + $code = $i['code']; ?> + <div style="padding-top:9px"> + <strong><?php echo sprintf(__( + /* %s is the name of a language */ 'Attachments for %s'), + Internationalization::getLanguageDescription($lang)); + ?></strong> + <div style="margin:0 0 3px"><em class="faded"><?php echo __( + 'These attachments are only available when article is rendered in this language.' + ); ?></em></div> + </div> + <?php + print $faq_form->getField('attachments.'.$code)->render(); + } +} ?> </div> <div class="tab_content" style="display:none;" id="notes"> + <div> + <b><?php echo __('Internal Notes');?></b>: + <div class="faded"><?php echo __("Be liberal, they're internal");?></div> + </div> + <div style="margin-top:10px"></div> <textarea class="richtext no-bar" name="notes" cols="21" rows="8" style="width: 80%;"><?php echo $info['notes']; ?></textarea> </div> diff --git a/scp/css/scp.css b/scp/css/scp.css index 191f3d88b3f4a2480a3f872f8056de64053de6e0..ca4e4b4385d7d738bd9ab9ffdb86c6a0996dd727 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -955,6 +955,11 @@ ul.tabs li.active a { font-weight: bold; } +ul.tabs li.empty { + padding: 5px; + border: none !important; +} + ul.tabs.vertical { display: inline-block; height: auto;