public function __construct()
 {
     /** @var AuthenticationHandler $auth */
     $auth = Application::getInstance()->authenticationHandler;
     $auth::getInstance();
     $this->addContent('user_data', AuthenticationHandler::$data);
     $m = new ModelCategory();
     $this->addContent('categories', $m->all(Query::condition()->order('name_category', 'ASC')));
 }
Example #2
0
 public function share($pData)
 {
     $pData['added_date_post'] = "NOW()";
     $pData['id_user'] = AuthenticationHandler::$data['id_user'];
     $pData['status_post'] = 1;
     $pData['permalink_post'] = $this->generatePermalink();
     $id_tags = array();
     if (isset($pData['tags_post']) && !empty($pData['tags_post'])) {
         $tags = explode(",", $pData['tags_post']);
         foreach ($tags as &$t) {
             $t = trim($t);
         }
         $m = new ModelCategory();
         $id_tags = $m->prepareCategories($tags);
         unset($pData['tags_post']);
     }
     $this->insert($pData);
     $id = $this->getInsertId();
     foreach ($id_tags as $i) {
         Query::insert(array('id_post' => $id, 'id_category' => $i))->into('post_category')->execute();
     }
     return $pData['permalink_post'];
 }