saveGalleryOrder( (int)$article_id, (string)$order ); } public static function image_alt_change( $image_id, $image_alt ) { global $mdb; $result = $mdb -> update( 'pp_articles_images', [ 'alt' => $image_alt ], [ 'id' => $image_id ] ); \S::delete_cache(); return $result; } public static function article_url( $article_id ) { global $mdb; $results = $mdb -> query( "SELECT seo_link FROM pp_articles_langs AS pal, pp_langs AS pl WHERE lang_id = pl.id AND article_id = " . (int)$article_id . " AND seo_link != '' ORDER BY o ASC LIMIT 1" ) -> fetchAll(); if ( !$results[0]['seo_link'] ) { $title = self::article_title( $article_id ); return 'a-' . $article_id . '-' . \S::seo( $title ); } else return $results[0]['seo_link']; } public static function articles_by_date_add( $date_start, $date_end ) { global $mdb; $results = $mdb -> query( 'SELECT ' . 'id ' . 'FROM ' . 'pp_articles ' . 'WHERE ' . 'status = 1 ' . 'AND ' . 'date_add BETWEEN \'' . $date_start . '\' AND \'' . $date_end . '\' ' . 'ORDER BY ' . 'date_add DESC' ) -> fetchAll(); if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row ) $articles[] = \front\factory\Articles::article_details( $row['id'], 'pl' ); return $articles; } public static function article_pages( $article_id ) { global $mdb; $results = $mdb -> query( "SELECT page_id FROM pp_articles_pages WHERE article_id = " . (int)$article_id ) -> fetchAll(); if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row ) { if ( $out == '' ) $out .= ' - '; $out .= \admin\factory\Pages::page_title( $row['page_id'] ); if ( end( $results ) != $row ) $out .= ' / '; } return $out; } public static function article_title( $article_id ) { global $mdb; $results = $mdb -> query( "SELECT title FROM pp_articles_langs AS pal, pp_langs AS pl WHERE lang_id = pl.id AND article_id = " . (int)$article_id . " AND title != '' ORDER BY o ASC LIMIT 1" ) -> fetchAll(); return $results[0]['title']; } /** * @deprecated Logika przeniesiona do Domain\Article\ArticleRepository::archive(). */ public static function articles_set_archive( $article_id ) { global $mdb; $repository = new \Domain\Article\ArticleRepository( $mdb ); return $repository->archive( (int)$article_id ); } public static function file_name_change( $file_id, $file_name ) { global $mdb; $mdb -> update( 'pp_articles_files', [ 'name' => $file_name ], [ 'id' => (int)$file_id ] ); return true; } public static function delete_file( $file_id ) { global $mdb; $mdb -> update( 'pp_articles_files', [ 'to_delete' => 1 ], [ 'id' => (int)$file_id ] ); return true; } public static function delete_img( $image_id ) { global $mdb; $mdb -> update( 'pp_articles_images', [ 'to_delete' => 1 ], [ 'id' => (int)$image_id ] ); return true; } public static function article_details( $article_id ) { global $mdb; $repository = new \Domain\Article\ArticleRepository( $mdb ); return $repository->find( (int)$article_id ); } public static function max_order() { global $mdb; return $mdb -> max( 'pp_articles_pages', 'o' ); } /** * @deprecated Logika przeniesiona do Domain\Article\ArticleRepository::save(). * Ta metoda pozostaje jako fasada dla backward compatibility. */ public static function article_save( $article_id, $title, $main_image, $entry, $text, $table_of_contents, $status, $show_title, $show_table_of_contents, $show_date_add, $date_add, $show_date_modify, $date_modify, $seo_link, $meta_title, $meta_description, $meta_keywords, $layout_id, $pages, $noindex, $repeat_entry, $copy_from, $social_icons, $block_direct_access ) { global $mdb, $user; $repository = new \Domain\Article\ArticleRepository( $mdb ); return $repository->save( (int)$article_id, [ 'title' => $title, 'main_image' => $main_image, 'entry' => $entry, 'text' => $text, 'table_of_contents' => $table_of_contents, 'status' => $status, 'show_title' => $show_title, 'show_table_of_contents' => $show_table_of_contents, 'show_date_add' => $show_date_add, 'date_add' => $date_add, 'show_date_modify' => $show_date_modify, 'date_modify' => $date_modify, 'seo_link' => $seo_link, 'meta_title' => $meta_title, 'meta_description' => $meta_description, 'meta_keywords' => $meta_keywords, 'layout_id' => $layout_id, 'pages' => $pages, 'noindex' => $noindex, 'repeat_entry' => $repeat_entry, 'copy_from' => $copy_from, 'social_icons' => $social_icons, 'block_direct_access' => $block_direct_access, ], (int)$user['id'] ); } public static function delete_nonassigned_files() { global $mdb; $repository = new \Domain\Article\ArticleRepository( $mdb ); $repository->deleteNonassignedFiles(); } public static function delete_nonassigned_images() { global $mdb; $repository = new \Domain\Article\ArticleRepository( $mdb ); $repository->deleteNonassignedImages(); } } ?>