/**
  * @static
  * @return CArrayList
  */
 private static function getCacheHelps()
 {
     if (is_null(self::$_cacheHelp)) {
         self::$_cacheHelp = new CArrayList();
     }
     return self::$_cacheHelp;
 }
 public function actionAutosave()
 {
     if (CRequest::getInt("id") !== 0) {
         $help = CHelpManager::getHelp(CRequest::getInt("id"));
         if (!is_null($help)) {
             $help->content = CRequest::getString("content", $help::getClassName());
             $help->save();
         }
     }
 }
Example #3
0
 public static function helpForCurrentPage()
 {
     if (!is_null(CHelpManager::getHelpForCurrentPage())) {
         echo '<div class="alert alert-info">';
         echo '<h4>' . CHelpManager::getHelpForCurrentPage()->title . '</h4>';
         $printHelpBox = false;
         if (mb_strlen(CHelpManager::getHelpForCurrentPage()->content) > 512) {
             $symbols = 512;
             // Количество символов которые надо вывести
             $text = "";
             $words = explode(" ", CHelpManager::getHelpForCurrentPage()->content);
             for ($i = 0; $i < count($words); $i++) {
                 $nv_str = $text . $words[$i] . " ";
                 if (strlen($nv_str) < $symbols) {
                     $text = $nv_str;
                 } else {
                     break;
                 }
             }
             echo $text . "...";
             echo '<p><a href="#help" data-toggle="modal">Читать полностью</a></p>';
             $printHelpBox = true;
         } else {
             echo CHelpManager::getHelpForCurrentPage()->content;
         }
         if (CSession::getCurrentUser()->hasRole("help_add_inline")) {
             echo '<p>';
             echo '<a href="' . WEB_ROOT . '_modules/_help/index.php?action=edit&id=' . CHelpManager::getHelpForCurrentPage()->getId() . '" target="_blank">Редактировать справку</a>';
             echo '</p>';
         }
         echo '</div>';
         if ($printHelpBox) {
             echo '
                 <div class="modal hide fade" id="help">
                     <div class="modal-header">
                         <button type="button" class="close" data-dismiss="modal" aria-hidden="true">?</button>
                         <h3 id="myModalLabel">Справка</h3>
                     </div>
                     <div class="modal-body">
                         ' . CHelpManager::getHelpForCurrentPage()->content . '
                     </div>
                     <div class="modal-footer">
                         <button class="btn" data-dismiss="modal" aria-hidden="true">Закрыть</button>
                     </div>
                 </div>
             ';
         }
     } elseif (CSession::getCurrentUser()->hasRole("help_add_inline")) {
         echo '<div class="alert alert-info">';
         $uri = "";
         if (array_key_exists("REQUEST_URI", $_SERVER)) {
             $uri = $_SERVER["REQUEST_URI"];
             $uri = str_replace(ROOT_FOLDER, "", $uri);
         }
         echo '<a href="' . WEB_ROOT . '_modules/_help/index.php?action=add&page=' . $uri . '" target="_blank">Добавить справку для текущей страницы</a>';
         echo '</div>';
     }
 }