Exemplo n.º 1
0
         $version_codes = array();
         $content_versions = array();
         for ($ver_code = 0; $ver_code <= $section_info['max_ver_code']; $ver_code++) {
             $content_version = new ContentVersion();
             $filename = DocSectionManager::getSectionContentPath($section_id, $ver_code, 'org');
             $fp = fopen($filename, "r");
             if ($fp) {
                 $fstats = fstat($fp);
                 $content_version->pub_time = $pub_time = date('Y-m-d H:i', $fstats['mtime']) . ' CST';
                 $content_version->author_id = trim(fgets($fp));
                 $content_version->type_handle = trim(fgets($fp));
                 $content_version->attached_files = fgets($fp);
                 $content_version->content_subject = trim(fgets($fp));
                 $content_version->org_content = fread($fp, filesize($filename));
                 fclose($fp);
                 $filename = DocSectionManager::getSectionContentPath($section_id, $ver_code, 'html');
                 if (file_exists($filename)) {
                     $content_version->html_content = file_get_contents($filename);
                 } else {
                     $content_version->html_content = NULL;
                 }
                 $version_codes["{$ver_code}"] = "Version {$ver_code} ({$pub_time})";
                 $content_versions[] = $content_version;
             } else {
                 $content_versions[] = NULL;
             }
         }
         $json = Loader::helper('json');
         $content_versions_json = $json->encode($content_versions);
     }
 }
Exemplo n.º 2
0
 public function add_new_ref_link_list()
 {
     if (!fse_try_to_login()) {
         header("location:/fse_login");
         return;
     }
     $page_id = $this->post('cID');
     $project_id = $this->post('projectID');
     $area_handle = $this->post('areaHandle');
     $domain_handle = $this->post('domainHandle');
     $volume_handle = $this->post('volumeHandle');
     $part_handle = $this->post('partHandle');
     $chapter_handle = $this->post('chapterHandle');
     $page_path = ProjectInfo::assemblePath($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle);
     if (!isset($_SESSION['FSEInfo'])) {
         set_page_action_status($page_id, t('New Reference'), 'error', t('You do not sign in or session expired.'));
         header("Location: {$page_path}");
         return;
     }
     $project_info = ProjectInfo::getBasicInfo($project_id);
     if ($project_info == false) {
         set_page_action_status($page_id, t('New Reference'), 'error', t('No such project!'));
         header("Location: {$page_path}");
         return;
     }
     $fse_id = $_SESSION['FSEInfo']['fse_id'];
     if ($domain_handle == 'community' && $part_handle != 'na') {
     } else {
         if (substr(ProjectInfo::getUserRights($project_id, $fse_id), 1, 1) != 't') {
             set_page_action_status($page_id, t('New Reference'), 'error', t('You have no right to edit the content of this project.'));
             header("Location: {$page_path}");
             return;
         }
     }
     $type_handle = 'post-reference:markdown_extra:none:none:none';
     $section_subject = t('Reference');
     $section_content = '';
     for ($i = 0; $i < DocSectionManager::MAX_ATTACHED_FILES; $i++) {
         $ref_title = $this->post("refTitle{$i}");
         $ref_link = $this->post("refLink{$i}");
         if (strlen($ref_title) > 0 && strlen($ref_link) > DocSectionManager::MIN_LINK_STRLEN) {
             $section_content .= "1. [{$ref_title}]({$ref_link})\n";
         }
     }
     if (mb_strlen($section_content) < self::MIN_CONTENT_LEN) {
         set_page_action_status($page_id, t('New Reference'), 'error', t('Too short content!'));
         header("Location: {$page_path}");
         return;
     }
     $section_manager = new DocSectionManager();
     $res = $section_manager->addNewSection($fse_id, $page_id, $area_handle, $project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle, $type_handle, $section_subject, $section_content, '[]');
     if ($res != DocSectionManager::EC_OK) {
         set_page_action_status($page_id, t('New Reference'), 'error', t('Failed to add a new section: %s', $section_manager->getErrorMessage($res)));
         header("Location: {$page_path}");
         return;
     }
     set_page_action_status($page_id, t('New Reference'), 'success', t('Succeed to add new reference.'));
     ProjectInfo::onChangeThreads($project_id, $domain_handle, $volume_handle, $part_handle);
     header("Location: {$page_path}");
 }
}
$ret_info->status = 'success';
$nr = 0;
foreach ($sections as $pst) {
    if ($nr >= $nr_requested) {
        break;
    }
    $author_info = FSEInfo::getNameInfo($pst['author_id']);
    if ($author_info == false) {
        continue;
    }
    $comments = DocSectionManager::getCachedComments($domain_handle, $pst['id']);
    if (count($comments) == 0) {
        continue;
    }
    $plain_content = DocSectionManager::getPlainContent($pst['id'], $pst['curr_ver_code']);
    $link = ProjectInfo::assemblePath($pst['project_id'], $pst['domain_handle'], $pst['volume_handle'], $pst['part_handle'], $pst['chapter_handle']);
    $link .= '#section-' . $pst['id'];
    if (strlen($plain_content['title']) == 0) {
        $page = Page::getByID($pst['page_id']);
        $plain_content['title'] = $page->getCollectionName();
    }
    $ret_info->detail .= '
<div class="panel panel-default">
<div class="panel-body">
	<div class="media" style="margin-top:15px">
		<a class="media-left" href="' . FSEInfo::getPersonalHomeLink($author_info) . '">
			<img class="middle-avatar" src="' . $author_info['avatar_url'] . '" alt="' . $author_info['nick_name'] . '">
		</a>
		<div class="media-body">
			<h4 class="media-heading">
Exemplo n.º 4
0
				<?php 
echo h5($c->getCollectionName());
?>
<br />
			</h1>
			<p class="lead">
				<?php 
echo h5($c->getCollectionDescription());
?>
			</p>
		</div>
	</header>

<?php 
$domain_long_desc = ProjectInfo::getDomainLongDesc($project_id, $domain_handle);
$domain_long_desc = DocSectionManager::safeMarkdown2HTML($domain_long_desc);
$common_request_parts = "?fsenDocLang={$doc_lang}&cID={$page_id}&projectID={$project_id}&domainHandle={$domain_handle}&volumeHandle={$volume_handle}&partHandle={$part_handle}&chapterHandle={$chapter_handle}";
?>
	<header class="text-center project-subpage-desc">
		<span class="glyphicon glyphicon-group big-glyph text-major-default"></span><?php 
echo $domain_long_desc;
?>
	</header>

	<article class="formal-content" lang="<?php 
echo $doc_lang;
?>
">

<!-- MainForeword area: Flex columns -->
		<section class="container-fluid">
Exemplo n.º 5
0
    exit(0);
}
if (!preg_match("/^[a-f0-9]{32}\$/", $section_id)) {
    $ret_info->detail = t('Bad section!');
    echo $json->encode($ret_info);
    exit(0);
}
$section_info = DocSectionManager::getSectionInfo($domain_handle, $section_id);
if ($section_info == false) {
    $ret_info->detail = t('No such section!');
    echo $json->encode($ret_info);
    exit(0);
}
$ret_info->status = 'success';
$ret_info->nr_total_comments = $section_info['nr_comments'];
$comments = DocSectionManager::getCachedComments($domain_handle, $section_id);
if (count($comments) == 0) {
    $ret_info->detail = '';
    echo $json->encode($ret_info);
    exit(0);
}
if ($nr_comments < 1) {
    $nr_comments = 1;
}
$nr = 0;
$ret_info->detail = '<ul class="list-group" style="width:300px;">';
foreach ($comments as $comment) {
    if ($nr >= $nr_comments) {
        break;
    }
    $author_name_info = FSEInfo::getNameInfo($comment['author_id']);
Exemplo n.º 6
0
 public static function addOwnerMemberSection($project_id, $fse_info = false)
 {
     /* add owner member section on misc page */
     if ($fse_info == false) {
         $project_info = ProjectInfo::getBasicInfo($project_id);
         if ($project_info == false) {
             exit(0);
         }
         $fse_info = FSEInfo::getNameInfo($project_info['fse_id']);
         $fse_info = FSEInfo::getBasicProfile($fse_info['user_name']);
     } else {
         $fse_info['avatar_url'] = get_url_from_file_id($fse_info['avatar_file_id']);
     }
     $page_path = self::assemblePath($project_id, 'misc');
     $about_page = Page::getByPath($page_path);
     $type_handle = 'member:markdown_safe:' . $fse_info['user_name'] . ':primary:none';
     $section_content = sprintf(self::OWNER_MARKDOWN_TEXT, FSEInfo::getPersonalHomeLink($fse_info, true), FSEInfo::getPersonalHomeLink($fse_info), $fse_info['avatar_url'], ProjectInfo::$mRoleDescriptions[substr($project_id, -2)]['owner'], h5($fse_info['self_desc']));
     $section_manager = new DocSectionManager();
     $res = $section_manager->addNewSection($fse_info['fse_id'], $about_page->getCollectionID(), 'Members', $project_id, 'misc', 'na', 'na', 'na', $type_handle, '', $section_content, '[]');
 }
Exemplo n.º 7
0
 public static function getPlainContent($section_id, $curr_ver_code, $max_length = 140)
 {
     $plain_content = array();
     $filename = self::getSectionContentPath($section_id, $curr_ver_code, 'org');
     $fp = fopen($filename, "r");
     if ($fp) {
         $plain_content['author_id'] = trim(fgets($fp));
         $tmp = trim(fgets($fp));
         $tmp = fgets($fp);
         $plain_content['title'] = trim(fgets($fp));
         $fstats = fstat($fp);
         $plain_content['edit_time'] = date('Y-m-d H:i', $fstats['mtime']) . ' CST';
         fclose($fp);
         unset($fp);
         unset($fstats);
         unset($tmp);
     } else {
         return false;
     }
     $filename = DocSectionManager::getSectionContentPath($section_id, $curr_ver_code, 'html');
     $html_content = file_get_contents($filename);
     if ($html_content) {
         $plain_content['content'] = strip_tags($html_content);
         if (mb_strlen($plain_content['content']) > $max_length) {
             $plain_content['content'] = mb_substr($plain_content['content'], 0, $max_length) . '…';
         }
     }
     return $plain_content;
 }
Exemplo n.º 8
0
 * limitations under the License.
 */
defined('C5_EXECUTE') or die("Access Denied.");
Loader::model('fsen_localization');
FSENLocalization::setupInterfaceLocalization4AjaxRequest();
$domain_handle = $_REQUEST['domainHandle'];
$section_id = $_REQUEST['sectionID'];
require_once 'helpers/check_login.php';
require_once 'helpers/fsen/DocSectionManager.php';
require_once 'helpers/fsen/ProjectInfo.php';
if (!fse_try_to_login()) {
    $error_info = t('You are not signed in.');
} else {
    if (preg_match("/^[a-f0-9]{32}\$/", $section_id) && in_array($domain_handle, ProjectInfo::$mDomainList)) {
        $db = Loader::db();
        $section_info = DocSectionManager::getSectionInfo($domain_handle, $section_id);
        if (count($section_info) == 0) {
            $error_info = t('No such section ID!');
        } else {
            if ($current_ver_code > $section_info['max_ver_code']) {
                $error_info = t('Bad request!');
            } else {
                $project_id = $section_info['project_id'];
                $project_info = ProjectInfo::getBasicInfo($project_id);
                if ($project_info == false) {
                    $error_info = t('Bad project');
                } else {
                    if (($user_right = ProjectInfo::getUserEditRight($project_id, $domain_handle, $section_info['volume_handle'], $section_info['part_handle'], $section_info['chapter_handle'], $_SESSION['FSEInfo']['fse_id'])) != 0) {
                        switch ($user_right) {
                            case ProjectInfo::EDIT_PAGE_USER_BANNED:
                                $error_info = t('You are banned currently due to the violation against the site policy!');
Exemplo n.º 9
0
if (!fse_try_to_login()) {
    $ret_info->detail = t('Not signed in');
    echo $json->encode($ret_info);
    exit(0);
}
if (!in_array($domain_handle, ProjectInfo::$mDomainList)) {
    $ret_info->detail = t('Bad request');
    echo $json->encode($ret_info);
    exit(0);
}
if (!preg_match("/^[a-f0-9]{32}\$/", $section_id)) {
    $ret_info->detail = 'Bad section';
    echo $json->encode($ret_info);
    exit(0);
}
$action_id = DocSectionManager::checkActionComment($domain_handle, $section_id, $_SESSION['FSEInfo']['fse_id'], DocSectionManager::COMMENT_ACTION_FAVORITE);
if ($action_id == false) {
    DocSectionManager::newComment($domain_handle, $section_id, $_SESSION['FSEInfo']['fse_id'], DocSectionManager::COMMENT_ACTION_FAVORITE, NULL, NULL);
    $ret_info->status = 'favorited';
    $ret_info->detail = t('Your favorite stored.');
    $ret_info->section_info = DocSectionManager::getSectionInfo($domain_handle, $section_id);
} else {
    $ret_info->status = 'canceled';
    $ret_info->detail = t('Your favorite canceled.');
    $ret_info->section_info = DocSectionManager::cancelComment($domain_handle, $section_id, $action_id);
}
echo $json->encode($ret_info);
exit(0);
?>

Exemplo n.º 10
0
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
defined('C5_EXECUTE') or die('Access Denied.');
/*
$page = Page::getCurrentPage ();
$page_path = $page->getCollectionPath ();
$page_id = $page->getCollectionID ();
$path_frags = explode ('/', trim ($page_path, '/'));
$project_id = $path_frags[1];
*/
if ($currentVerCode > 0) {
    $last_author_id = $author_id;
    $last_edit_time = $edit_time;
    $last_author_name_info = FSEInfo::getNameInfo($last_author_id);
    $full_content_file_name = DocSectionManager::getSectionContentPath($sectionID, 0, 'org');
    $fp = fopen($full_content_file_name, "r");
    if ($fp) {
        $author_id = trim(fgets($fp));
        $fstats = fstat($fp);
        $edit_time = date('Y-m-d H:i', $fstats['mtime']) . ' CST';
        fclose($fp);
        unset($fp);
        $author_name_info = FSEInfo::getNameInfo($author_id);
    }
}
$request_part = "?fsenDocLang={$doc_lang}&domainHandle={$domainHandle}&sectionID={$sectionID}&currentVerCode={$currentVerCode}";
$visible_class = 'visible-on-logged-in';
$link_style = false;
$type_fragments = explode(":", $type_handle);
switch ($type_fragments[0]) {
    public $detail;
}
$ret_info = new ReturnInfo();
$ret_info->status = 'error';
$ret_info->detail = t('N/A');
if (!in_array($domain_handle, ProjectInfo::$mDomainList)) {
    $ret_info->detail = t('Bad domain');
    echo $json->encode($ret_info);
    exit(0);
}
if (!preg_match("/^[a-f0-9]{32}\$/", $section_id)) {
    $ret_info->detail = t('Bad section');
    echo $json->encode($ret_info);
    exit(0);
}
$comments = DocSectionManager::getEarlierActionComments($domain_handle, $section_id, $oldest_comment_id);
if (count($comments) == 0) {
    $ret_info->status = 'nodata';
    $ret_info->detail = t('No data available');
    echo $json->encode($ret_info);
    exit(0);
}
$ret_info->status = 'success';
$ret_info->detail = '';
foreach ($comments as $comment) {
    $author_name_info = FSEInfo::getNameInfo($comment['author_id']);
    if ($author_name_info == false) {
        continue;
    }
    if ($comment['action'] == DocSectionManager::COMMENT_ACTION_PRAISE) {
        $body = '<span class="glyphicon glyphicon-thumbs-up" style="color:#eb7350;"></span>';
Exemplo n.º 12
0
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
defined('C5_EXECUTE') or die('Access Denied.');
require_once 'helpers/fsen/DocSectionManager.php';
$home_long_desc = trim(ProjectInfo::getDomainLongDesc($project_id, 'home'));
if (mb_strlen($home_long_desc) > 15) {
    $alert_content = DocSectionManager::safeMarkdown2HTML($home_long_desc);
    ?>

<header class="project-alert-banner alert alert-dismissible fade in" role='alert'>
	<?php 
    echo $alert_content;
    ?>
	<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
</header>

<?php 
}
?>

Exemplo n.º 13
0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
defined('C5_EXECUTE') or die('Access Denied.');
require_once 'helpers/fsen/DocSectionManager.php';
require_once 'helpers/fsen/FSEInfo.php';
$doc_lang = $_REQUEST['fsenDocLang'];
if (!isset($doc_lang)) {
    $doc_lang = 'en';
}
$full_content_file_name = DocSectionManager::getSectionContentPath($sectionID, $currentVerCode, 'html');
$html_content = file_get_contents($full_content_file_name);
$full_content_file_name = DocSectionManager::getSectionContentPath($sectionID, $currentVerCode, 'org');
$fp = fopen($full_content_file_name, "r");
if ($fp) {
    $author_id = trim(fgets($fp));
    $type_handle = trim(fgets($fp));
    $attached_files = fgets($fp);
    $content_subject = trim(fgets($fp));
    $fstats = fstat($fp);
    $edit_time = date('Y-m-d H:i', $fstats['mtime']) . ' CST';
    fclose($fp);
    unset($fp);
    $author_name_info = FSEInfo::getNameInfo($author_id);
}
$json = Loader::helper('json');
$attached_files = $json->decode($attached_files);
unset($json);
Exemplo n.º 14
0
    public $status;
    public $detail;
    public $comment_info;
}
$ret_info = new ReturnInfo();
$ret_info->status = 'error';
$ret_info->detail = t('N/A');
$ret_info->comment_info = array();
if (!in_array($domain_handle, ProjectInfo::$mDomainList)) {
    $ret_info->detail = t('Bad domain');
    echo $json->encode($ret_info);
    exit(0);
}
if (!preg_match("/^[a-f0-9]{32}\$/", $section_id)) {
    $ret_info->detail = t('Bad section');
    echo $json->encode($ret_info);
    exit(0);
}
$comment_info = DocSectionManager::getSectionCommentInfo($domain_handle, $section_id);
if ($comment_info == false) {
    $ret_info->detail = t('Not existed section');
    echo $json->encode($ret_info);
    exit(0);
}
$ret_info->status = 'success';
$ret_info->comment_info = $comment_info;
echo $json->encode($ret_info);
exit(0);
?>

Exemplo n.º 15
0
    }
    ?>
						</div>

						<!-- Favorites -->
						<div role="tabpanel" class="tab-pane fade" id="divFavorites">
							<div class="v-seperator">
							</div>
<?php 
    if ($nr_favorites > 0) {
        ?>
							<ul class="list-group">
<?php 
        foreach ($my_favorites as $fvr) {
            $info = DocSectionManager::getSectionInfo(false, $fvr['section_id']);
            $plain_content = DocSectionManager::getPlainContent($fvr['section_id'], $info['curr_ver_code']);
            $link = ProjectInfo::assemblePath($info['project_id'], $info['domain_handle'], $info['volume_handle'], $info['part_handle'], $info['chapter_handle']);
            $link .= '#section-' . $fvr['section_id'];
            if (strlen($plain_content['title']) == 0) {
                $page = Page::getByID($info['page_id']);
                $plain_content['title'] = $page->getCollectionName();
            }
            ?>
<li class="list-group-item">
	<span class="badge"><?php 
            echo $info['heat_level'];
            ?>
</span>
	<h4 class="list-group-item-heading"><a href="<?php 
            echo $link;
            ?>
Exemplo n.º 16
0
                        $error_info = t('You have no right to recover a deleted/shielded post by the administrator.');
                    } else {
                        if ($user_rights[2] != 't' && $section_info['author_id'] != $curr_fse_id) {
                            $error_info = t('You have no right to recover the post.');
                        }
                    }
                }
                $form_action = "/fse_settings/projects/recover_post";
            }
        }
    } else {
        $error_info = t('Bad Request!');
    }
}
if (!isset($error_info)) {
    $filename = DocSectionManager::getSectionContentPath($section_id, $current_ver_code - 1, 'html');
    $previous_content = file_get_contents($filename);
}
?>

<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal">
		<span aria-hidden="true">&times;</span>
		<span class="sr-only"><?php 
echo t('Close');
?>
</span>
	</button>
	<h4 class="modal-title"><?php 
echo t('Recover Post');
?>
Exemplo n.º 17
0
}
$ret_info = new ReturnInfo();
$ret_info->status = 'error';
$ret_info->detail = t('N/A');
if (!fse_try_to_login()) {
    $ret_info->detail = t('Not signed in.');
    echo $json->encode($ret_info);
    exit(0);
}
if ($_SESSION[$form_token_name] != $form_token) {
    $ret_info->detail = t('Bad request or session expired.');
    echo $json->encode($ret_info);
    exit(0);
}
//unset ($_SESSION [$form_token_name]);
$comment = DocSectionManager::newComment($domain_handle, $section_id, $_SESSION['FSEInfo']['fse_id'], $comment_action, $comment_body, $comment_reply_to);
if ($comment == false) {
    $ret_info->status = 'error';
    $ret_info->detail = t('Bad comment');
    echo $json->encode($ret_info);
    exit(0);
}
$author_info = $_SESSION['FSEInfo'];
if (!isset($fse_info['avatar_url'])) {
    $author_info['avatar_url'] = get_url_from_file_id($author_info['avatar_file_id']);
}
$uh = Loader::helper('concrete/urls');
$bt = BlockType::getByHandle('document_section');
$delete_action = $uh->getBlockTypeToolsURL($bt) . '/delete_comment.php';
if (preg_match("/^[0-9a-f]{32}\$/", $comment['replied_author_id'])) {
    $replied_name_info = FSEInfo::getNameInfo($comment['replied_author_id']);