コード例 #1
0
ファイル: comments.php プロジェクト: gischen/PHP-CMS
 public function post_edit()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('comments')) {
         return;
     }
     //Flash current values to session
     Input::flash();
     $id = Input::get('editingMode');
     $editComment = Comment::find($id);
     $editComment->name = Input::get('name');
     $editComment->email = Input::get('email');
     $editComment->content = Input::get('content');
     //Add rules here
     $rules = array('name' => 'required', 'email' => 'required', 'content' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     //Validate rules
     if ($validation->fails()) {
         return Redirect::to($_SERVER['PATH_INFO'] . '?id=' . $editComment->id)->with_errors($validation);
     }
     //Update the comment
     $editComment->save();
     return Redirect::to($_SERVER['PATH_INFO'] . '?id=' . $editComment->id)->with('successmessage', 'Comment successfully updated');
 }
コード例 #2
0
ファイル: home.php プロジェクト: gischen/PHP-CMS
 public function get_index()
 {
     $articles = cmsHelper::getAllArticles($message, true);
     //get the article limit size
     $articles = $articles->where('status', '=', 1)->paginate(Setting::find(2)->value);
     $dbquery = $articles;
     $articles = cmsHelper::bakeArticleForViewers($articles->results);
     return View::make('visitor.index', array("articles" => $articles, 'dbquery' => $dbquery));
 }
コード例 #3
0
ファイル: authorArticles.php プロジェクト: gischen/PHP-CMS
 public function get_index($authorname)
 {
     $user = User::where('username', '=', $authorname)->first();
     //get the article limit size
     $articles = Article::where('author_id', '=', $user->id)->paginate(Setting::find(2)->value);
     $dbquery = $articles;
     $articles = cmsHelper::bakeArticleForViewers($articles->results);
     return View::make('visitor.index', array("articles" => $articles, 'dbquery' => $dbquery, 'message' => 'Showing all articles by ' . $user->displayname));
 }
コード例 #4
0
ファイル: articles.php プロジェクト: gischen/PHP-CMS
 public function post_add()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('articles')) {
         return;
     }
     Input::flash();
     $articlecontent = Input::get('ArticleContent');
     $category = Input::get('ArticleCategory');
     $title = Input::get('ArticleTitle');
     $innercat = Input::get('ArticleCategoryInner');
     $saving_id = Input::get('ArticleEditing');
     $articleUrl = Input::get('ArticleTitleUrl');
     $articleStatus = Input::get('StatusSelect');
     $articletype = Input::get('ArticleType');
     $onlySelectTitle = Input::get('OnlyTitleSelect');
     $comments = Input::get('Comments');
     $author = Input::get('Author');
     $addedTags = !isset($_POST['selectorbox']) ? array() : $_POST['selectorbox'];
     //Add rules here
     $rules = array('ArticleTitle' => 'required|max:100', 'ArticleTitleUrl' => 'required', 'ArticleCategory' => 'required', 'ArticleContent' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     //Validate rules
     if (!empty($saving_id) && $validation->fails()) {
         return Redirect::to('/admin/articles/edit?id=' . $saving_id)->with_errors($validation)->with('EditedTags', $addedTags);
     } elseif ($validation->fails()) {
         return Redirect::to('/admin/articles/add')->with_errors($validation)->with('EditedTags', $addedTags);
     }
     if (isset($innercat)) {
         $category = $innercat;
     }
     $temp = !empty($saving_id) ? Article::find($saving_id) : new Article();
     $temp->content = $articlecontent;
     $temp->category_id = $category;
     $temp->title = $title;
     $temp->url = $articleUrl;
     $temp->status = $articleStatus;
     $temp->onlytitle = $onlySelectTitle;
     $temp->articletype = $articletype;
     $temp->author_id = Auth::user()->type == 1 ? $author + 1 : Auth::user()->id;
     $temp->comments = $comments;
     $temp->Tags()->delete();
     echo $temp->save();
     foreach ($addedTags as $tagName) {
         $tagt = Tag::where("tname", "=", $tagName)->first();
         $temp->Tags()->attach($tagt->id);
     }
     Input::flush();
     if (!empty($saving_id)) {
         return Redirect::to('/admin/articles/edit?id=' . $saving_id)->with('EditedTags', $addedTags)->with("successmessage", "Article Edited successfully");
     } else {
         return Redirect::to('/admin/articles/edit?id=' . $temp->id)->with('EditedTags', $addedTags)->with("successmessage", "Article Posted");
     }
 }
コード例 #5
0
ファイル: users.php プロジェクト: gischen/PHP-CMS
 function post_add()
 {
     //Flash current values to session
     Input::flash();
     //Same action is used for editing and adding a new category
     $username = Input::get("userName");
     $password = Input::get("userPassword");
     $saving_id = Input::get('editingMode');
     $tempType = Input::get('type');
     $userDisplayName = Input::get('userDisplayName');
     if (!cmsHelper::isCurrentUserAllowedToPerform('users') && $saving_id != Auth::user()->id) {
         return;
     }
     //Add rules here
     $rules = array('userName' => 'required|max:100', 'userPassword' => 'required', 'userDisplayName' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     //Validate rules
     if ($validation->fails()) {
         return Redirect::to('/admin/users/add')->with_errors($validation);
     }
     $present = User::where('username', '=', $username)->count();
     if (empty($saving_id) && $present > 0) {
         return Redirect::to('/admin/users/add')->with("errormessage", "User with the same 'username' already exists");
     }
     $present = User::where('displayname', '=', $userDisplayName)->count();
     if (empty($saving_id) && $present > 0) {
         return Redirect::to('/admin/users/add')->with("errormessage", "User with the same 'displayname' already exists");
     }
     $temp = !empty($saving_id) ? User::find($saving_id) : new User();
     $temp->username = $username;
     $temp->password = Hash::make($password);
     $temp->displayname = $userDisplayName;
     if (isset($tempType)) {
         $temp->type = $tempType + 2;
     }
     $temp->save();
     Input::flush();
     return Redirect::to('/admin/users/add')->with("successmessage", !empty($saving_id) ? "User Edited successfuly" : "New User Added successfully");
 }
コード例 #6
0
ファイル: settings.php プロジェクト: gischen/PHP-CMS
 public function post_view()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('settings')) {
         return;
     }
     Input::flash();
     //Add rules here
     $rules = array('articlelimit' => 'required', 'articlesize' => 'required', 'commentsize' => 'required', 'convertemotions' => 'required', 'maintenance' => 'required', 'textboxrows' => 'required', 'unregistercomments' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     if ($validation->fails()) {
         return Redirect::to("/admin/settings/view")->with_errors($validation);
     }
     $settings = Setting::all();
     foreach ($settings as $setting) {
         $setting->value = Input::get($setting->keyname);
         $setting->save();
     }
     Input::flush();
     return Redirect::to("/admin/settings/view")->with("successmessage", "Settings updated");
 }
コード例 #7
0
ファイル: tags.php プロジェクト: gischen/PHP-CMS
 function post_add()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('tags')) {
         return;
     }
     //Flash current values to session
     Input::flash();
     //Same action is used for editing and adding a new category
     $tag_title = Input::get("tagName");
     $tag_url = Input::get("tagNameUrl");
     $saving_id = Input::get('editingMode');
     //Add rules here
     $rules = array('tagName' => 'required|max:100', 'tagNameUrl' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     $checkIfTagExists = Tag::where('id', '!=', $saving_id)->where('turl', '=', $tag_url)->count();
     //Check if same tag exists
     if ($checkIfTagExists > 0) {
         return Redirect::to('/admin/tags/add')->with("errormessage", "Tag with the same url already exists");
     }
     //Validate rules
     if ($validation->fails()) {
         return Redirect::to('/admin/tags/add')->with_errors($validation);
     }
     $temp = !empty($saving_id) ? Tag::find($saving_id) : new Tag();
     $temp->turl = $tag_url;
     $temp->tname = $tag_title;
     $temp->save();
     Input::flush();
     if (!empty($saving_id)) {
         return Redirect::to('/admin/tags/edit?id=' . $saving_id)->with('successmessage', "Tag Edited successfully");
     } else {
         return Redirect::to('/admin/tags/add')->with("successmessage", "New Tag Added successfully");
     }
 }
コード例 #8
0
ファイル: cmsHelper.php プロジェクト: gischen/PHP-CMS
 static function getAllArticlesByStatus($status, &$message, $orderby = "id")
 {
     if (Auth::user()->type != 1) {
         $message = 'Showing all ' . cmsHelper::getArticleStatusArray($status) . ' articles by me';
         return Article::where('author_id', '=', Auth::user()->id)->where('status', '=', $status)->order_by($orderby, 'desc');
     }
     $message = 'Showing all ' . cmsHelper::getArticleStatusArray($status);
     return Article::where('status', '=', $status)->order_by($orderby, 'desc');
 }
コード例 #9
0
ファイル: navigation.blade.php プロジェクト: gischen/PHP-CMS
$submenus['Articles'][0] = "View~All Articles";
$submenus['Articles'][1] = "Add~Add/Edit";
$submenus['Articles'][2] = "View~View unpublished Articles~type=unpublished";
//Categories functions
$submenus['Categories'] = array();
$submenus['Categories'][0] = "View~All Categories";
$submenus['Categories'][1] = "Add~Add/Edit";
$submenus['Comments'] = array();
$submenus['Comments'][0] = "View~All Comments";
$submenus['Tags'] = array();
$submenus['Tags'][0] = "View~All Tags";
$submenus['Tags'][1] = "Add~Add/Edit";
$submenus['Settings'] = array();
$submenus['Settings'][0] = "View~Adjust Settings";
$submenus['Users'] = array();
if (cmsHelper::isCurrentUserAllowedToPerform('users')) {
    $submenus['Users'][0] = "View~All Users";
    $submenus['Users'][1] = "Add~Add/Edit User";
}
echo "<ul>";
for ($i = 0; $i < count($mainmenus); $i++) {
    $temp = explode('~', $mainmenus[$i]);
    if ($type === $temp[0] || isset($type_alt) && $type_alt === $temp[0]) {
        echo '<li id="adminmenumainSelected"><a href="/admin/' . strtolower($temp[1]) . '" >' . $temp[0] . '</a></li>';
    } else {
        echo '<li><a href="/admin/' . strtolower($temp[1]) . '" class="adminmenumain">' . $temp[0] . '</a></li>';
    }
}
echo '</ul>';
if (strcmp('dashboard', $type) != 0) {
    echo '<div style="padding:0px;margin-top:10px;border-top: 1px solid #EFEFEF;color: #ccbc8d;display:block"></div><div style="padding:0px;margin-bottom:5px;border-top: 1px solid #D2D2D2;color: #8b6903;display:block"></div><ul>';
コード例 #10
0
ファイル: taglist.blade.php プロジェクト: gischen/PHP-CMS
@layout('visitor.front')

@section('title')
Home
@endsection

@section('content')
    <?php 
$tag = Tag::where('turl', '=', $tagurl)->first();
$articles = $tag->Articles;
$articles = cmsHelper::bakeArticleForViewers($articles);
?>
    <?php 
VisitorLogger::logVisitor($tag->id, 'T');
?>


<?php 
echo View::make('visitor.index', array("articles" => $articles, 'dbquery' => null, 'message' => "Showing all posts tagged with " . $tag->tname));
?>

@endsection
コード例 #11
0
ファイル: add.blade.php プロジェクト: gischen/PHP-CMS
echo Form::select('StatusSelect', cmsHelper::getArticleStatusArray(), Input::old('StatusSelect', $passedArticle->status));
?>
</td>
                                <td><p>Only Title </p></td>
                                <td><?php 
echo Form::select('OnlyTitleSelect', cmsHelper::getDisableEnableArray(), Input::old('OnlyTitleSelect', $passedArticle->onlytitle));
?>
</td>
                                <td><p>Type </p></td>
                                <td><?php 
echo Form::select('ArticleType', cmsHelper::getArticleTypeArray(), Input::old('ArticleType', $passedArticle->articletype));
?>
</td>
                                <td><p>Author </p></td>
                                <td><?php 
echo Form::select('Author', cmsHelper::getAllAuthorsArray(), Input::old('Author', $passedArticle->author_id - 1), Auth::user()->id != 1 ? array("disabled" => "enabled") : array());
?>
</td>
                                <td><p>Comments </p></td>
                                <td><?php 
echo Form::select('Comments', array("No", "Yes"), Input::old('Comments', $passedArticle->comments));
?>
</td>

                                <td><?php 
echo Form::submit('Submit', array('id' => 'adminbutton'));
?>
</td>
                            </tr>
                        </table>
コード例 #12
0
ファイル: add.blade.php プロジェクト: gischen/PHP-CMS
                        <?php 
echo Form::password('userPassword', array('style' => 'width: 400px;margin-left: 0px;'));
?>
                    </td></tr>

                    <tr><td style="width: 900px"><label style="font-weight: bold">Display Name</label>
                        <p id="message">Choose a name for other user's to recognize you</p>
                        <?php 
echo Form::text('userDisplayName', Input::old('userDisplayName', $passedUser->displayname), array('style' => 'width: 400px;margin-left: 0px;'));
?>
                    </td></tr>

                    <tr><td style="width: 900px"><label style="font-weight: bold">User Type</label>
                        <p id="message">Authority of the user</p>
                        <?php 
echo Form::select('type', cmsHelper::getUserTypeArray(), Input::old('type', $passedUser->type - 2), Input::old("editingMode", $passedUser->id) == 1 || Auth::user()->id != 1 ? array("disabled" => "enabled") : array());
?>
                    </td></tr>
<!-- Form output starts     -->



<?php 
echo Form::hidden('editingMode', Input::old("editingMode", $passedUser->id));
?>
                <tr><td colspan="3"> <?php 
echo Form::submit(is_null($passedUser->id) ? "Add" : "Edit", array('id' => 'adminbutton'));
?>
   </td></tr>

<?php 
コード例 #13
-1
ファイル: categoryArticles.php プロジェクト: gischen/PHP-CMS
 public function get_index($categoryParent, $categoryChild = null)
 {
     //Load details of the passed category
     $parentCategoryDetails = Category::where('curl', '=', $categoryParent)->first();
     if ($categoryChild == null) {
         $childCategoryDetails = null;
     } else {
         $childCategoryDetails = Category::where('curl', '=', $categoryChild)->first();
     }
     //Gets all articles in the default Sub Category
     if (is_null($parentCategoryDetails)) {
         return Response::error('404');
     }
     if (is_null($childCategoryDetails)) {
         $allarticles = Category::find($parentCategoryDetails->id)->Article()->where("status", '=', '1')->get();
     } else {
         $allarticles = Category::find($childCategoryDetails->id)->Article()->where("status", '=', '1')->get();
     }
     //Pushes all articles within the Sub category of a parent Category
     if (is_null($childCategoryDetails)) {
         $inner_categories = $parentCategoryDetails->InnerCategory()->get();
         foreach ($inner_categories as $innercat) {
             $allarticlesinner = Category::find($innercat->id)->Article()->get();
             foreach ($allarticlesinner as $innercatarticles) {
                 array_push($allarticles, $innercatarticles);
             }
         }
     }
     //A  sort on articles  using the POSTed ID
     usort($allarticles, 'cmsHelper::sortById');
     $allarticles = cmsHelper::bakeArticleForViewers($allarticles);
     //make and return the view
     return View::make('visitor.categorylist', array('allarticles' => $allarticles, 'parentCategoryDetails' => $parentCategoryDetails, 'childCategoryDetails' => $childCategoryDetails));
 }
コード例 #14
-1
ファイル: categories.php プロジェクト: gischen/PHP-CMS
 public function post_add()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('categories')) {
         return;
     }
     //Flash current values to session
     Input::flash();
     global $category_title;
     //Same action is used for editing and adding a new category
     $category_title = Input::get("categoryName");
     $category_url = Input::get("categoryNameUrl");
     $parnet_id = Input::get("parentId");
     $category_desc = Input::get("description");
     $saving_id = Input::get('editingMode');
     $counter = 0;
     if ($parnet_id == 0) {
         $counter = Category::where('id', '!=', $saving_id)->where('curl', '=', $category_url)->count();
     } else {
         $counter = Category::where('id', '!=', $saving_id)->where('parent_id', '=', $parnet_id)->where('curl', '=', $category_url)->count();
     }
     //Add rules here
     $rules = array('categoryName' => 'required|max:100', 'categoryNameUrl' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     //Validate rules
     if ($counter > 0 || $validation->fails()) {
         if ($counter == 0) {
             return Redirect::to('/admin/categories/add')->with_errors($validation);
         } else {
             return Redirect::to('/admin/categories/add')->with('errormessage', 'Category with the same name already exists (having the same settings)');
         }
     }
     /* //Check if a category with the same name exists (skip current editing category)
        if (Category::where("cname", '=', $category_title)->where("parent_id", '=', $parnet_id)->where("id", '!=', $saving_id)->count() > 0) {
            echo "Category already present";
            die();
        }*/
     //Check if edit/new post action is performed
     $saveCategory = !empty($saving_id) ? Category::find($saving_id) : new Category();
     $saveCategory->cname = $category_title;
     $saveCategory->curl = $category_url;
     $saveCategory->cdescription = $category_desc;
     $saveCategory->parent_id = $parnet_id != 0 ? $parnet_id : null;
     $saveCategory->save();
     Input::flush();
     //Print appropriate message
     if (!empty($saving_id)) {
         return Redirect::to('/admin/categories/edit?id=' . $saving_id)->with('successmessage', 'Category Edited Successfully');
     } else {
         return Redirect::to('/admin/categories/add')->with('successmessage', 'New Category Added Successfully');
     }
 }