Пример #1
0
 public static function Append($plugid, $skin, $socket, $rules)
 {
     $plugloc = Model_PlugLoc::Create();
     $plugloc['plugid'] = $plugid;
     $plugloc['skin'] = $skin;
     $plugloc['socket'] = $socket;
     $plugloc['rules'] = $rules;
     $plugloc->save();
     return $plugloc['id'];
 }
Пример #2
0
 private static function _GetPluginsFor($for)
 {
     $locs = new Model_PlugLoc();
     $locs->where('skin = ?', Typeframe_Skin::Current());
     $locs->where('socket = ?', $for);
     $locs->where('plugin.siteid = ?', Typeframe::CurrentPage()->siteid());
     $locs->order('sortnum');
     $result = array();
     foreach ($locs->select() as $loc) {
         $show = true;
         if ($loc['rules']) {
             $show = self::ProcessRules($loc['rules']);
         }
         if ($show) {
             $plug = $loc['plugin'];
             $result[] = $plug;
         }
     }
     return $result;
 }
Пример #3
0
<?php

/**
 * Delete a plugin and remove it from all locations.
 */
// save typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// requires POST
if ('POST' != $_SERVER['REQUEST_METHOD']) {
    Typeframe::Redirect('Nothing to do.', $typef_app_dir);
    return;
}
// get and validate plugin id
$plugid = trim(@$_POST['plugid']);
$plug = Model_Plug::Get($plugid);
if (!$plug->exists()) {
    Typeframe::Redirect('Invalid plugin id.', $typef_app_dir);
    return;
}
// delete any locations that use this plugin
$plug_locs = new Model_PlugLoc();
$plug_locs->where('plugid = ?', $plugid);
foreach ($plug_locs->getAll() as $plug_loc) {
    $plug_loc->delete();
}
// delete the plugin itself
$plug->delete();
// done
Typeframe::Redirect('Plugin deleted.', "{$typef_app_dir}?skin={$_POST['skin']}");
Пример #4
0
<?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));
Пример #5
0
<?php

/**
 * Change the order of plugins in a socket.
 */
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!isset($_POST['locid']) || !is_array($_POST['locid'])) {
        Typeframe::Redirect('Invalid socket plugin ids.', $typef_app_dir);
    } else {
        $sortnum = 1;
        foreach ($_POST['locid'] as $locid) {
            $plugloc = Model_PlugLoc::Get($locid);
            $plugloc->set('sortnum', $sortnum);
            $plugloc->save();
            ++$sortnum;
        }
        Typeframe::Redirect('Plugins sorted.', $typef_app_dir);
    }
} else {
    Typeframe::Redirect('Nothing to do.', $typef_app_dir);
}
Пример #6
0
    $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();
    Typeframe::Redirect('Plugin location updated.', Typeframe::CurrentPage()->applicationUri() . '?skin=' . $row['skin']);
    return;
}
// add plugin location to template
$pm->setVariable('plugin', $plug_loc);
// define enterprise children, root
if (TYPEF_ENT) {
    $children = TypeframeEnterpriseChild::DAOFactory();
    $children = $children->getAll();
    array_unshift($children, TypeframeEnterprise::GetChild(0));
    // add to template
    foreach ($children as $child) {
        $pm->addLoop('children', array('id' => $child->get('id'), 'name' => TYPEF_ENT_CHILD_NAME . ' ' . $child->get('childname')));
Пример #7
0
$skins = array();
foreach (glob(TYPEF_DIR . '/skins/*', GLOB_ONLYDIR) as $directory) {
    $skins[] = basename($directory);
}
$pm->setVariable('skins', $skins);
// set skin; add to template
$skin = trim(@$_REQUEST['skin']);
$skin = strlen($skin) > 0 ? $_REQUEST['skin'] : (TYPEF_SITE_SKIN ? TYPEF_SITE_SKIN : 'default');
if (!in_array($skin, $skins)) {
    Typeframe::Redirect("'{$skin}' was not found in the skins directory.", TYPEF_WEB_DIR . '/admin/skins');
    return;
}
$pm->setVariable('skin', $skin);
// load sockets
$plugins = array();
$sockets = new Model_PlugLoc();
$sockets->where('skin = ?', $skin);
$sockets->where('plugin.siteid = ?', Typeframe::CurrentPage()->siteid());
$sockets->order('socket, sortnum');
foreach ($sockets->getAll() as $socket) {
    if (!isset($plugins[$socket->get('socket')])) {
        $plugins[$socket->get('socket')] = array();
    }
    $plugins[$socket->get('socket')][] = $socket;
}
// define skin file
$skinfile = TYPEF_DIR . '/skins/' . $skin . '/skin.html';
if (!file_exists($skinfile)) {
    $skinfile = TYPEF_DIR . '/skins/default/skin.html';
}
// load sockets for skin file