PageRenderTime 45ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/music/admin/lyric.php

http://nukeviet-music.googlecode.com/
PHP | 138 lines | 102 code | 26 blank | 10 comment | 12 complexity | d432b587f4b1dc130069c4444745d062 MD5 | raw file
  1. <?php
  2. /**
  3. * @Project NUKEVIET-MUSIC
  4. * @Phan Tan Dung (phantandung92@gmail.com)
  5. * @Copyright (C) 2010 Freeware
  6. * @Createdate 25-12-2010 14:43
  7. */
  8. if( ! defined( 'NV_IS_MUSIC_ADMIN' ) ) die( 'Stop!!!' );
  9. $page_title = $lang_module['sub_lyric'];
  10. // Call jquery datepicker + shadowbox
  11. $my_head .= "<link type=\"text/css\" href=\"" . NV_BASE_SITEURL . "js/ui/jquery.ui.core.css\" rel=\"stylesheet\" />\n";
  12. $my_head .= "<link type=\"text/css\" href=\"" . NV_BASE_SITEURL . "js/ui/jquery.ui.theme.css\" rel=\"stylesheet\" />\n";
  13. $my_head .= "<link type=\"text/css\" href=\"" . NV_BASE_SITEURL . "js/ui/jquery.ui.datepicker.css\" rel=\"stylesheet\" />\n";
  14. $my_head .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/ui/jquery.ui.core.min.js\"></script>\n";
  15. $my_head .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/ui/jquery.ui.datepicker.min.js\"></script>\n";
  16. $my_head .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/language/jquery.ui.datepicker-" . NV_LANG_INTERFACE . ".js\"></script>\n";
  17. $now_page = $nv_Request->get_int( 'now_page', 'get', 0 );
  18. if( $now_page == 0 )
  19. {
  20. $now_page = 1;
  21. $first_page = 0;
  22. }
  23. else
  24. {
  25. $first_page = ( $now_page - 1 ) * 50;
  26. }
  27. $sql = "FROM `" . NV_PREFIXLANG . "_" . $module_data . "_lyric` AS a INNER JOIN `" . NV_PREFIXLANG . "_" . $module_data . "` AS b ON a.songid=b.id WHERE a.id!=0";
  28. $link = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $op;
  29. // Search data
  30. $data_search = array(
  31. "q" => filter_text_input( 'q', 'get', $lang_module['filter_enterkey'], 1, 100 ), //
  32. "from" => filter_text_input( 'from', 'get', '', 1, 100 ), //
  33. "to" => filter_text_input( 'to', 'get', '', 1, 100 ), //
  34. "disabled" => " disabled=\"disabled\"" //
  35. );
  36. // Enable cancel filter data
  37. if( ( $data_search['q'] != $lang_module['filter_enterkey'] and ! empty( $data_search['q'] ) ) or ! empty( $data_search['from'] ) or ! empty( $data_search['to'] ) )
  38. {
  39. $data_search['disabled'] = "";
  40. }
  41. if( ! empty( $data_search['q'] ) and $data_search['q'] != $lang_module['filter_enterkey'] )
  42. {
  43. $link .= "&amp;q=" . $data_search['q'];
  44. $sql .= " AND ( a.body LIKE '%" . $db->dblikeescape( $data_search['q'] ) . "%' OR b.tenthat LIKE '%" . $db->dblikeescape( $data_search['q'] ) . "%' )";
  45. }
  46. if( ! empty( $data_search['from'] ) )
  47. {
  48. unset( $match );
  49. if( preg_match( "/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/", $data_search['from'], $match ) )
  50. {
  51. $from = mktime( 0, 0, 0, $match[2], $match[1], $match[3] );
  52. $sql .= " AND a.dt >= " . $from;
  53. $link .= "&amp;from=" . $data_search['from'];
  54. }
  55. }
  56. if( ! empty( $data_search['to'] ) )
  57. {
  58. unset( $match );
  59. if( preg_match( "/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/", $data_search['to'], $match ) )
  60. {
  61. $to = mktime( 0, 0, 0, $match[2], $match[1], $match[3] );
  62. $sql .= " AND a.dt <= " . $to;
  63. $link .= "&amp;to=" . $data_search['to'];
  64. }
  65. }
  66. $sql .= " ORDER BY a.id DESC";
  67. // Get num row
  68. $sql1 = "SELECT COUNT(*) " . $sql;
  69. $result1 = $db->sql_query( $sql1 );
  70. list( $output ) = $db->sql_fetchrow( $result1 );
  71. $ts = ceil( $output / 50 );
  72. $xtpl = new XTemplate( "lyric.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_name );
  73. $xtpl->assign( 'LANG', $lang_module );
  74. $xtpl->assign( 'URL_DEL_BACK', str_replace( "&amp;", "&", $link ) );
  75. $xtpl->assign( 'URL_ACTIVE_LIST', "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=listactive&where=_lyric" );
  76. $xtpl->assign( 'URL_DEL', "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=delall&where=_lyric" );
  77. $xtpl->assign( 'NV_BASE_ADMINURL', NV_BASE_ADMINURL );
  78. $xtpl->assign( 'NV_NAME_VARIABLE', NV_NAME_VARIABLE );
  79. $xtpl->assign( 'NV_OP_VARIABLE', NV_OP_VARIABLE );
  80. $xtpl->assign( 'MODULE_NAME', $module_name );
  81. $xtpl->assign( 'OP', $op );
  82. $xtpl->assign( 'DATA_SEARCH', $data_search );
  83. $xtpl->assign( 'URL_CANCEL', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op );
  84. $sql = "SELECT a.*, b.tenthat " . $sql . " LIMIT " . $first_page . ", 50";
  85. $result = $db->sql_query( $sql );
  86. $link_del = "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=del";
  87. $link_active = "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=active&where=_lyric&id=";
  88. $link_edit = "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=editlyric";
  89. while( $row = $db->sql_fetchrow( $result ) )
  90. {
  91. $xtpl->assign( 'id', $row['id'] );
  92. $xtpl->assign( 'user', $row['user'] );
  93. $xtpl->assign( 'body', nv_clean60( strip_tags( $row['body'] ), 200 ) );
  94. $xtpl->assign( 'song', $row['tenthat'] );
  95. $class = ( $i % 2 ) ? " class=\"second\"" : "";
  96. $xtpl->assign( 'class', $class );
  97. $xtpl->assign( 'URL_DEL_ONE', $link_del . "&where=_lyric&id=" . $row['id'] );
  98. $xtpl->assign( 'URL_EDIT', $link_edit . "&id=" . $row['id'] );
  99. $str_ac = ( $row['active'] == 1 ) ? $lang_module['active_yes'] : $lang_module['active_no'];
  100. $xtpl->assign( 'active', $str_ac );
  101. $xtpl->assign( 'URL_ACTIVE', $link_active . $row['id'] );
  102. $xtpl->parse( 'main.row' );
  103. }
  104. $xtpl->parse( 'main' );
  105. $contents = $xtpl->text( 'main' );
  106. $contents .= "<div align=\"center\" style=\"width:300px;margin:0px auto 0px auto;\">\n ";
  107. $contents .= new_page_admin( $ts, $now_page, $link );
  108. $contents .= "</div>\n";
  109. include ( NV_ROOTDIR . "/includes/header.php" );
  110. echo nv_admin_theme( $contents );
  111. include ( NV_ROOTDIR . "/includes/footer.php" );
  112. ?>