public static function init() { $app = new \Slim\Slim(); $app->setName(Application::InstanceName()); if (strpos($app->request()->getPath(), Application::BasePath()) === 0) { Doc::createInstance($app); Posts::createInstance($app); $app->run(); exit; } }
/** * Constructor. Returns Reponse object. * * @param array $args (optional) */ public function __construct($args = array()) { foreach ($args as $k => $v) { $this->{$k} = $v; } // turn results into objects if ($this->results) { $docs = array(); $doc_fields = array(); foreach ($this->results as $r) { if (!count($doc_fields)) { foreach ($r as $k => $v) { if (!property_exists($k, 'Doc')) { $doc_fields[] = $k; } } } //diag_dump($r); $d = new Doc($r); foreach ($doc_fields as $field) { $d->set_field($field, $r[$field]); } $docs[] = $d; } $this->results = $docs; } }
/** * Sets top-level bill information. */ public function createDoc() { $this->checkAttr('domdoc'); $this->setBillTitle(); $this->setBillSlug(); $bill = new Doc(); $bill->title = $this->title; $bill->slug = $this->slug; $bill->save(); try { $starter = new DocContent(); $starter->doc_id = $bill->id; $starter->content = $this->getBillMeta('legis-type') . ' ' . $this->getBillMeta('official-title'); $starter->save(); $bill->init_section = $starter->id; $bill->save(); $this->bill = $bill; $rootElement = $this->domdoc->getElementsByTagName($this->rootTag)->item(0); $c = 0; if (!is_object($rootElement)) { throw new Exception("Couldn't retrieve root element"); } foreach ($rootElement->childNodes as $child) { $this->saveChildren($child, $starter->id, $c++); } } catch (Exception $e) { $bill->delete(); $starter->delete(); throw new Exception($e->getMessage()); } return true; }
public function actionViewDocument() { if (isset($_GET['doc_id'])) { $doc_id = StringHelper::filterString($_GET['doc_id']); $detail_doc = Doc::model()->findAll(array("select" => "*", "condition" => "doc_id = :doc_id", "params" => array(':doc_id' => $doc_id))); $spCriteria = new CDbCriteria(); $spCriteria->select = "*"; $spCriteria->condition = "doc_id = :doc_id"; $spCriteria->params = array(':doc_id' => $doc_id); $subject_doc = SubjectDoc::model()->find($spCriteria); $spjCriteria = new CDbCriteria(); $spjCriteria->select = "*"; $spjCriteria->condition = "subject_id = :subject_id"; $spjCriteria->params = array(':subject_id' => $subject_doc->subject_id); $subject = Subject::model()->find($spjCriteria); $related_doc = Doc::model()->findAll(array("select" => "*", "limit" => "3", "order" => "RAND()")); foreach ($detail_doc as $detail) { $title = $detail->doc_name . " | Bluebee - UET"; $this->pageTitle = $title; if ($detail->doc_type == 3) { $image = Yii::app()->getBaseUrl(true) . $detail->doc_url; } else { $image = $detail->doc_url; } $des = $detail->doc_description; Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title')); Yii::app()->clientScript->registerMetaTag($image, null, null, array('property' => 'og:image')); Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:width')); Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:height')); Yii::app()->clientScript->registerMetaTag("website", null, null, array('property' => 'og:type')); Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description')); } $this->render('viewDocument', array('detail_doc' => $detail_doc, 'related_doc' => $related_doc, 'subject' => $subject)); } }
public function postSeen($docId, $commentId) { $allowed = false; $user = Auth::user(); $user->load('docs'); // Check user documents against current document foreach ($user->docs as $doc) { if ($doc->id == $docId) { $allowed = true; break; } } if (!$allowed) { throw new Exception("You are not authorized to mark this annotation as seen."); } $comment = Comment::find($commentId); $comment->seen = 1; $comment->save(); $doc = Doc::find($docId); $vars = array('sponsor' => $user->fname . ' ' . $user->lname, 'label' => 'comment', 'slug' => $doc->slug, 'title' => $doc->title, 'text' => $comment->text); $email = $comment->user->email; Mail::queue('email.read', $vars, function ($message) use($email) { $message->subject('Your feedback on Madison was viewed by a sponsor!'); $message->from('*****@*****.**', 'Madison'); $message->to($email); // Recipient address }); return Response::json($comment); }
public function searchDocument($doc_name) { $docCriteria = new CDbCriteria(); $docCriteria->select = "*"; $docCriteria->addSearchCondition('doc_name', $doc_name); $doc_result = Doc::model()->findAll($docCriteria); return $doc_result; }
public function support() { if (Session::$user) { Render::html(Doc::by_name('support')['content'], ['email' => Session::$user['email']]); } else { Render::php(HTML . 'login.php'); } }
public function actionSubject() { $subject_id = ""; if (isset($_GET["subject_id"])) { $subject_id = StringHelper::filterString($_GET["subject_id"]); } else { if (isset($_GET["subject_code"])) { $subject_code = StringHelper::filterString($_GET["subject_code"]); $subject_by_code = Subject::model()->findByAttributes(array('subject_code' => $subject_code)); $subject_id = $subject_by_code->subject_id; } } $subjectCriteria = new CDbCriteria(); $subjectCriteria->select = "*"; $subjectCriteria->condition = "subject_id = :subject_id"; $subjectCriteria->params = array(":subject_id" => $subject_id); $subject = Subject::model()->findAll($subjectCriteria); $teachers = Teacher::model()->with(array("subject_teacher" => array("select" => false, "condition" => "subject_id = :subject_id", "params" => array(":subject_id" => $subject_id))))->findAll(); // $doc = Doc::model()->with(array("docs" => array( // "select" => "*", // "condition" => "subject_id = :subject_id and active = 1", // "params" => array(":subject_id" => $subject_id) // )))->findAll(array("limit" => "3", "order" => "RAND()")); // // $reference = Doc::model()->with(array("docs" => array( // "select" => "*", // "condition" => "subject_id = :subject_id and active = 0", // "params" => array(":subject_id" => $subject_id) // )))->findAll(array("limit" => "3", "order" => "RAND()")); $lesson = Lesson::model()->findAll(array("select" => "*", "condition" => "lesson_subject = :lesson_subject", "params" => array(":lesson_subject" => $subject_id), "order" => "lesson_weeks ASC")); // $doc_related = Doc::model()->with(array("docs" => array( // "condition" => "subject_id = :subject_id", // "params" => array(":subject_id" => $subject_id) // )))->findAll(); // $sql = "SELECT * FROM tbl_doc JOIN tbl_subject_doc ON tbl_doc.doc_id = tbl_subject_doc.doc_id WHERE tbl_subject_doc.subject_id = " . $subject_id; // $doc_related = Yii::app()->db->createCommand($sql)->query(); $criteria = new CDbCriteria(); $criteria->select = 't.*'; $criteria->join = 'JOIN tbl_subject_doc ON t.doc_id = tbl_subject_doc.doc_id'; $criteria->condition = 'tbl_subject_doc.subject_id = :value'; $criteria->params = array(":value" => $subject_id); $doc_related = Doc::model()->findAll($criteria); // $doc_related = SubjectDoc::model()->findAll(array( // 'select' => '*', // 'condition' => 'subject_id = :subject_id', // 'params' => array(':subject_id' => $subject_id))); foreach ($subject as $subject_detail) { $title = $subject_detail->subject_name . " | Bluebee - UET"; $des = $subject_detail->subject_target; } $this->pageTitle = $title; Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title')); Yii::app()->clientScript->registerMetaTag(Yii::app()->createAbsoluteUrl('listOfSubject/subject?subject_id=') . $subject_id, null, null, array('property' => 'og:url')); Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description')); $category_father = Faculty::model()->findAll(); $subject_type = SubjectType::model()->findAll(); $this->render('subject', array('subject' => $subject, 'category_father' => $category_father, 'subject_type' => $subject_type, 'teacher' => $teachers, 'lesson' => $lesson, 'doc_related' => $doc_related)); }
public function __construct() { $docs = Doc::orderBy('updated_at', 'desc')->take(10)->get(); View::share('docs', $docs); $socials = array('og_image' => Config::get('socials.og_image'), 'og_title' => Config::get('socials.og_title'), 'og_description' => Config::get('socials.og_description'), 'og_url' => Request::url(), 'og_site_name' => Request::root()); View::share('socials', $socials); $params = array('hosts' => array('localhost:9200')); $this->es = new Elasticsearch\Client($params); }
/** * Execute the console command. * * @return mixed */ public function fire() { $doc_id = $this->argument('doc_id'); $filename = $this->argument('filename'); $doc = Doc::where('id', $doc_id)->first(); $this->info("Exporting activity for " . $doc->title); $annotations = Annotation::where('doc_id', $this->argument('doc_id'))->with('user')->with('comments')->get(); $comments = Comment::where('doc_id', $this->argument('doc_id'))->with('user')->get(); $headers = array("Created At", "Link", "Display Name", "Full Name", "Email", "Type", "Quote", "Text"); $toExport = array(); foreach ($annotations as $annotation) { $annotationArray = array(); $annotationArray['date'] = $annotation->created_at; $annotationArray['link'] = URL::to('/') . $annotation->uri . '#annotation_' . $annotation->id; $annotationArray['display_name'] = $annotation->user->fname . " " . substr($annotation->user->lname, 0, 1); $annotationArray['full_name'] = $annotation->user->fname . " " . $annotation->user->lname; $annotationArray['email'] = $annotation->user->email; $annotationArray['type'] = 'Annotation'; $annotationArray['quote'] = $annotation->quote; $annotationArray['text'] = $annotation->text; array_push($toExport, $annotationArray); foreach ($annotation->comments as $comment) { $user = User::find($comment->user_id); $commentArray = array(); $commentArray['date'] = $comment->created_at; $commentArray['link'] = ""; $commentArray['display_name'] = $user->fname . " " . substr($user->lname, 0, 1); $commentArray['full_name'] = $user->fname . " " . $user->lname; $commentArray['email'] = $user->email; $commentArray['type'] = "Annotation Comment"; $commentArray['quote'] = ""; $commentArray['text'] = $comment->text; array_push($toExport, $commentArray); } } foreach ($comments as $comment) { $commentArray = array(); $commentArray['date'] = $comment->created_at; $commentArray['link'] = ""; $commentArray['display_name'] = $comment->user->fname . " " . substr($comment->user->lname, 0, 1); $commentArray['full_name'] = $comment->user->fname . " " . $comment->user->lname; $commentArray['email'] = $comment->user->email; $commentArray['type'] = $comment->parent_id === null ? "Comment" : "Sub-comment"; $commentArray['quote'] = ""; $commentArray['text'] = $comment->text; array_push($toExport, $commentArray); } $this->info('Saving export to ' . $filename); $fp = fopen($filename, 'w'); fputcsv($fp, $headers); foreach ($toExport as $row) { fputcsv($fp, $row); } fclose($fp); $this->info('Done.'); }
public function actionUser() { if (isset($_GET["token"])) { $token = StringHelper::filterString($_GET["token"]); $user_current_token = User::model()->find(array('select' => '*', 'condition' => 'user_token = :user_token', 'params' => array(':user_token' => $token))); $spCriteria = new CDbCriteria(); $spCriteria->select = "*"; $spCriteria->condition = "user_id = '" . $user_current_token->user_id . "'"; $spjCriteria = new CDbCriteria(); $spjCriteria->select = "*"; $spjCriteria->condition = "doc_author = :doc_author"; $spjCriteria->params = array(':doc_author' => $user_current_token->user_id); $spjCriteria->order = 'doc_id DESC'; $count = Doc::model()->count($spjCriteria); $pages = new CPagination($count); $pages->pageSize = 12; $pages->applyLimit($spjCriteria); $user_doc_info = Doc::model()->findAll($spjCriteria); $user_current_id = User::model()->findByAttributes(array('user_id' => $user_current_token->user_id)); $this->pageTitle = $user_current_token->user_real_name . " | Bluebee - UET"; Yii::app()->clientScript->registerMetaTag($user_current_token->user_real_name . " | Bluebee - UET", null, null, array('property' => 'og:title')); Yii::app()->clientScript->registerMetaTag($user_current_token->user_avatar, null, null, array('property' => 'og:image')); if ($user_current_id) { $this->render('user', array('user_detail_info' => User::model()->findAll($spCriteria), 'user_doc_info' => $user_doc_info, 'pages' => $pages, 'doc_count' => $count)); } } if (isset($_GET["id"])) { $id = StringHelper::filterString($_GET["id"]); $spCriteria = new CDbCriteria(); $spCriteria->select = "*"; $spCriteria->condition = "user_id = :id"; $spCriteria->params = array(':id' => $id); $spjCriteria = new CDbCriteria(); $spjCriteria->select = "*"; $spjCriteria->condition = "doc_author = :doc_author"; $spjCriteria->params = array(':doc_author' => $id); $spjCriteria->order = 'doc_id DESC'; $count = Doc::model()->count($spjCriteria); $pages = new CPagination($count); $pages->pageSize = 12; $pages->applyLimit($spjCriteria); $user_doc_info = Doc::model()->findAll($spjCriteria); $user_detail_info = User::model()->findAll($spCriteria); foreach ($user_detail_info as $user) { $this->pageTitle = "Bluebee - UET | " . $user['user_real_name']; Yii::app()->clientScript->registerMetaTag("Bluebee - UET | " . $user['user_real_name'], null, null, array('property' => 'og:title')); Yii::app()->clientScript->registerMetaTag($user['user_avatar'], null, null, array('property' => 'og:image')); } $this->render('user', array('user_detail_info' => $user_detail_info, 'user_doc_info' => $user_doc_info, 'pages' => $pages, 'doc_count' => $count)); } }
public static function page_title() { if (isset(self::$page_title)) { return self::$page_title; } $flat_page_name = self::get_flat_page_name(); $title = isset($flat_pages[$flat_page_name]) ? $flat_pages[$flat_page_name]['title'] : FALSE; if ($title === FALSE) { $route = '/' . Router::$current_route_template; $doc = Doc::by_route($route); if (isset($doc['title'])) { $title = $doc['title']; } } return $title; }
/** * Execute the console command. * * @return mixed */ public function fire() { $docId = $this->argument('docId'); $docs = new Collection(); if (!is_null($docId)) { $doc = Doc::where('id', '=', $docId)->first(); if (!$doc) { return $this->error("Invalid Document ID"); } $docs->add($doc); } else { $rawDocs = DB::select(DB::raw("SELECT *\n\t\t\t\t\t FROM docs\n\t\t\t\t\t WHERE id NOT IN (\n\t\t\t\t\t\tSELECT doc_id \n\t\t\t\t\t\t FROM doc_group\n\t\t\t\t\t UNION ALL\n\t\t\t\t\t\tSELECT doc_id\n\t\t\t\t\t\t FROM doc_user\n\t\t\t\t\t)"), array()); $docs = new Collection(); foreach ($rawDocs as $raw) { $obj = new Doc(); foreach ($raw as $key => $val) { $obj->{$key} = $val; } $docs->add($obj); } } $sponsors = Doc::getAllValidSponsors(); foreach ($docs as $doc) { $this->info("Document Title: {$doc->title}\n"); foreach ($sponsors as $key => $sponsor) { $opt = $key + 1; $this->info("{$opt}) {$sponsor['display_name']}"); } $selected = (int) $this->ask("Please select a sponsor: ") - 1; if (!isset($sponsors[$selected])) { $this->error("Invalid Selection"); continue; } switch ($sponsors[$selected]['sponsor_type']) { case 'individual': $doc->userSponsor()->sync(array($sponsors[$selected]['id'])); $this->info("Assigned Document to Independent Sponsor"); break; case 'group': $doc->groupSponsor()->sync(array($sponsors[$selected]['id'])); $this->info("Assigned Document to Group Sponsor"); break; } } }
public function actionSaveUser() { $this->retVal = new stdClass(); $request = Yii::app()->request; if ($request->isPostRequest && isset($_POST['user_facebook_id'])) { try { $user_id_fb = StringHelper::filterString($request->getPost('user_facebook_id')); $check = User::model()->findByAttributes(array('user_id_fb' => $user_id_fb)); $user_dob = $request->getPost('user_dob'); $user_id = ""; if ($check) { $check->user_avatar = "http://graph.facebook.com/" . $user_id_fb . "/picture?type=large"; $check->user_id_fb = $user_id_fb; $this->retVal->user_data = $check; $this->retVal->message = 'true'; $check->save(FALSE); $user_id = $check->user_id; $this->retVal->user_data = $check; } else { $user = new User(); $user->user_avatar = "http://graph.facebook.com/" . $user_id_fb . "/picture?type=large"; $user->user_dob = $user_dob; $user->user_id_fb = $user_id_fb; if ($user->save(FALSE)) { $this->retVal->user_data = $user; $this->retVal->message = 'true'; $user_id = $user->user_id; } else { $this->retVal->message = 'false'; } } $criteria = new CDbCriteria(); $criteria->select = "*"; $criteria->condition = "doc_author = :doc_author"; $criteria->params = array(':doc_author' => $user_id); $count = Doc::model()->count($criteria); $this->retVal->doc_count = $count; } catch (exception $e) { $this->retVal->message = $e->getMessage(); } echo CJSON::encode($this->retVal); Yii::app()->end(); } }
/** * Method to handle document RSS feeds. * * @param string $slug * * @return view $feed->render() */ public function getFeed($slug) { $doc = Doc::where('slug', $slug)->with('comments', 'annotations', 'userSponsor', 'groupSponsor')->first(); $feed = Feed::make(); $feed->title = $doc->title; $feed->description = "Activity feed for '" . $doc->title . "'"; $feed->link = URL::to('docs/' . $slug); $feed->pubdate = $doc->updated_at; $feed->lang = 'en'; $activities = $doc->comments->merge($doc->annotations); $activities = $activities->sort(function ($a, $b) { return strtotime($a['updated_at']) > strtotime($b['updated_at']) ? -1 : 1; }); foreach ($activities as $activity) { $item = $activity->getFeedItem(); array_push($feed->items, $item); } return $feed->render('atom'); }
public function run() { $adminEmail = Config::get('madison.seeder.admin_email'); $adminPassword = Config::get('madison.seeder.admin_password'); // Login as admin to create docs $credentials = array('email' => $adminEmail, 'password' => $adminPassword); Auth::attempt($credentials); $admin = Auth::user(); $group = Group::where('id', '=', 1)->first(); // Create first doc $docSeedPath = app_path() . '/database/seeds/example.md'; if (file_exists($docSeedPath)) { $content = file_get_contents($docSeedPath); } else { $content = "New Document Content"; } $docOptions = array('title' => 'Example Document', 'content' => $content, 'sponsor' => $group->id, 'sponsorType' => Doc::SPONSOR_TYPE_GROUP); $document = Doc::createEmptyDocument($docOptions); Input::replace($input = ['content' => $content]); App::make('DocumentsController')->saveDocumentEdits($document->id); //Set first doc as featured doc $featuredSetting = new Setting(); $featuredSetting->meta_key = 'featured-doc'; $featuredSetting->meta_value = $document->id; $featuredSetting->save(); // Create second doc $docSeedPath = app_path() . '/database/seeds/example2.md'; if (file_exists($docSeedPath)) { $content = file_get_contents($docSeedPath); } else { $content = "New Document Content"; } $docOptions = array('title' => 'Second Example Document', 'sponsor' => $group->id, 'sponsorType' => Doc::SPONSOR_TYPE_GROUP); $document = Doc::createEmptyDocument($docOptions); DB::table('doc_contents')->insert(array('doc_id' => $document->id, 'content' => $content)); }
include_once 'includes/init.php'; include_once 'includes/classes/Doc.class'; $blid = getValue('blid', '-?[0-9]+', true); $can_delete = false; // until proven otherwise $error = $name = $owner = $type = ''; $event_id = -1; if ($is_admin) { $can_delete = true; } $res = dbi_execute(Doc::getSQLForDocId($blid)); if (!$res) { $error = db_error(); } else { if ($row = dbi_fetch_row($res)) { $doc = new Doc($row); $event_id = $doc->getEventId(); $name = $doc->getName(); $owner = $doc->getLogin(); $type = $doc->getType(); if ($owner == $login || user_is_assistant($login, $owner)) { $can_delete = true; } } else { // document not found $error = str_replace('XXX', $blid, translate('Invalid entry id XXX.')); } dbi_free_result($res); } if (empty($error) && !$can_delete && $event_id > 0) { // See if current user is creator of associated event
public function getAllSponsors() { $results = Doc::getAllValidSponsors(); return Response::json($results); }
public function actionFilterDocumentByTime() { $request = Yii::app()->request; if ($request->isPostRequest && isset($_POST)) { try { $FilerFormData = array('filter_time' => StringHelper::filterString($_POST['filter_time'])); $Criteria = new CDbCriteria(); //represent for query such as conditions, ordering by, limit/offset. $Criteria->select = "*"; $Criteria->order = "doc_id " . $FilerFormData['filter_time']; $result = Doc::model()->findAll($Criteria); $this->retVal = $result; } catch (exception $e) { // $this->retVal->message = $e->getMessage(); } } echo CJSON::encode($this->retVal); Yii::app()->end(); }
<?php return array("fields" => array("lesson_id" => array("label" => "ID"), "lesson_weeks" => array("label" => "Lesson week"), "lesson_subject" => array("label" => "Lesson of Subject", "type" => "_dropdown", "_list" => array("primary" => "subject_id", "displayAttr" => "subject_name", "src" => function () { $rows = Subject::model()->findAll(); return $rows; })), "lesson_doc" => array("label" => "Document of Lesson", "type" => "_dropdown", "_list" => array("primary" => "doc_id", "displayAttr" => "doc_name", "src" => function () { $rows = Doc::model()->findAll(); return $rows; }))), "columns" => array("lesson_id", "lesson_weeks", "lesson_subject", "lesson_doc"), "actions" => array("_view" => true, "_edit" => array("lesson_weeks", "lesson_subject", "lesson_doc"), "_delete" => true, "_new" => array("type" => "popup", "attr" => array("lesson_weeks", "lesson_subject", "lesson_doc")), "_search" => array("lesson_weeks", "lesson_subject", "lesson_doc"), "_search_advanced" => array("lesson_weeks", "lesson_subject", "lesson_doc"), "_customButtons" => array()), "default" => array("orderBy" => "lesson_id", "orderType" => "asc", "page" => 1, "per_page" => 10, "search" => "", "search_advanced" => ""), "tableAlias" => "lesson", "title" => "Lesson Manager", "condition" => false, "limit_values" => array(10, 20, 30, 40), "model" => "Lesson", "primary" => "lesson_id", "itemLabel" => "lesson", "additionalFiles" => array());
|-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ //Route::get('/', function() //{ //return View::make('hello'); //}); Route::get('test', function () { return 'heoolo'; }); Route::get('/doc', function () { $docs = Doc::all(); $list = ['docs' => $docs]; return View::make('article', $list); }); Route::any('foo', function () { return 'Hello World'; }); Route::resource('home', 'HomeController'); Route::resource('login', 'AuthController'); //用户登录验证控制器类 Route::resource('signup', 'RegistController'); //用户注册控制器类 Route::resource('user', 'UserController'); //用户信息访问、修改类RESTful控制器
public function createDocument() { if (!Auth::check()) { return Redirect::to('/')->with('error', 'You must be logged in'); } $input = Input::all(); $rules = array('title' => 'required'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return Redirect::to('documents')->withInput()->withErrors($validator); } try { $docOptions = array('title' => $input['title']); $user = Auth::user(); $activeGroup = Session::get('activeGroupId'); if ($activeGroup > 0) { $group = Group::where('id', '=', $activeGroup)->first(); if (!$group) { return Redirect::to('documents')->withInput()->with('error', 'Invalid Group'); } if (!$group->userHasRole($user, Group::ROLE_EDITOR) && !$group->userHasRole($user, Group::ROLE_OWNER)) { return Redirect::to('documents')->withInput()->with('error', 'You do not have permission to create a document for this group'); } $docOptions['sponsor'] = $activeGroup; $docOptions['sponsorType'] = Doc::SPONSOR_TYPE_GROUP; } else { if (!$user->hasRole(Role::ROLE_INDEPENDENT_SPONSOR)) { return Redirect::to('documents')->withInput()->with('error', 'You do not have permission to create a document as an individual'); } $docOptions['sponsor'] = Auth::user()->id; $docOptions['sponsorType'] = Doc::SPONSOR_TYPE_INDIVIDUAL; } $document = Doc::createEmptyDocument($docOptions); if ($activeGroup > 0) { Event::fire(MadisonEvent::NEW_GROUP_DOCUMENT, array('document' => $document, 'group' => $group)); } return Redirect::to("documents/edit/{$document->id}")->with('success_message', "Document Created Successfully"); } catch (\Exception $e) { return Redirect::to("documents")->withInput()->with('error', "Sorry there was an error processing your request - {$e->getMessage()}"); } }
/** * @name 读取生成日志 * @url http://www.baidu.com */ final function task_log() { if (empty($_POST) || empty($_POST['doc_path'])) { echo json_encode(array('msg' => '参数错误')); die; } require_once BASEPATH . 'libraries/doc/doc.php'; $obj = new Doc(); echo $obj->getTaskLog($_POST['doc_path']); }
public function getFeatured() { $featuredSetting = Setting::where('meta_key', '=', 'featured-doc')->first(); $doc = Doc::with('categories')->with('sponsor')->with('statuses')->with('dates'); if ($featuredSetting) { $featuredId = (int) $featuredSetting->meta_value; $doc = $doc->where('id', $featuredId)->where('private', '!=', '1')->first(); } else { $doc = $doc->orderBy('created_at', 'desc')->where('private', '!=', '1')->first(); $doc->thumbnail = '/img/default/default.jpg'; } $doc->enableCounts(); $return_doc = $doc->toArray(); $return_doc['introtext'] = $doc->introtext()->first()['meta_value']; $return_doc['updated_at'] = date('c', strtotime($return_doc['updated_at'])); $return_doc['created_at'] = date('c', strtotime($return_doc['created_at'])); return Response::json($return_doc); }
<?php require_once "conf/top.php"; include_once "models/class.Cours.php"; include_once "models/class.Doc.php"; include_once "models/class.Year.php"; include_once "models/class.Promo.php"; include_once "models/class.DocShared.php"; $cours = new Cours(); $doc = new Doc(); $docS = new DocShared(); $promo = new Promo(); $semestre = 1; if ($semestre == 1) { if ($level == 1 || $level == 2) { $cours_l = $cours->CoursListProfS1($userid); $doc_l = $docS->allyeardocProfS1($userid); } else { $promo_id = $promo->user_promo_id($userid); $cours_l = $cours->CoursListPS1($promo_id[0]['promo_id']); $doc_l = $docS->allyeardocS1($promo_id[0]['promo_id']); } } else { if ($level == 1 || $level == 2) { $cours_l = $cours->CoursListProfS2($userid); $doc_l = $docS->allyeardocProfS2($userid); } else { $promo_id = $promo->user_promo_id($userid); $cours_l = $cours->CoursListPS2($promo_id[0]['promo_id']); $doc_l = $docS->allyeardocS2($promo_id[0]['promo_id']); }
public function getAllStatuses() { $doc = Doc::with('statuses')->first(); $statuses = $doc->statuses; return Response::json($statuses); }
echo $detail_vid->video_link; ?> "></iframe> </div> </div> <?php } ?> <div class="underline1"></div> </div> <div class="one-third"> <div class="box more-box1"> <h6 style="color: #262626"><strong>TÀI LIỆU</strong></h6> <?php foreach ($doc_lesson as $doc) { $detail_doc = Doc::model()->find(array('select' => "*", 'condition' => "doc_id = :doc_id", 'params' => array(':doc_id' => $doc->doc_id))); ?> <div class="underline3"></div> <div class="block"> <img src="<?php echo $detail_doc->doc_url; ?> " height="70" width="50"/> <a href="<?php echo Yii::app()->createUrl('viewDocument?doc_id= ') . $detail_doc->doc_id; ?> "><i class="icon-arrow-down"></i><?php echo $detail_doc->doc_name; ?> </a> </div>
public static function render_doc_by_name($name, $context = []) { $template = new Template(Doc::by_name($name)['content'], TRUE); return $template->scrape($context)->render($context); }
/** * Method for handling annotation notifications * * @param Annotation $data * @return null */ public function onDocAnnotated($data) { $notices = Notification::getActiveNotifications(MadisonEvent::DOC_ANNOTATED); $notifications = $this->processNotices($notices, MadisonEvent::DOC_ANNOTATED); $doc = Doc::find($data->doc_id); //Load annotation link $data->link = $data->getLink(); $this->doNotificationActions($notifications, array('data' => array('annotation' => $data->toArray(), 'doc' => $doc->toArray()), 'subject' => 'A new annotation on a document!', 'from_email_address' => static::FROM_EMAIL_ADDRESS, 'from_email_name' => static::FROM_EMAIL_NAME)); }
/** * PUT route for saving documents. */ public function putDocs($id = '') { $user = Auth::user(); if (!$user->can('admin_manage_documents')) { return Redirect::to('/dashboard')->with('message', "You do not have permission"); } $content = Input::get('content'); $content_id = Input::get('content_id'); if ($content_id) { try { $doc_content = DocContent::find($content_id); } catch (Exception $e) { return Redirect::to('dashboard/docs/' . $id)->with('error', 'Error saving the document: ' . $e->getMessage()); } } else { $doc_content = new DocContent(); } $doc_content->doc_id = $id; $doc_content->content = $content; $doc_content->save(); Event::fire(MadisonEvent::DOC_EDITED, $doc); $doc = Doc::find($id); $doc->indexContent($doc_content); return Redirect::to('dashboard/docs/' . $id)->with('success_message', 'Document Saved Successfully'); }