/**
  * Display a listing of categories
  *
  * @return Response
  */
 public function index()
 {
     $data = Input::all();
     $categories = Category::where(function ($query) {
         if (Input::has('owner_type')) {
             $query->where('owner_type', Input::get('owner_type'));
         }
         if (Input::has('query')) {
             $query->where('name', 'like', '%' . Input::get('query') . '%');
         }
     });
     $types = Category::get(['owner_type']);
     $types = $types->groupBy(function ($category) {
         return $category->owner_type;
     })->toArray();
     if (Request::ajax()) {
         // SUGGESTIONS FOR AUTOCOMPLETE
         $categories = $categories->get();
         if (Input::has('query')) {
             $suggestions = array();
             foreach ($categories as $category) {
                 $suggestions[] = array("value" => $category->name, "data" => array('owner_type' => $category->owner_type));
             }
             $categories = array('suggestions' => $suggestions);
             return Response::json($categories);
         }
         // RETURN INDEX PANEL
         return View::make('categories.panels.index', compact('categories', 'types'));
     } else {
         $categories = $categories->paginate(Input::get('paginate', 10));
         return View::make('categories.index', compact('categories', 'types'));
     }
 }
 public static function generateSitemap($reGenerate = false)
 {
     // create new sitemap object
     $sitemap = App::make("sitemap");
     $sitemap->setCache('laravel.sitemap', 3600);
     if ($reGenerate) {
         Cache::forget($sitemap->model->getCacheKey());
     }
     // check if there is cached sitemap and build new only if is not
     if (!$sitemap->isCached()) {
         // add item to the sitemap (url, date, priority, freq)
         $sitemap->add(URL::to('/'), null, '1.0', 'daily');
         $categories = Category::get();
         foreach ($categories as $category) {
             $sitemap->add(URL::route('category', [$category->slug]), null, '1.0', 'daily');
         }
         // get all lists from db
         $lists = ViralList::orderBy('created_at', 'desc')->get();
         // add every post to the sitemap
         foreach ($lists as $list) {
             $sitemap->add(ListHelpers::viewListUrl($list), $list->updated_at, '1.0', 'monthly');
         }
     }
     // show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
     return $sitemap->render('xml');
 }
Example #3
0
/**
 * Theme functions for categories
 */
function total_categories()
{
    if (!($categories = Registry::get('categories'))) {
        $categories = Category::get();
        $categories = new Items($categories);
        Registry::set('categories', $categories);
    }
    return $categories->length();
}
Example #4
0
 function __construct($pth)
 {
     if (!is_example_path($pth) or !is_example_exists($pth)) {
         throw new Exception("Example {$pth} not exists");
     }
     $this->pth = $pth;
     $this->file_id = last(explode('/', $pth));
     $category_path = implode('/', but_last(explode('/', $pth)));
     $this->id = find_position($this->file_id, $category_path);
     $this->category = Category::get($category_path);
 }
Example #5
0
 function example_title($example)
 {
     $cats = array();
     foreach (bu::path() as $v) {
         if (preg_match('/^[0-9]+$/', $v)) {
             break;
         }
         $cats[] = Category::get($v)->name();
     }
     return 'Пример: ' . implode('/', $cats) . ' #' . $example->id();
 }
Example #6
0
 public function getRoot()
 {
     $treePath = array_values(array_filter(explode('/', $this->tree_path)));
     if (!empty($treePath[0])) {
         $category = Category::get($treePath[0]);
         if ($category) {
             return $category;
         }
     }
     return $this;
 }
 public function index()
 {
     switch ($this->type) {
         case 'categories':
             $list = Category::get(array('id', 'name', 'slug'));
             break;
         default:
             $list = Product::get(array('id', 'name', 'slug', 'pricing', 'in_stock', 'published'));
             break;
     }
     $this->layout->content = View::make('admin.control_panel.list', array('type' => $this->type, 'list' => $list));
 }
Example #8
0
 public static function getSub($path = '')
 {
     if ($path) {
         $path .= '/';
     }
     $dirs = glob(self::PREFIX . $path . '*', GLOB_ONLYDIR);
     if (!$dirs) {
         return array();
     }
     foreach ($dirs as $k => $v) {
         $v = str_replace(self::PREFIX, '', $v);
         $dirs[$k] = Category::get($v);
     }
     return sortByName($dirs);
 }
 public function get_update()
 {
     $post = Post::Find($this->post_id);
     $user = Auth::user();
     $categories = Category::get();
     $organisations = Organisation::get();
     $selected = array();
     foreach ($post->categories as $c) {
         $selected[] = $c->id;
     }
     $selected_org = array();
     foreach ($post->organisations as $o) {
         $selected_org[] = $o->id;
     }
     return View::Make('user.posts.update')->with('post', $post)->with('user', $user)->with('categories', $categories)->with('selected', $selected)->with('organisations', $organisations)->with('selected_org', $selected_org);
 }
Example #10
0
 public function generate_admin()
 {
     $post_count = $this->block->data('post_count');
     $alphabetical_order = $this->block->data('alphabetical_order');
     $category = $this->block->data('category');
     $count = array("1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "all" => "All");
     $option = array("yes" => "Yes", "no" => "No");
     $category_option = array("all" => "All");
     $categores = new Category();
     $all_category = $categores->get();
     foreach ($all_category->all as $key => $value) {
         $category_option[$value->id] = $value->name;
     }
     $this->admin_select('post_count', $count, 'Post Count: ', $post_count);
     $this->admin_select('alphabetical_order', $option, 'Alphabetical Order (a-z): ', $alphabetical_order);
     $this->admin_select('category', $category_option, 'Category: ', $category);
 }
Example #11
0
 /**
  * View group detail
  * @param $groupId
  */
 public function actionDetail($groupId)
 {
     $group = Group::get($groupId);
     RAssert::not_null($group);
     $group->category = Category::get($group->categoryId);
     $group->groupCreator = User::get($group->creator);
     $counter = $group->increaseCounter();
     // get latest 20 posts in the group
     $posts = Topic::find("groupId", $groupId)->join("user")->order_desc("createdTime")->range(0, 20);
     $data = ['group' => $group, 'counter' => $counter->totalCount, 'latestPosts' => $posts];
     $isLogin = Rays::isLogin();
     $data['hasJoined'] = $isLogin && GroupUser::isUserInGroup(Rays::user()->id, $group->id);
     $data['isManager'] = $isLogin && $group->creator == Rays::user()->id;
     $this->setHeaderTitle($group->name);
     $this->addCss("/public/css/post.css");
     $this->render('detail', $data, false);
 }
Example #12
0
 /**
  * Category administration
  */
 public function actionAdmin()
 {
     $data = array();
     if (Rays::isPost()) {
         if (isset($_POST['sub_items'])) {
             $items = $_POST['sub_items'];
             if (is_array($items)) {
                 foreach ($items as $item) {
                     if (!is_numeric($item)) {
                         return;
                     } else {
                         $cat = Category::get($item);
                         if ($cat->pid == 0) {
                             continue;
                         }
                         $cat->delete();
                     }
                 }
             }
         }
         if (isset($_POST['cat-name']) && isset($_POST['parent-id'])) {
             $name = trim($_POST['cat-name']);
             $pid = $_POST['parent-id'];
             if (is_numeric($pid)) {
                 if ($name == '') {
                     $this->flash('error', 'Category name cannot be blank.');
                 } else {
                     $result = Category::get($pid);
                     if ($result != null) {
                         $newCat = new Category();
                         $newCat->name = RHtml::encode(trim($name));
                         $newCat->pid = $pid;
                         $newCat->save();
                         $this->flash('message', 'Category ' . $name . " was created successfully.");
                     } else {
                         $this->flash('error', 'Parent category not exists.');
                     }
                 }
             }
         }
     }
     $data['categories'] = Category::find()->all();
     $this->layout = 'admin';
     $this->setHeaderTitle('Category administration');
     $this->render('admin', $data, false);
 }
 public function generate_admin()
 {
     $post_count = $this->block->data('post_count');
     $alphabetical_order = $this->block->data('alphabetical_order');
     $category = $this->block->data('category');
     $count = array("1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "all" => "All");
     $option = array("az" => "Alphabetical from A to Z", "za" => "Alphabetical from Z to A", "latest" => "Latest posts", "oldest" => "Oldest posts", "updated" => "Updated posts", "most_visited" => "Most visited", "less_visited" => "Less visited");
     $category_option = array("all" => "All");
     $categores = new Category();
     $all_category = $categores->get();
     foreach ($all_category->all as $key => $value) {
         $category_option[$value->id] = $value->name;
     }
     $this->admin_select('post_count', $count, 'Post Count: ', $post_count);
     $this->admin_select('alphabetical_order', $option, 'Posts order: ', $alphabetical_order);
     $this->admin_select('category', $category_option, 'Category: ', $category);
 }
Example #14
0
 public static function register()
 {
     // register home page
     Registry::set('home_page', Page::home());
     // register posts page
     Registry::set('posts_page', Page::posts());
     if (!is_admin()) {
         // register categories
         foreach (Category::get() as $itm) {
             $categories[$itm->id] = $itm;
         }
         Registry::set('all_categories', $categories);
         // register menu items
         $pages = Page::where('status', '=', 'published')->where('show_in_menu', '=', '1')->sort('menu_order')->get();
         $pages = new Items($pages);
         Registry::set('menu', $pages);
         Registry::set('total_menu_items', $pages->length());
     }
 }
Example #15
0
 public static function getGroupsOfCategory($categoryId, $start = 0, $limit = 0, $withSubCategory = true)
 {
     $category = Category::get($categoryId);
     if ($category == null) {
         return array();
     }
     $query = Group::find()->order_desc('id');
     if ($withSubCategory) {
         $subs = $category->children();
         $where = "[categoryId] in (?";
         $args = [$categoryId];
         for ($i = 0, $count = count($subs); $i < $count; $i++) {
             $where .= ",?";
             $args[] = $subs[$i]->id;
         }
         $where .= ')';
         $query->where($where, $args);
         unset($subs);
     }
     $groups = $start != 0 || $limit != 0 ? $query->range($start, $limit) : $query->all();
     return $groups;
 }
 public function index($arguments)
 {
     $this->Projects = new ArrayList();
     $slug = $arguments->param('Slug');
     $category = Category::get()->filter(array('Slug' => $slug))->First();
     if ($category) {
         $this->Title = $category->Name;
         $this->CategoryID = $category->ID;
         $projectsOfCategory = $category->ProjectPages()->sort('Sort', 'ASC');
         foreach ($projectsOfCategory as $project) {
             $this->Projects->add($project);
         }
         $otherProjects = DataObject::get('ProjectPage')->sort('Sort', 'ASC')->subtract($projectsOfCategory);
         $this->OtherProjects = new ArrayList();
         foreach ($otherProjects as $otherproject) {
             $otherproject->knockout = 1;
             $this->OtherProjects->add($otherproject);
         }
         return $this->renderWith(array('ProjectsPage', 'Page'));
     } else {
         return $this->httpError(404);
     }
 }
 public function editGarmentCategory()
 {
     $id = Input::get('editGarmentID');
     $garments = Category::find($id);
     $garms = Category::get();
     $isAdded = FALSE;
     $validInput = TRUE;
     $regex = "/^[a-zA-Z\\'\\-]+( [a-zA-Z\\'\\-]+)*\$/";
     $regexDesc = "/^[a-zA-Z0-9\\'\\-\\.\\,]+( [a-zA-Z0-9\\,\\'\\-\\.]+)*\$/";
     if (!trim(Input::get('editGarmentName')) == '' && !trim(Input::get('editGarmentDescription')) == '') {
         $validInput = TRUE;
         if (preg_match($regex, Input::get('editGarmentName')) && preg_match($regexDesc, Input::get('editGarmentDescription'))) {
             $validInput = TRUE;
         } else {
             $validInput = FALSE;
         }
     } else {
         $validInput = FALSE;
     }
     foreach ($garms as $garm) {
         if (!strcasecmp($garm->strGarmentCategoryID, Input::get('editGarmentID')) == 0 && strcasecmp($garm->strGarmentCategoryName, trim(Input::get('editGarmentName'))) == 0) {
             $isAdded = TRUE;
         }
     }
     if ($validInput) {
         if (!$isAdded) {
             $garments->strGarmentCategoryName = Input::get('editGarmentName');
             $garments->strGarmentCategoryDesc = trim(Input::get('editGarmentDescription'));
             $garments->save();
             return Redirect::to('/maintenance/garments?successEdit=true');
         } else {
             return Redirect::to('/maintenance/garments?success=duplicate');
         }
     } else {
         return Redirect::to('/maintenance/garments?input=invalid');
     }
 }
Example #18
0
 public function run()
 {
     $params = $this->getParams();
     $groupId = $params[0];
     if (!is_numeric($groupId)) {
         $this->getController()->page404();
         return;
     }
     if (($group = Group::get($groupId)) !== null) {
         if (Rays::isPost()) {
             // remove members request
             if (isset($_POST['selected_members'])) {
                 $ids = $_POST['selected_members'];
                 if (is_array($ids)) {
                     $flag = true;
                     foreach ($ids as $id) {
                         if (!is_numeric($id) || $id == $group->creator) {
                             $flag = false;
                             break;
                         }
                     }
                     if ($flag) {
                         GroupUser::removeUsers($groupId, $ids);
                     }
                 }
             }
         }
         $group->category = Category::get($group->categoryId);
         $members = Group::getMembers($group->id);
         $this->getController()->setHeaderTitle("Members in " . $group->name);
         $this->getController()->render('members', array('members' => $members, 'manager' => User::get($group->creator), 'group' => $group, 'memberCount' => count($members), 'topicCount' => Group::countTopics($groupId)), false);
     } else {
         $this->getController()->page404();
         return;
     }
 }
 public function getFilterTagsAction()
 {
     $show_view = false;
     $front = Zend_Controller_Front::getInstance();
     if ($front->getRequest()->getParam('controller') == 'category') {
         $cat_id = $front->getRequest()->getParam('cat_id');
         if ($cat_id) {
             $Category = new Category();
             $category = $Category->get($cat_id);
             if (trim($category['children']) == $cat_id) {
                 $ProductTag = new ProductTag();
                 $filter_tags = $ProductTag->get_top_popular($cat_id);
                 if (count($filter_tags) > 0) {
                     $this->view->filter_tags = $filter_tags;
                     $show_view = true;
                 }
             }
         }
     }
     if (!$show_view) {
         $this->_helper->viewRenderer->setNoRender();
         $this->_helper->layout->disableLayout();
     }
 }
 public function getotherAction()
 {
     $max_count = 10;
     $id = $this->_getParam('id');
     $ar_res = array();
     if ($id) {
         $Product = new Product();
         $Category = new Category();
         $product = $Product->get($id);
         $cat_id = $product['categoryId'];
         $category = $Category->get($cat_id);
         $ar_cats = explode(",", $category['children']);
         $toys = $Product->get_analogs($id, 10);
         foreach ($toys as $toy) {
             $ar_res[] = array('id' => $toy['id'], 'name' => iconv('cp1251', 'utf-8', $toy['name']), 'price' => $toy['price'], 'url' => $this->view->url(array("action" => "detail", "controller" => "toy", "toy_id" => $toy['id']), null, true), 'picture' => $toy['picture'], 'i_sort' => $toy['categoryId'] == $cat_id ? 1 : (in_array($toy['categoryId'], $ar_cats) ? 2 : 3));
         }
     }
     usort($ar_res, 'getothercmp');
     $ar_res = array_slice($ar_res, 0, $max_count);
     print_r(json_encode($ar_res));
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
     //return ($ar_res);
 }
Example #21
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use backend\models\category;
/* @var $this yii\web\View */
/* @var $model backend\models\Category */
/* @var $form yii\widgets\ActiveForm */
//fix the issue that it can assign itself as parent
$parentCatalog = ArrayHelper::merge([0 => '根分类'], ArrayHelper::map(Category::get(0, Category::find()->all()), 'id', 'str_label'));
unset($parentCatalog[$model->id]);
?>

<div class="category-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'link')->textInput(['maxlength' => true]);
?>
    <?php 
echo $form->field($model, 'pai')->textInput(['maxlength' => true]);
?>
    <?php 
Example #22
0
 public function searchNewsByApprovation()
 {
     return ($result = parent::get("SELECT * FROM {$this->prefix}news WHERE approvato='0' ORDER BY id DESC")) ? $result : false;
 }
Example #23
0
<div id="navigation">
	 <a href='/'>/</a> &rarr;
<?php 
$path = bu::path();
$prefix = '/';
$last = $path[count($path) - 1];
$last_i = count($path) - 1;
foreach ($path as $k => $v) {
    $category_path = trim($prefix . $v, '/');
    $c = Category::get($category_path);
    if ($k == $last_i) {
        if (preg_match('/^[0-9]+$/', $c->getName())) {
            echo '<b>пример #' . $id . '</b>' . "\n";
        } else {
            echo '<b>' . $c->getName() . '</b>' . "\n";
        }
    } else {
        echo '<a href="' . $prefix . $v . '">' . $c->getName() . '</a> &rarr;' . "\n";
    }
    $prefix = $prefix . $v . '/';
}
?>
</div>
Example #24
0
echo $object->image;
?>
">
            </span>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-4 col-sm-4" for="categoryselection">Category Selection:</label>
				<div class="col-md-8 col-sm-8">								
					<select class="form-control" id="select-required" name="category_id" data-parsley-required="true">
						<option value="">Select Category</option>					 
                        <?php 
$categories = new Category();
?>
						<?php 
foreach ($categories->get() as $category) {
    ?>
							<option value="<?php 
    echo $category->id;
    ?>
" <?php 
    if ($category->id == $object->category_id) {
        echo 'selected';
    }
    ?>
><?php 
    echo $category->name;
    ?>
</option>
                        <?php 
}
Example #25
0
<?php

/* requires
     $categoryid
  */
$subcategory = Category::get($subcategoryid);
$subcategoryname = $subcategoryrow['name'];
$subcategorydesc = $subcategoryrow['description'];
Example #26
0
?>
">
                                      </div>
                                      <?php 
if ($edit) {
    echo '<input type="hidden" class="form-control" name="id" value="' . $editVars->id . '">';
}
?>
                                  </div>

                                  <div class="form-group">
                                      <label class="col-sm-2 col-sm-2 control-label">Select Category</label>
                                      <div class="col-sm-10">
                                          <select class="form-control" name="category">
                                          <?php 
$getAllCategorys = Category::get();
$selected = '';
foreach ($getAllCategorys as $category) {
    if ($edit && $category->id == $editVars->category) {
        $selected = 'selected="selected"';
    } else {
        $selected = '';
    }
    ?>
                                            <option value="<?php 
    echo $category->id;
    ?>
" {{$selected}}><?php 
    echo $category->name;
    ?>
</option>
    $netto = $tmp_priceset[0][2];
}
?>

<div width="100%" align="center">

<?php 
// prepare search/filter params
$search_product = var_get_post("search_product", "");
$search_category = var_get_post("search_category", "");
$item_offset = var_get_post("item_offset", 0);
$item_count = var_get_post("item_count", 40);
if ($search_category != "") {
    require_once "DataBase/Category.php";
    $category = new Category();
    $tmp = $category->get($search_category);
    if (count($tmp) > 0) {
        echo "<small>Kategorie:</small> " . $tmp[0][1] . "";
    }
}
?>

<table border="0" width="80%">
	<tr class="table_header">
		<td>ProduktNr.</td>
		<td>Bezeichnung</td>
		<td>Anmerkung</td>
		<td>Preis</td>
	</tr>
<?php 
$list = $product->getByFilter($search_product, $search_category, $item_offset, $item_count);
 /** 
  *	Ham lay tat ca ban ghi trong bang category	
  *	@return array {name,created,modified}
  */
 public static function getAllItem()
 {
     return Category::get()->toArray();
 }
Example #29
0
 public function clone_task($task_id)
 {
     $result = new stdClass();
     $result->result = FALSE;
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $old_task = new Task();
     $old_task->get_by_id((int) $task_id);
     if ($old_task->exists()) {
         $new_task = $old_task->get_copy();
         if ($new_task->save()) {
             $this->lang->clone_overlays('tasks', $old_task->id, $new_task->id);
             $from = 'private/uploads/task_files/task_' . $old_task->id;
             $continue = TRUE;
             if (file_exists($from)) {
                 $to = 'private/uploads/task_files/task_' . $new_task->id;
                 if (!clone_directory($from, $to)) {
                     unlink_recursive($to, TRUE);
                     $this->db->trans_rollback();
                     $result->message = $this->lang->line('admin_tasks_error_message_files_not_cloned');
                     $continue = FALSE;
                 }
             }
             if ($continue) {
                 $old_categories = new Category();
                 $old_categories->where_related($old_task);
                 $old_categories->get();
                 if ($old_categories->result_count()) {
                     foreach ($old_categories->all as $old_category) {
                         $old_category->save($new_task);
                     }
                 }
                 $old_tests = new Test();
                 $old_tests->where_related($old_task);
                 $old_tests->get();
                 if ($old_tests->result_count()) {
                     foreach ($old_tests->all as $old_test) {
                         $new_test = $old_test->get_copy();
                         if ($new_test->save($new_task)) {
                             $this->lang->clone_overlays('tests', $old_test->id, $new_test->id);
                             $from = 'private/uploads/unit_tests/test_' . $old_test->id;
                             $to = 'private/uploads/unit_tests/test_' . $new_test->id;
                             clone_directory($from, $to);
                         }
                     }
                 }
                 $this->db->trans_commit();
                 $result->result = TRUE;
                 $result->message = $this->lang->line('admin_tasks_success_message_task_cloned');
             }
         } else {
             $this->db->trans_rollback();
             $result->message = $this->lang->line('admin_tasks_error_message_clone_dont_saved');
         }
     } else {
         $this->db->trans_rollback();
         $result->message = $this->lang->line('admin_tasks_error_message_task_not_found');
     }
     $this->output->set_content_type('application/json');
     $this->output->set_output(json_encode($result));
 }
Example #30
0
?>
">Add a category</a></h3>
<?php 
if (isset($_SESSION['formmessage'])) {
    $formmessage = $_SESSION['formmessage'];
    $formmessageclass = $_SESSION['formmessageclass'];
    echo '  <p class="message ' . $formmessageclass . '">' . $formmessage . '</p>';
    include "common/clearsessionmessage.php";
}
$categorycount = count($categories);
if ($categorycount > 0) {
    echo '      <ol class="contentlist">';
    foreach ($categories as $categoryrow) {
        $categoryid = $categoryrow['id'];
        $categoryname = $categoryrow['name'];
        $category = Category::get($categoryid, $userid);
        $entity = $category;
        include "hbardata.php";
        ?>
        <li><?php 
        echo $categoryname;
        ?>
          <ul class="list-inline contentlistactionlinks">
            <li><a href="editcategory?id=<?php 
        echo $categoryid;
        ?>
">Edit</a></li>
<?php 
        if ($subcategorycount == 0 && $itemcount == 0) {
            ?>
            <li>