Skip to content

Commit 236b291

Browse files
committed
[TRANSLATE] Tutorial news section
1 parent 9eacac3 commit 236b291

File tree

4 files changed

+93
-89
lines changed

4 files changed

+93
-89
lines changed

source/tutorial/conclusion.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ Kesimpulan
33
##########
44

55
Tutorial ini tidak mencakup semua hal yang Anda harapkan dari *content
6-
management system*, tetapi memperkenalkan Anda ke topik yang lebih penting dari
7-
routing, menulis controller*, dan *model*. Kami berharap tutorial ini memberi
8-
Anda wawasan tentang beberapa pola desain dasar CodeIgniter, yang dapat Anda
9-
perluas.
6+
management system*, tetapi memperkenalkan Anda ke topik yang lebih penting
7+
tentang *routing*, menulis *controller*, dan *model*. Kami berharap tutorial ini
8+
memberi Anda wawasan tentang beberapa pola desain dasar CodeIgniter, yang dapat
9+
Anda perluas.
1010

1111
Sekarang Anda telah menyelesaikan tutorial ini, kami sarankan Anda memeriksa
1212
sisa dokumentasi. CodeIgniter sering dipuji karena sifat dokumentasinya yang

source/tutorial/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ bagaimana aplikasi CodeIgniter dasar dibangun dalam langkah demi langkah.
99
Dalam tutorial ini, Anda akan membuat **aplikasi berita dasar** (*basic news
1010
application*). Anda akan mulai dengan menulis kode yang dapat memuat halaman
1111
statis. Berikutnya, Anda akan membuat bagian berita yang membaca berita dari
12-
database*. Akhirnya, Anda akan menambahkan *form* untuk membuat berita dalam
13-
database*.
12+
*database*. Akhirnya, Anda akan menambahkan *form* untuk membuat berita dalam
13+
*database*.
1414

1515
Tutorial ini akan difokuskan pada:
1616

source/tutorial/news_section.rst

Lines changed: 84 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,44 @@
22
Bagian Berita
33
#############
44

5-
In the last section, we went over some basic concepts of the framework
6-
by writing a class that includes static pages. We cleaned up the URI by
7-
adding custom routing rules. Now it's time to introduce dynamic content
8-
and start using a database.
5+
Pada bagian terakhir, kita mempelajari beberapa konsep dasar dari *framework*
6+
dengan menulis sebuah *class* yang meliputi halaman statis. Kita membersihkan
7+
URI dengan menambahkan *rule* routing kustom. Sekarang saatnya untuk mengenal
8+
konten dinamis dan mulai menggunakan database.
99

10-
Setting up your model
10+
Menyiapkan Model Anda
1111
---------------------
1212

13-
Instead of writing database operations right in the controller, queries
14-
should be placed in a model, so they can easily be reused later. Models
15-
are the place where you retrieve, insert, and update information in your
16-
database or other data stores. They represent your data.
13+
Alih-alih menulis operasi *database* di controller, query seharusnya ditempatkan
14+
dalam model, sehingga mereka dapat dengan mudah digunakan kembali nanti. *Model*
15+
adalah tempat di mana Anda mengambil, menambahkan, dan memperbarui informasi
16+
Anda di *database* atau menyimpan data lainnya. Mereka mewakili data Anda.
1717

18-
Open up the *application/models/* directory and create a new file called
19-
*News_model.php* and add the following code. Make sure you've configured
20-
your database properly as described :doc:`here <../database/configuration>`.
18+
Buka direktori ``application/models/`` dan buat file baru yang bernama
19+
``News_model.php`` dan tambahkan kode berikut. Pastikan Anda sudah
20+
menkonfigurasi *database* Anda dengan benar seperti yang dijelaskan
21+
:doc:`disini <../database/configuration>`.
2122

2223
::
2324

2425
<?php
25-
class News_model extends CI_Model {
26+
class News_model extends CI_Model
27+
{
2628

2729
public function __construct()
2830
{
2931
$this->load->database();
3032
}
3133
}
3234

33-
This code looks similar to the controller code that was used earlier. It
34-
creates a new model by extending ``CI_Model`` and loads the database
35-
library. This will make the database class available through the
36-
``$this->db`` object.
35+
Kode ini terlihat mirip dengan kode controller yang digunakan sebelumnya. Kode
36+
diatas menciptakan model baru dengan memperluas ``CI_Model`` dan memuat
37+
*library database*. Ini akan membuat *class database* yang tersedia melalui
38+
objek ``$this->db``.
3739

38-
Before querying the database, a database schema has to be created.
39-
Connect to your database and run the SQL command below (MySQL).
40-
Also add some seed records.
40+
Sebelum melakukan *query* ke *database*, skema *database* harus dibuat terlebih
41+
dahulu. Hubungkan ke *database* Anda dan jalankan perintah SQL di bawah ini
42+
(MySQL). Yang juga akan menambahkan beberapa *record*.
4143

4244
::
4345

@@ -50,20 +52,19 @@ Also add some seed records.
5052
KEY slug (slug)
5153
);
5254

53-
Now that the database and a model have been set up, you'll need a method
54-
to get all of our posts from our database. To do this, the database
55-
abstraction layer that is included with CodeIgniter
56-
:doc:`Query Builder <../database/query_builder>` — is used. This makes it
57-
possible to write your 'queries' once and make them work on :doc:`all
58-
supported database systems <../general/requirements>`. Add the
59-
following code to your model.
55+
Sekarang *database* dan *model* telah diatur, Anda akan memerlukan *method*
56+
untuk mendapatkan semua *posting* kita dari database. Untuk melakukan hal ini,
57+
*database abstraction layer* yang disertakan dengan CodeIgniter - :doc:`Query
58+
Builder <../database/query_builder>` - digunakan. Hal ini memungkinkan Anda
59+
untuk menulis '*query*' sekali dan membuat mereka bekerja pada :doc:`semua
60+
sistem database didukung <../general/requirements>`. Tambahkan kode berikut
61+
untuk *model* Anda.
6062

6163
::
6264

6365
public function get_news($slug = FALSE)
6466
{
65-
if ($slug === FALSE)
66-
{
67+
if ($slug === FALSE) {
6768
$query = $this->db->get('news');
6869
return $query->result_array();
6970
}
@@ -72,24 +73,26 @@ following code to your model.
7273
return $query->row_array();
7374
}
7475

75-
With this code you can perform two different queries. You can get all
76-
news records, or get a news item by its `slug <#>`_. You might have
77-
noticed that the ``$slug`` variable wasn't sanitized before running the
78-
query; :doc:`Query Builder <../database/query_builder>` does this for you.
76+
Dengan kode ini Anda dapat melakukan dua *query* yang berbeda. Anda bisa
77+
mendapatkan semua *record* berita, atau mendapatkan sebuah berita dengan `slug
78+
<#>`_. Anda mungkin melihat bahwa variabel ``$slug`` tidak dibersihkan sebelum
79+
menjalankan query*. :doc:`Query Builder <../database/query_builder>`
80+
melakukannya untuk anda.
7981

80-
Display the news
81-
----------------
82+
Menampilkan Berita
83+
------------------
8284

83-
Now that the queries are written, the model should be tied to the views
84-
that are going to display the news items to the user. This could be done
85-
in our ``Pages`` controller created earlier, but for the sake of clarity,
86-
a new ``News`` controller is defined. Create the new controller at
87-
*application/controllers/News.php*.
85+
Sekarang *query* sudah ditulis, *model* harus terikat dengan *view*
86+
yang akan menampilkan berita kepada pengguna. Hal ini dapat dilakukan
87+
di *controller* ``Pages`` yang kita buat sebelumnya, tapi demi kejelasan,
88+
*controller* ``News`` baru telah didefinisikan. Buat *controller* baru di
89+
``application/controllers/News.php``.
8890

8991
::
9092

9193
<?php
92-
class News extends CI_Controller {
94+
class News extends CI_Controller
95+
{
9396

9497
public function __construct()
9598
{
@@ -109,21 +112,21 @@ a new ``News`` controller is defined. Create the new controller at
109112
}
110113
}
111114

112-
Looking at the code, you may see some similarity with the files we
113-
created earlier. First, the ``__construct()`` method: it calls the
114-
constructor of its parent class (``CI_Controller``) and loads the model,
115-
so it can be used in all other methods in this controller.
116-
It also loads a collection of :doc:`URL Helper <../helpers/url_helper>`
117-
functions, because we'll use one of them in a view later.
115+
Melihat kode diatas, Anda dapat melihat beberapa kesamaan dengan file yang kita
116+
buat sebelumnya. Pertama, *method* ``__construct()``: itu memanggil konstruktor
117+
*class* induknya (``CI_Controller``) dan memuat *model*, sehingga dapat
118+
digunakan di semua *method* di dalam *controller* ini. Hal ini juga memuat
119+
*collection* dari fungsi :doc:`URL Helper <../helpers/url_helper>`, karena kita
120+
akan menggunakan salah satu dari mereka dalam *view* nanti.
118121

119-
Next, there are two methods to view all news items and one for a specific
120-
news item. You can see that the ``$slug`` variable is passed to the model's
121-
method in the second method. The model is using this slug to identify the
122-
news item to be returned.
122+
Berikutnya, ada dua *method* untuk melihat semua berita dan satu berita untuk
123+
berita tertentu. Anda dapat melihat bahwa variabel ``$slug`` dilewatkan ke
124+
*method* *model* dalam *method* kedua. *Model* ini menggunakan *slug* untuk
125+
mengidentifikasi berita yang dikembalikan.
123126

124-
Now the data is retrieved by the controller through our model, but
125-
nothing is displayed yet. The next thing to do is passing this data to
126-
the views.
127+
Sekarang data tersebut diambil oleh *controller* melalui *model* kami, tapi
128+
belum ada yang ditampilkan. Hal berikutnya yang harus dilakukan adalah
129+
mengoper (*passing*) data ini ke *view*.
127130

128131
::
129132

@@ -137,11 +140,11 @@ the views.
137140
$this->load->view('templates/footer');
138141
}
139142

140-
The code above gets all news records from the model and assigns it to a
141-
variable. The value for the title is also assigned to the ``$data['title']``
142-
element and all data is passed to the views. You now need to create a
143-
view to render the news items. Create *application/views/news/index.php*
144-
and add the next piece of code.
143+
Kode di atas berfungsi untuk mendapat semua *record* berita dari *model* dan
144+
*assign* ke sebuah variabel. Nilai untuk judul juga di-*assign* ke elemen
145+
``$data['title']`` dan semua data akan dioper ke *view*. Anda sekarang perlu
146+
untuk membuat *view* untuk memuat berita. Buat
147+
``application/views/news/index.php`` dan tambahkan potongan kode berikut.
145148

146149
::
147150

@@ -157,16 +160,17 @@ and add the next piece of code.
157160

158161
<?php endforeach; ?>
159162

160-
Here, each news item is looped and displayed to the user. You can see we
161-
wrote our template in PHP mixed with HTML. If you prefer to use a template
162-
language, you can use CodeIgniter's :doc:`Template
163-
Parser <../libraries/parser>` class or a third party parser.
163+
Di sini, setiap item berita diulang dan ditampilkan kepada pengguna. Anda dapat
164+
melihat kita menulis *template* kita di PHP yang dicampur dengan HTML. Jika
165+
Anda memilih untuk menggunakan *template language*, Anda dapat menggunakan
166+
CodeIgniter *class* :doc:`Template Parser <../libraries/parser>` atau
167+
*parser* pihak ketiga.
164168

165-
The news overview page is now done, but a page to display individual
166-
news items is still absent. The model created earlier is made in such
167-
way that it can easily be used for this functionality. You only need to
168-
add some code to the controller and create a new view. Go back to the
169-
``News`` controller and update ``view()`` with the following:
169+
Halaman ikhtisar berita sekarang selesai, tetapi halaman untuk menampilkan
170+
berita individu masih belum. *Model* yang dibuat sebelumnya dibuat sedemikian
171+
rupa agar mudah digunakan untuk fungsi ini. Anda hanya perlu menambahkan
172+
beberapa kode untuk *controller* dan membuat *view* baru. Kembali ke
173+
*controller* ``News`` dan perbaiki *method* ``view()`` seperti berikut:
170174

171175
::
172176

@@ -186,10 +190,10 @@ add some code to the controller and create a new view. Go back to the
186190
$this->load->view('templates/footer');
187191
}
188192

189-
Instead of calling the ``get_news()`` method without a parameter, the
190-
``$slug`` variable is passed, so it will return the specific news item.
191-
The only things left to do is create the corresponding view at
192-
*application/views/news/view.php*. Put the following code in this file.
193+
Alih-alih memanggil *method* ``get_news()`` tanpa parameter, variabel ``$slug``
194+
dioper, sehingga akan mengembalikan *item* berita tertentu. Satu-satunya hal
195+
yang tersisa untuk dilakukan adalah membuat *view* yang sesuai di
196+
``application/views/news/view.php``. Masukan kode berikut dalam file ini.
193197

194198
::
195199

@@ -200,12 +204,12 @@ The only things left to do is create the corresponding view at
200204
Routing
201205
-------
202206

203-
Because of the wildcard routing rule created earlier, you need an extra
204-
route to view the controller that you just made. Modify your routing file
205-
(*application/config/routes.php*) so it looks as follows.
206-
This makes sure the requests reaches the ``News`` controller instead of
207-
going directly to the ``Pages`` controller. The first line routes URI's
208-
with a slug to the ``view()`` method in the ``News`` controller.
207+
Karena *rule routing wildcard* yang kita buat sebelumnya, Anda perlu route*
208+
ekstra untuk melihat *controller* yang baru saja Anda buat. Modifikasi file
209+
*routing* (``application/config/routes.php``) sehingga terlihat sebagai berikut.
210+
Hal ini untuk memastikan permintaan mencapai *controller* ``News`` bukannya
211+
langsung ke *controller* ``Pages``. *Route* URI baris pertama dengan *slug* ke
212+
*method* ``view()`` dalam *controller* ``News``.
209213

210214
::
211215

@@ -214,5 +218,5 @@ with a slug to the ``view()`` method in the ``News`` controller.
214218
$route['(:any)'] = 'pages/view/$1';
215219
$route['default_controller'] = 'pages/view';
216220

217-
Point your browser to your document root, followed by index.php/news and
218-
watch your news page.
221+
Arahkan browser Anda ke *root* dokumen Anda, diikuti dengan ``index.php/news``
222+
dan lihat halaman berita Anda.

source/tutorial/static_pages.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Routing
142142
Anda mengunjungi ``index.php/pages/view/about`` Anda akan melihat halaman
143143
*about*, termasuk *header* dan *footer*.
144144

145-
Menggunakan *rule* routing kustom, Anda memiliki kekuatan untuk
145+
Menggunakan *rule* *routing* kustom, Anda memiliki kekuatan untuk
146146
memetakan setiap URI ke *controller* apapun dan *method*, dan bebas dari
147147
konvensi yang normal:
148148
``http://example.com/[controller-class]/[controller-method]/[arguments]``
@@ -156,14 +156,14 @@ kode lain yang mengatur setiap elemen di *array* ``$route``.
156156
$route['default_controller'] = 'pages/view';
157157
$route['(:any)'] = 'pages/view/$1';
158158

159-
CodeIgniter membaca *rule* routing dari atas ke bawah dan mengarahkan *request*
159+
CodeIgniter membaca *rule* *routing* dari atas ke bawah dan mengarahkan *request*
160160
ke *rule* pertama yang cocok. Setiap *rule* adalah *regular expression* (sisi
161161
kiri) dipetakan ke *controller* dan nama *method* dipisahkan oleh garis miring
162162
(sisi kanan). Ketika permintaan datang, CodeIgniter mencari *rule* yang cocok
163163
pertama kali, dan memanggil *controller* dan *method* yang sesuai, memungkinkan
164164
dengan argumen.
165165

166-
Informasi lebih lanjut tentang routing dapat ditemukan dalam dokumentasi
166+
Informasi lebih lanjut tentang *routing* dapat ditemukan dalam dokumentasi
167167
:doc:`URI Routing <../general/routing>`.
168168

169169
Di sini, aturan kedua dalam *array* ``$routes`` cocok dengan **semua**

0 commit comments

Comments
 (0)