示例#1
0
文件: DP.php 项目: quocphu/hiragana
 /**
  * Create instant
  * @return DP
  */
 public static function getInstant()
 {
     if (!isset(self::$instance) || is_null(self::$instant)) {
         self::$instant = new DP();
         self::$instant->db = new PDO('mysql:host=' . DBHOST . ';dbname=' . DBNAME . ';charset=utf8', DBUSER, DBPASS);
         self::$instant->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         self::$instant->db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
     }
     return self::$instant;
 }
示例#2
0
    echo DP::pretty($dp->getLiterature(), $internalLink);
    ?>
</span>
        </td>
      </tr>
	  <?php 
}
?>
	  <?php 
if ($dp->getNotes()) {
    ?>
      <tr>
        <th>Notes: </th>
        <td>
          <span class="dp-notes"><?php 
    echo DP::pretty($dp->getNotes(), $internalLink);
    ?>
</span>
        </td>
      </tr>
	  <?php 
}
?>
      <?php 
$relationsOut = $dp->getRelationsOut()->getData();
if (count($relationsOut) > 0) {
    ?>
		<tr>
		  <th>Relations: </th>
		  <td>
		    <ul>
示例#3
0
// Error page
Flight::route('/error', function () {
    $error = [];
    if (isset($_SESSION[ERROR])) {
        $error = $_SESSION[ERROR];
        $_SESSION[ERROR] = null;
    } else {
        $error[] = SYSTEM_ERROR;
    }
    Flight::render('./views/error.php', array('title' => Common::getTitle('Lỗi'), 'error' => $error));
});
// Update like, view, report of pattern
Flight::route('/api/view', function () {
    $type = $_POST['type'];
    $url = $_POST['url'];
    $db = DP::getInstant();
    $patternSrv = new PatternService($db);
    $id = explode('/', $url)[2];
    // 		PLog::log(explode('/', $url));
    // 		return;
    switch ($type) {
        case '0':
            //updateView
            $patternSrv->updateView($id, 1);
            break;
        case '1':
            // report
            $patternSrv->report($id, 1);
            break;
        case '2':
            // view