Beispiel #1
0
 /**
  * Check, if current url has old format - execute 301 redirect to correct address
  * @param $params
  */
 protected function _checkRedirect($params)
 {
     // get vars
     $segments = $params['segments'];
     $segCout = count($segments);
     // item url
     if ('item' == $segments[0] && 2 == $segCout) {
         $itemId = $this->_aliasItem->translateAliasToID($segments[1]);
         $item = $this->_itemTable->get((int) $itemId);
         $newUrl = $this->_getUrl($item, 'item');
         $this->_redirect($newUrl);
     }
     // for excess get param category_id
     if ($this->_config->get('fix_category_id', 0)) {
         $reg = '#' . $segments[0] . '\\?category_id=\\d*$#i';
         $curUrl = $this->app->jbenv->getCurrentUrl();
         if (preg_match($reg, $curUrl, $matches)) {
             $itemId = $this->_aliasItem->translateAliasToID($segments[0]);
             $item = $this->_itemTable->get((int) $itemId);
             $newUrl = $this->_getUrl($item, 'item');
             $this->_redirect($newUrl);
         }
     }
     // category url
     if ('category' == $segments[0] && (2 == $segCout || 3 == $segCout)) {
         // simple variant
         if (2 == $segCout) {
             $catId = $this->_aliasCat->translateAliasToID($segments[1]);
             $category = $this->_catTable->get((int) $catId);
             $newUrl = $this->_getUrl($category, 'category');
             $this->_redirect($newUrl);
         } else {
             if (3 == $segCout) {
                 // with pagination
                 $catId = $this->_aliasCat->translateAliasToID($segments[1]);
                 $category = $this->_catTable->get((int) $catId);
                 $newUrl = $this->_getUrl($category, 'category') . (int) $segments[2];
                 $this->_redirect($newUrl);
             }
         }
     }
     // feed
     if ('feed' == $segments[0] && ('rss' == $segments[1] || 'atom' == $segments[1]) && (3 == $segCout || 4 == $segCout)) {
         $appId = $this->_aliasApp->translateAliasToID($segments[2]);
         if ($appId) {
             if (isset($segments[3])) {
                 $categoryId = $this->_aliasCat->translateAliasToID($segments[3]);
                 $category = $this->_catTable->get($categoryId);
             } else {
                 $category = $this->app->object->create('category');
                 $category->id = 0;
                 $category->name = 'ROOT';
                 $category->alias = '_root';
             }
             $newUrl = $this->_getUrl($category, 'feed', $segments[1]);
             $this->_redirect($newUrl);
         }
     }
 }
Beispiel #2
0
 public static function has_role($catid, $userinfo)
 {
     $category = CategoryTable::getInstance()->find($catid);
     foreach ($userinfo['role'] as $role) {
         $roles[] = $role['id'];
     }
     $cat_roles = array_filter(explode(',', $category->manager));
     foreach ($cat_roles as $r) {
         if (in_array($r, $roles)) {
             return $category;
         }
     }
     return false;
 }
 public function index($id_or_alias)
 {
     parent::load('model', 'system/contrib/auth');
     parent::load('model', 'articles');
     $articles = Article::get_by_category($id_or_alias);
     import('system/share/web/paginator');
     $paginator = new Paginator($articles, $_GET['page'], 10);
     $category = CategoryTable::getInstance()->findByAlias($id_or_alias);
     $smarty = parent::load('smarty');
     $smarty->assign('category', $category[0]);
     $smarty->assign('paginator', $paginator->output());
     $smarty->assign('page_title', $category[0]->name);
     $smarty->display('article/list');
 }
Beispiel #4
0
 /**
  * Remove all catagories
  * @param int $appId
  * @param array $exclude
  * @return bool
  */
 public function removeAll($appId, $exclude = array())
 {
     if (!(int) $appId) {
         return false;
     }
     $conditions = array('application_id = ' . (int) $appId);
     if (!empty($exclude)) {
         $conditions[] = ' AND id NOT IN (' . implode(', ', $exclude) . ')';
     }
     $categories = $this->_table->all(compact('conditions'));
     foreach ($categories as $category) {
         $this->_table->delete($category);
         $this->_table->unsetObject($category->id);
         unset($category);
     }
     return true;
 }
Beispiel #5
0
                $quantity = floor($quantity / $row["rounding_factor"]) * $row["rounding_factor"];
            }
        }
        echo '     <td>' . $row["item_name"] . '</td>
                    <td>' . $row["unit"] . '</td>
                    <td>' . $row["quantity"] . '</td>
                    <td class="quantity_required">' . $quantity . '</td>
                    <td>
                        <textarea name="" id="" rows="2" onchange=updateNotes(this) value="' . $row["notes"] . '">' . $row["notes"] . '</textarea>
                        <input type="hidden" value="' . $row["item_id"] . '">
                    </td>
                </tr>';
    }
}
if (isset($_POST["getPrintPreviewTimeslots"])) {
    $result = CategoryTable::get_print_preview_timeslots($_POST["date"], $_POST["timeSlotName"]);
    $current_category = null;
    while ($row = $result->fetch_assoc()) {
        if ($row["category_name"] != $current_category and $row["category_name"] != null) {
            $current_category = $row["category_name"];
            echo '<tbody class="print_tbody" id="print_tbody">
                    <tr id="category"><td colspan="5" class="table_heading"><h4 class="none">' . $row["category_name"] . '</h4></td></tr>
                    <tr id="category_columns">
                        <th>Item</th>
                        <th>Unit</th>
                        <th>Quantity Present</th>
                        <th>Quantity Required</th>
                        <th>Notes</th>
                    </tr>';
        }
        echo '<tr id="column_data" class="row">';
Beispiel #6
0
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="main_iframe">
        <div class="div_category">
            <h4>Categories</h4><hr>
            <div class="div_list_category">
            <ul class="category_list" id="category_list" >
                <?php 
$result = CategoryTable::get_categories($date = date('Y-m-d'));
?>
                <?php 
while ($row = $result->fetch_assoc()) {
    ?>
                    <li id="<?php 
    echo $row['id'];
    ?>
" class="list_category_li" onclick=categorySelect(this)>
                        <div class="handle_delete"><img src="images/delete.png" alt="" width="30px" height="30px"></div>
                        <span><?php 
    echo $row["name"];
    ?>
</span>
                        <form action="edit_categories.php" method="post">
                            <input type="hidden" name="delete_id" value="<?php 
Beispiel #7
0
 function get_by_id($id)
 {
     $cateTab = new CategoryTable();
     return $cateTab->get_by_id($id);
 }
Beispiel #8
0
 public function category_edit($id)
 {
     parent::load('model', 'articles');
     parent::load('model', 'system/contrib/auth');
     $category = CategoryTable::getInstance()->find($id);
     if (!$category) {
         HTTPRedirect::flash_to('manager/article_categories', '分类不存在', $this->smarty);
     }
     $roles = RoleTable::getInstance()->findAll();
     $roles_cleaned = array();
     foreach ($roles as $role) {
         $roles_cleaned[$role['id']] = $role['name'];
     }
     $this->smarty->assign('roles', $roles_cleaned);
     $this->smarty->assign('checked', array_filter(explode(',', $category['manager'])));
     $this->smarty->assign('category', $category);
     if ($this->is_post()) {
         $category->name = trim(strip_tags($_POST['name']));
         $category->manager = sprintf(',%s,', implode(',', $_POST['roles']));
         $category->save();
         HTTPRedirect::flash_to('manager/article_categories', '修改分类成功', $this->smarty);
     }
     $this->smarty->display('manager/article/category_edit');
 }
Beispiel #9
0
 public function executeCatalog(sfWebRequest $request)
 {
     $this->catList = CategoryTable::getInstance()->getMainPageList();
 }
Beispiel #10
0
    <link rel="stylesheet" href="styles.css">
</head>
<body class="overflow_hidden">
    <?php 
$page = "home";
include_once "new_nav.php";
?>
    <div class="main">
        <div class="div_category" id="home_list">
           <ul class="category_list">
            <h4><?php 
echo date('D, M d Y', strtotime($_SESSION["date"]));
?>
</h4><hr>
            <?php 
$result = CategoryTable::get_categories($_SESSION["date"]);
while ($row = $result->fetch_assoc()) {
    ?>
                 <li class="list_category_li">
                    <span><?php 
    echo $row["name"];
    ?>
</span>
                    <input type="hidden" id="category_id" name="category_id" value="<?php 
    echo $row['id'];
    ?>
">
                    <span class="item_counter" id="total"><?php 
    echo ItemTable::get_total_items($row['id'], $_SESSION["date"]);
    ?>
</span>