Пример #1
0
 function CatalogSaveTagsAction()
 {
     $request = Project::getRequest();
     $catalog_id = (int) $request->getKeyByNumber(0);
     $page_number = (int) $request->getKeyByNumber(1);
     $tag_page_number = (int) $request->getKeyByNumber(2);
     // TODO::sortfield checking
     if (is_array($request->ids) && count($request->ids)) {
         foreach ($request->ids as $tag_id) {
             // TODO:: check for exists
             if (isset($request->tag_name[$tag_id]) && strlen($request->tag_name[$tag_id])) {
                 $tag_model = new BlogTagModel();
                 $tag_model->load($tag_id);
                 $tag_model->name = $request->tag_name[$tag_id];
                 if ($tag_model->id <= 0) {
                     $tag_model->posts_num = 0;
                     $tag_model->sortfield = 0;
                 }
                 if (isset($request->active[$tag_id])) {
                     if ($request->active[$tag_id] == 1) {
                         $tag_model->active = 1;
                     } else {
                         if ($tag_id > 0) {
                             $tag_model->delete($tag_id);
                         }
                         continue;
                     }
                 } else {
                     $tag_model->active = 1;
                 }
                 $tag_model->blog_catalog_id = $catalog_id;
                 $tag_model->save();
             }
         }
     }
     Project::getResponse()->redirect($request->createUrl('BlogAdmin', 'CatalogEdit', array($catalog_id, $page_number, $tag_page_number)));
 }