Since: 0.6
Author: Philippe Archambault (philippe.archambault@gmail.com)
Inheritance: extends PluginController
 /**
  *	Handles input, by calling according controller,
  *	an sets view depending on url.
  *	@return void
  */
 public function handleInput()
 {
     //Create database, get content catalog
     $db = new Database();
     $contentDAL = new contentDAL($db);
     $Catalog = new contentCatalog();
     $contentController = new ContentController($contentDAL, $Catalog);
     $contentCatalog = $contentController->getContent();
     //Handle login
     if ($this->navigationView->wantsToLogin()) {
         $login = new LoginController($this->users, $this->navigationView);
         $this->IsLoggedIn = $login->doLogin();
         if ($this->IsLoggedIn) {
             $this->navigationView->redirToAdmin();
         } else {
             $this->view = $login->getOutPut();
         }
     } else {
         if ($this->navigationView->wantsToUpload() && isset($_SESSION['user'])) {
             $this->view = new AdminView();
             $uploadController = new uploadController($this->view, $contentDAL, $this->users);
             $uploadController->doUpload();
         } else {
             if ($this->navigationView->wantsToReg()) {
                 $model = new RegFacade($this->userDAL);
                 $this->view = new RegView($this->navigationView);
                 $regControl = new RegisterController($model, $this->view);
                 $regControl->addUser();
                 $this->view = new RegView($this->navigationView);
             } else {
                 if ($this->navigationView->wantsToViewImage()) {
                     $this->view = new ImageView();
                     $imgController = new ImageController($this->view, $contentCatalog);
                     $imgController->getImage();
                 } else {
                     if ($this->navigationView->wantsToViewContent()) {
                         $commentView = new commentView();
                         $this->view = new ContentView($commentView);
                         $id = $this->view->getID();
                         $commentDAL = new commentDAL($db);
                         $commentController = new CommentController($commentView, $commentDAL);
                         $comments = $commentController->doComment($id);
                         $content = $contentController->getContentByID($id);
                         $this->view->createHTML($content, $comments);
                     } else {
                         $this->view = new galleryView();
                         $galController = new GalleryController($this->view);
                         $galController->doGallery($contentCatalog);
                     }
                 }
             }
         }
     }
 }
<?php 
require_once "../../controller/CommentController.php";
$comment = CommentController::GetCommentByID($_REQUEST["id"]);
?>
<script type="text/javascript">
$(document).ready(function()
{
	$("#form").submit(function()
	{
		// var name = $("#description").attr("value");
		// if(name.length < 10)
		// {
			// alert("Bạn phải mô tả chi tiết sản phẩm lớn hơn 10 kí tự!");
			// return false;
		// }
		// return true;
	});
});

function closePopupEdit() {
  $("#lightbox, #lightbox-panel, #info-panel, #info-addOk, #info-addFail").fadeOut(300);
}
function showMessageOk()
{
	$("#lightbox, #info-addOk").fadeIn(300);
}
function showMessageFail()
{
	$("#lightbox, #info-addFail").fadeIn(300);
}
</script>
 private function add_comment($request)
 {
     $_GET['object_id'] = $request['args']['id'];
     $_POST['comment[text]'] = $request['args']['comment'];
     CommentController::add();
     /*$response = false;
         	if (!empty($request ['args'])) {
         		$object = ProjectTasks::instance()->findByid($request ['args'] ['id']);
         		$comment = new Comment();
         		$comment_data = ($request ['args'] ['comment']);
         		
         		
         		try {
         			$comment->setFromAttributes($comment_data);
     	    		$comment->setRelObjectId($object->getId());
     	    		$comment->setObjectName(substr_utf($comment->getText(), 0, 250));
     
     	    		DB::beginWork();
     	    		$comment->save();
         			
     	    		$comment->addToMembers($object->getMembers());
     	    		$comment->addToSharingTable();
     	    		
     	    		// Subscribe user to object
     	    		if(!$object->isSubscriber(logged_user())) {
     	    			$object->subscribeUser(logged_user());
     	    		}
     	    		if (strlen($comment->getText()) < 100) {
     	    			$comment_head = $comment->getText();
     	    		} else {
     	    			$lastpos = strpos($comment->getText(), " ", 100);
     	    			if ($lastpos === false) $comment_head = $comment->getText();
     	    			else $comment_head = substr($comment->getText(), 0, $lastpos) . "...";
     	    		}
     	    		$comment_head = html_to_text($comment_head);
     	    		DB::commit();
         			$response = true;
         		} catch (Exception $e) {
         				DB::rollback();
         				return false;
         			}
         		}*/
     return $this->response('json', true);
 }
Example #4
0
    UserController::updateUsername($id);
});
$routes->get('/user/:id/password', function ($id) {
    UserController::editPassword($id);
});
$routes->post('/user/:id/password', function ($id) {
    UserController::updatePassword($id);
});
//site
$routes->get('/site/new_site', 'check_logged_in', function () {
    SiteController::new_site();
});
$routes->get('/site/show_site/:id', 'check_logged_in', function ($id) {
    SiteController::show($id);
});
$routes->get('/site/show_site/:id/edit', 'check_logged_in', function ($id) {
    SiteController::edit($id);
});
$routes->post('/site/show_site/:id/edit', 'check_logged_in', function ($id) {
    SiteController::update($id);
});
$routes->post('/site/:id/destroy', 'check_logged_in', function ($id) {
    SiteController::destroy($id);
});
$routes->post('/site', 'check_logged_in', function () {
    SiteController::save();
});
//comment
$routes->post('/comment', 'check_logged_in', function () {
    CommentController::save();
});
        ?>

                                </div>
                            </div>

                            <div class="comment-content"><span class="comment_content"><?php 
        echo $comment['content'];
        ?>
</span></div>
                            <?php 
        if ($comment['level'] < $maxTreeLevel) {
            ?>
                                <div class="comment-reply-field">
                                    <?php 
            Yii::import('application.modules.frontend.controllers.CommentController');
            $commentObj = new CommentController('comment_reply');
            $commentObj->actionReply($comment['id']);
            ?>
                                </div>
                            <?php 
        }
        ?>
                        </div>
                    </div>
                    <?php 
        $children = Comment::model()->getChildren($comment['id'], $maxTreeLevel);
        if (!empty($children)) {
            $this->render('_commentChildren', array('comments' => $children, 't' => $t, 'y' => $y + 1, 'maxTreeLevel' => $maxTreeLevel));
        }
        ?>
                </div>
        </head>
        <body class="body" >
 <?php 
include_once 'header.php';
?>
                <div id="contain" class="contain contain box-transparent">
       	<?php 
if (isset($_REQUEST['productid']) && $_REQUEST['productid'] != null) {
    include_once $contextPath . "controller/ProductController.php";
    include_once $contextPath . "controller/CommentController.php";
    include_once $contextPath . "controller/ProductImageController.php";
    include_once $contextPath . "controller/UserController.php";
    $productid = $_REQUEST['productid'];
    $product_detail = ProductController::GetProductByID($_REQUEST['productid']);
    $productImage = ProductImageController::GetImageOfProductFromProductID($productid);
    $productComment = CommentController::GetCommentFromProductID($productid);
    $_SESSION["addCart"] = "true";
} else {
    Utils::redirect("product-list.php");
}
?>
  
	<?php 
require_once 'left-menu.php';
?>
                  
<div >
	<div class="product-detail-picture">
		<div id="image_wrap" >
			<div href='<?php 
echo $contextPath . $productImage[1];
<?php

include_once "../utils/product_util.php";
include_once "../../../controller/CommentController.php";
include_once "../../../controller/ProductController.php";
include_once "../../../controller/ProductImageController.php";
if (isset($_POST["btnUpdateComment"])) {
    include_once "../../../controller/CommentController.php";
    $id = $_REQUEST["id"];
    $description = $_REQUEST["description"];
    $result = CommentController::Update($id, $description);
    if ($result) {
        header("Location:../comment_index.php?action=view&id=" . $id);
    } else {
        header("Location:../comment_index.php?action=view&id=" . $id);
    }
} else {
    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "delete") {
        include_once "../../../controller/CommentController.php";
        require_once "../utils/product_util.php";
        $id = $_REQUEST["id"];
        $result = CommentController::Delete($id);
        if ($result) {
            echo ProductUtil::createMessageBox("DELETE PRODUCT", "Deletion completed!");
        } else {
            echo ProductUtil::createMessageBox("DELETE PRODUCT", "Deletion does not complete!");
        }
    }
}
Example #8
0
<div class="comment-box-title">
    <?php 
echo Yii::t('comment', 'Reader\'s comments');
?>
</div>
<?php 
Yii::import('application.modules.frontend.controllers.CommentController');
$commentObj = new CommentController('comment_create');
$commentObj->actionCreate();
?>
<div class="my-comments-field">
    <?php 
if (!empty($comments)) {
    $arr = array('created_date' => Yii::t('comment', 'According to created date'), 'famous' => Yii::t('comment', 'According to the famous'));
    ?>
        <div class="According"><?php 
    echo CHtml::dropdownlist('order', $order, $arr);
    ?>
</div><img src="<?php 
    echo Yii::app()->request->baseUrl;
    ?>
/themes/backend/img/loading_balls.gif" id="loading_balls_2" style="display: none; width: 20px; height: 20px; vertical-align: middle" />
        <?php 
}
$this->render('_commentChildren', array('comments' => $comments, 'allComments' => $allComments, 't' => 0, 'y' => 0, 'maxTreeLevel' => $maxTreeLevel, 'pageSize' => $pageSize));
?>
    <div class="comment-Cpagination">
        <?php 
$this->widget('application.components.myComment.MyLinkPager', array('pages' => $pages));
?>
    </div>
			<thead>
				<tr>
					<th width="40px"><a href="#">ID<img src="img/icons/arrow_down_mini.gif" width="16" height="16" align="absmiddle" /></a></th>					
					<th width="10px"><a href="#">Product ID</a></th>
					<th width="10px"><a href="#">User ID</a></th>
					<th width="200px"><a href="#">Detail</a></th>
					<th width="70px"><a href="#">Create Date</a></th>
					<th width="65px"><a href="#">Action</a></th>
					
				</tr>
			</thead>
			<tbody>
				<?php 
require_once "../../controller/CommentController.php";
$comments = CommentController::GetAll($curItem, $maxItems);
$totalItems = CommentController::Count();
if ($totalItems != 0) {
    foreach ($comments as $comment) {
        if ($comment["ID"] != null && $comment["ID"] != "") {
            ?>
						<tr>
						<td class="a-center" width="40px"><?php 
            echo $comment["ID"];
            ?>
</td>
						
						<td width="70px"><?php 
            echo $comment["Product_ID"];
            ?>
</td>
						<td width="70px"><?php 
Example #10
0
    case 'auth.store':
        $controller = new AuthenticationController();
        $controller->store();
        break;
    case 'auth.attempt':
        $controller = new AuthenticationController();
        $controller->attempt();
        break;
    case 'login':
        $controller = new AuthenticationController();
        $controller->login();
        break;
    case 'account.edit':
        $controller = new AccountController();
        $controller->edit();
    case 'upload':
        $controller = new AccountController();
        $controller->upload();
        break;
    case 'logout':
        $controller = new AuthenticationController();
        $controller->logout();
        break;
    case 'comment.create':
        $controller = new CommentController();
        $controller->create();
        break;
    default:
        echo "404";
        break;
}
Example #11
0
$routes->post('/login', function () {
    $params = $_POST;
    $content = UserController::login($params);
    BaseController::set_flash($content);
    Redirect::to("/");
});
$routes->get('/image-:id', function ($id) {
    $content = ImageController::get($id);
    View::make("image.html", $content);
});
$routes->get('/uploadImage', function () {
    View::make('uploadImage.html');
});
$routes->post('/comment', function () {
    $params = $_POST;
    $content = CommentController::add($params);
    BaseController::set_flash($content);
    var_dump($params);
    Redirect::to("/image-" . $params["image"]);
});
$routes->post('/uploadImage', function () use($routes) {
    $params = $_POST;
    $fileparams = $_FILES;
    $content = ImageController::uploadImage($params, $fileparams);
    BaseController::set_flash($content);
    if (!array_key_exists("errors", $content)) {
        Redirect::to("/");
    } else {
        Redirect::to("/uploadImage");
    }
});