Example #1
0
File: odc.php Project: noinfo/odc
function odc_display_content($request_tag = "default", $anypage = FALSE)
{
    $tag = strtolower($request_tag);
    $page = strtolower($_SERVER['SCRIPT_NAME']);
    // now check for/get content from the database...
    if ($anypage) {
        $sql = 'SELECT content,markdown FROM odc WHERE tag="' . $tag . '" AND page="any";';
    } else {
        $sql = 'SELECT content,markdown FROM odc WHERE tag="' . $tag . '" AND page="' . $page . '";';
    }
    $rows = odc_my_query($sql);
    $content = mysql_fetch_assoc($rows);
    if (empty($content)) {
        // call function to create new content-stub if there is none
        odc_new($tag, $anypage);
    } else {
        // print out content
        if ($content['markdown'] > 0) {
            require_once $GLOBALS['MD_file'];
            echo markdown($content['content']);
        } else {
            echo $content['content'];
        }
    }
    // just for debugging, return nothing normally...
    //return "Tag: ".$tag." Page: ".$page;
    return;
}
Example #2
0
function odc_edit($id){
	
	$sql = 'SELECT tag,page,markdown,content FROM odc WHERE id="'.$id.'";';
	$rows = odc_my_query($sql);
	$onerow = mysql_fetch_assoc($rows);

	?>
<!-- HTML part -->	
<p>
Editing tag "<?=$onerow['tag']?>" on page <?=$onerow['page']?>.
</p>
<div>
<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
	<input type="hidden" name="id" value="<?=$id?>"/>
<textarea name="content" rows="25" cols="95">
<?=$onerow['content']?>
</textarea>

	<input type="submit" value="   save   "/>
</form>
</div>
<?
	// disable nicedit if simple-flag is set in odc_config or if content is markdown
	if(!$GLOBALS["simple_text_area"] && $onerow['markdown'] < 1){
?>
<!-- nicedit begin -->
<div>
<script type="text/javascript" src="<?=$GLOBALS['NCE_script_path']?>"></script>
<script type="text/javascript">
	bkLib.onDomLoaded(function() { nicEditors.allTextAreas(<?=$GLOBALS['NCE_editor_options']?>)});
</script>
</div>
<!-- nicedit end, html part end -->
<?php }
	return;
} // end of odc_edit()
Example #3
0
function odc_list($tabletags = "")
{
    // get config options from odc_config.php
    $basedir = $GLOBALS['basedir'];
    $deletable = $GLOBALS['deletable'];
    $editlink = $GLOBALS['edit_link'];
    $odc_dir = $GLOBALS['odc_dir'];
    $enable_markdown = $GLOBALS['enable_markdown'];
    // now get the content from the database...
    $sql = 'SELECT id,tag,markdown,page,content FROM odc WHERE 1 ORDER BY page;';
    //echo $sql;
    $rows = odc_my_query($sql);
    if ($deletable) {
        $html_table = "<form name=\"delete_stubs\" action=\"" . $odc_dir . "odc_action.php\" method=\"POST\">";
    }
    $html_table = $html_table . "<table " . $tabletags . ">\n\t<tr><th>page</th><th>tag</th>";
    if ($enable_markdown) {
        $html_table = $html_table . "<th title=\"markdown\">md</th>";
    }
    $html_table = $html_table . "<th>content</th><th>options</th>";
    if ($deletable) {
        $html_table = $html_table . "<th><select name=\"action\" id=\"action\">\n\t\t\t<option value=\"\" selected>action</option>\t\n\t\t\t<option value=\"delete\">delete</option>";
        if ($enable_markdown) {
            $html_table = $html_table . "<option value=\"markdown\">markdown</option>";
        }
        $html_table = $html_table . "</select></th>";
    }
    $html_table = $html_table . "</tr>";
    while ($onerow = mysql_fetch_assoc($rows)) {
        if ($onerow['page'] == "any") {
            // do not link to "any"-page content...
            $html_table = $html_table . "\n\t<tr><td>" . $onerow['page'] . "</td><td>" . $onerow['tag'] . "</td>";
        } else {
            $html_table = $html_table . "\n\t<tr><td><a href=\"" . $basedir . $onerow['page'] . "\">" . $onerow['page'] . "</a></td><td>" . $onerow['tag'] . "</td>";
        }
        if ($enable_markdown) {
            $html_table = $html_table . '<td><input type="radio" name="markdown_' . $onerow['id'] . '" title="markdown status for ' . $onerow['tag'] . '" ';
            if ($onerow['markdown'] > 0) {
                $html_table = $html_table . ' checked ';
            }
            $html_table = $html_table . 'disabled></td>';
        }
        // special handling of content (do not display...)
        if (empty($onerow['content'])) {
            $html_table = $html_table . "<td>empty</td>";
        } else {
            $html_table = $html_table . "<td>" . strlen($onerow['content']) . " characters</td>";
        }
        // display the edit button
        $html_table = $html_table . '<td><a href="' . $editlink . '?id=' . $onerow['id'] . '"><button>edit</button></a></td>';
        // display the mark if deletable
        if ($deletable) {
            $html_table = $html_table . '<td><input type="checkbox" name="marked[]" value="' . $onerow['id'] . '" title="' . $onerow['tag'] . '"></td>';
        }
        // end tablerow
        $html_table = $html_table . "</tr>";
    }
    if ($deletable) {
        $html_table = $html_table . "\n<tr><td colspan=\"6\" align=\"right\"><input type=\"submit\" value=\"perform action\" " . 'onClick="return confirm(\'Are you sure you want to perform the action on the marked content?\');"/></td>';
    }
    $html_table = $html_table . "\n</table>\n</form>";
    return $html_table;
}
Example #4
0
    }
}
if ($_POST['action'] == "markdown") {
    /*
    	Handles enabling and disabling of markdown support for stubs		
    */
    // this is necessary to ensure correct behaviour if no box was marked in the form
    if ($_POST['marked']) {
        $formvalues = $_POST['marked'];
    } else {
        $formvalues = array();
    }
    $all_ids = array();
    $sql = "SELECT id, markdown FROM odc WHERE TRUE;";
    // actually markdown-state is not really needed
    $result = odc_my_query($sql);
    // strings to hold ids for sql-request
    $markdown_on = "";
    $markdown_off = "";
    // first write down all ids (and markdown states, though these are unused for now)
    while ($row = mysql_fetch_assoc($result)) {
        $all_ids[$row['id']] = $row['markdown'];
    }
    // find all new states
    foreach ($all_ids as $key => $value) {
        if (in_array($key, $formvalues)) {
            $markdown_on .= ",'" . $key . "'";
        } else {
            $markdown_off .= ",'" . $key . "'";
        }
    }