Skip to content

Commit

Permalink
add city & tags: lib/News/NewsModel.php
Browse files Browse the repository at this point in the history
	fix autocomplete:   page/newsPage.php
	test Utils:   script/testScript.php
	add city_id:   static/js/autocomplete.js
	fix template:   template/newsedit.tpl
	modified:   tmp/classes.cache.php
  • Loading branch information
akalend committed Jan 29, 2011
1 parent 85bcc1b commit c2e2f0d
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 9 deletions.
3 changes: 3 additions & 0 deletions lib/News/NewsModel.php
Expand Up @@ -60,6 +60,9 @@ class NewsModel extends DbModel {
const SQL_UPDATE = "UPDATE news SET
title = '{{s(title)}}',
text = '{{s(text)}}',
city_id = '{{i(city_id)}}',
cityName = '{{s(city)}}',
tags = '{{s(tags)}}',
newsCategory = {{i(newsCategory)}}
WHERE id={{i(id)}}";

Expand Down
8 changes: 7 additions & 1 deletion page/newsPage.php
Expand Up @@ -81,6 +81,7 @@ private function showHot() {
private function edit() {
if ($this->Request->hasVar()) {
$data = $this->Request->getVars();

$is_err = $this->checkFielsd($data);

if(!$is_err) {
Expand All @@ -92,13 +93,18 @@ private function edit() {
} else {
$res = $this->Model->get($this->args['id']);
$res['img'] = ImageInfo::url($res['id'], 'large');
// var_dump($res);

// var_dump($res); 'city_id' => $res['city_id'],
// 'cityName' => $res['search'],
$data = array('isLogining' => $this->isLogining(),
'id' => $res['id'],
'title' => $res['title'],
'text' => $res['text'],
'city_id' => $res['city_id'],
'city' => $res['cityName'],
'haveImage' => $res['haveImage'],
'img' => $res['img'],
'tags' => $res['tags'],
'newsCategory' => $res['newsCategory'],);
}
$this->showPage($data);
Expand Down
6 changes: 5 additions & 1 deletion script/testScript.php
Expand Up @@ -31,7 +31,11 @@ public function __construct(Request $Request=null ) {
*
*/
public function run() {
$this->pagerTest();

$s='песня года';
$res = UtilConverter::transLiteral($s);
echo "$res\n";
//$this->pagerTest();
}

public function run2() {
Expand Down
15 changes: 13 additions & 2 deletions static/js/autocomplete.js
Expand Up @@ -49,6 +49,11 @@ autocomplete.changefeeld = function ( )
autocomplete.draw ();
}

//autocomplete.setData = function (data) {
// $("city_id").attr("value", data);
// $.log(data);
//}

// функция отрисовки результатов
autocomplete.draw = function ( )
{
Expand All @@ -62,7 +67,7 @@ autocomplete.draw = function ( )
block_obj.html ("");
for ( key in autocomplete.items )
{
var item = autocomplete.items[key];
var item = autocomplete.items[key].name;
item = item.replace(autocomplete.last_request, '<span class="highlight">'+autocomplete.last_request+'</span>');

var item_html = '<div id="autocomplite-result-item-'+key+'" class="autocomplite-result-item">';
Expand Down Expand Up @@ -91,10 +96,16 @@ autocomplete.draw = function ( )
// выбираем запись
autocomplete.selectitem = function ( key )
{
$(autocomplete.object).val( $("#autocomplite-result-item-"+key).text() );
$.log( 'key=' + key);
$.log( 'city=' + autocomplete.items[key].name );

$("#city_id").attr("value",autocomplete.items[key].id);

$(autocomplete.object).val( $("#autocomplite-result-item-"+key).text() );
$(autocomplete.object).focus();
clearInterval (autocomplete.objectfocus);
autocomplete.changefeeld ();


}

15 changes: 10 additions & 5 deletions template/newsedit.tpl
Expand Up @@ -19,15 +19,19 @@
</select></div>




регион ....
<input type="text" name="search" id="input-search" style="position: absolute; left: 150px" autocomplete="off"/>
<input type="text" value="{{city}}" name="city" id="input-search" style="position: absolute; left: 150px" autocomplete="off"/>
<ul id="request-log"></ul>

<input type="hidden" title="hidden" name="city_id" id="city_id" value=""/>

{{IF error_text}}<div style="color: red">не пустое</div>{{END}}
<textarea name="text" rows="20" style="width: 600px;">{{text}}</textarea>

<div>
метки : <input type="text" value="{{tags}}" style="width: 400px;" name="tags" autocomplete="off"/>
</div>

<div style="width: 600px;"><input type="submit" value="Save"></div>
</form>
Expand All @@ -54,12 +58,13 @@ autocomplete.sendrequest = function ()
$.post('/cityes', autocomplete.last_request,
function(ob) {
var i;
$.log(ob.cityes);
for( city in ob.cityes) {
//cityes[i] = ob.cityes[i].name;
$.log(ob.cityes[city].name);
cityes[city] = ob.cityes[city].name;
};
cityes[city] = ob.cityes[city];
};
}, 'json');
return cityes;
Expand Down
22 changes: 22 additions & 0 deletions tmp/app.log
Expand Up @@ -86,3 +86,25 @@
'upload' => NULL,
'db' => 0,
)
2011-29-01 02:43:08; ERROR ; array (
'title' => 'новость от матвиенко',
'id' => '8',
'newsCategory' => '2',
'city' => 'Вачи',
'city_id' => '632',
'text' => 'eeeerr
tttyyyuuu
uuuhhhttt',
'SID' => '3eef73ad7ac51e0f9b30c0fd31e5b19f',
)
2011-29-01 02:44:14; ERROR ; array (
'title' => 'новость от матвиенко',
'id' => '8',
'newsCategory' => '2',
'city' => 'Вачи',
'city_id' => '632',
'text' => 'eeeerr
tttyyyuuu
uuuhhhttt',
'SID' => '3eef73ad7ac51e0f9b30c0fd31e5b19f',
)
1 change: 1 addition & 0 deletions tmp/classes.cache.php
Expand Up @@ -22,4 +22,5 @@
'ImageResizer' => 'lib/Image/ImageResizer.php',
'ImageResize' => 'lib/Image/ImageResize.php',
'CaptchaRecaptcha' => 'lib/Captcha/CaptchaRecaptcha.php',
'UtilConverter' => 'lib/Util/UtilConverter.php',
);

0 comments on commit c2e2f0d

Please sign in to comment.