当前位置: 首页>>代码示例>>PHP>>正文


PHP url::item方法代码示例

本文整理汇总了PHP中url::item方法的典型用法代码示例。如果您正苦于以下问题:PHP url::item方法的具体用法?PHP url::item怎么用?PHP url::item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在url的用法示例。


在下文中一共展示了url::item方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_revision

 function action_revision($args)
 {
     global $manager, $tree, $user, $lang;
     /* Decode argumenst */
     $id = array_shift($args);
     $item =& $tree->getItemById($id);
     $id = $item['id'];
     if (!$tree->_hasRights('admin', $item['rights'])) {
         header('Location: ' . url::item($id));
         exit;
     }
     if (count($args)) {
         $action = array_shift($args);
         if ($action == 'create') {
             revisions::doCreateRevision($id);
             if ($_REQUEST['return']) {
                 header('Location: ' . $_REQUEST['return']);
                 exit;
             }
         }
         if ($action == 'publish') {
             revisions::doPublishRevision($id, $_REQUEST['revision']);
             if ($_REQUEST['return']) {
                 header('Location: ' . $_REQUEST['return']);
                 exit;
             }
         }
     }
     // Redirect
     header("Location: " . url::item());
     exit;
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:32,代码来源:plugin.php

示例2: event_ExecuteEditor

 function event_ExecuteEditor(&$data)
 {
     global $lang, $manager;
     if ($data['type'] == 'external' && $data['sheet'] == 'external') {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             if ($_REQUEST['url'] != 'http://') {
                 $res = sql::query("\r\n\t\t\t\t\t\t\tREPLACE \r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_external\r\n\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\tID='" . $data['params']['id'] . "',\r\n\t\t\t\t\t\t\t\trevision='" . $data['params']['revision'] . "',\r\n\t\t\t\t\t\t\t\turl='" . addslashes($_REQUEST['url']) . "'\r\n\t\t\t\t\t\t");
             }
             // Mark this action as a modification
             revisions::updateModificationDate($data['params']['id'], $data['params']['revision']);
             header("Location: " . url::item($data['params']['id'], 'edit') . "/external?revision=" . $data['params']['revision']);
             exit;
         }
         $res = sql::query("\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t*\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_external\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\tID='" . $data['params']['id'] . "' AND\r\n\t\t\t\t\t\trevision='" . $data['params']['revision'] . "'\r\n\t\t\t\t");
         $tpl = new Template($this->getTemplate('editor.template'));
         if ($row = sql::fetch_array($res)) {
             $tpl->set("url", $row['url']);
         } else {
             $tpl->set("url", 'http://');
         }
         $tpl->set("id", $data['params']['id']);
         $tpl->set("revision", $data['params']['revision']);
         $data['template']->append('content', $tpl->fetch());
     }
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:25,代码来源:plugin.php

示例3: event_ExecuteEditor

 function event_ExecuteEditor(&$data)
 {
     global $lang, $manager, $user;
     if (isset($manager->types[$data['type']]['content']['story']) && $data['sheet'] == 'contents') {
         // Retrieve story
         $res = sql::query("\n\t\t\t\t\tSELECT \n\t\t\t\t\t\t*\n\t\t\t\t\tFROM \n\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_story \n\t\t\t\t\tWHERE \n\t\t\t\t\t\t`ID` = '" . $data['params']['id'] . "' AND\n\t\t\t\t\t\t`revision` = '" . $data['params']['revision'] . "'\n\t\t\t\t");
         if ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
             $story = $row;
         } else {
             $story = array('text' => '');
         }
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $_POST['text'] = filter::images($_POST['text']);
             $_POST['text'] = filter::html($_POST['text']);
             $res = sql::query("\n\t\t\t\t\t\tREPLACE INTO \n\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_story \n\t\t\t\t\t\tSET \n\t\t\t\t\t\t\tID='" . $data['params']['id'] . "', \n\t\t\t\t\t\t\trevision='" . $data['params']['revision'] . "',\n\t\t\t\t\t\t\ttext='" . addslashes($_POST['text']) . "'\n\t\t\t\t\t");
             // Mark this action as a modification
             revisions::updateModificationDate($data['params']['id'], $data['params']['revision']);
             header("Location: " . url::item($data['params']['id'], 'edit') . "/contents?revision=" . $data['params']['revision']);
             exit;
         }
         $tpl = new Template($this->getTemplate('editor.template'));
         $tpl->set('story', $story);
         $tpl->set('id', $data['params']['id']);
         $tpl->set('revision', $data['params']['revision']);
         $data['template']->append('content', $tpl->fetch());
     }
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:27,代码来源:plugin.php

示例4: event_ExecuteEditor

 function event_ExecuteEditor(&$data)
 {
     global $lang, $manager;
     if ($data['sheet'] == 'background') {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $res = sql::query("\r\n\t\t\t\t\t\tREPLACE INTO \r\n\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_background\r\n\t\t\t\t\t\tSET \r\n\t\t\t\t\t\t\tID='" . $data['params']['id'] . "', \r\n\t\t\t\t\t\t\trevision='" . $data['params']['revision'] . "',\r\n\t\t\t\t\t\t\timage='" . addslashes($_REQUEST['image']) . "', \r\n\t\t\t\t\t\t\tmodified=NOW()\r\n\t\t\t\t\t");
             // Mark this action as a modification
             revisions::updateModificationDate($data['params']['id'], $data['params']['revision']);
             header("Location: " . url::item($data['params']['id'], 'edit') . "/background?revision=" . $data['params']['revision']);
             exit;
         }
         $res = sql::query("\r\n\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t* \r\n\t\t\t\t\tFROM \r\n\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_background\r\n\t\t\t\t\tWHERE \r\n\t\t\t\t\t\tid='" . $data['params']['id'] . "' AND\r\n\t\t\t\t\t\trevision='" . $data['params']['revision'] . "'\r\n\t\t\t\t");
         if ($row = sql::fetch_array($res)) {
             $image = $row['image'];
         } else {
             $image = '';
         }
         $tpl = new Template($this->getTemplate('editor.template'));
         $tpl->set('id', $data['params']['id']);
         $tpl->set('revision', $data['params']['revision']);
         $tpl->set('image', $image);
         $data['template']->append('content', $tpl->fetch());
         // Make sure the following assets are included
         $data['page']->assets->registerJavascript('/core/assets/javascript/modaldialog.js');
         $data['page']->assets->registerCSS($this->localAsset('editor.css'));
     }
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:27,代码来源:plugin.php

示例5: action_move

 function action_move($args)
 {
     global $manager, $tree, $user, $lang;
     /* Decode argumenst */
     $id = array_shift($args);
     $item =& $tree->getItemById($id);
     $id = $item['id'];
     if (!$tree->_hasRights('admin', $item['rights'])) {
         header('Location: ' . url::item($id));
         exit;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $parentid = intval($_POST['parent']);
         $position = 0;
         if ($parentid == 0) {
             reset($tree->tree);
             while (list($k, ) = each($tree->tree)) {
                 if ($tree->tree[$k]['id'] != 'admin') {
                     $position = max($position, $tree->tree[$k]['position']);
                 }
             }
         } else {
             if ($parent =& $tree->getItemById($parentid)) {
                 if (isset($parent['children'])) {
                     reset($parent['children']);
                     while (list($k, ) = each($parent['children'])) {
                         $position = max($position, $parent['children'][$k]['position']);
                     }
                 }
             }
         }
         $position++;
         treeStorage::startTransaction();
         treeStorage::prepareForMove($id, $parentid, $_POST['language']);
         sql::query("\r\n\t\t\t\t\tUPDATE \r\n\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents\r\n\t\t\t\t\tSET \r\n\t\t\t\t\t\t`parent`='" . $parentid . "',\r\n\t\t\t\t\t\t`position`=" . $position . "\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t`ID`='" . $id . "'\r\n\t\t\t\t");
         treeStorage::stopTransaction();
         // Our url needs to be rebuild...
         $url = url::item($id);
         $url = str_replace('/' . $item['meta']['language'] . '/', '/' . $_POST['language'] . '/', $url);
         header("Location: " . $url);
         exit;
     } else {
         @(include _BASE_LIBRARIES_ . 'resources/iso639to3166.php');
         $languages = array();
         $list = new languages(_DEFAULT_SITE_);
         while (list(, $language) = each($list->nodes)) {
             if ($language->public) {
                 $languages[] = array('id' => $language->id, 'name' => $language->name, 'flag' => strtolower($iso639to3166[$language->id]));
             }
         }
         $tpl = new Template($this->getTemplate('move.template'));
         $tpl->set('languages', $languages);
         $tpl->set('id', $id);
         echo $tpl->fetch();
         exit;
     }
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:57,代码来源:plugin.php

示例6: event_PreSkinParse

 function event_PreSkinParse(&$data)
 {
     global $manager, $tree;
     if ($data['params']['action'] == 'view' && ($data['type'] == 'redirect' || isset($manager->types[$data['type']]['content']['redirect']))) {
         if ($item =& $tree->getFirstChild($data['params']['id'])) {
             header("Location: " . url::item($item));
             exit;
         }
     }
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:10,代码来源:plugin.php

示例7: action_restore

 function action_restore($args)
 {
     global $manager, $tree, $user, $lang;
     /* Decode argumenst */
     $id = array_shift($args);
     if ($user->admin()) {
         $this->_restoreItem($id);
         header("Location: " . url::item($id));
     } else {
         header("Location: " . url::root());
     }
     exit;
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:13,代码来源:plugin.php

示例8: action_login

 function action_login($args)
 {
     global $manager, $tree, $user, $config, $lang;
     if ($config->get('inlineLogin')) {
         $page = new theme();
         $t = new Template($this->getTemplate('inline.template'));
         $l =& $lang;
     } else {
         $page = new admin();
         $t = new Template($this->getTemplate('form.template'));
         $l =& $user->lang;
     }
     if (count($args)) {
         $id = array_shift($args);
         // Check if the id contains an file extension
         if (preg_match('/(.*)\\.([a-z0-9]+)$/i', $id, $matches)) {
             $id = $matches[1];
         }
         $t->set('url', url::item($id, 'login'));
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $user->login(url::item($id));
             // If we end up here, we did not properly login... probably
             // username or password not correct...
             $t->set('error', $l->s('passwordnotcorrect'));
         } else {
             if (!$config->get('redirectToLogin')) {
                 $page->template->set('error', $l->s('notenoughrights') . ' ' . $l->s('logintoview'));
             }
         }
     } else {
         $t->set('url', url::action('login'));
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $user->login();
             // If we end up here, we did not properly login... probably
             // username or password not correct...
             $t->set('error', $l->s('passwordnotcorrect'));
         }
     }
     // Notify plugins of a PreSkinParse event;
     $data = array('page' => &$page, 'template' => &$page->template, 'type' => null, 'params' => array('action' => 'login', 'id' => null, 'args' => $args));
     $manager->handleEvent('PreSkinParse', $data);
     $page->template->set('title', $l->s('login'));
     $page->template->set('content', $t->fetch());
     $page->template->set('type', 'login');
     $page->show();
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:46,代码来源:plugin.php

示例9: action_delete

 function action_delete($args)
 {
     global $manager, $tree, $user, $lang;
     /* Decode argumenst */
     $id = array_shift($args);
     $item =& $tree->getItemById($id);
     $id = $item['id'];
     if (!$tree->_hasRights('admin', $item['rights'])) {
         header('Location: ' . url::item($id));
         exit;
     }
     $this->_deleteItem($id);
     // Redirect
     if ($item['parent'] > 0) {
         header("Location: " . url::item($item['parent']));
     } else {
         header("Location: " . url::item());
     }
     exit;
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:20,代码来源:plugin.php

示例10: action_duplicate

 function action_duplicate($args)
 {
     global $manager, $tree, $user, $lang;
     /* Decode argumenst */
     $id = array_shift($args);
     $item =& $tree->getItemById($id);
     $id = $item['id'];
     if (!$tree->_hasRights('admin', $item['rights'])) {
         header('Location: ' . url::item($id));
         exit;
     }
     if ($item['parent']) {
         $parentnode =& $tree->getItemById($item['parent']);
         $position = 0;
         if (isset($parentnode['children'])) {
             reset($parentnode['children']);
             while (list($k, ) = each($parentnode['children'])) {
                 $position = max($position, $parentnode['children'][$k]['position']);
             }
         }
         $position++;
         $parent = $item['parent'];
     } else {
         $position = 0;
         reset($tree->tree);
         while (list($k, ) = each($tree->tree)) {
             if ($tree->tree[$k]['id'] != 'admin') {
                 $position = max($position, $tree->tree[$k]['position']);
             }
         }
         $position++;
         $parent = '';
     }
     $newid = $this->_duplicateItem($id, $parent, $position);
     header("Location: " . url::item($newid, 'edit'));
     exit;
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:37,代码来源:plugin.php

示例11: logout

 function logout()
 {
     unset($_SESSION['USER_DATA']);
     header('Location: ' . url::item());
     exit;
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:6,代码来源:users.library.php

示例12: array_shift

        $action = array_shift($args);
    } else {
        $action = 'login';
    }
    if ($action != 'settings' && $config->get('multiLanguageSupport') && count($args)) {
        $language = array_shift($args);
    } else {
        $language = _DEFAULT_LANGUAGE_;
    }
    $lang = new language($language, _DEFAULT_SITE_, true);
    $user = new currentUser();
    $manager = new pluginManager();
    $tree = new pageTree($user, $manager, $language, _DEFAULT_SITE_);
    if ($action == 'login' && $user->loggedin()) {
        $id = $tree->getHome();
        header('Location: ' . url::item($id));
        exit;
    }
    $manager->handleAction($action, $args);
    exit;
}
if (!$config->get('installed')) {
    $lang = new language(_DEFAULT_LANGUAGE_, _DEFAULT_SITE_, true);
    $theme =& new theme();
    $theme->showError(_OFFLINE_MESSAGE_, 3);
}
if ($config->get('multiLanguageSupport') && count($args)) {
    $language = array_shift($args);
} else {
    $language = _DEFAULT_LANGUAGE_;
}
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:31,代码来源:core.library.php

示例13: action_create

 function action_create($args)
 {
     global $manager, $tree, $user, $lang;
     /* Decode argumenst */
     $id = array_shift($args);
     $item =& $tree->getItemById($id);
     $id = $item['id'];
     if (!$tree->_hasRights('create', $item['rights'])) {
         header('Location: ' . url::item($id));
         exit;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         // Determine the type of the page
         $type = $_POST['childtype'];
         if (isset($_POST['location']) && $_POST['location'] == 'sibling') {
             // Overwrite the type of the page
             $type = $_POST['siblingtype'];
             if ($item['parent'] > 0) {
                 // Set the item to its parent an continue...
                 $item =& $tree->getItemById($item['parent']);
             } else {
                 $position = 0;
                 reset($tree->tree);
                 while (list($k, ) = each($tree->tree)) {
                     if ($tree->tree[$k]['id'] != 'admin') {
                         $position = max($position, $tree->tree[$k]['position']);
                     }
                 }
                 $position++;
                 if (isset($_POST['language'])) {
                     $language = $_POST['language'];
                 } else {
                     $language = $tree->language;
                 }
                 if (isset($_POST['name'])) {
                     $name = $_POST['name'];
                 } else {
                     $name = $user->lang->s('untitled');
                 }
                 $slug = strtolower($name);
                 $slug = preg_replace('/(\\s+|_)/i', '-', $slug);
                 $slug = preg_replace('/[^a-z0-9\\-]/i', '', $slug);
                 $base = explode('/', $GLOBALS['HASH_URLS'][$data['params']['id']]);
                 array_shift($base);
                 $unique = false;
                 while (!$unique) {
                     $url = implode('/', array_merge($base, array($slug)));
                     if (isset($GLOBALS['HASH_IDS'][$url])) {
                         if (preg_match('/^(.*)-([0-9]+)$/i', $slug, $matches)) {
                             $slug = $matches[1] . '-' . (intval($matches[2]) + 1);
                         } else {
                             $slug = $slug . '-2';
                         }
                     } else {
                         $unique = true;
                     }
                 }
                 treeStorage::startTransaction();
                 list($left, $right) = treeStorage::prepareForInsert(0, $language);
                 $res = sql::query("\r\n\t\t\t\t\t\t\tINSERT INTO \r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents\r\n\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t\t`parent`='',\r\n\t\t\t\t\t\t\t\t`left`='" . $left . "',\r\n\t\t\t\t\t\t\t\t`right`='" . $right . "',\r\n\t\t\t\t\t\t\t\t`site`='" . _DEFAULT_SITE_ . "',\r\n\t\t\t\t\t\t\t\t`name`='" . addslashes($name) . "',\r\n\t\t\t\t\t\t\t\t`title`='',\r\n\t\t\t\t\t\t\t\t`slug`='" . addslashes($slug) . "',\r\n\t\t\t\t\t\t\t\t`type`='" . $type . "',\r\n\t\t\t\t\t\t\t\t`status`='0',\r\n\t\t\t\t\t\t\t\t`revision`=0,\r\n\t\t\t\t\t\t\t\t`position`='" . $position . "',\r\n\t\t\t\t\t\t\t\t`language`='" . $language . "',\r\n\t\t\t\t\t\t\t\t`author`='" . $user->id . "',\r\n\t\t\t\t\t\t\t\t`r_view`='3',\r\n\t\t\t\t\t\t\t\t`r_view_inv`='0',\r\n\t\t\t\t\t\t\t\t`r_edit`='6',\r\n\t\t\t\t\t\t\t\t`r_edit_inv`='0',\r\n\t\t\t\t\t\t\t\t`r_create`='6',\r\n\t\t\t\t\t\t\t\t`r_create_inv`='0',\r\n\t\t\t\t\t\t\t\t`r_admin`='6',\r\n\t\t\t\t\t\t\t\t`r_admin_inv`='0',\r\n\t\t\t\t\t\t\t\t`created`='" . time() . "',\r\n\t\t\t\t\t\t\t\t`modified`='" . time() . "',\r\n\t\t\t\t\t\t\t\t`visible`='1'\r\n\t\t\t\t\t\t");
                 treeStorage::stopTransaction();
                 $id = sql::insert_id();
                 /* Create the first revision */
                 revisions::doCreatePage($id);
                 header("Location: " . url::item($id, 'edit'));
                 exit;
             }
         }
         // Create the page
         $position = 0;
         if (isset($item['children'])) {
             reset($item['children']);
             while (list($k, ) = each($item['children'])) {
                 $position = max($position, $item['children'][$k]['position']);
             }
         }
         $position++;
         if (isset($_POST['language'])) {
             $language = $_POST['language'];
         } else {
             $language = $tree->language;
         }
         if (isset($_POST['name'])) {
             $name = $_POST['name'];
         } else {
             $name = $user->lang->s('untitled');
         }
         $slug = strtolower($name);
         $slug = preg_replace('/(\\s+|_)/i', '-', $slug);
         $slug = preg_replace('/[^a-z0-9\\-]/i', '', $slug);
         $base = explode('/', $GLOBALS['HASH_URLS'][$data['params']['id']]);
         array_shift($base);
         while (!$unique) {
             $url = implode('/', array_merge($base, array($slug)));
             if (isset($GLOBALS['HASH_IDS'][$url])) {
                 if (preg_match('/^(.*)-([0-9]+)$/i', $slug, $matches)) {
                     $slug = $matches[1] . '-' . (intval($matches[2]) + 1);
                 } else {
                     $slug = $slug . '-2';
                 }
//.........这里部分代码省略.........
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:101,代码来源:plugin.php

示例14: pageTree

    function pageTree(&$user, &$manager, $language, $site)
    {
        // Hash tables for quick URL translation
        $GLOBALS['HASH_URLS'] = array();
        $GLOBALS['HASH_IDS'] = array();
        $this->user =& $user;
        $this->manager =& $manager;
        $this->language = $language;
        $this->site = $site;
        $time = time();
        $res = sql::query('
			SELECT 
				* 
			FROM 
				' . _TABLE_PREFIX_ . 'contents 
			WHERE 
				language="' . $this->language . '" AND
				site="' . $this->site . '" AND
				status < 2
			ORDER BY 
				`left`
		');
        while ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
            if (intval($row['parent']) == 0 || isset($this->data[$row['parent']])) {
                // Create new hash entries for URL translation
                $slug = $row['slug'] == '' ? 'item-' . $row['ID'] : $row['slug'];
                if ($row['parent'] > 0) {
                    $url = $GLOBALS['HASH_URLS'][$row['parent']] . '/' . $slug;
                } else {
                    $url = $slug;
                }
                $GLOBALS['HASH_URLS'][$row['ID']] = $url;
                $GLOBALS['HASH_IDS'][$url] = $row['ID'];
                // Build tree
                $this->data[$row['ID']] = array('id' => intval($row['ID']), 'revision' => intval($row['revision']), 'parent' => intval($row['parent']), 'slug' => $row['slug'], 'set' => intval($row['set']), 'position' => $row['position'], 'created' => intval($row['created']), 'published' => intval($row['published']), 'modified' => intval($row['modified']), 'status' => $row['status'], 'name' => $row['name'], 'title' => $row['title'], 'type' => $row['type'], 'url' => url::item($row), 'expand' => false, 'rights' => array('r_view' => $row['r_view'], 'r_view_inv' => $row['r_view_inv'], 'r_edit' => $row['r_edit'], 'r_edit_inv' => $row['r_edit_inv'], 'r_create' => $row['r_create'], 'r_create_inv' => $row['r_create_inv'], 'r_admin' => $row['r_admin'], 'r_admin_inv' => $row['r_admin_inv'], 'author' => $row['author']), 'date' => array('activation' => $row['activation'], 'expiration' => $row['expiration'], 'visible' => $row['visible']), 'meta' => array('language' => $row['language'], 'created' => max($row['activation'], $row['created']), 'modified' => max($row['activation'], $row['modified'])));
                $sort = 0;
                $visible = true;
                $navigation = true && $row['visible'];
                /* Navigation and sort inherited from page type */
                if (isset($manager->types[$row['type']])) {
                    $navigation = $navigation && $manager->types[$row['type']]['visible'];
                    $sort = $manager->types[$row['type']]['sort'];
                }
                /* Check visibility of parent */
                if (intval($row['parent']) == 0) {
                    $this->tree[$row['ID']] =& $this->data[$row['ID']];
                } else {
                    $this->data[$row['parent']]['children'][] =& $this->data[$row['ID']];
                    /* Navigation manually set */
                    $navigation = $navigation && $this->data[$row['parent']]['visible'];
                }
                /* Check publishing date range */
                if ($visible) {
                    $visible = $visible && ($time > $this->data[$row['ID']]['date']['activation'] && $time < $this->data[$row['ID']]['date']['expiration']) || $time > $this->data[$row['ID']]['date']['activation'] && $this->data[$row['ID']]['date']['expiration'] == 0 || $this->data[$row['ID']]['date']['activation'] == 0 && $this->data[$row['ID']]['date']['expiration'] == 0;
                }
                /* Check view rights */
                if ($visible) {
                    $visible = $visible && $this->_hasRights('view', $this->data[$row['ID']]['rights']);
                }
                /* Check if a draft */
                if ($visible) {
                    $visible = $visible && $this->data[$row['ID']]['status'] > 0 || $this->user->admin();
                }
                $this->data[$row['ID']]['sort'] = $sort;
                $this->data[$row['ID']]['visible'] = $visible;
                $this->data[$row['ID']]['navigation'] = $navigation && $visible;
                if ($navigation && $visible) {
                    $tmp =& $this->data[$row['ID']];
                    while ($tmp['parent'] != 0) {
                        $tmp =& $this->data[$tmp['parent']];
                        $tmp['expand'] = true;
                    }
                }
                if ($row['slug'] != '') {
                    $this->slugs[$row['slug']] = $row['ID'];
                }
            }
        }
        if (!count($this->data)) {
            return;
        }
        // Sort all items
        while (list($id, ) = each($this->data)) {
            if (isset($this->data[$id]['children']) && $this->data[$id]['sort'] != 0) {
                switch (abs($this->data[$id]['sort'])) {
                    case 1:
                        $t = "strcasecmp(\$a['name'], \$b['name'])";
                        break;
                    case 2:
                        $t = "\$a['created'] - \$b['created']";
                        break;
                    case 3:
                        $t = "\$a['published'] - \$b['published']";
                        break;
                    case 4:
                        $t = "\$a['modified'] - \$b['modified']";
                        break;
                    default:
                        continue;
                }
//.........这里部分代码省略.........
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:101,代码来源:tree.library.php

示例15: event_ExecuteEditor

    function event_ExecuteEditor(&$data)
    {
        global $tree, $lang, $user, $config, $manager;
        if ($data['sheet'] == 'navigation') {
            $item =& $data['item'];
            $allow = false;
            $allow = $allow || $tree->_hasRights('admin', $item['rights']);
            if ($item['parent'] != '' && $item['parent'] != '0') {
                $parent =& $tree->getItemById($item['parent']);
                $allow = $allow || $tree->_hasRights('admin', $parent['rights']);
            }
            $errors = array();
            $tpl = new Template($this->getTemplate('editor.template'));
            if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                $hidden = isset($_POST['hidden']) && $_POST['hidden'] == 'yes' ? 0 : 1;
                $set = isset($_POST['set']) ? intval($_POST['set']) : 0;
                $res = sql::query("\r\n\t\t\t\t\t\tUPDATE \r\n\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents \r\n\t\t\t\t\t\tSET \r\n\t\t\t\t\t\t\t`set` = '" . addslashes($set) . "', \r\n\t\t\t\t\t\t\t`visible` = '" . $hidden . "' \r\n\t\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t\t`ID` = '" . $item['id'] . "'\r\n\t\t\t\t\t");
                if ($allow && isset($_POST['position'])) {
                    for ($i = 0; $i < intval($config->get('navigationSets')); $i++) {
                        $position = explode(',', $_POST['position'][$i]);
                        if ($set != $i) {
                            while (list($p, $id) = each($position)) {
                                if ($id == $item['id']) {
                                    unset($position[$p]);
                                }
                            }
                            reset($position);
                        }
                        /* Also include all disabled siblings, but at the bottom... */
                        $res = sql::query('
								SELECT 
									`ID`
								FROM 
									' . _TABLE_PREFIX_ . 'contents 
								WHERE 
									`parent` = ' . $item['parent'] . ' AND
									`set` = ' . $set . ' AND 
									`status` = 2 
								ORDER BY 
									`position`
							');
                        while ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
                            $position[] = $row['ID'];
                        }
                        /* Sort */
                        while (list($p, $id) = each($position)) {
                            treeStorage::startTransaction();
                            treeStorage::prepareForMove($id, $item['parent'], $item['meta']['language']);
                            $res = sql::query("\r\n\t\t\t\t\t\t\t\t\tUPDATE \r\n\t\t\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents \r\n\t\t\t\t\t\t\t\t\tSET \r\n\t\t\t\t\t\t\t\t\t\t`position`='" . addslashes($p + 100 * $set) . "'\r\n\t\t\t\t\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t\t\t\t\t`ID` = '" . addslashes($id) . "'\r\n\t\t\t\t\t\t\t\t");
                            treeStorage::stopTransaction();
                        }
                    }
                    header("Location: " . url::item($data['params']['id'], 'edit') . "/navigation");
                    exit;
                }
            }
            if ($data['item']['parent'] != '' && $data['item']['parent'] != '0') {
                $tpl->set('pages', $parent['children']);
            } else {
                // Make a copy that we can edit...
                $pages = $tree->tree;
                reset($pages);
                while (list($k, ) = each($pages)) {
                    if ($pages[$k]['id'] == 'admin') {
                        unset($pages[$k]);
                        continue;
                    }
                    if ($pages[$k]['status'] > 1) {
                        unset($pages[$k]);
                        continue;
                    }
                    /*
                    if ($data['item']['parent'] == 0 && $pages[$k]['set'] != $data['item']['set']) {
                    	unset($pages[$k]);
                    	continue;
                    }
                    */
                }
                $tpl->set('pages', $pages);
            }
            // Determine if we must sort this item manually
            $sort = 0;
            $hidden = true;
            if ($item['parent'] > 0) {
                $parent =& $tree->getItemById($item['parent']);
                if (isset($manager->types[$parent['type']])) {
                    $sort = $manager->types[$parent['type']]['sort'];
                    $hidden = $manager->types[$parent['type']]['visible'] == 0;
                }
            }
            $tpl->set('item', $data['item']);
            $tpl->set('id', $data['params']['id']);
            $tpl->set('allow', $allow);
            $tpl->set('hidden', $hidden);
            $tpl->set('sort', $sort);
            $tpl->set('sets', intval($config->get('navigationSets')));
            $data['template']->append('content', $tpl->fetch());
        }
    }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:99,代码来源:plugin.php


注:本文中的url::item方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。