function insertProcess() { $send = Request::get('send'); $valid = Validator::make(array('send.title' => 'required|min:1|slashes', 'send.parentid' => 'slashes', 'send.url' => 'required|min:1|slashes')); if (!$valid) { throw new Exception("Error Processing Request: " . Validator::getMessage()); } $loadData = Links::get(array('where' => "where url='" . String::encode($send['url']) . "'")); if (isset($loadData[0]['url'])) { throw new Exception("This link exists in database."); } if (!($id = Links::insert($send))) { throw new Exception("Error. " . Database::$error); } $updateData = array('sort_order' => $id); Links::update($id, $updateData); }
public function index() { $post = array('alert' => ''); Model::load('admincp/links'); $curPage = 0; if ($match = Uri::match('\\/page\\/(\\d+)')) { $curPage = $match[1]; } if (Request::has('btnAction')) { actionProcess(); } if (Request::has('btnAdd')) { try { insertProcess(); $post['alert'] = '<div class="alert alert-success">Add new link success.</div>'; } catch (Exception $e) { $post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>'; } } if (Request::has('btnSave')) { $match = Uri::match('\\/edit\\/(\\d+)'); try { updateProcess($match[1]); $post['alert'] = '<div class="alert alert-success">Update link success.</div>'; } catch (Exception $e) { $post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>'; } } if (Request::has('btnSearch')) { filterProcess(); } else { $post['pages'] = Misc::genSmallPage('admincp/links', $curPage); $post['theList'] = Links::get(array('limitShow' => 20, 'limitPage' => $curPage, 'orderby' => 'order by sort_order asc', 'cache' => 'no')); } if ($match = Uri::match('\\/edit\\/(\\d+)')) { $loadData = Links::get(array('where' => "where id='" . $match[1] . "'", 'cache' => 'no')); $post['edit'] = $loadData[0]; } $post['listLinks'] = Links::get(array('orderby' => 'order by sort_order asc', 'cache' => 'no')); System::setTitle('Links list - ' . ADMINCP_TITLE); View::make('admincp/head'); self::makeContents('linksList', $post); View::make('admincp/footer'); }
* @reference * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License */ // common definitions and initial processing include_once '../shared/global.php'; include_once 'links.php'; // look for the id $id = NULL; if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } elseif (isset($context['arguments'][0])) { $id = $context['arguments'][0]; } $id = strip_tags($id); // get the item from the database $item = Links::get($id); // get the related anchor, if any $anchor = NULL; if (isset($item['anchor']) && $item['anchor']) { $anchor = Anchors::get($item['anchor']); } // associates and authenticated editors can do what they want if (Surfer::is_associate() || Surfer::is_member() && is_object($anchor) && $anchor->is_assigned()) { $permitted = TRUE; } elseif (is_object($anchor) && !$anchor->is_viewable()) { $permitted = FALSE; } elseif (Surfer::is_member() && !strcmp($item['anchor'], 'user:'******'edit_id']) && Surfer::is($item['edit_id'])) { $permitted = TRUE; } else {
<?php $pageData = array(); $pageName = System::getCurrentPage(); $pageName = $pageName == '' ? 'home' : $pageName; if ($matches = Uri::match('^(\\w+)\\/?')) { $pageName = $matches[1]; } if ($matches = Uri::match('^page\\/(\\d+)')) { $pageName = 'home'; } // Theme::view('head'); $codeHead = Plugins::load('site_header'); $codeHead = is_array($codeHead) ? '' : $codeHead; $codeFooter = Plugins::load('site_footer'); $codeFooter = is_array($codeFooter) ? '' : $codeFooter; // print_r($codeHead);die(); System::defineGlobalVar('site_header', $codeHead); System::defineGlobalVar('site_footer', $codeFooter); $links = Links::get(array('cacheTime' => 3, 'orderby' => 'order by sort_order asc')); System::defineVar('linkList', $links, 'head'); Controller::loadWithPath('theme' . ucfirst($pageName), 'index', System::getThemePath() . 'controller/'); // Theme::view('footer');
if (preg_match('/^ftp\\./', $url)) { $url = 'ftp://' . $url; } elseif (preg_match('/^irc\\./', $url)) { $url = 'irc://' . $url; } elseif (preg_match('/^(news|nntp)\\./', $url)) { $url = 'news://' . $url; } elseif (preg_match('/^www\\./', $url)) { $url = 'http://' . $url; } else { $url = $context['url_to_root'] . $url; } } // remove last slash, if any, to normalize links in database $url = rtrim($url, '/'); // get the item from the database $item = Links::get($url); // get the related anchor, if any $anchor = NULL; if (isset($item['anchor']) && $item['anchor']) { $anchor = Anchors::get($item['anchor']); } // the anchor has to be viewable by this surfer if (is_object($anchor) && !$anchor->is_viewable()) { $permitted = FALSE; } else { $permitted = TRUE; } // load the skin, maybe with a variant load_skin('links', $anchor); // clear the tab we are in, if any if (is_object($anchor)) {
/** * This function adds all styles and scripts to the HTML. It also retrieves primary and secondary links from the App * */ public static function hook_post_display($data, $controller) { Backend::addScript(SITE_LINK . '/js/backend.js'); //TODO Add site_link, and other vars, as JS vars Backend::addScriptContent('var site_link = \'' . SITE_LINK . '\';'); //TODO if someone can land a script file in the correct place, he can insert JS at will... $comp_script = '/js/' . Controller::$area . '.component.js'; $comp_style = '/css/' . Controller::$area . '.component.css'; if (file_exists(WEB_FOLDER . $comp_script)) { Backend::addScript(SITE_LINK . $comp_script); } if (file_exists(WEB_FOLDER . $comp_style)) { Backend::addStyle(SITE_LINK . $comp_style); } //Make sure that jquery and backend is right at the top $scripts = array_unique(array_filter(Backend::getScripts())); $against = array(); if (in_array(SITE_LINK . '/js/jquery.js', $scripts)) { $against[] = SITE_LINK . '/js/jquery.js'; } if (in_array(SITE_LINK . '/js/backend.js', $scripts)) { $against[] = SITE_LINK . '/js/backend.js'; } $scripts = array_unique(array_merge($against, $scripts)); Backend::add('Styles', array_unique(array_filter(Backend::getStyles()))); Backend::add('Scripts', $scripts); Backend::add('ScriptContent', array_unique(array_filter(Backend::getScriptContent()))); $primary = Links::get('primary'); $secondary = Links::get('secondary'); $tertiary = Links::get('tertiary'); $app_class = ConfigValue::get('settings.Class', 'Application'); if (class_exists($app_class, true) && method_exists($app_class, 'getLinks')) { $app_pri = call_user_func(array($app_class, 'getLinks'), 'primary'); $app_sec = call_user_func(array($app_class, 'getLinks'), 'secondary'); $app_tri = call_user_func(array($app_class, 'getLinks'), 'tertiary'); } else { $app_pri = false; $app_sec = false; $app_tri = false; } $primary = array_merge($primary, is_array($app_pri) ? $app_pri : array()); $secondary = array_merge($secondary, is_array($app_sec) ? $app_sec : array()); $tertiary = array_merge($tertiary, is_array($app_tri) ? $app_tri : array()); Backend::add('primary_links', $primary); Backend::add('secondary_links', $secondary); Backend::add('tertiary_links', $tertiary); return $data; }