示例#1
0
文件: pages.php 项目: ssrsfs/blg
<?php

/**
 * Manage the pages where a plugin appears.
 */
// validate plugin location id
$plug_loc = Model_PlugLoc::Get($_REQUEST['locid']);
if (!$plug_loc->exists()) {
    Bam_Json::FailureOrRedirect('Invalid socket plugin id.', $typef_app_dir);
}
// process form
if ('POST' == $_SERVER['REQUEST_METHOD']) {
    // TODO: Handle empty rules array (assuming "all" for now)
    $rules = '';
    if (empty($_POST['allpages']) && isset($_POST['rules'])) {
        $allExcludes = true;
        foreach ($_POST['rules'] as $rule) {
            if (substr($rule, 0, 1) != '!') {
                $allExcludes = false;
            }
        }
        $rules = implode(';', $_POST['rules']);
        if ($allExcludes) {
            $rules = "url:*;{$rules}";
        }
    } else {
        $rules = 'url:*';
    }
    $plug_loc = Model_PlugLoc::Get($_POST['locid']);
    $plug_loc->set('rules', $rules);
    $plug_loc->save();
示例#2
0
文件: insert.php 项目: ssrsfs/blg
<?php

/**
 * Insert a plugin into a location (socket).
 */
// save typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// requires POST
if ('POST' != $_SERVER['REQUEST_METHOD']) {
    Bam_Json::FailureOrRedirect('Nothing to do.', $typef_app_dir);
}
// Do not display the plugin by default
$rules = 'url:*;!url:*';
// append plugin into location; get and check location id
$locid = Model_PlugLoc::Append($_POST['plugid'], $_POST['skin'], $_POST['socket'], $rules);
if (is_null($locid)) {
    Bam_Json::FailureOrRedirect('Error adding plugin to skin.', $typef_app_dir);
}
// build HTML if request is AJAX
if (requestIsAjax()) {
    $pm->setVariable('skin', $_POST['skin']);
    $pm->setVariable('p', new Plug_Loc($locid));
    $html = $pm->writeText('<pm:include template="admin/plugins/socket-plugin.inc.html" />');
} else {
    $html = null;
}
// done; return result
Bam_Json::SuccessOrRedirect('Plugin added to skin.', "{$typef_app_dir}?skin={$_POST['skin']}", array('html' => $html));
示例#3
0
文件: hierarchy.php 项目: ssrsfs/blg
<?php

/*
	11 april 2011: created from update.php
	12 april 2011: moved nested sortable class to its own file
	22 april 2011: dropped includes (now part of package/registry)
*/
// save some typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri() . 'categories/';
// get inputs and validate them
$ids = @$_POST['ids'];
$categories = new NestedSortable_Categories('Download_Category');
list($message, $categories) = $categories->parse($ids);
if (false === $categories) {
    die(Bam_Json::Failure($message));
}
// update each category
foreach ($categories as $category) {
    $category->save();
}
// done; return success
die(Bam_Json::Success('Download categories updated successfully.'));