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; }
<?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']}");
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 $source = file_get_contents($skinfile);